@frontify/guideline-blocks-settings 0.29.7 → 0.29.9

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