@frontify/guideline-blocks-settings 0.31.1 → 0.31.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @frontify/guideline-blocks-settings
2
2
 
3
+ ## 0.31.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#720](https://github.com/Frontify/brand-sdk/pull/720) [`7b8a520`](https://github.com/Frontify/brand-sdk/commit/7b8a5209df3b2116cf83838e6da2aae3f83fa33f) Thanks [@ragi96](https://github.com/ragi96)! - fix(Attachments): use the appropriate function for removing and adding asset
8
+
9
+ ## 0.31.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`68a9298`](https://github.com/Frontify/brand-sdk/commit/68a9298df9e2177e70333f47dc433a056d76625b)]:
14
+ - @frontify/app-bridge@3.1.0
15
+
3
16
  ## 0.31.1
4
17
 
5
18
  ### Patch Changes
@@ -1,54 +1,53 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { useBlockAssets as h } from "@frontify/app-bridge";
3
- import { createContext as A, useContext as p } from "react";
4
- const w = (e, n) => {
5
- const { blockAssets: s, updateAssetIdsFromKey: o } = h(e), r = (s == null ? void 0 : s[n]) || [];
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { useBlockAssets as p } from "@frontify/app-bridge";
3
+ import { createContext as w, useContext as u } from "react";
4
+ const l = (t, e) => {
5
+ const { blockAssets: n, addAssetIdsToKey: s, deleteAssetIdsFromKey: h, updateAssetIdsFromKey: d } = p(t), i = (n == null ? void 0 : n[e]) || [];
6
6
  return {
7
- onAttachmentsAdd: async (a) => {
8
- const c = r.map((t) => t.id);
9
- for (const t of a)
10
- c.push(t.id);
11
- await o(n, c);
7
+ onAttachmentsAdd: async (o) => {
8
+ await s(
9
+ e,
10
+ o.map((r) => r.id)
11
+ );
12
12
  },
13
- onAttachmentDelete: async (a) => {
14
- const c = r.filter((t) => t.id !== a.id).map((t) => t.id);
15
- await o(n, c);
13
+ onAttachmentDelete: async (o) => {
14
+ await h(e, [o.id]);
16
15
  },
17
- onAttachmentReplace: async (a, c) => {
18
- const t = r.map(
19
- (m) => m.id === a.id ? c.id : m.id
16
+ onAttachmentReplace: async (o, r) => {
17
+ const c = i.map(
18
+ (m) => m.id === o.id ? r.id : m.id
20
19
  );
21
- await o(n, t);
20
+ await d(e, c);
22
21
  },
23
- onAttachmentsSorted: async (a) => {
24
- const c = a.map((t) => t.id);
25
- await o(n, c);
22
+ onAttachmentsSorted: async (o) => {
23
+ const r = o.map((c) => c.id);
24
+ await d(e, r);
26
25
  },
27
- attachments: r,
28
- appBridge: e
26
+ attachments: i,
27
+ appBridge: t
29
28
  };
30
- }, d = A(null), u = ({
31
- appBridge: e,
32
- children: n,
33
- assetId: s
29
+ }, A = w(null), x = ({
30
+ appBridge: t,
31
+ children: e,
32
+ assetId: n
34
33
  }) => {
35
- const o = w(e, s);
36
- return /* @__PURE__ */ i(d.Provider, { value: o, children: n });
37
- }, B = () => {
38
- const e = p(d);
39
- if (!e)
34
+ const s = l(t, n);
35
+ return /* @__PURE__ */ a(A.Provider, { value: s, children: e });
36
+ }, D = () => {
37
+ const t = u(A);
38
+ if (!t)
40
39
  throw new Error(
41
40
  "No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC"
42
41
  );
43
- return e;
44
- }, D = (e, n) => {
45
- const s = (o) => /* @__PURE__ */ i(u, { appBridge: o.appBridge, assetId: n, children: /* @__PURE__ */ i(e, { ...o }) });
46
- return s.displayName = "withAttachmentsProvider", s;
42
+ return t;
43
+ }, F = (t, e) => {
44
+ const n = (s) => /* @__PURE__ */ a(x, { appBridge: s.appBridge, assetId: e, children: /* @__PURE__ */ a(t, { ...s }) });
45
+ return n.displayName = "withAttachmentsProvider", n;
47
46
  };
48
47
  export {
49
- u as AttachmentsProvider,
50
- w as useAttachments,
51
- B as useAttachmentsContext,
52
- D as withAttachmentsProvider
48
+ x as AttachmentsProvider,
49
+ l as useAttachments,
50
+ D as useAttachmentsContext,
51
+ F as withAttachmentsProvider
53
52
  };
54
53
  //# sourceMappingURL=useAttachments.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAttachments.es.js","sources":["../../src/hooks/useAttachments.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { AppBridgeBlock, Asset, useBlockAssets } from '@frontify/app-bridge';\nimport { type ReactNode, createContext, useContext } from 'react';\n\nimport { type BlockProps } from '../index';\n\nexport const useAttachments = (appBridge: AppBridgeBlock, assetId: string) => {\n const { blockAssets, updateAssetIdsFromKey } = useBlockAssets(appBridge);\n const attachments = blockAssets?.[assetId] || [];\n\n const onAttachmentsAdd = async (newAssets: Asset[]) => {\n const newAssetIds = attachments.map((attachment) => attachment.id);\n for (const asset of newAssets) {\n newAssetIds.push(asset.id);\n }\n await updateAssetIdsFromKey(assetId, newAssetIds);\n };\n\n const onAttachmentDelete = async (assetToDelete: Asset) => {\n const newAssetIds = attachments\n .filter((attachment) => attachment.id !== assetToDelete.id)\n .map((attachment) => attachment.id);\n\n await updateAssetIdsFromKey(assetId, newAssetIds);\n };\n\n const onAttachmentReplace = async (attachmentToReplace: Asset, newAsset: Asset) => {\n const newAssetIds = attachments.map((attachment) =>\n attachment.id === attachmentToReplace.id ? newAsset.id : attachment.id,\n );\n\n await updateAssetIdsFromKey(assetId, newAssetIds);\n };\n\n const onAttachmentsSorted = async (assets: Asset[]) => {\n const newAssetIds = assets.map((asset) => asset.id);\n\n await updateAssetIdsFromKey(assetId, newAssetIds);\n };\n\n return {\n onAttachmentsAdd,\n onAttachmentDelete,\n onAttachmentReplace,\n onAttachmentsSorted,\n attachments,\n appBridge,\n };\n};\n\nconst AttachmentsContext = createContext<ReturnType<typeof useAttachments> | null>(null);\n\nexport const AttachmentsProvider = ({\n appBridge,\n children,\n assetId,\n}: {\n appBridge: AppBridgeBlock;\n children: ReactNode;\n assetId: string;\n}) => {\n const attachmentContext = useAttachments(appBridge, assetId);\n\n return <AttachmentsContext.Provider value={attachmentContext}>{children}</AttachmentsContext.Provider>;\n};\n\nexport const useAttachmentsContext = () => {\n const context = useContext(AttachmentsContext);\n\n if (!context) {\n throw new Error(\n \"No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC\",\n );\n }\n\n return context;\n};\n\n/**\n * Block-level HOC for cases when there is only one attachment asset field related to the block.\n * Recommended for most cases.\n * If finer control is required over attachments, use {@link AttachmentsProvider} component.\n */\nexport const withAttachmentsProvider = <T extends BlockProps>(Component: (props: T) => ReactNode, assetId: string) => {\n const wrappedComponent = (props: T) => (\n <AttachmentsProvider appBridge={props.appBridge} assetId={assetId}>\n <Component {...props} />\n </AttachmentsProvider>\n );\n\n wrappedComponent.displayName = 'withAttachmentsProvider';\n\n return wrappedComponent;\n};\n"],"names":["useAttachments","appBridge","assetId","blockAssets","updateAssetIdsFromKey","useBlockAssets","attachments","newAssets","newAssetIds","attachment","asset","assetToDelete","attachmentToReplace","newAsset","assets","AttachmentsContext","createContext","AttachmentsProvider","children","attachmentContext","useAttachmentsContext","context","useContext","withAttachmentsProvider","Component","wrappedComponent","props","jsx"],"mappings":";;;AAOa,MAAAA,IAAiB,CAACC,GAA2BC,MAAoB;AAC1E,QAAM,EAAE,aAAAC,GAAa,uBAAAC,EAAsB,IAAIC,EAAeJ,CAAS,GACjEK,KAAcH,KAAA,gBAAAA,EAAcD,OAAY,CAAA;AAgCvC,SAAA;AAAA,IACH,kBA/BqB,OAAOK,MAAuB;AACnD,YAAMC,IAAcF,EAAY,IAAI,CAACG,MAAeA,EAAW,EAAE;AACjE,iBAAWC,KAASH;AACJ,QAAAC,EAAA,KAAKE,EAAM,EAAE;AAEvB,YAAAN,EAAsBF,GAASM,CAAW;AAAA,IAAA;AAAA,IA2BhD,oBAxBuB,OAAOG,MAAyB;AACvD,YAAMH,IAAcF,EACf,OAAO,CAACG,MAAeA,EAAW,OAAOE,EAAc,EAAE,EACzD,IAAI,CAACF,MAAeA,EAAW,EAAE;AAEhC,YAAAL,EAAsBF,GAASM,CAAW;AAAA,IAAA;AAAA,IAoBhD,qBAjBwB,OAAOI,GAA4BC,MAAoB;AAC/E,YAAML,IAAcF,EAAY;AAAA,QAAI,CAACG,MACjCA,EAAW,OAAOG,EAAoB,KAAKC,EAAS,KAAKJ,EAAW;AAAA,MAAA;AAGlE,YAAAL,EAAsBF,GAASM,CAAW;AAAA,IAAA;AAAA,IAahD,qBAVwB,OAAOM,MAAoB;AACnD,YAAMN,IAAcM,EAAO,IAAI,CAACJ,MAAUA,EAAM,EAAE;AAE5C,YAAAN,EAAsBF,GAASM,CAAW;AAAA,IAAA;AAAA,IAQhD,aAAAF;AAAA,IACA,WAAAL;AAAA,EAAA;AAER,GAEMc,IAAqBC,EAAwD,IAAI,GAE1EC,IAAsB,CAAC;AAAA,EAChC,WAAAhB;AAAA,EACA,UAAAiB;AAAA,EACA,SAAAhB;AACJ,MAIM;AACI,QAAAiB,IAAoBnB,EAAeC,GAAWC,CAAO;AAE3D,2BAAQa,EAAmB,UAAnB,EAA4B,OAAOI,GAAoB,UAAAD,EAAS,CAAA;AAC5E,GAEaE,IAAwB,MAAM;AACjC,QAAAC,IAAUC,EAAWP,CAAkB;AAE7C,MAAI,CAACM;AACD,UAAM,IAAI;AAAA,MACN;AAAA,IAAA;AAID,SAAAA;AACX,GAOaE,IAA0B,CAAuBC,GAAoCtB,MAAoB;AAClH,QAAMuB,IAAmB,CAACC,MACtB,gBAAAC,EAACV,GAAoB,EAAA,WAAWS,EAAM,WAAW,SAAAxB,GAC7C,UAAA,gBAAAyB,EAACH,GAAW,EAAA,GAAGE,GAAO,EAC1B,CAAA;AAGJ,SAAAD,EAAiB,cAAc,2BAExBA;AACX;"}
1
+ {"version":3,"file":"useAttachments.es.js","sources":["../../src/hooks/useAttachments.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { AppBridgeBlock, Asset, useBlockAssets } from '@frontify/app-bridge';\nimport { type ReactNode, createContext, useContext } from 'react';\n\nimport { type BlockProps } from '../index';\n\nexport const useAttachments = (appBridge: AppBridgeBlock, attachmentKey: string) => {\n const { blockAssets, addAssetIdsToKey, deleteAssetIdsFromKey, updateAssetIdsFromKey } = useBlockAssets(appBridge);\n const attachments = blockAssets?.[attachmentKey] || [];\n\n const onAttachmentsAdd = async (newAssets: Asset[]) => {\n await addAssetIdsToKey(\n attachmentKey,\n newAssets.map((asset) => asset.id),\n );\n };\n\n const onAttachmentDelete = async (assetToDelete: Asset) => {\n await deleteAssetIdsFromKey(attachmentKey, [assetToDelete.id]);\n };\n\n const onAttachmentReplace = async (attachmentToReplace: Asset, newAsset: Asset) => {\n const newAssetIds = attachments.map((attachment) =>\n attachment.id === attachmentToReplace.id ? newAsset.id : attachment.id,\n );\n\n await updateAssetIdsFromKey(attachmentKey, newAssetIds);\n };\n\n const onAttachmentsSorted = async (assets: Asset[]) => {\n const newAssetIds = assets.map((asset) => asset.id);\n\n await updateAssetIdsFromKey(attachmentKey, newAssetIds);\n };\n\n return {\n onAttachmentsAdd,\n onAttachmentDelete,\n onAttachmentReplace,\n onAttachmentsSorted,\n attachments,\n appBridge,\n };\n};\n\nconst AttachmentsContext = createContext<ReturnType<typeof useAttachments> | null>(null);\n\nexport const AttachmentsProvider = ({\n appBridge,\n children,\n assetId,\n}: {\n appBridge: AppBridgeBlock;\n children: ReactNode;\n assetId: string;\n}) => {\n const attachmentContext = useAttachments(appBridge, assetId);\n\n return <AttachmentsContext.Provider value={attachmentContext}>{children}</AttachmentsContext.Provider>;\n};\n\nexport const useAttachmentsContext = () => {\n const context = useContext(AttachmentsContext);\n\n if (!context) {\n throw new Error(\n \"No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC\",\n );\n }\n\n return context;\n};\n\n/**\n * Block-level HOC for cases when there is only one attachment asset field related to the block.\n * Recommended for most cases.\n * If finer control is required over attachments, use {@link AttachmentsProvider} component.\n */\nexport const withAttachmentsProvider = <T extends BlockProps>(Component: (props: T) => ReactNode, assetId: string) => {\n const wrappedComponent = (props: T) => (\n <AttachmentsProvider appBridge={props.appBridge} assetId={assetId}>\n <Component {...props} />\n </AttachmentsProvider>\n );\n\n wrappedComponent.displayName = 'withAttachmentsProvider';\n\n return wrappedComponent;\n};\n"],"names":["useAttachments","appBridge","attachmentKey","blockAssets","addAssetIdsToKey","deleteAssetIdsFromKey","updateAssetIdsFromKey","useBlockAssets","attachments","newAssets","asset","assetToDelete","attachmentToReplace","newAsset","newAssetIds","attachment","assets","AttachmentsContext","createContext","AttachmentsProvider","children","assetId","attachmentContext","useAttachmentsContext","context","useContext","withAttachmentsProvider","Component","wrappedComponent","props","jsx"],"mappings":";;;AAOa,MAAAA,IAAiB,CAACC,GAA2BC,MAA0B;AAChF,QAAM,EAAE,aAAAC,GAAa,kBAAAC,GAAkB,uBAAAC,GAAuB,uBAAAC,MAA0BC,EAAeN,CAAS,GAC1GO,KAAcL,KAAA,gBAAAA,EAAcD,OAAkB,CAAA;AA2B7C,SAAA;AAAA,IACH,kBA1BqB,OAAOO,MAAuB;AAC7C,YAAAL;AAAA,QACFF;AAAA,QACAO,EAAU,IAAI,CAACC,MAAUA,EAAM,EAAE;AAAA,MAAA;AAAA,IACrC;AAAA,IAuBA,oBApBuB,OAAOC,MAAyB;AACvD,YAAMN,EAAsBH,GAAe,CAACS,EAAc,EAAE,CAAC;AAAA,IAAA;AAAA,IAoB7D,qBAjBwB,OAAOC,GAA4BC,MAAoB;AAC/E,YAAMC,IAAcN,EAAY;AAAA,QAAI,CAACO,MACjCA,EAAW,OAAOH,EAAoB,KAAKC,EAAS,KAAKE,EAAW;AAAA,MAAA;AAGlE,YAAAT,EAAsBJ,GAAeY,CAAW;AAAA,IAAA;AAAA,IAatD,qBAVwB,OAAOE,MAAoB;AACnD,YAAMF,IAAcE,EAAO,IAAI,CAACN,MAAUA,EAAM,EAAE;AAE5C,YAAAJ,EAAsBJ,GAAeY,CAAW;AAAA,IAAA;AAAA,IAQtD,aAAAN;AAAA,IACA,WAAAP;AAAA,EAAA;AAER,GAEMgB,IAAqBC,EAAwD,IAAI,GAE1EC,IAAsB,CAAC;AAAA,EAChC,WAAAlB;AAAA,EACA,UAAAmB;AAAA,EACA,SAAAC;AACJ,MAIM;AACI,QAAAC,IAAoBtB,EAAeC,GAAWoB,CAAO;AAE3D,2BAAQJ,EAAmB,UAAnB,EAA4B,OAAOK,GAAoB,UAAAF,EAAS,CAAA;AAC5E,GAEaG,IAAwB,MAAM;AACjC,QAAAC,IAAUC,EAAWR,CAAkB;AAE7C,MAAI,CAACO;AACD,UAAM,IAAI;AAAA,MACN;AAAA,IAAA;AAID,SAAAA;AACX,GAOaE,IAA0B,CAAuBC,GAAoCN,MAAoB;AAClH,QAAMO,IAAmB,CAACC,MACtB,gBAAAC,EAACX,GAAoB,EAAA,WAAWU,EAAM,WAAW,SAAAR,GAC7C,UAAA,gBAAAS,EAACH,GAAW,EAAA,GAAGE,GAAO,EAC1B,CAAA;AAGJ,SAAAD,EAAiB,cAAc,2BAExBA;AACX;"}
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),i=require("@frontify/fondue"),x=require("react"),V=require("@frontify/app-bridge"),P=require("@dnd-kit/core"),sn=require("@dnd-kit/modifiers"),le=require("@dnd-kit/sortable"),rn=require("@react-aria/focus"),o=require("@udecode/plate"),Xe=require("slate-react"),an=require("@react-stately/overlays"),on=require("slate"),D=require("@ctrl/tinycolor");const U=e=>e.filter(Boolean).join(" "),ln=({onDrop:e,label:t,icon:n,secondaryLabel:r,isLoading:a,fillParentContainer:l,onAssetChooseClick:c,onUploadClick:d,withMenu:u=!0,onClick:f,validFileType:h,verticalLayout:g})=>{const[p,v]=x.useState(!1),[b,k]=x.useState(),j=x.useRef(null),[S,A]=x.useState(void 0),O=I=>{if(I.preventDefault(),v(!1),!R(I.dataTransfer.files)){A("Invalid"),setTimeout(()=>{A(void 0)},1e3);return}e==null||e(I.dataTransfer.files)},R=I=>{if(!h)return!0;for(let F=0;F<I.length;F++){const N=I[F].name.split(".").pop()??"";if(!V.FileExtensionSets[h].includes(N))return!1}return!0},H=I=>{if(!j.current||a)return;const{left:F,top:N}=j.current.getBoundingClientRect(),ie=I.clientX-F,oe=I.clientY-N;k([ie,oe])};return s.jsxs("button",{ref:j,"data-test-id":"block-inject-button",className:U(["tw-font-body tw-relative tw-text-sm tw-leading-4 tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",g?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",l?"tw-h-full":"tw-h-[72px]",p&&!a?"tw-border-dashed":"tw-border-solid",b&&"tw-bg-blank-state-pressed-inverse",p&&"tw-bg-blank-state-weak-inverse",S?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",a||b||p||S?"":"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",(p||b)&&!S?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:e?I=>{var F;if(v(!0),h==="Images")for(const N of Array.from(I.dataTransfer.items))(F=N==null?void 0:N.type)!=null&&F.startsWith("image/")?A(void 0):A("Invalid")}:void 0,onDragLeave:e?()=>{v(!1),A(void 0)}:void 0,onDrop:e?O:void 0,onClick:I=>{u&&H(I),f==null||f()},children:[a?s.jsx(i.LoadingCircle,{}):S?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(i.IconExclamationMarkTriangle,{}),S]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(t||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[t&&s.jsx("div",{className:"tw-font-medium",children:t}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),b&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:b[0],top:b[1]},children:s.jsx(i.Flyout,{onOpenChange:I=>!I&&k(void 0),isOpen:!0,fitContent:!0,hug:!1,legacyFooter:!1,trigger:s.jsx("div",{}),children:s.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[...d?[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Upload asset",onClick:()=>{d(),k(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconArrowCircleUp20,{})})}]:[],...c?[{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Browse asset",onClick:()=>{c(),k(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconImageStack20,{})})}]:[]]}]})})})]})},X=e=>{const t=r=>typeof r=="object"&&["red","green","blue"].every(l=>r.hasOwnProperty(l)),n=r=>{const a=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a}};return t(e)?n(e):e},cn=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),un=(e,t)=>{const n=cn(e)?X(e):e,r=new D.TinyColor(n);return t?r.getBrightness()<t:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},dn=e=>new D.TinyColor(X(e)).toHex8String(),gn=e=>new D.TinyColor(X(e)).toHexString(),Te=e=>new D.TinyColor(X(e)).toRgbString(),mn=(e,t)=>new D.TinyColor(t).setAlpha(e).toRgbString(),hn=e=>{const{r:t,g:n,b:r,a}=new D.TinyColor(e);return{red:t,green:n,blue:r,alpha:a}},Ge=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),fn=(e,t)=>{const n=Ge(e)?X(e):e,r=Ge(t)?X(t):t;let a=new D.TinyColor(n);const l=new D.TinyColor(r);for(;D.readability(a,l)<4.5;)a=a.darken(1);return a.toRgbString()},pn=(e,t,n)=>{const r=[...e],a=n<0?r.length+n:n;if(a>=0&&a<r.length){const l=r.splice(t,1)[0];r.splice(a,0,l)}return r},xn=e=>({backgroundColor:Te(e)});var M=(e=>(e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted",e))(M||{});const Qe={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var _=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(_||{});const G={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var $=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))($||{});const Y={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var W=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(W||{});const J={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var K=(e=>(e.Global="Global",e.Custom="Custom",e))(K||{}),q=(e=>(e.Auto="Auto",e.S="S",e.M="M",e.L="L",e))(q||{});const Ye={Auto:"4px",S:"10px",M:"30px",L:"50px"},wn={red:241,green:241,blue:241,alpha:1},Je={red:234,green:235,blue:235,alpha:1},yn="1px",re="24px",ae="24px",bn=(e=M.Solid,t="1px",n=Je)=>({borderStyle:Qe[e],borderWidth:t,borderColor:Te(n)}),vn=(e,t=!1,n)=>({borderRadius:t?n:G[e]}),Ze="Drag or press ↵ to move",et="Move with ↑↓←→ and confirm with ↵",Ke=({children:e})=>s.jsx("div",{className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:e}),Cn=e=>e==="IMAGE"?s.jsx(i.IconImage24,{}):e==="VIDEO"?s.jsx(i.IconPlayFrame24,{}):e==="AUDIO"?s.jsx(i.IconMusicNote24,{}):s.jsx(i.IconDocument24,{}),Be=x.forwardRef(({item:e,isEditing:t,transformStyle:n,isDragging:r,isOverlay:a,isLoading:l,onDelete:c,onReplaceWithBrowse:d,onReplaceWithUpload:u,onDownload:f},h)=>{const[g,p]=x.useState(),[v,{selectedFiles:b}]=V.useFileInput({multiple:!0,accept:"image/*"}),[k,{results:j,doneAll:S}]=V.useAssetUpload();x.useEffect(()=>{b&&k(b[0])},[b]),x.useEffect(()=>{S&&u(j[0])},[S,j]);const A=l||b&&!S;return s.jsxs("button",{"aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>f==null?void 0:f(),ref:h,style:{...n,opacity:r&&!a?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:U(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-box-neutral-hover",r?"tw-bg-box-neutral-hover":""]),children:[s.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:A?s.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small}):Cn(e.objectType)}),s.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:e.title}),s.jsx("div",{className:"tw-text-text-weak",children:`${e.fileSizeHumanReadable} - ${e.extension}`})]}),t&&s.jsx("div",{"data-test-id":"attachments-actionbar",className:U(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",a||(g==null?void 0:g.id)===e.id?"tw-opacity-100":"tw-opacity-0"]),children:s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsx(i.Flyout,{placement:i.FlyoutPlacement.Right,isOpen:(g==null?void 0:g.id)===e.id,fitContent:!0,legacyFooter:!1,onOpenChange:O=>p(O?e:void 0),trigger:(O,R)=>s.jsx(i.Button,{ref:R,icon:s.jsx(i.IconPen20,{}),emphasis:i.ButtonEmphasis.Default,onClick:()=>p(e)}),children:s.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Replace with upload",onClick:()=>{v(),p(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconArrowCircleUp20,{})})},{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Replace with asset",onClick:()=>{d(),p(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconImageStack20,{})})}]},{id:"menu-delete",menuItems:[{id:"delete",size:i.MenuItemContentSize.XSmall,title:"Delete",style:i.MenuItemStyle.Danger,onClick:()=>{c(),p(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconTrashBin20,{})})}]}]})})})})]})});Be.displayName="AttachmentItem";const kn=e=>{const{attributes:t,listeners:n,setNodeRef:r,transform:a,transition:l,isDragging:c}=le.useSortable({id:e.item.id}),d={transform:a?`translate(${a.x}px, ${a.y}px)`:"",transition:l,zIndex:c?2:1},u={...t,...n};return s.jsx(Be,{ref:r,isDragging:c,transformStyle:d,draggableProps:u,...e})},Sn=({children:e,isFlyoutOpen:t})=>s.jsxs("div",{className:U(["tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",t?"tw-bg-box-neutral-pressed tw-text-box-neutral-inverse-pressed":"tw-bg-base hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed tw-text-box-neutral-inverse hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed"]),children:[s.jsx(i.IconPaperclip16,{}),e,s.jsx(i.IconCaretDown12,{})]}),tt=({items:e=[],onDelete:t,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:a,onUpload:l,onSorted:c,appBridge:d,triggerComponent:u=Sn,isOpen:f,onOpenChange:h})=>{const[g,p]=x.useState(e),[v,b]=x.useState(!1),k=P.useSensors(P.useSensor(P.PointerSensor),P.useSensor(P.KeyboardSensor)),[j,S]=x.useState(void 0),[A,O]=x.useState(!1),[R,H]=x.useState([]),[I,F]=x.useState(null),N=V.useEditorState(d),{openAssetChooser:ie,closeAssetChooser:oe}=V.useAssetChooser(d),_e=f!==void 0,ye=_e?f:v,Q=g==null?void 0:g.find(y=>y.id===j),[Yt,{results:Ve,doneAll:ze}]=V.useAssetUpload({onUploadProgress:()=>!A&&O(!0)}),se=y=>{const B=_e?h:b;B==null||B(y)};x.useEffect(()=>{p(e)},[e]),x.useEffect(()=>{I&&(O(!0),Yt(I))},[I]),x.useEffect(()=>{(async()=>{ze&&(await l(Ve),O(!1))})()},[ze,Ve]);const Jt=()=>{se(!1),ie(y=>{a(y),oe(),se(!0)},{multiSelection:!0,selectedValueIds:g.map(y=>y.id)})},$e=y=>{se(!1),ie(async B=>{se(!0),oe(),H([...R,y.id]),await n(y,B[0]),H(R.filter(z=>z!==y.id))},{multiSelection:!1,selectedValueIds:g.map(B=>B.id)})},We=async(y,B)=>{H([...R,y.id]),await r(y,B),H(R.filter(z=>z!==y.id))},Zt=y=>{const{active:B}=y;S(B.id)},en=y=>{const{active:B,over:z}=y;if(z&&B.id!==z.id&&g){const tn=g.findIndex(be=>be.id===B.id),nn=g.findIndex(be=>be.id===z.id),qe=le.arrayMove(g,tn,nn);p(qe),c(qe)}S(void 0)};return N||((g==null?void 0:g.length)??0)>0?s.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Attachments",disabled:ye,enterDelay:500,triggerElement:s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(i.Flyout,{placement:i.FlyoutPlacement.BottomRight,onOpenChange:y=>se(Q?!0:y),isOpen:ye,hug:!1,fitContent:!0,legacyFooter:!1,trigger:s.jsx(u,{isFlyoutOpen:ye,children:s.jsx("div",{children:e.length>0?e.length:"Add"})}),children:s.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[g.length>0&&s.jsxs(P.DndContext,{sensors:k,collisionDetection:P.closestCenter,onDragStart:Zt,onDragEnd:en,modifiers:[sn.restrictToWindowEdges],children:[s.jsx(le.SortableContext,{items:g,strategy:le.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line",children:g.map(y=>s.jsx(kn,{isEditing:N,isLoading:R.includes(y.id),item:y,onDelete:()=>t(y),onReplaceWithBrowse:()=>$e(y),onReplaceWithUpload:B=>We(y,B),onDownload:()=>d.dispatch({name:"downloadAsset",payload:y})},y.id))})}),s.jsx(P.DragOverlay,{children:Q&&s.jsx(Be,{isOverlay:!0,isEditing:N,item:Q,isDragging:!0,onDelete:()=>t(Q),onReplaceWithBrowse:()=>$e(Q),onReplaceWithUpload:y=>We(Q,y)},j)})]}),N&&s.jsxs("div",{className:"tw-px-5 tw-py-3",children:[s.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),s.jsx(i.AssetInput,{isLoading:A,size:i.AssetInputSize.Small,onUploadClick:y=>F(y),onLibraryClick:Jt})]})]})})})}):null},nt=(e,t)=>{const{blockAssets:n,updateAssetIdsFromKey:r}=V.useBlockAssets(e),a=(n==null?void 0:n[t])||[];return{onAttachmentsAdd:async f=>{const h=a.map(g=>g.id);for(const g of f)h.push(g.id);await r(t,h)},onAttachmentDelete:async f=>{const h=a.filter(g=>g.id!==f.id).map(g=>g.id);await r(t,h)},onAttachmentReplace:async(f,h)=>{const g=a.map(p=>p.id===f.id?h.id:p.id);await r(t,g)},onAttachmentsSorted:async f=>{const h=f.map(g=>g.id);await r(t,h)},attachments:a,appBridge:e}},st=x.createContext(null),rt=({appBridge:e,children:t,assetId:n})=>{const r=nt(e,n);return s.jsx(st.Provider,{value:r,children:t})},at=()=>{const e=x.useContext(st);if(!e)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return e},Pn=(e,t)=>{const n=r=>s.jsx(rt,{appBridge:r.appBridge,assetId:t,children:s.jsx(e,{...r})});return n.displayName="withAttachmentsProvider",n},En=[P.KeyboardCode.Down,P.KeyboardCode.Right,P.KeyboardCode.Up,P.KeyboardCode.Left],it=(e,t)=>(n,{currentCoordinates:r,context:{activeNode:a}})=>{if(n.preventDefault(),En.includes(n.code)){const l=(a==null?void 0:a.offsetWidth)??0,c=(a==null?void 0:a.offsetHeight)??0;switch(n.code){case P.KeyboardCode.Right:return{...r,x:r.x+l+e};case P.KeyboardCode.Left:return{...r,x:r.x-l-e};case P.KeyboardCode.Down:return{...r,y:r.y+c+t};case P.KeyboardCode.Up:return{...r,y:r.y-c-t}}}},In={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},Tn=(e=0,t=0)=>{const n=it(e,t);return P.useSensors(P.useSensor(P.PointerSensor),P.useSensor(P.KeyboardSensor,{coordinateGetter:n,keyboardCodes:In}))},ce=(e,t)=>{const n=[i.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded","tw-text-xs tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return t?n.push("tw-bg-box-neutral-pressed","tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed","tw-text-text-weak hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),U(n)},Bn=({children:e,isFlyoutOpen:t})=>s.jsxs("div",{className:ce("pointer",t),children:[s.jsx(i.IconPaperclip16,{}),e,s.jsx(i.IconCaretDown12,{})]}),jn=({isOpen:e,onOpenChange:t})=>{const{appBridge:n,attachments:r,onAttachmentsAdd:a,onAttachmentDelete:l,onAttachmentReplace:c,onAttachmentsSorted:d}=at();return s.jsx(tt,{onUpload:a,onDelete:l,onReplaceWithBrowse:c,onReplaceWithUpload:c,onSorted:d,onBrowse:a,items:r,appBridge:n,triggerComponent:Bn,isOpen:e,onOpenChange:t})},ot=({items:e,flyoutMenu:t,attachments:n,isDragging:r})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[n.isEnabled&&s.jsx(Ke,{children:s.jsx(jn,{isOpen:n.isOpen&&!r,onOpenChange:n.onOpenChange})}),s.jsxs(Ke,{children:[e.map((a,l)=>"draggableProps"in a?s.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,open:r,position:i.TooltipPosition.Top,content:s.jsx("div",{children:r?et:a.tooltip??Ze}),triggerElement:s.jsx("button",{ref:a.setActivatorNodeRef,"data-test-id":"block-item-wrapper-toolbar-btn",...a.draggableProps,className:ce("grab",r),children:a.icon})},l):s.jsx(i.LegacyTooltip,{withArrow:!0,enterDelay:300,hoverDelay:0,disabled:r,position:i.TooltipPosition.Top,content:s.jsx("div",{children:a.tooltip??""}),triggerElement:s.jsx("button",{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:a.onClick,className:ce("pointer"),children:a.icon})},l)),t.items.length>0&&s.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,disabled:r||t.isOpen,position:i.TooltipPosition.Top,content:s.jsx("div",{children:"Options"}),triggerElement:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsx(i.Flyout,{isOpen:t.isOpen&&!r,legacyFooter:!1,fitContent:!0,hug:!1,onOpenChange:t.onOpenChange,trigger:s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-flyout",className:ce("pointer",t.isOpen&&!r),children:s.jsx(i.IconDotsHorizontal16,{})}),children:s.jsx(i.ActionMenu,{menuBlocks:t.items.map((a,l)=>({id:l.toString(),menuItems:a.map((c,d)=>({id:l.toString()+d.toString(),size:i.MenuItemContentSize.XSmall,title:c.title,style:c.style,onClick:()=>{t.onOpenChange(!1),c.onClick()},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:c.icon})}))}))})})})})]})]}),Ln=({children:e,toolbarFlyoutItems:t,toolbarItems:n,shouldHideWrapper:r,shouldHideComponent:a=!1,isDragging:l,shouldFillContainer:c,outlineOffset:d=2,shouldBeShown:u=!1,showAttachments:f=!1})=>{const[h,g]=x.useState(u),[p,v]=x.useState(!1),b=x.useRef(null);if(r)return s.jsx(s.Fragment,{children:e});const k=n==null?void 0:n.filter(S=>S!==void 0),j=h||p||u;return s.jsxs("div",{ref:b,"data-test-id":"block-item-wrapper",style:{outlineOffset:d},className:U(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",c&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",j&&"tw-outline",a&&"tw-opacity-0"]),children:[s.jsx("div",{style:{right:-1-d,bottom:`calc(100% - ${2+d}px)`},className:U(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",j&&"tw-opacity-100"]),children:s.jsx(ot,{flyoutMenu:{items:t,isOpen:h,onOpenChange:g},attachments:{isEnabled:f,isOpen:p,onOpenChange:v},items:k,isDragging:l})}),e]})},Nn=({onDownload:e})=>{const{isFocused:t,focusProps:n}=rn.useFocusRing();return s.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Download",enterDelay:500,triggerElement:s.jsx("button",{tabIndex:0,"aria-label":"Download",...n,className:U(["tw-outline-none tw-rounded",t&&i.FOCUS_STYLE]),onClick:e,onPointerDown:r=>r.preventDefault(),children:s.jsx("span",{"data-test-id":"download-button",className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:s.jsx(i.IconArrowCircleDown16,{})})})})},An=({value:e="",gap:t,columns:n,show:r=!0,plugins:a})=>{const[l,c]=x.useState(null);return x.useEffect(()=>{(async()=>c(await i.serializeRawToHtmlAsync(e,a,n,t)))()},[e,n,t,a]),!r||l==="<br />"?null:l!==null?s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:l}}):s.jsx("div",{className:"tw-rounded-sm tw-bg-base-alt tw-animate-pulse tw-h-full tw-min-h-[10px] tw-w-full"})},lt=e=>{if(!e)return!1;const t=n=>n.some(r=>r.text?r.text!=="":r.children?t(r.children):!1);try{const n=JSON.parse(e);return t(n)}catch{return!1}},Rn=(e="p",t="",n)=>lt(t)?t:JSON.stringify([{type:e,children:[{text:t,textStyle:e}],align:n}]),Fn=(e,t,n)=>e===K.Custom?t:n,Mn=e=>e.map(ct),ct=e=>({id:e.id,title:e.name,colors:e.colors.map(t=>({alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}))}),je=(e,t)=>{const n=o.getAboveNode(e,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},ut=e=>je(e,t=>{var n,r;return((r=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:r.link)||""}),dt=e=>je(e,t=>t.url||""),gt=e=>{var t,n;return e.url||((n=(t=e.chosenLink)==null?void 0:t.searchResult)==null?void 0:n.link)||""},mt=e=>je(e,gt),Le=/^\/(document|r)\/\S+$/i,fe=e=>{if(Le.test(e))return e;try{return new URL(e),e}catch{return`https://${e}`}},pe=e=>{if(Le.test(e))return!0;try{const t=new URL(e);return["http:","https:","mailto:","tel:"].includes(t.protocol)&&t.pathname!==""}catch{return!1}},ee=e=>pe(fe(e))||e==="",ht=(e,{type:t})=>{const{apply:n,normalizeNode:r}=e;return e.apply=a=>{if(a.type!=="set_selection"){n(a);return}const l=a.newProperties;if(!(l!=null&&l.focus)||!l.anchor||!o.isCollapsed(l)){n(a);return}const c=o.getAboveNode(e,{at:l,match:{type:o.getPluginType(e,C)}});if(c){const[,d]=c;let u;o.isStartPoint(e,l.focus,d)&&(u=o.getPreviousNodeEndPoint(e,d)),o.isEndPoint(e,l.focus,d)&&(u=o.getNextNodeStartPoint(e,d)),u&&(a.newProperties={anchor:u,focus:u})}n(a)},e.normalizeNode=([a,l])=>{if(a.type===o.getPluginType(e,C)){const c=e.selection;if(c&&o.isCollapsed(c)&&o.isEndPoint(e,c.focus,l)){const d=o.getNextNodeStartPoint(e,l);if(d)o.select(e,d);else{const u=on.Path.next(l);o.insertNodes(e,{text:""},{at:u}),o.select(e,u)}}}r([a,l])},o.withRemoveEmptyNodes(e,o.mockPlugin({options:{types:t}}))},ft=(e,t,n)=>{o.insertNodes(e,[yt(e,t)],n)},Ne=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(e=>({reset:()=>{e.url(""),e.text(""),e.buttonStyle("primary"),e.newTab(!1),e.mode(""),e.isEditing(!1)}})).extendActions(e=>({show:(t,n)=>{e.mode(t),e.isEditing(!1),e.openEditorId(n)},hide:()=>{e.reset(),e.openEditorId(null)}})).extendSelectors(e=>({isOpen:t=>e.openEditorId===t})),E=Ne.set,L=Ne.get,te=()=>Ne.use,Ae=e=>{if(!e.selection)return;const{isUrl:t,forceSubmit:n}=o.getPluginOptions(e,C),r=L.url();if(!((t==null?void 0:t(r))||n))return;const l=L.text(),c=L.buttonStyle(),d=L.newTab()?void 0:"_self";return E.hide(),pt(e,{url:r,text:l,buttonStyle:c,target:d,isUrl:u=>n||!t?!0:t(u)}),setTimeout(()=>{o.focusEditor(e,e.selection??void 0)},0),!0},ne=(e,t)=>o.withoutNormalizing(e,()=>{var n,r,a,l,c,d;if(t!=null&&t.split){if(o.getAboveNode(e,{at:(n=e.selection)==null?void 0:n.anchor,match:{type:o.getPluginType(e,C)}}))return o.splitNodes(e,{at:(r=e.selection)==null?void 0:r.anchor,match:h=>o.isElement(h)&&h.type===o.getPluginType(e,C)}),ne(e,{at:(a=e.selection)==null?void 0:a.anchor}),!0;if(o.getAboveNode(e,{at:(l=e.selection)==null?void 0:l.focus,match:{type:o.getPluginType(e,C)}}))return o.splitNodes(e,{at:(c=e.selection)==null?void 0:c.focus,match:h=>o.isElement(h)&&h.type===o.getPluginType(e,C)}),ne(e,{at:(d=e.selection)==null?void 0:d.focus}),!0}o.unwrapNodes(e,{match:{type:o.getPluginType(e,C)},...t})}),pt=(e,{url:t,text:n,buttonStyle:r,target:a,insertTextInButton:l,insertNodesOptions:c,isUrl:d=o.getPluginOptions(e,C).isUrl})=>{var S;const u=e.selection;if(!u)return;const f=o.getAboveNode(e,{at:u,match:{type:o.getPluginType(e,C)}});if(l&&f)return e.insertText(t),!0;if(!(d!=null&&d(t)))return;if(o.isDefined(n)&&n.length===0&&(n=t),f)return Un(t,e,f,a,r,n),!0;const h=o.findNode(e,{at:u,match:{type:o.getPluginType(e,C)}}),[g,p]=h??[],v=On(e,p,n);if(o.isExpanded(u))return Dn(f,e,t,r,a,n),!0;v&&o.removeNodes(e,{at:p});const b=o.getNodeProps(g??{}),k=(S=e.selection)==null?void 0:S.focus.path;if(!k)return;const j=o.getNodeLeaf(e,k);return n!=null&&n.length||(n=t),ft(e,{...b,url:t,target:a,children:[{...j,text:n}]},c),!0};function On(e,t,n){return t&&(n==null?void 0:n.length)&&n!==o.getEditorString(e,t)}function Dn(e,t,n,r,a,l){e?ne(t,{at:e[1]}):ne(t,{split:!0}),xt(t,{url:n,buttonStyle:r,target:a}),Re(t,{url:n,target:a,text:l})}function Un(e,t,n,r,a,l){var c,d,u;(e!==((c=n[0])==null?void 0:c.url)||r!==((d=n[0])==null?void 0:d.target)||a!==((u=n[0])==null?void 0:u.buttonStyle))&&o.setNodes(t,{url:e,target:r,buttonStyle:a},{at:n[1]}),Re(t,{url:e,text:l,target:r})}const Re=(e,{text:t})=>{const n=o.getAboveNode(e,{match:{type:o.getPluginType(e,C)}});if(n){const[r,a]=n;if(t!=null&&t.length&&t!==o.getEditorString(e,a)){const l=r.children[0];o.replaceNodeChildren(e,{at:a,nodes:{...l,text:t},insertOptions:{select:!0}})}}},xt=(e,{url:t,buttonStyle:n,target:r,...a})=>{o.wrapNodes(e,{type:o.getPluginType(e,C),url:t,buttonStyle:n,target:r,children:[]},{split:!0,...a})},Hn=(e,t)=>{const n=o.getAboveNode(e,{match:{type:C}});return Array.isArray(n)?t(n[0]):""},wt=e=>Hn(e,t=>t.url??""),yt=(e,{url:t,text:n="",buttonStyle:r="primary",target:a,children:l})=>({type:o.getPluginType(e,C),url:t,target:a,buttonStyle:r,children:l??[{text:n}]}),bt=(e,{focused:t}={})=>{if(L.mode()==="edit"){xe(e);return}Fe(e,{focused:t})},xe=e=>{const t=o.findNode(e,{match:{type:o.getPluginType(e,C)}});if(!t)return;const[n,r]=t;let a=o.getEditorString(e,r);E.url(n.url),E.newTab(n.target===void 0),a===n.url&&(a=""),E.text(a),E.isEditing(!0)},Fe=(e,{focused:t}={})=>{L.mode()||!t||o.isRangeAcrossBlocks(e,{at:e.selection})||o.someNode(e,{match:{type:o.getPluginType(e,C)}})||(E.text(o.getEditorString(e,e.selection)),E.show("insert",e.id))},we={buttonPrimary:{fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",marginTop:"10px",marginBottom:"10px",display:"inline-block",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",display:"inline-block",marginTop:"10px",marginBottom:"10px",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",display:"inline-block",marginTop:"10px",marginBottom:"10px",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},_n=e=>({...o.useElementProps({...e,elementToAttributes:n=>({url:n.href,buttonStyle:n.buttonStyle||"primary",target:n.target||"_blank"})}),onMouseOver:n=>{n.stopPropagation()}}),Vn=e=>{const{href:t,target:n,buttonStyle:r}=_n(e),{attributes:a,children:l}=e;return s.jsx(zn,{attributes:a,href:t,target:n,styles:we[`button${r.charAt(0).toUpperCase()+r.slice(1)}`],children:l})},zn=({attributes:e,styles:t={hover:{}},children:n,href:r="#",target:a})=>{const[l,c]=x.useState(!1);return s.jsx("a",{...e,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:r,target:a,style:l?{...t,...t.hover}:t,children:n})};class $n extends i.MarkupElement{constructor(t=C,n=Vn){super(t,n)}}const Wn=({type:e,...t})=>{const n=o.useEditorRef(),r=!!o.isRangeInSameBlock(n,{at:n.selection}),a=!!(n!=null&&n.selection)&&o.someNode(n,{match:{type:e}});return s.jsx(o.ToolbarButton,{tooltip:i.getTooltip(r?`Button
2
- ${i.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block."),classNames:i.getButtonClassNames(r),active:a,onMouseDown:async l=>{n&&(l.preventDefault(),l.stopPropagation(),o.focusEditor(n,n.selection??n.prevSelection??void 0),setTimeout(()=>{bt(n,{focused:!0})},0))},...t})},qn=({editor:e,id:t})=>s.jsx("div",{"data-plugin-id":t,children:s.jsx(Wn,{type:o.getPluginType(e,C),icon:s.jsx("span",{className:"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex",children:s.jsx(i.IconButton16,{})}),styles:i.buttonStyles})}),Gn=()=>{const e=ms({});return s.jsx("div",{"data-test-id":"floating-button-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:s.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[s.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(de.EditButton,{children:s.jsx(i.IconPen16,{})})}),s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(de.UnlinkButton,{children:s.jsx(i.IconTrashBin16,{})})})]})]})})},Kn=({section:e,selectedUrl:t,onSelectUrl:n})=>{const r=e.permanentLink===t;return s.jsx("button",{"data-test-id":"internal-link-selector-section-link",className:i.merge(["tw-py-2 tw-px-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",r?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[s.jsx(i.IconDocumentText16,{}),s.jsx("span",{className:"tw-text-s",children:e.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},Xn=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,appBridge:a})=>{const[l,c]=x.useState(e.id===r.documentId),d=e.permanentLink===t,{documentSections:u}=V.useDocumentSection(a,e.id),f=[...u.values()],h=f.length>0;return x.useEffect(()=>{e.id===r.pageId&&c(!0)},[r,e.id]),s.jsxs(s.Fragment,{children:[s.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:i.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",h?"tw-pl-7":"tw-pl-12",d?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[h&&s.jsx("button",{"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!l),children:s.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",l?"tw-rotate-90":""])})}),s.jsx("span",{className:"tw-text-s",children:e.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),l&&f.length>0&&f.map(g=>s.jsx(Kn,{section:g,selectedUrl:t,onSelectUrl:n},g.id))]})},vt=()=>s.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:s.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small})}),Qn=({appBridge:e,documentId:t,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a})=>{const[l,c]=x.useState([]),[d,u]=x.useState(!0),f=[...l.values()],h=!d&&f.length>0;return x.useEffect(()=>{e.getDocumentPagesByDocumentId(t).then(g=>{const p=g.filter(b=>!!b.category).sort((b,k)=>b.category.sort===k.category.sort?b.sort-k.sort:b.category.sort-k.category.sort),v=g.filter(b=>!b.category).sort((b,k)=>b.sort-k.sort);c([...p,...v])}).finally(()=>{u(!1)})},[]),d?s.jsx(vt,{}):h?s.jsx(s.Fragment,{children:f.map(g=>s.jsx(Xn,{page:g,appBridge:e,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a},g.id))}):s.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},Yn=({document:e,appBridge:t,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a})=>{const[l,c]=x.useState(e.id===a.documentId),d=e.permanentLink===n;return x.useEffect(()=>{e.id===a.documentId&&c(!0)},[a,e.id]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:i.merge(["tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full",d?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>r(e.permanentLink),children:[s.jsx("button",{role:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!l),children:s.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",l?"tw-rotate-90":""])})}),s.jsx(i.IconColorFan16,{}),s.jsx("span",{className:"tw-text-s",children:e.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),l&&s.jsx(Qn,{appBridge:t,documentId:e.id,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a})]})},Jn=({appBridge:e,selectedUrl:t,onSelectUrl:n})=>{const[r,a]=x.useState(!0),[l,c]=x.useState([]),[d,u]=x.useState({documentId:void 0,pageId:void 0}),f=[...l.values()];x.useEffect(()=>{t&&f.length>0&&h().then(g=>{u(g)})},[f.length]),x.useEffect(()=>{e.getAllDocuments().then(g=>{c(g)}).finally(()=>{a(!1)})},[]);const h=async()=>{const g={documentId:void 0,pageId:void 0};if(f.find(v=>v.permanentLink===t))return g;for(const v of f){const b=await e.getDocumentPagesByDocumentId(v.id);e.getAllDocuments();const k=[...b.values()];if(!!k.find(S=>S.permanentLink===t))return g.documentId=v.id,g;for(const S of k)if(!![...(await e.getDocumentSectionsByDocumentPageId(S.id)).values()].find(H=>H.permanentLink===t))return g.documentId=v.id,g.pageId=S.id,g}return g};return r?s.jsx(vt,{}):s.jsx(s.Fragment,{children:f.map(g=>s.jsx(Yn,{document:g,appBridge:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:d},g.id))})},Ct=({appBridge:e,url:t,onUrlChange:n,buttonSize:r=i.ButtonSize.Medium})=>{const{open:a,isOpen:l,close:c}=an.useOverlayTriggerState({}),[d,u]=x.useState(t),f=p=>{u(p)},h=p=>{p.key==="Enter"&&g()};x.useEffect(()=>{t&&!d&&u(t)},[t,d]);const g=()=>{n==null||n(d),c()};return s.jsxs("div",{"data-test-id":"internal-link-selector",onKeyDown:h,children:[s.jsx(i.Button,{icon:s.jsx(i.IconLink,{}),size:r,type:i.ButtonType.Button,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,onClick:()=>a(),children:"Internal link"}),s.jsxs(i.Modal,{zIndex:1001,onClose:()=>c(),isOpen:l,isDismissable:!0,children:[s.jsx(i.Modal.Header,{title:"Select internal link"}),s.jsx(i.Modal.Body,{children:s.jsx(Jn,{appBridge:e,selectedUrl:d,onSelectUrl:f})}),s.jsx(i.Modal.Footer,{buttons:[{children:"Cancel",onClick:()=>c(),style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default},{children:"Choose",onClick:p=>{p==null||p.preventDefault(),g()},style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Strong,disabled:!d}]})]})]})},kt=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:r,clearable:a,placeholder:l,newTab:c,openInNewTab:d,url:u="",required:f,info:h,label:g,buttonSize:p,hideInternalLinkButton:v})=>{const b=n?n(u):ee(u),k=c??(d?i.CheckboxState.Checked:i.CheckboxState.Unchecked);return s.jsxs("div",{"data-test-id":"link-input",children:[s.jsx(i.FormControl,{label:{children:g,htmlFor:"url",required:f,tooltip:h?{content:h,position:i.TooltipPosition.Top}:void 0},children:s.jsx(i.TextInput,{id:"url",value:u,clearable:a,onChange:e,placeholder:l??"https://example.com",focusOnMount:!0})}),!b&&s.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!v&&s.jsx("div",{className:"tw-mt-3",children:s.jsx(Ct,{url:u,appBridge:r,onUrlChange:e,buttonSize:p??i.ButtonSize.Medium})}),s.jsx("div",{className:"tw-mt-3",children:s.jsx(i.Checkbox,{value:"new-tab",label:"Open in new tab",state:k,onChange:t})})]})},St=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:r,onCancel:a,onSave:l,isValidUrlOrEmpty:c,hasValues:d,testId:u,appBridge:f,children:h})=>s.jsxs("div",{"data-test-id":u,className:"tw-bg-white tw-rounded tw-shadow tw-p-7 tw-min-w-[400px] tw-overflow-y-auto",children:[s.jsx(i.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:s.jsx(i.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:t})}),h,s.jsx("div",{className:"tw-mt-5",children:s.jsx(kt,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:c,appBridge:f})}),s.jsx("div",{className:"tw-mt-3",children:s.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[s.jsx(i.Button,{onClick:a,size:i.ButtonSize.Medium,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,children:"Cancel"}),s.jsx(i.Button,{onClick:l,size:i.ButtonSize.Medium,icon:s.jsx(i.IconCheckMark20,{}),disabled:!d||!c(e==null?void 0:e.url),children:"Save"})]})})]}),Zn=e=>{var n;const t=o.getAboveNode(e,{match:{type:C}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},es={url:"",text:"",buttonStyle:"primary",newTab:i.CheckboxState.Unchecked},ts=()=>{const[e,t]=x.useReducer((n,r)=>{const{type:a,payload:l}=r;switch(a){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...l};default:return n}},es);return[e,t]},ns=()=>{const e=o.useEditorRef(),[t,n]=ts();x.useEffect(()=>{const g=Zn(e);n({type:"INIT",payload:{text:L.text(),buttonStyle:g,newTab:L.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:L.url()}})},[n,e]);const r=g=>{n({type:"TEXT",payload:{text:g}})},a=g=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:g}})},l=g=>{n({type:"URL",payload:{url:g}})},c=g=>{n(g?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{E.hide()},u=g=>{if(!ee(t.url)||!f)return;const p=fe(t.url);E.text(t.text),E.url(p),E.buttonStyle(t.buttonStyle),E.newTab(t.newTab===i.CheckboxState.Checked),Ae(e)&&(g==null||g.preventDefault())},f=t.url!==""&&t.text!=="",{appBridge:h}=o.getPluginOptions(e,C);return o.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onButtonStyleChange:a,onUrlChange:l,onToggleTab:c,onCancel:d,onSave:u,hasValues:f,isValidUrlOrEmpty:ee,appBridge:h}},ue="link-plugin";var w=(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))(w||{});const T={heading1:{fontSize:"var(--f-theme-settings-heading1-font-size)",lineHeight:"var(--f-theme-settings-heading1-line-height)",marginTop:"var(--f-theme-settings-heading1-margin-top)",marginBottom:"var(--f-theme-settings-heading1-margin-bottom)",textDecoration:"var(--f-theme-settings-heading1-text-decoration)",fontStyle:"var(--f-theme-settings-heading1-font-style)",textTransform:"var(--f-theme-settings-heading1-text-transform)",letterSpacing:"var(--f-theme-settings-heading1-letter-spacing)",fontWeight:"var(--f-theme-settings-heading1-font-weight)",fontFamily:"var(--f-theme-settings-heading1-font-family)",color:"var(--f-theme-settings-heading1-color)"},heading2:{fontSize:"var(--f-theme-settings-heading2-font-size)",lineHeight:"var(--f-theme-settings-heading2-line-height)",marginTop:"var(--f-theme-settings-heading2-margin-top)",marginBottom:"var(--f-theme-settings-heading2-margin-bottom)",textDecoration:"var(--f-theme-settings-heading2-text-decoration)",fontStyle:"var(--f-theme-settings-heading2-font-style)",textTransform:"var(--f-theme-settings-heading2-text-transform)",letterSpacing:"var(--f-theme-settings-heading2-letter-spacing)",fontWeight:"var(--f-theme-settings-heading2-font-weight)",fontFamily:"var(--f-theme-settings-heading2-font-family)",color:"var(--f-theme-settings-heading2-color)"},heading3:{fontSize:"var(--f-theme-settings-heading3-font-size)",lineHeight:"var(--f-theme-settings-heading3-line-height)",marginTop:"var(--f-theme-settings-heading3-margin-top)",marginBottom:"var(--f-theme-settings-heading3-margin-bottom)",textDecoration:"var(--f-theme-settings-heading3-text-decoration)",fontStyle:"var(--f-theme-settings-heading3-font-style)",textTransform:"var(--f-theme-settings-heading3-text-transform)",letterSpacing:"var(--f-theme-settings-heading3-letter-spacing)",fontWeight:"var(--f-theme-settings-heading3-font-weight)",fontFamily:"var(--f-theme-settings-heading3-font-family)",color:"var(--f-theme-settings-heading3-color)"},heading4:{fontSize:"var(--f-theme-settings-heading4-font-size)",lineHeight:"var(--f-theme-settings-heading4-line-height)",marginTop:"var(--f-theme-settings-heading4-margin-top)",marginBottom:"var(--f-theme-settings-heading4-margin-bottom)",textDecoration:"var(--f-theme-settings-heading4-text-decoration)",fontStyle:"var(--f-theme-settings-heading4-font-style)",textTransform:"var(--f-theme-settings-heading4-text-transform)",letterSpacing:"var(--f-theme-settings-heading4-letter-spacing)",fontWeight:"var(--f-theme-settings-heading4-font-weight)",fontFamily:"var(--f-theme-settings-heading4-font-family)",color:"var(--f-theme-settings-heading4-color)"},custom1:{fontSize:"var(--f-theme-settings-custom1-font-size)",lineHeight:"var(--f-theme-settings-custom1-line-height)",marginTop:"var(--f-theme-settings-custom1-margin-top)",marginBottom:"var(--f-theme-settings-custom1-margin-bottom)",textDecoration:"var(--f-theme-settings-custom1-text-decoration)",fontStyle:"var(--f-theme-settings-custom1-font-style)",textTransform:"var(--f-theme-settings-custom1-text-transform)",letterSpacing:"var(--f-theme-settings-custom1-letter-spacing)",fontWeight:"var(--f-theme-settings-custom1-font-weight)",fontFamily:"var(--f-theme-settings-custom1-font-family)",color:"var(--f-theme-settings-custom1-color)"},custom2:{fontSize:"var(--f-theme-settings-custom2-font-size)",lineHeight:"var(--f-theme-settings-custom2-line-height)",marginTop:"var(--f-theme-settings-custom2-margin-top)",marginBottom:"var(--f-theme-settings-custom2-margin-bottom)",textDecoration:"var(--f-theme-settings-custom2-text-decoration)",fontStyle:"var(--f-theme-settings-custom2-font-style)",textTransform:"var(--f-theme-settings-custom2-text-transform)",letterSpacing:"var(--f-theme-settings-custom2-letter-spacing)",fontWeight:"var(--f-theme-settings-custom2-font-weight)",fontFamily:"var(--f-theme-settings-custom2-font-family)",color:"var(--f-theme-settings-custom2-color)"},custom3:{fontSize:"var(--f-theme-settings-custom3-font-size)",lineHeight:"var(--f-theme-settings-custom3-line-height)",marginTop:"var(--f-theme-settings-custom3-margin-top)",marginBottom:"var(--f-theme-settings-custom3-margin-bottom)",textDecoration:"var(--f-theme-settings-custom3-text-decoration)",fontStyle:"var(--f-theme-settings-custom3-font-style)",textTransform:"var(--f-theme-settings-custom3-text-transform)",letterSpacing:"var(--f-theme-settings-custom3-letter-spacing)",fontWeight:"var(--f-theme-settings-custom3-font-weight)",fontFamily:"var(--f-theme-settings-custom3-font-family)",color:"var(--f-theme-settings-custom3-color)"},p:{fontSize:"var(--f-theme-settings-body-font-size)",lineHeight:"var(--f-theme-settings-body-line-height)",marginTop:"var(--f-theme-settings-body-margin-top)",marginBottom:"var(--f-theme-settings-body-margin-bottom)",textDecoration:"var(--f-theme-settings-body-text-decoration)",fontStyle:"var(--f-theme-settings-body-font-style)",textTransform:"var(--f-theme-settings-body-text-transform)",letterSpacing:"var(--f-theme-settings-body-letter-spacing)",fontWeight:"var(--f-theme-settings-body-font-weight)",fontFamily:"var(--f-theme-settings-body-font-family)",color:"var(--f-theme-settings-body-color)"},quote:{fontSize:"var(--f-theme-settings-quote-font-size)",lineHeight:"var(--f-theme-settings-quote-line-height)",marginTop:"var(--f-theme-settings-quote-margin-top)",marginBottom:"var(--f-theme-settings-quote-margin-bottom)",textDecoration:"var(--f-theme-settings-quote-text-decoration)",fontStyle:"var(--f-theme-settings-quote-font-style)",textTransform:"var(--f-theme-settings-quote-text-transform)",letterSpacing:"var(--f-theme-settings-quote-letter-spacing)",fontWeight:"var(--f-theme-settings-quote-font-weight)",fontFamily:"var(--f-theme-settings-quote-font-family)",color:"var(--f-theme-settings-quote-color)"},imageCaption:{fontSize:"var(--f-theme-settings-image-caption-font-size)",lineHeight:"var(--f-theme-settings-image-caption-line-height)",marginTop:"var(--f-theme-settings-image-caption-margin-top)",marginBottom:"var(--f-theme-settings-image-caption-margin-bottom)",textDecoration:"var(--f-theme-settings-image-caption-text-decoration)",fontStyle:"var(--f-theme-settings-image-caption-font-style)",textTransform:"var(--f-theme-settings-image-caption-text-transform)",letterSpacing:"var(--f-theme-settings-image-caption-letter-spacing)",fontWeight:"var(--f-theme-settings-image-caption-font-weight)",fontFamily:"var(--f-theme-settings-image-caption-font-family)",color:"var(--f-theme-settings-image-caption-color)"},imageTitle:{fontSize:"var(--f-theme-settings-image-title-font-size)",lineHeight:"var(--f-theme-settings-image-title-line-height)",marginTop:"var(--f-theme-settings-image-title-margin-top)",marginBottom:"var(--f-theme-settings-image-title-margin-bottom)",textDecoration:"var(--f-theme-settings-image-title-text-decoration)",fontStyle:"var(--f-theme-settings-image-title-font-style)",textTransform:"var(--f-theme-settings-image-title-text-transform)",letterSpacing:"var(--f-theme-settings-image-title-letter-spacing)",fontWeight:"var(--f-theme-settings-image-title-font-weight)",fontFamily:"var(--f-theme-settings-image-title-font-family)",color:"var(--f-theme-settings-image-title-color)"},[ue]:{fontSize:"var(--f-theme-settings-link-font-size)",lineHeight:"var(--f-theme-settings-link-line-height)",marginTop:"var(--f-theme-settings-link-margin-top)",marginBottom:"var(--f-theme-settings-link-margin-bottom)",textDecoration:"var(--f-theme-settings-link-text-decoration)",fontStyle:"var(--f-theme-settings-link-font-style)",textTransform:"var(--f-theme-settings-link-text-transform)",letterSpacing:"var(--f-theme-settings-link-letter-spacing)",fontWeight:"var(--f-theme-settings-link-font-weight)",fontFamily:"var(--f-theme-settings-link-font-family)",color:"var(--f-theme-settings-link-color)"},...we},ss=()=>{const e=ns(),{state:t,onButtonStyleChange:n}=e;return s.jsx(St,{...e,testId:"floating-button-insert",children:s.jsx("div",{className:"tw-pt-5",children:s.jsxs(i.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[s.jsx(ve,{id:"primary",styles:T.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),s.jsx(ve,{id:"secondary",styles:T.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),s.jsx(ve,{id:"tertiary",styles:T.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},ve=({id:e,styles:t,isActive:n,onClick:r,children:a})=>{const[l,c]=x.useState(!1),d=()=>t&&t.hover&&l?{...t,...t.hover}:t;return s.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:r,style:{...d(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:a})},rs=()=>{const e=te().isEditing(),t=s.jsx(ss,{}),n=e?t:s.jsx(Gn,{});return s.jsxs(s.Fragment,{children:[s.jsx(de.InsertRoot,{children:t}),s.jsx(de.EditRoot,{children:n})]})},C="button",Pt="button-plugin",Et=e=>o.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:ht,renderAfterEditable:rs,options:{isUrl:pe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:e},then:(t,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class It extends i.Plugin{constructor({styles:t=we,...n}){super(Pt,{button:qn,markupElement:new $n,...n}),this.styles={},this.styles=t,this.appBridge=n==null?void 0:n.appBridge}plugins(){return[Et(this.appBridge)]}}const as=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=o.usePlateSelectors(n.id).keyEditor(),a=te().mode(),l=te().isOpen(n.id),{triggerFloatingButtonHotkeys:c}=o.getPluginOptions(n,C),d=x.useCallback(()=>{const p=o.getAboveNode(n,{match:{type:o.getPluginType(n,C)}});if(p){const[,v]=p;return o.getRangeBoundingClientRect(n,{anchor:o.getStartPoint(n,v),focus:o.getEndPoint(n,v)})}return o.getDefaultBoundingClientRect()},[n]),u=l&&a==="edit",{update:f,style:h,floating:g}=Bt({open:u,getBoundingClientRect:d,...e});return x.useEffect(()=>{const p=wt(n);if(p&&E.url(p),n.selection&&o.someNode(n,{match:{type:o.getPluginType(n,C)}})){E.show("edit",n.id),f();return}L.mode()==="edit"&&E.hide()},[n,r,f]),o.useHotkeys(c,p=>{p.preventDefault(),L.mode()==="edit"&&xe(n)},{enableOnContentEditable:!0},[]),hs(),Tt(),{style:{...h,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,g)}},is=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=Xe.useFocused(),a=te().mode(),l=te().isOpen(n.id),{triggerFloatingButtonHotkeys:c}=o.getPluginOptions(n,C);o.useHotkeys(c,h=>{h.preventDefault(),Fe(n,{focused:r})},{enableOnContentEditable:!0},[r]);const{update:d,style:u,floating:f}=Bt({open:l&&a==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return x.useEffect(()=>{l&&d(),E.updated(l)},[l,d]),Tt(),{style:{...u,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,f)}},os=e=>{const t=o.useEditorRef();return{onClick:x.useCallback(()=>{xe(t)},[t]),...e}},ls=o.createComponentAs(e=>{const t=os(e);return o.createElementAs("button",t)}),cs=e=>{const t=o.useEditorRef();return{onClick:x.useCallback(()=>{ne(t),o.focusEditor(t,t.selection??void 0)},[t]),...e}},us=o.createComponentAs(e=>{const t=cs(e);return o.createElementAs(o.Button,t)}),ds=o.createComponentAs(e=>{var n;const t=as(e);return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),gs=o.createComponentAs(e=>{var n;const t=is(e);return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),de={EditRoot:ds,InsertRoot:gs,EditButton:ls,UnlinkButton:us},ms=e=>{const t=te().updated(),n=x.useRef(null);x.useEffect(()=>{n.current&&t&&setTimeout(()=>{var a;(a=n.current)==null||a.focus()},0)},[t]);const r=x.useCallback(a=>{E.url(a.target.value)},[]);return o.mergeProps({onChange:r,defaultValue:L.url()},{...e,ref:o.useComposedRef(e.ref,n)})},hs=()=>{const e=o.useEditorRef();o.useHotkeys("*",t=>{t.key==="Enter"&&Ae(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Tt=()=>{const e=o.useEditorRef();o.useHotkeys("escape",()=>{if(L.mode()==="edit"){if(L.isEditing()){E.show("edit",e.id),o.focusEditor(e,e.selection??void 0);return}E.hide()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},fs=12,ps=-22,xs=96,Bt=e=>o.useVirtualFloating({placement:"bottom-start",middleware:[o.offset({mainAxis:fs,alignmentAxis:ps}),o.flip({padding:xs})],...e}),ws=({id:e="rte",isEditing:t,value:n,columns:r,gap:a,placeholder:l,plugins:c,onTextChange:d,showSerializedText:u})=>{const[f,h]=x.useState(!1),g=p=>{d&&p!==n&&d(p),h(!1)};return x.useEffect(()=>{const p=v=>(v.preventDefault(),v.returnValue="Unprocessed changes");return f&&window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[f]),t?s.jsx(i.RichTextEditor,{id:e,value:n,border:!1,placeholder:l,plugins:c,onValueChanged:()=>h(!0),onTextChange:g,hideExternalFloatingModals:p=>{L.isOpen(p)&&E.reset()}}):s.jsx(An,{value:n,columns:r,gap:a,show:u,plugins:c})},ys=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=Xe.useFocused(),a=o.useFloatingLinkSelectors().mode(),l=o.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:c}=o.getPluginOptions(n,o.ELEMENT_LINK);o.useHotkeys(c,h=>{o.triggerFloatingLinkInsert(n,{focused:r})&&h.preventDefault()},{enableOnContentEditable:!0},[r]);const{update:d,style:u,floating:f}=o.useVirtualFloatingLink({editorId:n.id,open:l&&a==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:()=>{},...e});return x.useEffect(()=>{l?(d(),o.floatingLinkActions.updated(!0)):o.floatingLinkActions.updated(!1)},[l,d]),o.useFloatingLinkEscape(),{style:{...u,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,f)}},bs=o.createComponentAs(e=>{var n;const t=ys({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),vs=o.createComponentAs(e=>{var n;const t=ks({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)});o.FloatingLink.EditRoot=vs;o.FloatingLink.InsertRoot=bs;const ge=o.FloatingLink,Cs=()=>{const e=o.useFloatingLinkUrlInput({});return s.jsx("div",{"data-test-id":"floating-link-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:s.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[s.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(ge.EditButton,{children:s.jsx(i.IconPen16,{})})}),s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(ge.UnlinkButton,{children:s.jsx(i.IconTrashBin16,{})})})]})]})})},ks=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=o.usePlateSelectors().keyEditor(),a=o.useFloatingLinkSelectors().mode(),l=o.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:c="command+k, ctrl+k"}=o.getPluginOptions(n,o.ELEMENT_LINK),d=x.useCallback(()=>{const p=o.getAboveNode(n,{match:{type:o.getPluginType(n,o.ELEMENT_LINK)}});if(p){const[,v]=p;return o.getRangeBoundingClientRect(n,{anchor:o.getStartPoint(n,v),focus:o.getEndPoint(n,v)})}return o.getDefaultBoundingClientRect()},[n]),u=l&&a==="edit",{update:f,style:h,floating:g}=o.useVirtualFloatingLink({editorId:n.id,open:u,getBoundingClientRect:d,...e});return x.useEffect(()=>{const p=mt(n);if(p&&o.floatingLinkActions.url(p),n.selection&&o.someNode(n,{match:{type:o.getPluginType(n,o.ELEMENT_LINK)}})){o.floatingLinkActions.show("edit",n.id),f();return}o.floatingLinkSelectors.mode()==="edit"&&o.floatingLinkActions.hide()},[n,r,f]),o.useHotkeys(c,p=>{p.preventDefault(),o.floatingLinkSelectors.mode()==="edit"&&o.triggerFloatingLinkEdit(n)},{enableOnContentEditable:!0},[]),o.useFloatingLinkEnter(),o.useFloatingLinkEscape(),{style:{...h,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,g)}},Ss={url:"",text:"",newTab:i.CheckboxState.Unchecked},Ps=()=>{const[e,t]=x.useReducer((n,r)=>{const{type:a,payload:l}=r;switch(a){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"INIT":return{...n,...l};default:return n}},Ss);return[e,t]},Es=()=>{const e=o.useEditorRef(),[t,n]=Ps();x.useEffect(()=>{const h=ut(e),g=dt(e);n({type:"INIT",payload:{text:o.floatingLinkSelectors.text(),newTab:o.floatingLinkSelectors.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:h&&g===""?h:o.floatingLinkSelectors.url()}})},[n,e]);const r=h=>{n({type:"TEXT",payload:{text:h}})},a=h=>{n({type:"URL",payload:{url:h}})},l=h=>{n(h?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{o.floatingLinkActions.hide()},d=h=>{if(!ee(t.url)||!u)return;const g=fe(t.url);o.floatingLinkActions.text(t.text),o.floatingLinkActions.url(g),o.floatingLinkActions.newTab(t.newTab===i.CheckboxState.Checked),o.submitFloatingLink(e)&&(h==null||h.preventDefault())},u=t.url!==""&&t.text!=="",{appBridge:f}=o.getPluginOptions(e,o.ELEMENT_LINK);return o.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onUrlChange:a,onToggleTab:l,onCancel:c,onSave:d,hasValues:u,isValidUrlOrEmpty:ee,appBridge:f}},Is=()=>s.jsx(St,{...Es(),testId:"floating-link-insert"}),Ts=({readOnly:e})=>{const t=o.useFloatingLinkSelectors().isEditing();if(e)return null;const n=s.jsx(Is,{}),r=t?n:s.jsx(Cs,{});return s.jsxs(s.Fragment,{children:[s.jsx(ge.InsertRoot,{children:n}),s.jsx(ge.EditRoot,{children:r})]})},Bs=({id:e,editorId:t})=>{const n=o.usePlateEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(o.LinkToolbarButton,{tooltip:i.getTooltip(r?`Link
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),i=require("@frontify/fondue"),x=require("react"),V=require("@frontify/app-bridge"),P=require("@dnd-kit/core"),sn=require("@dnd-kit/modifiers"),le=require("@dnd-kit/sortable"),rn=require("@react-aria/focus"),o=require("@udecode/plate"),Xe=require("slate-react"),an=require("@react-stately/overlays"),on=require("slate"),D=require("@ctrl/tinycolor");const U=e=>e.filter(Boolean).join(" "),ln=({onDrop:e,label:t,icon:n,secondaryLabel:r,isLoading:a,fillParentContainer:l,onAssetChooseClick:c,onUploadClick:d,withMenu:u=!0,onClick:f,validFileType:p,verticalLayout:g})=>{const[h,y]=x.useState(!1),[b,k]=x.useState(),j=x.useRef(null),[S,A]=x.useState(void 0),O=I=>{if(I.preventDefault(),y(!1),!R(I.dataTransfer.files)){A("Invalid"),setTimeout(()=>{A(void 0)},1e3);return}e==null||e(I.dataTransfer.files)},R=I=>{if(!p)return!0;for(let F=0;F<I.length;F++){const N=I[F].name.split(".").pop()??"";if(!V.FileExtensionSets[p].includes(N))return!1}return!0},H=I=>{if(!j.current||a)return;const{left:F,top:N}=j.current.getBoundingClientRect(),ie=I.clientX-F,oe=I.clientY-N;k([ie,oe])};return s.jsxs("button",{ref:j,"data-test-id":"block-inject-button",className:U(["tw-font-body tw-relative tw-text-sm tw-leading-4 tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",g?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",l?"tw-h-full":"tw-h-[72px]",h&&!a?"tw-border-dashed":"tw-border-solid",b&&"tw-bg-blank-state-pressed-inverse",h&&"tw-bg-blank-state-weak-inverse",S?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",a||b||h||S?"":"tw-text-text-weak hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",(h||b)&&!S?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:e?I=>{var F;if(y(!0),p==="Images")for(const N of Array.from(I.dataTransfer.items))(F=N==null?void 0:N.type)!=null&&F.startsWith("image/")?A(void 0):A("Invalid")}:void 0,onDragLeave:e?()=>{y(!1),A(void 0)}:void 0,onDrop:e?O:void 0,onClick:I=>{u&&H(I),f==null||f()},children:[a?s.jsx(i.LoadingCircle,{}):S?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(i.IconExclamationMarkTriangle,{}),S]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(t||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[t&&s.jsx("div",{className:"tw-font-medium",children:t}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),b&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:b[0],top:b[1]},children:s.jsx(i.Flyout,{onOpenChange:I=>!I&&k(void 0),isOpen:!0,fitContent:!0,hug:!1,legacyFooter:!1,trigger:s.jsx("div",{}),children:s.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[...d?[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Upload asset",onClick:()=>{d(),k(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconArrowCircleUp20,{})})}]:[],...c?[{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Browse asset",onClick:()=>{c(),k(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconImageStack20,{})})}]:[]]}]})})})]})},X=e=>{const t=r=>typeof r=="object"&&["red","green","blue"].every(l=>r.hasOwnProperty(l)),n=r=>{const a=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a}};return t(e)?n(e):e},cn=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),un=(e,t)=>{const n=cn(e)?X(e):e,r=new D.TinyColor(n);return t?r.getBrightness()<t:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},dn=e=>new D.TinyColor(X(e)).toHex8String(),gn=e=>new D.TinyColor(X(e)).toHexString(),Te=e=>new D.TinyColor(X(e)).toRgbString(),mn=(e,t)=>new D.TinyColor(t).setAlpha(e).toRgbString(),hn=e=>{const{r:t,g:n,b:r,a}=new D.TinyColor(e);return{red:t,green:n,blue:r,alpha:a}},Ge=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),fn=(e,t)=>{const n=Ge(e)?X(e):e,r=Ge(t)?X(t):t;let a=new D.TinyColor(n);const l=new D.TinyColor(r);for(;D.readability(a,l)<4.5;)a=a.darken(1);return a.toRgbString()},pn=(e,t,n)=>{const r=[...e],a=n<0?r.length+n:n;if(a>=0&&a<r.length){const l=r.splice(t,1)[0];r.splice(a,0,l)}return r},xn=e=>({backgroundColor:Te(e)});var M=(e=>(e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted",e))(M||{});const Qe={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var _=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(_||{});const G={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var $=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))($||{});const Y={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var W=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(W||{});const J={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var K=(e=>(e.Global="Global",e.Custom="Custom",e))(K||{}),q=(e=>(e.Auto="Auto",e.S="S",e.M="M",e.L="L",e))(q||{});const Ye={Auto:"4px",S:"10px",M:"30px",L:"50px"},wn={red:241,green:241,blue:241,alpha:1},Je={red:234,green:235,blue:235,alpha:1},yn="1px",re="24px",ae="24px",bn=(e=M.Solid,t="1px",n=Je)=>({borderStyle:Qe[e],borderWidth:t,borderColor:Te(n)}),vn=(e,t=!1,n)=>({borderRadius:t?n:G[e]}),Ze="Drag or press ↵ to move",et="Move with ↑↓←→ and confirm with ↵",Ke=({children:e})=>s.jsx("div",{className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:e}),Cn=e=>e==="IMAGE"?s.jsx(i.IconImage24,{}):e==="VIDEO"?s.jsx(i.IconPlayFrame24,{}):e==="AUDIO"?s.jsx(i.IconMusicNote24,{}):s.jsx(i.IconDocument24,{}),Be=x.forwardRef(({item:e,isEditing:t,transformStyle:n,isDragging:r,isOverlay:a,isLoading:l,onDelete:c,onReplaceWithBrowse:d,onReplaceWithUpload:u,onDownload:f},p)=>{const[g,h]=x.useState(),[y,{selectedFiles:b}]=V.useFileInput({multiple:!0,accept:"image/*"}),[k,{results:j,doneAll:S}]=V.useAssetUpload();x.useEffect(()=>{b&&k(b[0])},[b]),x.useEffect(()=>{S&&u(j[0])},[S,j]);const A=l||b&&!S;return s.jsxs("button",{"aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>f==null?void 0:f(),ref:p,style:{...n,opacity:r&&!a?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:U(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-box-neutral-hover",r?"tw-bg-box-neutral-hover":""]),children:[s.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:A?s.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small}):Cn(e.objectType)}),s.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:e.title}),s.jsx("div",{className:"tw-text-text-weak",children:`${e.fileSizeHumanReadable} - ${e.extension}`})]}),t&&s.jsx("div",{"data-test-id":"attachments-actionbar",className:U(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",a||(g==null?void 0:g.id)===e.id?"tw-opacity-100":"tw-opacity-0"]),children:s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsx(i.Flyout,{placement:i.FlyoutPlacement.Right,isOpen:(g==null?void 0:g.id)===e.id,fitContent:!0,legacyFooter:!1,onOpenChange:O=>h(O?e:void 0),trigger:(O,R)=>s.jsx(i.Button,{ref:R,icon:s.jsx(i.IconPen20,{}),emphasis:i.ButtonEmphasis.Default,onClick:()=>h(e)}),children:s.jsx(i.ActionMenu,{menuBlocks:[{id:"menu",menuItems:[{id:"upload",size:i.MenuItemContentSize.XSmall,title:"Replace with upload",onClick:()=>{y(),h(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconArrowCircleUp20,{})})},{id:"asset",size:i.MenuItemContentSize.XSmall,title:"Replace with asset",onClick:()=>{d(),h(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconImageStack20,{})})}]},{id:"menu-delete",menuItems:[{id:"delete",size:i.MenuItemContentSize.XSmall,title:"Delete",style:i.MenuItemStyle.Danger,onClick:()=>{c(),h(void 0)},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:s.jsx(i.IconTrashBin20,{})})}]}]})})})})]})});Be.displayName="AttachmentItem";const kn=e=>{const{attributes:t,listeners:n,setNodeRef:r,transform:a,transition:l,isDragging:c}=le.useSortable({id:e.item.id}),d={transform:a?`translate(${a.x}px, ${a.y}px)`:"",transition:l,zIndex:c?2:1},u={...t,...n};return s.jsx(Be,{ref:r,isDragging:c,transformStyle:d,draggableProps:u,...e})},Sn=({children:e,isFlyoutOpen:t})=>s.jsxs("div",{className:U(["tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",t?"tw-bg-box-neutral-pressed tw-text-box-neutral-inverse-pressed":"tw-bg-base hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed tw-text-box-neutral-inverse hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed"]),children:[s.jsx(i.IconPaperclip16,{}),e,s.jsx(i.IconCaretDown12,{})]}),tt=({items:e=[],onDelete:t,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:a,onUpload:l,onSorted:c,appBridge:d,triggerComponent:u=Sn,isOpen:f,onOpenChange:p})=>{const[g,h]=x.useState(e),[y,b]=x.useState(!1),k=P.useSensors(P.useSensor(P.PointerSensor),P.useSensor(P.KeyboardSensor)),[j,S]=x.useState(void 0),[A,O]=x.useState(!1),[R,H]=x.useState([]),[I,F]=x.useState(null),N=V.useEditorState(d),{openAssetChooser:ie,closeAssetChooser:oe}=V.useAssetChooser(d),_e=f!==void 0,ye=_e?f:y,Q=g==null?void 0:g.find(v=>v.id===j),[Yt,{results:Ve,doneAll:ze}]=V.useAssetUpload({onUploadProgress:()=>!A&&O(!0)}),se=v=>{const B=_e?p:b;B==null||B(v)};x.useEffect(()=>{h(e)},[e]),x.useEffect(()=>{I&&(O(!0),Yt(I))},[I]),x.useEffect(()=>{(async()=>{ze&&(await l(Ve),O(!1))})()},[ze,Ve]);const Jt=()=>{se(!1),ie(v=>{a(v),oe(),se(!0)},{multiSelection:!0,selectedValueIds:g.map(v=>v.id)})},$e=v=>{se(!1),ie(async B=>{se(!0),oe(),H([...R,v.id]),await n(v,B[0]),H(R.filter(z=>z!==v.id))},{multiSelection:!1,selectedValueIds:g.map(B=>B.id)})},We=async(v,B)=>{H([...R,v.id]),await r(v,B),H(R.filter(z=>z!==v.id))},Zt=v=>{const{active:B}=v;S(B.id)},en=v=>{const{active:B,over:z}=v;if(z&&B.id!==z.id&&g){const tn=g.findIndex(be=>be.id===B.id),nn=g.findIndex(be=>be.id===z.id),qe=le.arrayMove(g,tn,nn);h(qe),c(qe)}S(void 0)};return N||((g==null?void 0:g.length)??0)>0?s.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Attachments",disabled:ye,enterDelay:500,triggerElement:s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(i.Flyout,{placement:i.FlyoutPlacement.BottomRight,onOpenChange:v=>se(Q?!0:v),isOpen:ye,hug:!1,fitContent:!0,legacyFooter:!1,trigger:s.jsx(u,{isFlyoutOpen:ye,children:s.jsx("div",{children:e.length>0?e.length:"Add"})}),children:s.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[g.length>0&&s.jsxs(P.DndContext,{sensors:k,collisionDetection:P.closestCenter,onDragStart:Zt,onDragEnd:en,modifiers:[sn.restrictToWindowEdges],children:[s.jsx(le.SortableContext,{items:g,strategy:le.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line",children:g.map(v=>s.jsx(kn,{isEditing:N,isLoading:R.includes(v.id),item:v,onDelete:()=>t(v),onReplaceWithBrowse:()=>$e(v),onReplaceWithUpload:B=>We(v,B),onDownload:()=>d.dispatch({name:"downloadAsset",payload:v})},v.id))})}),s.jsx(P.DragOverlay,{children:Q&&s.jsx(Be,{isOverlay:!0,isEditing:N,item:Q,isDragging:!0,onDelete:()=>t(Q),onReplaceWithBrowse:()=>$e(Q),onReplaceWithUpload:v=>We(Q,v)},j)})]}),N&&s.jsxs("div",{className:"tw-px-5 tw-py-3",children:[s.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),s.jsx(i.AssetInput,{isLoading:A,size:i.AssetInputSize.Small,onUploadClick:v=>F(v),onLibraryClick:Jt})]})]})})})}):null},nt=(e,t)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:a,updateAssetIdsFromKey:l}=V.useBlockAssets(e),c=(n==null?void 0:n[t])||[];return{onAttachmentsAdd:async g=>{await r(t,g.map(h=>h.id))},onAttachmentDelete:async g=>{await a(t,[g.id])},onAttachmentReplace:async(g,h)=>{const y=c.map(b=>b.id===g.id?h.id:b.id);await l(t,y)},onAttachmentsSorted:async g=>{const h=g.map(y=>y.id);await l(t,h)},attachments:c,appBridge:e}},st=x.createContext(null),rt=({appBridge:e,children:t,assetId:n})=>{const r=nt(e,n);return s.jsx(st.Provider,{value:r,children:t})},at=()=>{const e=x.useContext(st);if(!e)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return e},Pn=(e,t)=>{const n=r=>s.jsx(rt,{appBridge:r.appBridge,assetId:t,children:s.jsx(e,{...r})});return n.displayName="withAttachmentsProvider",n},En=[P.KeyboardCode.Down,P.KeyboardCode.Right,P.KeyboardCode.Up,P.KeyboardCode.Left],it=(e,t)=>(n,{currentCoordinates:r,context:{activeNode:a}})=>{if(n.preventDefault(),En.includes(n.code)){const l=(a==null?void 0:a.offsetWidth)??0,c=(a==null?void 0:a.offsetHeight)??0;switch(n.code){case P.KeyboardCode.Right:return{...r,x:r.x+l+e};case P.KeyboardCode.Left:return{...r,x:r.x-l-e};case P.KeyboardCode.Down:return{...r,y:r.y+c+t};case P.KeyboardCode.Up:return{...r,y:r.y-c-t}}}},In={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},Tn=(e=0,t=0)=>{const n=it(e,t);return P.useSensors(P.useSensor(P.PointerSensor),P.useSensor(P.KeyboardSensor,{coordinateGetter:n,keyboardCodes:In}))},ce=(e,t)=>{const n=[i.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded","tw-text-xs tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return t?n.push("tw-bg-box-neutral-pressed","tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed","tw-text-text-weak hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),U(n)},Bn=({children:e,isFlyoutOpen:t})=>s.jsxs("div",{className:ce("pointer",t),children:[s.jsx(i.IconPaperclip16,{}),e,s.jsx(i.IconCaretDown12,{})]}),jn=({isOpen:e,onOpenChange:t})=>{const{appBridge:n,attachments:r,onAttachmentsAdd:a,onAttachmentDelete:l,onAttachmentReplace:c,onAttachmentsSorted:d}=at();return s.jsx(tt,{onUpload:a,onDelete:l,onReplaceWithBrowse:c,onReplaceWithUpload:c,onSorted:d,onBrowse:a,items:r,appBridge:n,triggerComponent:Bn,isOpen:e,onOpenChange:t})},ot=({items:e,flyoutMenu:t,attachments:n,isDragging:r})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[n.isEnabled&&s.jsx(Ke,{children:s.jsx(jn,{isOpen:n.isOpen&&!r,onOpenChange:n.onOpenChange})}),s.jsxs(Ke,{children:[e.map((a,l)=>"draggableProps"in a?s.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,open:r,position:i.TooltipPosition.Top,content:s.jsx("div",{children:r?et:a.tooltip??Ze}),triggerElement:s.jsx("button",{ref:a.setActivatorNodeRef,"data-test-id":"block-item-wrapper-toolbar-btn",...a.draggableProps,className:ce("grab",r),children:a.icon})},l):s.jsx(i.LegacyTooltip,{withArrow:!0,enterDelay:300,hoverDelay:0,disabled:r,position:i.TooltipPosition.Top,content:s.jsx("div",{children:a.tooltip??""}),triggerElement:s.jsx("button",{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:a.onClick,className:ce("pointer"),children:a.icon})},l)),t.items.length>0&&s.jsx(i.LegacyTooltip,{withArrow:!0,hoverDelay:0,enterDelay:300,disabled:r||t.isOpen,position:i.TooltipPosition.Top,content:s.jsx("div",{children:"Options"}),triggerElement:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsx(i.Flyout,{isOpen:t.isOpen&&!r,legacyFooter:!1,fitContent:!0,hug:!1,onOpenChange:t.onOpenChange,trigger:s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-flyout",className:ce("pointer",t.isOpen&&!r),children:s.jsx(i.IconDotsHorizontal16,{})}),children:s.jsx(i.ActionMenu,{menuBlocks:t.items.map((a,l)=>({id:l.toString(),menuItems:a.map((c,d)=>({id:l.toString()+d.toString(),size:i.MenuItemContentSize.XSmall,title:c.title,style:c.style,onClick:()=>{t.onOpenChange(!1),c.onClick()},initialValue:!0,decorator:s.jsx("div",{className:"tw-mr-2",children:c.icon})}))}))})})})})]})]}),Ln=({children:e,toolbarFlyoutItems:t,toolbarItems:n,shouldHideWrapper:r,shouldHideComponent:a=!1,isDragging:l,shouldFillContainer:c,outlineOffset:d=2,shouldBeShown:u=!1,showAttachments:f=!1})=>{const[p,g]=x.useState(u),[h,y]=x.useState(!1),b=x.useRef(null);if(r)return s.jsx(s.Fragment,{children:e});const k=n==null?void 0:n.filter(S=>S!==void 0),j=p||h||u;return s.jsxs("div",{ref:b,"data-test-id":"block-item-wrapper",style:{outlineOffset:d},className:U(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",c&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",j&&"tw-outline",a&&"tw-opacity-0"]),children:[s.jsx("div",{style:{right:-1-d,bottom:`calc(100% - ${2+d}px)`},className:U(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",j&&"tw-opacity-100"]),children:s.jsx(ot,{flyoutMenu:{items:t,isOpen:p,onOpenChange:g},attachments:{isEnabled:f,isOpen:h,onOpenChange:y},items:k,isDragging:l})}),e]})},Nn=({onDownload:e})=>{const{isFocused:t,focusProps:n}=rn.useFocusRing();return s.jsx(i.LegacyTooltip,{withArrow:!0,position:i.TooltipPosition.Top,content:"Download",enterDelay:500,triggerElement:s.jsx("button",{tabIndex:0,"aria-label":"Download",...n,className:U(["tw-outline-none tw-rounded",t&&i.FOCUS_STYLE]),onClick:e,onPointerDown:r=>r.preventDefault(),children:s.jsx("span",{"data-test-id":"download-button",className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:s.jsx(i.IconArrowCircleDown16,{})})})})},An=({value:e="",gap:t,columns:n,show:r=!0,plugins:a})=>{const[l,c]=x.useState(null);return x.useEffect(()=>{(async()=>c(await i.serializeRawToHtmlAsync(e,a,n,t)))()},[e,n,t,a]),!r||l==="<br />"?null:l!==null?s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:l}}):s.jsx("div",{className:"tw-rounded-sm tw-bg-base-alt tw-animate-pulse tw-h-full tw-min-h-[10px] tw-w-full"})},lt=e=>{if(!e)return!1;const t=n=>n.some(r=>r.text?r.text!=="":r.children?t(r.children):!1);try{const n=JSON.parse(e);return t(n)}catch{return!1}},Rn=(e="p",t="",n)=>lt(t)?t:JSON.stringify([{type:e,children:[{text:t,textStyle:e}],align:n}]),Fn=(e,t,n)=>e===K.Custom?t:n,Mn=e=>e.map(ct),ct=e=>({id:e.id,title:e.name,colors:e.colors.map(t=>({alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}))}),je=(e,t)=>{const n=o.getAboveNode(e,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},ut=e=>je(e,t=>{var n,r;return((r=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:r.link)||""}),dt=e=>je(e,t=>t.url||""),gt=e=>{var t,n;return e.url||((n=(t=e.chosenLink)==null?void 0:t.searchResult)==null?void 0:n.link)||""},mt=e=>je(e,gt),Le=/^\/(document|r)\/\S+$/i,fe=e=>{if(Le.test(e))return e;try{return new URL(e),e}catch{return`https://${e}`}},pe=e=>{if(Le.test(e))return!0;try{const t=new URL(e);return["http:","https:","mailto:","tel:"].includes(t.protocol)&&t.pathname!==""}catch{return!1}},ee=e=>pe(fe(e))||e==="",ht=(e,{type:t})=>{const{apply:n,normalizeNode:r}=e;return e.apply=a=>{if(a.type!=="set_selection"){n(a);return}const l=a.newProperties;if(!(l!=null&&l.focus)||!l.anchor||!o.isCollapsed(l)){n(a);return}const c=o.getAboveNode(e,{at:l,match:{type:o.getPluginType(e,C)}});if(c){const[,d]=c;let u;o.isStartPoint(e,l.focus,d)&&(u=o.getPreviousNodeEndPoint(e,d)),o.isEndPoint(e,l.focus,d)&&(u=o.getNextNodeStartPoint(e,d)),u&&(a.newProperties={anchor:u,focus:u})}n(a)},e.normalizeNode=([a,l])=>{if(a.type===o.getPluginType(e,C)){const c=e.selection;if(c&&o.isCollapsed(c)&&o.isEndPoint(e,c.focus,l)){const d=o.getNextNodeStartPoint(e,l);if(d)o.select(e,d);else{const u=on.Path.next(l);o.insertNodes(e,{text:""},{at:u}),o.select(e,u)}}}r([a,l])},o.withRemoveEmptyNodes(e,o.mockPlugin({options:{types:t}}))},ft=(e,t,n)=>{o.insertNodes(e,[yt(e,t)],n)},Ne=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(e=>({reset:()=>{e.url(""),e.text(""),e.buttonStyle("primary"),e.newTab(!1),e.mode(""),e.isEditing(!1)}})).extendActions(e=>({show:(t,n)=>{e.mode(t),e.isEditing(!1),e.openEditorId(n)},hide:()=>{e.reset(),e.openEditorId(null)}})).extendSelectors(e=>({isOpen:t=>e.openEditorId===t})),E=Ne.set,L=Ne.get,te=()=>Ne.use,Ae=e=>{if(!e.selection)return;const{isUrl:t,forceSubmit:n}=o.getPluginOptions(e,C),r=L.url();if(!((t==null?void 0:t(r))||n))return;const l=L.text(),c=L.buttonStyle(),d=L.newTab()?void 0:"_self";return E.hide(),pt(e,{url:r,text:l,buttonStyle:c,target:d,isUrl:u=>n||!t?!0:t(u)}),setTimeout(()=>{o.focusEditor(e,e.selection??void 0)},0),!0},ne=(e,t)=>o.withoutNormalizing(e,()=>{var n,r,a,l,c,d;if(t!=null&&t.split){if(o.getAboveNode(e,{at:(n=e.selection)==null?void 0:n.anchor,match:{type:o.getPluginType(e,C)}}))return o.splitNodes(e,{at:(r=e.selection)==null?void 0:r.anchor,match:p=>o.isElement(p)&&p.type===o.getPluginType(e,C)}),ne(e,{at:(a=e.selection)==null?void 0:a.anchor}),!0;if(o.getAboveNode(e,{at:(l=e.selection)==null?void 0:l.focus,match:{type:o.getPluginType(e,C)}}))return o.splitNodes(e,{at:(c=e.selection)==null?void 0:c.focus,match:p=>o.isElement(p)&&p.type===o.getPluginType(e,C)}),ne(e,{at:(d=e.selection)==null?void 0:d.focus}),!0}o.unwrapNodes(e,{match:{type:o.getPluginType(e,C)},...t})}),pt=(e,{url:t,text:n,buttonStyle:r,target:a,insertTextInButton:l,insertNodesOptions:c,isUrl:d=o.getPluginOptions(e,C).isUrl})=>{var S;const u=e.selection;if(!u)return;const f=o.getAboveNode(e,{at:u,match:{type:o.getPluginType(e,C)}});if(l&&f)return e.insertText(t),!0;if(!(d!=null&&d(t)))return;if(o.isDefined(n)&&n.length===0&&(n=t),f)return Un(t,e,f,a,r,n),!0;const p=o.findNode(e,{at:u,match:{type:o.getPluginType(e,C)}}),[g,h]=p??[],y=On(e,h,n);if(o.isExpanded(u))return Dn(f,e,t,r,a,n),!0;y&&o.removeNodes(e,{at:h});const b=o.getNodeProps(g??{}),k=(S=e.selection)==null?void 0:S.focus.path;if(!k)return;const j=o.getNodeLeaf(e,k);return n!=null&&n.length||(n=t),ft(e,{...b,url:t,target:a,children:[{...j,text:n}]},c),!0};function On(e,t,n){return t&&(n==null?void 0:n.length)&&n!==o.getEditorString(e,t)}function Dn(e,t,n,r,a,l){e?ne(t,{at:e[1]}):ne(t,{split:!0}),xt(t,{url:n,buttonStyle:r,target:a}),Re(t,{url:n,target:a,text:l})}function Un(e,t,n,r,a,l){var c,d,u;(e!==((c=n[0])==null?void 0:c.url)||r!==((d=n[0])==null?void 0:d.target)||a!==((u=n[0])==null?void 0:u.buttonStyle))&&o.setNodes(t,{url:e,target:r,buttonStyle:a},{at:n[1]}),Re(t,{url:e,text:l,target:r})}const Re=(e,{text:t})=>{const n=o.getAboveNode(e,{match:{type:o.getPluginType(e,C)}});if(n){const[r,a]=n;if(t!=null&&t.length&&t!==o.getEditorString(e,a)){const l=r.children[0];o.replaceNodeChildren(e,{at:a,nodes:{...l,text:t},insertOptions:{select:!0}})}}},xt=(e,{url:t,buttonStyle:n,target:r,...a})=>{o.wrapNodes(e,{type:o.getPluginType(e,C),url:t,buttonStyle:n,target:r,children:[]},{split:!0,...a})},Hn=(e,t)=>{const n=o.getAboveNode(e,{match:{type:C}});return Array.isArray(n)?t(n[0]):""},wt=e=>Hn(e,t=>t.url??""),yt=(e,{url:t,text:n="",buttonStyle:r="primary",target:a,children:l})=>({type:o.getPluginType(e,C),url:t,target:a,buttonStyle:r,children:l??[{text:n}]}),bt=(e,{focused:t}={})=>{if(L.mode()==="edit"){xe(e);return}Fe(e,{focused:t})},xe=e=>{const t=o.findNode(e,{match:{type:o.getPluginType(e,C)}});if(!t)return;const[n,r]=t;let a=o.getEditorString(e,r);E.url(n.url),E.newTab(n.target===void 0),a===n.url&&(a=""),E.text(a),E.isEditing(!0)},Fe=(e,{focused:t}={})=>{L.mode()||!t||o.isRangeAcrossBlocks(e,{at:e.selection})||o.someNode(e,{match:{type:o.getPluginType(e,C)}})||(E.text(o.getEditorString(e,e.selection)),E.show("insert",e.id))},we={buttonPrimary:{fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",marginTop:"10px",marginBottom:"10px",display:"inline-block",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",display:"inline-block",marginTop:"10px",marginBottom:"10px",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",display:"inline-block",marginTop:"10px",marginBottom:"10px",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},_n=e=>({...o.useElementProps({...e,elementToAttributes:n=>({url:n.href,buttonStyle:n.buttonStyle||"primary",target:n.target||"_blank"})}),onMouseOver:n=>{n.stopPropagation()}}),Vn=e=>{const{href:t,target:n,buttonStyle:r}=_n(e),{attributes:a,children:l}=e;return s.jsx(zn,{attributes:a,href:t,target:n,styles:we[`button${r.charAt(0).toUpperCase()+r.slice(1)}`],children:l})},zn=({attributes:e,styles:t={hover:{}},children:n,href:r="#",target:a})=>{const[l,c]=x.useState(!1);return s.jsx("a",{...e,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:r,target:a,style:l?{...t,...t.hover}:t,children:n})};class $n extends i.MarkupElement{constructor(t=C,n=Vn){super(t,n)}}const Wn=({type:e,...t})=>{const n=o.useEditorRef(),r=!!o.isRangeInSameBlock(n,{at:n.selection}),a=!!(n!=null&&n.selection)&&o.someNode(n,{match:{type:e}});return s.jsx(o.ToolbarButton,{tooltip:i.getTooltip(r?`Button
2
+ ${i.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block."),classNames:i.getButtonClassNames(r),active:a,onMouseDown:async l=>{n&&(l.preventDefault(),l.stopPropagation(),o.focusEditor(n,n.selection??n.prevSelection??void 0),setTimeout(()=>{bt(n,{focused:!0})},0))},...t})},qn=({editor:e,id:t})=>s.jsx("div",{"data-plugin-id":t,children:s.jsx(Wn,{type:o.getPluginType(e,C),icon:s.jsx("span",{className:"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex",children:s.jsx(i.IconButton16,{})}),styles:i.buttonStyles})}),Gn=()=>{const e=ms({});return s.jsx("div",{"data-test-id":"floating-button-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:s.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[s.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(de.EditButton,{children:s.jsx(i.IconPen16,{})})}),s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(de.UnlinkButton,{children:s.jsx(i.IconTrashBin16,{})})})]})]})})},Kn=({section:e,selectedUrl:t,onSelectUrl:n})=>{const r=e.permanentLink===t;return s.jsx("button",{"data-test-id":"internal-link-selector-section-link",className:i.merge(["tw-py-2 tw-px-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",r?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[s.jsx(i.IconDocumentText16,{}),s.jsx("span",{className:"tw-text-s",children:e.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},Xn=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,appBridge:a})=>{const[l,c]=x.useState(e.id===r.documentId),d=e.permanentLink===t,{documentSections:u}=V.useDocumentSection(a,e.id),f=[...u.values()],p=f.length>0;return x.useEffect(()=>{e.id===r.pageId&&c(!0)},[r,e.id]),s.jsxs(s.Fragment,{children:[s.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:i.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",p?"tw-pl-7":"tw-pl-12",d?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[p&&s.jsx("button",{"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!l),children:s.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",l?"tw-rotate-90":""])})}),s.jsx("span",{className:"tw-text-s",children:e.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),l&&f.length>0&&f.map(g=>s.jsx(Kn,{section:g,selectedUrl:t,onSelectUrl:n},g.id))]})},vt=()=>s.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:s.jsx(i.LoadingCircle,{size:i.LoadingCircleSize.Small})}),Qn=({appBridge:e,documentId:t,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a})=>{const[l,c]=x.useState([]),[d,u]=x.useState(!0),f=[...l.values()],p=!d&&f.length>0;return x.useEffect(()=>{e.getDocumentPagesByDocumentId(t).then(g=>{const h=g.filter(b=>!!b.category).sort((b,k)=>b.category.sort===k.category.sort?b.sort-k.sort:b.category.sort-k.category.sort),y=g.filter(b=>!b.category).sort((b,k)=>b.sort-k.sort);c([...h,...y])}).finally(()=>{u(!1)})},[]),d?s.jsx(vt,{}):p?s.jsx(s.Fragment,{children:f.map(g=>s.jsx(Xn,{page:g,appBridge:e,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a},g.id))}):s.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},Yn=({document:e,appBridge:t,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a})=>{const[l,c]=x.useState(e.id===a.documentId),d=e.permanentLink===n;return x.useEffect(()=>{e.id===a.documentId&&c(!0)},[a,e.id]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:i.merge(["tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full",d?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>r(e.permanentLink),children:[s.jsx("button",{role:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!l),children:s.jsx("div",{className:i.merge(["tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong",l?"tw-rotate-90":""])})}),s.jsx(i.IconColorFan16,{}),s.jsx("span",{className:"tw-text-s",children:e.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),l&&s.jsx(Qn,{appBridge:t,documentId:e.id,selectedUrl:n,onSelectUrl:r,itemsToExpandInitially:a})]})},Jn=({appBridge:e,selectedUrl:t,onSelectUrl:n})=>{const[r,a]=x.useState(!0),[l,c]=x.useState([]),[d,u]=x.useState({documentId:void 0,pageId:void 0}),f=[...l.values()];x.useEffect(()=>{t&&f.length>0&&p().then(g=>{u(g)})},[f.length]),x.useEffect(()=>{e.getAllDocuments().then(g=>{c(g)}).finally(()=>{a(!1)})},[]);const p=async()=>{const g={documentId:void 0,pageId:void 0};if(f.find(y=>y.permanentLink===t))return g;for(const y of f){const b=await e.getDocumentPagesByDocumentId(y.id);e.getAllDocuments();const k=[...b.values()];if(!!k.find(S=>S.permanentLink===t))return g.documentId=y.id,g;for(const S of k)if(!![...(await e.getDocumentSectionsByDocumentPageId(S.id)).values()].find(H=>H.permanentLink===t))return g.documentId=y.id,g.pageId=S.id,g}return g};return r?s.jsx(vt,{}):s.jsx(s.Fragment,{children:f.map(g=>s.jsx(Yn,{document:g,appBridge:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:d},g.id))})},Ct=({appBridge:e,url:t,onUrlChange:n,buttonSize:r=i.ButtonSize.Medium})=>{const{open:a,isOpen:l,close:c}=an.useOverlayTriggerState({}),[d,u]=x.useState(t),f=h=>{u(h)},p=h=>{h.key==="Enter"&&g()};x.useEffect(()=>{t&&!d&&u(t)},[t,d]);const g=()=>{n==null||n(d),c()};return s.jsxs("div",{"data-test-id":"internal-link-selector",onKeyDown:p,children:[s.jsx(i.Button,{icon:s.jsx(i.IconLink,{}),size:r,type:i.ButtonType.Button,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,onClick:()=>a(),children:"Internal link"}),s.jsxs(i.Modal,{zIndex:1001,onClose:()=>c(),isOpen:l,isDismissable:!0,children:[s.jsx(i.Modal.Header,{title:"Select internal link"}),s.jsx(i.Modal.Body,{children:s.jsx(Jn,{appBridge:e,selectedUrl:d,onSelectUrl:f})}),s.jsx(i.Modal.Footer,{buttons:[{children:"Cancel",onClick:()=>c(),style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default},{children:"Choose",onClick:h=>{h==null||h.preventDefault(),g()},style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Strong,disabled:!d}]})]})]})},kt=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:r,clearable:a,placeholder:l,newTab:c,openInNewTab:d,url:u="",required:f,info:p,label:g,buttonSize:h,hideInternalLinkButton:y})=>{const b=n?n(u):ee(u),k=c??(d?i.CheckboxState.Checked:i.CheckboxState.Unchecked);return s.jsxs("div",{"data-test-id":"link-input",children:[s.jsx(i.FormControl,{label:{children:g,htmlFor:"url",required:f,tooltip:p?{content:p,position:i.TooltipPosition.Top}:void 0},children:s.jsx(i.TextInput,{id:"url",value:u,clearable:a,onChange:e,placeholder:l??"https://example.com",focusOnMount:!0})}),!b&&s.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!y&&s.jsx("div",{className:"tw-mt-3",children:s.jsx(Ct,{url:u,appBridge:r,onUrlChange:e,buttonSize:h??i.ButtonSize.Medium})}),s.jsx("div",{className:"tw-mt-3",children:s.jsx(i.Checkbox,{value:"new-tab",label:"Open in new tab",state:k,onChange:t})})]})},St=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:r,onCancel:a,onSave:l,isValidUrlOrEmpty:c,hasValues:d,testId:u,appBridge:f,children:p})=>s.jsxs("div",{"data-test-id":u,className:"tw-bg-white tw-rounded tw-shadow tw-p-7 tw-min-w-[400px] tw-overflow-y-auto",children:[s.jsx(i.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:s.jsx(i.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:t})}),p,s.jsx("div",{className:"tw-mt-5",children:s.jsx(kt,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:c,appBridge:f})}),s.jsx("div",{className:"tw-mt-3",children:s.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[s.jsx(i.Button,{onClick:a,size:i.ButtonSize.Medium,style:i.ButtonStyle.Default,emphasis:i.ButtonEmphasis.Default,children:"Cancel"}),s.jsx(i.Button,{onClick:l,size:i.ButtonSize.Medium,icon:s.jsx(i.IconCheckMark20,{}),disabled:!d||!c(e==null?void 0:e.url),children:"Save"})]})})]}),Zn=e=>{var n;const t=o.getAboveNode(e,{match:{type:C}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},es={url:"",text:"",buttonStyle:"primary",newTab:i.CheckboxState.Unchecked},ts=()=>{const[e,t]=x.useReducer((n,r)=>{const{type:a,payload:l}=r;switch(a){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...l};default:return n}},es);return[e,t]},ns=()=>{const e=o.useEditorRef(),[t,n]=ts();x.useEffect(()=>{const g=Zn(e);n({type:"INIT",payload:{text:L.text(),buttonStyle:g,newTab:L.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:L.url()}})},[n,e]);const r=g=>{n({type:"TEXT",payload:{text:g}})},a=g=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:g}})},l=g=>{n({type:"URL",payload:{url:g}})},c=g=>{n(g?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{E.hide()},u=g=>{if(!ee(t.url)||!f)return;const h=fe(t.url);E.text(t.text),E.url(h),E.buttonStyle(t.buttonStyle),E.newTab(t.newTab===i.CheckboxState.Checked),Ae(e)&&(g==null||g.preventDefault())},f=t.url!==""&&t.text!=="",{appBridge:p}=o.getPluginOptions(e,C);return o.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onButtonStyleChange:a,onUrlChange:l,onToggleTab:c,onCancel:d,onSave:u,hasValues:f,isValidUrlOrEmpty:ee,appBridge:p}},ue="link-plugin";var w=(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))(w||{});const T={heading1:{fontSize:"var(--f-theme-settings-heading1-font-size)",lineHeight:"var(--f-theme-settings-heading1-line-height)",marginTop:"var(--f-theme-settings-heading1-margin-top)",marginBottom:"var(--f-theme-settings-heading1-margin-bottom)",textDecoration:"var(--f-theme-settings-heading1-text-decoration)",fontStyle:"var(--f-theme-settings-heading1-font-style)",textTransform:"var(--f-theme-settings-heading1-text-transform)",letterSpacing:"var(--f-theme-settings-heading1-letter-spacing)",fontWeight:"var(--f-theme-settings-heading1-font-weight)",fontFamily:"var(--f-theme-settings-heading1-font-family)",color:"var(--f-theme-settings-heading1-color)"},heading2:{fontSize:"var(--f-theme-settings-heading2-font-size)",lineHeight:"var(--f-theme-settings-heading2-line-height)",marginTop:"var(--f-theme-settings-heading2-margin-top)",marginBottom:"var(--f-theme-settings-heading2-margin-bottom)",textDecoration:"var(--f-theme-settings-heading2-text-decoration)",fontStyle:"var(--f-theme-settings-heading2-font-style)",textTransform:"var(--f-theme-settings-heading2-text-transform)",letterSpacing:"var(--f-theme-settings-heading2-letter-spacing)",fontWeight:"var(--f-theme-settings-heading2-font-weight)",fontFamily:"var(--f-theme-settings-heading2-font-family)",color:"var(--f-theme-settings-heading2-color)"},heading3:{fontSize:"var(--f-theme-settings-heading3-font-size)",lineHeight:"var(--f-theme-settings-heading3-line-height)",marginTop:"var(--f-theme-settings-heading3-margin-top)",marginBottom:"var(--f-theme-settings-heading3-margin-bottom)",textDecoration:"var(--f-theme-settings-heading3-text-decoration)",fontStyle:"var(--f-theme-settings-heading3-font-style)",textTransform:"var(--f-theme-settings-heading3-text-transform)",letterSpacing:"var(--f-theme-settings-heading3-letter-spacing)",fontWeight:"var(--f-theme-settings-heading3-font-weight)",fontFamily:"var(--f-theme-settings-heading3-font-family)",color:"var(--f-theme-settings-heading3-color)"},heading4:{fontSize:"var(--f-theme-settings-heading4-font-size)",lineHeight:"var(--f-theme-settings-heading4-line-height)",marginTop:"var(--f-theme-settings-heading4-margin-top)",marginBottom:"var(--f-theme-settings-heading4-margin-bottom)",textDecoration:"var(--f-theme-settings-heading4-text-decoration)",fontStyle:"var(--f-theme-settings-heading4-font-style)",textTransform:"var(--f-theme-settings-heading4-text-transform)",letterSpacing:"var(--f-theme-settings-heading4-letter-spacing)",fontWeight:"var(--f-theme-settings-heading4-font-weight)",fontFamily:"var(--f-theme-settings-heading4-font-family)",color:"var(--f-theme-settings-heading4-color)"},custom1:{fontSize:"var(--f-theme-settings-custom1-font-size)",lineHeight:"var(--f-theme-settings-custom1-line-height)",marginTop:"var(--f-theme-settings-custom1-margin-top)",marginBottom:"var(--f-theme-settings-custom1-margin-bottom)",textDecoration:"var(--f-theme-settings-custom1-text-decoration)",fontStyle:"var(--f-theme-settings-custom1-font-style)",textTransform:"var(--f-theme-settings-custom1-text-transform)",letterSpacing:"var(--f-theme-settings-custom1-letter-spacing)",fontWeight:"var(--f-theme-settings-custom1-font-weight)",fontFamily:"var(--f-theme-settings-custom1-font-family)",color:"var(--f-theme-settings-custom1-color)"},custom2:{fontSize:"var(--f-theme-settings-custom2-font-size)",lineHeight:"var(--f-theme-settings-custom2-line-height)",marginTop:"var(--f-theme-settings-custom2-margin-top)",marginBottom:"var(--f-theme-settings-custom2-margin-bottom)",textDecoration:"var(--f-theme-settings-custom2-text-decoration)",fontStyle:"var(--f-theme-settings-custom2-font-style)",textTransform:"var(--f-theme-settings-custom2-text-transform)",letterSpacing:"var(--f-theme-settings-custom2-letter-spacing)",fontWeight:"var(--f-theme-settings-custom2-font-weight)",fontFamily:"var(--f-theme-settings-custom2-font-family)",color:"var(--f-theme-settings-custom2-color)"},custom3:{fontSize:"var(--f-theme-settings-custom3-font-size)",lineHeight:"var(--f-theme-settings-custom3-line-height)",marginTop:"var(--f-theme-settings-custom3-margin-top)",marginBottom:"var(--f-theme-settings-custom3-margin-bottom)",textDecoration:"var(--f-theme-settings-custom3-text-decoration)",fontStyle:"var(--f-theme-settings-custom3-font-style)",textTransform:"var(--f-theme-settings-custom3-text-transform)",letterSpacing:"var(--f-theme-settings-custom3-letter-spacing)",fontWeight:"var(--f-theme-settings-custom3-font-weight)",fontFamily:"var(--f-theme-settings-custom3-font-family)",color:"var(--f-theme-settings-custom3-color)"},p:{fontSize:"var(--f-theme-settings-body-font-size)",lineHeight:"var(--f-theme-settings-body-line-height)",marginTop:"var(--f-theme-settings-body-margin-top)",marginBottom:"var(--f-theme-settings-body-margin-bottom)",textDecoration:"var(--f-theme-settings-body-text-decoration)",fontStyle:"var(--f-theme-settings-body-font-style)",textTransform:"var(--f-theme-settings-body-text-transform)",letterSpacing:"var(--f-theme-settings-body-letter-spacing)",fontWeight:"var(--f-theme-settings-body-font-weight)",fontFamily:"var(--f-theme-settings-body-font-family)",color:"var(--f-theme-settings-body-color)"},quote:{fontSize:"var(--f-theme-settings-quote-font-size)",lineHeight:"var(--f-theme-settings-quote-line-height)",marginTop:"var(--f-theme-settings-quote-margin-top)",marginBottom:"var(--f-theme-settings-quote-margin-bottom)",textDecoration:"var(--f-theme-settings-quote-text-decoration)",fontStyle:"var(--f-theme-settings-quote-font-style)",textTransform:"var(--f-theme-settings-quote-text-transform)",letterSpacing:"var(--f-theme-settings-quote-letter-spacing)",fontWeight:"var(--f-theme-settings-quote-font-weight)",fontFamily:"var(--f-theme-settings-quote-font-family)",color:"var(--f-theme-settings-quote-color)"},imageCaption:{fontSize:"var(--f-theme-settings-image-caption-font-size)",lineHeight:"var(--f-theme-settings-image-caption-line-height)",marginTop:"var(--f-theme-settings-image-caption-margin-top)",marginBottom:"var(--f-theme-settings-image-caption-margin-bottom)",textDecoration:"var(--f-theme-settings-image-caption-text-decoration)",fontStyle:"var(--f-theme-settings-image-caption-font-style)",textTransform:"var(--f-theme-settings-image-caption-text-transform)",letterSpacing:"var(--f-theme-settings-image-caption-letter-spacing)",fontWeight:"var(--f-theme-settings-image-caption-font-weight)",fontFamily:"var(--f-theme-settings-image-caption-font-family)",color:"var(--f-theme-settings-image-caption-color)"},imageTitle:{fontSize:"var(--f-theme-settings-image-title-font-size)",lineHeight:"var(--f-theme-settings-image-title-line-height)",marginTop:"var(--f-theme-settings-image-title-margin-top)",marginBottom:"var(--f-theme-settings-image-title-margin-bottom)",textDecoration:"var(--f-theme-settings-image-title-text-decoration)",fontStyle:"var(--f-theme-settings-image-title-font-style)",textTransform:"var(--f-theme-settings-image-title-text-transform)",letterSpacing:"var(--f-theme-settings-image-title-letter-spacing)",fontWeight:"var(--f-theme-settings-image-title-font-weight)",fontFamily:"var(--f-theme-settings-image-title-font-family)",color:"var(--f-theme-settings-image-title-color)"},[ue]:{fontSize:"var(--f-theme-settings-link-font-size)",lineHeight:"var(--f-theme-settings-link-line-height)",marginTop:"var(--f-theme-settings-link-margin-top)",marginBottom:"var(--f-theme-settings-link-margin-bottom)",textDecoration:"var(--f-theme-settings-link-text-decoration)",fontStyle:"var(--f-theme-settings-link-font-style)",textTransform:"var(--f-theme-settings-link-text-transform)",letterSpacing:"var(--f-theme-settings-link-letter-spacing)",fontWeight:"var(--f-theme-settings-link-font-weight)",fontFamily:"var(--f-theme-settings-link-font-family)",color:"var(--f-theme-settings-link-color)"},...we},ss=()=>{const e=ns(),{state:t,onButtonStyleChange:n}=e;return s.jsx(St,{...e,testId:"floating-button-insert",children:s.jsx("div",{className:"tw-pt-5",children:s.jsxs(i.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[s.jsx(ve,{id:"primary",styles:T.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),s.jsx(ve,{id:"secondary",styles:T.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),s.jsx(ve,{id:"tertiary",styles:T.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},ve=({id:e,styles:t,isActive:n,onClick:r,children:a})=>{const[l,c]=x.useState(!1),d=()=>t&&t.hover&&l?{...t,...t.hover}:t;return s.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:r,style:{...d(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:a})},rs=()=>{const e=te().isEditing(),t=s.jsx(ss,{}),n=e?t:s.jsx(Gn,{});return s.jsxs(s.Fragment,{children:[s.jsx(de.InsertRoot,{children:t}),s.jsx(de.EditRoot,{children:n})]})},C="button",Pt="button-plugin",Et=e=>o.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:ht,renderAfterEditable:rs,options:{isUrl:pe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:e},then:(t,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class It extends i.Plugin{constructor({styles:t=we,...n}){super(Pt,{button:qn,markupElement:new $n,...n}),this.styles={},this.styles=t,this.appBridge=n==null?void 0:n.appBridge}plugins(){return[Et(this.appBridge)]}}const as=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=o.usePlateSelectors(n.id).keyEditor(),a=te().mode(),l=te().isOpen(n.id),{triggerFloatingButtonHotkeys:c}=o.getPluginOptions(n,C),d=x.useCallback(()=>{const h=o.getAboveNode(n,{match:{type:o.getPluginType(n,C)}});if(h){const[,y]=h;return o.getRangeBoundingClientRect(n,{anchor:o.getStartPoint(n,y),focus:o.getEndPoint(n,y)})}return o.getDefaultBoundingClientRect()},[n]),u=l&&a==="edit",{update:f,style:p,floating:g}=Bt({open:u,getBoundingClientRect:d,...e});return x.useEffect(()=>{const h=wt(n);if(h&&E.url(h),n.selection&&o.someNode(n,{match:{type:o.getPluginType(n,C)}})){E.show("edit",n.id),f();return}L.mode()==="edit"&&E.hide()},[n,r,f]),o.useHotkeys(c,h=>{h.preventDefault(),L.mode()==="edit"&&xe(n)},{enableOnContentEditable:!0},[]),hs(),Tt(),{style:{...p,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,g)}},is=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=Xe.useFocused(),a=te().mode(),l=te().isOpen(n.id),{triggerFloatingButtonHotkeys:c}=o.getPluginOptions(n,C);o.useHotkeys(c,p=>{p.preventDefault(),Fe(n,{focused:r})},{enableOnContentEditable:!0},[r]);const{update:d,style:u,floating:f}=Bt({open:l&&a==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return x.useEffect(()=>{l&&d(),E.updated(l)},[l,d]),Tt(),{style:{...u,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,f)}},os=e=>{const t=o.useEditorRef();return{onClick:x.useCallback(()=>{xe(t)},[t]),...e}},ls=o.createComponentAs(e=>{const t=os(e);return o.createElementAs("button",t)}),cs=e=>{const t=o.useEditorRef();return{onClick:x.useCallback(()=>{ne(t),o.focusEditor(t,t.selection??void 0)},[t]),...e}},us=o.createComponentAs(e=>{const t=cs(e);return o.createElementAs(o.Button,t)}),ds=o.createComponentAs(e=>{var n;const t=as(e);return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),gs=o.createComponentAs(e=>{var n;const t=is(e);return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),de={EditRoot:ds,InsertRoot:gs,EditButton:ls,UnlinkButton:us},ms=e=>{const t=te().updated(),n=x.useRef(null);x.useEffect(()=>{n.current&&t&&setTimeout(()=>{var a;(a=n.current)==null||a.focus()},0)},[t]);const r=x.useCallback(a=>{E.url(a.target.value)},[]);return o.mergeProps({onChange:r,defaultValue:L.url()},{...e,ref:o.useComposedRef(e.ref,n)})},hs=()=>{const e=o.useEditorRef();o.useHotkeys("*",t=>{t.key==="Enter"&&Ae(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Tt=()=>{const e=o.useEditorRef();o.useHotkeys("escape",()=>{if(L.mode()==="edit"){if(L.isEditing()){E.show("edit",e.id),o.focusEditor(e,e.selection??void 0);return}E.hide()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},fs=12,ps=-22,xs=96,Bt=e=>o.useVirtualFloating({placement:"bottom-start",middleware:[o.offset({mainAxis:fs,alignmentAxis:ps}),o.flip({padding:xs})],...e}),ws=({id:e="rte",isEditing:t,value:n,columns:r,gap:a,placeholder:l,plugins:c,onTextChange:d,showSerializedText:u})=>{const[f,p]=x.useState(!1),g=h=>{d&&h!==n&&d(h),p(!1)};return x.useEffect(()=>{const h=y=>(y.preventDefault(),y.returnValue="Unprocessed changes");return f&&window.addEventListener("beforeunload",h),()=>window.removeEventListener("beforeunload",h)},[f]),t?s.jsx(i.RichTextEditor,{id:e,value:n,border:!1,placeholder:l,plugins:c,onValueChanged:()=>p(!0),onTextChange:g,hideExternalFloatingModals:h=>{L.isOpen(h)&&E.reset()}}):s.jsx(An,{value:n,columns:r,gap:a,show:u,plugins:c})},ys=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=Xe.useFocused(),a=o.useFloatingLinkSelectors().mode(),l=o.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:c}=o.getPluginOptions(n,o.ELEMENT_LINK);o.useHotkeys(c,p=>{o.triggerFloatingLinkInsert(n,{focused:r})&&p.preventDefault()},{enableOnContentEditable:!0},[r]);const{update:d,style:u,floating:f}=o.useVirtualFloatingLink({editorId:n.id,open:l&&a==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:()=>{},...e});return x.useEffect(()=>{l?(d(),o.floatingLinkActions.updated(!0)):o.floatingLinkActions.updated(!1)},[l,d]),o.useFloatingLinkEscape(),{style:{...u,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,f)}},bs=o.createComponentAs(e=>{var n;const t=ys({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)}),vs=o.createComponentAs(e=>{var n;const t=ks({...e,floatingOptions:{strategy:"absolute"}});return((n=t.style)==null?void 0:n.display)==="none"?null:o.createElementAs("div",t)});o.FloatingLink.EditRoot=vs;o.FloatingLink.InsertRoot=bs;const ge=o.FloatingLink,Cs=()=>{const e=o.useFloatingLinkUrlInput({});return s.jsx("div",{"data-test-id":"floating-link-edit",className:"tw-bg-white tw-text-text tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:s.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center",children:[s.jsx("span",{className:"tw-pointer-events-none",children:e.defaultValue}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(ge.EditButton,{children:s.jsx(i.IconPen16,{})})}),s.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(ge.UnlinkButton,{children:s.jsx(i.IconTrashBin16,{})})})]})]})})},ks=({floatingOptions:e,...t})=>{const n=o.useEditorRef(),r=o.usePlateSelectors().keyEditor(),a=o.useFloatingLinkSelectors().mode(),l=o.useFloatingLinkSelectors().isOpen(n.id),{triggerFloatingLinkHotkeys:c="command+k, ctrl+k"}=o.getPluginOptions(n,o.ELEMENT_LINK),d=x.useCallback(()=>{const h=o.getAboveNode(n,{match:{type:o.getPluginType(n,o.ELEMENT_LINK)}});if(h){const[,y]=h;return o.getRangeBoundingClientRect(n,{anchor:o.getStartPoint(n,y),focus:o.getEndPoint(n,y)})}return o.getDefaultBoundingClientRect()},[n]),u=l&&a==="edit",{update:f,style:p,floating:g}=o.useVirtualFloatingLink({editorId:n.id,open:u,getBoundingClientRect:d,...e});return x.useEffect(()=>{const h=mt(n);if(h&&o.floatingLinkActions.url(h),n.selection&&o.someNode(n,{match:{type:o.getPluginType(n,o.ELEMENT_LINK)}})){o.floatingLinkActions.show("edit",n.id),f();return}o.floatingLinkSelectors.mode()==="edit"&&o.floatingLinkActions.hide()},[n,r,f]),o.useHotkeys(c,h=>{h.preventDefault(),o.floatingLinkSelectors.mode()==="edit"&&o.triggerFloatingLinkEdit(n)},{enableOnContentEditable:!0},[]),o.useFloatingLinkEnter(),o.useFloatingLinkEscape(),{style:{...p,zIndex:1e3},...t,ref:o.useComposedRef(t.ref,g)}},Ss={url:"",text:"",newTab:i.CheckboxState.Unchecked},Ps=()=>{const[e,t]=x.useReducer((n,r)=>{const{type:a,payload:l}=r;switch(a){case"NEW_TAB":return{...n,newTab:i.CheckboxState.Checked};case"SAME_TAB":return{...n,newTab:i.CheckboxState.Unchecked};case"URL":case"TEXT":case"INIT":return{...n,...l};default:return n}},Ss);return[e,t]},Es=()=>{const e=o.useEditorRef(),[t,n]=Ps();x.useEffect(()=>{const p=ut(e),g=dt(e);n({type:"INIT",payload:{text:o.floatingLinkSelectors.text(),newTab:o.floatingLinkSelectors.newTab()?i.CheckboxState.Checked:i.CheckboxState.Unchecked,url:p&&g===""?p:o.floatingLinkSelectors.url()}})},[n,e]);const r=p=>{n({type:"TEXT",payload:{text:p}})},a=p=>{n({type:"URL",payload:{url:p}})},l=p=>{n(p?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{o.floatingLinkActions.hide()},d=p=>{if(!ee(t.url)||!u)return;const g=fe(t.url);o.floatingLinkActions.text(t.text),o.floatingLinkActions.url(g),o.floatingLinkActions.newTab(t.newTab===i.CheckboxState.Checked),o.submitFloatingLink(e)&&(p==null||p.preventDefault())},u=t.url!==""&&t.text!=="",{appBridge:f}=o.getPluginOptions(e,o.ELEMENT_LINK);return o.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onUrlChange:a,onToggleTab:l,onCancel:c,onSave:d,hasValues:u,isValidUrlOrEmpty:ee,appBridge:f}},Is=()=>s.jsx(St,{...Es(),testId:"floating-link-insert"}),Ts=({readOnly:e})=>{const t=o.useFloatingLinkSelectors().isEditing();if(e)return null;const n=s.jsx(Is,{}),r=t?n:s.jsx(Cs,{});return s.jsxs(s.Fragment,{children:[s.jsx(ge.InsertRoot,{children:n}),s.jsx(ge.EditRoot,{children:r})]})},Bs=({id:e,editorId:t})=>{const n=o.usePlateEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(o.LinkToolbarButton,{tooltip:i.getTooltip(r?`Link
3
3
  ${i.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block."),icon:s.jsx("span",{className:"tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex",children:s.jsx(i.IconLink,{size:i.IconSize.Size16})}),classNames:i.getButtonClassNames(r),styles:{root:{width:"24px",height:"24px"}},actionHandler:"onMouseDown"})})},js=e=>({...o.useElementProps({...e,elementToAttributes:n=>{var r,a;return{href:n.url||((a=(r=n.chosenLink)==null?void 0:r.searchResult)==null?void 0:a.link)||"",target:n.target||"_self"}}}),onMouseOver:n=>{n.stopPropagation()}}),Ls=e=>{const t=js(e),{attributes:n,children:r}=e;return s.jsx("a",{...n,href:t.href,target:t.target,style:T[ue],children:r})};class Ns extends i.MarkupElement{constructor(t=o.ELEMENT_LINK,n=Ls){super(t,n)}}const jt=e=>o.createPluginFactory({...o.createLinkPlugin(),renderAfterEditable:Ts,options:{isUrl:pe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k",appBridge:e}})();class Lt extends i.Plugin{constructor(t,n=T[ue]){super(ue,{button:Bs,markupElement:new Ns,...t}),this.styles={},this.styles=n,this.appBridge=t==null?void 0:t.appBridge}plugins(){return[jt(this.appBridge)]}}const As="textstyle-custom1-plugin";class Nt extends i.Plugin{constructor({styles:t=T.custom1,...n}={}){super(w.custom1,{label:"Custom 1",markupElement:new Rs,...n}),this.styles={},this.styles=t}plugins(){return[Fs(this.styles)]}}class Rs extends i.MarkupElement{constructor(t=As,n=At){super(t,n)}}const At=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("p",{...t,style:r,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),children:n})},Fs=e=>o.createPluginFactory({key:w.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:w.custom1}]}})({component:t=>s.jsx(At,{...t,styles:e})}),Ms="textstyle-custom2-plugin";class Rt extends i.Plugin{constructor({styles:t=T.custom2,...n}={}){super(w.custom2,{label:"Custom 2",markupElement:new Os,...n}),this.styles={},this.styles=t}plugins(){return[Ds(this.styles)]}}class Os extends i.MarkupElement{constructor(t=Ms,n=Ft){super(t,n)}}const Ft=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("p",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},Ds=e=>o.createPluginFactory({key:w.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:w.custom2}]}})({component:t=>s.jsx(Ft,{...t,styles:e})}),Us="textstyle-custom3-plugin";class Mt extends i.Plugin{constructor({styles:t=T.custom3,...n}={}){super(i.TextStyles.custom3,{label:"Custom 3",markupElement:new Hs,...n}),this.styles={},this.styles=t}plugins(){return[_s(this.styles)]}}class Hs extends i.MarkupElement{constructor(t=Us,n=Ot){super(t,n)}}const Ot=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("p",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},_s=e=>o.createPluginFactory({key:i.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:i.TextStyles.custom3}]}})({component:t=>s.jsx(Ot,{...t,styles:e})}),Vs="textstyle-heading1-plugin";class Dt extends i.Plugin{constructor({styles:t=T.heading1,...n}={}){super(w.heading1,{label:"Heading 1",markupElement:new zs,...n}),this.styles={},this.styles=t}plugins(){return[$s(this.styles)]}}class zs extends i.MarkupElement{constructor(t=Vs,n=Ce){super(t,n)}}const Ce=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("h1",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},$s=e=>o.createPluginFactory({key:w.heading1,isElement:!0,component:Ce,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:t=>s.jsx(Ce,{...t,styles:e})}),Ws="textstyle-heading2-plugin";class Ut extends i.Plugin{constructor({styles:t=T.heading2,...n}={}){super(w.heading2,{label:"Heading 2",markupElement:new qs,...n}),this.styles={},this.styles=t}plugins(){return[Gs(this.styles)]}}class qs extends i.MarkupElement{constructor(t=Ws,n=ke){super(t,n)}}const ke=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("h2",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},Gs=e=>o.createPluginFactory({key:w.heading2,isElement:!0,component:ke,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:t=>s.jsx(ke,{...t,styles:e})}),Ks="textstyle-heading3-plugin";class Ht extends i.Plugin{constructor({styles:t=T.heading3,...n}={}){super(w.heading3,{label:"Heading 3",markupElement:new Xs,...n}),this.styles={},this.styles=t}plugins(){return[Qs(this.styles)]}}class Xs extends i.MarkupElement{constructor(t=Ks,n=Se){super(t,n)}}const Se=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("h3",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},Qs=e=>o.createPluginFactory({key:w.heading3,isElement:!0,component:Se,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:t=>s.jsx(Se,{...t,styles:e})}),Ys="textstyle-heading4-plugin";class _t extends i.Plugin{constructor({styles:t=T.heading4,...n}={}){super(w.heading4,{label:"Heading 4",markupElement:new Js,...n}),this.styles={},this.styles=t}plugins(){return[Zs(this.styles)]}}class Js extends i.MarkupElement{constructor(t=Ys,n=Pe){super(t,n)}}const Pe=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("h4",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},Zs=e=>o.createPluginFactory({key:w.heading4,isElement:!0,component:Pe,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:t=>s.jsx(Pe,{...t,styles:e})}),er="textstyle-imageCaption-plugin";class Vt extends i.Plugin{constructor({styles:t=T.imageCaption,...n}={}){super(w.imageCaption,{label:"Image Caption",markupElement:new tr,...n}),this.styles={},this.styles=t}plugins(){return[nr(this.styles)]}}class tr extends i.MarkupElement{constructor(t=er,n=Ee){super(t,n)}}const Ee=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("p",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},nr=e=>o.createPluginFactory({key:w.imageCaption,isElement:!0,component:Ee,deserializeHtml:{rules:[{validClassName:w.imageCaption}]}})({component:t=>s.jsx(Ee,{...t,styles:e})}),sr="textstyle-imageTitle-plugin";class zt extends i.Plugin{constructor({styles:t=T.imageTitle,...n}={}){super(w.imageTitle,{label:"Image Title",markupElement:new rr,...n}),this.styles={},this.styles=t}plugins(){return[ar(this.styles)]}}class rr extends i.MarkupElement{constructor(t=sr,n=Ie){super(t,n)}}const Ie=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("p",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},ar=e=>o.createPluginFactory({key:w.imageTitle,isElement:!0,component:Ie,deserializeHtml:{rules:[{validClassName:w.imageTitle}]}})({component:t=>s.jsx(Ie,{...t,styles:e})});class $t extends i.Plugin{constructor({styles:t=T.p,...n}={}){super(w.p,{markupElement:new qt,label:"Body Text",...n}),this.styles={},this.styles=t}plugins(){return[Gt(this.styles)]}}const Wt="tw-m-0 tw-px-0 tw-py-0",me=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align,l=i.merge([a&&i.alignmentClassnames[a],Wt,i.getColumnBreakClasses(e)]);return s.jsx("p",{...t,className:l,style:r,children:n})};class qt extends i.MarkupElement{constructor(t=w.p,n=me){super(t,n)}}const Gt=e=>o.createPluginFactory({...o.createParagraphPlugin(),key:w.p,isElement:!0,component:me})({component:t=>s.jsx(me,{...t,styles:e})}),ir="textstyle-quote-plugin";class Kt extends i.Plugin{constructor({styles:t=T.quote,...n}={}){super(w.quote,{label:"Quote",markupElement:new or,...n}),this.styles={},this.styles=t}plugins(){return[Xt(this.styles)]}}class or extends i.MarkupElement{constructor(t=ir,n=he){super(t,n)}}const he=({element:e,attributes:t,children:n,styles:r})=>{const a=e.align;return s.jsx("blockquote",{...t,className:i.merge([a&&i.alignmentClassnames[a],i.getColumnBreakClasses(e)]),style:r,children:n})},Xt=e=>o.createPluginFactory({key:w.quote,isElement:!0,component:he,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:t=>s.jsx(he,{...t,styles:e})}),Me=[new Dt,new Ut,new Ht,new _t,new Nt,new Rt,new Mt,new Kt,new $t],Z=[w.heading1,w.heading2,w.heading3,w.heading4,w.custom1,w.custom2,w.custom3,w.quote,w.p],lr=[...Me,new Vt,new zt],cr=[...Z,w.imageCaption,w.imageTitle],ur=e=>new i.PluginComposer().setPlugin(new i.SoftBreakPlugin,new i.TextStylePlugin({textStyles:Me})).setPlugin([new i.BoldPlugin,new i.ItalicPlugin,new i.UnderlinePlugin,new i.StrikethroughPlugin,new Lt({appBridge:e}),new It({appBridge:e}),new i.CodePlugin],[new i.AlignLeftPlugin({validTypes:Z}),new i.AlignCenterPlugin({validTypes:Z}),new i.AlignRightPlugin({validTypes:Z}),new i.AlignJustifyPlugin({validTypes:Z}),new i.UnorderedListPlugin,new i.CheckboxListPlugin,new i.OrderedListPlugin,new i.ResetFormattingPlugin,new i.AutoformatPlugin]),dr="--f-theme-settings-",gr=e=>{const t=e!=null&&e.id?`hasBackground${e.id}`:"hasBackground",n=e!=null&&e.id?`backgroundColor${e.id}`:"backgroundColor",r=e!=null&&e.preventDefaultColor?void 0:(e==null?void 0:e.defaultColor)||wn,a=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Background",type:"switch",switchLabel:a,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,defaultValue:r,type:"colorInput"}]}},mr=e=>{const t=e!=null&&e.id?`hasBorder_${e.id}`:"hasBorder",n=e!=null&&e.id?`borderSelection_${e.id}`:"borderSelection",r=e!=null&&e.id?`borderStyle_${e.id}`:"borderStyle",a=e!=null&&e.id?`borderWidth_${e.id}`:"borderWidth",l=e!=null&&e.id?`borderColor_${e.id}`:"borderColor",c=(e==null?void 0:e.defaultColor)||Je,d=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Border",type:"switch",switchLabel:d,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,type:"multiInput",onChange:u=>m.appendUnit(u,a),layout:m.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:r,type:"dropdown",defaultValue:M.Solid,choices:[{value:M.Solid,label:M.Solid},{value:M.Dotted,label:M.Dotted},{value:M.Dashed,label:M.Dashed}]},{id:a,type:"input",defaultValue:yn,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px"},{id:l,type:"colorInput",defaultValue:c}]}],off:[]}},Oe=(e,t=_.None)=>({id:e,type:"segmentedControls",defaultValue:t,choices:[{value:_.None,label:"None"},{value:_.Small,label:"S"},{value:_.Medium,label:"M"},{value:_.Large,label:"L"}]}),hr=e=>{const t=e!=null&&e.id?`hasRadius_${e.id}`:"hasRadius",n=e!=null&&e.id?`radiusValue_${e.id}`:"radiusValue",r=e!=null&&e.id?`radiusChoice_${e.id}`:"radiusChoice",a=(e==null?void 0:e.defaultRadius)||_.None;return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:l=>{var c;return e!=null&&e.dependentSettingId?!!((c=l.getBlock(e.dependentSettingId))!=null&&c.value):!0},onChange:l=>m.presetCustomValue(l,r,n,(e==null?void 0:e.radiusStyleMap)||G),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,n)}],off:[Oe(r,a)]}},fr=e=>{const t=e!=null&&e.id?`hasExtendedCustomRadius_${e.id}`:"hasExtendedCustomRadius",n=e!=null&&e.id?`extendedRadiusValue_${e.id}`:"extendedRadiusValue",r=e!=null&&e.id?`extendedRadiusChoice_${e.id}`:"extendedRadiusChoice",a=e!=null&&e.id?`extendedRadiusTopLeft_${e.id}`:"extendedRadiusTopLeft",l=e!=null&&e.id?`extendedRadiusTopRight_${e.id}`:"extendedRadiusTopRight",c=e!=null&&e.id?`extendedRadiusBottomLeft_${e.id}`:"extendedRadiusBottomLeft",d=e!=null&&e.id?`extendedRadiusBottomRight_${e.id}`:"extendedRadiusBottomRight";return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:u=>{var f;return e!=null&&e.dependentSettingId?!!((f=u.getBlock(e.dependentSettingId))!=null&&f.value):!0},onChange:u=>{m.presetCustomValue(u,r,a,G),m.presetCustomValue(u,r,l,G),m.presetCustomValue(u,r,c,G),m.presetCustomValue(u,r,d,G)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,blocks:[{id:a,type:"input",label:"Top Left",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,a)},{id:l,type:"input",label:"Top Right",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,l)},{id:c,type:"input",label:"Bottom Left",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,c)},{id:d,type:"input",label:"Bottom Right",rules:[m.numericalOrPixelRule],onChange:u=>m.appendUnit(u,d)}]}],off:[Oe(r,e==null?void 0:e.defaultValue)]}},pr=e=>{const t=e!=null&&e.id?e.id:"hasCustomSpacing",n=e!=null&&e.dependentSettingId?e.dependentSettingId:"columns",r=e!=null&&e.spacingChoiceId?e.spacingChoiceId:"spacingChoice",a=e!=null&&e.spacingCustomId?e.spacingCustomId:"spacingCustom",l=e!=null&&e.defaultValueChoices?e.defaultValueChoices:q.M;return{id:t,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:c=>m.presetCustomValue(c,r,a,Ye),show:c=>{var d;return((d=c.getBlock(n))==null?void 0:d.value)!=="1"},on:[{id:a,type:"input",rules:[m.numericalOrPixelRule],onChange:c=>m.appendUnit(c,a)}],off:[{id:r,type:"slider",defaultValue:l,choices:[{value:q.Auto,label:"Auto"},{value:q.S,label:"S"},{value:q.M,label:"M"},{value:q.L,label:"L"}]}]}},De=e=>({id:e,type:"segmentedControls",defaultValue:W.None,choices:[{value:W.None,label:"None"},{value:W.Small,label:"S"},{value:W.Medium,label:"M"},{value:W.Large,label:"L"}]}),xr=e=>{const t=e!=null&&e.id?`hasCustomMarginValue_${e==null?void 0:e.id}`:"hasCustomMarginValue",n=e!=null&&e.id?`marginValue_${e==null?void 0:e.id}`:"marginValue",r=e!=null&&e.id?`marginChoice_${e==null?void 0:e.id}`:"marginChoice";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:a=>m.presetCustomValue(a,r,n,(e==null?void 0:e.marginStyleMap)||J),on:[{id:n,type:"input",placeholder:ae,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:a=>m.appendUnit(a,n)}],off:[De(r)]}},wr=e=>{const t=e!=null&&e.id?`hasExtendedCustomMargin_${e==null?void 0:e.id}`:"hasExtendedCustomMargin",n=e!=null&&e.id?`extendedMarginValues_${e==null?void 0:e.id}`:"extendedMarginValues",r=e!=null&&e.id?`extendedMarginChoice_${e==null?void 0:e.id}`:"extendedMarginChoice",a=e!=null&&e.id?`extendedMarginTop_${e==null?void 0:e.id}`:"extendedMarginTop",l=e!=null&&e.id?`extendedMarginLeft_${e==null?void 0:e.id}`:"extendedMarginLeft",c=e!=null&&e.id?`extendedMarginRight_${e==null?void 0:e.id}`:"extendedMarginRight",d=e!=null&&e.id?`extendedMarginBottom_${e==null?void 0:e.id}`:"extendedMarginBottom";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:u=>{m.presetCustomValue(u,r,a,J),m.presetCustomValue(u,r,l,J),m.presetCustomValue(u,r,c,J),m.presetCustomValue(u,r,d,J)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:a,type:"input",label:"Top",placeholder:ae,onChange:u=>m.appendUnit(u,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Left",placeholder:ae,onChange:u=>m.appendUnit(u,l),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:ae,onChange:u=>m.appendUnit(u,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:ae,onChange:u=>m.appendUnit(u,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[De(r)]}},Ue=e=>({id:e,type:"segmentedControls",defaultValue:$.Small,choices:[{value:$.None,label:"None"},{value:$.Small,label:"S"},{value:$.Medium,label:"M"},{value:$.Large,label:"L"}]}),yr=e=>{const t=e!=null&&e.id?`hasCustomPaddingValue_${e==null?void 0:e.id}`:"hasCustomPaddingValue",n=e!=null&&e.id?`paddingValue_${e==null?void 0:e.id}`:"paddingValue",r=e!=null&&e.id?`paddingChoice_${e==null?void 0:e.id}`:"paddingChoice";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:a=>m.presetCustomValue(a,r,n,(e==null?void 0:e.paddingStyleMap)||Y),on:[{id:n,type:"input",placeholder:re,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:a=>m.appendUnit(a,n)}],off:[Ue(r)]}},br=e=>{const t=e!=null&&e.id?`hasExtendedCustomPadding_${e==null?void 0:e.id}`:"hasExtendedCustomPadding",n=e!=null&&e.id?`extendedPaddingValues_${e==null?void 0:e.id}`:"extendedPaddingValues",r=e!=null&&e.id?`extendedPaddingChoice_${e==null?void 0:e.id}`:"extendedPaddingChoice",a=e!=null&&e.id?`extendedPaddingTop_${e==null?void 0:e.id}`:"extendedPaddingTop",l=e!=null&&e.id?`extendedPaddingLeft_${e==null?void 0:e.id}`:"extendedPaddingLeft",c=e!=null&&e.id?`extendedPaddingRight_${e==null?void 0:e.id}`:"extendedPaddingRight",d=e!=null&&e.id?`extendedPaddingBottom_${e==null?void 0:e.id}`:"extendedPaddingBottom";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:u=>{m.presetCustomValue(u,r,a,Y),m.presetCustomValue(u,r,l,Y),m.presetCustomValue(u,r,c,Y),m.presetCustomValue(u,r,d,Y)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:a,type:"input",label:"Top",placeholder:re,onChange:u=>m.appendUnit(u,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:l,type:"input",label:"Left",placeholder:re,onChange:u=>m.appendUnit(u,l),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:re,onChange:u=>m.appendUnit(u,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:re,onChange:u=>m.appendUnit(u,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Ue(r)]}},vr=e=>{const t=He(e==null?void 0:e.globalControlId);return{id:e!=null&&e.id?e.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>{var r;return((r=n.getBlock(t))==null?void 0:r.value)===K.Custom}}},He=e=>e||"security",Cr=e=>[{id:He(e),type:"segmentedControls",defaultValue:K.Global,choices:[{value:K.Global,label:"Global Settings"},{value:K.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:m.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Qt=(e=>(e.Main="main",e.Basics="basics",e.Layout="layout",e.Style="style",e.Security="security",e.Targets="targets",e))(Qt||{});const kr=e=>e,Sr=e=>e;exports.AllTextStylePlugins=lr;exports.AllTextStyles=cr;exports.Attachments=tt;exports.AttachmentsProvider=rt;exports.BUTTON_PLUGIN=Pt;exports.BlockButtonStyles=we;exports.BlockInjectButton=ln;exports.BlockItemWrapper=Ln;exports.BlockStyles=T;exports.BorderStyle=M;exports.ButtonPlugin=It;exports.Custom1Plugin=Nt;exports.Custom2Plugin=Rt;exports.Custom3Plugin=Mt;exports.DEFAULT_DRAGGING_TOOLTIP=et;exports.DEFAULT_DRAG_TOOLTIP=Ze;exports.DownloadButton=Nn;exports.ELEMENT_BUTTON=C;exports.GutterSpacing=q;exports.Heading1Plugin=Dt;exports.Heading2Plugin=Ut;exports.Heading3Plugin=Ht;exports.Heading4Plugin=_t;exports.ImageCaptionPlugin=Vt;exports.ImageTitlePlugin=zt;exports.LinkInput=kt;exports.LinkPlugin=Lt;exports.LinkSelector=Ct;exports.Margin=W;exports.PARAGRAPH_CLASSES=Wt;exports.Padding=$;exports.ParagraphMarkupElement=qt;exports.ParagraphMarkupElementNode=me;exports.ParagraphPlugin=$t;exports.QuoteMarkupElementNode=he;exports.QuotePlugin=Kt;exports.Radius=_;exports.RichTextEditor=ws;exports.Sections=Qt;exports.Security=K;exports.THEME_PREFIX=dr;exports.TextStylePluginsWithoutImage=Me;exports.TextStyles=w;exports.TextStylesWithoutImage=Z;exports.Toolbar=ot;exports.addHttps=fe;exports.borderStyleMap=Qe;exports.convertToRteValue=Rn;exports.createButtonNode=yt;exports.createButtonPlugin=Et;exports.createLinkPlugin=jt;exports.createParagraphPlugin=Gt;exports.createQuotePlugin=Xt;exports.customCoordinatesGetterFactory=it;exports.defineBlock=kr;exports.defineSettings=Sr;exports.getBackgroundColorStyles=xn;exports.getBackgroundSettings=gr;exports.getBorderRadiusSettings=hr;exports.getBorderRadiusSlider=Oe;exports.getBorderSettings=mr;exports.getBorderStyles=bn;exports.getDefaultPluginsWithLinkChooser=ur;exports.getExtendedBorderRadiusSettings=fr;exports.getGutterSettings=pr;exports.getLegacyUrl=ut;exports.getLinkFromEditor=mt;exports.getMarginExtendedSettings=wr;exports.getMarginSettings=xr;exports.getMarginSlider=De;exports.getPaddingExtendedSettings=br;exports.getPaddingSettings=yr;exports.getPaddingSlider=Ue;exports.getRadiusStyles=vn;exports.getReadableColor=fn;exports.getSecurityDownloadableSetting=vr;exports.getSecurityGlobalControlId=He;exports.getSecurityGlobalControlSetting=Cr;exports.getUrl=dt;exports.getUrlFromEditor=wt;exports.getUrlFromLinkOrLegacyLink=gt;exports.gutterSpacingStyleMap=Ye;exports.hasRichTextValue=lt;exports.insertButton=ft;exports.isDark=un;exports.isDownloadable=Fn;exports.isValidUrl=pe;exports.isValidUrlOrEmpty=ee;exports.joinClassNames=U;exports.mapAppBridgeColorPaletteToFonduePalette=ct;exports.mapAppBridgeColorPalettesToFonduePalettes=Mn;exports.marginStyleMap=J;exports.moveItemInArray=pn;exports.paddingStyleMap=Y;exports.radiusStyleMap=G;exports.relativeUrlRegex=Le;exports.setAlpha=mn;exports.submitFloatingButton=Ae;exports.toColorObject=hn;exports.toHex8String=dn;exports.toHexString=gn;exports.toRgbaString=Te;exports.toShortRgba=X;exports.triggerFloatingButton=bt;exports.triggerFloatingButtonEdit=xe;exports.triggerFloatingButtonInsert=Fe;exports.unwrapButton=ne;exports.upsertButton=pt;exports.upsertButtonText=Re;exports.useAttachments=nt;exports.useAttachmentsContext=at;exports.useDndSensors=Tn;exports.withAttachmentsProvider=Pn;exports.withButton=ht;exports.wrapButton=xt;Object.keys(m).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>m[e]})});
4
4
  //# sourceMappingURL=index.cjs.js.map