efficient-easel 19.2.0 → 19.3.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.
- package/dist/{chunk-3Z2MVLCD.js → chunk-4ES5JGGX.js} +1 -1
- package/dist/chunk-7OKL7HDV.js +1 -0
- package/dist/{chunk-BQMZ2YAF.js → chunk-A6CY3TQ5.js} +1 -1
- package/dist/chunk-CNKVVHDA.js +63 -0
- package/dist/chunk-FIVU2COQ.js +2 -0
- package/dist/{chunk-RTCNJRF6.js → chunk-FMZGR7EG.js} +1 -1
- package/dist/chunk-H5YLVKGA.js +1 -0
- package/dist/{chunk-UZXGXMNO.js → chunk-KOVJODTY.js} +11 -11
- package/dist/{chunk-45NZSAND.js → chunk-KWE5U6CE.js} +1 -1
- package/dist/{chunk-6U6AISPX.js → chunk-ME4V6PML.js} +4 -4
- package/dist/chunk-OGBYHQE6.js +5 -0
- package/dist/chunk-P5VYGWYO.js +1 -0
- package/dist/{chunk-G3GWAP5R.js → chunk-QAJAEWCZ.js} +1 -1
- package/dist/chunk-U6LF5YVK.js +8 -0
- package/dist/chunk-VULUDKA3.js +21 -0
- package/dist/chunk-YOXKBOZX.js +1 -0
- package/dist/{chunk-WXFZD7WC.js → chunk-ZKY45F5G.js} +1 -1
- package/dist/chunk-ZO3UUK45.js +18 -0
- package/dist/{chunk-2XMHLXMA.js → chunk-ZOBSIXRD.js} +1 -1
- package/dist/copy/index.js +14 -14
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.js +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/menu/index.d.ts +3 -3
- package/dist/menu/index.js +1 -1
- package/dist/node-ops/index.d.ts +11 -7
- package/dist/node-ops/index.js +1 -1
- package/dist/panel/index.js +6 -6
- package/dist/panel/panel.css +21 -12
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.d.ts +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/SaveControls.d.ts +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.d.ts +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.d.ts +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +17 -17
- package/dist/screen/components/usePartBridge.d.ts +1 -1
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.d.ts +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/preview-dom.js +1 -1
- package/dist/screen/lib/puck/style-clipboard.d.ts +1 -1
- package/dist/screen/lib/puck/style-clipboard.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/strings/index.js +2 -2
- package/dist/style-clipboard/index.d.ts +1 -1
- package/dist/text-styles/index.js +22 -22
- package/dist/{types-BsyPh6EW.d.ts → types-BbOBWXMP.d.ts} +3 -0
- package/package.json +1 -1
- package/dist/chunk-BALFHI3G.js +0 -2
- package/dist/chunk-EFQCH7CO.js +0 -1
- package/dist/chunk-I2BCNLLV.js +0 -5
- package/dist/chunk-LFHMDGLE.js +0 -8
- package/dist/chunk-LOXB5OVK.js +0 -63
- package/dist/chunk-OD4WIIER.js +0 -1
- package/dist/chunk-OSPUG6S6.js +0 -1
- package/dist/chunk-UAS2LEW2.js +0 -1
- package/dist/chunk-Z2V3TTAR.js +0 -18
- package/dist/chunk-ZFFWO2AF.js +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{HERO_SLIDER_GOTO_EVENT as t}from"./chunk-IQ5TA7AM.js";import{isPreviewClick as e}from"./chunk-R5L2E7JX.js";var n=()=>document.querySelector(".sf-editor #preview-frame");function o(t){e()||requestAnimationFrame(()=>{n()?.contentDocument?.querySelector(`[data-puck-component="${CSS.escape(t)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})})}function r(e,o){const r=n()?.contentWindow;if(!r)return;const c={id:e,index:o};r.dispatchEvent(new CustomEvent(t,{detail:c}))}function c(){requestAnimationFrame(()=>{n()?.contentWindow?.scrollTo({top:0,behavior:"smooth"})})}function u(t,{passes:e=[150,400],onPinned:o}={}){let r=0,c=!1;const u=[],i=()=>{const r=n(),s=r?.contentWindow,l=r?.contentDocument;if(!s||!l)return!1;const a=t(s,l);if(null==a)return!1;if(s.scrollTo({left:s.scrollX,top:a,behavior:"instant"}),!c){c=!0,o?.();for(const t of e)u.push(setTimeout(i,t))}return!0},s=()=>{!i()&&r++<150&&u.push(setTimeout(s,32))};return s(),()=>u.forEach(clearTimeout)}function i(t){return u((e,n)=>{const o=n.querySelector(`[data-puck-component="${CSS.escape(t)}"]`);return o?e.scrollY+o.getBoundingClientRect().top:null})}function s(t){return u((t,e)=>{if(!e.querySelector("[data-puck-component]"))return null;const n=Math.max(e.documentElement.scrollHeight,e.body?.scrollHeight??0);return n<=e.documentElement.clientHeight?null:n},{passes:[150,400,800,1300,2e3],onPinned:t})}export{r as gotoPreviewSlide,s as pinPreviewToBottom,i as pinPreviewToSection,n as previewFrame,o as scrollPreviewToSection,c as scrollPreviewToTop};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-OGBYHQE6.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-KOVJODTY.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-U3JP4VGF.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-KOVJODTY.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-JBOSEHIX.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s,scrollPreviewToTop as d}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as a,useEaselUndoKeys as c,useEaselSaveKey as p,editorRootFocus as u}from"./chunk-A6CY3TQ5.js";import{SlotChildActionsProvider as f}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as h,DEFAULT_PANEL_W as m,clampPanelWidth as g}from"./chunk-C56MPJBH.js";import{usePartBridge as y}from"./chunk-H5YLVKGA.js";import{useSectionOps as v}from"./chunk-7OKL7HDV.js";import{ScreenSaveIcon as k,ScreenMainButton as b}from"./chunk-PY7OOQEZ.js";import{useBrowserOffline as S}from"./chunk-RKTF5XLP.js";import{AddChildRow as w}from"./chunk-5545A3PC.js";import{AddSidePanel as x}from"./chunk-U6LF5YVK.js";import{keepsSharedSections as z,sharedSectionsOf as C}from"./chunk-43AEUUNQ.js";import{SidePanelHead as O,PanelShowStrip as N}from"./chunk-SINAM2IT.js";import{offeredChoices as I}from"./chunk-M2Z775ZC.js";import{useScreenSaveSwitch as B,useScreenNodeKeys as P,useScreenPinned as $,useScreenDocumentLabel as M,useScreenCanvasFrame as T,useScreenInspectorPanel as j,useScreenDevices as A,useScreenPickFollowsSelection as L,useScreenLeftView as E,SELECTION_MODE as R,sameInspectorMode as V,useScreenBridges as F,useScreenBlockRules as D,useScreenBlockLook as H,useScreenStorageNamespace as W,useScreenNotify as U,useScreenCanvasHead as Y,isSlotMode as G,useScreenStyleClipboard as J,useScreenDocumentPass as K,useScreenCanvasDrag as X,ScreenCanvasTargetProvider as Z,isPinnedFirst as q,isPinnedLast as Q,screenSlotsOf as _}from"./chunk-OGBYHQE6.js";import{MediaPopup as ee}from"./chunk-MS2U6MV5.js";import{useNodeClipboard as ne,useNodeContextMenu as te}from"./chunk-YOXKBOZX.js";import{PageEditGuardNotices as oe}from"./chunk-5DPIGWUL.js";import{useScreenDocument as re}from"./chunk-M62P4IQK.js";import{requestMediaPick as ie}from"./chunk-RYNBSKE7.js";import{useMediaPanel as le,usePanelPick as se,useMediaBrowsing as de,useOpenMediaBrowse as ae,useMediaPlace as ce}from"./chunk-LNHT2KPX.js";import{useEaselSession as pe}from"./chunk-O7Q4DDJT.js";import{useEaselHost as ue,useHostEscape as fe}from"./chunk-U3JP4VGF.js";import{LayersIcon as he,MediaIcon as me}from"./chunk-4VJATVVR.js";import{DEFAULT_SCREEN_WORDS as ge}from"./chunk-23DYNW6S.js";import{heldStyle as ye,styleShortcut as ve}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as ke}from"./chunk-6WY6ZXJG.js";import{rootRowName as be,slotChildRowName as Se,slotChildRenameProp as we,sectionRenameProp as xe}from"./chunk-BHRC3ASL.js";import{ROOT_ZONE as ze,blockNodeActions as Ce,TREE_MAX_DEPTH as Oe,childSlotsOf as Ne,slotFieldsOf as Ie,newNodeId as Be,slotChildrenIn as Pe,nestsInTree as $e}from"./chunk-PLVEGYK6.js";import{useEasel as Me,useEaselApi as Te,CanvasPassThroughContext as je,CanvasSharedContext as Ae}from"./chunk-KOVJODTY.js";import{TreeRow as Le,Subtree as Ee,LayersTree as Re,TreeGroupLabel as Ve,TreeRowAction as Fe,TreeSeam as De}from"./chunk-A6Z4SD3I.js";import{DEFAULT_TREE_WORDS as He}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as We}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ue,useNodeOps as Ye,clickPick as Ge}from"./chunk-X3TYRF5V.js";import{EaselTopBar as Je,TopBarCluster as Ke,EaselIconButton as Xe,TopBarDivider as Ze,DeviceSwitch as qe,InspectorIconButton as Qe,PanelResizeHandle as _e,MAX_PANEL_W as en,MIN_PANEL_W_BY_SIDE as nn,panelWidthVars as tn}from"./chunk-ZG6PVMC3.js";import{DEFAULT_NOTICE_WORDS as on,DEFAULT_CHROME_WORDS as rn}from"./chunk-AJSDWWJW.js";import{holderOf as ln,nameOrSomeone as sn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as dn}from"./chunk-RE4LP46F.js";import{useWords as an}from"./chunk-MFIRYGHW.js";import{insertSeams as cn,CanvasDragLayer as pn,CanvasInsert as un}from"./chunk-ZO3UUK45.js";import{DEFAULT_DRAG_WORDS as fn}from"./chunk-KAML3KQH.js";import{createDragSession as hn,useTreeDrag as mn,gapToMoveIndex as gn}from"./chunk-67GNT6PF.js";import{useCanvasFrame as yn,LIST_SELECTOR as vn,BLOCK_SELECTOR as kn,useCanvasTyping as bn,useCanvasEvent as Sn,nodeIdAt as wn,frameRectToHost as xn,BLOCK_ATTRIBUTE as zn,drawnBox as Cn}from"./chunk-X4T6JT3M.js";import{ROOT_ID as On,ROOT_SLOT as Nn,zoneKey as In,parseZoneKey as Bn,find as Pn,DataError as $n}from"./chunk-KRXQM65X.js";import{useRef as Mn,useMemo as Tn,useState as jn,useEffect as An,useCallback as Ln,useLayoutEffect as En,Fragment as Rn,useId as Vn}from"react";import{ColoredBadge as Fn,Tabs as Dn,toast as Hn,readMediaFileDrag as Wn,Tooltip as Un,groupColors as Yn,Dialog as Gn,FormField as Jn,Input as Kn,Button as Xn,MEDIA_FILE_DRAG_TYPE as Zn}from"efficient-shell/ui";import{UndoIcon as qn,RedoIcon as Qn,RefreshIcon as _n,AddIcon as et,TrashIcon as nt,EyeOffIcon as tt,EyeIcon as ot,SharedIcon as rt,DuplicateIcon as it}from"efficient-shell/icons/efficient";import{jsx as lt,jsxs as st,Fragment as dt}from"react/jsx-runtime";var at="media-file";function ct({name:e,onMake:n,onCancel:t}){const o=an("screen",ge).shared,[r,i]=jn(e),[l,s]=jn(!1),d=Vn(),a=Mn(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
|
|
2
|
+
return lt(Gn,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */st(dt,{children:[
|
|
3
|
+
/* @__PURE__ */lt(Xn,{variant:"secondary",onClick:t,children:o.cancel}),
|
|
4
|
+
/* @__PURE__ */lt(Xn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */lt("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */lt(Jn,{label:o.name,htmlFor:d,children:/* @__PURE__ */lt(Kn,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var pt=/* @__PURE__ */new WeakSet;function ut(e,n,t){const o=Pn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function ft({canvas:e,tabs:n,onSelect:t}){const o=Mn(null),[r,i]=jn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return En(()=>{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=xn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),a={};for(const o of n){const n=t.querySelector(`[${zn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?Cn(n):null;if(!i||0===i.height){a[o.id]=null;continue}const s=xn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),c=s.top+s.height;if(c<d.top||s.top>d.top+d.height){a[o.id]=null;continue}const p=o.below?c+4:Math.max(s.top,d.top)+6;a[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(a)},a=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",a,!0),r.addEventListener("resize",a);const c=new r.MutationObserver(a);return c.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",a,!0),r.removeEventListener("resize",a),c.disconnect()}},[e,l]),/* @__PURE__ */lt("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */lt("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:e.reach?
|
|
5
|
+
/* @__PURE__ */lt(Un,{content:e.reach,children:/* @__PURE__ */st(Fn,{colorClass:Yn("success","solid"),size:"sm",children:[
|
|
6
|
+
/* @__PURE__ */lt("span",{className:"es-band-tab-mark",children:/* @__PURE__ */lt(rt,{size:12})}),e.label]})}):/* @__PURE__ */lt(Fn,{colorClass:Yn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function ht({expand:e}){/* @__PURE__ */
|
|
7
|
+
return lt("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */st(dt,e?{children:[
|
|
8
|
+
/* @__PURE__ */lt("path",{d:"M8 9l4-4 4 4"}),
|
|
9
|
+
/* @__PURE__ */lt("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
10
|
+
/* @__PURE__ */lt("path",{d:"M8 4l4 4 4-4"}),
|
|
11
|
+
/* @__PURE__ */lt("path",{d:"M8 20l4-4 4 4"}),
|
|
12
|
+
/* @__PURE__ */lt("path",{d:"M5 12h14"})]})})}var mt=`${vn}, ${kn}`;function gt(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 yt="__rungs";var vt="screen:band",kt={duplicate:!0,delete:!0};function bt(){const vn=ue(),{target:xn,docId:zn,capabilities:Cn,currentSlug:Vn,siteId:Un,onPublish:Yn,saveState:Gn,saveConflict:Jn,retrySave:Kn,toggleAutoSave:Xn,flushSave:rt,access:bt,saveUnreachable:St=!1,readOnly:wt,readOnlyReason:xt=null}=re(),zt=B(),Ct=P(),{mediaEditing:Ot,hasEditGuard:Nt,hasPinnedChrome:It}=Cn,{appState:Bt,dispatch:Pt,history:$t,selectedItem:Mt,getSelectorForId:Tt,config:jt}=Me(e=>e),At=$(),{first:Lt,firstGroup:Et,lastGroup:Rt,isSectionGroup:Vt,sectionGroupZone:Ft,panelOf:Dt}=At,Ht=Dt(Lt),Wt=e=>q(At,e),Ut=e=>Q(At,e),Yt="node"===At.firstRow,Gt=At.band??null,Jt=an("screen",ge),Kt=an("tree",He),Xt=an("drag",fn),Zt=an("notice",on),qt=an("lock",dn),Qt=an("menu",We),_t=an("styleClipboard",ke),eo=an("chrome",rn),no=M()??`/${Vn}`,to=T(),oo=j(),ro=v({readOnly:wt}),io=v({readOnly:wt,foldIntoHistory:!0}),lo=Mn(null),so=Te(),ao=Tn(()=>({...ro,select:e=>{lo.current=e,ro.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=so.config;lo.current=Ue(e,t,n)}ro.commitDocument(e,n)}}),[ro,so]),co=Bt.ui,po=co.leftSideBarVisible,uo=co.rightSideBarVisible,{options:fo,widths:ho,initial:mo,fluid:go,fit:yo}=A(),[vo,ko]=jn(mo),bo=le(),So=Ot&&null!==bo,wo=se(),xo=de(),zo=null!==wo||xo,Co=ae();L(Mt?.props.id);const{read:Oo,write:No,forSelection:Io}=E(),[Bo,Po]=jn(Oo);An(()=>{No(Bo)},[Bo]);const[$o,Mo]=jn(0),To=Mn(null),jo=Mn(null),Ao=yn(jo,{readySelector:mt}),Lo=bn(Ao),Eo=a(jo);c(jo,Ao);const Ro=S(),Vo=ln(bt),Fo={state:Gn,offline:Ro||Gn.failed&&St,readOnlyReason:xt,editing:Vo?Zt.editing({name:sn(Vo.name,qt),noun:Jt.noun}):null,conflict:null!=Jn,notSaving:Jt.bar.notSaving},Do=()=>{wt||(Gn.failed?Kn():rt())};p(jo,Ao,Do);const[Ho,Wo]=jn(!1),Uo=Mn(!1),[Yo,Go]=jn(null),[Jo,Ko]=jn([]),[Xo,Zo]=jn(R),qo="puck"===Xo.kind,Qo=o(Xo,Mt?.props.id),[_o,er]=jn(null);An(()=>{_o&&(r(),er(null))},[_o]);const nr=Mn(Tt);nr.current=Tt;const tr=Ln((e,{scroll:n})=>{Po(n=>Io(e,n)),n&&er(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=nr.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&$r(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),or=Mn(null);An(()=>{const e=or.current;or.current=null;const n=null==Mt?.props.id?null:String(Mt.props.id);Zo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Dt(Mt?.type)??R);const t=Mt?.props.id,o=lo.current;if(lo.current=null,!t)return;const r=Tt(t);tr(String(t),{scroll:!i(o,r??null,ze)})},[Mt?.props.id,tr]);const rr=Ln(e=>{Zo(n=>V(n,e)?n:e),Pt({type:"setUi",ui:{rightSideBarVisible:!0}})},[Pt]),ir=Mn(()=>{});ir.current=(e,n)=>{const t=e?Ii(e.zone??ze)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Mt?.props.id?null:String(Mt.props.id);Zo(e=>V(e,n)?e:n),o!==r&&(or.current={id:o,mode:n},ao.select(e))};const lr=Ln((e,n)=>ir.current(e,n),[]),sr={kind:Xo.kind,mode:Xo,open:rr,show:e=>Zo(e),reveal:()=>{uo||Pt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:lr},dr=F(sr,{data:Bt.data,selected:Mt??null,zoneOf:e=>Tt(e)?.zone,readOnly:Boolean(wt),select:e=>{Zo(R),ao.select({index:e})},replace:(e,n)=>ao.replaceComponent(ze,e,n),scrollTo:e=>l(e)},{device:vo,refreshes:$o},{setView:Po,reveal:()=>{po||Pt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),ar=dr.resolveLeftView?dr.resolveLeftView(Bo):"sections",cr=D(),{isLockedBlock:pr,duplicateBlocked:ur,nestDepth:fr,newSectionNode:hr,canAddTo:mr,blockIsOffered:gr}=cr,yr=H(),{labelAtLevel:vr,Icon:kr,useProducts:br}=yr,Sr=yr.rowName?(e,n,t)=>yr.rowName(e,n,t):void 0,wr=Ln(e=>{Pt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),tr(e,{scroll:!0})},[Pt,tr]),{selectNode:xr,openPartId:zr}=y({mode:Xo,setMode:Zo,onOpenPart:wr}),[Cr,Or]=jn(null);fe(null!==Cr,()=>Or(null));const Nr=h(W()),Ir=Nr.collapsed,Br=Nr.panelWidths,[Pr,$r]=jn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(Ir);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
13
|
+
return new Set}});An(()=>{try{window.localStorage.setItem(Ir,JSON.stringify([...Pr]))}catch{}},[Pr]);const[Mr,Tr]=jn(()=>{if("undefined"==typeof window)return{...m};try{const e=window.localStorage.getItem(Br);if(!e)return{...m};const n=JSON.parse(e);return{left:g(Number(n.left)||m.left,"left"),right:g(Number(n.right)||m.right,"right")}}catch{return{...m}}});An(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Br,JSON.stringify(Mr))}catch{}},300);return()=>clearTimeout(e)},[Mr]);const jr=Ln((e,n)=>Tr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Ar=Ln(e=>jr("left",e),[jr]),Lr=Ln(e=>jr("right",e),[jr]),Er=e=>Pr.has(e),Rr=e=>$r(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Vr=Mn(!1),Fr=Mn(null);An(()=>{if(Vr.current&&!Ho){const e=Fr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??jo.current?.querySelector(`button[aria-label="${CSS.escape(Jt.add.title)}"]`))?.focus(),Fr.current=null}Vr.current=Ho},[Ho]),An(()=>{if(!Ho||!Eo)return;const e=e=>{"Escape"===e.key&&ll()};return Eo.addEventListener("keydown",e),()=>Eo.removeEventListener("keydown",e)},[Ho,Eo]),fe(Ho,()=>ll()),An(()=>{!po&&Ho&&(Wo(!1),Go(null),Uo.current=!1)},[po]);const Dr=U(),Hr=(e,n="success",t)=>{if(Dr)return void(t?Dr(e,"error"===n?"error":"info",t):Dr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Hn.error(e,{...o,duration:t?.duration??3200}):Hn.success(e,{...o,duration:t?.duration??1900})},Wr=Mn(null),[Ur,Yr]=jn(0),[Gr,Jr]=jn(0),Kr=Y(),Xr=Mn(null),Zr=e=>Math.max(0,e.clientHeight-(Xr.current?.offsetHeight??0));An(()=>{const e=Wr.current;if(!e)return;const n=()=>{Yr(e.clientWidth),Jr(Zr(e))};n();const t=new ResizeObserver(n);return t.observe(e),Xr.current&&t.observe(Xr.current),()=>t.disconnect()},[]),En(()=>{Wr.current&&(Yr(Wr.current.clientWidth),Jr(Zr(Wr.current)))},[Mr,po,uo]);const qr=vo===go?Ur>0?Ur:ho[go]:ho[vo],Qr=Ur>0?Math.min(Ur/qr,"shrink"===yo?1:2):1,_r=qr*Qr,ei=Ur>0&&_r>Ur+1,ni={width:_r,height:Gr||"100%",flex:"none",position:"relative"},ti={width:qr,height:Gr?Gr/Qr:"100%",maxHeight:"none",transform:1!==Qr?`scale(${Qr})`:void 0,transformOrigin:"top left"},oi=()=>Pt({type:"setUi",ui:{leftSideBarVisible:!po}}),ri=()=>Pt({type:"setUi",ui:{rightSideBarVisible:!uo}}),ii=e=>{Ho&&(Wo(!1),Go(null),Uo.current=!1,po&&Bo===e)||(Po(e),po||Pt({type:"setUi",ui:{leftSideBarVisible:!0}}))},li=()=>{ie(vn,{accept:"image/*",title:eo.mediaLibrary})},si=()=>{Zo(R),ao.select(null),d()},di=()=>{Zo(Ht??R),uo||Pt({type:"setUi",ui:{rightSideBarVisible:!0}})},ai=Bt.data.content??[],ci=()=>{const e=ai.findIndex(Wt),n=ai.findIndex(Ut);return{floor:e>=0?e+1:0,cap:n>=0?n:ai.length}},pi=jt,ui=cr.stripCopy,fi=n=>e(n,ui),hi=ne(),mi=Ye({data:Bt.data,config:pi,readOnly:Boolean(wt),clipboard:hi,strip:ui?e=>ui(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==On||e.slot!==Nn)return{min:0,max:n-1};const{floor:t,cap:o}=ci();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Zo(R);const t=void 0===n||"node"===n?.kind?n:null;ao.commitDocument(e,t)}}),gi=pe(),[yi,vi]=jn(null),ki=e=>{const n=ai.find(n=>String(n.props.id)===e),t=At.shared;n&&t&&mi.swap(e,t.detach(n))},bi=e=>{const n=Pn(Bt.data,jt,e);if(!n)return!1;const t=In(n.place),o=n.node,r=t===ze?Ci(o):Vi(o),i=t===ze?At.shared?.usedOn(o):null;return!!mi.remove(e)&&(Hr(i?Jt.shared.removed({count:Math.max(0,i.length-1)}):Jt.deleted({name:r}),"success",{duration:8e3,action:{label:Jt.bar.undo,onClick:()=>{mi.restore(n.node,n.place)}}}),!0)},Si={...mi,remove:bi},wi=e=>vr(e,"block",jt.components[e]?.label??e),xi=Ln(e=>jt.components[e]?.defaultProps??{},[jt]),zi=e=>vr(e,"section",wi(e)),Ci=e=>be({type:e.type,props:e.props??{}},zi(e.type),Sr),{nodeAddresses:Oi,zoneItems:Ni}=Tn(()=>{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>=Oe)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of Ne(jt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(ai,ze,0),{nodeAddresses:e,zoneItems:n}},[ai,jt]),Ii=Ln(e=>Ni.get(e)??[],[Ni]),Bi=e=>{const n=Oi.get(e);return n?Ii(n.zone)[n.index]:void 0},Pi=e=>_(cr,jt,e),$i=e=>{if(!cr.slotsOf||e===ze)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=Bi(e.slice(0,n));if(!t)return null;const o=Pi(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}},Mi=(()=>{if(!G(Xo))return null;const e=`${Xo.nodeId}:${Xo.slot}`;return $i(e)?.slot.panel===Xo.kind?e:null})(),Ti=Mn(null);An(()=>{const e=Ti.current;if(Ti.current=null,!Mi||!G(Xo))return;const n=Xo.nodeId;tr(n,{scroll:e!==Mi}),$r(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Xo]);const ji=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Oi.get(e);n&&(n.zone===ze?_i(n.index):Ol(n.zone,n.index,e,Bi(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Mi!==i&&(Ti.current=i),lr(null,r),uo||Pt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Ai=(e,n,t)=>{const o=`${e}:${n}`;if($r(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;Mi!==o&&(Ti.current=o);lr(null,{kind:t,nodeId:e,slot:n})},Li=(e,n,t)=>{if(wt||!cr.moveSlot)return;const o=Bi(e),r=o?Pi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:yt,index:n},s=gn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=cr.moveSlot(e,n,s);"string"==typeof d&&Ai(e,d,i.panel)},Ei=br(),Ri=Tn(()=>{const e=/* @__PURE__ */new Map;for(const n of Ei??[])e.set(n.slug,n.name);return e},[Ei]),Vi=e=>Se(e,wi,yr.plainText,e=>Ri.get(e),yr.rowName),Fi=(e,n)=>{const t=jt.components[e.type]?.fields,o=n===ze||Ql(n)?"section":"block",r=n===ze&&(Wt(e)||Ut(e)||Vt(e.type)),i="block"===o?we(t):r?null:xe(t);return yr.renamePropOf?yr.renamePropOf(e,o,i):i},Di=(e,n,t,o)=>{if(!(!wt&&Cr?.zone===e&&Cr.index===n))return;const r=(t,o)=>{Or(null),o&&((e,n,t)=>{const o=Ii(e)[n];if(!o)return;const r=Fi(o,e);r&&ao.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
14
|
+
return lt("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Jt.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)},Hi=t(J(),_t),Wi=Hi.scope({target:xn,siteId:Un,docId:zn}),Ui=jt,Yi=(e,n)=>n===ze?zi(e):wi(e),Gi=(e,n,t)=>{const o=Hi.plan(Wi,t,Yi(t.type,e),Ui);o&&(o.changed&&ao.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Hr(o.message))},Ji=te({nodesIn:Ii,nodeAt:(e,n)=>Ii(e)[n]??null,labelOf:(e,n)=>n===ze?zi(e):wi(e),renamePropOf:Fi,beginRename:(e,n)=>Or({zone:e,index:n}),history:{hasPast:$t.hasPast,hasFuture:$t.hasFuture,back:()=>$t.back(),forward:()=>$t.forward()},openPageSettings:()=>{ao.select(null),Zo(R)},pageSettingsLabel:Jt.pageSettings,words:{menu:Qt,styleClipboard:_t,screen:Jt.menu},readOnly:Boolean(wt),collapseAll:()=>$r(new Set(Ii(ze).map(e=>String(e.props.id)))),onPasteRefused:e=>Hr(e?Jt.pasteRefused({name:e.label}):Jt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>ns(e,n),menuRows:(e,n,t)=>{const o=dr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=At.shared;if(!t||n!==ze)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:Jt.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return wt||pr(e.type,e)?n:{...n,change:[{label:Jt.shared.detach,onClick:()=>ki(e.props.id)}],remove:[{label:Jt.shared.removeFromPage,danger:!0,onClick:()=>{bi(e.props.id)}}]}}return wt||Wt(e)||Ut(e)||Vt(e.type)?null:z(gi)?{change:[{label:Jt.shared.makeShared,onClick:()=>vi({id:e.props.id,name:Ci(e)})}]}:null})(e,n);if(!r)return o;return Object.fromEntries(["pick","make","change","remove"].map(e=>[e,[...o?.[e]??[],...r[e]??[]]]).filter(([,e])=>e.length>0))},isLocked:e=>pr(e.type,e),duplicateBlocked:e=>ur(Bt.data,e),permits:e=>{const n=Ce(jt,e.type);return At.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:Si,isPinned:(e,n)=>n===ze&&(Wt(e)||Ut(e)),sectionBand:ci,locate:e=>Oi.get(e)??null,rowNameOf:(e,n)=>n===ze?Ci(e):Vi(e),selectAt:(e,n,t,o)=>{e===ze?_i(n):Ol(e,n,t,o??"")},slotRung:e=>{const n=$i(e);return n?.slot.panel?{label:n.slot.label,select:()=>ji(n.node,n.slot,!1)}:null},style:{held:()=>ye(Wi),canCopy:e=>Hi.rows(Ui,e).some(e=>!1!==e.counted),copy:(e,n)=>Hi.copy(Wi,e,Yi(e.type,n),Ui),paste:(e,n,t)=>Gi(e,n,t)},keys:Ct?{target:Eo,selected:()=>{const e=Bt.ui.itemSelector;return e?{zone:e.zone??ze,index:e.index}:null},held:()=>hi.get(),readOnly:Boolean(wt),onDone:({done:e,name:n})=>{"copied"===e&&Hr(Jt.copied({name:n}))}}:void 0},Ao),Ki=Mn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});An(()=>{Ki.current={copy:(e,n)=>Hi.copy(Wi,e,Yi(e.type,n),Ui),paste:Gi,at:()=>{const e=Bt.ui.itemSelector;if(!e)return null;const n=e.zone??ze,t=Ii(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(wt)}});const Xi=Ln(e=>{const n=ve(e);if(!n)return;const t=Ki.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))},[]);An(()=>{if(!Eo)return;const e=e=>Xi(e);return Eo.addEventListener("keydown",e),()=>Eo.removeEventListener("keydown",e)},[Xi,Eo]),Sn(Ao,"keydown",Xi);const Zi=ai.map(e=>e.props.id).join("|");An(()=>{const e=Ao?.document??null,n=Ao?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Ko(e=>e.length?[]:e);const n=ai.findIndex(Ut),t=n>=0?n:ai.length,o=n=>{const t=ai[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(kn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=ai.length>0&&!Wt(ai[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=gt(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})}Ko(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()}},[Ao,Zi,vo,Qr,po,uo,Mt?.props.id]);const qi=Ao?.document??null,Qi=Ao?.window??null;An(()=>{const e=To.current;if(!e||!qi||!Qi)return;const n=[],t=()=>{const n=qi.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Qi.scrollTo({left:Qi.scrollX,top:Qi.scrollY+t,behavior:"instant"}),!0};return To.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[qi,Qi]);const _i=e=>{Zo(R),ao.select({index:e}),dr.sectionPressed?.(ai[e]);const n=ai[e]?.props?.id;n&&l(n)},el=e=>{const{floor:n,cap:t}=ci(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Mt&&Xo.kind!==Ht?.kind?ai.findIndex(e=>e.props.id===Mt.props.id):-1;return o(r>=0?r+1:t)},nl=(e,n)=>{const{floor:t,cap:o}=ci(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(ao.reorderComponent(ze,e,i),ao.select({index:i}),{moved:!0,dest:i})},tl=(e,n,t,o)=>{Zo(R),ao.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Hr(Jt.sectionAdded({name:t}))},ol=(e,n)=>{const t=el(n),o=hr(e,{nodeDefaults:xi,newNodeId:Be,sectionLabel:zi,blockIsOffered:gr}),r=o?ao.insertNode(ze,t,o):ao.insertSection(e,t);return tl(t,r,zi(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:a}of Ne(jt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=mr(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:a,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},rl=e=>il(ze,e),il=(e,n)=>{Fr.current=document.activeElement??null,Go(null===n?null:{zone:e,index:n}),Wo(!0),po||(Uo.current=!0,Pt({type:"setUi",ui:{leftSideBarVisible:!0}}))},ll=()=>{Wo(!1),Go(null),Uo.current&&Pt({type:"setUi",ui:{leftSideBarVisible:!1}}),Uo.current=!1},sl=(e,n)=>yr.rowName?n?Wt(e)?yr.rowName(e,"section",Jt.header):Ut(e)?yr.rowName(e,"section",Jt.footer):Vt(e.type)?yr.rowName(e,"section",wi(e.type)):Ci(e):Vi(e):n?zi(e.type):wi(e.type),dl=e=>n=>{e()},al=(e,n,t)=>{if(wt)return null;const o=Ii(e)[n];return o&&!Ce(jt,o.type).delete||o&&pr(o.type,o)?null:/* @__PURE__ */lt(Fe,{kind:"delete",label:e===ze&&o&&At.shared?.usedOn(o)?Jt.shared.removeFromPage:Jt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Ii(e)[n]?.props?.id;null!=t&&bi(String(t))})(e,n),children:/* @__PURE__ */lt(nt,{size:15})})},cl=e=>yr.rowPreview?.(e)||void 0,pl=e=>yr.rowMarks?.(e)??void 0,ul=(e,n,t)=>yr.rowActions?.(e,n,t)??null,fl=(e,n,t,o)=>{if(wt)return null;if(pr(t.type,t))return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
15
|
+
return lt(Fe,{kind:"eye",label:r?Jt.showNamed({name:o}):Jt.hideNamed({name:o}),onClick:()=>ml(e,n,t),children:/* @__PURE__ */lt(r?tt:ot,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},hl=e=>Ds(ze,e),ml=(e,n,t)=>{ao.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},gl=e=>Ie(jt,e),yl=e=>Ne(jt,e),vl=e=>cr.slotsOf?Pi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:Pe(e,n.slot)})):[{slot:null,rung:null,kids:yl(e)}],kl=e=>cr.slotsOf?vl(e).flatMap(e=>e.kids):yl(e),bl=e=>Boolean(cr.slotsOf)&&Pi(e).some(e=>e.rung),Sl=(e,n,t)=>null===t?void 0===n?mr(e):mr(e,n):mr(e,n,t),wl=(e,n,t)=>{const o=$e(jt,e.type,n)&&(t||kl(e).length>0||bl(e));return{collapsible:o,folded:o&&Er(String(e.props.id))}},xl=(e,n,t)=>vl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>wl(e,r,t(e.type)).collapsible?[String(e.props.id),...xl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),zl=e=>kl(e).length>0||bl(e)||Boolean(mr(e.type)),Cl=e=>Boolean(mr(e)),Ol=(e,n,t,o)=>{if(Zo(R),mr(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),ao.select({index:n,zone:e}),l(t)}else ao.select({index:n,zone:e}),l(t)},Nl=(e,n,t,o,r)=>{const i=`${e}:${n}`;ao.insertComponent(i,t,o),mr(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),ao.select({index:o,zone:i})}):ao.select({index:o,zone:i})},Il=Mn(/* @__PURE__ */new Set);An(()=>{ai.forEach(e=>{const n=mr(e.type)?.spec;if(!n)return;const t=e.props.id;if(Il.current.has(t))return;Il.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(xi)).forEach((e,t)=>io.seedChild(o,t,n.childType,e))})},[ai,io,xi]);const Bl=Mn(/* @__PURE__ */new Set);An(()=>{ai.forEach((e,t)=>{const o=e.props.id;if(Bl.current.has(o))return;const r=n(e,gl(e.type));Bl.current.add(o),r&&io.replaceComponent(ze,t,{...e,props:r})})},[ai,io]),K(io,jt);const Pl=ai.findIndex(Ut),$l=Pl>=0?ai[Pl]:null,Ml=Yt?ai.findIndex(Wt):-1,Tl=Ml>=0?ai[Ml]:null,jl=At.groupTab,Al=Tn(()=>jl?e=>Vt(e.type):void 0,[jl]),Ll=Boolean(At.groupBadge),El=At.sharedReach,Rl=e=>El?.(e)??void 0,Vl=Tn(()=>El?new Set(ai.filter(e=>Rl(e)).map(e=>String(e.props.id))):null,[ai,El]),Fl=Tn(()=>Vl?e=>Vl.has(e):void 0,[Vl]),Dl=At.first?El?.({type:At.first,props:{id:""}})??void 0:void 0,Hl=At.groupBadge?/* @__PURE__ */lt("span",{className:"es-tree-group-badge",children:/* @__PURE__ */lt(Fn,{tone:"info",size:"xs",children:At.groupBadge})}):void 0,Wl=ai.find(e=>e.type===Et)??null,Ul=ai.find(e=>e.type===Rt)??null,Yl=Pl>=0?Pl:ai.length,Gl=[];ai.forEach(e=>{Ut(e)||(zl(e)&&Gl.push(String(e.props.id)),Gl.push(...xl(e,1,Cl)))}),$l&&(Gl.push(String($l.props.id)),Gl.push(...xl($l,1,Cl)));const Jl=Gl.length>0&&Gl.every(e=>Pr.has(e)),Kl=e=>{const n=yr.blockRowName(e,wi);return yr.rowName?yr.rowName(e,"block",n):n},Xl=(e,n,t,o)=>{const r=Ii(e)[t];if(!r)return;const i={...Bn(e),index:t},l={...Bn(n),index:Math.min(Math.max(o,0),Ii(n).length)},s=gn(i,l);if(e!==n||s!==t)try{mi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof $n))throw e}},Zl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of yl(e))n.add(r),t(o)};for(const t of gl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},ql=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Oi.get(n);if(!e)return null;if(e.zone===ze)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Ql=e=>{const n=e.slice(0,e.indexOf(":")),t=ai.find(e=>Vt(e.type)&&String(e.props.id)===n);return t&&Ft(n)===e?t:null},_l=(e,n)=>{const t=Ql(e);return!t||(!At.groupAccepts||At.groupAccepts(t.type,n,Ii(e).length))},es=(e,n,t)=>{if(e.rung){const t=Bi(e.rung.nodeId),o=t?Pi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===yt&&n.index>=0&&n.index<=o}if(n.slot===yt)return!1;if(e.add)return rs(e.add,n);const o=In(n);if(Vt(e.type))return!1;const r=Ql(o),i=Ql(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!_l(o,e.type))&&(n.index>=0&&n.index<=Ii(o).length));if(e.zone===ze||o===ze){if(e.zone!==o)return!1;const{floor:t,cap:r}=ci();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Ii(o).length)return!1;if(e.zone===o)return!0;const l=$l&&!At.lastIsOpen?String($l.props.id):null;return(!l||ql(e.zone)!==l&&ql(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Ii(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Oi.get(i),s=l?Ii(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Zl(r).has(n))return!1;const d=mr(s.type,fr(Bt?.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?.(Ii(n),r))})(e.zone,o,e.index,t)},ns=(e,n)=>{const t=In(e.from),o=e.node;return t===In(n)?_l(t,o.type):es({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},ts=e=>{const n=e.slice(0,e.indexOf(":")),t=Oi.get(n),o=t?Ii(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=mr(o.type,fr(Bt?.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=I(r.choices??(r.spec?[{type:r.spec.childType,label:wi(r.spec.childType)}]:[])),l=$i(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:sl(o,t.zone===ze)}},os=(e,n)=>{if("section"!==e.kind)return e;const t=In(n);return t===ze||Ql(t)?e:ts(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},rs=(e,n)=>{const t=os(e,n),o=In(n);if("shared"===t.kind){if(o!==ze||!At.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=ci();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(Ql(o)){const e="section"===t.kind?t.type:t.template.node.type;return _l(o,e)&&n.index>=0&&n.index<=Ii(o).length}if(o!==ze)return!1;const{floor:e,cap:r}=ci();return n.index>=e&&n.index<=r}if(o===ze)return!1;const r=ts(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Ii(o))},is=(e,n)=>{const t=os(e,n);if("block"!==t.kind&&Ql(In(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&_l(n,o)){if("section"===e.kind)ao.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;ao.insertNode(n,t,fi(e.template.node))}Zo(R),ao.select({index:t,zone:n})}})(t,In(n),n.index);if("section"===t.kind)return void ol(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=el(t),r=ao.insertNode(ze,o,n);tl(o,r,e)})(t.template.name,fi(t.template.node),n.index);if("shared"===t.kind){const e=At.shared?.nodeOf(t.section);if(!e)return;const o=el(n.index);return void(mi.restore(e,{parentId:On,slot:Nn,index:o})&&tl(o,e.props.id,t.section.title))}const o=In(n),r=ts(o);r&&(r.target.spec?Nl(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{ao.insertComponent(e,n,t),Zo(R),ao.select({index:t,zone:e})})(o,t.type,n.index))},ls=(e,n)=>{e.media?function(e){const n=Ls();if(!n||!Ts)return;Rs(n).then(n=>{n&&function(e,n){if(!Ts)return;const t=Ts.create(e,{nodeDefaults:xi,newNodeId:Be,sectionLabel:zi,blockIsOffered:gr}),o=In(n);if(o===ze){const e=el(n.index),o=ao.insertNode(ze,e,t);return void tl(e,o,zi(t.type))}ao.insertNode(o,n.index,t),Zo(R),ao.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Li(e.rung.nodeId,e.index,n.index):e.add?is(e.add,n):e.zone===ze?nl(e.index,n.index):Xl(e.zone,In(n),e.index,n.index)},[ss]=jn(()=>hn()),ds=mn({keyOf:e=>e.id,readOnly:Boolean(wt),session:ss,canDrop:es,onDrop:ls,onStep:(e,n)=>{e.rung?Li(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===ze?((e,n)=>{const t=zi(ai[e]?.type??""),o=nl(e,n<0?e-1:e+2);if(!o.moved)return void Hr(n<0?Jt.sectionFirst({name:t}):Jt.sectionLast({name:t}));const{floor:r,cap:i}=ci();Hr(Jt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Xl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),as=Ln(e=>{const{floor:n,cap:t}=ci(),o=[];for(const r of e.nodes){const e=In(r.place),i=Ii(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Wt(i)||Ut(i)||pr(i.type,i))continue;if(Vt(i.type))continue;const l=Boolean(Ql(e)),s=e===ze||l;e===ze&&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?zi(i.type):Vi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=In(e.list);if(n===ze&&0===e.children.length)return[{...e,addLabel:Jt.addSection,addAlways:!0}];const t=ts(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(Ql(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=In(e.list),t=n===ze||Ql(n)?null:ts(n);return t?.choices.length?cn(e,t.target.spec?.addLabel??Jt.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[Bt.data]),cs=null==Mt?.props.id?null:String(Mt.props.id),ps=Ln(e=>{const n=jt,t=e=>!e.item.rung&&null!==Pn(Bt.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(cs);return i||(r(Ge(Bt.data,n,o.item.id,cs,Al))??o)},[Bt.data,jt,cs,Al]),[us,fs]=jn(null),hs=Boolean(jl||El);Sn(Ao,"mouseover",e=>{if(!hs)return;const n=wn(e.target),t=n?ut(Bt.data,jt,n):null;t!==us&&fs(t)}),Sn(Ao,"mouseout",e=>{hs&&!e.relatedTarget&&fs(null)});const ms=e=>Wt(e)||Ut(e)||Vt(e.type),gs=e=>{const n=Vt(e.type)?wi(e.type):Wt(e)?Jt.header:Ut(e)?Jt.footer:null;return null===n?Ci(e):yr.rowName?yr.rowName(e,"section",n):n},ys=[];if(hs){const e=cs?ut(Bt.data,jt,cs):null;for(const n of/* @__PURE__ */new Set([e,us])){const e=n?ai.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=Wt(e)||e.type===Et,o=Rl(e);if(o){ys.push({id:String(e.props.id),label:gs(e),below:t,reach:o});continue}if(!jl||!ms(e))continue;const r=jl(e);r&&ys.push({id:String(e.props.id),label:r,below:t})}}const vs=pe(),ks=Mn(null);An(()=>{const e=At.changeNotice;if(!e)return;const n=JSON.stringify(ai.filter(ms)),t=ks.current;if(ks.current={doc:zn,bands:n,index:$t.index},!t||t.doc!==zn||t.bands===n)return;$t.hasPast&&$t.index>=t.index&&!pt.has(vs)&&(pt.add(vs),Hr(e,"success",{action:{label:Jt.bar.undo,onClick:()=>$t.back()},duration:8e3}))},[ai]);const bs=e=>{Zo(R),ao.select(e.zone===ze?{index:e.index}:{index:e.index,zone:e.zone})},Ss=X(),ws=()=>({data:Bt.data,device:vo,ops:ao,inspector:sr}),xs=Ss?.model,zs=Tn(()=>xs?e=>xs(e,as(e),ws()):as,[xs,as,vo]),Cs=Ss?.measure,Os=Cs?(e,n)=>Cs(e,n,ws()):void 0,Ns=Ss?.canDrop,Is=Ns?(e,n)=>Ns(e,n,es,ws()):es,Bs=Ss?.drop,Ps=Bs?(e,n)=>Bs(e,n,ls,ws()):ls,$s=Ss?.pick,Ms=$s?e=>$s(e,bs,ws()):bs,Ts=Ss?.media??null,js=Mn(null),As=Tn(()=>Ts?{id:at,zone:"",index:-1,type:Ts.adds.type,add:{kind:Ts.adds.kind,type:Ts.adds.type},media:!0}:null,[Ts]);An(()=>{if(!As||wt||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(Zn))(e)&&(js.current=null,ss.start({key:at,item:As}))},n=e=>{ss.get()?.item.media&&(js.current=Wn(e.dataTransfer))},t=()=>{ss.get()?.item.media&&ss.end()};return document.addEventListener("dragstart",e),document.addEventListener("drop",n,!0),document.addEventListener("dragend",t,!0),()=>{document.removeEventListener("dragstart",e),document.removeEventListener("drop",n,!0),document.removeEventListener("dragend",t,!0)}},[As,wt,ss]);const Ls=()=>{const e=js.current;return js.current=null,e},Es=ce(),Rs=async e=>{if(!Es)return e;const n=await Es(e);return n?{...e,id:n.id,url:n.url}:null};const Vs=(e,n)=>{if(!Ts)return;const t=Pn(so.getState().appState.data,pi,n);if(!t)return;const o=t.node;ao.replaceComponent(In(t.place),t.place.index,{...o,props:{...Ts.replace(o,e),id:o.props.id}})},Fs=e=>{const n=In(e),t=$i(n);t&&ji(t.node,t.slot,!1),il(n,e.index)},Ds=(e,n)=>/* @__PURE__ */lt(De,{...wt?{}:ds.seam({place:{...Bn(e),index:n}})},`seam:${e}:${n}`),Hs={rowClick:dl,isCollapsed:Er,toggleCollapse:Rr},Ws=e=>{const n=String(e.props.id),t=ai.findIndex(e=>String(e.props.id)===n),o=Ft(n),r=Ii(o),i=Er(n),l=wi(e.type),s=yr.rowName?yr.rowName(e,"section",l):l,d=e=>Ds(o,e);/* @__PURE__ */
|
|
16
|
+
return st(dt,{children:[
|
|
17
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:e.type,size:13}),name:s,preview:cl(e),marks:pl(e),onSelect:()=>_i(t),nameSlot:Di(ze,t,n,s),selected:Qo===n,badge:Rl(e)?void 0:Hl,shared:Rl(e),actions:ul(e,ze,t)??void 0,rowProps:{"data-node-id":n,onClick:dl(()=>_i(t))},fold:{open:!i,label:"section",onToggle:()=>Rr(n)}}),!i&&/* @__PURE__ */st(Ee,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Ci(n),l=zl(n),s=l&&Er(r),a=()=>Ol(o,t,r,e.type),{rowProps:c,...p}=ds.row({item:{id:r,zone:o,index:t,type:n.type},place:{...Bn(o),index:t}},{"data-node-id":r,onClick:dl(a)});/* @__PURE__ */
|
|
18
|
+
return st(Rn,{children:[d(t),
|
|
19
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:n.type,size:13}),name:i,preview:cl(n),marks:pl(n),onSelect:a,nameSlot:Di(o,t,r,i),selected:Qo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Rr(r)}:void 0,actions:/* @__PURE__ */st(dt,{children:[al(o,t,i),ul(n,o,t),fl(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */lt(Ee,{children:Gs(n,2)})]},r)}),d(r.length)]})]})},Us=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=ds.dragging,d=!Er(l)&&s?.rung?.nodeId!==i,a={...Bn(l),index:0},c=s&&!s.rung&&es(s,a)?a:void 0,p=()=>ji(e,n,!0),{rowProps:u,...f}=ds.row({item:{id:`rung:${l}`,zone:`${i}:${yt}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:yt,index:t},into:c,canDrag:Boolean(cr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:dl(p)}),h=wt?null:cr.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
20
|
+
return st(Rn,{children:[n.heading,
|
|
21
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Mi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Rr(l)},actions:h&&h.length>0?/* @__PURE__ */lt(dt,{children:h.map((t,o)=>/* @__PURE__ */lt(Fe,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(wt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Ai(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__ */lt(nt,{size:15}):/* @__PURE__ */lt(it,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */lt(Ee,{children:r})]},l)},Ys=(e,n)=>{const t=vl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
22
|
+
return lt(dt,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Sl(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,a=null===t.slot?null:`${e.props.id}:${t.slot}`,c=(e,n)=>Ds(e,n),p=/* @__PURE__ */st(dt,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Qo===String(n.props.id),{collapsible:i,folded:s}=wl(n,l,Cl(n.type)),d=String(n.props.id),a=Kl(n),p=()=>Ol(t,o,d,e.type),{rowProps:u,...f}=ds.row({item:{id:d,zone:t,index:o,type:n.type},place:{...Bn(t),index:o}},{"data-node-id":d,onClick:dl(p)});/* @__PURE__ */
|
|
23
|
+
return st(Rn,{children:[0===o&&c(t,0),
|
|
24
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:n.type,size:13}),name:a,preview:cl(n),marks:pl(n),onSelect:p,nameSlot:Di(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Rr(d)}:void 0,actions:/* @__PURE__ */st(dt,{children:[al(t,o,a),ul(n,t,o),fl(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */lt(Ee,{children:Ys(n,l+1)}),c(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===a?d&&!i.some(e=>e.zone===d)?c(d,0):null:0!==i.length||!t.rung&&d!==a?null:c(a,0)]});return t.rung?Us(e,t.rung,r++,o,p):/* @__PURE__ */lt(Rn,{children:p},t.slot??"")})})},Gs=(e,n)=>{const t=fr(Bt?.data,e.type,String(e.props.id)),o=vl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
25
|
+
return lt(dt,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Sl(e.type,t,o.slot),a=d?.spec??null,c=a&&Array.isArray(e.props[a.slot])?e.props[a.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=a&&!a.fixed?`${u}:${a.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>Ds(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===f)),v=/* @__PURE__ */st(dt,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Qo===String(n.props.id),i=Vi(n),l=String(n.props.id),{collapsible:d,folded:a}=wl(n,s,Cl(n.type)),c=gl(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...Bn(p),index:Ii(p).length}:void 0,f=ds.dragging,h=u&&f&&es(f,u)?u:void 0,g=()=>Ol(t,o,l,e.type),{rowProps:y,...v}=ds.row({item:{id:l,zone:t,index:o,type:n.type},place:{...Bn(t),index:o},into:h,canDrag:!pr(n.type,n)},{"data-node-id":l,onClick:dl(g)});/* @__PURE__ */
|
|
26
|
+
return st(Rn,{children:[0===o&&m(t,0),
|
|
27
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:n.type,size:13}),name:i,preview:cl(n),marks:pl(n),onSelect:g,nameSlot:Di(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...v,fold:d?{open:!a,label:"group",onToggle:()=>Rr(l)}:void 0,actions:pr(n.type,n)?ul(n,t,o)??void 0:/* @__PURE__ */st(dt,{children:[al(t,o,i),ul(n,t,o),fl(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */lt(Ee,{children:Gs(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
|
|
28
|
+
/* @__PURE__ */lt(w,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>Nl(e.props.id,a.slot,a.childType,c.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?Us(e,o.rung,i++,r,v):/* @__PURE__ */lt(Rn,{children:v},o.slot??"")})})},Js=Ho,Ks=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:po&&!Js&&ar===e.id,onSelect:()=>ii(e.id)}:e,Xs=[...(dr.railLead??[]).map(Ks),{id:"sections",label:Jt.layers,icon:/* @__PURE__ */lt(he,{}),active:po&&!Js&&"sections"===ar,onSelect:()=>ii("sections")},...(dr.railTrail??[]).map(Ks)];So?Xs.push({id:"media",label:Jt.railMedia,icon:/* @__PURE__ */lt(me,{}),active:zo,onSelect:Co}):Ot&&Xs.push({id:"media",label:Jt.railMedia,icon:/* @__PURE__ */lt(me,{}),onSelect:li});const Zs={value:Xs.find(e=>!0===e.active)?.id??"",press:e=>{const n=Xs.find(n=>n.id===e);n&&!n.disabled&&!0!==n.active&&n.onSelect?.()},items:Xs.map(e=>({id:e.id,icon:e.icon,label:/* @__PURE__ */lt("span",{className:"sr-only",children:e.label}),tooltip:e.label,disabled:e.disabled}))},qs=[...dr.railLead??[],...dr.railTrail??[]].find(e=>"panel"in e&&e.id===ar),Qs=Boolean(Gt?.foldable),_s=Gt?.label??(Nt?Jt.pageSections:Jt.templateSections),ed=Qs&&Er(vt),nd=/* @__PURE__ */st(dt,{children:[ai.map((e,n)=>{if(Wt(e)||Ut(e)||Vt(e.type))return null;const t=Qo===String(e.props.id),o=Boolean(e.props._hidden);yl(e);const r=String(e.props.id),i=dr.hasOwnRows?.(e)??!1,l=zl(e)||i,s=l&&Er(r),d=gl(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...Bn(a),index:Ii(a).length}:void 0,p=ds.dragging,u=c&&p&&es(p,c)?c:void 0,{rowProps:f,...h}=ds.row({item:{id:r,zone:ze,index:n,type:e.type},place:{...Bn(ze),index:n},into:u,canDrag:!pr(e.type,e)},{"data-node-id":r,onClick:dl(()=>_i(n))});/* @__PURE__ */
|
|
29
|
+
return st(Rn,{children:[n>0&&hl(n),
|
|
30
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:e.type,size:13}),name:Ci(e),preview:cl(e),marks:pl(e),shared:Rl(e),onSelect:()=>_i(n),nameSlot:Di(ze,n,r,Ci(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Rr(r)}:void 0,actions:/* @__PURE__ */st(dt,{children:[al(ze,n,Ci(e)),ul(e,ze,n),fl(ze,n,e,Ci(e))]}),rowProps:f}),zl(e)&&!s&&/* @__PURE__ */st(Ee,{children:[Gs(e,1),dr.partRows?.(e,Hs)]}),i&&!s&&/* @__PURE__ */lt(Ee,{children:dr.ownRows?.(e,n,Hs)})]},String(e.props.id??n))}),Yl>0&&hl(Yl)]}),td=(e,n,t)=>{const o=String(e.props.id),r=kl(e).length>0||bl(e)||Boolean(mr(e.type)),i=r&&Er(o),l="header"===t?Jt.header:Jt.footer,s=yr.rowName?yr.rowName(e,"section",l):l;/* @__PURE__ */
|
|
31
|
+
return st(dt,{children:[
|
|
32
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:t,size:13}),name:s,preview:cl(e),marks:pl(e),badge:Rl(e)?void 0:Hl,shared:Rl(e),onSelect:()=>_i(n),nameSlot:Di(ze,n,o,s),selected:Qo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Rr(o)}:void 0,actions:ul(e,ze,n)??void 0,rowProps:{"data-node-id":o,onClick:dl(()=>_i(n))}}),r&&!i&&/* @__PURE__ */lt(Ee,{children:Ys(e,1)})]})};return(dr.wrap??(e=>e))(
|
|
33
|
+
/* @__PURE__ */lt(Z,{target:Ao,children:/* @__PURE__ */st("div",{ref:jo,className:"sf-editor es-editor",style:tn(Mr),onContextMenu:Ji.onEditorContextMenu,...u(vn),children:[
|
|
34
|
+
/* @__PURE__ */st(Je,{children:[
|
|
35
|
+
/* @__PURE__ */lt("div",{className:"es-cluster es-cluster--left","aria-hidden":"true"}),
|
|
36
|
+
/* @__PURE__ */st(Ke,{children:[
|
|
37
|
+
/* @__PURE__ */lt(Xe,{label:Jt.bar.undo,disabled:Boolean(wt)||!$t.hasPast,onClick:()=>$t.back(),children:/* @__PURE__ */lt(qn,{})}),
|
|
38
|
+
/* @__PURE__ */lt(Xe,{label:Jt.bar.redo,disabled:Boolean(wt)||!$t.hasFuture,onClick:()=>$t.forward(),children:/* @__PURE__ */lt(Qn,{})}),
|
|
39
|
+
/* @__PURE__ */lt(Ze,{}),
|
|
40
|
+
/* @__PURE__ */lt(qe,{devices:fo,value:vo,onChange:ko}),
|
|
41
|
+
/* @__PURE__ */lt(Xe,{label:Jt.bar.refresh,tip:Jt.bar.refreshTip,onClick:()=>{To.current=(()=>{const e=Ao?.document;if(!e)return null;const n=ai.findIndex(Ut),t=n>=0?n:ai.length;let o=null;for(let n=0;n<t;n++){const t=ai[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=Mt?.props?.id??ai[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Mo(e=>e+1)},children:/* @__PURE__ */lt(_n,{})})]}),
|
|
42
|
+
/* @__PURE__ */st(Ke,{kind:"right",style:{minWidth:300},children:[
|
|
43
|
+
/* @__PURE__ */lt(k,{input:Fo,words:Jt.saveStatus}),dr.barLead?.(),dr.barTrail?.(),dr.mainAction||!dr.barMain?/* @__PURE__ */lt(b,{input:Fo,action:dr.mainAction??{label:Jt.done,onPress:()=>{Yn(Bt.data)}},readOnly:Boolean(wt),saveSwitch:zt,onToggleAutoSave:Xn,onSaveNow:Do,bar:Jt.bar,words:Jt.saveStatus}):dr.barMain()]})]}),
|
|
44
|
+
/* @__PURE__ */lt(oe,{}),
|
|
45
|
+
/* @__PURE__ */st("div",{className:"sf-body",children:[po?/* @__PURE__ */st(dt,{children:[
|
|
46
|
+
/* @__PURE__ */st("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Jt.leftPanel,children:[
|
|
47
|
+
/* @__PURE__ */lt("div",{className:"es-paneltabs",children:/* @__PURE__ */lt(Dn,{variant:"underline",block:!0,"aria-label":Jt.bar.views,value:Zs.value,onChange:Zs.press,items:Zs.items})}),Ho?/* @__PURE__ */lt(x,{at:Yo?{label:(e=>{const n=Ql(e.zone);if(n)return Jt.add.addingTo({name:yr.rowName?sl(n,!0):wi(n.type)});if(e.zone===ze){const n=ai[e.index];return n&&!Ut(n)?Jt.add.addingBefore({name:sl(n,!0)}):Jt.add.addingAtEnd}const t=ts(e.zone);return t?Jt.add.addingTo({name:t.parentName}):Jt.add.addingHere})(Yo),onClear:()=>Go(null)}:void 0,placeBlocks:Yo&&Yo.zone!==ze?ts(Yo.zone)?.choices:void 0,canTake:Yo?e=>{if(!Yo)return null;const n={...Bn(Yo.zone),index:Yo.index};if(rs(e,n))return null;if("shared"===e.kind&&Yo.zone===ze&&!At.shared?.nodeOf(e.section))return Jt.shared.alreadyHere;const t=Ql(Yo.zone);if(t)return Jt.add.notInside({name:sl(t,!0)});if(Yo.zone===ze)return Jt.add.onlySections;const o=ts(Yo.zone);return o?Jt.add.notInside({name:o.parentName}):Jt.add.onlySections}:void 0,onPick:Yo?e=>{if(!Yo)return;const n={...Bn(Yo.zone),index:Yo.index};rs(e,n)&&(is(e,n),ll())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:"shared"===e.kind?e.section.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:"shared"===e.kind?e.section.node.type:e.type,add:e}),session:ss,siteWide:dr.addPanelRow?.(ll),onClose:ll,onHide:oi,readOnly:Boolean(wt)}):qs?qs.panel({onHide:oi,notify:Hr}):/* @__PURE__ */st(dt,{children:[
|
|
48
|
+
/* @__PURE__ */lt(O,{icon:/* @__PURE__ */lt(he,{}),title:Jt.layers,context:no,actions:/* @__PURE__ */st(dt,{children:[!wt&&/* @__PURE__ */lt(Qe,{label:Jt.add.title,onClick:()=>rl(null),children:/* @__PURE__ */lt(et,{size:15})}),
|
|
49
|
+
/* @__PURE__ */lt(Qe,{label:Jl?Jt.expandAll:Jt.collapseAll,title:0===Gl.length?Jt.nothingToFold:void 0,disabled:0===Gl.length,onClick:()=>$r(e=>{const n=new Set(Gl);return Jl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Gl])}),children:/* @__PURE__ */lt(ht,{expand:Jl})})]}),onHide:oi}),
|
|
50
|
+
/* @__PURE__ */st(Re,{className:"sf-tree sf-scroll",words:Kt,children:[
|
|
51
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:"page",size:13}),name:Jt.pageSettings,onSelect:si,selected:!Mt&&qo,rowProps:{onClick:dl(si)}}),Wl&&/* @__PURE__ */st(dt,{children:[!Ll&&/* @__PURE__ */lt(Ve,{children:Jt.header}),Ws(Wl)]}),It&&!(Ll&&Wl)&&/* @__PURE__ */st(dt,{children:[!Ll&&/* @__PURE__ */lt(Ve,{children:Jt.header}),!Yt&&/* @__PURE__ */lt(Le,{words:Kt,icon:/* @__PURE__ */lt(kr,{type:"header",size:13}),name:Jt.header,badge:Dl?void 0:Hl,shared:Dl,onSelect:di,selected:Xo.kind===Ht?.kind,rowProps:{onClick:dl(di)}})]}),Tl&&!(Ll&&Wl)&&td(Tl,Ml,"header"),!Qs&&/* @__PURE__ */lt(Ve,{children:_s}),Qs?/* @__PURE__ */st(dt,{children:[
|
|
52
|
+
/* @__PURE__ */lt(Le,{words:Kt,icon:null,name:_s,fold:{open:!ed,label:_s,onToggle:()=>Rr(vt)}}),!ed&&/* @__PURE__ */lt(Ee,{children:nd})]}):nd,It&&!Ll&&/* @__PURE__ */lt(Ve,{children:Jt.footer}),$l&&!(Ll&&Ul)&&td($l,Pl,"footer"),Ul&&Ws(Ul),dr.treeFoot?.()]})]})]}),
|
|
53
|
+
/* @__PURE__ */lt(_e,{side:"left",width:Mr.left,min:nn.left,max:en,defaultWidth:m.left,label:Jt.resizeLeftPanel,onResize:Ar})]}):/* @__PURE__ */lt(N,{side:"left",onShow:oi}),
|
|
54
|
+
/* @__PURE__ */st("div",{ref:Wr,className:"sf-center sf-scroll","data-sf-canvas-head":Kr?"":void 0,style:{overflowX:ei?"auto":"hidden",overflowY:"hidden"},children:[Kr&&/* @__PURE__ */lt("div",{ref:Xr,className:"sf-canvas-head",children:/* @__PURE__ */lt(Kr,{device:vo})}),
|
|
55
|
+
/* @__PURE__ */st("div",{className:"sf-frame-scaler",style:ni,children:[
|
|
56
|
+
/* @__PURE__ */lt("div",{className:"sf-frame "+(vo===go?"":`sf-frame--${vo}`),style:ti,children:/* @__PURE__ */st("div",{className:"sf-preview-host",children:[
|
|
57
|
+
/* @__PURE__ */lt(je.Provider,{value:Al,children:/* @__PURE__ */lt(Ae.Provider,{value:Fl,children:/* @__PURE__ */lt(to,{},$o)})}),
|
|
58
|
+
/* @__PURE__ */lt(pn,{canvas:Ao,session:ss,model:zs,measure:Os,canDrop:Is,onDrop:Ps,choose:ps,onPick:Ms,dropOn:Ts?{accepts:(e,n)=>{if(!e.media||!Ts||n.item.rung)return!1;const t=Pn(Bt.data,pi,n.item.id);return null!==t&&Ts.takes(t.node)},onDrop:(e,n)=>(e=>{const n=Ls();n&&Ts&&Rs(n).then(n=>{n&&Vs(n,e.item.id)})})(n),label:()=>Jt.canvasReplaceImage}:void 0,onZoneAdd:Fs,onSeamAdd:Fs,zoneAddLabel:Jt.canvasAddBlock,words:Xt.canvas,readOnly:Boolean(wt),revision:Bt.data}),Jo.length>0&&!Lo&&/* @__PURE__ */lt("div",{className:"sf-preview-gaps",children:Jo.map(e=>
|
|
59
|
+
/* @__PURE__ */lt(un,{index:e.index,label:Jt.addSectionHere,onInsert:()=>rl(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))})]})}),hs?/* @__PURE__ */lt(ft,{canvas:Ao,tabs:ys,onSelect:e=>{const n=ai.findIndex(n=>String(n.props.id)===e);n>=0&&_i(n)}}):null]})]}),uo?/* @__PURE__ */st(dt,{children:[
|
|
60
|
+
/* @__PURE__ */lt(f,{value:{selectChild:Ol,addChild:Nl,childRowName:Vi,blockRowName:Kl},children:/* @__PURE__ */lt(oo,{mode:Xo,onOpenWebsiteSettings:dr.openSettings??(()=>{}),onOpenSiteStyles:dr.openStyles,onSelectNode:xr,onNotify:Hr,onHidePanel:ri,nodeActions:Mt?Ce(jt,Mt.type):kt})}),
|
|
61
|
+
/* @__PURE__ */lt(_e,{side:"right",width:Mr.right,min:nn.right,max:en,defaultWidth:m.right,label:Jt.resizeSettingsPanel,onResize:Lr})]}):
|
|
62
|
+
/* @__PURE__ */lt(N,{side:"right",onShow:ri})]}),Ji.menu,
|
|
63
|
+
/* @__PURE__ */lt(ee,{}),yi?/* @__PURE__ */lt(ct,{name:yi.name,onMake:e=>(async(e,n)=>{const t=ai.find(n=>String(n.props.id)===e),o=At.shared;if(!t||!o)return;let r;try{r=await C(gi).create(n,t)}catch{return void Hr(Jt.shared.makeFailed,"error")}o.adopt(t,r),vi(null)})(yi.id,e),onCancel:()=>vi(null)}):null]})}))}export{bt as ScreenChrome};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e,jsxs as n,Fragment as l}from"react/jsx-runtime";function r(e){return e.map((e,n)=>{const l=String(n);if("—"===e.label)return{type:"divider",key:l};if(e.header)return{type:"label",key:l,label:e.label};if(e.children?.length){const n=e.children.some(e=>void 0!==e.checked);return{type:"submenu",key:l,label:e.label,icon:t(e),items:e.children.map((e,l)=>n?{type:"radio",key:String(l),label:c(e),icon:t(e),checked:Boolean(e.checked),onSelect:e.onClick}:{type:"item",key:String(l),label:c(e),icon:t(e),danger:e.danger,onSelect:e.onClick})}}return{type:"item",key:l,label:c(e),icon:t(e),danger:e.danger,disabled:e.disabled,onSelect:e.onClick}})}function i(e){return e.find(e=>e.header)?.label}function t(n){return null==n.icon?void 0:/* @__PURE__ */e("span",{className:"es-menu-icon","aria-hidden":"true",children:n.icon})}function c(r){return null==r.icon&&null==r.shortcut?r.label:/* @__PURE__ */n(l,{children:[
|
|
2
|
+
/* @__PURE__ */e("span",{className:"es-menu-label",children:r.label}),null==r.shortcut?null:/* @__PURE__ */e("span",{className:"es-menu-shortcut","aria-hidden":"true",children:r.shortcut})]})}export{r as easelMenuEntries,i as menuLabel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e,offeredChoices as r}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as s}from"./chunk-
|
|
1
|
+
import{blockRuns as e,offeredChoices as r}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as s}from"./chunk-OGBYHQE6.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-23DYNW6S.js";import{useWords as n}from"./chunk-MFIRYGHW.js";import{DropdownMenu as c}from"efficient-shell/ui";import{jsxs as i,Fragment as o,jsx as l}from"react/jsx-runtime";function p({choices:p,onPick:a}){const{Icon:m}=s(),u=n("screen",t),f=e(r(p)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */i(o,{children:[e.group," ",
|
|
2
2
|
/* @__PURE__ */l("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */l("span",{className:"sf-chip",children:/* @__PURE__ */l(m,{type:e.type,size:13})}),onSelect:()=>a(e.type)}))]);/* @__PURE__ */
|
|
3
3
|
return l(c,{align:"start",triggerClassName:"sf-add-card",items:f,trigger:/* @__PURE__ */i(o,{children:[
|
|
4
4
|
/* @__PURE__ */l("span",{className:"sf-plus sf-plus--sm",children:"+"}),u.addBlockMenu]})})}export{p as AddBlockRow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-7OKL7HDV.js";import{SELECTION_MODE as e}from"./chunk-OGBYHQE6.js";import{decodePartId as r,encodePartId as t}from"./chunk-IYT6NN2J.js";import{useEasel as n}from"./chunk-KOVJODTY.js";import{usePreviewParts as p}from"./chunk-I54UCYOU.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=n(o=>o),I=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{k(l)},[k,l]);const K=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(K)},[K,f]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&I.select(r)},[i,u,I]),openPartId:K}}export{m as usePartBridge};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPickPart as l,clickPick as s}from"./chunk-X3TYRF5V.js";import{setCanvasNonce as a,CANVAS_TYPABLE_EVENT as c,isTypingTarget as d,frameRectToHost as u,CANVAS_TYPING_EVENT as p,drawnBox as f}from"./chunk-X4T6JT3M.js";import{find as h,ROOT_ID as m,getList as g,remove as v,parseZoneKey as y,move as w,duplicate as b,replaceNode as k,createNode as S,insert as C,normalizeData as I,createResolveCache as E,resolveNodeData as D,ROOT_SLOT as x}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as M,fieldsFrom as A,defaultsFrom as O}from"./chunk-NKB3KVAB.js";import{selectionBox as R,placeWindow as z,offsetOrigin as V,colorRunOf as P,ColorWindow as $,startCanvasTyping as B,textMap as L}from"./chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as N}from"./chunk-KRL3IUV3.js";import{useWords as K}from"./chunk-MFIRYGHW.js";import{createContext as j,useEffect as Z,useContext as T,useRef as F,useSyncExternalStore as H,useState as W,useMemo as Y,useCallback as q,useLayoutEffect as X}from"react";import{jsx as U,jsxs as G,Fragment as J}from"react/jsx-runtime";import{createPortal as Q}from"react-dom";import{registerModalEscapeInterceptor as _,FloatingBar as ee,TextToolbar as te,LinkPicker as ne}from"efficient-shell/ui";function oe(e){return!["setData","setUi","set"].includes(e.type)}var re=(e,t,n,o)=>{const r=g(e,t,y(n));return r?.[o]??null},ie=(e,t,n,o,r)=>{const i=re(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function le(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function se(e,t,n){return n?"node"===n.kind?h(e,t,n.id)?n:null:n.parentId===m?g(e,t,n)?n:null:h(e,t,n.parentId)&&g(e,t,n)?n:null:null}function ae(e,t,n,r=!1){const{itemSelector:i,selectedSlot:l,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,i??null)),"selectedSlot"in n&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ce(e,t,n){const o=de(e,t,n);if(o===e)return e;const r=se(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function de(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 ae(e,n,"function"==typeof t.ui?t.ui(le(e,n)):t.ui);case"set":{const r={data:o,ui:le(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=ae(l,n,i.ui,!0)),l}case"insert":{const r={...y(t.destinationZone),index:t.destinationIndex},i=S(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:C(o,n,r,i)}}case"replace":{const r=ie(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:k(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=ie(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=b(o,n,r.props.id),l=re(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return de(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=re(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...y(t.destinationZone),index:t.destinationIndex};return{...e,data:w(o,n,r.props.id,i)}}case"remove":{const r=ie(o,n,t.zone,t.index,"remove");return{...e,data:v(o,n,r.props.id)}}default:return e}}var ue={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},pe={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},fe=0,he=()=>`history-${fe+=1}`;function me(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=I(e.data,t);let a=s,c={data:s,selection:null,ui:{...pe}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...pe,...i}}}let d=[{core:c,at:-1/0,sealed:!0,id:he()}],u=0;const p=e=>{const t=d[u],n=r();!e&&u===d.length-1&&u>0&&!t.sealed&&n-t.at<i?d=[...d.slice(0,u),{...t,core:c,at:n}]:(d=[...d.slice(0,u+1),{core:c,at:n,sealed:e,id:he()}],u=d.length-1)},f=/* @__PURE__ */new Set;let m=null,v=null,y=0,w=null,b=!1;const S=()=>{for(const e of[...f])e()},C=()=>{d=[...d.slice(0,u),{...d[u],core:c},...d.slice(u+1)]},x=(t,n)=>{y>0?b=b||n:(n?p(!1):c!==t&&C(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&S())},M=e=>{const n=c;if(c=ce(c,e,t),c===n)return;const o=e.recordHistory??oe(e);x(n,o&&c.data!==n.data)},A=t=>{0===y&&(w=c,b=!1),y+=1;try{t()}catch(e){throw y-=1,0===y&&w&&(c=w,w=null),e}if(y-=1,y>0||!w)return;const n=w;w=null,b&&c.data!==n.data?p(!0):c!==n&&C(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&S()},O=e=>{const n=c,o=se(c.data,t,e);var r,i;(r=o,i=c.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(c={...c,selection:o},x(n,!1))},R=t=>{const n=c;u=t,c=d[u].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&S()},z=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ue,...l,...n}};let V=z();const P=E(),$={resolveCache:P,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([D(r,t,{cache:P,trigger:e,metadata:n}),...i.map(o=>D(o,t,{cache:P,trigger:e,metadata:n}))]);A(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const l=i[n].props.id,s=h(r,t,l)?.node;s&&s===h(o,t,l)?.node&&(r=k(r,t,l,e.node))}),l.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:l.node.props,readOnly:l.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:se(r,t,c.selection)},x(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=h(c.data,t,e)?.node;if(!r)return!1;const i=await D(r,t,{cache:P,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return A(()=>{const n=c;if(h(c.data,t,e)?.node!==r)return;const o=k(c.data,t,e,i.node);o!==c.data&&(c={...c,data:o,selection:se(o,t,c.selection)},x(n,!1),l=!0)}),l},get config(){return t},get loaded(){return a},getState(){if(m&&v===c)return m;const e=c,o={data:e.data,ui:le(e,t)},r="node"===e.selection?.kind?h(e.data,t,e.selection.id)?.node??null:null;return m={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:M,history:{back:()=>$.undo(),forward:()=>$.redo(),hasPast:u>0,hasFuture:u<d.length-1,histories:d.map(e=>({id:e.id,state:{data:e.core.data,ui:le(e.core,t)}})),index:u,setHistoryIndex:e=>{e>=0&&e<d.length&&e!==u&&R(e)}},getPermissions:V,getItemById:n=>h(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return g(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},v=e,m},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:M,batch:A,group:()=>{const e=u,t=d[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,d[e]?.id!==t)return;if(u<=e+1)return void(u===e+1&&(d=[...d.slice(0,u),{...d[u],sealed:!0},...d.slice(u+1)]));const o=d[u];d=[...d.slice(0,e+1),{...o,sealed:!0},...d.slice(u+1)],u=e+1}}},select:e=>O(e?{kind:"node",id:e}:null),selectSlot:e=>O(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){A(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:se(e.data,t,o)},x(n,e.data!==n.data)})},load(e,n={}){const o=c,r=I(e,t);c={...c,data:r,selection:se(r,t,n.selection??c.selection)},a=r,n.keepHistory||(d=[{core:c,at:-1/0,sealed:!0,id:he()}],u=0),c!==o&&S()},undo(){u>0&&R(u-1)},redo(){u<d.length-1&&R(u+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,l)||(l=e,V=z(),m=null,S())},setConfig(e){e!==t&&(t=e,V=z(),m=null,S())}};return $}function ge(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&&d(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 ve=j(null),ye=j(!0);function we({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return Z(()=>{n&&e.resolveAll()},[e,n]),Z(()=>{if(t&&"undefined"!=typeof document)return ge(document,e)},[e,t]),/* @__PURE__ */U(ve.Provider,{value:e,children:/* @__PURE__ */U(ye.Provider,{value:t,children:o})})}function be(){const e=T(ve);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ke(e){const t=be(),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 H(t.subscribe,o,o)}function Se(){return function(e){return ke(e)}}var Ce="data-puck-component",Ie="data-puck-dropzone",Ee={},De="data-es-mirror",xe="undefined"==typeof window?Z:X;function Me(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${De}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(De,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Ae({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:c="auto",nonce:d}){const u=K("canvas",e),p=F(null),[f,h]=W(null);return xe(()=>{const e=p.current,t=f?.ownerDocument.defaultView;if("auto"!==c||!e||!f||!t)return;const n=()=>{e.style.height=`${Math.ceil(f.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(f),()=>r?.disconnect()},[f,c]),xe(()=>{let e=p.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=p.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"===c&&t.classList.add("es-frame-fill"),e.body.appendChild(t),a(e,d),h(t),s?.(e);let n=null;const o=p.current?.ownerDocument;if(l&&o){Me(o,e,d);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Me(o,e,d)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),h(null),s?.(null)}},[]),/* @__PURE__ */U("iframe",{ref:p,id:n,title:o??u.frame,className:["es-canvas-frame","fill"===c?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:f?Q(t,f):null})}var Oe=j(null),Re=j(Ee),ze=[];function Ve({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=be(),s=ke(n=>g(n.appState.data,l.config,{parentId:e,slot:t})??ze),a=ke(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==m),c=ke(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=T(Oe),u=["es-zone"];return s.length&&u.push("has-children"),e===m&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==m&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */U("div",{className:u.join(" "),[Ie]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */U(Ze,{node:e},e.props.id))})}function Pe(e,t){return Y(()=>{const n={};for(const o of M(A(e)))n[o]=function(e={}){/* @__PURE__ */
|
|
1
|
+
import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPickPart as l,clickPick as s}from"./chunk-X3TYRF5V.js";import{selectionBox as a,placeWindow as c,offsetOrigin as d,colorRunOf as u,ColorWindow as p,startCanvasTyping as f,textMap as h}from"./chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as m}from"./chunk-KRL3IUV3.js";import{useWords as g}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as v,CANVAS_TYPABLE_EVENT as y,isTypingTarget as w,frameRectToHost as b,CANVAS_TYPING_EVENT as k,drawnBox as S}from"./chunk-X4T6JT3M.js";import{find as C,ROOT_ID as I,getList as E,remove as D,parseZoneKey as x,move as M,duplicate as A,replaceNode as O,createNode as R,insert as z,normalizeData as V,createResolveCache as P,resolveNodeData as $,ROOT_SLOT as B}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as L,fieldsFrom as N,defaultsFrom as K}from"./chunk-NKB3KVAB.js";import{createContext as j,useEffect as Z,useContext as T,useRef as F,useSyncExternalStore as H,useState as W,useMemo as Y,useCallback as q,useLayoutEffect as X}from"react";import{jsx as U,jsxs as G,Fragment as J}from"react/jsx-runtime";import{createPortal as Q}from"react-dom";import{registerModalEscapeInterceptor as _,FloatingBar as ee,TextToolbar as te,LinkPicker as ne}from"efficient-shell/ui";function oe(e){return!["setData","setUi","set"].includes(e.type)}var re=(e,t,n,o)=>{const r=E(e,t,x(n));return r?.[o]??null},ie=(e,t,n,o,r)=>{const i=re(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function le(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function se(e,t,n){return n?"node"===n.kind?C(e,t,n.id)?n:null:n.parentId===I?E(e,t,n)?n:null:C(e,t,n.parentId)&&E(e,t,n)?n:null:null}function ae(e,t,n,r=!1){const{itemSelector:i,selectedSlot:l,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,i??null)),"selectedSlot"in n&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ce(e,t,n){const o=de(e,t,n);if(o===e)return e;const r=se(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function de(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 ae(e,n,"function"==typeof t.ui?t.ui(le(e,n)):t.ui);case"set":{const r={data:o,ui:le(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=ae(l,n,i.ui,!0)),l}case"insert":{const r={...x(t.destinationZone),index:t.destinationIndex},i=R(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:z(o,n,r,i)}}case"replace":{const r=ie(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:O(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=ie(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=A(o,n,r.props.id),l=re(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return de(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=re(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...x(t.destinationZone),index:t.destinationIndex};return{...e,data:M(o,n,r.props.id,i)}}case"remove":{const r=ie(o,n,t.zone,t.index,"remove");return{...e,data:D(o,n,r.props.id)}}default:return e}}var ue={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},pe={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},fe=0,he=()=>`history-${fe+=1}`;function me(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=V(e.data,t);let a=s,c={data:s,selection:null,ui:{...pe}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...pe,...i}}}let d=[{core:c,at:-1/0,sealed:!0,id:he()}],u=0;const p=e=>{const t=d[u],n=r();!e&&u===d.length-1&&u>0&&!t.sealed&&n-t.at<i?d=[...d.slice(0,u),{...t,core:c,at:n}]:(d=[...d.slice(0,u+1),{core:c,at:n,sealed:e,id:he()}],u=d.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},b=()=>{d=[...d.slice(0,u),{...d[u],core:c},...d.slice(u+1)]},k=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=ce(c,e,t),c===n)return;const o=e.recordHistory??oe(e);k(n,o&&c.data!==n.data)},I=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},D=e=>{const n=c,o=se(c.data,t,e);var r,i;(r=o,i=c.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(c={...c,selection:o},k(n,!1))},x=t=>{const n=c;u=t,c=d[u].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},M=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ue,...l,...n}};let A=M();const R=P(),z={resolveCache:R,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([$(r,t,{cache:R,trigger:e,metadata:n}),...i.map(o=>$(o,t,{cache:R,trigger:e,metadata:n}))]);I(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const l=i[n].props.id,s=C(r,t,l)?.node;s&&s===C(o,t,l)?.node&&(r=O(r,t,l,e.node))}),l.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:l.node.props,readOnly:l.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:se(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=C(c.data,t,e)?.node;if(!r)return!1;const i=await $(r,t,{cache:R,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return I(()=>{const n=c;if(C(c.data,t,e)?.node!==r)return;const o=O(c.data,t,e,i.node);o!==c.data&&(c={...c,data:o,selection:se(o,t,c.selection)},k(n,!1),l=!0)}),l},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,o={data:e.data,ui:le(e,t)},r="node"===e.selection?.kind?C(e.data,t,e.selection.id)?.node??null:null;return h={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:S,history:{back:()=>z.undo(),forward:()=>z.redo(),hasPast:u>0,hasFuture:u<d.length-1,histories:d.map(e=>({id:e.id,state:{data:e.core.data,ui:le(e.core,t)}})),index:u,setHistoryIndex:e=>{e>=0&&e<d.length&&e!==u&&x(e)}},getPermissions:A,getItemById:n=>C(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return E(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:I,group:()=>{const e=u,t=d[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,d[e]?.id!==t)return;if(u<=e+1)return void(u===e+1&&(d=[...d.slice(0,u),{...d[u],sealed:!0},...d.slice(u+1)]));const o=d[u];d=[...d.slice(0,e+1),{...o,sealed:!0},...d.slice(u+1)],u=e+1}}},select:e=>D(e?{kind:"node",id:e}:null),selectSlot:e=>D(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){I(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:se(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=V(e,t);c={...c,data:r,selection:se(r,t,n.selection??c.selection)},a=r,n.keepHistory||(d=[{core:c,at:-1/0,sealed:!0,id:he()}],u=0),c!==o&&w()},undo(){u>0&&x(u-1)},redo(){u<d.length-1&&x(u+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,l)||(l=e,A=M(),h=null,w())},setConfig(e){e!==t&&(t=e,A=M(),h=null,w())}};return z}function ge(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&&w(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 ve=j(null),ye=j(!0);function we({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return Z(()=>{n&&e.resolveAll()},[e,n]),Z(()=>{if(t&&"undefined"!=typeof document)return ge(document,e)},[e,t]),/* @__PURE__ */U(ve.Provider,{value:e,children:/* @__PURE__ */U(ye.Provider,{value:t,children:o})})}function be(){const e=T(ve);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ke(e){const t=be(),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 H(t.subscribe,o,o)}function Se(){return function(e){return ke(e)}}var Ce="data-puck-component",Ie="data-puck-dropzone",Ee={},De="data-es-mirror",xe="undefined"==typeof window?Z:X;function Me(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${De}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(De,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Ae({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=g("canvas",e),u=F(null),[p,f]=W(null);return xe(()=>{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]),xe(()=>{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),v(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){Me(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Me(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */U("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?Q(t,p):null})}var Oe=j(null),Re=j(Ee),ze=[];function Ve({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=be(),s=ke(n=>E(n.appState.data,l.config,{parentId:e,slot:t})??ze),a=ke(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==I),c=ke(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=T(Oe),u=["es-zone"];return s.length&&u.push("has-children"),e===I&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==I&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */U("div",{className:u.join(" "),[Ie]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */U(Ze,{node:e},e.props.id))})}function Pe(e,t){return Y(()=>{const n={};for(const o of L(N(e)))n[o]=function(e={}){/* @__PURE__ */
|
|
2
2
|
return U(Ve,{parentId:t,slot:o,...e})};return n},[e,t])}function $e(e){return Y(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
-
return U(Ve,{parentId:e,slot:t,...n})},[e])}var Be=["top","bottom","zIndex"];function Le(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Ne(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));Le(e,"position",t?"sticky":"relative");for(const n of Be)Le(e,n,t?.[n]??"");return!!t}var Ke="data-es-canvas-relative";function je(e){e.hasAttribute(Ke)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Ke));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Ke,"")),!1)}function Ze({node:e}){const t=be().config.components[e.type],n=e.props.id,o=F(null),r=function(e,t){return Y(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Ce),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(Ce,e),n.setAttribute("data-puck-dnd",e),je(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(()=>{});xe(()=>o.current()),xe(()=>{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?je(e):Ne(e));const s=T(Re),a=Pe(t,n),c=$e(n);if(!t?.render)return null;const d=t.render,u={...
|
|
4
|
-
/* @__PURE__ */U("div",{ref:i,[Ce]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */U(d,{...u,puck:p,editMode:!0})})}function Te({metadata:e}){const t=ke(e=>e.config),n=ke(e=>e.appState.data.root).props??{},o=t.root?.render,r=Pe(t.root,
|
|
3
|
+
return U(Ve,{parentId:e,slot:t,...n})},[e])}var Be=["top","bottom","zIndex"];function Le(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Ne(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));Le(e,"position",t?"sticky":"relative");for(const n of Be)Le(e,n,t?.[n]??"");return!!t}var Ke="data-es-canvas-relative";function je(e){e.hasAttribute(Ke)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Ke));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Ke,"")),!1)}function Ze({node:e}){const t=be().config.components[e.type],n=e.props.id,o=F(null),r=function(e,t){return Y(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Ce),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(Ce,e),n.setAttribute("data-puck-dnd",e),je(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(()=>{});xe(()=>o.current()),xe(()=>{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?je(e):Ne(e));const s=T(Re),a=Pe(t,n),c=$e(n);if(!t?.render)return null;const d=t.render,u={...K(t),...e.props,...a},p={renderDropZone:c,isEditing:!0,dragRef:t.inline?r:null,metadata:{...s,...t.metadata}};return t.inline?/* @__PURE__ */U(d,{...u,puck:p,editMode:!0}):
|
|
4
|
+
/* @__PURE__ */U("div",{ref:i,[Ce]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */U(d,{...u,puck:p,editMode:!0})})}function Te({metadata:e}){const t=ke(e=>e.config),n=ke(e=>e.appState.data.root).props??{},o=t.root?.render,r=Pe(t.root,I),i=$e(I),l=/* @__PURE__ */U(Ve,{parentId:I,slot:B}),s=o?/* @__PURE__ */U(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
|
|
5
5
|
return U(Re.Provider,{value:e??Ee,children:s})}var Fe=j(void 0),He=j(void 0),We=j(void 0);function Ye({element:e}){const t=F(null),n=qe(t,e?()=>e:null,e);/* @__PURE__ */
|
|
6
|
-
return U("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function qe(e,t,n){const[o,r]=W(null),i=F(t);return i.current=t,xe(()=>{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=
|
|
7
|
-
return U(ee,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?
|
|
8
|
-
/* @__PURE__ */U(ne,{className:"es-copy-link es-copy-pop",value:
|
|
9
|
-
return U("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 Qe({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:a,onDocument:
|
|
10
|
-
/* @__PURE__ */U(Oe.Provider,{value:
|
|
6
|
+
return U("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function qe(e,t,n){const[o,r]=W(null),i=F(t);return i.current=t,xe(()=>{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=S(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 Xe({id:e,kind:t,overlay:n}){const o=F(null),r=T(He),i=null!==e&&!0===r?.(e),l=qe(o,e?t=>t.querySelector(`[${Ce}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),s=/* @__PURE__ */U("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}${i?" is-shared":""}`,style:l?{position:"absolute",top:l.top,left:l.left,width:l.width,height:l.height}:{display:"none"}});return n&&e?/* @__PURE__ */U(n,{componentId:e,kind:t,children:s}):s}function Ue(e,t,n){const o=h(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function Ge({s:e,element:t,toolbar:n,label:o,keys:r}){const i=g("copy",m),l=e.pressed(),s=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,h=F(null),[v,y]=W(!1),[w,k]=W(null),S=v||null!==w,C=()=>{e.hold(),y(!1),k({href:e.pressed().href})},I=()=>{y(!1),k(null),e.resume()};X(()=>{r.current={escape:()=>!!S&&(I(),!0),link:()=>!!s.has("link")&&(C(),!0)}}),X(()=>()=>{r.current=null},[r]);const E=F(I);E.current=I,Z(()=>{if(v)return _(e=>{const t=h.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(E.current(),!0)},()=>h.current?.querySelector(".es-copy-colors"))},[v]),Z(()=>{const n=h.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]),X(()=>{const e=h.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?a(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,u=s?b(s,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=s?b(s,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,m.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const k=c({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:d(n)});n.style.top=`${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:u(l.color,f),open:v,onToggle:()=>{k(null),v?I():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
|
|
7
|
+
return U(ee,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?b(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__ */U("div",{ref:h,children:/* @__PURE__ */U(te,{layout:"row",offered:s,pressed:l.marks,onMark:t=>{"link"===t?C():e.press(t)},color:D,linkOpen:null!==w,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__ */G(J,{children:[v&&f?/* @__PURE__ */U(p,{colors:f,current:l.color,words:i.colors??m.colors,onPick:t=>e.color(t)}):null,w?
|
|
8
|
+
/* @__PURE__ */U(ne,{className:"es-copy-link es-copy-pop",value:w.href??"",onApply:t=>{k(null),e.link(t)},onRemove:null!==w.href?()=>{k(null),e.link(null)}:void 0,onCancel:I}):null]})})})})}function Je({element:e}){const t=F(null),n=qe(t,()=>e(),e);/* @__PURE__ */
|
|
9
|
+
return U("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 Qe({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:a,onDocument:c,height:d,title:u,nonce:p,hotkeys:h,frameWrapper:m,overlay:v,children:w,typing:b,passThrough:S}){const C=be(),I=T(Fe),E=S??I,D=T(ye),x=g("canvas",e),M=h??D,[A,O]=W(void 0),R=ke(e=>"node"===e.selection?.kind?e.selection.id:null),[z,V]=W(null),[P,$]=W(null),B=T(We),[L,N]=W(null),K=F(null),[,j]=W(0),H=F(b);H.current=b;const Y=F(null),q=F(null),X=ke(e=>e.appState.data);Z(()=>{const e=q.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=R&&!L&&H.current?.atSelection?.()?R:null;e.dispatchEvent(new t(y,{detail:{id:n}}))},[R,L,X]);const J=e=>{const t=q.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(k,{detail:{typing:e}}))},Q=(e,t)=>{K.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=C.group(),r=e.element,i=f({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Ue(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>j(e=>e+1),onEscape:()=>Y.current?.escape()??!1,onLinkKey:()=>Y.current?.link()??!1,end:e=>{o.close(),K.current?.element===r&&(K.current=null),N(null),J(!1),H.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${Ce}]`)?.getAttribute(Ce);return l&&C.select(l),K.current={s:i,element:r,target:e},N(()=>r),V(null),J(!0),H.current?.onChange?.({typing:!0,element:n}),!0};Z(()=>()=>K.current?.s.stop("stop"),[]);const _=e=>{const t=K.current?.element();return Boolean(t&&t.contains(e))},ee=e=>{const t=e.closest?.(`[${Ce}]`)?.getAttribute(Ce);if(!t)return;const n=C.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=B?.partAt(e,t)??null;if(r){const e=l(n.appState.data,C.config,t,r.id,o,B?.selected()??null,E);if(e)return{node:e.node,part:e.part?r:null}}return{node:s(n.appState.data,C.config,t,o,E)??t,part:null}},te=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(K.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=H.current?.atSelection?.();n&&Q(n,null)&&e.preventDefault()},ne=/* @__PURE__ */G("div",{ref:q,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),K.current){if(_(t))return;K.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=ee(t);if(void 0!==o)return C.select(o.node),void(B&&(o.part?.id??null)!==B.selected()&&B.select(o.part?.id??null));t.hasAttribute?.(Ie)||(C.select(null),B?.selected()&&B.select(null))},onDoubleClick:e=>{const t=H.current;if(!t||_(e.target))return;const n=t.at(e.target);n&&Q(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>te(e),onMouseOver:e=>{if(K.current)return;const t=ee(e.target),n=t?.part&&t.part.id!==B?.selected()?t.part.element:null,o=t&&!t.part?t.node:null;o!==z&&V(o),n!==P&&$(n)},onMouseLeave:()=>{V(null),$(null)},children:[
|
|
10
|
+
/* @__PURE__ */U(Oe.Provider,{value:z,children:/* @__PURE__ */U(Te,{metadata:r})}),
|
|
11
11
|
/* @__PURE__ */G("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
12
|
-
/* @__PURE__ */U(Xe,{id
|
|
13
|
-
/* @__PURE__ */U(Xe,{id
|
|
14
|
-
return G("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing"
|
|
12
|
+
/* @__PURE__ */U(Xe,{id:!L&&z&&z!==R?z:null,kind:"hover",overlay:v}),B?/* @__PURE__ */U(Ye,{element:L?null:P}):null,
|
|
13
|
+
/* @__PURE__ */U(Xe,{id:L?null:R,kind:"selected",overlay:v}),L?/* @__PURE__ */U(Je,{element:L}):null]}),w]}),oe=m?/* @__PURE__ */U(m,{document:A,children:ne}):ne;Z(()=>{if(A&&M)return ge(A,C)},[A,M,C]),Z(()=>{if(!A)return;const e=e=>{if("Enter"===e.key)return void te(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=C.getState();if("node"!==n.selection?.kind)return;if(B?.selected())return void B.select(null);const o=i(n.appState.data,C.config,n.selection);"node"===o?.kind&&C.select(o.id)};return A.addEventListener("keydown",e),()=>A.removeEventListener("keydown",e)},[A,C,B]);/* @__PURE__ */
|
|
14
|
+
return G("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":L?"":void 0,children:[L&&K.current?.target.toolbar?/* @__PURE__ */U(Ge,{s:K.current.s,element:K.current.element,toolbar:K.current.target.toolbar,label:x.textTools,keys:Y}):null,t?/* @__PURE__ */U(Ae,{mirrorStyles:a,onDocument:e=>{O(e??void 0),c?.(e)},height:d,title:u,nonce:p,children:oe}):/* @__PURE__ */U("div",{id:"preview-frame","data-puck-entry":"",children:oe})]})}function _e(e={}){const t=be(),n=ke(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function et(){const e=be(),n=ke(e=>e.config),o=e.resolveCache,r=ke(e=>e.selectedItem),i=ke(e=>e.appState.data.root),l=r?r.props.id:"root",s=i.props??{},a=Y(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?C(d.appState.data,n,l):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:l,node:a,block:c,parent:f,appState:d.appState}),m=ke(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),g=q(t=>{(async()=>{const r=e.getState();if("root"!==l){const i=r.getItemById(l),s=r.getSelectorForId(l);if(!i||!s)return;const a={...i,props:{...i.props,...t}},{node:c}=await $(a,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(l);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const i=r.appState.data.root.props??{},{node:s}=await $({type:"root",props:{...i,...t}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,n,o,l]),v=q((e,t)=>g({[e]:t}),[g]);return{id:l,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{Ae as CanvasFrame,We as CanvasPartsContext,Fe as CanvasPassThroughContext,He as CanvasSharedContext,pe as DEFAULT_UI,Qe as EaselCanvas,we as EaselProvider,Te as EditDocument,ge as bindUndoKeys,me as createEasel,Se as createUseEasel,oe as recordsByDefault,ce as reduce,le as uiView,ke as useEasel,be as useEaselApi,_e as useEaselNodeOps,et as useSelectedFields,se as validSelection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-OGBYHQE6.js";import{useEaselHost as e}from"./chunk-U3JP4VGF.js";import{createEasel as r,EaselProvider as o}from"./chunk-KOVJODTY.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
|
|
2
2
|
return a(o,{easel:d,hotkeys:h.ownsDocument,children:/* @__PURE__ */a(t,{parts:f,children:u})})}export{i as ScreenStoreProvider};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-CNKVVHDA.js";import{ScreenStoreProvider as e}from"./chunk-KWE5U6CE.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-M62P4IQK.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-23DYNW6S.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(e),k=r(n);function N({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
2
|
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
3
|
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
4
|
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
|
-
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function
|
|
7
|
-
/* @__PURE__ */u(
|
|
5
|
+
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
+
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function H({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),H=t(()=>s(!g),[g]),A=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:A.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
+
/* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:H,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:A.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:A.waitingForAuthorization})}export{H as DocumentScreen,j as ScreenMount};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{usePickFollowsSelection as n}from"./chunk-LNHT2KPX.js";import{slotFieldsOf as e}from"./chunk-PLVEGYK6.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-KOVJODTY.js";import{Inspector as i}from"./chunk-VULUDKA3.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(n,t,r){const i=n.slotsOf?.(r);return i||e(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h=()=>k,v=()=>"",g=()=>null,y=()=>{},b={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},L={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},j={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},w={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function D(){/* @__PURE__ */
|
|
2
|
+
return s(t,{height:"fill"})}function P(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
|
|
3
|
+
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var S=o({});function N({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return s(S.Provider,{value:n,children:e})}function C(){return u(S)}function G(){return(C().useOwnerName??v)()}function K(){return(C().useDocumentLabel??g)()}function T(n,e,t,r){return(C().useBridges??h)(n,e,t,r)}function x(n){return(C().useStandaloneBridges??h)(n)}function B(n,e){(C().useDocumentPass??y)(n,e)}function I(){return C().blockRules??b}function V(){return C().blockLook??O}function A(){return C().devices??L}function F(){return C().leftView??j}function H(){return C().pinned??w}function R(){return C().saveSwitch??!0}function U(e){n(!0===C().pickFollowsSelection,e)}function Y(){return C().storageNamespace||void 0}function E(){return C().styleClipboard??null}function J(){return C().nodeKeys??!0}function X(){return C().notify??null}function Z(){return C().Canvas??D}function q(){return C().CanvasHead??null}function z(){return C().canvasDrag??null}var M=o(null);function Q({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return s(M.Provider,{value:n,children:e})}function W(){return u(M)}function $(){return C().Inspector??P}export{c as SELECTION_MODE,Q as ScreenCanvasTargetProvider,N as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,V as useScreenBlockLook,I as useScreenBlockRules,T as useScreenBridges,z as useScreenCanvasDrag,Z as useScreenCanvasFrame,q as useScreenCanvasHead,W as useScreenCanvasTarget,A as useScreenDevices,K as useScreenDocumentLabel,B as useScreenDocumentPass,$ as useScreenInspectorPanel,F as useScreenLeftView,J as useScreenNodeKeys,X as useScreenNotify,G as useScreenOwnerName,C as useScreenParts,U as useScreenPickFollowsSelection,H as useScreenPinned,R as useScreenSaveSwitch,Y as useScreenStorageNamespace,E as useScreenStyleClipboard,x as useStandaloneScreenBridges};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_NODE_MENU_WORDS as e}from"./chunk-WK3AFPXY.js";import{TrashIcon as n,EyeIcon as o,EyeOffIcon as t,RenameIcon as i,PasteIcon as c,CopyIcon as l,MoveDownIcon as s,MoveUpIcon as p,DuplicateIcon as a,AddIcon as r,LayersIcon as u}from"efficient-shell/icons/efficient";import{jsx as h}from"react/jsx-runtime";function d(){let e=null;const n=/* @__PURE__ */new Set;return{get:()=>e,set(o){e=o;for(const e of[...n])e()},subscribe:e=>(n.add(e),()=>n.delete(e))}}var m={layer:{icon:/* @__PURE__ */h(u,{})},addInside:{icon:/* @__PURE__ */h(r,{})},duplicate:{icon:/* @__PURE__ */h(a,{})},moveUp:{icon:/* @__PURE__ */h(p,{})},moveDown:{icon:/* @__PURE__ */h(s,{})},copy:{icon:/* @__PURE__ */h(l,{}),shortcut:"⌘C"},cut:{icon:/* @__PURE__ */h(l,{}),shortcut:"⌘X"},paste:{icon:/* @__PURE__ */h(c,{}),shortcut:"⌘V"},rename:{icon:/* @__PURE__ */h(i,{})},hide:{icon:/* @__PURE__ */h(t,{})},show:{icon:/* @__PURE__ */h(o,{})},upLevel:{},delete:{icon:/* @__PURE__ */h(n,{}),danger:!0}};function v(n){const{actions:o,rows:t={},extras:i={},words:c=e}=n,l=e=>({...m[e],label:c[e],...t[e]}),s=(e,n,o)=>{const t=l(e),i={label:o??t.label??e,onClick:n};return t.icon&&(i.icon=t.icon),t.shortcut&&(i.shortcut=t.shortcut),t.danger&&(i.danger=!0),i},p=(e,n)=>n?s(e,n):{...s(e,()=>{}),disabled:!0},a=()=>{const e=l("layer"),o={label:e.label??c.layer,onClick:()=>{},children:n.layer.items};return e.icon&&(o.icon=e.icon),o},r=[],u=[],h=[],d=[],v=!!n.layer&&n.layer.items.length>1;if(v&&"pick"===(n.layer.group??"pick")&&r.push(a()),o.addInside&&u.push(s("addInside",o.addInside)),o.duplicate&&u.push(s("duplicate",o.duplicate)),void 0!==o.moveUp&&u.push(p("moveUp",o.moveUp)),void 0!==o.moveDown&&u.push(p("moveDown",o.moveDown)),o.copy&&u.push(s("copy",o.copy)),o.cut&&u.push(s("cut",o.cut)),o.paste){const e=l("paste").label??c.paste;u.push(s("paste",o.paste.run,c.pasteNamed({paste:e,label:o.paste.label})))}o.rename&&h.push(s("rename",o.rename)),o.hide&&h.push(o.hide.hidden?s("show",o.hide.run):s("hide",o.hide.run)),v&&"change"===n.layer.group&&h.push(a()),o.upLevel&&h.push(s("upLevel",o.upLevel)),o.delete&&d.push(s("delete",o.delete)),r.push(...i.pick??[]),u.push(...i.make??[]),h.push(...i.change??[]),d.push(...i.remove??[]);const b=[r,u,n.style??[],h,d].filter(e=>e.length>0),f=r.length+u.length+h.length+d.length===0,g=[{label:n.title,header:!0,onClick:()=>{}}];return f&&n.pinnedLine&&g.push({label:n.pinnedLine,header:!0,onClick:()=>{}}),b.forEach((e,o)=>{(o>0||f&&n.pinnedLine)&&g.push({label:"—",onClick:()=>{}}),g.push(...e)}),g}export{d as createNodeClipboard,v as nodeMenuItems};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import{DEFAULT_FIELDS_WORDS as e}from"./chunk-WRFD4EXD.js";import{useWords as l}from"./chunk-MFIRYGHW.js";import{SearchableSelect as a,Select as n}from"efficient-shell/ui";import{jsx as s,jsxs as i}from"react/jsx-runtime";function r(e,l){return e.find(e=>Object.is(e.value,l))}var o=e=>String(e);function t(r){const{id:t,options:u,placeholder:d,readOnly:c=!1,ariaLabel:v,ariaLabelledBy:h,searchable:m=!1,searchPlaceholder:p,groupCount:f=!1,renderOption:b}=r,g=l("fields",e),O=h?{"aria-labelledby":h}:v?{"aria-label":v}:{},j=u.some(e=>void 0!==e.thumb),x=j||void 0!==b||u.some(e=>void 0!==e.meta),N=e=>""===e?void 0:u[Number(e)],y=(e,l)=>{const a=N(e.value);return a?/* @__PURE__ */i("span",{className:"es-fsel-row",children:[j?/* @__PURE__ */s("span",{className:"es-fsel-thumb","aria-hidden":"true",children:a.thumb?/* @__PURE__ */s("img",{src:a.thumb,alt:"",loading:"lazy"}):null}):null,
|
|
2
2
|
/* @__PURE__ */s("span",{className:"es-fsel-label",children:b?b(a,{active:l.active??!1,chosen:l.selected}):a.label}),void 0===a.meta||m?null:/* @__PURE__ */s("span",{className:"es-fsel-meta","aria-hidden":"true",children:a.meta})]}):e.label},C=[];let T=null;if(u.forEach((e,l)=>{const a={value:o(l),label:e.label,...e.disabled?{disabled:!0}:{},...m&&e.meta?{sublabel:e.meta}:{},...!m&&e.description?{description:e.description}:{}};void 0===e.group?(T=null,C.push(a)):T&&T.label===e.group?T.options.push(a):(T={label:e.group,options:[a]},C.push(T))}),f)for(const e of C)"options"in e&&(e.label=`${e.label} ${e.options.length}`);const V=e=>e.flatMap(e=>{const l=N(e.value);return l?[l]:[]});if(m){const l={id:t,options:C,placeholder:p??d??g.search??e.search,disabled:c,renderOption:x?y:void 0,...O};if(!0===r.multiple){const e=Array.isArray(r.value)?r.value:[],n=r.onChange;/* @__PURE__ */
|
|
3
3
|
return s("div",{className:"es-fsel",children:/* @__PURE__ */s(a,{...l,multiple:!0,value:u.flatMap((l,a)=>e.some(e=>Object.is(e,l.value))?[o(a)]:[]),onChange:e=>n(u.filter((l,a)=>e.includes(o(a))).map(e=>e.value))})})}const n=u.findIndex(e=>Object.is(e.value,r.value)),i=r.onChange;/* @__PURE__ */
|
|
4
|
-
return s("div",{className:"es-fsel",children:/* @__PURE__ */s(a,{...l,value:n>=0?o(n):"",clearable:!1,onChange:e=>{const l=N(e);l&&!Object.is(l.value,r.value)&&i(l.value)}})})}const A={id:t,size:"
|
|
4
|
+
return s("div",{className:"es-fsel",children:/* @__PURE__ */s(a,{...l,value:n>=0?o(n):"",clearable:!1,onChange:e=>{const l=N(e);l&&!Object.is(l.value,r.value)&&i(l.value)}})})}const A={id:t,size:"md",className:"es-fsel-button",options:C,placeholder:d??g.choose,readOnly:c,renderOption:x?y:void 0,...O};if(!0===r.multiple){const e=Array.isArray(r.value)?r.value:[],l=l=>e.some(e=>Object.is(e,l.value)),a=u.flatMap((e,a)=>l(e)?[o(a)]:[]),i=r.onChange;/* @__PURE__ */
|
|
5
5
|
return s("div",{className:"es-fsel",children:/* @__PURE__ */s(n,{...A,multiple:!0,value:a,renderValue:r.renderValue?e=>r.renderValue(V(e)):void 0,valueText:r.valueText?e=>r.valueText(V(e)):void 0,onChange:e=>i(u.filter((l,a)=>e.includes(o(a))).map(e=>e.value))})})}const M=u.findIndex(e=>Object.is(e.value,r.value)),I=r.onChange;/* @__PURE__ */
|
|
6
6
|
return s("div",{className:"es-fsel",children:/* @__PURE__ */s(n,{...A,value:M>=0?o(M):"",renderValue:r.renderValue?e=>r.renderValue(V(e)[0]):void 0,valueText:r.valueText?e=>r.valueText(V(e)[0]):void 0,footer:r.footer?.length?[...r.footer]:void 0,changed:r.changed,onChange:e=>{const l=N(e);l&&!Object.is(l.value,r.value)&&I(l.value)}})})}export{t as FieldSelect,r as optionFor};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-PA3PNTVV.js";import{blockTypesIn as o}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as l}from"./chunk-BVN33R76.js";import{sharedSectionsOf as r}from"./chunk-43AEUUNQ.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SINAM2IT.js";import{blockRuns as c}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as a,useScreenBlockRules as d,useScreenPinned as p}from"./chunk-OGBYHQE6.js";import{useEaselSession as m}from"./chunk-O7Q4DDJT.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-23DYNW6S.js";import{useEasel as u}from"./chunk-KOVJODTY.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-ZO3UUK45.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-KAML3KQH.js";import{useState as b,useEffect as v,useMemo as j,useRef as w}from"react";import{SharedIcon as C,AddIcon as O}from"efficient-shell/icons/efficient";import{ContextMenu as T,toast as $,Dialog as x,Button as A}from"efficient-shell/ui";import{jsx as D,jsxs as E,Fragment as I}from"react/jsx-runtime";function M({name:e,pages:t,onDelete:n,onCancel:o}){const l=h("screen",f).shared,[r,i]=b(!1),s=w(null);/* @__PURE__ */
|
|
2
|
+
return D(x,{open:!0,role:"alertdialog",size:"sm",title:l.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */E(I,{children:[
|
|
3
|
+
/* @__PURE__ */D(A,{ref:s,variant:"secondary",onClick:o,children:l.cancel}),
|
|
4
|
+
/* @__PURE__ */D(A,{variant:"danger",loading:r,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:l.deleteShared})]}),children:l.deleteMessage({count:t})})}var N=e=>`section:${e}`,B=e=>`block:${e}`,F=e=>`template:${e}`,S=e=>`shared:${e}`;function H({at:w,placeBlocks:x,canTake:A,onPick:H,itemFor:K,session:L,siteWide:Q,onClose:U,onHide:V,readOnly:Y}){const z=u(e=>e.config),P=a(),{labelAtLevel:W,categoryLabel:Z,firstSection:R,Icon:G,Thumbnail:J}=P,{blockIsOffered:_,canAddTo:q}=d(),X=h("screen",f).add,ee=h("drag",g).add,te=m(),[ne,oe]=b([]);v(()=>{let e=!1;const t=e=>_(e,te);return l(te).list().then(n=>{if(e)return;const l=z.components;oe(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[z,te]);const le=p().shared,re=h("screen",f).shared,[ie,se]=b([]),[ce,ae]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>_(e,te);return r(te).list().then(n=>{if(e)return;const l=z.components;se(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[z,te,ce]);const[de,pe]=b(null),[me,fe]=b(null),ue=j(()=>e(z,P),[z]),ye=e=>W(e,"section",z.components[e]?.label??e),he=e=>({type:N(e.type),label:e.name,cover:/* @__PURE__ */D(J,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:X.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ke=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=ne.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=ie.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}return null},ge=e=>/* @__PURE__ */D("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */D(G,{type:e,size:26})}),be=j(()=>{const e=t(ue,R),o=/* @__PURE__ */new Map,l=e=>{e.retired||o.has(e.type)||!_(e.type,te)||o.set(e.type,e)};for(const t of e?[e]:ue){const e=q(t.type)?.choices??[];e.forEach(l),e.forEach(e=>q(e.type,1)?.choices?.forEach(l))}x?.forEach(l);const r=new Set(ue.map(e=>e.type)),i=[...o.values()].filter(e=>!r.has(e.type)),s=e=>({type:B(e.type),label:e.label,cover:ge(e.type),title:X.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>o.has(e.type)?{...he(e),cover:ge(e.type)}:he(e),d=[];ie.length>0&&d.push({key:"shared",title:re.group,tiles:ie.map(e=>({type:S(e.id),label:e.title,cover:/* @__PURE__ */D(J,{type:e.node.type}),mark:/* @__PURE__ */D(C,{size:12}),title:re.onPages({count:e.used_on.length}),keywords:[ye(e.node.type),e.node.type]}))}),ne.length>0&&d.push({key:"templates",title:X.templates,tiles:ne.map(e=>({type:F(e.id),label:e.name,cover:/* @__PURE__ */D(J,{type:e.node.type}),keywords:[ye(e.node.type),e.node.type]}))});const p=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(z.categories??{})){const o=ue.filter(e=>e.cat===t);if(0===o.length)continue;const l=e&&o.some(t=>t.type===e.type)?e:null,r=(l?[l,...o.filter(e=>e.type!==l.type)]:o).map(a);l&&!m&&(r.splice(1,0,...p.map(s)),m=!0),d.push({key:`category:${t}`,title:n(z,t,Z),tiles:r})}const f=d.find(e=>e.key?.startsWith("category:"));if(!m&&f&&p.length>0&&(f.tiles=[...f.tiles,...p.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{d.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!A)return d;const u=d.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ke(e.type),n=t?A(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[ne,ie,re,ue,z,X,A,x,te]);/* @__PURE__ */
|
|
5
|
+
return E(I,{children:[
|
|
6
|
+
/* @__PURE__ */D(i,{icon:/* @__PURE__ */D(O,{size:15}),title:X.title,context:X.contextAll,actions:/* @__PURE__ */D(s,{label:X.done,description:X.doneDescription,onClick:U}),onHide:V}),
|
|
7
|
+
/* @__PURE__ */E("div",{className:"sf-addside sf-scroll",children:[
|
|
8
|
+
/* @__PURE__ */D(k,{groups:be,session:L,itemFor:e=>K(ke(e)??{kind:"section",type:e}),onInsert:H?e=>{const t=ke(e);t&&H(t)}:void 0,onTileMenu:(e,t)=>{const n=ke(e);return"shared"===n?.kind&&!Y&&(pe({section:n.section,...t}),!0)},at:w,hint:X.hint,searchLabel:X.search,readOnly:Y,words:ee}),Q??null]}),de?/* @__PURE__ */D(T,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>pe(null),"aria-label":de.section.title,items:y([{label:re.deleteShared,danger:!0,onClick:()=>{fe(de.section),pe(null)}}])}):null,me?/* @__PURE__ */D(M,{name:me.title,pages:me.used_on.length,onDelete:()=>(async e=>{try{await r(te).remove(e.id)}catch{return void $.error(re.deleteFailed)}fe(null),le?.removed?.(e),se(t=>t.filter(t=>t.id!==e.id)),ae(e=>e+1)})(me),onCancel:()=>fe(null)}):null]})}export{H as AddSidePanel,B as blockKey,N as sectionKey,S as sharedKey,F as templateKey};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{TreeSeam as t}from"./chunk-A6Z4SD3I.js";import{DEFAULT_TREE_WORDS as l}from"./chunk-K56YDHYQ.js";import{easelMenuEntries as a}from"./chunk-FIVU2COQ.js";import{SETTINGS_BUCKETS as r,SettingsGroup as o}from"./chunk-RC25EGHD.js";import{DEFAULT_PANEL_WORDS as i}from"./chunk-KFV7N2DJ.js";import{FieldNumber as s}from"./chunk-ZOBSIXRD.js";import{FieldSelect as c}from"./chunk-QAJAEWCZ.js";import{DEFAULT_FIELDS_WORDS as d}from"./chunk-WRFD4EXD.js";import{SettingsField as u,SettingsSegmented as m}from"./chunk-36LVP5WD.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{useTreeDrag as p,gapToMoveIndex as f}from"./chunk-67GNT6PF.js";import{withTip as b}from"./chunk-P2VEMZH5.js";import{Textarea as g,Input as v,SortableList as y,ListRow as k,ContextMenu as x,tabPanelId as w,Tabs as C,tabButtonId as N}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as O,useState as D,useLayoutEffect as j,useId as $}from"react";import{jsx as S,jsxs as I}from"react/jsx-runtime";import{ChevronIcon as P,LockIcon as F,MoveUpIcon as L,MoveDownIcon as E,DuplicateIcon as R,TrashIcon as A}from"efficient-shell/icons/efficient";function M({id:e,value:n,onChange:t,placeholder:l,multiline:a=!1,rows:r=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return a?/* @__PURE__ */S(g,{id:e,size:"sm",className:"es-fin",value:c,rows:r,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */S(v,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function T(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function W(e,n,t){const l=e.slice(),[a]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,a),l}function z(e,n){return e.filter((e,t)=>t!==n)}function H(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var B='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',V={parentId:"list",slot:"items"};function K({label:e,icon:n,noun:r,items:o,onChange:i,newItem:s,summary:c,itemName:u,thumb:m,min:g=0,max:v,readOnly:w=!1,open:C,onOpen:N,renderItem:$,renderRow:M,canRemove:K,lockedReason:Z,fixed:J=!1,removeOnRow:Q=!0,canDuplicate:X,above:Y,head:G=!0}){const q=h("fields",d).list,U=h("tree",l),_=r??q.item,ee=!w&&!J&&("number"!=typeof v||o.length<v),ne=o.length<=g,te=e=>!!K&&!K(o[e],e),le=e=>!w&&!J&&Q&&!ne&&!te(e),ae=e=>ee&&(!X||X(o[e],e)),re=(e,n)=>u?u(e,n):q.itemName({noun:_,n:n+1}),oe=O([]),ie=O(null),[se,ce]=D(null),de=O(null),[ue,me]=D(null),[he,pe]=D("");j(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(B)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=o.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(B)].indexOf(l),a=l;ie.current={index:n,nth:e,start:"number"==typeof a.selectionStart?a.selectionStart:null,end:"number"==typeof a.selectionEnd?a.selectionEnd:null}}i(W(o,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(C,e,n);a!==C&&N(a),pe(q.moved({n:n+1,total:o.length}))},be=e=>{ee&&(i(T(o,e,s())),M?(ie.current={index:e,nth:0,start:null,end:null},null!==C&&C>=e&&N(C+1)):N(e))},ge=e=>{le(e)&&(i(z(o,e)),C===e?N(null):null!==C&&C>e&&N(C-1))},ve=p({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===V.parentId&&n.slot===V.slot,onDrop:(e,n)=>{const t=f({...V,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<o.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:q.moveUp,icon:/* @__PURE__ */S(L,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<o.length-1&&n.push({label:q.moveDown,icon:/* @__PURE__ */S(E,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),ae(e)&&n.push({label:q.duplicate,icon:/* @__PURE__ */S(R,{size:14}),onClick:()=>(e=>{ae(e)&&(i(T(o,e+1,H(o[e]))),null!==C&&C>e&&N(C+1))})(e)}),le(e)&&n.push({label:q.delete,icon:/* @__PURE__ */S(A,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=o.slice();t[e]=n,i(t)};/* @__PURE__ */
|
|
2
|
+
return I("div",{className:"es-list",children:[G?/* @__PURE__ */I("div",{className:"es-list-head",children:[
|
|
3
|
+
/* @__PURE__ */I("span",{className:"es-list-label",children:[n?/* @__PURE__ */S("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
|
|
4
|
+
/* @__PURE__ */S("span",{className:"es-list-count",children:o.length})]}):null,Y?/* @__PURE__ */S("div",{className:"es-list-above",children:Y}):null,o.length?/* @__PURE__ */I(y,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[o.map((e,n)=>{const l=ve.row({item:n,place:{...V,index:n}}),a=l.draggable&&se!==n,r=!M&&C===n,o=!w&&!J&&Q&&te(n),i=["es-list-row",M?"is-inline":"is-item",r?"is-open":"",a?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */S(t,{...ve.seam({place:{...V,index:n}}),onAdd:ee?()=>be(n):void 0,label:q.addHere({noun:_})},`seam-${n}`):null,
|
|
5
|
+
/* @__PURE__ */S(k,{className:i,flat:!!M,active:r,draggable:l.draggable,dragHint:U.dragHint,dragging:l.dragging,drop:"before"===l.drop||"after"===l.drop?l.drop:void 0,onMove:l.draggable?e=>fe(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{oe.current[n]=e},rowProps:{...l.rowProps,draggable:a||void 0,onPointerDown:e=>{const t=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),a=!!t&&t===t.ownerDocument.activeElement;e.currentTarget.draggable=l.draggable&&!a,de.current=t&&!a?t:null,ce(a?n:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),l.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const a=e.currentTarget.getBoundingClientRect();return void ke(n,a.left+24,a.bottom,e.currentTarget)}l.rowProps.onKeyDown?.(e)}},actions:w||J||!Q?void 0:o?b(Z?Z(e,n):q.locked,/* @__PURE__ */S("span",{className:"es-list-lock",role:"img","aria-label":Z?Z(e,n):q.locked,children:/* @__PURE__ */S(F,{size:13})})):b(q.deleteItem({noun:_}),/* @__PURE__ */S("button",{type:"button",className:"es-list-x","aria-label":q.deleteItem({noun:_}),disabled:!le(n),onClick:()=>ge(n),children:"×"})),below:r?/* @__PURE__ */S("div",{className:"es-list-item",children:$(e,n,xe(n))}):void 0,children:M?/* @__PURE__ */S("div",{className:"es-list-row-main",children:M(e,n,xe(n))}):/* @__PURE__ */I("button",{type:"button",className:"es-list-open","aria-expanded":r,onClick:()=>N(r?null:n),children:[m?/* @__PURE__ */S("span",{className:"es-list-thumb","aria-hidden":"true",children:m(e,n)}):null,
|
|
6
|
+
/* @__PURE__ */S("span",{className:"es-list-row-name",children:re(e,n)}),/* @__PURE__ */S("span",c?{className:"es-list-row-summary",children:c(e,n)}:{className:"es-list-row-summary"}),
|
|
7
|
+
/* @__PURE__ */S(P,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},n)]}),
|
|
8
|
+
/* @__PURE__ */S(t,{...ve.seam({place:{...V,index:o.length}})})]}):null,w||J?null:/* @__PURE__ */S("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(o.length),children:q.add({noun:_})}),
|
|
9
|
+
/* @__PURE__ */S("span",{className:"es-list-said","aria-live":"polite",children:he}),ue&&ue.index<o.length?
|
|
10
|
+
/* @__PURE__ */S(x,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),items:a(ye(ue.index))}):null]})}var Z=e=>e<6?e+1:6,J=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function Q({field:e,name:t,id:l,value:a,onChange:r,readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=D(!0),p=a&&"object"==typeof a?a:{};/* @__PURE__ */
|
|
11
|
+
return S(o,{id:`${l}-group`,title:J(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */S(Y,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>r({...p,[e]:n}),readOnly:i,context:s,showWhenContext:c,renderers:d,headingLevel:Z(u)},e))})}function X({field:e,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=D(null),f=u?d??null:h,b=u??p,g=Array.isArray(a)?a:[],v=e.getItemSummary;/* @__PURE__ */
|
|
12
|
+
return S(K,{label:J(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:r,newItem:()=>H({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(a,r,d)=>Object.entries(n(e.arrayFields,{values:a,context:s})).map(([e,n])=>/* @__PURE__ */S(Y,{field:n,name:`${t}[${r}].${e}`,id:`${l}-${r}-${e}`,value:a?.[e],onChange:n=>d({...a,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function Y(e){const{field:n,name:t,id:l,value:a,onChange:r,readOnly:o,context:i,renderers:d}=e;if(!n||n.marker||!1===n.visible)return null;const h=d?.[n.type];if(h)return h({field:n,name:t,id:l,value:a,onChange:r,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:a,onChange:r,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
|
|
13
|
+
return S(u,{label:J(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(M,{id:l,value:"string"==typeof a?a:null==a?"":String(a),onChange:r,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
|
|
14
|
+
return S(u,{label:J(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(s,{id:l,value:"number"==typeof a?a:void 0,onChange:r,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
|
|
15
|
+
return S(u,{label:J(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(c,{id:l,value:a,options:n.options,onChange:r,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
|
|
16
|
+
return S(u,{label:J(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */S(m,{ariaLabel:J(n,t),value:a,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||r(e)}})});case"object":/* @__PURE__ */
|
|
17
|
+
return S(Q,{...e,field:n});case"array":/* @__PURE__ */
|
|
18
|
+
return S(X,{...e,field:n});case"slot":return null}}var G=e=>r.includes(e);function q(n,t){let l,a=r[0];const o=[],i=/* @__PURE__ */new Set;for(const[r,s]of Object.entries(n))s&&(G(s.bucket)&&((s.marker||s.bucket!==a)&&(l=void 0),a=s.bucket),s.marker&&"string"==typeof s.fold?l={key:r,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||(o.push(l?{name:r,field:s,bucket:a,fold:l}:{name:r,field:s,bucket:a}),"slot"!==s.type&&i.add(a)));return{rows:o,buckets:r.filter(e=>i.has(e))}}function U(e){return new Map(q(e).rows.map(e=>[e.name,e.bucket]))}function _(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ee({fields:e,values:n,onChange:t,readOnly:l=!1,context:a,showWhenContext:r,tab:s,onTab:c,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:p,ariaLabel:f,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const O=h("panel",i),j=$(),P=p??`es-insp${j.replace(/:/g,"")}`,F=q(e,{values:n,context:r}),[L,E]=D(void 0),R=s??L,A=R&&F.buckets.includes(R)?R:F.buckets[0],[M,T]=D(null),W=M&&M.panel===P&&F.rows.some(e=>e.name===M.name)?M:null,z=d&&F.buckets.length>1,H=z&&A?w(P,A):`${P}-rows`,[B,V]=D(()=>/* @__PURE__ */new Set),K=y??B,J=(e,n)=>{/* @__PURE__ */return S(o,{title:e.title,open:!K.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&V(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${P}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},Q=e=>z&&e!==A,X=({name:e,field:o,bucket:i,fold:s})=>/* @__PURE__ */S("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!Q(i)||void 0,children:/* @__PURE__ */S(Y,{field:o,name:e,id:`${P}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:a,showWhenContext:r,renderers:m,openItem:W&&W.name===e?W.index:null,onOpenItem:n=>T(null===n?null:{panel:P,name:e,index:n}),headingLevel:s?Z(x):x})},e);/* @__PURE__ */
|
|
19
|
+
return I("div",{className:"es-insp",children:[z?/* @__PURE__ */S("div",{className:"es-insp-tabs",children:/* @__PURE__ */S(C,{variant:"underline",block:!0,"aria-label":f??O.settings,idPrefix:P,value:A,onChange:e=>{const n=e;void 0===s&&E(n),c?.(n)},items:F.buckets.map(e=>{const n=O.buckets[e],t=u?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */S("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
|
|
20
|
+
/* @__PURE__ */I("div",{className:"es-insp-rows",id:H,role:z?"tabpanel":void 0,"aria-labelledby":z&&A?N(P,A):void 0,children:[b?v?/* @__PURE__ */S("div",{className:"es-insp-band","data-fold":v.key,children:J(v,b)}):b:null,_(F.rows).map((e,n)=>{if(!e.fold)return e.rows.map(X);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
|
|
21
|
+
return S("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!Q(t)&&!l)||void 0,children:J(e.fold,e.rows.map(X))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{M as FieldText,ee as Inspector,Y as InspectorField,K as ListField,U as bucketsOf,H as copyItem,T as insertAt,J as labelOf,W as moveTo,q as planFields,z as removeAt};
|