tiptap-editor-codeveda 0.1.18 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
- (function(H,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@tiptap/extension-table"),require("@tiptap/extension-table-row"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-image"),require("@tiptap/extension-link"),require("@tiptap/extension-text-style"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-code-block-lowlight"),require("lowlight"),require("@tiptap/core"),require("@tiptap/extension-underline"),require("@tiptap/extension-strike"),require("@tiptap/extension-blockquote"),require("@tiptap/extension-horizontal-rule"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("@floating-ui/react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-table","@tiptap/extension-table-row","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-image","@tiptap/extension-link","@tiptap/extension-text-style","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-code-block-lowlight","lowlight","@tiptap/core","@tiptap/extension-underline","@tiptap/extension-strike","@tiptap/extension-blockquote","@tiptap/extension-horizontal-rule","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","@floating-ui/react","react-dom"],T):(H=typeof globalThis<"u"?globalThis:H||self,T(H.TiptapEditorCodeveda={},H.React,H.react,H.StarterKit,H.extensionTable,H.TableRow,H.TableCell,H.TableHeader,H.Image,H.Link,H.extensionTextStyle,H.Color,H.Highlight,H.CodeBlockLowlight,H.lowlight$1,H.core,H.Underline,H.Strike,H.Blockquote,H.HorizontalRule,H.lucideReact,H.reactSlot,H.classVarianceAuthority,H.clsx,H.tailwindMerge,H.react$1,H.ReactDOM))})(this,(function(H,T,Z,$r,Kr,$t,Kt,qt,qr,Wr,Jr,Vr,Gr,Yr,Wt,W,Zr,Xr,Qr,es,M,ts,ns,rs,ss,se,Jt){"use strict";function os(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const he=os(T);var Ze={exports:{}},$e={};/**
1
+ (function(H,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@tiptap/extension-table"),require("@tiptap/extension-table-row"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-image"),require("@tiptap/extension-link"),require("@tiptap/extension-text-style"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-code-block-lowlight"),require("lowlight"),require("@tiptap/core"),require("@tiptap/extension-underline"),require("@tiptap/extension-strike"),require("@tiptap/extension-blockquote"),require("@tiptap/extension-horizontal-rule"),require("lucide-react"),require("@radix-ui/react-slot"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("@floating-ui/react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@tiptap/react","@tiptap/starter-kit","@tiptap/extension-table","@tiptap/extension-table-row","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-image","@tiptap/extension-link","@tiptap/extension-text-style","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-code-block-lowlight","lowlight","@tiptap/core","@tiptap/extension-underline","@tiptap/extension-strike","@tiptap/extension-blockquote","@tiptap/extension-horizontal-rule","lucide-react","@radix-ui/react-slot","class-variance-authority","clsx","tailwind-merge","@floating-ui/react","react-dom"],T):(H=typeof globalThis<"u"?globalThis:H||self,T(H.TiptapEditorCodeveda={},H.React,H.react,H.StarterKit,H.extensionTable,H.TableRow,H.TableCell,H.TableHeader,H.Image,H.Link,H.extensionTextStyle,H.Color,H.Highlight,H.CodeBlockLowlight,H.lowlight$1,H.core,H.Underline,H.Strike,H.Blockquote,H.HorizontalRule,H.lucideReact,H.reactSlot,H.classVarianceAuthority,H.clsx,H.tailwindMerge,H.react$1,H.ReactDOM))})(this,(function(H,T,Z,Kr,qr,$t,Kt,qt,Wr,Jr,Vr,Gr,Yr,Zr,Wt,W,Xr,Qr,es,ts,M,ns,rs,ss,os,se,Jt){"use strict";function is(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const he=is(T);var Ze={exports:{}},$e={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Vt;function is(){if(Vt)return $e;Vt=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var a in s)a!=="key"&&(o[a]=s[a])}else o=s;return s=o.ref,{$$typeof:t,type:r,key:i,ref:s!==void 0?s:null,props:o}}return $e.Fragment=e,$e.jsx=n,$e.jsxs=n,$e}var Ke={};/**
9
+ */var Vt;function as(){if(Vt)return $e;Vt=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var a in s)a!=="key"&&(o[a]=s[a])}else o=s;return s=o.ref,{$$typeof:t,type:r,key:i,ref:s!==void 0?s:null,props:o}}return $e.Fragment=e,$e.jsx=n,$e.jsxs=n,$e}var Ke={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,11 +14,11 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var Gt;function as(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&(function(){function t(b){if(b==null)return null;if(typeof b=="function")return b.$$typeof===L?null:b.displayName||b.name||null;if(typeof b=="string")return b;switch(b){case w:return"Fragment";case N:return"Profiler";case p:return"StrictMode";case v:return"Suspense";case x:return"SuspenseList";case P:return"Activity"}if(typeof b=="object")switch(typeof b.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),b.$$typeof){case g:return"Portal";case y:return(b.displayName||"Context")+".Provider";case S:return(b._context.displayName||"Context")+".Consumer";case _:var A=b.render;return b=b.displayName,b||(b=A.displayName||A.name||"",b=b!==""?"ForwardRef("+b+")":"ForwardRef"),b;case O:return A=b.displayName||null,A!==null?A:t(b.type)||"Memo";case E:A=b._payload,b=b._init;try{return t(b(A))}catch{}}return null}function e(b){return""+b}function n(b){try{e(b);var A=!1}catch{A=!0}if(A){A=console;var j=A.error,J=typeof Symbol=="function"&&Symbol.toStringTag&&b[Symbol.toStringTag]||b.constructor.name||"Object";return j.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",J),e(b)}}function r(b){if(b===w)return"<>";if(typeof b=="object"&&b!==null&&b.$$typeof===E)return"<...>";try{var A=t(b);return A?"<"+A+">":"<...>"}catch{return"<...>"}}function s(){var b=$.A;return b===null?null:b.getOwner()}function o(){return Error("react-stack-top-frame")}function i(b){if(V.call(b,"key")){var A=Object.getOwnPropertyDescriptor(b,"key").get;if(A&&A.isReactWarning)return!1}return b.key!==void 0}function a(b,A){function j(){I||(I=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",A))}j.isReactWarning=!0,Object.defineProperty(b,"key",{get:j,configurable:!0})}function c(){var b=t(this.type);return C[b]||(C[b]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),b=this.props.ref,b!==void 0?b:null}function u(b,A,j,J,re,ee,Fe,oe){return j=ee.ref,b={$$typeof:h,type:b,key:A,props:ee,_owner:re},(j!==void 0?j:null)!==null?Object.defineProperty(b,"ref",{enumerable:!1,get:c}):Object.defineProperty(b,"ref",{enumerable:!1,value:null}),b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(b,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(b,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Fe}),Object.defineProperty(b,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:oe}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b}function d(b,A,j,J,re,ee,Fe,oe){var X=A.children;if(X!==void 0)if(J)if(D(X)){for(J=0;J<X.length;J++)f(X[J]);Object.freeze&&Object.freeze(X)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(X);if(V.call(A,"key")){X=t(b);var Oe=Object.keys(A).filter(function(yi){return yi!=="key"});J=0<Oe.length?"{key: someKey, "+Oe.join(": ..., ")+": ...}":"{key: someKey}",z[X+J]||(Oe=0<Oe.length?"{"+Oe.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var Gt;function ls(){return Gt||(Gt=1,process.env.NODE_ENV!=="production"&&(function(){function t(b){if(b==null)return null;if(typeof b=="function")return b.$$typeof===E?null:b.displayName||b.name||null;if(typeof b=="string")return b;switch(b){case w:return"Fragment";case N:return"Profiler";case g:return"StrictMode";case x:return"Suspense";case _:return"SuspenseList";case U:return"Activity"}if(typeof b=="object")switch(typeof b.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),b.$$typeof){case m:return"Portal";case y:return(b.displayName||"Context")+".Provider";case C:return(b._context.displayName||"Context")+".Consumer";case S:var O=b.render;return b=b.displayName,b||(b=O.displayName||O.name||"",b=b!==""?"ForwardRef("+b+")":"ForwardRef"),b;case D:return O=b.displayName||null,O!==null?O:t(b.type)||"Memo";case v:O=b._payload,b=b._init;try{return t(b(O))}catch{}}return null}function e(b){return""+b}function n(b){try{e(b);var O=!1}catch{O=!0}if(O){O=console;var j=O.error,J=typeof Symbol=="function"&&Symbol.toStringTag&&b[Symbol.toStringTag]||b.constructor.name||"Object";return j.call(O,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",J),e(b)}}function r(b){if(b===w)return"<>";if(typeof b=="object"&&b!==null&&b.$$typeof===v)return"<...>";try{var O=t(b);return O?"<"+O+">":"<...>"}catch{return"<...>"}}function s(){var b=z.A;return b===null?null:b.getOwner()}function o(){return Error("react-stack-top-frame")}function i(b){if(V.call(b,"key")){var O=Object.getOwnPropertyDescriptor(b,"key").get;if(O&&O.isReactWarning)return!1}return b.key!==void 0}function a(b,O){function j(){L||(L=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",O))}j.isReactWarning=!0,Object.defineProperty(b,"key",{get:j,configurable:!0})}function c(){var b=t(this.type);return k[b]||(k[b]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),b=this.props.ref,b!==void 0?b:null}function u(b,O,j,J,re,ee,He,oe){return j=ee.ref,b={$$typeof:p,type:b,key:O,props:ee,_owner:re},(j!==void 0?j:null)!==null?Object.defineProperty(b,"ref",{enumerable:!1,get:c}):Object.defineProperty(b,"ref",{enumerable:!1,value:null}),b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(b,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(b,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:He}),Object.defineProperty(b,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:oe}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b}function d(b,O,j,J,re,ee,He,oe){var X=O.children;if(X!==void 0)if(J)if(R(X)){for(J=0;J<X.length;J++)f(X[J]);Object.freeze&&Object.freeze(X)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(X);if(V.call(O,"key")){X=t(b);var Oe=Object.keys(O).filter(function(xi){return xi!=="key"});J=0<Oe.length?"{key: someKey, "+Oe.join(": ..., ")+": ...}":"{key: someKey}",B[X+J]||(Oe=0<Oe.length?"{"+Oe.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,J,X,Oe,X),z[X+J]=!0)}if(X=null,j!==void 0&&(n(j),X=""+j),i(A)&&(n(A.key),X=""+A.key),"key"in A){j={};for(var Ce in A)Ce!=="key"&&(j[Ce]=A[Ce])}else j=A;return X&&a(j,typeof b=="function"?b.displayName||b.name||"Unknown":b),u(b,X,ee,re,s(),j,Fe,oe)}function f(b){typeof b=="object"&&b!==null&&b.$$typeof===h&&b._store&&(b._store.validated=1)}var m=T,h=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),y=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),L=Symbol.for("react.client.reference"),$=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,D=Array.isArray,R=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(b){return b()}};var I,C={},U=m.react_stack_bottom_frame.bind(m,o)(),k=R(r(o)),z={};Ke.Fragment=w,Ke.jsx=function(b,A,j,J,re){var ee=1e4>$.recentlyCreatedOwnerStacks++;return d(b,A,j,!1,J,re,ee?Error("react-stack-top-frame"):U,ee?R(r(b)):k)},Ke.jsxs=function(b,A,j,J,re){var ee=1e4>$.recentlyCreatedOwnerStacks++;return d(b,A,j,!0,J,re,ee?Error("react-stack-top-frame"):U,ee?R(r(b)):k)}})()),Ke}var Yt;function ls(){return Yt||(Yt=1,process.env.NODE_ENV==="production"?Ze.exports=is():Ze.exports=as()),Ze.exports}var l=ls();const Zt=$r.configure({codeBlock:!1}),Xt=Kr.Table.configure({resizable:!0}),Qt=qr.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}),en=Wr.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),tn=Jr.TextStyle,nn=Vr.configure({types:["textStyle"]}),rn=Gr.configure({multicolor:!0}),cs=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),us=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],ds=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],fs=[...us,...ds],ps=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),hs=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),ms=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),gs=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function bs(t){const e=t.regex,n=cs(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",o=/@-?\w[\w]*(-\w+)*/,i="[a-zA-Z-][a-zA-Z0-9_-]*",a=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+i,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+hs.join("|")+")"},{begin:":(:)?("+ms.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+gs.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...a,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:ps.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...a,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+fs.join("|")+")\\b"}]}}const sn="[A-Za-z$_][0-9A-Za-z$_]*",ws=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],ys=["true","false","null","undefined","NaN","Infinity"],on=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],an=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],ln=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],xs=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],vs=[].concat(ln,on,an);function Es(t){const e=t.regex,n=(k,{after:z})=>{const b="</"+k[0].slice(1);return k.input.indexOf(b,z)!==-1},r=sn,s={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(k,z)=>{const b=k[0].length+k.index,A=k.input[b];if(A==="<"||A===","){z.ignoreMatch();return}A===">"&&(n(k,{after:b})||z.ignoreMatch());let j;const J=k.input.substring(b);if(j=J.match(/^\s*=/)){z.ignoreMatch();return}if((j=J.match(/^\s+extends\s+/))&&j.index===0){z.ignoreMatch();return}}},a={$pattern:sn,keyword:ws,literal:ys,built_in:vs,"variable.language":xs},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},h={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},p={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,m]},S={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},y=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,g,w,p,{match:/\$\d+/},f];m.contains=y.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(y)});const _=[].concat(S,m.contains),v=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(_)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:v},O={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},E={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...on,...an]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},L={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[x],illegal:/%/},$={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(k){return e.concat("(?!",k.join("|"),")")}const D={match:e.concat(/\b/,V([...ln,"super","import"].map(k=>`${k}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},R={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},I={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",U={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:v,CLASS_REFERENCE:E},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,g,w,p,S,{match:/\$\d+/},f,E,{scope:"attr",match:r+e.lookahead(":"),relevance:0},U,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,t.REGEXP_MODE,{className:"function",begin:C,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:v}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},L,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},R,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},D,$,O,I,{match:/\$[(.]/}]}}const Xe="[A-Za-z$_][0-9A-Za-z$_]*",cn=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],un=["true","false","null","undefined","NaN","Infinity"],dn=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],fn=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],pn=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],hn=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],mn=[].concat(pn,dn,fn);function Ns(t){const e=t.regex,n=(k,{after:z})=>{const b="</"+k[0].slice(1);return k.input.indexOf(b,z)!==-1},r=Xe,s={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(k,z)=>{const b=k[0].length+k.index,A=k.input[b];if(A==="<"||A===","){z.ignoreMatch();return}A===">"&&(n(k,{after:b})||z.ignoreMatch());let j;const J=k.input.substring(b);if(j=J.match(/^\s*=/)){z.ignoreMatch();return}if((j=J.match(/^\s+extends\s+/))&&j.index===0){z.ignoreMatch();return}}},a={$pattern:Xe,keyword:cn,literal:un,built_in:mn,"variable.language":hn},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},m={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},h={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,m],subLanguage:"graphql"}},p={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,m]},S={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},y=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,g,w,p,{match:/\$\d+/},f];m.contains=y.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(y)});const _=[].concat(S,m.contains),v=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(_)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:v},O={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},E={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...dn,...fn]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},L={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[x],illegal:/%/},$={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(k){return e.concat("(?!",k.join("|"),")")}const D={match:e.concat(/\b/,V([...pn,"super","import"].map(k=>`${k}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},R={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},I={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",U={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:v,CLASS_REFERENCE:E},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,h,g,w,p,S,{match:/\$\d+/},f,E,{scope:"attr",match:r+e.lookahead(":"),relevance:0},U,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,t.REGEXP_MODE,{className:"function",begin:C,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:v}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},L,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},R,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},D,$,O,I,{match:/\$[(.]/}]}}function _s(t){const e=t.regex,n=Ns(t),r=Xe,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},i={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},a={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:Xe,keyword:cn.concat(c),literal:un,built_in:mn.concat(s),"variable.language":hn},d={className:"meta",begin:"@"+r},f=(w,p,N)=>{const S=w.contains.findIndex(y=>y.label===p);if(S===-1)throw new Error("can not find mode to replace");w.contains.splice(S,1,N)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(d);const m=n.contains.find(w=>w.scope==="attr"),h=Object.assign({},m,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,m,h]),n.contains=n.contains.concat([d,o,i,h]),f(n,"shebang",t.SHEBANG()),f(n,"use_strict",a);const g=n.contains.find(w=>w.label==="func.def");return g.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Ss(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},i=t.inherit(o,{begin:/\(/,end:/\)/}),a=t.inherit(t.APOS_STRING_MODE,{className:"string"}),c=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,c,a,i,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,i,c,a]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Cs(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},d={begin:/\{\{/,relevance:0},f={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c,d,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,d,u]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},m="[0-9](_?[0-9])*",h=`(\\b(${m}))?\\.(${m})|\\b(${m})\\.`,g=`\\b|${r.join("|")}`,w={className:"number",relevance:0,variants:[{begin:`(\\b(${m})|(${h}))[eE][+-]?(${m})[jJ]?(?=${g})`},{begin:`(${h})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${g})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${g})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${g})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${g})`},{begin:`\\b(${m})[jJ](?=${g})`}]},p={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",c,w,f,t.HASH_COMMENT_MODE]}]};return u.contains=[f,w,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|\?)|=>/,contains:[c,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,p,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[w,N,f]}]}}var Le="[0-9](_*[0-9])*",Qe=`\\.(${Le})`,et="[0-9a-fA-F](_*[0-9a-fA-F])*",gn={className:"number",variants:[{begin:`(\\b(${Le})((${Qe})|\\.)?|(${Qe}))[eE][+-]?(${Le})[fFdD]?\\b`},{begin:`\\b(${Le})((${Qe})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Qe})[fFdD]?\\b`},{begin:`\\b(${Le})[fFdD]\\b`},{begin:`\\b0[xX]((${et})\\.?|(${et})?\\.(${et}))[pP][+-]?(${Le})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${et})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function bn(t,e,n){return n===-1?"":t.replace(e,r=>bn(t,e,n-1))}function Ts(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+bn("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),c={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},d={className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:c,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[d,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:c,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[u,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,gn,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},gn,u]}}function ks(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",i="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",a={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},h=e.optional(s)+t.IDENT_RE+"\\s*\\(",p={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},N=[f,a,n,t.C_BLOCK_COMMENT_MODE,d,u],S={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:p,contains:N.concat([{begin:/\(/,end:/\)/,keywords:p,contains:N.concat(["self"]),relevance:0}]),relevance:0},y={begin:"("+i+"[\\*&\\s]+)+"+h,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:p,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:p,relevance:0},{begin:h,returnBegin:!0,contains:[t.inherit(m,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,d,a,{begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,d,a]}]},a,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:p,disableAutodetect:!0,illegal:"</",contains:[].concat(S,y,N,[f,{begin:t.IDENT_RE+"::",keywords:p},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:f,strings:u,keywords:p}}}function As(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",i="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",a={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},h=e.optional(s)+t.IDENT_RE+"\\s*\\(",g=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],p=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],N=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],_={type:w,keyword:g,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:p},v={className:"function.dispatch",relevance:0,keywords:{_hint:N},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},x=[v,f,a,n,t.C_BLOCK_COMMENT_MODE,d,u],O={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:_,contains:x.concat([{begin:/\(/,end:/\)/,keywords:_,contains:x.concat(["self"]),relevance:0}]),relevance:0},E={className:"function",begin:"("+i+"[\\*&\\s]+)+"+h,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:_,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:_,relevance:0},{begin:h,returnBegin:!0,contains:[m],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,d]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,d,a,{begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,d,a]}]},a,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:_,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(O,E,v,x,[f,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:_,contains:["self",a]},{begin:t.IDENT_RE+"::",keywords:_},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function Os(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],i=["double precision","large object","with timezone","without timezone"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],m=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],h=d,g=[...u,...c].filter(v=>!d.includes(v)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},p={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},N={match:e.concat(/\b/,e.either(...h),/\s*\(/),relevance:0,keywords:{built_in:h}};function S(v){return e.concat(/\b/,e.either(...v.map(x=>x.replace(/\s+/,"\\s+"))),/\b/)}const y={scope:"keyword",match:S(m),relevance:0};function _(v,{exceptions:x,when:O}={}){const E=O;return x=x||[],v.map(P=>P.match(/\|\d+$/)||x.includes(P)?P:E(P)?`${P}|0`:P)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:_(g,{when:v=>v.length<3}),literal:o,type:a,built_in:f},contains:[{scope:"type",match:S(i)},y,N,w,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,p]}}const wn=W.Mark.create({name:"codeBlockBg",addOptions(){return{multicolor:!0,HTMLAttributes:{}}},inclusive:!1,addAttributes(){return{color:{default:null,parseHTML:t=>t.getAttribute("data-background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-background-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}},parseHTML(){return[{tag:"span[data-background-color]",getAttrs:t=>typeof t=="string"?!1:{color:t.getAttribute("data-background-color")}}]},renderHTML({HTMLAttributes:t,mark:e}){const n=e.attrs?.color||t["data-background-color"];return n?["span",{"data-background-color":n,style:`background-color: ${n}; color: inherit`},0]:["span",{},0]},addCommands(){return{setCodeBlockBg:t=>({commands:e})=>e.setMark(this.name,{color:t}),toggleCodeBlockBg:t=>({commands:e})=>e.toggleMark(this.name,{color:t}),unsetCodeBlockBg:()=>({commands:t})=>t.unsetMark(this.name)}}}),me=Wt.createLowlight(Wt.all);me.register("html",Ss),me.register("css",bs),me.register("js",Es),me.register("ts",_s),me.register("java",Ts),me.register("c",ks),me.register("cpp",As),me.register("python",Cs),me.register("sql",Os);const yn=Yr.extend({marks(){return"codeBlockBg"}}).configure({lowlight:me}),xn=Zr,vn=Xr,En=Qr,Nn=es;function Rs({node:t,updateAttributes:e,editor:n}){const[r,s]=T.useState(t.attrs?.open??!0),[o,i]=T.useState(!1),[a,c]=T.useState(t.attrs?.title||"Output"),u=T.useRef(null),d=n?.isEditable??!1;T.useEffect(()=>{o&&u.current&&(u.current.focus(),u.current.select())},[o]);const f=()=>{i(!1),e({title:a,open:r})},m=p=>{p.key==="Enter"?f():p.key==="Escape"&&(c(t.attrs?.title||"Output"),i(!1))},h=()=>{const p=!r;s(p),e({title:a,open:p})},g=()=>{d&&n&&confirm("Are you sure you want to delete this accordion?")&&n.chain().focus().deleteNode("accordion").run()},w=p=>{if(!d||!n)return;const{selection:N}=n.state,{$anchor:S}=N;if(p.key==="Enter"&&!p.shiftKey&&S.nodeBefore?.type.name==="accordion"){p.preventDefault(),p.stopPropagation();const y=S.nodeBefore;if(y&&y.childCount>0){const _=y.lastChild;if(_&&_.content.size>0){let v=-1;if(n.state.doc.descendants((x,O)=>{if(x.type.name==="accordionItem")return v=O,!1}),v!==-1){const x=v+_.nodeSize-2;n.chain().focus().setTextSelection(x).run()}}else{let v=-1;n.state.doc.descendants((x,O)=>{if(x.type.name==="accordionItem")return v=O,!1}),v!==-1&&n.chain().focus().setTextSelection(v+1).run()}}return}if((p.key==="Backspace"||p.key==="Delete")&&!p.shiftKey){if(S.nodeBefore?.type.name==="accordion"){p.preventDefault(),p.stopPropagation();return}if(S.nodeAfter?.type.name==="accordion"){p.preventDefault(),p.stopPropagation();return}if(S.parent.type.name==="accordionItem"){const y=S.parent,_=S.parentOffset===0,v=y.content.content.some(x=>x.type.name==="paragraph"?x.content.size>0:!0);if(_&&!v&&p.key==="Backspace"){p.preventDefault(),p.stopPropagation();return}}if(S.parent.type.name==="accordion"&&!S.parent.content.content.some(v=>v.type.name==="accordionItem"?v.content.content.some(x=>x.type.name==="paragraph"?x.content.size>0:!0):!0)){p.preventDefault(),p.stopPropagation();return}}};return l.jsxs(Z.NodeViewWrapper,{className:"accordion border border-gray-200 rounded-lg mb-3 overflow-hidden",onKeyDown:w,children:[l.jsx("div",{className:"accordion-header bg-gray-50 border-b border-gray-200",onClick:h,children:l.jsxs("div",{className:"flex items-center gap-2 px-1",children:[l.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),h()},className:"flex items-center justify-center w-6 h-6 text-gray-600 hover:text-gray-800",title:r?"Collapse":"Expand",children:l.jsx("span",{className:`cursor-pointer transition-transform duration-200 ${r?"rotate-90":""}`,children:"▶"})}),o?l.jsx("input",{ref:u,type:"text",value:a,onChange:p=>c(p.target.value),onBlur:f,onKeyDown:m,className:"bg-transparent border-b border-gray-300 outline-none font-medium text-gray-800 flex-1 py-1",placeholder:"Enter accordion title..."}):l.jsx("div",{onClick:d?p=>{p.stopPropagation(),i(!0)}:void 0,className:`font-medium text-gray-800 flex-1 py-1 ${d?"cursor-text hover:text-blue-600":"cursor-pointer"}`,title:d?"Click to edit title":void 0,children:a}),d&&l.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),g()},className:"px-2 py-1 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors rounded",title:"Delete accordion",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]})}),r&&l.jsx("div",{className:"accordion-content p-3 bg-white",children:l.jsx(Z.NodeViewContent,{})})]})}const _n=W.Node.create({name:"accordion",group:"block",content:"accordionItem+",defining:!0,isolating:!0,addAttributes(){return{title:{default:"Output",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>t.title?{"data-title":t.title}:{}},open:{default:!0,parseHTML:t=>t.getAttribute("data-open")==="true",renderHTML:t=>({"data-open":t.open})}}},parseHTML(){return[{tag:'div[data-type="accordion"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"accordion"}),0]},addNodeView(){return Z.ReactNodeViewRenderer(Rs)},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(o=>o.type.name==="accordionItem"?o.content.content.some(i=>i.type.name==="paragraph"?i.content.size>0:!0):!0)},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(o=>o.type.name==="accordionItem"?o.content.content.some(i=>i.type.name==="paragraph"?i.content.size>0:!0):!0)}}},addCommands(){return{insertAccordion:()=>({commands:t})=>t.insertContent({type:this.name,content:[{type:"accordionItem",content:[{type:"paragraph",content:[{type:"text",text:"Accordion Item 1"}]}]}]})}}}),Sn=W.Node.create({name:"accordionItem",group:"block",content:"block+",defining:!0,isolating:!0,parseHTML(){return[{tag:'div[data-type="accordion-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"accordion-item"}),0]},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.parent.type.name==="accordionItem",!1},Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="accordionItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function Is({node:t,updateAttributes:e,editor:n}){const[r,s]=T.useState(t.attrs?.activeTab??0),[o,i]=T.useState(null),[a,c]=T.useState(""),u=T.useRef(null),d=t.content?.content||[],f=n?.isEditable??!1;T.useEffect(()=>{const y=t.attrs?.activeTab??0;y!==r&&s(y)},[t.attrs?.activeTab]),T.useEffect(()=>{o!==null&&u.current&&(u.current.focus(),u.current.select())},[o]);const m=y=>{s(y),e({...t.attrs,activeTab:y})},h=(y,_)=>{f&&(i(y),c(_))},g=()=>{f&&n&&confirm("Are you sure you want to delete this tabs component?")&&n.chain().focus().deleteNode("tabs").run()},w=()=>{if(o!==null&&d[o]&&n){let y=-1;n.state.doc.descendants((_,v)=>{if(_.type.name==="tabItem"&&_.attrs.tabIndex===o)return y=v,!1}),y!==-1&&n.chain().focus().command(({tr:_,dispatch:v})=>{if(v){const x=_.doc.nodeAt(y);x&&_.setNodeMarkup(y,void 0,{...x.attrs,title:a})}return!0}).run()}i(null),c("")},p=y=>{y.key==="Enter"?w():y.key==="Escape"&&(i(null),c(""))},N=y=>d[y]?.attrs?.title||`Tab ${y+1}`,S=y=>{if(!f||!n)return;const{selection:_}=n.state,{$anchor:v}=_;if(y.key==="Enter"&&!y.shiftKey&&v.nodeBefore?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();const x=v.nodeBefore;if(x&&x.childCount>0){const O=x.lastChild;if(O&&O.content.size>0){let E=-1;if(n.state.doc.descendants((P,L)=>{if(P.type.name==="tabItem"&&P.attrs.tabIndex===x.childCount-1)return E=L,!1}),E!==-1){const P=E+O.nodeSize-2;n.chain().focus().setTextSelection(P).run()}}}return}if((y.key==="Backspace"||y.key==="Delete")&&!y.shiftKey){if(v.nodeBefore?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();return}if(v.nodeAfter?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();return}}};return l.jsxs(Z.NodeViewWrapper,{className:"tabs-container border border-gray-200 rounded-lg mb-4 overflow-hidden","data-active-tab":r,onKeyDown:S,children:[l.jsx("div",{className:"tabs-header bg-gray-50 border-b border-gray-200",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex flex-1 overflow-x-auto",children:d.map((y,_)=>l.jsx("button",{type:"button",onClick:()=>m(_),className:`px-4 py-2 text-sm font-medium border-b-2 border-r border-gray-200 transition-colors relative lg:px-12 cursor-pointer ${r===_?"border-blue-500 border-r-gray-200 text-blue-600 bg-white":"border-transparent border-r-gray-200 text-gray-500 hover:text-gray-700 hover:border-gray-300"} ${_===d.length-1?"border-r-0":""}`,children:o===_?l.jsx("input",{ref:u,type:"text",value:a,onChange:v=>c(v.target.value),onBlur:w,onKeyDown:p,className:"bg-transparent border-none outline-none text-center min-w-16",onClick:v=>v.stopPropagation()}):l.jsx("span",{onClick:f?v=>{v.stopPropagation(),h(_,N(_))}:void 0,className:f?"cursor-text":"cursor-pointer",title:f?"Click to edit title":void 0,children:N(_)})},_))}),f&&l.jsx("button",{type:"button",onClick:g,className:"px-3 py-2 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors",title:"Delete tabs",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]})}),l.jsx("div",{className:"tabs-content",children:l.jsx(Z.NodeViewContent,{className:"tab-content-wrapper","data-active-tab":r})})]})}function Ms({node:t,editor:e}){const n=t.attrs?.tabIndex||0,r=e?.isEditable??!1,s=o=>{if(!r||!e)return;const{selection:i}=e.state,{$anchor:a}=i;if(o.key==="Enter"&&!o.shiftKey&&a.parent.type.name==="tabItem"){const c=a.parent;if(a.parentOffset===c.childCount)return}if(o.key==="Backspace"&&a.parent.type.name==="tabItem"){const c=a.parent;if(a.parentOffset===0&&c.childCount>0&&c.firstChild&&a.pos===a.start(a.depth))return}};return l.jsx(Z.NodeViewWrapper,{className:"tab-item-content p-4","data-tab-index":n,onKeyDown:s,children:l.jsx(Z.NodeViewContent,{})})}const Cn=W.Node.create({name:"tabs",group:"block",content:"tabItem+",defining:!0,isolating:!0,addAttributes(){return{activeTab:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-active-tab")||"0"),renderHTML:t=>({"data-active-tab":t.activeTab})},tabCount:{default:2,parseHTML:t=>parseInt(t.getAttribute("data-tab-count")||"2"),renderHTML:t=>({"data-tab-count":t.tabCount})}}},parseHTML(){return[{tag:'div[data-type="tabs"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"tabs"}),0]},addNodeView(){return Z.ReactNodeViewRenderer(Is,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="tabs"},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="tabs"}}},addCommands(){return{insertTabs:(t={tabCount:2})=>({commands:e})=>{const n=Math.min(Math.max(t.tabCount||2,2),6),r=Array.from({length:n},(s,o)=>({type:"tabItem",attrs:{tabIndex:o,title:`Tab ${o+1}`},content:[{type:"paragraph",content:[{type:"text",text:`Content for Tab ${o+1}. This is unique content for this tab.`}]}]}));return e.insertContent({type:this.name,attrs:{activeTab:0,tabCount:n},content:r})}}}}),Tn=W.Node.create({name:"tabItem",group:"block",content:"block+",defining:!0,isolating:!0,addAttributes(){return{tabIndex:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-tab-index")||"0"),renderHTML:t=>({"data-tab-index":t.tabIndex})},title:{default:"Tab",parseHTML:t=>t.getAttribute("data-title")||"Tab",renderHTML:t=>({"data-title":t.title})}}},parseHTML(){return[{tag:'div[data-type="tab-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"tab-item"}),0]},addNodeView(){return Z.ReactNodeViewRenderer(Ms,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Enter:()=>!1,Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="tabItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function Ls(...t){return ss.twMerge(rs.clsx(t))}const Ds=ns.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Y({className:t,variant:e,size:n,asChild:r=!1,...s}){const o=r?ts.Slot:"button";return l.jsx(o,{"data-slot":"button",className:Ls(Ds({variant:e,size:n,className:t})),...s})}const Ps=({node:t,updateAttributes:e,deleteNode:n,editor:r})=>{const[s,o]=T.useState(!1),[i,a]=T.useState("simple"),[c,u]=T.useState(""),[d,f]=T.useState({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),m=x=>{const O=x.toLowerCase();return O.includes("youtube.com")||O.includes("youtu.be")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox":O.includes("codesandbox.io")||O.includes("stackblitz.com")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox allow-top-navigation":"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"},h=x=>{const O=m(x);f({...d,src:x,sandbox:O})},g=()=>{p&&(e(d),o(!1))},w=()=>{f({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),o(!1)},[p,N]=T.useState(r?.isEditable??!1);T.useEffect(()=>{if(r){const x=()=>{N(r.isEditable)};return x(),r.on("update",x),r.on("selectionUpdate",x),()=>{r.off("update",x),r.off("selectionUpdate",x)}}},[r]);const S=()=>{p&&o(!0)},y=()=>{const x=`<iframe src="${d.src}" style="width:${d.width}; height: ${d.height}; ${d.style}" title="${d.title}" allow="${d.allow}" sandbox="${d.sandbox}"></iframe>`;navigator.clipboard.writeText(x)},_=x=>{const P=new DOMParser().parseFromString(x,"text/html").querySelector("iframe");if(P){const L=P.getAttribute("src")||"",$={src:L,width:P.getAttribute("width")||"100%",height:P.getAttribute("height")||"500px",title:P.getAttribute("title")||"",allow:P.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:P.getAttribute("sandbox")||m(L),style:P.getAttribute("style")||""};return f($),!0}return!1},v=()=>{_(c)?(a("simple"),u("")):alert("Invalid iframe HTML code. Please check your input.")};return s?l.jsx(Z.NodeViewWrapper,{className:"iframe-extension-editing",children:l.jsxs("div",{className:"border-2 border-blue-500 rounded-lg p-4 bg-blue-50",children:[l.jsxs("div",{className:"flex gap-2 mb-4",children:[l.jsx(Y,{onClick:()=>a("simple"),size:"sm",variant:i==="simple"?"default":"outline",className:"flex-1",children:"Simple Mode"}),l.jsx(Y,{onClick:()=>a("advanced"),size:"sm",variant:i==="advanced"?"default":"outline",className:"flex-1",children:"Advanced Mode"})]}),i==="simple"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Source URL"}),l.jsx("input",{type:"url",value:d.src,onChange:x=>h(x.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"https://example.com/embed"}),l.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Sandbox attributes are automatically configured based on the URL for optimal compatibility."})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Width"}),l.jsx("input",{type:"text",value:d.width,onChange:x=>f({...d,width:x.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"100%"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Height"}),l.jsx("input",{type:"text",value:d.height,onChange:x=>f({...d,height:x.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"500px"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),l.jsx("input",{type:"text",value:d.title,onChange:x=>f({...d,title:x.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Embedded Content"})]})]}):l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Paste your iframe HTML code"}),l.jsx("textarea",{value:c,onChange:x=>u(x.target.value),className:"w-full h-32 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:'<iframe src="https://example.com/embed" style="width:100%; height:500px; border:0; border-radius:4px; overflow:hidden;" title="Example" allow="..." sandbox="..."></iframe>'})]}),l.jsx("div",{className:"text-xs text-gray-600",children:"Paste your complete iframe HTML code here. The extension will automatically extract the attributes."}),l.jsxs("div",{className:"border-t pt-3",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Sandbox Attributes (Advanced)"}),l.jsx("input",{type:"text",value:d.sandbox,onChange:x=>f({...d,sandbox:x.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-xs",placeholder:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"}),l.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Override automatic sandbox configuration if needed. Common values: allow-scripts, allow-same-origin, allow-forms, allow-popups"})]})]}),l.jsxs("div",{className:"flex gap-2 mt-4",children:[i==="advanced"&&l.jsx(Y,{onClick:v,size:"sm",className:"bg-green-600 hover:bg-green-700",children:"Parse & Apply"}),l.jsx(Y,{onClick:g,size:"sm",className:"bg-blue-600 hover:bg-blue-700",children:"Save"}),l.jsx(Y,{onClick:w,size:"sm",variant:"outline",children:"Cancel"})]})]})}):l.jsx(Z.NodeViewWrapper,{className:"iframe-extension",children:l.jsxs("div",{className:"relative group",children:[l.jsx("iframe",{src:t.attrs.src,width:t.attrs.width,height:t.attrs.height,title:t.attrs.title,allow:t.attrs.allow,sandbox:t.attrs.sandbox,style:{...js(t.attrs.style),width:t.attrs.width,height:t.attrs.height},className:"rounded-lg"}),p&&l.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 bg-white/90 backdrop-blur-sm rounded-lg p-1 shadow-lg border",children:l.jsxs("div",{className:"flex gap-1",children:[l.jsx(Y,{onClick:S,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Edit iframe",children:l.jsx(M.Settings,{className:"h-4 w-4"})}),l.jsx(Y,{onClick:()=>window.open(t.attrs.src,"_blank"),size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Open in new tab",children:l.jsx(M.ExternalLink,{className:"h-4 w-4"})}),l.jsx(Y,{onClick:y,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Copy iframe code",children:l.jsx(M.Copy,{className:"h-4 w-4"})}),l.jsx(Y,{onClick:()=>{p&&n()},size:"sm",variant:"ghost",className:"h-8 w-8 p-0 text-red-600 hover:text-red-700",title:"Delete iframe",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]})}),t.attrs.src&&l.jsxs("div",{className:"mt-2 text-xs text-gray-500 bg-gray-100 px-2 py-1 rounded",children:["Source: ",t.attrs.src]})]})})},js=t=>{const e={};return t&&t.split(";").forEach(n=>{const[r,s]=n.split(":").map(o=>o.trim());if(r&&s){const o=r.replace(/-([a-z])/g,i=>i[1].toUpperCase());e[o]=s}}),e},kn=W.Node.create({name:"iframe",group:"block",atom:!0,addOptions(){return{readOnly:!1}},addAttributes(){return{src:{default:"",parseHTML:t=>t.getAttribute("src")||"",renderHTML:t=>({src:t.src})},width:{default:"100%",parseHTML:t=>t.getAttribute("width")||"100%",renderHTML:t=>({width:t.width})},height:{default:"500px",parseHTML:t=>t.getAttribute("height")||"500px",renderHTML:t=>({height:t.height})},title:{default:"",parseHTML:t=>t.getAttribute("title")||"",renderHTML:t=>({title:t.title})},allow:{default:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",parseHTML:t=>t.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",renderHTML:t=>({allow:t.allow})},sandbox:{default:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",parseHTML:t=>t.getAttribute("sandbox")||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",renderHTML:t=>({sandbox:t.sandbox})},style:{default:"",parseHTML:t=>t.getAttribute("style")||"",renderHTML:t=>({style:t.style})}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",W.mergeAttributes(t)]},addNodeView(){return Z.ReactNodeViewRenderer(Ps)},addCommands(){return{insertIframe:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{src:t.src||"",width:t.width||"100%",height:t.height||"500px",title:t.title||"Embedded Content",allow:t.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.style||""}})}}}),An=W.Node.create({name:"video",addOptions(){return{inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}},group(){return this.options.inline?"inline":"block"},draggable:!1,addAttributes(){return{src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},type:{default:null,parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},title:{default:null,parseHTML:t=>t.getAttribute("title"),renderHTML:t=>t.title?{title:t.title}:{}}}},parseHTML(){return[{tag:"video"}]},renderHTML({HTMLAttributes:t}){const{src:e,type:n,title:r}=t;return e?["video",W.mergeAttributes(this.options.HTMLAttributes,t,{controls:!0,preload:"metadata"}),["source",{src:e,type:n||"video/mp4"}],r||"Your browser does not support the video tag."]:["video",W.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),Bs=()=>({type:"column",content:[{type:"paragraph"}]}),On=W.Node.create({name:"columnLayout",group:"block",content:"column+",defining:!0,isolating:!0,addOptions(){return{HTMLAttributes:{},defaultColumns:2}},addAttributes(){return{columns:{default:this.options.defaultColumns,parseHTML:t=>{const e=Number(t.getAttribute("data-columns"));return Number.isNaN(e)?this.options.defaultColumns:e},renderHTML:t=>({"data-columns":t.columns})}}},parseHTML(){return[{tag:'div[data-type="column-layout"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":"column-layout"}),0]},addCommands(){return{insertColumnLayout:t=>({commands:e})=>{const n=t?.columns??this.options.defaultColumns,r=Array.from({length:Math.max(n,1)},()=>Bs());return e.insertContent({type:this.name,attrs:{columns:n},content:r})},setColumnLayoutColumns:t=>({state:e,dispatch:n})=>{const r=W.findParentNode(s=>s.type===this.type)(e.selection);if(!r)return!1;if(n){const s=e.tr.setNodeMarkup(r.pos,this.type,{...r.node.attrs,columns:t},r.node.marks);n(s)}return!0}}}}),Rn=W.Node.create({name:"column",content:"block+",isolating:!0,defining:!0,parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"column"}),0]}});function zs({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:s=600,closeDelay:o=0}={}){const[i,a]=he.useState(t),c=n??i,u=r??a,d=se.useFloating({placement:e,open:c,onOpenChange:u,whileElementsMounted:se.autoUpdate,middleware:[se.offset(4),se.flip({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),se.shift({padding:4})]}),f=d.context,m=se.useHover(f,{mouseOnly:!0,move:!1,restMs:s,enabled:n==null,delay:{close:o}}),h=se.useFocus(f,{enabled:n==null}),g=se.useDismiss(f),w=se.useRole(f,{role:"tooltip"}),p=se.useInteractions([m,h,g,w]);return he.useMemo(()=>({open:c,setOpen:u,...p,...d}),[c,u,p,d])}const vt=he.createContext(null);function In(){const t=he.useContext(vt);if(t==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return t}function tt({children:t,...e}){const n=zs(e);return e.useDelayGroup?l.jsx(se.FloatingDelayGroup,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:l.jsx(vt.Provider,{value:n,children:t})}):l.jsx(vt.Provider,{value:n,children:t})}const nt=he.forwardRef(function({children:e,asChild:n=!1,...r},s){const o=In(),i=he.isValidElement(e)?parseInt(he.version,10)>=19?e.props.ref:e.ref:void 0,a=se.useMergeRefs([o.refs.setReference,s,i]);if(n&&he.isValidElement(e)){const c={"data-tooltip-state":o.open?"open":"closed"};return he.cloneElement(e,o.getReferenceProps({ref:a,...r,...typeof e.props=="object"?e.props:{},...c}))}return l.jsx("button",{ref:a,"data-tooltip-state":o.open?"open":"closed",...o.getReferenceProps(r),children:e})}),rt=he.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:s={},...o},i){const a=In(),c=se.useMergeRefs([a.refs.setFloating,i]);if(!a.open)return null;const u=l.jsx("div",{ref:c,style:{...a.floatingStyles,...e},...a.getFloatingProps(o),className:"tiptap-tooltip",children:n});return r?l.jsx(se.FloatingPortal,{...s,children:u}):u});tt.displayName="Tooltip",nt.displayName="TooltipTrigger",rt.displayName="TooltipContent";const B=({onClick:t,isActive:e=!1,children:n,title:r,className:s=""})=>{const o=l.jsx(Y,{type:"button",onClick:t,variant:e?"default":"outline",size:"sm",className:`h-8 w-8 p-0 transition-all cursor-pointer ${e?"bg-blue-600 text-white border-blue-600 hover:bg-blue-700":"bg-white hover:bg-gray-50"} ${s}`,children:n});return r?l.jsxs(tt,{delay:500,closeDelay:0,children:[l.jsx(nt,{asChild:!0,children:o}),l.jsx(rt,{children:r})]}):o},Us=({onColorChange:t})=>{const e=["#000000","#ffffff","#7d7a75","#9f765a","#d27b2d","#fdd835","#50946e","#377dc9","#9a6bb4","#c14c8a","#cf5148"];return l.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>l.jsxs(tt,{delay:300,closeDelay:0,children:[l.jsx(nt,{asChild:!0,children:l.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),l.jsxs(rt,{children:["Set color to ",n]})]},n))})},Hs=({onColorChange:t})=>{const e=["#B0B0B0","#F2F0EF","#e7e4de","#f3e1d5","#ffe4c2","#fff7cc","#d6f2e3","#d5e6fa","#ebddf5","#f9d6e8","#f8d0cb"];return l.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>l.jsxs(tt,{delay:300,closeDelay:0,children:[l.jsx(nt,{asChild:!0,children:l.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),l.jsxs(rt,{children:["Set background color to ",n]})]},n))})},Fs=({editor:t,isReadOnly:e,onImageUpload:n,onVideoUpload:r,isImageUploading:s,isVideoUploading:o,showImageInput:i,setShowImageInput:a,imageUrl:c,setImageUrl:u,handleImageUrlInsert:d,imageUploadFunction:f})=>{const[m,h]=T.useState(!1),g=T.useRef(null);return T.useEffect(()=>{const w=p=>{g.current&&!g.current.contains(p.target)&&h(!1)};return m&&document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[m]),e?null:l.jsxs("div",{className:"sticky top-0 z-40 border border-gray-300 mb-10 p-4 bg-gray-50/95 flex flex-wrap gap-2 shadow-sm backdrop-blur-sm",children:[l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(B,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:l.jsx(M.Heading1,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:l.jsx(M.Heading2,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:l.jsx(M.Heading3,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleHeading({level:4}).run(),isActive:t.isActive("heading",{level:4}),title:"Heading 4",children:l.jsx(M.Heading4,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().setParagraph().run(),isActive:t.isActive("paragraph"),title:"Paragraph",children:l.jsx(M.FileText,{className:"h-4 w-4"})})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(B,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:l.jsx(M.List,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:l.jsx(M.ListOrdered,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:l.jsx(B,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table (3x3)",children:l.jsx(M.Table,{className:"h-4 w-4"})})}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(B,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Block Quote",children:l.jsx(M.Quote,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:l.jsx(M.Minus,{className:"h-4 w-4"})})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsxs("div",{className:"relative",children:[l.jsx(B,{onClick:()=>a(!i),title:"Insert Image",className:s?"opacity-50":"",children:s?l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):l.jsx(M.Image,{className:"h-4 w-4"})}),s&&l.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),i&&l.jsx("div",{className:`absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg min-w-80 image-input-container ${s?"opacity-75":""}`,children:l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-sm font-medium text-gray-900",children:"Insert Image"}),l.jsx("button",{type:"button",onClick:()=>a(!1),className:`text-gray-400 hover:text-gray-600 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,children:"✕"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Image URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"url",value:c,onChange:w=>u(w.target.value),placeholder:"https://example.com/image.jpg",className:`flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,onKeyDown:w=>{w.key==="Enter"&&d()}}),l.jsx(Y,{type:"button",onClick:d,size:"sm",className:"px-4 py-2",disabled:!c.trim()||s,children:"Insert"})]}),c.trim()&&l.jsxs("div",{className:"mt-2 p-2 border border-gray-200 rounded bg-gray-50",children:[l.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Preview:"}),l.jsx("img",{src:c.trim(),alt:"Preview",className:"max-w-full h-auto max-h-32 rounded border",onError:w=>{const p=w.currentTarget;p.style.display="none";const N=p.nextElementSibling;N&&(N.style.display="block")}}),l.jsx("p",{className:"text-xs text-red-500 hidden",children:"Invalid image URL"})]})]}),l.jsxs("div",{className:"border-t pt-3",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Or Upload Image"}),l.jsx(Y,{type:"button",onClick:n,size:"sm",variant:"outline",className:"w-full",disabled:!f||s,children:s?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),l.jsx("span",{children:"Uploading..."})]}):f?"Choose File":"Upload not available"}),s&&l.jsxs("div",{className:"mt-2 text-xs text-blue-600 flex items-center gap-1",children:[l.jsx("div",{className:"animate-pulse",children:"⏳"}),l.jsx("span",{children:"Please wait while your image uploads..."})]}),!f&&l.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Upload function not provided"})]})]})})]}),l.jsxs("div",{className:"relative",children:[l.jsx(B,{onClick:r,title:o?"Upload Video to Firebase":"Upload Video (Base64)",className:o?"opacity-50":"",children:o?l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):l.jsx(M.Video,{className:"h-4 w-4"})}),o&&l.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),!r&&l.jsx("div",{className:"absolute top-full mt-1 left-0 bg-gray-800 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-50",children:"Video upload not available"})]})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(B,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:l.jsx(M.Code,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().insertAccordion().run(),title:"Insert Accordion",children:l.jsx(M.PanelTopOpen,{className:"h-4 w-4 cursor-pointer"})})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(B,{onClick:()=>t.chain().focus().insertTabs({tabCount:2}).run(),title:"Insert 2 Tabs",children:l.jsx("span",{className:"text-xs font-mono",children:"2T"})}),l.jsxs("div",{className:"relative w-full",ref:g,children:[l.jsx(B,{onClick:()=>h(!m),title:"Insert Tabs",className:"w-full px-2",children:l.jsxs("div",{className:"flex items-center gap-1 w-full justify-between",children:[l.jsx("span",{className:"text-xs font-mono",children:"Tabs"}),l.jsx(M.ChevronDown,{className:"h-3 w-3"})]})}),m&&l.jsx("div",{className:"absolute top-full mt-1 left-0 z-10 bg-white border border-gray-300 rounded-lg shadow-lg min-w-32",children:l.jsxs("div",{className:"p-1 space-y-1",children:[l.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:3}).run(),h(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"3 Tabs"}),l.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:4}).run(),h(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"4 Tabs"}),l.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:5}).run(),h(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"5 Tabs"}),l.jsx(Y,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:6}).run(),h(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"6 Tabs"})]})})]})]}),l.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:l.jsx(B,{onClick:()=>{const w=prompt("Enter the URL for your iframe:","https://example.com/embed");w&&t.chain().focus().insertIframe({src:w,width:"100%",height:"500px",title:"Embedded Content"}).run()},title:"Insert iframe",children:l.jsx(M.Frame,{className:"h-4 w-4"})})}),l.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:l.jsx(B,{onClick:()=>t.chain().focus().insertColumnLayout({columns:2}).run(),title:"Insert 2 Column Layout",children:l.jsx("div",{className:"flex items-center gap-1",children:l.jsx(M.Columns3,{className:"h-4 w-4"})})})})]})},Mn=["top","right","bottom","left"],Ln=["start","end"],Dn=Mn.reduce((t,e)=>t.concat(e,e+"-"+Ln[0],e+"-"+Ln[1]),[]),ge=Math.min,ne=Math.max,st=Math.round,be=t=>({x:t,y:t}),$s={left:"right",right:"left",bottom:"top",top:"bottom"},Ks={start:"end",end:"start"};function Et(t,e,n){return ne(t,ge(e,n))}function ve(t,e){return typeof t=="function"?t(e):t}function le(t){return t.split("-")[0]}function de(t){return t.split("-")[1]}function Pn(t){return t==="x"?"y":"x"}function Nt(t){return t==="y"?"height":"width"}const qs=new Set(["top","bottom"]);function we(t){return qs.has(le(t))?"y":"x"}function _t(t){return Pn(we(t))}function jn(t,e,n){n===void 0&&(n=!1);const r=de(t),s=_t(t),o=Nt(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=it(i)),[i,it(i)]}function Ws(t){const e=it(t);return[ot(t),e,ot(e)]}function ot(t){return t.replace(/start|end/g,e=>Ks[e])}const Bn=["left","right"],zn=["right","left"],Js=["top","bottom"],Vs=["bottom","top"];function Gs(t,e,n){switch(t){case"top":case"bottom":return n?e?zn:Bn:e?Bn:zn;case"left":case"right":return e?Js:Vs;default:return[]}}function Ys(t,e,n,r){const s=de(t);let o=Gs(le(t),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map(ot)))),o}function it(t){return t.replace(/left|right|bottom|top/g,e=>$s[e])}function Zs(t){return{top:0,right:0,bottom:0,left:0,...t}}function St(t){return typeof t!="number"?Zs(t):{top:t,right:t,bottom:t,left:t}}function De(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Un(t,e,n){let{reference:r,floating:s}=t;const o=we(e),i=_t(e),a=Nt(i),c=le(e),u=o==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,m=r[a]/2-s[a]/2;let h;switch(c){case"top":h={x:d,y:r.y-s.height};break;case"bottom":h={x:d,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(de(e)){case"start":h[i]-=m*(n&&u?-1:1);break;case"end":h[i]+=m*(n&&u?-1:1);break}return h}const Xs=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=o.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(e));let u=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:f}=Un(u,r,c),m=r,h={},g=0;for(let w=0;w<a.length;w++){const{name:p,fn:N}=a[w],{x:S,y,data:_,reset:v}=await N({x:d,y:f,initialPlacement:r,placement:m,strategy:s,middlewareData:h,rects:u,platform:i,elements:{reference:t,floating:e}});d=S??d,f=y??f,h={...h,[p]:{...h[p],..._}},v&&g<=50&&(g++,typeof v=="object"&&(v.placement&&(m=v.placement),v.rects&&(u=v.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):v.rects),{x:d,y:f}=Un(u,m,c)),w=-1)}return{x:d,y:f,placement:m,strategy:s,middlewareData:h}};async function Pe(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:i,elements:a,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:m=!1,padding:h=0}=ve(e,t),g=St(h),p=a[m?f==="floating"?"reference":"floating":f],N=De(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(p)))==null||n?p:p.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),S=f==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),_=await(o.isElement==null?void 0:o.isElement(y))?await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1}:{x:1,y:1},v=De(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:y,strategy:c}):S);return{top:(N.top-v.top+g.top)/_.y,bottom:(v.bottom-N.bottom+g.bottom)/_.y,left:(N.left-v.left+g.left)/_.x,right:(v.right-N.right+g.right)/_.x}}const Qs=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:c}=e,{element:u,padding:d=0}=ve(t,e)||{};if(u==null)return{};const f=St(d),m={x:n,y:r},h=_t(s),g=Nt(h),w=await i.getDimensions(u),p=h==="y",N=p?"top":"left",S=p?"bottom":"right",y=p?"clientHeight":"clientWidth",_=o.reference[g]+o.reference[h]-m[h]-o.floating[g],v=m[h]-o.reference[h],x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let O=x?x[y]:0;(!O||!await(i.isElement==null?void 0:i.isElement(x)))&&(O=a.floating[y]||o.floating[g]);const E=_/2-v/2,P=O/2-w[g]/2-1,L=ge(f[N],P),$=ge(f[S],P),V=L,D=O-w[g]-$,R=O/2-w[g]/2+E,I=Et(V,R,D),C=!c.arrow&&de(s)!=null&&R!==I&&o.reference[g]/2-(R<V?L:$)-w[g]/2<0,U=C?R<V?R-V:R-D:0;return{[h]:m[h]+U,data:{[h]:I,centerOffset:R-I-U,...C&&{alignmentOffset:U}},reset:C}}});function eo(t,e,n){return(t?[...n.filter(s=>de(s)===t),...n.filter(s=>de(s)!==t)]:n.filter(s=>le(s)===s)).filter(s=>t?de(s)===t||(e?ot(s)!==s:!1):!0)}const to=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:o,middlewareData:i,placement:a,platform:c,elements:u}=e,{crossAxis:d=!1,alignment:f,allowedPlacements:m=Dn,autoAlignment:h=!0,...g}=ve(t,e),w=f!==void 0||m===Dn?eo(f||null,h,m):m,p=await Pe(e,g),N=((n=i.autoPlacement)==null?void 0:n.index)||0,S=w[N];if(S==null)return{};const y=jn(S,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(a!==S)return{reset:{placement:w[0]}};const _=[p[le(S)],p[y[0]],p[y[1]]],v=[...((r=i.autoPlacement)==null?void 0:r.overflows)||[],{placement:S,overflows:_}],x=w[N+1];if(x)return{data:{index:N+1,overflows:v},reset:{placement:x}};const O=v.map(L=>{const $=de(L.placement);return[L.placement,$&&d?L.overflows.slice(0,2).reduce((V,D)=>V+D,0):L.overflows[0],L.overflows]}).sort((L,$)=>L[1]-$[1]),P=((s=O.filter(L=>L[2].slice(0,de(L[0])?2:3).every($=>$<=0))[0])==null?void 0:s[0])||O[0][0];return P!==a?{data:{index:N+1,overflows:v},reset:{placement:P}}:{}}}},no=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:a,platform:c,elements:u}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...p}=ve(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const N=le(s),S=we(a),y=le(a)===a,_=await(c.isRTL==null?void 0:c.isRTL(u.floating)),v=m||(y||!w?[it(a)]:Ws(a)),x=g!=="none";!m&&x&&v.push(...Ys(a,w,g,_));const O=[a,...v],E=await Pe(e,p),P=[];let L=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&P.push(E[N]),f){const R=jn(s,i,_);P.push(E[R[0]],E[R[1]])}if(L=[...L,{placement:s,overflows:P}],!P.every(R=>R<=0)){var $,V;const R=((($=o.flip)==null?void 0:$.index)||0)+1,I=O[R];if(I&&(!(f==="alignment"?S!==we(I):!1)||L.every(k=>we(k.placement)===S?k.overflows[0]>0:!0)))return{data:{index:R,overflows:L},reset:{placement:I}};let C=(V=L.filter(U=>U.overflows[0]<=0).sort((U,k)=>U.overflows[1]-k.overflows[1])[0])==null?void 0:V.placement;if(!C)switch(h){case"bestFit":{var D;const U=(D=L.filter(k=>{if(x){const z=we(k.placement);return z===S||z==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(z=>z>0).reduce((z,b)=>z+b,0)]).sort((k,z)=>k[1]-z[1])[0])==null?void 0:D[0];U&&(C=U);break}case"initialPlacement":C=a;break}if(s!==C)return{reset:{placement:C}}}return{}}}};function Hn(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Fn(t){return Mn.some(e=>t[e]>=0)}const ro=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...s}=ve(t,e);switch(r){case"referenceHidden":{const o=await Pe(e,{...s,elementContext:"reference"}),i=Hn(o,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Fn(i)}}}case"escaped":{const o=await Pe(e,{...s,altBoundary:!0}),i=Hn(o,n.floating);return{data:{escapedOffsets:i,escaped:Fn(i)}}}default:return{}}}}};function $n(t){const e=ge(...t.map(o=>o.left)),n=ge(...t.map(o=>o.top)),r=ne(...t.map(o=>o.right)),s=ne(...t.map(o=>o.bottom));return{x:e,y:n,width:r-e,height:s-n}}function so(t){const e=t.slice().sort((s,o)=>s.y-o.y),n=[];let r=null;for(let s=0;s<e.length;s++){const o=e[s];!r||o.y-r.y>r.height/2?n.push([o]):n[n.length-1].push(o),r=o}return n.map(s=>De($n(s)))}const oo=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:o,strategy:i}=e,{padding:a=2,x:c,y:u}=ve(t,e),d=Array.from(await(o.getClientRects==null?void 0:o.getClientRects(r.reference))||[]),f=so(d),m=De($n(d)),h=St(a);function g(){if(f.length===2&&f[0].left>f[1].right&&c!=null&&u!=null)return f.find(p=>c>p.left-h.left&&c<p.right+h.right&&u>p.top-h.top&&u<p.bottom+h.bottom)||m;if(f.length>=2){if(we(n)==="y"){const L=f[0],$=f[f.length-1],V=le(n)==="top",D=L.top,R=$.bottom,I=V?L.left:$.left,C=V?L.right:$.right,U=C-I,k=R-D;return{top:D,bottom:R,left:I,right:C,width:U,height:k,x:I,y:D}}const p=le(n)==="left",N=ne(...f.map(L=>L.right)),S=ge(...f.map(L=>L.left)),y=f.filter(L=>p?L.left===S:L.right===N),_=y[0].top,v=y[y.length-1].bottom,x=S,O=N,E=O-x,P=v-_;return{top:_,bottom:v,left:x,right:O,width:E,height:P,x,y:_}}return m}const w=await o.getElementRects({reference:{getBoundingClientRect:g},floating:r.floating,strategy:i});return s.reference.x!==w.reference.x||s.reference.y!==w.reference.y||s.reference.width!==w.reference.width||s.reference.height!==w.reference.height?{reset:{rects:w}}:{}}}},io=new Set(["left","top"]);async function ao(t,e){const{placement:n,platform:r,elements:s}=t,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=le(n),a=de(n),c=we(n)==="y",u=io.has(i)?-1:1,d=o&&c?-1:1,f=ve(e,t);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(h=a==="end"?g*-1:g),c?{x:h*d,y:m*u}:{x:m*u,y:h*d}}const lo=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:o,placement:i,middlewareData:a}=e,c=await ao(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:i}}}}},co=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:o=!0,crossAxis:i=!1,limiter:a={fn:p=>{let{x:N,y:S}=p;return{x:N,y:S}}},...c}=ve(t,e),u={x:n,y:r},d=await Pe(e,c),f=we(le(s)),m=Pn(f);let h=u[m],g=u[f];if(o){const p=m==="y"?"top":"left",N=m==="y"?"bottom":"right",S=h+d[p],y=h-d[N];h=Et(S,h,y)}if(i){const p=f==="y"?"top":"left",N=f==="y"?"bottom":"right",S=g+d[p],y=g-d[N];g=Et(S,g,y)}const w=a.fn({...e,[m]:h,[f]:g});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[m]:o,[f]:i}}}}}},uo=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:o,platform:i,elements:a}=e,{apply:c=()=>{},...u}=ve(t,e),d=await Pe(e,u),f=le(s),m=de(s),h=we(s)==="y",{width:g,height:w}=o.floating;let p,N;f==="top"||f==="bottom"?(p=f,N=m===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(N=f,p=m==="end"?"top":"bottom");const S=w-d.top-d.bottom,y=g-d.left-d.right,_=ge(w-d[p],S),v=ge(g-d[N],y),x=!e.middlewareData.shift;let O=_,E=v;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(E=y),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(O=S),x&&!m){const L=ne(d.left,0),$=ne(d.right,0),V=ne(d.top,0),D=ne(d.bottom,0);h?E=g-2*(L!==0||$!==0?L+$:ne(d.left,d.right)):O=w-2*(V!==0||D!==0?V+D:ne(d.top,d.bottom))}await c({...e,availableWidth:E,availableHeight:O});const P=await i.getDimensions(a.floating);return g!==P.width||w!==P.height?{reset:{rects:!0}}:{}}}};function at(){return typeof window<"u"}function je(t){return Kn(t)?(t.nodeName||"").toLowerCase():"#document"}function ie(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ee(t){var e;return(e=(Kn(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Kn(t){return at()?t instanceof Node||t instanceof ie(t).Node:!1}function fe(t){return at()?t instanceof Element||t instanceof ie(t).Element:!1}function ye(t){return at()?t instanceof HTMLElement||t instanceof ie(t).HTMLElement:!1}function qn(t){return!at()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ie(t).ShadowRoot}const fo=new Set(["inline","contents"]);function qe(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=pe(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!fo.has(s)}const po=new Set(["table","td","th"]);function ho(t){return po.has(je(t))}const mo=[":popover-open",":modal"];function lt(t){return mo.some(e=>{try{return t.matches(e)}catch{return!1}})}const go=["transform","translate","scale","rotate","perspective"],bo=["transform","translate","scale","rotate","perspective","filter"],wo=["paint","layout","strict","content"];function Ct(t){const e=Tt(),n=fe(t)?pe(t):t;return go.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||bo.some(r=>(n.willChange||"").includes(r))||wo.some(r=>(n.contain||"").includes(r))}function yo(t){let e=ke(t);for(;ye(e)&&!Be(e);){if(Ct(e))return e;if(lt(e))return null;e=ke(e)}return null}function Tt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const xo=new Set(["html","body","#document"]);function Be(t){return xo.has(je(t))}function pe(t){return ie(t).getComputedStyle(t)}function ct(t){return fe(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ke(t){if(je(t)==="html")return t;const e=t.assignedSlot||t.parentNode||qn(t)&&t.host||Ee(t);return qn(e)?e.host:e}function Wn(t){const e=ke(t);return Be(e)?t.ownerDocument?t.ownerDocument.body:t.body:ye(e)&&qe(e)?e:Wn(e)}function Jn(t,e,n){var r;e===void 0&&(e=[]);const s=Wn(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),i=ie(s);return o?(kt(i),e.concat(i,i.visualViewport||[],qe(s)?s:[],[])):e.concat(s,Jn(s,[]))}function kt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Vn(t){const e=pe(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=ye(t),o=s?t.offsetWidth:n,i=s?t.offsetHeight:r,a=st(n)!==o||st(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function Gn(t){return fe(t)?t:t.contextElement}function ze(t){const e=Gn(t);if(!ye(e))return be(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=Vn(e);let i=(o?st(n.width):n.width)/r,a=(o?st(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const vo=be(0);function Yn(t){const e=ie(t);return!Tt()||!e.visualViewport?vo:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Eo(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ie(t)?!1:e}function We(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=Gn(t);let i=be(1);e&&(r?fe(r)&&(i=ze(r)):i=ze(t));const a=Eo(o,n,r)?Yn(o):be(0);let c=(s.left+a.x)/i.x,u=(s.top+a.y)/i.y,d=s.width/i.x,f=s.height/i.y;if(o){const m=ie(o),h=r&&fe(r)?ie(r):r;let g=m,w=kt(g);for(;w&&r&&h!==g;){const p=ze(w),N=w.getBoundingClientRect(),S=pe(w),y=N.left+(w.clientLeft+parseFloat(S.paddingLeft))*p.x,_=N.top+(w.clientTop+parseFloat(S.paddingTop))*p.y;c*=p.x,u*=p.y,d*=p.x,f*=p.y,c+=y,u+=_,g=ie(w),w=kt(g)}}return De({width:d,height:f,x:c,y:u})}function ut(t,e){const n=ct(t).scrollLeft;return e?e.left+n:We(Ee(t)).left+n}function Zn(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-ut(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function No(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",i=Ee(r),a=e?lt(e.floating):!1;if(r===i||a&&o)return n;let c={scrollLeft:0,scrollTop:0},u=be(1);const d=be(0),f=ye(r);if((f||!f&&!o)&&((je(r)!=="body"||qe(i))&&(c=ct(r)),ye(r))){const h=We(r);u=ze(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const m=i&&!f&&!o?Zn(i,c):be(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+m.x,y:n.y*u.y-c.scrollTop*u.y+d.y+m.y}}function _o(t){return Array.from(t.getClientRects())}function So(t){const e=Ee(t),n=ct(t),r=t.ownerDocument.body,s=ne(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=ne(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ut(t);const a=-n.scrollTop;return pe(r).direction==="rtl"&&(i+=ne(e.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}const Xn=25;function Co(t,e){const n=ie(t),r=Ee(t),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,a=0,c=0;if(s){o=s.width,i=s.height;const d=Tt();(!d||d&&e==="fixed")&&(a=s.offsetLeft,c=s.offsetTop)}const u=ut(r);if(u<=0){const d=r.ownerDocument,f=d.body,m=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-h);g<=Xn&&(o-=g)}else u<=Xn&&(o+=u);return{width:o,height:i,x:a,y:c}}const To=new Set(["absolute","fixed"]);function ko(t,e){const n=We(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=ye(t)?ze(t):be(1),i=t.clientWidth*o.x,a=t.clientHeight*o.y,c=s*o.x,u=r*o.y;return{width:i,height:a,x:c,y:u}}function Qn(t,e,n){let r;if(e==="viewport")r=Co(t,n);else if(e==="document")r=So(Ee(t));else if(fe(e))r=ko(e,n);else{const s=Yn(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return De(r)}function er(t,e){const n=ke(t);return n===e||!fe(n)||Be(n)?!1:pe(n).position==="fixed"||er(n,e)}function Ao(t,e){const n=e.get(t);if(n)return n;let r=Jn(t,[]).filter(a=>fe(a)&&je(a)!=="body"),s=null;const o=pe(t).position==="fixed";let i=o?ke(t):t;for(;fe(i)&&!Be(i);){const a=pe(i),c=Ct(i);!c&&a.position==="fixed"&&(s=null),(o?!c&&!s:!c&&a.position==="static"&&!!s&&To.has(s.position)||qe(i)&&!c&&er(t,i))?r=r.filter(d=>d!==i):s=a,i=ke(i)}return e.set(t,r),r}function Oo(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const i=[...n==="clippingAncestors"?lt(e)?[]:Ao(e,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Qn(e,d,s);return u.top=ne(f.top,u.top),u.right=ge(f.right,u.right),u.bottom=ge(f.bottom,u.bottom),u.left=ne(f.left,u.left),u},Qn(e,a,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Ro(t){const{width:e,height:n}=Vn(t);return{width:e,height:n}}function Io(t,e,n){const r=ye(e),s=Ee(e),o=n==="fixed",i=We(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=be(0);function u(){c.x=ut(s)}if(r||!r&&!o)if((je(e)!=="body"||qe(s))&&(a=ct(e)),r){const h=We(e,!0,o,e);c.x=h.x+e.clientLeft,c.y=h.y+e.clientTop}else s&&u();o&&!r&&s&&u();const d=s&&!r&&!o?Zn(s,a):be(0),f=i.left+a.scrollLeft-c.x-d.x,m=i.top+a.scrollTop-c.y-d.y;return{x:f,y:m,width:i.width,height:i.height}}function At(t){return pe(t).position==="static"}function tr(t,e){if(!ye(t)||pe(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ee(t)===n&&(n=n.ownerDocument.body),n}function nr(t,e){const n=ie(t);if(lt(t))return n;if(!ye(t)){let s=ke(t);for(;s&&!Be(s);){if(fe(s)&&!At(s))return s;s=ke(s)}return n}let r=tr(t,e);for(;r&&ho(r)&&At(r);)r=tr(r,e);return r&&Be(r)&&At(r)&&!Ct(r)?n:r||yo(t)||n}const Mo=async function(t){const e=this.getOffsetParent||nr,n=this.getDimensions,r=await n(t.floating);return{reference:Io(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lo(t){return pe(t).direction==="rtl"}const Do={convertOffsetParentRelativeRectToViewportRelativeRect:No,getDocumentElement:Ee,getClippingRect:Oo,getOffsetParent:nr,getElementRects:Mo,getClientRects:_o,getDimensions:Ro,getScale:ze,isElement:fe,isRTL:Lo},rr=lo,sr=to,or=co,ir=no,ar=uo,lr=ro,cr=Qs,ur=oo,dr=(t,e,n)=>{const r=new Map,s={platform:Do,...n},o={...s.platform,_c:r};return Xs(t,e,{...s,platform:o})};function fr(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),o=e.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)n++;return n}if(s.content.size||o.content.size){let i=fr(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function pr(t,e,n,r){for(let s=t.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=t.child(--s),a=e.child(--o),c=i.nodeSize;if(i==a){n-=c,r-=c;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let u=0,d=Math.min(i.text.length,a.text.length);for(;u<d&&i.text[i.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(i.content.size||a.content.size){let u=pr(i.content,a.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class K{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,o){for(let i=0,a=0;a<n;i++){let c=this.content[i],u=a+c.nodeSize;if(u>e&&r(c,s+a,o||null,i)!==!1&&c.content.size){let d=a+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,s+d)}a=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let o="",i=!0;return this.nodesBetween(e,n,(a,c)=>{let u=a.isText?a.text.slice(Math.max(e,c)-c,n-c):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&r&&(i?i=!1:o+=r),o+=u},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new K(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let o=0,i=0;i<n;o++){let a=this.content[o],c=i+a.nodeSize;c>e&&((i<e||c>n)&&(a.isText?a=a.cut(Math.max(0,e-i),Math.min(a.text.length,n-i)):a=a.cut(Math.max(0,e-i-1),Math.min(a.content.size,n-i-1))),r.push(a),s+=a.nodeSize),i=c}return new K(r,s)}cutByIndex(e,n){return e==n?K.empty:e==0&&n==this.content.length?this:new K(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new K(s,o)}addToStart(e){return new K([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new K(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return fr(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return pr(this,e,n,r)}findIndex(e){if(e==0)return dt(0,e);if(e==this.size)return dt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),o=r+s.nodeSize;if(o>=e)return o==e?dt(n+1,o):dt(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return K.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new K(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return K.empty;let n,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(n||(n=e.slice(0,s)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new K(n||e,r)}static from(e){if(!e)return K.empty;if(e instanceof K)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new K([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}K.empty=new K([],0);const Ot={index:0,offset:0};function dt(t,e){return Ot.index=t,Ot.offset=e,Ot}class Po extends Error{}class F{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=mr(this.content,e+this.openStart,n);return r&&new F(r,this.openStart,this.openEnd)}removeBetween(e,n){return new F(hr(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return F.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new F(K.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)s++;return new F(e,r,s)}}F.empty=new F(K.empty,0,0);function hr(t,e,n){let{index:r,offset:s}=t.findIndex(e),o=t.maybeChild(r),{index:i,offset:a}=t.findIndex(n);if(s==e||o.isText){if(a!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(hr(o.content,e-s-1,n-s-1)))}function mr(t,e,n,r){let{index:s,offset:o}=t.findIndex(e),i=t.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=mr(i.content,e-o-1,n,i);return a&&t.replaceChild(s,i.copy(a))}const gr=65535,br=Math.pow(2,16);function jo(t,e){return t+e*br}function wr(t){return t&gr}function Bo(t){return(t-(t&gr))/br}const yr=1,xr=2,ft=4,vr=8;class Er{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&vr)>0}get deletedBefore(){return(this.delInfo&(yr|ft))>0}get deletedAfter(){return(this.delInfo&(xr|ft))>0}get deletedAcross(){return(this.delInfo&ft)>0}}class ae{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ae.empty)return ae.empty}recover(e){let n=0,r=wr(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Bo(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?s:0);if(c>e)break;let u=this.ranges[a+o],d=this.ranges[a+i],f=c+u;if(e<=f){let m=u?e==c?-1:e==f?1:n:n,h=c+s+(m<0?0:d);if(r)return h;let g=e==(n<0?c:f)?null:jo(a/3,e-c),w=e==c?xr:e==f?yr:ft;return(n<0?e!=c:e!=f)&&(w|=vr),new Er(h,w,g)}s+=d-u}return r?e+s:new Er(e+s,0,null)}touches(e,n){let r=0,s=wr(n),o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[a+o],d=c+u;if(e<=d&&a==s*3)return!0;r+=this.ranges[a+i]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],a=i-(this.inverted?o:0),c=i+(this.inverted?0:o),u=this.ranges[s+n],d=this.ranges[s+r];e(a,a+u,c,c+d),o+=d-u}}invert(){return new ae(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ae.empty:new ae(e<0?[0,-e,0]:[0,0,e])}}ae.empty=new ae([]);const Rt=Object.create(null);class te{getMap(){return ae.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Rt[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Rt)throw new RangeError("Duplicate use of step JSON ID "+e);return Rt[e]=n,n.prototype.jsonID=e,n}}class G{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new G(e,null)}static fail(e){return new G(null,e)}static fromReplace(e,n,r,s){try{return G.ok(e.replace(n,r,s))}catch(o){if(o instanceof Po)return G.fail(o.message);throw o}}}function It(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let o=t.child(s);o.content.size&&(o=o.copy(It(o.content,e,o))),o.isInline&&(o=e(o,n,s)),r.push(o)}return K.fromArray(r)}class Re extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new F(It(n.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),n.openStart,n.openEnd);return G.fromReplace(e,this.from,this.to,o)}invert(){return new Ie(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Re(n.pos,r.pos,this.mark)}merge(e){return e instanceof Re&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Re(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Re(n.from,n.to,e.markFromJSON(n.mark))}}te.jsonID("addMark",Re);class Ie extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new F(It(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return G.fromReplace(e,this.from,this.to,r)}invert(){return new Re(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ie(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ie&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ie(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ie(n.from,n.to,e.markFromJSON(n.mark))}}te.jsonID("removeMark",Ie);class Me extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return G.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return G.fromReplace(e,this.pos,this.pos+1,new F(K.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Me(this.pos,n.marks[s]);return new Me(this.pos,this.mark)}}return new Je(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Me(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Me(n.pos,e.markFromJSON(n.mark))}}te.jsonID("addNodeMark",Me);class Je extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return G.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return G.fromReplace(e,this.pos,this.pos+1,new F(K.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Me(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Je(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Je(n.pos,e.markFromJSON(n.mark))}}te.jsonID("removeNodeMark",Je);class Ne extends te{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Mt(e,this.from,this.to)?G.fail("Structure replace would overwrite content"):G.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ae([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ne(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ne(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ne)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?F.empty:new F(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ne(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?F.empty:new F(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ne(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ne(n.from,n.to,F.fromJSON(e,n.slice),!!n.structure)}}te.jsonID("replace",Ne);class Ue extends te{constructor(e,n,r,s,o,i,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=a}apply(e){if(this.structure&&(Mt(e,this.from,this.gapFrom)||Mt(e,this.gapTo,this.to)))return G.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return G.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?G.fromReplace(e,this.from,this.to,r):G.fail("Content does not fit in gap")}getMap(){return new ae([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ue(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||o>r.pos?null:new Ue(n.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ue(n.from,n.to,n.gapFrom,n.gapTo,F.fromJSON(e,n.slice),n.insert,!!n.structure)}}te.jsonID("replaceAround",Ue);function Mt(t,e,n){let r=t.resolve(e),s=n-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}class Ve extends te{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return G.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return G.fromReplace(e,this.pos,this.pos+1,new F(K.from(s),0,n.isLeaf?0:1))}getMap(){return ae.empty}invert(e){return new Ve(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ve(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ve(n.pos,n.attr,n.value)}}te.jsonID("attr",Ve);class pt extends te{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return G.ok(r)}getMap(){return ae.empty}invert(e){return new pt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new pt(n.attr,n.value)}}te.jsonID("docAttr",pt);let Ge=class extends Error{};Ge=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Ge.prototype=Object.create(Error.prototype),Ge.prototype.constructor=Ge,Ge.prototype.name="TransformError";const Lt=Object.create(null);class q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Nr(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=F.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:c,$to:u}=i[a],d=e.mapping.slice(o);e.replaceRange(d.map(c.pos),d.map(u.pos),a?F.empty:n),a==0&&Cr(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:a}=s[o],c=e.mapping.slice(r),u=c.map(i.pos),d=c.map(a.pos);o?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),Cr(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new ce(e):He(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=n<0?He(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):He(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new _e(e.node(0))}static atStart(e){return He(e,e,0,0,1)||new _e(e)}static atEnd(e){return He(e,e,e.content.size,e.childCount,-1)||new _e(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Lt[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Lt)throw new RangeError("Duplicate use of selection JSON ID "+e);return Lt[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ce.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class Nr{constructor(e,n){this.$from=e,this.$to=n}}let _r=!1;function Sr(t){!_r&&!t.parent.inlineContent&&(_r=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ce extends q{constructor(e,n=e){Sr(e),Sr(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let s=e.resolve(n.map(this.anchor));return new ce(s.parent.inlineContent?s:r,r)}replace(e,n=F.empty){if(super.replace(e,n),n==F.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ce&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ht(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ce(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let o=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(o)n=o.$head;else return q.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new ce(e,n)}}q.jsonID("text",ce);class ht{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ht(e.map(this.anchor),e.map(this.head))}resolve(e){return ce.between(e.resolve(this.anchor),e.resolve(this.head))}}class ue extends q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),o=e.resolve(s);return r?q.near(o):new ue(o)}content(){return new F(K.from(this.node),0,0)}eq(e){return e instanceof ue&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Dt(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ue(e.resolve(n.anchor))}static create(e,n){return new ue(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ue.prototype.visible=!1,q.jsonID("node",ue);class Dt{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ht(r,r):new Dt(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ue.isSelectable(r)?new ue(n):q.near(n)}}class _e extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=F.empty){if(n==F.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new _e(e)}map(e){return new _e(e)}eq(e){return e instanceof _e}getBookmark(){return zo}}q.jsonID("all",_e);const zo={map(){return this},resolve(t){return new _e(t)}};function He(t,e,n,r,s,o=!1){if(e.inlineContent)return ce.create(t,n);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let a=e.child(i);if(a.isAtom){if(!o&&ue.isSelectable(a))return ue.create(t,n-(s<0?a.nodeSize:0))}else{let c=He(t,a,n+s,s<0?a.childCount:0,s,o);if(c)return c}n+=a.nodeSize*s}return null}function Cr(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Ne||s instanceof Ue))return;let o=t.mapping.maps[r],i;o.forEach((a,c,u,d)=>{i==null&&(i=d)}),t.setSelection(q.near(t.doc.resolve(i),n))}function Tr(t,e){return!e||!t?t:t.bind(e)}class mt{constructor(e,n,r){this.name=e,this.init=Tr(n.init,r),this.apply=Tr(n.apply,r)}}new mt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new mt("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new mt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new mt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function kr(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=kr(s,e,{})),n[r]=s}return n}class Ar{constructor(e){this.spec=e,this.props={},e.props&&kr(e.props,this,this.props),this.key=e.key?e.key.key:Or("plugin")}getState(e){return e[this.key]}}const Pt=Object.create(null);function Or(t){return t in Pt?t+"$"+ ++Pt[t]:(Pt[t]=0,t+"$")}class Ye{constructor(e="key"){this.key=Or(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}for(var Ae={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},gt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Uo=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ho=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Q=0;Q<10;Q++)Ae[48+Q]=Ae[96+Q]=String(Q);for(var Q=1;Q<=24;Q++)Ae[Q+111]="F"+Q;for(var Q=65;Q<=90;Q++)Ae[Q]=String.fromCharCode(Q+32),gt[Q]=String.fromCharCode(Q);for(var jt in Ae)gt.hasOwnProperty(jt)||(gt[jt]=Ae[jt]);function Fo(t){var e=Uo&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ho&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?gt:Ae)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const $o=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ko=typeof navigator<"u"&&/Win/.test(navigator.platform);function qo(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,o,i;for(let a=0;a<e.length-1;a++){let c=e[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))$o?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),i&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Wo(t){let e=Object.create(null);for(let n in t)e[qo(n)]=t[n];return e}function Bt(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Jo(t){let e=Wo(t);return function(n,r){let s=Fo(r),o,i=e[Bt(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Bt(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Ko&&r.ctrlKey&&r.altKey)&&(o=Ae[r.keyCode])&&o!=s){let a=e[Bt(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var zt,Ut;if(typeof WeakMap<"u"){let t=new WeakMap;zt=e=>t.get(e),Ut=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;zt=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Ut=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Se=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let o=r+1,i=s+1;for(let a=1;o<this.width&&this.map[e+a]==n;a++)o++;for(let a=1;i<this.height&&this.map[e+this.width*a]==n;a++)i++;return{left:r,top:s,right:o,bottom:i}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:o,bottom:i}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[o*this.width+(n<0?r-1:s)]:(n<0?o==0:i==this.height)?null:this.map[r+this.width*(n<0?o-1:i)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:o}=this.findCell(t),{left:i,right:a,top:c,bottom:u}=this.findCell(e);return{left:Math.min(n,i),top:Math.min(s,c),right:Math.max(r,a),bottom:Math.max(o,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const o=r*this.width+s,i=this.map[o];n[i]||(n[i]=!0,!(s==t.left&&s&&this.map[o-1]==i||r==t.top&&r&&this.map[o-this.width]==i)&&e.push(i))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const o=s+n.child(r).nodeSize;if(r==t){let i=e+t*this.width;const a=(t+1)*this.width;for(;i<a&&this.map[i]<s;)i++;return i==a?o-1:this.map[i]}s=o}}static get(t){return zt(t)||Ut(t,Vo(t))}};function Vo(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Go(t),n=t.childCount,r=[];let s=0,o=null;const i=[];for(let u=0,d=e*n;u<d;u++)r[u]=0;for(let u=0,d=0;u<n;u++){const f=t.child(u);d++;for(let g=0;;g++){for(;s<r.length&&r[s]!=0;)s++;if(g==f.childCount)break;const w=f.child(g),{colspan:p,rowspan:N,colwidth:S}=w.attrs;for(let y=0;y<N;y++){if(y+u>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:N-y});break}const _=s+y*e;for(let v=0;v<p;v++){r[_+v]==0?r[_+v]=d:(o||(o=[])).push({type:"collision",row:u,pos:d,n:p-v});const x=S&&S[v];if(x){const O=(_+v)%e*2,E=i[O];E==null||E!=x&&i[O+1]==1?(i[O]=x,i[O+1]=1):E==x&&i[O+1]++}}}s+=p,d+=w.nodeSize}const m=(u+1)*e;let h=0;for(;s<m;)r[s++]==0&&h++;h&&(o||(o=[])).push({type:"missing",row:u,n:h}),d++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new Se(e,n,r,o);let c=!1;for(let u=0;!c&&u<i.length;u+=2)i[u]!=null&&i[u+1]<n&&(c=!0);return c&&Yo(a,i,t),a}function Go(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let o=0;if(n)for(let i=0;i<r;i++){const a=t.child(i);for(let c=0;c<a.childCount;c++){const u=a.child(c);i+u.attrs.rowspan>r&&(o+=u.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const a=s.child(i);o+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Yo(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const o=t.map[s];if(r[o])continue;r[o]=!0;const i=n.nodeAt(o);if(!i)throw new RangeError(`No cell with offset ${o} found`);let a=null;const c=i.attrs;for(let u=0;u<c.colspan;u++){const d=(s+u)%t.width,f=e[d*2];f!=null&&(!c.colwidth||c.colwidth[u]!=f)&&((a||(a=Zo(c)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function Zo(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Ht(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}new Ye("selectingCells");function Xo(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Rr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Qo(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Xo(e.$head)||ei(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function ei(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Ir(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Mr(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Lr(t,e,n){const r=t.node(-1),s=Se.get(r),o=t.start(-1),i=s.nextCell(t.pos-o,e,n);return i==null?null:t.node(0).resolve(o+i)}function Dr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}var xe=class Te extends q{constructor(e,n=e){const r=e.node(-1),s=Se.get(r),o=e.start(-1),i=s.rectBetween(e.pos-o,n.pos-o),a=e.node(0),c=s.cellsInRect(i).filter(d=>d!=n.pos-o);c.unshift(n.pos-o);const u=c.map(d=>{const f=r.nodeAt(d);if(!f)throw RangeError(`No cell with offset ${d} found`);const m=o+d+1;return new Nr(a.resolve(m),a.resolve(m+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Ir(r)&&Ir(s)&&Mr(r,s)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Te.rowSelection(r,s):o&&this.isColSelection()?Te.colSelection(r,s):new Te(r,s)}return ce.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Se.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},i=[];for(let c=s.top;c<s.bottom;c++){const u=[];for(let d=c*n.width+s.left,f=s.left;f<s.right;f++,d++){const m=n.map[d];if(o[m])continue;o[m]=!0;const h=n.findCell(m);let g=e.nodeAt(m);if(!g)throw RangeError(`No cell with offset ${m} found`);const w=s.left-h.left,p=h.right-s.right;if(w>0||p>0){let N=g.attrs;if(w>0&&(N=Dr(N,0,w)),p>0&&(N=Dr(N,N.colspan-p,p)),h.left<s.left){if(g=g.type.createAndFill(N),!g)throw RangeError(`Could not create cell with attrs ${JSON.stringify(N)}`)}else g=g.type.create(N,g.content)}if(h.top<s.top||h.bottom>s.bottom){const N={...g.attrs,rowspan:Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top)};h.top<s.top?g=g.type.createAndFill(N):g=g.type.create(N,g.content)}u.push(g)}i.push(e.child(c).copy(K.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:i;return new F(K.from(a),1,1)}replace(e,n=F.empty){const r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:a,$to:c}=s[i],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(c.pos),i?F.empty:n)}const o=q.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new F(K.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Se.get(n),s=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<o.length;i++)e(n.nodeAt(o[i]),s+o[i])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Se.get(r),o=e.start(-1),i=s.findCell(e.pos-o),a=s.findCell(n.pos-o),c=e.node(0);return i.top<=a.top?(i.top>0&&(e=c.resolve(o+s.map[i.left])),a.bottom<s.height&&(n=c.resolve(o+s.map[s.width*(s.height-1)+a.right-1]))):(a.top>0&&(n=c.resolve(o+s.map[a.left])),i.bottom<s.height&&(e=c.resolve(o+s.map[s.width*(s.height-1)+i.right-1]))),new Te(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Se.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(s,o)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,a)==n.width}eq(e){return e instanceof Te&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Se.get(r),o=e.start(-1),i=s.findCell(e.pos-o),a=s.findCell(n.pos-o),c=e.node(0);return i.left<=a.left?(i.left>0&&(e=c.resolve(o+s.map[i.top*s.width])),a.right<s.width&&(n=c.resolve(o+s.map[s.width*(a.top+1)-1]))):(a.left>0&&(n=c.resolve(o+s.map[a.top*s.width])),i.right<s.width&&(e=c.resolve(o+s.map[s.width*(i.top+1)-1]))),new Te(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Te(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Te(e.resolve(n),e.resolve(r))}getBookmark(){return new ti(this.$anchorCell.pos,this.$headCell.pos)}};xe.prototype.visible=!1,q.jsonID("cell",xe);var ti=class Fr{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Fr(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Mr(n,r)?new xe(n,r):q.near(r,1)}};new Ye("fix-tables");function Pr(t){const e=t.selection,n=Qo(t),r=n.node(-1),s=n.start(-1),o=Se.get(r);return{...e instanceof xe?o.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o.findCell(n.pos-s),tableStart:s,map:o,table:r}}function ni(t){return function(e,n){if(!Rr(e))return!1;if(n){const r=Ht(e.schema),s=Pr(e),o=e.tr,i=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),a=i.map(c=>s.table.nodeAt(c));for(let c=0;c<i.length;c++)a[c].type==r.header_cell&&o.setNodeMarkup(s.tableStart+i[c],r.cell,a[c].attrs);if(o.steps.length==0)for(let c=0;c<i.length;c++)o.setNodeMarkup(s.tableStart+i[c],r.header_cell,a[c].attrs);n(o)}return!0}}function jr(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const o=e.table.nodeAt(r[s]);if(o&&o.type!==n.header_cell)return!1}return!0}function Ft(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ni(t):function(n,r){if(!Rr(n))return!1;if(r){const s=Ht(n.schema),o=Pr(n),i=n.tr,a=jr("row",o,s),c=jr("column",o,s),d=(t==="column"?a:t==="row"?c:!1)?1:0,f=t=="column"?{left:0,top:d,right:1,bottom:o.map.height}:t=="row"?{left:d,top:0,right:o.map.width,bottom:1}:o,m=t=="column"?c?s.cell:s.header_cell:t=="row"?a?s.cell:s.header_cell:s.cell;o.map.cellsInRect(f).forEach(h=>{const g=h+o.tableStart,w=i.doc.nodeAt(g);w&&i.setNodeMarkup(g,m,w.attrs)}),r(i)}return!0}}Ft("row",{useDeprecatedLogic:!0}),Ft("column",{useDeprecatedLogic:!0}),Ft("cell",{useDeprecatedLogic:!0});function bt(t,e){const n=t.selection;if(!(n instanceof xe))return!1;if(e){const r=t.tr,s=Ht(t.schema).cell.createAndFill().content;n.forEachCell((o,i)=>{o.content.eq(s)||r.replace(r.mapping.map(i+1),r.mapping.map(i+o.nodeSize-1),new F(s,0,0))}),r.docChanged&&e(r)}return!0}Jo({ArrowLeft:yt("horiz",-1),ArrowRight:yt("horiz",1),ArrowUp:yt("vert",-1),ArrowDown:yt("vert",1),"Shift-ArrowLeft":xt("horiz",-1),"Shift-ArrowRight":xt("horiz",1),"Shift-ArrowUp":xt("vert",-1),"Shift-ArrowDown":xt("vert",1),Backspace:bt,"Mod-Backspace":bt,Delete:bt,"Mod-Delete":bt});function wt(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function yt(t,e){return(n,r,s)=>{if(!s)return!1;const o=n.selection;if(o instanceof xe)return wt(n,r,q.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const i=Br(s,t,e);if(i==null)return!1;if(t=="horiz")return wt(n,r,q.near(n.doc.resolve(o.head+e),e));{const a=n.doc.resolve(i),c=Lr(a,t,e);let u;return c?u=q.near(c,1):e<0?u=q.near(n.doc.resolve(a.before(-1)),-1):u=q.near(n.doc.resolve(a.after(-1)),1),wt(n,r,u)}}}function xt(t,e){return(n,r,s)=>{if(!s)return!1;const o=n.selection;let i;if(o instanceof xe)i=o;else{const c=Br(s,t,e);if(c==null)return!1;i=new xe(n.doc.resolve(c))}const a=Lr(i.$headCell,t,e);return a?wt(n,r,new xe(i.$anchorCell,a)):!1}}function Br(t,e,n){if(!(t.state.selection instanceof ce))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const o=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const a=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?a:null}}return null}new Ye("tableColumnResizing");function ri(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),i=Math.max(t.right,e.right)-s,a=r-n,c=s,u=n;return new DOMRect(c,u,i,a)}var si=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:s=60,shouldShow:o,appendTo:i,options:a}){this.preventHide=!1,this.isVisible=!1,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:u,from:d,to:f})=>{const{doc:m,selection:h}=u,{empty:g}=h,w=!m.textBetween(d,f).length&&W.isTextSelection(u.selection),p=this.element.contains(document.activeElement);return!(!(c.hasFocus()||p)||g||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var u;if(this.preventHide){this.preventHide=!1;return}c?.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(c.relatedTarget))||c?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,u)=>{const d=!u?.selection.eq(c.state.selection),f=!u?.doc.eq(c.state.doc);!d&&!f||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,d,f,u)},this.updateDelay))},this.updateHandler=(c,u,d,f)=>{const{composing:m}=c;if(m||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=s,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),window.addEventListener("resize",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(ir(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(or(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(rr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(cr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(ar(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(sr(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(lr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(ur(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}updatePosition(){const{selection:t}=this.editor.state,e=W.posToDOMRect(this.view,t.from,t.to);let n={getBoundingClientRect:()=>e,getClientRects:()=>[e]};if(t instanceof ue){let r=this.view.nodeDOM(t.from);const s=r.dataset.nodeViewWrapper?r:r.querySelector("[data-node-view-wrapper]");s&&(r=s),r&&(n={getBoundingClientRect:()=>r.getBoundingClientRect(),getClientRects:()=>[r.getBoundingClientRect()]})}if(t instanceof xe){const{$anchorCell:r,$headCell:s}=t,o=r?r.pos:s.pos,i=s?s.pos:r.pos,a=this.view.nodeDOM(o),c=this.view.nodeDOM(i);if(!a||!c)return;const u=a===c?a.getBoundingClientRect():ri(a.getBoundingClientRect(),c.getBoundingClientRect());n={getBoundingClientRect:()=>u,getClientRects:()=>[u]}}dr(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:o})=>{this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!e?.selection.eq(t.state.selection),o=!e?.doc.eq(t.state.doc);this.updateHandler(t,s,o,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,o=Math.min(...s.map(c=>c.$from.pos)),i=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:o,to:i})}show(){var t,e;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(e=(t=this.appendTo)!=null?t:this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},zr=t=>new Ar({key:typeof t.pluginKey=="string"?new Ye(t.pluginKey):t.pluginKey,view:e=>new si({view:e,...t})});W.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[zr({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var oi=class{constructor({editor:t,element:e,view:n,options:r,shouldShow:s}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:o,state:i})=>{const{selection:a}=i,{$anchor:c,empty:u}=a,d=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent&&c.parent.childCount===0&&!this.getTextContent(c.parent);return!(!o.hasFocus()||!u||!d||!f||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(o,i,a,c)=>{const{composing:u}=o;if(u||!i&&!a)return;if(!this.getShouldShow(c)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var i;if(this.preventHide){this.preventHide=!1;return}o?.relatedTarget&&((i=this.element.parentNode)!=null&&i.contains(o.relatedTarget))||o?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=n,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}getTextContent(t){return W.getText(t,{textSerializers:W.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(ir(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(or(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(rr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(cr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(ar(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(sr(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(lr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(ur(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,o=Math.min(...s.map(c=>c.$from.pos)),i=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:o,to:i})}updatePosition(){const{selection:t}=this.editor.state,e=W.posToDOMRect(this.view,t.from,t.to);dr({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:o})=>{this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!e?.selection.eq(t.state.selection),r=!e?.doc.eq(t.state.doc);this.updateHandler(t,n,r,e)}show(){var t;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(t=this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Ur=t=>new Ar({key:typeof t.pluginKey=="string"?new Ye(t.pluginKey):t.pluginKey,view:e=>new oi({view:e,...t})});W.Extension.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Ur({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,shouldShow:this.options.shouldShow})]:[]}});var Hr=T.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:n,resizeDelay:r,shouldShow:s=null,options:o,children:i,...a},c)=>{const u=T.useRef(document.createElement("div"));typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:d}=Z.useCurrentEditor();return T.useEffect(()=>{const f=u.current;if(f.style.visibility="hidden",f.style.position="absolute",e?.isDestroyed||d?.isDestroyed)return;const m=e||d;if(!m){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const h=zr({updateDelay:n,resizeDelay:r,editor:m,element:f,pluginKey:t,shouldShow:s,options:o});return m.registerPlugin(h),()=>{m.unregisterPlugin(t),window.requestAnimationFrame(()=>{f.parentNode&&f.parentNode.removeChild(f)})}},[e,d]),Jt.createPortal(l.jsx("div",{...a,children:i}),u.current)}),ii=T.forwardRef(({pluginKey:t="floatingMenu",editor:e,shouldShow:n=null,options:r,children:s,...o},i)=>{const a=T.useRef(document.createElement("div"));typeof i=="function"?i(a.current):i&&(i.current=a.current);const{editor:c}=Z.useCurrentEditor();return T.useEffect(()=>{const u=a.current;if(u.style.visibility="hidden",u.style.position="absolute",e?.isDestroyed||c?.isDestroyed)return;const d=e||c;if(!d){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const f=Ur({editor:d,element:u,pluginKey:t,shouldShow:n,options:r});return d.registerPlugin(f),()=>{d.unregisterPlugin(t),window.requestAnimationFrame(()=>{u.parentNode&&u.parentNode.removeChild(u)})}},[e,c]),Jt.createPortal(l.jsx("div",{...o,children:s}),a.current)});const ai=({editor:t,isReadOnly:e})=>{const[n,r]=T.useState(!1),[s,o]=T.useState(!1),[i,a]=T.useState(""),[c,u]=T.useState(!1),d=()=>{i&&(t.chain().focus().extendMarkRange("link").setLink({href:i}).run(),a(""),u(!1))};return e?null:l.jsx(Hr,{editor:t,shouldShow:({editor:f,state:m})=>{const{from:h,to:g}=m.selection;return h!==g&&!f.isActive("codeBlock")},className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:l.jsxs("div",{className:"flex gap-1 items-center",children:[l.jsx(B,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:l.jsx(M.Bold,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:l.jsx(M.Italic,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:l.jsx(M.Underline,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:l.jsx(M.Strikethrough,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:l.jsx(M.Code,{className:"h-4 w-4 cursor-pointer"})}),l.jsxs("div",{className:"relative",children:[l.jsx(B,{onClick:()=>r(!n),title:"Text Color",children:l.jsx(M.Type,{className:"h-4 w-4 cursor-pointer"})}),n&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsx(Us,{onColorChange:f=>{t.chain().focus().setColor(f).run(),r(!1)}})})]}),l.jsxs("div",{className:"relative",children:[l.jsx(B,{onClick:()=>o(!s),title:"Background Color",children:l.jsx(M.Palette,{className:"h-4 w-4 cursor-pointer"})}),s&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsx(Hs,{onColorChange:f=>{t.chain().focus().toggleHighlight({color:f}).run(),o(!1)}})})]}),l.jsxs("div",{className:"relative",children:[l.jsx(B,{onClick:()=>u(!c),isActive:t.isActive("link"),title:"Add/Edit Link",children:l.jsx(M.Link,{className:"h-4 w-4 cursor-pointer"})}),c&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"url",placeholder:"Enter URL...",value:i,onChange:f=>a(f.target.value),className:"px-2 py-1 text-sm border border-gray-300 rounded",onKeyDown:f=>{f.key==="Enter"&&d()}}),l.jsx(Y,{type:"button",onClick:d,size:"sm",className:"h-8 cursor-pointer",children:"Set"})]})})]})]})})},li=[{label:"Green",value:"#4caf5040"},{label:"Red",value:"#f4433640"},{label:"Grey",value:"#9e9e9e40"}],ci=({onColorChange:t})=>l.jsx("div",{className:"flex gap-2",children:li.map(({label:e,value:n})=>l.jsxs("button",{type:"button",className:"flex flex-col items-center text-xs text-gray-600",onClick:()=>t(n),children:[l.jsx("span",{className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n}}),e]},n))}),ui=({editor:t,isReadOnly:e})=>{const[n,r]=T.useState(!1);return e?null:l.jsx(Hr,{editor:t,shouldShow:({editor:s,state:o})=>s.isActive("codeBlock")&&!o.selection.empty,className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:l.jsx("div",{className:"flex gap-1 items-center",children:l.jsxs("div",{className:"relative",children:[l.jsx(B,{onClick:()=>r(!n),title:"Background Color",isActive:t.isActive("codeBlockBg"),children:l.jsx(M.Palette,{className:"h-4 w-4 cursor-pointer"})}),n&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsx(ci,{onColorChange:s=>{t.chain().focus().toggleCodeBlockBg(s).run(),r(!1)}})})]})})})},di=({editor:t,isReadOnly:e,onImageClick:n})=>e?null:l.jsxs(ii,{editor:t,className:"floating-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg flex gap-1 z-50",children:[l.jsx(B,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",children:l.jsx(M.Heading1,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:l.jsx(M.Heading2,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:l.jsx(M.Heading3,{className:"h-4 w-4"})}),l.jsx(B,{onClick:()=>t.chain().focus().setParagraph().run(),title:"Paragraph",children:l.jsx(M.FileText,{className:"h-4 w-4"})}),l.jsx(B,{onClick:n,title:"Insert Image",children:l.jsx(M.Image,{className:"h-4 w-4"})})]}),fi=({editor:t,isReadOnly:e,position:n})=>!n.show||e?null:l.jsxs("div",{className:"table-bubble-menu bg-white border-2 border-blue-500 rounded-lg p-2 shadow-lg",style:{position:"absolute",top:`${n.top}px`,left:`${n.left}px`,zIndex:50,backdropFilter:"blur(8px)",background:"rgba(255, 255, 255, 0.95)"},children:[l.jsxs("div",{className:"flex gap-1 items-center",children:[l.jsx(B,{onClick:()=>t.chain().focus().addRowBefore().run(),title:"Add Row Before",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"↑ Row"})]})}),l.jsx(B,{onClick:()=>t.chain().focus().addRowAfter().run(),title:"Add Row After",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Row ↓"})]})}),l.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),l.jsx(B,{onClick:()=>t.chain().focus().addColumnBefore().run(),title:"Add Column Before",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:["ß",l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"← Col"})]})}),l.jsx(B,{onClick:()=>t.chain().focus().addColumnAfter().run(),title:"Add Column After",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Col →"})]})}),l.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),l.jsx(B,{onClick:()=>t.chain().focus().deleteColumn().run(),title:"Delete Column",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Minus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Col"})]})}),l.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),l.jsx(B,{onClick:()=>t.chain().focus().deleteRow().run(),title:"Delete Row",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Minus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Row"})]})}),l.jsx(B,{onClick:()=>t.chain().focus().deleteTable().run(),title:"Delete Table",className:"text-red-600 hover:bg-red-50",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"absolute top-full left-5 w-0 h-0 border-l-6 border-r-6 border-t-6 border-l-transparent border-r-transparent border-t-blue-500"})]}),pi=({editor:t})=>l.jsxs("div",{className:"mb-2 p-2 bg-gray-100 rounded text-xs",children:[l.jsx("strong",{children:"Debug:"})," Current position - H1:"," ",t.isActive("heading",{level:1})?"✅":"❌"," | H2:"," ",t.isActive("heading",{level:2})?"✅":"❌"," | H3:"," ",t.isActive("heading",{level:3})?"✅":"❌"," | P:"," ",t.isActive("paragraph")?"✅":"❌"," | Bold:"," ",t.isActive("bold")?"✅":"❌"," | List:"," ",t.isActive("bulletList")?"✅":"❌"," | Table:"," ",t.isActive("table")?"✅":"❌"]}),hi=({isReadOnly:t,setIsReadOnly:e,onLogContent:n})=>l.jsxs("div",{className:"mb-4 flex justify-end gap-2",children:[l.jsxs(Y,{type:"button",onClick:n,variant:"outline",size:"sm",className:"flex items-center gap-2",title:"Log content to console for backend storage",children:[l.jsx(M.Terminal,{className:"h-4 w-4"}),"Log Content"]}),l.jsx(Y,{type:"button",onClick:()=>e(!t),variant:t?"default":"outline",size:"sm",className:"flex items-center gap-2",children:t?l.jsxs(l.Fragment,{children:[l.jsx(M.Lock,{className:"h-4 w-4"}),"Read Only"]}):l.jsxs(l.Fragment,{children:[l.jsx(M.LockOpen,{className:"h-4 w-4"}),"Editable"]})})]}),mi=t=>{const e={html:t.getHTML(),json:t.getJSON(),text:t.getText(),isEmpty:t.isEmpty,characterCount:t.storage.characterCount?.characters()||t.getText().length,wordCount:t.storage.characterCount?.words()||t.getText().split(/\s+/).filter(n=>n.length>0).length,timestamp:new Date().toISOString()};return console.log("📄 Tiptap Editor Content for Backend Storage:"),console.log("================================================"),console.log("📋 HTML Output (for rendering):",e.html),console.log("📋 JSON Output (for editing):",e.json),console.log("📋 Plain Text:",e.text),console.log("📊 Stats:",{isEmpty:e.isEmpty,characters:e.characterCount,words:e.wordCount,timestamp:e.timestamp}),console.log("================================================"),e},gi=({onImageUpload:t,onVideoUpload:e,onImageDelete:n,onVideoDelete:r,content:s,setEditorContent:o})=>{const[i,a]=T.useState(""),[c,u]=T.useState(!1),[,d]=T.useState({}),[f,m]=T.useState(!1),[h,g]=T.useState(!1),[w,p]=T.useState(!1),[N,S]=T.useState(null),y=T.useRef(null),[_,v]=T.useState({top:0,left:0,show:!1}),x=D=>{const R=new Set,I=C=>{C.type==="image"&&C.attrs?.src&&R.add(C.attrs.src),C.content&&Array.isArray(C.content)&&C.content.forEach(I)};return I(D),R},O=D=>{const R=new Set,I=C=>{C.type==="video"&&C.attrs?.src&&R.add(C.attrs.src),C.content&&Array.isArray(C.content)&&C.content.forEach(I)};return I(D),R},E=Z.useEditor({extensions:[Zt,Xt,$t,qt,Kt,Qt,en,xn,vn,tn,nn,rn,yn,wn,En,Nn,_n,Sn,Cn,Tn,kn,On,Rn,An.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:s||`
22
+ <%s key={someKey} {...props} />`,J,X,Oe,X),B[X+J]=!0)}if(X=null,j!==void 0&&(n(j),X=""+j),i(O)&&(n(O.key),X=""+O.key),"key"in O){j={};for(var _e in O)_e!=="key"&&(j[_e]=O[_e])}else j=O;return X&&a(j,typeof b=="function"?b.displayName||b.name||"Unknown":b),u(b,X,ee,re,s(),j,He,oe)}function f(b){typeof b=="object"&&b!==null&&b.$$typeof===p&&b._store&&(b._store.validated=1)}var h=T,p=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),C=Symbol.for("react.consumer"),y=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),E=Symbol.for("react.client.reference"),z=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,R=Array.isArray,I=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(b){return b()}};var L,k={},F=h.react_stack_bottom_frame.bind(h,o)(),A=I(r(o)),B={};Ke.Fragment=w,Ke.jsx=function(b,O,j,J,re){var ee=1e4>z.recentlyCreatedOwnerStacks++;return d(b,O,j,!1,J,re,ee?Error("react-stack-top-frame"):F,ee?I(r(b)):A)},Ke.jsxs=function(b,O,j,J,re){var ee=1e4>z.recentlyCreatedOwnerStacks++;return d(b,O,j,!0,J,re,ee?Error("react-stack-top-frame"):F,ee?I(r(b)):A)}})()),Ke}var Yt;function cs(){return Yt||(Yt=1,process.env.NODE_ENV==="production"?Ze.exports=as():Ze.exports=ls()),Ze.exports}var l=cs();const Zt=Kr.configure({codeBlock:!1}),Xt=qr.Table.configure({resizable:!0}),Qt=Wr.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}),en=Jr.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),tn=Vr.TextStyle,nn=Gr.configure({types:["textStyle"]}),rn=Yr.configure({multicolor:!0}),us=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),ds=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],fs=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],ps=[...ds,...fs],hs=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),ms=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),gs=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),bs=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function ws(t){const e=t.regex,n=us(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",o=/@-?\w[\w]*(-\w+)*/,i="[a-zA-Z-][a-zA-Z0-9_-]*",a=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+i,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+ms.join("|")+")"},{begin:":(:)?("+gs.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+bs.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...a,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...a,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:hs.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...a,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+ps.join("|")+")\\b"}]}}const sn="[A-Za-z$_][0-9A-Za-z$_]*",ys=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],xs=["true","false","null","undefined","NaN","Infinity"],on=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],an=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],ln=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],vs=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Es=[].concat(ln,on,an);function Ns(t){const e=t.regex,n=(A,{after:B})=>{const b="</"+A[0].slice(1);return A.input.indexOf(b,B)!==-1},r=sn,s={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,B)=>{const b=A[0].length+A.index,O=A.input[b];if(O==="<"||O===","){B.ignoreMatch();return}O===">"&&(n(A,{after:b})||B.ignoreMatch());let j;const J=A.input.substring(b);if(j=J.match(/^\s*=/)){B.ignoreMatch();return}if((j=J.match(/^\s+extends\s+/))&&j.index===0){B.ignoreMatch();return}}},a={$pattern:sn,keyword:ys,literal:xs,built_in:Es,"variable.language":vs},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},y=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,m,w,g,{match:/\$\d+/},f];h.contains=y.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(y)});const S=[].concat(C,h.contains),x=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(S)}]),_={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:x},D={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},v={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...on,...an]}},U={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},E={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[_],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(A){return e.concat("(?!",A.join("|"),")")}const R={match:e.concat(/\b/,V([...ln,"super","import"].map(A=>`${A}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},L={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},_]},k="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(k)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[_]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),U,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,m,w,g,C,{match:/\$\d+/},f,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},F,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:k,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:x}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},E,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[_,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[_]},R,z,D,L,{match:/\$[(.]/}]}}const Xe="[A-Za-z$_][0-9A-Za-z$_]*",cn=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],un=["true","false","null","undefined","NaN","Infinity"],dn=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],fn=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],pn=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],hn=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],mn=[].concat(pn,dn,fn);function Ss(t){const e=t.regex,n=(A,{after:B})=>{const b="</"+A[0].slice(1);return A.input.indexOf(b,B)!==-1},r=Xe,s={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(A,B)=>{const b=A[0].length+A.index,O=A.input[b];if(O==="<"||O===","){B.ignoreMatch();return}O===">"&&(n(A,{after:b})||B.ignoreMatch());let j;const J=A.input.substring(b);if(j=J.match(/^\s*=/)){B.ignoreMatch();return}if((j=J.match(/^\s+extends\s+/))&&j.index===0){B.ignoreMatch();return}}},a={$pattern:Xe,keyword:cn,literal:un,built_in:mn,"variable.language":hn},c="[0-9](_?[0-9])*",u=`\\.(${c})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${u})|\\.)?|(${u}))[eE][+-]?(${c})\\b`},{begin:`\\b(${d})\\b((${u})\\b|\\.)?|(${u})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},p={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},m={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},y=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,m,w,g,{match:/\$\d+/},f];h.contains=y.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(y)});const S=[].concat(C,h.contains),x=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(S)}]),_={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:x},D={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},v={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...dn,...fn]}},U={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},E={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[_],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(A){return e.concat("(?!",A.join("|"),")")}const R={match:e.concat(/\b/,V([...pn,"super","import"].map(A=>`${A}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},L={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},_]},k="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(k)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[_]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),U,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,p,m,w,g,C,{match:/\$\d+/},f,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},F,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:k,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:x}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},E,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[_,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[_]},R,z,D,L,{match:/\$[(.]/}]}}function Cs(t){const e=t.regex,n=Ss(t),r=Xe,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},i={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},a={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},c=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],u={$pattern:Xe,keyword:cn.concat(c),literal:un,built_in:mn.concat(s),"variable.language":hn},d={className:"meta",begin:"@"+r},f=(w,g,N)=>{const C=w.contains.findIndex(y=>y.label===g);if(C===-1)throw new Error("can not find mode to replace");w.contains.splice(C,1,N)};Object.assign(n.keywords,u),n.exports.PARAMS_CONTAINS.push(d);const h=n.contains.find(w=>w.scope==="attr"),p=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,p]),n.contains=n.contains.concat([d,o,i,p]),f(n,"shebang",t.SHEBANG()),f(n,"use_strict",a);const m=n.contains.find(w=>w.label==="func.def");return m.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function _s(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},i=t.inherit(o,{begin:/\(/,end:/\)/}),a=t.inherit(t.APOS_STRING_MODE,{className:"string"}),c=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,c,a,i,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,i,c,a]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:u}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Ts(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],a={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},c={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:a,illegal:/#/},d={begin:/\{\{/,relevance:0},f={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,c,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,c,d,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,d,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,d,u]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",p=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,m=`\\b|${r.join("|")}`,w={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${p}))[eE][+-]?(${h})[jJ]?(?=${m})`},{begin:`(${p})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${m})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${m})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${m})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${m})`},{begin:`\\b(${h})[jJ](?=${m})`}]},g={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:a,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:["self",c,w,f,t.HASH_COMMENT_MODE]}]};return u.contains=[f,w,c],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:a,illegal:/(<\/|\?)|=>/,contains:[c,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,g,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[w,N,f]}]}}var Le="[0-9](_*[0-9])*",Qe=`\\.(${Le})`,et="[0-9a-fA-F](_*[0-9a-fA-F])*",gn={className:"number",variants:[{begin:`(\\b(${Le})((${Qe})|\\.)?|(${Qe}))[eE][+-]?(${Le})[fFdD]?\\b`},{begin:`\\b(${Le})((${Qe})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Qe})[fFdD]?\\b`},{begin:`\\b(${Le})[fFdD]\\b`},{begin:`\\b0[xX]((${et})\\.?|(${et})?\\.(${et}))[pP][+-]?(${Le})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${et})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function bn(t,e,n){return n===-1?"":t.replace(e,r=>bn(t,e,n-1))}function ks(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+bn("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),c={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},u={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},d={className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:c,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[d,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:c,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:c,relevance:0,contains:[u,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,gn,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},gn,u]}}function As(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",i="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",a={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},p=e.optional(s)+t.IDENT_RE+"\\s*\\(",g={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},N=[f,a,n,t.C_BLOCK_COMMENT_MODE,d,u],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:g,contains:N.concat([{begin:/\(/,end:/\)/,keywords:g,contains:N.concat(["self"]),relevance:0}]),relevance:0},y={begin:"("+i+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:g,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:g,relevance:0},{begin:p,returnBegin:!0,contains:[t.inherit(h,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,d,a,{begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,d,a]}]},a,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C",aliases:["h"],keywords:g,disableAutodetect:!0,illegal:"</",contains:[].concat(C,y,N,[f,{begin:t.IDENT_RE+"::",keywords:g},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:f,strings:u,keywords:g}}}function Os(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",i="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",a={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},d={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},f={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},h={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},p=e.optional(s)+t.IDENT_RE+"\\s*\\(",m=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],g=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],N=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],S={type:w,keyword:m,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:g},x={className:"function.dispatch",relevance:0,keywords:{_hint:N},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},_=[x,f,a,n,t.C_BLOCK_COMMENT_MODE,d,u],D={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:S,contains:_.concat([{begin:/\(/,end:/\)/,keywords:S,contains:_.concat(["self"]),relevance:0}]),relevance:0},v={className:"function",begin:"("+i+"[\\*&\\s]+)+"+p,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:S,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:S,relevance:0},{begin:p,returnBegin:!0,contains:[h],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,d]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:S,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,u,d,a,{begin:/\(/,end:/\)/,keywords:S,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,u,d,a]}]},a,n,t.C_BLOCK_COMMENT_MODE,f]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:S,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(D,v,x,_,[f,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:S,contains:["self",a]},{begin:t.IDENT_RE+"::",keywords:S},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function Rs(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],i=["double precision","large object","with timezone","without timezone"],a=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],c=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],p=d,m=[...u,...c].filter(x=>!d.includes(x)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},g={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},N={match:e.concat(/\b/,e.either(...p),/\s*\(/),relevance:0,keywords:{built_in:p}};function C(x){return e.concat(/\b/,e.either(...x.map(_=>_.replace(/\s+/,"\\s+"))),/\b/)}const y={scope:"keyword",match:C(h),relevance:0};function S(x,{exceptions:_,when:D}={}){const v=D;return _=_||[],x.map(U=>U.match(/\|\d+$/)||_.includes(U)?U:v(U)?`${U}|0`:U)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:S(m,{when:x=>x.length<3}),literal:o,type:a,built_in:f},contains:[{scope:"type",match:C(i)},y,N,w,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,g]}}const wn=W.Mark.create({name:"codeBlockBg",addOptions(){return{multicolor:!0,HTMLAttributes:{}}},inclusive:!1,addAttributes(){return{color:{default:null,parseHTML:t=>t.getAttribute("data-background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-background-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}},parseHTML(){return[{tag:"span[data-background-color]",getAttrs:t=>typeof t=="string"?!1:{color:t.getAttribute("data-background-color")}}]},renderHTML({HTMLAttributes:t,mark:e}){const n=e.attrs?.color||t["data-background-color"];return n?["span",{"data-background-color":n,style:`background-color: ${n}; color: inherit`},0]:["span",{},0]},addCommands(){return{setCodeBlockBg:t=>({commands:e})=>e.setMark(this.name,{color:t}),toggleCodeBlockBg:t=>({commands:e})=>e.toggleMark(this.name,{color:t}),unsetCodeBlockBg:()=>({commands:t})=>t.unsetMark(this.name)}}}),me=Wt.createLowlight(Wt.all);me.register("html",_s),me.register("css",ws),me.register("js",Ns),me.register("ts",Cs),me.register("java",ks),me.register("c",As),me.register("cpp",Os),me.register("python",Ts),me.register("sql",Rs);const yn=Zr.extend({marks(){return"codeBlockBg"}}).configure({lowlight:me}),xn=Xr,vn=Qr,En=es,Nn=ts;function Is({node:t,updateAttributes:e,editor:n}){const[r,s]=T.useState(t.attrs?.open??!0),[o,i]=T.useState(!1),[a,c]=T.useState(t.attrs?.title||"Output"),u=T.useRef(null),d=n?.isEditable??!1;T.useEffect(()=>{o&&u.current&&(u.current.focus(),u.current.select())},[o]);const f=()=>{i(!1),e({title:a,open:r})},h=g=>{g.key==="Enter"?f():g.key==="Escape"&&(c(t.attrs?.title||"Output"),i(!1))},p=()=>{const g=!r;s(g),e({title:a,open:g})},m=()=>{d&&n&&confirm("Are you sure you want to delete this accordion?")&&n.chain().focus().deleteNode("accordion").run()},w=g=>{if(!d||!n)return;const{selection:N}=n.state,{$anchor:C}=N;if(g.key==="Enter"&&!g.shiftKey&&C.nodeBefore?.type.name==="accordion"){g.preventDefault(),g.stopPropagation();const y=C.nodeBefore;if(y&&y.childCount>0){const S=y.lastChild;if(S&&S.content.size>0){let x=-1;if(n.state.doc.descendants((_,D)=>{if(_.type.name==="accordionItem")return x=D,!1}),x!==-1){const _=x+S.nodeSize-2;n.chain().focus().setTextSelection(_).run()}}else{let x=-1;n.state.doc.descendants((_,D)=>{if(_.type.name==="accordionItem")return x=D,!1}),x!==-1&&n.chain().focus().setTextSelection(x+1).run()}}return}if((g.key==="Backspace"||g.key==="Delete")&&!g.shiftKey){if(C.nodeBefore?.type.name==="accordion"){g.preventDefault(),g.stopPropagation();return}if(C.nodeAfter?.type.name==="accordion"){g.preventDefault(),g.stopPropagation();return}if(C.parent.type.name==="accordionItem"){const y=C.parent,S=C.parentOffset===0,x=y.content.content.some(_=>_.type.name==="paragraph"?_.content.size>0:!0);if(S&&!x&&g.key==="Backspace"){g.preventDefault(),g.stopPropagation();return}}if(C.parent.type.name==="accordion"&&!C.parent.content.content.some(x=>x.type.name==="accordionItem"?x.content.content.some(_=>_.type.name==="paragraph"?_.content.size>0:!0):!0)){g.preventDefault(),g.stopPropagation();return}}};return l.jsxs(Z.NodeViewWrapper,{className:"accordion border border-gray-200 rounded-lg mb-3 overflow-hidden",onKeyDown:w,children:[l.jsx("div",{className:"accordion-header bg-gray-50 border-b border-gray-200",onClick:p,children:l.jsxs("div",{className:"flex items-center gap-2 px-1",children:[l.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),p()},className:"flex items-center justify-center w-6 h-6 text-gray-600 hover:text-gray-800",title:r?"Collapse":"Expand",children:l.jsx("span",{className:`cursor-pointer transition-transform duration-200 ${r?"rotate-90":""}`,children:"▶"})}),o?l.jsx("input",{ref:u,type:"text",value:a,onChange:g=>c(g.target.value),onBlur:f,onKeyDown:h,className:"bg-transparent border-b border-gray-300 outline-none font-medium text-gray-800 flex-1 py-1",placeholder:"Enter accordion title..."}):l.jsx("div",{onClick:d?g=>{g.stopPropagation(),i(!0)}:void 0,className:`font-medium text-gray-800 flex-1 py-1 ${d?"cursor-text hover:text-blue-600":"cursor-pointer"}`,title:d?"Click to edit title":void 0,children:a}),d&&l.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),m()},className:"px-2 py-1 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors rounded",title:"Delete accordion",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]})}),r&&l.jsx("div",{className:"accordion-content p-3 bg-white",children:l.jsx(Z.NodeViewContent,{})})]})}const Sn=W.Node.create({name:"accordion",group:"block",content:"accordionItem+",defining:!0,isolating:!0,addAttributes(){return{title:{default:"Output",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>t.title?{"data-title":t.title}:{}},open:{default:!0,parseHTML:t=>t.getAttribute("data-open")==="true",renderHTML:t=>({"data-open":t.open})}}},parseHTML(){return[{tag:'div[data-type="accordion"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"accordion"}),0]},addNodeView(){return Z.ReactNodeViewRenderer(Is)},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(o=>o.type.name==="accordionItem"?o.content.content.some(i=>i.type.name==="paragraph"?i.content.size>0:!0):!0)},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="accordion"||n.parent.type.name==="accordion"&&!n.parent.content.content.some(o=>o.type.name==="accordionItem"?o.content.content.some(i=>i.type.name==="paragraph"?i.content.size>0:!0):!0)}}},addCommands(){return{insertAccordion:()=>({commands:t})=>t.insertContent({type:this.name,content:[{type:"accordionItem",content:[{type:"paragraph",content:[{type:"text",text:"Accordion Item 1"}]}]}]})}}}),Cn=W.Node.create({name:"accordionItem",group:"block",content:"block+",defining:!0,isolating:!0,parseHTML(){return[{tag:'div[data-type="accordion-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"accordion-item"}),0]},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.parent.type.name==="accordionItem",!1},Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="accordionItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function Ms({node:t,updateAttributes:e,editor:n}){const[r,s]=T.useState(t.attrs?.activeTab??0),[o,i]=T.useState(null),[a,c]=T.useState(""),u=T.useRef(null),d=t.content?.content||[],f=n?.isEditable??!1;T.useEffect(()=>{const y=t.attrs?.activeTab??0;y!==r&&s(y)},[t.attrs?.activeTab]),T.useEffect(()=>{o!==null&&u.current&&(u.current.focus(),u.current.select())},[o]);const h=y=>{s(y),e({...t.attrs,activeTab:y})},p=(y,S)=>{f&&(i(y),c(S))},m=()=>{f&&n&&confirm("Are you sure you want to delete this tabs component?")&&n.chain().focus().deleteNode("tabs").run()},w=()=>{if(o!==null&&d[o]&&n){let y=-1;n.state.doc.descendants((S,x)=>{if(S.type.name==="tabItem"&&S.attrs.tabIndex===o)return y=x,!1}),y!==-1&&n.chain().focus().command(({tr:S,dispatch:x})=>{if(x){const _=S.doc.nodeAt(y);_&&S.setNodeMarkup(y,void 0,{..._.attrs,title:a})}return!0}).run()}i(null),c("")},g=y=>{y.key==="Enter"?w():y.key==="Escape"&&(i(null),c(""))},N=y=>d[y]?.attrs?.title||`Tab ${y+1}`,C=y=>{if(!f||!n)return;const{selection:S}=n.state,{$anchor:x}=S;if(y.key==="Enter"&&!y.shiftKey&&x.nodeBefore?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();const _=x.nodeBefore;if(_&&_.childCount>0){const D=_.lastChild;if(D&&D.content.size>0){let v=-1;if(n.state.doc.descendants((U,E)=>{if(U.type.name==="tabItem"&&U.attrs.tabIndex===_.childCount-1)return v=E,!1}),v!==-1){const U=v+D.nodeSize-2;n.chain().focus().setTextSelection(U).run()}}}return}if((y.key==="Backspace"||y.key==="Delete")&&!y.shiftKey){if(x.nodeBefore?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();return}if(x.nodeAfter?.type.name==="tabs"){y.preventDefault(),y.stopPropagation();return}}};return l.jsxs(Z.NodeViewWrapper,{className:"tabs-container border border-gray-200 rounded-lg mb-4 overflow-hidden","data-active-tab":r,onKeyDown:C,children:[l.jsx("div",{className:"tabs-header bg-gray-50 border-b border-gray-200",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex flex-1",children:d.map((y,S)=>l.jsx("button",{type:"button",onClick:()=>h(S),className:`flex-1 px-4 py-2 text-sm font-medium border-b-2 border-r border-gray-200 transition-colors relative cursor-pointer ${r===S?"border-blue-500 border-r-gray-200 text-blue-600 bg-white":"border-transparent border-r-gray-200 text-gray-500 hover:text-gray-700 hover:border-gray-300"} ${S===d.length-1?"border-r-0":""}`,children:o===S?l.jsx("input",{ref:u,type:"text",value:a,onChange:x=>c(x.target.value),onBlur:w,onKeyDown:g,className:"bg-transparent border-none outline-none text-center w-full",onClick:x=>x.stopPropagation()}):l.jsx("span",{onClick:f?x=>{x.stopPropagation(),p(S,N(S))}:void 0,className:`block w-full text-center ${f?"cursor-text":"cursor-pointer"}`,title:f?"Click to edit title":void 0,children:N(S)})},S))}),f&&l.jsx("button",{type:"button",onClick:m,className:"px-3 py-2 text-red-600 hover:text-red-700 hover:bg-red-50 transition-colors",title:"Delete tabs",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]})}),l.jsx("div",{className:"tabs-content",children:l.jsx(Z.NodeViewContent,{className:"tab-content-wrapper","data-active-tab":r})})]})}function Ls({node:t,editor:e}){const n=t.attrs?.tabIndex||0,r=e?.isEditable??!1,s=o=>{if(!r||!e)return;const{selection:i}=e.state,{$anchor:a}=i;if(o.key==="Enter"&&!o.shiftKey&&a.parent.type.name==="tabItem"){const c=a.parent;if(a.parentOffset===c.childCount)return}if(o.key==="Backspace"&&a.parent.type.name==="tabItem"){const c=a.parent;if(a.parentOffset===0&&c.childCount>0&&c.firstChild&&a.pos===a.start(a.depth))return}};return l.jsx(Z.NodeViewWrapper,{className:"tab-item-content p-4","data-tab-index":n,onKeyDown:s,children:l.jsx(Z.NodeViewContent,{})})}const _n=W.Node.create({name:"tabs",group:"block",content:"tabItem+",defining:!0,isolating:!0,addAttributes(){return{activeTab:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-active-tab")||"0"),renderHTML:t=>({"data-active-tab":t.activeTab})},tabCount:{default:2,parseHTML:t=>parseInt(t.getAttribute("data-tab-count")||"2"),renderHTML:t=>({"data-tab-count":t.tabCount})}}},parseHTML(){return[{tag:'div[data-type="tabs"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"tabs"}),0]},addNodeView(){return Z.ReactNodeViewRenderer(Ms,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeBefore?.type.name==="tabs"},Delete:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;return n.nodeAfter?.type.name==="tabs"}}},addCommands(){return{insertTabs:(t={tabCount:2})=>({commands:e})=>{const n=Math.min(Math.max(t.tabCount||2,2),6),r=Array.from({length:n},(s,o)=>({type:"tabItem",attrs:{tabIndex:o,title:`Tab ${o+1}`},content:[{type:"paragraph",content:[{type:"text",text:`Content for Tab ${o+1}. This is unique content for this tab.`}]}]}));return e.insertContent({type:this.name,attrs:{activeTab:0,tabCount:n},content:r})}}}}),Tn=W.Node.create({name:"tabItem",group:"block",content:"block+",defining:!0,isolating:!0,addAttributes(){return{tabIndex:{default:0,parseHTML:t=>parseInt(t.getAttribute("data-tab-index")||"0"),renderHTML:t=>({"data-tab-index":t.tabIndex})},title:{default:"Tab",parseHTML:t=>t.getAttribute("data-title")||"Tab",renderHTML:t=>({"data-title":t.title})}}},parseHTML(){return[{tag:'div[data-type="tab-item"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"tab-item"}),0]},addNodeView(){return Z.ReactNodeViewRenderer(Ls,{contentDOMElementTag:"div"})},addKeyboardShortcuts(){return{Enter:()=>!1,Backspace:({editor:t})=>{const{selection:e}=t.state,{$anchor:n}=e;if(n.parent.type.name==="tabItem"&&n.parentOffset===0&&n.depth>0){const r=n.start(n.depth);if(n.pos<=r+1)return!0}return!1}}}});function Ds(...t){return os.twMerge(ss.clsx(t))}const Ps=rs.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function G({className:t,variant:e,size:n,asChild:r=!1,...s}){const o=r?ns.Slot:"button";return l.jsx(o,{"data-slot":"button",className:Ds(Ps({variant:e,size:n,className:t})),...s})}const js=({node:t,updateAttributes:e,deleteNode:n,editor:r})=>{const[s,o]=T.useState(!1),[i,a]=T.useState("simple"),[c,u]=T.useState(""),[d,f]=T.useState(!1),h=T.useRef(null),[p,m]=T.useState({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),w=E=>{const z=E.toLowerCase();return z.includes("youtube.com")||z.includes("youtu.be")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox":z.includes("codesandbox.io")||z.includes("stackblitz.com")?"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation allow-popups-to-escape-sandbox allow-top-navigation":"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"},g=E=>{const z=w(E);m({...p,src:E,sandbox:z})},N=()=>{y&&(e(p),o(!1))},C=()=>{m({src:t.attrs.src||"",width:t.attrs.width||"100%",height:t.attrs.height||"500px",title:t.attrs.title||"",allow:t.attrs.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.attrs.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.attrs.style||""}),o(!1)},[y,S]=T.useState(r?.isEditable??!1);T.useEffect(()=>{if(r){const E=()=>{S(r.isEditable)};return E(),r.on("update",E),r.on("selectionUpdate",E),()=>{r.off("update",E),r.off("selectionUpdate",E)}}},[r]);const x=()=>{y&&o(!0)},_=()=>{const E=`<iframe src="${p.src}" style="width:${p.width}; height: ${p.height}; ${p.style}" title="${p.title}" allow="${p.allow}" sandbox="${p.sandbox}"></iframe>`;navigator.clipboard.writeText(E)},D=()=>{h.current&&(d?document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen():h.current.requestFullscreen?h.current.requestFullscreen():h.current.webkitRequestFullscreen?h.current.webkitRequestFullscreen():h.current.mozRequestFullScreen?h.current.mozRequestFullScreen():h.current.msRequestFullscreen&&h.current.msRequestFullscreen())};T.useEffect(()=>{const E=()=>{const z=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);f(z)};return document.addEventListener("fullscreenchange",E),document.addEventListener("webkitfullscreenchange",E),document.addEventListener("mozfullscreenchange",E),document.addEventListener("MSFullscreenChange",E),()=>{document.removeEventListener("fullscreenchange",E),document.removeEventListener("webkitfullscreenchange",E),document.removeEventListener("mozfullscreenchange",E),document.removeEventListener("MSFullscreenChange",E)}},[]);const v=E=>{const R=new DOMParser().parseFromString(E,"text/html").querySelector("iframe");if(R){const I=R.getAttribute("src")||"",L={src:I,width:R.getAttribute("width")||"100%",height:R.getAttribute("height")||"500px",title:R.getAttribute("title")||"",allow:R.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:R.getAttribute("sandbox")||w(I),style:R.getAttribute("style")||""};return m(L),!0}return!1},U=()=>{v(c)?(a("simple"),u("")):alert("Invalid iframe HTML code. Please check your input.")};return s?l.jsx(Z.NodeViewWrapper,{className:"iframe-extension-editing",children:l.jsxs("div",{className:"border-2 border-blue-500 rounded-lg p-4 bg-blue-50",children:[l.jsxs("div",{className:"flex gap-2 mb-4",children:[l.jsx(G,{onClick:()=>a("simple"),size:"sm",variant:i==="simple"?"default":"outline",className:"flex-1",children:"Simple Mode"}),l.jsx(G,{onClick:()=>a("advanced"),size:"sm",variant:i==="advanced"?"default":"outline",className:"flex-1",children:"Advanced Mode"})]}),i==="simple"?l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Source URL"}),l.jsx("input",{type:"url",value:p.src,onChange:E=>g(E.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"https://example.com/embed"}),l.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Sandbox attributes are automatically configured based on the URL for optimal compatibility."})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Width"}),l.jsx("input",{type:"text",value:p.width,onChange:E=>m({...p,width:E.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"100%"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Height"}),l.jsx("input",{type:"text",value:p.height,onChange:E=>m({...p,height:E.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"500px"})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),l.jsx("input",{type:"text",value:p.title,onChange:E=>m({...p,title:E.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Embedded Content"})]})]}):l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Paste your iframe HTML code"}),l.jsx("textarea",{value:c,onChange:E=>u(E.target.value),className:"w-full h-32 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-sm",placeholder:'<iframe src="https://example.com/embed" style="width:100%; height:500px; border:0; border-radius:4px; overflow:hidden;" title="Example" allow="..." sandbox="..."></iframe>'})]}),l.jsx("div",{className:"text-xs text-gray-600",children:"Paste your complete iframe HTML code here. The extension will automatically extract the attributes."}),l.jsxs("div",{className:"border-t pt-3",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Sandbox Attributes (Advanced)"}),l.jsx("input",{type:"text",value:p.sandbox,onChange:E=>m({...p,sandbox:E.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 font-mono text-xs",placeholder:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation"}),l.jsx("div",{className:"text-xs text-gray-600 mt-1",children:"Override automatic sandbox configuration if needed. Common values: allow-scripts, allow-same-origin, allow-forms, allow-popups"})]})]}),l.jsxs("div",{className:"flex gap-2 mt-4",children:[i==="advanced"&&l.jsx(G,{onClick:U,size:"sm",className:"bg-green-600 hover:bg-green-700",children:"Parse & Apply"}),l.jsx(G,{onClick:N,size:"sm",className:"bg-blue-600 hover:bg-blue-700",children:"Save"}),l.jsx(G,{onClick:C,size:"sm",variant:"outline",children:"Cancel"})]})]})}):l.jsx(Z.NodeViewWrapper,{className:"iframe-extension",children:l.jsxs("div",{ref:h,className:"relative group",children:[l.jsx("iframe",{src:t.attrs.src,...d?{}:{width:t.attrs.width,height:t.attrs.height},title:t.attrs.title,allow:t.attrs.allow,sandbox:t.attrs.sandbox,style:{...Bs(t.attrs.style),...d?{width:"100vw",height:"100vh"}:{width:t.attrs.width,height:t.attrs.height}},className:d?"rounded-lg iframe-fullscreen":"rounded-lg"}),y&&l.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200 bg-white/90 backdrop-blur-sm rounded-lg p-1 shadow-lg border",children:l.jsxs("div",{className:"flex gap-1",children:[l.jsx(G,{onClick:x,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Edit iframe",children:l.jsx(M.Settings,{className:"h-4 w-4"})}),l.jsx(G,{onClick:()=>window.open(t.attrs.src,"_blank"),size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Open in new tab",children:l.jsx(M.ExternalLink,{className:"h-4 w-4"})}),l.jsx(G,{onClick:_,size:"sm",variant:"ghost",className:"h-8 w-8 p-0",title:"Copy iframe code",children:l.jsx(M.Copy,{className:"h-4 w-4"})}),l.jsx(G,{onClick:()=>{y&&n()},size:"sm",variant:"ghost",className:"h-8 w-8 p-0 text-red-600 hover:text-red-700",title:"Delete iframe",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]})}),l.jsx("div",{className:`absolute hidden md:block ${d?"md:top-[22px]":"md:top-[7px]"} md:right-[150px] bg-white/90 rounded-lg p-1 shadow-lg border z-10 cursor-pointer`,children:l.jsx(G,{onClick:D,size:"sm",variant:"ghost",className:"h-6 w-8 p-0 cursor-pointer",title:d?"Exit fullscreen":"Enter fullscreen",children:d?l.jsx(M.Minimize,{className:"h-4 w-4"}):l.jsx(M.Maximize,{className:"h-4 w-4"})})}),y&&t.attrs.src&&l.jsxs("div",{className:"mt-2 text-xs text-gray-500 bg-gray-100 px-2 py-1 rounded",children:["Source: ",t.attrs.src]})]})})},Bs=t=>{const e={};return t&&t.split(";").forEach(n=>{const[r,s]=n.split(":").map(o=>o.trim());if(r&&s){const o=r.replace(/-([a-z])/g,i=>i[1].toUpperCase());e[o]=s}}),e},kn=W.Node.create({name:"iframe",group:"block",atom:!0,addOptions(){return{readOnly:!1}},addAttributes(){return{src:{default:"",parseHTML:t=>t.getAttribute("src")||"",renderHTML:t=>({src:t.src})},width:{default:"100%",parseHTML:t=>t.getAttribute("width")||"100%",renderHTML:t=>({width:t.width})},height:{default:"500px",parseHTML:t=>t.getAttribute("height")||"500px",renderHTML:t=>({height:t.height})},title:{default:"",parseHTML:t=>t.getAttribute("title")||"",renderHTML:t=>({title:t.title})},allow:{default:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",parseHTML:t=>t.getAttribute("allow")||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",renderHTML:t=>({allow:t.allow})},sandbox:{default:"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",parseHTML:t=>t.getAttribute("sandbox")||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",renderHTML:t=>({sandbox:t.sandbox})},style:{default:"",parseHTML:t=>t.getAttribute("style")||"",renderHTML:t=>({style:t.style})}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",W.mergeAttributes(t)]},addNodeView(){return Z.ReactNodeViewRenderer(js)},addCommands(){return{insertIframe:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:{src:t.src||"",width:t.width||"100%",height:t.height||"500px",title:t.title||"Embedded Content",allow:t.allow||"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",sandbox:t.sandbox||"allow-scripts allow-same-origin allow-forms allow-popups allow-modals allow-presentation",style:t.style||""}})}}}),An=W.Node.create({name:"video",addOptions(){return{inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}}},group(){return this.options.inline?"inline":"block"},draggable:!1,addAttributes(){return{src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},type:{default:null,parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},title:{default:null,parseHTML:t=>t.getAttribute("title"),renderHTML:t=>t.title?{title:t.title}:{}}}},parseHTML(){return[{tag:"video"}]},renderHTML({HTMLAttributes:t}){const{src:e,type:n,title:r}=t;return e?["video",W.mergeAttributes(this.options.HTMLAttributes,t,{controls:!0,preload:"metadata"}),["source",{src:e,type:n||"video/mp4"}],r||"Your browser does not support the video tag."]:["video",W.mergeAttributes(this.options.HTMLAttributes,t)]},addCommands(){return{setVideo:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),zs=()=>({type:"column",content:[{type:"paragraph"}]}),On=W.Node.create({name:"columnLayout",group:"block",content:"column+",defining:!0,isolating:!0,addOptions(){return{HTMLAttributes:{},defaultColumns:2}},addAttributes(){return{columns:{default:this.options.defaultColumns,parseHTML:t=>{const e=Number(t.getAttribute("data-columns"));return Number.isNaN(e)?this.options.defaultColumns:e},renderHTML:t=>({"data-columns":t.columns})}}},parseHTML(){return[{tag:'div[data-type="column-layout"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":"column-layout"}),0]},addCommands(){return{insertColumnLayout:t=>({commands:e})=>{const n=t?.columns??this.options.defaultColumns,r=Array.from({length:Math.max(n,1)},()=>zs());return e.insertContent({type:this.name,attrs:{columns:n},content:r})},setColumnLayoutColumns:t=>({state:e,dispatch:n})=>{const r=W.findParentNode(s=>s.type===this.type)(e.selection);if(!r)return!1;if(n){const s=e.tr.setNodeMarkup(r.pos,this.type,{...r.node.attrs,columns:t},r.node.marks);n(s)}return!0}}}}),Rn=W.Node.create({name:"column",content:"block+",isolating:!0,defining:!0,parseHTML(){return[{tag:'div[data-type="column"]'}]},renderHTML({HTMLAttributes:t}){return["div",W.mergeAttributes(t,{"data-type":"column"}),0]}});function Us({initialOpen:t=!1,placement:e="top",open:n,onOpenChange:r,delay:s=600,closeDelay:o=0}={}){const[i,a]=he.useState(t),c=n??i,u=r??a,d=se.useFloating({placement:e,open:c,onOpenChange:u,whileElementsMounted:se.autoUpdate,middleware:[se.offset(4),se.flip({crossAxis:e.includes("-"),fallbackAxisSideDirection:"start",padding:4}),se.shift({padding:4})]}),f=d.context,h=se.useHover(f,{mouseOnly:!0,move:!1,restMs:s,enabled:n==null,delay:{close:o}}),p=se.useFocus(f,{enabled:n==null}),m=se.useDismiss(f),w=se.useRole(f,{role:"tooltip"}),g=se.useInteractions([h,p,m,w]);return he.useMemo(()=>({open:c,setOpen:u,...g,...d}),[c,u,g,d])}const vt=he.createContext(null);function In(){const t=he.useContext(vt);if(t==null)throw new Error("Tooltip components must be wrapped in <TooltipProvider />");return t}function tt({children:t,...e}){const n=Us(e);return e.useDelayGroup?l.jsx(se.FloatingDelayGroup,{delay:{open:e.delay??0,close:e.closeDelay??0},timeoutMs:e.timeout,children:l.jsx(vt.Provider,{value:n,children:t})}):l.jsx(vt.Provider,{value:n,children:t})}const nt=he.forwardRef(function({children:e,asChild:n=!1,...r},s){const o=In(),i=he.isValidElement(e)?parseInt(he.version,10)>=19?e.props.ref:e.ref:void 0,a=se.useMergeRefs([o.refs.setReference,s,i]);if(n&&he.isValidElement(e)){const c={"data-tooltip-state":o.open?"open":"closed"};return he.cloneElement(e,o.getReferenceProps({ref:a,...r,...typeof e.props=="object"?e.props:{},...c}))}return l.jsx("button",{ref:a,"data-tooltip-state":o.open?"open":"closed",...o.getReferenceProps(r),children:e})}),rt=he.forwardRef(function({style:e,children:n,portal:r=!0,portalProps:s={},...o},i){const a=In(),c=se.useMergeRefs([a.refs.setFloating,i]);if(!a.open)return null;const u=l.jsx("div",{ref:c,style:{...a.floatingStyles,...e},...a.getFloatingProps(o),className:"tiptap-tooltip",children:n});return r?l.jsx(se.FloatingPortal,{...s,children:u}):u});tt.displayName="Tooltip",nt.displayName="TooltipTrigger",rt.displayName="TooltipContent";const P=({onClick:t,isActive:e=!1,children:n,title:r,className:s=""})=>{const o=l.jsx(G,{type:"button",onClick:t,variant:e?"default":"outline",size:"sm",className:`h-8 w-8 p-0 transition-all cursor-pointer ${e?"bg-blue-600 text-white border-blue-600 hover:bg-blue-700":"bg-white hover:bg-gray-50"} ${s}`,children:n});return r?l.jsxs(tt,{delay:500,closeDelay:0,children:[l.jsx(nt,{asChild:!0,children:o}),l.jsx(rt,{children:r})]}):o},Fs=({onColorChange:t})=>{const e=["#000000","#ffffff","#7d7a75","#9f765a","#d27b2d","#fdd835","#50946e","#377dc9","#9a6bb4","#c14c8a","#cf5148"];return l.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>l.jsxs(tt,{delay:300,closeDelay:0,children:[l.jsx(nt,{asChild:!0,children:l.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),l.jsxs(rt,{children:["Set color to ",n]})]},n))})},Hs=({onColorChange:t})=>{const e=["#B0B0B0","#F2F0EF","#e7e4de","#f3e1d5","#ffe4c2","#fff7cc","#d6f2e3","#d5e6fa","#ebddf5","#f9d6e8","#f8d0cb"];return l.jsx("div",{className:"flex flex-wrap gap-1 w-32",children:e.map(n=>l.jsxs(tt,{delay:300,closeDelay:0,children:[l.jsx(nt,{asChild:!0,children:l.jsx("button",{type:"button",className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n},onClick:()=>t(n)})}),l.jsxs(rt,{children:["Set background color to ",n]})]},n))})},$s=({editor:t,isReadOnly:e,onImageUpload:n,onVideoUpload:r,isImageUploading:s,isVideoUploading:o,showImageInput:i,setShowImageInput:a,imageUrl:c,setImageUrl:u,handleImageUrlInsert:d,imageUploadFunction:f})=>{const[h,p]=T.useState(!1),m=T.useRef(null);return T.useEffect(()=>{const w=g=>{m.current&&!m.current.contains(g.target)&&p(!1)};return h&&document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[h]),e?null:l.jsxs("div",{className:"sticky top-0 z-40 border border-gray-300 mb-10 p-4 bg-gray-50/95 flex flex-wrap gap-2 shadow-sm backdrop-blur-sm",children:[l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:l.jsx(M.Heading1,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:l.jsx(M.Heading2,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:l.jsx(M.Heading3,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:4}).run(),isActive:t.isActive("heading",{level:4}),title:"Heading 4",children:l.jsx(M.Heading4,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().setParagraph().run(),isActive:t.isActive("paragraph"),title:"Paragraph",children:l.jsx(M.FileText,{className:"h-4 w-4"})})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(P,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:l.jsx(M.List,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:l.jsx(M.ListOrdered,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:l.jsx(P,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table (3x3)",children:l.jsx(M.Table,{className:"h-4 w-4"})})}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(P,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Block Quote",children:l.jsx(M.Quote,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:l.jsx(M.Minus,{className:"h-4 w-4"})})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsxs("div",{className:"relative",children:[l.jsx(P,{onClick:()=>a(!i),title:"Insert Image",className:s?"opacity-50":"",children:s?l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):l.jsx(M.Image,{className:"h-4 w-4"})}),s&&l.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),i&&l.jsx("div",{className:`absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg min-w-80 image-input-container ${s?"opacity-75":""}`,children:l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-sm font-medium text-gray-900",children:"Insert Image"}),l.jsx("button",{type:"button",onClick:()=>a(!1),className:`text-gray-400 hover:text-gray-600 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,children:"✕"})]}),l.jsxs("div",{children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Image URL"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"url",value:c,onChange:w=>u(w.target.value),placeholder:"https://example.com/image.jpg",className:`flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 ${s?"opacity-50 cursor-not-allowed":""}`,disabled:s,onKeyDown:w=>{w.key==="Enter"&&d()}}),l.jsx(G,{type:"button",onClick:d,size:"sm",className:"px-4 py-2",disabled:!c.trim()||s,children:"Insert"})]}),c.trim()&&l.jsxs("div",{className:"mt-2 p-2 border border-gray-200 rounded bg-gray-50",children:[l.jsx("p",{className:"text-xs text-gray-600 mb-2",children:"Preview:"}),l.jsx("img",{src:c.trim(),alt:"Preview",className:"max-w-full h-auto max-h-32 rounded border",onError:w=>{const g=w.currentTarget;g.style.display="none";const N=g.nextElementSibling;N&&(N.style.display="block")}}),l.jsx("p",{className:"text-xs text-red-500 hidden",children:"Invalid image URL"})]})]}),l.jsxs("div",{className:"border-t pt-3",children:[l.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Or Upload Image"}),l.jsx(G,{type:"button",onClick:n,size:"sm",variant:"outline",className:"w-full",disabled:!f||s,children:s?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),l.jsx("span",{children:"Uploading..."})]}):f?"Choose File":"Upload not available"}),s&&l.jsxs("div",{className:"mt-2 text-xs text-blue-600 flex items-center gap-1",children:[l.jsx("div",{className:"animate-pulse",children:"⏳"}),l.jsx("span",{children:"Please wait while your image uploads..."})]}),!f&&l.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Upload function not provided"})]})]})})]}),l.jsxs("div",{className:"relative",children:[l.jsx(P,{onClick:r,title:o?"Upload Video to Firebase":"Upload Video (Base64)",className:o?"opacity-50":"",children:o?l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}):l.jsx(M.Video,{className:"h-4 w-4"})}),o&&l.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-blue-600 rounded-full animate-pulse"}),!r&&l.jsx("div",{className:"absolute top-full mt-1 left-0 bg-gray-800 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-50",children:"Video upload not available"})]})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(P,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:l.jsx(M.Code,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().insertAccordion().run(),title:"Insert Accordion",children:l.jsx(M.PanelTopOpen,{className:"h-4 w-4 cursor-pointer"})})]}),l.jsxs("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:[l.jsx(P,{onClick:()=>t.chain().focus().insertTabs({tabCount:2}).run(),title:"Insert 2 Tabs",children:l.jsx("span",{className:"text-xs font-mono",children:"2T"})}),l.jsxs("div",{className:"relative w-full",ref:m,children:[l.jsx(P,{onClick:()=>p(!h),title:"Insert Tabs",className:"w-full px-2",children:l.jsxs("div",{className:"flex items-center gap-1 w-full justify-between",children:[l.jsx("span",{className:"text-xs font-mono",children:"Tabs"}),l.jsx(M.ChevronDown,{className:"h-3 w-3"})]})}),h&&l.jsx("div",{className:"absolute top-full mt-1 left-0 z-10 bg-white border border-gray-300 rounded-lg shadow-lg min-w-32",children:l.jsxs("div",{className:"p-1 space-y-1",children:[l.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:3}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"3 Tabs"}),l.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:4}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"4 Tabs"}),l.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:5}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"5 Tabs"}),l.jsx(G,{type:"button",variant:"ghost",size:"sm",onClick:()=>{t.chain().focus().insertTabs({tabCount:6}).run(),p(!1)},className:"w-full justify-start text-xs font-mono hover:bg-gray-100",children:"6 Tabs"})]})})]})]}),l.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:l.jsx(P,{onClick:()=>{const w=prompt("Enter the URL for your iframe:","https://example.com/embed");w&&t.chain().focus().insertIframe({src:w,width:"100%",height:"500px",title:"Embedded Content"}).run()},title:"Insert iframe",children:l.jsx(M.Frame,{className:"h-4 w-4"})})}),l.jsx("div",{className:"flex gap-1 border-r border-gray-300 pr-2",children:l.jsx(P,{onClick:()=>t.chain().focus().insertColumnLayout({columns:2}).run(),title:"Insert 2 Column Layout",children:l.jsx("div",{className:"flex items-center gap-1",children:l.jsx(M.Columns3,{className:"h-4 w-4"})})})})]})},Mn=["top","right","bottom","left"],Ln=["start","end"],Dn=Mn.reduce((t,e)=>t.concat(e,e+"-"+Ln[0],e+"-"+Ln[1]),[]),ge=Math.min,ne=Math.max,st=Math.round,be=t=>({x:t,y:t}),Ks={left:"right",right:"left",bottom:"top",top:"bottom"},qs={start:"end",end:"start"};function Et(t,e,n){return ne(t,ge(e,n))}function ve(t,e){return typeof t=="function"?t(e):t}function le(t){return t.split("-")[0]}function de(t){return t.split("-")[1]}function Pn(t){return t==="x"?"y":"x"}function Nt(t){return t==="y"?"height":"width"}const Ws=new Set(["top","bottom"]);function we(t){return Ws.has(le(t))?"y":"x"}function St(t){return Pn(we(t))}function jn(t,e,n){n===void 0&&(n=!1);const r=de(t),s=St(t),o=Nt(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=it(i)),[i,it(i)]}function Js(t){const e=it(t);return[ot(t),e,ot(e)]}function ot(t){return t.replace(/start|end/g,e=>qs[e])}const Bn=["left","right"],zn=["right","left"],Vs=["top","bottom"],Gs=["bottom","top"];function Ys(t,e,n){switch(t){case"top":case"bottom":return n?e?zn:Bn:e?Bn:zn;case"left":case"right":return e?Vs:Gs;default:return[]}}function Zs(t,e,n,r){const s=de(t);let o=Ys(le(t),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map(ot)))),o}function it(t){return t.replace(/left|right|bottom|top/g,e=>Ks[e])}function Xs(t){return{top:0,right:0,bottom:0,left:0,...t}}function Ct(t){return typeof t!="number"?Xs(t):{top:t,right:t,bottom:t,left:t}}function De(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Un(t,e,n){let{reference:r,floating:s}=t;const o=we(e),i=St(e),a=Nt(i),c=le(e),u=o==="y",d=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,h=r[a]/2-s[a]/2;let p;switch(c){case"top":p={x:d,y:r.y-s.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-s.width,y:f};break;default:p={x:r.x,y:r.y}}switch(de(e)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const Qs=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,a=o.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(e));let u=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:f}=Un(u,r,c),h=r,p={},m=0;for(let w=0;w<a.length;w++){const{name:g,fn:N}=a[w],{x:C,y,data:S,reset:x}=await N({x:d,y:f,initialPlacement:r,placement:h,strategy:s,middlewareData:p,rects:u,platform:i,elements:{reference:t,floating:e}});d=C??d,f=y??f,p={...p,[g]:{...p[g],...S}},x&&m<=50&&(m++,typeof x=="object"&&(x.placement&&(h=x.placement),x.rects&&(u=x.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):x.rects),{x:d,y:f}=Un(u,h,c)),w=-1)}return{x:d,y:f,placement:h,strategy:s,middlewareData:p}};async function Pe(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:i,elements:a,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=ve(e,t),m=Ct(p),g=a[h?f==="floating"?"reference":"floating":f],N=De(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(g)))==null||n?g:g.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),C=f==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,y=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),S=await(o.isElement==null?void 0:o.isElement(y))?await(o.getScale==null?void 0:o.getScale(y))||{x:1,y:1}:{x:1,y:1},x=De(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:C,offsetParent:y,strategy:c}):C);return{top:(N.top-x.top+m.top)/S.y,bottom:(x.bottom-N.bottom+m.bottom)/S.y,left:(N.left-x.left+m.left)/S.x,right:(x.right-N.right+m.right)/S.x}}const eo=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:o,platform:i,elements:a,middlewareData:c}=e,{element:u,padding:d=0}=ve(t,e)||{};if(u==null)return{};const f=Ct(d),h={x:n,y:r},p=St(s),m=Nt(p),w=await i.getDimensions(u),g=p==="y",N=g?"top":"left",C=g?"bottom":"right",y=g?"clientHeight":"clientWidth",S=o.reference[m]+o.reference[p]-h[p]-o.floating[m],x=h[p]-o.reference[p],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let D=_?_[y]:0;(!D||!await(i.isElement==null?void 0:i.isElement(_)))&&(D=a.floating[y]||o.floating[m]);const v=S/2-x/2,U=D/2-w[m]/2-1,E=ge(f[N],U),z=ge(f[C],U),V=E,R=D-w[m]-z,I=D/2-w[m]/2+v,L=Et(V,I,R),k=!c.arrow&&de(s)!=null&&I!==L&&o.reference[m]/2-(I<V?E:z)-w[m]/2<0,F=k?I<V?I-V:I-R:0;return{[p]:h[p]+F,data:{[p]:L,centerOffset:I-L-F,...k&&{alignmentOffset:F}},reset:k}}});function to(t,e,n){return(t?[...n.filter(s=>de(s)===t),...n.filter(s=>de(s)!==t)]:n.filter(s=>le(s)===s)).filter(s=>t?de(s)===t||(e?ot(s)!==s:!1):!0)}const no=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var n,r,s;const{rects:o,middlewareData:i,placement:a,platform:c,elements:u}=e,{crossAxis:d=!1,alignment:f,allowedPlacements:h=Dn,autoAlignment:p=!0,...m}=ve(t,e),w=f!==void 0||h===Dn?to(f||null,p,h):h,g=await Pe(e,m),N=((n=i.autoPlacement)==null?void 0:n.index)||0,C=w[N];if(C==null)return{};const y=jn(C,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(a!==C)return{reset:{placement:w[0]}};const S=[g[le(C)],g[y[0]],g[y[1]]],x=[...((r=i.autoPlacement)==null?void 0:r.overflows)||[],{placement:C,overflows:S}],_=w[N+1];if(_)return{data:{index:N+1,overflows:x},reset:{placement:_}};const D=x.map(E=>{const z=de(E.placement);return[E.placement,z&&d?E.overflows.slice(0,2).reduce((V,R)=>V+R,0):E.overflows[0],E.overflows]}).sort((E,z)=>E[1]-z[1]),U=((s=D.filter(E=>E[2].slice(0,de(E[0])?2:3).every(z=>z<=0))[0])==null?void 0:s[0])||D[0][0];return U!==a?{data:{index:N+1,overflows:x},reset:{placement:U}}:{}}}},ro=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:a,platform:c,elements:u}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:w=!0,...g}=ve(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const N=le(s),C=we(a),y=le(a)===a,S=await(c.isRTL==null?void 0:c.isRTL(u.floating)),x=h||(y||!w?[it(a)]:Js(a)),_=m!=="none";!h&&_&&x.push(...Zs(a,w,m,S));const D=[a,...x],v=await Pe(e,g),U=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&U.push(v[N]),f){const I=jn(s,i,S);U.push(v[I[0]],v[I[1]])}if(E=[...E,{placement:s,overflows:U}],!U.every(I=>I<=0)){var z,V;const I=(((z=o.flip)==null?void 0:z.index)||0)+1,L=D[I];if(L&&(!(f==="alignment"?C!==we(L):!1)||E.every(A=>we(A.placement)===C?A.overflows[0]>0:!0)))return{data:{index:I,overflows:E},reset:{placement:L}};let k=(V=E.filter(F=>F.overflows[0]<=0).sort((F,A)=>F.overflows[1]-A.overflows[1])[0])==null?void 0:V.placement;if(!k)switch(p){case"bestFit":{var R;const F=(R=E.filter(A=>{if(_){const B=we(A.placement);return B===C||B==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(B=>B>0).reduce((B,b)=>B+b,0)]).sort((A,B)=>A[1]-B[1])[0])==null?void 0:R[0];F&&(k=F);break}case"initialPlacement":k=a;break}if(s!==k)return{reset:{placement:k}}}return{}}}};function Fn(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Hn(t){return Mn.some(e=>t[e]>=0)}const so=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...s}=ve(t,e);switch(r){case"referenceHidden":{const o=await Pe(e,{...s,elementContext:"reference"}),i=Fn(o,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Hn(i)}}}case"escaped":{const o=await Pe(e,{...s,altBoundary:!0}),i=Fn(o,n.floating);return{data:{escapedOffsets:i,escaped:Hn(i)}}}default:return{}}}}};function $n(t){const e=ge(...t.map(o=>o.left)),n=ge(...t.map(o=>o.top)),r=ne(...t.map(o=>o.right)),s=ne(...t.map(o=>o.bottom));return{x:e,y:n,width:r-e,height:s-n}}function oo(t){const e=t.slice().sort((s,o)=>s.y-o.y),n=[];let r=null;for(let s=0;s<e.length;s++){const o=e[s];!r||o.y-r.y>r.height/2?n.push([o]):n[n.length-1].push(o),r=o}return n.map(s=>De($n(s)))}const io=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:s,platform:o,strategy:i}=e,{padding:a=2,x:c,y:u}=ve(t,e),d=Array.from(await(o.getClientRects==null?void 0:o.getClientRects(r.reference))||[]),f=oo(d),h=De($n(d)),p=Ct(a);function m(){if(f.length===2&&f[0].left>f[1].right&&c!=null&&u!=null)return f.find(g=>c>g.left-p.left&&c<g.right+p.right&&u>g.top-p.top&&u<g.bottom+p.bottom)||h;if(f.length>=2){if(we(n)==="y"){const E=f[0],z=f[f.length-1],V=le(n)==="top",R=E.top,I=z.bottom,L=V?E.left:z.left,k=V?E.right:z.right,F=k-L,A=I-R;return{top:R,bottom:I,left:L,right:k,width:F,height:A,x:L,y:R}}const g=le(n)==="left",N=ne(...f.map(E=>E.right)),C=ge(...f.map(E=>E.left)),y=f.filter(E=>g?E.left===C:E.right===N),S=y[0].top,x=y[y.length-1].bottom,_=C,D=N,v=D-_,U=x-S;return{top:S,bottom:x,left:_,right:D,width:v,height:U,x:_,y:S}}return h}const w=await o.getElementRects({reference:{getBoundingClientRect:m},floating:r.floating,strategy:i});return s.reference.x!==w.reference.x||s.reference.y!==w.reference.y||s.reference.width!==w.reference.width||s.reference.height!==w.reference.height?{reset:{rects:w}}:{}}}},ao=new Set(["left","top"]);async function lo(t,e){const{placement:n,platform:r,elements:s}=t,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=le(n),a=de(n),c=we(n)==="y",u=ao.has(i)?-1:1,d=o&&c?-1:1,f=ve(e,t);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),c?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const co=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:o,placement:i,middlewareData:a}=e,c=await lo(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:i}}}}},uo=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:o=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:N,y:C}=g;return{x:N,y:C}}},...c}=ve(t,e),u={x:n,y:r},d=await Pe(e,c),f=we(le(s)),h=Pn(f);let p=u[h],m=u[f];if(o){const g=h==="y"?"top":"left",N=h==="y"?"bottom":"right",C=p+d[g],y=p-d[N];p=Et(C,p,y)}if(i){const g=f==="y"?"top":"left",N=f==="y"?"bottom":"right",C=m+d[g],y=m-d[N];m=Et(C,m,y)}const w=a.fn({...e,[h]:p,[f]:m});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:o,[f]:i}}}}}},fo=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:o,platform:i,elements:a}=e,{apply:c=()=>{},...u}=ve(t,e),d=await Pe(e,u),f=le(s),h=de(s),p=we(s)==="y",{width:m,height:w}=o.floating;let g,N;f==="top"||f==="bottom"?(g=f,N=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(N=f,g=h==="end"?"top":"bottom");const C=w-d.top-d.bottom,y=m-d.left-d.right,S=ge(w-d[g],C),x=ge(m-d[N],y),_=!e.middlewareData.shift;let D=S,v=x;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(v=y),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(D=C),_&&!h){const E=ne(d.left,0),z=ne(d.right,0),V=ne(d.top,0),R=ne(d.bottom,0);p?v=m-2*(E!==0||z!==0?E+z:ne(d.left,d.right)):D=w-2*(V!==0||R!==0?V+R:ne(d.top,d.bottom))}await c({...e,availableWidth:v,availableHeight:D});const U=await i.getDimensions(a.floating);return m!==U.width||w!==U.height?{reset:{rects:!0}}:{}}}};function at(){return typeof window<"u"}function je(t){return Kn(t)?(t.nodeName||"").toLowerCase():"#document"}function ie(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ee(t){var e;return(e=(Kn(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Kn(t){return at()?t instanceof Node||t instanceof ie(t).Node:!1}function fe(t){return at()?t instanceof Element||t instanceof ie(t).Element:!1}function ye(t){return at()?t instanceof HTMLElement||t instanceof ie(t).HTMLElement:!1}function qn(t){return!at()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ie(t).ShadowRoot}const po=new Set(["inline","contents"]);function qe(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=pe(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!po.has(s)}const ho=new Set(["table","td","th"]);function mo(t){return ho.has(je(t))}const go=[":popover-open",":modal"];function lt(t){return go.some(e=>{try{return t.matches(e)}catch{return!1}})}const bo=["transform","translate","scale","rotate","perspective"],wo=["transform","translate","scale","rotate","perspective","filter"],yo=["paint","layout","strict","content"];function _t(t){const e=Tt(),n=fe(t)?pe(t):t;return bo.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||wo.some(r=>(n.willChange||"").includes(r))||yo.some(r=>(n.contain||"").includes(r))}function xo(t){let e=ke(t);for(;ye(e)&&!Be(e);){if(_t(e))return e;if(lt(e))return null;e=ke(e)}return null}function Tt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const vo=new Set(["html","body","#document"]);function Be(t){return vo.has(je(t))}function pe(t){return ie(t).getComputedStyle(t)}function ct(t){return fe(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ke(t){if(je(t)==="html")return t;const e=t.assignedSlot||t.parentNode||qn(t)&&t.host||Ee(t);return qn(e)?e.host:e}function Wn(t){const e=ke(t);return Be(e)?t.ownerDocument?t.ownerDocument.body:t.body:ye(e)&&qe(e)?e:Wn(e)}function Jn(t,e,n){var r;e===void 0&&(e=[]);const s=Wn(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),i=ie(s);return o?(kt(i),e.concat(i,i.visualViewport||[],qe(s)?s:[],[])):e.concat(s,Jn(s,[]))}function kt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Vn(t){const e=pe(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=ye(t),o=s?t.offsetWidth:n,i=s?t.offsetHeight:r,a=st(n)!==o||st(r)!==i;return a&&(n=o,r=i),{width:n,height:r,$:a}}function Gn(t){return fe(t)?t:t.contextElement}function ze(t){const e=Gn(t);if(!ye(e))return be(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=Vn(e);let i=(o?st(n.width):n.width)/r,a=(o?st(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Eo=be(0);function Yn(t){const e=ie(t);return!Tt()||!e.visualViewport?Eo:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function No(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ie(t)?!1:e}function We(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=Gn(t);let i=be(1);e&&(r?fe(r)&&(i=ze(r)):i=ze(t));const a=No(o,n,r)?Yn(o):be(0);let c=(s.left+a.x)/i.x,u=(s.top+a.y)/i.y,d=s.width/i.x,f=s.height/i.y;if(o){const h=ie(o),p=r&&fe(r)?ie(r):r;let m=h,w=kt(m);for(;w&&r&&p!==m;){const g=ze(w),N=w.getBoundingClientRect(),C=pe(w),y=N.left+(w.clientLeft+parseFloat(C.paddingLeft))*g.x,S=N.top+(w.clientTop+parseFloat(C.paddingTop))*g.y;c*=g.x,u*=g.y,d*=g.x,f*=g.y,c+=y,u+=S,m=ie(w),w=kt(m)}}return De({width:d,height:f,x:c,y:u})}function ut(t,e){const n=ct(t).scrollLeft;return e?e.left+n:We(Ee(t)).left+n}function Zn(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-ut(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function So(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",i=Ee(r),a=e?lt(e.floating):!1;if(r===i||a&&o)return n;let c={scrollLeft:0,scrollTop:0},u=be(1);const d=be(0),f=ye(r);if((f||!f&&!o)&&((je(r)!=="body"||qe(i))&&(c=ct(r)),ye(r))){const p=We(r);u=ze(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!o?Zn(i,c):be(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-c.scrollTop*u.y+d.y+h.y}}function Co(t){return Array.from(t.getClientRects())}function _o(t){const e=Ee(t),n=ct(t),r=t.ownerDocument.body,s=ne(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=ne(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ut(t);const a=-n.scrollTop;return pe(r).direction==="rtl"&&(i+=ne(e.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:a}}const Xn=25;function To(t,e){const n=ie(t),r=Ee(t),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,a=0,c=0;if(s){o=s.width,i=s.height;const d=Tt();(!d||d&&e==="fixed")&&(a=s.offsetLeft,c=s.offsetTop)}const u=ut(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-p);m<=Xn&&(o-=m)}else u<=Xn&&(o+=u);return{width:o,height:i,x:a,y:c}}const ko=new Set(["absolute","fixed"]);function Ao(t,e){const n=We(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=ye(t)?ze(t):be(1),i=t.clientWidth*o.x,a=t.clientHeight*o.y,c=s*o.x,u=r*o.y;return{width:i,height:a,x:c,y:u}}function Qn(t,e,n){let r;if(e==="viewport")r=To(t,n);else if(e==="document")r=_o(Ee(t));else if(fe(e))r=Ao(e,n);else{const s=Yn(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return De(r)}function er(t,e){const n=ke(t);return n===e||!fe(n)||Be(n)?!1:pe(n).position==="fixed"||er(n,e)}function Oo(t,e){const n=e.get(t);if(n)return n;let r=Jn(t,[]).filter(a=>fe(a)&&je(a)!=="body"),s=null;const o=pe(t).position==="fixed";let i=o?ke(t):t;for(;fe(i)&&!Be(i);){const a=pe(i),c=_t(i);!c&&a.position==="fixed"&&(s=null),(o?!c&&!s:!c&&a.position==="static"&&!!s&&ko.has(s.position)||qe(i)&&!c&&er(t,i))?r=r.filter(d=>d!==i):s=a,i=ke(i)}return e.set(t,r),r}function Ro(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const i=[...n==="clippingAncestors"?lt(e)?[]:Oo(e,this._c):[].concat(n),r],a=i[0],c=i.reduce((u,d)=>{const f=Qn(e,d,s);return u.top=ne(f.top,u.top),u.right=ge(f.right,u.right),u.bottom=ge(f.bottom,u.bottom),u.left=ne(f.left,u.left),u},Qn(e,a,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Io(t){const{width:e,height:n}=Vn(t);return{width:e,height:n}}function Mo(t,e,n){const r=ye(e),s=Ee(e),o=n==="fixed",i=We(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=be(0);function u(){c.x=ut(s)}if(r||!r&&!o)if((je(e)!=="body"||qe(s))&&(a=ct(e)),r){const p=We(e,!0,o,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else s&&u();o&&!r&&s&&u();const d=s&&!r&&!o?Zn(s,a):be(0),f=i.left+a.scrollLeft-c.x-d.x,h=i.top+a.scrollTop-c.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function At(t){return pe(t).position==="static"}function tr(t,e){if(!ye(t)||pe(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ee(t)===n&&(n=n.ownerDocument.body),n}function nr(t,e){const n=ie(t);if(lt(t))return n;if(!ye(t)){let s=ke(t);for(;s&&!Be(s);){if(fe(s)&&!At(s))return s;s=ke(s)}return n}let r=tr(t,e);for(;r&&mo(r)&&At(r);)r=tr(r,e);return r&&Be(r)&&At(r)&&!_t(r)?n:r||xo(t)||n}const Lo=async function(t){const e=this.getOffsetParent||nr,n=this.getDimensions,r=await n(t.floating);return{reference:Mo(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Do(t){return pe(t).direction==="rtl"}const Po={convertOffsetParentRelativeRectToViewportRelativeRect:So,getDocumentElement:Ee,getClippingRect:Ro,getOffsetParent:nr,getElementRects:Lo,getClientRects:Co,getDimensions:Io,getScale:ze,isElement:fe,isRTL:Do},rr=co,sr=no,or=uo,ir=ro,ar=fo,lr=so,cr=eo,ur=io,dr=(t,e,n)=>{const r=new Map,s={platform:Po,...n},o={...s.platform,_c:r};return Qs(t,e,{...s,platform:o})};function fr(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),o=e.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)n++;return n}if(s.content.size||o.content.size){let i=fr(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function pr(t,e,n,r){for(let s=t.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=t.child(--s),a=e.child(--o),c=i.nodeSize;if(i==a){n-=c,r-=c;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let u=0,d=Math.min(i.text.length,a.text.length);for(;u<d&&i.text[i.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(i.content.size||a.content.size){let u=pr(i.content,a.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class K{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,o){for(let i=0,a=0;a<n;i++){let c=this.content[i],u=a+c.nodeSize;if(u>e&&r(c,s+a,o||null,i)!==!1&&c.content.size){let d=a+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),r,s+d)}a=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let o="",i=!0;return this.nodesBetween(e,n,(a,c)=>{let u=a.isText?a.text.slice(Math.max(e,c)-c,n-c):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&r&&(i?i=!1:o+=r),o+=u},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new K(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let o=0,i=0;i<n;o++){let a=this.content[o],c=i+a.nodeSize;c>e&&((i<e||c>n)&&(a.isText?a=a.cut(Math.max(0,e-i),Math.min(a.text.length,n-i)):a=a.cut(Math.max(0,e-i-1),Math.min(a.content.size,n-i-1))),r.push(a),s+=a.nodeSize),i=c}return new K(r,s)}cutByIndex(e,n){return e==n?K.empty:e==0&&n==this.content.length?this:new K(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new K(s,o)}addToStart(e){return new K([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new K(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return fr(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return pr(this,e,n,r)}findIndex(e){if(e==0)return dt(0,e);if(e==this.size)return dt(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),o=r+s.nodeSize;if(o>=e)return o==e?dt(n+1,o):dt(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return K.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new K(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return K.empty;let n,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(n||(n=e.slice(0,s)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new K(n||e,r)}static from(e){if(!e)return K.empty;if(e instanceof K)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new K([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}K.empty=new K([],0);const Ot={index:0,offset:0};function dt(t,e){return Ot.index=t,Ot.offset=e,Ot}class jo extends Error{}class ${constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=mr(this.content,e+this.openStart,n);return r&&new $(r,this.openStart,this.openEnd)}removeBetween(e,n){return new $(hr(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return $.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new $(K.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)s++;return new $(e,r,s)}}$.empty=new $(K.empty,0,0);function hr(t,e,n){let{index:r,offset:s}=t.findIndex(e),o=t.maybeChild(r),{index:i,offset:a}=t.findIndex(n);if(s==e||o.isText){if(a!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(hr(o.content,e-s-1,n-s-1)))}function mr(t,e,n,r){let{index:s,offset:o}=t.findIndex(e),i=t.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=mr(i.content,e-o-1,n,i);return a&&t.replaceChild(s,i.copy(a))}const gr=65535,br=Math.pow(2,16);function Bo(t,e){return t+e*br}function wr(t){return t&gr}function zo(t){return(t-(t&gr))/br}const yr=1,xr=2,ft=4,vr=8;class Er{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&vr)>0}get deletedBefore(){return(this.delInfo&(yr|ft))>0}get deletedAfter(){return(this.delInfo&(xr|ft))>0}get deletedAcross(){return(this.delInfo&ft)>0}}class ae{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ae.empty)return ae.empty}recover(e){let n=0,r=wr(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+zo(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?s:0);if(c>e)break;let u=this.ranges[a+o],d=this.ranges[a+i],f=c+u;if(e<=f){let h=u?e==c?-1:e==f?1:n:n,p=c+s+(h<0?0:d);if(r)return p;let m=e==(n<0?c:f)?null:Bo(a/3,e-c),w=e==c?xr:e==f?yr:ft;return(n<0?e!=c:e!=f)&&(w|=vr),new Er(p,w,m)}s+=d-u}return r?e+s:new Er(e+s,0,null)}touches(e,n){let r=0,s=wr(n),o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[a+o],d=c+u;if(e<=d&&a==s*3)return!0;r+=this.ranges[a+i]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],a=i-(this.inverted?o:0),c=i+(this.inverted?0:o),u=this.ranges[s+n],d=this.ranges[s+r];e(a,a+u,c,c+d),o+=d-u}}invert(){return new ae(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ae.empty:new ae(e<0?[0,-e,0]:[0,0,e])}}ae.empty=new ae([]);const Rt=Object.create(null);class te{getMap(){return ae.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Rt[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Rt)throw new RangeError("Duplicate use of step JSON ID "+e);return Rt[e]=n,n.prototype.jsonID=e,n}}class Y{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Y(e,null)}static fail(e){return new Y(null,e)}static fromReplace(e,n,r,s){try{return Y.ok(e.replace(n,r,s))}catch(o){if(o instanceof jo)return Y.fail(o.message);throw o}}}function It(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let o=t.child(s);o.content.size&&(o=o.copy(It(o.content,e,o))),o.isInline&&(o=e(o,n,s)),r.push(o)}return K.fromArray(r)}class Re extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new $(It(n.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),n.openStart,n.openEnd);return Y.fromReplace(e,this.from,this.to,o)}invert(){return new Ie(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Re(n.pos,r.pos,this.mark)}merge(e){return e instanceof Re&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Re(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Re(n.from,n.to,e.markFromJSON(n.mark))}}te.jsonID("addMark",Re);class Ie extends te{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new $(It(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Y.fromReplace(e,this.from,this.to,r)}invert(){return new Re(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ie(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ie&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ie(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ie(n.from,n.to,e.markFromJSON(n.mark))}}te.jsonID("removeMark",Ie);class Me extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Y.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Y.fromReplace(e,this.pos,this.pos+1,new $(K.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Me(this.pos,n.marks[s]);return new Me(this.pos,this.mark)}}return new Je(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Me(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Me(n.pos,e.markFromJSON(n.mark))}}te.jsonID("addNodeMark",Me);class Je extends te{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Y.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Y.fromReplace(e,this.pos,this.pos+1,new $(K.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Me(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Je(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Je(n.pos,e.markFromJSON(n.mark))}}te.jsonID("removeNodeMark",Je);class Ne extends te{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Mt(e,this.from,this.to)?Y.fail("Structure replace would overwrite content"):Y.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ae([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ne(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ne(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ne)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?$.empty:new $(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ne(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?$.empty:new $(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ne(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ne(n.from,n.to,$.fromJSON(e,n.slice),!!n.structure)}}te.jsonID("replace",Ne);class Ue extends te{constructor(e,n,r,s,o,i,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=a}apply(e){if(this.structure&&(Mt(e,this.from,this.gapFrom)||Mt(e,this.gapTo,this.to)))return Y.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Y.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Y.fromReplace(e,this.from,this.to,r):Y.fail("Content does not fit in gap")}getMap(){return new ae([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ue(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||o>r.pos?null:new Ue(n.pos,r.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ue(n.from,n.to,n.gapFrom,n.gapTo,$.fromJSON(e,n.slice),n.insert,!!n.structure)}}te.jsonID("replaceAround",Ue);function Mt(t,e,n){let r=t.resolve(e),s=n-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}class Ve extends te{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Y.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return Y.fromReplace(e,this.pos,this.pos+1,new $(K.from(s),0,n.isLeaf?0:1))}getMap(){return ae.empty}invert(e){return new Ve(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ve(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ve(n.pos,n.attr,n.value)}}te.jsonID("attr",Ve);class pt extends te{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Y.ok(r)}getMap(){return ae.empty}invert(e){return new pt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new pt(n.attr,n.value)}}te.jsonID("docAttr",pt);let Ge=class extends Error{};Ge=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Ge.prototype=Object.create(Error.prototype),Ge.prototype.constructor=Ge,Ge.prototype.name="TransformError";const Lt=Object.create(null);class q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Nr(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=$.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:c,$to:u}=i[a],d=e.mapping.slice(o);e.replaceRange(d.map(c.pos),d.map(u.pos),a?$.empty:n),a==0&&_r(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:a}=s[o],c=e.mapping.slice(r),u=c.map(i.pos),d=c.map(a.pos);o?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),_r(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new ce(e):Fe(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=n<0?Fe(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Fe(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Se(e.node(0))}static atStart(e){return Fe(e,e,0,0,1)||new Se(e)}static atEnd(e){return Fe(e,e,e.content.size,e.childCount,-1)||new Se(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Lt[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Lt)throw new RangeError("Duplicate use of selection JSON ID "+e);return Lt[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ce.between(this.$anchor,this.$head).getBookmark()}}q.prototype.visible=!0;class Nr{constructor(e,n){this.$from=e,this.$to=n}}let Sr=!1;function Cr(t){!Sr&&!t.parent.inlineContent&&(Sr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ce extends q{constructor(e,n=e){Cr(e),Cr(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return q.near(r);let s=e.resolve(n.map(this.anchor));return new ce(s.parent.inlineContent?s:r,r)}replace(e,n=$.empty){if(super.replace(e,n),n==$.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ce&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ht(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ce(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let o=q.findFrom(n,r,!0)||q.findFrom(n,-r,!0);if(o)n=o.$head;else return q.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(q.findFrom(e,-r,!0)||q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new ce(e,n)}}q.jsonID("text",ce);class ht{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ht(e.map(this.anchor),e.map(this.head))}resolve(e){return ce.between(e.resolve(this.anchor),e.resolve(this.head))}}class ue extends q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),o=e.resolve(s);return r?q.near(o):new ue(o)}content(){return new $(K.from(this.node),0,0)}eq(e){return e instanceof ue&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Dt(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ue(e.resolve(n.anchor))}static create(e,n){return new ue(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ue.prototype.visible=!1,q.jsonID("node",ue);class Dt{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ht(r,r):new Dt(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ue.isSelectable(r)?new ue(n):q.near(n)}}class Se extends q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=$.empty){if(n==$.empty){e.delete(0,e.doc.content.size);let r=q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Se(e)}map(e){return new Se(e)}eq(e){return e instanceof Se}getBookmark(){return Uo}}q.jsonID("all",Se);const Uo={map(){return this},resolve(t){return new Se(t)}};function Fe(t,e,n,r,s,o=!1){if(e.inlineContent)return ce.create(t,n);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let a=e.child(i);if(a.isAtom){if(!o&&ue.isSelectable(a))return ue.create(t,n-(s<0?a.nodeSize:0))}else{let c=Fe(t,a,n+s,s<0?a.childCount:0,s,o);if(c)return c}n+=a.nodeSize*s}return null}function _r(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Ne||s instanceof Ue))return;let o=t.mapping.maps[r],i;o.forEach((a,c,u,d)=>{i==null&&(i=d)}),t.setSelection(q.near(t.doc.resolve(i),n))}function Tr(t,e){return!e||!t?t:t.bind(e)}class mt{constructor(e,n,r){this.name=e,this.init=Tr(n.init,r),this.apply=Tr(n.apply,r)}}new mt("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new mt("selection",{init(t,e){return t.selection||q.atStart(e.doc)},apply(t){return t.selection}}),new mt("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new mt("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function kr(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=kr(s,e,{})),n[r]=s}return n}class Ar{constructor(e){this.spec=e,this.props={},e.props&&kr(e.props,this,this.props),this.key=e.key?e.key.key:Or("plugin")}getState(e){return e[this.key]}}const Pt=Object.create(null);function Or(t){return t in Pt?t+"$"+ ++Pt[t]:(Pt[t]=0,t+"$")}class Ye{constructor(e="key"){this.key=Or(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}for(var Ae={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},gt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Fo=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ho=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Q=0;Q<10;Q++)Ae[48+Q]=Ae[96+Q]=String(Q);for(var Q=1;Q<=24;Q++)Ae[Q+111]="F"+Q;for(var Q=65;Q<=90;Q++)Ae[Q]=String.fromCharCode(Q+32),gt[Q]=String.fromCharCode(Q);for(var jt in Ae)gt.hasOwnProperty(jt)||(gt[jt]=Ae[jt]);function $o(t){var e=Fo&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ho&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?gt:Ae)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Ko=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),qo=typeof navigator<"u"&&/Win/.test(navigator.platform);function Wo(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,o,i;for(let a=0;a<e.length-1;a++){let c=e[a];if(/^(cmd|meta|m)$/i.test(c))i=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))o=!0;else if(/^mod$/i.test(c))Ko?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),i&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function Jo(t){let e=Object.create(null);for(let n in t)e[Wo(n)]=t[n];return e}function Bt(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Vo(t){let e=Jo(t);return function(n,r){let s=$o(r),o,i=e[Bt(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Bt(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(qo&&r.ctrlKey&&r.altKey)&&(o=Ae[r.keyCode])&&o!=s){let a=e[Bt(o,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var zt,Ut;if(typeof WeakMap<"u"){let t=new WeakMap;zt=e=>t.get(e),Ut=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;zt=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Ut=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Ce=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let o=r+1,i=s+1;for(let a=1;o<this.width&&this.map[e+a]==n;a++)o++;for(let a=1;i<this.height&&this.map[e+this.width*a]==n;a++)i++;return{left:r,top:s,right:o,bottom:i}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:o,bottom:i}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[o*this.width+(n<0?r-1:s)]:(n<0?o==0:i==this.height)?null:this.map[r+this.width*(n<0?o-1:i)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:o}=this.findCell(t),{left:i,right:a,top:c,bottom:u}=this.findCell(e);return{left:Math.min(n,i),top:Math.min(s,c),right:Math.max(r,a),bottom:Math.max(o,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const o=r*this.width+s,i=this.map[o];n[i]||(n[i]=!0,!(s==t.left&&s&&this.map[o-1]==i||r==t.top&&r&&this.map[o-this.width]==i)&&e.push(i))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const o=s+n.child(r).nodeSize;if(r==t){let i=e+t*this.width;const a=(t+1)*this.width;for(;i<a&&this.map[i]<s;)i++;return i==a?o-1:this.map[i]}s=o}}static get(t){return zt(t)||Ut(t,Go(t))}};function Go(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=Yo(t),n=t.childCount,r=[];let s=0,o=null;const i=[];for(let u=0,d=e*n;u<d;u++)r[u]=0;for(let u=0,d=0;u<n;u++){const f=t.child(u);d++;for(let m=0;;m++){for(;s<r.length&&r[s]!=0;)s++;if(m==f.childCount)break;const w=f.child(m),{colspan:g,rowspan:N,colwidth:C}=w.attrs;for(let y=0;y<N;y++){if(y+u>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:d,n:N-y});break}const S=s+y*e;for(let x=0;x<g;x++){r[S+x]==0?r[S+x]=d:(o||(o=[])).push({type:"collision",row:u,pos:d,n:g-x});const _=C&&C[x];if(_){const D=(S+x)%e*2,v=i[D];v==null||v!=_&&i[D+1]==1?(i[D]=_,i[D+1]=1):v==_&&i[D+1]++}}}s+=g,d+=w.nodeSize}const h=(u+1)*e;let p=0;for(;s<h;)r[s++]==0&&p++;p&&(o||(o=[])).push({type:"missing",row:u,n:p}),d++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const a=new Ce(e,n,r,o);let c=!1;for(let u=0;!c&&u<i.length;u+=2)i[u]!=null&&i[u+1]<n&&(c=!0);return c&&Zo(a,i,t),a}function Yo(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let o=0;if(n)for(let i=0;i<r;i++){const a=t.child(i);for(let c=0;c<a.childCount;c++){const u=a.child(c);i+u.attrs.rowspan>r&&(o+=u.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const a=s.child(i);o+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function Zo(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const o=t.map[s];if(r[o])continue;r[o]=!0;const i=n.nodeAt(o);if(!i)throw new RangeError(`No cell with offset ${o} found`);let a=null;const c=i.attrs;for(let u=0;u<c.colspan;u++){const d=(s+u)%t.width,f=e[d*2];f!=null&&(!c.colwidth||c.colwidth[u]!=f)&&((a||(a=Xo(c)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:a})}}function Xo(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Ft(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}new Ye("selectingCells");function Qo(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Rr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ei(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Qo(e.$head)||ti(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function ti(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Ir(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Mr(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Lr(t,e,n){const r=t.node(-1),s=Ce.get(r),o=t.start(-1),i=s.nextCell(t.pos-o,e,n);return i==null?null:t.node(0).resolve(o+i)}function Dr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}var xe=class Te extends q{constructor(e,n=e){const r=e.node(-1),s=Ce.get(r),o=e.start(-1),i=s.rectBetween(e.pos-o,n.pos-o),a=e.node(0),c=s.cellsInRect(i).filter(d=>d!=n.pos-o);c.unshift(n.pos-o);const u=c.map(d=>{const f=r.nodeAt(d);if(!f)throw RangeError(`No cell with offset ${d} found`);const h=o+d+1;return new Nr(a.resolve(h),a.resolve(h+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Ir(r)&&Ir(s)&&Mr(r,s)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Te.rowSelection(r,s):o&&this.isColSelection()?Te.colSelection(r,s):new Te(r,s)}return ce.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Ce.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},i=[];for(let c=s.top;c<s.bottom;c++){const u=[];for(let d=c*n.width+s.left,f=s.left;f<s.right;f++,d++){const h=n.map[d];if(o[h])continue;o[h]=!0;const p=n.findCell(h);let m=e.nodeAt(h);if(!m)throw RangeError(`No cell with offset ${h} found`);const w=s.left-p.left,g=p.right-s.right;if(w>0||g>0){let N=m.attrs;if(w>0&&(N=Dr(N,0,w)),g>0&&(N=Dr(N,N.colspan-g,g)),p.left<s.left){if(m=m.type.createAndFill(N),!m)throw RangeError(`Could not create cell with attrs ${JSON.stringify(N)}`)}else m=m.type.create(N,m.content)}if(p.top<s.top||p.bottom>s.bottom){const N={...m.attrs,rowspan:Math.min(p.bottom,s.bottom)-Math.max(p.top,s.top)};p.top<s.top?m=m.type.createAndFill(N):m=m.type.create(N,m.content)}u.push(m)}i.push(e.child(c).copy(K.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:i;return new $(K.from(a),1,1)}replace(e,n=$.empty){const r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:a,$to:c}=s[i],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(c.pos),i?$.empty:n)}const o=q.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new $(K.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Ce.get(n),s=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<o.length;i++)e(n.nodeAt(o[i]),s+o[i])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Ce.get(r),o=e.start(-1),i=s.findCell(e.pos-o),a=s.findCell(n.pos-o),c=e.node(0);return i.top<=a.top?(i.top>0&&(e=c.resolve(o+s.map[i.left])),a.bottom<s.height&&(n=c.resolve(o+s.map[s.width*(s.height-1)+a.right-1]))):(a.top>0&&(n=c.resolve(o+s.map[a.left])),i.bottom<s.height&&(e=c.resolve(o+s.map[s.width*(s.height-1)+i.right-1]))),new Te(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Ce.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(s,o)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,a=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,a)==n.width}eq(e){return e instanceof Te&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Ce.get(r),o=e.start(-1),i=s.findCell(e.pos-o),a=s.findCell(n.pos-o),c=e.node(0);return i.left<=a.left?(i.left>0&&(e=c.resolve(o+s.map[i.top*s.width])),a.right<s.width&&(n=c.resolve(o+s.map[s.width*(a.top+1)-1]))):(a.left>0&&(n=c.resolve(o+s.map[a.top*s.width])),i.right<s.width&&(e=c.resolve(o+s.map[s.width*(i.top+1)-1]))),new Te(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Te(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Te(e.resolve(n),e.resolve(r))}getBookmark(){return new ni(this.$anchorCell.pos,this.$headCell.pos)}};xe.prototype.visible=!1,q.jsonID("cell",xe);var ni=class $r{constructor(e,n){this.anchor=e,this.head=n}map(e){return new $r(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Mr(n,r)?new xe(n,r):q.near(r,1)}};new Ye("fix-tables");function Pr(t){const e=t.selection,n=ei(t),r=n.node(-1),s=n.start(-1),o=Ce.get(r);return{...e instanceof xe?o.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o.findCell(n.pos-s),tableStart:s,map:o,table:r}}function ri(t){return function(e,n){if(!Rr(e))return!1;if(n){const r=Ft(e.schema),s=Pr(e),o=e.tr,i=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),a=i.map(c=>s.table.nodeAt(c));for(let c=0;c<i.length;c++)a[c].type==r.header_cell&&o.setNodeMarkup(s.tableStart+i[c],r.cell,a[c].attrs);if(o.steps.length==0)for(let c=0;c<i.length;c++)o.setNodeMarkup(s.tableStart+i[c],r.header_cell,a[c].attrs);n(o)}return!0}}function jr(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const o=e.table.nodeAt(r[s]);if(o&&o.type!==n.header_cell)return!1}return!0}function Ht(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?ri(t):function(n,r){if(!Rr(n))return!1;if(r){const s=Ft(n.schema),o=Pr(n),i=n.tr,a=jr("row",o,s),c=jr("column",o,s),d=(t==="column"?a:t==="row"?c:!1)?1:0,f=t=="column"?{left:0,top:d,right:1,bottom:o.map.height}:t=="row"?{left:d,top:0,right:o.map.width,bottom:1}:o,h=t=="column"?c?s.cell:s.header_cell:t=="row"?a?s.cell:s.header_cell:s.cell;o.map.cellsInRect(f).forEach(p=>{const m=p+o.tableStart,w=i.doc.nodeAt(m);w&&i.setNodeMarkup(m,h,w.attrs)}),r(i)}return!0}}Ht("row",{useDeprecatedLogic:!0}),Ht("column",{useDeprecatedLogic:!0}),Ht("cell",{useDeprecatedLogic:!0});function bt(t,e){const n=t.selection;if(!(n instanceof xe))return!1;if(e){const r=t.tr,s=Ft(t.schema).cell.createAndFill().content;n.forEachCell((o,i)=>{o.content.eq(s)||r.replace(r.mapping.map(i+1),r.mapping.map(i+o.nodeSize-1),new $(s,0,0))}),r.docChanged&&e(r)}return!0}Vo({ArrowLeft:yt("horiz",-1),ArrowRight:yt("horiz",1),ArrowUp:yt("vert",-1),ArrowDown:yt("vert",1),"Shift-ArrowLeft":xt("horiz",-1),"Shift-ArrowRight":xt("horiz",1),"Shift-ArrowUp":xt("vert",-1),"Shift-ArrowDown":xt("vert",1),Backspace:bt,"Mod-Backspace":bt,Delete:bt,"Mod-Delete":bt});function wt(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function yt(t,e){return(n,r,s)=>{if(!s)return!1;const o=n.selection;if(o instanceof xe)return wt(n,r,q.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const i=Br(s,t,e);if(i==null)return!1;if(t=="horiz")return wt(n,r,q.near(n.doc.resolve(o.head+e),e));{const a=n.doc.resolve(i),c=Lr(a,t,e);let u;return c?u=q.near(c,1):e<0?u=q.near(n.doc.resolve(a.before(-1)),-1):u=q.near(n.doc.resolve(a.after(-1)),1),wt(n,r,u)}}}function xt(t,e){return(n,r,s)=>{if(!s)return!1;const o=n.selection;let i;if(o instanceof xe)i=o;else{const c=Br(s,t,e);if(c==null)return!1;i=new xe(n.doc.resolve(c))}const a=Lr(i.$headCell,t,e);return a?wt(n,r,new xe(i.$anchorCell,a)):!1}}function Br(t,e,n){if(!(t.state.selection instanceof ce))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const o=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const a=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?a:null}}return null}new Ye("tableColumnResizing");function si(t,e){const n=Math.min(t.top,e.top),r=Math.max(t.bottom,e.bottom),s=Math.min(t.left,e.left),i=Math.max(t.right,e.right)-s,a=r-n,c=s,u=n;return new DOMRect(c,u,i,a)}var oi=class{constructor({editor:t,element:e,view:n,updateDelay:r=250,resizeDelay:s=60,shouldShow:o,appendTo:i,options:a}){this.preventHide=!1,this.isVisible=!1,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:c,state:u,from:d,to:f})=>{const{doc:h,selection:p}=u,{empty:m}=p,w=!h.textBetween(d,f).length&&W.isTextSelection(u.selection),g=this.element.contains(document.activeElement);return!(!(c.hasFocus()||g)||m||w||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:c})=>{var u;if(this.preventHide){this.preventHide=!1;return}c?.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(c.relatedTarget))||c?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(c,u)=>{const d=!u?.selection.eq(c.state.selection),f=!u?.doc.eq(c.state.doc);!d&&!f||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(c,d,f,u)},this.updateDelay))},this.updateHandler=(c,u,d,f)=>{const{composing:h}=c;if(h||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.editor=t,this.element=e,this.view=n,this.updateDelay=r,this.resizeDelay=s,this.appendTo=i,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),window.addEventListener("resize",this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(ir(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(or(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(rr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(cr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(ar(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(sr(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(lr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(ur(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}updatePosition(){const{selection:t}=this.editor.state,e=W.posToDOMRect(this.view,t.from,t.to);let n={getBoundingClientRect:()=>e,getClientRects:()=>[e]};if(t instanceof ue){let r=this.view.nodeDOM(t.from);const s=r.dataset.nodeViewWrapper?r:r.querySelector("[data-node-view-wrapper]");s&&(r=s),r&&(n={getBoundingClientRect:()=>r.getBoundingClientRect(),getClientRects:()=>[r.getBoundingClientRect()]})}if(t instanceof xe){const{$anchorCell:r,$headCell:s}=t,o=r?r.pos:s.pos,i=s?s.pos:r.pos,a=this.view.nodeDOM(o),c=this.view.nodeDOM(i);if(!a||!c)return;const u=a===c?a.getBoundingClientRect():si(a.getBoundingClientRect(),c.getBoundingClientRect());n={getBoundingClientRect:()=>u,getClientRects:()=>[u]}}dr(n,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:o})=>{this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const{state:n}=t,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(t,e);return}const s=!e?.selection.eq(t.state.selection),o=!e?.doc.eq(t.state.doc);this.updateHandler(t,s,o,e)}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,o=Math.min(...s.map(c=>c.$from.pos)),i=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,element:this.element,view:this.view,state:n,oldState:t,from:o,to:i})}show(){var t,e;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(e=(t=this.appendTo)!=null?t:this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},zr=t=>new Ar({key:typeof t.pluginKey=="string"?new Ye(t.pluginKey):t.pluginKey,view:e=>new oi({view:e,...t})});W.Extension.create({name:"bubbleMenu",addOptions(){return{element:null,pluginKey:"bubbleMenu",updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[zr({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,shouldShow:this.options.shouldShow})]:[]}});var ii=class{constructor({editor:t,element:e,view:n,options:r,shouldShow:s}){this.preventHide=!1,this.isVisible=!1,this.shouldShow=({view:o,state:i})=>{const{selection:a}=i,{$anchor:c,empty:u}=a,d=c.depth===1,f=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent&&c.parent.childCount===0&&!this.getTextContent(c.parent);return!(!o.hasFocus()||!u||!d||!f||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(o,i,a,c)=>{const{composing:u}=o;if(u||!i&&!a)return;if(!this.getShouldShow(c)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var i;if(this.preventHide){this.preventHide=!1;return}o?.relatedTarget&&((i=this.element.parentNode)!=null&&i.contains(o.relatedTarget))||o?.relatedTarget!==this.editor.view.dom&&this.hide()},this.editor=t,this.element=e,this.view=n,this.floatingUIOptions={...this.floatingUIOptions,...r},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.update(n,n.state),this.getShouldShow()&&this.show()}getTextContent(t){return W.getText(t,{textSerializers:W.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const t=[];return this.floatingUIOptions.flip&&t.push(ir(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&t.push(or(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&t.push(rr(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&t.push(cr(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&t.push(ar(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&t.push(sr(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&t.push(lr(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&t.push(ur(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),t}getShouldShow(t){var e;const{state:n}=this.view,{selection:r}=n,{ranges:s}=r,o=Math.min(...s.map(c=>c.$from.pos)),i=Math.max(...s.map(c=>c.$to.pos));return(e=this.shouldShow)==null?void 0:e.call(this,{editor:this.editor,view:this.view,state:n,oldState:t,from:o,to:i})}updatePosition(){const{selection:t}=this.editor.state,e=W.posToDOMRect(this.view,t.from,t.to);dr({getBoundingClientRect:()=>e,getClientRects:()=>[e]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:r,y:s,strategy:o})=>{this.element.style.width="max-content",this.element.style.position=o,this.element.style.left=`${r}px`,this.element.style.top=`${s}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(t,e){const n=!e?.selection.eq(t.state.selection),r=!e?.doc.eq(t.state.doc);this.updateHandler(t,n,r,e)}show(){var t;this.isVisible||(this.element.style.visibility="visible",this.element.style.opacity="1",(t=this.view.dom.parentElement)==null||t.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Ur=t=>new Ar({key:typeof t.pluginKey=="string"?new Ye(t.pluginKey):t.pluginKey,view:e=>new ii({view:e,...t})});W.Extension.create({name:"floatingMenu",addOptions(){return{element:null,options:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Ur({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,options:this.options.options,shouldShow:this.options.shouldShow})]:[]}});var Fr=T.forwardRef(({pluginKey:t="bubbleMenu",editor:e,updateDelay:n,resizeDelay:r,shouldShow:s=null,options:o,children:i,...a},c)=>{const u=T.useRef(document.createElement("div"));typeof c=="function"?c(u.current):c&&(c.current=u.current);const{editor:d}=Z.useCurrentEditor();return T.useEffect(()=>{const f=u.current;if(f.style.visibility="hidden",f.style.position="absolute",e?.isDestroyed||d?.isDestroyed)return;const h=e||d;if(!h){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const p=zr({updateDelay:n,resizeDelay:r,editor:h,element:f,pluginKey:t,shouldShow:s,options:o});return h.registerPlugin(p),()=>{h.unregisterPlugin(t),window.requestAnimationFrame(()=>{f.parentNode&&f.parentNode.removeChild(f)})}},[e,d]),Jt.createPortal(l.jsx("div",{...a,children:i}),u.current)}),ai=T.forwardRef(({pluginKey:t="floatingMenu",editor:e,shouldShow:n=null,options:r,children:s,...o},i)=>{const a=T.useRef(document.createElement("div"));typeof i=="function"?i(a.current):i&&(i.current=a.current);const{editor:c}=Z.useCurrentEditor();return T.useEffect(()=>{const u=a.current;if(u.style.visibility="hidden",u.style.position="absolute",e?.isDestroyed||c?.isDestroyed)return;const d=e||c;if(!d){console.warn("FloatingMenu component is not rendered inside of an editor component or does not have editor prop.");return}const f=Ur({editor:d,element:u,pluginKey:t,shouldShow:n,options:r});return d.registerPlugin(f),()=>{d.unregisterPlugin(t),window.requestAnimationFrame(()=>{u.parentNode&&u.parentNode.removeChild(u)})}},[e,c]),Jt.createPortal(l.jsx("div",{...o,children:s}),a.current)});const li=({editor:t,isReadOnly:e})=>{const[n,r]=T.useState(!1),[s,o]=T.useState(!1),[i,a]=T.useState(""),[c,u]=T.useState(!1),d=()=>{i&&(t.chain().focus().extendMarkRange("link").setLink({href:i}).run(),a(""),u(!1))};return e?null:l.jsx(Fr,{editor:t,shouldShow:({editor:f,state:h})=>{const{from:p,to:m}=h.selection;return p!==m&&!f.isActive("codeBlock")},className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:l.jsxs("div",{className:"flex gap-1 items-center",children:[l.jsx(P,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:l.jsx(M.Bold,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:l.jsx(M.Italic,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:l.jsx(M.Underline,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:l.jsx(M.Strikethrough,{className:"h-4 w-4 cursor-pointer"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:l.jsx(M.Code,{className:"h-4 w-4 cursor-pointer"})}),l.jsxs("div",{className:"relative",children:[l.jsx(P,{onClick:()=>r(!n),title:"Text Color",children:l.jsx(M.Type,{className:"h-4 w-4 cursor-pointer"})}),n&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsx(Fs,{onColorChange:f=>{t.chain().focus().setColor(f).run(),r(!1)}})})]}),l.jsxs("div",{className:"relative",children:[l.jsx(P,{onClick:()=>o(!s),title:"Background Color",children:l.jsx(M.Palette,{className:"h-4 w-4 cursor-pointer"})}),s&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsx(Hs,{onColorChange:f=>{t.chain().focus().toggleHighlight({color:f}).run(),o(!1)}})})]}),l.jsxs("div",{className:"relative",children:[l.jsx(P,{onClick:()=>u(!c),isActive:t.isActive("link"),title:"Add/Edit Link",children:l.jsx(M.Link,{className:"h-4 w-4 cursor-pointer"})}),c&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{type:"url",placeholder:"Enter URL...",value:i,onChange:f=>a(f.target.value),className:"px-2 py-1 text-sm border border-gray-300 rounded",onKeyDown:f=>{f.key==="Enter"&&d()}}),l.jsx(G,{type:"button",onClick:d,size:"sm",className:"h-8 cursor-pointer",children:"Set"})]})})]})]})})},ci=[{label:"Green",value:"#4caf5040"},{label:"Red",value:"#f4433640"},{label:"Grey",value:"#9e9e9e40"}],ui=({onColorChange:t})=>l.jsx("div",{className:"flex gap-2",children:ci.map(({label:e,value:n})=>l.jsxs("button",{type:"button",className:"flex flex-col items-center text-xs text-gray-600",onClick:()=>t(n),children:[l.jsx("span",{className:"w-6 h-6 rounded border border-gray-300 cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:n}}),e]},n))}),Hr=[{value:"",label:"Plain Text"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"js",label:"JavaScript"},{value:"ts",label:"TypeScript"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"c",label:"C"},{value:"cpp",label:"C++"},{value:"sql",label:"SQL"}],di=({editor:t,isReadOnly:e})=>{const[n,r]=T.useState(!1),[s,o]=T.useState(!1),i=T.useRef(null),a=t.getAttributes("codeBlock").language||"";if(T.useEffect(()=>{const u=d=>{i.current&&!i.current.contains(d.target)&&o(!1)};return s&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[s]),e)return null;const c=u=>{t.chain().focus().updateAttributes("codeBlock",{language:u||null}).run(),o(!1)};return l.jsx(Fr,{editor:t,shouldShow:({editor:u})=>u.isActive("codeBlock"),className:"bubble-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg z-50",children:l.jsxs("div",{className:"flex gap-1 items-center",children:[l.jsxs("div",{className:"relative",ref:i,children:[l.jsx(P,{onClick:()=>{o(!s),r(!1)},title:"Select Language",className:"px-2 min-w-[120px]",children:l.jsxs("div",{className:"flex items-center gap-1 w-full justify-between",children:[l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Code,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:Hr.find(u=>u.value===a)?.label||"Plain Text"})]}),l.jsx(M.ChevronDown,{className:"h-3 w-3"})]})}),s&&l.jsx("div",{className:"absolute top-full mt-1 left-0 z-10 bg-white border border-gray-300 rounded-lg shadow-lg min-w-[140px] max-h-[300px] overflow-y-auto",children:l.jsx("div",{className:"p-1 space-y-1",children:Hr.map(u=>l.jsx(G,{type:"button",variant:a===u.value?"default":"ghost",size:"sm",onClick:()=>c(u.value),className:`w-full justify-start text-xs hover:bg-gray-100 ${a===u.value?"bg-blue-600 text-white hover:bg-blue-700":""}`,children:u.label},u.value))})})]}),l.jsxs("div",{className:"relative",children:[l.jsx(P,{onClick:()=>{r(!n),o(!1)},title:"Background Color",isActive:t.isActive("codeBlockBg"),children:l.jsx(M.Palette,{className:"h-4 w-4 cursor-pointer"})}),n&&l.jsx("div",{className:"absolute top-full mt-1 z-10 bg-white border border-gray-300 rounded-lg p-2 shadow-lg",children:l.jsx(ui,{onColorChange:u=>{t.chain().focus().toggleCodeBlockBg(u).run(),r(!1)}})})]})]})})},fi=({editor:t,isReadOnly:e,onImageClick:n})=>e?null:l.jsxs(ai,{editor:t,className:"floating-menu bg-white border border-gray-300 rounded-lg p-2 shadow-lg flex gap-1 z-50",children:[l.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),title:"Heading 1",children:l.jsx(M.Heading1,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),title:"Heading 2",children:l.jsx(M.Heading2,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),title:"Heading 3",children:l.jsx(M.Heading3,{className:"h-4 w-4"})}),l.jsx(P,{onClick:()=>t.chain().focus().setParagraph().run(),title:"Paragraph",children:l.jsx(M.FileText,{className:"h-4 w-4"})}),l.jsx(P,{onClick:n,title:"Insert Image",children:l.jsx(M.Image,{className:"h-4 w-4"})})]}),pi=({editor:t,isReadOnly:e,position:n})=>!n.show||e?null:l.jsxs("div",{className:"table-bubble-menu bg-white border-2 border-blue-500 rounded-lg p-2 shadow-lg",style:{position:"absolute",top:`${n.top}px`,left:`${n.left}px`,zIndex:50,backdropFilter:"blur(8px)",background:"rgba(255, 255, 255, 0.95)"},children:[l.jsxs("div",{className:"flex gap-1 items-center",children:[l.jsx(P,{onClick:()=>t.chain().focus().addRowBefore().run(),title:"Add Row Before",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"↑ Row"})]})}),l.jsx(P,{onClick:()=>t.chain().focus().addRowAfter().run(),title:"Add Row After",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Row ↓"})]})}),l.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),l.jsx(P,{onClick:()=>t.chain().focus().addColumnBefore().run(),title:"Add Column Before",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:["ß",l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"← Col"})]})}),l.jsx(P,{onClick:()=>t.chain().focus().addColumnAfter().run(),title:"Add Column After",className:"h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Plus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Col →"})]})}),l.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),l.jsx(P,{onClick:()=>t.chain().focus().deleteColumn().run(),title:"Delete Column",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Minus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Col"})]})}),l.jsx("div",{className:"h-6 w-px bg-gray-300 mx-1"}),l.jsx(P,{onClick:()=>t.chain().focus().deleteRow().run(),title:"Delete Row",className:"text-red-600 hover:bg-red-50 h-8 w-auto px-2",children:l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(M.Minus,{className:"h-3 w-3"}),l.jsx("span",{className:"text-xs",children:"Row"})]})}),l.jsx(P,{onClick:()=>t.chain().focus().deleteTable().run(),title:"Delete Table",className:"text-red-600 hover:bg-red-50",children:l.jsx(M.Trash2,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"absolute top-full left-5 w-0 h-0 border-l-6 border-r-6 border-t-6 border-l-transparent border-r-transparent border-t-blue-500"})]}),hi=({editor:t})=>l.jsxs("div",{className:"mb-2 p-2 bg-gray-100 rounded text-xs",children:[l.jsx("strong",{children:"Debug:"})," Current position - H1:"," ",t.isActive("heading",{level:1})?"✅":"❌"," | H2:"," ",t.isActive("heading",{level:2})?"✅":"❌"," | H3:"," ",t.isActive("heading",{level:3})?"✅":"❌"," | P:"," ",t.isActive("paragraph")?"✅":"❌"," | Bold:"," ",t.isActive("bold")?"✅":"❌"," | List:"," ",t.isActive("bulletList")?"✅":"❌"," | Table:"," ",t.isActive("table")?"✅":"❌"]}),mi=({isReadOnly:t,setIsReadOnly:e,onLogContent:n})=>l.jsxs("div",{className:"mb-4 flex justify-end gap-2",children:[l.jsxs(G,{type:"button",onClick:n,variant:"outline",size:"sm",className:"flex items-center gap-2",title:"Log content to console for backend storage",children:[l.jsx(M.Terminal,{className:"h-4 w-4"}),"Log Content"]}),l.jsx(G,{type:"button",onClick:()=>e(!t),variant:t?"default":"outline",size:"sm",className:"flex items-center gap-2",children:t?l.jsxs(l.Fragment,{children:[l.jsx(M.Lock,{className:"h-4 w-4"}),"Read Only"]}):l.jsxs(l.Fragment,{children:[l.jsx(M.LockOpen,{className:"h-4 w-4"}),"Editable"]})})]}),gi=t=>{const e={html:t.getHTML(),json:t.getJSON(),text:t.getText(),isEmpty:t.isEmpty,characterCount:t.storage.characterCount?.characters()||t.getText().length,wordCount:t.storage.characterCount?.words()||t.getText().split(/\s+/).filter(n=>n.length>0).length,timestamp:new Date().toISOString()};return console.log("📄 Tiptap Editor Content for Backend Storage:"),console.log("================================================"),console.log("📋 HTML Output (for rendering):",e.html),console.log("📋 JSON Output (for editing):",e.json),console.log("📋 Plain Text:",e.text),console.log("📊 Stats:",{isEmpty:e.isEmpty,characters:e.characterCount,words:e.wordCount,timestamp:e.timestamp}),console.log("================================================"),e},bi=({onImageUpload:t,onVideoUpload:e,onImageDelete:n,onVideoDelete:r,content:s,setEditorContent:o})=>{const[i,a]=T.useState(""),[c,u]=T.useState(!1),[,d]=T.useState({}),[f,h]=T.useState(!1),[p,m]=T.useState(!1),[w,g]=T.useState(!1),[N,C]=T.useState(null),y=T.useRef(null),[S,x]=T.useState({top:0,left:0,show:!1}),_=R=>{const I=new Set,L=k=>{k.type==="image"&&k.attrs?.src&&I.add(k.attrs.src),k.content&&Array.isArray(k.content)&&k.content.forEach(L)};return L(R),I},D=R=>{const I=new Set,L=k=>{k.type==="video"&&k.attrs?.src&&I.add(k.attrs.src),k.content&&Array.isArray(k.content)&&k.content.forEach(L)};return L(R),I},v=Z.useEditor({extensions:[Zt,Xt,$t,qt,Kt,Qt,en,xn,vn,tn,nn,rn,yn,wn,En,Nn,Sn,Cn,_n,Tn,kn,On,Rn,An.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:s||`
23
23
  <p>Hello World. Create your own content here.</p>
24
- `,editable:!f,editorProps:{attributes:{class:"prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none min-h-[400px] p-4"},handlePaste:(D,R,I)=>{const U=Array.from(R.clipboardData?.items||[]).filter(z=>z.type.indexOf("image")!==-1);if(U.length>0&&t&&y.current){R.preventDefault();const z=U.map(b=>{const A=b.getAsFile();return A?t(A).then(j=>(j&&y.current&&y.current.chain().focus().setImage({src:j}).run(),j)).catch(j=>(console.error("Failed to upload pasted image:",j),alert("Failed to upload pasted image. Please try again."),null)):Promise.resolve(null)});return g(!0),Promise.all(z).finally(()=>{g(!1)}),!0}const k=R.clipboardData?.getData("text/html");if(k&&t&&y.current){const A=new DOMParser().parseFromString(k,"text/html").querySelectorAll("img");if(A.length>0){const j=Array.from(A).filter(J=>{const re=J.getAttribute("src");return re&&(re.startsWith("data:")||re.startsWith("http://")||re.startsWith("https://"))});if(j.length>0){R.preventDefault();const J=j.map(re=>{const ee=re.getAttribute("src");if(!ee)return Promise.resolve(null);const Fe=(oe,X)=>{const Oe=new File([oe],X,{type:oe.type||"image/png"});return t(Oe).then(Ce=>(Ce&&y.current&&y.current.chain().focus().setImage({src:Ce}).run(),Ce)).catch(Ce=>(console.error("Failed to upload pasted image:",Ce),alert("Failed to upload pasted image. Please try again."),null))};return ee.startsWith("data:")?fetch(ee).then(oe=>oe.blob()).then(oe=>Fe(oe,"pasted-image.png")):ee.startsWith("http://")||ee.startsWith("https://")?fetch(ee).then(oe=>oe.blob()).then(oe=>Fe(oe,"pasted-image.png")):Promise.resolve(null)});return g(!0),Promise.all(J).finally(()=>{g(!1)}),!0}}}return!1}},onUpdate:()=>{const D=E.getJSON();if(N){const R=x(N),I=x(D),C=[...R].filter(b=>!I.has(b)),U=O(N),k=O(D),z=[...U].filter(b=>!k.has(b));C.forEach(b=>{n&&n(b).catch(A=>{console.error("Failed to delete image:",A)})}),z.forEach(b=>{r&&r(b).catch(A=>{console.error("Failed to delete video:",A)})})}S(D),o?.({html:E.getHTML(),json:D}),d({})},onSelectionUpdate:()=>{o?.({html:E.getHTML(),json:E.getJSON()}),d({})}});T.useEffect(()=>{E&&(y.current=E,S(E.getJSON()))},[E]),T.useEffect(()=>{if(E&&s!==void 0){const D=E.getJSON();S(D)}},[s,E]),T.useEffect(()=>{E&&E.setEditable(!f)},[E,f]),T.useEffect(()=>{if(!E)return;const D=()=>{if(E.isActive("table")&&!f){const{from:I}=E.state.selection;let C=null;const U=E.view.domAtPos(I);if(U.node&&U.node.parentElement){let k=U.node.parentElement;for(;k&&k!==E.view.dom;){if(k.tagName==="TABLE"){C=k;break}k=k.parentElement}}if(C){const k=C.getBoundingClientRect(),z=E.view.dom.getBoundingClientRect();v({top:k.bottom-z.top+10,left:k.left-z.left,show:!0})}}else v(I=>({...I,show:!1}))},R=()=>{D()};return E.on("selectionUpdate",R),E.on("update",R),()=>{E.off("selectionUpdate",R),E.off("update",R)}},[E]),T.useEffect(()=>{const D=R=>{R.target.closest(".image-input-container")||u(!1)};return c&&document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[c]);const P=T.useCallback(async()=>{const D=document.createElement("input");D.type="file",D.accept="image/*",D.onchange=async R=>{const I=R.target.files?.[0];if(I&&t)try{g(!0);const C=await t(I);C&&E?.chain().focus().setImage({src:C}).run()}catch(C){console.error("Failed to upload image:",C),alert("Failed to upload image. Please try again.")}finally{g(!1)}},D.click()},[E,t]),L=T.useCallback(()=>{i.trim()&&(E?.chain().focus().setImage({src:i.trim()}).run(),a(""),u(!1))},[E,i]),$=T.useCallback(async()=>{const D=document.createElement("input");D.type="file",D.accept="video/*",D.onchange=async R=>{const I=R.target.files?.[0];if(I&&e)try{p(!0);const C=await e(I);if(C){console.log("Attempting to insert video:",{src:C,type:I.type,title:I.name});try{const U=E?.chain().focus().setVideo({src:C,type:I.type,title:I.name}).run();console.log("Video insertion result:",U)}catch(U){throw console.error("Error inserting video into editor:",U),U}}}catch(C){console.error("Failed to upload video:",C),console.error("Error details:",{message:C instanceof Error?C.message:"Unknown error",stack:C instanceof Error?C.stack:"No stack trace"}),alert(`Failed to upload video: ${C instanceof Error?C.message:"Unknown error"}`)}finally{p(!1)}else if(I&&!e){const C=new FileReader;C.onload=U=>{const k=U.target?.result;console.log("Attempting to insert base64 video:",{src:k.substring(0,100)+"...",type:I.type,title:I.name});try{const z=E?.chain().focus().setVideo({src:k,type:I.type,title:I.name}).run();console.log("Base64 video insertion result:",z)}catch(z){console.error("Error inserting base64 video into editor:",z)}},C.readAsDataURL(I)}},D.click()},[E,e]),V=T.useCallback(()=>{if(E)return mi(E)},[E]);return E?l.jsxs("div",{className:"w-full max-w-6xl mx-auto p-4",children:[E&&l.jsx(pi,{editor:E}),l.jsx(hi,{editor:E,isReadOnly:f,setIsReadOnly:m,onLogContent:V}),l.jsx(Fs,{editor:E,isReadOnly:f,onImageUpload:P,onVideoUpload:$,isImageUploading:h,isVideoUploading:w,showImageInput:c,setShowImageInput:u,imageUrl:i,setImageUrl:a,handleImageUrlInsert:L,imageUploadFunction:t}),l.jsxs("div",{className:"relative border border-gray-300 border-t-1 rounded-t-lg rounded-b-lg min-h-[400px]",children:[l.jsx(Z.EditorContent,{editor:E,className:"tiptap-editor"}),h&&l.jsx("div",{className:"absolute inset-0 bg-white/80 backdrop-blur-sm flex items-center justify-center z-50 rounded-lg",children:l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-gray-200 border-t-blue-600"}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx("svg",{className:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),l.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Uploading image..."})]})}),l.jsx(di,{editor:E,isReadOnly:f,onImageClick:()=>u(!c)}),l.jsx(ai,{editor:E,isReadOnly:f}),l.jsx(ui,{editor:E,isReadOnly:f}),l.jsx(fi,{editor:E,isReadOnly:f,position:_})]})]}):null},bi=({styles:t,editorContent:e,immediatelyRender:n=!1})=>{const[,r]=T.useState({}),[s]=T.useState(!0),o=Z.useEditor({extensions:[Zt,Xt,$t,qt,Kt,Qt.configure({inline:!1,allowBase64:!0}),en.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),xn,vn,tn,nn.configure({types:["textStyle"]}),rn.configure({multicolor:!0}),yn,wn,En,Nn,_n,Sn,Cn,Tn,kn,On,Rn,An.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:e||"<h1>Nothing on Canvas :(</h1>",editable:!s,immediatelyRender:n,editorProps:{attributes:{class:`prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none min-h-[400px] p-4 ${t}`}},onUpdate:()=>{r({})},onSelectionUpdate:()=>{r({})}});return T.useEffect(()=>{o&&o.setEditable(!s)},[o,s]),o?l.jsx("div",{className:"w-full max-w-6xl mx-auto p-4",children:l.jsx(Z.EditorContent,{editor:o,className:"tiptap-editor"})}):null};function wi(t){const[e,n]=T.useState(t??{html:"",json:null}),r=T.useCallback(s=>{n(s)},[]);return{content:e,html:e.html,json:e.json,setContent:r}}H.TiptapEditor=gi,H.TiptapViewer=bi,H.useEditorContent=wi,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));
24
+ `,editable:!f,editorProps:{attributes:{class:"prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none min-h-[400px] p-4"},handlePaste:(R,I,L)=>{const F=Array.from(I.clipboardData?.items||[]).filter(B=>B.type.indexOf("image")!==-1);if(F.length>0&&t&&y.current){I.preventDefault();const B=F.map(b=>{const O=b.getAsFile();return O?t(O).then(j=>(j&&y.current&&y.current.chain().focus().setImage({src:j}).run(),j)).catch(j=>(console.error("Failed to upload pasted image:",j),alert("Failed to upload pasted image. Please try again."),null)):Promise.resolve(null)});return m(!0),Promise.all(B).finally(()=>{m(!1)}),!0}const A=I.clipboardData?.getData("text/html");if(A&&t&&y.current){const O=new DOMParser().parseFromString(A,"text/html").querySelectorAll("img");if(O.length>0){const j=Array.from(O).filter(J=>{const re=J.getAttribute("src");return re&&(re.startsWith("data:")||re.startsWith("http://")||re.startsWith("https://"))});if(j.length>0){I.preventDefault();const J=j.map(re=>{const ee=re.getAttribute("src");if(!ee)return Promise.resolve(null);const He=(oe,X)=>{const Oe=new File([oe],X,{type:oe.type||"image/png"});return t(Oe).then(_e=>(_e&&y.current&&y.current.chain().focus().setImage({src:_e}).run(),_e)).catch(_e=>(console.error("Failed to upload pasted image:",_e),alert("Failed to upload pasted image. Please try again."),null))};return ee.startsWith("data:")?fetch(ee).then(oe=>oe.blob()).then(oe=>He(oe,"pasted-image.png")):ee.startsWith("http://")||ee.startsWith("https://")?fetch(ee).then(oe=>oe.blob()).then(oe=>He(oe,"pasted-image.png")):Promise.resolve(null)});return m(!0),Promise.all(J).finally(()=>{m(!1)}),!0}}}return!1}},onUpdate:()=>{const R=v.getJSON();if(N){const I=_(N),L=_(R),k=[...I].filter(b=>!L.has(b)),F=D(N),A=D(R),B=[...F].filter(b=>!A.has(b));k.forEach(b=>{n&&n(b).catch(O=>{console.error("Failed to delete image:",O)})}),B.forEach(b=>{r&&r(b).catch(O=>{console.error("Failed to delete video:",O)})})}C(R),o?.({html:v.getHTML(),json:R}),d({})},onSelectionUpdate:()=>{o?.({html:v.getHTML(),json:v.getJSON()}),d({})}});T.useEffect(()=>{v&&(y.current=v,C(v.getJSON()))},[v]),T.useEffect(()=>{if(v&&s!==void 0){const R=v.getJSON();C(R)}},[s,v]),T.useEffect(()=>{v&&v.setEditable(!f)},[v,f]),T.useEffect(()=>{if(!v)return;const R=()=>{if(v.isActive("table")&&!f){const{from:L}=v.state.selection;let k=null;const F=v.view.domAtPos(L);if(F.node&&F.node.parentElement){let A=F.node.parentElement;for(;A&&A!==v.view.dom;){if(A.tagName==="TABLE"){k=A;break}A=A.parentElement}}if(k){const A=k.getBoundingClientRect(),B=v.view.dom.getBoundingClientRect();x({top:A.bottom-B.top+10,left:A.left-B.left,show:!0})}}else x(L=>({...L,show:!1}))},I=()=>{R()};return v.on("selectionUpdate",I),v.on("update",I),()=>{v.off("selectionUpdate",I),v.off("update",I)}},[v]),T.useEffect(()=>{const R=I=>{I.target.closest(".image-input-container")||u(!1)};return c&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[c]);const U=T.useCallback(async()=>{const R=document.createElement("input");R.type="file",R.accept="image/*",R.onchange=async I=>{const L=I.target.files?.[0];if(L&&t)try{m(!0);const k=await t(L);k&&v?.chain().focus().setImage({src:k}).run()}catch(k){console.error("Failed to upload image:",k),alert("Failed to upload image. Please try again.")}finally{m(!1)}},R.click()},[v,t]),E=T.useCallback(()=>{i.trim()&&(v?.chain().focus().setImage({src:i.trim()}).run(),a(""),u(!1))},[v,i]),z=T.useCallback(async()=>{const R=document.createElement("input");R.type="file",R.accept="video/*",R.onchange=async I=>{const L=I.target.files?.[0];if(L&&e)try{g(!0);const k=await e(L);if(k){console.log("Attempting to insert video:",{src:k,type:L.type,title:L.name});try{const F=v?.chain().focus().setVideo({src:k,type:L.type,title:L.name}).run();console.log("Video insertion result:",F)}catch(F){throw console.error("Error inserting video into editor:",F),F}}}catch(k){console.error("Failed to upload video:",k),console.error("Error details:",{message:k instanceof Error?k.message:"Unknown error",stack:k instanceof Error?k.stack:"No stack trace"}),alert(`Failed to upload video: ${k instanceof Error?k.message:"Unknown error"}`)}finally{g(!1)}else if(L&&!e){const k=new FileReader;k.onload=F=>{const A=F.target?.result;console.log("Attempting to insert base64 video:",{src:A.substring(0,100)+"...",type:L.type,title:L.name});try{const B=v?.chain().focus().setVideo({src:A,type:L.type,title:L.name}).run();console.log("Base64 video insertion result:",B)}catch(B){console.error("Error inserting base64 video into editor:",B)}},k.readAsDataURL(L)}},R.click()},[v,e]),V=T.useCallback(()=>{if(v)return gi(v)},[v]);return v?l.jsxs("div",{className:"w-full max-w-6xl mx-auto p-4",children:[v&&l.jsx(hi,{editor:v}),l.jsx(mi,{editor:v,isReadOnly:f,setIsReadOnly:h,onLogContent:V}),l.jsx($s,{editor:v,isReadOnly:f,onImageUpload:U,onVideoUpload:z,isImageUploading:p,isVideoUploading:w,showImageInput:c,setShowImageInput:u,imageUrl:i,setImageUrl:a,handleImageUrlInsert:E,imageUploadFunction:t}),l.jsxs("div",{className:"relative border border-gray-300 border-t-1 rounded-t-lg rounded-b-lg min-h-[400px]",children:[l.jsx(Z.EditorContent,{editor:v,className:"tiptap-editor"}),p&&l.jsx("div",{className:"absolute inset-0 bg-white/80 backdrop-blur-sm flex items-center justify-center z-50 rounded-lg",children:l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-gray-200 border-t-blue-600"}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx("svg",{className:"w-6 h-6 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})})]}),l.jsx("p",{className:"text-sm font-medium text-gray-700",children:"Uploading image..."})]})}),l.jsx(fi,{editor:v,isReadOnly:f,onImageClick:()=>u(!c)}),l.jsx(li,{editor:v,isReadOnly:f}),l.jsx(di,{editor:v,isReadOnly:f}),l.jsx(pi,{editor:v,isReadOnly:f,position:S})]})]}):null},wi=({styles:t,editorContent:e,immediatelyRender:n=!1})=>{const[,r]=T.useState({}),[s]=T.useState(!0),o=Z.useEditor({extensions:[Zt,Xt,$t,qt,Kt,Qt.configure({inline:!1,allowBase64:!0}),en.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https"}),xn,vn,tn,nn.configure({types:["textStyle"]}),rn.configure({multicolor:!0}),yn,wn,En,Nn,Sn,Cn,_n,Tn,kn,On,Rn,An.configure({inline:!1,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-lg shadow-sm"}})],content:e||"<h1>Nothing on Canvas :(</h1>",editable:!s,immediatelyRender:n,editorProps:{attributes:{class:`prose prose-sm sm:prose lg:prose-lg xl:prose-2xl mx-auto focus:outline-none min-h-[400px] p-4 ${t}`}},onUpdate:()=>{r({})},onSelectionUpdate:()=>{r({})}});return T.useEffect(()=>{o&&o.setEditable(!s)},[o,s]),o?l.jsx("div",{className:"w-full max-w-6xl mx-auto p-4",children:l.jsx(Z.EditorContent,{editor:o,className:"tiptap-editor"})}):null};function yi(t){const[e,n]=T.useState(t??{html:"",json:null}),r=T.useCallback(s=>{n(s)},[]);return{content:e,html:e.html,json:e.json,setContent:r}}H.TiptapEditor=bi,H.TiptapViewer=wi,H.useEditorContent=yi,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})}));