efficient-easel 24.2.0 → 25.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/README.md +43 -2
  2. package/dist/{CanvasDragLayer-NZpaX6aq.d.ts → CanvasDragLayer-DXeQGrwJ.d.ts} +42 -3
  3. package/dist/canvas/index.d.ts +2 -139
  4. package/dist/canvas/index.js +1 -1
  5. package/dist/chrome/index.js +1 -1
  6. package/dist/{chunk-6NJHYXJM.js → chunk-3XECMGXX.js} +1 -1
  7. package/dist/{chunk-FRAIEWRC.js → chunk-62UGN7VM.js} +1 -1
  8. package/dist/{chunk-HNKB2ZYR.js → chunk-6ATIYLUL.js} +1 -1
  9. package/dist/{chunk-Y53EKN35.js → chunk-6EDVZBUO.js} +1 -1
  10. package/dist/{chunk-JMAOCKB2.js → chunk-6WTWYHC2.js} +3 -3
  11. package/dist/chunk-7UFKEX72.js +1 -0
  12. package/dist/chunk-BBD3FLU3.js +16 -0
  13. package/dist/chunk-CEC5XLN4.js +1 -0
  14. package/dist/chunk-CWELHADJ.js +1 -0
  15. package/dist/chunk-DX3VILZ3.js +6 -0
  16. package/dist/chunk-ERB6FAZT.js +2 -0
  17. package/dist/{chunk-TGZCD6IP.js → chunk-EUFDQ4KL.js} +1 -1
  18. package/dist/chunk-FEP6XMNX.js +1 -0
  19. package/dist/chunk-FR7EEKFF.js +1 -0
  20. package/dist/chunk-GDO4QJ4G.js +1 -0
  21. package/dist/{chunk-GMCZXMOV.js → chunk-GR3XRILS.js} +1 -1
  22. package/dist/chunk-H6BER2EU.js +1 -0
  23. package/dist/{chunk-G67G63O5.js → chunk-ITIVCER6.js} +1 -1
  24. package/dist/chunk-IW5QXREH.js +64 -0
  25. package/dist/chunk-JIP5JNRB.js +1 -0
  26. package/dist/chunk-JQQFB7EZ.js +1 -0
  27. package/dist/{chunk-AGWKB77Q.js → chunk-K53PQAMP.js} +1 -1
  28. package/dist/{chunk-4ESG53BH.js → chunk-KF3LT7J2.js} +1 -1
  29. package/dist/{chunk-CLOS6SSX.js → chunk-KO47WAWR.js} +1 -1
  30. package/dist/chunk-KVIEUWTX.js +11 -0
  31. package/dist/{chunk-QORC32JO.js → chunk-LUHGBFOD.js} +3 -3
  32. package/dist/{chunk-DDH2DYQP.js → chunk-LUOY3A3Q.js} +1 -1
  33. package/dist/chunk-MIX7EGRG.js +2 -0
  34. package/dist/{chunk-2FYFAAAK.js → chunk-OXOUGEAT.js} +1 -1
  35. package/dist/chunk-PMRN5Z3T.js +1 -0
  36. package/dist/{chunk-55KKGABA.js → chunk-PVBDKBJB.js} +1 -1
  37. package/dist/{chunk-RPMSET77.js → chunk-QTHQPJWA.js} +1 -1
  38. package/dist/{chunk-ISS72IKO.js → chunk-QZJKWKGH.js} +1 -1
  39. package/dist/{chunk-IYHO4XQX.js → chunk-S6YOIRXQ.js} +1 -1
  40. package/dist/{chunk-5PXVT7JY.js → chunk-SBVIW3KJ.js} +1 -1
  41. package/dist/chunk-SC6E3UUS.js +13 -0
  42. package/dist/{chunk-LN43DP2A.js → chunk-SQTVXE5D.js} +13 -13
  43. package/dist/chunk-TOKMFZPB.js +1 -0
  44. package/dist/chunk-U3LTJSBU.js +20 -0
  45. package/dist/{chunk-75C6WFNF.js → chunk-UCZQWQNS.js} +1 -1
  46. package/dist/chunk-UDWXBS46.js +1 -0
  47. package/dist/{chunk-WYTPBF3Q.js → chunk-VBEVZZTV.js} +11 -11
  48. package/dist/{chunk-OITNWE52.js → chunk-XLC7HWW3.js} +1 -1
  49. package/dist/chunk-XTDOSL2M.js +8 -0
  50. package/dist/chunk-YYD257TD.js +1 -0
  51. package/dist/copy/index.js +13 -13
  52. package/dist/copy-place-CQIemdtU.d.ts +25 -0
  53. package/dist/data/index.d.ts +4 -1
  54. package/dist/data/index.js +1 -1
  55. package/dist/dom-BpxMcHFP.d.ts +200 -0
  56. package/dist/drag/index.d.ts +2 -3
  57. package/dist/drag/index.js +1 -1
  58. package/dist/draw/index.d.ts +1 -1
  59. package/dist/draw/index.js +1 -1
  60. package/dist/easel/index.d.ts +67 -1
  61. package/dist/easel/index.js +1 -1
  62. package/dist/edit-lock/index.d.ts +0 -46
  63. package/dist/edit-lock/index.js +1 -1
  64. package/dist/fields/fields.css +6 -40
  65. package/dist/fields/index.d.ts +1 -6
  66. package/dist/fields/index.js +1 -1
  67. package/dist/node-ops/index.js +1 -1
  68. package/dist/page-copy/index.d.ts +110 -0
  69. package/dist/page-copy/index.js +5 -0
  70. package/dist/panel/index.d.ts +29 -34
  71. package/dist/panel/index.js +1 -1
  72. package/dist/panel/panel.css +0 -78
  73. package/dist/screen/components/AddBlockRow.js +1 -1
  74. package/dist/screen/components/AddSidePanel.d.ts +37 -57
  75. package/dist/screen/components/AddSidePanel.js +1 -1
  76. package/dist/screen/components/NodeContextMenu.d.ts +19 -11
  77. package/dist/screen/components/NodeContextMenu.js +1 -1
  78. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  79. package/dist/screen/components/SaveControls.d.ts +10 -11
  80. package/dist/screen/components/SaveControls.js +1 -1
  81. package/dist/screen/components/ScreenChrome.js +1 -1
  82. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  83. package/dist/screen/components/ScreenMount.d.ts +5 -6
  84. package/dist/screen/components/ScreenMount.js +1 -1
  85. package/dist/screen/components/ScreenStoreProvider.d.ts +8 -9
  86. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  87. package/dist/screen/components/SectionScreenShell.js +17 -17
  88. package/dist/screen/components/SidePanelHead.js +1 -1
  89. package/dist/screen/components/panel-widths.js +1 -1
  90. package/dist/screen/components/usePartBridge.d.ts +10 -11
  91. package/dist/screen/components/usePartBridge.js +1 -1
  92. package/dist/screen/index.d.ts +9 -10
  93. package/dist/screen/index.js +1 -1
  94. package/dist/screen/lib/document/block-set-host.d.ts +55 -0
  95. package/dist/screen/lib/document/block-set-host.js +1 -0
  96. package/dist/screen/lib/document/block-types-in.js +1 -1
  97. package/dist/screen/lib/document/box-fields.d.ts +160 -5
  98. package/dist/screen/lib/document/box-fields.js +1 -9
  99. package/dist/screen/lib/document/device-fields.js +1 -1
  100. package/dist/screen/lib/document/palette-sections.d.ts +33 -97
  101. package/dist/screen/lib/document/palette-sections.js +1 -1
  102. package/dist/screen/lib/document/preview-dom.js +1 -1
  103. package/dist/screen/lib/document/section-doc.js +1 -1
  104. package/dist/screen/lib/document/style-clipboard.d.ts +10 -11
  105. package/dist/screen/lib/document/style-clipboard.js +1 -1
  106. package/dist/screen/lib/document/use-section-ops.js +1 -1
  107. package/dist/screen/lib/document-switch.js +1 -1
  108. package/dist/screen/lib/failure.js +1 -1
  109. package/dist/screen/lib/host-inbound.js +1 -1
  110. package/dist/screen/lib/key-scope.js +1 -1
  111. package/dist/screen/lib/media-picker.js +1 -1
  112. package/dist/screen/lib/page-lock.js +1 -1
  113. package/dist/screen/lib/screen-parts.d.ts +251 -12
  114. package/dist/screen/lib/screen-parts.js +1 -1
  115. package/dist/screen/screen.css +6 -0
  116. package/dist/screen/words.d.ts +9 -0
  117. package/dist/screen/words.js +1 -1
  118. package/dist/strings/index.d.ts +4 -1
  119. package/dist/strings/index.js +2 -2
  120. package/dist/style-clipboard/index.d.ts +0 -32
  121. package/dist/style-clipboard/index.js +1 -1
  122. package/dist/text-styles/index.d.ts +7 -6
  123. package/dist/text-styles/index.js +37 -36
  124. package/dist/text-styles/text-styles.css +5 -53
  125. package/dist/tree/index.d.ts +2 -2
  126. package/dist/{types-DBy3L69b.d.ts → types-CoUTWUwB.d.ts} +1 -1
  127. package/dist/words-Dl8Qja4K.d.ts +32 -0
  128. package/package.json +15 -3
  129. package/dist/chunk-3FIS2FRS.js +0 -1
  130. package/dist/chunk-7RSE6KKY.js +0 -1
  131. package/dist/chunk-CMPFUJ26.js +0 -8
  132. package/dist/chunk-CZAAGBVL.js +0 -7
  133. package/dist/chunk-DSKNJXB4.js +0 -1
  134. package/dist/chunk-FJTCSQWK.js +0 -16
  135. package/dist/chunk-G7ISR6DI.js +0 -1
  136. package/dist/chunk-H4Z2V56N.js +0 -21
  137. package/dist/chunk-K7MMLCTT.js +0 -2
  138. package/dist/chunk-KRL3IUV3.js +0 -1
  139. package/dist/chunk-LF3FUSCQ.js +0 -1
  140. package/dist/chunk-THWO5YVZ.js +0 -1
  141. package/dist/chunk-TOHOGVAE.js +0 -15
  142. package/dist/chunk-UKPZ2YWE.js +0 -64
  143. package/dist/chunk-V7U33NF2.js +0 -1
  144. package/dist/chunk-VKPOH6MK.js +0 -1
  145. package/dist/chunk-YU3WHLGI.js +0 -1
  146. package/dist/repeat-D65bJS8d.d.ts +0 -49
  147. package/dist/session-EsjORLQ0.d.ts +0 -43
@@ -1,36 +1,37 @@
1
- import{hexReadout as e,ColourWindow as s,typedHex as t}from"../chunk-U6LJ5UKD.js";import{DEFAULT_TEXT_STYLES_WORDS as a}from"../chunk-OGH6CC3E.js";export{DEFAULT_TEXT_STYLES_WORDS}from"../chunk-OGH6CC3E.js";import"../chunk-OFBZOI6W.js";import{FieldSlider as n}from"../chunk-ZEH6QLBH.js";import{TEXT_STYLE_KINDS as l,canAddTextStyle as i,TEXT_STYLE_MAX as r,isDefaultTextStyle as o,CAMPAIGN_TEXT_STYLE_SETTINGS as d,TEXT_STYLE_SETTINGS as c,textStyleRowSize as u,describeTextStyle as m,updateTextStyle as h,textStyleCaseCss as f,TEXT_STYLE_CASES as p,addTextStyle as v,removeTextStyle as y,TEXT_STYLE_RANGES as S}from"../chunk-YHZSBL2N.js";export{CAMPAIGN_TEXT_STYLE_SETTINGS,TEXT_STYLE_CASES,TEXT_STYLE_CASE_CSS,TEXT_STYLE_DEFAULT_COUNT,TEXT_STYLE_KINDS,TEXT_STYLE_MAX,TEXT_STYLE_RANGES,TEXT_STYLE_SETTINGS,addTextStyle,canAddTextStyle,defaultTextStyles,describeTextStyle,isDefaultTextStyle,isTextStyleCase,removeTextStyle,resolveTextStyle,textStyleCaseCss,textStyleCaseOfCss,textStyleRowSize,updateTextStyle,weightWord}from"../chunk-YHZSBL2N.js";import{FieldSelect as g}from"../chunk-KFWNGPW3.js";import"../chunk-JACEEVVF.js";import{useWords as b}from"../chunk-MFIRYGHW.js";import{withTip as k}from"../chunk-P2VEMZH5.js";import{hsvToHex as N,Tooltip as C,ColorSwatch as x,IconButton as T}from"efficient-shell/ui";import{useState as w,useRef as E,useId as z,useEffect as O,Fragment as _}from"react";import{TrashIcon as L,ChevronIcon as A,BoldIcon as j,ItalicIcon as M,CaseLowerIcon as $,CaseCapitalizedIcon as W,CaseUpperIcon as Y,CaseNormalIcon as I}from"efficient-shell/icons/efficient";import{jsxs as D,jsx as X,Fragment as F}from"react/jsx-runtime";var H=`conic-gradient(${[0,60,120,180,240,300,0].map(e=>N({h:e,s:1,v:1})).join(", ")})`;function P({value:t,hex:a,colours:n,label:l,followsWord:i,anyWord:r,onChange:o,readOnly:d=!1}){const[c,u]=w(!1),m=E(null),h=E(null),f=z(),p=void 0!==t&&n.some(e=>e.key===t),v=void 0!==t&&!p;return O(()=>{if(!c)return;const e=m.current?.ownerDocument;if(!e)return;const s=e=>{m.current&&!m.current.contains(e.target)&&u(!1)};return e.addEventListener("click",s,!0),()=>e.removeEventListener("click",s,!0)},[c]),/* @__PURE__ */D("div",{ref:m,className:"es-ts-set","data-ts-setting":"color",children:[
2
- /* @__PURE__ */D("div",{className:"es-ts-top",children:[
3
- /* @__PURE__ */X("span",{className:"es-ts-sub",children:l}),
4
- /* @__PURE__ */X("span",{className:"es-ts-colour-read",children:a?e(a):i})]}),
5
- /* @__PURE__ */D("div",{className:"es-ts-swatches",role:"group","aria-label":l,children:[n.map(s=>/* @__PURE__ */X(C,{content:`${s.name} · ${e(s.value)}`,children:/* @__PURE__ */X(x,{color:s.value,size:"sm",className:"es-ts-swatch","aria-label":s.name,selected:t===s.key,disabled:d,onClick:()=>o(s.key)})},s.key)),
6
- /* @__PURE__ */X(C,{content:r,children:/* @__PURE__ */X(x,{ref:h,color:H,size:"sm",className:"es-ts-swatch es-ts-swatch--any","aria-label":r,selected:v,"aria-expanded":c,"aria-controls":c?f:void 0,disabled:d,onClick:()=>u(e=>!e)})})]}),c?/* @__PURE__ */X(s,{id:f,value:a??"",onChange:e=>o(e),label:l,readOnly:d,onClose:()=>{u(!1),h.current?.focus()}}):null]})}function B({styles:e,onChange:s,fonts:t,colours:n=[],settings:c=d,auto:u=[],fallback:m,sample:h,openId:f,defaultOpenId:p=null,onOpenChange:S,onAdd:g,rowActions:N,onRemove:C,max:x=r,device:T="desktop",readOnly:_=!1}){const A=b("textStyles",a),j=z(),[M,$]=w(p),W=void 0!==f?f:M,Y=e=>{void 0===f&&$(e),S?.(e)},I=E(null),[H,P]=w(null);O(()=>{if(!H||!I.current)return;const e=[...I.current.querySelectorAll(".es-ts-item")].find(e=>e.dataset.tsId===H.id),s=e?e.querySelector(".es-ts-row"):I.current.querySelector(`.es-ts-add[data-ts-kind="${H.kind}"]`);s?.focus(),P(null)},[H]);/* @__PURE__ */
7
- return X("div",{className:"es-ts",ref:I,children:l.map(a=>{const l=e.filter(e=>e.kind===a),r=!i(e,a,x),d=!_&&!r;/* @__PURE__ */
8
- return D(G,{label:A.groups[a],children:[l.map(a=>{const l=N?.(a),i=null!=l&&!1!==l,r=Boolean(C)&&!_&&!o(a);/* @__PURE__ */
9
- return X(R,{style:a,fonts:t,colours:n,settings:c,auto:u,fallback:m,sample:h,device:T,readOnly:_,open:W===a.id,onOpenChange:e=>Y(e?a.id:null),onChange:t=>s(e.map(e=>e.id===t.id?t:e)),actions:r||i?/* @__PURE__ */D(F,{children:[r?k(A.remove,/* @__PURE__ */X("button",{type:"button",className:"es-ts-del","aria-label":A.removeNamed({name:a.name}),onClick:()=>(t=>{if(_||!C)return;const a=y(e,t.id,{name:A.styleName});if(!a)return;const n=e.filter(e=>e.kind===t.kind),l=n[n.indexOf(t)+1];W===t.id&&Y(null),s(a.styles),C(a.removed),P({id:l?.id??null,kind:t.kind})})(a),children:/* @__PURE__ */X(L,{size:14,"aria-hidden":"true"})})):null,i?l:null]}):null},a.id)}),k(!_&&r?A.full({kind:a,max:x}):void 0,/* @__PURE__ */D("button",{type:"button",className:"es-ts-add","data-ts-kind":a,disabled:_,"aria-disabled":!(_||!r)||void 0,"aria-describedby":!_&&r?`${j}-full-${a}`:void 0,onClick:()=>{d&&(t=>{if(_)return;const a=v(e,t,{max:x,name:A.styleName,make:g});a&&s(a.styles)})(a)},children:[
10
- /* @__PURE__ */X("span",{className:"es-ts-add-word",children:A.add[a]}),
11
- /* @__PURE__ */X("span",{className:"es-ts-count",children:A.count({n:l.length,max:x})})]})),_||!r?null:/* @__PURE__ */X("span",{id:`${j}-full-${a}`,className:"es-vh",children:A.full({kind:a,max:x})})]},a)})})}function G({label:e,children:s}){const t=z();/* @__PURE__ */
12
- return D("section",{className:"es-ts-section","aria-labelledby":t,children:[
13
- /* @__PURE__ */X("div",{className:"es-ts-group",id:t,children:e}),s]})}function R({style:e,fonts:s,colours:t=[],settings:n=d,auto:l=[],fallback:i,sample:r,open:o,onOpenChange:f,onChange:p,actions:v,device:y="desktop",readOnly:S=!1}){const g=b("textStyles",a),k=`${z()}-open-${e.id}`,N=new Set(l),C=c.filter(e=>n.includes(e)),x={...i?.(e)??{},...e.values},T="phone"===y,w=T&&void 0!==e.values.sizePhone?{...x,size:e.values.sizePhone}:x,E=s.find(e=>e.value===x.font),O={fontFamily:E?.family,fontSize:`${u(w.size??16)}px`,fontWeight:x.weight,fontStyle:x.italic?"italic":void 0};/* @__PURE__ */
14
- return D(_,{children:[
15
- /* @__PURE__ */D("div",{className:"es-ts-item","data-ts-id":e.id,children:[
16
- /* @__PURE__ */D("button",{type:"button",className:"es-ts-row","aria-expanded":o,"aria-controls":o?k:void 0,onClick:()=>f(!o),children:[
17
- /* @__PURE__ */X("span",{className:"es-ts-chev","aria-hidden":"true",children:/* @__PURE__ */X(A,{size:12})}),
18
- /* @__PURE__ */X("span",{className:"es-ts-name",style:O,children:e.name}),
19
- /* @__PURE__ */X("span",{className:"es-ts-meta",children:m(w,s,g,{autoSize:N.has("size")&&w===x&&void 0===e.values.size})})]}),v?/* @__PURE__ */X("div",{className:"es-ts-actions",children:v}):null]}),o?/* @__PURE__ */X("div",{className:"es-ts-open",id:k,children:/* @__PURE__ */X(V,{style:e,values:x,fonts:s,colours:t,settings:C,autoSet:N,sample:r??g.sample,words:g,phone:T,readOnly:S,set:s=>p(h([e],e.id,s)[0])})}):null]})}var U={none:I,upper:Y,capitalize:W,lower:$};function V({style:e,values:s,fonts:a,colours:l,settings:i,autoSet:r,sample:o,words:d,phone:c,readOnly:u,set:m}){const h=e.values,p=a.find(e=>e.value===s.font),v=function(e,s){return e?s.find(s=>s.key===e)?.value??t(e)??void 0:void 0}(s.color,l),y=e=>"largestSize"===e||r.has(e),g=e=>y(e)?h[e]:s[e],b=g("size"),N=c&&void 0!==h.sizePhone?h.sizePhone:b,C=g("lineSpacing"),x=g("letterSpacing"),w=y("letterCase")?h.letterCase:s.letterCase,E={fontFamily:p?.family,fontSize:void 0===N?void 0:`${N}px`,fontWeight:s.weight,fontStyle:s.italic?"italic":void 0,lineHeight:void 0===C?void 0:String(C/100),letterSpacing:void 0===x?void 0:`${x}px`,color:v,textTransform:f(w)},z=e=>{const t=S[e],a=y(e);/* @__PURE__ */
20
- return X("div",{className:"es-ts-slider","data-ts-setting":e,children:/* @__PURE__ */X(n,{label:d.settings[e],value:h[e],onChange:s=>m({[e]:s}),min:t.min,max:t.max,step:t.step,shiftStep:t.shiftStep,sliderMin:t.sliderMin,sliderMax:t.sliderMax,unit:t.unit||void 0,styleValue:a?void 0:s[e],auto:a?d.auto:void 0,readOnly:u})},e)};/* @__PURE__ */
21
- return D(F,{children:[
22
- /* @__PURE__ */X("div",{className:"es-ts-preview",style:E,"aria-label":d.preview,children:o}),i.map(t=>{switch(t){case"font":/* @__PURE__ */
23
- return X(Z,{value:h.font,fonts:a,words:d,readOnly:u,set:m},t);case"color":/* @__PURE__ */
24
- return X(K,{value:h.color,hex:v,colours:l,words:d,readOnly:u,set:m},t);case"emphasis":{const e=(s.weight??400)>=600,a=!1!==p?.italic;/* @__PURE__ */
25
- return D("div",{className:"es-ts-set","data-ts-setting":t,children:[
26
- /* @__PURE__ */X("span",{className:"es-ts-sub",children:d.settings.emphasis}),
27
- /* @__PURE__ */D("div",{className:"es-ts-icons",children:[k(d.bold,/* @__PURE__ */X(T,{className:"es-ts-icon","aria-label":d.bold,"aria-pressed":e,disabled:u,onClick:()=>m({weight:e?400:700}),children:/* @__PURE__ */X(j,{size:16})})),u||a?k(d.italic,/* @__PURE__ */X(T,{className:"es-ts-icon","aria-label":d.italic,"aria-pressed":Boolean(s.italic),disabled:u,onClick:()=>m({italic:!s.italic||void 0}),children:/* @__PURE__ */X(M,{size:16})})):/* @__PURE__ */X(T,{className:"es-ts-icon","aria-label":d.italic,"aria-pressed":Boolean(s.italic),"aria-disabled":!0,disabledReason:d.italicMissing,children:/* @__PURE__ */X(M,{size:16})})]})]},t)}case"letterCase":/* @__PURE__ */
28
- return X(q,{value:h.letterCase??s.letterCase,auto:y("letterCase"),words:d,readOnly:u,set:m},t);case"largestSize":return"heading"===e.kind?z(t):null;case"size":return c?(()=>{const e=S.size;/* @__PURE__ */
29
- return X("div",{className:"es-ts-slider","data-ts-setting":"size","data-ts-device":"phone",children:/* @__PURE__ */X(n,{label:d.settings.size,value:h.sizePhone,onChange:e=>m({sizePhone:e}),min:e.min,max:e.max,step:e.step,shiftStep:e.shiftStep,sliderMin:e.sliderMin,sliderMax:e.sliderMax,unit:e.unit||void 0,styleValue:b,readOnly:u})},"size")})():z(t);default:return z(t)}})]})}function Z({value:e,fonts:s,words:t,readOnly:a,set:n}){const l=z();/* @__PURE__ */
30
- return D("div",{className:"es-ts-set","data-ts-setting":"font",children:[
31
- /* @__PURE__ */X("span",{className:"es-ts-sub",id:l,children:t.settings.font}),
32
- /* @__PURE__ */X(g,{value:e,options:s.map(e=>({label:e.label,value:e.value})),onChange:e=>n({font:e}),ariaLabelledBy:l,readOnly:a})]})}function K({value:e,hex:s,colours:t,words:a,readOnly:n,set:l}){/* @__PURE__ */
33
- return X(P,{value:e,hex:s,colours:t,label:a.settings.color,followsWord:a.colour.follows,anyWord:a.colour.any,readOnly:n,onChange:e=>l({color:e})})}function q({value:e,auto:s,words:t,readOnly:a,set:n}){const l=s?["auto",...p]:p,i=e??(s?"auto":"none"),r=E([]),o=e=>n({letterCase:"auto"===e?void 0:e});/* @__PURE__ */
34
- return D("div",{className:"es-ts-set","data-ts-setting":"letterCase",children:[
35
- /* @__PURE__ */X("span",{className:"es-ts-sub",children:t.settings.letterCase}),
36
- /* @__PURE__ */X("div",{className:"es-ts-icons",role:"radiogroup","aria-label":t.settings.letterCase,onKeyDown:e=>{const s="ArrowRight"===e.key||"ArrowDown"===e.key?1:"ArrowLeft"===e.key||"ArrowUp"===e.key?-1:0;if(!s||a)return;e.preventDefault();const t=(l.indexOf(i)+s+l.length)%l.length;o(l[t]),r.current[t]?.focus()},children:l.map((e,s)=>{const n=e===i;if("auto"===e)return k(t.case.autoTitle,/* @__PURE__ */X(T,{ref:e=>{r.current[s]=e},role:"radio",pressed:n,className:"es-ts-icon es-ts-icon--word","aria-checked":n,"aria-label":t.case.auto,tabIndex:n?0:-1,disabled:a,onClick:()=>o(e),children:t.case.auto},e));const l=U[e];return k(t.case[e],/* @__PURE__ */X(T,{ref:e=>{r.current[s]=e},role:"radio",pressed:n,className:"es-ts-icon","aria-checked":n,"aria-label":t.case[e],tabIndex:n?0:-1,disabled:a,onClick:()=>o(e),children:/* @__PURE__ */X(l,{size:16})},e))})})]})}export{P as ColourSwatchRow,R as TextStyleItem,G as TextStylesGroup,B as TextStylesList};
1
+ import{hexReadout as e,ColourWindow as s,typedHex as t}from"../chunk-U6LJ5UKD.js";import{DEFAULT_TEXT_STYLES_WORDS as a}from"../chunk-OGH6CC3E.js";export{DEFAULT_TEXT_STYLES_WORDS}from"../chunk-OGH6CC3E.js";import"../chunk-OFBZOI6W.js";import{FieldSlider as l}from"../chunk-ZEH6QLBH.js";import{TEXT_STYLE_KINDS as i,canAddTextStyle as n,TEXT_STYLE_MAX as r,isDefaultTextStyle as o,CAMPAIGN_TEXT_STYLE_SETTINGS as d,TEXT_STYLE_SETTINGS as c,textStyleRowSize as u,describeTextStyle as m,updateTextStyle as h,textStyleCaseCss as p,TEXT_STYLE_CASES as v,addTextStyle as f,removeTextStyle as y,TEXT_STYLE_RANGES as g}from"../chunk-YHZSBL2N.js";export{CAMPAIGN_TEXT_STYLE_SETTINGS,TEXT_STYLE_CASES,TEXT_STYLE_CASE_CSS,TEXT_STYLE_DEFAULT_COUNT,TEXT_STYLE_KINDS,TEXT_STYLE_MAX,TEXT_STYLE_RANGES,TEXT_STYLE_SETTINGS,addTextStyle,canAddTextStyle,defaultTextStyles,describeTextStyle,isDefaultTextStyle,isTextStyleCase,removeTextStyle,resolveTextStyle,textStyleCaseCss,textStyleCaseOfCss,textStyleRowSize,updateTextStyle,weightWord}from"../chunk-YHZSBL2N.js";import{FieldSelect as S}from"../chunk-KFWNGPW3.js";import{SettingsSegmented as b}from"../chunk-DX3VILZ3.js";import"../chunk-JACEEVVF.js";import{useWords as N}from"../chunk-MFIRYGHW.js";import{withTip as C}from"../chunk-P2VEMZH5.js";import{hsvToHex as T,Tooltip as k,ColorSwatch as x,Popover as z,colorSwatchClasses as E,IconButton as w,Button as O}from"efficient-shell/ui";import{useId as _,useState as L,useRef as j,useEffect as A,Fragment as M}from"react";import{TrashIcon as $,ChevronIcon as W,BoldIcon as Y,ItalicIcon as X,CaseLowerIcon as I,CaseCapitalizedIcon as F,CaseUpperIcon as H,CaseNormalIcon as P}from"efficient-shell/icons/efficient";import{jsxs as B,jsx as G,Fragment as D}from"react/jsx-runtime";var R=`conic-gradient(${[0,60,120,180,240,300,0].map(e=>T({h:e,s:1,v:1})).join(", ")})`;function V({value:t,hex:a,colours:l,label:i,followsWord:n,anyWord:r,onChange:o,readOnly:d=!1}){const c=void 0!==t&&l.some(e=>e.key===t),u=void 0!==t&&!c;/* @__PURE__ */
2
+ return B("div",{className:"es-ts-set","data-ts-setting":"color",children:[
3
+ /* @__PURE__ */B("div",{className:"es-ts-top",children:[
4
+ /* @__PURE__ */G("span",{className:"es-ts-sub",children:i}),
5
+ /* @__PURE__ */G("span",{className:"es-ts-colour-read",children:a?e(a):n})]}),
6
+ /* @__PURE__ */B("div",{className:"es-ts-swatches",role:"group","aria-label":i,children:[l.map(s=>/* @__PURE__ */G(k,{content:`${s.name} · ${e(s.value)}`,children:/* @__PURE__ */G(x,{color:s.value,size:"sm",className:"es-ts-swatch","aria-label":s.name,selected:t===s.key,disabled:d,onClick:()=>o(s.key)})},s.key)),
7
+ /* @__PURE__ */G(k,{content:r,children:/* @__PURE__ */G(z,{trigger:/* @__PURE__ */G("span",{"aria-hidden":"true",className:"absolute inset-0",style:{background:R}}),triggerLabel:r,triggerClassName:E({size:"sm",selected:u,className:"es-ts-swatch es-ts-swatch--any"}),"aria-label":i,disabled:d,children:/* @__PURE__ */G(s,{value:a??"",onChange:e=>o(e),label:i,readOnly:d})})})]})]})}function Z({styles:e,onChange:s,fonts:t,colours:l=[],settings:c=d,auto:u=[],fallback:m,sample:h,openId:p,defaultOpenId:v=null,onOpenChange:g,onAdd:S,rowActions:b,onRemove:T,max:k=r,device:x="desktop",readOnly:z=!1}){const E=N("textStyles",a),M=_(),[W,Y]=L(v),X=void 0!==p?p:W,I=e=>{void 0===p&&Y(e),g?.(e)},F=j(null),[H,P]=L(null);A(()=>{if(!H||!F.current)return;const e=[...F.current.querySelectorAll(".es-ts-item")].find(e=>e.dataset.tsId===H.id),s=e?e.querySelector(".es-ts-row"):F.current.querySelector(`.es-ts-add[data-ts-kind="${H.kind}"]`);s?.focus(),P(null)},[H]);/* @__PURE__ */
8
+ return G("div",{className:"es-ts",ref:F,children:i.map(a=>{const i=e.filter(e=>e.kind===a),r=!n(e,a,k),d=!z&&!r;/* @__PURE__ */
9
+ return B(U,{label:E.groups[a],children:[i.map(a=>{const i=b?.(a),n=null!=i&&!1!==i,r=Boolean(T)&&!z&&!o(a);/* @__PURE__ */
10
+ return G(q,{style:a,fonts:t,colours:l,settings:c,auto:u,fallback:m,sample:h,device:x,readOnly:z,open:X===a.id,onOpenChange:e=>I(e?a.id:null),onChange:t=>s(e.map(e=>e.id===t.id?t:e)),actions:r||n?/* @__PURE__ */B(D,{children:[r?C(E.remove,/* @__PURE__ */G(w,{variant:"ghost-danger",size:"sm",className:"es-ts-del","aria-label":E.removeNamed({name:a.name}),onClick:()=>(t=>{if(z||!T)return;const a=y(e,t.id,{name:E.styleName});if(!a)return;const l=e.filter(e=>e.kind===t.kind),i=l[l.indexOf(t)+1];X===t.id&&I(null),s(a.styles),T(a.removed),P({id:i?.id??null,kind:t.kind})})(a),children:/* @__PURE__ */G($,{size:14,"aria-hidden":"true"})})):null,n?i:null]}):null},a.id)}),C(!z&&r?E.full({kind:a,max:k}):void 0,/* @__PURE__ */B(O,{variant:"link",className:"es-ts-add","data-ts-kind":a,disabled:z,"aria-disabled":!(z||!r)||void 0,"aria-describedby":!z&&r?`${M}-full-${a}`:void 0,onClick:()=>{d&&(t=>{if(z)return;const a=f(e,t,{max:k,name:E.styleName,make:S});a&&s(a.styles)})(a)},children:[
11
+ /* @__PURE__ */G("span",{className:"es-ts-add-word",children:E.add[a]}),
12
+ /* @__PURE__ */G("span",{className:"es-ts-count",children:E.count({n:i.length,max:k})})]})),z||!r?null:/* @__PURE__ */G("span",{id:`${M}-full-${a}`,className:"es-vh",children:E.full({kind:a,max:k})})]},a)})})}function U({label:e,children:s}){const t=_();/* @__PURE__ */
13
+ return B("section",{className:"es-ts-section","aria-labelledby":t,children:[
14
+ /* @__PURE__ */G("div",{className:"es-ts-group",id:t,children:e}),s]})}function q({style:e,fonts:s,colours:t=[],settings:l=d,auto:i=[],fallback:n,sample:r,open:o,onOpenChange:p,onChange:v,actions:f,device:y="desktop",readOnly:g=!1}){const S=N("textStyles",a),b=`${_()}-open-${e.id}`,C=new Set(i),T=c.filter(e=>l.includes(e)),k={...n?.(e)??{},...e.values},x="phone"===y,z=x&&void 0!==e.values.sizePhone?{...k,size:e.values.sizePhone}:k,E=s.find(e=>e.value===k.font),w={fontFamily:E?.family,fontSize:`${u(z.size??16)}px`,fontWeight:k.weight,fontStyle:k.italic?"italic":void 0};/* @__PURE__ */
15
+ return B(M,{children:[
16
+ /* @__PURE__ */B("div",{className:"es-ts-item","data-ts-id":e.id,children:[
17
+ /* @__PURE__ */B("button",{type:"button",className:"es-ts-row","aria-expanded":o,"aria-controls":o?b:void 0,onClick:()=>p(!o),children:[
18
+ /* @__PURE__ */G("span",{className:"es-ts-chev","aria-hidden":"true",children:/* @__PURE__ */G(W,{size:12})}),
19
+ /* @__PURE__ */G("span",{className:"es-ts-name",style:w,children:e.name}),
20
+ /* @__PURE__ */G("span",{className:"es-ts-meta",children:m(z,s,S,{autoSize:C.has("size")&&z===k&&void 0===e.values.size})})]}),f?/* @__PURE__ */G("div",{className:"es-ts-actions",children:f}):null]}),o?/* @__PURE__ */G("div",{className:"es-ts-open",id:b,children:/* @__PURE__ */G(J,{style:e,values:k,fonts:s,colours:t,settings:T,autoSet:C,sample:r??S.sample,words:S,phone:x,readOnly:g,set:s=>v(h([e],e.id,s)[0])})}):null]})}var K={none:P,upper:H,capitalize:F,lower:I};function J({style:e,values:s,fonts:a,colours:i,settings:n,autoSet:r,sample:o,words:d,phone:c,readOnly:u,set:m}){const h=e.values,v=a.find(e=>e.value===s.font),f=function(e,s){return e?s.find(s=>s.key===e)?.value??t(e)??void 0:void 0}(s.color,i),y=e=>"largestSize"===e||r.has(e),S=e=>y(e)?h[e]:s[e],b=S("size"),N=c&&void 0!==h.sizePhone?h.sizePhone:b,T=S("lineSpacing"),k=S("letterSpacing"),x=y("letterCase")?h.letterCase:s.letterCase,z={fontFamily:v?.family,fontSize:void 0===N?void 0:`${N}px`,fontWeight:s.weight,fontStyle:s.italic?"italic":void 0,lineHeight:void 0===T?void 0:String(T/100),letterSpacing:void 0===k?void 0:`${k}px`,color:f,textTransform:p(x)},E=e=>{const t=g[e],a=y(e);/* @__PURE__ */
21
+ return G("div",{className:"es-ts-slider","data-ts-setting":e,children:/* @__PURE__ */G(l,{label:d.settings[e],value:h[e],onChange:s=>m({[e]:s}),min:t.min,max:t.max,step:t.step,shiftStep:t.shiftStep,sliderMin:t.sliderMin,sliderMax:t.sliderMax,unit:t.unit||void 0,styleValue:a?void 0:s[e],auto:a?d.auto:void 0,readOnly:u})},e)};/* @__PURE__ */
22
+ return B(D,{children:[
23
+ /* @__PURE__ */G("div",{className:"es-ts-preview",style:z,"aria-label":d.preview,children:o}),n.map(t=>{switch(t){case"font":/* @__PURE__ */
24
+ return G(Q,{value:h.font,fonts:a,words:d,readOnly:u,set:m},t);case"color":/* @__PURE__ */
25
+ return G(ee,{value:h.color,hex:f,colours:i,words:d,readOnly:u,set:m},t);case"emphasis":{const e=(s.weight??400)>=600,a=!1!==v?.italic;/* @__PURE__ */
26
+ return B("div",{className:"es-ts-set","data-ts-setting":t,children:[
27
+ /* @__PURE__ */G("span",{className:"es-ts-sub",children:d.settings.emphasis}),
28
+ /* @__PURE__ */B("div",{className:"es-ts-icons",children:[C(d.bold,/* @__PURE__ */G(w,{className:"es-ts-icon","aria-label":d.bold,"aria-pressed":e,disabled:u,onClick:()=>m({weight:e?400:700}),children:/* @__PURE__ */G(Y,{size:16})})),u||a?C(d.italic,/* @__PURE__ */G(w,{className:"es-ts-icon","aria-label":d.italic,"aria-pressed":Boolean(s.italic),disabled:u,onClick:()=>m({italic:!s.italic||void 0}),children:/* @__PURE__ */G(X,{size:16})})):/* @__PURE__ */G(w,{className:"es-ts-icon","aria-label":d.italic,"aria-pressed":Boolean(s.italic),"aria-disabled":!0,disabledReason:d.italicMissing,children:/* @__PURE__ */G(X,{size:16})})]})]},t)}case"letterCase":/* @__PURE__ */
29
+ return G(se,{value:h.letterCase??s.letterCase,auto:y("letterCase"),words:d,readOnly:u,set:m},t);case"largestSize":return"heading"===e.kind?E(t):null;case"size":return c?(()=>{const e=g.size;/* @__PURE__ */
30
+ return G("div",{className:"es-ts-slider","data-ts-setting":"size","data-ts-device":"phone",children:/* @__PURE__ */G(l,{label:d.settings.size,value:h.sizePhone,onChange:e=>m({sizePhone:e}),min:e.min,max:e.max,step:e.step,shiftStep:e.shiftStep,sliderMin:e.sliderMin,sliderMax:e.sliderMax,unit:e.unit||void 0,styleValue:b,readOnly:u})},"size")})():E(t);default:return E(t)}})]})}function Q({value:e,fonts:s,words:t,readOnly:a,set:l}){const i=_();/* @__PURE__ */
31
+ return B("div",{className:"es-ts-set","data-ts-setting":"font",children:[
32
+ /* @__PURE__ */G("span",{className:"es-ts-sub",id:i,children:t.settings.font}),
33
+ /* @__PURE__ */G(S,{value:e,options:s.map(e=>({label:e.label,value:e.value})),onChange:e=>l({font:e}),ariaLabelledBy:i,readOnly:a})]})}function ee({value:e,hex:s,colours:t,words:a,readOnly:l,set:i}){/* @__PURE__ */
34
+ return G(V,{value:e,hex:s,colours:t,label:a.settings.color,followsWord:a.colour.follows,anyWord:a.colour.any,readOnly:l,onChange:e=>i({color:e})})}function se({value:e,auto:s,words:t,readOnly:a,set:l}){const i=v.map(e=>{const s=K[e];return{id:e,label:/* @__PURE__ */G(s,{size:16}),title:t.case[e]}}),n=s?[{id:"auto",label:/* @__PURE__ */G("span",{children:t.case.auto}),title:t.case.autoTitle},...i]:i;/* @__PURE__ */
35
+ return B("div",{className:"es-ts-set","data-ts-setting":"letterCase",children:[
36
+ /* @__PURE__ */G("span",{className:"es-ts-sub",children:t.settings.letterCase}),
37
+ /* @__PURE__ */G(b,{options:n,value:e??(s?"auto":"none"),ariaLabel:t.settings.letterCase,disabled:a,onChange:e=>l({letterCase:"auto"===e?void 0:e})})]})}export{V as ColourSwatchRow,q as TextStyleItem,U as TextStylesGroup,Z as TextStylesList};
@@ -83,32 +83,6 @@
83
83
  }
84
84
  @media (prefers-reduced-motion: reduce) { .es-ts-actions { transition: none; } }
85
85
 
86
- /* Delete: the Layers trash (tree.css `.es-tree-del`) — 22 px, the glyph 14,
87
- red at 0.7, full with a red tint under the pointer. */
88
- .es-ts-del {
89
- all: unset;
90
- box-sizing: border-box;
91
- display: flex;
92
- align-items: center;
93
- justify-content: center;
94
- width: 22px;
95
- height: 22px;
96
- border-radius: var(--radius-md);
97
- color: var(--es-danger, var(--status-danger-soft-ink));
98
- opacity: 0.7;
99
- cursor: pointer;
100
- transition: opacity 0.12s, background 0.12s, color 0.12s;
101
- }
102
- .es-ts-del svg { width: 14px; height: 14px; }
103
- .es-ts-del:hover,
104
- .es-ts-del:focus-visible {
105
- opacity: 1;
106
- background: var(--es-danger-tint, var(--status-danger-soft));
107
- color: var(--es-danger-strong, var(--status-danger-soft-ink));
108
- }
109
- .es-ts-del:focus-visible { outline: 2px solid var(--es-accent, var(--accent-600, var(--submit-bg))); outline-offset: 0; }
110
- @media (prefers-reduced-motion: reduce) { .es-ts-del { transition: none; } }
111
-
112
86
  .es-ts-row {
113
87
  all: unset;
114
88
  box-sizing: border-box;
@@ -227,49 +201,27 @@
227
201
  .es-ts-swatches { gap: var(--es-space-4, 4px); }
228
202
  }
229
203
 
230
- /* B · I and Letter case: the text box's 32 px buttons (react-os-shell
204
+ /* B · I: the text box's 32 px buttons (react-os-shell
231
205
  IconButton md); pressed = the light blue the toolbar's pressed marks wear. */
232
206
  .es-ts-icons {
233
207
  display: flex;
234
208
  flex-wrap: wrap;
235
209
  gap: var(--es-space-2, 2px);
236
210
  }
237
- /* An icon is efficient-shell's IconButton (harness UI-24): a toggle lit from
238
- `aria-pressed`, a case radio from `pressed` (it says `aria-checked`). What
239
- stays is the word button's width. */
240
- .es-ts-icon--word {
241
- width: auto;
242
- padding: 0 var(--es-space-8, 8px);
243
- font-size: var(--text-sm, 14px);
244
- font-weight: 500;
245
- }
246
-
247
- /* The window Any color opens (the shell's ColorPickerPanel): under the row, in
248
- the panel's flow, as wide as the row — not the panel's own popover width,
249
- which is wider than a 220 px panel's row. */
250
- .es-ts-set > .es-pick-window {
251
- width: auto;
252
- margin-top: var(--es-space-4, 4px);
253
- }
254
211
 
255
212
  /* ── "+ Add heading" · 3 / 7 ──────────────────────────────────────────────── */
256
213
 
214
+ /* The shell's Button (`link`, harness UI-6): its ink, focus ring and off look
215
+ are the kit's. What stays here is the line's layout — the words at the
216
+ start, the count at the end. */
257
217
  .es-ts-add {
258
- all: unset;
259
- box-sizing: border-box;
260
218
  display: flex;
261
- align-items: center;
219
+ width: 100%;
262
220
  justify-content: space-between;
263
221
  gap: var(--es-space-8, 8px);
264
222
  padding: var(--es-space-12, 12px) 0 0;
265
223
  font-size: var(--text-sm, 14px);
266
- font-weight: 500;
267
- color: var(--es-accent, var(--accent-600, var(--submit-bg)));
268
- cursor: pointer;
269
224
  }
270
- .es-ts-add:focus-visible { outline: 2px solid var(--es-accent, var(--accent-600, var(--submit-bg))); outline-offset: 2px; border-radius: var(--radius-sm); }
271
- .es-ts-add:disabled,
272
- .es-ts-add[aria-disabled='true'] { color: var(--es-disabled, var(--ink-faintest)); cursor: not-allowed; }
273
225
  .es-ts-count {
274
226
  font-size: var(--text-xs, 12px);
275
227
  font-weight: 400;
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { L as LayersTreeProps, S as SubtreeProps, a as TreeGroupLabelProps, b as TreeEmptySlotProps, c as TreeRowProps, d as TreeRowActionProps, e as TreeSeamProps } from '../types-DBy3L69b.js';
3
- export { f as TreeRowFold, T as TreeRowMark } from '../types-DBy3L69b.js';
2
+ import { L as LayersTreeProps, S as SubtreeProps, T as TreeGroupLabelProps, a as TreeEmptySlotProps, b as TreeRowProps, c as TreeRowActionProps, d as TreeSeamProps } from '../types-CoUTWUwB.js';
3
+ export { e as TreeRowFold, f as TreeRowMark } from '../types-CoUTWUwB.js';
4
4
  export { T as TreeWords } from '../words-Cl9xMUYY.js';
5
5
  import 'efficient-shell/ui';
6
6
 
@@ -168,4 +168,4 @@ type TreeSeamProps = {
168
168
  seamProps?: HTMLAttributes<HTMLDivElement>;
169
169
  };
170
170
 
171
- export type { LayersTreeProps as L, SubtreeProps as S, TreeRowMark as T, TreeGroupLabelProps as a, TreeEmptySlotProps as b, TreeRowProps as c, TreeRowActionProps as d, TreeSeamProps as e, TreeRowFold as f };
171
+ export type { LayersTreeProps as L, SubtreeProps as S, TreeGroupLabelProps as T, TreeEmptySlotProps as a, TreeRowProps as b, TreeRowActionProps as c, TreeSeamProps as d, TreeRowFold as e, TreeRowMark as f };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The Duplicate page dialog's own words (`efficient-easel/strings`): what it
3
+ * says and what it asks. Plain TypeScript with no import, like the module it
4
+ * belongs to. A sentence with a name in it is a function, so a host puts the
5
+ * name where its language wants it.
6
+ */
7
+ type PageCopyWords = {
8
+ /** The window's title; `name` is the page being copied. */
9
+ title: (v: {
10
+ name: string;
11
+ }) => string;
12
+ /** The primary button. */
13
+ submit: string;
14
+ /** The Title field's label. */
15
+ titleLabel: string;
16
+ /** The URL handle field's label. */
17
+ slugLabel: string;
18
+ /** Under Title: what a copy is. */
19
+ hint: string;
20
+ /** Under URL handle: the address the copy will have. */
21
+ address: (v: {
22
+ host: string;
23
+ slug: string;
24
+ }) => string;
25
+ /** Another page already uses the handle. */
26
+ clash: string;
27
+ /** The backend refused or the call failed. */
28
+ failed: string;
29
+ };
30
+ declare const DEFAULT_PAGE_COPY_WORDS: PageCopyWords;
31
+
32
+ export { DEFAULT_PAGE_COPY_WORDS as D, type PageCopyWords as P };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-easel",
3
- "version": "24.2.0",
3
+ "version": "25.1.0",
4
4
  "description": "Efficient Easel: the EFFICIENT editors' shared engine and chrome: the saved document as pure functions, the published renderer, and the editor frame, panels, Layers tree, text grammar and type-in-place box. Published as editor-shell up to 0.66.0 and as efficient-editor up to 0.95.0.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Efficient Pty Ltd",
@@ -54,6 +54,7 @@
54
54
  "./copy",
55
55
  "./style-clipboard",
56
56
  "./strings",
57
+ "./page-copy",
57
58
  "./screen/components/AddBlockRow",
58
59
  "./screen/components/AddChildRow",
59
60
  "./screen/components/AddSidePanel",
@@ -94,6 +95,7 @@
94
95
  "./screen/lib/document/add-target-types",
95
96
  "./screen/lib/document/block-choice",
96
97
  "./screen/lib/document/block-types-in",
98
+ "./screen/lib/document/block-set-host",
97
99
  "./screen/lib/document/box-fields",
98
100
  "./screen/lib/document/device-fields",
99
101
  "./screen/lib/document/field-buckets",
@@ -236,6 +238,11 @@
236
238
  "import": "./dist/draw/client.js",
237
239
  "default": "./dist/draw/client.js"
238
240
  },
241
+ "./page-copy": {
242
+ "types": "./dist/page-copy/index.d.ts",
243
+ "import": "./dist/page-copy/index.js",
244
+ "default": "./dist/page-copy/index.js"
245
+ },
239
246
  "./edit-lock": {
240
247
  "types": "./dist/edit-lock/index.d.ts",
241
248
  "import": "./dist/edit-lock/index.js",
@@ -428,6 +435,11 @@
428
435
  "import": "./dist/screen/lib/document/content-tree.js",
429
436
  "default": "./dist/screen/lib/document/content-tree.js"
430
437
  },
438
+ "./screen/lib/document/block-set-host": {
439
+ "types": "./dist/screen/lib/document/block-set-host.d.ts",
440
+ "import": "./dist/screen/lib/document/block-set-host.js",
441
+ "default": "./dist/screen/lib/document/block-set-host.js"
442
+ },
431
443
  "./screen/lib/document/box-fields": {
432
444
  "types": "./dist/screen/lib/document/box-fields.d.ts",
433
445
  "import": "./dist/screen/lib/document/box-fields.js",
@@ -633,7 +645,7 @@
633
645
  "dist"
634
646
  ],
635
647
  "peerDependencies": {
636
- "efficient-shell": "^10.20.0",
648
+ "efficient-shell": "^11.1.0",
637
649
  "react": ">=18",
638
650
  "react-dom": ">=18"
639
651
  },
@@ -643,7 +655,7 @@
643
655
  "@types/node": "^22.0.0",
644
656
  "@types/react": "^18.2.0",
645
657
  "@types/react-dom": "^18.2.0",
646
- "efficient-shell": "^10.20.0",
658
+ "efficient-shell": "^11.1.0",
647
659
  "esbuild": "^0.27.0",
648
660
  "jsdom": "^26.1.0",
649
661
  "react": "^18.2.0",
@@ -1 +0,0 @@
1
- import{mediaPickStoreFor as e}from"./chunk-NCXYC7WI.js";var t=/* @__PURE__ */new Map,n=0;function o(o,i){if(!o.connected)return Promise.resolve(null);const r=(n+=1,`mp-${"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():String(n)}`),c=e(o);return c?c.request({requestId:r,accept:i.accept,title:i.title,file:i.file??null,...i.options?{options:i.options}:{}}):new Promise(e=>{t.set(r,e),o.send("storefront-editor:open-media-picker",{requestId:r,accept:i.accept,title:i.title,...i.file?{file:i.file}:{}})})}function i(e,n){const o=t.get(e);o&&(t.delete(e),o(n))}export{o as requestMediaPick,i as resolveMediaPick};
@@ -1 +0,0 @@
1
- import{useSectionOps as o}from"./chunk-OITNWE52.js";import{SELECTION_MODE as e}from"./chunk-QORC32JO.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-FJTCSQWK.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),I=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{k(l)},[k,l]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&I.select(r)},[i,u,I]),openPartId:h}}export{m as usePartBridge};
@@ -1,8 +0,0 @@
1
- import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-VKPOH6MK.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as l}from"./chunk-N7E6264U.js";import{sharedSectionsOf as r}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-5PXVT7JY.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as d,useScreenPinned as p}from"./chunk-QORC32JO.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-IYHO4XQX.js";import{useEasel as u}from"./chunk-FJTCSQWK.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-LN43DP2A.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-TQ5Y6S2X.js";import{useState as b,useEffect as v,useMemo as j,useRef as C}from"react";import{SharedIcon as O,AddIcon as w}from"efficient-shell/icons/efficient";import{ContextMenu as I,toast as F,Dialog as T,Button as $}from"efficient-shell/ui";import{jsx as x,jsxs as E,Fragment as H}from"react/jsx-runtime";function M({name:e,pages:t,onDelete:n,onCancel:o}){const l=h("screen",f).shared,[r,i]=b(!1),s=C(null);/* @__PURE__ */
2
- return x(T,{open:!0,role:"alertdialog",size:"sm",title:l.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */E(H,{children:[
3
- /* @__PURE__ */x($,{ref:s,variant:"secondary",onClick:o,children:l.cancel}),
4
- /* @__PURE__ */x($,{variant:"danger",loading:r,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:l.deleteShared})]}),children:l.deleteMessage({count:t})})}var Q=e=>`section:${e}`,S=e=>`block:${e}`,W=e=>`template:${e}`,A=e=>`shared:${e}`;function J({at:C,placeBlocks:T,canTake:$,onPick:J,itemFor:L,session:N,siteWide:P,onClose:Y,onHide:z,readOnly:B}){const D=u(e=>e.config),G=a(),{labelAtLevel:R,categoryLabel:U,firstSection:V,Icon:X,Thumbnail:K}=G,{blockIsOffered:_,canAddTo:Z}=d(),q=h("screen",f).add,ee=h("drag",g).add,te=m(),[ne,oe]=b([]);v(()=>{let e=!1;const t=e=>_(e,te);return l(te).list().then(n=>{if(e)return;const l=D.components;oe(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[D,te]);const le=p().shared,re=h("screen",f).shared,[ie,se]=b([]),[ce,ae]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>_(e,te);return r(te).list().then(n=>{if(e)return;const l=D.components;se(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[D,te,ce]);const[de,pe]=b(null),[me,fe]=b(null),ue=j(()=>e(D,G),[D]),ye=e=>R(e,"section",D.components[e]?.label??e),he=e=>({type:Q(e.type),label:e.name,cover:/* @__PURE__ */x(K,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:q.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ke=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=ne.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=ie.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}return null},ge=e=>/* @__PURE__ */x("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */x(X,{type:e,size:26})}),be=j(()=>{const e=t(ue,V),o=/* @__PURE__ */new Map,l=e=>{e.retired||o.has(e.type)||!_(e.type,te)||o.set(e.type,e)};for(const t of e?[e]:ue){const e=Z(t.type)?.choices??[];e.forEach(l),e.forEach(e=>Z(e.type,1)?.choices?.forEach(l))}T?.forEach(l);const r=new Set(ue.map(e=>e.type)),i=[...o.values()].filter(e=>!r.has(e.type)),s=e=>({type:S(e.type),label:e.label,cover:ge(e.type),title:q.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>o.has(e.type)?{...he(e),cover:ge(e.type)}:he(e),d=[];ie.length>0&&d.push({key:"shared",title:re.group,tiles:ie.map(e=>({type:A(e.id),label:e.title,cover:/* @__PURE__ */x(K,{type:e.node.type}),mark:/* @__PURE__ */x(O,{size:12}),title:re.onPages({count:e.used_on.length}),keywords:[ye(e.node.type),e.node.type]}))}),ne.length>0&&d.push({key:"templates",title:q.templates,tiles:ne.map(e=>({type:W(e.id),label:e.name,cover:/* @__PURE__ */x(K,{type:e.node.type}),keywords:[ye(e.node.type),e.node.type]}))});const p=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(D.categories??{})){const o=ue.filter(e=>e.cat===t);if(0===o.length)continue;const l=e&&o.some(t=>t.type===e.type)?e:null,r=(l?[l,...o.filter(e=>e.type!==l.type)]:o).map(a);l&&!m&&(r.splice(1,0,...p.map(s)),m=!0),d.push({key:`category:${t}`,title:n(D,t,U),tiles:r})}const f=d.find(e=>e.key?.startsWith("category:"));if(!m&&f&&p.length>0&&(f.tiles=[...f.tiles,...p.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{d.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!$)return d;const u=d.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ke(e.type),n=t?$(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[ne,ie,re,ue,D,q,$,T,te]);/* @__PURE__ */
5
- return E(H,{children:[
6
- /* @__PURE__ */x(i,{icon:/* @__PURE__ */x(w,{size:15}),title:q.title,context:q.contextAll,actions:/* @__PURE__ */x(s,{label:q.done,description:q.doneDescription,onClick:Y}),onHide:z}),
7
- /* @__PURE__ */E("div",{className:"sf-addside sf-scroll",children:[
8
- /* @__PURE__ */x(k,{groups:be,session:N,itemFor:e=>L(ke(e)??{kind:"section",type:e}),onInsert:J?e=>{const t=ke(e);t&&J(t)}:void 0,onTileMenu:(e,t)=>{const n=ke(e);return"shared"===n?.kind&&!B&&(pe({section:n.section,...t}),!0)},at:C,hint:q.hint,searchLabel:q.search,readOnly:B,words:ee}),P??null]}),de?/* @__PURE__ */x(I,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>pe(null),"aria-label":de.section.title,items:y([{label:re.deleteShared,danger:!0,onClick:()=>{fe(de.section),pe(null)}}])}):null,me?/* @__PURE__ */x(M,{name:me.title,pages:me.used_on.length,onDelete:()=>(async e=>{try{await r(te).remove(e.id)}catch{return void F.error(re.deleteFailed)}fe(null),le?.removed?.(e),se(t=>t.filter(t=>t.id!==e.id)),ae(e=>e+1)})(me),onCancel:()=>fe(null)}):null]})}export{J as AddSidePanel,S as blockKey,Q as sectionKey,A as sharedKey,W as templateKey};
@@ -1,7 +0,0 @@
1
- import{SettingRow as e,Segmented as a,Tooltip as s}from"efficient-shell/ui";import{jsx as i,jsxs as l}from"react/jsx-runtime";function n({label:a,labelId:s,icon:l,value:n,hint:t,changed:c,htmlFor:d,action:r,children:o,className:m}){/* @__PURE__ */
2
- return i(e,{size:"compact",label:a,labelId:s,icon:l,readout:n,description:t,changed:c,controlId:d,action:r,value:o,className:m})}function t({options:e,value:n,onChange:t,ariaLabel:c,fit:d,disabled:r=!1,className:o}){const m=d&&function(e,a){return{"--es-fit-count":e,"--es-fit-labels":`${a.labelsPx}px`,"--es-fit-widest":`${a.widestLabelPx}px`}}(e.length,d),b=e.findIndex(e=>e.id===n);
3
- /* @__PURE__ */
4
- return i("div",{className:"es-segs-fit","data-disabled":r||void 0,style:m,children:/* @__PURE__ */i(a,{size:"sm",label:c,className:`es-segs${m?" is-measured":""}${o?` ${o}`:""}`,value:b<0?"":String(b),onChange:a=>t(e[Number(a)].id),options:e.map((e,a)=>{const n=e.title??("string"==typeof e.label?e.label:void 0),t="string"!=typeof e.label,c=a=>n&&(e.icon||t)?/* @__PURE__ */i(s,{content:n,children:a}):a;return{value:String(a),disabled:r||!0===e.disabled,icon:e.icon?c(
5
- /* @__PURE__ */i("span",{className:"es-seg-icon","aria-hidden":"true",children:e.icon})):void 0,label:t?/* @__PURE__ */l("span",{className:"es-seg-word es-seg-drawn",children:[c(
6
- /* @__PURE__ */i("span",{className:"es-seg-mark","aria-hidden":"true",children:e.label})),
7
- /* @__PURE__ */i("span",{className:"es-vh",children:n})]}):/* @__PURE__ */i("span",{className:"es-seg-word",children:e.label})}})})})}export{n as SettingsField,t as SettingsSegmented};
@@ -1 +0,0 @@
1
- import{panelFieldsOf as t}from"./chunk-5XL2RXFU.js";import{withoutDeviceGate as o}from"./chunk-2FYFAAAK.js";import{DESIGN_GROUP_KEY as n,BUCKET_KEY as e}from"./chunk-3QB2ZQXK.js";import{STYLE_KIND as r,fieldKind as s,copyStyle as c,heldStyle as i,planPaste as p,pasteMessage as u}from"./chunk-V7U33NF2.js";import{ANCHOR_FIELD_KEYS as f,foldMetaOf as a,MEDIA_FIELD_MARKER as l,TEXT_FIELD_MARKER as m,LINK_FIELD_MARKER as h}from"./chunk-ANPOR6EY.js";import{deviceMetaOf as y}from"./chunk-YCSZAP7T.js";var j=/* @__PURE__ */new Set([n.Size,n.Design,n.Layout,n.Position]),w=new Set(Object.values(n)),b=new Set(Object.values(e)),S=new Set(f),k=/* @__PURE__ */new Set(["focal","imageFocal"]),A=[l,m,h];function g(t){return`site:${t??""}`}function v(t){if(!t||"object"!=typeof t)return null;const n=t,e=o(t)??t,c=n[r]??e[r];if("string"==typeof c)return c;const i=n.options??e.options;if(Array.isArray(i)){return`choice:${i.map(t=>String(t?.value)).sort().join("|")}`}return s(e)}function F(t){const n=t,e=o(t);return A.some(t=>t in n||e&&t in e)}function O(o,n){const r=t(o,n)??{},s=[];let c=!0,i=!1;for(const[t,o]of Object.entries(r))b.has(t)?(c=t===e.Design,i=!1):w.has(t)?c&&(i=j.has(t)):i&&o&&"object"==typeof o&&!t.startsWith("_")&&(a(o)||S.has(t)||k.has(t)||F(o)||"slot"!==o.type&&s.push({path:[t],kind:v(o),counted:"mobile"!==y(o)?.tier}));return s}function d(t,o,n,e,r){c({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function L(t,o,n,e,r,s){const c=i(n);if(!c)return null;const f=p(c,{type:e.type,rows:t(o,e),props:e.props});return{...f,message:u(f,c.sourceLabel,r,s)}}function P(t,o,n,e){d(O,t,o,n,e)}function X(t,o,n,e,r){return L(O,t,o,n,e,r)}var Y={scope:t=>g(t.siteId),rows:(t,o)=>O(t,o),copy:(t,o,n,e)=>P(e,t,o,n),plan:(t,o,n,e)=>X(e,t,o,n)};function D(t,o){if(!t&&!o)return Y;const n=t?.rows,e=n?(t,o)=>n(t,o):O;return{scope:t?.scope??Y.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>d(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>L(e,s,t,n,r,o))}}export{P as copyNodeStyle,O as nodeStyleRows,X as planNodePaste,v as shopFieldKind,g as siteStyleScope,D as styleClipboardOf};
@@ -1,16 +0,0 @@
1
- import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-AGWKB77Q.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as l,clickPickPart as i,clickPick as s}from"./chunk-RPMSET77.js";import{selectionBox as a,placeWindow as c,offsetOrigin as u,colorRunOf as d,ColorWindow as p,startCanvasTyping as f,textMap as h}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as m}from"./chunk-KRL3IUV3.js";import{useWords as g}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as v,CANVAS_TYPABLE_EVENT as y,related as w,isTypingTarget as b,upsertCanvasStyle as k,removeCanvasStyle as S,WORDS_CLEAR as C,frameRectToHost as I,CANVAS_TYPING_EVENT as E,drawnBox as D}from"./chunk-YU3WHLGI.js";import{queryAllCopies as x}from"./chunk-LF3FUSCQ.js";import{find as A,ROOT_ID as O,getList as M,remove as $,parseZoneKey as R,move as z,duplicate as P,replaceNode as L,createNode as V,insert as j,normalizeData as N,createResolveCache as B,slotsOf as K,resolveNodeData as Z,ROOT_SLOT as F}from"./chunk-TGZCD6IP.js";import{topLevelSlotKeys as T,fieldsFrom as H,drawnBlockCount as W,defaultsFrom as Y}from"./chunk-KXM6YRG2.js";import{createContext as q,useEffect as U,useContext as G,useRef as Q,useSyncExternalStore as X,useState as J,useReducer as _,useMemo as ee,useCallback as te,useLayoutEffect as ne}from"react";import{jsx as oe,jsxs as re,Fragment as le}from"react/jsx-runtime";import{createPortal as ie}from"react-dom";import{registerModalEscapeInterceptor as se,FloatingBar as ae,TextToolbar as ce,LinkPicker as ue}from"efficient-shell/ui";function de(e){return!["setData","setUi","set"].includes(e.type)}var pe=(e,t,n,o)=>{const r=M(e,t,R(n));return r?.[o]??null},fe=(e,t,n,o,r)=>{const l=pe(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function he(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function me(e,t,n){return n?"node"===n.kind?A(e,t,n.id)?n:null:n.parentId===O?M(e,t,n)?n:null:A(e,t,n.parentId)&&M(e,t,n)?n:null:null}function ge(e,t,n,r=!1){const{itemSelector:l,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,l??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:r?s:{...e.ui,...s}}}function ve(e,t,n){const o=ye(e,t,n);if(o===e)return e;const r=me(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ye(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return ge(e,n,"function"==typeof t.ui?t.ui(he(e,n)):t.ui);case"set":{const r={data:o,ui:he(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=ge(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:j(o,n,r,l)}}case"replace":{const r=fe(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:L(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=fe(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=P(o,n,r.props.id),i=pe(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return ye(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=pe(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...R(t.destinationZone),index:t.destinationIndex};return{...e,data:z(o,n,r.props.id,l)}}case"remove":{const r=fe(o,n,t.zone,t.index,"remove");return{...e,data:$(o,n,r.props.id)}}default:return e}}var we={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},be={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ke=0,Se=()=>`history-${ke+=1}`;function Ce(e){let t=e.config;const r=e.now??(()=>Date.now()),l=e.historyCoalesceMs??250;let i=e.permissions??{};const s=N(e.data,t);let a=s,c={data:s,selection:null,ui:{...be}};if(e.ui){const{itemSelector:n,selectedSlot:r,...l}=e.ui;c={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...be,...l}}}let u=[{core:c,at:-1/0,sealed:!0,id:Se()}],d=0;const p=e=>{const t=u[d],n=r();!e&&d===u.length-1&&d>0&&!t.sealed&&n-t.at<l?u=[...u.slice(0,d),{...t,core:c,at:n}]:(u=[...u.slice(0,d+1),{core:c,at:n,sealed:e,id:Se()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},b=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+1)]},k=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=ve(c,e,t),c===n)return;const o=e.recordHistory??de(e);k(n,o&&c.data!==n.data)},C=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=e=>{const n=c,o=me(c.data,t,e);var r,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()},D=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...we,...i,...n}};let x=D();const O=B(),$={resolveCache:O,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([Z(r,t,{cache:O,trigger:e,metadata:n}),...l.map(o=>Z(o,t,{cache:O,trigger:e,metadata:n}))]);C(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=A(r,t,i)?.node;s&&s===A(o,t,i)?.node&&(r=L(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:me(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=A(c.data,t,e)?.node;if(!r)return!1;const l=await Z(r,t,{cache:O,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return C(()=>{const n=c;if(A(c.data,t,e)?.node!==r)return;const o=L(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:me(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,o={data:e.data,ui:he(e,t)},r="node"===e.selection?.kind?A(e.data,t,e.selection.id)?.node??null:null;return h={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:S,history:{back:()=>$.undo(),forward:()=>$.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:he(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&E(e)}},getPermissions:x,getItemById:n=>A(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return M(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:C,group:()=>{const e=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=>I(e?{kind:"node",id:e}:null),selectSlot:e=>I(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:me(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=N(e,t);c={...c,data:r,selection:me(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:Se()}],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,x=D(),h=null,w())},setConfig(e){e!==t&&(t=e,x=D(),h=null,w())}};return $}function Ie(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&b(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var Ee=q(null),De=q(!0);function xe({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return U(()=>{n&&e.resolveAll()},[e,n]),U(()=>{if(t&&"undefined"!=typeof document)return Ie(document,e)},[e,t]),/* @__PURE__ */oe(Ee.Provider,{value:e,children:/* @__PURE__ */oe(De.Provider,{value:t,children:o})})}function Ae(){const e=G(Ee);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Oe(e){const t=Ae(),n=Q({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const 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 X(t.subscribe,o,o)}function Me(){return function(e){return Oe(e)}}var $e=["--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"],Re="host-tokens";function ze(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of $e){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?k(t,Re,n):S(t,Re)}var Pe="data-easel-block",Le="data-easel-dropzone",Ve={},je="data-es-mirror",Ne="undefined"==typeof window?U:ne;function Be(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${je}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(je,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Ke({children:t,id:n="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=g("canvas",e),d=Q(null),[p,f]=J(null);return Ne(()=>{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]),Ne(()=>{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),v(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){Be(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Be(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){ze(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>ze(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__ */oe("iframe",{ref:d,id:n,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?ie(t,p):null})}var Ze=q(null),Fe=q(Ve),Te=[];function He({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=Ae(),s=Oe(n=>M(n.appState.data,i.config,{parentId:e,slot:t})??Te),a=Oe(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==O),c=Oe(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=G(Ze),d=["es-zone"];return s.length&&d.push("has-children"),e===O&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==O&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */oe("div",{className:d.join(" "),[Le]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */oe(Je,{node:e},e.props.id))})}function We(e,t,n,o){const r=ee(()=>{const n={};for(const o of T(H(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
2
- return oe(He,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=W(n[e],o);return r}function Ye(e){return ee(()=>function({zone:t,...n}){/* @__PURE__ */
3
- return oe(He,{parentId:e,slot:t,...n})},[e])}var qe=["top","bottom","zIndex"];function Ue(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Ge(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));Ue(e,"position",t?"sticky":"relative");for(const n of qe)Ue(e,n,t?.[n]??"");return!!t}var Qe="data-es-canvas-relative";function Xe(e){e.hasAttribute(Qe)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Qe));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Qe,"")),!1)}function Je({node:e}){const t=Ae().config,n=t.components[e.type],o=e.props.id,r=Q(null),l=function(e,t){return ee(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Pe),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Pe,e),n.setAttribute("data-easel-dnd",e),Xe(n))},[e,t])}(o,r),i=Q(null),s=!!n?.inline;!function(e,t){const n=Q(!1),o=Q(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=Q(()=>{});Ne(()=>o.current()),Ne(()=>{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?Xe(e):Ge(e));const a=G(Fe),c=We(n,o,e.props,t.components),u=Ye(o);if(!n?.render)return null;const d=n.render,p={...Y(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */oe(d,{...p,editor:f,editMode:!0}):
4
- /* @__PURE__ */oe("div",{ref:i,[Pe]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */oe(d,{...p,editor:f,editMode:!0})})}function _e({metadata:e}){const t=Oe(e=>e.config),n=Oe(e=>e.appState.data.root).props??{},o=t.root?.render,r=We(t.root,O,n,t.components),l=Ye(O),i=/* @__PURE__ */oe(He,{parentId:O,slot:F}),s=o?/* @__PURE__ */oe(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
5
- return oe(Fe.Provider,{value:e??Ve,children:s})}var et=q(void 0),tt=q(void 0);function nt(e,t,n,o){const r=A(e,t,n);return!!r&&(K(r.node,t).length>0||!1===o.whole)}var ot=q(void 0),rt="data-es-chrome",lt=q(void 0);function it(e){const t=e?.closest?.(`[${rt}]`)??null,n=t?.getAttribute(rt);return t&&n?{id:n,element:t}:null}function st({element:e}){const t=Q(null),n=ut(t,e?()=>e:null,e);/* @__PURE__ */
6
- return oe("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}var at={"--es-words-clear":`${C}px`};function ct({element:e,words:t=!1}){const n=Q(null),o=ut(n,e?()=>e:null,e);/* @__PURE__ */
7
- return oe("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...at}:{display:"none"}})}function ut(e,t,n){return pt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var dt=[];function pt(e,t,n){const[o,r]=J(dt),l=Q(t);return l.current=t,Ne(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(dt);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=D(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:dt;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}function ft({id:e,kind:t,overlay:n}){const o=Q(null),r=G(tt),l=null!==e&&!0===r?.(e),i=pt(o,e?t=>x(t,`[${Pe}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=`es-canvas-outline is-${t}${l?" is-shared":""}`,u=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),d=/* @__PURE__ */re(le,{children:[
8
- /* @__PURE__ */oe("div",{ref:o,"aria-hidden":"true",className:c,style:s?u(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */oe("div",{"aria-hidden":"true",className:c,style:u(e)},t))]});return n&&e?/* @__PURE__ */oe(n,{componentId:e,kind:t,children:d}):d}function ht(e,t,n){const o=h(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 mt({s:e,element:t,toolbar:n,label:o,keys:r}){const l=g("copy",m),i=e.pressed(),s=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,h=Q(null),[v,y]=J(!1),[w,b]=J(null),k=v||null!==w,S=()=>{e.hold(),y(!1),b({href:e.pressed().href})},C=()=>{y(!1),b(null),e.resume()};ne(()=>{r.current={escape:()=>!!k&&(C(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),ne(()=>()=>{r.current=null},[r]);const E=Q(C);E.current=C,U(()=>{if(v)return se(e=>{const t=h.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>h.current?.querySelector(".es-copy-colors"))},[v]),U(()=>{const n=h.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;y(!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]),ne(()=>{const e=h.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,l=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,i=(l?a(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,d=s?I(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},p=o.getBoundingClientRect(),f=s?I(s,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:d.left,right:d.left+d.width,top:Math.min(d.top,f.top-6,m.top),bottom:Math.max(d.top+d.height,f.top+f.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const b=c({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:u(n)});n.style.top=`${b.top}px`,n.style.left=`${b.left}px`,n.style.setProperty("--es-pop-point",`${b.point}px`),n.dataset.side=b.above?"above":"below"});const D=f?{run:d(i.color,f),open:v,onToggle:()=>{b(null),v?C():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
9
- return oe(ae,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?I(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */oe("div",{ref:h,children:/* @__PURE__ */oe(ce,{layout:"row",offered:s,pressed:i.marks,onMark:t=>{"link"===t?S():e.press(t)},color:D,linkOpen:null!==w,list:{pressed:i.list,onList:t=>e.list(t)},clear:i.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:i.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */re(le,{children:[v&&f?/* @__PURE__ */oe(p,{colors:f,current:i.color,words:l.colors??m.colors,onPick:t=>e.color(t)}):null,w?
10
- /* @__PURE__ */oe(ue,{className:"es-copy-link es-copy-pop",value:w.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==w.href?()=>{b(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function gt({element:e,which:t}){const n=Q(null),o=ut(n,()=>e(),t);/* @__PURE__ */
11
- return oe("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...at}:{display:"none"}})}function vt({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:a,onDocument:c,height:u,title:d,nonce:p,hotkeys:h,frameWrapper:m,overlay:v,children:b,typing:k,passThrough:S}){const C=Ae(),I=G(et),D=S??I,x=G(De),O=g("canvas",e),M=h??x,[$,R]=J(void 0),z=Oe(e=>"node"===e.selection?.kind?e.selection.id:null),[P,L]=J(null),[V,j]=J(null),N=G(ot),B=G(lt),[Z,F]=J(null),[,T]=_(e=>e+1,0),[,H]=_(e=>e+1,0),W=e=>{N?.select(e),H()},[Y,q]=J(null),X=Q(null),[,ee]=J(0),te=Q(k);te.current=k;const ne=Q(null),le=Q(null),ie=()=>{if(!z)return null;const e=te.current?.atSelection?.()?.element()??null;if(!e)return null;const t=le.current?.ownerDocument;if(N){const n=N.selected()&&t?N.selectedPart?.(t)??null:null;return n&&w(n.element,e)?n.element:null}const n=A(C.getState().appState.data,C.config,z);return n&&0===K(n.node,C.config).length?e:null},se=Oe(e=>e.appState.data),ae=N?.selected()??null;U(()=>{const e=le.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=z&&!Y&&te.current?.atSelection?.()?z:null,o=n?ie():null;e.dispatchEvent(new t(y,{detail:o?{id:n,words:o}:{id:n}}))},[z,Y,se,ae]);const ce=e=>{const t=le.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(E,{detail:{typing:e}}))},ue=(e,t)=>{X.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=C.group(),r=e.element,l=f({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:ht(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>ee(e=>e+1),onEscape:()=>ne.current?.escape()??!1,onLinkKey:()=>ne.current?.link()??!1,end:e=>{o.close(),X.current?.element===r&&(X.current=null),q(null),ce(!1),te.current?.onChange?.({typing:!1,why:e})}});if(!l)return o.close(),!1;const i=n.closest?.(`[${Pe}]`)?.getAttribute(Pe);return i&&C.select(i),X.current={s:l,element:r,target:e},q(()=>r),L(null),ce(!0),te.current?.onChange?.({typing:!0,element:n}),!0};U(()=>()=>X.current?.s.stop("stop"),[]);const de=e=>{const t=X.current?.element();return Boolean(t&&t.contains(e))},pe=(e,t)=>nt(C.getState().appState.data,C.config,e,t),fe=e=>{const t=e.closest?.(`[${Pe}]`)?.getAttribute(Pe);if(!t)return;const n=C.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=N?.partAt(e,t)??null;if(r){const e=i(n.appState.data,C.config,t,r.id,o,N?.selected()??null,D);if(e)return{node:e.node,part:e.part?r:null}}return{node:s(n.appState.data,C.config,t,o,D)??t,part:null}},he=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(X.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=te.current?.atSelection?.();n&&ue(n,null)&&e.preventDefault()},me=le.current?.ownerDocument??null,ge=N?.selected()&&me&&z?N.selectedPart?.(me)??null:null,ve=ge&&z&&pe(z,ge)?ge.element:null,ye=B?.selected()??null,we=ye&&me?Array.from(me.querySelectorAll(`[${rt}]`)).find(e=>e.getAttribute(rt)===ye)??null:null,be=Y?null:ie(),ke=/* @__PURE__ */re("div",{ref:le,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),X.current){if(de(t))return;X.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=B?it(t):null;if(B&&o)return B.select(o.id),F(null),void T();const r=fe(t);if(void 0!==r)return C.select(r.node),void(N&&(r.part?.id??null)!==N.selected()&&W(r.part?.id??null));t.hasAttribute?.(Le)||(C.select(null),N?.selected()&&W(null))},onDoubleClick:e=>{const t=te.current;if(!t||de(e.target))return;const n=t.at(e.target);n&&ue(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>he(e),onMouseOver:e=>{if(X.current)return;const t=B?it(e.target):null;if(t?.element!==Z?.element&&F(t),t)return null!==P&&L(null),void(null!==V&&j(null));const n=fe(e.target),o=!!n?.part&&pe(n.node,n.part),r=n?.part&&o&&n.part.id!==N?.selected()?n.part:null,l=!n||n.part&&o?null:n.node;l!==P&&L(l),r?.id===V?.id&&r?.element===V?.element||j(r)},onMouseLeave:()=>{L(null),j(null),F(null)},children:[
12
- /* @__PURE__ */oe(Ze.Provider,{value:P,children:/* @__PURE__ */oe(_e,{metadata:r})}),
13
- /* @__PURE__ */re("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
14
- /* @__PURE__ */oe(ft,{id:!Y&&P&&P!==z?P:null,kind:"hover",overlay:v}),N?/* @__PURE__ */oe(st,{element:Y||!V||V.id===N.selected()?null:V.element}):null,be||ve?/* @__PURE__ */oe(ct,{element:Y?null:be??ve,words:null!==be}):null,B?/* @__PURE__ */oe(st,{element:Y||!Z||Z.element===we?null:Z.element}):null,we?/* @__PURE__ */oe(ct,{element:Y?null:we}):null,
15
- /* @__PURE__ */oe(ft,{id:Y||ve||be||we?null:z,kind:"selected",overlay:v}),Y?/* @__PURE__ */oe(gt,{element:()=>{const e=Y?.()??null;return e?ge&&w(ge.element,e)?ge.element:e:null},which:ge?.element??Y}):null]}),b]}),Se=m?/* @__PURE__ */oe(m,{document:$,children:ke}):ke;U(()=>{if($&&M)return Ie($,C)},[$,M,C]),U(()=>{if(!$)return;const e=e=>{if("Enter"===e.key)return void he(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=C.getState();if("node"!==n.selection?.kind)return;if(N?.selected())return void W(null);const o=l(n.appState.data,C.config,n.selection);"node"===o?.kind&&C.select(o.id)};return $.addEventListener("keydown",e),()=>$.removeEventListener("keydown",e)},[$,C,N]);/* @__PURE__ */
16
- return re("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-easel-preview":"","data-es-typing":Y?"":void 0,children:[Y&&X.current?.target.toolbar?/* @__PURE__ */oe(mt,{s:X.current.s,element:X.current.element,toolbar:X.current.target.toolbar,label:O.textTools,keys:ne}):null,t?/* @__PURE__ */oe(Ke,{mirrorStyles:a,onDocument:e=>{R(e??void 0),c?.(e)},height:u,title:d,nonce:p,children:Se}):/* @__PURE__ */oe("div",{id:"preview-frame","data-easel-entry":"",children:Se})]})}function yt(e={}){const t=Ae(),n=Oe(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function wt(){return kt(Oe(e=>e.selectedItem))}function bt(){return kt(null)}function kt(e){const n=Ae(),o=Oe(e=>e.config),r=n.resolveCache,l=Oe(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=ee(()=>e||{type:"root",props:s},[e,s]),c=e?o.components[e.type]:o.root,u=n.getState(),d=e?A(u.appState.data,o,i):null,p=d&&"root"!==d.place.parentId?d.place.parentId:null,f=p?u.getItemById(p)??null:null,{fields:h}=t({id:i,node:a,block:c,parent:f,appState:u.appState}),m=Oe(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=te(e=>{(async()=>{const t=n.getState();if("root"!==i){const l=t.getItemById(i),s=t.getSelectorForId(i);if(!l||!s)return;const a={...l,props:{...l.props,...e}},{node:c}=await Z(a,o,{cache:r,trigger:"replace"}),u=n.getState().getSelectorForId(i);if(!u)return;return void n.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const l=t.appState.data.root.props??{},{node:s}=await Z({type:"root",props:{...l,...e}},o,{cache:r,trigger:"replace"});n.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[n,o,r,i]),v=te((e,t)=>g({[e]:t}),[g]);return{id:i,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{rt as CHROME_ATTR,lt as CanvasChromeContext,Ke as CanvasFrame,ot as CanvasPartsContext,et as CanvasPassThroughContext,tt as CanvasSharedContext,be as DEFAULT_UI,vt as EaselCanvas,xe as EaselProvider,_e as EditDocument,Ie as bindUndoKeys,Ce as createEasel,Me as createUseEasel,nt as partHasOwnBox,de as recordsByDefault,ve as reduce,he as uiView,Oe as useEasel,Ae as useEaselApi,yt as useEaselNodeOps,bt as useRootFields,wt as useSelectedFields,me as validSelection};
@@ -1 +0,0 @@
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-IYHO4XQX.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{easelMenuEntries as r,menuLabel as i}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-YU3WHLGI.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as y}from"./chunk-TGZCD6IP.js";import{useState as h,useCallback as k,useRef as b,useEffect as v}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,StylesIcon as O,LayersIcon as z,CopyIcon as P}from"efficient-shell/icons/efficient";import{jsx as A}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 Y=c(),j=/* @__PURE__ */new WeakMap;function D(e){if(e.claimsPage)return Y;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",c);let t=j.get(n);return t||(t=c(),j.set(n,t)),t}function I(){return D(e())}function K(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:y,slot:m,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 M(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 X(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?K(e,t.zone,t.index+1):null;for(const l of T(e,t)){const t=K(e,l.zone,l.index+1);if(o(n,t))return t}return null}function S(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(u(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 L(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=M(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:X(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function E(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,a=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=M(e,i,t),k=T(e,n),b=d.held,v=b&&!p?X(e,b,n):null,g=!e.readOnly,w=e.style?o({held:g?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return s({title:a,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:g&&m&&y.duplicate?()=>d.duplicate(c):void 0,...U(g&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,a):void 0,cut:g&&h.cut?()=>d.cut(c,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:g&&m&&y.delete?()=>d.remove(c):void 0},style:w,extras:e.menuRows?.(i,t,r)??void 0,pinnedLine:p?V(e).pinned:void 0})}function U(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var V=e=>e.words?.screen??t.menu;function B(e){const n=V(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=K(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):f(c.from)===l)){const n=s,t=e.words?.menu??a;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */A(O,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */A(z,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function R(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??a,c=V(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function N(e){return e.shiftKey}function F(e,t){const[o,l]=h(null),r=k(()=>l(null),[]);n(null!==o,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=S(e);if(!o)return;const l=t.selected();if(!l)return;const r=L(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),s=e.keys?.target??null;v(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),d(t,"keydown",c);const a=k(n=>{if(N(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(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,r=o?.getAttribute("data-easel-block"),i=r?e.locate(r):null;n.preventDefault();const c=p(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(t,"mousedown",r),d(t,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:o?/* @__PURE__ */A(G,{host:e,target:o,onClose:r}):null,closeMenu:r}}function G({host:e,target:n,onClose:t}){const o="node"===n.kind?E(e,n):"input"===n.kind?R(e,n.el):B(e);return 0===o.length?null:/* @__PURE__ */A(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),items:r(o)})}export{Y as EASEL_NODE_CLIPBOARD,T as ancestorChain,D as nodeClipboardOf,M as nodeClipboardRules,E as nodeMenuItems,S as nodeShortcut,B as pageMenuItems,X as pastePlace,L as runNodeShortcut,R as textMenuItems,I as useNodeClipboard,F as useNodeContextMenu};
@@ -1,21 +0,0 @@
1
- import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{noControlMetaOf as t,deviceMetaOf as l}from"./chunk-YCSZAP7T.js";import{TreeSeam as r}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as a}from"./chunk-K56YDHYQ.js";import{easelMenuEntries as o}from"./chunk-FIVU2COQ.js";import{SETTINGS_BUCKETS as i,SettingsGroup as s}from"./chunk-FM6JO4WF.js";import{DEFAULT_PANEL_WORDS as c}from"./chunk-KFV7N2DJ.js";import{FieldNumber as d}from"./chunk-Y2T3JX7K.js";import{FieldSelect as u}from"./chunk-KFWNGPW3.js";import{DEFAULT_FIELDS_WORDS as m}from"./chunk-JACEEVVF.js";import{SettingsField as h,SettingsSegmented as p}from"./chunk-CZAAGBVL.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{useTreeDrag as b,gapToMoveIndex as g}from"./chunk-6NJHYXJM.js";import{withTip as v}from"./chunk-P2VEMZH5.js";import{Textarea as y,Input as k,ItemCount as x,SortableList as w,ListRow as C,ContextMenu as N,tabPanelId as O,Tabs as j,tabButtonId as $}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as S,useState as I,useLayoutEffect as D,useId as F}from"react";import{jsx as P,jsxs as L}from"react/jsx-runtime";import{ChevronIcon as E,LockIcon as M,MoveUpIcon as A,MoveDownIcon as T,DuplicateIcon as W,TrashIcon as z}from"efficient-shell/icons/efficient";function R({id:e,value:n,onChange:t,placeholder:l,multiline:r=!1,rows:a=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return r?/* @__PURE__ */P(y,{id:e,size:"sm",className:"es-fin",value:c,rows:a,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */P(k,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function H(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function J(e,n,t){const l=e.slice(),[r]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,r),l}function V(e,n){return e.filter((e,t)=>t!==n)}function Y(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var K='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function Z({label:e,icon:n,noun:t,items:l,onChange:i,newItem:s,summary:c,itemName:d,thumb:u,min:h=0,max:p,readOnly:y=!1,open:k,onOpen:O,renderItem:j,renderRow:$,canRemove:F,lockedReason:R,fixed:Z=!1,removeOnRow:X=!0,canDuplicate:G,above:Q,head:q=!0}){const U=f("fields",m).list,_=f("tree",a),ee=t??U.item,ne=!y&&!Z&&("number"!=typeof p||l.length<p),te=l.length<=h,le=e=>!!F&&!F(l[e],e),re=e=>!y&&!Z&&X&&!te&&!le(e),ae=e=>ne&&(!G||G(l[e],e)),oe=(e,n)=>d?d(e,n):U.itemName({noun:ee,n:n+1}),ie=S([]),se=S(null),[ce,de]=I(null),ue=S(null),[me,he]=I(null),[pe,fe]=I("");D(()=>{const e=se.current;if(!e)return;se.current=null;const n=ie.current[e.index]?.querySelectorAll(K)[e.nth]??ie.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const be=(e,n)=>{if(n<0||n>=l.length||n===e)return;const t=ie.current[e],r=t?.ownerDocument.activeElement;if(t&&r&&t.contains(r)){const e=[...t.querySelectorAll(K)].indexOf(r),l=r;se.current={index:n,nth:e,start:"number"==typeof l.selectionStart?l.selectionStart:null,end:"number"==typeof l.selectionEnd?l.selectionEnd:null}}i(J(l,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(k,e,n);a!==k&&O(a),fe(U.moved({n:n+1,total:l.length}))},ge=e=>{ne&&(i(H(l,e,s())),$?(se.current={index:e,nth:0,start:null,end:null},null!==k&&k>=e&&O(k+1)):O(e))},ve=e=>{re(e)&&(i(V(l,e)),k===e?O(null):null!==k&&k>e&&O(k-1))},ye=b({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=g({...B,index:e},n);t!==e&&be(e,t)},onStep:(e,n)=>be(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<l.length,readOnly:y}),ke=e=>{const n=[];return e>0&&n.push({label:U.moveUp,icon:/* @__PURE__ */P(A,{size:14}),shortcut:"⌥↑",onClick:()=>be(e,e-1)}),e<l.length-1&&n.push({label:U.moveDown,icon:/* @__PURE__ */P(T,{size:14}),shortcut:"⌥↓",onClick:()=>be(e,e+1)}),ae(e)&&n.push({label:U.duplicate,icon:/* @__PURE__ */P(W,{size:14}),onClick:()=>(e=>{ae(e)&&(i(H(l,e+1,Y(l[e]))),null!==k&&k>e&&O(k+1))})(e)}),re(e)&&n.push({label:U.delete,icon:/* @__PURE__ */P(z,{size:14}),danger:!0,onClick:()=>ve(e)}),n},xe=(e,n,t,l)=>{y||0===ke(e).length||he({index:e,x:n,y:t,owner:l})},we=e=>n=>{const t=l.slice();t[e]=n,i(t)};/* @__PURE__ */
2
- return L("div",{className:"es-list",children:[q?/* @__PURE__ */L("div",{className:"es-list-head",children:[
3
- /* @__PURE__ */L("span",{className:"es-list-label",children:[n?/* @__PURE__ */P("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
4
- /* @__PURE__ */P(x,{count:l.length,label:U.count({noun:ee,n:l.length}),showZero:!0})]}):null,Q?/* @__PURE__ */P("div",{className:"es-list-above",children:Q}):null,l.length?/* @__PURE__ */L(w,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ye.rootProps(),children:[l.map((e,n)=>{const t=ye.row({item:n,place:{...B,index:n}}),l=t.draggable&&ce!==n,a=!$&&k===n,o=!y&&!Z&&X&&le(n),i=["es-list-row",$?"is-inline":"is-item",a?"is-open":"",l?"is-draggable":"",t.dragging?"is-dragging":"",t.drop?`is-drop-${t.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */P(r,{...ye.seam({place:{...B,index:n}}),onAdd:ne?()=>ge(n):void 0,label:U.addHere({noun:ee})},`seam-${n}`):null,
5
- /* @__PURE__ */P(C,{className:i,flat:!!$,active:a,draggable:t.draggable,dragHint:_.dragHint,dragging:t.dragging,drop:"before"===t.drop||"after"===t.drop?t.drop:void 0,onMove:t.draggable?e=>be(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{ie.current[n]=e},rowProps:{...t.rowProps,draggable:l||void 0,onPointerDown:e=>{const l=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),r=!!l&&l===l.ownerDocument.activeElement;e.currentTarget.draggable=t.draggable&&!r,ue.current=l&&!r?l:null,de(r?n:null)},onDragStart:e=>{const n=ue.current;ue.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),t.rowProps.onDragStart?.(e)},onContextMenu:e=>{y||(e.preventDefault(),e.stopPropagation(),xe(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const r=e.currentTarget.getBoundingClientRect();return void xe(n,r.left+24,r.bottom,e.currentTarget)}t.rowProps.onKeyDown?.(e)}},actions:y||Z||!X?void 0:o?v(R?R(e,n):U.locked,/* @__PURE__ */P("span",{className:"es-list-lock",role:"img","aria-label":R?R(e,n):U.locked,children:/* @__PURE__ */P(M,{size:13})})):v(U.deleteItem({noun:ee}),/* @__PURE__ */P("button",{type:"button",className:"es-list-x","aria-label":U.deleteItem({noun:ee}),disabled:!re(n),onClick:()=>ve(n),children:"×"})),below:a?/* @__PURE__ */P("div",{className:"es-list-item",children:j(e,n,we(n))}):void 0,children:$?/* @__PURE__ */P("div",{className:"es-list-row-main",children:$(e,n,we(n))}):/* @__PURE__ */L("button",{type:"button",className:"es-list-open","aria-expanded":a,onClick:()=>O(a?null:n),children:[u?/* @__PURE__ */P("span",{className:"es-list-thumb","aria-hidden":"true",children:u(e,n)}):null,
6
- /* @__PURE__ */P("span",{className:"es-list-row-name",children:oe(e,n)}),/* @__PURE__ */P("span",c?{className:"es-list-row-summary",children:c(e,n)}:{className:"es-list-row-summary"}),
7
- /* @__PURE__ */P(E,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},n)]}),
8
- /* @__PURE__ */P(r,{...ye.seam({place:{...B,index:l.length}})})]}):null,y||Z?null:/* @__PURE__ */P("button",{type:"button",className:"es-list-add",disabled:!ne,onClick:()=>ge(l.length),children:U.add({noun:ee})}),
9
- /* @__PURE__ */P("span",{className:"es-list-said","aria-live":"polite",children:pe}),me&&me.index<l.length?
10
- /* @__PURE__ */P(N,{at:{x:me.x,y:me.y},owner:me.owner,onClose:()=>he(null),items:o(ke(me.index))}):null]})}var X=e=>e<6?e+1:6,G=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function Q({field:e,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=I(!0),p=r&&"object"==typeof r?r:{};/* @__PURE__ */
11
- return P(s,{id:`${l}-group`,title:G(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */P(U,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>a({...p,[e]:n}),readOnly:o,context:i,showWhenContext:c,renderers:d,headingLevel:X(u)},e))})}function q({field:e,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=I(null),f=u?d??null:h,b=u??p,g=Array.isArray(r)?r:[],v=e.getItemSummary;/* @__PURE__ */
12
- return P(Z,{label:G(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:a,newItem:()=>Y({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(r,a,d)=>Object.entries(n(e.arrayFields,{values:r,context:s})).map(([e,n])=>/* @__PURE__ */P(U,{field:n,name:`${t}[${a}].${e}`,id:`${l}-${a}-${e}`,value:r?.[e],onChange:n=>d({...r,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function U(e){const{field:n,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,renderers:s}=e;if(!n||n.marker||!1===n.visible)return null;const c=s?.[n.type];if(c)return c({field:n,name:t,id:l,value:r,onChange:a,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:r,onChange:a,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
- return P(h,{label:G(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(R,{id:l,value:"string"==typeof r?r:null==r?"":String(r),onChange:a,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
14
- return P(h,{label:G(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(d,{id:l,value:"number"==typeof r?r:void 0,onChange:a,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
15
- return P(h,{label:G(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(u,{id:l,value:r,options:n.options,onChange:a,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
- return P(h,{label:G(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(p,{ariaLabel:G(n,t),value:r,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||a(e)}})});case"object":/* @__PURE__ */
17
- return P(Q,{...e,field:n});case"array":/* @__PURE__ */
18
- return P(q,{...e,field:n});case"slot":return null}}function _(e,n){if("mobile"!==n)return!0;const r=e;if(!r||r.marker||"slot"===r.type||"always"===t(e))return!0;const a=l(e)?.tier;return"mobile"===a||"each"===a}var ee={},ne=e=>i.includes(e);function te(n,t){let l,r=i[0];const a=[],o=/* @__PURE__ */new Set;for(const[i,s]of Object.entries(n))s&&(ne(s.bucket)&&((s.marker||s.bucket!==r)&&(l=void 0),r=s.bucket),s.marker&&"string"==typeof s.fold?l={key:i,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||t&&!_(s,t.context?.device)||(a.push(l?{name:i,field:s,bucket:r,fold:l}:{name:i,field:s,bucket:r}),"slot"!==s.type&&o.add(r)));return{rows:a,buckets:i.filter(e=>o.has(e))}}function le(e){return new Map(te(e).rows.map(e=>[e.name,e.bucket]))}function re(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ae({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,showWhenContext:a,tab:o,onTab:i,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:h,ariaLabel:p,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const w=f("panel",c),C=F(),N=h??`es-insp${C.replace(/:/g,"")}`,S=te(e,{values:n,context:a}),[D,E]=I(void 0),M=o??D,A=M&&S.buckets.includes(M)?M:S.buckets[0],[T,W]=I(null),z=T&&T.panel===N&&S.rows.some(e=>e.name===T.name)?T:null,R=d&&S.buckets.length>1,H=R&&A?O(N,A):`${N}-rows`,[J,V]=I(()=>/* @__PURE__ */new Set),Y=y??J,K=(e,n)=>{/* @__PURE__ */return P(s,{title:e.title,open:!Y.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&V(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${N}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},B=e=>R&&e!==A,Z=({name:e,field:o,bucket:i,fold:s})=>/* @__PURE__ */P("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!B(i)||void 0,children:/* @__PURE__ */P(U,{field:o,name:e,id:`${N}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,showWhenContext:a,renderers:m,openItem:z&&z.name===e?z.index:null,onOpenItem:n=>W(null===n?null:{panel:N,name:e,index:n}),headingLevel:s?X(x):x})},e);/* @__PURE__ */
19
- return L("div",{className:"es-insp",children:[R?/* @__PURE__ */P("div",{className:"es-insp-tabs",children:/* @__PURE__ */P(j,{variant:"underline",block:!0,"aria-label":p??w.settings,idPrefix:N,value:A,onChange:e=>{const n=e;void 0===o&&E(n),i?.(n)},items:S.buckets.map(e=>{const n=w.buckets[e],t=u?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */P("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
- /* @__PURE__ */L("div",{className:"es-insp-rows",id:H,role:R?"tabpanel":void 0,"aria-labelledby":R&&A?$(N,A):void 0,children:[b&&_(ee,a?.device)?v?/* @__PURE__ */P("div",{className:"es-insp-band","data-fold":v.key,children:K(v,b)}):b:null,re(S.rows).map((e,n)=>{if(!e.fold)return e.rows.map(Z);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
- return P("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!B(t)&&!l)||void 0,children:K(e.fold,e.rows.map(Z))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{R as FieldText,ae as Inspector,U as InspectorField,Z as ListField,le as bucketsOf,Y as copyItem,_ as fieldShownInView,H as insertAt,G as labelOf,J as moveTo,te as planFields,V as removeAt};
@@ -1,2 +0,0 @@
1
- import{routeSharedHostMessage as e}from"./chunk-ISS72IKO.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-CLOS6SSX.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-IYHO4XQX.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 S,CLAIM_FAIL_OPEN_MS as b,holderOf as I}from"./chunk-THWO5YVZ.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as B,useMemo as C,useCallback as E,useEffect as H,useRef as O}from"react";import{jsx as T}from"react/jsx-runtime";var N={content:[],root:{},zones:{}};var A=j(null);function M(){const e=R(A);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function L({target:j,addressing:R=o,onHostMessage:M,children:L}){const Y=R,{homeSlug:D,entryMayBounce:F,entryBounce:V,onSwitch:X,tellsHost:W,adapterFor:K,migrateRenamedProps:U,describeMissing:Z,onLoadFailed:x}=Y,[G,Q]=B(j),z=k(),_=d(),q=C(()=>f(_),[_]),J=C(()=>t(_),[_]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??D??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=_.blocks,oe=C(()=>K(G,q,te),[K,q,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=E(e=>_.documentHooks?.stored?.(e)??e,[_]);H(()=>{m(_,ne)},[_,ne]);const se=O(G);H(()=>{se.current=G},[G]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(M?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Br(e.target)}}}),de=!_.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(q.lock),[ke,ve]=B(null),[ge,pe]=B(null),[he,ye]=B(null),[we,Se]=B(null),be=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,be):null,[Pe,je]=B(null),Re=O(null),Be=O(null),[Ce,Ee]=B(!1),He=O(null),[Oe,Te]=B(null),Ne=O(null),[Ae,Me]=B(null),[Le,Ye]=B(!1),De=O(null);H(()=>{De.current=Ae},[Ae]);const[Fe,Ve]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Xe=O(Fe);H(()=>{Xe.current=Fe},[Fe]);const We=O(()=>Promise.resolve(!1)),Ke=E(e=>{Be.current=e,Ee(!0)},[]),Ue=g({save:async({id:e,data:r})=>{if(p(Xe.current)){if(!await We.current(e,r)){if(!p(Xe.current))return void Ke({id:e,data:r});throw new Error("page save did not land")}}else Ke({id:e,data:r})},onFailure:(e,r)=>{0===r&&z.send("storefront-editor:save-failed")}}),{state:Ze,push:xe,flush:Ge,pause:Qe,resume:ze,stop:_e,reset:qe,retryNow:Je,hasPending:$e}=Ue,er=O(Ze);H(()=>{er.current=Ze},[Ze]);const rr=u(Ze),nr=E(()=>{const e=Be.current;e&&(Be.current=null,Ee(!1),xe(e))},[xe]),tr=O("");tr.current||(tr.current=h());const[or,ur]=B(0),ar=O(!1),[sr,ir]=B(F(j)),lr=O(!1);H(()=>{if(lr.current)return;lr.current=!0;const e=z.address.search(),r=V(j,e);r?z.address.load(r):F(j)&&ir(!1)},[j,z]);const cr=z.send;H(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=_.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==D&&re!==D?void z.address.load({kind:"page",slug:D,siteId:ne??void 0}):(Se({target:t,slug:re,missing:!0,sentence:Z?.(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),Ne.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:N,s=U(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),Se({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},_),cause:r(o,_)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=E(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=E(async e=>{const r=le.current;if(!r&&_.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,_)){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,_]),mr=E(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=E(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Xe.current))return!1;if(De.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,Ne.current,tr.current));if(t.ok)return Ne.current=t.value.version??Ne.current,Ye(!1),!0;const o=J.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Xe.current=e,Ve(e),!1}const u=J.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Ne.current=n.value,We.current(e,r,!0)}_e(),De.current=u,Me(u)}return Ye(i(t.error,_)?.status===c),!1},[oe,fr,_e,_]);H(()=>{We.current=kr},[kr]);const vr=E(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);He.current=r,p(Xe.current)?xe({id:ke,data:r}):Ke({id:ke,data:r})},[ke,cr,Ke,xe,ae]),gr=E(async()=>{p(Xe.current)&&nr();return await Ge()&&null==Be.current},[nr,Ge]),pr=O(gr);H(()=>{pr.current=gr},[gr]);const hr=O(fr);H(()=>{hr.current=fr},[fr]);const yr=E(()=>{z.address.reload()},[z]),wr=O(()=>Promise.resolve(!1));H(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Ne.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Be.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const Sr=null!==Pe;H(()=>{if(!fe||!ke||!de||Sr)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:()=>Xe.current,heldWrite:()=>({pending:null!=Be.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=De.current}),setAccess:e=>{Xe.current=e,Ve(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=J.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(Ve({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),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,Sr]);const br=E(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=E(()=>{Ve(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=E(()=>{er.current.paused?(p(Xe.current)&&nr(),ze()):Qe()},[nr,Qe,ze]),jr=E(()=>{Je()},[Je]),Rr=E(e=>{He.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{qe(),Be.current=null,Ee(!1)},setVersion:e=>{Ne.current=e},setSaveConflict:Me,setAccess:Ve}),X(e),Q(e),Re.current=null,je(null),ve(null),pe(null),ye(null),Se(null),z.address.show(e),"document"!==e.kind&&W(e)&&z.send("storefront-editor:navigated",{target:e})},[qe,z,me,X,W]),Br=E(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,D))return;const r=null!=Be.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?Te(e):Ge().then(r=>{r?Rr(e):Te(e)})},[Rr,$e,Ge,D]),Cr=E(()=>Te(null),[]),Er=E(()=>{Te(e=>(e&&Rr(e),null))},[Rr]),Hr=E(async()=>{const e=Oe;if(!e)return;await gr()&&(Te(null),Rr(e))},[Oe,gr,Rr]),Or=E(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Xe.current)||De.current)return;const r=ae(e);if(!await kr(ke,r))return void(De.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,Ne.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})}Ne.current=t.value.version??Ne.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
2
- return T(A.Provider,{value:{target:G,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:()=>He.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Ze,autoSaveEnabled:!Ze.paused,autoSaveStoppedByConflict:Ze.stopped,hasUnsavedEdits:Ze.pending||Ce,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Or,access:Fe,readOnly:null!==I(Fe)||null!==Pe||null!==Ae,readOnlyReason:Pe,takeOverEditing:br,viewReadOnly:Ir,saveConflict:Ae,saveUnreachable:Le,reloadFromServer:yr,navigate:Br,pendingNav:Oe,cancelPendingNav:Cr,discardAndNavigate:Er,saveAndNavigate:Hr},children:L})}export{A as ScreenDocumentContext,L as ScreenDocumentProvider,M as useScreenDocument};