@frontify/guideline-blocks-settings 2.1.7 → 2.1.9

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/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),o=require("@frontify/fondue/rte"),X=require("@frontify/app-bridge"),u=require("react"),I=require("@dnd-kit/core"),Rn=require("@dnd-kit/modifiers"),pt=require("@dnd-kit/sortable"),U=require("@frontify/fondue"),h=require("@frontify/fondue/components"),k=require("@frontify/fondue/icons"),Dn=require("@react-aria/focus"),ft=require("react-dom"),_=require("@ctrl/tinycolor"),$=t=>t.filter(Boolean).join(" "),Mn=({onDrop:t,label:e,icon:n,secondaryLabel:r,isLoading:a,fillParentContainer:i,onAssetChooseClick:c,onUploadClick:d,withMenu:l=!0,onClick:p,validFileType:w,verticalLayout:g})=>{const[f,v]=u.useState(!1),[x,S]=u.useState(),N=u.useRef(null),[A,L]=u.useState(void 0),H=C=>{if(C.preventDefault(),v(!1),!D(C.dataTransfer.files)){L("Invalid"),setTimeout(()=>{L(void 0)},1e3);return}t?.(C.dataTransfer.files)},D=C=>{if(!w)return!0;for(let M=0;M<C.length;M++){const W=C[M].name.split(".").pop()??"";if(!X.FileExtensionSets[w].includes(W))return!1}return!0},F=C=>{if(!N.current||a)return;const{clientX:M,clientY:W}=C,lt=M===0&&W===0,{left:gt,top:Pt,width:It,height:mt}=N.current.getBoundingClientRect(),ht=lt?It/2:M-gt,z=lt?mt/2:W-Pt;S([ht,z])},j=u.useCallback(C=>{C(),S(void 0)},[]),Tt=u.useMemo(()=>{const C=[];return d&&C.push({onSelect:()=>j(d),title:"Upload asset",icon:s.jsx(k.IconArrowCircleUp,{size:"20"})}),c&&C.push({onSelect:()=>j(c),title:"Browse asset",icon:s.jsx(k.IconImageStack,{size:"20"})}),C},[c,d,j]);return s.jsxs("button",{ref:N,"data-test-id":"block-inject-button",className:$(["tw-body-medium tw-relative tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",g?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",i?"tw-h-full":"tw-h-[72px]",f&&!a?"tw-border-dashed":"tw-border-solid",x&&"tw-bg-blank-state-pressed-inverse",f&&"tw-bg-blank-state-weak-inverse",A?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",a||x||f||A?"":"tw-text-secondary hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",(f||x)&&!A?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:t?C=>{if(v(!0),w==="Images")for(const M of Array.from(C.dataTransfer.items))M?.type?.startsWith("image/")?L(void 0):L("Invalid")}:void 0,onDragOver:t?C=>{C.preventDefault()}:void 0,onDragLeave:t?()=>{v(!1),L(void 0)}:void 0,onDrop:t?H:void 0,onClick:C=>{l&&!x&&F(C),p?.()},children:[a?s.jsx(h.LoadingCircle,{}):A?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(k.IconExclamationMarkTriangle,{size:"16"}),A]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(e||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&s.jsx("div",{className:"tw-font-medium",children:e}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),x&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:x[0],top:x[1]},children:s.jsxs(h.Flyout.Root,{open:!0,onOpenChange:C=>!C&&S(void 0),children:[s.jsx(h.Flyout.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Flyout.Content,{triggerOffset:"compact",children:s.jsxs(h.Dropdown.Root,{open:!0,children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Dropdown.Content,{triggerOffset:"compact",children:Tt.map(C=>s.jsxs(h.Dropdown.Item,{onSelect:C.onSelect,children:[C.icon,C.title]},C.title))})]})})]})})]})},Z=t=>{const e=r=>typeof r=="object"&&["red","green","blue"].every(i=>r.hasOwnProperty(i)),n=r=>{const a=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a}};return e(t)?n(t):t},Fn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),On=(t,e)=>{const n=Fn(t)?Z(t):t,r=new _.TinyColor(n);return e?r.getBrightness()<e:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},_n=t=>new _.TinyColor(Z(t)).toHex8String(),Un=t=>new _.TinyColor(Z(t)).toHexString(),Ot=t=>new _.TinyColor(Z(t)).toRgbString(),Hn=(t,e)=>new _.TinyColor(e).setAlpha(t).toRgbString(),zn=t=>{const{r:e,g:n,b:r,a}=new _.TinyColor(t);return{red:e,green:n,blue:r,alpha:a}},se=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Vn=(t,e)=>{const n=se(t)?Z(t):t,r=se(e)?Z(e):e;let a=new _.TinyColor(n);const i=new _.TinyColor(r);for(;_.readability(a,i)<4.5;)a=a.darken(1);return a.toRgbString()},$n=(t,e,n)=>{const r=[...t],a=n<0?r.length+n:n;if(a>=0&&a<r.length){const i=r.splice(e,1)[0];r.splice(a,0,i)}return r},Wn=t=>({backgroundColor:Ot(t)}),qn={red:241,green:241,blue:241,alpha:1},le={red:234,green:235,blue:235,alpha:1},Gn="1px",ct="24px",dt="24px";var O=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(O||{});const ce={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var V=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(V||{});const Q={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var G=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(G||{});const tt={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var K=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(K||{});const et={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var J=(t=>(t.Global="Global",t.Custom="Custom",t))(J||{}),Y=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(Y||{});const de={Auto:"4px",S:"10px",M:"30px",L:"50px"},Kn=(t=O.Solid,e="1px",n=le)=>({borderStyle:ce[t],borderWidth:e,borderColor:Ot(n)}),Yn=(t,e=!1,n)=>({borderRadius:e?n:Q[t]}),_t=u.createContext(!1);_t.displayName="DragPreviewContext";const ue=({children:t,isDragPreview:e})=>s.jsx(_t.Provider,{value:e,children:t}),at=()=>u.useContext(_t),Ut=u.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Ut.displayName="MultiFlyoutContext";const ge=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const r=u.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return s.jsx(Ut.Provider,{value:r,children:t})},me=()=>u.useContext(Ut),xt=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=me(),r=u.useCallback(a=>{n(i=>{const c=i.filter(d=>d!==t);return a?[...c,t]:c})},[t,n]);return{isOpen:e.includes(t),onOpenChange:r}},Ht=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:a,updateAssetIdsFromKey:i}=e,c=n?.[t]||[];return{onAttachmentsAdd:async g=>{await r(t,g.map(f=>f.id))},onAttachmentDelete:async g=>{await a(t,[g.id])},onAttachmentReplace:async(g,f)=>{const v=c.map(x=>x.id===g.id?f.id:x.id);await i(t,v)},onAttachmentsSorted:async g=>{const f=g.map(v=>v.id);await i(t,f)},attachments:c}},he=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:a,onAttachmentsSorted:i,attachments:c}=Ht(e,X.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:a,onAttachmentsSorted:i,attachments:c,appBridge:t}},bt=u.createContext(null);bt.displayName="AttachmentsContext";const pe=({appBridge:t,children:e,assetId:n})=>{const r=he(t,n);return s.jsx(bt.Provider,{value:r,children:e})},Qn=({blockAssetBundle:t,appBridge:e,children:n,assetId:r})=>{const a=Ht(r,t);return s.jsx(bt.Provider,{value:{...a,appBridge:e},children:n})},fe=()=>{const t=u.useContext(bt);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},Xn=(t,e)=>{const n=r=>s.jsx(pe,{appBridge:r.appBridge,assetId:e,children:s.jsx(t,{...r})});return n.displayName="withAttachmentsProvider",n},Jn=[I.KeyboardCode.Down,I.KeyboardCode.Right,I.KeyboardCode.Up,I.KeyboardCode.Left],we=(t,e)=>(n,{currentCoordinates:r,context:{activeNode:a}})=>{if(n.preventDefault(),Jn.includes(n.code)){const i=a?.offsetWidth??0,c=a?.offsetHeight??0;switch(n.code){case I.KeyboardCode.Right:return{...r,x:r.x+i+t};case I.KeyboardCode.Left:return{...r,x:r.x-i-t};case I.KeyboardCode.Down:return{...r,y:r.y+c+e};case I.KeyboardCode.Up:return{...r,y:r.y-c-e}}}},Zn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},ts=(t=0,e=0)=>{const n=u.useMemo(()=>({coordinateGetter:we(t,e),keyboardCodes:Zn}),[t,e]);return I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor,n))},es=t=>t==="IMAGE"?s.jsx(k.IconImage,{size:"24"}):t==="VIDEO"?s.jsx(k.IconPlayFrame,{size:"24"}):t==="AUDIO"?s.jsx(k.IconMusicNote,{size:"24"}):s.jsx(k.IconDocument,{size:"24"}),ye=u.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:r,isDragging:a,isOverlay:i,isLoading:c,onDelete:d,onReplaceWithBrowse:l,onReplaceWithUpload:p,onDownload:w},g)=>{const[f,v]=u.useState(),[x,{selectedFiles:S}]=X.useFileInput({multiple:!0,accept:"image/*"}),[N,{results:A,doneAll:L}]=X.useAssetUpload(),{focusProps:H,isFocusVisible:D}=Dn.useFocusRing();u.useEffect(()=>{S&&N(S[0])},[S]),u.useEffect(()=>{L&&p(A[0])},[L,A]);const F=c||S&&!L;return s.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!f&&w?.(),ref:g,style:{...r,opacity:a&&!i?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:$(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-container-secondary-hover",a?"tw-bg-container-secondary-hover":""]),children:[s.jsx("div",{className:"tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:F?s.jsx(h.LoadingCircle,{size:"small"}):es(t.objectType)}),s.jsxs("div",{className:"tw-text-small tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:t.title}),s.jsx("div",{className:"tw-text-secondary",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&s.jsxs("div",{"data-test-id":"attachments-actionbar",className:$(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",i||f?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[s.jsx("button",{type:"button",...H,...n,"aria-label":"Drag attachment",className:$([" tw-border-primary tw-bg-container-secondary active:tw-bg-container-secondary-active tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded-medium tw-h-9 tw-w-9 ",a||i?"tw-cursor-grabbing tw-bg-container-secondary-active hover:tw-bg-container-secondary-active":"tw-cursor-grab hover:tw-bg-container-secondary-hover",D&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",D&&"tw-z-[2]"]),children:s.jsx(k.IconGrabHandle,{})}),s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsxs(h.Dropdown.Root,{open:f?.id===t.id,onOpenChange:j=>v(j?t:void 0),children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx(h.Button,{aspect:"square",ref:g,onPress:j=>{j?.stopPropagation(),j?.preventDefault()},emphasis:"default",children:s.jsx(k.IconPen,{size:"20"})})}),s.jsxs(h.Dropdown.Content,{side:"right",children:[s.jsxs(h.Dropdown.Group,{children:[s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:j=>{j?.stopPropagation(),x(),v(void 0)},children:[s.jsx(k.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),s.jsxs(h.Dropdown.Item,{onSelect:j=>{j?.stopPropagation(),l(),v(void 0)},children:[s.jsx(k.IconImageStack,{size:"20"}),"Replace with asset"]})]}),s.jsx(h.Dropdown.Group,{children:s.jsxs(h.Dropdown.Item,{emphasis:"danger",onSelect:j=>{j?.stopPropagation(),d(),v(void 0)},children:[s.jsx(k.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});ye.displayName="AttachmentItem";const ns=t=>{const{attributes:e,listeners:n,setNodeRef:r,transform:a,transition:i,isDragging:c}=pt.useSortable({id:t.item.id}),d={transform:a?`translate(${a.x}px, ${a.y}px)`:"",transition:i,zIndex:c?2:1},l={...e,...n};return s.jsx(ye,{ref:r,isDragging:c,transformStyle:d,draggableProps:l,...t})},xe=u.forwardRef(({children:t,...e},n)=>s.jsxs(h.Button,{ref:n,size:"small",rounding:"full",emphasis:"default","data-test-id":"attachments-button-trigger",...e,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));xe.displayName="AttachmentsButtonTrigger";const be=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:a,onUpload:i,onSorted:c,appBridge:d,triggerComponent:l=xe,isOpen:p,onOpenChange:w})=>{const[g,f]=u.useState(t),[v,x]=u.useState(!1),S=I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor)),[N,A]=u.useState(void 0),[L,H]=u.useState(!1),[D,F]=u.useState([]),[j,Tt]=u.useState(null),C=X.useEditorState(d),{openAssetChooser:M,closeAssetChooser:W}=X.useAssetChooser(d),lt=p!==void 0,gt=lt?p:v,Pt=g?.find(b=>b.id===N),[It,{results:mt,doneAll:ht}]=X.useAssetUpload({onUploadProgress:()=>!L&&H(!0)}),z=b=>{(lt?w:x)?.(b)};u.useEffect(()=>{f(t)},[t]),u.useEffect(()=>{j&&(H(!0),It(j))},[j]),u.useEffect(()=>{(async()=>ht&&(await i(mt),H(!1)))()},[ht,mt]);const Pn=()=>{z(!1),M(b=>{a(b),W(),z(!0)},{multiSelection:!0,selectedValueIds:g.map(b=>b.id)})},In=b=>{z(!1),M(async R=>{z(!0),W(),F([...D,b.id]),await n(b,R[0]),F(D.filter(q=>q!==b.id))},{multiSelection:!1,selectedValueIds:g.map(R=>R.id)})},En=async(b,R)=>{F([...D,b.id]),await r(b,R),F(D.filter(q=>q!==b.id))},jn=b=>{const{active:R}=b;A(R.id)},Bn=b=>{const{active:R,over:q}=b;if(q&&R.id!==q.id&&g){const An=g.findIndex(Et=>Et.id===R.id),Ln=g.findIndex(Et=>Et.id===q.id),ne=pt.arrayMove(g,An,Ln);f(ne),c(ne)}A(void 0)},Nn={onOpenAutoFocus:b=>{b.preventDefault()},onEscapeKeyDown:b=>{b.stopPropagation(),z(!1)}};return C||(g?.length??0)>0?s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(h.Flyout.Root,{open:gt,onOpenChange:b=>z(Pt?!0:b),children:s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:s.jsx(l,{isFlyoutOpen:gt,children:s.jsx("div",{children:t.length>0?t.length:"Add"})})})}),s.jsx(h.Flyout.Content,{side:"bottom",align:"end",...Nn,children:s.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[g.length>0&&s.jsx(I.DndContext,{sensors:S,collisionDetection:I.closestCenter,onDragStart:jn,onDragEnd:Bn,modifiers:[Rn.restrictToVerticalAxis],children:s.jsx(pt.SortableContext,{items:g,strategy:pt.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:g.map(b=>s.jsx(ns,{isEditing:C,isLoading:D.includes(b.id),item:b,onDelete:()=>e(b),onReplaceWithBrowse:()=>In(b),onReplaceWithUpload:R=>En(b,R),onDownload:()=>d.dispatch({name:"downloadAsset",payload:b})},b.id))})})}),C&&s.jsxs("div",{className:"tw-px-5 tw-py-3",children:[s.jsx("div",{className:"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4",children:"Add attachments"}),s.jsx(U.AssetInput,{isLoading:L,size:U.AssetInputSize.Small,onUploadClick:b=>Tt(b),onLibraryClick:Pn})]})]})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},ss=(t,e)=>{const n=[U.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded-medium","tw-text-x-small tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),$(n)},it=u.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:r="pointer","data-test-id":a="base-toolbar-button",...i},c)=>s.jsx("button",{onClick:t,className:ss(r,n),"data-test-id":a,...i,ref:c,children:e}));it.displayName="BaseToolbarButton";const ve=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs(it,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));ve.displayName="AttachmentsToolbarButtonTrigger";const Ce="attachments",Se=({flyoutId:t=Ce})=>{const e=U.useMemoizedId(t),{appBridge:n,attachments:r,onAttachmentsAdd:a,onAttachmentDelete:i,onAttachmentReplace:c,onAttachmentsSorted:d}=fe(),{isOpen:l,onOpenChange:p}=xt(e),w=at();return s.jsx(be,{onUpload:a,onDelete:i,onReplaceWithBrowse:c,onReplaceWithUpload:c,onSorted:d,onBrowse:a,items:r,appBridge:n,triggerComponent:ve,isOpen:l&&!w,onOpenChange:p})},ke="Drag or press ↵ to move",Te="Move with ↑↓←→ and confirm with ↵",zt=({content:t,children:e,open:n,disabled:r})=>r?e:s.jsxs(h.Tooltip.Root,{enterDelay:300,open:n,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:e}),s.jsx(h.Tooltip.Content,{side:"top",children:s.jsx("div",{children:t})})]}),Pe=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:r})=>{const a=at();return s.jsx(zt,{...a&&{open:a},content:s.jsx("div",{children:a?Te:t??ke}),children:s.jsx(it,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:a,cursor:"grab",...r,children:e})})},Ie=({content:t,icon:e,tooltip:n,flyoutId:r,flyoutFooter:a,flyoutHeader:i})=>{const c=U.useMemoizedId(r),{isOpen:d,onOpenChange:l}=xt(c),p=at();return s.jsx(zt,{disabled:p||d,content:n,children:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsxs(h.Flyout.Root,{open:d&&!p,onOpenChange:l,children:[s.jsx(h.Flyout.Trigger,{asChild:!0,children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:d&&!p,children:e})}),s.jsxs(h.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[i?s.jsx(h.Flyout.Header,{children:i}):null,s.jsx(h.Flyout.Body,{children:t}),a?s.jsx(h.Flyout.Footer,{children:a}):null]})]})})})},Vt="menu",Ee=({items:t,flyoutId:e=Vt,tooltip:n="Options"})=>{const r=U.useMemoizedId(e),{isOpen:a,onOpenChange:i}=xt(r),c=at();return s.jsx(h.Dropdown.Root,{open:a&&!c,onOpenChange:i,children:s.jsxs(h.Tooltip.Root,{children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Dropdown.Trigger,{asChild:!0,children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:s.jsx(k.IconDotsHorizontal,{size:"16"})})})}),s.jsx(h.Dropdown.Content,{children:t.map((d,l)=>s.jsx(h.Dropdown.Group,{children:d.map((p,w)=>s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{i(!1),p.onClick()},emphasis:p.style||"default",children:[s.jsx("div",{className:"tw-mr-2",children:p.icon}),s.jsx("span",{children:p.title})]},`${l}-${w}`))},l))}),s.jsx(h.Tooltip.Content,{children:n})]})})},os=({tooltip:t,icon:e,onClick:n})=>{const r=at();return s.jsx(zt,{disabled:r,content:t??"",children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},oe=({children:t})=>s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),je=({items:t,attachments:e})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&s.jsx(oe,{children:s.jsx(Se,{})}),t.length>0&&s.jsx(oe,{children:t.map(n=>{switch(n.type){case"dragHandle":return s.jsx(Pe,{...n},n.tooltip+n.type);case"menu":return s.jsx(Ee,{...n},n.tooltip+n.type);case"flyout":return s.jsx(Ie,{...n},n.tooltip+n.type);default:return s.jsx(os,{...n},n.tooltip+n.type)}})})]}),Be=u.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:a=!1,shouldFillContainer:i,outlineOffset:c=0,shouldBeShown:d=!1,showAttachments:l=!1})=>{const[p,w]=u.useState(d?[Vt]:[]),g=u.useRef(null);if(n)return s.jsx(s.Fragment,{children:t});const f=e?.filter(x=>x!==void 0),v=p.length>0||d;return s.jsx(ue,{isDragPreview:a,children:s.jsx(ge,{openFlyoutIds:p,setOpenFlyoutIds:w,children:s.jsxs("div",{ref:g,"data-test-id":"block-item-wrapper",style:{outlineOffset:c},className:$(["tw-relative tw-group",i&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",v&&"tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",r&&"tw-opacity-0"]),children:[s.jsx("div",{style:{right:-1-c,bottom:`calc(100% - ${2+c}px)`},className:$(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",v&&"tw-opacity-100"]),children:s.jsx(je,{attachments:{isEnabled:l},items:f})}),t]})})})});Be.displayName="BlockItemWrapper";const rs=({onDownload:t,ariaLabel:e})=>s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Button,{"aria-label":e??"Download",onPress:t,"data-test-id":"download-button",aspect:"square",emphasis:"default",rounding:"full",size:"small",type:"button",variant:"default",hugWidth:!0,children:s.jsx(k.IconArrowCircleDown,{size:16})})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Download"})]}),as=({ref:t,disabled:e,onChange:n})=>{u.useEffect(()=>{if(e||!t.current)return;let r=!1;const a=new IntersectionObserver(([i])=>{i.isIntersecting!==r&&(r=i.isIntersecting,n(i.isIntersecting))});return a.observe(t.current),()=>{a.disconnect()}},[t,e,n])},is=({value:t="",gap:e,customClass:n,show:r=!0,plugins:a})=>{const[i,c]=u.useState(null);return u.useEffect(()=>{(async()=>{const l=await o.serializeRawToHtmlAsync(t,a,void 0,e,n);c(l)})().catch(console.error)},[t,e,a,n]),!r||i==="<br />"||i===null?null:s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:i}})},$t=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),E=$t.set,B=$t.get,ut=()=>$t.use,Ne=t=>{if(!t)return!1;const e=n=>n.some(r=>r.text?r.text!=="":r.children?e(r.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},ls=(t="p",e="",n)=>Ne(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),cs=(t,e,n)=>t===J.Custom?e:n,ds=t=>t.map(Ae),Ae=t=>({id:t.id,title:t.name,colors:t.colors.map(gs)}),us=t=>"revision"in t,gs=t=>{if(us(t)){const{title:e,revision:n}=t;return{alpha:n.rgba.alpha?n.rgba.alpha/255:1,red:n.rgba.red??0,green:n.rgba.green??0,blue:n.rgba.blue??0,name:e??""}}return{alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}},Wt=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},ms=t=>Wt(t,e=>e.chosenLink?.searchResult?.link||""),hs=t=>Wt(t,e=>e.url||""),qt=t=>t.url||t.chosenLink?.searchResult?.link||"",ps=t=>Wt(t,qt),Gt=/^\/(document|r)\/\S+$/i,vt=t=>{if(Gt.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},Ct=t=>{if(Gt.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},st=t=>Ct(vt(t))||t==="",Le=(t,{type:e})=>{const{apply:n,normalizeNode:r}=t;return t.apply=a=>{if(a.type!=="set_selection"){n(a);return}const i=a.newProperties;if(!i?.focus||!i.anchor||!o.isCollapsed(i)){n(a);return}const c=o.getAboveNode(t,{at:i,match:{type:o.getPluginType(t,T)}});if(c){const[,d]=c;let l;o.isStartPoint(t,i.focus,d)&&(l=o.getPreviousNodeEndPoint(t,d)),o.isEndPoint(t,i.focus,d)&&(l=o.getNextNodeStartPoint(t,d)),l&&(a.newProperties={anchor:l,focus:l})}n(a)},t.normalizeNode=([a,i])=>{if(a.type===o.getPluginType(t,T)){const c=t.selection;if(c&&o.isCollapsed(c)&&o.isEndPoint(t,c.focus,i)){const d=o.getNextNodeStartPoint(t,i);if(d)o.select(t,d);else{const l=o.Path.next(i);o.insertNodes(t,{text:""},{at:l}),o.select(t,l)}}}r([a,i])},o.withRemoveEmptyNodes(t,o.mockPlugin({options:{types:e}}))},Re=(t,e,n)=>{o.insertNodes(t,[Oe(t,e)],n)},Kt=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=o.getPluginOptions(t,T),r=B.url();if(!(e?.(r)||n))return;const i=B.text(),c=B.buttonStyle(),d=B.newTab()?void 0:"_self";return E.reset(),De(t,{url:r,text:i,buttonStyle:c,target:d,isUrl:l=>n||!e?!0:e(l)}),setTimeout(()=>{o.focusEditor(t,t.selection??void 0)},0),!0},ot=(t,e)=>o.withoutNormalizing(t,()=>{if(e?.split){if(o.getAboveNode(t,{at:t.selection?.anchor,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.anchor,match:a=>o.isElement(a)&&a.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.anchor}),!0;if(o.getAboveNode(t,{at:t.selection?.focus,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.focus,match:a=>o.isElement(a)&&a.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.focus}),!0}o.unwrapNodes(t,{match:{type:o.getPluginType(t,T)},...e})}),De=(t,{url:e,text:n,buttonStyle:r,target:a,insertTextInButton:i,insertNodesOptions:c,isUrl:d=o.getPluginOptions(t,T).isUrl})=>{const l=t.selection;if(!l)return;const p=o.getAboveNode(t,{at:l,match:{type:o.getPluginType(t,T)}});if(i&&p)return t.insertText(e),!0;if(!d?.(e))return;if(o.isDefined(n)&&n.length===0&&(n=e),p)return ys(e,t,p,a,r,n),!0;const w=o.findNode(t,{at:l,match:{type:o.getPluginType(t,T)}}),[g,f]=w??[],v=fs(t,f,n);if(o.isExpanded(l))return ws(p,t,e,r,a,n),!0;v&&o.removeNodes(t,{at:f});const x=o.getNodeProps(g??{}),S=t.selection?.focus.path;if(!S)return;const N=o.getNodeLeaf(t,S);return n?.length||(n=e),Re(t,{...x,url:e,target:a,children:[{...N,text:n}]},c),!0};function fs(t,e,n){return e&&n?.length&&n!==o.getEditorString(t,e)}function ws(t,e,n,r,a,i){t?ot(e,{at:t[1]}):ot(e,{split:!0}),Me(e,{url:n,buttonStyle:r,target:a}),Yt(e,{text:i})}function ys(t,e,n,r,a,i){(t!==n[0]?.url||r!==n[0]?.target||a!==n[0]?.buttonStyle)&&o.setNodes(e,{url:t,target:r,buttonStyle:a},{at:n[1]}),Yt(e,{text:i})}const Yt=(t,{text:e})=>{const n=o.getAboveNode(t,{match:{type:o.getPluginType(t,T)}});if(n){const[r,a]=n;if(e?.length&&e!==o.getEditorString(t,a)){const i=r.children[0];o.replaceNodeChildren(t,{at:a,nodes:{...i,text:e},insertOptions:{select:!0}})}}},Me=(t,{url:e,buttonStyle:n,target:r,...a})=>{o.wrapNodes(t,{type:o.getPluginType(t,T),url:e,buttonStyle:n,target:r,children:[]},{split:!0,...a})},xs=(t,e)=>{const n=o.getAboveNode(t,{match:{type:T}});return Array.isArray(n)?e(n[0]):""},Fe=t=>xs(t,e=>e.url??""),Oe=(t,{url:e,text:n="",buttonStyle:r="primary",target:a,children:i})=>({type:o.getPluginType(t,T),url:e,target:a,buttonStyle:r,children:i??[{text:n}]}),_e=(t,{focused:e}={})=>{if(B.mode()==="edit"){St(t);return}Qt(t,{focused:e})},St=t=>{const e=o.findNode(t,{match:{type:o.getPluginType(t,T)}});if(!e)return;const[n,r]=e;let a=o.getEditorString(t,r);E.url(n.url),E.newTab(n.target===void 0),a===n.url&&(a=""),E.text(a),E.isEditing(!0)},Qt=(t,{focused:e}={})=>{B.mode()||!e||o.isRangeAcrossBlocks(t,{at:t.selection})||o.someNode(t,{match:{type:o.getPluginType(t,T)}})||(E.text(o.getEditorString(t,t.selection)),E.show("insert",t.id))},jt={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},kt={buttonPrimary:{...jt,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...jt,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...jt,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},bs=t=>{const{attributes:e,children:n}=t,r=t.element.url||t.element.chosenLink?.searchResult?.link||"",a=t.element.target||"_self",i=String(t.element.buttonStyle)||"primary";return s.jsx(vs,{attributes:e,href:r,target:a,styles:kt[`button${i.charAt(0).toUpperCase()+i.slice(1)}`],children:n})},vs=({attributes:t,styles:e={hover:{}},children:n,href:r="#",target:a})=>{const[i,c]=u.useState(!1);return s.jsx("a",{...t,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:r,target:a,style:i?{...e,...e.hover}:e,children:n})};class Cs extends o.MarkupElement{constructor(e=T,n=bs){super(e,n)}}const Ue=u.forwardRef((t,e)=>{const n=o.useEditorRef();return s.jsx(o.ToolbarButton,{ref:e,...t,onMouseDown:r=>{r.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{_e(n,{focused:!0})},children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconButton,{size:16})})})});Ue.displayName="ButtonToolbarButton";const Ss=({editorId:t,id:e})=>{const n=o.useEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection}),a=o.getPluginType(n,T),i=!!n?.selection&&o.someNode(n,{match:{type:a}});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(Ue,{pressed:i,disabled:!r,tooltip:o.getTooltip(r?`Button
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),o=require("@frontify/fondue/rte"),X=require("@frontify/app-bridge"),u=require("react"),I=require("@dnd-kit/core"),Rn=require("@dnd-kit/modifiers"),pt=require("@dnd-kit/sortable"),U=require("@frontify/fondue"),h=require("@frontify/fondue/components"),k=require("@frontify/fondue/icons"),Dn=require("@react-aria/focus"),ft=require("react-dom"),_=require("@ctrl/tinycolor"),$=t=>t.filter(Boolean).join(" "),Mn=({onDrop:t,label:e,icon:n,secondaryLabel:r,isLoading:a,fillParentContainer:i,onAssetChooseClick:c,onUploadClick:d,withMenu:l=!0,onClick:p,validFileType:w,verticalLayout:g})=>{const[f,v]=u.useState(!1),[x,S]=u.useState(),N=u.useRef(null),[A,L]=u.useState(void 0),H=C=>{if(C.preventDefault(),v(!1),!D(C.dataTransfer.files)){L("Invalid"),setTimeout(()=>{L(void 0)},1e3);return}t?.(C.dataTransfer.files)},D=C=>{if(!w)return!0;for(let M=0;M<C.length;M++){const W=C[M].name.split(".").pop()??"";if(!X.FileExtensionSets[w].includes(W))return!1}return!0},F=C=>{if(!N.current||a)return;const{clientX:M,clientY:W}=C,lt=M===0&&W===0,{left:gt,top:Pt,width:It,height:mt}=N.current.getBoundingClientRect(),ht=lt?It/2:M-gt,z=lt?mt/2:W-Pt;S([ht,z])},j=u.useCallback(C=>{C(),S(void 0)},[]),Tt=u.useMemo(()=>{const C=[];return d&&C.push({onSelect:()=>j(d),title:"Upload asset",icon:s.jsx(k.IconArrowCircleUp,{size:"20"})}),c&&C.push({onSelect:()=>j(c),title:"Browse asset",icon:s.jsx(k.IconImageStack,{size:"20"})}),C},[c,d,j]);return s.jsxs("button",{ref:N,"data-test-id":"block-inject-button",className:$(["tw-body-medium tw-relative tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",g?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",i?"tw-h-full":"tw-h-[72px]",f&&!a?"tw-border-dashed":"tw-border-solid",x&&"tw-bg-blank-state-pressed-inverse",f&&"tw-bg-blank-state-weak-inverse",A?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",a||x||f||A?"":"tw-text-secondary hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",(f||x)&&!A?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:t?C=>{if(v(!0),w==="Images")for(const M of Array.from(C.dataTransfer.items))M?.type?.startsWith("image/")?L(void 0):L("Invalid")}:void 0,onDragOver:t?C=>{C.preventDefault()}:void 0,onDragLeave:t?()=>{v(!1),L(void 0)}:void 0,onDrop:t?H:void 0,onClick:C=>{l&&!x&&F(C),p?.()},children:[a?s.jsx(h.LoadingCircle,{}):A?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(k.IconExclamationMarkTriangle,{size:"16"}),A]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(e||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&s.jsx("div",{className:"tw-font-medium",children:e}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),x&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:x[0],top:x[1]},children:s.jsxs(h.Flyout.Root,{open:!0,onOpenChange:C=>!C&&S(void 0),children:[s.jsx(h.Flyout.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Flyout.Content,{triggerOffset:"compact",children:s.jsxs(h.Dropdown.Root,{open:!0,children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Dropdown.Content,{triggerOffset:"compact",children:Tt.map(C=>s.jsxs(h.Dropdown.Item,{onSelect:C.onSelect,children:[C.icon,C.title]},C.title))})]})})]})})]})},Z=t=>{const e=r=>typeof r=="object"&&["red","green","blue"].every(i=>r.hasOwnProperty(i)),n=r=>{const a=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a}};return e(t)?n(t):t},Fn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),On=(t,e)=>{const n=Fn(t)?Z(t):t,r=new _.TinyColor(n);return e?r.getBrightness()<e:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},_n=t=>new _.TinyColor(Z(t)).toHex8String(),Un=t=>new _.TinyColor(Z(t)).toHexString(),Ot=t=>new _.TinyColor(Z(t)).toRgbString(),Hn=(t,e)=>new _.TinyColor(e).setAlpha(t).toRgbString(),zn=t=>{const{r:e,g:n,b:r,a}=new _.TinyColor(t);return{red:e,green:n,blue:r,alpha:a}},se=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Vn=(t,e)=>{const n=se(t)?Z(t):t,r=se(e)?Z(e):e;let a=new _.TinyColor(n);const i=new _.TinyColor(r);for(;_.readability(a,i)<4.5;)a=a.darken(1);return a.toRgbString()},$n=(t,e,n)=>{const r=[...t],a=n<0?r.length+n:n;if(a>=0&&a<r.length){const i=r.splice(e,1)[0];r.splice(a,0,i)}return r},Wn=t=>({backgroundColor:Ot(t)}),qn={red:241,green:241,blue:241,alpha:1},le={red:234,green:235,blue:235,alpha:1},Gn="1px",ct="24px",dt="24px";var O=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(O||{});const ce={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var V=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(V||{});const Q={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var G=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(G||{});const tt={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var K=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(K||{});const et={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var J=(t=>(t.Global="Global",t.Custom="Custom",t))(J||{}),Y=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(Y||{});const de={Auto:"4px",S:"10px",M:"30px",L:"50px"},Kn=(t=O.Solid,e="1px",n=le)=>({borderStyle:ce[t],borderWidth:e,borderColor:Ot(n)}),Yn=(t,e=!1,n)=>({borderRadius:e?n:Q[t]}),_t=u.createContext(!1);_t.displayName="DragPreviewContext";const ue=({children:t,isDragPreview:e})=>s.jsx(_t.Provider,{value:e,children:t}),at=()=>u.useContext(_t),Ut=u.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Ut.displayName="MultiFlyoutContext";const ge=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const r=u.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return s.jsx(Ut.Provider,{value:r,children:t})},me=()=>u.useContext(Ut),xt=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=me(),r=u.useCallback(a=>{n(i=>{const c=i.filter(d=>d!==t);return a?[...c,t]:c})},[t,n]);return{isOpen:e.includes(t),onOpenChange:r}},Ht=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:a,updateAssetIdsFromKey:i}=e,c=n?.[t]||[];return{onAttachmentsAdd:async g=>{await r(t,g.map(f=>f.id))},onAttachmentDelete:async g=>{await a(t,[g.id])},onAttachmentReplace:async(g,f)=>{const v=c.map(x=>x.id===g.id?f.id:x.id);await i(t,v)},onAttachmentsSorted:async g=>{const f=g.map(v=>v.id);await i(t,f)},attachments:c}},he=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:a,onAttachmentsSorted:i,attachments:c}=Ht(e,X.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:a,onAttachmentsSorted:i,attachments:c,appBridge:t}},bt=u.createContext(null);bt.displayName="AttachmentsContext";const pe=({appBridge:t,children:e,assetId:n})=>{const r=he(t,n);return s.jsx(bt.Provider,{value:r,children:e})},Qn=({blockAssetBundle:t,appBridge:e,children:n,assetId:r})=>{const a=Ht(r,t);return s.jsx(bt.Provider,{value:{...a,appBridge:e},children:n})},fe=()=>{const t=u.useContext(bt);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},Xn=(t,e)=>{const n=r=>s.jsx(pe,{appBridge:r.appBridge,assetId:e,children:s.jsx(t,{...r})});return n.displayName="withAttachmentsProvider",n},Jn=[I.KeyboardCode.Down,I.KeyboardCode.Right,I.KeyboardCode.Up,I.KeyboardCode.Left],we=(t,e)=>(n,{currentCoordinates:r,context:{activeNode:a}})=>{if(n.preventDefault(),Jn.includes(n.code)){const i=a?.offsetWidth??0,c=a?.offsetHeight??0;switch(n.code){case I.KeyboardCode.Right:return{...r,x:r.x+i+t};case I.KeyboardCode.Left:return{...r,x:r.x-i-t};case I.KeyboardCode.Down:return{...r,y:r.y+c+e};case I.KeyboardCode.Up:return{...r,y:r.y-c-e}}}},Zn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},ts=(t=0,e=0)=>{const n=u.useMemo(()=>({coordinateGetter:we(t,e),keyboardCodes:Zn}),[t,e]);return I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor,n))},es=t=>t==="IMAGE"?s.jsx(k.IconImage,{size:"24"}):t==="VIDEO"?s.jsx(k.IconPlayFrame,{size:"24"}):t==="AUDIO"?s.jsx(k.IconMusicNote,{size:"24"}):s.jsx(k.IconDocument,{size:"24"}),ye=u.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:r,isDragging:a,isOverlay:i,isLoading:c,onDelete:d,onReplaceWithBrowse:l,onReplaceWithUpload:p,onDownload:w},g)=>{const[f,v]=u.useState(),[x,{selectedFiles:S}]=X.useFileInput({multiple:!0,accept:"image/*"}),[N,{results:A,doneAll:L}]=X.useAssetUpload(),{focusProps:H,isFocusVisible:D}=Dn.useFocusRing();u.useEffect(()=>{S&&N(S[0])},[S]),u.useEffect(()=>{L&&p(A[0])},[L,A]);const F=c||S&&!L;return s.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!f&&w?.(),ref:g,style:{...r,opacity:a&&!i?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:$(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-container-secondary-hover",a?"tw-bg-container-secondary-hover":""]),children:[s.jsx("div",{className:"tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:F?s.jsx(h.LoadingCircle,{size:"small"}):es(t.objectType)}),s.jsxs("div",{className:"tw-text-small tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:t.title}),s.jsx("div",{className:"tw-text-secondary",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&s.jsxs("div",{"data-test-id":"attachments-actionbar",className:$(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",i||f?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[s.jsx("button",{type:"button",...H,...n,"aria-label":"Drag attachment",className:$([" tw-border-primary tw-bg-container-secondary active:tw-bg-container-secondary-active tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded-medium tw-h-9 tw-w-9 ",a||i?"tw-cursor-grabbing tw-bg-container-secondary-active hover:tw-bg-container-secondary-active":"tw-cursor-grab hover:tw-bg-container-secondary-hover",D&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",D&&"tw-z-[2]"]),children:s.jsx(k.IconGrabHandle,{})}),s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsxs(h.Dropdown.Root,{open:f?.id===t.id,onOpenChange:j=>v(j?t:void 0),children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx(h.Button,{aspect:"square",ref:g,onPress:j=>{j?.stopPropagation(),j?.preventDefault()},emphasis:"default",children:s.jsx(k.IconPen,{size:"20"})})}),s.jsxs(h.Dropdown.Content,{side:"right",children:[s.jsxs(h.Dropdown.Group,{children:[s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:j=>{j?.stopPropagation(),x(),v(void 0)},children:[s.jsx(k.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),s.jsxs(h.Dropdown.Item,{onSelect:j=>{j?.stopPropagation(),l(),v(void 0)},children:[s.jsx(k.IconImageStack,{size:"20"}),"Replace with asset"]})]}),s.jsx(h.Dropdown.Group,{children:s.jsxs(h.Dropdown.Item,{emphasis:"danger",onSelect:j=>{j?.stopPropagation(),d(),v(void 0)},children:[s.jsx(k.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});ye.displayName="AttachmentItem";const ns=t=>{const{attributes:e,listeners:n,setNodeRef:r,transform:a,transition:i,isDragging:c}=pt.useSortable({id:t.item.id}),d={transform:a?`translate(${a.x}px, ${a.y}px)`:"",transition:i,zIndex:c?2:1},l={...e,...n};return s.jsx(ye,{ref:r,isDragging:c,transformStyle:d,draggableProps:l,...t})},xe=u.forwardRef(({children:t,...e},n)=>s.jsxs(h.Button,{ref:n,size:"small",rounding:"full",emphasis:"default","data-test-id":"attachments-button-trigger",className:"tw-body-medium",...e,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));xe.displayName="AttachmentsButtonTrigger";const be=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:a,onUpload:i,onSorted:c,appBridge:d,triggerComponent:l=xe,isOpen:p,onOpenChange:w})=>{const[g,f]=u.useState(t),[v,x]=u.useState(!1),S=I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor)),[N,A]=u.useState(void 0),[L,H]=u.useState(!1),[D,F]=u.useState([]),[j,Tt]=u.useState(null),C=X.useEditorState(d),{openAssetChooser:M,closeAssetChooser:W}=X.useAssetChooser(d),lt=p!==void 0,gt=lt?p:v,Pt=g?.find(b=>b.id===N),[It,{results:mt,doneAll:ht}]=X.useAssetUpload({onUploadProgress:()=>!L&&H(!0)}),z=b=>{(lt?w:x)?.(b)};u.useEffect(()=>{f(t)},[t]),u.useEffect(()=>{j&&(H(!0),It(j))},[j]),u.useEffect(()=>{(async()=>ht&&(await i(mt),H(!1)))()},[ht,mt]);const Pn=()=>{z(!1),M(b=>{a(b),W(),z(!0)},{multiSelection:!0,selectedValueIds:g.map(b=>b.id)})},In=b=>{z(!1),M(async R=>{z(!0),W(),F([...D,b.id]),await n(b,R[0]),F(D.filter(q=>q!==b.id))},{multiSelection:!1,selectedValueIds:g.map(R=>R.id)})},En=async(b,R)=>{F([...D,b.id]),await r(b,R),F(D.filter(q=>q!==b.id))},jn=b=>{const{active:R}=b;A(R.id)},Bn=b=>{const{active:R,over:q}=b;if(q&&R.id!==q.id&&g){const An=g.findIndex(Et=>Et.id===R.id),Ln=g.findIndex(Et=>Et.id===q.id),ne=pt.arrayMove(g,An,Ln);f(ne),c(ne)}A(void 0)},Nn={onOpenAutoFocus:b=>{b.preventDefault()},onEscapeKeyDown:b=>{b.stopPropagation(),z(!1)}};return C||(g?.length??0)>0?s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(h.Flyout.Root,{open:gt,onOpenChange:b=>z(Pt?!0:b),children:s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:s.jsx(l,{isFlyoutOpen:gt,children:s.jsx("div",{children:t.length>0?t.length:"Add"})})})}),s.jsx(h.Flyout.Content,{side:"bottom",align:"end",...Nn,children:s.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[g.length>0&&s.jsx(I.DndContext,{sensors:S,collisionDetection:I.closestCenter,onDragStart:jn,onDragEnd:Bn,modifiers:[Rn.restrictToVerticalAxis],children:s.jsx(pt.SortableContext,{items:g,strategy:pt.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:g.map(b=>s.jsx(ns,{isEditing:C,isLoading:D.includes(b.id),item:b,onDelete:()=>e(b),onReplaceWithBrowse:()=>In(b),onReplaceWithUpload:R=>En(b,R),onDownload:()=>d.dispatch({name:"downloadAsset",payload:b})},b.id))})})}),C&&s.jsxs("div",{className:"tw-px-5 tw-py-3",children:[s.jsx("div",{className:"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4",children:"Add attachments"}),s.jsx(U.AssetInput,{isLoading:L,size:U.AssetInputSize.Small,onUploadClick:b=>Tt(b),onLibraryClick:Pn})]})]})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},ss=(t,e)=>{const n=[U.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded-medium","tw-body-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),$(n)},it=u.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:r="pointer","data-test-id":a="base-toolbar-button",...i},c)=>s.jsx("button",{onClick:t,className:ss(r,n),"data-test-id":a,...i,ref:c,children:e}));it.displayName="BaseToolbarButton";const ve=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs(it,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));ve.displayName="AttachmentsToolbarButtonTrigger";const Ce="attachments",Se=({flyoutId:t=Ce})=>{const e=U.useMemoizedId(t),{appBridge:n,attachments:r,onAttachmentsAdd:a,onAttachmentDelete:i,onAttachmentReplace:c,onAttachmentsSorted:d}=fe(),{isOpen:l,onOpenChange:p}=xt(e),w=at();return s.jsx(be,{onUpload:a,onDelete:i,onReplaceWithBrowse:c,onReplaceWithUpload:c,onSorted:d,onBrowse:a,items:r,appBridge:n,triggerComponent:ve,isOpen:l&&!w,onOpenChange:p})},ke="Drag or press ↵ to move",Te="Move with ↑↓←→ and confirm with ↵",zt=({content:t,children:e,open:n,disabled:r})=>r?e:s.jsxs(h.Tooltip.Root,{enterDelay:300,open:n,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:e}),s.jsx(h.Tooltip.Content,{side:"top",children:s.jsx("div",{children:t})})]}),Pe=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:r})=>{const a=at();return s.jsx(zt,{...a&&{open:a},content:s.jsx("div",{children:a?Te:t??ke}),children:s.jsx(it,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:a,cursor:"grab",...r,children:e})})},Ie=({content:t,icon:e,tooltip:n,flyoutId:r,flyoutFooter:a,flyoutHeader:i})=>{const c=U.useMemoizedId(r),{isOpen:d,onOpenChange:l}=xt(c),p=at();return s.jsx(zt,{disabled:p||d,content:n,children:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsxs(h.Flyout.Root,{open:d&&!p,onOpenChange:l,children:[s.jsx(h.Flyout.Trigger,{asChild:!0,children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:d&&!p,children:e})}),s.jsxs(h.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[i?s.jsx(h.Flyout.Header,{children:i}):null,s.jsx(h.Flyout.Body,{children:t}),a?s.jsx(h.Flyout.Footer,{children:a}):null]})]})})})},Vt="menu",Ee=({items:t,flyoutId:e=Vt,tooltip:n="Options"})=>{const r=U.useMemoizedId(e),{isOpen:a,onOpenChange:i}=xt(r),c=at();return s.jsx(h.Dropdown.Root,{open:a&&!c,onOpenChange:i,children:s.jsxs(h.Tooltip.Root,{children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Dropdown.Trigger,{asChild:!0,children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:s.jsx(k.IconDotsHorizontal,{size:"16"})})})}),s.jsx(h.Dropdown.Content,{children:t.map((d,l)=>s.jsx(h.Dropdown.Group,{children:d.map((p,w)=>s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{i(!1),p.onClick()},emphasis:p.style||"default",children:[s.jsx("div",{className:"tw-mr-2",children:p.icon}),s.jsx("span",{children:p.title})]},`${l}-${w}`))},l))}),s.jsx(h.Tooltip.Content,{children:n})]})})},os=({tooltip:t,icon:e,onClick:n})=>{const r=at();return s.jsx(zt,{disabled:r,content:t??"",children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},oe=({children:t})=>s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),je=({items:t,attachments:e})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&s.jsx(oe,{children:s.jsx(Se,{})}),t.length>0&&s.jsx(oe,{children:t.map(n=>{switch(n.type){case"dragHandle":return s.jsx(Pe,{...n},n.tooltip+n.type);case"menu":return s.jsx(Ee,{...n},n.tooltip+n.type);case"flyout":return s.jsx(Ie,{...n},n.tooltip+n.type);default:return s.jsx(os,{...n},n.tooltip+n.type)}})})]}),Be=u.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:a=!1,shouldFillContainer:i,outlineOffset:c=0,shouldBeShown:d=!1,showAttachments:l=!1})=>{const[p,w]=u.useState(d?[Vt]:[]),g=u.useRef(null);if(n)return s.jsx(s.Fragment,{children:t});const f=e?.filter(x=>x!==void 0),v=p.length>0||d;return s.jsx(ue,{isDragPreview:a,children:s.jsx(ge,{openFlyoutIds:p,setOpenFlyoutIds:w,children:s.jsxs("div",{ref:g,"data-test-id":"block-item-wrapper",style:{outlineOffset:c},className:$(["tw-relative tw-group",i&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",v&&"tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",r&&"tw-opacity-0"]),children:[s.jsx("div",{style:{right:-1-c,bottom:`calc(100% - ${2+c}px)`},className:$(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",v&&"tw-opacity-100"]),children:s.jsx(je,{attachments:{isEnabled:l},items:f})}),t]})})})});Be.displayName="BlockItemWrapper";const rs=({onDownload:t,ariaLabel:e})=>s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Button,{"aria-label":e??"Download",onPress:t,"data-test-id":"download-button",aspect:"square",emphasis:"default",rounding:"full",size:"small",type:"button",variant:"default",hugWidth:!0,children:s.jsx(k.IconArrowCircleDown,{size:16})})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Download"})]}),as=({ref:t,disabled:e,onChange:n})=>{u.useEffect(()=>{if(e||!t.current)return;let r=!1;const a=new IntersectionObserver(([i])=>{i.isIntersecting!==r&&(r=i.isIntersecting,n(i.isIntersecting))});return a.observe(t.current),()=>{a.disconnect()}},[t,e,n])},is=({value:t="",gap:e,customClass:n,show:r=!0,plugins:a})=>{const[i,c]=u.useState(null);return u.useEffect(()=>{(async()=>{const l=await o.serializeRawToHtmlAsync(t,a,void 0,e,n);c(l)})().catch(console.error)},[t,e,a,n]),!r||i==="<br />"||i===null?null:s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:i}})},$t=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),E=$t.set,B=$t.get,ut=()=>$t.use,Ne=t=>{if(!t)return!1;const e=n=>n.some(r=>r.text?r.text!=="":r.children?e(r.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},ls=(t="p",e="",n)=>Ne(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),cs=(t,e,n)=>t===J.Custom?e:n,ds=t=>t.map(Ae),Ae=t=>({id:t.id,title:t.name,colors:t.colors.map(gs)}),us=t=>"revision"in t,gs=t=>{if(us(t)){const{title:e,revision:n}=t;return{alpha:n.rgba.alpha?n.rgba.alpha/255:1,red:n.rgba.red??0,green:n.rgba.green??0,blue:n.rgba.blue??0,name:e??""}}return{alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}},Wt=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},ms=t=>Wt(t,e=>e.chosenLink?.searchResult?.link||""),hs=t=>Wt(t,e=>e.url||""),qt=t=>t.url||t.chosenLink?.searchResult?.link||"",ps=t=>Wt(t,qt),Gt=/^\/(document|r)\/\S+$/i,vt=t=>{if(Gt.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},Ct=t=>{if(Gt.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},st=t=>Ct(vt(t))||t==="",Le=(t,{type:e})=>{const{apply:n,normalizeNode:r}=t;return t.apply=a=>{if(a.type!=="set_selection"){n(a);return}const i=a.newProperties;if(!i?.focus||!i.anchor||!o.isCollapsed(i)){n(a);return}const c=o.getAboveNode(t,{at:i,match:{type:o.getPluginType(t,T)}});if(c){const[,d]=c;let l;o.isStartPoint(t,i.focus,d)&&(l=o.getPreviousNodeEndPoint(t,d)),o.isEndPoint(t,i.focus,d)&&(l=o.getNextNodeStartPoint(t,d)),l&&(a.newProperties={anchor:l,focus:l})}n(a)},t.normalizeNode=([a,i])=>{if(a.type===o.getPluginType(t,T)){const c=t.selection;if(c&&o.isCollapsed(c)&&o.isEndPoint(t,c.focus,i)){const d=o.getNextNodeStartPoint(t,i);if(d)o.select(t,d);else{const l=o.Path.next(i);o.insertNodes(t,{text:""},{at:l}),o.select(t,l)}}}r([a,i])},o.withRemoveEmptyNodes(t,o.mockPlugin({options:{types:e}}))},Re=(t,e,n)=>{o.insertNodes(t,[Oe(t,e)],n)},Kt=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=o.getPluginOptions(t,T),r=B.url();if(!(e?.(r)||n))return;const i=B.text(),c=B.buttonStyle(),d=B.newTab()?void 0:"_self";return E.reset(),De(t,{url:r,text:i,buttonStyle:c,target:d,isUrl:l=>n||!e?!0:e(l)}),setTimeout(()=>{o.focusEditor(t,t.selection??void 0)},0),!0},ot=(t,e)=>o.withoutNormalizing(t,()=>{if(e?.split){if(o.getAboveNode(t,{at:t.selection?.anchor,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.anchor,match:a=>o.isElement(a)&&a.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.anchor}),!0;if(o.getAboveNode(t,{at:t.selection?.focus,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.focus,match:a=>o.isElement(a)&&a.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.focus}),!0}o.unwrapNodes(t,{match:{type:o.getPluginType(t,T)},...e})}),De=(t,{url:e,text:n,buttonStyle:r,target:a,insertTextInButton:i,insertNodesOptions:c,isUrl:d=o.getPluginOptions(t,T).isUrl})=>{const l=t.selection;if(!l)return;const p=o.getAboveNode(t,{at:l,match:{type:o.getPluginType(t,T)}});if(i&&p)return t.insertText(e),!0;if(!d?.(e))return;if(o.isDefined(n)&&n.length===0&&(n=e),p)return ys(e,t,p,a,r,n),!0;const w=o.findNode(t,{at:l,match:{type:o.getPluginType(t,T)}}),[g,f]=w??[],v=fs(t,f,n);if(o.isExpanded(l))return ws(p,t,e,r,a,n),!0;v&&o.removeNodes(t,{at:f});const x=o.getNodeProps(g??{}),S=t.selection?.focus.path;if(!S)return;const N=o.getNodeLeaf(t,S);return n?.length||(n=e),Re(t,{...x,url:e,target:a,children:[{...N,text:n}]},c),!0};function fs(t,e,n){return e&&n?.length&&n!==o.getEditorString(t,e)}function ws(t,e,n,r,a,i){t?ot(e,{at:t[1]}):ot(e,{split:!0}),Me(e,{url:n,buttonStyle:r,target:a}),Yt(e,{text:i})}function ys(t,e,n,r,a,i){(t!==n[0]?.url||r!==n[0]?.target||a!==n[0]?.buttonStyle)&&o.setNodes(e,{url:t,target:r,buttonStyle:a},{at:n[1]}),Yt(e,{text:i})}const Yt=(t,{text:e})=>{const n=o.getAboveNode(t,{match:{type:o.getPluginType(t,T)}});if(n){const[r,a]=n;if(e?.length&&e!==o.getEditorString(t,a)){const i=r.children[0];o.replaceNodeChildren(t,{at:a,nodes:{...i,text:e},insertOptions:{select:!0}})}}},Me=(t,{url:e,buttonStyle:n,target:r,...a})=>{o.wrapNodes(t,{type:o.getPluginType(t,T),url:e,buttonStyle:n,target:r,children:[]},{split:!0,...a})},xs=(t,e)=>{const n=o.getAboveNode(t,{match:{type:T}});return Array.isArray(n)?e(n[0]):""},Fe=t=>xs(t,e=>e.url??""),Oe=(t,{url:e,text:n="",buttonStyle:r="primary",target:a,children:i})=>({type:o.getPluginType(t,T),url:e,target:a,buttonStyle:r,children:i??[{text:n}]}),_e=(t,{focused:e}={})=>{if(B.mode()==="edit"){St(t);return}Qt(t,{focused:e})},St=t=>{const e=o.findNode(t,{match:{type:o.getPluginType(t,T)}});if(!e)return;const[n,r]=e;let a=o.getEditorString(t,r);E.url(n.url),E.newTab(n.target===void 0),a===n.url&&(a=""),E.text(a),E.isEditing(!0)},Qt=(t,{focused:e}={})=>{B.mode()||!e||o.isRangeAcrossBlocks(t,{at:t.selection})||o.someNode(t,{match:{type:o.getPluginType(t,T)}})||(E.text(o.getEditorString(t,t.selection)),E.show("insert",t.id))},jt={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},kt={buttonPrimary:{...jt,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...jt,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...jt,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},bs=t=>{const{attributes:e,children:n}=t,r=t.element.url||t.element.chosenLink?.searchResult?.link||"",a=t.element.target||"_self",i=String(t.element.buttonStyle)||"primary";return s.jsx(vs,{attributes:e,href:r,target:a,styles:kt[`button${i.charAt(0).toUpperCase()+i.slice(1)}`],children:n})},vs=({attributes:t,styles:e={hover:{}},children:n,href:r="#",target:a})=>{const[i,c]=u.useState(!1);return s.jsx("a",{...t,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:r,target:a,style:i?{...e,...e.hover}:e,children:n})};class Cs extends o.MarkupElement{constructor(e=T,n=bs){super(e,n)}}const Ue=u.forwardRef((t,e)=>{const n=o.useEditorRef();return s.jsx(o.ToolbarButton,{ref:e,...t,onMouseDown:r=>{r.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{_e(n,{focused:!0})},children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconButton,{size:16})})})});Ue.displayName="ButtonToolbarButton";const Ss=({editorId:t,id:e})=>{const n=o.useEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection}),a=o.getPluginType(n,T),i=!!n?.selection&&o.someNode(n,{match:{type:a}});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(Ue,{pressed:i,disabled:!r,tooltip:o.getTooltip(r?`Button
2
2
  ${o.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},rt="link-plugin";var y=(t=>(t.heading1="heading1",t.heading2="heading2",t.heading3="heading3",t.heading4="heading4",t.custom1="custom1",t.custom2="custom2",t.custom3="custom3",t.quote="quote",t.imageCaption="imageCaption",t.imageTitle="imageTitle",t.p="p",t))(y||{});const P={heading1:{fontSize:"var(--f-theme-settings-heading1-font-size)",lineHeight:"var(--f-theme-settings-heading1-line-height)",marginTop:"var(--f-theme-settings-heading1-margin-top)",marginBottom:"var(--f-theme-settings-heading1-margin-bottom)",textDecoration:"var(--f-theme-settings-heading1-text-decoration)",fontStyle:"var(--f-theme-settings-heading1-font-style)",textTransform:"var(--f-theme-settings-heading1-text-transform)",letterSpacing:"var(--f-theme-settings-heading1-letter-spacing)",fontWeight:"var(--f-theme-settings-heading1-font-weight)",fontFamily:"var(--f-theme-settings-heading1-font-family)",color:"var(--f-theme-settings-heading1-color)"},heading2:{fontSize:"var(--f-theme-settings-heading2-font-size)",lineHeight:"var(--f-theme-settings-heading2-line-height)",marginTop:"var(--f-theme-settings-heading2-margin-top)",marginBottom:"var(--f-theme-settings-heading2-margin-bottom)",textDecoration:"var(--f-theme-settings-heading2-text-decoration)",fontStyle:"var(--f-theme-settings-heading2-font-style)",textTransform:"var(--f-theme-settings-heading2-text-transform)",letterSpacing:"var(--f-theme-settings-heading2-letter-spacing)",fontWeight:"var(--f-theme-settings-heading2-font-weight)",fontFamily:"var(--f-theme-settings-heading2-font-family)",color:"var(--f-theme-settings-heading2-color)"},heading3:{fontSize:"var(--f-theme-settings-heading3-font-size)",lineHeight:"var(--f-theme-settings-heading3-line-height)",marginTop:"var(--f-theme-settings-heading3-margin-top)",marginBottom:"var(--f-theme-settings-heading3-margin-bottom)",textDecoration:"var(--f-theme-settings-heading3-text-decoration)",fontStyle:"var(--f-theme-settings-heading3-font-style)",textTransform:"var(--f-theme-settings-heading3-text-transform)",letterSpacing:"var(--f-theme-settings-heading3-letter-spacing)",fontWeight:"var(--f-theme-settings-heading3-font-weight)",fontFamily:"var(--f-theme-settings-heading3-font-family)",color:"var(--f-theme-settings-heading3-color)"},heading4:{fontSize:"var(--f-theme-settings-heading4-font-size)",lineHeight:"var(--f-theme-settings-heading4-line-height)",marginTop:"var(--f-theme-settings-heading4-margin-top)",marginBottom:"var(--f-theme-settings-heading4-margin-bottom)",textDecoration:"var(--f-theme-settings-heading4-text-decoration)",fontStyle:"var(--f-theme-settings-heading4-font-style)",textTransform:"var(--f-theme-settings-heading4-text-transform)",letterSpacing:"var(--f-theme-settings-heading4-letter-spacing)",fontWeight:"var(--f-theme-settings-heading4-font-weight)",fontFamily:"var(--f-theme-settings-heading4-font-family)",color:"var(--f-theme-settings-heading4-color)"},custom1:{fontSize:"var(--f-theme-settings-custom1-font-size)",lineHeight:"var(--f-theme-settings-custom1-line-height)",marginTop:"var(--f-theme-settings-custom1-margin-top)",marginBottom:"var(--f-theme-settings-custom1-margin-bottom)",textDecoration:"var(--f-theme-settings-custom1-text-decoration)",fontStyle:"var(--f-theme-settings-custom1-font-style)",textTransform:"var(--f-theme-settings-custom1-text-transform)",letterSpacing:"var(--f-theme-settings-custom1-letter-spacing)",fontWeight:"var(--f-theme-settings-custom1-font-weight)",fontFamily:"var(--f-theme-settings-custom1-font-family)",color:"var(--f-theme-settings-custom1-color)"},custom2:{fontSize:"var(--f-theme-settings-custom2-font-size)",lineHeight:"var(--f-theme-settings-custom2-line-height)",marginTop:"var(--f-theme-settings-custom2-margin-top)",marginBottom:"var(--f-theme-settings-custom2-margin-bottom)",textDecoration:"var(--f-theme-settings-custom2-text-decoration)",fontStyle:"var(--f-theme-settings-custom2-font-style)",textTransform:"var(--f-theme-settings-custom2-text-transform)",letterSpacing:"var(--f-theme-settings-custom2-letter-spacing)",fontWeight:"var(--f-theme-settings-custom2-font-weight)",fontFamily:"var(--f-theme-settings-custom2-font-family)",color:"var(--f-theme-settings-custom2-color)"},custom3:{fontSize:"var(--f-theme-settings-custom3-font-size)",lineHeight:"var(--f-theme-settings-custom3-line-height)",marginTop:"var(--f-theme-settings-custom3-margin-top)",marginBottom:"var(--f-theme-settings-custom3-margin-bottom)",textDecoration:"var(--f-theme-settings-custom3-text-decoration)",fontStyle:"var(--f-theme-settings-custom3-font-style)",textTransform:"var(--f-theme-settings-custom3-text-transform)",letterSpacing:"var(--f-theme-settings-custom3-letter-spacing)",fontWeight:"var(--f-theme-settings-custom3-font-weight)",fontFamily:"var(--f-theme-settings-custom3-font-family)",color:"var(--f-theme-settings-custom3-color)"},p:{fontSize:"var(--f-theme-settings-body-font-size)",lineHeight:"var(--f-theme-settings-body-line-height)",marginTop:"var(--f-theme-settings-body-margin-top)",marginBottom:"var(--f-theme-settings-body-margin-bottom)",textDecoration:"var(--f-theme-settings-body-text-decoration)",fontStyle:"var(--f-theme-settings-body-font-style)",textTransform:"var(--f-theme-settings-body-text-transform)",letterSpacing:"var(--f-theme-settings-body-letter-spacing)",fontWeight:"var(--f-theme-settings-body-font-weight)",fontFamily:"var(--f-theme-settings-body-font-family)",color:"var(--f-theme-settings-body-color)"},quote:{fontSize:"var(--f-theme-settings-quote-font-size)",lineHeight:"var(--f-theme-settings-quote-line-height)",marginTop:"var(--f-theme-settings-quote-margin-top)",marginBottom:"var(--f-theme-settings-quote-margin-bottom)",textDecoration:"var(--f-theme-settings-quote-text-decoration)",fontStyle:"var(--f-theme-settings-quote-font-style)",textTransform:"var(--f-theme-settings-quote-text-transform)",letterSpacing:"var(--f-theme-settings-quote-letter-spacing)",fontWeight:"var(--f-theme-settings-quote-font-weight)",fontFamily:"var(--f-theme-settings-quote-font-family)",color:"var(--f-theme-settings-quote-color)"},imageCaption:{fontSize:"var(--f-theme-settings-image-caption-font-size)",lineHeight:"var(--f-theme-settings-image-caption-line-height)",marginTop:"var(--f-theme-settings-image-caption-margin-top)",marginBottom:"var(--f-theme-settings-image-caption-margin-bottom)",textDecoration:"var(--f-theme-settings-image-caption-text-decoration)",fontStyle:"var(--f-theme-settings-image-caption-font-style)",textTransform:"var(--f-theme-settings-image-caption-text-transform)",letterSpacing:"var(--f-theme-settings-image-caption-letter-spacing)",fontWeight:"var(--f-theme-settings-image-caption-font-weight)",fontFamily:"var(--f-theme-settings-image-caption-font-family)",color:"var(--f-theme-settings-image-caption-color)"},imageTitle:{fontSize:"var(--f-theme-settings-image-title-font-size)",lineHeight:"var(--f-theme-settings-image-title-line-height)",marginTop:"var(--f-theme-settings-image-title-margin-top)",marginBottom:"var(--f-theme-settings-image-title-margin-bottom)",textDecoration:"var(--f-theme-settings-image-title-text-decoration)",fontStyle:"var(--f-theme-settings-image-title-font-style)",textTransform:"var(--f-theme-settings-image-title-text-transform)",letterSpacing:"var(--f-theme-settings-image-title-letter-spacing)",fontWeight:"var(--f-theme-settings-image-title-font-weight)",fontFamily:"var(--f-theme-settings-image-title-font-family)",color:"var(--f-theme-settings-image-title-color)"},[rt]:{fontSize:"var(--f-theme-settings-link-font-size)",lineHeight:"var(--f-theme-settings-link-line-height)",marginTop:"var(--f-theme-settings-link-margin-top)",marginBottom:"var(--f-theme-settings-link-margin-bottom)",textDecoration:"var(--f-theme-settings-link-text-decoration)",fontStyle:"var(--f-theme-settings-link-font-style)",textTransform:"var(--f-theme-settings-link-text-transform)",letterSpacing:"var(--f-theme-settings-link-letter-spacing)",fontWeight:"var(--f-theme-settings-link-font-weight)",fontFamily:"var(--f-theme-settings-link-font-family)",color:"var(--f-theme-settings-link-color)"},...kt},ks=()=>{const t=o.useEditorRef();return s.jsx(o.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:s.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-button-edit-url",href:B.url(),target:"_blank",rel:"noopener noreferrer",style:P[rt],className:"tw-break-all",children:B.url()}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{onClick:()=>{St(t)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconPen,{size:16})}),s.jsx("button",{onClick:()=>{ot(t),o.focusEditor(t,t.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconTrashBin,{size:16})})]})]})})},He=t=>t.filter(e=>!!e.title?.trim()),ze=()=>s.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:s.jsx(h.LoadingCircle,{size:"small"})}),Ts=({section:t,selectedUrl:e,onSelectUrl:n})=>{const r=t.permanentLink===e;return s.jsx("button",{"data-test-id":"internal-link-selector-section-link",type:"button","data-is-active":r,className:`
3
3
  tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full
4
4
  ${r?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[s.jsx(k.IconDocumentText,{size:16}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Section"})]})})},Ps=({page:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:a})=>{const[i,c]=u.useState(t.id===r.documentId),[d,l]=u.useState([]),p=t.permanentLink===e;u.useEffect(()=>{(async()=>{const f=await a(t.id),v=He(f);l(v)})()},[t.id,a]),u.useEffect(()=>{t.id===r.pageId&&c(!0)},[r,t.id]);const w=d.length>0;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","data-test-id":"internal-link-selector-page-link",className:`