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