@frontify/guideline-blocks-settings 0.30.1 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(l,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@frontify/sidebar-settings"),require("react/jsx-runtime"),require("@frontify/fondue"),require("react"),require("@frontify/app-bridge"),require("@dnd-kit/core"),require("@dnd-kit/modifiers"),require("@dnd-kit/sortable"),require("@react-aria/focus"),require("@udecode/plate"),require("slate-react"),require("@react-stately/overlays"),require("slate"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","@frontify/sidebar-settings","react/jsx-runtime","@frontify/fondue","react","@frontify/app-bridge","@dnd-kit/core","@dnd-kit/modifiers","@dnd-kit/sortable","@react-aria/focus","@udecode/plate","slate-react","@react-stately/overlays","slate","@ctrl/tinycolor"],m):(l=typeof globalThis<"u"?globalThis:l||self,m(l.GuidelineBlocksSettings={},l.sidebarSettings,l.jsxRuntime,l.fondue,l.React,l.appBridge,l.core,l.modifiers,l.sortable,l.focus,l.plate,l.slateReact,l.overlays,l.slate,l.tinycolor))})(this,function(l,m,r,i,b,W,E,Jt,le,ze,o,$e,Zt,Rt,V){"use strict";const Sa="",U=e=>e.filter(Boolean).join(" "),en=({onDrop:e,label:t,icon:n,secondaryLabel:a,isLoading:s,fillParentContainer:c,onAssetChooseClick:d,onUploadClick:g,withMenu:u=!0,onClick:w,validFileType:f,verticalLayout:h})=>{const[y,k]=b.useState(!1),[C,S]=b.useState(),A=b.useRef(null),[I,F]=b.useState(void 0),$=P=>{if(P.preventDefault(),k(!1),!D(P.dataTransfer.files)){F("Invalid"),setTimeout(()=>{F(void 0)},1e3);return}e==null||e(P.dataTransfer.files)},D=P=>{if(!f)return!0;for(let M=0;M<P.length;M++){const O=P[M].name.split(".").pop()??"";if(!W.FileExtensionSets[f].includes(O))return!1}return!0},_=P=>{if(!A.current||s)return;const{left:M,top:O}=A.current.getBoundingClientRect(),ve=P.clientX-M,ie=P.clientY-O;S([ve,ie])};return r.jsxs("button",{ref:A,"data-test-id":"block-inject-button",className:U(["tw-font-body tw-relative tw-text-sm tw-leading-4 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",h?"[&: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",c?"tw-h-full":"tw-h-[72px]",y&&!s?"tw-border-dashed":"tw-border-solid",C&&"tw-bg-blank-state-pressed-inverse",y&&"tw-bg-blank-state-weak-inverse",I?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",s||C||y||I?"":"tw-text-text-weak 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",(y||C)&&!I?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:e?P=>{var M;if(k(!0),f==="Images")for(const O of Array.from(P.dataTransfer.items))(M=O==null?void 0:O.type)!=null&&M.startsWith("image/")?F(void 0):F("Invalid")}:void 0,onDragLeave:e?()=>{k(!1),F(void 0)}:void 0,onDrop:e?$:void 0,onClick:P=>{u&&_(P),w==null||w()},children:[s?r.jsx(i.LoadingCircle,{}):I?r.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[r.jsx(i.IconExclamationMarkTriangle,{}),I]}):r.jsxs(r.Fragment,{children:[n&&r.jsx("div",{children:n}),(t||a)&&r.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[t&&r.jsx("div",{className:"tw-font-medium",children:t}),a&&r.jsx("div",{className:"tw-font-normal",children:a})]})]}),C&&r.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:C[0],top:C[1]},children:r.jsx(i.Flyout,{onOpenChange:P=>!P&&S(void 0),isOpen:!0,fitContent:!0,hug:!1,legacyFooter:!1,trigger:r.jsx("div",{}),children:r.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[...g?[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Upload asset",onClick:()=>{g(),S(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconArrowCircleUp20,{})})}]:[],...d?[{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Browse asset",onClick:()=>{d(),S(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconImageStack20,{})})}]:[]]}]})})})]})},q=e=>{const t=a=>typeof a=="object"&&["red","green","blue"].every(c=>a.hasOwnProperty(c)),n=a=>{const s=typeof a.alpha=="number"?a.alpha:1;return{r:a.red,g:a.green,b:a.blue,a:s}};return t(e)?n(e):e},tn=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),nn=(e,t)=>{const n=tn(e)?q(e):e,a=new V.TinyColor(n);return t?a.getBrightness()<t:a.isDark()||a.getAlpha()>.25&&a.getAlpha()<1},rn=e=>new V.TinyColor(q(e)).toHex8String(),an=e=>new V.TinyColor(q(e)).toHexString(),ke=e=>new V.TinyColor(q(e)).toRgbString(),sn=(e,t)=>new V.TinyColor(t).setAlpha(e).toRgbString(),on=e=>{const{r:t,g:n,b:a,a:s}=new V.TinyColor(e);return{red:t,green:n,blue:a,alpha:s}},We=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),ln=(e,t)=>{const n=We(e)?q(e):e,a=We(t)?q(t):t;let s=new V.TinyColor(n);const c=new V.TinyColor(a);for(;V.readability(s,c)<4.5;)s=s.darken(1);return s.toRgbString()},cn=(e,t,n)=>{const a=[...e],s=n<0?a.length+n:n;if(s>=0&&s<a.length){const c=a.splice(t,1)[0];a.splice(s,0,c)}return a},dn=e=>({backgroundColor:ke(e)});var H=(e=>(e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted",e))(H||{});const qe={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var z=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(z||{});const G={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var K=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(K||{});const J={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var j=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(j||{});const Z={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var X=(e=>(e.Global="Global",e.Custom="Custom",e))(X||{}),Q=(e=>(e.Auto="Auto",e.S="S",e.M="M",e.L="L",e))(Q||{});const Ge={Auto:"4px",S:"10px",M:"30px",L:"50px"},un={red:241,green:241,blue:241,alpha:1},Ke={red:234,green:235,blue:235,alpha:1},gn="1px",ae="24px",se="24px",hn=(e=H.Solid,t="1px",n=Ke)=>({borderStyle:qe[e],borderWidth:t,borderColor:ke(n)}),mn=(e,t=!1,n)=>({borderRadius:t?n:G[e]}),je="Drag or press ↵ to move",Xe="Move with ↑↓←→ and confirm with ↵",Qe=({children:e})=>r.jsx("div",{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:e}),fn=e=>e==="IMAGE"?r.jsx(i.IconImage24,{}):e==="VIDEO"?r.jsx(i.IconPlayFrame24,{}):e==="AUDIO"?r.jsx(i.IconMusicNote24,{}):r.jsx(i.IconDocument24,{}),pe=b.forwardRef(({item:e,isEditing:t,draggableProps:n,transformStyle:a,isDragging:s,isOverlay:c,isLoading:d,onDelete:g,onReplaceWithBrowse:u,onReplaceWithUpload:w,onDownload:f},h)=>{const[y,k]=b.useState(),[C,{selectedFiles:S}]=W.useFileInput({multiple:!0,accept:"image/*"}),[A,{results:I,doneAll:F}]=W.useAssetUpload(),{focusProps:$,isFocusVisible:D}=ze.useFocusRing();b.useEffect(()=>{S&&A(S[0])},[S]),b.useEffect(()=>{F&&w(I[0])},[F,I]);const _=d||S&&!F;return r.jsxs("button",{"aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>f==null?void 0:f(),ref:h,style:{...a,opacity:s&&!c?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:U(["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-box-neutral-hover",s?"tw-bg-box-neutral-hover":""]),children:[r.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:_?r.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small}):fn(e.objectType)}),r.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[r.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:e.title}),r.jsx("div",{className:"tw-text-text-weak",children:`${e.fileSizeHumanReadable} - ${e.extension}`})]}),t&&r.jsxs("div",{"data-test-id":"attachments-actionbar",className:U(["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",c||(y==null?void 0:y.id)===e.id?"tw-opacity-100":"tw-opacity-0"]),children:[r.jsx("button",{...$,...n,"aria-label":"Drag attachment",className:U([" tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed 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 tw-h-9 tw-w-9 ",s||c?"tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed":"tw-cursor-grab hover:tw-bg-button-background-hover",D&&i.FOCUS_STYLE,D&&"tw-z-[2]"]),children:r.jsx(i.IconGrabHandle20,{})}),r.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:r.jsx(i.Flyout,{placement:i.FlyoutPlacement.Right,isOpen:(y==null?void 0:y.id)===e.id,fitContent:!0,legacyFooter:!1,onOpenChange:P=>k(P?e:void 0),trigger:(P,M)=>r.jsx(i.Button,{ref:M,icon:r.jsx(i.IconPen20,{}),emphasis:i.ButtonEmphasis.Default,onClick:()=>k(e)}),children:r.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Replace with upload",onClick:()=>{C(),k(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconArrowCircleUp20,{})})},{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Replace with asset",onClick:()=>{u(),k(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconImageStack20,{})})}]},{id:"menu-delete",menuItems:[{id:"delete",size:i.MenuItemContentSize.XSmall,title:"Delete",style:i.MenuItemStyle.Danger,onClick:()=>{g(),k(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconTrashBin20,{})})}]}]})})})]})]})});pe.displayName="AttachmentItem";const wn=e=>{const{attributes:t,listeners:n,setNodeRef:a,transform:s,transition:c,isDragging:d}=le.useSortable({id:e.item.id}),g={transform:s?`translate(${s.x}px, ${s.y}px)`:"",transition:c,zIndex:d?2:1},u={...t,...n};return r.jsx(pe,{ref:a,isDragging:d,transformStyle:g,draggableProps:u,...e})},yn=({children:e,isFlyoutOpen:t})=>r.jsxs("div",{className:U(["tw-flex tw-text-[13px] tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",t?"tw-bg-box-neutral-pressed tw-text-box-neutral-inverse-pressed":"tw-bg-base hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed tw-text-box-neutral-inverse hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed"]),children:[r.jsx(i.IconPaperclip16,{}),e,r.jsx(i.IconCaretDown12,{})]}),Ye=({items:e=[],onDelete:t,onReplaceWithBrowse:n,onReplaceWithUpload:a,onBrowse:s,onUpload:c,onSorted:d,appBridge:g,triggerComponent:u=yn,isOpen:w,onOpenChange:f})=>{const[h,y]=b.useState(e),[k,C]=b.useState(!1),S=E.useSensors(E.useSensor(E.PointerSensor),E.useSensor(E.KeyboardSensor)),[A,I]=b.useState(void 0),[F,$]=b.useState(!1),[D,_]=b.useState([]),[P,M]=b.useState(null),O=W.useEditorState(g),ve=w!==void 0,ie=ve?w:k,re=h==null?void 0:h.find(p=>p.id===A),[ba,{results:Kt,doneAll:jt}]=W.useAssetUpload({onUploadProgress:()=>!F&&$(!0)}),oe=p=>{const L=ve?f:C;L==null||L(p)};b.useEffect(()=>{y(e)},[e]),b.useEffect(()=>{P&&($(!0),ba(P))},[P]),b.useEffect(()=>{(async()=>{jt&&(await c(Kt),$(!1))})()},[jt,Kt]);const va=()=>{oe(!1),g.openAssetChooser(p=>{s(p),g.closeAssetChooser(),oe(!0)},{multiSelection:!0,selectedValueIds:h.map(p=>p.id)})},Xt=p=>{oe(!1),g.openAssetChooser(async L=>{oe(!0),g.closeAssetChooser(),_([...D,p.id]),await n(p,L[0]),_(D.filter(Y=>Y!==p.id))},{multiSelection:!1,selectedValueIds:h.map(L=>L.id)})},Qt=async(p,L)=>{_([...D,p.id]),await a(p,L),_(D.filter(Y=>Y!==p.id))},ka=p=>{const{active:L}=p;I(L.id)},pa=p=>{const{active:L,over:Y}=p;if(Y&&L.id!==Y.id&&h){const Ca=h.findIndex(Ve=>Ve.id===L.id),xa=h.findIndex(Ve=>Ve.id===Y.id),Yt=le.arrayMove(h,Ca,xa);y(Yt),d(Yt)}I(void 0)};return O||((h==null?void 0:h.length)??0)>0?r.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Attachments",disabled:ie,enterDelay:500,triggerElement:r.jsx("div",{"data-test-id":"attachments-flyout-button",children:r.jsx(i.Flyout,{placement:i.FlyoutPlacement.BottomRight,onOpenChange:p=>oe(re?!0:p),isOpen:ie,hug:!1,fitContent:!0,legacyFooter:!1,trigger:r.jsx(u,{isFlyoutOpen:ie,children:r.jsx("div",{children:e.length>0?e.length:"Add"})}),children:r.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[h.length>0&&r.jsxs(E.DndContext,{sensors:S,collisionDetection:E.closestCenter,onDragStart:ka,onDragEnd:pa,modifiers:[Jt.restrictToWindowEdges],children:[r.jsx(le.SortableContext,{items:h,strategy:le.rectSortingStrategy,children:r.jsx("div",{className:"tw-border-b tw-border-b-line",children:h.map(p=>r.jsx(wn,{isEditing:O,isLoading:D.includes(p.id),item:p,onDelete:()=>t(p),onReplaceWithBrowse:()=>Xt(p),onReplaceWithUpload:L=>Qt(p,L),onDownload:()=>g.dispatch({name:"downloadAsset",payload:p})},p.id))})}),r.jsx(E.DragOverlay,{children:re&&r.jsx(pe,{isOverlay:!0,isEditing:O,item:re,isDragging:!0,onDelete:()=>t(re),onReplaceWithBrowse:()=>Xt(re),onReplaceWithUpload:p=>Qt(re,p)},A)})]}),O&&r.jsxs("div",{className:"tw-px-5 tw-py-3",children:[r.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),r.jsx(i.AssetInput,{isLoading:F,size:i.AssetInputSize.Small,onUploadClick:p=>M(p),onLibraryClick:va})]})]})})})}):null},Je=(e,t)=>{const{blockAssets:n,updateAssetIdsFromKey:a}=W.useBlockAssets(e),s=(n==null?void 0:n[t])||[];return{onAttachmentsAdd:async w=>{const f=s.map(h=>h.id);for(const h of w)f.push(h.id);await a(t,f)},onAttachmentDelete:async w=>{const f=s.filter(h=>h.id!==w.id).map(h=>h.id);await a(t,f)},onAttachmentReplace:async(w,f)=>{const h=s.map(y=>y.id===w.id?f.id:y.id);await a(t,h)},onAttachmentsSorted:async w=>{const f=w.map(h=>h.id);await a(t,f)},attachments:s,appBridge:e}},Ze=b.createContext(null),Re=({appBridge:e,children:t,assetId:n})=>{const a=Je(e,n);return r.jsx(Ze.Provider,{value:a,children:t})},et=()=>{const e=b.useContext(Ze);if(!e)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return e},bn=(e,t)=>{const n=a=>r.jsx(Re,{appBridge:a.appBridge,assetId:t,children:r.jsx(e,{...a})});return n.displayName="withAttachmentsProvider",n},vn=[E.KeyboardCode.Down,E.KeyboardCode.Right,E.KeyboardCode.Up,E.KeyboardCode.Left],tt=(e,t)=>(n,{currentCoordinates:a,context:{activeNode:s}})=>{if(n.preventDefault(),vn.includes(n.code)){const c=(s==null?void 0:s.offsetWidth)??0,d=(s==null?void 0:s.offsetHeight)??0;switch(n.code){case E.KeyboardCode.Right:return{...a,x:a.x+c+e};case E.KeyboardCode.Left:return{...a,x:a.x-c-e};case E.KeyboardCode.Down:return{...a,y:a.y+d+t};case E.KeyboardCode.Up:return{...a,y:a.y-d-t}}}},kn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},pn=(e=0,t=0)=>{const n=tt(e,t);return E.useSensors(E.useSensor(E.PointerSensor),E.useSensor(E.KeyboardSensor,{coordinateGetter:n,keyboardCodes:kn}))},ce=(e,t)=>{const n=[i.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded","tw-text-xs tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return t?n.push("tw-bg-box-neutral-pressed","tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed","tw-text-text-weak hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),U(n)},Cn=({children:e,isFlyoutOpen:t})=>r.jsxs("div",{className:ce("pointer",t),children:[r.jsx(i.IconPaperclip16,{}),e,r.jsx(i.IconCaretDown12,{})]}),xn=({isOpen:e,onOpenChange:t})=>{const{appBridge:n,attachments:a,onAttachmentsAdd:s,onAttachmentDelete:c,onAttachmentReplace:d,onAttachmentsSorted:g}=et();return r.jsx(Ye,{onUpload:s,onDelete:c,onReplaceWithBrowse:d,onReplaceWithUpload:d,onSorted:g,onBrowse:s,items:a,appBridge:n,triggerComponent:Cn,isOpen:e,onOpenChange:t})},nt=({items:e,flyoutMenu:t,attachments:n,isDragging:a})=>r.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[n.isEnabled&&r.jsx(Qe,{children:r.jsx(xn,{isOpen:n.isOpen&&!a,onOpenChange:n.onOpenChange})}),r.jsxs(Qe,{children:[e.map((s,c)=>"draggableProps"in s?r.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,open:a,position:i.TooltipPosition.Top,content:r.jsx("div",{children:a?Xe:s.tooltip??je}),triggerElement:r.jsx("button",{ref:s.setActivatorNodeRef,"data-test-id":"block-item-wrapper-toolbar-btn",...s.draggableProps,className:ce("grab",a),children:s.icon})},c):r.jsx(i.LegacyTooltip,{withArrow:!0,enterDelay:300,hoverDelay:0,disabled:a,position:i.TooltipPosition.Top,content:r.jsx("div",{children:s.tooltip??""}),triggerElement:r.jsx("button",{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:s.onClick,className:ce("pointer"),children:s.icon})},c)),t.items.length>0&&r.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,disabled:a||t.isOpen,position:i.TooltipPosition.Top,content:r.jsx("div",{children:"Options"}),triggerElement:r.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:r.jsx(i.Flyout,{isOpen:t.isOpen&&!a,legacyFooter:!1,fitContent:!0,hug:!1,onOpenChange:t.onOpenChange,trigger:r.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-flyout",className:ce("pointer",t.isOpen&&!a),children:r.jsx(i.IconDotsHorizontal16,{})}),children:r.jsx(i.ActionMenu,{menuBlocks:t.items.map((s,c)=>({id:c.toString(),menuItems:s.map((d,g)=>({id:c.toString()+g.toString(),size:i.MenuItemContentSize.XSmall,title:d.title,style:d.style,onClick:()=>{t.onOpenChange(!1),d.onClick()},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:d.icon})}))}))})})})})]})]}),Sn=({children:e,toolbarFlyoutItems:t,toolbarItems:n,shouldHideWrapper:a,shouldHideComponent:s=!1,isDragging:c,shouldFillContainer:d,outlineOffset:g=2,shouldBeShown:u=!1,showAttachments:w=!1})=>{const[f,h]=b.useState(u),[y,k]=b.useState(!1),C=b.useRef(null);if(a)return r.jsx(r.Fragment,{children:e});const S=n==null?void 0:n.filter(I=>I!==void 0),A=f||y||u;return r.jsxs("div",{ref:C,"data-test-id":"block-item-wrapper",style:{outlineOffset:g},className:U(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",d&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",A&&"tw-outline",s&&"tw-opacity-0"]),children:[r.jsx("div",{style:{right:-1-g,bottom:`calc(100% - ${2+g}px)`},className:U(["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",A&&"tw-opacity-100"]),children:r.jsx(nt,{flyoutMenu:{items:t,isOpen:f,onOpenChange:h},attachments:{isEnabled:w,isOpen:y,onOpenChange:k},items:S,isDragging:c})}),e]})},Pn=({onDownload:e})=>{const{isFocused:t,focusProps:n}=ze.useFocusRing();return r.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Download",enterDelay:500,triggerElement:r.jsx("button",{tabIndex:0,"aria-label":"Download",...n,className:U(["tw-outline-none tw-rounded",t&&i.FOCUS_STYLE]),onClick:e,onPointerDown:a=>a.preventDefault(),children:r.jsx("span",{"data-test-id":"download-button",className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:r.jsx(i.IconArrowCircleDown16,{})})})})},En=({value:e="",gap:t,columns:n,show:a=!0,plugins:s})=>{const[c,d]=b.useState(null);return b.useEffect(()=>{(async()=>d(await i.serializeRawToHtmlAsync(e,s,n,t)))()},[e,n,t,s]),!a||c==="<br />"?null:c!==null?r.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:c}}):r.jsx("div",{className:"tw-rounded-sm tw-bg-base-alt tw-animate-pulse tw-h-full tw-min-h-[10px] tw-w-full"})},rt=e=>{if(!e)return!1;const t=n=>n.some(a=>a.text?a.text!=="":a.children?t(a.children):!1);try{const n=JSON.parse(e);return t(n)}catch{return!1}},In=(e="p",t="",n)=>rt(t)?t:JSON.stringify([{type:e,children:[{text:t,textStyle:e}],align:n}]),Tn=(e,t,n)=>e===X.Custom?t:n,Bn=e=>e.map(at),at=e=>({id:e.id,title:e.name,colors:e.colors.map(t=>({alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}))}),Ce=(e,t)=>{const n=o.getAboveNode(e,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},st=e=>Ce(e,t=>{var n,a;return((a=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:a.link)||""}),it=e=>Ce(e,t=>t.url||""),ot=e=>{var t,n;return e.url||((n=(t=e.chosenLink)==null?void 0:t.searchResult)==null?void 0:n.link)||""},lt=e=>Ce(e,ot),xe=/^\/(document|r)\/\S+$/i,de=e=>{if(xe.test(e))return e;try{return new URL(e),e}catch{return`https://${e}`}},ue=e=>{if(xe.test(e))return!0;try{const t=new URL(e);return["http:","https:","mailto:","tel:"].includes(t.protocol)&&t.pathname!==""}catch{return!1}},R=e=>ue(de(e))||e==="",ct=(e,{type:t})=>{const{apply:n,normalizeNode:a}=e;return e.apply=s=>{if(s.type!=="set_selection"){n(s);return}const c=s.newProperties;if(!(c!=null&&c.focus)||!c.anchor||!o.isCollapsed(c)){n(s);return}const d=o.getAboveNode(e,{at:c,match:{type:o.getPluginType(e,x)}});if(d){const[,g]=d;let u;o.isStartPoint(e,c.focus,g)&&(u=o.getPreviousNodeEndPoint(e,g)),o.isEndPoint(e,c.focus,g)&&(u=o.getNextNodeStartPoint(e,g)),u&&(s.newProperties={anchor:u,focus:u})}n(s)},e.normalizeNode=([s,c])=>{if(s.type===o.getPluginType(e,x)){const d=e.selection;if(d&&o.isCollapsed(d)&&o.isEndPoint(e,d.focus,c)){const g=o.getNextNodeStartPoint(e,c);if(g)o.select(e,g);else{const u=Rt.Path.next(c);o.insertNodes(e,{text:""},{at:u}),o.select(e,u)}}}a([s,c])},o.withRemoveEmptyNodes(e,o.mockPlugin({options:{types:t}}))},dt=(e,t,n)=>{o.insertNodes(e,[mt(e,t)],n)},Se=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(e=>({reset:()=>{e.url(""),e.text(""),e.buttonStyle("primary"),e.newTab(!1),e.mode(""),e.isEditing(!1)}})).extendActions(e=>({show:(t,n)=>{e.mode(t),e.isEditing(!1),e.openEditorId(n)},hide:()=>{e.reset(),e.openEditorId(null)}})).extendSelectors(e=>({isOpen:t=>e.openEditorId===t})),T=Se.set,N=Se.get,ee=()=>Se.use,Pe=e=>{if(!e.selection)return;const{isUrl:t,forceSubmit:n}=o.getPluginOptions(e,x),a=N.url();if(!((t==null?void 0:t(a))||n))return;const c=N.text(),d=N.buttonStyle(),g=N.newTab()?void 0:"_self";return T.hide(),ut(e,{url:a,text:c,buttonStyle:d,target:g,isUrl:u=>n||!t?!0:t(u)}),setTimeout(()=>{o.focusEditor(e,e.selection??void 0)},0),!0},te=(e,t)=>o.withoutNormalizing(e,()=>{var n,a,s,c,d,g;if(t!=null&&t.split){if(o.getAboveNode(e,{at:(n=e.selection)==null?void 0:n.anchor,match:{type:o.getPluginType(e,x)}}))return o.splitNodes(e,{at:(a=e.selection)==null?void 0:a.anchor,match:f=>o.isElement(f)&&f.type===o.getPluginType(e,x)}),te(e,{at:(s=e.selection)==null?void 0:s.anchor}),!0;if(o.getAboveNode(e,{at:(c=e.selection)==null?void 0:c.focus,match:{type:o.getPluginType(e,x)}}))return o.splitNodes(e,{at:(d=e.selection)==null?void 0:d.focus,match:f=>o.isElement(f)&&f.type===o.getPluginType(e,x)}),te(e,{at:(g=e.selection)==null?void 0:g.focus}),!0}o.unwrapNodes(e,{match:{type:o.getPluginType(e,x)},...t})}),ut=(e,{url:t,text:n,buttonStyle:a,target:s,insertTextInButton:c,insertNodesOptions:d,isUrl:g=o.getPluginOptions(e,x).isUrl})=>{var I;const u=e.selection;if(!u)return;const w=o.getAboveNode(e,{at:u,match:{type:o.getPluginType(e,x)}});if(c&&w)return e.insertText(t),!0;if(!(g!=null&&g(t)))return;if(o.isDefined(n)&&n.length===0&&(n=t),w)return An(t,e,w,s,a,n),!0;const f=o.findNode(e,{at:u,match:{type:o.getPluginType(e,x)}}),[h,y]=f??[],k=Ln(e,y,n);if(o.isExpanded(u))return Nn(w,e,t,a,s,n),!0;k&&o.removeNodes(e,{at:y});const C=o.getNodeProps(h??{}),S=(I=e.selection)==null?void 0:I.focus.path;if(!S)return;const A=o.getNodeLeaf(e,S);return n!=null&&n.length||(n=t),dt(e,{...C,url:t,target:s,children:[{...A,text:n}]},d),!0};function Ln(e,t,n){return t&&(n==null?void 0:n.length)&&n!==o.getEditorString(e,t)}function Nn(e,t,n,a,s,c){e?te(t,{at:e[1]}):te(t,{split:!0}),gt(t,{url:n,buttonStyle:a,target:s}),Ee(t,{url:n,target:s,text:c})}function An(e,t,n,a,s,c){var d,g,u;(e!==((d=n[0])==null?void 0:d.url)||a!==((g=n[0])==null?void 0:g.target)||s!==((u=n[0])==null?void 0:u.buttonStyle))&&o.setNodes(t,{url:e,target:a,buttonStyle:s},{at:n[1]}),Ee(t,{url:e,text:c,target:a})}const Ee=(e,{text:t})=>{const n=o.getAboveNode(e,{match:{type:o.getPluginType(e,x)}});if(n){const[a,s]=n;if(t!=null&&t.length&&t!==o.getEditorString(e,s)){const c=a.children[0];o.replaceNodeChildren(e,{at:s,nodes:{...c,text:t},insertOptions:{select:!0}})}}},gt=(e,{url:t,buttonStyle:n,target:a,...s})=>{o.wrapNodes(e,{type:o.getPluginType(e,x),url:t,buttonStyle:n,target:a,children:[]},{split:!0,...s})},Fn=(e,t)=>{const n=o.getAboveNode(e,{match:{type:x}});return Array.isArray(n)?t(n[0]):""},ht=e=>Fn(e,t=>t.url??""),mt=(e,{url:t,text:n="",buttonStyle:a="primary",target:s,children:c})=>({type:o.getPluginType(e,x),url:t,target:s,buttonStyle:a,children:c??[{text:n}]}),ft=(e,{focused:t}={})=>{if(N.mode()==="edit"){ge(e);return}Ie(e,{focused:t})},ge=e=>{const t=o.findNode(e,{match:{type:o.getPluginType(e,x)}});if(!t)return;const[n,a]=t;let s=o.getEditorString(e,a);T.url(n.url),T.newTab(n.target===void 0),s===n.url&&(s=""),T.text(s),T.isEditing(!0)},Ie=(e,{focused:t}={})=>{N.mode()||!t||o.isRangeAcrossBlocks(e,{at:e.selection})||o.someNode(e,{match:{type:o.getPluginType(e,x)}})||(T.text(o.getEditorString(e,e.selection)),T.show("insert",e.id))},he={buttonPrimary:{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)",marginTop:"10px",marginBottom:"10px",display:"inline-block",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:{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)",display:"inline-block",marginTop:"10px",marginBottom:"10px",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:{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)",display:"inline-block",marginTop:"10px",marginBottom:"10px",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)"}}},Mn=e=>({...o.useElementProps({...e,elementToAttributes:n=>({url:n.href,buttonStyle:n.buttonStyle||"primary",target:n.target||"_blank"})}),onMouseOver:n=>{n.stopPropagation()}}),On=e=>{const{href:t,target:n,buttonStyle:a}=Mn(e),{attributes:s,children:c}=e;return r.jsx(Dn,{attributes:s,href:t,target:n,styles:he[`button${a.charAt(0).toUpperCase()+a.slice(1)}`],children:c})},Dn=({attributes:e,styles:t={hover:{}},children:n,href:a="#",target:s})=>{const[c,d]=b.useState(!1);return r.jsx("a",{...e,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),href:a,target:s,style:c?{...t,...t.hover}:t,children:n})};class Un extends i.MarkupElement{constructor(t=x,n=On){super(t,n)}}const Hn=({type:e,...t})=>{const n=o.useEditorRef(),a=!!o.isRangeInSameBlock(n,{at:n.selection}),s=!!(n!=null&&n.selection)&&o.someNode(n,{match:{type:e}});return r.jsx(o.ToolbarButton,{tooltip:i.getTooltip(a?`Button
2
- ${i.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block."),classNames:i.getButtonClassNames(a),active:s,onMouseDown:async c=>{n&&(c.preventDefault(),c.stopPropagation(),o.focusEditor(n,n.selection??n.prevSelection??void 0),setTimeout(()=>{ft(n,{focused:!0})},0))},...t})},_n=({editor:e,id:t})=>r.jsx("div",{"data-plugin-id":t,children:r.jsx(Hn,{type:o.getPluginType(e,x),icon:r.jsx("span",{className:"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex",children:r.jsx(i.IconButton16,{})}),styles:i.buttonStyles})}),Vn=()=>{const e=ir({});return r.jsx("div",{"data-test-id":"floating-button-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:r.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[r.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),r.jsxs("span",{className:"tw-flex tw-gap-2",children:[r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(fe.EditButton,{children:r.jsx(i.IconPen16,{})})}),r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(fe.UnlinkButton,{children:r.jsx(i.IconTrashBin16,{})})})]})]})})},zn=({section:e,selectedUrl:t,onSelectUrl:n})=>{const a=e.permanentLink===t;return r.jsx("button",{"data-test-id":"internal-link-selector-section-link",className:i.merge(["tw-py-2 tw-px-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",a?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:r.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[r.jsx(i.IconDocumentText16,{}),r.jsx("span",{className:"tw-text-s",children:e.title}),r.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},$n=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:a,appBridge:s})=>{const[c,d]=b.useState(e.id===a.documentId),g=e.permanentLink===t,{documentSections:u}=W.useDocumentSection(s,e.id),w=[...u.values()],f=w.length>0;return b.useEffect(()=>{e.id===a.pageId&&d(!0)},[a,e.id]),r.jsxs(r.Fragment,{children:[r.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:i.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",f?"tw-pl-7":"tw-pl-12",g?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:r.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[f&&r.jsx("button",{"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!c),children:r.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",c?"tw-rotate-90":""])})}),r.jsx("span",{className:"tw-text-s",children:e.title}),r.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),c&&w.length>0&&w.map(h=>r.jsx(zn,{section:h,selectedUrl:t,onSelectUrl:n},h.id))]})},wt=()=>r.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:r.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small})}),Wn=({appBridge:e,documentId:t,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s})=>{const[c,d]=b.useState([]),[g,u]=b.useState(!0),w=[...c.values()],f=!g&&w.length>0;return b.useEffect(()=>{e.getDocumentPagesByDocumentId(t).then(h=>{const y=h.filter(C=>!!C.category).sort((C,S)=>C.category.sort===S.category.sort?C.sort-S.sort:C.category.sort-S.category.sort),k=h.filter(C=>!C.category).sort((C,S)=>C.sort-S.sort);d([...y,...k])}).finally(()=>{u(!1)})},[]),g?r.jsx(wt,{}):f?r.jsx(r.Fragment,{children:w.map(h=>r.jsx($n,{page:h,appBridge:e,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s},h.id))}):r.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},qn=({document:e,appBridge:t,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s})=>{const[c,d]=b.useState(e.id===s.documentId),g=e.permanentLink===n;return b.useEffect(()=>{e.id===s.documentId&&d(!0)},[s,e.id]),r.jsxs(r.Fragment,{children:[r.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:i.merge(["tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full",g?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>a(e.permanentLink),children:[r.jsx("button",{role:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!c),children:r.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",c?"tw-rotate-90":""])})}),r.jsx(i.IconColorFan16,{}),r.jsx("span",{className:"tw-text-s",children:e.title}),r.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),c&&r.jsx(Wn,{appBridge:t,documentId:e.id,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s})]})},Gn=({appBridge:e,selectedUrl:t,onSelectUrl:n})=>{const[a,s]=b.useState(!0),[c,d]=b.useState([]),[g,u]=b.useState({documentId:void 0,pageId:void 0}),w=[...c.values()];b.useEffect(()=>{t&&w.length>0&&f().then(h=>{u(h)})},[w.length]),b.useEffect(()=>{e.getAllDocuments().then(h=>{d(h)}).finally(()=>{s(!1)})},[]);const f=async()=>{const h={documentId:void 0,pageId:void 0};if(w.find(k=>k.permanentLink===t))return h;for(const k of w){const C=await e.getDocumentPagesByDocumentId(k.id);e.getAllDocuments();const S=[...C.values()];if(!!S.find(I=>I.permanentLink===t))return h.documentId=k.id,h;for(const I of S)if(!![...(await e.getDocumentSectionsByDocumentPageId(I.id)).values()].find(_=>_.permanentLink===t))return h.documentId=k.id,h.pageId=I.id,h}return h};return a?r.jsx(wt,{}):r.jsx(r.Fragment,{children:w.map(h=>r.jsx(qn,{document:h,appBridge:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:g},h.id))})},yt=({appBridge:e,url:t,onUrlChange:n,buttonSize:a=i.ButtonSize.Medium})=>{const{open:s,isOpen:c,close:d}=Zt.useOverlayTriggerState({}),[g,u]=b.useState(t),w=y=>{u(y)},f=y=>{y.key==="Enter"&&h()};b.useEffect(()=>{t&&!g&&u(t)},[t,g]);const h=()=>{n==null||n(g),d()};return r.jsxs("div",{"data-test-id":"internal-link-selector",onKeyDown:f,children:[r.jsx(i.Button,{icon:r.jsx(i.IconLink,{}),size:a,type:i.ButtonType.Button,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,onClick:()=>s(),children:"Internal link"}),r.jsxs(i.Modal,{zIndex:1001,onClose:()=>d(),isOpen:c,isDismissable:!0,children:[r.jsx(i.Modal.Header,{title:"Select internal link"}),r.jsx(i.Modal.Body,{children:r.jsx(Gn,{appBridge:e,selectedUrl:g,onSelectUrl:w})}),r.jsx(i.Modal.Footer,{buttons:[{children:"Cancel",onClick:()=>d(),style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default},{children:"Choose",onClick:y=>{y==null||y.preventDefault(),h()},style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Strong,disabled:!g}]})]})]})},bt=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:a,clearable:s,placeholder:c,newTab:d,openInNewTab:g,url:u="",required:w,info:f,label:h,buttonSize:y,hideInternalLinkButton:k})=>{const C=n?n(u):R(u),S=d??(g?i.CheckboxState.Checked:i.CheckboxState.Unchecked);return r.jsxs("div",{"data-test-id":"link-input",children:[r.jsx(i.FormControl,{label:{children:h,htmlFor:"url",required:w,tooltip:f?{content:f,position:i.TooltipPosition.Top}:void 0},children:r.jsx(i.TextInput,{id:"url",value:u,clearable:s,onChange:e,placeholder:c??"https://example.com",focusOnMount:!0})}),!C&&r.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!k&&r.jsx("div",{className:"tw-mt-3",children:r.jsx(yt,{url:u,appBridge:a,onUrlChange:e,buttonSize:y??i.ButtonSize.Medium})}),r.jsx("div",{className:"tw-mt-3",children:r.jsx(i.Checkbox,{value:"new-tab",label:"Open in new tab",state:S,onChange:t})})]})},vt=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:a,onCancel:s,onSave:c,isValidUrlOrEmpty:d,hasValues:g,testId:u,appBridge:w,children:f})=>r.jsxs("div",{"data-test-id":u,className:"tw-bg-white tw-rounded tw-shadow tw-p-7 tw-min-w-[400px] tw-overflow-y-auto",children:[r.jsx(i.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:r.jsx(i.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:t})}),f,r.jsx("div",{className:"tw-mt-5",children:r.jsx(bt,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:a,isValidUrlOrEmpty:d,appBridge:w})}),r.jsx("div",{className:"tw-mt-3",children:r.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[r.jsx(i.Button,{onClick:s,size:i.ButtonSize.Medium,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,children:"Cancel"}),r.jsx(i.Button,{onClick:c,size:i.ButtonSize.Medium,icon:r.jsx(i.IconCheckMark20,{}),disabled:!g||!d(e==null?void 0:e.url),children:"Save"})]})})]}),Kn=e=>{var n;const t=o.getAboveNode(e,{match:{type:x}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},jn={url:"",text:"",buttonStyle:"primary",newTab:i.CheckboxState.Unchecked},Xn=()=>{const[e,t]=b.useReducer((n,a)=>{const{type:s,payload:c}=a;switch(s){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...c};default:return n}},jn);return[e,t]},Qn=()=>{const e=o.useEditorRef(),[t,n]=Xn();b.useEffect(()=>{const h=Kn(e);n({type:"INIT",payload:{text:N.text(),buttonStyle:h,newTab:N.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:N.url()}})},[n,e]);const a=h=>{n({type:"TEXT",payload:{text:h}})},s=h=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:h}})},c=h=>{n({type:"URL",payload:{url:h}})},d=h=>{n(h?{type:"NEW_TAB"}:{type:"SAME_TAB"})},g=()=>{T.hide()},u=h=>{if(!R(t.url)||!w)return;const y=de(t.url);T.text(t.text),T.url(y),T.buttonStyle(t.buttonStyle),T.newTab(t.newTab===i.CheckboxState.Checked),Pe(e)&&(h==null||h.preventDefault())},w=t.url!==""&&t.text!=="",{appBridge:f}=o.getPluginOptions(e,x);return o.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:a,onButtonStyleChange:s,onUrlChange:c,onToggleTab:d,onCancel:g,onSave:u,hasValues:w,isValidUrlOrEmpty:R,appBridge:f}},me="link-plugin";var v=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e.p="p",e))(v||{});const B={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)"},[me]:{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)"},...he},Yn=()=>{const e=Qn(),{state:t,onButtonStyleChange:n}=e;return r.jsx(vt,{...e,testId:"floating-button-insert",children:r.jsx("div",{className:"tw-pt-5",children:r.jsxs(i.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[r.jsx(Te,{id:"primary",styles:B.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),r.jsx(Te,{id:"secondary",styles:B.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),r.jsx(Te,{id:"tertiary",styles:B.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},Te=({id:e,styles:t,isActive:n,onClick:a,children:s})=>{const[c,d]=b.useState(!1),g=()=>t&&t.hover&&c?{...t,...t.hover}:t;return r.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:a,style:{...g(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:s})},Jn=()=>{const e=ee().isEditing(),t=r.jsx(Yn,{}),n=e?t:r.jsx(Vn,{});return r.jsxs(r.Fragment,{children:[r.jsx(fe.InsertRoot,{children:t}),r.jsx(fe.EditRoot,{children:n})]})},x="button",kt="button-plugin",pt=e=>o.createPluginFactory({key:x,isElement:!0,isInline:!0,props:({element:t})=>({nodeProps:{href:t==null?void 0:t.url,target:t==null?void 0:t.target}}),withOverrides:ct,renderAfterEditable:Jn,options:{isUrl:ue,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:e},then:(t,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:a=>({type:n,url:a.getAttribute("href"),target:a.getAttribute("target")||"_blank"})}})})();class Ct extends i.Plugin{constructor({styles:t=he,...n}){super(kt,{button:_n,markupElement:new Un,...n}),this.styles={},this.styles=t,this.appBridge=n==null?void 0:n.appBridge}plugins(){return[pt(this.appBridge)]}}const Zn=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),a=o.usePlateSelectors(n.id).keyEditor(),s=ee().mode(),c=ee().isOpen(n.id),{triggerFloatingButtonHotkeys:d}=o.getPluginOptions(n,x),g=b.useCallback(()=>{const y=o.getAboveNode(n,{match:{type:o.getPluginType(n,x)}});if(y){const[,k]=y;return o.getRangeBoundingClientRect(n,{anchor:o.getStartPoint(n,k),focus:o.getEndPoint(n,k)})}return o.getDefaultBoundingClientRect()},[n]),u=c&&s==="edit",{update:w,style:f,floating:h}=St({open:u,getBoundingClientRect:g,...e});return b.useEffect(()=>{const y=ht(n);if(y&&T.url(y),n.selection&&o.someNode(n,{match:{type:o.getPluginType(n,x)}})){T.show("edit",n.id),w();return}N.mode()==="edit"&&T.hide()},[n,a,w]),o.useHotkeys(d,y=>{y.preventDefault(),N.mode()==="edit"&&ge(n)},{enableOnContentEditable:!0},[]),or(),xt(),{style:{...f,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,h)}},Rn=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),a=$e.useFocused(),s=ee().mode(),c=ee().isOpen(n.id),{triggerFloatingButtonHotkeys:d}=o.getPluginOptions(n,x);o.useHotkeys(d,f=>{f.preventDefault(),Ie(n,{focused:a})},{enableOnContentEditable:!0},[a]);const{update:g,style:u,floating:w}=St({open:c&&s==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return b.useEffect(()=>{c&&g(),T.updated(c)},[c,g]),xt(),{style:{...u,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,w)}},er=e=>{const t=o.useEditorRef();return{onClick:b.useCallback(()=>{ge(t)},[t]),...e}},tr=o.createComponentAs(e=>{const t=er(e);return o.createElementAs("button",t)}),nr=e=>{const t=o.useEditorRef();return{onClick:b.useCallback(()=>{te(t),o.focusEditor(t,t.selection??void 0)},[t]),...e}},rr=o.createComponentAs(e=>{const t=nr(e);return o.createElementAs(o.Button,t)}),ar=o.createComponentAs(e=>{var n;const t=Zn(e);return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),sr=o.createComponentAs(e=>{var n;const t=Rn(e);return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),fe={EditRoot:ar,InsertRoot:sr,EditButton:tr,UnlinkButton:rr},ir=e=>{const t=ee().updated(),n=b.useRef(null);b.useEffect(()=>{n.current&&t&&setTimeout(()=>{var s;(s=n.current)==null||s.focus()},0)},[t]);const a=b.useCallback(s=>{T.url(s.target.value)},[]);return o.mergeProps({onChange:a,defaultValue:N.url()},{...e,ref:o.useComposedRef(e.ref,n)})},or=()=>{const e=o.useEditorRef();o.useHotkeys("*",t=>{t.key==="Enter"&&Pe(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},xt=()=>{const e=o.useEditorRef();o.useHotkeys("escape",()=>{if(N.mode()==="edit"){if(N.isEditing()){T.show("edit",e.id),o.focusEditor(e,e.selection??void 0);return}T.hide()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},lr=12,cr=-22,dr=96,St=e=>o.useVirtualFloating({placement:"bottom-start",middleware:[o.offset({mainAxis:lr,alignmentAxis:cr}),o.flip({padding:dr})],...e}),ur=({id:e="rte",isEditing:t,value:n,columns:a,gap:s,placeholder:c,plugins:d,onTextChange:g,showSerializedText:u})=>{const[w,f]=b.useState(!1),h=y=>{g&&y!==n&&g(y),f(!1)};return b.useEffect(()=>{const y=k=>(k.preventDefault(),k.returnValue="Unprocessed changes");return w&&window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[w]),t?r.jsx(i.RichTextEditor,{id:e,value:n,border:!1,placeholder:c,plugins:d,onValueChanged:()=>f(!0),onTextChange:h,hideExternalFloatingModals:y=>{N.isOpen(y)&&T.reset()}}):r.jsx(En,{value:n,columns:a,gap:s,show:u,plugins:d})},gr=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),a=$e.useFocused(),s=o.useFloatingLinkSelectors().mode(),c=o.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:d}=o.getPluginOptions(n,o.ELEMENT_LINK);o.useHotkeys(d,f=>{o.triggerFloatingLinkInsert(n,{focused:a})&&f.preventDefault()},{enableOnContentEditable:!0},[a]);const{update:g,style:u,floating:w}=o.useVirtualFloatingLink({editorId:n.id,open:c&&s==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:()=>{},...e});return b.useEffect(()=>{c?(g(),o.floatingLinkActions.updated(!0)):o.floatingLinkActions.updated(!1)},[c,g]),o.useFloatingLinkEscape(),{style:{...u,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,w)}},hr=o.createComponentAs(e=>{var n;const t=gr({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),mr=o.createComponentAs(e=>{var n;const t=wr({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)});o.FloatingLink.EditRoot=mr,o.FloatingLink.InsertRoot=hr;const we=o.FloatingLink,fr=()=>{const e=o.useFloatingLinkUrlInput({});return r.jsx("div",{"data-test-id":"floating-link-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:r.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[r.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),r.jsxs("span",{className:"tw-flex tw-gap-2",children:[r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(we.EditButton,{children:r.jsx(i.IconPen16,{})})}),r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(we.UnlinkButton,{children:r.jsx(i.IconTrashBin16,{})})})]})]})})},wr=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),a=o.usePlateSelectors().keyEditor(),s=o.useFloatingLinkSelectors().mode(),c=o.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:d="command+k, ctrl+k"}=o.getPluginOptions(n,o.ELEMENT_LINK),g=b.useCallback(()=>{const y=o.getAboveNode(n,{match:{type:o.getPluginType(n,o.ELEMENT_LINK)}});if(y){const[,k]=y;return o.getRangeBoundingClientRect(n,{anchor:o.getStartPoint(n,k),focus:o.getEndPoint(n,k)})}return o.getDefaultBoundingClientRect()},[n]),u=c&&s==="edit",{update:w,style:f,floating:h}=o.useVirtualFloatingLink({editorId:n.id,open:u,getBoundingClientRect:g,...e});return b.useEffect(()=>{const y=lt(n);if(y&&o.floatingLinkActions.url(y),n.selection&&o.someNode(n,{match:{type:o.getPluginType(n,o.ELEMENT_LINK)}})){o.floatingLinkActions.show("edit",n.id),w();return}o.floatingLinkSelectors.mode()==="edit"&&o.floatingLinkActions.hide()},[n,a,w]),o.useHotkeys(d,y=>{y.preventDefault(),o.floatingLinkSelectors.mode()==="edit"&&o.triggerFloatingLinkEdit(n)},{enableOnContentEditable:!0},[]),o.useFloatingLinkEnter(),o.useFloatingLinkEscape(),{style:{...f,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,h)}},yr={url:"",text:"",newTab:i.CheckboxState.Unchecked},br=()=>{const[e,t]=b.useReducer((n,a)=>{const{type:s,payload:c}=a;switch(s){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"INIT":return{...n,...c};default:return n}},yr);return[e,t]},vr=()=>{const e=o.useEditorRef(),[t,n]=br();b.useEffect(()=>{const f=st(e),h=it(e);n({type:"INIT",payload:{text:o.floatingLinkSelectors.text(),newTab:o.floatingLinkSelectors.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:f&&h===""?f:o.floatingLinkSelectors.url()}})},[n,e]);const a=f=>{n({type:"TEXT",payload:{text:f}})},s=f=>{n({type:"URL",payload:{url:f}})},c=f=>{n(f?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{o.floatingLinkActions.hide()},g=f=>{if(!R(t.url)||!u)return;const h=de(t.url);o.floatingLinkActions.text(t.text),o.floatingLinkActions.url(h),o.floatingLinkActions.newTab(t.newTab===i.CheckboxState.Checked),o.submitFloatingLink(e)&&(f==null||f.preventDefault())},u=t.url!==""&&t.text!=="",{appBridge:w}=o.getPluginOptions(e,o.ELEMENT_LINK);return o.useHotkeys("enter",g,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:a,onUrlChange:s,onToggleTab:c,onCancel:d,onSave:g,hasValues:u,isValidUrlOrEmpty:R,appBridge:w}},kr=()=>r.jsx(vt,{...vr(),testId:"floating-link-insert"}),pr=({readOnly:e})=>{const t=o.useFloatingLinkSelectors().isEditing();if(e)return null;const n=r.jsx(kr,{}),a=t?n:r.jsx(fr,{});return r.jsxs(r.Fragment,{children:[r.jsx(we.InsertRoot,{children:n}),r.jsx(we.EditRoot,{children:a})]})},Cr=({id:e,editorId:t})=>{const n=o.usePlateEditorState(o.useEventPlateId(t)),a=!!o.isRangeInSameBlock(n,{at:n.selection});return r.jsx("div",{"data-plugin-id":e,children:r.jsx(o.LinkToolbarButton,{tooltip:i.getTooltip(a?`Link
3
- ${i.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block."),icon:r.jsx("span",{className:"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex",children:r.jsx(i.IconLink,{size:i.IconSize.Size16})}),classNames:i.getButtonClassNames(a),styles:{root:{width:"24px",height:"24px"}},actionHandler:"onMouseDown"})})},xr=e=>({...o.useElementProps({...e,elementToAttributes:n=>{var a,s;return{href:n.url||((s=(a=n.chosenLink)==null?void 0:a.searchResult)==null?void 0:s.link)||"",target:n.target||"_self"}}}),onMouseOver:n=>{n.stopPropagation()}}),Sr=e=>{const t=xr(e),{attributes:n,children:a}=e;return r.jsx("a",{...n,href:t.href,target:t.target,style:B[me],children:a})};class Pr extends i.MarkupElement{constructor(t=o.ELEMENT_LINK,n=Sr){super(t,n)}}const Pt=e=>o.createPluginFactory({...o.createLinkPlugin(),renderAfterEditable:pr,options:{isUrl:ue,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k",appBridge:e}})();class Et extends i.Plugin{constructor(t,n=B[me]){super(me,{button:Cr,markupElement:new Pr,...t}),this.styles={},this.styles=n,this.appBridge=t==null?void 0:t.appBridge}plugins(){return[Pt(this.appBridge)]}}const Er="textstyle-custom1-plugin";class It extends i.Plugin{constructor({styles:t=B.custom1,...n}={}){super(v.custom1,{label:"Custom 1",markupElement:new Ir,...n}),this.styles={},this.styles=t}plugins(){return[Tr(this.styles)]}}class Ir extends i.MarkupElement{constructor(t=Er,n=Tt){super(t,n)}}const Tt=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,style:a,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),children:n})},Tr=e=>o.createPluginFactory({key:v.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom1}]}})({component:t=>r.jsx(Tt,{...t,styles:e})}),Br="textstyle-custom2-plugin";class Bt extends i.Plugin{constructor({styles:t=B.custom2,...n}={}){super(v.custom2,{label:"Custom 2",markupElement:new Lr,...n}),this.styles={},this.styles=t}plugins(){return[Nr(this.styles)]}}class Lr extends i.MarkupElement{constructor(t=Br,n=Lt){super(t,n)}}const Lt=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Nr=e=>o.createPluginFactory({key:v.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom2}]}})({component:t=>r.jsx(Lt,{...t,styles:e})}),Ar="textstyle-custom3-plugin";class Nt extends i.Plugin{constructor({styles:t=B.custom3,...n}={}){super(i.TextStyles.custom3,{label:"Custom 3",markupElement:new Fr,...n}),this.styles={},this.styles=t}plugins(){return[Mr(this.styles)]}}class Fr extends i.MarkupElement{constructor(t=Ar,n=At){super(t,n)}}const At=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Mr=e=>o.createPluginFactory({key:i.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:i.TextStyles.custom3}]}})({component:t=>r.jsx(At,{...t,styles:e})}),Or="textstyle-heading1-plugin";class Ft extends i.Plugin{constructor({styles:t=B.heading1,...n}={}){super(v.heading1,{label:"Heading 1",markupElement:new Dr,...n}),this.styles={},this.styles=t}plugins(){return[Ur(this.styles)]}}class Dr extends i.MarkupElement{constructor(t=Or,n=Be){super(t,n)}}const Be=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h1",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Ur=e=>o.createPluginFactory({key:v.heading1,isElement:!0,component:Be,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:t=>r.jsx(Be,{...t,styles:e})}),Hr="textstyle-heading2-plugin";class Mt extends i.Plugin{constructor({styles:t=B.heading2,...n}={}){super(v.heading2,{label:"Heading 2",markupElement:new _r,...n}),this.styles={},this.styles=t}plugins(){return[Vr(this.styles)]}}class _r extends i.MarkupElement{constructor(t=Hr,n=Le){super(t,n)}}const Le=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h2",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Vr=e=>o.createPluginFactory({key:v.heading2,isElement:!0,component:Le,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:t=>r.jsx(Le,{...t,styles:e})}),zr="textstyle-heading3-plugin";class Ot extends i.Plugin{constructor({styles:t=B.heading3,...n}={}){super(v.heading3,{label:"Heading 3",markupElement:new $r,...n}),this.styles={},this.styles=t}plugins(){return[Wr(this.styles)]}}class $r extends i.MarkupElement{constructor(t=zr,n=Ne){super(t,n)}}const Ne=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h3",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Wr=e=>o.createPluginFactory({key:v.heading3,isElement:!0,component:Ne,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:t=>r.jsx(Ne,{...t,styles:e})}),qr="textstyle-heading4-plugin";class Dt extends i.Plugin{constructor({styles:t=B.heading4,...n}={}){super(v.heading4,{label:"Heading 4",markupElement:new Gr,...n}),this.styles={},this.styles=t}plugins(){return[Kr(this.styles)]}}class Gr extends i.MarkupElement{constructor(t=qr,n=Ae){super(t,n)}}const Ae=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h4",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Kr=e=>o.createPluginFactory({key:v.heading4,isElement:!0,component:Ae,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:t=>r.jsx(Ae,{...t,styles:e})}),jr="textstyle-imageCaption-plugin";class Ut extends i.Plugin{constructor({styles:t=B.imageCaption,...n}={}){super(v.imageCaption,{label:"Image Caption",markupElement:new Xr,...n}),this.styles={},this.styles=t}plugins(){return[Qr(this.styles)]}}class Xr extends i.MarkupElement{constructor(t=jr,n=Fe){super(t,n)}}const Fe=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Qr=e=>o.createPluginFactory({key:v.imageCaption,isElement:!0,component:Fe,deserializeHtml:{rules:[{validClassName:v.imageCaption}]}})({component:t=>r.jsx(Fe,{...t,styles:e})}),Yr="textstyle-imageTitle-plugin";class Ht extends i.Plugin{constructor({styles:t=B.imageTitle,...n}={}){super(v.imageTitle,{label:"Image Title",markupElement:new Jr,...n}),this.styles={},this.styles=t}plugins(){return[Zr(this.styles)]}}class Jr extends i.MarkupElement{constructor(t=Yr,n=Me){super(t,n)}}const Me=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Zr=e=>o.createPluginFactory({key:v.imageTitle,isElement:!0,component:Me,deserializeHtml:{rules:[{validClassName:v.imageTitle}]}})({component:t=>r.jsx(Me,{...t,styles:e})});class _t extends i.Plugin{constructor({styles:t=B.p,...n}={}){super(v.p,{markupElement:new zt,label:"Body Text",...n}),this.styles={},this.styles=t}plugins(){return[$t(this.styles)]}}const Vt="tw-m-0 tw-px-0 tw-py-0",ye=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align,c=i.merge([s&&i.alignmentClassnames[s],Vt,i.getColumnBreakClasses(e)]);return r.jsx("p",{...t,className:c,style:a,children:n})};class zt extends i.MarkupElement{constructor(t=v.p,n=ye){super(t,n)}}const $t=e=>o.createPluginFactory({...o.createParagraphPlugin(),key:v.p,isElement:!0,component:ye})({component:t=>r.jsx(ye,{...t,styles:e})}),Rr="textstyle-quote-plugin";class Wt extends i.Plugin{constructor({styles:t=B.quote,...n}={}){super(v.quote,{label:"Quote",markupElement:new ea,...n}),this.styles={},this.styles=t}plugins(){return[qt(this.styles)]}}class ea extends i.MarkupElement{constructor(t=Rr,n=be){super(t,n)}}const be=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("blockquote",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},qt=e=>o.createPluginFactory({key:v.quote,isElement:!0,component:be,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:t=>r.jsx(be,{...t,styles:e})}),Oe=[new Ft,new Mt,new Ot,new Dt,new It,new Bt,new Nt,new Wt,new _t],ne=[v.heading1,v.heading2,v.heading3,v.heading4,v.custom1,v.custom2,v.custom3,v.quote,v.p],ta=[...Oe,new Ut,new Ht],na=[...ne,v.imageCaption,v.imageTitle],ra=e=>new i.PluginComposer().setPlugin(new i.SoftBreakPlugin,new i.TextStylePlugin({textStyles:Oe})).setPlugin([new i.BoldPlugin,new i.ItalicPlugin,new i.UnderlinePlugin,new i.StrikethroughPlugin,new Et({appBridge:e}),new Ct({appBridge:e}),new i.CodePlugin],[new i.AlignLeftPlugin({validTypes:ne}),new i.AlignCenterPlugin({validTypes:ne}),new i.AlignRightPlugin({validTypes:ne}),new i.AlignJustifyPlugin({validTypes:ne}),new i.UnorderedListPlugin,new i.CheckboxListPlugin,new i.OrderedListPlugin,new i.ResetFormattingPlugin,new i.AutoformatPlugin]),aa="--f-theme-settings-",sa=e=>{const t=e!=null&&e.id?`hasBackground${e.id}`:"hasBackground",n=e!=null&&e.id?`backgroundColor${e.id}`:"backgroundColor",a=e!=null&&e.preventDefaultColor?void 0:(e==null?void 0:e.defaultColor)||un,s=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Background",type:"switch",switchLabel:s,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,defaultValue:a,type:"colorInput"}]}},ia=e=>{const t=e!=null&&e.id?`hasBorder_${e.id}`:"hasBorder",n=e!=null&&e.id?`borderSelection_${e.id}`:"borderSelection",a=e!=null&&e.id?`borderStyle_${e.id}`:"borderStyle",s=e!=null&&e.id?`borderWidth_${e.id}`:"borderWidth",c=e!=null&&e.id?`borderColor_${e.id}`:"borderColor",d=(e==null?void 0:e.defaultColor)||Ke,g=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Border",type:"switch",switchLabel:g,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,type:"multiInput",onChange:u=>m.appendUnit(u,s),layout:m.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:a,type:"dropdown",defaultValue:H.Solid,choices:[{value:H.Solid,label:H.Solid},{value:H.Dotted,label:H.Dotted},{value:H.Dashed,label:H.Dashed}]},{id:s,type:"input",defaultValue:gn,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px"},{id:c,type:"colorInput",defaultValue:d}]}],off:[]}},De=(e,t=z.None)=>({id:e,type:"segmentedControls",defaultValue:t,choices:[{value:z.None,label:"None"},{value:z.Small,label:"S"},{value:z.Medium,label:"M"},{value:z.Large,label:"L"}]}),oa=e=>{const t=e!=null&&e.id?`hasRadius_${e.id}`:"hasRadius",n=e!=null&&e.id?`radiusValue_${e.id}`:"radiusValue",a=e!=null&&e.id?`radiusChoice_${e.id}`:"radiusChoice",s=(e==null?void 0:e.defaultRadius)||z.None;return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:c=>{var d;return e!=null&&e.dependentSettingId?!!((d=c.getBlock(e.dependentSettingId))!=null&&d.value):!0},onChange:c=>m.presetCustomValue(c,a,n,(e==null?void 0:e.radiusStyleMap)||G),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[m.numericalOrPixelRule],onChange:c=>m.appendUnit(c,n)}],off:[De(a,s)]}},la=e=>{const t=e!=null&&e.id?`hasExtendedCustomRadius_${e.id}`:"hasExtendedCustomRadius",n=e!=null&&e.id?`extendedRadiusValue_${e.id}`:"extendedRadiusValue",a=e!=null&&e.id?`extendedRadiusChoice_${e.id}`:"extendedRadiusChoice",s=e!=null&&e.id?`extendedRadiusTopLeft_${e.id}`:"extendedRadiusTopLeft",c=e!=null&&e.id?`extendedRadiusTopRight_${e.id}`:"extendedRadiusTopRight",d=e!=null&&e.id?`extendedRadiusBottomLeft_${e.id}`:"extendedRadiusBottomLeft",g=e!=null&&e.id?`extendedRadiusBottomRight_${e.id}`:"extendedRadiusBottomRight";return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:u=>{var w;return e!=null&&e.dependentSettingId?!!((w=u.getBlock(e.dependentSettingId))!=null&&w.value):!0},onChange:u=>{m.presetCustomValue(u,a,s,G),m.presetCustomValue(u,a,c,G),m.presetCustomValue(u,a,d,G),m.presetCustomValue(u,a,g,G)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,blocks:[{id:s,type:"input",label:"Top Left",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,s)},{id:c,type:"input",label:"Top Right",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,c)},{id:d,type:"input",label:"Bottom Left",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,d)},{id:g,type:"input",label:"Bottom Right",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,g)}]}],off:[De(a,e==null?void 0:e.defaultValue)]}},ca=e=>{const t=e!=null&&e.id?e.id:"hasCustomSpacing",n=e!=null&&e.dependentSettingId?e.dependentSettingId:"columns",a=e!=null&&e.spacingChoiceId?e.spacingChoiceId:"spacingChoice",s=e!=null&&e.spacingCustomId?e.spacingCustomId:"spacingCustom",c=e!=null&&e.defaultValueChoices?e.defaultValueChoices:Q.M;return{id:t,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:d=>m.presetCustomValue(d,a,s,Ge),show:d=>{var g;return((g=d.getBlock(n))==null?void 0:g.value)!=="1"},on:[{id:s,type:"input",rules:[m.numericalOrPixelRule],onChange:d=>m.appendUnit(d,s)}],off:[{id:a,type:"slider",defaultValue:c,choices:[{value:Q.Auto,label:"Auto"},{value:Q.S,label:"S"},{value:Q.M,label:"M"},{value:Q.L,label:"L"}]}]}},Ue=e=>({id:e,type:"segmentedControls",defaultValue:j.None,choices:[{value:j.None,label:"None"},{value:j.Small,label:"S"},{value:j.Medium,label:"M"},{value:j.Large,label:"L"}]}),da=e=>{const t=e!=null&&e.id?`hasCustomMarginValue_${e==null?void 0:e.id}`:"hasCustomMarginValue",n=e!=null&&e.id?`marginValue_${e==null?void 0:e.id}`:"marginValue",a=e!=null&&e.id?`marginChoice_${e==null?void 0:e.id}`:"marginChoice";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:s=>m.presetCustomValue(s,a,n,(e==null?void 0:e.marginStyleMap)||Z),on:[{id:n,type:"input",placeholder:se,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:s=>m.appendUnit(s,n)}],off:[Ue(a)]}},ua=e=>{const t=e!=null&&e.id?`hasExtendedCustomMargin_${e==null?void 0:e.id}`:"hasExtendedCustomMargin",n=e!=null&&e.id?`extendedMarginValues_${e==null?void 0:e.id}`:"extendedMarginValues",a=e!=null&&e.id?`extendedMarginChoice_${e==null?void 0:e.id}`:"extendedMarginChoice",s=e!=null&&e.id?`extendedMarginTop_${e==null?void 0:e.id}`:"extendedMarginTop",c=e!=null&&e.id?`extendedMarginLeft_${e==null?void 0:e.id}`:"extendedMarginLeft",d=e!=null&&e.id?`extendedMarginRight_${e==null?void 0:e.id}`:"extendedMarginRight",g=e!=null&&e.id?`extendedMarginBottom_${e==null?void 0:e.id}`:"extendedMarginBottom";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:u=>{m.presetCustomValue(u,a,s,Z),m.presetCustomValue(u,a,c,Z),m.presetCustomValue(u,a,d,Z),m.presetCustomValue(u,a,g,Z)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:s,type:"input",label:"Top",placeholder:se,onChange:u=>m.appendUnit(u,s),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Left",placeholder:se,onChange:u=>m.appendUnit(u,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:se,onChange:u=>m.appendUnit(u,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:g,type:"input",label:"Bottom",placeholder:se,onChange:u=>m.appendUnit(u,g),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Ue(a)]}},He=e=>({id:e,type:"segmentedControls",defaultValue:K.Small,choices:[{value:K.None,label:"None"},{value:K.Small,label:"S"},{value:K.Medium,label:"M"},{value:K.Large,label:"L"}]}),ga=e=>{const t=e!=null&&e.id?`hasCustomPaddingValue_${e==null?void 0:e.id}`:"hasCustomPaddingValue",n=e!=null&&e.id?`paddingValue_${e==null?void 0:e.id}`:"paddingValue",a=e!=null&&e.id?`paddingChoice_${e==null?void 0:e.id}`:"paddingChoice";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:s=>m.presetCustomValue(s,a,n,(e==null?void 0:e.paddingStyleMap)||J),on:[{id:n,type:"input",placeholder:ae,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:s=>m.appendUnit(s,n)}],off:[He(a)]}},ha=e=>{const t=e!=null&&e.id?`hasExtendedCustomPadding_${e==null?void 0:e.id}`:"hasExtendedCustomPadding",n=e!=null&&e.id?`extendedPaddingValues_${e==null?void 0:e.id}`:"extendedPaddingValues",a=e!=null&&e.id?`extendedPaddingChoice_${e==null?void 0:e.id}`:"extendedPaddingChoice",s=e!=null&&e.id?`extendedPaddingTop_${e==null?void 0:e.id}`:"extendedPaddingTop",c=e!=null&&e.id?`extendedPaddingLeft_${e==null?void 0:e.id}`:"extendedPaddingLeft",d=e!=null&&e.id?`extendedPaddingRight_${e==null?void 0:e.id}`:"extendedPaddingRight",g=e!=null&&e.id?`extendedPaddingBottom_${e==null?void 0:e.id}`:"extendedPaddingBottom";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:u=>{m.presetCustomValue(u,a,s,J),m.presetCustomValue(u,a,c,J),m.presetCustomValue(u,a,d,J),m.presetCustomValue(u,a,g,J)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:s,type:"input",label:"Top",placeholder:ae,onChange:u=>m.appendUnit(u,s),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Left",placeholder:ae,onChange:u=>m.appendUnit(u,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:ae,onChange:u=>m.appendUnit(u,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:g,type:"input",label:"Bottom",placeholder:ae,onChange:u=>m.appendUnit(u,g),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[He(a)]}},ma=e=>{const t=_e(e==null?void 0:e.globalControlId);return{id:e!=null&&e.id?e.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>{var a;return((a=n.getBlock(t))==null?void 0:a.value)===X.Custom}}},_e=e=>e||"security",fa=e=>[{id:_e(e),type:"segmentedControls",defaultValue:X.Global,choices:[{value:X.Global,label:"Global Settings"},{value:X.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:m.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Gt=(e=>(e.Main="main",e.Basics="basics",e.Layout="layout",e.Style="style",e.Security="security",e.Targets="targets",e))(Gt||{});const wa=e=>e,ya=e=>e;l.AllTextStylePlugins=ta,l.AllTextStyles=na,l.Attachments=Ye,l.AttachmentsProvider=Re,l.BUTTON_PLUGIN=kt,l.BlockButtonStyles=he,l.BlockInjectButton=en,l.BlockItemWrapper=Sn,l.BlockStyles=B,l.BorderStyle=H,l.ButtonPlugin=Ct,l.Custom1Plugin=It,l.Custom2Plugin=Bt,l.Custom3Plugin=Nt,l.DEFAULT_DRAGGING_TOOLTIP=Xe,l.DEFAULT_DRAG_TOOLTIP=je,l.DownloadButton=Pn,l.ELEMENT_BUTTON=x,l.GutterSpacing=Q,l.Heading1Plugin=Ft,l.Heading2Plugin=Mt,l.Heading3Plugin=Ot,l.Heading4Plugin=Dt,l.ImageCaptionPlugin=Ut,l.ImageTitlePlugin=Ht,l.LinkInput=bt,l.LinkPlugin=Et,l.LinkSelector=yt,l.Margin=j,l.PARAGRAPH_CLASSES=Vt,l.Padding=K,l.ParagraphMarkupElement=zt,l.ParagraphMarkupElementNode=ye,l.ParagraphPlugin=_t,l.QuoteMarkupElementNode=be,l.QuotePlugin=Wt,l.Radius=z,l.RichTextEditor=ur,l.Sections=Gt,l.Security=X,l.THEME_PREFIX=aa,l.TextStylePluginsWithoutImage=Oe,l.TextStyles=v,l.TextStylesWithoutImage=ne,l.Toolbar=nt,l.addHttps=de,l.borderStyleMap=qe,l.convertToRteValue=In,l.createButtonNode=mt,l.createButtonPlugin=pt,l.createLinkPlugin=Pt,l.createParagraphPlugin=$t,l.createQuotePlugin=qt,l.customCoordinatesGetterFactory=tt,l.defineBlock=wa,l.defineSettings=ya,l.getBackgroundColorStyles=dn,l.getBackgroundSettings=sa,l.getBorderRadiusSettings=oa,l.getBorderRadiusSlider=De,l.getBorderSettings=ia,l.getBorderStyles=hn,l.getDefaultPluginsWithLinkChooser=ra,l.getExtendedBorderRadiusSettings=la,l.getGutterSettings=ca,l.getLegacyUrl=st,l.getLinkFromEditor=lt,l.getMarginExtendedSettings=ua,l.getMarginSettings=da,l.getMarginSlider=Ue,l.getPaddingExtendedSettings=ha,l.getPaddingSettings=ga,l.getPaddingSlider=He,l.getRadiusStyles=mn,l.getReadableColor=ln,l.getSecurityDownloadableSetting=ma,l.getSecurityGlobalControlId=_e,l.getSecurityGlobalControlSetting=fa,l.getUrl=it,l.getUrlFromEditor=ht,l.getUrlFromLinkOrLegacyLink=ot,l.gutterSpacingStyleMap=Ge,l.hasRichTextValue=rt,l.insertButton=dt,l.isDark=nn,l.isDownloadable=Tn,l.isValidUrl=ue,l.isValidUrlOrEmpty=R,l.joinClassNames=U,l.mapAppBridgeColorPaletteToFonduePalette=at,l.mapAppBridgeColorPalettesToFonduePalettes=Bn,l.marginStyleMap=Z,l.moveItemInArray=cn,l.paddingStyleMap=J,l.radiusStyleMap=G,l.relativeUrlRegex=xe,l.setAlpha=sn,l.submitFloatingButton=Pe,l.toColorObject=on,l.toHex8String=rn,l.toHexString=an,l.toRgbaString=ke,l.toShortRgba=q,l.triggerFloatingButton=ft,l.triggerFloatingButtonEdit=ge,l.triggerFloatingButtonInsert=Ie,l.unwrapButton=te,l.upsertButton=ut,l.upsertButtonText=Ee,l.useAttachments=Je,l.useAttachmentsContext=et,l.useDndSensors=pn,l.withAttachmentsProvider=bn,l.withButton=ct,l.wrapButton=gt,Object.keys(m).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:()=>m[e]})}),Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@frontify/sidebar-settings"),require("react/jsx-runtime"),require("@frontify/fondue"),require("react"),require("@frontify/app-bridge"),require("@dnd-kit/core"),require("@dnd-kit/modifiers"),require("@dnd-kit/sortable"),require("@react-aria/focus"),require("@udecode/plate"),require("slate-react"),require("@react-stately/overlays"),require("slate"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","@frontify/sidebar-settings","react/jsx-runtime","@frontify/fondue","react","@frontify/app-bridge","@dnd-kit/core","@dnd-kit/modifiers","@dnd-kit/sortable","@react-aria/focus","@udecode/plate","slate-react","@react-stately/overlays","slate","@ctrl/tinycolor"],m):(o=typeof globalThis<"u"?globalThis:o||self,m(o.GuidelineBlocksSettings={},o.sidebarSettings,o.jsxRuntime,o.fondue,o.React,o.appBridge,o.core,o.modifiers,o.sortable,o.focus,o.plate,o.slateReact,o.overlays,o.slate,o.tinycolor))})(this,function(o,m,r,i,b,z,E,Zt,le,Rt,l,$e,en,tn,H){"use strict";const Ea="",_=e=>e.filter(Boolean).join(" "),nn=({onDrop:e,label:t,icon:n,secondaryLabel:a,isLoading:s,fillParentContainer:c,onAssetChooseClick:d,onUploadClick:g,withMenu:u=!0,onClick:w,validFileType:f,verticalLayout:h})=>{const[y,C]=b.useState(!1),[k,S]=b.useState(),A=b.useRef(null),[P,M]=b.useState(void 0),V=T=>{if(T.preventDefault(),C(!1),!D(T.dataTransfer.files)){M("Invalid"),setTimeout(()=>{M(void 0)},1e3);return}e==null||e(T.dataTransfer.files)},D=T=>{if(!f)return!0;for(let U=0;U<T.length;U++){const F=T[U].name.split(".").pop()??"";if(!z.FileExtensionSets[f].includes(F))return!1}return!0},W=T=>{if(!A.current||s)return;const{left:U,top:F}=A.current.getBoundingClientRect(),be=T.clientX-U,ve=T.clientY-F;S([be,ve])};return r.jsxs("button",{ref:A,"data-test-id":"block-inject-button",className:_(["tw-font-body tw-relative tw-text-sm tw-leading-4 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",h?"[&: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",c?"tw-h-full":"tw-h-[72px]",y&&!s?"tw-border-dashed":"tw-border-solid",k&&"tw-bg-blank-state-pressed-inverse",y&&"tw-bg-blank-state-weak-inverse",P?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",s||k||y||P?"":"tw-text-text-weak 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",(y||k)&&!P?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:e?T=>{var U;if(C(!0),f==="Images")for(const F of Array.from(T.dataTransfer.items))(U=F==null?void 0:F.type)!=null&&U.startsWith("image/")?M(void 0):M("Invalid")}:void 0,onDragLeave:e?()=>{C(!1),M(void 0)}:void 0,onDrop:e?V:void 0,onClick:T=>{u&&W(T),w==null||w()},children:[s?r.jsx(i.LoadingCircle,{}):P?r.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[r.jsx(i.IconExclamationMarkTriangle,{}),P]}):r.jsxs(r.Fragment,{children:[n&&r.jsx("div",{children:n}),(t||a)&&r.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[t&&r.jsx("div",{className:"tw-font-medium",children:t}),a&&r.jsx("div",{className:"tw-font-normal",children:a})]})]}),k&&r.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:k[0],top:k[1]},children:r.jsx(i.Flyout,{onOpenChange:T=>!T&&S(void 0),isOpen:!0,fitContent:!0,hug:!1,legacyFooter:!1,trigger:r.jsx("div",{}),children:r.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[...g?[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Upload asset",onClick:()=>{g(),S(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconArrowCircleUp20,{})})}]:[],...d?[{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Browse asset",onClick:()=>{d(),S(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconImageStack20,{})})}]:[]]}]})})})]})},q=e=>{const t=a=>typeof a=="object"&&["red","green","blue"].every(c=>a.hasOwnProperty(c)),n=a=>{const s=typeof a.alpha=="number"?a.alpha:1;return{r:a.red,g:a.green,b:a.blue,a:s}};return t(e)?n(e):e},rn=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),an=(e,t)=>{const n=rn(e)?q(e):e,a=new H.TinyColor(n);return t?a.getBrightness()<t:a.isDark()||a.getAlpha()>.25&&a.getAlpha()<1},sn=e=>new H.TinyColor(q(e)).toHex8String(),ln=e=>new H.TinyColor(q(e)).toHexString(),pe=e=>new H.TinyColor(q(e)).toRgbString(),on=(e,t)=>new H.TinyColor(t).setAlpha(e).toRgbString(),cn=e=>{const{r:t,g:n,b:a,a:s}=new H.TinyColor(e);return{red:t,green:n,blue:a,alpha:s}},We=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),dn=(e,t)=>{const n=We(e)?q(e):e,a=We(t)?q(t):t;let s=new H.TinyColor(n);const c=new H.TinyColor(a);for(;H.readability(s,c)<4.5;)s=s.darken(1);return s.toRgbString()},un=(e,t,n)=>{const a=[...e],s=n<0?a.length+n:n;if(s>=0&&s<a.length){const c=a.splice(t,1)[0];a.splice(s,0,c)}return a},gn=e=>({backgroundColor:pe(e)});var O=(e=>(e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted",e))(O||{});const qe={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var $=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))($||{});const G={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var K=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(K||{});const J={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var j=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(j||{});const Z={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var X=(e=>(e.Global="Global",e.Custom="Custom",e))(X||{}),Q=(e=>(e.Auto="Auto",e.S="S",e.M="M",e.L="L",e))(Q||{});const Ge={Auto:"4px",S:"10px",M:"30px",L:"50px"},hn={red:241,green:241,blue:241,alpha:1},Ke={red:234,green:235,blue:235,alpha:1},mn="1px",ae="24px",se="24px",fn=(e=O.Solid,t="1px",n=Ke)=>({borderStyle:qe[e],borderWidth:t,borderColor:pe(n)}),wn=(e,t=!1,n)=>({borderRadius:t?n:G[e]}),je="Drag or press ↵ to move",Xe="Move with ↑↓←→ and confirm with ↵",Qe=({children:e})=>r.jsx("div",{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:e}),yn=e=>e==="IMAGE"?r.jsx(i.IconImage24,{}):e==="VIDEO"?r.jsx(i.IconPlayFrame24,{}):e==="AUDIO"?r.jsx(i.IconMusicNote24,{}):r.jsx(i.IconDocument24,{}),ke=b.forwardRef(({item:e,isEditing:t,transformStyle:n,isDragging:a,isOverlay:s,isLoading:c,onDelete:d,onReplaceWithBrowse:g,onReplaceWithUpload:u,onDownload:w},f)=>{const[h,y]=b.useState(),[C,{selectedFiles:k}]=z.useFileInput({multiple:!0,accept:"image/*"}),[S,{results:A,doneAll:P}]=z.useAssetUpload();b.useEffect(()=>{k&&S(k[0])},[k]),b.useEffect(()=>{P&&u(A[0])},[P,A]);const M=c||k&&!P;return r.jsxs("button",{"aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>w==null?void 0:w(),ref:f,style:{...n,opacity:a&&!s?.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-box-neutral-hover",a?"tw-bg-box-neutral-hover":""]),children:[r.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:M?r.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small}):yn(e.objectType)}),r.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[r.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:e.title}),r.jsx("div",{className:"tw-text-text-weak",children:`${e.fileSizeHumanReadable} - ${e.extension}`})]}),t&&r.jsx("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",s||(h==null?void 0:h.id)===e.id?"tw-opacity-100":"tw-opacity-0"]),children:r.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:r.jsx(i.Flyout,{placement:i.FlyoutPlacement.Right,isOpen:(h==null?void 0:h.id)===e.id,fitContent:!0,legacyFooter:!1,onOpenChange:V=>y(V?e:void 0),trigger:(V,D)=>r.jsx(i.Button,{ref:D,icon:r.jsx(i.IconPen20,{}),emphasis:i.ButtonEmphasis.Default,onClick:()=>y(e)}),children:r.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Replace with upload",onClick:()=>{C(),y(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconArrowCircleUp20,{})})},{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Replace with asset",onClick:()=>{g(),y(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconImageStack20,{})})}]},{id:"menu-delete",menuItems:[{id:"delete",size:i.MenuItemContentSize.XSmall,title:"Delete",style:i.MenuItemStyle.Danger,onClick:()=>{d(),y(void 0)},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:r.jsx(i.IconTrashBin20,{})})}]}]})})})})]})});ke.displayName="AttachmentItem";const bn=e=>{const{attributes:t,listeners:n,setNodeRef:a,transform:s,transition:c,isDragging:d}=le.useSortable({id:e.item.id}),g={transform:s?`translate(${s.x}px, ${s.y}px)`:"",transition:c,zIndex:d?2:1},u={...t,...n};return r.jsx(ke,{ref:a,isDragging:d,transformStyle:g,draggableProps:u,...e})},vn=({children:e,isFlyoutOpen:t})=>r.jsxs("div",{className:_(["tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",t?"tw-bg-box-neutral-pressed tw-text-box-neutral-inverse-pressed":"tw-bg-base hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed tw-text-box-neutral-inverse hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed"]),children:[r.jsx(i.IconPaperclip16,{}),e,r.jsx(i.IconCaretDown12,{})]}),Ye=({items:e=[],onDelete:t,onReplaceWithBrowse:n,onReplaceWithUpload:a,onBrowse:s,onUpload:c,onSorted:d,appBridge:g,triggerComponent:u=vn,isOpen:w,onOpenChange:f})=>{const[h,y]=b.useState(e),[C,k]=b.useState(!1),S=E.useSensors(E.useSensor(E.PointerSensor),E.useSensor(E.KeyboardSensor)),[A,P]=b.useState(void 0),[M,V]=b.useState(!1),[D,W]=b.useState([]),[T,U]=b.useState(null),F=z.useEditorState(g),{openAssetChooser:be,closeAssetChooser:ve}=z.useAssetChooser(g),Kt=w!==void 0,Ve=Kt?w:C,re=h==null?void 0:h.find(p=>p.id===A),[pa,{results:jt,doneAll:Xt}]=z.useAssetUpload({onUploadProgress:()=>!M&&V(!0)}),ie=p=>{const L=Kt?f:k;L==null||L(p)};b.useEffect(()=>{y(e)},[e]),b.useEffect(()=>{T&&(V(!0),pa(T))},[T]),b.useEffect(()=>{(async()=>{Xt&&(await c(jt),V(!1))})()},[Xt,jt]);const ka=()=>{ie(!1),be(p=>{s(p),ve(),ie(!0)},{multiSelection:!0,selectedValueIds:h.map(p=>p.id)})},Qt=p=>{ie(!1),be(async L=>{ie(!0),ve(),W([...D,p.id]),await n(p,L[0]),W(D.filter(Y=>Y!==p.id))},{multiSelection:!1,selectedValueIds:h.map(L=>L.id)})},Yt=async(p,L)=>{W([...D,p.id]),await a(p,L),W(D.filter(Y=>Y!==p.id))},Ca=p=>{const{active:L}=p;P(L.id)},xa=p=>{const{active:L,over:Y}=p;if(Y&&L.id!==Y.id&&h){const Sa=h.findIndex(ze=>ze.id===L.id),Pa=h.findIndex(ze=>ze.id===Y.id),Jt=le.arrayMove(h,Sa,Pa);y(Jt),d(Jt)}P(void 0)};return F||((h==null?void 0:h.length)??0)>0?r.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Attachments",disabled:Ve,enterDelay:500,triggerElement:r.jsx("div",{"data-test-id":"attachments-flyout-button",children:r.jsx(i.Flyout,{placement:i.FlyoutPlacement.BottomRight,onOpenChange:p=>ie(re?!0:p),isOpen:Ve,hug:!1,fitContent:!0,legacyFooter:!1,trigger:r.jsx(u,{isFlyoutOpen:Ve,children:r.jsx("div",{children:e.length>0?e.length:"Add"})}),children:r.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[h.length>0&&r.jsxs(E.DndContext,{sensors:S,collisionDetection:E.closestCenter,onDragStart:Ca,onDragEnd:xa,modifiers:[Zt.restrictToWindowEdges],children:[r.jsx(le.SortableContext,{items:h,strategy:le.rectSortingStrategy,children:r.jsx("div",{className:"tw-border-b tw-border-b-line",children:h.map(p=>r.jsx(bn,{isEditing:F,isLoading:D.includes(p.id),item:p,onDelete:()=>t(p),onReplaceWithBrowse:()=>Qt(p),onReplaceWithUpload:L=>Yt(p,L),onDownload:()=>g.dispatch({name:"downloadAsset",payload:p})},p.id))})}),r.jsx(E.DragOverlay,{children:re&&r.jsx(ke,{isOverlay:!0,isEditing:F,item:re,isDragging:!0,onDelete:()=>t(re),onReplaceWithBrowse:()=>Qt(re),onReplaceWithUpload:p=>Yt(re,p)},A)})]}),F&&r.jsxs("div",{className:"tw-px-5 tw-py-3",children:[r.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),r.jsx(i.AssetInput,{isLoading:M,size:i.AssetInputSize.Small,onUploadClick:p=>U(p),onLibraryClick:ka})]})]})})})}):null},Je=(e,t)=>{const{blockAssets:n,updateAssetIdsFromKey:a}=z.useBlockAssets(e),s=(n==null?void 0:n[t])||[];return{onAttachmentsAdd:async w=>{const f=s.map(h=>h.id);for(const h of w)f.push(h.id);await a(t,f)},onAttachmentDelete:async w=>{const f=s.filter(h=>h.id!==w.id).map(h=>h.id);await a(t,f)},onAttachmentReplace:async(w,f)=>{const h=s.map(y=>y.id===w.id?f.id:y.id);await a(t,h)},onAttachmentsSorted:async w=>{const f=w.map(h=>h.id);await a(t,f)},attachments:s,appBridge:e}},Ze=b.createContext(null),Re=({appBridge:e,children:t,assetId:n})=>{const a=Je(e,n);return r.jsx(Ze.Provider,{value:a,children:t})},et=()=>{const e=b.useContext(Ze);if(!e)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return e},pn=(e,t)=>{const n=a=>r.jsx(Re,{appBridge:a.appBridge,assetId:t,children:r.jsx(e,{...a})});return n.displayName="withAttachmentsProvider",n},kn=[E.KeyboardCode.Down,E.KeyboardCode.Right,E.KeyboardCode.Up,E.KeyboardCode.Left],tt=(e,t)=>(n,{currentCoordinates:a,context:{activeNode:s}})=>{if(n.preventDefault(),kn.includes(n.code)){const c=(s==null?void 0:s.offsetWidth)??0,d=(s==null?void 0:s.offsetHeight)??0;switch(n.code){case E.KeyboardCode.Right:return{...a,x:a.x+c+e};case E.KeyboardCode.Left:return{...a,x:a.x-c-e};case E.KeyboardCode.Down:return{...a,y:a.y+d+t};case E.KeyboardCode.Up:return{...a,y:a.y-d-t}}}},Cn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},xn=(e=0,t=0)=>{const n=tt(e,t);return E.useSensors(E.useSensor(E.PointerSensor),E.useSensor(E.KeyboardSensor,{coordinateGetter:n,keyboardCodes:Cn}))},oe=(e,t)=>{const n=[i.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded","tw-text-xs tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return t?n.push("tw-bg-box-neutral-pressed","tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed","tw-text-text-weak hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),_(n)},Sn=({children:e,isFlyoutOpen:t})=>r.jsxs("div",{className:oe("pointer",t),children:[r.jsx(i.IconPaperclip16,{}),e,r.jsx(i.IconCaretDown12,{})]}),Pn=({isOpen:e,onOpenChange:t})=>{const{appBridge:n,attachments:a,onAttachmentsAdd:s,onAttachmentDelete:c,onAttachmentReplace:d,onAttachmentsSorted:g}=et();return r.jsx(Ye,{onUpload:s,onDelete:c,onReplaceWithBrowse:d,onReplaceWithUpload:d,onSorted:g,onBrowse:s,items:a,appBridge:n,triggerComponent:Sn,isOpen:e,onOpenChange:t})},nt=({items:e,flyoutMenu:t,attachments:n,isDragging:a})=>r.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[n.isEnabled&&r.jsx(Qe,{children:r.jsx(Pn,{isOpen:n.isOpen&&!a,onOpenChange:n.onOpenChange})}),r.jsxs(Qe,{children:[e.map((s,c)=>"draggableProps"in s?r.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,open:a,position:i.TooltipPosition.Top,content:r.jsx("div",{children:a?Xe:s.tooltip??je}),triggerElement:r.jsx("button",{ref:s.setActivatorNodeRef,"data-test-id":"block-item-wrapper-toolbar-btn",...s.draggableProps,className:oe("grab",a),children:s.icon})},c):r.jsx(i.LegacyTooltip,{withArrow:!0,enterDelay:300,hoverDelay:0,disabled:a,position:i.TooltipPosition.Top,content:r.jsx("div",{children:s.tooltip??""}),triggerElement:r.jsx("button",{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:s.onClick,className:oe("pointer"),children:s.icon})},c)),t.items.length>0&&r.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,disabled:a||t.isOpen,position:i.TooltipPosition.Top,content:r.jsx("div",{children:"Options"}),triggerElement:r.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:r.jsx(i.Flyout,{isOpen:t.isOpen&&!a,legacyFooter:!1,fitContent:!0,hug:!1,onOpenChange:t.onOpenChange,trigger:r.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-flyout",className:oe("pointer",t.isOpen&&!a),children:r.jsx(i.IconDotsHorizontal16,{})}),children:r.jsx(i.ActionMenu,{menuBlocks:t.items.map((s,c)=>({id:c.toString(),menuItems:s.map((d,g)=>({id:c.toString()+g.toString(),size:i.MenuItemContentSize.XSmall,title:d.title,style:d.style,onClick:()=>{t.onOpenChange(!1),d.onClick()},initialValue:!0,decorator:r.jsx("div",{className:"tw-mr-2",children:d.icon})}))}))})})})})]})]}),En=({children:e,toolbarFlyoutItems:t,toolbarItems:n,shouldHideWrapper:a,shouldHideComponent:s=!1,isDragging:c,shouldFillContainer:d,outlineOffset:g=2,shouldBeShown:u=!1,showAttachments:w=!1})=>{const[f,h]=b.useState(u),[y,C]=b.useState(!1),k=b.useRef(null);if(a)return r.jsx(r.Fragment,{children:e});const S=n==null?void 0:n.filter(P=>P!==void 0),A=f||y||u;return r.jsxs("div",{ref:k,"data-test-id":"block-item-wrapper",style:{outlineOffset:g},className:_(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",d&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",A&&"tw-outline",s&&"tw-opacity-0"]),children:[r.jsx("div",{style:{right:-1-g,bottom:`calc(100% - ${2+g}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",A&&"tw-opacity-100"]),children:r.jsx(nt,{flyoutMenu:{items:t,isOpen:f,onOpenChange:h},attachments:{isEnabled:w,isOpen:y,onOpenChange:C},items:S,isDragging:c})}),e]})},In=({onDownload:e})=>{const{isFocused:t,focusProps:n}=Rt.useFocusRing();return r.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Download",enterDelay:500,triggerElement:r.jsx("button",{tabIndex:0,"aria-label":"Download",...n,className:_(["tw-outline-none tw-rounded",t&&i.FOCUS_STYLE]),onClick:e,onPointerDown:a=>a.preventDefault(),children:r.jsx("span",{"data-test-id":"download-button",className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:r.jsx(i.IconArrowCircleDown16,{})})})})},Tn=({value:e="",gap:t,columns:n,show:a=!0,plugins:s})=>{const[c,d]=b.useState(null);return b.useEffect(()=>{(async()=>d(await i.serializeRawToHtmlAsync(e,s,n,t)))()},[e,n,t,s]),!a||c==="<br />"?null:c!==null?r.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:c}}):r.jsx("div",{className:"tw-rounded-sm tw-bg-base-alt tw-animate-pulse tw-h-full tw-min-h-[10px] tw-w-full"})},rt=e=>{if(!e)return!1;const t=n=>n.some(a=>a.text?a.text!=="":a.children?t(a.children):!1);try{const n=JSON.parse(e);return t(n)}catch{return!1}},Bn=(e="p",t="",n)=>rt(t)?t:JSON.stringify([{type:e,children:[{text:t,textStyle:e}],align:n}]),Ln=(e,t,n)=>e===X.Custom?t:n,Nn=e=>e.map(at),at=e=>({id:e.id,title:e.name,colors:e.colors.map(t=>({alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}))}),Ce=(e,t)=>{const n=l.getAboveNode(e,{match:{type:l.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},st=e=>Ce(e,t=>{var n,a;return((a=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:a.link)||""}),it=e=>Ce(e,t=>t.url||""),lt=e=>{var t,n;return e.url||((n=(t=e.chosenLink)==null?void 0:t.searchResult)==null?void 0:n.link)||""},ot=e=>Ce(e,lt),xe=/^\/(document|r)\/\S+$/i,ce=e=>{if(xe.test(e))return e;try{return new URL(e),e}catch{return`https://${e}`}},de=e=>{if(xe.test(e))return!0;try{const t=new URL(e);return["http:","https:","mailto:","tel:"].includes(t.protocol)&&t.pathname!==""}catch{return!1}},R=e=>de(ce(e))||e==="",ct=(e,{type:t})=>{const{apply:n,normalizeNode:a}=e;return e.apply=s=>{if(s.type!=="set_selection"){n(s);return}const c=s.newProperties;if(!(c!=null&&c.focus)||!c.anchor||!l.isCollapsed(c)){n(s);return}const d=l.getAboveNode(e,{at:c,match:{type:l.getPluginType(e,x)}});if(d){const[,g]=d;let u;l.isStartPoint(e,c.focus,g)&&(u=l.getPreviousNodeEndPoint(e,g)),l.isEndPoint(e,c.focus,g)&&(u=l.getNextNodeStartPoint(e,g)),u&&(s.newProperties={anchor:u,focus:u})}n(s)},e.normalizeNode=([s,c])=>{if(s.type===l.getPluginType(e,x)){const d=e.selection;if(d&&l.isCollapsed(d)&&l.isEndPoint(e,d.focus,c)){const g=l.getNextNodeStartPoint(e,c);if(g)l.select(e,g);else{const u=tn.Path.next(c);l.insertNodes(e,{text:""},{at:u}),l.select(e,u)}}}a([s,c])},l.withRemoveEmptyNodes(e,l.mockPlugin({options:{types:t}}))},dt=(e,t,n)=>{l.insertNodes(e,[mt(e,t)],n)},Se=l.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(e=>({reset:()=>{e.url(""),e.text(""),e.buttonStyle("primary"),e.newTab(!1),e.mode(""),e.isEditing(!1)}})).extendActions(e=>({show:(t,n)=>{e.mode(t),e.isEditing(!1),e.openEditorId(n)},hide:()=>{e.reset(),e.openEditorId(null)}})).extendSelectors(e=>({isOpen:t=>e.openEditorId===t})),I=Se.set,N=Se.get,ee=()=>Se.use,Pe=e=>{if(!e.selection)return;const{isUrl:t,forceSubmit:n}=l.getPluginOptions(e,x),a=N.url();if(!((t==null?void 0:t(a))||n))return;const c=N.text(),d=N.buttonStyle(),g=N.newTab()?void 0:"_self";return I.hide(),ut(e,{url:a,text:c,buttonStyle:d,target:g,isUrl:u=>n||!t?!0:t(u)}),setTimeout(()=>{l.focusEditor(e,e.selection??void 0)},0),!0},te=(e,t)=>l.withoutNormalizing(e,()=>{var n,a,s,c,d,g;if(t!=null&&t.split){if(l.getAboveNode(e,{at:(n=e.selection)==null?void 0:n.anchor,match:{type:l.getPluginType(e,x)}}))return l.splitNodes(e,{at:(a=e.selection)==null?void 0:a.anchor,match:f=>l.isElement(f)&&f.type===l.getPluginType(e,x)}),te(e,{at:(s=e.selection)==null?void 0:s.anchor}),!0;if(l.getAboveNode(e,{at:(c=e.selection)==null?void 0:c.focus,match:{type:l.getPluginType(e,x)}}))return l.splitNodes(e,{at:(d=e.selection)==null?void 0:d.focus,match:f=>l.isElement(f)&&f.type===l.getPluginType(e,x)}),te(e,{at:(g=e.selection)==null?void 0:g.focus}),!0}l.unwrapNodes(e,{match:{type:l.getPluginType(e,x)},...t})}),ut=(e,{url:t,text:n,buttonStyle:a,target:s,insertTextInButton:c,insertNodesOptions:d,isUrl:g=l.getPluginOptions(e,x).isUrl})=>{var P;const u=e.selection;if(!u)return;const w=l.getAboveNode(e,{at:u,match:{type:l.getPluginType(e,x)}});if(c&&w)return e.insertText(t),!0;if(!(g!=null&&g(t)))return;if(l.isDefined(n)&&n.length===0&&(n=t),w)return Mn(t,e,w,s,a,n),!0;const f=l.findNode(e,{at:u,match:{type:l.getPluginType(e,x)}}),[h,y]=f??[],C=An(e,y,n);if(l.isExpanded(u))return Fn(w,e,t,a,s,n),!0;C&&l.removeNodes(e,{at:y});const k=l.getNodeProps(h??{}),S=(P=e.selection)==null?void 0:P.focus.path;if(!S)return;const A=l.getNodeLeaf(e,S);return n!=null&&n.length||(n=t),dt(e,{...k,url:t,target:s,children:[{...A,text:n}]},d),!0};function An(e,t,n){return t&&(n==null?void 0:n.length)&&n!==l.getEditorString(e,t)}function Fn(e,t,n,a,s,c){e?te(t,{at:e[1]}):te(t,{split:!0}),gt(t,{url:n,buttonStyle:a,target:s}),Ee(t,{url:n,target:s,text:c})}function Mn(e,t,n,a,s,c){var d,g,u;(e!==((d=n[0])==null?void 0:d.url)||a!==((g=n[0])==null?void 0:g.target)||s!==((u=n[0])==null?void 0:u.buttonStyle))&&l.setNodes(t,{url:e,target:a,buttonStyle:s},{at:n[1]}),Ee(t,{url:e,text:c,target:a})}const Ee=(e,{text:t})=>{const n=l.getAboveNode(e,{match:{type:l.getPluginType(e,x)}});if(n){const[a,s]=n;if(t!=null&&t.length&&t!==l.getEditorString(e,s)){const c=a.children[0];l.replaceNodeChildren(e,{at:s,nodes:{...c,text:t},insertOptions:{select:!0}})}}},gt=(e,{url:t,buttonStyle:n,target:a,...s})=>{l.wrapNodes(e,{type:l.getPluginType(e,x),url:t,buttonStyle:n,target:a,children:[]},{split:!0,...s})},On=(e,t)=>{const n=l.getAboveNode(e,{match:{type:x}});return Array.isArray(n)?t(n[0]):""},ht=e=>On(e,t=>t.url??""),mt=(e,{url:t,text:n="",buttonStyle:a="primary",target:s,children:c})=>({type:l.getPluginType(e,x),url:t,target:s,buttonStyle:a,children:c??[{text:n}]}),ft=(e,{focused:t}={})=>{if(N.mode()==="edit"){ue(e);return}Ie(e,{focused:t})},ue=e=>{const t=l.findNode(e,{match:{type:l.getPluginType(e,x)}});if(!t)return;const[n,a]=t;let s=l.getEditorString(e,a);I.url(n.url),I.newTab(n.target===void 0),s===n.url&&(s=""),I.text(s),I.isEditing(!0)},Ie=(e,{focused:t}={})=>{N.mode()||!t||l.isRangeAcrossBlocks(e,{at:e.selection})||l.someNode(e,{match:{type:l.getPluginType(e,x)}})||(I.text(l.getEditorString(e,e.selection)),I.show("insert",e.id))},ge={buttonPrimary:{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)",marginTop:"10px",marginBottom:"10px",display:"inline-block",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:{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)",display:"inline-block",marginTop:"10px",marginBottom:"10px",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:{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)",display:"inline-block",marginTop:"10px",marginBottom:"10px",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)"}}},Dn=e=>({...l.useElementProps({...e,elementToAttributes:n=>({url:n.href,buttonStyle:n.buttonStyle||"primary",target:n.target||"_blank"})}),onMouseOver:n=>{n.stopPropagation()}}),Un=e=>{const{href:t,target:n,buttonStyle:a}=Dn(e),{attributes:s,children:c}=e;return r.jsx(Hn,{attributes:s,href:t,target:n,styles:ge[`button${a.charAt(0).toUpperCase()+a.slice(1)}`],children:c})},Hn=({attributes:e,styles:t={hover:{}},children:n,href:a="#",target:s})=>{const[c,d]=b.useState(!1);return r.jsx("a",{...e,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),href:a,target:s,style:c?{...t,...t.hover}:t,children:n})};class _n extends i.MarkupElement{constructor(t=x,n=Un){super(t,n)}}const Vn=({type:e,...t})=>{const n=l.useEditorRef(),a=!!l.isRangeInSameBlock(n,{at:n.selection}),s=!!(n!=null&&n.selection)&&l.someNode(n,{match:{type:e}});return r.jsx(l.ToolbarButton,{tooltip:i.getTooltip(a?`Button
2
+ ${i.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block."),classNames:i.getButtonClassNames(a),active:s,onMouseDown:async c=>{n&&(c.preventDefault(),c.stopPropagation(),l.focusEditor(n,n.selection??n.prevSelection??void 0),setTimeout(()=>{ft(n,{focused:!0})},0))},...t})},zn=({editor:e,id:t})=>r.jsx("div",{"data-plugin-id":t,children:r.jsx(Vn,{type:l.getPluginType(e,x),icon:r.jsx("span",{className:"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex",children:r.jsx(i.IconButton16,{})}),styles:i.buttonStyles})}),$n=()=>{const e=or({});return r.jsx("div",{"data-test-id":"floating-button-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:r.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[r.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),r.jsxs("span",{className:"tw-flex tw-gap-2",children:[r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(me.EditButton,{children:r.jsx(i.IconPen16,{})})}),r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(me.UnlinkButton,{children:r.jsx(i.IconTrashBin16,{})})})]})]})})},Wn=({section:e,selectedUrl:t,onSelectUrl:n})=>{const a=e.permanentLink===t;return r.jsx("button",{"data-test-id":"internal-link-selector-section-link",className:i.merge(["tw-py-2 tw-px-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",a?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:r.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[r.jsx(i.IconDocumentText16,{}),r.jsx("span",{className:"tw-text-s",children:e.title}),r.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},qn=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:a,appBridge:s})=>{const[c,d]=b.useState(e.id===a.documentId),g=e.permanentLink===t,{documentSections:u}=z.useDocumentSection(s,e.id),w=[...u.values()],f=w.length>0;return b.useEffect(()=>{e.id===a.pageId&&d(!0)},[a,e.id]),r.jsxs(r.Fragment,{children:[r.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:i.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",f?"tw-pl-7":"tw-pl-12",g?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:r.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[f&&r.jsx("button",{"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!c),children:r.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",c?"tw-rotate-90":""])})}),r.jsx("span",{className:"tw-text-s",children:e.title}),r.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),c&&w.length>0&&w.map(h=>r.jsx(Wn,{section:h,selectedUrl:t,onSelectUrl:n},h.id))]})},wt=()=>r.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:r.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small})}),Gn=({appBridge:e,documentId:t,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s})=>{const[c,d]=b.useState([]),[g,u]=b.useState(!0),w=[...c.values()],f=!g&&w.length>0;return b.useEffect(()=>{e.getDocumentPagesByDocumentId(t).then(h=>{const y=h.filter(k=>!!k.category).sort((k,S)=>k.category.sort===S.category.sort?k.sort-S.sort:k.category.sort-S.category.sort),C=h.filter(k=>!k.category).sort((k,S)=>k.sort-S.sort);d([...y,...C])}).finally(()=>{u(!1)})},[]),g?r.jsx(wt,{}):f?r.jsx(r.Fragment,{children:w.map(h=>r.jsx(qn,{page:h,appBridge:e,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s},h.id))}):r.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},Kn=({document:e,appBridge:t,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s})=>{const[c,d]=b.useState(e.id===s.documentId),g=e.permanentLink===n;return b.useEffect(()=>{e.id===s.documentId&&d(!0)},[s,e.id]),r.jsxs(r.Fragment,{children:[r.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:i.merge(["tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full",g?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>a(e.permanentLink),children:[r.jsx("button",{role:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!c),children:r.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",c?"tw-rotate-90":""])})}),r.jsx(i.IconColorFan16,{}),r.jsx("span",{className:"tw-text-s",children:e.title}),r.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),c&&r.jsx(Gn,{appBridge:t,documentId:e.id,selectedUrl:n,onSelectUrl:a,itemsToExpandInitially:s})]})},jn=({appBridge:e,selectedUrl:t,onSelectUrl:n})=>{const[a,s]=b.useState(!0),[c,d]=b.useState([]),[g,u]=b.useState({documentId:void 0,pageId:void 0}),w=[...c.values()];b.useEffect(()=>{t&&w.length>0&&f().then(h=>{u(h)})},[w.length]),b.useEffect(()=>{e.getAllDocuments().then(h=>{d(h)}).finally(()=>{s(!1)})},[]);const f=async()=>{const h={documentId:void 0,pageId:void 0};if(w.find(C=>C.permanentLink===t))return h;for(const C of w){const k=await e.getDocumentPagesByDocumentId(C.id);e.getAllDocuments();const S=[...k.values()];if(!!S.find(P=>P.permanentLink===t))return h.documentId=C.id,h;for(const P of S)if(!![...(await e.getDocumentSectionsByDocumentPageId(P.id)).values()].find(W=>W.permanentLink===t))return h.documentId=C.id,h.pageId=P.id,h}return h};return a?r.jsx(wt,{}):r.jsx(r.Fragment,{children:w.map(h=>r.jsx(Kn,{document:h,appBridge:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:g},h.id))})},yt=({appBridge:e,url:t,onUrlChange:n,buttonSize:a=i.ButtonSize.Medium})=>{const{open:s,isOpen:c,close:d}=en.useOverlayTriggerState({}),[g,u]=b.useState(t),w=y=>{u(y)},f=y=>{y.key==="Enter"&&h()};b.useEffect(()=>{t&&!g&&u(t)},[t,g]);const h=()=>{n==null||n(g),d()};return r.jsxs("div",{"data-test-id":"internal-link-selector",onKeyDown:f,children:[r.jsx(i.Button,{icon:r.jsx(i.IconLink,{}),size:a,type:i.ButtonType.Button,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,onClick:()=>s(),children:"Internal link"}),r.jsxs(i.Modal,{zIndex:1001,onClose:()=>d(),isOpen:c,isDismissable:!0,children:[r.jsx(i.Modal.Header,{title:"Select internal link"}),r.jsx(i.Modal.Body,{children:r.jsx(jn,{appBridge:e,selectedUrl:g,onSelectUrl:w})}),r.jsx(i.Modal.Footer,{buttons:[{children:"Cancel",onClick:()=>d(),style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default},{children:"Choose",onClick:y=>{y==null||y.preventDefault(),h()},style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Strong,disabled:!g}]})]})]})},bt=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:a,clearable:s,placeholder:c,newTab:d,openInNewTab:g,url:u="",required:w,info:f,label:h,buttonSize:y,hideInternalLinkButton:C})=>{const k=n?n(u):R(u),S=d??(g?i.CheckboxState.Checked:i.CheckboxState.Unchecked);return r.jsxs("div",{"data-test-id":"link-input",children:[r.jsx(i.FormControl,{label:{children:h,htmlFor:"url",required:w,tooltip:f?{content:f,position:i.TooltipPosition.Top}:void 0},children:r.jsx(i.TextInput,{id:"url",value:u,clearable:s,onChange:e,placeholder:c??"https://example.com",focusOnMount:!0})}),!k&&r.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!C&&r.jsx("div",{className:"tw-mt-3",children:r.jsx(yt,{url:u,appBridge:a,onUrlChange:e,buttonSize:y??i.ButtonSize.Medium})}),r.jsx("div",{className:"tw-mt-3",children:r.jsx(i.Checkbox,{value:"new-tab",label:"Open in new tab",state:S,onChange:t})})]})},vt=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:a,onCancel:s,onSave:c,isValidUrlOrEmpty:d,hasValues:g,testId:u,appBridge:w,children:f})=>r.jsxs("div",{"data-test-id":u,className:"tw-bg-white tw-rounded tw-shadow tw-p-7 tw-min-w-[400px] tw-overflow-y-auto",children:[r.jsx(i.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:r.jsx(i.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:t})}),f,r.jsx("div",{className:"tw-mt-5",children:r.jsx(bt,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:a,isValidUrlOrEmpty:d,appBridge:w})}),r.jsx("div",{className:"tw-mt-3",children:r.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[r.jsx(i.Button,{onClick:s,size:i.ButtonSize.Medium,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,children:"Cancel"}),r.jsx(i.Button,{onClick:c,size:i.ButtonSize.Medium,icon:r.jsx(i.IconCheckMark20,{}),disabled:!g||!d(e==null?void 0:e.url),children:"Save"})]})})]}),Xn=e=>{var n;const t=l.getAboveNode(e,{match:{type:x}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},Qn={url:"",text:"",buttonStyle:"primary",newTab:i.CheckboxState.Unchecked},Yn=()=>{const[e,t]=b.useReducer((n,a)=>{const{type:s,payload:c}=a;switch(s){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...c};default:return n}},Qn);return[e,t]},Jn=()=>{const e=l.useEditorRef(),[t,n]=Yn();b.useEffect(()=>{const h=Xn(e);n({type:"INIT",payload:{text:N.text(),buttonStyle:h,newTab:N.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:N.url()}})},[n,e]);const a=h=>{n({type:"TEXT",payload:{text:h}})},s=h=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:h}})},c=h=>{n({type:"URL",payload:{url:h}})},d=h=>{n(h?{type:"NEW_TAB"}:{type:"SAME_TAB"})},g=()=>{I.hide()},u=h=>{if(!R(t.url)||!w)return;const y=ce(t.url);I.text(t.text),I.url(y),I.buttonStyle(t.buttonStyle),I.newTab(t.newTab===i.CheckboxState.Checked),Pe(e)&&(h==null||h.preventDefault())},w=t.url!==""&&t.text!=="",{appBridge:f}=l.getPluginOptions(e,x);return l.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:a,onButtonStyleChange:s,onUrlChange:c,onToggleTab:d,onCancel:g,onSave:u,hasValues:w,isValidUrlOrEmpty:R,appBridge:f}},he="link-plugin";var v=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e.p="p",e))(v||{});const B={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)"},[he]:{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)"},...ge},Zn=()=>{const e=Jn(),{state:t,onButtonStyleChange:n}=e;return r.jsx(vt,{...e,testId:"floating-button-insert",children:r.jsx("div",{className:"tw-pt-5",children:r.jsxs(i.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[r.jsx(Te,{id:"primary",styles:B.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),r.jsx(Te,{id:"secondary",styles:B.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),r.jsx(Te,{id:"tertiary",styles:B.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},Te=({id:e,styles:t,isActive:n,onClick:a,children:s})=>{const[c,d]=b.useState(!1),g=()=>t&&t.hover&&c?{...t,...t.hover}:t;return r.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:a,style:{...g(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:s})},Rn=()=>{const e=ee().isEditing(),t=r.jsx(Zn,{}),n=e?t:r.jsx($n,{});return r.jsxs(r.Fragment,{children:[r.jsx(me.InsertRoot,{children:t}),r.jsx(me.EditRoot,{children:n})]})},x="button",pt="button-plugin",kt=e=>l.createPluginFactory({key:x,isElement:!0,isInline:!0,props:({element:t})=>({nodeProps:{href:t==null?void 0:t.url,target:t==null?void 0:t.target}}),withOverrides:ct,renderAfterEditable:Rn,options:{isUrl:de,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:e},then:(t,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:a=>({type:n,url:a.getAttribute("href"),target:a.getAttribute("target")||"_blank"})}})})();class Ct extends i.Plugin{constructor({styles:t=ge,...n}){super(pt,{button:zn,markupElement:new _n,...n}),this.styles={},this.styles=t,this.appBridge=n==null?void 0:n.appBridge}plugins(){return[kt(this.appBridge)]}}const er=({floatingOptions:e,...t})=>{const n=l.useEditorRef(),a=l.usePlateSelectors(n.id).keyEditor(),s=ee().mode(),c=ee().isOpen(n.id),{triggerFloatingButtonHotkeys:d}=l.getPluginOptions(n,x),g=b.useCallback(()=>{const y=l.getAboveNode(n,{match:{type:l.getPluginType(n,x)}});if(y){const[,C]=y;return l.getRangeBoundingClientRect(n,{anchor:l.getStartPoint(n,C),focus:l.getEndPoint(n,C)})}return l.getDefaultBoundingClientRect()},[n]),u=c&&s==="edit",{update:w,style:f,floating:h}=St({open:u,getBoundingClientRect:g,...e});return b.useEffect(()=>{const y=ht(n);if(y&&I.url(y),n.selection&&l.someNode(n,{match:{type:l.getPluginType(n,x)}})){I.show("edit",n.id),w();return}N.mode()==="edit"&&I.hide()},[n,a,w]),l.useHotkeys(d,y=>{y.preventDefault(),N.mode()==="edit"&&ue(n)},{enableOnContentEditable:!0},[]),cr(),xt(),{style:{...f,zIndex:1e3},...t,ref:l.useComposedRef(t.ref,h)}},tr=({floatingOptions:e,...t})=>{const n=l.useEditorRef(),a=$e.useFocused(),s=ee().mode(),c=ee().isOpen(n.id),{triggerFloatingButtonHotkeys:d}=l.getPluginOptions(n,x);l.useHotkeys(d,f=>{f.preventDefault(),Ie(n,{focused:a})},{enableOnContentEditable:!0},[a]);const{update:g,style:u,floating:w}=St({open:c&&s==="insert",getBoundingClientRect:l.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return b.useEffect(()=>{c&&g(),I.updated(c)},[c,g]),xt(),{style:{...u,zIndex:1e3},...t,ref:l.useComposedRef(t.ref,w)}},nr=e=>{const t=l.useEditorRef();return{onClick:b.useCallback(()=>{ue(t)},[t]),...e}},rr=l.createComponentAs(e=>{const t=nr(e);return l.createElementAs("button",t)}),ar=e=>{const t=l.useEditorRef();return{onClick:b.useCallback(()=>{te(t),l.focusEditor(t,t.selection??void 0)},[t]),...e}},sr=l.createComponentAs(e=>{const t=ar(e);return l.createElementAs(l.Button,t)}),ir=l.createComponentAs(e=>{var n;const t=er(e);return((n=t.style)==null?void 0:n.display)==="none"?null:l.createElementAs("div",t)}),lr=l.createComponentAs(e=>{var n;const t=tr(e);return((n=t.style)==null?void 0:n.display)==="none"?null:l.createElementAs("div",t)}),me={EditRoot:ir,InsertRoot:lr,EditButton:rr,UnlinkButton:sr},or=e=>{const t=ee().updated(),n=b.useRef(null);b.useEffect(()=>{n.current&&t&&setTimeout(()=>{var s;(s=n.current)==null||s.focus()},0)},[t]);const a=b.useCallback(s=>{I.url(s.target.value)},[]);return l.mergeProps({onChange:a,defaultValue:N.url()},{...e,ref:l.useComposedRef(e.ref,n)})},cr=()=>{const e=l.useEditorRef();l.useHotkeys("*",t=>{t.key==="Enter"&&Pe(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},xt=()=>{const e=l.useEditorRef();l.useHotkeys("escape",()=>{if(N.mode()==="edit"){if(N.isEditing()){I.show("edit",e.id),l.focusEditor(e,e.selection??void 0);return}I.hide()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},dr=12,ur=-22,gr=96,St=e=>l.useVirtualFloating({placement:"bottom-start",middleware:[l.offset({mainAxis:dr,alignmentAxis:ur}),l.flip({padding:gr})],...e}),hr=({id:e="rte",isEditing:t,value:n,columns:a,gap:s,placeholder:c,plugins:d,onTextChange:g,showSerializedText:u})=>{const[w,f]=b.useState(!1),h=y=>{g&&y!==n&&g(y),f(!1)};return b.useEffect(()=>{const y=C=>(C.preventDefault(),C.returnValue="Unprocessed changes");return w&&window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[w]),t?r.jsx(i.RichTextEditor,{id:e,value:n,border:!1,placeholder:c,plugins:d,onValueChanged:()=>f(!0),onTextChange:h,hideExternalFloatingModals:y=>{N.isOpen(y)&&I.reset()}}):r.jsx(Tn,{value:n,columns:a,gap:s,show:u,plugins:d})},mr=({floatingOptions:e,...t})=>{const n=l.useEditorRef(),a=$e.useFocused(),s=l.useFloatingLinkSelectors().mode(),c=l.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:d}=l.getPluginOptions(n,l.ELEMENT_LINK);l.useHotkeys(d,f=>{l.triggerFloatingLinkInsert(n,{focused:a})&&f.preventDefault()},{enableOnContentEditable:!0},[a]);const{update:g,style:u,floating:w}=l.useVirtualFloatingLink({editorId:n.id,open:c&&s==="insert",getBoundingClientRect:l.getSelectionBoundingClientRect,whileElementsMounted:()=>{},...e});return b.useEffect(()=>{c?(g(),l.floatingLinkActions.updated(!0)):l.floatingLinkActions.updated(!1)},[c,g]),l.useFloatingLinkEscape(),{style:{...u,zIndex:1e3},...t,ref:l.useComposedRef(t.ref,w)}},fr=l.createComponentAs(e=>{var n;const t=mr({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:l.createElementAs("div",t)}),wr=l.createComponentAs(e=>{var n;const t=br({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:l.createElementAs("div",t)});l.FloatingLink.EditRoot=wr,l.FloatingLink.InsertRoot=fr;const fe=l.FloatingLink,yr=()=>{const e=l.useFloatingLinkUrlInput({});return r.jsx("div",{"data-test-id":"floating-link-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:r.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[r.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),r.jsxs("span",{className:"tw-flex tw-gap-2",children:[r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(fe.EditButton,{children:r.jsx(i.IconPen16,{})})}),r.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:r.jsx(fe.UnlinkButton,{children:r.jsx(i.IconTrashBin16,{})})})]})]})})},br=({floatingOptions:e,...t})=>{const n=l.useEditorRef(),a=l.usePlateSelectors().keyEditor(),s=l.useFloatingLinkSelectors().mode(),c=l.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:d="command+k, ctrl+k"}=l.getPluginOptions(n,l.ELEMENT_LINK),g=b.useCallback(()=>{const y=l.getAboveNode(n,{match:{type:l.getPluginType(n,l.ELEMENT_LINK)}});if(y){const[,C]=y;return l.getRangeBoundingClientRect(n,{anchor:l.getStartPoint(n,C),focus:l.getEndPoint(n,C)})}return l.getDefaultBoundingClientRect()},[n]),u=c&&s==="edit",{update:w,style:f,floating:h}=l.useVirtualFloatingLink({editorId:n.id,open:u,getBoundingClientRect:g,...e});return b.useEffect(()=>{const y=ot(n);if(y&&l.floatingLinkActions.url(y),n.selection&&l.someNode(n,{match:{type:l.getPluginType(n,l.ELEMENT_LINK)}})){l.floatingLinkActions.show("edit",n.id),w();return}l.floatingLinkSelectors.mode()==="edit"&&l.floatingLinkActions.hide()},[n,a,w]),l.useHotkeys(d,y=>{y.preventDefault(),l.floatingLinkSelectors.mode()==="edit"&&l.triggerFloatingLinkEdit(n)},{enableOnContentEditable:!0},[]),l.useFloatingLinkEnter(),l.useFloatingLinkEscape(),{style:{...f,zIndex:1e3},...t,ref:l.useComposedRef(t.ref,h)}},vr={url:"",text:"",newTab:i.CheckboxState.Unchecked},pr=()=>{const[e,t]=b.useReducer((n,a)=>{const{type:s,payload:c}=a;switch(s){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"INIT":return{...n,...c};default:return n}},vr);return[e,t]},kr=()=>{const e=l.useEditorRef(),[t,n]=pr();b.useEffect(()=>{const f=st(e),h=it(e);n({type:"INIT",payload:{text:l.floatingLinkSelectors.text(),newTab:l.floatingLinkSelectors.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:f&&h===""?f:l.floatingLinkSelectors.url()}})},[n,e]);const a=f=>{n({type:"TEXT",payload:{text:f}})},s=f=>{n({type:"URL",payload:{url:f}})},c=f=>{n(f?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{l.floatingLinkActions.hide()},g=f=>{if(!R(t.url)||!u)return;const h=ce(t.url);l.floatingLinkActions.text(t.text),l.floatingLinkActions.url(h),l.floatingLinkActions.newTab(t.newTab===i.CheckboxState.Checked),l.submitFloatingLink(e)&&(f==null||f.preventDefault())},u=t.url!==""&&t.text!=="",{appBridge:w}=l.getPluginOptions(e,l.ELEMENT_LINK);return l.useHotkeys("enter",g,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:a,onUrlChange:s,onToggleTab:c,onCancel:d,onSave:g,hasValues:u,isValidUrlOrEmpty:R,appBridge:w}},Cr=()=>r.jsx(vt,{...kr(),testId:"floating-link-insert"}),xr=({readOnly:e})=>{const t=l.useFloatingLinkSelectors().isEditing();if(e)return null;const n=r.jsx(Cr,{}),a=t?n:r.jsx(yr,{});return r.jsxs(r.Fragment,{children:[r.jsx(fe.InsertRoot,{children:n}),r.jsx(fe.EditRoot,{children:a})]})},Sr=({id:e,editorId:t})=>{const n=l.usePlateEditorState(l.useEventPlateId(t)),a=!!l.isRangeInSameBlock(n,{at:n.selection});return r.jsx("div",{"data-plugin-id":e,children:r.jsx(l.LinkToolbarButton,{tooltip:i.getTooltip(a?`Link
3
+ ${i.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block."),icon:r.jsx("span",{className:"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex",children:r.jsx(i.IconLink,{size:i.IconSize.Size16})}),classNames:i.getButtonClassNames(a),styles:{root:{width:"24px",height:"24px"}},actionHandler:"onMouseDown"})})},Pr=e=>({...l.useElementProps({...e,elementToAttributes:n=>{var a,s;return{href:n.url||((s=(a=n.chosenLink)==null?void 0:a.searchResult)==null?void 0:s.link)||"",target:n.target||"_self"}}}),onMouseOver:n=>{n.stopPropagation()}}),Er=e=>{const t=Pr(e),{attributes:n,children:a}=e;return r.jsx("a",{...n,href:t.href,target:t.target,style:B[he],children:a})};class Ir extends i.MarkupElement{constructor(t=l.ELEMENT_LINK,n=Er){super(t,n)}}const Pt=e=>l.createPluginFactory({...l.createLinkPlugin(),renderAfterEditable:xr,options:{isUrl:de,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k",appBridge:e}})();class Et extends i.Plugin{constructor(t,n=B[he]){super(he,{button:Sr,markupElement:new Ir,...t}),this.styles={},this.styles=n,this.appBridge=t==null?void 0:t.appBridge}plugins(){return[Pt(this.appBridge)]}}const Tr="textstyle-custom1-plugin";class It extends i.Plugin{constructor({styles:t=B.custom1,...n}={}){super(v.custom1,{label:"Custom 1",markupElement:new Br,...n}),this.styles={},this.styles=t}plugins(){return[Lr(this.styles)]}}class Br extends i.MarkupElement{constructor(t=Tr,n=Tt){super(t,n)}}const Tt=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,style:a,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),children:n})},Lr=e=>l.createPluginFactory({key:v.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom1}]}})({component:t=>r.jsx(Tt,{...t,styles:e})}),Nr="textstyle-custom2-plugin";class Bt extends i.Plugin{constructor({styles:t=B.custom2,...n}={}){super(v.custom2,{label:"Custom 2",markupElement:new Ar,...n}),this.styles={},this.styles=t}plugins(){return[Fr(this.styles)]}}class Ar extends i.MarkupElement{constructor(t=Nr,n=Lt){super(t,n)}}const Lt=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Fr=e=>l.createPluginFactory({key:v.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom2}]}})({component:t=>r.jsx(Lt,{...t,styles:e})}),Mr="textstyle-custom3-plugin";class Nt extends i.Plugin{constructor({styles:t=B.custom3,...n}={}){super(i.TextStyles.custom3,{label:"Custom 3",markupElement:new Or,...n}),this.styles={},this.styles=t}plugins(){return[Dr(this.styles)]}}class Or extends i.MarkupElement{constructor(t=Mr,n=At){super(t,n)}}const At=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Dr=e=>l.createPluginFactory({key:i.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:i.TextStyles.custom3}]}})({component:t=>r.jsx(At,{...t,styles:e})}),Ur="textstyle-heading1-plugin";class Ft extends i.Plugin{constructor({styles:t=B.heading1,...n}={}){super(v.heading1,{label:"Heading 1",markupElement:new Hr,...n}),this.styles={},this.styles=t}plugins(){return[_r(this.styles)]}}class Hr extends i.MarkupElement{constructor(t=Ur,n=Be){super(t,n)}}const Be=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h1",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},_r=e=>l.createPluginFactory({key:v.heading1,isElement:!0,component:Be,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:t=>r.jsx(Be,{...t,styles:e})}),Vr="textstyle-heading2-plugin";class Mt extends i.Plugin{constructor({styles:t=B.heading2,...n}={}){super(v.heading2,{label:"Heading 2",markupElement:new zr,...n}),this.styles={},this.styles=t}plugins(){return[$r(this.styles)]}}class zr extends i.MarkupElement{constructor(t=Vr,n=Le){super(t,n)}}const Le=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h2",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},$r=e=>l.createPluginFactory({key:v.heading2,isElement:!0,component:Le,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:t=>r.jsx(Le,{...t,styles:e})}),Wr="textstyle-heading3-plugin";class Ot extends i.Plugin{constructor({styles:t=B.heading3,...n}={}){super(v.heading3,{label:"Heading 3",markupElement:new qr,...n}),this.styles={},this.styles=t}plugins(){return[Gr(this.styles)]}}class qr extends i.MarkupElement{constructor(t=Wr,n=Ne){super(t,n)}}const Ne=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h3",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Gr=e=>l.createPluginFactory({key:v.heading3,isElement:!0,component:Ne,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:t=>r.jsx(Ne,{...t,styles:e})}),Kr="textstyle-heading4-plugin";class Dt extends i.Plugin{constructor({styles:t=B.heading4,...n}={}){super(v.heading4,{label:"Heading 4",markupElement:new jr,...n}),this.styles={},this.styles=t}plugins(){return[Xr(this.styles)]}}class jr extends i.MarkupElement{constructor(t=Kr,n=Ae){super(t,n)}}const Ae=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("h4",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Xr=e=>l.createPluginFactory({key:v.heading4,isElement:!0,component:Ae,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:t=>r.jsx(Ae,{...t,styles:e})}),Qr="textstyle-imageCaption-plugin";class Ut extends i.Plugin{constructor({styles:t=B.imageCaption,...n}={}){super(v.imageCaption,{label:"Image Caption",markupElement:new Yr,...n}),this.styles={},this.styles=t}plugins(){return[Jr(this.styles)]}}class Yr extends i.MarkupElement{constructor(t=Qr,n=Fe){super(t,n)}}const Fe=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},Jr=e=>l.createPluginFactory({key:v.imageCaption,isElement:!0,component:Fe,deserializeHtml:{rules:[{validClassName:v.imageCaption}]}})({component:t=>r.jsx(Fe,{...t,styles:e})}),Zr="textstyle-imageTitle-plugin";class Ht extends i.Plugin{constructor({styles:t=B.imageTitle,...n}={}){super(v.imageTitle,{label:"Image Title",markupElement:new Rr,...n}),this.styles={},this.styles=t}plugins(){return[ea(this.styles)]}}class Rr extends i.MarkupElement{constructor(t=Zr,n=Me){super(t,n)}}const Me=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("p",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},ea=e=>l.createPluginFactory({key:v.imageTitle,isElement:!0,component:Me,deserializeHtml:{rules:[{validClassName:v.imageTitle}]}})({component:t=>r.jsx(Me,{...t,styles:e})});class _t extends i.Plugin{constructor({styles:t=B.p,...n}={}){super(v.p,{markupElement:new zt,label:"Body Text",...n}),this.styles={},this.styles=t}plugins(){return[$t(this.styles)]}}const Vt="tw-m-0 tw-px-0 tw-py-0",we=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align,c=i.merge([s&&i.alignmentClassnames[s],Vt,i.getColumnBreakClasses(e)]);return r.jsx("p",{...t,className:c,style:a,children:n})};class zt extends i.MarkupElement{constructor(t=v.p,n=we){super(t,n)}}const $t=e=>l.createPluginFactory({...l.createParagraphPlugin(),key:v.p,isElement:!0,component:we})({component:t=>r.jsx(we,{...t,styles:e})}),ta="textstyle-quote-plugin";class Wt extends i.Plugin{constructor({styles:t=B.quote,...n}={}){super(v.quote,{label:"Quote",markupElement:new na,...n}),this.styles={},this.styles=t}plugins(){return[qt(this.styles)]}}class na extends i.MarkupElement{constructor(t=ta,n=ye){super(t,n)}}const ye=({element:e,attributes:t,children:n,styles:a})=>{const s=e.align;return r.jsx("blockquote",{...t,className:i.merge([s&&i.alignmentClassnames[s],i.getColumnBreakClasses(e)]),style:a,children:n})},qt=e=>l.createPluginFactory({key:v.quote,isElement:!0,component:ye,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:t=>r.jsx(ye,{...t,styles:e})}),Oe=[new Ft,new Mt,new Ot,new Dt,new It,new Bt,new Nt,new Wt,new _t],ne=[v.heading1,v.heading2,v.heading3,v.heading4,v.custom1,v.custom2,v.custom3,v.quote,v.p],ra=[...Oe,new Ut,new Ht],aa=[...ne,v.imageCaption,v.imageTitle],sa=e=>new i.PluginComposer().setPlugin(new i.SoftBreakPlugin,new i.TextStylePlugin({textStyles:Oe})).setPlugin([new i.BoldPlugin,new i.ItalicPlugin,new i.UnderlinePlugin,new i.StrikethroughPlugin,new Et({appBridge:e}),new Ct({appBridge:e}),new i.CodePlugin],[new i.AlignLeftPlugin({validTypes:ne}),new i.AlignCenterPlugin({validTypes:ne}),new i.AlignRightPlugin({validTypes:ne}),new i.AlignJustifyPlugin({validTypes:ne}),new i.UnorderedListPlugin,new i.CheckboxListPlugin,new i.OrderedListPlugin,new i.ResetFormattingPlugin,new i.AutoformatPlugin]),ia="--f-theme-settings-",la=e=>{const t=e!=null&&e.id?`hasBackground${e.id}`:"hasBackground",n=e!=null&&e.id?`backgroundColor${e.id}`:"backgroundColor",a=e!=null&&e.preventDefaultColor?void 0:(e==null?void 0:e.defaultColor)||hn,s=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Background",type:"switch",switchLabel:s,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,defaultValue:a,type:"colorInput"}]}},oa=e=>{const t=e!=null&&e.id?`hasBorder_${e.id}`:"hasBorder",n=e!=null&&e.id?`borderSelection_${e.id}`:"borderSelection",a=e!=null&&e.id?`borderStyle_${e.id}`:"borderStyle",s=e!=null&&e.id?`borderWidth_${e.id}`:"borderWidth",c=e!=null&&e.id?`borderColor_${e.id}`:"borderColor",d=(e==null?void 0:e.defaultColor)||Ke,g=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Border",type:"switch",switchLabel:g,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,type:"multiInput",onChange:u=>m.appendUnit(u,s),layout:m.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:a,type:"dropdown",defaultValue:O.Solid,choices:[{value:O.Solid,label:O.Solid},{value:O.Dotted,label:O.Dotted},{value:O.Dashed,label:O.Dashed}]},{id:s,type:"input",defaultValue:mn,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px"},{id:c,type:"colorInput",defaultValue:d}]}],off:[]}},De=(e,t=$.None)=>({id:e,type:"segmentedControls",defaultValue:t,choices:[{value:$.None,label:"None"},{value:$.Small,label:"S"},{value:$.Medium,label:"M"},{value:$.Large,label:"L"}]}),ca=e=>{const t=e!=null&&e.id?`hasRadius_${e.id}`:"hasRadius",n=e!=null&&e.id?`radiusValue_${e.id}`:"radiusValue",a=e!=null&&e.id?`radiusChoice_${e.id}`:"radiusChoice",s=(e==null?void 0:e.defaultRadius)||$.None;return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:c=>{var d;return e!=null&&e.dependentSettingId?!!((d=c.getBlock(e.dependentSettingId))!=null&&d.value):!0},onChange:c=>m.presetCustomValue(c,a,n,(e==null?void 0:e.radiusStyleMap)||G),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[m.numericalOrPixelRule],onChange:c=>m.appendUnit(c,n)}],off:[De(a,s)]}},da=e=>{const t=e!=null&&e.id?`hasExtendedCustomRadius_${e.id}`:"hasExtendedCustomRadius",n=e!=null&&e.id?`extendedRadiusValue_${e.id}`:"extendedRadiusValue",a=e!=null&&e.id?`extendedRadiusChoice_${e.id}`:"extendedRadiusChoice",s=e!=null&&e.id?`extendedRadiusTopLeft_${e.id}`:"extendedRadiusTopLeft",c=e!=null&&e.id?`extendedRadiusTopRight_${e.id}`:"extendedRadiusTopRight",d=e!=null&&e.id?`extendedRadiusBottomLeft_${e.id}`:"extendedRadiusBottomLeft",g=e!=null&&e.id?`extendedRadiusBottomRight_${e.id}`:"extendedRadiusBottomRight";return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:u=>{var w;return e!=null&&e.dependentSettingId?!!((w=u.getBlock(e.dependentSettingId))!=null&&w.value):!0},onChange:u=>{m.presetCustomValue(u,a,s,G),m.presetCustomValue(u,a,c,G),m.presetCustomValue(u,a,d,G),m.presetCustomValue(u,a,g,G)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,blocks:[{id:s,type:"input",label:"Top Left",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,s)},{id:c,type:"input",label:"Top Right",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,c)},{id:d,type:"input",label:"Bottom Left",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,d)},{id:g,type:"input",label:"Bottom Right",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,g)}]}],off:[De(a,e==null?void 0:e.defaultValue)]}},ua=e=>{const t=e!=null&&e.id?e.id:"hasCustomSpacing",n=e!=null&&e.dependentSettingId?e.dependentSettingId:"columns",a=e!=null&&e.spacingChoiceId?e.spacingChoiceId:"spacingChoice",s=e!=null&&e.spacingCustomId?e.spacingCustomId:"spacingCustom",c=e!=null&&e.defaultValueChoices?e.defaultValueChoices:Q.M;return{id:t,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:d=>m.presetCustomValue(d,a,s,Ge),show:d=>{var g;return((g=d.getBlock(n))==null?void 0:g.value)!=="1"},on:[{id:s,type:"input",rules:[m.numericalOrPixelRule],onChange:d=>m.appendUnit(d,s)}],off:[{id:a,type:"slider",defaultValue:c,choices:[{value:Q.Auto,label:"Auto"},{value:Q.S,label:"S"},{value:Q.M,label:"M"},{value:Q.L,label:"L"}]}]}},Ue=e=>({id:e,type:"segmentedControls",defaultValue:j.None,choices:[{value:j.None,label:"None"},{value:j.Small,label:"S"},{value:j.Medium,label:"M"},{value:j.Large,label:"L"}]}),ga=e=>{const t=e!=null&&e.id?`hasCustomMarginValue_${e==null?void 0:e.id}`:"hasCustomMarginValue",n=e!=null&&e.id?`marginValue_${e==null?void 0:e.id}`:"marginValue",a=e!=null&&e.id?`marginChoice_${e==null?void 0:e.id}`:"marginChoice";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:s=>m.presetCustomValue(s,a,n,(e==null?void 0:e.marginStyleMap)||Z),on:[{id:n,type:"input",placeholder:se,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:s=>m.appendUnit(s,n)}],off:[Ue(a)]}},ha=e=>{const t=e!=null&&e.id?`hasExtendedCustomMargin_${e==null?void 0:e.id}`:"hasExtendedCustomMargin",n=e!=null&&e.id?`extendedMarginValues_${e==null?void 0:e.id}`:"extendedMarginValues",a=e!=null&&e.id?`extendedMarginChoice_${e==null?void 0:e.id}`:"extendedMarginChoice",s=e!=null&&e.id?`extendedMarginTop_${e==null?void 0:e.id}`:"extendedMarginTop",c=e!=null&&e.id?`extendedMarginLeft_${e==null?void 0:e.id}`:"extendedMarginLeft",d=e!=null&&e.id?`extendedMarginRight_${e==null?void 0:e.id}`:"extendedMarginRight",g=e!=null&&e.id?`extendedMarginBottom_${e==null?void 0:e.id}`:"extendedMarginBottom";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:u=>{m.presetCustomValue(u,a,s,Z),m.presetCustomValue(u,a,c,Z),m.presetCustomValue(u,a,d,Z),m.presetCustomValue(u,a,g,Z)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:s,type:"input",label:"Top",placeholder:se,onChange:u=>m.appendUnit(u,s),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Left",placeholder:se,onChange:u=>m.appendUnit(u,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:se,onChange:u=>m.appendUnit(u,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:g,type:"input",label:"Bottom",placeholder:se,onChange:u=>m.appendUnit(u,g),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Ue(a)]}},He=e=>({id:e,type:"segmentedControls",defaultValue:K.Small,choices:[{value:K.None,label:"None"},{value:K.Small,label:"S"},{value:K.Medium,label:"M"},{value:K.Large,label:"L"}]}),ma=e=>{const t=e!=null&&e.id?`hasCustomPaddingValue_${e==null?void 0:e.id}`:"hasCustomPaddingValue",n=e!=null&&e.id?`paddingValue_${e==null?void 0:e.id}`:"paddingValue",a=e!=null&&e.id?`paddingChoice_${e==null?void 0:e.id}`:"paddingChoice";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:s=>m.presetCustomValue(s,a,n,(e==null?void 0:e.paddingStyleMap)||J),on:[{id:n,type:"input",placeholder:ae,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:s=>m.appendUnit(s,n)}],off:[He(a)]}},fa=e=>{const t=e!=null&&e.id?`hasExtendedCustomPadding_${e==null?void 0:e.id}`:"hasExtendedCustomPadding",n=e!=null&&e.id?`extendedPaddingValues_${e==null?void 0:e.id}`:"extendedPaddingValues",a=e!=null&&e.id?`extendedPaddingChoice_${e==null?void 0:e.id}`:"extendedPaddingChoice",s=e!=null&&e.id?`extendedPaddingTop_${e==null?void 0:e.id}`:"extendedPaddingTop",c=e!=null&&e.id?`extendedPaddingLeft_${e==null?void 0:e.id}`:"extendedPaddingLeft",d=e!=null&&e.id?`extendedPaddingRight_${e==null?void 0:e.id}`:"extendedPaddingRight",g=e!=null&&e.id?`extendedPaddingBottom_${e==null?void 0:e.id}`:"extendedPaddingBottom";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:u=>{m.presetCustomValue(u,a,s,J),m.presetCustomValue(u,a,c,J),m.presetCustomValue(u,a,d,J),m.presetCustomValue(u,a,g,J)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:s,type:"input",label:"Top",placeholder:ae,onChange:u=>m.appendUnit(u,s),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Left",placeholder:ae,onChange:u=>m.appendUnit(u,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:ae,onChange:u=>m.appendUnit(u,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:g,type:"input",label:"Bottom",placeholder:ae,onChange:u=>m.appendUnit(u,g),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[He(a)]}},wa=e=>{const t=_e(e==null?void 0:e.globalControlId);return{id:e!=null&&e.id?e.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>{var a;return((a=n.getBlock(t))==null?void 0:a.value)===X.Custom}}},_e=e=>e||"security",ya=e=>[{id:_e(e),type:"segmentedControls",defaultValue:X.Global,choices:[{value:X.Global,label:"Global Settings"},{value:X.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:m.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Gt=(e=>(e.Main="main",e.Basics="basics",e.Layout="layout",e.Style="style",e.Security="security",e.Targets="targets",e))(Gt||{});const ba=e=>e,va=e=>e;o.AllTextStylePlugins=ra,o.AllTextStyles=aa,o.Attachments=Ye,o.AttachmentsProvider=Re,o.BUTTON_PLUGIN=pt,o.BlockButtonStyles=ge,o.BlockInjectButton=nn,o.BlockItemWrapper=En,o.BlockStyles=B,o.BorderStyle=O,o.ButtonPlugin=Ct,o.Custom1Plugin=It,o.Custom2Plugin=Bt,o.Custom3Plugin=Nt,o.DEFAULT_DRAGGING_TOOLTIP=Xe,o.DEFAULT_DRAG_TOOLTIP=je,o.DownloadButton=In,o.ELEMENT_BUTTON=x,o.GutterSpacing=Q,o.Heading1Plugin=Ft,o.Heading2Plugin=Mt,o.Heading3Plugin=Ot,o.Heading4Plugin=Dt,o.ImageCaptionPlugin=Ut,o.ImageTitlePlugin=Ht,o.LinkInput=bt,o.LinkPlugin=Et,o.LinkSelector=yt,o.Margin=j,o.PARAGRAPH_CLASSES=Vt,o.Padding=K,o.ParagraphMarkupElement=zt,o.ParagraphMarkupElementNode=we,o.ParagraphPlugin=_t,o.QuoteMarkupElementNode=ye,o.QuotePlugin=Wt,o.Radius=$,o.RichTextEditor=hr,o.Sections=Gt,o.Security=X,o.THEME_PREFIX=ia,o.TextStylePluginsWithoutImage=Oe,o.TextStyles=v,o.TextStylesWithoutImage=ne,o.Toolbar=nt,o.addHttps=ce,o.borderStyleMap=qe,o.convertToRteValue=Bn,o.createButtonNode=mt,o.createButtonPlugin=kt,o.createLinkPlugin=Pt,o.createParagraphPlugin=$t,o.createQuotePlugin=qt,o.customCoordinatesGetterFactory=tt,o.defineBlock=ba,o.defineSettings=va,o.getBackgroundColorStyles=gn,o.getBackgroundSettings=la,o.getBorderRadiusSettings=ca,o.getBorderRadiusSlider=De,o.getBorderSettings=oa,o.getBorderStyles=fn,o.getDefaultPluginsWithLinkChooser=sa,o.getExtendedBorderRadiusSettings=da,o.getGutterSettings=ua,o.getLegacyUrl=st,o.getLinkFromEditor=ot,o.getMarginExtendedSettings=ha,o.getMarginSettings=ga,o.getMarginSlider=Ue,o.getPaddingExtendedSettings=fa,o.getPaddingSettings=ma,o.getPaddingSlider=He,o.getRadiusStyles=wn,o.getReadableColor=dn,o.getSecurityDownloadableSetting=wa,o.getSecurityGlobalControlId=_e,o.getSecurityGlobalControlSetting=ya,o.getUrl=it,o.getUrlFromEditor=ht,o.getUrlFromLinkOrLegacyLink=lt,o.gutterSpacingStyleMap=Ge,o.hasRichTextValue=rt,o.insertButton=dt,o.isDark=an,o.isDownloadable=Ln,o.isValidUrl=de,o.isValidUrlOrEmpty=R,o.joinClassNames=_,o.mapAppBridgeColorPaletteToFonduePalette=at,o.mapAppBridgeColorPalettesToFonduePalettes=Nn,o.marginStyleMap=Z,o.moveItemInArray=un,o.paddingStyleMap=J,o.radiusStyleMap=G,o.relativeUrlRegex=xe,o.setAlpha=on,o.submitFloatingButton=Pe,o.toColorObject=cn,o.toHex8String=sn,o.toHexString=ln,o.toRgbaString=pe,o.toShortRgba=q,o.triggerFloatingButton=ft,o.triggerFloatingButtonEdit=ue,o.triggerFloatingButtonInsert=Ie,o.unwrapButton=te,o.upsertButton=ut,o.upsertButtonText=Ee,o.useAttachments=Je,o.useAttachmentsContext=et,o.useDndSensors=xn,o.withAttachmentsProvider=pn,o.withButton=ct,o.wrapButton=gt,Object.keys(m).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:()=>m[e]})}),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
4
4
  //# sourceMappingURL=index.umd.js.map