@frontify/guideline-blocks-settings 0.32.0 → 0.32.2

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