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