@frontify/guideline-blocks-settings 0.34.5 → 0.34.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/RichTextEditor/RichTextEditor.es.js +12 -12
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,20 +7,20 @@ import { floatingButtonSelectors as L, floatingButtonActions as S } from "./plug
|
|
|
7
7
|
const E = x(
|
|
8
8
|
({
|
|
9
9
|
id: d = "rte",
|
|
10
|
-
isEnabled:
|
|
10
|
+
isEnabled: i,
|
|
11
11
|
value: t,
|
|
12
12
|
columns: n,
|
|
13
|
-
gap:
|
|
13
|
+
gap: r,
|
|
14
14
|
placeholder: f,
|
|
15
15
|
plugins: s,
|
|
16
|
-
onTextChange:
|
|
16
|
+
onTextChange: o,
|
|
17
17
|
showSerializedText: w
|
|
18
18
|
}) => {
|
|
19
19
|
const [c, u] = h(!1), b = a(
|
|
20
20
|
(e) => {
|
|
21
|
-
e !== t && (
|
|
21
|
+
e !== t && (o == null || o(e)), u(!1);
|
|
22
22
|
},
|
|
23
|
-
[
|
|
23
|
+
[o, t]
|
|
24
24
|
), g = a(() => u(!0), []), V = a((e) => {
|
|
25
25
|
L.isOpen(e) && S.reset();
|
|
26
26
|
}, []);
|
|
@@ -29,7 +29,7 @@ const E = x(
|
|
|
29
29
|
m.preventDefault(), m.returnValue = "Unprocessed changes";
|
|
30
30
|
};
|
|
31
31
|
return c && window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
|
|
32
|
-
}, [c]),
|
|
32
|
+
}, [c]), i ? /* @__PURE__ */ l(
|
|
33
33
|
v,
|
|
34
34
|
{
|
|
35
35
|
id: d,
|
|
@@ -41,17 +41,17 @@ const E = x(
|
|
|
41
41
|
onTextChange: b,
|
|
42
42
|
hideExternalFloatingModals: V
|
|
43
43
|
}
|
|
44
|
-
) : /* @__PURE__ */ l(P, { value: t, columns: n, gap:
|
|
44
|
+
) : /* @__PURE__ */ l(P, { value: t, columns: n, gap: r, show: w, plugins: s });
|
|
45
45
|
}
|
|
46
46
|
);
|
|
47
47
|
E.displayName = "InternalRichTextEditor";
|
|
48
48
|
const M = (d) => {
|
|
49
|
-
const
|
|
50
|
-
|
|
49
|
+
const i = R(null), [t, n] = h(!1), { isEditing: r, ...f } = d, s = a((o) => {
|
|
50
|
+
o && n(!0);
|
|
51
51
|
}, []);
|
|
52
|
-
return I({ ref:
|
|
53
|
-
n(!1);
|
|
54
|
-
}, []), /* @__PURE__ */ l("div", { className: "tw-block tw-w-full", ref:
|
|
52
|
+
return I({ ref: i, disabled: !r, onChange: s }), p(() => {
|
|
53
|
+
r || n(!1);
|
|
54
|
+
}, [r]), /* @__PURE__ */ l("div", { className: "tw-block tw-w-full", ref: i, children: /* @__PURE__ */ l(E, { ...f, isEnabled: r && t }) });
|
|
55
55
|
};
|
|
56
56
|
export {
|
|
57
57
|
M as RichTextEditor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.es.js","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { memo, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { RichTextEditor as FondueRichTextEditor } from '@frontify/fondue';\nimport { RichTextEditorProps } from './types';\nimport { SerializedText } from './SerializedText';\nimport { floatingButtonActions, floatingButtonSelectors } from './plugins/ButtonPlugin/components';\nimport { useIsInViewport } from '../../hooks/useIsInViewport';\n\nconst InternalRichTextEditor = memo(\n ({\n id = 'rte',\n isEnabled,\n value,\n columns,\n gap,\n placeholder,\n plugins,\n onTextChange,\n showSerializedText,\n }: Omit<RichTextEditorProps, 'isEditing'> & { isEnabled: boolean }) => {\n const [shouldPreventPageLeave, setShouldPreventPageLeave] = useState(false);\n\n const handleTextChange = useCallback(\n (newContent: string) => {\n if (newContent !== value) {\n onTextChange?.(newContent);\n
|
|
1
|
+
{"version":3,"file":"RichTextEditor.es.js","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { memo, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { RichTextEditor as FondueRichTextEditor } from '@frontify/fondue';\nimport { RichTextEditorProps } from './types';\nimport { SerializedText } from './SerializedText';\nimport { floatingButtonActions, floatingButtonSelectors } from './plugins/ButtonPlugin/components';\nimport { useIsInViewport } from '../../hooks/useIsInViewport';\n\nconst InternalRichTextEditor = memo(\n ({\n id = 'rte',\n isEnabled,\n value,\n columns,\n gap,\n placeholder,\n plugins,\n onTextChange,\n showSerializedText,\n }: Omit<RichTextEditorProps, 'isEditing'> & { isEnabled: boolean }) => {\n const [shouldPreventPageLeave, setShouldPreventPageLeave] = useState(false);\n\n const handleTextChange = useCallback(\n (newContent: string) => {\n if (newContent !== value) {\n onTextChange?.(newContent);\n }\n setShouldPreventPageLeave(false);\n },\n [onTextChange, value],\n );\n\n const handleValueChange = useCallback(() => setShouldPreventPageLeave(true), []);\n\n const handleHideExternalFloatingModals = useCallback((editorId: string) => {\n if (floatingButtonSelectors.isOpen(editorId)) {\n floatingButtonActions.reset();\n }\n }, []);\n\n useEffect(() => {\n const unloadHandler = (event: BeforeUnloadEvent) => {\n event.preventDefault();\n event.returnValue = 'Unprocessed changes';\n };\n\n if (shouldPreventPageLeave) {\n window.addEventListener('beforeunload', unloadHandler);\n }\n\n return () => window.removeEventListener('beforeunload', unloadHandler);\n }, [shouldPreventPageLeave]);\n\n if (isEnabled) {\n return (\n <FondueRichTextEditor\n id={id}\n value={value}\n border={false}\n placeholder={placeholder}\n plugins={plugins}\n onValueChanged={handleValueChange}\n onTextChange={handleTextChange}\n hideExternalFloatingModals={handleHideExternalFloatingModals}\n />\n );\n }\n return <SerializedText value={value} columns={columns} gap={gap} show={showSerializedText} plugins={plugins} />;\n },\n);\nInternalRichTextEditor.displayName = 'InternalRichTextEditor';\n\nexport const RichTextEditor = (props: RichTextEditorProps) => {\n const ref = useRef<HTMLDivElement>(null);\n const [hasEnteredViewport, setHasEnteredViewport] = useState(false);\n\n const { isEditing, ...internalRteProps } = props;\n\n const onViewportVisibilityChange = useCallback((isInViewport: boolean) => {\n if (isInViewport) {\n setHasEnteredViewport(true);\n }\n }, []);\n\n useIsInViewport({ ref, disabled: !isEditing, onChange: onViewportVisibilityChange });\n\n useEffect(() => {\n if (!isEditing) {\n setHasEnteredViewport(false);\n }\n }, [isEditing]);\n\n return (\n <div className=\"tw-block tw-w-full\" ref={ref}>\n <InternalRichTextEditor {...internalRteProps} isEnabled={isEditing && hasEnteredViewport} />\n </div>\n );\n};\n"],"names":["InternalRichTextEditor","memo","id","isEnabled","value","columns","gap","placeholder","plugins","onTextChange","showSerializedText","shouldPreventPageLeave","setShouldPreventPageLeave","useState","handleTextChange","useCallback","newContent","handleValueChange","handleHideExternalFloatingModals","editorId","floatingButtonSelectors","floatingButtonActions","useEffect","unloadHandler","event","jsx","FondueRichTextEditor","SerializedText","RichTextEditor","props","ref","useRef","hasEnteredViewport","setHasEnteredViewport","isEditing","internalRteProps","onViewportVisibilityChange","isInViewport","useIsInViewport"],"mappings":";;;;;;AAUA,MAAMA,IAAyBC;AAAA,EAC3B,CAAC;AAAA,IACG,IAAAC,IAAK;AAAA,IACL,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,KAAAC;AAAA,IACA,aAAAC;AAAA,IACA,SAAAC;AAAA,IACA,cAAAC;AAAA,IACA,oBAAAC;AAAA,EAAA,MACmE;AACnE,UAAM,CAACC,GAAwBC,CAAyB,IAAIC,EAAS,EAAK,GAEpEC,IAAmBC;AAAA,MACrB,CAACC,MAAuB;AACpB,QAAIA,MAAeZ,MACfK,KAAA,QAAAA,EAAeO,KAEnBJ,EAA0B,EAAK;AAAA,MACnC;AAAA,MACA,CAACH,GAAcL,CAAK;AAAA,IAAA,GAGlBa,IAAoBF,EAAY,MAAMH,EAA0B,EAAI,GAAG,CAAA,CAAE,GAEzEM,IAAmCH,EAAY,CAACI,MAAqB;AACnE,MAAAC,EAAwB,OAAOD,CAAQ,KACvCE,EAAsB,MAAM;AAAA,IAEpC,GAAG,CAAE,CAAA;AAeL,WAbAC,EAAU,MAAM;AACN,YAAAC,IAAgB,CAACC,MAA6B;AAChD,QAAAA,EAAM,eAAe,GACrBA,EAAM,cAAc;AAAA,MAAA;AAGxB,aAAIb,KACO,OAAA,iBAAiB,gBAAgBY,CAAa,GAGlD,MAAM,OAAO,oBAAoB,gBAAgBA,CAAa;AAAA,IAAA,GACtE,CAACZ,CAAsB,CAAC,GAEvBR,IAEI,gBAAAsB;AAAA,MAACC;AAAAA,MAAA;AAAA,QACG,IAAAxB;AAAA,QACA,OAAAE;AAAA,QACA,QAAQ;AAAA,QACR,aAAAG;AAAA,QACA,SAAAC;AAAA,QACA,gBAAgBS;AAAA,QAChB,cAAcH;AAAA,QACd,4BAA4BI;AAAA,MAAA;AAAA,IAAA,sBAIhCS,GAAe,EAAA,OAAAvB,GAAc,SAAAC,GAAkB,KAAAC,GAAU,MAAMI,GAAoB,SAAAF,EAAkB,CAAA;AAAA,EACjH;AACJ;AACAR,EAAuB,cAAc;AAExB,MAAA4B,IAAiB,CAACC,MAA+B;AACpD,QAAAC,IAAMC,EAAuB,IAAI,GACjC,CAACC,GAAoBC,CAAqB,IAAIpB,EAAS,EAAK,GAE5D,EAAE,WAAAqB,GAAW,GAAGC,EAAA,IAAqBN,GAErCO,IAA6BrB,EAAY,CAACsB,MAA0B;AACtE,IAAIA,KACAJ,EAAsB,EAAI;AAAA,EAElC,GAAG,CAAE,CAAA;AAEL,SAAAK,EAAgB,EAAE,KAAAR,GAAK,UAAU,CAACI,GAAW,UAAUE,GAA4B,GAEnFd,EAAU,MAAM;AACZ,IAAKY,KACDD,EAAsB,EAAK;AAAA,EAC/B,GACD,CAACC,CAAS,CAAC,GAGT,gBAAAT,EAAA,OAAA,EAAI,WAAU,sBAAqB,KAAAK,GAChC,UAAA,gBAAAL,EAACzB,GAAwB,EAAA,GAAGmC,GAAkB,WAAWD,KAAaF,EAAA,CAAoB,EAC9F,CAAA;AAER;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";var yn=Object.defineProperty;var vn=(e,t,n)=>t in e?yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>(vn(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@frontify/sidebar-settings"),a=require("react/jsx-runtime"),r=require("@frontify/fondue"),m=require("react"),G=require("@frontify/app-bridge"),T=require("@dnd-kit/core"),Cn=require("@dnd-kit/modifiers"),ue=require("@dnd-kit/sortable"),tt=require("@react-aria/focus"),Sn=require("@react-stately/overlays"),_=require("@ctrl/tinycolor"),O=e=>e.filter(Boolean).join(" "),kn=({onDrop:e,label:t,icon:n,secondaryLabel:s,isLoading:i,fillParentContainer:o,onAssetChooseClick:l,onUploadClick:u,withMenu:c=!0,onClick:f,validFileType:h,verticalLayout:d})=>{const[x,p]=m.useState(!1),[w,v]=m.useState(),k=m.useRef(null),[E,A]=m.useState(void 0),R=S=>{if(S.preventDefault(),p(!1),!F(S.dataTransfer.files)){A("Invalid"),setTimeout(()=>{A(void 0)},1e3);return}e==null||e(S.dataTransfer.files)},F=S=>{if(!h)return!0;for(let L=0;L<S.length;L++){const M=S[L].name.split(".").pop()??"";if(!G.FileExtensionSets[h].includes(M))return!1}return!0},U=S=>{if(!k.current||i)return;const{left:L,top:M}=k.current.getBoundingClientRect(),le=S.clientX-L,ce=S.clientY-M;v([le,ce])};return a.jsxs("button",{ref:k,"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",d?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",o?"tw-h-full":"tw-h-[72px]",x&&!i?"tw-border-dashed":"tw-border-solid",w&&"tw-bg-blank-state-pressed-inverse",x&&"tw-bg-blank-state-weak-inverse",E?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",i||w||x||E?"":"tw-text-text-weak hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",(x||w)&&!E?"[&>*]: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),h==="Images")for(const M of Array.from(S.dataTransfer.items))(L=M==null?void 0:M.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),f==null||f()},children:[i?a.jsx(r.LoadingCircle,{}):E?a.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[a.jsx(r.IconExclamationMarkTriangle,{}),E]}):a.jsxs(a.Fragment,{children:[n&&a.jsx("div",{children:n}),(t||s)&&a.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[t&&a.jsx("div",{className:"tw-font-medium",children:t}),s&&a.jsx("div",{className:"tw-font-normal",children:s})]})]}),w&&a.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:w[0],top:w[1]},children:a.jsx(r.Flyout,{onOpenChange:S=>!S&&v(void 0),isOpen:!0,fitContent:!0,hug:!1,legacyFooter:!1,trigger:a.jsx("div",{}),children:a.jsx(r.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[...u?[{id:"upload",size:r.MenuItemContentSize.XSmall,title:"Upload asset",onClick:()=>{u(),v(void 0)},initialValue:!0,decorator:a.jsx("div",{className:"tw-mr-2",children:a.jsx(r.IconArrowCircleUp20,{})})}]:[],...l?[{id:"asset",size:r.MenuItemContentSize.XSmall,title:"Browse asset",onClick:()=>{l(),v(void 0)},initialValue:!0,decorator:a.jsx("div",{className:"tw-mr-2",children:a.jsx(r.IconImageStack20,{})})}]:[]]}]})})})]})},X=e=>{const t=s=>typeof s=="object"&&["red","green","blue"].every(o=>s.hasOwnProperty(o)),n=s=>{const i=typeof s.alpha=="number"?s.alpha:1;return{r:s.red,g:s.green,b:s.blue,a:i}};return t(e)?n(e):e},Tn=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),Pn=(e,t)=>{const n=Tn(e)?X(e):e,s=new _.TinyColor(n);return t?s.getBrightness()<t:s.isDark()||s.getAlpha()>.25&&s.getAlpha()<1},In=e=>new _.TinyColor(X(e)).toHex8String(),En=e=>new _.TinyColor(X(e)).toHexString(),Ee=e=>new _.TinyColor(X(e)).toRgbString(),Bn=(e,t)=>new _.TinyColor(t).setAlpha(e).toRgbString(),jn=e=>{const{r:t,g:n,b:s,a:i}=new _.TinyColor(e);return{red:t,green:n,blue:s,alpha:i}},Ye=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),Nn=(e,t)=>{const n=Ye(e)?X(e):e,s=Ye(t)?X(t):t;let i=new _.TinyColor(n);const o=new _.TinyColor(s);for(;_.readability(i,o)<4.5;)i=i.darken(1);return i.toRgbString()},Ln=(e,t,n)=>{const s=[...e],i=n<0?s.length+n:n;if(i>=0&&i<s.length){const o=s.splice(t,1)[0];s.splice(i,0,o)}return s},An=e=>({backgroundColor:Ee(e)});var D=(e=>(e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted",e))(D||{});const nt={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 rt={Auto:"4px",S:"10px",M:"30px",L:"50px"},Rn={red:241,green:241,blue:241,alpha:1},st={red:234,green:235,blue:235,alpha:1},Mn="1px",re="24px",se="24px",Fn=(e=D.Solid,t="1px",n=st)=>({borderStyle:nt[e],borderWidth:t,borderColor:Ee(n)}),Dn=(e,t=!1,n)=>({borderRadius:t?n:q[e]}),at=m.createContext(!1),it=({children:e,isDragPreview:t})=>a.jsx(at.Provider,{value:t,children:e}),ie=()=>m.useContext(at),ot=m.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")}),lt=({children:e,openFlyoutIds:t,setOpenFlyoutIds:n})=>{const s=m.useMemo(()=>({openFlyoutIds:t,setOpenFlyoutIds:n}),[t,n]);return a.jsx(ot.Provider,{value:s,children:e})},ct=()=>m.useContext(ot),he=e=>{const{openFlyoutIds:t,setOpenFlyoutIds:n}=ct(),s=m.useCallback(i=>{n(o=>{const l=o.filter(u=>u!==e);return i?[...l,e]:l})},[e,n]);return{isOpen:t.includes(e),onOpenChange:s}},Je=({children:e})=>a.jsx("div",{className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:e}),ut=(e,t)=>{const{blockAssets:n,addAssetIdsToKey:s,deleteAssetIdsFromKey:i,updateAssetIdsFromKey:o}=G.useBlockAssets(e),l=(n==null?void 0:n[t])||[];return{onAttachmentsAdd:async d=>{await s(t,d.map(x=>x.id))},onAttachmentDelete:async d=>{await i(t,[d.id])},onAttachmentReplace:async(d,x)=>{const p=l.map(w=>w.id===d.id?x.id:w.id);await o(t,p)},onAttachmentsSorted:async d=>{const x=d.map(p=>p.id);await o(t,x)},attachments:l,appBridge:e}},dt=m.createContext(null),gt=({appBridge:e,children:t,assetId:n})=>{const s=ut(e,n);return a.jsx(dt.Provider,{value:s,children:t})},mt=()=>{const e=m.useContext(dt);if(!e)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return e},On=(e,t)=>{const n=s=>a.jsx(gt,{appBridge:s.appBridge,assetId:t,children:a.jsx(e,{...s})});return n.displayName="withAttachmentsProvider",n},Un=[T.KeyboardCode.Down,T.KeyboardCode.Right,T.KeyboardCode.Up,T.KeyboardCode.Left],ht=(e,t)=>(n,{currentCoordinates:s,context:{activeNode:i}})=>{if(n.preventDefault(),Un.includes(n.code)){const o=(i==null?void 0:i.offsetWidth)??0,l=(i==null?void 0:i.offsetHeight)??0;switch(n.code){case T.KeyboardCode.Right:return{...s,x:s.x+o+e};case T.KeyboardCode.Left:return{...s,x:s.x-o-e};case T.KeyboardCode.Down:return{...s,y:s.y+l+t};case T.KeyboardCode.Up:return{...s,y:s.y-l-t}}}},_n={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},Hn=(e=0,t=0)=>{const n=ht(e,t);return T.useSensors(T.useSensor(T.PointerSensor),T.useSensor(T.KeyboardSensor,{coordinateGetter:n,keyboardCodes:_n}))},Vn=e=>e==="IMAGE"?a.jsx(r.IconImage24,{}):e==="VIDEO"?a.jsx(r.IconPlayFrame24,{}):e==="AUDIO"?a.jsx(r.IconMusicNote24,{}):a.jsx(r.IconDocument24,{}),Be=m.forwardRef(({item:e,isEditing:t,draggableProps:n,transformStyle:s,isDragging:i,isOverlay:o,isLoading:l,onDelete:u,onReplaceWithBrowse:c,onReplaceWithUpload:f,onDownload:h},d)=>{const[x,p]=m.useState(),[w,{selectedFiles:v}]=G.useFileInput({multiple:!0,accept:"image/*"}),[k,{results:E,doneAll:A}]=G.useAssetUpload(),{focusProps:R,isFocusVisible:F}=tt.useFocusRing();m.useEffect(()=>{v&&k(v[0])},[v]),m.useEffect(()=>{A&&f(E[0])},[A,E]);const U=l||v&&!A;return a.jsxs("button",{"aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>h==null?void 0:h(),ref:d,style:{...s,opacity:i&&!o?.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",i?"tw-bg-box-neutral-hover":""]),children:[a.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:U?a.jsx(r.LoadingCircle,{size:r.LoadingCircleSize.Small}):Vn(e.objectType)}),a.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[a.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:e.title}),a.jsx("div",{className:"tw-text-text-weak",children:`${e.fileSizeHumanReadable} - ${e.extension}`})]}),t&&a.jsxs("div",{"data-test-id":"attachments-actionbar",className: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",o||(x==null?void 0:x.id)===e.id?"tw-opacity-100":"tw-opacity-0"]),children:[a.jsx("button",{...R,...n,"aria-label":"Drag attachment",className:O([" tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded tw-h-9 tw-w-9 ",i||o?"tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed":"tw-cursor-grab hover:tw-bg-button-background-hover",F&&r.FOCUS_STYLE,F&&"tw-z-[2]"]),children:a.jsx(r.IconGrabHandle20,{})}),a.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:a.jsx(r.Flyout,{placement:r.FlyoutPlacement.Right,isOpen:(x==null?void 0:x.id)===e.id,fitContent:!0,legacyFooter:!1,onOpenChange:S=>p(S?e:void 0),trigger:(S,L)=>a.jsx(r.Button,{ref:L,icon:a.jsx(r.IconPen20,{}),emphasis:r.ButtonEmphasis.Default,onClick:()=>p(e)}),children:a.jsx(r.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[{id:"upload",size:r.MenuItemContentSize.XSmall,title:"Replace with upload",onClick:()=>{w(),p(void 0)},initialValue:!0,decorator:a.jsx("div",{className:"tw-mr-2",children:a.jsx(r.IconArrowCircleUp20,{})})},{id:"asset",size:r.MenuItemContentSize.XSmall,title:"Replace with asset",onClick:()=>{c(),p(void 0)},initialValue:!0,decorator:a.jsx("div",{className:"tw-mr-2",children:a.jsx(r.IconImageStack20,{})})}]},{id:"menu-delete",menuItems:[{id:"delete",size:r.MenuItemContentSize.XSmall,title:"Delete",style:r.MenuItemStyle.Danger,onClick:()=>{u(),p(void 0)},initialValue:!0,decorator:a.jsx("div",{className:"tw-mr-2",children:a.jsx(r.IconTrashBin20,{})})}]}]})})})]})]})});Be.displayName="AttachmentItem";const zn=e=>{const{attributes:t,listeners:n,setNodeRef:s,transform:i,transition:o,isDragging:l}=ue.useSortable({id:e.item.id}),u={transform:i?`translate(${i.x}px, ${i.y}px)`:"",transition:o,zIndex:l?2:1},c={...t,...n};return a.jsx(Be,{ref:s,isDragging:l,transformStyle:u,draggableProps:c,...e})},$n=({children:e,isFlyoutOpen:t,triggerProps:n,triggerRef:s})=>a.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",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"]),...n,ref:s,"data-test-id":"attachments-button-trigger",children:[a.jsx(r.IconPaperclip16,{}),e,a.jsx(r.IconCaretDown12,{})]}),ft=({items:e=[],onDelete:t,onReplaceWithBrowse:n,onReplaceWithUpload:s,onBrowse:i,onUpload:o,onSorted:l,appBridge:u,triggerComponent:c=$n,isOpen:f,onOpenChange:h})=>{const[d,x]=m.useState(e),[p,w]=m.useState(!1),v=T.useSensors(T.useSensor(T.PointerSensor),T.useSensor(T.KeyboardSensor)),[k,E]=m.useState(void 0),[A,R]=m.useState(!1),[F,U]=m.useState([]),[S,L]=m.useState(null),M=G.useEditorState(u),{openAssetChooser:le,closeAssetChooser:ce}=G.useAssetChooser(u),We=f!==void 0,be=We?f:p,Q=d==null?void 0:d.find(y=>y.id===k),[hn,{results:qe,doneAll:Ge}]=G.useAssetUpload({onUploadProgress:()=>!A&&R(!0)}),ne=y=>{const I=We?h:w;I==null||I(y)};m.useEffect(()=>{x(e)},[e]),m.useEffect(()=>{S&&(R(!0),hn(S))},[S]),m.useEffect(()=>{(async()=>{Ge&&(await o(qe),R(!1))})()},[Ge,qe]);const fn=()=>{ne(!1),le(y=>{i(y),ce(),ne(!0)},{multiSelection:!0,selectedValueIds:d.map(y=>y.id)})},Ke=y=>{ne(!1),le(async I=>{ne(!0),ce(),U([...F,y.id]),await n(y,I[0]),U(F.filter(V=>V!==y.id))},{multiSelection:!1,selectedValueIds:d.map(I=>I.id)})},Xe=async(y,I)=>{U([...F,y.id]),await s(y,I),U(F.filter(V=>V!==y.id))},xn=y=>{const{active:I}=y;E(I.id)},pn=y=>{const{active:I,over:V}=y;if(V&&I.id!==V.id&&d){const wn=d.findIndex(ye=>ye.id===I.id),bn=d.findIndex(ye=>ye.id===V.id),Qe=ue.arrayMove(d,wn,bn);x(Qe),l(Qe)}E(void 0)};return M||((d==null?void 0:d.length)??0)>0?a.jsx(r.LegacyTooltip,{withArrow:!0,position:r.TooltipPosition.Top,content:"Attachments",disabled:be,enterDelay:500,triggerElement:a.jsx("div",{"data-test-id":"attachments-flyout-button",children:a.jsx(r.Flyout,{placement:r.FlyoutPlacement.BottomRight,onOpenChange:y=>ne(Q?!0:y),isOpen:be,hug:!1,fitContent:!0,legacyFooter:!1,trigger:(y,I)=>a.jsx(c,{isFlyoutOpen:be,triggerProps:y,triggerRef:I,children:a.jsx("div",{children:e.length>0?e.length:"Add"})}),children:a.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[d.length>0&&a.jsxs(T.DndContext,{sensors:v,collisionDetection:T.closestCenter,onDragStart:xn,onDragEnd:pn,modifiers:[Cn.restrictToWindowEdges],children:[a.jsx(ue.SortableContext,{items:d,strategy:ue.rectSortingStrategy,children:a.jsx("div",{className:"tw-border-b tw-border-b-line",children:d.map(y=>a.jsx(zn,{isEditing:M,isLoading:F.includes(y.id),item:y,onDelete:()=>t(y),onReplaceWithBrowse:()=>Ke(y),onReplaceWithUpload:I=>Xe(y,I),onDownload:()=>u.dispatch({name:"downloadAsset",payload:y})},y.id))})}),a.jsx(T.DragOverlay,{children:Q&&a.jsx(Be,{isOverlay:!0,isEditing:M,item:Q,isDragging:!0,onDelete:()=>t(Q),onReplaceWithBrowse:()=>Ke(Q),onReplaceWithUpload:y=>Xe(Q,y)},k)})]}),M&&a.jsxs("div",{className:"tw-px-5 tw-py-3",children:[a.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),a.jsx(r.AssetInput,{isLoading:A,size:r.AssetInputSize.Small,onUploadClick:y=>L(y),onLibraryClick:fn})]})]})})})}):null},Wn=(e,t)=>{const n=[r.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"),O(n)},oe=m.forwardRef(({onClick:e,children:t,forceActiveStyle:n,cursor:s="pointer","data-test-id":i="base-toolbar-button",...o},l)=>a.jsx("button",{onClick:e,className:Wn(s,n),"data-test-id":i,...o,ref:l,children:t}));oe.displayName="BaseToolbarButton";const qn=({children:e,isFlyoutOpen:t,triggerProps:n,triggerRef:s})=>a.jsxs(oe,{forceActiveStyle:t,"data-test-id":"attachments-toolbar-button-trigger",...n,ref:s,children:[a.jsx(r.IconPaperclip16,{}),e,a.jsx(r.IconCaretDown12,{})]}),xt="attachments",pt=({flyoutId:e=xt})=>{const t=r.useMemoizedId(e),{appBridge:n,attachments:s,onAttachmentsAdd:i,onAttachmentDelete:o,onAttachmentReplace:l,onAttachmentsSorted:u}=mt(),{isOpen:c,onOpenChange:f}=he(t),h=ie();return a.jsx(ft,{onUpload:i,onDelete:o,onReplaceWithBrowse:l,onReplaceWithUpload:l,onSorted:u,onBrowse:i,items:s,appBridge:n,triggerComponent:qn,isOpen:c&&!h,onOpenChange:f})},je=({open:e,content:t,children:n,disabled:s})=>a.jsx(r.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,open:e,disabled:s,position:r.TooltipPosition.Top,content:a.jsx("div",{children:t}),triggerElement:n,"data-test-id":"toolbar-button-tooltip"}),Gn=({tooltip:e,icon:t,onClick:n})=>{const s=ie();return a.jsx(je,{disabled:s,content:e??"",children:a.jsx(oe,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:t})})},wt="Drag or press ↵ to move",bt="Move with ↑↓←→ and confirm with ↵",yt=({tooltip:e,icon:t,setActivatorNodeRef:n,draggableProps:s})=>{const i=ie();return a.jsx(je,{open:i,content:a.jsx("div",{children:i?bt:e??wt}),children:a.jsx(oe,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:i,cursor:"grab",...s,children:t})})},Ne=({content:e,icon:t,tooltip:n,flyoutId:s,flyoutFooter:i,flyoutHeader:o})=>{const l=r.useMemoizedId(s),{isOpen:u,onOpenChange:c}=he(l),f=ie();return a.jsx(je,{disabled:f||u,content:n,children:a.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:a.jsx(r.Flyout,{isOpen:u&&!f,legacyFooter:!1,fixedFooter:i,fixedHeader:o,fitContent:!0,hug:!1,placement:r.FlyoutPlacement.BottomRight,onOpenChange:c,trigger:(h,d)=>a.jsx(oe,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:u&&!f,...h,ref:d,children:t}),children:e})})})},vt=({items:e,flyoutId:t})=>{const{onOpenChange:n}=he(t);return a.jsx(r.ActionMenu,{menuBlocks:e.map((s,i)=>({id:i.toString(),menuItems:s.map((o,l)=>({id:i.toString()+l.toString(),size:r.MenuItemContentSize.XSmall,title:o.title,style:o.style,onClick:()=>{n(!1),o.onClick()},initialValue:!0,decorator:a.jsx("div",{className:"tw-mr-2",children:o.icon})}))}))})},Le="menu",Ct=({items:e,flyoutId:t=Le,tooltip:n="Options"})=>{const s=r.useMemoizedId(t);return a.jsx(Ne,{icon:a.jsx(r.IconDotsHorizontal16,{}),tooltip:n,flyoutId:s,content:a.jsx(vt,{items:e,flyoutId:s})})},St=({items:e,attachments:t})=>a.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[t.isEnabled&&a.jsx(Je,{children:a.jsx(pt,{})}),a.jsx(Je,{children:e.map(n=>n.type==="dragHandle"?a.jsx(yt,{...n},n.tooltip+n.type):n.type==="menu"?a.jsx(Ct,{...n},n.tooltip+n.type):n.type==="flyout"?a.jsx(Ne,{...n},n.tooltip+n.type):a.jsx(Gn,{...n},n.tooltip+n.type))})]}),Kn=({children:e,toolbarItems:t,shouldHideWrapper:n,shouldHideComponent:s=!1,isDragging:i=!1,shouldFillContainer:o,outlineOffset:l=2,shouldBeShown:u=!1,showAttachments:c=!1})=>{const[f,h]=m.useState(u?[Le]:[]),d=m.useRef(null);if(n)return a.jsx(a.Fragment,{children:e});const x=t==null?void 0:t.filter(w=>w!==void 0),p=f.length>0||u;return a.jsx(it,{isDragPreview:i,children:a.jsx(lt,{openFlyoutIds:f,setOpenFlyoutIds:h,children:a.jsxs("div",{ref:d,"data-test-id":"block-item-wrapper",style:{outlineOffset:l},className:O(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",o&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",p&&"tw-outline",s&&"tw-opacity-0"]),children:[a.jsx("div",{style:{right:-1-l,bottom:`calc(100% - ${2+l}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",p&&"tw-opacity-100"]),children:a.jsx(St,{attachments:{isEnabled:c},items:x})}),e]})})})},Xn=({onDownload:e})=>{const{isFocused:t,focusProps:n}=tt.useFocusRing();return a.jsx(r.LegacyTooltip,{withArrow:!0,position:r.TooltipPosition.Top,content:"Download",enterDelay:500,triggerElement:a.jsx("button",{tabIndex:0,"aria-label":"Download",...n,className:O(["tw-outline-none tw-rounded",t&&r.FOCUS_STYLE]),onClick:e,onPointerDown:s=>s.preventDefault(),children:a.jsx("span",{"data-test-id":"download-button",className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:a.jsx(r.IconArrowCircleDown16,{})})})})},Qn=({value:e="",gap:t,columns:n,show:s=!0,plugins:i})=>{const[o,l]=m.useState(null);return m.useEffect(()=>{(async()=>l(await r.serializeRawToHtmlAsync(e,i,n,t)))()},[e,n,t,i]),!s||o==="<br />"?null:o!==null?a.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:o}}):a.jsx("div",{className:"tw-rounded-sm tw-bg-base-alt tw-animate-pulse tw-h-full tw-min-h-[10px] tw-w-full"})},Ae=r.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})),P=Ae.set,N=Ae.get,ae=()=>Ae.use,kt=e=>{if(!e)return!1;const t=n=>n.some(s=>s.text?s.text!=="":s.children?t(s.children):!1);try{const n=JSON.parse(e);return t(n)}catch{return!1}},Yn=(e="p",t="",n)=>kt(t)?t:JSON.stringify([{type:e,children:[{text:t,textStyle:e}],align:n}]),Jn=(e,t,n)=>e===K.Custom?t:n,Zn=e=>e.map(Tt),Tt=e=>({id:e.id,title:e.name,colors:e.colors.map(tr)}),er=e=>"revision"in e,tr=e=>{if(er(e)){const{title:t,revision:n}=e;return{alpha:n.rgba.alpha?n.rgba.alpha/255:1,red:n.rgba.red??0,green:n.rgba.green??0,blue:n.rgba.blue??0,name:t??""}}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,t)=>{const n=r.getAboveNode(e,{match:{type:r.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},nr=e=>Re(e,t=>{var n,s;return((s=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:s.link)||""}),rr=e=>Re(e,t=>t.url||""),Me=e=>{var t,n;return e.url||((n=(t=e.chosenLink)==null?void 0:t.searchResult)==null?void 0:n.link)||""},sr=e=>Re(e,Me),Fe=/^\/(document|r)\/\S+$/i,fe=e=>{if(Fe.test(e))return e;try{return new URL(e),e}catch{return`https://${e}`}},xe=e=>{if(Fe.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=>xe(fe(e))||e==="",Pt=(e,{type:t})=>{const{apply:n,normalizeNode:s}=e;return e.apply=i=>{if(i.type!=="set_selection"){n(i);return}const o=i.newProperties;if(!(o!=null&&o.focus)||!o.anchor||!r.isCollapsed(o)){n(i);return}const l=r.getAboveNode(e,{at:o,match:{type:r.getPluginType(e,C)}});if(l){const[,u]=l;let c;r.isStartPoint(e,o.focus,u)&&(c=r.getPreviousNodeEndPoint(e,u)),r.isEndPoint(e,o.focus,u)&&(c=r.getNextNodeStartPoint(e,u)),c&&(i.newProperties={anchor:c,focus:c})}n(i)},e.normalizeNode=([i,o])=>{if(i.type===r.getPluginType(e,C)){const l=e.selection;if(l&&r.isCollapsed(l)&&r.isEndPoint(e,l.focus,o)){const u=r.getNextNodeStartPoint(e,o);if(u)r.select(e,u);else{const c=r.Path.next(o);r.insertNodes(e,{text:""},{at:c}),r.select(e,c)}}}s([i,o])},r.withRemoveEmptyNodes(e,r.mockPlugin({options:{types:t}}))},It=(e,t,n)=>{r.insertNodes(e,[Nt(e,t)],n)},De=e=>{if(!e.selection)return;const{isUrl:t,forceSubmit:n}=r.getPluginOptions(e,C),s=N.url();if(!((t==null?void 0:t(s))||n))return;const o=N.text(),l=N.buttonStyle(),u=N.newTab()?void 0:"_self";return P.reset(),Et(e,{url:s,text:o,buttonStyle:l,target:u,isUrl:c=>n||!t?!0:t(c)}),setTimeout(()=>{r.focusEditor(e,e.selection??void 0)},0),!0},te=(e,t)=>r.withoutNormalizing(e,()=>{var n,s,i,o,l,u;if(t!=null&&t.split){if(r.getAboveNode(e,{at:(n=e.selection)==null?void 0:n.anchor,match:{type:r.getPluginType(e,C)}}))return r.splitNodes(e,{at:(s=e.selection)==null?void 0:s.anchor,match:h=>r.isElement(h)&&h.type===r.getPluginType(e,C)}),te(e,{at:(i=e.selection)==null?void 0:i.anchor}),!0;if(r.getAboveNode(e,{at:(o=e.selection)==null?void 0:o.focus,match:{type:r.getPluginType(e,C)}}))return r.splitNodes(e,{at:(l=e.selection)==null?void 0:l.focus,match:h=>r.isElement(h)&&h.type===r.getPluginType(e,C)}),te(e,{at:(u=e.selection)==null?void 0:u.focus}),!0}r.unwrapNodes(e,{match:{type:r.getPluginType(e,C)},...t})}),Et=(e,{url:t,text:n,buttonStyle:s,target:i,insertTextInButton:o,insertNodesOptions:l,isUrl:u=r.getPluginOptions(e,C).isUrl})=>{var E;const c=e.selection;if(!c)return;const f=r.getAboveNode(e,{at:c,match:{type:r.getPluginType(e,C)}});if(o&&f)return e.insertText(t),!0;if(!(u!=null&&u(t)))return;if(r.isDefined(n)&&n.length===0&&(n=t),f)return or(t,e,f,i,s,n),!0;const h=r.findNode(e,{at:c,match:{type:r.getPluginType(e,C)}}),[d,x]=h??[],p=ar(e,x,n);if(r.isExpanded(c))return ir(f,e,t,s,i,n),!0;p&&r.removeNodes(e,{at:x});const w=r.getNodeProps(d??{}),v=(E=e.selection)==null?void 0:E.focus.path;if(!v)return;const k=r.getNodeLeaf(e,v);return n!=null&&n.length||(n=t),It(e,{...w,url:t,target:i,children:[{...k,text:n}]},l),!0};function ar(e,t,n){return t&&(n==null?void 0:n.length)&&n!==r.getEditorString(e,t)}function ir(e,t,n,s,i,o){e?te(t,{at:e[1]}):te(t,{split:!0}),Bt(t,{url:n,buttonStyle:s,target:i}),Oe(t,{url:n,target:i,text:o})}function or(e,t,n,s,i,o){var l,u,c;(e!==((l=n[0])==null?void 0:l.url)||s!==((u=n[0])==null?void 0:u.target)||i!==((c=n[0])==null?void 0:c.buttonStyle))&&r.setNodes(t,{url:e,target:s,buttonStyle:i},{at:n[1]}),Oe(t,{url:e,text:o,target:s})}const Oe=(e,{text:t})=>{const n=r.getAboveNode(e,{match:{type:r.getPluginType(e,C)}});if(n){const[s,i]=n;if(t!=null&&t.length&&t!==r.getEditorString(e,i)){const o=s.children[0];r.replaceNodeChildren(e,{at:i,nodes:{...o,text:t},insertOptions:{select:!0}})}}},Bt=(e,{url:t,buttonStyle:n,target:s,...i})=>{r.wrapNodes(e,{type:r.getPluginType(e,C),url:t,buttonStyle:n,target:s,children:[]},{split:!0,...i})},lr=(e,t)=>{const n=r.getAboveNode(e,{match:{type:C}});return Array.isArray(n)?t(n[0]):""},jt=e=>lr(e,t=>t.url??""),Nt=(e,{url:t,text:n="",buttonStyle:s="primary",target:i,children:o})=>({type:r.getPluginType(e,C),url:t,target:i,buttonStyle:s,children:o??[{text:n}]}),Lt=(e,{focused:t}={})=>{if(N.mode()==="edit"){pe(e);return}Ue(e,{focused:t})},pe=e=>{const t=r.findNode(e,{match:{type:r.getPluginType(e,C)}});if(!t)return;const[n,s]=t;let i=r.getEditorString(e,s);P.url(n.url),P.newTab(n.target===void 0),i===n.url&&(i=""),P.text(i),P.isEditing(!0)},Ue=(e,{focused:t}={})=>{N.mode()||!t||r.isRangeAcrossBlocks(e,{at:e.selection})||r.someNode(e,{match:{type:r.getPluginType(e,C)}})||(P.text(r.getEditorString(e,e.selection)),P.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)"}}},cr=e=>{var l,u;const{attributes:t,children:n}=e,s=e.element.url||((u=(l=e.element.chosenLink)==null?void 0:l.searchResult)==null?void 0:u.link)||"",i=e.element.target||"_self",o=String(e.element.buttonStyle)||"primary";return a.jsx(ur,{attributes:t,href:s,target:i,styles:we[`button${o.charAt(0).toUpperCase()+o.slice(1)}`],children:n})},ur=({attributes:e,styles:t={hover:{}},children:n,href:s="#",target:i})=>{const[o,l]=m.useState(!1);return a.jsx("a",{...e,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),href:s,target:i,style:o?{...t,...t.hover}:t,children:n})};class dr extends r.MarkupElement{constructor(t=C,n=cr){super(t,n)}}const At=m.forwardRef((e,t)=>{const n=r.useEditorRef();return a.jsx(r.ToolbarButton,{ref:t,...e,onMouseDown:()=>{r.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Lt(n,{focused:!0})},children:a.jsx(r.IconStylingWrapper,{icon:a.jsx(r.IconButton16,{})})})});At.displayName="ButtonToolbarButton";const gr=({editorId:e,id:t})=>{const n=r.useEditorState(r.useEventPlateId(e)),s=!!r.isRangeInSameBlock(n,{at:n.selection}),i=r.getPluginType(n,C),o=!!(n!=null&&n.selection)&&r.someNode(n,{match:{type:i}});return a.jsx("div",{"data-plugin-id":t,children:a.jsx(At,{pressed:o,disabled:!s,tooltip:r.getTooltip(s?`Button
|
|
2
|
-
${r.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},mr=()=>{const e=r.useEditorRef();return a.jsx(r.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:a.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[a.jsx("span",{className:"tw-pointer-events-none",children:N.url()}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{onClick:()=>{pe(e)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(r.IconPen16,{})}),a.jsx("button",{onClick:()=>{te(e),r.focusEditor(e,e.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(r.IconTrashBin16,{})})]})]})})},hr=({section:e,selectedUrl:t,onSelectUrl:n})=>{const s=e.permanentLink===t;return a.jsx("button",{"data-test-id":"internal-link-selector-section-link",className:r.merge(["tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",s?"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:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[a.jsx(r.IconDocumentText16,{}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},fr=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i})=>{const[o,l]=m.useState(e.id===s.documentId),[u,c]=m.useState([]),f=e.permanentLink===t;m.useEffect(()=>{(async()=>{const p=await i(e.id);c(p)})()},[e.id,i]),m.useEffect(()=>{e.id===s.pageId&&l(!0)},[s,e.id]);const h=[...u.values()],d=h.length>0;return a.jsxs(a.Fragment,{children:[a.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:r.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",d?"tw-pl-7":"tw-pl-12",f?"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:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[d&&a.jsx("button",{"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>l(!o),children:a.jsx("div",{className:r.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",o?"tw-rotate-90":""])})}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),o&&h.length>0&&h.map(x=>a.jsx(hr,{section:x,selectedUrl:t,onSelectUrl:n},x.id))]})},Rt=()=>a.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:a.jsx(r.LoadingCircle,{size:r.LoadingCircleSize.Small})}),xr=({documentId:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:o})=>{const[l,u]=m.useState([]),[c,f]=m.useState(!0),h=[...l.values()],d=!c&&h.length>0;return m.useEffect(()=>{o(e).then(x=>{const p=x.filter(v=>!!v.category).sort((v,k)=>v.category.sort===k.category.sort?v.sort-k.sort:v.category.sort-k.category.sort),w=x.filter(v=>!v.category).sort((v,k)=>v.sort-k.sort);u([...p,...w])}).finally(()=>{f(!1)})},[]),c?a.jsx(Rt,{}):d?a.jsx(a.Fragment,{children:h.map(x=>a.jsx(fr,{page:x,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i},x.id))}):a.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},pr=({document:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:o})=>{const[l,u]=m.useState(e.id===s.documentId),c=e.permanentLink===t;return m.useEffect(()=>{e.id===s.documentId&&u(!0)},[s,e.id]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:r.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:[a.jsx("button",{role:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>u(!l),children:a.jsx("div",{className:r.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",l?"tw-rotate-90":""])})}),a.jsx(r.IconColorFan16,{}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),l&&a.jsx(xr,{documentId:e.id,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:o})]})},wr=({selectedUrl:e,onSelectUrl:t,getAllDocuments:n,getDocumentPagesByDocumentId:s,getDocumentSectionsByDocumentPageId:i})=>{const[o,l]=m.useState(!0),[u,c]=m.useState([]),[f,h]=m.useState({documentId:void 0,pageId:void 0}),d=[...u.values()];m.useEffect(()=>{e&&d.length>0&&x().then(p=>{h(p)})},[d.length]),m.useEffect(()=>{n().then(p=>{c(p)}).finally(()=>{l(!1)})},[]);const x=async()=>{const p={documentId:void 0,pageId:void 0};if(d.find(v=>v.permanentLink===e))return p;for(const v of d){const E=[...(await s(v.id)).values()];if(!!E.find(R=>R.permanentLink===e))return p.documentId=v.id,p;for(const R of E)if(!![...(await i(R.id)).values()].find(L=>L.permanentLink===e))return p.documentId=v.id,p.pageId=R.id,p}return p};return o?a.jsx(Rt,{}):a.jsx(a.Fragment,{children:d.map(p=>a.jsx(pr,{document:p,selectedUrl:e,onSelectUrl:t,itemsToExpandInitially:f,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:s},p.id))})},Mt=({url:e,onUrlChange:t,buttonSize:n=r.ButtonSize.Medium,getAllDocuments:s,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:o})=>{const{open:l,isOpen:u,close:c}=Sn.useOverlayTriggerState({}),[f,h]=m.useState(e),d=w=>{h(w)},x=w=>{w.key==="Enter"&&p()};m.useEffect(()=>{e&&!f&&h(e)},[e,f]);const p=()=>{t==null||t(f),c()};return a.jsxs("div",{onPointerDown:w=>w.preventDefault(),"data-test-id":"internal-link-selector",onKeyDown:x,children:[a.jsx(r.Button,{icon:a.jsx(r.IconLink,{}),size:n,type:r.ButtonType.Button,style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Default,onClick:()=>l(),children:"Internal link"}),a.jsxs(r.Modal,{zIndex:1001,onClose:()=>c(),isOpen:u,isDismissable:!0,children:[a.jsx(r.Modal.Header,{title:"Select internal link"}),a.jsx(r.Modal.Body,{children:a.jsx(wr,{selectedUrl:f,onSelectUrl:d,getAllDocuments:s,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:o})}),a.jsx(r.Modal.Footer,{buttons:[{children:"Cancel",onClick:()=>c(),style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Default},{children:"Choose",onClick:w=>{w==null||w.preventDefault(),p()},style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Strong,disabled:!f}]})]})]})},Ft=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:s,clearable:i,placeholder:o,newTab:l,openInNewTab:u,url:c="",required:f,info:h,label:d,buttonSize:x,hideInternalLinkButton:p})=>{const w=n?n(c):ee(c),v=l??(u?r.CheckboxState.Checked:r.CheckboxState.Unchecked);return a.jsxs("div",{"data-test-id":"link-input",children:[a.jsx(r.FormControl,{label:{children:d,htmlFor:"url",required:f,tooltip:h?{content:h,position:r.TooltipPosition.Top}:void 0},children:a.jsx(r.TextInput,{id:"url",value:c,clearable:i,onChange:e,placeholder:o??"https://example.com",focusOnMount:!0})}),!w&&a.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!p&&a.jsx("div",{className:"tw-mt-3",children:a.jsx(Mt,{url:c,onUrlChange:e,buttonSize:x??r.ButtonSize.Medium,getAllDocuments:()=>s.getAllDocuments(),getDocumentPagesByDocumentId:k=>s.getDocumentPagesByDocumentId(k),getDocumentSectionsByDocumentPageId:k=>s.getDocumentSectionsByDocumentPageId(k)})}),a.jsx("div",{className:"tw-mt-3",children:a.jsx(r.Checkbox,{value:"new-tab",label:"Open in new tab",state:v,onChange:t})})]})},Dt=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:s,onCancel:i,onSave:o,isValidUrlOrEmpty:l,hasValues:u,testId:c,appBridge:f,children:h})=>a.jsxs(r.FloatingModalWrapper,{"data-test-id":c,padding:"28px",minWidth:"400px",children:[a.jsx(r.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:a.jsx(r.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:t})}),h,a.jsx("div",{className:"tw-mt-5",children:a.jsx(Ft,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:s,isValidUrlOrEmpty:l,appBridge:f})}),a.jsx("div",{className:"tw-mt-3",children:a.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[a.jsx(r.Button,{onClick:i,size:r.ButtonSize.Medium,style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Default,children:"Cancel"}),a.jsx(r.Button,{onClick:o,size:r.ButtonSize.Medium,icon:a.jsx(r.IconCheckMark20,{}),disabled:!l(e==null?void 0:e.url)||!u,children:"Save"})]})})]}),br=e=>{var n;const t=r.getAboveNode(e,{match:{type:C}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},yr={url:"",text:"",buttonStyle:"primary",newTab:r.CheckboxState.Unchecked},vr=()=>{const[e,t]=m.useReducer((n,s)=>{const{type:i,payload:o}=s;switch(i){case"NEW_TAB":return{...n,newTab:r.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:r.CheckboxState.Unchecked};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...o};default:return n}},yr);return[e,t]},Cr=()=>{const e=r.useEditorRef(),[t,n]=vr();m.useEffect(()=>{const d=br(e);n({type:"INIT",payload:{text:N.text(),buttonStyle:d,newTab:N.newTab()?r.CheckboxState.Checked:r.CheckboxState.Unchecked,url:N.url()}})},[n,e]);const s=d=>{n({type:"TEXT",payload:{text:d}})},i=d=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:d}})},o=d=>{n({type:"URL",payload:{url:d}})},l=d=>{n(d?{type:"NEW_TAB"}:{type:"SAME_TAB"})},u=()=>{P.reset()},c=d=>{if(!ee(t.url)||!f)return;const x=fe(t.url);P.text(t.text),P.url(x),P.buttonStyle(t.buttonStyle),P.newTab(t.newTab===r.CheckboxState.Checked),De(e)&&(d==null||d.preventDefault())},f=t.url!==""&&t.text!=="",{appBridge:h}=r.getPluginOptions(e,C);return r.useHotkeys("enter",c,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:s,onButtonStyleChange:i,onUrlChange:o,onToggleTab:l,onCancel:u,onSave:c,hasValues:f,isValidUrlOrEmpty:ee,appBridge:h}},de="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)"},[de]:{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},Sr=()=>{const e=Cr(),{state:t,onButtonStyleChange:n}=e;return a.jsx(Dt,{...e,testId:"floating-button-insert",children:a.jsx("div",{className:"tw-pt-5",children:a.jsxs(r.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[a.jsx(ve,{id:"primary",styles:j.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),a.jsx(ve,{id:"secondary",styles:j.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),a.jsx(ve,{id:"tertiary",styles:j.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},ve=({id:e,styles:t,isActive:n,onClick:s,children:i})=>{const[o,l]=m.useState(!1),u=()=>t&&t.hover&&o?{...t,...t.hover}:t;return a.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:s,style:{...u(),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:i})},Ze={placement:"bottom-start",strategy:"absolute",middleware:[r.offset(12),r.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},kr=()=>{const{ref:e,...t}=Ir(Ze),{ref:n,...s}=Tr(Ze),i=r.useEditorRef(),o=ae(),l=o.isOpen(i.id),u=o.isEditing(),c=o.mode(),f=a.jsx(Sr,{}),h=u?f:a.jsx(mr,{});return a.jsxs(a.Fragment,{children:[l&&c==="insert"&&a.jsx("div",{ref:e,...t,children:f}),l&&c==="edit"&&a.jsx("div",{ref:n,...s,children:h})]})},C="button",Ot="button-plugin",Ut=e=>r.createPluginFactory({key:C,isElement:!0,isInline:!0,props:({element:t})=>({nodeProps:{href:t==null?void 0:t.url,target:t==null?void 0:t.target}}),withOverrides:Pt,renderAfterEditable:kr,options:{isUrl:xe,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:s=>({type:n,url:s.getAttribute("href"),target:s.getAttribute("target")||"_blank"})}})})();class _t extends r.Plugin{constructor({styles:n=we,...s}){super(Ot,{button:gr,markupElement:new dr,...s});B(this,"styles",{});B(this,"appBridge");this.styles=n,this.appBridge=s==null?void 0:s.appBridge}plugins(){return[Ut(this.appBridge)]}}const Tr=e=>{const t=r.useEditorRef(),n=ae().mode(),s=ae().isOpen(t.id),i=r.useEditorVersion(),{triggerFloatingButtonHotkeys:o}=r.getPluginOptions(t,C),l=m.useCallback(()=>{const d=r.getAboveNode(t,{match:{type:r.getPluginType(t,C)}});if(d){const[,x]=d;return r.getRangeBoundingClientRect(t,{anchor:r.getStartPoint(t,x),focus:r.getEndPoint(t,x)})}return r.getDefaultBoundingClientRect()},[t]),u=s&&n==="edit",{update:c,style:f,floating:h}=Vt({open:u,getBoundingClientRect:l,...e});return m.useEffect(()=>{const d=jt(t);if(d&&P.url(d),t.selection&&r.someNode(t,{match:{type:r.getPluginType(t,C)}})){P.show("edit",t.id),c();return}N.mode()==="edit"&&P.reset()},[t,i,c]),r.useHotkeys(o,d=>{d.preventDefault(),N.mode()==="edit"&&pe(t)},{enableOnContentEditable:!0},[]),Pr(),Ht(),{style:{...f,zIndex:1e3},ref:r.useComposedRef(h)}},Pr=()=>{const e=r.useEditorRef();r.useHotkeys("*",t=>{t.key==="Enter"&&De(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Ht=()=>{const e=r.useEditorRef();r.useHotkeys("escape",()=>{if(N.mode()==="edit"){if(N.isEditing()){P.show("edit",e.id),r.focusEditor(e,e.selection??void 0);return}P.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Ir=e=>{const t=r.useEditorRef(),n=r.useFocused(),s=ae().mode(),i=ae().isOpen(t.id),{triggerFloatingButtonHotkeys:o}=r.getPluginOptions(t,C);r.useHotkeys(o,f=>{f.preventDefault(),Ue(t,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:l,style:u,floating:c}=Vt({open:i&&s==="insert",getBoundingClientRect:r.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return m.useEffect(()=>{i&&l(),P.updated(i)},[i,l]),Ht(),{style:{...u,zIndex:1e3},ref:r.useComposedRef(c)}},Er=12,Br=-22,jr=96,Vt=e=>r.useVirtualFloating({placement:"bottom-start",middleware:[r.offset({mainAxis:Er,alignmentAxis:Br}),r.flip({padding:jr})],...e}),Nr=({ref:e,disabled:t,onChange:n})=>{m.useEffect(()=>{if(t||!e.current)return;let s=!1;const i=new IntersectionObserver(([o])=>{o.isIntersecting!==s&&(s=o.isIntersecting,n(o.isIntersecting))});return i.observe(e.current),()=>{i.disconnect()}},[e,t,n])},zt=m.memo(({id:e="rte",isEnabled:t,value:n,columns:s,gap:i,placeholder:o,plugins:l,onTextChange:u,showSerializedText:c})=>{const[f,h]=m.useState(!1),d=m.useCallback(w=>{w!==n&&(u==null||u(w),h(!1))},[u,n]),x=m.useCallback(()=>h(!0),[]),p=m.useCallback(w=>{N.isOpen(w)&&P.reset()},[]);return m.useEffect(()=>{const w=v=>{v.preventDefault(),v.returnValue="Unprocessed changes"};return f&&window.addEventListener("beforeunload",w),()=>window.removeEventListener("beforeunload",w)},[f]),t?a.jsx(r.RichTextEditor,{id:e,value:n,border:!1,placeholder:o,plugins:l,onValueChanged:x,onTextChange:d,hideExternalFloatingModals:p}):a.jsx(Qn,{value:n,columns:s,gap:i,show:c,plugins:l})});zt.displayName="InternalRichTextEditor";const Lr=e=>{const t=m.useRef(null),[n,s]=m.useState(!1),{isEditing:i,...o}=e,l=m.useCallback(u=>{u&&s(!0)},[]);return Nr({ref:t,disabled:!i,onChange:l}),m.useEffect(()=>{s(!1)},[]),a.jsx("div",{className:"tw-block tw-w-full",ref:t,children:a.jsx(zt,{...o,isEnabled:i&&n})})},Ar=({editButtonProps:e,unlinkButtonProps:t})=>{const{element:n}=r.useLinkOpenButtonState(),s=n?Me(n):"";return a.jsx(r.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:a.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[a.jsx("span",{className:"tw-pointer-events-none",children:s}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...e,children:a.jsx(r.IconPen16,{})}),a.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...t,children:a.jsx(r.IconTrashBin16,{})})]})]})})},$t=(e,t)=>{const n=r.getAboveNode(e,{match:{type:r.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},Rr=e=>$t(e,t=>{var n,s;return((s=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:s.link)||""}),Mr=e=>$t(e,t=>t.url||""),Fr={url:"",text:"",newTab:r.CheckboxState.Unchecked},Dr=()=>{const[e,t]=m.useReducer((n,s)=>{const{type:i,payload:o}=s;switch(i){case"NEW_TAB":return{...n,newTab:r.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:r.CheckboxState.Unchecked};case"URL":case"TEXT":case"INIT":return{...n,...o};default:return n}},Fr);return[e,t]},Or=()=>{const e=r.useEditorRef(),[t,n]=Dr();m.useEffect(()=>{const h=Rr(e),d=Mr(e),x=r.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:r.floatingLinkSelectors.text(),newTab:x?r.CheckboxState.Checked:r.CheckboxState.Unchecked,url:h&&d===""?h:r.floatingLinkSelectors.url()}})},[n,e]);const s=h=>{n({type:"TEXT",payload:{text:h}})},i=h=>{n({type:"URL",payload:{url:h}})},o=h=>{n(h?{type:"NEW_TAB"}:{type:"SAME_TAB"})},l=()=>{r.floatingLinkActions.reset()},u=h=>{!ee(t.url)||!c||(r.floatingLinkActions.text(t.text),r.floatingLinkActions.url(fe(t.url)),r.floatingLinkActions.newTab(t.newTab===r.CheckboxState.Checked),r.submitFloatingLink(e)&&(h==null||h.preventDefault()))},c=t.url!==""&&t.text!=="",{appBridge:f}=r.getPluginOptions(e,r.ELEMENT_LINK);return r.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:s,onUrlChange:i,onToggleTab:o,onCancel:l,onSave:u,hasValues:c,isValidUrlOrEmpty:ee,appBridge:f}},Ur=()=>a.jsx(Dt,{...Or(),testId:"floating-link-insert"}),et={placement:"bottom-start",strategy:"absolute",middleware:[r.offset(12),r.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},_r=()=>{const e=r.useFloatingLinkInsertState({floatingOptions:et}),{props:t,ref:n,hidden:s}=r.useFloatingLinkInsert(e),i=r.useFloatingLinkEditState({floatingOptions:et}),{props:o,ref:l,editButtonProps:u,unlinkButtonProps:c}=r.useFloatingLinkEdit(i);if(s)return null;const f=a.jsx(Ur,{}),h=i.isEditing?f:a.jsx(Ar,{editButtonProps:u,unlinkButtonProps:c});return a.jsxs(a.Fragment,{children:[e.isOpen&&!i.isOpen&&a.jsx("div",{ref:n,...t,style:{...t.style,zIndex:1e3},children:f}),i.isOpen&&a.jsx("div",{ref:l,...o,style:{...o.style,zIndex:1e3},children:h})]})},Wt=m.forwardRef((e,t)=>{const n=r.useEditorRef(),s=r.useLinkToolbarButtonState(),{props:i}=r.useLinkToolbarButton(s);return a.jsx(r.ToolbarButton,{onMouseDown:()=>{r.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:t,...i,...e,children:a.jsx(r.IconStylingWrapper,{icon:a.jsx(r.IconLink16,{})})})});Wt.displayName="LinkToolbarButton";const Hr=({id:e,editorId:t})=>{const n=r.useEditorState(r.useEventPlateId(t)),s=!!r.isRangeInSameBlock(n,{at:n.selection});return a.jsx("div",{"data-plugin-id":e,children:a.jsx(Wt,{disabled:!s,tooltip:r.getTooltip(s?`Link
|
|
2
|
+
${r.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},mr=()=>{const e=r.useEditorRef();return a.jsx(r.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:a.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[a.jsx("span",{className:"tw-pointer-events-none",children:N.url()}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{onClick:()=>{pe(e)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(r.IconPen16,{})}),a.jsx("button",{onClick:()=>{te(e),r.focusEditor(e,e.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(r.IconTrashBin16,{})})]})]})})},hr=({section:e,selectedUrl:t,onSelectUrl:n})=>{const s=e.permanentLink===t;return a.jsx("button",{"data-test-id":"internal-link-selector-section-link",className:r.merge(["tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",s?"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:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[a.jsx(r.IconDocumentText16,{}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},fr=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i})=>{const[o,l]=m.useState(e.id===s.documentId),[u,c]=m.useState([]),f=e.permanentLink===t;m.useEffect(()=>{(async()=>{const p=await i(e.id);c(p)})()},[e.id,i]),m.useEffect(()=>{e.id===s.pageId&&l(!0)},[s,e.id]);const h=[...u.values()],d=h.length>0;return a.jsxs(a.Fragment,{children:[a.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:r.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",d?"tw-pl-7":"tw-pl-12",f?"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:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[d&&a.jsx("button",{"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>l(!o),children:a.jsx("div",{className:r.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",o?"tw-rotate-90":""])})}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),o&&h.length>0&&h.map(x=>a.jsx(hr,{section:x,selectedUrl:t,onSelectUrl:n},x.id))]})},Rt=()=>a.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:a.jsx(r.LoadingCircle,{size:r.LoadingCircleSize.Small})}),xr=({documentId:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:o})=>{const[l,u]=m.useState([]),[c,f]=m.useState(!0),h=[...l.values()],d=!c&&h.length>0;return m.useEffect(()=>{o(e).then(x=>{const p=x.filter(v=>!!v.category).sort((v,k)=>v.category.sort===k.category.sort?v.sort-k.sort:v.category.sort-k.category.sort),w=x.filter(v=>!v.category).sort((v,k)=>v.sort-k.sort);u([...p,...w])}).finally(()=>{f(!1)})},[]),c?a.jsx(Rt,{}):d?a.jsx(a.Fragment,{children:h.map(x=>a.jsx(fr,{page:x,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i},x.id))}):a.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},pr=({document:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:o})=>{const[l,u]=m.useState(e.id===s.documentId),c=e.permanentLink===t;return m.useEffect(()=>{e.id===s.documentId&&u(!0)},[s,e.id]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:r.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:[a.jsx("button",{role:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>u(!l),children:a.jsx("div",{className:r.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",l?"tw-rotate-90":""])})}),a.jsx(r.IconColorFan16,{}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),l&&a.jsx(xr,{documentId:e.id,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:s,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:o})]})},wr=({selectedUrl:e,onSelectUrl:t,getAllDocuments:n,getDocumentPagesByDocumentId:s,getDocumentSectionsByDocumentPageId:i})=>{const[o,l]=m.useState(!0),[u,c]=m.useState([]),[f,h]=m.useState({documentId:void 0,pageId:void 0}),d=[...u.values()];m.useEffect(()=>{e&&d.length>0&&x().then(p=>{h(p)})},[d.length]),m.useEffect(()=>{n().then(p=>{c(p)}).finally(()=>{l(!1)})},[]);const x=async()=>{const p={documentId:void 0,pageId:void 0};if(d.find(v=>v.permanentLink===e))return p;for(const v of d){const E=[...(await s(v.id)).values()];if(!!E.find(R=>R.permanentLink===e))return p.documentId=v.id,p;for(const R of E)if(!![...(await i(R.id)).values()].find(L=>L.permanentLink===e))return p.documentId=v.id,p.pageId=R.id,p}return p};return o?a.jsx(Rt,{}):a.jsx(a.Fragment,{children:d.map(p=>a.jsx(pr,{document:p,selectedUrl:e,onSelectUrl:t,itemsToExpandInitially:f,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:s},p.id))})},Mt=({url:e,onUrlChange:t,buttonSize:n=r.ButtonSize.Medium,getAllDocuments:s,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:o})=>{const{open:l,isOpen:u,close:c}=Sn.useOverlayTriggerState({}),[f,h]=m.useState(e),d=w=>{h(w)},x=w=>{w.key==="Enter"&&p()};m.useEffect(()=>{e&&!f&&h(e)},[e,f]);const p=()=>{t==null||t(f),c()};return a.jsxs("div",{onPointerDown:w=>w.preventDefault(),"data-test-id":"internal-link-selector",onKeyDown:x,children:[a.jsx(r.Button,{icon:a.jsx(r.IconLink,{}),size:n,type:r.ButtonType.Button,style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Default,onClick:()=>l(),children:"Internal link"}),a.jsxs(r.Modal,{zIndex:1001,onClose:()=>c(),isOpen:u,isDismissable:!0,children:[a.jsx(r.Modal.Header,{title:"Select internal link"}),a.jsx(r.Modal.Body,{children:a.jsx(wr,{selectedUrl:f,onSelectUrl:d,getAllDocuments:s,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:o})}),a.jsx(r.Modal.Footer,{buttons:[{children:"Cancel",onClick:()=>c(),style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Default},{children:"Choose",onClick:w=>{w==null||w.preventDefault(),p()},style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Strong,disabled:!f}]})]})]})},Ft=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:s,clearable:i,placeholder:o,newTab:l,openInNewTab:u,url:c="",required:f,info:h,label:d,buttonSize:x,hideInternalLinkButton:p})=>{const w=n?n(c):ee(c),v=l??(u?r.CheckboxState.Checked:r.CheckboxState.Unchecked);return a.jsxs("div",{"data-test-id":"link-input",children:[a.jsx(r.FormControl,{label:{children:d,htmlFor:"url",required:f,tooltip:h?{content:h,position:r.TooltipPosition.Top}:void 0},children:a.jsx(r.TextInput,{id:"url",value:c,clearable:i,onChange:e,placeholder:o??"https://example.com",focusOnMount:!0})}),!w&&a.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!p&&a.jsx("div",{className:"tw-mt-3",children:a.jsx(Mt,{url:c,onUrlChange:e,buttonSize:x??r.ButtonSize.Medium,getAllDocuments:()=>s.getAllDocuments(),getDocumentPagesByDocumentId:k=>s.getDocumentPagesByDocumentId(k),getDocumentSectionsByDocumentPageId:k=>s.getDocumentSectionsByDocumentPageId(k)})}),a.jsx("div",{className:"tw-mt-3",children:a.jsx(r.Checkbox,{value:"new-tab",label:"Open in new tab",state:v,onChange:t})})]})},Dt=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:s,onCancel:i,onSave:o,isValidUrlOrEmpty:l,hasValues:u,testId:c,appBridge:f,children:h})=>a.jsxs(r.FloatingModalWrapper,{"data-test-id":c,padding:"28px",minWidth:"400px",children:[a.jsx(r.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:a.jsx(r.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:t})}),h,a.jsx("div",{className:"tw-mt-5",children:a.jsx(Ft,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:s,isValidUrlOrEmpty:l,appBridge:f})}),a.jsx("div",{className:"tw-mt-3",children:a.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[a.jsx(r.Button,{onClick:i,size:r.ButtonSize.Medium,style:r.ButtonStyle.Default,emphasis:r.ButtonEmphasis.Default,children:"Cancel"}),a.jsx(r.Button,{onClick:o,size:r.ButtonSize.Medium,icon:a.jsx(r.IconCheckMark20,{}),disabled:!l(e==null?void 0:e.url)||!u,children:"Save"})]})})]}),br=e=>{var n;const t=r.getAboveNode(e,{match:{type:C}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},yr={url:"",text:"",buttonStyle:"primary",newTab:r.CheckboxState.Unchecked},vr=()=>{const[e,t]=m.useReducer((n,s)=>{const{type:i,payload:o}=s;switch(i){case"NEW_TAB":return{...n,newTab:r.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:r.CheckboxState.Unchecked};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...o};default:return n}},yr);return[e,t]},Cr=()=>{const e=r.useEditorRef(),[t,n]=vr();m.useEffect(()=>{const d=br(e);n({type:"INIT",payload:{text:N.text(),buttonStyle:d,newTab:N.newTab()?r.CheckboxState.Checked:r.CheckboxState.Unchecked,url:N.url()}})},[n,e]);const s=d=>{n({type:"TEXT",payload:{text:d}})},i=d=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:d}})},o=d=>{n({type:"URL",payload:{url:d}})},l=d=>{n(d?{type:"NEW_TAB"}:{type:"SAME_TAB"})},u=()=>{P.reset()},c=d=>{if(!ee(t.url)||!f)return;const x=fe(t.url);P.text(t.text),P.url(x),P.buttonStyle(t.buttonStyle),P.newTab(t.newTab===r.CheckboxState.Checked),De(e)&&(d==null||d.preventDefault())},f=t.url!==""&&t.text!=="",{appBridge:h}=r.getPluginOptions(e,C);return r.useHotkeys("enter",c,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:s,onButtonStyleChange:i,onUrlChange:o,onToggleTab:l,onCancel:u,onSave:c,hasValues:f,isValidUrlOrEmpty:ee,appBridge:h}},de="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)"},[de]:{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},Sr=()=>{const e=Cr(),{state:t,onButtonStyleChange:n}=e;return a.jsx(Dt,{...e,testId:"floating-button-insert",children:a.jsx("div",{className:"tw-pt-5",children:a.jsxs(r.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[a.jsx(ve,{id:"primary",styles:j.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),a.jsx(ve,{id:"secondary",styles:j.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),a.jsx(ve,{id:"tertiary",styles:j.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},ve=({id:e,styles:t,isActive:n,onClick:s,children:i})=>{const[o,l]=m.useState(!1),u=()=>t&&t.hover&&o?{...t,...t.hover}:t;return a.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:s,style:{...u(),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:i})},Ze={placement:"bottom-start",strategy:"absolute",middleware:[r.offset(12),r.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},kr=()=>{const{ref:e,...t}=Ir(Ze),{ref:n,...s}=Tr(Ze),i=r.useEditorRef(),o=ae(),l=o.isOpen(i.id),u=o.isEditing(),c=o.mode(),f=a.jsx(Sr,{}),h=u?f:a.jsx(mr,{});return a.jsxs(a.Fragment,{children:[l&&c==="insert"&&a.jsx("div",{ref:e,...t,children:f}),l&&c==="edit"&&a.jsx("div",{ref:n,...s,children:h})]})},C="button",Ot="button-plugin",Ut=e=>r.createPluginFactory({key:C,isElement:!0,isInline:!0,props:({element:t})=>({nodeProps:{href:t==null?void 0:t.url,target:t==null?void 0:t.target}}),withOverrides:Pt,renderAfterEditable:kr,options:{isUrl:xe,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:s=>({type:n,url:s.getAttribute("href"),target:s.getAttribute("target")||"_blank"})}})})();class _t extends r.Plugin{constructor({styles:n=we,...s}){super(Ot,{button:gr,markupElement:new dr,...s});B(this,"styles",{});B(this,"appBridge");this.styles=n,this.appBridge=s==null?void 0:s.appBridge}plugins(){return[Ut(this.appBridge)]}}const Tr=e=>{const t=r.useEditorRef(),n=ae().mode(),s=ae().isOpen(t.id),i=r.useEditorVersion(),{triggerFloatingButtonHotkeys:o}=r.getPluginOptions(t,C),l=m.useCallback(()=>{const d=r.getAboveNode(t,{match:{type:r.getPluginType(t,C)}});if(d){const[,x]=d;return r.getRangeBoundingClientRect(t,{anchor:r.getStartPoint(t,x),focus:r.getEndPoint(t,x)})}return r.getDefaultBoundingClientRect()},[t]),u=s&&n==="edit",{update:c,style:f,floating:h}=Vt({open:u,getBoundingClientRect:l,...e});return m.useEffect(()=>{const d=jt(t);if(d&&P.url(d),t.selection&&r.someNode(t,{match:{type:r.getPluginType(t,C)}})){P.show("edit",t.id),c();return}N.mode()==="edit"&&P.reset()},[t,i,c]),r.useHotkeys(o,d=>{d.preventDefault(),N.mode()==="edit"&&pe(t)},{enableOnContentEditable:!0},[]),Pr(),Ht(),{style:{...f,zIndex:1e3},ref:r.useComposedRef(h)}},Pr=()=>{const e=r.useEditorRef();r.useHotkeys("*",t=>{t.key==="Enter"&&De(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Ht=()=>{const e=r.useEditorRef();r.useHotkeys("escape",()=>{if(N.mode()==="edit"){if(N.isEditing()){P.show("edit",e.id),r.focusEditor(e,e.selection??void 0);return}P.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Ir=e=>{const t=r.useEditorRef(),n=r.useFocused(),s=ae().mode(),i=ae().isOpen(t.id),{triggerFloatingButtonHotkeys:o}=r.getPluginOptions(t,C);r.useHotkeys(o,f=>{f.preventDefault(),Ue(t,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:l,style:u,floating:c}=Vt({open:i&&s==="insert",getBoundingClientRect:r.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return m.useEffect(()=>{i&&l(),P.updated(i)},[i,l]),Ht(),{style:{...u,zIndex:1e3},ref:r.useComposedRef(c)}},Er=12,Br=-22,jr=96,Vt=e=>r.useVirtualFloating({placement:"bottom-start",middleware:[r.offset({mainAxis:Er,alignmentAxis:Br}),r.flip({padding:jr})],...e}),Nr=({ref:e,disabled:t,onChange:n})=>{m.useEffect(()=>{if(t||!e.current)return;let s=!1;const i=new IntersectionObserver(([o])=>{o.isIntersecting!==s&&(s=o.isIntersecting,n(o.isIntersecting))});return i.observe(e.current),()=>{i.disconnect()}},[e,t,n])},zt=m.memo(({id:e="rte",isEnabled:t,value:n,columns:s,gap:i,placeholder:o,plugins:l,onTextChange:u,showSerializedText:c})=>{const[f,h]=m.useState(!1),d=m.useCallback(w=>{w!==n&&(u==null||u(w)),h(!1)},[u,n]),x=m.useCallback(()=>h(!0),[]),p=m.useCallback(w=>{N.isOpen(w)&&P.reset()},[]);return m.useEffect(()=>{const w=v=>{v.preventDefault(),v.returnValue="Unprocessed changes"};return f&&window.addEventListener("beforeunload",w),()=>window.removeEventListener("beforeunload",w)},[f]),t?a.jsx(r.RichTextEditor,{id:e,value:n,border:!1,placeholder:o,plugins:l,onValueChanged:x,onTextChange:d,hideExternalFloatingModals:p}):a.jsx(Qn,{value:n,columns:s,gap:i,show:c,plugins:l})});zt.displayName="InternalRichTextEditor";const Lr=e=>{const t=m.useRef(null),[n,s]=m.useState(!1),{isEditing:i,...o}=e,l=m.useCallback(u=>{u&&s(!0)},[]);return Nr({ref:t,disabled:!i,onChange:l}),m.useEffect(()=>{i||s(!1)},[i]),a.jsx("div",{className:"tw-block tw-w-full",ref:t,children:a.jsx(zt,{...o,isEnabled:i&&n})})},Ar=({editButtonProps:e,unlinkButtonProps:t})=>{const{element:n}=r.useLinkOpenButtonState(),s=n?Me(n):"";return a.jsx(r.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:a.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[a.jsx("span",{className:"tw-pointer-events-none",children:s}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...e,children:a.jsx(r.IconPen16,{})}),a.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...t,children:a.jsx(r.IconTrashBin16,{})})]})]})})},$t=(e,t)=>{const n=r.getAboveNode(e,{match:{type:r.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},Rr=e=>$t(e,t=>{var n,s;return((s=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:s.link)||""}),Mr=e=>$t(e,t=>t.url||""),Fr={url:"",text:"",newTab:r.CheckboxState.Unchecked},Dr=()=>{const[e,t]=m.useReducer((n,s)=>{const{type:i,payload:o}=s;switch(i){case"NEW_TAB":return{...n,newTab:r.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:r.CheckboxState.Unchecked};case"URL":case"TEXT":case"INIT":return{...n,...o};default:return n}},Fr);return[e,t]},Or=()=>{const e=r.useEditorRef(),[t,n]=Dr();m.useEffect(()=>{const h=Rr(e),d=Mr(e),x=r.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:r.floatingLinkSelectors.text(),newTab:x?r.CheckboxState.Checked:r.CheckboxState.Unchecked,url:h&&d===""?h:r.floatingLinkSelectors.url()}})},[n,e]);const s=h=>{n({type:"TEXT",payload:{text:h}})},i=h=>{n({type:"URL",payload:{url:h}})},o=h=>{n(h?{type:"NEW_TAB"}:{type:"SAME_TAB"})},l=()=>{r.floatingLinkActions.reset()},u=h=>{!ee(t.url)||!c||(r.floatingLinkActions.text(t.text),r.floatingLinkActions.url(fe(t.url)),r.floatingLinkActions.newTab(t.newTab===r.CheckboxState.Checked),r.submitFloatingLink(e)&&(h==null||h.preventDefault()))},c=t.url!==""&&t.text!=="",{appBridge:f}=r.getPluginOptions(e,r.ELEMENT_LINK);return r.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:s,onUrlChange:i,onToggleTab:o,onCancel:l,onSave:u,hasValues:c,isValidUrlOrEmpty:ee,appBridge:f}},Ur=()=>a.jsx(Dt,{...Or(),testId:"floating-link-insert"}),et={placement:"bottom-start",strategy:"absolute",middleware:[r.offset(12),r.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},_r=()=>{const e=r.useFloatingLinkInsertState({floatingOptions:et}),{props:t,ref:n,hidden:s}=r.useFloatingLinkInsert(e),i=r.useFloatingLinkEditState({floatingOptions:et}),{props:o,ref:l,editButtonProps:u,unlinkButtonProps:c}=r.useFloatingLinkEdit(i);if(s)return null;const f=a.jsx(Ur,{}),h=i.isEditing?f:a.jsx(Ar,{editButtonProps:u,unlinkButtonProps:c});return a.jsxs(a.Fragment,{children:[e.isOpen&&!i.isOpen&&a.jsx("div",{ref:n,...t,style:{...t.style,zIndex:1e3},children:f}),i.isOpen&&a.jsx("div",{ref:l,...o,style:{...o.style,zIndex:1e3},children:h})]})},Wt=m.forwardRef((e,t)=>{const n=r.useEditorRef(),s=r.useLinkToolbarButtonState(),{props:i}=r.useLinkToolbarButton(s);return a.jsx(r.ToolbarButton,{onMouseDown:()=>{r.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:t,...i,...e,children:a.jsx(r.IconStylingWrapper,{icon:a.jsx(r.IconLink16,{})})})});Wt.displayName="LinkToolbarButton";const Hr=({id:e,editorId:t})=>{const n=r.useEditorState(r.useEventPlateId(t)),s=!!r.isRangeInSameBlock(n,{at:n.selection});return a.jsx("div",{"data-plugin-id":e,children:a.jsx(Wt,{disabled:!s,tooltip:r.getTooltip(s?`Link
|
|
3
3
|
${r.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},Vr=e=>{var l,u;const{attributes:t,children:n}=e,{styles:s}=r.useRichTextEditorContext(),i=e.element.url||((u=(l=e.element.chosenLink)==null?void 0:l.searchResult)==null?void 0:u.link)||"",o=e.element.target||"_self";return a.jsx("a",{...t,href:i,target:o,style:s[de],children:n})};class zr extends r.MarkupElement{constructor(t=r.ELEMENT_LINK,n=Vr){super(t,n)}}const qt=e=>r.createPluginFactory({...r.createLinkPlugin(),renderAfterEditable:_r,options:{isUrl:xe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:e}})();class Gt extends r.Plugin{constructor({styles:n=j[de],...s}){super(de,{button:Hr,markupElement:new zr,...s});B(this,"styles",{});B(this,"appBridge");this.styles=n,this.appBridge=s.appBridge}plugins(){return[qt(this.appBridge)]}}const $r="textstyle-custom1-plugin";class Kt extends r.Plugin{constructor({styles:n=j.custom1,...s}={}){super(b.custom1,{label:"Custom 1",markupElement:new Wr,...s});B(this,"styles",{});this.styles=n}plugins(){return[qr(this.styles)]}}class Wr extends r.MarkupElement{constructor(t=$r,n=Xt){super(t,n)}}const Xt=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("p",{...t,style:s,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),children:n})},qr=e=>r.createPluginFactory({key:b.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:b.custom1}]}})({component:t=>a.jsx(Xt,{...t,styles:e})}),Gr="textstyle-custom2-plugin";class Qt extends r.Plugin{constructor({styles:n=j.custom2,...s}={}){super(b.custom2,{label:"Custom 2",markupElement:new Kr,...s});B(this,"styles",{});this.styles=n}plugins(){return[Xr(this.styles)]}}class Kr extends r.MarkupElement{constructor(t=Gr,n=Yt){super(t,n)}}const Yt=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("p",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},Xr=e=>r.createPluginFactory({key:b.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:b.custom2}]}})({component:t=>a.jsx(Yt,{...t,styles:e})}),Qr="textstyle-custom3-plugin";class Jt extends r.Plugin{constructor({styles:n=j.custom3,...s}={}){super(r.TextStyles.custom3,{label:"Custom 3",markupElement:new Yr,...s});B(this,"styles",{});this.styles=n}plugins(){return[Jr(this.styles)]}}class Yr extends r.MarkupElement{constructor(t=Qr,n=Zt){super(t,n)}}const Zt=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("p",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},Jr=e=>r.createPluginFactory({key:r.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:r.TextStyles.custom3}]}})({component:t=>a.jsx(Zt,{...t,styles:e})}),Zr="textstyle-heading1-plugin";class en extends r.Plugin{constructor({styles:n=j.heading1,...s}={}){super(b.heading1,{label:"Heading 1",markupElement:new es,...s});B(this,"styles",{});this.styles=n}plugins(){return[ts(this.styles)]}}class es extends r.MarkupElement{constructor(t=Zr,n=Ce){super(t,n)}}const Ce=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("h1",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},ts=e=>r.createPluginFactory({key:b.heading1,isElement:!0,component:Ce,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:t=>a.jsx(Ce,{...t,styles:e})}),ns="textstyle-heading2-plugin";class tn extends r.Plugin{constructor({styles:n=j.heading2,...s}={}){super(b.heading2,{label:"Heading 2",markupElement:new rs,...s});B(this,"styles",{});this.styles=n}plugins(){return[ss(this.styles)]}}class rs extends r.MarkupElement{constructor(t=ns,n=Se){super(t,n)}}const Se=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("h2",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},ss=e=>r.createPluginFactory({key:b.heading2,isElement:!0,component:Se,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:t=>a.jsx(Se,{...t,styles:e})}),as="textstyle-heading3-plugin";class nn extends r.Plugin{constructor({styles:n=j.heading3,...s}={}){super(b.heading3,{label:"Heading 3",markupElement:new is,...s});B(this,"styles",{});this.styles=n}plugins(){return[os(this.styles)]}}class is extends r.MarkupElement{constructor(t=as,n=ke){super(t,n)}}const ke=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("h3",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},os=e=>r.createPluginFactory({key:b.heading3,isElement:!0,component:ke,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:t=>a.jsx(ke,{...t,styles:e})}),ls="textstyle-heading4-plugin";class rn extends r.Plugin{constructor({styles:n=j.heading4,...s}={}){super(b.heading4,{label:"Heading 4",markupElement:new cs,...s});B(this,"styles",{});this.styles=n}plugins(){return[us(this.styles)]}}class cs extends r.MarkupElement{constructor(t=ls,n=Te){super(t,n)}}const Te=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("h4",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},us=e=>r.createPluginFactory({key:b.heading4,isElement:!0,component:Te,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:t=>a.jsx(Te,{...t,styles:e})}),ds="textstyle-imageCaption-plugin";class sn extends r.Plugin{constructor({styles:n=j.imageCaption,...s}={}){super(b.imageCaption,{label:"Image Caption",markupElement:new gs,...s});B(this,"styles",{});this.styles=n}plugins(){return[ms(this.styles)]}}class gs extends r.MarkupElement{constructor(t=ds,n=Pe){super(t,n)}}const Pe=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("p",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},ms=e=>r.createPluginFactory({key:b.imageCaption,isElement:!0,component:Pe,deserializeHtml:{rules:[{validClassName:b.imageCaption}]}})({component:t=>a.jsx(Pe,{...t,styles:e})}),hs="textstyle-imageTitle-plugin";class an extends r.Plugin{constructor({styles:n=j.imageTitle,...s}={}){super(b.imageTitle,{label:"Image Title",markupElement:new fs,...s});B(this,"styles",{});this.styles=n}plugins(){return[xs(this.styles)]}}class fs extends r.MarkupElement{constructor(t=hs,n=Ie){super(t,n)}}const Ie=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("p",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},xs=e=>r.createPluginFactory({key:b.imageTitle,isElement:!0,component:Ie,deserializeHtml:{rules:[{validClassName:b.imageTitle}]}})({component:t=>a.jsx(Ie,{...t,styles:e})});class on extends r.Plugin{constructor({styles:n=j.p,...s}={}){super(b.p,{markupElement:new cn,label:"Body Text",...s});B(this,"styles",{});this.styles=n}plugins(){return[un(this.styles)]}}const ln="tw-m-0 tw-px-0 tw-py-0",ge=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align,o=r.merge([i&&r.alignmentClassnames[i],ln,r.getColumnBreakClasses(e)]);return a.jsx("p",{...t,className:o,style:s,children:n})};class cn extends r.MarkupElement{constructor(t=b.p,n=ge){super(t,n)}}const un=e=>r.createPluginFactory({...r.createParagraphPlugin(),key:b.p,isElement:!0,component:ge})({component:t=>a.jsx(ge,{...t,styles:e})}),ps="textstyle-quote-plugin";class dn extends r.Plugin{constructor({styles:n=j.quote,...s}={}){super(b.quote,{label:"Quote",markupElement:new ws,...s});B(this,"styles",{});this.styles=n}plugins(){return[gn(this.styles)]}}class ws extends r.MarkupElement{constructor(t=ps,n=me){super(t,n)}}const me=({element:e,attributes:t,children:n,styles:s})=>{const i=e.align;return a.jsx("blockquote",{...t,className:r.merge([i&&r.alignmentClassnames[i],r.getColumnBreakClasses(e)]),style:s,children:n})},gn=e=>r.createPluginFactory({key:b.quote,isElement:!0,component:me,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:t=>a.jsx(me,{...t,styles:e})}),_e=[new en,new tn,new nn,new rn,new Kt,new Qt,new Jt,new dn,new on],Z=[b.heading1,b.heading2,b.heading3,b.heading4,b.custom1,b.custom2,b.custom3,b.quote,b.p],bs=[..._e,new sn,new an],ys=[...Z,b.imageCaption,b.imageTitle],vs=e=>new r.PluginComposer().setPlugin(new r.SoftBreakPlugin,new r.TextStylePlugin({textStyles:_e})).setPlugin([new r.BoldPlugin,new r.ItalicPlugin,new r.UnderlinePlugin,new r.StrikethroughPlugin,new Gt({appBridge:e}),new _t({appBridge:e}),new r.CodePlugin],[new r.AlignLeftPlugin({validTypes:Z}),new r.AlignCenterPlugin({validTypes:Z}),new r.AlignRightPlugin({validTypes:Z}),new r.AlignJustifyPlugin({validTypes:Z}),new r.UnorderedListPlugin,new r.CheckboxListPlugin,new r.OrderedListPlugin,new r.ResetFormattingPlugin,new r.AutoformatPlugin]),Cs="--f-theme-settings-",Ss=e=>{const t=e!=null&&e.id?`hasBackground${e.id}`:"hasBackground",n=e!=null&&e.id?`backgroundColor${e.id}`:"backgroundColor",s=e!=null&&e.preventDefaultColor?void 0:(e==null?void 0:e.defaultColor)||Rn,i=e!=null&&e.label?e.label:"Background",o=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:i,type:"switch",switchLabel:o,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,defaultValue:s,type:"colorInput"}]}},ks=e=>{const t=e!=null&&e.id?`hasBorder_${e.id}`:"hasBorder",n=e!=null&&e.id?`borderSelection_${e.id}`:"borderSelection",s=e!=null&&e.id?`borderStyle_${e.id}`:"borderStyle",i=e!=null&&e.id?`borderWidth_${e.id}`:"borderWidth",o=e!=null&&e.id?`borderColor_${e.id}`:"borderColor",l=(e==null?void 0:e.defaultColor)||st,u=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Border",type:"switch",switchLabel:u,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,type:"multiInput",onChange:c=>g.appendUnit(c,i),layout:g.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:s,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:i,type:"input",defaultValue:Mn,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px"},{id:o,type:"colorInput",defaultValue:l}]}],off:[]}},He=(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"}]}),Ts=e=>{const t=e!=null&&e.id?`hasRadius_${e.id}`:"hasRadius",n=e!=null&&e.id?`radiusValue_${e.id}`:"radiusValue",s=e!=null&&e.id?`radiusChoice_${e.id}`:"radiusChoice",i=(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:o=>{var l;return e!=null&&e.dependentSettingId?!!((l=o.getBlock(e.dependentSettingId))!=null&&l.value):!0},onChange:o=>g.presetCustomValue(o,s,n,(e==null?void 0:e.radiusStyleMap)||q),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[g.numericalOrPixelRule],onChange:o=>g.appendUnit(o,n)}],off:[He(s,i)]}},Ps=e=>{const t=e!=null&&e.id?`hasExtendedCustomRadius_${e.id}`:"hasExtendedCustomRadius",n=e!=null&&e.id?`extendedRadiusValue_${e.id}`:"extendedRadiusValue",s=e!=null&&e.id?`extendedRadiusChoice_${e.id}`:"extendedRadiusChoice",i=e!=null&&e.id?`extendedRadiusTopLeft_${e.id}`:"extendedRadiusTopLeft",o=e!=null&&e.id?`extendedRadiusTopRight_${e.id}`:"extendedRadiusTopRight",l=e!=null&&e.id?`extendedRadiusBottomLeft_${e.id}`:"extendedRadiusBottomLeft",u=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 f;return e!=null&&e.dependentSettingId?!!((f=c.getBlock(e.dependentSettingId))!=null&&f.value):!0},onChange:c=>{g.presetCustomValue(c,s,i,q),g.presetCustomValue(c,s,o,q),g.presetCustomValue(c,s,l,q),g.presetCustomValue(c,s,u,q)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,blocks:[{id:i,type:"input",label:"Top Left",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,i)},{id:o,type:"input",label:"Top Right",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,o)},{id:l,type:"input",label:"Bottom Left",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,l)},{id:u,type:"input",label:"Bottom Right",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,u)}]}],off:[He(s,e==null?void 0:e.defaultValue)]}},Is=e=>{const t=e!=null&&e.id?e.id:"hasCustomSpacing",n=e!=null&&e.dependentSettingId?e.dependentSettingId:"columns",s=e!=null&&e.spacingChoiceId?e.spacingChoiceId:"spacingChoice",i=e!=null&&e.spacingCustomId?e.spacingCustomId:"spacingCustom",o=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:l=>g.presetCustomValue(l,s,i,rt),show:l=>{var u;return((u=l.getBlock(n))==null?void 0:u.value)!=="1"},on:[{id:i,type:"input",rules:[g.numericalOrPixelRule],onChange:l=>g.appendUnit(l,i)}],off:[{id:s,type:"slider",defaultValue:o,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"}]}),Es=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",s=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:i=>g.presetCustomValue(i,s,n,(e==null?void 0:e.marginStyleMap)||J),on:[{id:n,type:"input",placeholder:se,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>g.appendUnit(i,n)}],off:[Ve(s)]}},Bs=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",s=e!=null&&e.id?`extendedMarginChoice_${e==null?void 0:e.id}`:"extendedMarginChoice",i=e!=null&&e.id?`extendedMarginTop_${e==null?void 0:e.id}`:"extendedMarginTop",o=e!=null&&e.id?`extendedMarginLeft_${e==null?void 0:e.id}`:"extendedMarginLeft",l=e!=null&&e.id?`extendedMarginRight_${e==null?void 0:e.id}`:"extendedMarginRight",u=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=>{g.presetCustomValue(c,s,i,J),g.presetCustomValue(c,s,o,J),g.presetCustomValue(c,s,l,J),g.presetCustomValue(c,s,u,J)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:se,onChange:c=>g.appendUnit(c,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:o,type:"input",label:"Left",placeholder:se,onChange:c=>g.appendUnit(c,o),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Right",placeholder:se,onChange:c=>g.appendUnit(c,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:se,onChange:c=>g.appendUnit(c,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Ve(s)]}},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"}]}),js=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",s=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:i=>g.presetCustomValue(i,s,n,(e==null?void 0:e.paddingStyleMap)||Y),on:[{id:n,type:"input",placeholder:re,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>g.appendUnit(i,n)}],off:[ze(s)]}},Ns=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",s=e!=null&&e.id?`extendedPaddingChoice_${e==null?void 0:e.id}`:"extendedPaddingChoice",i=e!=null&&e.id?`extendedPaddingTop_${e==null?void 0:e.id}`:"extendedPaddingTop",o=e!=null&&e.id?`extendedPaddingLeft_${e==null?void 0:e.id}`:"extendedPaddingLeft",l=e!=null&&e.id?`extendedPaddingRight_${e==null?void 0:e.id}`:"extendedPaddingRight",u=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=>{g.presetCustomValue(c,s,i,Y),g.presetCustomValue(c,s,o,Y),g.presetCustomValue(c,s,l,Y),g.presetCustomValue(c,s,u,Y)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:re,onChange:c=>g.appendUnit(c,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:o,type:"input",label:"Left",placeholder:re,onChange:c=>g.appendUnit(c,o),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Right",placeholder:re,onChange:c=>g.appendUnit(c,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:re,onChange:c=>g.appendUnit(c,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[ze(s)]}},Ls=e=>{const t=$e(e==null?void 0:e.globalControlId);return{id:e!=null&&e.id?e.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>{var s;return((s=n.getBlock(t))==null?void 0:s.value)===K.Custom}}},$e=e=>e||"security",As=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:g.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var mn=(e=>(e.Main="main",e.Basics="basics",e.Layout="layout",e.Style="style",e.Security="security",e.Targets="targets",e))(mn||{});const Rs=e=>e,Ms=e=>e;exports.AllTextStylePlugins=bs;exports.AllTextStyles=ys;exports.Attachments=ft;exports.AttachmentsProvider=gt;exports.AttachmentsToolbarButton=pt;exports.BUTTON_PLUGIN=Ot;exports.BlockButtonStyles=we;exports.BlockInjectButton=kn;exports.BlockItemWrapper=Kn;exports.BlockStyles=j;exports.BorderStyle=D;exports.ButtonPlugin=_t;exports.Custom1Plugin=Kt;exports.Custom2Plugin=Qt;exports.Custom3Plugin=Jt;exports.DEFAULT_ATTACHMENTS_BUTTON_ID=xt;exports.DEFAULT_DRAGGING_TOOLTIP=bt;exports.DEFAULT_DRAG_TOOLTIP=wt;exports.DEFAULT_MENU_BUTTON_ID=Le;exports.DownloadButton=Xn;exports.DragHandleToolbarButton=yt;exports.DragPreviewContextProvider=it;exports.ELEMENT_BUTTON=C;exports.FlyoutToolbarButton=Ne;exports.GutterSpacing=W;exports.Heading1Plugin=en;exports.Heading2Plugin=tn;exports.Heading3Plugin=nn;exports.Heading4Plugin=rn;exports.ImageCaptionPlugin=sn;exports.ImageTitlePlugin=an;exports.LinkInput=Ft;exports.LinkPlugin=Gt;exports.LinkSelector=Mt;exports.Margin=$;exports.MenuToolbarButton=Ct;exports.MultiFlyoutContextProvider=lt;exports.PARAGRAPH_CLASSES=ln;exports.Padding=z;exports.ParagraphMarkupElement=cn;exports.ParagraphMarkupElementNode=ge;exports.ParagraphPlugin=on;exports.QuoteMarkupElementNode=me;exports.QuotePlugin=dn;exports.Radius=H;exports.RichTextEditor=Lr;exports.Sections=mn;exports.Security=K;exports.THEME_PREFIX=Cs;exports.TextStylePluginsWithoutImage=_e;exports.TextStyles=b;exports.TextStylesWithoutImage=Z;exports.Toolbar=St;exports.ToolbarFlyoutMenu=vt;exports.addHttps=fe;exports.borderStyleMap=nt;exports.convertToRteValue=Yn;exports.createButtonNode=Nt;exports.createButtonPlugin=Ut;exports.createLinkPlugin=qt;exports.createParagraphPlugin=un;exports.createQuotePlugin=gn;exports.customCoordinatesGetterFactory=ht;exports.defineBlock=Rs;exports.defineSettings=Ms;exports.getBackgroundColorStyles=An;exports.getBackgroundSettings=Ss;exports.getBorderRadiusSettings=Ts;exports.getBorderRadiusSlider=He;exports.getBorderSettings=ks;exports.getBorderStyles=Fn;exports.getDefaultPluginsWithLinkChooser=vs;exports.getExtendedBorderRadiusSettings=Ps;exports.getGutterSettings=Is;exports.getLegacyUrl=nr;exports.getLinkFromEditor=sr;exports.getMarginExtendedSettings=Bs;exports.getMarginSettings=Es;exports.getMarginSlider=Ve;exports.getPaddingExtendedSettings=Ns;exports.getPaddingSettings=js;exports.getPaddingSlider=ze;exports.getRadiusStyles=Dn;exports.getReadableColor=Nn;exports.getSecurityDownloadableSetting=Ls;exports.getSecurityGlobalControlId=$e;exports.getSecurityGlobalControlSetting=As;exports.getUrl=rr;exports.getUrlFromEditor=jt;exports.getUrlFromLinkOrLegacyLink=Me;exports.gutterSpacingStyleMap=rt;exports.hasRichTextValue=kt;exports.insertButton=It;exports.isDark=Pn;exports.isDownloadable=Jn;exports.isValidUrl=xe;exports.isValidUrlOrEmpty=ee;exports.joinClassNames=O;exports.mapAppBridgeColorPaletteToFonduePalette=Tt;exports.mapAppBridgeColorPalettesToFonduePalettes=Zn;exports.marginStyleMap=J;exports.moveItemInArray=Ln;exports.paddingStyleMap=Y;exports.radiusStyleMap=q;exports.relativeUrlRegex=Fe;exports.setAlpha=Bn;exports.submitFloatingButton=De;exports.toColorObject=jn;exports.toHex8String=In;exports.toHexString=En;exports.toRgbaString=Ee;exports.toShortRgba=X;exports.triggerFloatingButton=Lt;exports.triggerFloatingButtonEdit=pe;exports.triggerFloatingButtonInsert=Ue;exports.unwrapButton=te;exports.upsertButton=Et;exports.upsertButtonText=Oe;exports.useAttachments=ut;exports.useAttachmentsContext=mt;exports.useDndSensors=Hn;exports.useDragPreviewContext=ie;exports.useMultiFlyoutContext=ct;exports.useMultiFlyoutState=he;exports.withAttachmentsProvider=On;exports.withButton=Pt;exports.wrapButton=Bt;Object.keys(g).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>g[e]})});
|
|
4
4
|
//# sourceMappingURL=index.cjs.js.map
|