efficient-easel 14.2.0 → 16.0.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 (82) hide show
  1. package/README.md +5 -4
  2. package/dist/{CanvasDragLayer-CLb7j-CZ.d.ts → CanvasDragLayer-dZCPbQCP.d.ts} +1 -1
  3. package/dist/canvas/index.d.ts +21 -1
  4. package/dist/canvas/index.js +1 -1
  5. package/dist/{chunk-NY7HHUGB.js → chunk-23VM4PMV.js} +2 -2
  6. package/dist/{chunk-44QA42OJ.js → chunk-63ZDVAVE.js} +1 -1
  7. package/dist/chunk-BALFHI3G.js +2 -0
  8. package/dist/{chunk-CMXK3JT3.js → chunk-GGC72GS4.js} +1 -1
  9. package/dist/{chunk-CY52PUMZ.js → chunk-HM7S7H5H.js} +1 -1
  10. package/dist/{chunk-XGW6NWLC.js → chunk-JD5HXBEX.js} +1 -1
  11. package/dist/{chunk-AYWN5NRH.js → chunk-KAML3KQH.js} +1 -1
  12. package/dist/{chunk-YKJ3RIMT.js → chunk-KFPCMMRK.js} +1 -1
  13. package/dist/chunk-N2B32EZB.js +5 -0
  14. package/dist/{chunk-TR4APEJZ.js → chunk-N2BVA6TS.js} +1 -1
  15. package/dist/chunk-N3LYD2LK.js +21 -0
  16. package/dist/chunk-OFBZOI6W.js +1 -0
  17. package/dist/{chunk-F3A7SXSV.js → chunk-OK7OH2ZN.js} +1 -1
  18. package/dist/{chunk-35VMTYPH.js → chunk-P3XVBLZ6.js} +4 -4
  19. package/dist/chunk-POSLNRTO.js +18 -0
  20. package/dist/chunk-PQRYAW2G.js +5 -0
  21. package/dist/chunk-RQBIFINA.js +57 -0
  22. package/dist/chunk-SMM3ST7A.js +13 -0
  23. package/dist/chunk-U6LJ5UKD.js +6 -0
  24. package/dist/chunk-UVQR7W6I.js +1 -0
  25. package/dist/chunk-WXFZD7WC.js +1 -0
  26. package/dist/chunk-X4T6JT3M.js +1 -0
  27. package/dist/copy/copy.css +9 -9
  28. package/dist/copy/index.d.ts +2 -29
  29. package/dist/copy/index.js +12 -13
  30. package/dist/drag/drag.css +22 -0
  31. package/dist/drag/index.d.ts +2 -2
  32. package/dist/drag/index.js +1 -1
  33. package/dist/easel/easel.css +26 -0
  34. package/dist/easel/index.js +1 -1
  35. package/dist/fields/index.js +1 -1
  36. package/dist/menu/index.d.ts +22 -27
  37. package/dist/menu/index.js +1 -1
  38. package/dist/menu/menu.css +7 -6
  39. package/dist/pick/index.d.ts +5 -70
  40. package/dist/pick/index.js +1 -3
  41. package/dist/pick/pick.css +1 -21
  42. package/dist/screen/components/AddBlockRow.js +1 -1
  43. package/dist/screen/components/AddSidePanel.js +1 -1
  44. package/dist/screen/components/MediaSidePanel.js +1 -1
  45. package/dist/screen/components/NodeContextMenu.d.ts +3 -3
  46. package/dist/screen/components/NodeContextMenu.js +1 -1
  47. package/dist/screen/components/SaveControls.d.ts +2 -2
  48. package/dist/screen/components/ScreenChrome.js +1 -1
  49. package/dist/screen/components/ScreenMount.d.ts +2 -2
  50. package/dist/screen/components/ScreenMount.js +1 -1
  51. package/dist/screen/components/ScreenStoreProvider.d.ts +2 -2
  52. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  53. package/dist/screen/components/SectionScreenShell.js +15 -15
  54. package/dist/screen/components/usePartBridge.d.ts +2 -2
  55. package/dist/screen/components/usePartBridge.js +1 -1
  56. package/dist/screen/index.d.ts +2 -2
  57. package/dist/screen/index.js +1 -1
  58. package/dist/screen/lib/key-scope.js +1 -1
  59. package/dist/screen/lib/puck/style-clipboard.d.ts +2 -2
  60. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  61. package/dist/screen/lib/screen-parts.d.ts +2 -2
  62. package/dist/screen/lib/screen-parts.js +1 -1
  63. package/dist/strings/catalogue.d.ts +2 -2
  64. package/dist/strings/catalogue.js +1 -1
  65. package/dist/strings/index.d.ts +2 -2
  66. package/dist/strings/index.js +1 -1
  67. package/dist/text-styles/index.js +36 -36
  68. package/dist/{words-BDignMl_.d.ts → words-CvwYvkJm.d.ts} +2 -0
  69. package/dist/{words-is_Vy6hn.d.ts → words-DWvCJXwR.d.ts} +2 -37
  70. package/package.json +3 -3
  71. package/dist/chunk-5XUMLKQF.js +0 -6
  72. package/dist/chunk-643PVCEG.js +0 -1
  73. package/dist/chunk-BXMXTO36.js +0 -1
  74. package/dist/chunk-CSGTPJTY.js +0 -5
  75. package/dist/chunk-D46OYLJR.js +0 -5
  76. package/dist/chunk-EA2HTX37.js +0 -5
  77. package/dist/chunk-ILXP5VX5.js +0 -1
  78. package/dist/chunk-LPM2SCM4.js +0 -13
  79. package/dist/chunk-NW4LJ4G4.js +0 -1
  80. package/dist/chunk-QFVRMARS.js +0 -18
  81. package/dist/chunk-SO5OLDH7.js +0 -21
  82. package/dist/chunk-XUAKHY4T.js +0 -57
@@ -0,0 +1,57 @@
1
+ import{styleClipboardOf as e}from"./chunk-XT6DOSHO.js";import{markedTreeNodeId as n,revealSelectedTreeRow as t,sameSelector as o}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as r}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as i}from"./chunk-26OOWIJJ.js";import{ScreenSaveIcon as l,ScreenMainButton as s}from"./chunk-RSKHAHPJ.js";import{useBrowserOffline as d}from"./chunk-RKTF5XLP.js";import{scrollPreviewToSection as c,gotoPreviewSlide as a,scrollPreviewToTop as p}from"./chunk-3Z2MVLCD.js";import{useEaselKeyTarget as u,useEaselUndoKeys as f,useEaselSaveKey as h,editorRootFocus as m}from"./chunk-HM7S7H5H.js";import{SlotChildActionsProvider as g}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as y,DEFAULT_PANEL_W as S,clampPanelWidth as k}from"./chunk-TZIIRGVY.js";import{usePartBridge as v}from"./chunk-GGC72GS4.js";import{useSectionOps as b}from"./chunk-N2BVA6TS.js";import{AddChildRow as w}from"./chunk-5545A3PC.js";import{AddSidePanel as x}from"./chunk-N2B32EZB.js";import{SidePanelHead as z,PanelShowStrip as C}from"./chunk-62VPYC7F.js";import{MediaSidePanel as B}from"./chunk-63ZDVAVE.js";import{useScreenSaveSwitch as I,useScreenNodeKeys as O,useScreenPinned as N,useScreenDocumentLabel as P,useScreenCanvasFrame as $,useScreenInspectorPanel as M,useScreenDevices as T,useScreenPickFollowsSelection as A,useScreenLeftView as j,SELECTION_MODE as L,sameInspectorMode as R,useScreenBridges as E,useScreenBlockRules as V,useScreenBlockLook as H,useScreenStorageNamespace as F,useScreenNotify as W,useScreenCanvasHead as D,isSlotMode as G,useScreenStyleClipboard as J,useScreenDocumentPass as U,useScreenCanvasDrag as Y,ScreenCanvasTargetProvider as K,isPinnedFirst as Z,isPinnedLast as X,screenSlotsOf as q}from"./chunk-PQRYAW2G.js";import{useNodeClipboard as _,useNodeContextMenu as Q}from"./chunk-UVQR7W6I.js";import{PageEditGuardNotices as ee}from"./chunk-2H3W5OLQ.js";import{useScreenDocument as ne}from"./chunk-ZZ64CEC2.js";import{requestMediaPick as te}from"./chunk-KG7RJWOK.js";import{useMediaPanel as oe,usePanelPick as re,useCancelPanelPick as ie}from"./chunk-R6WTQWAC.js";import{useEaselSession as le}from"./chunk-O7Q4DDJT.js";import{useEaselHost as se,useHostEscape as de}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as ce}from"./chunk-VVPZMWJE.js";import{heldStyle as ae,styleShortcut as pe}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as ue}from"./chunk-6WY6ZXJG.js";import{DEFAULT_NODE_MENU_WORDS as fe}from"./chunk-WK3AFPXY.js";import{rootRowName as he,slotChildRowName as me,slotChildRenameProp as ge,sectionRenameProp as ye}from"./chunk-TBF5CVPA.js";import{ROOT_ZONE as Se,blockNodeActions as ke,TREE_MAX_DEPTH as ve,childSlotsOf as be,slotFieldsOf as we,slotChildrenIn as xe,nestsInTree as ze,newNodeId as Ce}from"./chunk-PLVEGYK6.js";import{useEasel as Be,useEaselApi as Ie,CanvasPassThroughContext as Oe}from"./chunk-SMM3ST7A.js";import{toItemSelector as Ne,useNodeOps as Pe,clickPick as $e}from"./chunk-ECM5F6JJ.js";import{TreeRow as Me,Subtree as Te,LayersTree as Ae,TreeGroupLabel as je,TreeRowAction as Le,TreeSeam as Re}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Ee}from"./chunk-K56YDHYQ.js";import{LayersIcon as Ve,MediaIcon as He}from"./chunk-4VJATVVR.js";import{EaselTopBar as Fe,TopBarRail as We,TopBarCluster as De,EaselIconButton as Ge,TopBarDivider as Je,DeviceSwitch as Ue,InspectorIconButton as Ye,PanelResizeHandle as Ke,MAX_PANEL_W as Ze,MIN_PANEL_W as Xe,panelWidthVars as qe}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as _e,DEFAULT_CHROME_WORDS as Qe}from"./chunk-Z6PVRXVY.js";import{holderOf as en,nameOrSomeone as nn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as tn}from"./chunk-RE4LP46F.js";import{useWords as on}from"./chunk-MFIRYGHW.js";import{insertSeams as rn,CanvasDragLayer as ln,CanvasInsert as sn}from"./chunk-POSLNRTO.js";import{DEFAULT_DRAG_WORDS as dn}from"./chunk-KAML3KQH.js";import{createDragSession as cn,useTreeDrag as an,gapToMoveIndex as pn}from"./chunk-67GNT6PF.js";import{useCanvasFrame as un,LIST_SELECTOR as fn,BLOCK_SELECTOR as hn,useCanvasTyping as mn,useCanvasEvent as gn,nodeIdAt as yn,frameRectToHost as Sn,BLOCK_ATTRIBUTE as kn,drawnBox as vn}from"./chunk-X4T6JT3M.js";import{ROOT_ID as bn,ROOT_SLOT as wn,zoneKey as xn,parseZoneKey as zn,find as Cn,DataError as Bn}from"./chunk-KRXQM65X.js";import{useRef as In,useMemo as On,useState as Nn,useEffect as Pn,useCallback as $n,useLayoutEffect as Mn,Fragment as Tn}from"react";import{ColoredBadge as An,toast as jn,groupColors as Ln}from"efficient-shell/ui";import{UndoIcon as Rn,RedoIcon as En,RefreshIcon as Vn,AddIcon as Hn,TrashIcon as Fn,EyeOffIcon as Wn,EyeIcon as Dn,DuplicateIcon as Gn}from"efficient-shell/icons/efficient";import{jsx as Jn,jsxs as Un,Fragment as Yn}from"react/jsx-runtime";var Kn=/* @__PURE__ */new WeakSet;function Zn(e,n,t){const o=Cn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Xn({canvas:e,tabs:n,onSelect:t}){const o=In(null),[r,i]=Nn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Mn(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=Sn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${kn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?vn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=Sn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Jn("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Jn("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Jn(An,{colorClass:Ln("info","solid"),size:"sm",children:e.label})},e.id):null})})}function qn({expand:e}){/* @__PURE__ */
2
+ return Jn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Un(Yn,e?{children:[
3
+ /* @__PURE__ */Jn("path",{d:"M8 9l4-4 4 4"}),
4
+ /* @__PURE__ */Jn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
5
+ /* @__PURE__ */Jn("path",{d:"M8 4l4 4 4-4"}),
6
+ /* @__PURE__ */Jn("path",{d:"M8 20l4-4 4 4"}),
7
+ /* @__PURE__ */Jn("path",{d:"M5 12h14"})]})})}var _n=`${fn}, ${hn}`;function Qn(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var et="__rungs";var nt="screen:band",tt={duplicate:!0,delete:!0};function ot(){const fn=se(),{target:Sn,docId:kn,capabilities:vn,currentSlug:Ln,siteId:ot,onPublish:rt,saveState:it,saveConflict:lt,retrySave:st,toggleAutoSave:dt,flushSave:ct,access:at,saveUnreachable:pt=!1,readOnly:ut,readOnlyReason:ft=null}=ne(),ht=I(),mt=O(),{mediaEditing:gt,hasEditGuard:yt,hasPinnedChrome:St}=vn,{appState:kt,dispatch:vt,history:bt,selectedItem:wt,getSelectorForId:xt,config:zt}=Be(e=>e),Ct=N(),{first:Bt,firstGroup:It,lastGroup:Ot,isSectionGroup:Nt,sectionGroupZone:Pt,panelOf:$t}=Ct,Mt=$t(Bt),Tt=e=>Z(Ct,e),At=e=>X(Ct,e),jt="node"===Ct.firstRow,Lt=Ct.band??null,Rt=on("screen",ce),Et=on("tree",Ee),Vt=on("drag",dn),Ht=on("notice",_e),Ft=on("lock",tn),Wt=on("menu",fe),Dt=on("styleClipboard",ue),Gt=on("chrome",Qe),Jt=P()??`/${Ln}`,Ut=$(),Yt=M(),Kt=b({readOnly:ut}),Zt=b({readOnly:ut,foldIntoHistory:!0}),Xt=In(null),qt=Ie(),_t=On(()=>({...Kt,select:e=>{Xt.current=e,Kt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=qt.config;Xt.current=Ne(e,t,n)}Kt.commitDocument(e,n)}}),[Kt,qt]),Qt=kt.ui,eo=Qt.leftSideBarVisible,no=Qt.rightSideBarVisible,{options:to,widths:oo,initial:ro,fluid:io,fit:lo}=T(),[so,co]=Nn(ro),ao=oe(),po=gt&&null!==ao,uo=re(),fo=ie();A(wt?.props.id);const{read:ho,write:mo,forSelection:go}=j(),[yo,So]=Nn(ho);Pn(()=>{mo(yo)},[yo]);const[ko,vo]=Nn(0),bo=In(null),wo=In(null),xo=un(wo,{readySelector:_n}),zo=mn(xo),Co=u(wo);f(wo,xo);const Bo=d(),Io=en(at),Oo={state:it,offline:Bo||it.failed&&pt,readOnlyReason:ft,editing:Io?Ht.editing({name:nn(Io.name,Ft),noun:Rt.noun}):null,conflict:null!=lt,notSaving:Rt.bar.notSaving},No=()=>{ut||(it.failed?st():ct())};h(wo,xo,No);const[Po,$o]=Nn(!1),Mo=In(!1),To=In(!1),[Ao,jo]=Nn(null),[Lo,Ro]=Nn([]),[Eo,Vo]=Nn(L),Ho="puck"===Eo.kind,Fo=n(Eo,wt?.props.id),[Wo,Do]=Nn(null);Pn(()=>{Wo&&(t(),Do(null))},[Wo]);const Go=In(xt);Go.current=xt;const Jo=$n((e,{scroll:n})=>{So(n=>go(e,n)),n&&Do(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Go.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&br(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Uo=In(null);Pn(()=>{const e=Uo.current;Uo.current=null;const n=null==wt?.props.id?null:String(wt.props.id);Vo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:$t(wt?.type)??L);const t=wt?.props.id,r=Xt.current;if(Xt.current=null,!t)return;const i=xt(t);Jo(String(t),{scroll:!o(r,i??null,Se)})},[wt?.props.id,Jo]);const Yo=$n(e=>{Vo(n=>R(n,e)?n:e),vt({type:"setUi",ui:{rightSideBarVisible:!0}})},[vt]),Ko=In(()=>{});Ko.current=(e,n)=>{const t=e?hi(e.zone??Se)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==wt?.props.id?null:String(wt.props.id);Vo(e=>R(e,n)?e:n),o!==r&&(Uo.current={id:o,mode:n},_t.select(e))};const Zo=$n((e,n)=>Ko.current(e,n),[]),Xo={kind:Eo.kind,mode:Eo,open:Yo,show:e=>Vo(e),reveal:()=>{no||vt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Zo},qo=E(Xo,{data:kt.data,selected:wt??null,zoneOf:e=>xt(e)?.zone,readOnly:Boolean(ut),select:e=>{Vo(L),_t.select({index:e})},replace:(e,n)=>_t.replaceComponent(Se,e,n),scrollTo:e=>Vi(e)},{device:so,refreshes:ko},{setView:So,reveal:()=>{eo||vt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),_o=qo.pinnedSource??!1,Qo=qo.resolveLeftView?qo.resolveLeftView(yo,po):"media"===yo&&po?yo:"sections",er=V(),{isLockedBlock:nr,duplicateBlocked:tr,nestDepth:or,newSectionNode:rr,canAddTo:ir,blockIsOffered:lr}=er,sr=H(),{labelAtLevel:dr,Icon:cr,useProducts:ar}=sr,pr=sr.rowName?(e,n,t)=>sr.rowName(e,n,t):void 0,ur=$n(e=>{vt({type:"setUi",ui:{rightSideBarVisible:!0}}),c(e),Jo(e,{scroll:!0})},[vt,Jo]),{selectNode:fr,openPartId:hr}=v({mode:Eo,setMode:Vo,onOpenPart:ur}),[mr,gr]=Nn(null);de(null!==mr,()=>gr(null));const yr=y(F()),Sr=yr.collapsed,kr=yr.panelWidths,[vr,br]=Nn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(Sr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
8
+ return new Set}});Pn(()=>{try{window.localStorage.setItem(Sr,JSON.stringify([...vr]))}catch{}},[vr]);const[wr,xr]=Nn(()=>{if("undefined"==typeof window)return{...S};try{const e=window.localStorage.getItem(kr);if(!e)return{...S};const n=JSON.parse(e);return{left:k(Number(n.left)||S.left),right:k(Number(n.right)||S.right)}}catch{return{...S}}});Pn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(kr,JSON.stringify(wr))}catch{}},300);return()=>clearTimeout(e)},[wr]);const zr=$n((e,n)=>xr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Cr=$n(e=>zr("left",e),[zr]),Br=$n(e=>zr("right",e),[zr]),Ir=e=>vr.has(e),Or=e=>br(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Nr=In(!1),Pr=In(null);Pn(()=>{if(Nr.current&&!Po){const e=Pr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??wo.current?.querySelector(`button[aria-label="${CSS.escape(Rt.add.title)}"]`))?.focus(),Pr.current=null}Nr.current=Po},[Po]),Pn(()=>{if(!Po||!Co)return;const e=e=>{"Escape"===e.key&&Yi()};return Co.addEventListener("keydown",e),()=>Co.removeEventListener("keydown",e)},[Po,Co]),de(Po,()=>Yi()),Pn(()=>{!eo&&Po&&($o(!1),jo(null),Mo.current=!1)},[eo]),Pn(()=>{if(!uo)return To.current&&vt({type:"setUi",ui:{leftSideBarVisible:!1}}),void(To.current=!1);Po&&($o(!1),jo(null),To.current=Mo.current,Mo.current=!1),eo||(To.current=!0,vt({type:"setUi",ui:{leftSideBarVisible:!0}}))},[uo]),Pn(()=>{!eo&&uo&&(To.current=!1,fo())},[eo]),Pn(()=>{if(!uo||!Co)return;const e=e=>{"Escape"===e.key&&fo()};return Co.addEventListener("keydown",e),()=>Co.removeEventListener("keydown",e)},[uo,Co]),de(null!==uo,()=>fo());const $r=W(),Mr=(e,n="success",t)=>{if($r)return void(t?$r(e,"error"===n?"error":"info",t):$r(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?jn.error(e,{...o,duration:t?.duration??3200}):jn.success(e,{...o,duration:t?.duration??1900})},Tr=In(null),[Ar,jr]=Nn(0),[Lr,Rr]=Nn(0),Er=D(),Vr=In(null),Hr=e=>Math.max(0,e.clientHeight-(Vr.current?.offsetHeight??0));Pn(()=>{const e=Tr.current;if(!e)return;const n=()=>{jr(e.clientWidth),Rr(Hr(e))};n();const t=new ResizeObserver(n);return t.observe(e),Vr.current&&t.observe(Vr.current),()=>t.disconnect()},[]),Mn(()=>{Tr.current&&(jr(Tr.current.clientWidth),Rr(Hr(Tr.current)))},[wr,eo,no]);const Fr=so===io?Ar>0?Ar:oo[io]:oo[so],Wr=Ar>0?Math.min(Ar/Fr,"shrink"===lo?1:2):1,Dr=Fr*Wr,Gr=Ar>0&&Dr>Ar+1,Jr={width:Dr,height:Lr||"100%",flex:"none",position:"relative"},Ur={width:Fr,height:Lr?Lr/Wr:"100%",maxHeight:"none",transform:1!==Wr?`scale(${Wr})`:void 0,transformOrigin:"top left"},Yr=()=>vt({type:"setUi",ui:{leftSideBarVisible:!eo}}),Kr=()=>vt({type:"setUi",ui:{rightSideBarVisible:!no}}),Zr=e=>{Po&&($o(!1),jo(null),Mo.current=!1,eo&&yo===e)||uo&&(To.current=!1,fo(),eo&&yo===e)||(eo&&yo===e?Yr():(So(e),eo||vt({type:"setUi",ui:{leftSideBarVisible:!0}})))},Xr=()=>{te(fn,{accept:"image/*",title:Gt.mediaLibrary})},qr=()=>{Vo(L),_t.select(null),p()},_r=()=>{Vo(Mt??L),no||vt({type:"setUi",ui:{rightSideBarVisible:!0}})},Qr=kt.data.content??[],ei=()=>{const e=Qr.findIndex(Tt),n=Qr.findIndex(At);return{floor:e>=0?e+1:0,cap:n>=0?n:Qr.length}},ni=zt,ti=er.stripCopy,oi=e=>r(e,ti),ri=_(),ii=Pe({data:kt.data,config:ni,readOnly:Boolean(ut),clipboard:ri,strip:ti?e=>ti(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==bn||e.slot!==wn)return{min:0,max:n-1};const{floor:t,cap:o}=ei();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Vo(L);const t=void 0===n||"node"===n?.kind?n:null;_t.commitDocument(e,t)}}),li=e=>{const n=Cn(kt.data,zt,e);if(!n)return!1;const t=xn(n.place),o=n.node,r=t===Se?pi(o):Ci(o);return!!ii.remove(e)&&(Mr(Rt.deleted({name:r}),"success",{duration:8e3,action:{label:Rt.bar.undo,onClick:()=>{ii.restore(n.node,n.place)}}}),!0)},si={...ii,remove:li},di=e=>dr(e,"block",zt.components[e]?.label??e),ci=$n(e=>zt.components[e]?.defaultProps??{},[zt]),ai=e=>dr(e,"section",di(e)),pi=e=>he({type:e.type,props:e.props??{}},ai(e.type),pr),{nodeAddresses:ui,zoneItems:fi}=On(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,t=(o,r,i)=>{n.set(r,o),o.forEach((n,o)=>{const l=String(n.props?.id??"");if(l&&e.set(l,{zone:r,index:o}),i>=ve)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of be(zt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(Qr,Se,0),{nodeAddresses:e,zoneItems:n}},[Qr,zt]),hi=$n(e=>fi.get(e)??[],[fi]),mi=e=>{const n=ui.get(e);return n?hi(n.zone)[n.index]:void 0},gi=e=>q(er,zt,e),yi=e=>{if(!er.slotsOf||e===Se)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=mi(e.slice(0,n));if(!t)return null;const o=gi(t).filter(e=>e.rung),r=o.findIndex(t=>t.slot===e.slice(n+1));return r<0?null:{node:t,slot:o[r],position:r}},Si=(()=>{if(!G(Eo))return null;const e=`${Eo.nodeId}:${Eo.slot}`;return yi(e)?.slot.panel===Eo.kind?e:null})(),ki=In(null);Pn(()=>{const e=ki.current;if(ki.current=null,!Si||!G(Eo))return;const n=Eo.nodeId;Jo(n,{scroll:e!==Si}),br(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Eo]);const vi=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=ui.get(e);n&&(n.zone===Se?Hi(n.index):hl(n.zone,n.index,e,mi(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Si!==i&&(ki.current=i),Zo(null,r),no||vt({type:"setUi",ui:{rightSideBarVisible:!0}}),Vi(o)},bi=(e,n,t)=>{const o=`${e}:${n}`;if(br(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;Si!==o&&(ki.current=o);Zo(null,{kind:t,nodeId:e,slot:n})},wi=(e,n,t)=>{if(ut||!er.moveSlot)return;const o=mi(e),r=o?gi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:et,index:n},s=pn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=er.moveSlot(e,n,s);"string"==typeof d&&bi(e,d,i.panel)},xi=ar(),zi=On(()=>{const e=/* @__PURE__ */new Map;for(const n of xi??[])e.set(n.slug,n.name);return e},[xi]),Ci=e=>me(e,di,sr.plainText,e=>zi.get(e),sr.rowName),Bi=(e,n)=>{const t=zt.components[e.type]?.fields,o=n===Se||jl(n)?"section":"block",r=n===Se&&(Tt(e)||At(e)||Nt(e.type)),i="block"===o?ge(t):r?null:ye(t);return sr.renamePropOf?sr.renamePropOf(e,o,i):i},Ii=(e,n,t,o)=>{if(!(!ut&&mr?.zone===e&&mr.index===n))return;const r=(t,o)=>{gr(null),o&&((e,n,t)=>{const o=hi(e)[n];if(!o)return;const r=Bi(o,e);r&&_t.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
9
+ return Jn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Rt.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},Oi=e(J(),Dt),Ni=Oi.scope({target:Sn,siteId:ot,docId:kn}),Pi=zt,$i=(e,n)=>n===Se?ai(e):di(e),Mi=(e,n,t)=>{const o=Oi.plan(Ni,t,$i(t.type,e),Pi);o&&(o.changed&&_t.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Mr(o.message))},Ti=Q({nodesIn:hi,nodeAt:(e,n)=>hi(e)[n]??null,labelOf:(e,n)=>n===Se?ai(e):di(e),renamePropOf:Bi,beginRename:(e,n)=>gr({zone:e,index:n}),history:{hasPast:bt.hasPast,hasFuture:bt.hasFuture,back:()=>bt.back(),forward:()=>bt.forward()},openPageSettings:()=>{_t.select(null),Vo(L)},pageSettingsLabel:Rt.pageSettings,words:{menu:Wt,styleClipboard:Dt,screen:Rt.menu},readOnly:Boolean(ut),collapseAll:()=>br(new Set(hi(Se).map(e=>String(e.props.id)))),onPasteRefused:e=>Mr(e?Rt.pasteRefused({name:e.label}):Rt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>El(e,n),menuRows:qo.menuRows,isLocked:e=>nr(e.type),duplicateBlocked:e=>tr(kt.data,e),permits:e=>ke(zt,e.type),nodeOps:si,isPinned:(e,n)=>n===Se&&(Tt(e)||At(e)),sectionBand:ei,locate:e=>ui.get(e)??null,rowNameOf:(e,n)=>n===Se?pi(e):Ci(e),selectAt:(e,n,t,o)=>{e===Se?Hi(n):hl(e,n,t,o??"")},slotRung:e=>{const n=yi(e);return n?.slot.panel?{label:n.slot.label,select:()=>vi(n.node,n.slot,!1)}:null},style:{held:()=>ae(Ni),canCopy:e=>Oi.rows(Pi,e).some(e=>!1!==e.counted),copy:(e,n)=>Oi.copy(Ni,e,$i(e.type,n),Pi),paste:(e,n,t)=>Mi(e,n,t)},keys:mt?{target:Co,selected:()=>{const e=kt.ui.itemSelector;return e?{zone:e.zone??Se,index:e.index}:null},held:()=>ri.get(),readOnly:Boolean(ut),onDone:({done:e,name:n})=>{"copied"===e&&Mr(Rt.copied({name:n}))}}:void 0},xo),Ai=In({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Pn(()=>{Ai.current={copy:(e,n)=>Oi.copy(Ni,e,$i(e.type,n),Pi),paste:Mi,at:()=>{const e=kt.ui.itemSelector;if(!e)return null;const n=e.zone??Se,t=hi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(ut)}});const ji=$n(e=>{const n=pe(e);if(!n)return;const t=Ai.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);Pn(()=>{if(!Co)return;const e=e=>ji(e);return Co.addEventListener("keydown",e),()=>Co.removeEventListener("keydown",e)},[ji,Co]),gn(xo,"keydown",ji);const Li=Qr.map(e=>e.props.id).join("|");Pn(()=>{const e=xo?.document??null,n=xo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Ro(e=>e.length?[]:e);const n=Qr.findIndex(At),t=n>=0?n:Qr.length,o=n=>{const t=Qr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(hn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=Qr.length>0&&!Tt(Qr[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=Qn(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}Ro(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[xo,Li,so,Wr,eo,no,wt?.props.id]);const Ri=xo?.document??null,Ei=xo?.window??null;Pn(()=>{const e=bo.current;if(!e||!Ri||!Ei)return;const n=[],t=()=>{const n=Ri.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Ei.scrollTo({left:Ei.scrollX,top:Ei.scrollY+t,behavior:"instant"}),!0};return bo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Ri,Ei]);const Vi=e=>{qo.holdCanvasOn?qo.holdCanvasOn(e):c(e)},Hi=e=>{Vo(L),_t.select({index:e}),qo.sectionPressed?.(Qr[e]);const n=Qr[e]?.props?.id;n&&Vi(n)},Fi=e=>{const{floor:n,cap:t}=ei(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=wt&&Eo.kind!==Mt?.kind?Qr.findIndex(e=>e.props.id===wt.props.id):-1;return o(r>=0?r+1:t)},Wi=(e,n)=>{const{floor:t,cap:o}=ei(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(_t.reorderComponent(Se,e,i),_t.select({index:i}),{moved:!0,dest:i})},Di=(e,n,t,o)=>{Vo(L),_t.select(o?{index:o.index,zone:o.zone}:{index:e}),c(n),Mr(Rt.sectionAdded({name:t}))},Gi=(e,n)=>{const t=Fi(n),o=rr(e,{nodeDefaults:ci,newNodeId:Ce,sectionLabel:ai,blockIsOffered:lr}),r=o?_t.insertNode(Se,t,o):_t.insertSection(e,t);return Di(t,r,ai(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of be(zt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=ir(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Ji=e=>Ui(Se,e),Ui=(e,n)=>{Pr.current=document.activeElement??null,uo&&(Mo.current=To.current,To.current=!1,fo()),jo(null===n?null:{zone:e,index:n}),$o(!0),eo||(Mo.current=!0,vt({type:"setUi",ui:{leftSideBarVisible:!0}}))},Yi=()=>{$o(!1),jo(null),Mo.current&&vt({type:"setUi",ui:{leftSideBarVisible:!1}}),Mo.current=!1},Ki=(e,n)=>sr.rowName?n?Tt(e)?sr.rowName(e,"section",Rt.header):At(e)?sr.rowName(e,"section",Rt.footer):Nt(e.type)?sr.rowName(e,"section",di(e.type)):pi(e):Ci(e):n?ai(e.type):di(e.type),Zi=e=>n=>{e()},Xi=()=>qo.editPinnedSource?.(),qi=(e,n,t)=>{if(ut)return null;const o=hi(e)[n];return o&&!ke(zt,o.type).delete?null:/* @__PURE__ */Jn(Le,{kind:"delete",label:Rt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=hi(e)[n]?.props?.id;null!=t&&li(String(t))})(e,n),children:/* @__PURE__ */Jn(Fn,{size:15})})},_i=e=>sr.rowPreview?.(e)||void 0,Qi=e=>sr.rowMarks?.(e)??void 0,el=(e,n,t)=>sr.rowActions?.(e,n,t)??null,nl=(e,n,t,o)=>{if(ut)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
10
+ return Jn(Le,{kind:"eye",label:r?Rt.showNamed({name:o}):Rt.hideNamed({name:o}),onClick:()=>ol(e,n,t),children:/* @__PURE__ */Jn(r?Wn:Dn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},tl=e=>ms(Se,e),ol=(e,n,t)=>{_t.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},rl=e=>we(zt,e),il=e=>be(zt,e),ll=e=>er.slotsOf?gi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:xe(e,n.slot)})):[{slot:null,rung:null,kids:il(e)}],sl=e=>er.slotsOf?ll(e).flatMap(e=>e.kids):il(e),dl=e=>Boolean(er.slotsOf)&&gi(e).some(e=>e.rung),cl=(e,n,t)=>null===t?void 0===n?ir(e):ir(e,n):ir(e,n,t),al=(e,n,t)=>{const o=ze(zt,e.type,n)&&(t||sl(e).length>0||dl(e));return{collapsible:o,folded:o&&Ir(String(e.props.id))}},pl=(e,n,t)=>ll(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>al(e,r,t(e.type)).collapsible?[String(e.props.id),...pl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),ul=e=>sl(e).length>0||dl(e)||Boolean(ir(e.type)),fl=e=>Boolean(ir(e)),hl=(e,n,t,o)=>{if(Vo(L),ir(o)?.spec?.slider){const t=e.split(":")[0];a(t,n),_t.select({index:n,zone:e}),c(t)}else _t.select({index:n,zone:e}),Vi(t)},ml=(e,n,t,o,r)=>{const i=`${e}:${n}`;_t.insertComponent(i,t,o),ir(r)?.spec?.slider?requestAnimationFrame(()=>{a(e,o),_t.select({index:o,zone:i})}):_t.select({index:o,zone:i})},gl=In(/* @__PURE__ */new Set);Pn(()=>{Qr.forEach(e=>{const n=ir(e.type)?.spec;if(!n)return;const t=e.props.id;if(gl.current.has(t))return;gl.current.add(t);if((Array.isArray(e.props[n.slot])?e.props[n.slot]:[]).length>0)return;if(n.skipSeed?.(e.props))return;const o=`${t}:${n.slot}`,r=n.legacy?.(e.props)??[];(r.length?r:n.seeds(ci)).forEach((e,t)=>Zt.seedChild(o,t,n.childType,e))})},[Qr,Zt,ci]);const yl=In(/* @__PURE__ */new Set);Pn(()=>{Qr.forEach((e,n)=>{const t=e.props.id;if(yl.current.has(t))return;const o=i(e,rl(e.type));yl.current.add(t),o&&Zt.replaceComponent(Se,n,{...e,props:o})})},[Qr,Zt]),U(Zt,zt);const Sl=Qr.findIndex(At),kl=Sl>=0?Qr[Sl]:null,vl=jt?Qr.findIndex(Tt):-1,bl=vl>=0?Qr[vl]:null,wl=Ct.groupTab,xl=On(()=>wl?e=>Nt(e.type):void 0,[wl]),zl=Boolean(Ct.groupBadge),Cl=Ct.groupBadge?/* @__PURE__ */Jn("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Jn(An,{tone:"info",size:"xs",children:Ct.groupBadge})}):void 0,Bl=Qr.find(e=>e.type===It)??null,Il=Qr.find(e=>e.type===Ot)??null,Ol=Sl>=0?Sl:Qr.length,Nl=[];Qr.forEach(e=>{At(e)||(ul(e)&&Nl.push(String(e.props.id)),Nl.push(...pl(e,1,fl)))}),kl&&(Nl.push(String(kl.props.id)),Nl.push(...pl(kl,1,fl)));const Pl=Nl.length>0&&Nl.every(e=>vr.has(e)),$l=e=>{const n=sr.blockRowName(e,di);return sr.rowName?sr.rowName(e,"block",n):n},Ml=(e,n,t,o)=>{const r=hi(e)[t];if(!r)return;const i={...zn(e),index:t},l={...zn(n),index:Math.min(Math.max(o,0),hi(n).length)},s=pn(i,l);if(e!==n||s!==t)try{ii.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Bn))throw e}},Tl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of il(e))n.add(r),t(o)};for(const t of rl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Al=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=ui.get(n);if(!e)return null;if(e.zone===Se)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},jl=e=>{const n=e.slice(0,e.indexOf(":")),t=Qr.find(e=>Nt(e.type)&&String(e.props.id)===n);return t&&Pt(n)===e?t:null},Ll=(e,n)=>{const t=jl(e);return!t||(!Ct.groupAccepts||Ct.groupAccepts(t.type,n,hi(e).length))},Rl=(e,n,t)=>{if(e.rung){const t=mi(e.rung.nodeId),o=t?gi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===et&&n.index>=0&&n.index<=o}if(n.slot===et)return!1;if(e.add)return Fl(e.add,n);const o=xn(n);if(Nt(e.type))return!1;const r=jl(o),i=jl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!Ll(o,e.type))&&(n.index>=0&&n.index<=hi(o).length));if(e.zone===Se||o===Se){if(e.zone!==o)return!1;const{floor:t,cap:r}=ei();return n.index>=t&&n.index<=r}if(n.index<0||n.index>hi(o).length)return!1;if(e.zone===o)return!0;const l=kl&&!Ct.lastIsOpen?String(kl.props.id):null;return(!l||Al(e.zone)!==l&&Al(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??hi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=ui.get(i),s=l?hi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Tl(r).has(n))return!1;const d=ir(s.type,or(kt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(hi(n),r))})(e.zone,o,e.index,t)},El=(e,n)=>{const t=xn(e.from),o=e.node;return t===xn(n)?Ll(t,o.type):Rl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Vl=e=>{const n=e.slice(0,e.indexOf(":")),t=ui.get(n),o=t?hi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=ir(o.type,or(kt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:di(r.spec.childType)}]:[]),l=yi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Ki(o,t.zone===Se)}},Hl=(e,n)=>{if("section"!==e.kind)return e;const t=xn(n);return t===Se||jl(t)?e:Vl(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},Fl=(e,n)=>{const t=Hl(e,n),o=xn(n);if("block"!==t.kind){if(jl(o)){const e="section"===t.kind?t.type:t.template.node.type;return Ll(o,e)&&n.index>=0&&n.index<=hi(o).length}if(o!==Se)return!1;const{floor:e,cap:r}=ei();return n.index>=e&&n.index<=r}if(o===Se)return!1;const r=Vl(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(hi(o))},Wl=(e,n)=>{const t=Hl(e,n);if("block"!==t.kind&&jl(xn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&Ll(n,o)){if("section"===e.kind)_t.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;_t.insertNode(n,t,oi(e.template.node))}Vo(L),_t.select({index:t,zone:n})}})(t,xn(n),n.index);if("section"===t.kind)return void Gi(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=Fi(t),r=_t.insertNode(Se,o,n);Di(o,r,e)})(t.template.name,oi(t.template.node),n.index);const o=xn(n),r=Vl(o);r&&(r.target.spec?ml(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{_t.insertComponent(e,n,t),Vo(L),_t.select({index:t,zone:e})})(o,t.type,n.index))},Dl=(e,n)=>{e.rung?wi(e.rung.nodeId,e.index,n.index):e.add?Wl(e.add,n):e.zone===Se?Wi(e.index,n.index):Ml(e.zone,xn(n),e.index,n.index)},[Gl]=Nn(()=>cn()),Jl=an({keyOf:e=>e.id,readOnly:Boolean(ut),session:Gl,canDrop:Rl,onDrop:Dl,onStep:(e,n)=>{e.rung?wi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===Se?((e,n)=>{const t=ai(Qr[e]?.type??""),o=Wi(e,n<0?e-1:e+2);if(!o.moved)return void Mr(n<0?Rt.sectionFirst({name:t}):Rt.sectionLast({name:t}));const{floor:r,cap:i}=ei();Mr(Rt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Ml(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Ul=$n(e=>{const{floor:n,cap:t}=ei(),o=[];for(const r of e.nodes){const e=xn(r.place),i=hi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Tt(i)||At(i)||nr(i.type))continue;if(Nt(i.type))continue;const l=Boolean(jl(e)),s=e===Se||l;e===Se&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?ai(i.type):Ci(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=xn(e.list);if(n===Se&&0===e.children.length)return[{...e,addLabel:Rt.addSection,addAlways:!0}];const t=Vl(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(jl(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=xn(e.list),t=n===Se||jl(n)?null:Vl(n);return t?.choices.length?rn(e,t.target.spec?.addLabel??Rt.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[kt.data]),Yl=null==wt?.props.id?null:String(wt.props.id),Kl=$n(e=>{const n=zt,t=e=>!e.item.rung&&null!==Cn(kt.data,n,e.item.id),o=e[e.length-1];if(!t(o))return o;const r=n=>e.find(e=>t(e)&&e.item.id===n),i=r(Yl);return i||(r($e(kt.data,n,o.item.id,Yl,xl))??o)},[kt.data,zt,Yl,xl]),[Zl,Xl]=Nn(null);gn(xo,"mouseover",e=>{if(!wl)return;const n=yn(e.target),t=n?Zn(kt.data,zt,n):null;t!==Zl&&Xl(t)}),gn(xo,"mouseout",e=>{wl&&!e.relatedTarget&&Xl(null)});const ql=e=>Tt(e)||At(e)||Nt(e.type),_l=[];if(wl){const e=Yl?Zn(kt.data,zt,Yl):null;for(const n of/* @__PURE__ */new Set([e,Zl])){const e=n?Qr.find(e=>String(e.props.id)===n):void 0;if(!e||!ql(e))continue;const t=wl(e);t&&_l.push({id:String(e.props.id),label:t,below:Tt(e)||e.type===It})}}const Ql=le(),es=In(null);Pn(()=>{const e=Ct.changeNotice;if(!e)return;const n=JSON.stringify(Qr.filter(ql)),t=es.current;if(es.current={doc:kn,bands:n,index:bt.index},!t||t.doc!==kn||t.bands===n)return;bt.hasPast&&bt.index>=t.index&&!Kn.has(Ql)&&(Kn.add(Ql),Mr(e,"success",{action:{label:Rt.bar.undo,onClick:()=>bt.back()},duration:8e3}))},[Qr]);const ns=e=>{Vo(L),_t.select(e.zone===Se?{index:e.index}:{index:e.index,zone:e.zone})},ts=Y(),os=()=>({data:kt.data,device:so,ops:_t,inspector:Xo}),rs=ts?.model,is=On(()=>rs?e=>rs(e,Ul(e),os()):Ul,[rs,Ul,so]),ls=ts?.measure,ss=ls?(e,n)=>ls(e,n,os()):void 0,ds=ts?.canDrop,cs=ds?(e,n)=>ds(e,n,Rl,os()):Rl,as=ts?.drop,ps=as?(e,n)=>as(e,n,Dl,os()):Dl,us=ts?.pick,fs=us?e=>us(e,ns,os()):ns,hs=e=>{const n=xn(e),t=yi(n);t&&vi(t.node,t.slot,!1),Ui(n,e.index)},ms=(e,n)=>/* @__PURE__ */Jn(Re,{...ut?{}:Jl.seam({place:{...zn(e),index:n}})},`seam:${e}:${n}`),gs={rowClick:Zi,isCollapsed:Ir,toggleCollapse:Or},ys=e=>{const n=String(e.props.id),t=Qr.findIndex(e=>String(e.props.id)===n),o=Pt(n),r=hi(o),i=Ir(n),l=di(e.type),s=sr.rowName?sr.rowName(e,"section",l):l,d=e=>ms(o,e);/* @__PURE__ */
11
+ return Un(Yn,{children:[
12
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:e.type,size:13}),name:s,preview:_i(e),marks:Qi(e),onSelect:()=>Hi(t),nameSlot:Ii(Se,t,n,s),selected:Fo===n,badge:Cl,actions:el(e,Se,t)??void 0,rowProps:{"data-node-id":n,onClick:Zi(()=>Hi(t))},fold:{open:!i,label:"section",onToggle:()=>Or(n)}}),!i&&/* @__PURE__ */Un(Te,{children:[r.map((n,t)=>{const r=String(n.props.id),i=pi(n),l=ul(n),s=l&&Ir(r),c=()=>hl(o,t,r,e.type),{rowProps:a,...p}=Jl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...zn(o),index:t}},{"data-node-id":r,onClick:Zi(c)});/* @__PURE__ */
13
+ return Un(Tn,{children:[d(t),
14
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:n.type,size:13}),name:i,preview:_i(n),marks:Qi(n),onSelect:c,nameSlot:Ii(o,t,r,i),selected:Fo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Or(r)}:void 0,actions:/* @__PURE__ */Un(Yn,{children:[qi(o,t,i),el(n,o,t),nl(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Jn(Te,{children:vs(n,2)})]},r)}),d(r.length)]})]})},Ss=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Jl.dragging,d=!Ir(l)&&s?.rung?.nodeId!==i,c={...zn(l),index:0},a=s&&!s.rung&&Rl(s,c)?c:void 0,p=()=>vi(e,n,!0),{rowProps:u,...f}=Jl.row({item:{id:`rung:${l}`,zone:`${i}:${et}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:et,index:t},into:a,canDrag:Boolean(er.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Zi(p)}),h=ut?null:er.slotActions?.(e,n.slot);/* @__PURE__ */
15
+ return Un(Tn,{children:[n.heading,
16
+ /* @__PURE__ */Jn(Me,{words:Et,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Si===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Or(l)},actions:h&&h.length>0?/* @__PURE__ */Jn(Yn,{children:h.map((t,o)=>/* @__PURE__ */Jn(Le,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(ut||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&bi(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Jn(Fn,{size:15}):/* @__PURE__ */Jn(Gn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Jn(Te,{children:r})]},l)},ks=(e,n)=>{const t=ll(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
17
+ return Jn(Yn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=cl(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=(e,n)=>ms(e,n),p=/* @__PURE__ */Un(Yn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Fo===String(n.props.id),{collapsible:i,folded:s}=al(n,l,fl(n.type)),d=String(n.props.id),c=$l(n),p=()=>hl(t,o,d,e.type),{rowProps:u,...f}=Jl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...zn(t),index:o}},{"data-node-id":d,onClick:Zi(p)});/* @__PURE__ */
18
+ return Un(Tn,{children:[0===o&&a(t,0),
19
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:n.type,size:13}),name:c,preview:_i(n),marks:Qi(n),onSelect:p,nameSlot:Ii(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Or(d)}:void 0,actions:/* @__PURE__ */Un(Yn,{children:[qi(t,o,c),el(n,t,o),nl(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Jn(Te,{children:ks(n,l+1)}),a(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?a(d,0):null:0!==i.length||!t.rung&&d!==c?null:a(c,0)]});return t.rung?Ss(e,t.rung,r++,o,p):/* @__PURE__ */Jn(Tn,{children:p},t.slot??"")})})},vs=(e,n)=>{const t=or(kt?.data,e.type,String(e.props.id)),o=ll(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
20
+ return Jn(Yn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=cl(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>ms(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),S=/* @__PURE__ */Un(Yn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Fo===String(n.props.id),i=Ci(n),l=String(n.props.id),{collapsible:d,folded:c}=al(n,s,fl(n.type)),a=rl(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...zn(p),index:hi(p).length}:void 0,f=Jl.dragging,h=u&&f&&Rl(f,u)?u:void 0,g=()=>hl(t,o,l,e.type),{rowProps:y,...S}=Jl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...zn(t),index:o},into:h,canDrag:!nr(n.type)},{"data-node-id":l,onClick:Zi(g)});/* @__PURE__ */
21
+ return Un(Tn,{children:[0===o&&m(t,0),
22
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:n.type,size:13}),name:i,preview:_i(n),marks:Qi(n),onSelect:g,nameSlot:Ii(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...S,fold:d?{open:!c,label:"group",onToggle:()=>Or(l)}:void 0,actions:nr(n.type)?el(n,t,o)??void 0:/* @__PURE__ */Un(Yn,{children:[qi(t,o,i),el(n,t,o),nl(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Jn(Te,{children:vs(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
23
+ /* @__PURE__ */Jn(w,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>ml(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?Ss(e,o.rung,i++,r,S):/* @__PURE__ */Jn(Tn,{children:S},o.slot??"")})})},bs=Po||null!==uo,ws=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:eo&&!bs&&Qo===e.id,onSelect:()=>Zr(e.id)}:e,xs=[...(qo.railLead??[]).map(ws),{id:"sections",label:Rt.layers,icon:/* @__PURE__ */Jn(Ve,{}),active:eo&&!bs&&"sections"===Qo,onSelect:()=>Zr("sections")},...(qo.railTrail??[]).map(ws)];po?xs.push({id:"media",label:Rt.railMedia,icon:/* @__PURE__ */Jn(He,{}),active:eo&&!Po&&(null!==uo||"media"===Qo),onSelect:()=>Zr("media")}):gt&&xs.push({id:"media",label:Rt.railMedia,icon:/* @__PURE__ */Jn(He,{}),onSelect:Xr});const zs=[...qo.railLead??[],...qo.railTrail??[]].find(e=>"panel"in e&&e.id===Qo),Cs=Boolean(Lt?.foldable)&&!_o,Bs=Lt?.label??(yt?Rt.pageSections:Rt.templateSections),Is=Cs&&Ir(nt),Os=/* @__PURE__ */Un(Yn,{children:[Qr.map((e,n)=>{if(Tt(e)||At(e)||Nt(e.type))return null;const t=Fo===String(e.props.id),o=Boolean(e.props._hidden);il(e);const r=String(e.props.id),i=qo.hasOwnRows?.(e)??!1,l=ul(e)||i,s=l&&Ir(r),d=rl(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...zn(c),index:hi(c).length}:void 0,p=Jl.dragging,u=a&&p&&Rl(p,a)?a:void 0,{rowProps:f,...h}=Jl.row({item:{id:r,zone:Se,index:n,type:e.type},place:{...zn(Se),index:n},into:u},{"data-node-id":r,onClick:Zi(()=>Hi(n))});/* @__PURE__ */
24
+ return Un(Tn,{children:[n>0&&tl(n),
25
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:e.type,size:13}),name:pi(e),preview:_i(e),marks:Qi(e),onSelect:()=>Hi(n),nameSlot:Ii(Se,n,r,pi(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Or(r)}:void 0,actions:/* @__PURE__ */Un(Yn,{children:[qi(Se,n,pi(e)),el(e,Se,n),nl(Se,n,e,pi(e))]}),rowProps:f}),ul(e)&&!s&&/* @__PURE__ */Un(Te,{children:[vs(e,1),qo.partRows?.(e,gs)]}),i&&!s&&/* @__PURE__ */Jn(Te,{children:qo.ownRows?.(e,n,gs)})]},String(e.props.id??n))}),!_o&&Ol>0&&tl(Ol)]}),Ns=(e,n,t)=>{const o=String(e.props.id),r=sl(e).length>0||dl(e)||Boolean(ir(e.type)),i=r&&Ir(o),l="header"===t?Rt.header:Rt.footer,s=sr.rowName?sr.rowName(e,"section",l):l;/* @__PURE__ */
26
+ return Un(Yn,{children:[
27
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:t,size:13}),name:s,preview:_i(e),marks:Qi(e),badge:Cl,onSelect:()=>Hi(n),nameSlot:Ii(Se,n,o,s),selected:Fo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Or(o)}:void 0,actions:el(e,Se,n)??void 0,rowProps:{"data-node-id":o,onClick:Zi(()=>Hi(n))}}),r&&!i&&/* @__PURE__ */Jn(Te,{children:ks(e,1)})]})};return(qo.wrap??(e=>e))(
28
+ /* @__PURE__ */Jn(K,{target:xo,children:/* @__PURE__ */Un("div",{ref:wo,className:"sf-editor es-editor",style:qe(wr),onContextMenu:Ti.onEditorContextMenu,...m(fn),children:[
29
+ /* @__PURE__ */Un(Fe,{children:[
30
+ /* @__PURE__ */Jn(We,{items:xs,ariaLabel:Rt.bar.views}),
31
+ /* @__PURE__ */Un(De,{children:[
32
+ /* @__PURE__ */Jn(Ge,{label:Rt.bar.undo,disabled:Boolean(ut)||!bt.hasPast,onClick:()=>bt.back(),children:/* @__PURE__ */Jn(Rn,{})}),
33
+ /* @__PURE__ */Jn(Ge,{label:Rt.bar.redo,disabled:Boolean(ut)||!bt.hasFuture,onClick:()=>bt.forward(),children:/* @__PURE__ */Jn(En,{})}),
34
+ /* @__PURE__ */Jn(Je,{}),
35
+ /* @__PURE__ */Jn(Ue,{devices:to,value:so,onChange:co}),
36
+ /* @__PURE__ */Jn(Ge,{label:Rt.bar.refresh,tip:Rt.bar.refreshTip,onClick:()=>{bo.current=(()=>{const e=xo?.document;if(!e)return null;const n=Qr.findIndex(At),t=n>=0?n:Qr.length;let o=null;for(let n=0;n<t;n++){const t=Qr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=wt?.props?.id??Qr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),vo(e=>e+1)},children:/* @__PURE__ */Jn(Vn,{})})]}),
37
+ /* @__PURE__ */Un(De,{kind:"right",style:{minWidth:300},children:[
38
+ /* @__PURE__ */Jn(l,{input:Oo,words:Rt.saveStatus}),qo.barLead?.(),qo.barTrail?.(),qo.mainAction||!qo.barMain?/* @__PURE__ */Jn(s,{input:Oo,action:qo.mainAction??{label:Rt.done,onPress:()=>{rt(kt.data)}},readOnly:Boolean(ut),saveSwitch:ht,onToggleAutoSave:dt,onSaveNow:No,bar:Rt.bar,words:Rt.saveStatus}):qo.barMain()]})]}),
39
+ /* @__PURE__ */Jn(ee,{}),
40
+ /* @__PURE__ */Un("div",{className:"sf-body",children:[eo?/* @__PURE__ */Un(Yn,{children:[
41
+ /* @__PURE__ */Jn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Rt.leftPanel,children:Po?/* @__PURE__ */Jn(x,{at:Ao?{label:(e=>{const n=jl(e.zone);if(n)return Rt.add.addingTo({name:sr.rowName?Ki(n,!0):di(n.type)});if(e.zone===Se){const n=Qr[e.index];return n&&!At(n)?Rt.add.addingBefore({name:Ki(n,!0)}):Rt.add.addingAtEnd}const t=Vl(e.zone);return t?Rt.add.addingTo({name:t.parentName}):Rt.add.addingHere})(Ao),onClear:()=>jo(null)}:void 0,placeBlocks:Ao&&Ao.zone!==Se?Vl(Ao.zone)?.choices:void 0,canTake:Ao?e=>{if(!Ao)return null;const n={...zn(Ao.zone),index:Ao.index};if(Fl(e,n))return null;const t=jl(Ao.zone);if(t)return Rt.add.notInside({name:Ki(t,!0)});if(Ao.zone===Se)return Rt.add.onlySections;const o=Vl(Ao.zone);return o?Rt.add.notInside({name:o.parentName}):Rt.add.onlySections}:void 0,onPick:Ao?e=>{if(!Ao)return;const n={...zn(Ao.zone),index:Ao.index};Fl(e,n)&&(Wl(e,n),Yi())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Gl,siteWide:qo.addPanelRow?.(Yi),onClose:Yi,onHide:Yr,readOnly:Boolean(ut)}):uo&&ao?
42
+ /* @__PURE__ */Jn(B,{panel:ao,pick:uo,onHide:Yr}):zs?zs.panel({onHide:Yr,notify:Mr}):"media"===Qo&&ao?/* @__PURE__ */Jn(B,{panel:ao,pick:null,onHide:Yr}):/* @__PURE__ */Un(Yn,{children:[
43
+ /* @__PURE__ */Jn(z,{icon:/* @__PURE__ */Jn(Ve,{}),title:Rt.layers,context:Jt,actions:/* @__PURE__ */Un(Yn,{children:[!ut&&/* @__PURE__ */Jn(Ye,{label:Rt.add.title,onClick:()=>Ji(null),children:/* @__PURE__ */Jn(Hn,{size:15})}),
44
+ /* @__PURE__ */Jn(Ye,{label:Pl?Rt.expandAll:Rt.collapseAll,title:0===Nl.length?Rt.nothingToFold:void 0,disabled:0===Nl.length,onClick:()=>br(e=>{const n=new Set(Nl);return Pl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Nl])}),children:/* @__PURE__ */Jn(qn,{expand:Pl})})]}),onHide:Yr}),
45
+ /* @__PURE__ */Un(Ae,{className:"sf-tree sf-scroll",words:Et,children:[
46
+ /* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:"page",size:13}),name:Rt.pageSettings,onSelect:qr,selected:!wt&&Ho,rowProps:{onClick:Zi(qr)}}),Bl&&/* @__PURE__ */Un(Yn,{children:[!zl&&/* @__PURE__ */Jn(je,{children:Rt.header}),ys(Bl)]}),!_o&&St&&!(zl&&Bl)&&/* @__PURE__ */Un(Yn,{children:[!zl&&/* @__PURE__ */Jn(je,{children:Rt.header}),!jt&&/* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:"header",size:13}),name:Rt.header,badge:Cl,onSelect:_r,selected:Eo.kind===Mt?.kind,rowProps:{onClick:Zi(_r)}})]}),!_o&&bl&&!(zl&&Bl)&&Ns(bl,vl,"header"),!_o&&!Cs&&/* @__PURE__ */Jn(je,{children:Bs}),Cs?/* @__PURE__ */Un(Yn,{children:[
47
+ /* @__PURE__ */Jn(Me,{words:Et,icon:null,name:Bs,fold:{open:!Is,label:Bs,onToggle:()=>Or(nt)}}),!Is&&/* @__PURE__ */Jn(Te,{children:Os})]}):Os,St&&!zl&&/* @__PURE__ */Jn(je,{children:Rt.footer}),kl&&!(zl&&Il)&&Ns(kl,Sl,"footer"),!_o&&!kl&&St&&!zl&&/* @__PURE__ */Jn(Me,{words:Et,icon:/* @__PURE__ */Jn(cr,{type:"footer",size:13}),name:Rt.footer,onSelect:Xi,rowProps:{onClick:Zi(Xi),title:Rt.editFooter}}),Il&&ys(Il),qo.treeFoot?.()]})]})}),
48
+ /* @__PURE__ */Jn(Ke,{side:"left",width:wr.left,min:Xe,max:Ze,defaultWidth:S.left,label:Rt.resizeLeftPanel,onResize:Cr})]}):/* @__PURE__ */Jn(C,{side:"left",onShow:Yr}),
49
+ /* @__PURE__ */Un("div",{ref:Tr,className:"sf-center sf-scroll","data-sf-canvas-head":Er?"":void 0,style:{overflowX:Gr?"auto":"hidden",overflowY:"hidden"},children:[Er&&/* @__PURE__ */Jn("div",{ref:Vr,className:"sf-canvas-head",children:/* @__PURE__ */Jn(Er,{device:so})}),
50
+ /* @__PURE__ */Un("div",{className:"sf-frame-scaler",style:Jr,children:[
51
+ /* @__PURE__ */Jn("div",{className:"sf-frame "+(so===io?"":`sf-frame--${so}`),style:Ur,children:/* @__PURE__ */Un("div",{className:"sf-preview-host",children:[
52
+ /* @__PURE__ */Jn(Oe.Provider,{value:xl,children:/* @__PURE__ */Jn(Ut,{},ko)}),
53
+ /* @__PURE__ */Jn(ln,{canvas:xo,session:Gl,model:is,measure:ss,canDrop:cs,onDrop:ps,choose:Kl,onPick:fs,onZoneAdd:hs,onSeamAdd:hs,zoneAddLabel:Rt.canvasAddBlock,words:Vt.canvas,readOnly:Boolean(ut),revision:kt.data}),Lo.length>0&&!zo&&/* @__PURE__ */Jn("div",{className:"sf-preview-gaps",children:Lo.map(e=>
54
+ /* @__PURE__ */Jn(sn,{index:e.index,label:Rt.addSectionHere,onInsert:()=>Ji(e.index),className:void 0===e.height?"sf-preview-gap":"sf-preview-gap sf-preview-gap--tight",style:void 0===e.height?{top:e.top}:{top:e.top,height:e.height}},e.index))})]})}),wl?/* @__PURE__ */Jn(Xn,{canvas:xo,tabs:_l,onSelect:e=>{const n=Qr.findIndex(n=>String(n.props.id)===e);n>=0&&Hi(n)}}):null]})]}),no?/* @__PURE__ */Un(Yn,{children:[
55
+ /* @__PURE__ */Jn(g,{value:{selectChild:hl,addChild:ml,childRowName:Ci,blockRowName:$l},children:/* @__PURE__ */Jn(Yt,{mode:Eo,onOpenWebsiteSettings:qo.openSettings??(()=>{}),onOpenSiteStyles:qo.openStyles,onSelectNode:fr,onNotify:Mr,onHidePanel:Kr,nodeActions:wt?ke(zt,wt.type):tt})}),
56
+ /* @__PURE__ */Jn(Ke,{side:"right",width:wr.right,min:Xe,max:Ze,defaultWidth:S.right,label:Rt.resizeSettingsPanel,onResize:Br})]}):
57
+ /* @__PURE__ */Jn(C,{side:"right",onShow:Kr})]}),Ti.menu]})}))}export{ot as ScreenChrome};
@@ -0,0 +1,13 @@
1
+ import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{toItemSelector as t,fromItemSelector as n,useNodeOps as o,parentStep as r,clickPick as i}from"./chunk-ECM5F6JJ.js";import{useResolvedFields as l}from"./chunk-YRLPFZW3.js";import{selectionBox as s,placeWindow as a,offsetOrigin as c,colorRunOf as d,ColorWindow as u,startCanvasTyping as p,textMap as f}from"./chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as h}from"./chunk-B4JN227A.js";import{useWords as m}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as g,CANVAS_TYPABLE_EVENT as v,isTypingTarget as y,frameRectToHost as w,CANVAS_TYPING_EVENT as b,drawnBox as k}from"./chunk-X4T6JT3M.js";import{find as S,ROOT_ID as C,getList as I,remove as E,parseZoneKey as D,move as x,duplicate as M,replaceNode as A,createNode as O,insert as z,normalizeData as R,createResolveCache as P,resolveNodeData as V,ROOT_SLOT as B}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as N,fieldsFrom as $,defaultsFrom as L}from"./chunk-NKB3KVAB.js";import{createContext as K,useEffect as j,useContext as Z,useRef as F,useSyncExternalStore as T,useState as H,useMemo as W,useCallback as q,useLayoutEffect as Y}from"react";import{jsx as J,jsxs as X,Fragment as U}from"react/jsx-runtime";import{createPortal as G}from"react-dom";import{registerModalEscapeInterceptor as Q,FloatingBar as _,TextToolbar as ee,LinkPicker as te}from"efficient-shell/ui";function ne(e){return!["setData","setUi","set"].includes(e.type)}var oe=(e,t,n,o)=>{const r=I(e,t,D(n));return r?.[o]??null},re=(e,t,n,o,r)=>{const i=oe(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function ie(e,n){const{selection:o}=e;return{...e.ui,itemSelector:t(e.data,n,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function le(e,t,n){return n?"node"===n.kind?S(e,t,n.id)?n:null:n.parentId===C?I(e,t,n)?n:null:S(e,t,n.parentId)&&I(e,t,n)?n:null:null}function se(e,t,o,r=!1){const{itemSelector:i,selectedSlot:l,...s}=o;let a=e.selection;var c;return"itemSelector"in o&&(a=n(e.data,t,i??null)),"selectedSlot"in o&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ae(e,t,n){const o=ce(e,t,n);if(o===e)return e;const r=le(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ce(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 se(e,n,"function"==typeof t.ui?t.ui(ie(e,n)):t.ui);case"set":{const r={data:o,ui:ie(e,n)},i="function"==typeof t.state?t.state(r):t.state;let l=i.data?{...e,data:i.data}:e;return i.ui&&(l=se(l,n,i.ui,!0)),l}case"insert":{const r={...D(t.destinationZone),index:t.destinationIndex},i=O(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:z(o,n,r,i)}}case"replace":{const r=re(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:A(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=re(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=M(o,n,r.props.id),l=oe(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return ce(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=oe(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...D(t.destinationZone),index:t.destinationIndex};return{...e,data:x(o,n,r.props.id,i)}}case"remove":{const r=re(o,n,t.zone,t.index,"remove");return{...e,data:E(o,n,r.props.id)}}default:return e}}var de={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},ue={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},pe=0,fe=()=>`history-${pe+=1}`;function he(e){let o=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=R(e.data,o);let a={data:s,selection:null,ui:{...ue}};if(e.ui){const{itemSelector:t,selectedSlot:r,...i}=e.ui;a={data:s,selection:r?{kind:"slot",...r}:n(s,o,t??null),ui:{...ue,...i}}}let c=[{core:a,at:-1/0,sealed:!0,id:fe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:a,at:n}]:(c=[...c.slice(0,d+1),{core:a,at:n,sealed:e,id:fe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,m=0,g=null,v=!1;const y=()=>{for(const e of[...p])e()},w=()=>{c=[...c.slice(0,d),{...c[d],core:a},...c.slice(d+1)]},b=(t,n)=>{m>0?v=v||n:(n?u(!1):a!==t&&w(),a.data!==t.data&&e.onChange?.(a.data),a!==t&&y())},k=e=>{const t=a;if(a=ae(a,e,o),a===t)return;const n=e.recordHistory??ne(e);b(t,n&&a.data!==t.data)},C=t=>{0===m&&(g=a,v=!1),m+=1;try{t()}catch(e){throw m-=1,0===m&&g&&(a=g,g=null),e}if(m-=1,m>0||!g)return;const n=g;g=null,v&&a.data!==n.data?u(!0):a!==n&&w(),a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},E=e=>{const t=a,n=le(a.data,o,e);var r,i;(r=n,i=a.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(a={...a,selection:n},b(t,!1))},D=t=>{const n=a;d=t,a=c[d].core,a.data!==n.data&&e.onChange?.(a.data),a!==n&&y()},x=()=>(e={})=>{const t=e.root?o.root?.permissions:o.components[e.item?.type??e.type??""]?.permissions;return{...de,...l,...t}};let M=x();const O=P(),z={resolveCache:O,async resolveAll({trigger:e="load",metadata:t}={}){const n=a.data,r={type:"root",props:{...n.root.props??{}}},i=[...n.content,...Object.values(n.zones??{}).flat()],[l,...s]=await Promise.all([V(r,o,{cache:O,trigger:e,metadata:t}),...i.map(n=>V(n,o,{cache:O,trigger:e,metadata:t}))]);C(()=>{const e=a;let t=a.data;s.forEach((e,r)=>{if(!e.didChange)return;const l=i[r].props.id,s=S(t,o,l)?.node;s&&s===S(n,o,l)?.node&&(t=A(t,o,l,e.node))}),l.didChange&&t.root===n.root&&(t={...t,root:{...t.root,props:l.node.props,readOnly:l.node.readOnly??t.root.readOnly}}),t!==a.data&&(a={...a,data:t,selection:le(t,o,a.selection)},b(e,!1))})},async resolveNode(e,{trigger:t="replace",metadata:n}={}){const r=S(a.data,o,e)?.node;if(!r)return!1;const i=await V(r,o,{cache:O,trigger:t,metadata:n});if(!i.didChange)return!1;let l=!1;return C(()=>{const t=a;if(S(a.data,o,e)?.node!==r)return;const n=A(a.data,o,e,i.node);n!==a.data&&(a={...a,data:n,selection:le(n,o,a.selection)},b(t,!1),l=!0)}),l},get config(){return o},getState(){if(f&&h===a)return f;const e=a,n={data:e.data,ui:ie(e,o)},r="node"===e.selection?.kind?S(e.data,o,e.selection.id)?.node??null:null;return f={appState:n,selection:e.selection,selectedItem:r,config:o,dispatch:k,history:{back:()=>z.undo(),forward:()=>z.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:ie(e.core,o)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&D(e)}},getPermissions:M,getItemById:t=>S(e.data,o,t)?.node,getItemBySelector:t=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return I(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,o,t),getSelectorForId:n=>{const r=t(e.data,o,{kind:"node",id:n});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:k,batch:C,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>E(e?{kind:"node",id:e}:null),selectSlot:e=>E(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const t=a,n=void 0===e.select?a.selection:e.select;a={...a,data:e.data,selection:le(e.data,o,n)},b(t,e.data!==t.data)})},load(e,t={}){const n=a,r=R(e,o);a={...a,data:r,selection:le(r,o,t.selection??a.selection)},t.keepHistory||(c=[{core:a,at:-1/0,sealed:!0,id:fe()}],d=0),a!==n&&y()},undo(){d>0&&D(d-1)},redo(){d<c.length-1&&D(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,l)||(l=e,M=x(),f=null,y())},setConfig(e){e!==o&&(o=e,M=x(),f=null,y())}};return z}function me(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&y(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 ge=K(null),ve=K(!0);function ye({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return j(()=>{n&&e.resolveAll()},[e,n]),j(()=>{if(t&&"undefined"!=typeof document)return me(document,e)},[e,t]),/* @__PURE__ */J(ge.Provider,{value:e,children:/* @__PURE__ */J(ve.Provider,{value:t,children:o})})}function we(){const e=Z(ge);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function be(e){const t=we(),n=F({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return T(t.subscribe,o,o)}function ke(){return function(e){return be(e)}}var Se="data-puck-component",Ce="data-puck-dropzone",Ie={},Ee="data-es-mirror",De="undefined"==typeof window?j:Y;function xe(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ee}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ee,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Me({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=m("canvas",e),u=F(null),[p,f]=H(null);return De(()=>{const e=u.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),De(()=>{let e=u.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=u.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),g(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){xe(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>xe(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */J("iframe",{ref:u,id:n,title:o??d.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:p?G(t,p):null})}var Ae=K(null),Oe=K(Ie),ze=[];function Re({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=we(),s=be(n=>I(n.appState.data,l.config,{parentId:e,slot:t})??ze),a=be(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==C),c=be(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=Z(Ae),u=["es-zone"];return s.length&&u.push("has-children"),e===C&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==C&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */J("div",{className:u.join(" "),[Ce]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */J(je,{node:e},e.props.id))})}function Pe(e,t){return W(()=>{const n={};for(const o of N($(e)))n[o]=function(e={}){/* @__PURE__ */
2
+ return J(Re,{parentId:t,slot:o,...e})};return n},[e,t])}function Ve(e){return W(()=>function({zone:t,...n}){/* @__PURE__ */
3
+ return J(Re,{parentId:e,slot:t,...n})},[e])}var Be=["top","bottom","zIndex"];function Ne(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function $e(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));Ne(e,"position",t?"sticky":"relative");for(const n of Be)Ne(e,n,t?.[n]??"");return!!t}var Le="data-es-canvas-relative";function Ke(e){e.hasAttribute(Le)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Le));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Le,"")),!1)}function je({node:e}){const t=we().config.components[e.type],n=e.props.id,o=F(null),r=function(e,t){return W(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Se),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(Se,e),n.setAttribute("data-puck-dnd",e),Ke(n))},[e,t])}(n,o),i=F(null),l=!!t?.inline;!function(e,t){const n=F(!1),o=F(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=F(()=>{});De(()=>o.current()),De(()=>{const t=e(),i=t?.ownerDocument.defaultView;if(!t||!i)return;const l=()=>o.current();i.addEventListener("resize",l);const s=i.ResizeObserver,a=s?new s(l):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&i.MutationObserver&&(c=new i.MutationObserver(l),c.observe(e,{attributes:!0}))},r.current(),()=>{i.removeEventListener("resize",l),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>l?o.current:i.current,e=>l?Ke(e):$e(e));const s=Z(Oe),a=Pe(t,n),c=Ve(n);if(!t?.render)return null;const d=t.render,u={...L(t),...e.props,...a},p={renderDropZone:c,isEditing:!0,dragRef:t.inline?r:null,metadata:{...s,...t.metadata}};return t.inline?/* @__PURE__ */J(d,{...u,puck:p,editMode:!0}):
4
+ /* @__PURE__ */J("div",{ref:i,[Se]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */J(d,{...u,puck:p,editMode:!0})})}function Ze({metadata:e}){const t=be(e=>e.config),n=be(e=>e.appState.data.root).props??{},o=t.root?.render,r=Pe(t.root,C),i=Ve(C),l=/* @__PURE__ */J(Re,{parentId:C,slot:B}),s=o?/* @__PURE__ */J(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
+ return J(Oe.Provider,{value:e??Ie,children:s})}var Fe=K(void 0);function Te(e,t,n){const[o,r]=H(null),i=F(t);return i.current=t,De(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const l=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=k(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(l))};l();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function He({id:e,kind:t,overlay:n}){const o=F(null),r=Te(o,e?t=>t.querySelector(`[${Se}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */J("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */J(n,{componentId:e,kind:t,children:i}):i}function We(e,t,n){const o=f(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function qe({s:e,element:t,toolbar:n,label:o,keys:r}){const i=m("copy",h),l=e.pressed(),p=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,g=F(null),[v,y]=H(!1),[b,k]=H(null),S=v||null!==b,C=()=>{e.hold(),y(!1),k({href:e.pressed().href})},I=()=>{y(!1),k(null),e.resume()};Y(()=>{r.current={escape:()=>!!S&&(I(),!0),link:()=>!!p.has("link")&&(C(),!0)}}),Y(()=>()=>{r.current=null},[r]);const E=F(I);E.current=I,j(()=>{if(v)return Q(e=>{const t=g.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>g.current?.querySelector(".es-copy-colors"))},[v]),j(()=>{const n=g.current;if(!S||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const i=o=>{const r=o.target;if(r&&n.contains(r))return;y(!1),k(null);const i=t();r&&i&&i.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",i,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",i,!0)}},[S,e,t]),Y(()=>{const e=g.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(S&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,i=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,l=(i?s(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),d=o.ownerDocument.defaultView?.frameElement,u=d?w(d,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=d?w(d,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},h=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),m={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,h.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,h.bottom)},v=e.ownerDocument.documentElement,y=(d??o.closest(".es-canvas")??o).getBoundingClientRect(),b={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(b.right<=b.left||b.bottom<=b.top||0===n.offsetWidth)return;const k=a({anchor:m,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:b,parent:c(n)});n.style.top=`${k.top}px`,n.style.left=`${k.left}px`,n.style.setProperty("--es-pop-point",`${k.point}px`),n.dataset.side=k.above?"above":"below"});const D=f?{run:d(l.color,f),open:v,onToggle:()=>{k(null),v?I():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
6
+ return J(_,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?w(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__ */J("div",{ref:g,children:/* @__PURE__ */J(ee,{layout:"row",offered:p,pressed:l.marks,onMark:t=>{"link"===t?C():e.press(t)},color:D,linkOpen:null!==b,list:{pressed:l.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:l.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */X(U,{children:[v&&f?/* @__PURE__ */J(u,{colors:f,current:l.color,words:i.colors??h.colors,onPick:t=>e.color(t)}):null,b?
7
+ /* @__PURE__ */J(te,{className:"es-copy-link es-copy-pop",value:b.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==b.href?()=>{k(null),e.link(null)}:void 0,onCancel:I}):null]})})})})}function Ye({element:e}){const t=F(null),n=Te(t,()=>e(),e);/* @__PURE__ */
8
+ return J("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Je({frame:t=!0,className:n,style:o,metadata:l,mirrorStyles:s,onDocument:a,height:c,title:d,nonce:u,hotkeys:f,frameWrapper:h,overlay:g,children:y,typing:w,passThrough:k}){const S=we(),C=Z(Fe),I=k??C,E=Z(ve),D=m("canvas",e),x=f??E,[M,A]=H(void 0),O=be(e=>"node"===e.selection?.kind?e.selection.id:null),[z,R]=H(null),[P,V]=H(null),B=F(null),[,N]=H(0),$=F(w);$.current=w;const L=F(null),K=F(null),T=be(e=>e.appState.data);j(()=>{const e=K.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=O&&!P&&$.current?.atSelection?.()?O:null;e.dispatchEvent(new t(v,{detail:{id:n}}))},[O,P,T]);const W=e=>{const t=K.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(b,{detail:{typing:e}}))},q=(e,t)=>{B.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=S.group(),r=e.element,i=p({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:We(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>N(e=>e+1),onEscape:()=>L.current?.escape()??!1,onLinkKey:()=>L.current?.link()??!1,end:e=>{o.close(),B.current?.element===r&&(B.current=null),V(null),W(!1),$.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${Se}]`)?.getAttribute(Se);return l&&S.select(l),B.current={s:i,element:r,target:e},V(()=>r),R(null),W(!0),$.current?.onChange?.({typing:!0,element:n}),!0};j(()=>()=>B.current?.s.stop("stop"),[]);const Y=e=>{const t=B.current?.element();return Boolean(t&&t.contains(e))},U=e=>{const t=e.closest?.(`[${Se}]`)?.getAttribute(Se);if(!t)return;const n=S.getState(),o="node"===n.selection?.kind?n.selection.id:null;return i(n.appState.data,S.config,t,o,I)??t},G=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(B.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=$.current?.atSelection?.();n&&q(n,null)&&e.preventDefault()},Q=/* @__PURE__ */X("div",{ref:K,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),B.current){if(Y(t))return;B.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=U(t);void 0===o?t.hasAttribute?.(Ce)||S.select(null):S.select(o)},onDoubleClick:e=>{const t=$.current;if(!t||Y(e.target))return;const n=t.at(e.target);n&&q(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>G(e),onMouseOver:e=>{if(B.current)return;const t=U(e.target)??null;t!==z&&R(t)},onMouseLeave:()=>R(null),children:[
9
+ /* @__PURE__ */J(Ae.Provider,{value:z,children:/* @__PURE__ */J(Ze,{metadata:l})}),
10
+ /* @__PURE__ */X("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
11
+ /* @__PURE__ */J(He,{id:!P&&z&&z!==O?z:null,kind:"hover",overlay:g}),
12
+ /* @__PURE__ */J(He,{id:P?null:O,kind:"selected",overlay:g}),P?/* @__PURE__ */J(Ye,{element:P}):null]}),y]}),_=h?/* @__PURE__ */J(h,{document:M,children:Q}):Q;j(()=>{if(M&&x)return me(M,S)},[M,x,S]),j(()=>{if(!M)return;const e=e=>{if("Enter"===e.key)return void G(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=S.getState();if("node"!==n.selection?.kind)return;const o=r(n.appState.data,S.config,n.selection);"node"===o?.kind&&S.select(o.id)};return M.addEventListener("keydown",e),()=>M.removeEventListener("keydown",e)},[M,S]);/* @__PURE__ */
13
+ return X("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":P?"":void 0,children:[P&&B.current?.target.toolbar?/* @__PURE__ */J(qe,{s:B.current.s,element:B.current.element,toolbar:B.current.target.toolbar,label:D.textTools,keys:L}):null,t?/* @__PURE__ */J(Me,{mirrorStyles:s,onDocument:e=>{A(e??void 0),a?.(e)},height:c,title:d,nonce:u,children:_}):/* @__PURE__ */J("div",{id:"preview-frame","data-puck-entry":"",children:_})]})}function Xe(e={}){const t=we(),n=be(e=>e.appState.data);return o({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Ue(){const e=we(),t=be(e=>e.config),n=e.resolveCache,o=be(e=>e.selectedItem),r=be(e=>e.appState.data.root),i=o?o.props.id:"root",s=r.props??{},a=W(()=>o||{type:"root",props:s},[o,s]),c=o?t.components[o.type]:t.root,d=e.getState(),u=o?S(d.appState.data,t,i):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=l({id:i,node:a,block:c,parent:f,appState:d.appState}),m=be(e=>!1===e.getPermissions(o?{item:o}:{root:!0}).edit),g=q(o=>{(async()=>{const r=e.getState();if("root"!==i){const l=r.getItemById(i),s=r.getSelectorForId(i);if(!l||!s)return;const a={...l,props:{...l.props,...o}},{node:c}=await V(a,t,{cache:n,trigger:"replace"}),d=e.getState().getSelectorForId(i);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const l=r.appState.data.root.props??{},{node:s}=await V({type:"root",props:{...l,...o}},t,{cache:n,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,t,n,i]),v=q((e,t)=>g({[e]:t}),[g]);return{id:i,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{Me as CanvasFrame,Fe as CanvasPassThroughContext,ue as DEFAULT_UI,Je as EaselCanvas,ye as EaselProvider,Ze as EditDocument,me as bindUndoKeys,he as createEasel,ke as createUseEasel,ne as recordsByDefault,ae as reduce,ie as uiView,be as useEasel,we as useEaselApi,Xe as useEaselNodeOps,Ue as useSelectedFields,le as validSelection};
@@ -0,0 +1,6 @@
1
+ import{DEFAULT_PICK_WORDS as e}from"./chunk-OFBZOI6W.js";import{parseHexColor as t,Popover as n,colorSwatchClasses as r,colorFill as l,ColorPickerPanel as i}from"efficient-shell/ui";export{hexToHsv,hsvToHex}from"efficient-shell/ui";import{useRef as a,useState as s,useLayoutEffect as o,useEffect as c}from"react";import{jsx as u,jsxs as p}from"react/jsx-runtime";var d=t,h=7,m=e=>e.toUpperCase(),g=(e,t,n)=>Math.min(n,Math.max(t,e));function f(e,t,n){return{s:n.width>0?g((e-n.left)/n.width,0,1):0,v:n.height>0?1-g((t-n.top)/n.height,0,1):0}}function v(e,t){return t.width>0?360*g((e-t.left)/t.width,0,1):0}function w({value:t,onChange:i,label:h,theme:g,caption:f,inherited:v,after:w,id:x,readOnly:C,words:y=e.colour}){const E=a(null),L=a(null),N=()=>{const e=E.current?.parentElement;return e?.classList.contains("es-field-head")?e.querySelector(":scope > .es-field-name .es-field-label"):e?.classList.contains("es-pick-line")?e.querySelector(":scope > .es-pick-line-label"):null},O=()=>L.current?.querySelector(".es-pick-hexwrap > *")??null,B=e=>e.scrollWidth>e.clientWidth+1,R=e=>{e&&(B(e)?e.dataset.clipped="true":delete e.dataset.clipped)},D=a(()=>{});D.current=()=>{R(N()),W||R(O())};const[T,S]=s(null),[W,M]=s(null);o(()=>D.current()),c(()=>{const e=E.current?.parentElement,t=e?.ownerDocument.defaultView;if(!e||!t?.ResizeObserver)return;const n=new t.ResizeObserver(()=>D.current());return n.observe(e),()=>n.disconnect()},[]),c(()=>{const e=E.current?.parentElement;if(!e)return;const t=e=>{const t=e;if(!t)return null;const n=N(),r=O();return n&&(t===n||n.contains(t))?n:r&&t===r?r:null},n=e=>{const n=t(e.target),r=P();if(!n||!r||n.ownerDocument.activeElement===n||!B(n))return;const l=n.getBoundingClientRect(),i=r.getBoundingClientRect(),a="INPUT"===n.tagName?n.value:n.textContent??"";S({text:a,left:l.left-i.left,top:l.top-i.top})},r=e=>{t(e.target)&&S(null)};return e.addEventListener("pointerover",n),e.addEventListener("pointerout",r),()=>{e.removeEventListener("pointerover",n),e.removeEventListener("pointerout",r)}},[]);const P=()=>{const e=E.current?.parentElement;return e&&(e.classList.contains("es-field-head")||e.classList.contains("es-pick-line"))?e:L.current},q=t?null:d(v??""),F=void 0===f||t&&d(f)===d(t)?null:f,U=F??(t?m(t):q?m(q):y.notSet);/* @__PURE__ */
2
+ return u("div",{ref:E,className:"es-pick-colour",children:/* @__PURE__ */p("div",{ref:L,className:"es-pick-colour-row","data-editing":W??void 0,onFocus:e=>{const t=e.target,n=P();if(!n||!t.classList.contains("es-pick-hex"))return;S(null),t.style.setProperty("--es-pick-edit-room",n.getBoundingClientRect().right-t.getBoundingClientRect().left+"px");const r=t.parentElement?.nextElementSibling,l=!!r&&t.getBoundingClientRect().right>r.getBoundingClientRect().left-2;M(l?"over":"room")},onBlur:e=>{const t=e.target;t.classList.contains("es-pick-hex")&&(t.style.removeProperty("--es-pick-edit-room"),M(null))},children:[
3
+ /* @__PURE__ */u(n,{id:x,className:"es-pick-swatch-wrap",trigger:/* @__PURE__ */u("span",{"aria-hidden":"true",style:{position:"absolute",inset:0,...l(t||q)}}),triggerLabel:y.swatch({label:h,shown:U}),triggerClassName:r({className:t?"es-pick-swatch":q?"es-pick-swatch is-inherited":"es-pick-swatch is-unset"}),"aria-label":y.dialog({label:h}),disabled:C,children:/* @__PURE__ */u(k,{value:t,onChange:i,label:h,theme:g,inherited:v,readOnly:C})}),
4
+ /* @__PURE__ */u("span",{className:"es-pick-hexwrap",children:null===F?/* @__PURE__ */u(b,{value:t,follows:q?m(q):void 0,onChange:e=>{C||e===t||i(e)},name:y.hex({label:h}),readOnly:C}):/* @__PURE__ */u("span",{className:"es-pick-caption",children:F})}),w,T?/* @__PURE__ */u("span",{className:"es-pick-tag","aria-hidden":"true",style:{left:T.left,top:T.top},children:T.text}):null]})})}function k({value:e,onChange:t,label:n,theme:r,onClose:l,id:a,inherited:s,readOnly:o,words:c,swatch:p,dragWrites:d="live"}){/* @__PURE__ */
5
+ return u(i,{id:a,className:"es-pick-window",value:e,onChange:t,label:n,presets:r?.map(e=>({value:e.value,label:e.name})),fallback:s,dragWrites:d,disabled:o,onClose:l})}function b({value:e,follows:t,onChange:n,name:r,readOnly:l}){const[i,o]=s(null),c=a(!1);/* @__PURE__ */
6
+ return u("input",{type:"text",className:!e&&t?"es-pick-hex is-inherited":"es-pick-hex",value:i??(e?m(e):t??""),"aria-label":r,maxLength:7,spellCheck:!1,autoComplete:"off",readOnly:l,onChange:t=>{o(t.target.value);const r=d(t.target.value);null!==r&&r!==e&&n(r)},onFocus:e=>e.currentTarget.select(),onMouseDown:e=>{c.current=e.currentTarget.ownerDocument.activeElement!==e.currentTarget},onMouseUp:e=>{c.current&&e.preventDefault(),c.current=!1},onKeyDown:e=>{"Enter"!==e.key&&"Escape"!==e.key||(e.preventDefault(),e.stopPropagation(),o(null),e.currentTarget.blur())},onBlur:()=>o(null)})}export{w as ColourPicker,k as ColourWindow,h as HEX_MAX_LENGTH,m as hexReadout,v as hueFromPoint,f as svFromPoint,d as typedHex};
@@ -0,0 +1 @@
1
+ import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{useHostEscape as n}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-VVPZMWJE.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{createNodeClipboard as l,nodeMenuItems as r}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as i}from"./chunk-WK3AFPXY.js";import{ROOT_ZONE as c}from"./chunk-PLVEGYK6.js";import{easelMenuEntries as s,menuLabel as a}from"./chunk-BALFHI3G.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-X4T6JT3M.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,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,SettingsIcon as z,LayersIcon as P,CopyIcon as O}from"efficient-shell/icons/efficient";import{jsx as A}from"react/jsx-runtime";function D(e,n){const t=[],o=/* @__PURE__ */new Set;let l={zone:n.zone,index:n.index};for(;l;){const n=e.nodeAt(l.zone,l.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:l.zone,index:l.index,node:n,parentType:null}),l.zone===c)break;const r=l.zone.lastIndexOf(":");if(r<=0)break;l=e.locate(l.zone.slice(0,r))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var K=l(),M=/* @__PURE__ */new WeakMap;function j(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",l);let t=M.get(n);return t||(t=l(),M.set(n,t)),t}function S(){return j(e())}function T(e,n,t){if(n===c){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,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 X(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?T(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=T(e,l.zone,l.index+1);if(o(n,t))return t}return null}function L(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 V(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=X(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:E(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function I(e,n){const{zone:t,index:l}=n,i=e.nodeAt(t,l);if(!i)return[];const s=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),h=e.permits?.(i)??{duplicate:!0,delete:!0},y=X(e,i,t),k=D(e,n),b=d.held,v=b&&!p?E(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,l,i),words:e.words?.styleClipboard}):[];return r({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)},l=n.zone===c?null:e.slotRung?.(n.zone)??null;return l?[o,{label:l.label,checked:!1,onClick:l.select}]:[o]})},actions:{duplicate:g&&m&&h.duplicate?()=>d.duplicate(s):void 0,moveUp:g&&d.canStep(s,-1)?()=>d.step(s,-1):void 0,moveDown:g&&d.canStep(s,1)?()=>d.step(s,1):void 0,copy:y.copy?()=>d.copy(s,a):void 0,cut:g&&y.cut?()=>d.cut(s,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,l):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(s,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(s):void 0},style:w,extras:e.menuRows?.(i,t,l)??void 0,pinnedLine:p?R(e).pinned:void 0})}var R=e=>e.words?.screen??t.menu;function B(e){const n=R(e),o=!e.readOnly,l=[];o&&e.history.hasPast&&l.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&l.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const r=[],s=e.nodeOps.held,a=T(e,c,e.sectionBand().cap);if(o&&s&&(e.canPasteAt?e.canPasteAt(s,a):f(s.from)===c)){const n=a,t=e.words?.menu??i;r.push({label:t.pasteNamed({paste:t.paste,label:s.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[l,r,[{label:e.pageSettingsLabel??t.pageSettings,icon:/* @__PURE__ */A(z,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(P,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function U(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}))},c=e.words?.menu??i,s=R(e),a=[];l&&(a.push({label:c.copy,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),a.push({label:c.cut,icon:/* @__PURE__ */A(O,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),a.push({label:c.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[a,n.value?[{label:s.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 Y(e){return e.shiftKey}function F(e,t){const[o,l]=y(null),r=k(()=>l(null),[]);n(null!==o,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=L(e);if(!o)return;const l=t.selected();if(!l)return;const r=V(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),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(Y(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(Y(n)||!t)return;const o=n.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;n.preventDefault();const c=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(N,{host:e,target:o,onClose:r}):null,closeMenu:r}}function N({host:e,target:n,onClose:t}){const o="node"===n.kind?I(e,n):"input"===n.kind?U(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":a(o),items:s(o)})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,j as nodeClipboardOf,X as nodeClipboardRules,I as nodeMenuItems,L as nodeShortcut,B as pageMenuItems,E as pastePlace,V as runNodeShortcut,U as textMenuItems,S as useNodeClipboard,F as useNodeContextMenu};
@@ -0,0 +1 @@
1
+ import{easelMenuEntries as o,menuLabel as e}from"./chunk-BALFHI3G.js";import{ContextMenu as r}from"efficient-shell/ui";import{jsx as t}from"react/jsx-runtime";function n({x:n,y:l,items:i,onClose:m,owner:s,portalTo:u}){return 0===i.length?null:/* @__PURE__ */t(r,{at:{x:n,y:l},owner:s??u??null,onClose:m,"aria-label":e(i),items:o(i)})}export{n as EaselContextMenu};
@@ -0,0 +1 @@
1
+ import{useState as t,useEffect as e,useRef as n}from"react";var o=/* @__PURE__ */new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function r(t){const e=t;if(!e||"string"!=typeof e.tagName)return!1;const n=e.tagName.toUpperCase();if("TEXTAREA"===n||"SELECT"===n)return!0;if("INPUT"===n)return!o.has(String(e.type??"text").toLowerCase());if(e.isContentEditable)return!0;const r=e.closest?.("[contenteditable]");return!(!r||"false"===r.getAttribute("contenteditable"))||null!=e.closest?.('[role="textbox"]')}var i="data-puck-component";function c(t,e=i){const n=t;return n&&"function"==typeof n.closest?n.closest(`[${e}]`)?.getAttribute(e)??null:null}function u(t){const e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return{left:e.left,top:e.top,width:e.width,height:e.height};let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const e of Array.from(t.children)){const t=e.getBoundingClientRect();t.width<=0||t.height<=0||(n=Math.min(n,t.left),o=Math.min(o,t.top),r=Math.max(r,t.right??t.left+t.width),i=Math.max(i,t.bottom??t.top+t.height))}return n===1/0?{left:e.left,top:e.top,width:e.width,height:e.height}:{left:n,top:o,width:r-n,height:i-o}}function l(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function s(t,e,n){const o=t.getBoundingClientRect(),r=n?.getBoundingClientRect()??{left:0,top:0},i=l(t);return{left:o.left-r.left+e.left*i,top:o.top-r.top+e.top*i,width:e.width*i,height:e.height*i}}function a(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function d(t,e,n){const o=s(t,e,n),r=a(n);return{left:o.left/r,top:o.top/r,width:o.width/r,height:o.height/r}}function f(t,e,n){const o=t.getBoundingClientRect(),r=a(t);return{x:(e-o.left)/r,y:(n-o.top)/r}}function h(t,e,n,o){const{left:r,top:i}=s(t,{left:e,top:n,width:0,height:0},o);return{x:r,y:i}}function m({available:t,width:e,maxScale:n=1}){const o=Math.max(0,t);if(!e||e<=0)return{width:o,scale:1,shownWidth:o};const r=o>0?Math.min(o/e,n):1;return{width:e,scale:r,shownWidth:e*r}}var w="data-es-canvas-style",g=/* @__PURE__ */new WeakMap;function p(t,e){e?g.set(t,e):g.delete(t)}function b(t,e,n){const o=t.head??t.documentElement;let r=y(t,e);if(!r){r=t.createElement("style"),r.setAttribute(w,e);const n=g.get(t);n&&r.setAttribute("nonce",n),o.appendChild(r)}return r.textContent!==n&&(r.textContent=n),r}function v(t,e){y(t,e)?.remove()}function y(t,e){for(const n of Array.from(t.querySelectorAll(`style[${w}]`)))if(n.getAttribute(w)===e)return n;return null}var E="[data-puck-component]",A="[data-puck-dropzone]",C="iframe#preview-frame";function L(t){const e=t.contentDocument;if(!e||!t.contentWindow||"loading"===e.readyState||!e.body)return!1;if(t.hasAttribute("srcdoc"))return"about:srcdoc"===e.URL;const n=t.getAttribute("src");return!n||"about:blank"===n||"about:blank"!==e.URL}function x(t,e,{selector:n=C,readySelector:o}={}){let r=null,i=null,c=!1,u=!1,l=null;const s=()=>{l?.observer.disconnect(),l=null},a=()=>{if(u)return;let t=null;if(r&&L(r)){const e=r.contentDocument;(t=>{if(!o||t.querySelector(o))return s(),!0;if(l?.doc!==t){s();const e=t.defaultView?.MutationObserver;if(e){const n=new e(()=>a());n.observe(t,{childList:!0,subtree:!0}),l={doc:t,observer:n}}}return!1})(e)&&(t={frame:r,document:e,window:r.contentWindow})}else s();(t===i||!!t&&!!i&&t.frame===i.frame&&t.document===i.document)&&c||(c=!0,i=t,e(i))},d=()=>a(),f=()=>{const e=t.querySelector?.(n);e!==r?(r?.removeEventListener("load",d),r=e,r?.addEventListener("load",d),a()):a()},h=t.ownerDocument?.defaultView??t.defaultView,m=h?.MutationObserver,w=m?new m(t=>(t=>null!==r&&!r.isConnected||t.some(t=>[...t.addedNodes,...t.removedNodes].some(t=>"IFRAME"===t.nodeName||!!t.querySelector?.("iframe"))))(t)&&f()):null;return w?.observe(t,{childList:!0,subtree:!0}),f(),()=>{u=!0,w?.disconnect(),s(),r?.removeEventListener("load",d),r=null}}function M(n,{selector:o,readySelector:r}={}){const[i,c]=t(null);return e(()=>{const t=n.current;if(!t)return;const e=x(t,c,{selector:o,readySelector:r});return()=>{e(),c(null)}},[n,o,r]),i}var R="easel:canvas-typing",S="easel:canvas-typable";function B(t,o,r,{on:i="document",capture:c=!1}={}){const u=n(r);u.current=r;const l=t?.document??null,s=t?.window??null;e(()=>{const t="window"===i?s:l;if(!t)return;const e=t=>u.current(t);return t.addEventListener(o,e,c),()=>t.removeEventListener(o,e,c)},[l,s,o,i,c])}function k(e){const[n,o]=t(!1);return B(e,R,t=>o(Boolean(t.detail?.typing))),n}function W(t,n,o){const r=t?.document??null;e(()=>{if(!r)return;if(!o)return void v(r,n);const t=b(r,n,o),e=r.defaultView?.MutationObserver,i=e?new e(()=>{t.isConnected||b(r,n,o)}):null;return i?.observe(r.head??r.documentElement,{childList:!0}),()=>{i?.disconnect(),v(r,n)}},[r,n,o])}function q(n,{settle:o=[150,450]}={}){const[r,i]=t(0),c=n?.frame??null,u=n?.document??null,l=n?.window??null,s=o.join(",");return e(()=>{if(!c||!u||!l)return;const t=c.ownerDocument.defaultView;let e=!1,n=0;const r=()=>{if(e)return;e=!0;const o=()=>{e=!1,i(t=>t+1)};t?.requestAnimationFrame?n=t.requestAnimationFrame(o):o()},s=[],a=(t,e)=>{t.addEventListener(e,r,!0),s.push(()=>t.removeEventListener(e,r,!0))};a(u,"scroll"),a(l,"resize"),t&&(a(t,"scroll"),a(t,"resize"));const d=t?.ResizeObserver;if(d){const t=new d(r);t.observe(c),u.documentElement&&t.observe(u.documentElement),s.push(()=>t.disconnect())}const f=u.defaultView?.MutationObserver,h=u.body??u.documentElement;if(f&&h){const t=new f(r);t.observe(u===c.ownerDocument?c:h,{childList:!0,subtree:!0}),s.push(()=>t.disconnect())}const m=u.fonts;m&&a(m,"loadingdone");const w=o.map(t=>setTimeout(r,t));return r(),()=>{for(const t of s)t();for(const t of w)clearTimeout(t);n&&t?.cancelAnimationFrame&&t.cancelAnimationFrame(n)}},[c,u,l,s]),r}export{i as BLOCK_ATTRIBUTE,E as BLOCK_SELECTOR,C as CANVAS_SELECTOR,S as CANVAS_TYPABLE_EVENT,R as CANVAS_TYPING_EVENT,A as LIST_SELECTOR,f as clientPointToLayer,u as drawnBox,a as elementScale,m as fitCanvas,h as framePointToHost,s as frameRectToHost,d as frameRectToLayer,l as frameScale,L as isFrameReady,r as isTypingTarget,c as nodeIdAt,v as removeCanvasStyle,p as setCanvasNonce,b as upsertCanvasStyle,B as useCanvasEvent,M as useCanvasFrame,q as useCanvasLayout,W as useCanvasStyle,k as useCanvasTyping,x as watchCanvasFrame};
@@ -273,8 +273,8 @@
273
273
  * The toolbar is efficient-shell's `TextToolbar` (S4/E2, harness UI-24): its
274
274
  * grid, its sizes, its narrow step and its colour fill are the shell's sheet
275
275
  * (`.rosh-tb-*` in ui.css), held by the shell's own specs. Its wrapper is the
276
- * size container; its direct children carry `--rosh-tb-size`,
277
- * `--rosh-tb-steps`, `--rosh-tb-color-col` and `--rosh-tb-link-col`, and the
276
+ * size container; its direct children carry `--rosh-tb-size` and the two
277
+ * window buttons' centres, `--rosh-tb-color-x` and `--rosh-tb-link-x`, and the
278
278
  * two windows below are drawn among them, so they read those. What stays here
279
279
  * is the toolbar's place in the box: the gap under it.
280
280
  */
@@ -311,11 +311,11 @@
311
311
  box-shadow: var(--rosh-glass-solid-shadow);
312
312
  }
313
313
 
314
- /* The point, aimed at its button: column k of row 1 across the box (100cqw),
315
- whose cells are `--rosh-tb-steps` + 1 (nine, or eight with no host control).
316
- Row 1 draws only what the host offers, so k is the button's column as
317
- drawn: the shell's toolbar writes `--rosh-tb-color-col` and `--rosh-tb-link-col` on
318
- its wrapper (`textToolbarWindowColumns`), never a fixed 4 or 5. */
314
+ /* The point, aimed at its button's centre, which the shell's toolbar says
315
+ for both of its layouts — the panel's nine-cell grid and the canvas's one
316
+ row (`--rosh-tb-color-x`, `--rosh-tb-link-x`, efficient-shell #566) — from
317
+ the button's column as drawn (`textToolbarWindowColumns`), never a fixed 4
318
+ or 5. Easel never re-derives the grid. */
319
319
  .es-copy-pop::before {
320
320
  content: '';
321
321
  position: absolute;
@@ -330,11 +330,11 @@
330
330
 
331
331
  /* Aimed at the words (measured), or — unmeasured — at its button, as above. */
332
332
  .es-copy-colors::before {
333
- left: var(--es-pop-point, calc(var(--rosh-tb-color-col) * (100cqw - var(--rosh-tb-size)) / var(--rosh-tb-steps) + var(--rosh-tb-size) / 2 - 6px));
333
+ left: var(--es-pop-point, calc(var(--rosh-tb-color-x) - 6px));
334
334
  }
335
335
 
336
336
  .es-copy-link.es-copy-pop::before {
337
- left: var(--es-pop-point, calc(var(--rosh-tb-link-col) * (100cqw - var(--rosh-tb-size)) / var(--rosh-tb-steps) + var(--rosh-tb-size) / 2 - 6px));
337
+ left: var(--es-pop-point, calc(var(--rosh-tb-link-x) - 6px));
338
338
  }
339
339
 
340
340
  /* Opened above the words: the point is on the bottom edge, aimed down. */
@@ -1,44 +1,17 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
3
2
  import { c as CopyBoxProps, d as CopyCell, T as TextBoxHandle } from '../canvas-typing-BsNigaCa.js';
4
3
  export { e as COPY_CELLS, b as CanvasTypingEnd, f as CanvasTypingOptions, g as CanvasTypingSession, h as ColorWindow, i as CopyBoxAlign, j as CopyBoxFooter, C as CopyBoxLastTool, k as CopyCase, l as CopyCellPreset, m as CopyCells, a as CopyThemeColor, M as MarkWriter, S as SelectionSource, n as TextAreaHandle, o as TextMap, p as ToolbarMark, q as colorRunOf, r as insertSelection, s as markSelection, t as startCanvasTyping, u as textMap } from '../canvas-typing-BsNigaCa.js';
5
- import { MarkStyle, MarkupTool, InlineRule, MarkedLine, WrapResult } from 'efficient-shell/markup';
6
4
  export { TextToolbar, TextToolbarProps } from 'efficient-shell/ui';
7
5
  import { F as FieldOption } from '../types-CDX6vd6A.js';
8
6
  import { a as CopyAlign } from '../words-D-yhjdOg.js';
9
7
  export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, C as CopyWords, f as copyAlignOptions } from '../words-D-yhjdOg.js';
10
8
  import { TextStyleCase } from '../text-styles/model.js';
9
+ import { InlineRule, MarkStyle, MarkedLine, WrapResult } from 'efficient-shell/markup';
11
10
  import '../buckets-Tj-nkBpg.js';
12
11
  import '../words-gIDCeRv3.js';
13
12
 
14
13
  declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, align, actions, toolbar, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, colors, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
15
14
 
16
- /** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
17
- * shortcut.
18
- * @deprecated The toolbar spells its own shortcuts. Removed in 12.0.0. */
19
- declare function ariaShortcut(shortcut: string | undefined): string | undefined;
20
- /** @deprecated Draw `TextToolbar` (`efficient-shell/ui`). Removed in 12.0.0. */
21
- interface MarkBarProps {
22
- /** The marks to offer: styles, or a host's descriptors (only `style` is read). */
23
- tools: readonly MarkStyle[] | readonly MarkupTool[];
24
- onApply: (style: MarkStyle) => void;
25
- disabled?: boolean;
26
- /** One control of the host's, drawn in row 1's last cell. */
27
- actions?: ReactNode;
28
- /** Not drawn: the toolbar's alignment is a value. */
29
- align?: ReactNode;
30
- /** Not drawn: the drawings are the shell set's. */
31
- glyphs?: Partial<Record<MarkStyle, ReactNode>>;
32
- /** The toolbar's accessible name; "Formatting" (`EaselStrings.copy.formatting`) by default. */
33
- ariaLabel?: string;
34
- /** The marks the selection already wears. */
35
- pressed?: Partial<Record<MarkStyle, boolean>>;
36
- /** The style whose own window is open (`'link'` lights the link button). */
37
- open?: MarkStyle | null;
38
- }
39
- /** @deprecated Draw `TextToolbar` (`efficient-shell/ui`). Removed in 12.0.0. */
40
- declare function MarkBar({ tools, onApply, disabled, actions, ariaLabel, pressed, open }: MarkBarProps): react.JSX.Element;
41
-
42
15
  /** Whether the lines are a list, and which kind. */
43
16
  type TextList = 'none' | 'bullet' | 'number';
44
17
  /** How the letters are drawn: as typed, all capitals, each word capitalized,
@@ -350,4 +323,4 @@ interface CaretEdit {
350
323
  */
351
324
  declare function useCaretEdit({ target, onChange }: CaretEdit): (edit: (el: HTMLInputElement | HTMLTextAreaElement | null) => WrapResult) => void;
352
325
 
353
- export { type CaretEdit, CopyAlign, CopyBox, CopyBoxProps, CopyCell, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInputEvent, type RichInputResult, type RichInsert, type RichLayout, type RichLine, type RichPending, type Snapshot, TYPING_BURST_MS, TextBoxHandle, type TextCase, type TextList, TextPartPanel, type TextPartPanelProps, type TextPartStrip, ariaShortcut, createHistory, editVisible, markupOfRange, newLine, pasteToMarkup, richInput, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
326
+ export { type CaretEdit, CopyAlign, CopyBox, CopyBoxProps, CopyCell, type History, MARKUP_CLIPBOARD_TYPE, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInputEvent, type RichInputResult, type RichInsert, type RichLayout, type RichLine, type RichPending, type Snapshot, TYPING_BURST_MS, TextBoxHandle, type TextCase, type TextList, TextPartPanel, type TextPartPanelProps, type TextPartStrip, createHistory, editVisible, markupOfRange, newLine, pasteToMarkup, richInput, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
@@ -1,18 +1,17 @@
1
- import{TEXT_STYLE_CASES as e}from"../chunk-YHZSBL2N.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,colorRunOf as o,textRange as a,selectionBox as s,placeWindow as i,offsetOrigin as c,visibleArea as u,ColorWindow as d,markPress as p,pasteToMarkup as m,richInput as h,editVisible as f,MARKUP_CLIPBOARD_TYPE as g,markupOfRange as y}from"../chunk-NY7HHUGB.js";export{ColorWindow,MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,colorRunOf,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-NY7HHUGB.js";import{DEFAULT_COPY_WORDS as v}from"../chunk-B4JN227A.js";import{FieldNumber as b}from"../chunk-2XMHLXMA.js";import{FieldSelect as S}from"../chunk-G3GWAP5R.js";import"../chunk-WRFD4EXD.js";import{SettingsSwitch as k,SettingsField as x,SettingsSegmented as w}from"../chunk-36LVP5WD.js";import{GoldTextInput as E}from"../chunk-H4UMY7QF.js";import{useWords as C}from"../chunk-MFIRYGHW.js";import{TextToolbar as D,registerModalEscapeInterceptor as N,textToolbarRows as L,LinkPicker as O,Tooltip as T,IconButton as R}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as H,useState as K,useLayoutEffect as M,useEffect as P,useId as j}from"react";import{RETIRED_MARKS as B,applyMark as F,marksIn as $,STANDARD_MARKUP as V,listIn as z,colorIn as U,spanFor as W,findLink as A,colorOver as Y,setList as I,unlinkAt as G,removeLink as q,linkOver as _,writeLink as X}from"efficient-shell/markup";import{jsxs as Z,jsx as J,Fragment as Q}from"react/jsx-runtime";import{ParagraphSpacingIcon as ee,LetterSpacingIcon as te,LineSpacingIcon as ne,TextSizeIcon as re,AlignJustifyIcon as le,AlignRightIcon as oe,AlignCenterIcon as ae,AlignLeftIcon as se,StylesIcon as ie,TypeIcon as ce,AlignmentIcon as ue,ListFormatIcon as de,CaseIcon as pe,ItalicIcon as me,NumberedListIcon as he,ListIcon as fe,ListNoneIcon as ge,CaseLowerIcon as ye,CaseCapitalizedIcon as ve,CaseUpperIcon as be,CaseNormalIcon as Se}from"efficient-shell/icons/efficient";function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=F){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Ee(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ce(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function De(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function Ne({value:e,rules:l,multiline:o,readOnly:a=!1,placeholder:s,ariaLabel:i,handle:c,onEdit:u,onSelect:d,onHistory:p,onFormat:v,pending:b,onCommit:S,onCancel:k}){const x=H(null),w=H(null),E=H(null),C=H(null),D=H(null),N=H(e),[L,O]=K(0),T=H({value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v});T.current={value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v};const R=()=>{const e=x.current,t=w.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ce(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ce(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},j=(e,t)=>{const n=x.current,r=w.current;if(!n||!r)return;const[l,o]=De(r,e),[a,s]=De(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};c.current={getSource(){const e=R(),t=w.current;if(!e||!t)return null;const[r,l]=n(t.layout,e[0],e[1]);return{start:r,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},O(e=>e+1)},focus(){x.current?.focus()},rangeOf(e,n){const r=x.current,l=w.current;if(!r||!l)return null;const[o,a]=t(l.layout,e,n),[s,i]=De(l,o),[c,u]=De(l,a),d=r.ownerDocument.createRange();return d.setStart(s,i),d.setEnd(c,u),d}},M(()=>{const n=x.current;if(!n||D.current)return;const o=C.current?null:R();w.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Ee(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,r(e,l)),E.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&n.ownerDocument.activeElement===n&&j(o[0],Math.min(o[1],w.current.layout.text.length)));C.current=null;const s=w.current.layout,[i,c]=a.vis??t(s,a.src[0],a.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),j(i,c)},[e,l,L]);const B=(e,t,r)=>{const l=w.current,[o,a]=n(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==T.current.value?T.current.onEdit(e.text,{start:o,end:a},r):O(e=>e+1)};P(()=>{const e=x.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=T.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=w.current,i=R();if(!s||!i)return;const c="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,u=c&&!c.collapsed?[Ce(s,e,c.startContainer,c.startOffset),Ce(s,e,c.endContainer,c.endOffset)]:null,d=h({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:i,target:u,pending:a});d&&("history"!==d.kind?"format"!==d.kind?B(d.edit,d.range,d.kind):T.current.onFormat(d.style):T.current.onHistory(d.dir))},n=()=>{D.current||O(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),P(()=>{const e=x.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=c.current?.getSource();e&&d(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const F=(t,n=!1)=>{const r=R();if(!r||r[0]===r[1])return;t.preventDefault();const o=w.current;t.clipboardData.setData("text/plain",o.layout.text.slice(r[0],r[1])),t.clipboardData.setData(g,y(e,l,r[0],r[1])),n&&!a&&B(f(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
1
+ import{TEXT_STYLE_CASES as e}from"../chunk-YHZSBL2N.js";import{selectionToVisible as t,selectionToSource as n,richLayout as r,createHistory as l,colorRunOf as o,textRange as a,selectionBox as s,placeWindow as c,offsetOrigin as i,visibleArea as u,ColorWindow as d,markPress as p,pasteToMarkup as m,richInput as h,editVisible as f,MARKUP_CLIPBOARD_TYPE as g,markupOfRange as y}from"../chunk-23VM4PMV.js";export{ColorWindow,MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,colorRunOf,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as v}from"../chunk-B4JN227A.js";import{FieldNumber as b}from"../chunk-2XMHLXMA.js";import{FieldSelect as S}from"../chunk-G3GWAP5R.js";import"../chunk-WRFD4EXD.js";import{SettingsSwitch as k,SettingsField as x,SettingsSegmented as w}from"../chunk-36LVP5WD.js";import{GoldTextInput as E}from"../chunk-H4UMY7QF.js";import{useWords as C}from"../chunk-MFIRYGHW.js";import{registerModalEscapeInterceptor as D,textToolbarRows as N,TextToolbar as L,LinkPicker as O,Tooltip as T,IconButton as R}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as M,useState as P,useLayoutEffect as K,useEffect as V,useId as F}from"react";import{RETIRED_MARKS as H,applyMark as j,marksIn as B,STANDARD_MARKUP as $,listIn as z,colorIn as W,spanFor as A,findLink as I,colorOver as U,setList as Y,unlinkAt as q,removeLink as G,linkOver as _,writeLink as X}from"efficient-shell/markup";import{jsxs as Z,jsx as J,Fragment as Q}from"react/jsx-runtime";import{ParagraphSpacingIcon as ee,LetterSpacingIcon as te,LineSpacingIcon as ne,TextSizeIcon as re,AlignJustifyIcon as le,AlignRightIcon as oe,AlignCenterIcon as ae,AlignLeftIcon as se,StylesIcon as ce,TypeIcon as ie,AlignmentIcon as ue,ListFormatIcon as de,CaseIcon as pe,ItalicIcon as me,NumberedListIcon as he,ListIcon as fe,ListNoneIcon as ge,CaseLowerIcon as ye,CaseCapitalizedIcon as ve,CaseUpperIcon as be,CaseNormalIcon as Se}from"efficient-shell/icons/efficient";function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=j){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Ee(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ce(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function De(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function Ne({value:e,rules:l,multiline:o,readOnly:a=!1,placeholder:s,ariaLabel:c,handle:i,onEdit:u,onSelect:d,onHistory:p,onFormat:v,pending:b,onCommit:S,onCancel:k}){const x=M(null),w=M(null),E=M(null),C=M(null),D=M(null),N=M(e),[L,O]=P(0),T=M({value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v});T.current={value:e,rules:l,multiline:o,readOnly:a,pending:b,onEdit:u,onHistory:p,onFormat:v};const R=()=>{const e=x.current,t=w.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ce(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ce(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},F=(e,t)=>{const n=x.current,r=w.current;if(!n||!r)return;const[l,o]=De(r,e),[a,s]=De(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};i.current={getSource(){const e=R(),t=w.current;if(!e||!t)return null;const[r,l]=n(t.layout,e[0],e[1]);return{start:r,end:l}},setSource(e,t,n){C.current={text:n,src:[e,t]},O(e=>e+1)},focus(){x.current?.focus()},rangeOf(e,n){const r=x.current,l=w.current;if(!r||!l)return null;const[o,a]=t(l.layout,e,n),[s,c]=De(l,o),[i,u]=De(l,a),d=r.ownerDocument.createRange();return d.setStart(s,c),d.setEnd(i,u),d}},K(()=>{const n=x.current;if(!n||D.current)return;const o=C.current?null:R();w.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Ee(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,r(e,l)),E.current=e;const a=C.current;if(!a||a.text!==e)return void(o&&n.ownerDocument.activeElement===n&&F(o[0],Math.min(o[1],w.current.layout.text.length)));C.current=null;const s=w.current.layout,[c,i]=a.vis??t(s,a.src[0],a.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),F(c,i)},[e,l,L]);const H=(e,t,r)=>{const l=w.current,[o,a]=n(l.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==T.current.value?T.current.onEdit(e.text,{start:o,end:a},r):O(e=>e+1)};V(()=>{const e=x.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=T.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=w.current,c=R();if(!s||!c)return;const i="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,u=i&&!i.collapsed?[Ce(s,e,i.startContainer,i.startOffset),Ce(s,e,i.endContainer,i.endOffset)]:null,d=h({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:c,target:u,pending:a});d&&("history"!==d.kind?"format"!==d.kind?H(d.edit,d.range,d.kind):T.current.onFormat(d.style):T.current.onHistory(d.dir))},n=()=>{D.current||O(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),V(()=>{const e=x.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=i.current?.getSource();e&&d(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const j=(t,n=!1)=>{const r=R();if(!r||r[0]===r[1])return;t.preventDefault();const o=w.current;t.clipboardData.setData("text/plain",o.layout.text.slice(r[0],r[1])),t.clipboardData.setData(g,y(e,l,r[0],r[1])),n&&!a&&H(f(e,l,r[0],r[1],{text:""}),r,"edit")};/* @__PURE__ */
2
2
  return Z("div",{className:"es-rich-wrap",children:[s&&""===e?/* @__PURE__ */J("div",{className:"es-rich-placeholder","aria-hidden":"true",children:s}):null,
3
- /* @__PURE__ */J("div",{ref:x,className:`es-rich${o?" is-multiline":" is-single"}${a?" is-off":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":i,"aria-readonly":a||void 0,"aria-placeholder":s,tabIndex:a?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&S?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),k?.(N.current),void(N.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==N.current&&S?.(e),N.current=e)},onCompositionStart:()=>{const e=R()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=T.current;e.data?B(f(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):O(e=>e+1)},onCopy:e=>F(e),onCut:e=>F(e,!0),onPaste:t=>{if(t.preventDefault(),a)return;const n=R();if(!n)return;const r=t.clipboardData.getData(g),s=r?o?r:r.replace(/\s*\r?\n\s*/g," "):m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:o,rules:l});B(f(e,l,n[0],n[1],{markup:s}),n,"edit")}})]})}var Le={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */J(re,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */J(ne,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */J(te,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */J(ee,{}),unit:"px",step:1,shiftStep:10,min:0}};function Oe(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Te({cells:e,words:t,readOnly:n=!1}){const r=t??v.cells,l=j();/* @__PURE__ */
4
- return J("div",{className:"es-copy-cells-fit",children:/* @__PURE__ */J("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,o=e.name??(e.nameKey?r[e.nameKey]:e.key),a=e.unit??"",s=e.step??1,i=`${l}-${e.key}`;/* @__PURE__ */
3
+ /* @__PURE__ */J("div",{ref:x,className:`es-rich${o?" is-multiline":" is-single"}${a?" is-off":""}`,contentEditable:!a,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":o,"aria-label":c,"aria-readonly":a||void 0,"aria-placeholder":s,tabIndex:a?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&S?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),k?.(N.current),void(N.current=e);"Enter"!==t.key||o||(t.preventDefault(),e!==N.current&&S?.(e),N.current=e)},onCompositionStart:()=>{const e=R()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=T.current;e.data?H(f(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):O(e=>e+1)},onCopy:e=>j(e),onCut:e=>j(e,!0),onPaste:t=>{if(t.preventDefault(),a)return;const n=R();if(!n)return;const r=t.clipboardData.getData(g),s=r?o?r:r.replace(/\s*\r?\n\s*/g," "):m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:t.currentTarget.ownerDocument,multiline:o,rules:l});H(f(e,l,n[0],n[1],{markup:s}),n,"edit")}})]})}var Le={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */J(re,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */J(ne,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */J(te,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */J(ee,{}),unit:"px",step:1,shiftStep:10,min:0}};function Oe(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Te({cells:e,words:t,readOnly:n=!1}){const r=t??v.cells,l=F();/* @__PURE__ */
4
+ return J("div",{className:"es-copy-cells-fit",children:/* @__PURE__ */J("div",{className:"es-copy-cells",children:e.map(e=>{const t=e.scale??1,o=e.name??(e.nameKey?r[e.nameKey]:e.key),a=e.unit??"",s=e.step??1,c=`${l}-${e.key}`;/* @__PURE__ */
5
5
  return Z("div",{className:"es-copy-cell",children:[
6
- /* @__PURE__ */J("label",{className:"es-field-label es-copy-cell-name",htmlFor:i,children:o}),
7
- /* @__PURE__ */J(b,{id:i,value:Oe(e.value,t),styleValue:Oe(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:a||void 0,steppers:"compact",readOnly:n,ariaLabel:o,title:r.tip({name:o,step:s,unit:a})})]},e.key)})})})}function Re({target:e,onChange:t}){const n=H(null);return M(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var He=/* @__PURE__ */new Set([...B,"clear"]);function Ke(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}function Me({tools:e,onApply:t,disabled:n=!1,actions:r,ariaLabel:l,pressed:o,open:a=null}){const s=C("copy",v),i=("string"==typeof e[0]?e:e.map(e=>e.style)).filter(e=>!He.has(e));/* @__PURE__ */
8
- return J(D,{"aria-label":l??s.formatting,offered:new Set(i),pressed:o??{},onMark:e=>t(e),linkOpen:"link"===a,list:i.includes("bullet")||i.includes("number")?{pressed:null,onList:e=>t(e)}:void 0,last:r,disabled:n})}function Pe({value:e,onChange:t,onCommit:n,onCancel:r,multiline:h=!1,placeholder:f,ariaLabel:g,className:y,readOnly:b=!1,rules:S,tools:x=[],writeMark:w,align:T,actions:R,toolbar:B,barLabel:ee,renderFooter:te,inputRef:ne,barShows:re="always",richText:le=!0,defaultShowMarks:oe=!1,colors:ae,cells:se,letterCase:ie,lastTool:ce}){const ue=C("copy",v),de=H(null),pe=ne??de,[me,he]=K(!1),[fe,ge]=K(null),ye=H(l()).current,ve=H(null);P(()=>{const t=ve.current;t&&e===t.to?ve.current=null:t&&e===t.from||(ve.current=null,ye.reset())},[e,ye]);const be=n=>{ve.current={from:ve.current?.from??e,to:n},t(n)},Se=t=>({text:e,start:t?.selectionStart??fe?.start??e.length,end:t?.selectionEnd??fe?.end??e.length}),[ke,Ee]=K(oe),Ce=le&&!(h&&ke),De=H(null),Le=j(),[Oe,Ke]=K(null),[Me,Pe]=K(!1),je=()=>{if(!Ce)return pe.current;const e=De.current?.getSource()??fe;return e?{selectionStart:e.start,selectionEnd:e.end}:null},Be=Re({target:pe,onChange:be}),Fe=e=>(ge({start:e.selectionStart,end:e.selectionEnd}),e),$e=(t,n)=>{if(!Ce)return void Be(e=>(n&&ye.record(Se(e),"edit",Date.now()),Fe(t(e))));const r=je(),l=Fe(t(r));n&&ye.record(Se(r),"edit",Date.now()),Ke(null),l.text!==e&&be(l.text),De.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},Ve=e=>$e(e,!0),ze=e=>$e(t=>{const n=Se(t),r=ye[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),Ue=H(null);M(()=>{const t=Ue.current;t&&(Ue.current=null,Ce?De.current?.setSource(t.start,t.end,e):(pe.current?.focus(),pe.current?.setSelectionRange(t.start,t.end),ge(t)))},[Ce]);const[We,Ae]=K(null),Ye=S??V,Ie=("string"==typeof x[0]?x:x.map(e=>e.style)).filter(e=>!He.has(e)),Ge={};if(fe){const t=$(e,fe.start,fe.end,Ye);for(const e of Ie){const n=t.has(e)||"highlight"===e&&t.has("accent");Ge[e]=!!Oe?.add.includes(e)||!Oe?.drop.includes(e)&&n}Ge.link=t.has("link")}const qe=()=>{const t=je(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},_e=t=>{if("link"!==t&&W(0,t)){const{start:n,end:r}=qe();if(n===r&&!Ce)return void Ve(n=>xe(e,t,n,(e,t,n,r)=>F(e,t,n,r,Ye,ue.placeholders)));const l=p({value:e,rules:Ye,start:n,end:r,style:t,pending:Oe});return void("pending"===l.kind?Ke(l.pending):Ve(()=>l.result))}if("link"!==t){const n=w??((e,t,n,r)=>F(e,t,n,r,V,ue.placeholders));return void Ve(r=>xe(e,t,r,n))}const n=je(),r=n?.selectionStart??e.length,l=n?.selectionEnd??r;Pe(!1),Ae({start:r,end:l,link:A(e,r,l)})},Xe=Boolean(fe&&fe.start!==fe.end),Ze=fe?z(e,fe.start,fe.end,Ye):null,Je=fe?Oe&&void 0!==Oe.color&&Oe.at===fe.start?Oe.color:U(e,fe.start,fe.end,Ye):null,Qe=o(Je,ae),et=t=>{Ce?t?De.current?.setSource(t.start,t.end,e):De.current?.focus():(pe.current?.focus(),t&&pe.current?.setSelectionRange(t.start,t.end))},tt=()=>{const e=We;Ae(null),et(e?{start:e.start,end:e.end}:fe)},nt=()=>{const e=lt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Pe(!1),t&&et(fe)},rt=H(nt);rt.current=nt,P(()=>{if(Me)return N(e=>{const t=lt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(rt.current(),!0)},()=>lt.current?.querySelector(".es-copy-colors"))},[Me]);const lt=H(null),ot=Me||null!==We;P(()=>{const e=lt.current;if(!ot||!e)return;const t=e.ownerDocument,n=()=>{Pe(!1),Ae(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[ot]);const at=We??(Me?fe??{start:e.length,end:e.length}:null),st=H(()=>{});st.current=()=>{const e=lt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!at)return;const n=Ce?null:e.querySelector(".es-gold-layer"),r=Ce?De.current?.rangeOf(at.start,at.end)??null:n?a(n,at.start,at.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,d=r?s(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!d)return;const p=i({anchor:d,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:u(e),parent:c(t)});t.style.top=`${p.top}px`,t.style.left=`${p.left}px`,t.style.setProperty("--es-pop-point",`${p.point}px`),t.dataset.side=p.above?"above":"below"},M(()=>{const e=lt.current;if(!ot||!e)return;const t=()=>st.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[ot,Me,We,at?.start,at?.end,Ce]);const it="always"===re||me||null!==We||Me,ct=ae&&ae.length>0?{run:Qe,open:Me,onToggle:()=>{Ae(null),Me?nt():Pe(!0)}}:void 0,ut=it?ce?ce({className:"rosh-tb-btn",disabled:b,selected:Xe,keepCaret:e=>e.preventDefault(),insert:t=>Ve(n=>we(e,t,n))}):"classic"===B?R:void 0:void 0,dt=new Set(Ie),pt=T?{value:T.value,allow:T.allow,onChange:T.onChange,disabled:T.disabled}:void 0,mt={pressed:Ze,onList:t=>{const{start:n,end:r}=qe(),l=z(e,n,r,Ye);Ve(()=>I(e,n,r,l===t?null:t,Ye))}},ht=L({offered:dt,color:ct,last:ut,alignment:pt,list:mt,letterCase:ie});/* @__PURE__ */
9
- return Z("div",{ref:lt,className:"es-copy"+(y?` ${y}`:""),onFocus:()=>he(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||he(!1)},onKeyDown:e=>{const t=e.target===pe.current||Boolean(e.target.closest?.(".es-rich"));if(b||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void ze(l||e.shiftKey?"redo":"undo");const o={b:"bold",i:"italic",u:"underline",k:"link"}[`${e.shiftKey?"shift+":""}${n}`];o&&Ie.includes(o)&&(e.preventDefault(),e.stopPropagation(),_e(o))},onPaste:t=>{const n=pe.current;if(b||!n||t.target!==n)return;t.preventDefault();const r=m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:h,rules:Ye});Ve(t=>we(e,r,t))},style:ae&&ae.length>0?Object.fromEntries(ae.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=pe.current;t&&t.ownerDocument.activeElement===t&&ge({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[it&&(ht.words||ht.paragraph)?
10
- /* @__PURE__ */J(D,{className:"es-copy-toolbar","aria-label":ee??ue.formatting,offered:dt,pressed:Ge,onMark:e=>_e(e),color:ct,linkOpen:null!==We,last:ut,alignment:pt,list:mt,letterCase:ie,disabled:b,windows:/* @__PURE__ */Z(Q,{children:[Me&&ae&&ae.length>0?/* @__PURE__ */J(d,{colors:ae,current:Je,words:ue.colors??v.colors,onPick:t=>{const{start:n,end:r}=qe();if(n!==r)Ve(()=>Y(e,n,r,t,Ye));else{if(!Ce)return;Ke({add:Oe?.add??[],drop:Oe?.drop??[],color:t,at:n})}}}):null,We?We&&/* @__PURE__ */J(O,{className:"es-copy-link es-copy-pop",value:We.link?.href??"",onApply:t=>{const n=We;Ae(null),Ve(()=>Ce?_(e,n.start,n.end,t,Ye):X(e,n.start,n.end,t))},onRemove:We.link?()=>{const t=We.link,n=We;Ae(null),t&&Ve(()=>Ce?G(e,n.start,n.end,Ye):q(e,t))}:void 0,onCancel:tt}):null]})}):null,se&&se.length>0?/* @__PURE__ */J(Te,{cells:se,words:ue.cells??v.cells,readOnly:b}):null,Ce?/* @__PURE__ */J(Ne,{value:e,rules:Ye,multiline:h,readOnly:b,placeholder:f,ariaLabel:g,handle:De,pending:Oe??void 0,onEdit:(t,n,r)=>{ye.record({text:e,start:n.start,end:n.end},r,Date.now()),Ke(null),be(t)},onSelect:e=>{ge(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Oe||e.start===Oe.at&&e.end===Oe.at||Ke(null)},onHistory:ze,onFormat:e=>{Ie.includes(e)&&_e(e)},onCommit:n,onCancel:r}):/* @__PURE__ */J(E,{value:e,onInput:e=>{ye.record(Se(null),"type",Date.now()),be(e)},onCommit:n,onCancel:r,multiline:h,placeholder:f,ariaLabel:g,rules:S,disabled:b,inputRef:pe,className:"es-copy-box"}),te?te({focused:me,insert:t=>Ve(n=>we(e,t,n))}):null,le&&h?
6
+ /* @__PURE__ */J("label",{className:"es-field-label es-copy-cell-name",htmlFor:c,children:o}),
7
+ /* @__PURE__ */J(b,{id:c,value:Oe(e.value,t),styleValue:Oe(e.styleValue,t),onChange:n=>e.onChange(void 0===n?void 0:Number((n/t).toFixed(6))),min:e.min,max:e.max,step:s,shiftStep:e.shiftStep,icon:e.icon,unit:a||void 0,steppers:"compact",readOnly:n,ariaLabel:o,title:r.tip({name:o,step:s,unit:a})})]},e.key)})})})}function Re({target:e,onChange:t}){const n=M(null);return K(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var Me=/* @__PURE__ */new Set([...H,"clear"]);function Pe({value:e,onChange:t,onCommit:n,onCancel:r,multiline:h=!1,placeholder:f,ariaLabel:g,className:y,readOnly:b=!1,rules:S,tools:x=[],writeMark:w,align:T,actions:R,toolbar:H,barLabel:ee,renderFooter:te,inputRef:ne,barShows:re="always",richText:le=!0,defaultShowMarks:oe=!1,colors:ae,cells:se,letterCase:ce,lastTool:ie}){const ue=C("copy",v),de=M(null),pe=ne??de,[me,he]=P(!1),[fe,ge]=P(null),ye=M(l()).current,ve=M(null);V(()=>{const t=ve.current;t&&e===t.to?ve.current=null:t&&e===t.from||(ve.current=null,ye.reset())},[e,ye]);const be=n=>{ve.current={from:ve.current?.from??e,to:n},t(n)},Se=t=>({text:e,start:t?.selectionStart??fe?.start??e.length,end:t?.selectionEnd??fe?.end??e.length}),[ke,Ee]=P(oe),Ce=le&&!(h&&ke),De=M(null),Le=F(),[Oe,Pe]=P(null),[Ke,Ve]=P(!1),Fe=()=>{if(!Ce)return pe.current;const e=De.current?.getSource()??fe;return e?{selectionStart:e.start,selectionEnd:e.end}:null},He=Re({target:pe,onChange:be}),je=e=>(ge({start:e.selectionStart,end:e.selectionEnd}),e),Be=(t,n)=>{if(!Ce)return void He(e=>(n&&ye.record(Se(e),"edit",Date.now()),je(t(e))));const r=Fe(),l=je(t(r));n&&ye.record(Se(r),"edit",Date.now()),Pe(null),l.text!==e&&be(l.text),De.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},$e=e=>Be(e,!0),ze=e=>Be(t=>{const n=Se(t),r=ye[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),We=M(null);K(()=>{const t=We.current;t&&(We.current=null,Ce?De.current?.setSource(t.start,t.end,e):(pe.current?.focus(),pe.current?.setSelectionRange(t.start,t.end),ge(t)))},[Ce]);const[Ae,Ie]=P(null),Ue=S??$,Ye=("string"==typeof x[0]?x:x.map(e=>e.style)).filter(e=>!Me.has(e)),qe={};if(fe){const t=B(e,fe.start,fe.end,Ue);for(const e of Ye){const n=t.has(e)||"highlight"===e&&t.has("accent");qe[e]=!!Oe?.add.includes(e)||!Oe?.drop.includes(e)&&n}qe.link=t.has("link")}const Ge=()=>{const t=Fe(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},_e=t=>{if("link"!==t&&A(0,t)){const{start:n,end:r}=Ge();if(n===r&&!Ce)return void $e(n=>xe(e,t,n,(e,t,n,r)=>j(e,t,n,r,Ue,ue.placeholders)));const l=p({value:e,rules:Ue,start:n,end:r,style:t,pending:Oe});return void("pending"===l.kind?Pe(l.pending):$e(()=>l.result))}if("link"!==t){const n=w??((e,t,n,r)=>j(e,t,n,r,$,ue.placeholders));return void $e(r=>xe(e,t,r,n))}const n=Fe(),r=n?.selectionStart??e.length,l=n?.selectionEnd??r;Ve(!1),Ie({start:r,end:l,link:I(e,r,l)})},Xe=Boolean(fe&&fe.start!==fe.end),Ze=fe?z(e,fe.start,fe.end,Ue):null,Je=fe?Oe&&void 0!==Oe.color&&Oe.at===fe.start?Oe.color:W(e,fe.start,fe.end,Ue):null,Qe=o(Je,ae),et=t=>{Ce?t?De.current?.setSource(t.start,t.end,e):De.current?.focus():(pe.current?.focus(),t&&pe.current?.setSelectionRange(t.start,t.end))},tt=()=>{const e=Ae;Ie(null),et(e?{start:e.start,end:e.end}:fe)},nt=()=>{const e=lt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));Ve(!1),t&&et(fe)},rt=M(nt);rt.current=nt,V(()=>{if(Ke)return D(e=>{const t=lt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(rt.current(),!0)},()=>lt.current?.querySelector(".es-copy-colors"))},[Ke]);const lt=M(null),ot=Ke||null!==Ae;V(()=>{const e=lt.current;if(!ot||!e)return;const t=e.ownerDocument,n=()=>{Ve(!1),Ie(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[ot]);const at=Ae??(Ke?fe??{start:e.length,end:e.length}:null),st=M(()=>{});st.current=()=>{const e=lt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!at)return;const n=Ce?null:e.querySelector(".es-gold-layer"),r=Ce?De.current?.rangeOf(at.start,at.end)??null:n?a(n,at.start,at.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,d=r?s(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!d)return;const p=c({anchor:d,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:u(e),parent:i(t)});t.style.top=`${p.top}px`,t.style.left=`${p.left}px`,t.style.setProperty("--es-pop-point",`${p.point}px`),t.dataset.side=p.above?"above":"below"},K(()=>{const e=lt.current;if(!ot||!e)return;const t=()=>st.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[ot,Ke,Ae,at?.start,at?.end,Ce]);const ct="always"===re||me||null!==Ae||Ke,it=ae&&ae.length>0?{run:Qe,open:Ke,onToggle:()=>{Ie(null),Ke?nt():Ve(!0)}}:void 0,ut=ct?ie?ie({className:"rosh-tb-btn",disabled:b,selected:Xe,keepCaret:e=>e.preventDefault(),insert:t=>$e(n=>we(e,t,n))}):"classic"===H?R:void 0:void 0,dt=new Set(Ye),pt=T?{value:T.value,allow:T.allow,onChange:T.onChange,disabled:T.disabled}:void 0,mt={pressed:Ze,onList:t=>{const{start:n,end:r}=Ge(),l=z(e,n,r,Ue);$e(()=>Y(e,n,r,l===t?null:t,Ue))}},ht=N({offered:dt,color:it,last:ut,alignment:pt,list:mt,letterCase:ce});/* @__PURE__ */
8
+ return Z("div",{ref:lt,className:"es-copy"+(y?` ${y}`:""),onFocus:()=>he(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||he(!1)},onKeyDown:e=>{const t=e.target===pe.current||Boolean(e.target.closest?.(".es-rich"));if(b||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void ze(l||e.shiftKey?"redo":"undo");const o={b:"bold",i:"italic",u:"underline",k:"link"}[`${e.shiftKey?"shift+":""}${n}`];o&&Ye.includes(o)&&(e.preventDefault(),e.stopPropagation(),_e(o))},onPaste:t=>{const n=pe.current;if(b||!n||t.target!==n)return;t.preventDefault();const r=m({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:h,rules:Ue});$e(t=>we(e,r,t))},style:ae&&ae.length>0?Object.fromEntries(ae.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=pe.current;t&&t.ownerDocument.activeElement===t&&ge({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[ct&&(ht.words||ht.paragraph)?
9
+ /* @__PURE__ */J(L,{className:"es-copy-toolbar","aria-label":ee??ue.formatting,offered:dt,pressed:qe,onMark:e=>_e(e),color:it,linkOpen:null!==Ae,last:ut,alignment:pt,list:mt,letterCase:ce,disabled:b,windows:/* @__PURE__ */Z(Q,{children:[Ke&&ae&&ae.length>0?/* @__PURE__ */J(d,{colors:ae,current:Je,words:ue.colors??v.colors,onPick:t=>{const{start:n,end:r}=Ge();if(n!==r)$e(()=>U(e,n,r,t,Ue));else{if(!Ce)return;Pe({add:Oe?.add??[],drop:Oe?.drop??[],color:t,at:n})}}}):null,Ae?Ae&&/* @__PURE__ */J(O,{className:"es-copy-link es-copy-pop",value:Ae.link?.href??"",onApply:t=>{const n=Ae;Ie(null),$e(()=>Ce?_(e,n.start,n.end,t,Ue):X(e,n.start,n.end,t))},onRemove:Ae.link?()=>{const t=Ae.link,n=Ae;Ie(null),t&&$e(()=>Ce?q(e,n.start,n.end,Ue):G(e,t))}:void 0,onCancel:tt}):null]})}):null,se&&se.length>0?/* @__PURE__ */J(Te,{cells:se,words:ue.cells??v.cells,readOnly:b}):null,Ce?/* @__PURE__ */J(Ne,{value:e,rules:Ue,multiline:h,readOnly:b,placeholder:f,ariaLabel:g,handle:De,pending:Oe??void 0,onEdit:(t,n,r)=>{ye.record({text:e,start:n.start,end:n.end},r,Date.now()),Pe(null),be(t)},onSelect:e=>{ge(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Oe||e.start===Oe.at&&e.end===Oe.at||Pe(null)},onHistory:ze,onFormat:e=>{Ye.includes(e)&&_e(e)},onCommit:n,onCancel:r}):/* @__PURE__ */J(E,{value:e,onInput:e=>{ye.record(Se(null),"type",Date.now()),be(e)},onCommit:n,onCancel:r,multiline:h,placeholder:f,ariaLabel:g,rules:S,disabled:b,inputRef:pe,className:"es-copy-box"}),te?te({focused:me,insert:t=>$e(n=>we(e,t,n))}):null,le&&h?
11
10
  /* @__PURE__ */Z("div",{className:"es-copy-marks",children:[
12
- /* @__PURE__ */J(k,{checked:ke,onChange:()=>{const e=je();Ue.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:fe,Ke(null),Ee(e=>!e)},ariaLabelledBy:Le,disabled:b}),
13
- /* @__PURE__ */J("span",{id:Le,className:"es-copy-marks-label",children:ue.showMarks??"Show marks"})]}):null]})}var je=["left","center","right","justify"],Be=v.align,Fe={left:/* @__PURE__ */J(se,{}),center:/* @__PURE__ */J(ae,{}),right:/* @__PURE__ */J(oe,{}),justify:/* @__PURE__ */J(le,{})},$e={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function Ve(e,t=Be){return je.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:Fe[e],title:t[e]}))}var ze=["none","bullet","number"],Ue=e,We={none:/* @__PURE__ */J(ge,{}),bullet:/* @__PURE__ */J(fe,{}),number:/* @__PURE__ */J(he,{})},Ae={none:/* @__PURE__ */J(Se,{}),upper:/* @__PURE__ */J(be,{}),capitalize:/* @__PURE__ */J(ve,{}),lower:/* @__PURE__ */J(ye,{})};function Ye({label:e,icon:t,answers:n,names:r,glyphs:l,row:o,readOnly:a}){const s=o.value||o.styleValue||"";/* @__PURE__ */
14
- return J(x,{label:e,icon:t,children:/* @__PURE__ */J(w,{ariaLabel:e,value:s,disabled:a,onChange:e=>{a||o.onChange(function(e,t){return t===e.value||""===e.value&&t===e.styleValue?"":t}(o,e))},options:n.map(e=>({id:e,label:l[e],title:r[e]}))})})}function Ie({kept:e,keptHint:t,readOnly:n=!1,style:r,font:l,italic:o,cells:a,align:s,list:i,letterCase:c}){const u=C("copy",v),d={...v.panel,...u.panel},p=r&&!n?[r.onEditStyles&&{label:d.editStyles,onSelect:r.onEditStyles},r.onUpdateStyle&&{label:d.updateStyle,onSelect:r.onUpdateStyle}].filter(e=>!!e):[],m=!!o&&(o.value??o.styleValue??!1),h=o?/* @__PURE__ */J(T,{content:d.italic,children:/* @__PURE__ */J(R,{size:"sm",variant:"ghost","aria-label":d.italic,"aria-pressed":m,disabled:n,onClick:()=>{if(n)return;const e=!m;o.onChange(e===(o.styleValue??!1)?void 0:e)},children:/* @__PURE__ */J(me,{})})}):null;/* @__PURE__ */
11
+ /* @__PURE__ */J(k,{checked:ke,onChange:()=>{const e=Fe();We.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:fe,Pe(null),Ee(e=>!e)},ariaLabelledBy:Le,disabled:b}),
12
+ /* @__PURE__ */J("span",{id:Le,className:"es-copy-marks-label",children:ue.showMarks??"Show marks"})]}):null]})}var Ke=["left","center","right","justify"],Ve=v.align,Fe={left:/* @__PURE__ */J(se,{}),center:/* @__PURE__ */J(ae,{}),right:/* @__PURE__ */J(oe,{}),justify:/* @__PURE__ */J(le,{})},He={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function je(e,t=Ve){return Ke.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:Fe[e],title:t[e]}))}var Be=["none","bullet","number"],$e=e,ze={none:/* @__PURE__ */J(ge,{}),bullet:/* @__PURE__ */J(fe,{}),number:/* @__PURE__ */J(he,{})},We={none:/* @__PURE__ */J(Se,{}),upper:/* @__PURE__ */J(be,{}),capitalize:/* @__PURE__ */J(ve,{}),lower:/* @__PURE__ */J(ye,{})};function Ae({label:e,icon:t,answers:n,names:r,glyphs:l,row:o,readOnly:a}){const s=o.value||o.styleValue||"";/* @__PURE__ */
13
+ return J(x,{label:e,icon:t,children:/* @__PURE__ */J(w,{ariaLabel:e,value:s,disabled:a,onChange:e=>{a||o.onChange(function(e,t){return t===e.value||""===e.value&&t===e.styleValue?"":t}(o,e))},options:n.map(e=>({id:e,label:l[e],title:r[e]}))})})}function Ie({kept:e,keptHint:t,readOnly:n=!1,style:r,font:l,italic:o,cells:a,align:s,list:c,letterCase:i}){const u=C("copy",v),d={...v.panel,...u.panel},p=r&&!n?[r.onEditStyles&&{label:d.editStyles,onSelect:r.onEditStyles},r.onUpdateStyle&&{label:d.updateStyle,onSelect:r.onUpdateStyle}].filter(e=>!!e):[],m=!!o&&(o.value??o.styleValue??!1),h=o?/* @__PURE__ */J(T,{content:d.italic,children:/* @__PURE__ */J(R,{size:"sm",variant:"ghost","aria-label":d.italic,"aria-pressed":m,disabled:n,onClick:()=>{if(n)return;const e=!m;o.onChange(e===(o.styleValue??!1)?void 0:e)},children:/* @__PURE__ */J(me,{})})}):null;/* @__PURE__ */
15
14
  return Z("div",{className:"es-tpp",children:[e?/* @__PURE__ */Z("div",{className:"es-tpp-kept",children:[
16
- /* @__PURE__ */J(Pe,{...e,readOnly:n||e.readOnly}),t?/* @__PURE__ */J("p",{className:"es-field-hint",children:t}):null]}):null,r?/* @__PURE__ */J(x,{label:d.style,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */J(S,{ariaLabel:d.style,value:r.value,options:r.options,onChange:r.onChange,changed:r.changed,footer:p,readOnly:n})}):null,l?/* @__PURE__ */J(x,{label:d.font,icon:/* @__PURE__ */J(ce,{}),children:/* @__PURE__ */Z("div",{className:"es-tpp-font",children:[
15
+ /* @__PURE__ */J(Pe,{...e,readOnly:n||e.readOnly}),t?/* @__PURE__ */J("p",{className:"es-field-hint",children:t}):null]}):null,r?/* @__PURE__ */J(x,{label:d.style,icon:/* @__PURE__ */J(ce,{}),children:/* @__PURE__ */J(S,{ariaLabel:d.style,value:r.value,options:r.options,onChange:r.onChange,changed:r.changed,footer:p,readOnly:n})}):null,l?/* @__PURE__ */J(x,{label:d.font,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */Z("div",{className:"es-tpp-font",children:[
17
16
  /* @__PURE__ */J("div",{className:"es-tpp-font-select",children:/* @__PURE__ */J(S,{ariaLabel:d.font,value:l.value||void 0,placeholder:l.styleValue,options:l.options,onChange:l.onChange,searchable:l.searchable,readOnly:n})}),h]})}):h?
18
- /* @__PURE__ */J(x,{label:d.italic,icon:/* @__PURE__ */J(ce,{}),children:/* @__PURE__ */J("div",{className:"es-tpp-font",children:h})}):null,a?.length?/* @__PURE__ */J(Te,{cells:a,words:u.cells,readOnly:n}):null,s?/* @__PURE__ */J(Ye,{label:u.alignment,icon:/* @__PURE__ */J(ue,{}),answers:je.filter(e=>!s.allow||s.allow.includes(e)),names:u.align,glyphs:Fe,row:s,readOnly:n}):null,i?/* @__PURE__ */J(Ye,{label:d.list,icon:/* @__PURE__ */J(de,{}),answers:ze,names:d.lists,glyphs:We,row:i,readOnly:n}):null,c?/* @__PURE__ */J(Ye,{label:d.capitalization,icon:/* @__PURE__ */J(pe,{}),answers:Ue,names:d.cases,glyphs:Ae,row:c,readOnly:n}):null]})}export{je as COPY_ALIGNS,$e as COPY_ALIGN_FIT,Fe as COPY_ALIGN_GLYPHS,Be as COPY_ALIGN_LABELS,Le as COPY_CELLS,Pe as CopyBox,Te as CopyCells,Me as MarkBar,Ne as RichBox,Ie as TextPartPanel,Ke as ariaShortcut,Ve as copyAlignOptions,we as insertSelection,xe as markSelection,Re as useCaretEdit};
17
+ /* @__PURE__ */J(x,{label:d.italic,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */J("div",{className:"es-tpp-font",children:h})}):null,a?.length?/* @__PURE__ */J(Te,{cells:a,words:u.cells,readOnly:n}):null,s?/* @__PURE__ */J(Ae,{label:u.alignment,icon:/* @__PURE__ */J(ue,{}),answers:Ke.filter(e=>!s.allow||s.allow.includes(e)),names:u.align,glyphs:Fe,row:s,readOnly:n}):null,c?/* @__PURE__ */J(Ae,{label:d.list,icon:/* @__PURE__ */J(de,{}),answers:Be,names:d.lists,glyphs:ze,row:c,readOnly:n}):null,i?/* @__PURE__ */J(Ae,{label:d.capitalization,icon:/* @__PURE__ */J(pe,{}),answers:$e,names:d.cases,glyphs:We,row:i,readOnly:n}):null]})}export{Ke as COPY_ALIGNS,He as COPY_ALIGN_FIT,Fe as COPY_ALIGN_GLYPHS,Ve as COPY_ALIGN_LABELS,Le as COPY_CELLS,Pe as CopyBox,Te as CopyCells,Ne as RichBox,Ie as TextPartPanel,je as copyAlignOptions,we as insertSelection,xe as markSelection,Re as useCaretEdit};