efficient-easel 10.2.0 → 10.3.1
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-IZ2QRXSE.js → chunk-535CJ7J4.js} +1 -1
- package/dist/{chunk-TROOTMAD.js → chunk-545BRJIU.js} +1 -1
- package/dist/{chunk-74ZFATLG.js → chunk-BGY4Q2SL.js} +1 -1
- package/dist/{chunk-YMEN4KVE.js → chunk-BJNZKYK7.js} +1 -1
- package/dist/{chunk-ERA3XM2U.js → chunk-BPMLHWWM.js} +1 -1
- package/dist/{chunk-7O6MDCDU.js → chunk-EVY5SXFW.js} +5 -5
- package/dist/chunk-G5MRFCCW.js +5 -0
- package/dist/chunk-MMAC2VER.js +57 -0
- package/dist/{chunk-M32O2WRM.js → chunk-PE6ZY5IW.js} +11 -11
- package/dist/chunk-QDAJKEG3.js +1 -0
- package/dist/{chunk-IL6QCPO6.js → chunk-TJ6NRHYF.js} +1 -1
- package/dist/{chunk-A5OEGP7B.js → chunk-VYHA6EA6.js} +4 -4
- package/dist/copy/index.js +12 -12
- package/dist/easel/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +15 -15
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/text-styles/index.d.ts +35 -1
- package/dist/text-styles/index.js +26 -24
- package/package.json +1 -1
- package/dist/chunk-FJ3ZJJ5Z.js +0 -57
- package/dist/chunk-ICN6COBK.js +0 -5
- package/dist/chunk-OWK7DGWG.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
1
|
+
import{ScreenPartsProvider as t}from"./chunk-EVY5SXFW.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-PE6ZY5IW.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
|
|
2
2
|
return i(n,{easel:h,hotkeys:d.ownsDocument,children:/* @__PURE__ */i(t,{parts:f,children:u})})}export{a as ScreenStoreProvider};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-
|
|
1
|
+
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-EVY5SXFW.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-JTUUIVBZ.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{DropdownMenu as n}from"efficient-shell/ui";import{jsxs as c,Fragment as i,jsx as o}from"react/jsx-runtime";function l({choices:l,onPick:p}){const{Icon:a}=r(),m=t("screen",s),u=e(l).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */c(i,{children:[e.group," ",
|
|
2
2
|
/* @__PURE__ */o("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(a,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
3
3
|
return o(n,{align:"start",triggerClassName:"sf-add-card",items:u,trigger:/* @__PURE__ */c(i,{children:[
|
|
4
4
|
/* @__PURE__ */o("span",{className:"sf-plus sf-plus--sm",children:"+"}),m.addBlockMenu]})})}export{l as AddBlockRow};
|
|
@@ -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-PE6ZY5IW.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useScreenOwnerName as e}from"./chunk-
|
|
1
|
+
import{useScreenOwnerName as e}from"./chunk-EVY5SXFW.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-IE55HNMA.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
|
|
2
2
|
return o(r,{children:[
|
|
3
3
|
/* @__PURE__ */t(i,{context:p,pick:d?{kind:c(d.accept),field:d.title||void 0}:null,onCancel:()=>d&&n(d.requestId,null),onHide:m}),
|
|
4
4
|
/* @__PURE__ */t("div",{className:"sf-media-panel",children:/* @__PURE__ */t(l,{pick:d,onPick:e=>d&&n(d.requestId,e)})})]})}export{l as MediaSidePanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-EVY5SXFW.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-PE6ZY5IW.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,5 +1,5 @@
|
|
|
1
|
-
import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-
|
|
2
|
-
return s(t,{height:"fill"})}function
|
|
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
|
|
4
|
-
return s(
|
|
5
|
-
return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return D().Inspector??
|
|
1
|
+
import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-PE6ZY5IW.js";import{Inspector as i}from"./chunk-26GHWMNN.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(e,t,r){const i=e.slotsOf?.(r);return i||n(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={},v=()=>k,g=()=>"",y=()=>null,b=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},j={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},w={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},L={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},N={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function P(){/* @__PURE__ */
|
|
2
|
+
return s(t,{height:"fill"})}function S(){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 C=o({});function G({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return s(C.Provider,{value:n,children:e})}function D(){return u(C)}function I(){return(D().useOwnerName??g)()}function x(){return(D().useDocumentLabel??y)()}function B(n,e,t,r){return(D().useBridges??v)(n,e,t,r)}function T(n){return(D().useStandaloneBridges??v)(n)}function W(n,e){(D().useDocumentPass??b)(n,e)}function A(){return D().blockRules??O}function F(){return D().blockLook??j}function R(){return D().devices??w}function E(){return D().leftView??L}function H(){return D().pinned??N}function K(){return D().saveSwitch??!0}function V(n){e(!0===D().pickFollowsSelection,n)}function Y(){return D().add??h}function Z(){return D().storageNamespace||void 0}function M(){return D().styleClipboard??null}function Q(){return D().nodeKeys??!0}function q(){return D().notify??null}function z(){return D().Canvas??P}function J(){return D().CanvasHead??null}function U(){return D().canvasDrag??null}var X=o(null);function $({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return D().Inspector??S}export{c as SELECTION_MODE,$ as ScreenCanvasTargetProvider,G as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,Y as useScreenAdd,F as useScreenBlockLook,A as useScreenBlockRules,B as useScreenBridges,U as useScreenCanvasDrag,z as useScreenCanvasFrame,J as useScreenCanvasHead,_ as useScreenCanvasTarget,R as useScreenDevices,x as useScreenDocumentLabel,W as useScreenDocumentPass,nn as useScreenInspectorPanel,E as useScreenLeftView,Q as useScreenNodeKeys,q as useScreenNotify,I as useScreenOwnerName,D as useScreenParts,V as useScreenPickFollowsSelection,H as useScreenPinned,K as useScreenSaveSwitch,Z as useScreenStorageNamespace,M as useScreenStyleClipboard,T as useStandaloneScreenBridges};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{buildPaletteSections as e,pinnedSection as t,paletteWithoutPinned as o,categoryLabel as n}from"./chunk-PA3PNTVV.js";import{blockTypesIn as i}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-PPL7GB7D.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as a}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as p,useScreenBlockRules as m}from"./chunk-EVY5SXFW.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-JTUUIVBZ.js";import{useEasel as f}from"./chunk-PE6ZY5IW.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-FCLW4LEN.js";import{DEFAULT_DRAG_WORDS as y}from"./chunk-O2NLQBFX.js";import{useState as h,useEffect as b,useMemo as j}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as B,jsxs as $,Fragment as L}from"react/jsx-runtime";var O=e=>`section:${e}`,v=e=>`block:${e}`,I=e=>`template:${e}`;function V({blocks:V,blocksOnly:x,at:F,sectionAccepts:N,onAdd:A,itemFor:P,session:W,siteWide:C,onClose:D,onHide:E,readOnly:H}){const T=f(e=>e.config),Y=p(),{labelAtLevel:w,categoryLabel:Q,firstSection:R,Icon:S,Thumbnail:Z}=Y,{blockIsOffered:z}=m(),G=u("screen",d).add,J=u("drag",y).add,U=l(),[X,K]=h([]);b(()=>{let e=!1;const t=e=>z(e,U);return s(U).list().then(o=>{if(e)return;const n=T.components;K(o.filter(e=>e.node?.type&&n[e.node.type]&&i(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[T,U]);const M=j(()=>e(T,Y),[T]),q=e=>({type:O(e.type),label:e.name,cover:/* @__PURE__ */B(Z,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:G.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),_=j(()=>{const e=[];if(V&&V.choices.length>0&&a(V.choices).forEach((t,o)=>{e.push({key:`blocks:${o}`,title:0===o?`${G.inside({name:V.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:v(e.type),label:e.label,icon:/* @__PURE__ */B(S,{type:e.type,size:18}),title:G.tile({name:e.label})}))})}),x)return e;const i=e=>!N||N(e),s=t(M,R);s&&i(s.type)&&e.push({key:"start",title:G.startBlank,tiles:[q(s)]});const r=X.filter(e=>i(e.node.type));r.length>0&&e.push({key:"templates",title:G.templates,tiles:r.map(e=>{return{type:I(e.id),label:e.name,cover:/* @__PURE__ */B(Z,{type:e.node.type}),keywords:[(t=e.node.type,w(t,"section",T.components[t]?.label??t)),e.node.type]};var t})});const c=o(M,R);for(const t of Object.keys(T.categories??{})){const o=c.filter(e=>e.cat===t&&i(e.type));0!==o.length&&e.push({key:`category:${t}`,title:n(T,t,Q),tiles:o.map(q)})}return e},[V,x,X,M,T,G,N]),ee=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=X.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null};/* @__PURE__ */
|
|
2
|
+
return $(L,{children:[
|
|
3
|
+
/* @__PURE__ */B(r,{icon:/* @__PURE__ */B(g,{size:15}),title:G.title,context:x?G.contextBlocks:G.contextAll,actions:/* @__PURE__ */B(c,{label:G.done,description:G.doneDescription,onClick:D}),onHide:E}),
|
|
4
|
+
/* @__PURE__ */$("div",{className:"sf-addside sf-scroll",children:[
|
|
5
|
+
/* @__PURE__ */B(k,{groups:_,session:W,itemFor:e=>P(ee(e)??{kind:"section",type:e}),onInsert:e=>{const t=ee(e);t&&A(t)},at:F,hint:x?G.hintBlocks:G.hint,searchLabel:x?G.searchBlocks:G.searchSections,readOnly:H,words:J}),C&&!x?C:null]})]})}export{V as AddSidePanel,v as blockKey,O as sectionKey,I as templateKey};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-BRDCD4LK.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-BHRC3ASL.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,useEaselSaveKey as m,editorRootFocus as g}from"./chunk-BGY4Q2SL.js";import{SlotChildActionsProvider as y}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as S,DEFAULT_PANEL_W as k,clampPanelWidth as v}from"./chunk-TZIIRGVY.js";import{usePartBridge as b}from"./chunk-QDAJKEG3.js";import{useSectionOps as x}from"./chunk-BPMLHWWM.js";import{useNodeClipboard as w,useNodeContextMenu as z}from"./chunk-D6N77AOS.js";import{PageEditGuardNotices as B}from"./chunk-P4CL4YQI.js";import{ScreenSaveIcon as C,ScreenMainButton as I}from"./chunk-W4U4SHKW.js";import{useBrowserOffline as N}from"./chunk-RKTF5XLP.js";import{useScreenDocument as O}from"./chunk-THZ46DC5.js";import{requestMediaPick as P}from"./chunk-KG7RJWOK.js";import{heldStyle as $,styleShortcut as A}from"./chunk-V7U33NF2.js";import{AddChildRow as T}from"./chunk-5545A3PC.js";import{AddSidePanel as M}from"./chunk-G5MRFCCW.js";import{SidePanelHead as j,PanelShowStrip as L}from"./chunk-PPL7GB7D.js";import{useEaselSession as E}from"./chunk-O7Q4DDJT.js";import{MediaSidePanel as R}from"./chunk-BJNZKYK7.js";import{useScreenSaveSwitch as V,useScreenNodeKeys as F,useScreenPinned as H,useScreenDocumentLabel as W,useScreenCanvasFrame as D,useScreenInspectorPanel as G,useScreenDevices as J,useScreenPickFollowsSelection as U,useScreenLeftView as Y,useScreenAdd as K,SELECTION_MODE as X,sameInspectorMode as Z,useScreenBridges as q,useScreenBlockRules as _,useScreenBlockLook as Q,useScreenStorageNamespace as ee,useScreenNotify as ne,useScreenCanvasHead as te,isSlotMode as oe,useScreenStyleClipboard as re,useScreenDocumentPass as ie,useScreenCanvasDrag as le,ScreenCanvasTargetProvider as se,isPinnedFirst as de,isPinnedLast as ce,screenSlotsOf as ae}from"./chunk-EVY5SXFW.js";import{ROOT_ZONE as pe,blockNodeActions as ue,TREE_MAX_DEPTH as fe,childSlotsOf as he,slotFieldsOf as me,slotChildrenIn as ge,nestsInTree as ye,newNodeId as Se}from"./chunk-PLVEGYK6.js";import{useMediaPanel as ke,usePanelPick as ve,useCancelPanelPick as be}from"./chunk-R6WTQWAC.js";import{useEaselHost as xe,useHostEscape as we}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as ze}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as Be}from"./chunk-JTUUIVBZ.js";import{useEasel as Ce,useEaselApi as Ie,CanvasPassThroughContext as Ne}from"./chunk-PE6ZY5IW.js";import{TreeRow as Oe,Subtree as Pe,LayersTree as $e,TreeGroupLabel as Ae,TreeRowAction as Te,TreeSeam as Me}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Le}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ee,useNodeOps as Re,clickPick as Ve}from"./chunk-ECM5F6JJ.js";import{LayersIcon as Fe,MediaIcon as He}from"./chunk-4VJATVVR.js";import{EaselTopBar as We,TopBarRail as De,TopBarCluster as Ge,EaselIconButton as Je,TopBarDivider as Ue,DeviceSwitch as Ye,InspectorIconButton as Ke,PanelResizeHandle as Xe,MAX_PANEL_W as Ze,MIN_PANEL_W as qe,panelWidthVars as _e}from"./chunk-IE55HNMA.js";import{DEFAULT_NOTICE_WORDS as Qe,DEFAULT_CHROME_WORDS as en}from"./chunk-Z6PVRXVY.js";import{holderOf as nn,nameOrSomeone as tn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as on}from"./chunk-RE4LP46F.js";import{useWords as rn}from"./chunk-MFIRYGHW.js";import{insertSeams as ln,CanvasDragLayer as sn,CanvasInsert as dn}from"./chunk-FCLW4LEN.js";import{DEFAULT_DRAG_WORDS as cn}from"./chunk-O2NLQBFX.js";import{createDragSession as an,useTreeDrag as pn,gapToMoveIndex as un}from"./chunk-67GNT6PF.js";import{useCanvasFrame as fn,LIST_SELECTOR as hn,BLOCK_SELECTOR as mn,useCanvasEvent as gn,nodeIdAt as yn,frameRectToHost as Sn,BLOCK_ATTRIBUTE as kn,drawnBox as vn}from"./chunk-ILXP5VX5.js";import{zoneKey as bn,ROOT_ID as xn,ROOT_SLOT as wn,parseZoneKey as zn,find as Bn,DataError as Cn}from"./chunk-KRXQM65X.js";import{useRef as In,useMemo as Nn,useState as On,useEffect as Pn,useCallback as $n,useLayoutEffect as An,Fragment as Tn}from"react";import{ColoredBadge as Mn,toast as jn,groupColors as Ln}from"efficient-shell/ui";import{UndoIcon as En,RedoIcon as Rn,RefreshIcon as Vn,TrashIcon as Fn,EyeOffIcon as Hn,EyeIcon as Wn,DuplicateIcon as Dn}from"efficient-shell/icons/efficient";import{jsx as Gn,jsxs as Jn,Fragment as Un}from"react/jsx-runtime";var Yn=/* @__PURE__ */new WeakSet;function Kn(e,n,t){const o=Bn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function Xn({canvas:e,tabs:n,onSelect:t}){const o=In(null),[r,i]=On({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return An(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=Sn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),c={};for(const o of n){const n=t.querySelector(`[${kn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?vn(n):null;if(!i||0===i.height){c[o.id]=null;continue}const s=Sn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),a=s.top+s.height;if(a<d.top||s.top>d.top+d.height){c[o.id]=null;continue}const p=o.below?a+4:Math.max(s.top,d.top)+6;c[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(c)},c=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",c,!0),r.addEventListener("resize",c);const a=new r.MutationObserver(c);return a.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",c,!0),r.removeEventListener("resize",c),a.disconnect()}},[e,l]),/* @__PURE__ */Gn("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */Gn("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:/* @__PURE__ */Gn(Mn,{colorClass:Ln("info","solid"),size:"sm",children:e.label})},e.id):null})})}function Zn({expand:e}){/* @__PURE__ */
|
|
2
|
+
return Gn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Jn(Un,e?{children:[
|
|
3
|
+
/* @__PURE__ */Gn("path",{d:"M8 9l4-4 4 4"}),
|
|
4
|
+
/* @__PURE__ */Gn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
|
|
5
|
+
/* @__PURE__ */Gn("path",{d:"M8 4l4 4 4-4"}),
|
|
6
|
+
/* @__PURE__ */Gn("path",{d:"M8 20l4-4 4 4"}),
|
|
7
|
+
/* @__PURE__ */Gn("path",{d:"M5 12h14"})]})})}var qn=`${hn}, ${mn}`;function _n(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 Qn="__rungs";var et="screen:band",nt={duplicate:!0,delete:!0};function tt(){const hn=xe(),{target:Sn,docId:kn,capabilities:vn,currentSlug:Ln,siteId:tt,onPublish:ot,saveState:rt,saveConflict:it,retrySave:lt,toggleAutoSave:st,flushSave:dt,access:ct,saveUnreachable:at=!1,readOnly:pt,readOnlyReason:ut=null}=O(),ft=V(),ht=F(),{mediaEditing:mt,hasEditGuard:gt,hasPinnedChrome:yt}=vn,{appState:St,dispatch:kt,history:vt,selectedItem:bt,getSelectorForId:xt,config:wt}=Ce(e=>e),zt=H(),{first:Bt,firstGroup:Ct,lastGroup:It,isSectionGroup:Nt,sectionGroupZone:Ot,panelOf:Pt}=zt,$t=Pt(Bt),At=e=>de(zt,e),Tt=e=>ce(zt,e),Mt="node"===zt.firstRow,jt=zt.band??null,Lt=rn("screen",Be),Et=rn("tree",je),Rt=rn("drag",cn),Vt=rn("notice",Qe),Ft=rn("lock",on),Ht=rn("menu",Le),Wt=rn("styleClipboard",ze),Dt=rn("chrome",en),Gt=W()??`/${Ln}`,Jt=D(),Ut=G(),Yt=x({readOnly:pt}),Kt=x({readOnly:pt,foldIntoHistory:!0}),Xt=In(null),Zt=Ie(),qt=Nn(()=>({...Yt,select:e=>{Xt.current=e,Yt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Zt.config;Xt.current=Ee(e,t,n)}Yt.commitDocument(e,n)}}),[Yt,Zt]),_t=St.ui,Qt=_t.leftSideBarVisible,eo=_t.rightSideBarVisible,{options:no,widths:to,initial:oo,fluid:ro,fit:io}=J(),[lo,so]=On(oo),co=ke(),ao=mt&&null!==co,po=ve(),uo=be();U(bt?.props.id);const{read:fo,write:ho,forSelection:mo}=Y(),[go,yo]=On(fo);Pn(()=>{ho(go)},[go]);const[So,ko]=On(0),vo=In(null),bo=In(null),xo=fn(bo,{readySelector:qn}),wo=f(bo);h(bo,xo);const zo=N(),Bo=nn(ct),Co={state:rt,offline:zo||rt.failed&&at,readOnlyReason:ut,editing:Bo?Vt.editing({name:tn(Bo.name,Ft),noun:Lt.noun}):null,conflict:null!=it,notSaving:Lt.bar.notSaving},Io=()=>{pt||(rt.failed?lt():dt())};m(bo,xo,Io);const[No,Oo]=On(!1),Po=In(!1),$o=In(!1),[Ao,To]=On(null),Mo=K(),jo=e=>To(null===e?null:{zone:pe,index:e}),[Lo,Eo]=On([]),[Ro,Vo]=On(X),Fo="puck"===Ro.kind,Ho=No&&!Ao&&Mo.railTarget?Mo.railTarget(St.data,{node:bt??null,mode:Ro}):null,Wo=Ho?{zone:bn(Ho),index:Ho.index}:null,Do=Ao??Wo,Go=Do&&Do.zone===pe?Do.index:null,Jo=o(Ro,bt?.props.id),[Uo,Yo]=On(null);Pn(()=>{Uo&&(r(),Yo(null))},[Uo]);const Ko=In(xt);Ko.current=xt;const Xo=$n((e,{scroll:n})=>{yo(n=>mo(e,n)),n&&Yo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Ko.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Br(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Zo=In(null);Pn(()=>{const e=Zo.current;Zo.current=null;const n=null==bt?.props.id?null:String(bt.props.id);Vo(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Pt(bt?.type)??X);const t=bt?.props.id,o=Xt.current;if(Xt.current=null,!t)return;const r=xt(t);Xo(String(t),{scroll:!i(o,r??null,pe)})},[bt?.props.id,Xo]);const qo=$n(e=>{Vo(n=>Z(n,e)?n:e),kt({type:"setUi",ui:{rightSideBarVisible:!0}})},[kt]),_o=In(()=>{});_o.current=(e,n)=>{const t=e?Si(e.zone??pe)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==bt?.props.id?null:String(bt.props.id);Vo(e=>Z(e,n)?e:n),o!==r&&(Zo.current={id:o,mode:n},qt.select(e))};const Qo=$n((e,n)=>_o.current(e,n),[]),er={kind:Ro.kind,mode:Ro,open:qo,show:e=>Vo(e),reveal:()=>{eo||kt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Qo},nr=q(er,{data:St.data,selected:bt??null,zoneOf:e=>xt(e)?.zone,readOnly:Boolean(pt),select:e=>{Vo(X),qt.select({index:e})},replace:(e,n)=>qt.replaceComponent(pe,e,n),scrollTo:e=>Di(e)},{device:lo,refreshes:So},{setView:yo,reveal:()=>{Qt||kt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),tr=nr.pinnedSource??!1,or=nr.resolveLeftView?nr.resolveLeftView(go,ao):"media"===go&&ao?go:"sections",rr=_(),{isLockedBlock:ir,duplicateBlocked:lr,nestDepth:sr,newSectionNode:dr,canAddTo:cr,blockIsOffered:ar}=rr,pr=Q(),{labelAtLevel:ur,Icon:fr,useProducts:hr}=pr,mr=pr.rowName?(e,n,t)=>pr.rowName(e,n,t):void 0,gr=$n(e=>{kt({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Xo(e,{scroll:!0})},[kt,Xo]),{selectNode:yr,openPartId:Sr}=b({mode:Ro,setMode:Vo,onOpenPart:gr}),[kr,vr]=On(null);we(null!==kr,()=>vr(null));const br=S(ee()),xr=br.collapsed,wr=br.panelWidths,[zr,Br]=On(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(xr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
|
|
8
|
+
return new Set}});Pn(()=>{try{window.localStorage.setItem(xr,JSON.stringify([...zr]))}catch{}},[zr]);const[Cr,Ir]=On(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(wr);if(!e)return{...k};const n=JSON.parse(e);return{left:v(Number(n.left)||k.left),right:v(Number(n.right)||k.right)}}catch{return{...k}}});Pn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(wr,JSON.stringify(Cr))}catch{}},300);return()=>clearTimeout(e)},[Cr]);const Nr=$n((e,n)=>Ir(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Or=$n(e=>Nr("left",e),[Nr]),Pr=$n(e=>Nr("right",e),[Nr]),$r=e=>zr.has(e),Ar=e=>Br(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Tr=In(!1),Mr=In(null);Pn(()=>{if(Tr.current&&!No){const e=Mr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??bo.current?.querySelector(`button[aria-label="${CSS.escape(Lt.add.title)}"]`))?.focus(),Mr.current=null}Tr.current=No},[No]),Pn(()=>{if(!No||!wo)return;const e=e=>{"Escape"===e.key&&_i()};return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[No,wo]),we(No,()=>_i()),Pn(()=>{!Qt&&No&&(Oo(!1),To(null),Po.current=!1)},[Qt]),Pn(()=>{if(!po)return $o.current&&kt({type:"setUi",ui:{leftSideBarVisible:!1}}),void($o.current=!1);No&&(Oo(!1),To(null),$o.current=Po.current,Po.current=!1),Qt||($o.current=!0,kt({type:"setUi",ui:{leftSideBarVisible:!0}}))},[po]),Pn(()=>{!Qt&&po&&($o.current=!1,uo())},[Qt]),Pn(()=>{if(!po||!wo)return;const e=e=>{"Escape"===e.key&&uo()};return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[po,wo]),we(null!==po,()=>uo());const jr=ne(),Lr=(e,n="success",t)=>{if(jr)return void(t?jr(e,"error"===n?"error":"info",t):jr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?jn.error(e,{...o,duration:t?.duration??3200}):jn.success(e,{...o,duration:t?.duration??1900})},Er=In(null),[Rr,Vr]=On(0),[Fr,Hr]=On(0),Wr=te(),Dr=In(null),Gr=e=>Math.max(0,e.clientHeight-(Dr.current?.offsetHeight??0));Pn(()=>{const e=Er.current;if(!e)return;const n=()=>{Vr(e.clientWidth),Hr(Gr(e))};n();const t=new ResizeObserver(n);return t.observe(e),Dr.current&&t.observe(Dr.current),()=>t.disconnect()},[]),An(()=>{Er.current&&(Vr(Er.current.clientWidth),Hr(Gr(Er.current)))},[Cr,Qt,eo]);const Jr=lo===ro?Rr>0?Rr:to[ro]:to[lo],Ur=Rr>0?Math.min(Rr/Jr,"shrink"===io?1:2):1,Yr=Jr*Ur,Kr=Rr>0&&Yr>Rr+1,Xr={width:Yr,height:Fr||"100%",flex:"none",position:"relative"},Zr={width:Jr,height:Fr?Fr/Ur:"100%",maxHeight:"none",transform:1!==Ur?`scale(${Ur})`:void 0,transformOrigin:"top left"},qr=()=>kt({type:"setUi",ui:{leftSideBarVisible:!Qt}}),_r=()=>kt({type:"setUi",ui:{rightSideBarVisible:!eo}}),Qr=e=>{No&&(Oo(!1),To(null),Po.current=!1,Qt&&go===e)||po&&($o.current=!1,uo(),Qt&&go===e)||(Qt&&go===e?qr():(yo(e),Qt||kt({type:"setUi",ui:{leftSideBarVisible:!0}})))},ei=()=>{P(hn,{accept:"image/*",title:Dt.mediaLibrary})},ni=()=>{Vo(X),qt.select(null),u()},ti=()=>{Vo($t??X),eo||kt({type:"setUi",ui:{rightSideBarVisible:!0}})},oi=St.data.content??[],ri=()=>{const e=oi.findIndex(At),n=oi.findIndex(Tt);return{floor:e>=0?e+1:0,cap:n>=0?n:oi.length}},ii=wt,li=rr.stripCopy,si=n=>e(n,li),di=w(),ci=Re({data:St.data,config:ii,readOnly:Boolean(pt),clipboard:di,strip:li?e=>li(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==xn||e.slot!==wn)return{min:0,max:n-1};const{floor:t,cap:o}=ri();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Vo(X);const t=void 0===n||"node"===n?.kind?n:null;qt.commitDocument(e,t)}}),ai=e=>{const n=Bn(St.data,wt,e);if(!n)return!1;const t=bn(n.place),o=n.node,r=t===pe?mi(o):Oi(o);return!!ci.remove(e)&&(Lr(Lt.deleted({name:r}),"success",{duration:8e3,action:{label:Lt.bar.undo,onClick:()=>{ci.restore(n.node,n.place)}}}),!0)},pi={...ci,remove:ai},ui=e=>ur(e,"block",wt.components[e]?.label??e),fi=$n(e=>wt.components[e]?.defaultProps??{},[wt]),hi=e=>ur(e,"section",ui(e)),mi=e=>l({type:e.type,props:e.props??{}},hi(e.type),mr),{nodeAddresses:gi,zoneItems:yi}=Nn(()=>{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>=fe)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of he(wt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(oi,pe,0),{nodeAddresses:e,zoneItems:n}},[oi,wt]),Si=$n(e=>yi.get(e)??[],[yi]),ki=e=>{const n=gi.get(e);return n?Si(n.zone)[n.index]:void 0},vi=e=>ae(rr,wt,e),bi=e=>{if(!rr.slotsOf||e===pe)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=ki(e.slice(0,n));if(!t)return null;const o=vi(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}},xi=(()=>{if(!oe(Ro))return null;const e=`${Ro.nodeId}:${Ro.slot}`;return bi(e)?.slot.panel===Ro.kind?e:null})(),wi=In(null);Pn(()=>{const e=wi.current;if(wi.current=null,!xi||!oe(Ro))return;const n=Ro.nodeId;Xo(n,{scroll:e!==xi}),Br(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Ro]);const zi=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=gi.get(e);n&&(n.zone===pe?Gi(n.index):vl(n.zone,n.index,e,ki(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&xi!==i&&(wi.current=i),Qo(null,r),eo||kt({type:"setUi",ui:{rightSideBarVisible:!0}}),Di(o)},Bi=(e,n,t)=>{const o=`${e}:${n}`;if(Br(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;xi!==o&&(wi.current=o);Qo(null,{kind:t,nodeId:e,slot:n})},Ci=(e,n,t)=>{if(pt||!rr.moveSlot)return;const o=ki(e),r=o?vi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Qn,index:n},s=un(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=rr.moveSlot(e,n,s);"string"==typeof d&&Bi(e,d,i.panel)},Ii=hr(),Ni=Nn(()=>{const e=/* @__PURE__ */new Map;for(const n of Ii??[])e.set(n.slug,n.name);return e},[Ii]),Oi=e=>s(e,ui,pr.plainText,e=>Ni.get(e),pr.rowName),Pi=(e,n)=>{const t=wt.components[e.type]?.fields,o=n===pe||Wl(n)?"section":"block",r=n===pe&&(At(e)||Tt(e)||Nt(e.type)),i="block"===o?d(t):r?null:c(t);return pr.renamePropOf?pr.renamePropOf(e,o,i):i},$i=(e,n,t,o)=>{if(!(!pt&&kr?.zone===e&&kr.index===n))return;const r=(t,o)=>{vr(null),o&&((e,n,t)=>{const o=Si(e)[n];if(!o)return;const r=Pi(o,e);r&&qt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
|
|
9
|
+
return Gn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Lt.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)},Ai=t(re(),Wt),Ti=Ai.scope({target:Sn,siteId:tt,docId:kn}),Mi=wt,ji=(e,n)=>n===pe?hi(e):ui(e),Li=(e,n,t)=>{const o=Ai.plan(Ti,t,ji(t.type,e),Mi);o&&(o.changed&&qt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Lr(o.message))},Ei=z({nodesIn:Si,nodeAt:(e,n)=>Si(e)[n]??null,labelOf:(e,n)=>n===pe?hi(e):ui(e),renamePropOf:Pi,beginRename:(e,n)=>vr({zone:e,index:n}),history:{hasPast:vt.hasPast,hasFuture:vt.hasFuture,back:()=>vt.back(),forward:()=>vt.forward()},openAddSection:()=>{qt.select(null),Zi(null)},openPageSettings:()=>{qt.select(null),Vo(X)},pageSettingsLabel:Lt.pageSettings,words:{menu:Ht,styleClipboard:Wt,screen:Lt.menu},readOnly:Boolean(pt),collapseAll:()=>Br(new Set(Si(pe).map(e=>String(e.props.id)))),onPasteRefused:e=>Lr(e?Lt.pasteRefused({name:e.label}):Lt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Jl(e,n),menuRows:nr.menuRows,isLocked:e=>ir(e.type),duplicateBlocked:e=>lr(St.data,e),permits:e=>ue(wt,e.type),canAddTo:cr,nodeOps:pi,isPinned:(e,n)=>n===pe&&(At(e)||Tt(e)),sectionBand:ri,openAddInside:(e,n)=>{e===pe?Gi(n):qt.select({zone:e,index:n}),Zi(null)},locate:e=>gi.get(e)??null,rowNameOf:(e,n)=>n===pe?mi(e):Oi(e),selectAt:(e,n,t,o)=>{e===pe?Gi(n):vl(e,n,t,o??"")},slotRung:e=>{const n=bi(e);return n?.slot.panel?{label:n.slot.label,select:()=>zi(n.node,n.slot,!1)}:null},style:{held:()=>$(Ti),canCopy:e=>Ai.rows(Mi,e).some(e=>!1!==e.counted),copy:(e,n)=>Ai.copy(Ti,e,ji(e.type,n),Mi),paste:(e,n,t)=>Li(e,n,t)},keys:ht?{target:wo,selected:()=>{const e=St.ui.itemSelector;return e?{zone:e.zone??pe,index:e.index}:null},held:()=>di.get(),readOnly:Boolean(pt),onDone:({done:e,name:n})=>{"copied"===e&&Lr(Lt.copied({name:n}))}}:void 0},xo),Ri=In({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Pn(()=>{Ri.current={copy:(e,n)=>Ai.copy(Ti,e,ji(e.type,n),Mi),paste:Li,at:()=>{const e=St.ui.itemSelector;if(!e)return null;const n=e.zone??pe,t=Si(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(pt)}});const Vi=$n(e=>{const n=A(e);if(!n)return;const t=Ri.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);Pn(()=>{if(!wo)return;const e=e=>Vi(e);return wo.addEventListener("keydown",e),()=>wo.removeEventListener("keydown",e)},[Vi,wo]),gn(xo,"keydown",Vi);const Fi=oi.map(e=>e.props.id).join("|");Pn(()=>{const e=xo?.document??null,n=xo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void Eo(e=>e.length?[]:e);const n=oi.findIndex(Tt),t=n>=0?n:oi.length,o=n=>{const t=oi[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(mn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=oi.length>0&&!At(oi[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=_n(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})}Eo(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[xo,Fi,lo,Ur,Qt,eo,bt?.props.id]);const Hi=xo?.document??null,Wi=xo?.window??null;Pn(()=>{const e=vo.current;if(!e||!Hi||!Wi)return;const n=[],t=()=>{const n=Hi.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Wi.scrollTo({left:Wi.scrollX,top:Wi.scrollY+t,behavior:"instant"}),!0};return vo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Hi,Wi]);const Di=e=>{nr.holdCanvasOn?nr.holdCanvasOn(e):a(e)},Gi=e=>{Vo(X),qt.select({index:e}),nr.sectionPressed?.(oi[e]);const n=oi[e]?.props?.id;n&&Di(n)},Ji=e=>{const{floor:n,cap:t}=ri(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=bt&&Ro.kind!==$t?.kind?oi.findIndex(e=>e.props.id===bt.props.id):-1;return o(r>=0?r+1:t)},Ui=(e,n)=>{const{floor:t,cap:o}=ri(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(qt.reorderComponent(pe,e,i),qt.select({index:i}),{moved:!0,dest:i})},Yi=(e,n,t,o)=>{Vo(X),qt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Lr(Lt.sectionAdded({name:t}))},Ki=(e,n)=>{const t=Ji(n),o=dr(e,{nodeDefaults:fi,newNodeId:Se,sectionLabel:hi,blockIsOffered:ar}),r=o?qt.insertNode(pe,t,o):qt.insertSection(e,t);return Yi(t,r,hi(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of he(wt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=cr(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Xi=(e,n,t)=>{const o=Ji(t),r=qt.insertNode(pe,o,n);return Yi(o,r,e),o},Zi=e=>qi(pe,e),qi=(e,n)=>{Mr.current=document.activeElement??null,po&&(Po.current=$o.current,$o.current=!1,uo()),To(null===n?null:{zone:e,index:n}),Oo(!0),Qt||(Po.current=!0,kt({type:"setUi",ui:{leftSideBarVisible:!0}}))},_i=()=>{Oo(!1),To(null),Po.current&&kt({type:"setUi",ui:{leftSideBarVisible:!1}}),Po.current=!1},Qi=(e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&Dl(n,o)){if("section"===e.kind)qt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;qt.insertNode(n,t,si(e.template.node))}Vo(X),qt.select({index:t,zone:n})}},el=(e,n)=>pr.rowName?n?At(e)?pr.rowName(e,"section",Lt.header):Tt(e)?pr.rowName(e,"section",Lt.footer):Nt(e.type)?pr.rowName(e,"section",ui(e.type)):mi(e):Oi(e):n?hi(e.type):ui(e.type),nl=e=>n=>{e()},tl=()=>nr.editPinnedSource?.(),ol=(e,n,t)=>{if(pt)return null;const o=Si(e)[n];return o&&!ue(wt,o.type).delete?null:/* @__PURE__ */Gn(Te,{kind:"delete",label:Lt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Si(e)[n]?.props?.id;null!=t&&ai(String(t))})(e,n),children:/* @__PURE__ */Gn(Fn,{size:15})})},rl=e=>pr.rowPreview?.(e)||void 0,il=e=>pr.rowMarks?.(e)??void 0,ll=(e,n,t)=>pr.rowActions?.(e,n,t)??null,sl=(e,n,t,o)=>{if(pt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
|
|
10
|
+
return Gn(Te,{kind:"eye",label:r?Lt.showNamed({name:o}):Lt.hideNamed({name:o}),onClick:()=>cl(e,n,t),children:/* @__PURE__ */Gn(r?Hn:Wn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},dl=e=>{const n=hi(oi[e]?.type??""),t=n?Lt.addSectionBefore({name:n}):Lt.addSectionHere;return vs(pe,e,()=>Zi(e),t)},cl=(e,n,t)=>{qt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},al=e=>me(wt,e),pl=e=>he(wt,e),ul=e=>rr.slotsOf?vi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:ge(e,n.slot)})):[{slot:null,rung:null,kids:pl(e)}],fl=e=>rr.slotsOf?ul(e).flatMap(e=>e.kids):pl(e),hl=e=>Boolean(rr.slotsOf)&&vi(e).some(e=>e.rung),ml=(e,n,t)=>null===t?void 0===n?cr(e):cr(e,n):cr(e,n,t),gl=(e,n,t)=>{const o=ye(wt,e.type,n)&&(t||fl(e).length>0||hl(e));return{collapsible:o,folded:o&&$r(String(e.props.id))}},yl=(e,n,t)=>ul(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>gl(e,r,t(e.type)).collapsible?[String(e.props.id),...yl(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Sl=e=>fl(e).length>0||hl(e)||Boolean(cr(e.type)),kl=e=>Boolean(cr(e)),vl=(e,n,t,o)=>{if(Vo(X),cr(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),qt.select({index:n,zone:e}),a(t)}else qt.select({index:n,zone:e}),Di(t)},bl=(e,n,t,o,r)=>{const i=`${e}:${n}`;qt.insertComponent(i,t,o),cr(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),qt.select({index:o,zone:i})}):qt.select({index:o,zone:i})},xl=(e,n,t)=>{qt.insertComponent(e,n,t),Vo(X),qt.select({index:t,zone:e})},wl=In(/* @__PURE__ */new Set);Pn(()=>{oi.forEach(e=>{const n=cr(e.type)?.spec;if(!n)return;const t=e.props.id;if(wl.current.has(t))return;wl.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(fi)).forEach((e,t)=>Kt.seedChild(o,t,n.childType,e))})},[oi,Kt,fi]);const zl=In(/* @__PURE__ */new Set);Pn(()=>{oi.forEach((e,t)=>{const o=e.props.id;if(zl.current.has(o))return;const r=n(e,al(e.type));zl.current.add(o),r&&Kt.replaceComponent(pe,t,{...e,props:r})})},[oi,Kt]),ie(Kt,wt);const Bl=oi.findIndex(Tt),Cl=Bl>=0?oi[Bl]:null,Il=Mt?oi.findIndex(At):-1,Nl=Il>=0?oi[Il]:null,Ol=zt.groupTab,Pl=Nn(()=>Ol?e=>Nt(e.type):void 0,[Ol]),$l=Boolean(zt.groupBadge),Al=zt.groupBadge?/* @__PURE__ */Gn("span",{className:"es-tree-group-badge",children:/* @__PURE__ */Gn(Mn,{tone:"info",size:"xs",children:zt.groupBadge})}):void 0,Tl=oi.find(e=>e.type===Ct)??null,Ml=oi.find(e=>e.type===It)??null,jl=Bl>=0?Bl:oi.length,Ll=[];oi.forEach(e=>{Tt(e)||(Sl(e)&&Ll.push(String(e.props.id)),Ll.push(...yl(e,1,kl)))}),Cl&&(Ll.push(String(Cl.props.id)),Ll.push(...yl(Cl,1,kl)));const El=Ll.length>0&&Ll.every(e=>zr.has(e)),Rl=e=>{const n=pr.blockRowName(e,ui);return pr.rowName?pr.rowName(e,"block",n):n},Vl=(e,n,t,o)=>{const r=Si(e)[t];if(!r)return;const i={...zn(e),index:t},l={...zn(n),index:Math.min(Math.max(o,0),Si(n).length)},s=un(i,l);if(e!==n||s!==t)try{ci.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof Cn))throw e}},Fl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of pl(e))n.add(r),t(o)};for(const t of al(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},Hl=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=gi.get(n);if(!e)return null;if(e.zone===pe)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Wl=e=>{const n=e.slice(0,e.indexOf(":")),t=oi.find(e=>Nt(e.type)&&String(e.props.id)===n);return t&&Ot(n)===e?t:null},Dl=(e,n)=>{const t=Wl(e);return!t||(!zt.groupAccepts||zt.groupAccepts(t.type,n,Si(e).length))},Gl=(e,n,t)=>{if(e.rung){const t=ki(e.rung.nodeId),o=t?vi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Qn&&n.index>=0&&n.index<=o}if(n.slot===Qn)return!1;if(e.add)return Yl(e.add,n);const o=bn(n);if(Nt(e.type))return!1;const r=Wl(o),i=Wl(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!Dl(o,e.type))&&(n.index>=0&&n.index<=Si(o).length));if(e.zone===pe||o===pe){if(e.zone!==o)return!1;const{floor:t,cap:r}=ri();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Si(o).length)return!1;if(e.zone===o)return!0;const l=Cl&&!zt.lastIsOpen?String(Cl.props.id):null;return(!l||Hl(e.zone)!==l&&Hl(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Si(e)[t];if(!r)return!1;const i=n.split(":")[0],l=gi.get(i),s=l?Si(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Fl(r).has(n))return!1;const d=cr(s.type,sr(St?.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?.(Si(n),r))})(e.zone,o,e.index,t)},Jl=(e,n)=>{const t=bn(e.from),o=e.node;return t===bn(n)?Dl(t,o.type):Gl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Ul=e=>{const n=e.slice(0,e.indexOf(":")),t=gi.get(n),o=t?Si(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=cr(o.type,sr(St?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:ui(r.spec.childType)}]:[]),l=bi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:el(o,t.zone===pe)}},Yl=(e,n)=>{const t=bn(n);if("block"!==e.kind){if(Wl(t)){const o="section"===e.kind?e.type:e.template.node.type;return Dl(t,o)&&n.index>=0&&n.index<=Si(t).length}if(t!==pe)return!1;const{floor:o,cap:r}=ri();return n.index>=o&&n.index<=r}if(t===pe)return!1;const o=Ul(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(Si(t))},Kl=(e,n)=>{e.rung?Ci(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&Wl(bn(n)))return void Qi(e,bn(n),n.index);if("section"===e.kind)return void Ki(e.type,n.index);if("template"===e.kind)return void Xi(e.template.name,si(e.template.node),n.index);const t=bn(n),o=Ul(t);o&&(o.target.spec?bl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):xl(t,e.type,n.index))})(e.add,n):e.zone===pe?Ui(e.index,n.index):Vl(e.zone,bn(n),e.index,n.index)},[Xl]=On(()=>an()),Zl=pn({keyOf:e=>e.id,readOnly:Boolean(pt),session:Xl,canDrop:Gl,onDrop:Kl,onStep:(e,n)=>{e.rung?Ci(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===pe?((e,n)=>{const t=hi(oi[e]?.type??""),o=Ui(e,n<0?e-1:e+2);if(!o.moved)return void Lr(n<0?Lt.sectionFirst({name:t}):Lt.sectionLast({name:t}));const{floor:r,cap:i}=ri();Lr(Lt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Vl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),ql=$n(e=>{const{floor:n,cap:t}=ri(),o=[];for(const r of e.nodes){const e=bn(r.place),i=Si(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(At(i)||Tt(i)||ir(i.type))continue;if(Nt(i.type))continue;const l=Boolean(Wl(e)),s=e===pe||l;e===pe&&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?hi(i.type):Oi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=bn(e.list);return n===pe&&0===e.children.length?[{...e,addLabel:Lt.addSection,addAlways:!0}]:e.children.length>0||Boolean(Ul(n)?.choices.length)||Boolean(Wl(n))?[e]:[]}),i=r.flatMap(e=>{const n=bn(e.list);return n===pe||Wl(n)||!Ul(n)?.choices.length?[]:ln(e,Lt.addBlockHere)});return{sources:o,zones:r,seams:i}},[St.data]),_l=null==bt?.props.id?null:String(bt.props.id),Ql=$n(e=>{const n=wt,t=e=>!e.item.rung&&null!==Bn(St.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(_l);return i||(r(Ve(St.data,n,o.item.id,_l,Pl))??o)},[St.data,wt,_l,Pl]),[es,ns]=On(null);gn(xo,"mouseover",e=>{if(!Ol)return;const n=yn(e.target),t=n?Kn(St.data,wt,n):null;t!==es&&ns(t)}),gn(xo,"mouseout",e=>{Ol&&!e.relatedTarget&&ns(null)});const ts=e=>At(e)||Tt(e)||Nt(e.type),os=[];if(Ol){const e=_l?Kn(St.data,wt,_l):null;for(const n of/* @__PURE__ */new Set([e,es])){const e=n?oi.find(e=>String(e.props.id)===n):void 0;if(!e||!ts(e))continue;const t=Ol(e);t&&os.push({id:String(e.props.id),label:t,below:At(e)||e.type===Ct})}}const rs=E(),is=In(null);Pn(()=>{const e=zt.changeNotice;if(!e)return;const n=JSON.stringify(oi.filter(ts)),t=is.current;if(is.current={doc:kn,bands:n,index:vt.index},!t||t.doc!==kn||t.bands===n)return;vt.hasPast&&vt.index>=t.index&&!Yn.has(rs)&&(Yn.add(rs),Lr(e,"success",{action:{label:Lt.bar.undo,onClick:()=>vt.back()},duration:8e3}))},[oi]);const ls=e=>{Vo(X),qt.select(e.zone===pe?{index:e.index}:{index:e.index,zone:e.zone})},ss=le(),ds=()=>({data:St.data,device:lo,ops:qt,inspector:er}),cs=ss?.model,as=Nn(()=>cs?e=>cs(e,ql(e),ds()):ql,[cs,ql,lo]),ps=ss?.measure,us=ps?(e,n)=>ps(e,n,ds()):void 0,fs=ss?.canDrop,hs=fs?(e,n)=>fs(e,n,Gl,ds()):Gl,ms=ss?.drop,gs=ms?(e,n)=>ms(e,n,Kl,ds()):Kl,ys=ss?.pick,Ss=ys?e=>ys(e,ls,ds()):ls,ks=e=>{const n=bn(e),t=bi(n);t&&zi(t.node,t.slot,!1),qi(n,e.index)},vs=(e,n,t,o)=>/* @__PURE__ */Gn(Me,{...pt?{}:Zl.seam({place:{...zn(e),index:n}}),onAdd:pt?void 0:t,label:o},`seam:${e}:${n}`),bs={rowClick:nl,isCollapsed:$r,toggleCollapse:Ar},xs=e=>{const n=String(e.props.id),t=oi.findIndex(e=>String(e.props.id)===n),o=Ot(n),r=Si(o),i=$r(n),l=ui(e.type),s=pr.rowName?pr.rowName(e,"section",l):l,d=e=>vs(o,e,()=>qi(o,e),Lt.addSectionHere);/* @__PURE__ */
|
|
11
|
+
return Jn(Un,{children:[
|
|
12
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:e.type,size:13}),name:s,preview:rl(e),marks:il(e),onSelect:()=>Gi(t),nameSlot:$i(pe,t,n,s),selected:Jo===n,badge:Al,actions:ll(e,pe,t)??void 0,rowProps:{"data-node-id":n,onClick:nl(()=>Gi(t))},fold:{open:!i,label:"section",onToggle:()=>Ar(n)}}),!i&&/* @__PURE__ */Jn(Pe,{children:[r.map((n,t)=>{const r=String(n.props.id),i=mi(n),l=Sl(n),s=l&&$r(r),c=()=>vl(o,t,r,e.type),{rowProps:a,...p}=Zl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...zn(o),index:t}},{"data-node-id":r,onClick:nl(c)});/* @__PURE__ */
|
|
13
|
+
return Jn(Tn,{children:[d(t),
|
|
14
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:c,nameSlot:$i(o,t,r,i),selected:Jo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Ar(r)}:void 0,actions:/* @__PURE__ */Jn(Un,{children:[ol(o,t,i),ll(n,o,t),sl(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Gn(Pe,{children:Bs(n,2)})]},r)}),d(r.length)]})]})},ws=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=Zl.dragging,d=!$r(l)&&s?.rung?.nodeId!==i,c={...zn(l),index:0},a=s&&!s.rung&&Gl(s,c)?c:void 0,p=()=>zi(e,n,!0),{rowProps:u,...f}=Zl.row({item:{id:`rung:${l}`,zone:`${i}:${Qn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Qn,index:t},into:a,canDrag:Boolean(rr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:nl(p)}),h=pt?null:rr.slotActions?.(e,n.slot);/* @__PURE__ */
|
|
15
|
+
return Jn(Tn,{children:[n.heading,
|
|
16
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:xi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Ar(l)},actions:h&&h.length>0?/* @__PURE__ */Gn(Un,{children:h.map((t,o)=>/* @__PURE__ */Gn(Te,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(pt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Bi(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Gn(Fn,{size:15}):/* @__PURE__ */Gn(Dn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Gn(Pe,{children:r})]},l)},zs=(e,n)=>{const t=ul(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
|
|
17
|
+
return Gn(Un,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=ml(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=null!==c&&Boolean(Ul(c)?.choices.length),p=(e,n)=>a?vs(e,n,()=>qi(e,n),Lt.addBlockHere):vs(e,n),u=/* @__PURE__ */Jn(Un,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Jo===String(n.props.id),{collapsible:i,folded:s}=gl(n,l,kl(n.type)),d=String(n.props.id),c=Rl(n),a=()=>vl(t,o,d,e.type),{rowProps:u,...f}=Zl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...zn(t),index:o}},{"data-node-id":d,onClick:nl(a)});/* @__PURE__ */
|
|
18
|
+
return Jn(Tn,{children:[0===o&&p(t,0),
|
|
19
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:n.type,size:13}),name:c,preview:rl(n),marks:il(n),onSelect:a,nameSlot:$i(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Ar(d)}:void 0,actions:/* @__PURE__ */Jn(Un,{children:[ol(t,o,c),ll(n,t,o),sl(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Gn(Pe,{children:zs(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==c?null:p(c,0)]});return t.rung?ws(e,t.rung,r++,o,u):/* @__PURE__ */Gn(Tn,{children:u},t.slot??"")})})},Bs=(e,n)=>{const t=sr(St?.data,e.type,String(e.props.id)),o=ul(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
|
|
20
|
+
return Gn(Un,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=ml(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(n,t)=>{const o=n===f&&c&&!c.addBlocked?.(a)?()=>bl(e.props.id,c.slot,c.childType,t,e.type):n===h?()=>qi(n,t):void 0;return vs(n,t,o,n===f&&c?c.addLabel:Lt.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),S=/* @__PURE__ */Jn(Un,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Jo===String(n.props.id),i=Oi(n),l=String(n.props.id),{collapsible:d,folded:c}=gl(n,s,kl(n.type)),a=al(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...zn(p),index:Si(p).length}:void 0,f=Zl.dragging,h=u&&f&&Gl(f,u)?u:void 0,g=()=>vl(t,o,l,e.type),{rowProps:y,...S}=Zl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...zn(t),index:o},into:h,canDrag:!ir(n.type)},{"data-node-id":l,onClick:nl(g)});/* @__PURE__ */
|
|
21
|
+
return Jn(Tn,{children:[0===o&&m(t,0),
|
|
22
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:n.type,size:13}),name:i,preview:rl(n),marks:il(n),onSelect:g,nameSlot:$i(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...S,fold:d?{open:!c,label:"group",onToggle:()=>Ar(l)}:void 0,actions:ir(n.type)?ll(n,t,o)??void 0:/* @__PURE__ */Jn(Un,{children:[ol(t,o,i),ll(n,t,o),sl(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Gn(Pe,{children:Bs(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
|
|
23
|
+
/* @__PURE__ */Gn(T,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>bl(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?ws(e,o.rung,i++,r,S):/* @__PURE__ */Gn(Tn,{children:S},o.slot??"")})})},Cs=(()=>{if(!bt||!Fo)return null;const e=String(bt.type),n=String(bt.props.id),t=cr(e,sr(St?.data,e,n));if(!t||"footer"===t.source)return null;const o=oi.some(e=>String(e.props?.id)===n),r=Array.isArray(bt.props[t.slot])?bt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:ui(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:el(bt,o),choices:i,onPick:o=>{t.spec?bl(n,t.slot,o,r.length,e):xl(`${n}:${t.slot}`,o,r.length)}}})(),Is=Do&&Do.zone!==pe&&!Wl(Do.zone)?Do.zone:null,Ns=!0===Mo.blocksFirst,Os=Is?Ul(Is):Ns&&Do?null:Cs,Ps=Do&&Wl(Do.zone)?Do.zone:null,$s=Ps&&zt.groupAccepts?e=>Dl(Ps,e):void 0,As=Boolean(Ao&&Is)||Ns&&Boolean(Os&&Os.choices.length>0),Ts=No||null!==po,Ms=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Qt&&!Ts&&or===e.id,onSelect:()=>Qr(e.id)}:e,js=[{id:"add",label:Lt.add.title,icon:/* @__PURE__ */Gn("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:No,onSelect:()=>No?_i():Zi(null)},...(nr.railLead??[]).map(Ms),{id:"sections",label:Lt.layers,icon:/* @__PURE__ */Gn(Fe,{}),active:Qt&&!Ts&&"sections"===or,onSelect:()=>Qr("sections")},...(nr.railTrail??[]).map(Ms)];ao?js.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Gn(He,{}),active:Qt&&!No&&(null!==po||"media"===or),onSelect:()=>Qr("media")}):mt&&js.push({id:"media",label:Lt.railMedia,icon:/* @__PURE__ */Gn(He,{}),onSelect:ei});const Ls=[...nr.railLead??[],...nr.railTrail??[]].find(e=>"panel"in e&&e.id===or),Es=Boolean(jt?.foldable)&&!tr,Rs=jt?.label??(gt?Lt.pageSections:Lt.templateSections),Vs=Es&&$r(et),Fs=/* @__PURE__ */Jn(Un,{children:[oi.map((e,n)=>{if(At(e)||Tt(e)||Nt(e.type))return null;const t=Jo===String(e.props.id),o=Boolean(e.props._hidden);pl(e);const r=String(e.props.id),i=nr.hasOwnRows?.(e)??!1,l=Sl(e)||i,s=l&&$r(r),d=al(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...zn(c),index:Si(c).length}:void 0,p=Zl.dragging,u=a&&p&&Gl(p,a)?a:void 0,{rowProps:f,...h}=Zl.row({item:{id:r,zone:pe,index:n,type:e.type},place:{...zn(pe),index:n},into:u},{"data-node-id":r,onClick:nl(()=>Gi(n))});/* @__PURE__ */
|
|
24
|
+
return Jn(Tn,{children:[n>0&&dl(n),
|
|
25
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:e.type,size:13}),name:mi(e),preview:rl(e),marks:il(e),onSelect:()=>Gi(n),nameSlot:$i(pe,n,r,mi(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Ar(r)}:void 0,actions:/* @__PURE__ */Jn(Un,{children:[ol(pe,n,mi(e)),ll(e,pe,n),sl(pe,n,e,mi(e))]}),rowProps:f}),Sl(e)&&!s&&/* @__PURE__ */Jn(Pe,{children:[Bs(e,1),nr.partRows?.(e,bs)]}),i&&!s&&/* @__PURE__ */Gn(Pe,{children:nr.ownRows?.(e,n,bs)})]},String(e.props.id??n))}),!tr&&jl>0&&dl(jl),jt?.addAtEnd&&!tr&&!pt&&/* @__PURE__ */Gn(T,{small:!0,label:Lt.addSection,blocked:null,onAdd:()=>Zi(jl)})]}),Hs=(e,n,t)=>{const o=String(e.props.id),r=fl(e).length>0||hl(e)||Boolean(cr(e.type)),i=r&&$r(o),l="header"===t?Lt.header:Lt.footer,s=pr.rowName?pr.rowName(e,"section",l):l;/* @__PURE__ */
|
|
26
|
+
return Jn(Un,{children:[
|
|
27
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:t,size:13}),name:s,preview:rl(e),marks:il(e),badge:Al,onSelect:()=>Gi(n),nameSlot:$i(pe,n,o,s),selected:Jo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Ar(o)}:void 0,actions:ll(e,pe,n)??void 0,rowProps:{"data-node-id":o,onClick:nl(()=>Gi(n))}}),r&&!i&&/* @__PURE__ */Gn(Pe,{children:zs(e,1)})]})};return(nr.wrap??(e=>e))(
|
|
28
|
+
/* @__PURE__ */Gn(se,{target:xo,children:/* @__PURE__ */Jn("div",{ref:bo,className:"sf-editor es-editor",style:_e(Cr),onContextMenu:Ei.onEditorContextMenu,...g(hn),children:[
|
|
29
|
+
/* @__PURE__ */Jn(We,{children:[
|
|
30
|
+
/* @__PURE__ */Gn(De,{items:js,ariaLabel:Lt.bar.views}),
|
|
31
|
+
/* @__PURE__ */Jn(Ge,{children:[
|
|
32
|
+
/* @__PURE__ */Gn(Je,{label:Lt.bar.undo,disabled:Boolean(pt)||!vt.hasPast,onClick:()=>vt.back(),children:/* @__PURE__ */Gn(En,{})}),
|
|
33
|
+
/* @__PURE__ */Gn(Je,{label:Lt.bar.redo,disabled:Boolean(pt)||!vt.hasFuture,onClick:()=>vt.forward(),children:/* @__PURE__ */Gn(Rn,{})}),
|
|
34
|
+
/* @__PURE__ */Gn(Ue,{}),
|
|
35
|
+
/* @__PURE__ */Gn(Ye,{devices:no,value:lo,onChange:so}),
|
|
36
|
+
/* @__PURE__ */Gn(Je,{label:Lt.bar.refresh,tip:Lt.bar.refreshTip,onClick:()=>{vo.current=(()=>{const e=xo?.document;if(!e)return null;const n=oi.findIndex(Tt),t=n>=0?n:oi.length;let o=null;for(let n=0;n<t;n++){const t=oi[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=bt?.props?.id??oi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),ko(e=>e+1)},children:/* @__PURE__ */Gn(Vn,{})})]}),
|
|
37
|
+
/* @__PURE__ */Jn(Ge,{kind:"right",style:{minWidth:300},children:[
|
|
38
|
+
/* @__PURE__ */Gn(C,{input:Co,words:Lt.saveStatus}),nr.barLead?.(),nr.barTrail?.(),nr.mainAction||!nr.barMain?/* @__PURE__ */Gn(I,{input:Co,action:nr.mainAction??{label:Lt.done,onPress:()=>{ot(St.data)}},readOnly:Boolean(pt),saveSwitch:ft,onToggleAutoSave:st,onSaveNow:Io,bar:Lt.bar,words:Lt.saveStatus}):nr.barMain()]})]}),
|
|
39
|
+
/* @__PURE__ */Gn(B,{}),
|
|
40
|
+
/* @__PURE__ */Jn("div",{className:"sf-body",children:[Qt?/* @__PURE__ */Jn(Un,{children:[
|
|
41
|
+
/* @__PURE__ */Gn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Lt.leftPanel,children:No?/* @__PURE__ */Gn(M,{blocks:Os,blocksOnly:As,sectionAccepts:$s,at:Ao?{label:(e=>{const n=Wl(e.zone);if(n)return Lt.add.addingTo({name:pr.rowName?el(n,!0):ui(n.type)});if(e.zone===pe){const n=oi[e.index];return n&&!Tt(n)?Lt.add.addingBefore({name:el(n,!0)}):Lt.add.addingAtEnd}const t=Ul(e.zone);return t?Lt.add.addingTo({name:t.parentName}):Lt.add.addingHere})(Ao),onClear:()=>To(null)}:void 0,onAdd:e=>{const n=Do,t=(e,n)=>{Ao&&To({zone:e,index:n})};if(n&&"block"!==e.kind&&Wl(n.zone))return Qi(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===Go)return void Ki(e);const n=Ki(e,Go);Ao&&jo(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===Go)return void Xi(e,n);const t=Xi(e,n,Go);Ao&&jo(t+1)})(e.template.name,si(e.template.node));if(n&&n.zone!==pe){const o=Ul(n.zone);if(!o)return;return o.target.spec?bl(o.parentId,o.target.slot,e.type,n.index,o.parent.type):xl(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Cs?.onPick(e.type)},itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Xl,siteWide:nr.addPanelRow?.(_i),onClose:_i,onHide:qr,readOnly:Boolean(pt)}):po&&co?
|
|
42
|
+
/* @__PURE__ */Gn(R,{panel:co,pick:po,onHide:qr}):Ls?Ls.panel({onHide:qr,notify:Lr}):"media"===or&&co?/* @__PURE__ */Gn(R,{panel:co,pick:null,onHide:qr}):/* @__PURE__ */Jn(Un,{children:[
|
|
43
|
+
/* @__PURE__ */Gn(j,{icon:/* @__PURE__ */Gn(Fe,{}),title:Lt.layers,context:Gt,actions:
|
|
44
|
+
/* @__PURE__ */Gn(Ke,{label:El?Lt.expandAll:Lt.collapseAll,title:0===Ll.length?Lt.nothingToFold:void 0,disabled:0===Ll.length,onClick:()=>Br(e=>{const n=new Set(Ll);return El?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Ll])}),children:/* @__PURE__ */Gn(Zn,{expand:El})}),onHide:qr}),
|
|
45
|
+
/* @__PURE__ */Jn($e,{className:"sf-tree sf-scroll",words:Et,children:[
|
|
46
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:"page",size:13}),name:Lt.pageSettings,onSelect:ni,selected:!bt&&Fo,rowProps:{onClick:nl(ni)}}),Tl&&/* @__PURE__ */Jn(Un,{children:[!$l&&/* @__PURE__ */Gn(Ae,{children:Lt.header}),xs(Tl)]}),!tr&&yt&&!($l&&Tl)&&/* @__PURE__ */Jn(Un,{children:[!$l&&/* @__PURE__ */Gn(Ae,{children:Lt.header}),!Mt&&/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:"header",size:13}),name:Lt.header,badge:Al,onSelect:ti,selected:Ro.kind===$t?.kind,rowProps:{onClick:nl(ti)}})]}),!tr&&Nl&&!($l&&Tl)&&Hs(Nl,Il,"header"),!tr&&!Es&&/* @__PURE__ */Gn(Ae,{children:Rs}),Es?/* @__PURE__ */Jn(Un,{children:[
|
|
47
|
+
/* @__PURE__ */Gn(Oe,{words:Et,icon:null,name:Rs,fold:{open:!Vs,label:Rs,onToggle:()=>Ar(et)}}),!Vs&&/* @__PURE__ */Gn(Pe,{children:Fs})]}):Fs,yt&&!$l&&/* @__PURE__ */Gn(Ae,{children:Lt.footer}),Cl&&!($l&&Ml)&&Hs(Cl,Bl,"footer"),!tr&&!Cl&&yt&&!$l&&/* @__PURE__ */Gn(Oe,{words:Et,icon:/* @__PURE__ */Gn(fr,{type:"footer",size:13}),name:Lt.footer,onSelect:tl,rowProps:{onClick:nl(tl),title:Lt.editFooter}}),Ml&&xs(Ml),nr.treeFoot?.()]})]})}),
|
|
48
|
+
/* @__PURE__ */Gn(Xe,{side:"left",width:Cr.left,min:qe,max:Ze,defaultWidth:k.left,label:Lt.resizeLeftPanel,onResize:Or})]}):/* @__PURE__ */Gn(L,{side:"left",onShow:qr}),
|
|
49
|
+
/* @__PURE__ */Jn("div",{ref:Er,className:"sf-center sf-scroll","data-sf-canvas-head":Wr?"":void 0,style:{overflowX:Kr?"auto":"hidden",overflowY:"hidden"},children:[Wr&&/* @__PURE__ */Gn("div",{ref:Dr,className:"sf-canvas-head",children:/* @__PURE__ */Gn(Wr,{device:lo})}),
|
|
50
|
+
/* @__PURE__ */Jn("div",{className:"sf-frame-scaler",style:Xr,children:[
|
|
51
|
+
/* @__PURE__ */Gn("div",{className:"sf-frame "+(lo===ro?"":`sf-frame--${lo}`),style:Zr,children:/* @__PURE__ */Jn("div",{className:"sf-preview-host",children:[
|
|
52
|
+
/* @__PURE__ */Gn(Ne.Provider,{value:Pl,children:/* @__PURE__ */Gn(Jt,{},So)}),
|
|
53
|
+
/* @__PURE__ */Gn(sn,{canvas:xo,session:Xl,model:as,measure:us,canDrop:hs,onDrop:gs,choose:Ql,onPick:Ss,onZoneAdd:ks,onSeamAdd:ks,zoneAddLabel:Lt.canvasAddBlock,words:Rt.canvas,readOnly:Boolean(pt),revision:St.data}),Lo.length>0&&/* @__PURE__ */Gn("div",{className:"sf-preview-gaps",children:Lo.map(e=>
|
|
54
|
+
/* @__PURE__ */Gn(dn,{index:e.index,label:Lt.addSectionHere,onInsert:()=>Zi(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))})]})}),Ol?/* @__PURE__ */Gn(Xn,{canvas:xo,tabs:os,onSelect:e=>{const n=oi.findIndex(n=>String(n.props.id)===e);n>=0&&Gi(n)}}):null]})]}),eo?/* @__PURE__ */Jn(Un,{children:[
|
|
55
|
+
/* @__PURE__ */Gn(y,{value:{selectChild:vl,addChild:bl,childRowName:Oi,blockRowName:Rl},children:/* @__PURE__ */Gn(Ut,{mode:Ro,onOpenWebsiteSettings:nr.openSettings??(()=>{}),onOpenSiteStyles:nr.openStyles,onSelectNode:yr,onNotify:Lr,onHidePanel:_r,nodeActions:bt?ue(wt,bt.type):nt})}),
|
|
56
|
+
/* @__PURE__ */Gn(Xe,{side:"right",width:Cr.right,min:qe,max:Ze,defaultWidth:k.right,label:Lt.resizeSettingsPanel,onResize:Pr})]}):
|
|
57
|
+
/* @__PURE__ */Gn(L,{side:"right",onShow:_r})]}),Ei.menu]})}))}export{tt as ScreenChrome};
|
|
@@ -1,11 +1,11 @@
|
|
|
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,clickPick as a}from"./chunk-ECM5F6JJ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-IL6QCPO6.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f,drawnBox as h}from"./chunk-ILXP5VX5.js";import{find as m,ROOT_ID as g,getList as v,remove as y,parseZoneKey as w,move as k,duplicate as b,replaceNode as S,createNode as I,insert as C,normalizeData as E,createResolveCache as x,resolveNodeData as D,ROOT_SLOT as O}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as P,fieldsFrom as A,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as z,useEffect as K,useContext as N,useRef as $,useSyncExternalStore as j,useState as B,useMemo as L,useCallback as R,useLayoutEffect as Z}from"react";import{jsx as V,jsxs as F}from"react/jsx-runtime";import{createPortal as T}from"react-dom";import{FloatingBar as H,TextToolbar as Y}from"efficient-shell/ui";function W(e){return!["setData","setUi","set"].includes(e.type)}var X=(e,t,n,o)=>{const r=v(e,t,w(n));return r?.[o]??null},q=(e,t,n,o,r)=>{const i=X(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function U(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 J(e,t,n){return n?"node"===n.kind?m(e,t,n.id)?n:null:n.parentId===g?v(e,t,n)?n:null:m(e,t,n.parentId)&&v(e,t,n)?n:null:null}function Q(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=_(e,t,n);if(o===e)return e;const r=J(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function _(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 Q(e,n,"function"==typeof t.ui?t.ui(U(e,n)):t.ui);case"set":{const r={data:o,ui:U(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...w(t.destinationZone),index:t.destinationIndex},i=I(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:C(o,n,r,i)}}case"replace":{const r=q(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:S(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=q(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=b(o,n,r.props.id),a=X(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return _(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=X(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...w(t.destinationZone),index:t.destinationIndex};return{...e,data:k(o,n,r.props.id,i)}}case"remove":{const r=q(o,n,t.zone,t.index,"remove");return{...e,data:y(o,n,r.props.id)}}default:return e}}var ee={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},te={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ne=0,oe=()=>`history-${ne+=1}`;function re(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=E(e.data,t);let l={data:s,selection:null,ui:{...te}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...te,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:oe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,g=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},b=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{g>0?w=w||n:(n?u(!1):l!==t&&b(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},C=e=>{const n=l;if(l=G(l,e,t),l===n)return;const o=e.recordHistory??W(e);I(n,o&&l.data!==n.data)},O=t=>{0===g&&(y=l,w=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(l=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&b(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},P=e=>{const n=l,o=J(l.data,t,e);var r,i;(r=o,i=l.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))||(l={...l,selection:o},I(n,!1))},A=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},M=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ee,...a,...n}};let z=M();const K=x(),N={resolveCache:K,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([D(r,t,{cache:K,trigger:e,metadata:n}),...i.map(o=>D(o,t,{cache:K,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=m(n,t,a)?.node;s&&s===m(o,t,a)?.node&&(n=S(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:J(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=m(l.data,t,e)?.node;if(!r)return!1;const i=await D(r,t,{cache:K,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(m(l.data,t,e)?.node!==r)return;const o=S(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:J(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&h===l)return f;const e=l,o={data:e.data,ui:U(e,t)},r="node"===e.selection?.kind?m(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:C,history:{back:()=>N.undo(),forward:()=>N.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:U(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&A(e)}},getPermissions:z,getItemById:n=>m(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return v(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}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:C,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>P(e?{kind:"node",id:e}:null),selectSlot:e=>P(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:J(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=E(e,t);l={...l,data:r,selection:J(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0),l!==o&&k()},undo(){d>0&&A(d-1)},redo(){d<c.length-1&&A(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=M(),f=null,k())},setConfig(e){e!==t&&(t=e,z=M(),f=null,k())}};return N}function ie(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(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 ae=z(null),se=z(!0);function le({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return K(()=>{n&&e.resolveAll()},[e,n]),K(()=>{if(t&&"undefined"!=typeof document)return ie(document,e)},[e,t]),/* @__PURE__ */V(ae.Provider,{value:e,children:/* @__PURE__ */V(se.Provider,{value:t,children:o})})}function ce(){const e=N(ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function de(e){const t=ce(),n=$({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 j(t.subscribe,o,o)}function ue(){return function(e){return de(e)}}var pe="data-puck-component",fe="data-puck-dropzone",he={},me="data-es-mirror",ge="undefined"==typeof window?K:Z;function ve(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${me}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(me,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ye({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=$(null),[h,m]=B(null);return ge(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),ge(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.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"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ve(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ve(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */V("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?T(t,h):null})}var we=z(null),ke=z(he),be=[];function Se({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=ce(),s=de(n=>v(n.appState.data,a.config,{parentId:e,slot:t})??be),l=de(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==g),c=de(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=N(we),u=["es-zone"];return s.length&&u.push("has-children"),e===g&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==g&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */V("div",{className:u.join(" "),[fe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */V(Ee,{node:e},e.props.id))})}function Ie(e,t){return L(()=>{const n={};for(const o of P(A(e)))n[o]=function(e={}){/* @__PURE__ */
|
|
2
|
-
return
|
|
3
|
-
return
|
|
4
|
-
return
|
|
5
|
-
return
|
|
6
|
-
return
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
9
|
-
/* @__PURE__ */
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
return
|
|
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,clickPick as a}from"./chunk-ECM5F6JJ.js";import{startCanvasTyping as s,textMap as l}from"./chunk-TJ6NRHYF.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f,drawnBox as h}from"./chunk-ILXP5VX5.js";import{find as m,ROOT_ID as g,getList as v,remove as y,parseZoneKey as w,move as k,duplicate as b,replaceNode as S,createNode as I,insert as C,normalizeData as E,createResolveCache as x,resolveNodeData as D,ROOT_SLOT as O}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as A,fieldsFrom as M,defaultsFrom as P}from"./chunk-NKB3KVAB.js";import{createContext as z,useEffect as N,useContext as K,useRef as R,useSyncExternalStore as $,useState as j,useMemo as B,useCallback as Z,useLayoutEffect as L}from"react";import{jsx as F,jsxs as V}from"react/jsx-runtime";import{createPortal as T}from"react-dom";import{FloatingBar as H,TextToolbar as Y}from"efficient-shell/ui";function W(e){return!["setData","setUi","set"].includes(e.type)}var X=(e,t,n,o)=>{const r=v(e,t,w(n));return r?.[o]??null},q=(e,t,n,o,r)=>{const i=X(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function J(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 U(e,t,n){return n?"node"===n.kind?m(e,t,n.id)?n:null:n.parentId===g?v(e,t,n)?n:null:m(e,t,n.parentId)&&v(e,t,n)?n:null:null}function G(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function Q(e,t,n){const o=_(e,t,n);if(o===e)return e;const r=U(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function _(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 G(e,n,"function"==typeof t.ui?t.ui(J(e,n)):t.ui);case"set":{const r={data:o,ui:J(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=G(a,n,i.ui,!0)),a}case"insert":{const r={...w(t.destinationZone),index:t.destinationIndex},i=I(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:C(o,n,r,i)}}case"replace":{const r=q(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:S(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=q(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=b(o,n,r.props.id),a=X(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return _(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=X(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...w(t.destinationZone),index:t.destinationIndex};return{...e,data:k(o,n,r.props.id,i)}}case"remove":{const r=q(o,n,t.zone,t.index,"remove");return{...e,data:y(o,n,r.props.id)}}default:return e}}var ee={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},te={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ne=0,oe=()=>`history-${ne+=1}`;function re(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=E(e.data,t);let l={data:s,selection:null,ui:{...te}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...te,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:oe()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,h=null,g=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},b=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{g>0?w=w||n:(n?u(!1):l!==t&&b(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},C=e=>{const n=l;if(l=Q(l,e,t),l===n)return;const o=e.recordHistory??W(e);I(n,o&&l.data!==n.data)},O=t=>{0===g&&(y=l,w=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(l=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&b(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},A=e=>{const n=l,o=U(l.data,t,e);var r,i;(r=o,i=l.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))||(l={...l,selection:o},I(n,!1))},M=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},P=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...ee,...a,...n}};let z=P();const N=x(),K={resolveCache:N,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([D(r,t,{cache:N,trigger:e,metadata:n}),...i.map(o=>D(o,t,{cache:N,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=m(n,t,a)?.node;s&&s===m(o,t,a)?.node&&(n=S(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:U(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=m(l.data,t,e)?.node;if(!r)return!1;const i=await D(r,t,{cache:N,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(m(l.data,t,e)?.node!==r)return;const o=S(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:U(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&h===l)return f;const e=l,o={data:e.data,ui:J(e,t)},r="node"===e.selection?.kind?m(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:C,history:{back:()=>K.undo(),forward:()=>K.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:J(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&M(e)}},getPermissions:z,getItemById:n=>m(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return v(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}},h=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:C,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:U(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=E(e,t);l={...l,data:r,selection:U(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:oe()}],d=0),l!==o&&k()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,z=P(),f=null,k())},setConfig(e){e!==t&&(t=e,z=P(),f=null,k())}};return K}function ie(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(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 ae=z(null),se=z(!0);function le({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return N(()=>{n&&e.resolveAll()},[e,n]),N(()=>{if(t&&"undefined"!=typeof document)return ie(document,e)},[e,t]),/* @__PURE__ */F(ae.Provider,{value:e,children:/* @__PURE__ */F(se.Provider,{value:t,children:o})})}function ce(){const e=K(ae);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function de(e){const t=ce(),n=R({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return $(t.subscribe,o,o)}function ue(){return function(e){return de(e)}}var pe="data-puck-component",fe="data-puck-dropzone",he={},me="data-es-mirror",ge="undefined"==typeof window?N:L;function ve(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${me}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(me,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ye({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=R(null),[h,m]=j(null);return ge(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),ge(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.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"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ve(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ve(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */F("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?T(t,h):null})}var we=z(null),ke=z(he),be=[];function Se({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=ce(),s=de(n=>v(n.appState.data,a.config,{parentId:e,slot:t})??be),l=de(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==g),c=de(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=K(we),u=["es-zone"];return s.length&&u.push("has-children"),e===g&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==g&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */F("div",{className:u.join(" "),[fe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */F(Ee,{node:e},e.props.id))})}function Ie(e,t){return B(()=>{const n={};for(const o of A(M(e)))n[o]=function(e={}){/* @__PURE__ */
|
|
2
|
+
return F(Se,{parentId:t,slot:o,...e})};return n},[e,t])}function Ce(e){return B(()=>function({zone:t,...n}){/* @__PURE__ */
|
|
3
|
+
return F(Se,{parentId:e,slot:t,...n})},[e])}function Ee({node:e}){const t=ce().config.components[e.type],n=e.props.id,o=function(e){const t=R(null);return B(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(pe),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(pe,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(n),r=K(ke),i=Ie(t,n),a=Ce(n);if(!t?.render)return null;const s=t.render,l={...P(t),...e.props,...i},c={renderDropZone:a,isEditing:!0,dragRef:t.inline?o:null,metadata:{...r,...t.metadata}};return t.inline?/* @__PURE__ */F(s,{...l,puck:c,editMode:!0}):/* @__PURE__ */F("div",{[pe]:n,"data-puck-dnd":n,style:{position:"relative"},children:/* @__PURE__ */F(s,{...l,puck:c,editMode:!0})})}function xe({metadata:e}){const t=de(e=>e.config),n=de(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ie(t.root,g),i=Ce(g),a=/* @__PURE__ */F(Se,{parentId:g,slot:O}),s=o?/* @__PURE__ */F(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:a}):a;/* @__PURE__ */
|
|
4
|
+
return F(ke.Provider,{value:e??he,children:s})}var De=z(void 0);function Oe(e,t,n){const[o,r]=j(null),i=R(t);return i.current=t,ge(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const a=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=h(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)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.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),()=>{l?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Ae({id:e,kind:t,overlay:n}){const o=R(null),r=Oe(o,e?t=>t.querySelector(`[${pe}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */F("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */F(n,{componentId:e,kind:t,children:i}):i}function Me(e,t,n){const o=l(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let a=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))a=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(a=o.at(n.startContainer,n.startOffset))}if(null===a)return[r,r];const c=o.text;let d=a,u=a;for(;d>0&&!/\s/.test(c[d-1]);)d-=1;for(;u<c.length&&!/\s/.test(c[u]);)u+=1;return[d,u]}function Pe({s:e,element:t,toolbar:n,label:o}){const r=e.pressed(),i=new Set(n.offered.filter(e=>"link"!==e));/* @__PURE__ */
|
|
5
|
+
return F(H,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?p(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__ */F("div",{style:{width:"18rem"},children:/* @__PURE__ */F(Y,{offered:i,pressed:r.marks,onMark:t=>{"link"!==t&&e.press(t)},list:{pressed:r.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:r.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)})})})})}function ze({element:e}){const t=R(null),n=Oe(t,()=>e(),e);/* @__PURE__ */
|
|
6
|
+
return F("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 Ne({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:l,onDocument:d,height:u,title:p,nonce:h,hotkeys:m,frameWrapper:g,overlay:v,children:y,typing:w,passThrough:k}){const b=ce(),S=K(De),I=k??S,C=K(se),E=c("canvas",e),x=m??C,[D,O]=j(void 0),A=de(e=>"node"===e.selection?.kind?e.selection.id:null),[M,P]=j(null),[z,$]=j(null),B=R(null),[,Z]=j(0),L=R(w);L.current=w;const T=R(null),H=e=>{const t=T.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(f,{detail:{typing:e}}))},Y=(e,t)=>{B.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=b.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Me(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>Z(e=>e+1),end:e=>{o.close(),B.current?.element===r&&(B.current=null),$(null),H(!1),L.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${pe}]`)?.getAttribute(pe);return a&&b.select(a),B.current={s:i,element:r,target:e},$(()=>r),P(null),H(!0),L.current?.onChange?.({typing:!0,element:n}),!0};N(()=>()=>B.current?.s.stop("stop"),[]);const W=e=>{const t=B.current?.element();return Boolean(t&&t.contains(e))},X=e=>{const t=e.closest?.(`[${pe}]`)?.getAttribute(pe);if(!t)return;const n=b.getState(),o="node"===n.selection?.kind?n.selection.id:null;return a(n.appState.data,b.config,t,o,I)??t},q=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(B.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=L.current?.atSelection?.();n&&Y(n,null)&&e.preventDefault()},J=/* @__PURE__ */V("div",{ref:T,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),B.current){if(W(t))return;B.current.s.stop("outside")}const n=X(t);void 0===n?t.hasAttribute?.(fe)||b.select(null):b.select(n)},onDoubleClick:e=>{const t=L.current;if(!t||W(e.target))return;const n=t.at(e.target);n&&Y(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>q(e),onMouseOver:e=>{if(B.current)return;const t=X(e.target)??null;t!==M&&P(t)},onMouseLeave:()=>P(null),children:[
|
|
7
|
+
/* @__PURE__ */F(we.Provider,{value:M,children:/* @__PURE__ */F(xe,{metadata:r})}),
|
|
8
|
+
/* @__PURE__ */V("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
9
|
+
/* @__PURE__ */F(Ae,{id:!z&&M&&M!==A?M:null,kind:"hover",overlay:v}),
|
|
10
|
+
/* @__PURE__ */F(Ae,{id:z?null:A,kind:"selected",overlay:v}),z?/* @__PURE__ */F(ze,{element:z}):null]}),y]}),U=g?/* @__PURE__ */F(g,{document:D,children:J}):J;N(()=>{if(D&&x)return ie(D,b)},[D,x,b]),N(()=>{if(!D)return;const e=e=>{if("Enter"===e.key)return void q(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=b.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,b.config,n.selection);"node"===o?.kind&&b.select(o.id)};return D.addEventListener("keydown",e),()=>D.removeEventListener("keydown",e)},[D,b]);/* @__PURE__ */
|
|
11
|
+
return V("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":z?"":void 0,children:[z&&B.current?.target.toolbar?/* @__PURE__ */F(Pe,{s:B.current.s,element:B.current.element,toolbar:B.current.target.toolbar,label:E.textTools}):null,t?/* @__PURE__ */F(ye,{mirrorStyles:l,onDocument:e=>{O(e??void 0),d?.(e)},height:u,title:p,nonce:h,children:U}):/* @__PURE__ */F("div",{id:"preview-frame","data-puck-entry":"",children:U})]})}function Ke(e={}){const t=ce(),n=de(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function Re(){const e=ce(),n=de(e=>e.config),o=e.resolveCache,r=de(e=>e.selectedItem),i=de(e=>e.appState.data.root),a=r?r.props.id:"root",s=i.props??{},l=B(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?m(d.appState.data,n,a):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:a,node:l,block:c,parent:f,appState:d.appState}),g=de(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),v=Z(t=>{(async()=>{const r=e.getState();if("root"!==a){const i=r.getItemById(a),s=r.getSelectorForId(a);if(!i||!s)return;const l={...i,props:{...i.props,...t}},{node:c}=await D(l,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(a);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 D({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,a]),y=Z((e,t)=>v({[e]:t}),[v]);return{id:a,node:l,fields:h,values:l.props,readOnly:g,onChange:y,onChangeMany:v}}export{ye as CanvasFrame,De as CanvasPassThroughContext,te as DEFAULT_UI,Ne as EaselCanvas,le as EaselProvider,xe as EditDocument,ie as bindUndoKeys,re as createEasel,ue as createUseEasel,W as recordsByDefault,Q as reduce,J as uiView,de as useEasel,ce as useEaselApi,Ke as useEaselNodeOps,Re as useSelectedFields,U as validSelection};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-BPMLHWWM.js";import{decodePartId as e,encodePartId as r}from"./chunk-IYT6NN2J.js";import{usePreviewParts as t}from"./chunk-I54UCYOU.js";import{SELECTION_MODE as n}from"./chunk-EVY5SXFW.js";import{useEasel as p}from"./chunk-PE6ZY5IW.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:I}){const{getSelectorForId:a}=p(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=t(),l=d(o=>{const r=e(o);if(!r)return;const{nodeId:t,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===t&&o.propKey===p?o:{kind:"part",nodeId:t,propKey:p}),I?.(t)):i(o=>"part"===o.kind?n:o)},[i,I]);c(()=>{k(l)},[k,l]);const h=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>n);const e=a(o);e&&u.select(e)},[i,a,u]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,listIn as s,setList as a,isSafeLinkHref as c}from"./chunk-546BBOPE.js";var u=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),d=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function h(l,o){const i=o.rules??t,s=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.createElement("template");i.innerHTML=t;const s=[[]],a=()=>s[s.length-1],h=()=>{const t=a();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&s.push([])},p=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=a();" "===t&&(0===o.length&&s.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(u.has(o))return;if("br"===o)return void s.push([]);let i=e,f=n,m=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(f=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();m=c(t)?t:null}const g=1===t.nodeType?l.style:null;if(g){const t=g.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===g.fontStyle||"oblique"===g.fontStyle?f=!0:"normal"===g.fontStyle&&(f=!1)}const b=d.has(o);b&&h();for(const e of[...t.childNodes])p(e,i,f,m);b&&h()};p(i.content,!1,!1,null);for(;s.length>1&&0===s[s.length-1].length;)s.pop();return s.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const s of i){const i=f(t,s.bold?o("bold"):null,s.italic?o("italic"):null,s.links),a=e([i]).text;if(n([i],r(a,l)))return a}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?s.join("\n"):1===s.length?s[0]:s.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function f(t,e,n,r){let o=0,i=null,s=null,a=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),s=e?.[c]?s??l(++o,"bold"):null,a=n?.[c]?a??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,s,a].filter(t=>null!==t)}})}}var p="application/x-efficient-markup",m=/^([0-9]{1,3})\. $/;function g(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const s=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:m.exec(n[e]),s=t.bullet||r,a=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=a?a.length+2:s?2:0,h={bullet:s,number:a,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:s,text:s.map(t=>t.text).join("\n")}}function b(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function k(t,e){const[n,r]=b(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function x(t,e){const[n,r]=b(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return k(t,e)}function v(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function y(t,e,n){return[v(t,e),v(t,n)]}function w(t,e,n){return e===n?[k(t,e),k(t,e)]:[x(t,e),k(t,n)]}function D(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function T(t,o,i,s,a){const c=g(t,o),[u,d,h]=b(c,Math.min(i,s)),[f,p,m]=b(c,Math.max(i,s)),k=D(u,d),x=D(f,p),v=u.chars.slice(0,k),y=f.chars.slice(x),w=i!==s&&u.chars[k]&&(h!==m||k<x)?u.chars[k].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(u,k);let T=(A=c.lines,Math.max(0,...A.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var A;const S=t=>{let e;if(void 0!==a.markup){const t=T;e=r(a.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(a.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:u.bullet,number:u.number??null,chars:[...v,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...y]}}else l.chars.push(...y);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},E=void 0!==a.markup?[null]:[(t=>{let e=t.filter(t=>!a.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of a.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(T++,t);n&&(e=[...e,n])}if(void 0!==a.color){e=e.filter(t=>"color"!==t.kind);const t=null===a.color?null:l(T++,"color",a.color);t&&(e=[...e,t])}return e})(w),w,[]];let M="",N="";for(const t of E){const r=S(t),l=e(r.lines).text;if(M=l,N=r.shown,n(r.lines,g(l,o).lines))break}return{text:M,caret:Math.min(i,s)+N.length}}function A(t,e,n,r){const l=g(t,e),[o,,i]=b(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?T(t,e,n,r,{text:"\n"}):S(t,e,i,!1,n)}function S(t,n,r,l,o){const i=g(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function E(t,n,r,l){const o=g(t,n),[i,s,a]=b(o,Math.min(r,l)),[c,u,d]=b(o,Math.max(r,l)),h=o.lines.slice(a,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?D(i,s):0,o=r===d-a?D(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(h).text}function M(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function N(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,s]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,s]=t.target);const a=[i,s];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:A(e,n,i,s),range:a}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let c=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=h({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:T(e,n,i,s,{markup:l}),range:a}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:T(e,n,i,s,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:a}}if(l.startsWith("delete")){const t=g(e,n),r=t.text;if(i===s){const o=l.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:S(e,n,c,!1,i),range:a};if(o?0===i:i===r.length)return null;o?i=M(r,i,-1):s=M(r,s,1)}return{kind:"type",edit:T(e,n,i,s,{text:""}),range:[i,s]}}return null}var B=1e3;function C(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,s){const a="type"===i&&"type"===r&&s-l<1e3;r=i,l=s,n=[],a||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var j={sup:"sub",sub:"sup"};function q(t){const{value:e,rules:n,start:r,end:l,style:s,pending:a}=t,c=j[s];if(r===l){const t=o(e,r,l,n),i=a&&a.at===r?a:null,u=t.has(s),d=!!i?.add.includes(s)||!i?.drop.includes(s)&&u;let h=(i?.add??[]).filter(t=>t!==s),f=(i?.drop??[]).filter(t=>t!==s);return d&&u?f.push(s):d||u||h.push(s),!d&&c&&(h=h.filter(t=>t!==c),t.has(c)&&(f=[...f.filter(t=>t!==c),c])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:r}:null}}let u=e,d=r,h=l;if(c&&!o(u,d,h,n).has(s)&&o(u,d,h,n).has(c)){const t=i(u,d,h,c,n);({text:u,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(u,d,h,s,n)}}var F=/^(block|list-item|flex|grid|table|flow-root)$/;function L(t){const e=t.ownerDocument.defaultView;return!!e&&F.test(e.getComputedStyle(t).display)}function O(t,e){const n=[],r=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let o="",i=!1;const s=()=>{i&&(o+="\n",i=!1)},a=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&s(),r.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,l.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){r.set(t,o.length),l.set(t,o.length);continue}if("BR"===t.tagName){s(),r.set(t,o.length),o+="\n",l.set(t,o.length);continue}const u=L(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),r.set(t,o.length);const d=o.length;a(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),l.set(t,o.length),u&&(i=!0)}};r.set(t,0),a(t),l.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(r.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?r.get(n[e])??l.get(t)??0:l.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const r=n[t],l=r.start+r.length;if(e<r.start)return[r.node,0];if(e<l||e===l&&(t===n.length-1||n[t+1].start>e))return 3===r.node.nodeType?[r.node,e-r.start]:[r.node,0]}const r=n[n.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function P(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(O(e,t.skip).text!==g(n,r).text)return null;const l=t.now??(()=>Date.now()),i=C();let c=e,u=!1,d=null,f=null,m=[t.caret[0],t.caret[1]],b=null,k=!1;const x=()=>t.onSelect?.(),v={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},D=()=>c.ownerDocument,A=()=>D().defaultView?.getSelection()??null,S=()=>{if(!f)return!0;Q();const e=O(c,t.skip);if(e.text!==g(n,r).text)return!1;const[l,o]=f,[i,s]=e.dom(l),[a,u]=e.dom(o);return D().activeElement!==c&&c.focus({preventScroll:!0}),A()?.setBaseAndExtent(i,s,a,u),m=f,M=f,f=null,x(),!0};let M=null;const B=()=>{if(!M)return!1;const t=A(),e=t?.anchorNode??null;return!(e&&e.isConnected&&c.contains(e))||e===c&&0===t.anchorOffset&&(0!==M[0]||0!==M[1])},j=()=>{f=M,S()},F=()=>{S(),D().activeElement===c&&B()&&j();const e=A();if(!(e&&e.anchorNode&&e.focusNode&&c.contains(e.anchorNode)&&c.contains(e.focusNode)))return m;const n=O(c,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return m=r<=l?[r,l]:[l,r],m},L=t=>{const e=D().defaultView;t<=0||!e?M=null:e.requestAnimationFrame(()=>{u||f||(Q(),D().activeElement===c?(B()&&(j(),x()),L(t-1)):M=null)})},P=(t,e)=>{f=[t,e];const n=t=>{if(u)return;if(S())return void L(3);const e=D().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},V=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),P(e.caret,e.caret),x()):P(e.caret,e.caret)},W=t=>w(g(n,r),t[0],t[1]),I=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[s,a]=y(g(n,r),e.selectionStart,e.selectionEnd);P(s,a),x()},K=t=>{if(u)return;const e=F(),[l,o]=W(e),i=q({value:n,rules:r,start:l,end:o,style:t,pending:b});if("pending"===i.kind)return b=i.pending,void x();I(i.result,e)},R=e=>{n=e.text,t.write(n),P(e.start,e.end)},U=e=>{u||(u=!0,X.removeEventListener("selectionchange",Y),J(c),t.end(e))},$=(t,e)=>{const l=F();!u&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",g(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(p,E(n,r,l[0],l[1])),e&&V(T(n,r,l[0],l[1],{text:""}),l,"edit"))},z=t=>t.preventDefault(),H=()=>{t.remount?.()},Z=[["keydown",t=>{if(u||t.isComposing)return;const e=t.metaKey||t.ctrlKey;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void U("escape");if("Enter"===t.key&&(!t.shiftKey||e))return t.preventDefault(),t.stopPropagation(),void U("enter");if(e&&("z"===t.key||"Z"===t.key||"y"===t.key)){t.preventDefault(),t.stopPropagation();const e=F(),r={text:n,start:e[0],end:e[1]},l="y"===t.key||t.shiftKey?i.redo(r):i.undo(r);l&&R(l)}}],["beforeinput",e=>{if(u)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=F(),o=O(c,t.skip),s="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,a=s&&!s.collapsed?[o.at(s.startContainer,s.startOffset),o.at(s.endContainer,s.endOffset)]:null,d=N({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:D(),sel:l,target:a,pending:b&&b.at===W(l)[0]?b:null});if(d){if("type"!==d.kind&&"edit"!==d.kind||(b=null),"history"===d.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===d.dir?i.undo(t):i.redo(t);return void(e&&R(e))}"format"!==d.kind?V(d.edit,d.range,d.kind):K(d.style)}}],["compositionstart",()=>{d=F()}],["compositionend",e=>{const o=d;if(d=null,!u&&o)if(e.data){const s=T(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=s.text,t.write(n),H(),P(s.caret,s.caret)}else H(),P(o[0],o[0])}],["paste",e=>{if(u)return;e.preventDefault();const l=F(),o=e.clipboardData,i=o?.getData(p)??"",s=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):h({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:D(),multiline:t.multiline,rules:r});V(T(n,r,l[0],l[1],{markup:s}),l,"edit")}],["copy",t=>$(t,!1)],["cut",t=>$(t,!0)],["drop",z],["dragstart",z],["blur",e=>{if(u||null!==d||k)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{u||(n.isConnected&&n===t.element()?k||n.ownerDocument.activeElement===n||U("blur"):P(m[0],m[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}],["focus",()=>{k=!1}]];function G(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of Z)t.addEventListener(e,n)}function J(t){for(const[e,n]of Z)t.removeEventListener(e,n);null===v.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",v.contenteditable),null===v.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",v.spellcheck),t.removeAttribute("data-es-typing")}function Q(){const e=t.element();e&&e!==c&&(J(c),c=e,G(c))}const X=c.ownerDocument;function Y(){u||x()}return X.addEventListener("selectionchange",Y),G(c),c.focus({preventScroll:!0}),P(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=g(t,r).text.length,[l,o]=F();n=t,i.reset(),P(Math.min(l,e),Math.min(o,e))},stop(t="stop"){U(t)},pressed(){const[t,e]=W(F()),l=o(n,t,e,r),i={};for(const e of["bold","italic","underline","strike","sup","sub","link"]){const n=l.has(e),r=b&&b.at===t?b:null;i[e]=!!r?.add.includes(e)||!r?.drop.includes(e)&&n}return{marks:i,list:s(n,t,e,r),selected:e>t}},press:K,insert(t){if(u)return;k=!1;const e=F(),[r,l]=W(e),o=r+t.length;I({text:n.slice(0,r)+t+n.slice(l),selectionStart:o,selectionEnd:o},e),Q(),c.focus({preventScroll:!0})},hold(){u||(k=!0)},list(e){if(u||!t.multiline)return;const l=F(),[o,i]=W(l),c=s(n,o,i,r);I(a(n,o,i,c===e?null:e,r),l)}}}export{p as MARKUP_CLIPBOARD_TYPE,B as TYPING_BURST_MS,C as createHistory,T as editVisible,q as markPress,E as markupOfRange,A as newLine,h as pasteToMarkup,N as richInput,g as richLayout,w as selectionToSource,y as selectionToVisible,S as setBullet,P as startCanvasTyping,O as textMap,k as toSource,x as toSourceStart,v as toVisible};
|
|
1
|
+
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,listIn as s,setList as a,isSafeLinkHref as c}from"./chunk-546BBOPE.js";var u=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),d=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function h(l,o){const i=o.rules??t,s=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.createElement("template");i.innerHTML=t;const s=[[]],a=()=>s[s.length-1],h=()=>{const t=a();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&s.push([])},p=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=a();" "===t&&(0===o.length&&s.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(u.has(o))return;if("br"===o)return void s.push([]);let i=e,f=n,m=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(f=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();m=c(t)?t:null}const g=1===t.nodeType?l.style:null;if(g){const t=g.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===g.fontStyle||"oblique"===g.fontStyle?f=!0:"normal"===g.fontStyle&&(f=!1)}const b=d.has(o);b&&h();for(const e of[...t.childNodes])p(e,i,f,m);b&&h()};p(i.content,!1,!1,null);for(;s.length>1&&0===s[s.length-1].length;)s.pop();return s.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const s of i){const i=f(t,s.bold?o("bold"):null,s.italic?o("italic"):null,s.links),a=e([i]).text;if(n([i],r(a,l)))return a}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?s.join("\n"):1===s.length?s[0]:s.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function f(t,e,n,r){let o=0,i=null,s=null,a=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),s=e?.[c]?s??l(++o,"bold"):null,a=n?.[c]?a??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,s,a].filter(t=>null!==t)}})}}var p="application/x-efficient-markup",m=/^([0-9]{1,3})\. $/;function g(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const s=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:m.exec(n[e]),s=t.bullet||r,a=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=a?a.length+2:s?2:0,h={bullet:s,number:a,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:s,text:s.map(t=>t.text).join("\n")}}function b(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function k(t,e){const[n,r]=b(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function x(t,e){const[n,r]=b(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return k(t,e)}function v(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function y(t,e,n){return[v(t,e),v(t,n)]}function w(t,e,n){return e===n?[k(t,e),k(t,e)]:[x(t,e),k(t,n)]}function D(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function T(t,o,i,s,a){const c=g(t,o),[u,d,h]=b(c,Math.min(i,s)),[f,p,m]=b(c,Math.max(i,s)),k=D(u,d),x=D(f,p),v=u.chars.slice(0,k),y=f.chars.slice(x),w=i!==s&&u.chars[k]&&(h!==m||k<x)?u.chars[k].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(u,k);let T=(A=c.lines,Math.max(0,...A.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var A;const S=t=>{let e;if(void 0!==a.markup){const t=T;e=r(a.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(a.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:u.bullet,number:u.number??null,chars:[...v,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...y]}}else l.chars.push(...y);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},E=void 0!==a.markup?[null]:[(t=>{let e=t.filter(t=>!a.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of a.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(T++,t);n&&(e=[...e,n])}if(void 0!==a.color){e=e.filter(t=>"color"!==t.kind);const t=null===a.color?null:l(T++,"color",a.color);t&&(e=[...e,t])}return e})(w),w,[]];let M="",N="";for(const t of E){const r=S(t),l=e(r.lines).text;if(M=l,N=r.shown,n(r.lines,g(l,o).lines))break}return{text:M,caret:Math.min(i,s)+N.length}}function A(t,e,n,r){const l=g(t,e),[o,,i]=b(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?T(t,e,n,r,{text:"\n"}):S(t,e,i,!1,n)}function S(t,n,r,l,o){const i=g(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function E(t,n,r,l){const o=g(t,n),[i,s,a]=b(o,Math.min(r,l)),[c,u,d]=b(o,Math.max(r,l)),h=o.lines.slice(a,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?D(i,s):0,o=r===d-a?D(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(h).text}function M(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function N(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,s]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,s]=t.target);const a=[i,s];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:A(e,n,i,s),range:a}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let c=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=h({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:T(e,n,i,s,{markup:l}),range:a}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:T(e,n,i,s,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:a}}if(l.startsWith("delete")){const t=g(e,n),r=t.text;if(i===s){const o=l.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:S(e,n,c,!1,i),range:a};if(o?0===i:i===r.length)return null;o?i=M(r,i,-1):s=M(r,s,1)}return{kind:"type",edit:T(e,n,i,s,{text:""}),range:[i,s]}}return null}var B=1e3;function C(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,s){const a="type"===i&&"type"===r&&s-l<1e3;r=i,l=s,n=[],a||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var j={sup:"sub",sub:"sup"};function q(t){const{value:e,rules:n,start:r,end:l,style:s,pending:a}=t,c=j[s];if(r===l){const t=o(e,r,l,n),i=a&&a.at===r?a:null,u=t.has(s),d=!!i?.add.includes(s)||!i?.drop.includes(s)&&u;let h=(i?.add??[]).filter(t=>t!==s),f=(i?.drop??[]).filter(t=>t!==s);return d&&u?f.push(s):d||u||h.push(s),!d&&c&&(h=h.filter(t=>t!==c),t.has(c)&&(f=[...f.filter(t=>t!==c),c])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:r}:null}}let u=e,d=r,h=l;if(c&&!o(u,d,h,n).has(s)&&o(u,d,h,n).has(c)){const t=i(u,d,h,c,n);({text:u,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(u,d,h,s,n)}}var F=/^(block|list-item|flex|grid|table|flow-root)$/;function L(t){const e=t.ownerDocument.defaultView;return!!e&&F.test(e.getComputedStyle(t).display)}function O(t,e){const n=[],r=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let o="",i=!1;const s=()=>{i&&(o+="\n",i=!1)},a=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&s(),r.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,l.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){r.set(t,o.length),l.set(t,o.length);continue}if("BR"===t.tagName){s(),r.set(t,o.length),o+="\n",l.set(t,o.length);continue}const u=L(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),r.set(t,o.length);const d=o.length;a(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),l.set(t,o.length),u&&(i=!0)}};r.set(t,0),a(t),l.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(r.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?r.get(n[e])??l.get(t)??0:l.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const r=n[t],l=r.start+r.length;if(e<r.start)return[r.node,0];if(e<l||e===l&&(t===n.length-1||n[t+1].start>e))return 3===r.node.nodeType?[r.node,e-r.start]:[r.node,0]}const r=n[n.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function P(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(O(e,t.skip).text!==g(n,r).text)return null;const l=t.now??(()=>Date.now()),i=C();let c=e,u=!1,d=null,f=null,m=[t.caret[0],t.caret[1]],b=null,k=!1;const x=()=>t.onSelect?.(),v={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},D=()=>c.ownerDocument,A=()=>D().defaultView?.getSelection()??null,S=()=>{if(!f)return!0;Q();const e=O(c,t.skip);if(e.text!==g(n,r).text)return!1;const[l,o]=f,[i,s]=e.dom(l),[a,u]=e.dom(o);return D().activeElement!==c&&c.focus({preventScroll:!0}),A()?.setBaseAndExtent(i,s,a,u),m=f,M=f,f=null,x(),!0};let M=null;const B=()=>{if(!M)return!1;const t=A(),e=t?.anchorNode??null;return!(e&&e.isConnected&&c.contains(e))||e===c&&0===t.anchorOffset&&(0!==M[0]||0!==M[1])},j=()=>{f=M,S()},F=()=>{S(),D().activeElement===c&&B()&&j();const e=A();if(!(e&&e.anchorNode&&e.focusNode&&c.contains(e.anchorNode)&&c.contains(e.focusNode)))return m;const n=O(c,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return m=r<=l?[r,l]:[l,r],m},L=t=>{const e=D().defaultView;t<=0||!e?M=null:e.requestAnimationFrame(()=>{u||f||(Q(),D().activeElement===c?(B()&&(j(),x()),L(t-1)):M=null)})},P=(t,e)=>{f=[t,e];const n=t=>{if(u)return;if(S())return void L(3);const e=D().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},V=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),P(e.caret,e.caret),x()):P(e.caret,e.caret)},W=t=>w(g(n,r),t[0],t[1]),I=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[s,a]=y(g(n,r),e.selectionStart,e.selectionEnd);P(s,a),x()},K=t=>{if(u)return;const e=F(),[l,o]=W(e),i=q({value:n,rules:r,start:l,end:o,style:t,pending:b});if("pending"===i.kind)return b=i.pending,void x();I(i.result,e)},R=e=>{n=e.text,t.write(n),P(e.start,e.end)},U=e=>{u||(u=!0,X.removeEventListener("selectionchange",Y),J(c),t.end(e))},$=(t,e)=>{const l=F();!u&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",g(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(p,E(n,r,l[0],l[1])),e&&V(T(n,r,l[0],l[1],{text:""}),l,"edit"))},z=t=>t.preventDefault(),H=()=>{t.remount?.()},Z=[["keydown",t=>{if(u||t.isComposing)return;const e=t.metaKey||t.ctrlKey;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void U("escape");if("Enter"===t.key&&(!t.shiftKey||e))return t.preventDefault(),t.stopPropagation(),void U("enter");if(e&&("z"===t.key||"Z"===t.key||"y"===t.key)){t.preventDefault(),t.stopPropagation();const e=F(),r={text:n,start:e[0],end:e[1]},l="y"===t.key||t.shiftKey?i.redo(r):i.undo(r);l&&R(l)}}],["beforeinput",e=>{if(u)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=F(),o=O(c,t.skip),s="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,a=s&&!s.collapsed?[o.at(s.startContainer,s.startOffset),o.at(s.endContainer,s.endOffset)]:null,d=N({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:D(),sel:l,target:a,pending:b&&b.at===W(l)[0]?b:null});if(d){if("type"!==d.kind&&"edit"!==d.kind||(b=null),"history"===d.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===d.dir?i.undo(t):i.redo(t);return void(e&&R(e))}"format"!==d.kind?V(d.edit,d.range,d.kind):K(d.style)}}],["compositionstart",()=>{d=F()}],["compositionend",e=>{const o=d;if(d=null,!u&&o)if(e.data){const s=T(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=s.text,t.write(n),H(),P(s.caret,s.caret)}else H(),P(o[0],o[0])}],["paste",e=>{if(u)return;e.preventDefault();const l=F(),o=e.clipboardData,i=o?.getData(p)??"",s=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):h({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:D(),multiline:t.multiline,rules:r});V(T(n,r,l[0],l[1],{markup:s}),l,"edit")}],["copy",t=>$(t,!1)],["cut",t=>$(t,!0)],["drop",z],["dragstart",z],["blur",e=>{if(u||null!==d||k)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{u||(n.isConnected&&n===t.element()?k||n.ownerDocument.activeElement===n||U("blur"):P(m[0],m[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}],["focus",()=>{k=!1}]];function G(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of Z)t.addEventListener(e,n)}function J(t){for(const[e,n]of Z)t.removeEventListener(e,n);null===v.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",v.contenteditable),null===v.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",v.spellcheck),t.removeAttribute("data-es-typing")}function Q(){const e=t.element();e&&e!==c&&(J(c),c=e,G(c))}const X=c.ownerDocument;function Y(){u||x()}return X.addEventListener("selectionchange",Y),G(c),c.focus({preventScroll:!0}),P(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=g(t,r).text.length,[l,o]=F();n=t,i.reset(),P(Math.min(l,e),Math.min(o,e))},stop(t="stop"){U(t)},pressed(){const[t,e]=W(F()),l=o(n,t,e,r),i={};for(const e of["bold","italic","underline","strike","sup","sub","link"]){const n=l.has(e),r=b&&b.at===t?b:null;i[e]=!!r?.add.includes(e)||!r?.drop.includes(e)&&n}return{marks:i,list:s(n,t,e,r),selected:e>t}},press:K,insert(t){if(u)return;k=!1;const e=F(),[r,l]=W(e),o=r+t.length;I({text:n.slice(0,r)+t+n.slice(l),selectionStart:o,selectionEnd:o},e),Q(),c.focus({preventScroll:!0})},hold(){u||(F(),k=!0)},list(e){if(u||!t.multiline)return;const l=F(),[o,i]=W(l),c=s(n,o,i,r);I(a(n,o,i,c===e?null:e,r),l)}}}export{p as MARKUP_CLIPBOARD_TYPE,B as TYPING_BURST_MS,C as createHistory,T as editVisible,q as markPress,E as markupOfRange,A as newLine,h as pasteToMarkup,N as richInput,g as richLayout,w as selectionToSource,y as selectionToVisible,S as setBullet,P as startCanvasTyping,O as textMap,k as toSource,x as toSourceStart,v as toVisible};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-535CJ7J4.js";import{ScreenChrome as e}from"./chunk-MMAC2VER.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-THZ46DC5.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-JTUUIVBZ.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(n),k=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const 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 N=(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 y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
+
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function H({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),H=t(()=>s(!g),[g]),M=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:M.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(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:M.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:M.waitingForAuthorization})}export{H as DocumentScreen,y as ScreenMount};
|