@frontify/guideline-blocks-settings 0.28.6 → 0.29.1

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