openwriter 0.37.1 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/client/assets/crimson-pro-latin-wght-italic-CkPs-Rv6.woff2 +0 -0
  2. package/dist/client/assets/crimson-pro-latin-wght-normal-C4R2PX-h.woff2 +0 -0
  3. package/dist/client/assets/dm-sans-latin-wght-italic-Cz4n9dED.woff2 +0 -0
  4. package/dist/client/assets/dm-sans-latin-wght-normal-Xz1IZZA0.woff2 +0 -0
  5. package/dist/client/assets/dm-serif-display-latin-400-italic-DpcbibHm.woff2 +0 -0
  6. package/dist/client/assets/dm-serif-display-latin-400-normal-C5_t9oOD.woff2 +0 -0
  7. package/dist/client/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
  8. package/dist/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  9. package/dist/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  10. package/dist/client/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  11. package/dist/client/assets/ibm-plex-sans-latin-400-italic-CZTNEAuW.woff2 +0 -0
  12. package/dist/client/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  13. package/dist/client/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  14. package/dist/client/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  15. package/dist/client/assets/index-D57aFMR_.css +1 -0
  16. package/dist/client/assets/index-DKnYQz7a.js +215 -0
  17. package/dist/client/assets/inter-latin-wght-italic-DpCbqKDY.woff2 +0 -0
  18. package/dist/client/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  19. package/dist/client/assets/libre-baskerville-latin-400-italic-Dx5Rrf3o.woff2 +0 -0
  20. package/dist/client/assets/libre-baskerville-latin-400-normal-C42RasBZ.woff2 +0 -0
  21. package/dist/client/assets/libre-baskerville-latin-700-normal-CLGq6Yj4.woff2 +0 -0
  22. package/dist/client/assets/literata-latin-wght-italic-Bm_GJfSc.woff2 +0 -0
  23. package/dist/client/assets/literata-latin-wght-normal-DLxlUchJ.woff2 +0 -0
  24. package/dist/client/assets/newsreader-latin-wght-italic-Bxi8ein9.woff2 +0 -0
  25. package/dist/client/assets/newsreader-latin-wght-normal-CCVVNp6i.woff2 +0 -0
  26. package/dist/client/assets/playfair-display-latin-wght-italic-DmbndNpe.woff2 +0 -0
  27. package/dist/client/assets/playfair-display-latin-wght-normal-BOwq7MWX.woff2 +0 -0
  28. package/dist/client/assets/source-serif-4-latin-wght-italic-D2yaqPoE.woff2 +0 -0
  29. package/dist/client/assets/source-serif-4-latin-wght-normal-D9elroTD.woff2 +0 -0
  30. package/dist/client/assets/space-grotesk-latin-wght-normal-BhU9QXUp.woff2 +0 -0
  31. package/dist/client/assets/space-mono-latin-400-italic-YylcN9Ay.woff2 +0 -0
  32. package/dist/client/assets/space-mono-latin-400-normal-Rg4St2Dn.woff2 +0 -0
  33. package/dist/client/assets/space-mono-latin-700-normal-mWgeinG7.woff2 +0 -0
  34. package/dist/client/index.html +5 -5
  35. package/dist/plugins/github/dist/blog-tools.js +8 -2
  36. package/dist/plugins/github/dist/git-sync.d.ts +11 -1
  37. package/dist/plugins/github/dist/git-sync.js +73 -14
  38. package/dist/plugins/github/dist/index.js +15 -5
  39. package/dist/server/content-type-meta.js +1 -0
  40. package/dist/server/helpers.js +2 -2
  41. package/dist/server/index.js +3 -0
  42. package/dist/server/logger.js +2 -2
  43. package/dist/server/manuscript/assemble.js +128 -0
  44. package/dist/server/manuscript/index.js +35 -0
  45. package/dist/server/manuscript/load.js +65 -0
  46. package/dist/server/manuscript/parse.js +59 -0
  47. package/dist/server/manuscript/render/css.js +41 -0
  48. package/dist/server/manuscript/render/docx.js +10 -0
  49. package/dist/server/manuscript/render/epub.js +156 -0
  50. package/dist/server/manuscript/render/html.js +91 -0
  51. package/dist/server/manuscript/render/md.js +41 -0
  52. package/dist/server/manuscript/resolve.js +42 -0
  53. package/dist/server/manuscript-routes.js +78 -0
  54. package/dist/server/mcp.js +78 -4
  55. package/dist/server/state.js +1 -1
  56. package/dist/server/ws.js +8 -0
  57. package/package.json +15 -1
  58. package/skill/docs/footnotes.md +1 -1
  59. package/dist/client/assets/index-BBEdpqBq.js +0 -215
  60. package/dist/client/assets/index-Dz0iuWDM.css +0 -1
@@ -0,0 +1,215 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var q0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Dl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Wh={exports:{}},Ya={},Vh={exports:{}},Rt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var K0;function kM(){if(K0)return Rt;K0=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(A){return A===null||typeof A!="object"?null:(A=m&&A[m]||A["@@iterator"],typeof A=="function"?A:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,k={};function w(A,D,te){this.props=A,this.context=D,this.refs=k,this.updater=te||v}w.prototype.isReactComponent={},w.prototype.setState=function(A,D){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,D,"setState")},w.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function S(){}S.prototype=w.prototype;function N(A,D,te){this.props=A,this.context=D,this.refs=k,this.updater=te||v}var j=N.prototype=new S;j.constructor=N,x(j,w.prototype),j.isPureReactComponent=!0;var M=Array.isArray,_=Object.prototype.hasOwnProperty,R={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function $(A,D,te){var fe,we={},oe=null,Se=null;if(D!=null)for(fe in D.ref!==void 0&&(Se=D.ref),D.key!==void 0&&(oe=""+D.key),D)_.call(D,fe)&&!L.hasOwnProperty(fe)&&(we[fe]=D[fe]);var Ee=arguments.length-2;if(Ee===1)we.children=te;else if(1<Ee){for(var Le=Array(Ee),Ie=0;Ie<Ee;Ie++)Le[Ie]=arguments[Ie+2];we.children=Le}if(A&&A.defaultProps)for(fe in Ee=A.defaultProps,Ee)we[fe]===void 0&&(we[fe]=Ee[fe]);return{$$typeof:t,type:A,key:oe,ref:Se,props:we,_owner:R.current}}function B(A,D){return{$$typeof:t,type:A.type,key:D,ref:A.ref,props:A.props,_owner:A._owner}}function F(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function K(A){var D={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(te){return D[te]})}var z=/\/+/g;function ee(A,D){return typeof A=="object"&&A!==null&&A.key!=null?K(""+A.key):D.toString(36)}function P(A,D,te,fe,we){var oe=typeof A;(oe==="undefined"||oe==="boolean")&&(A=null);var Se=!1;if(A===null)Se=!0;else switch(oe){case"string":case"number":Se=!0;break;case"object":switch(A.$$typeof){case t:case e:Se=!0}}if(Se)return Se=A,we=we(Se),A=fe===""?"."+ee(Se,0):fe,M(we)?(te="",A!=null&&(te=A.replace(z,"$&/")+"/"),P(we,D,te,"",function(Ie){return Ie})):we!=null&&(F(we)&&(we=B(we,te+(!we.key||Se&&Se.key===we.key?"":(""+we.key).replace(z,"$&/")+"/")+A)),D.push(we)),1;if(Se=0,fe=fe===""?".":fe+":",M(A))for(var Ee=0;Ee<A.length;Ee++){oe=A[Ee];var Le=fe+ee(oe,Ee);Se+=P(oe,D,te,Le,we)}else if(Le=g(A),typeof Le=="function")for(A=Le.call(A),Ee=0;!(oe=A.next()).done;)oe=oe.value,Le=fe+ee(oe,Ee++),Se+=P(oe,D,te,Le,we);else if(oe==="object")throw D=String(A),Error("Objects are not valid as a React child (found: "+(D==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":D)+"). If you meant to render a collection of children, use an array instead.");return Se}function U(A,D,te){if(A==null)return A;var fe=[],we=0;return P(A,fe,"","",function(oe){return D.call(te,oe,we++)}),fe}function J(A){if(A._status===-1){var D=A._result;D=D(),D.then(function(te){(A._status===0||A._status===-1)&&(A._status=1,A._result=te)},function(te){(A._status===0||A._status===-1)&&(A._status=2,A._result=te)}),A._status===-1&&(A._status=0,A._result=D)}if(A._status===1)return A._result.default;throw A._result}var ie={current:null},q={transition:null},ue={ReactCurrentDispatcher:ie,ReactCurrentBatchConfig:q,ReactCurrentOwner:R};function Y(){throw Error("act(...) is not supported in production builds of React.")}return Rt.Children={map:U,forEach:function(A,D,te){U(A,function(){D.apply(this,arguments)},te)},count:function(A){var D=0;return U(A,function(){D++}),D},toArray:function(A){return U(A,function(D){return D})||[]},only:function(A){if(!F(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},Rt.Component=w,Rt.Fragment=n,Rt.Profiler=s,Rt.PureComponent=N,Rt.StrictMode=r,Rt.Suspense=d,Rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ue,Rt.act=Y,Rt.cloneElement=function(A,D,te){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var fe=x({},A.props),we=A.key,oe=A.ref,Se=A._owner;if(D!=null){if(D.ref!==void 0&&(oe=D.ref,Se=R.current),D.key!==void 0&&(we=""+D.key),A.type&&A.type.defaultProps)var Ee=A.type.defaultProps;for(Le in D)_.call(D,Le)&&!L.hasOwnProperty(Le)&&(fe[Le]=D[Le]===void 0&&Ee!==void 0?Ee[Le]:D[Le])}var Le=arguments.length-2;if(Le===1)fe.children=te;else if(1<Le){Ee=Array(Le);for(var Ie=0;Ie<Le;Ie++)Ee[Ie]=arguments[Ie+2];fe.children=Ee}return{$$typeof:t,type:A.type,key:we,ref:oe,props:fe,_owner:Se}},Rt.createContext=function(A){return A={$$typeof:o,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:i,_context:A},A.Consumer=A},Rt.createElement=$,Rt.createFactory=function(A){var D=$.bind(null,A);return D.type=A,D},Rt.createRef=function(){return{current:null}},Rt.forwardRef=function(A){return{$$typeof:c,render:A}},Rt.isValidElement=F,Rt.lazy=function(A){return{$$typeof:h,_payload:{_status:-1,_result:A},_init:J}},Rt.memo=function(A,D){return{$$typeof:f,type:A,compare:D===void 0?null:D}},Rt.startTransition=function(A){var D=q.transition;q.transition={};try{A()}finally{q.transition=D}},Rt.unstable_act=Y,Rt.useCallback=function(A,D){return ie.current.useCallback(A,D)},Rt.useContext=function(A){return ie.current.useContext(A)},Rt.useDebugValue=function(){},Rt.useDeferredValue=function(A){return ie.current.useDeferredValue(A)},Rt.useEffect=function(A,D){return ie.current.useEffect(A,D)},Rt.useId=function(){return ie.current.useId()},Rt.useImperativeHandle=function(A,D,te){return ie.current.useImperativeHandle(A,D,te)},Rt.useInsertionEffect=function(A,D){return ie.current.useInsertionEffect(A,D)},Rt.useLayoutEffect=function(A,D){return ie.current.useLayoutEffect(A,D)},Rt.useMemo=function(A,D){return ie.current.useMemo(A,D)},Rt.useReducer=function(A,D,te){return ie.current.useReducer(A,D,te)},Rt.useRef=function(A){return ie.current.useRef(A)},Rt.useState=function(A){return ie.current.useState(A)},Rt.useSyncExternalStore=function(A,D,te){return ie.current.useSyncExternalStore(A,D,te)},Rt.useTransition=function(){return ie.current.useTransition()},Rt.version="18.3.1",Rt}var G0;function Pl(){return G0||(G0=1,Vh.exports=kM()),Vh.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var J0;function SM(){if(J0)return Ya;J0=1;var t=Pl(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(c,d,f){var h,m={},g=null,v=null;f!==void 0&&(g=""+f),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(v=d.ref);for(h in d)r.call(d,h)&&!i.hasOwnProperty(h)&&(m[h]=d[h]);if(c&&c.defaultProps)for(h in d=c.defaultProps,d)m[h]===void 0&&(m[h]=d[h]);return{$$typeof:e,type:c,key:g,ref:v,props:m,_owner:s.current}}return Ya.Fragment=n,Ya.jsx=o,Ya.jsxs=o,Ya}var Y0;function EM(){return Y0||(Y0=1,Wh.exports=SM()),Wh.exports}var l=EM(),y=Pl();const Ri=Dl(y);var Xc={},qh={exports:{}},Sr={},Kh={exports:{}},Gh={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var X0;function NM(){return X0||(X0=1,(function(t){function e(q,ue){var Y=q.length;q.push(ue);e:for(;0<Y;){var A=Y-1>>>1,D=q[A];if(0<s(D,ue))q[A]=ue,q[Y]=D,Y=A;else break e}}function n(q){return q.length===0?null:q[0]}function r(q){if(q.length===0)return null;var ue=q[0],Y=q.pop();if(Y!==ue){q[0]=Y;e:for(var A=0,D=q.length,te=D>>>1;A<te;){var fe=2*(A+1)-1,we=q[fe],oe=fe+1,Se=q[oe];if(0>s(we,Y))oe<D&&0>s(Se,we)?(q[A]=Se,q[oe]=Y,A=oe):(q[A]=we,q[fe]=Y,A=fe);else if(oe<D&&0>s(Se,Y))q[A]=Se,q[oe]=Y,A=oe;else break e}}return ue}function s(q,ue){var Y=q.sortIndex-ue.sortIndex;return Y!==0?Y:q.id-ue.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,c=o.now();t.unstable_now=function(){return o.now()-c}}var d=[],f=[],h=1,m=null,g=3,v=!1,x=!1,k=!1,w=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(q){for(var ue=n(f);ue!==null;){if(ue.callback===null)r(f);else if(ue.startTime<=q)r(f),ue.sortIndex=ue.expirationTime,e(d,ue);else break;ue=n(f)}}function M(q){if(k=!1,j(q),!x)if(n(d)!==null)x=!0,J(_);else{var ue=n(f);ue!==null&&ie(M,ue.startTime-q)}}function _(q,ue){x=!1,k&&(k=!1,S($),$=-1),v=!0;var Y=g;try{for(j(ue),m=n(d);m!==null&&(!(m.expirationTime>ue)||q&&!K());){var A=m.callback;if(typeof A=="function"){m.callback=null,g=m.priorityLevel;var D=A(m.expirationTime<=ue);ue=t.unstable_now(),typeof D=="function"?m.callback=D:m===n(d)&&r(d),j(ue)}else r(d);m=n(d)}if(m!==null)var te=!0;else{var fe=n(f);fe!==null&&ie(M,fe.startTime-ue),te=!1}return te}finally{m=null,g=Y,v=!1}}var R=!1,L=null,$=-1,B=5,F=-1;function K(){return!(t.unstable_now()-F<B)}function z(){if(L!==null){var q=t.unstable_now();F=q;var ue=!0;try{ue=L(!0,q)}finally{ue?ee():(R=!1,L=null)}}else R=!1}var ee;if(typeof N=="function")ee=function(){N(z)};else if(typeof MessageChannel<"u"){var P=new MessageChannel,U=P.port2;P.port1.onmessage=z,ee=function(){U.postMessage(null)}}else ee=function(){w(z,0)};function J(q){L=q,R||(R=!0,ee())}function ie(q,ue){$=w(function(){q(t.unstable_now())},ue)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_continueExecution=function(){x||v||(x=!0,J(_))},t.unstable_forceFrameRate=function(q){0>q||125<q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<q?Math.floor(1e3/q):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(d)},t.unstable_next=function(q){switch(g){case 1:case 2:case 3:var ue=3;break;default:ue=g}var Y=g;g=ue;try{return q()}finally{g=Y}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(q,ue){switch(q){case 1:case 2:case 3:case 4:case 5:break;default:q=3}var Y=g;g=q;try{return ue()}finally{g=Y}},t.unstable_scheduleCallback=function(q,ue,Y){var A=t.unstable_now();switch(typeof Y=="object"&&Y!==null?(Y=Y.delay,Y=typeof Y=="number"&&0<Y?A+Y:A):Y=A,q){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=Y+D,q={id:h++,callback:ue,priorityLevel:q,startTime:Y,expirationTime:D,sortIndex:-1},Y>A?(q.sortIndex=Y,e(f,q),n(d)===null&&q===n(f)&&(k?(S($),$=-1):k=!0,ie(M,Y-A))):(q.sortIndex=D,e(d,q),x||v||(x=!0,J(_))),q},t.unstable_shouldYield=K,t.unstable_wrapCallback=function(q){var ue=g;return function(){var Y=g;g=ue;try{return q.apply(this,arguments)}finally{g=Y}}}})(Gh)),Gh}var Q0;function CM(){return Q0||(Q0=1,Kh.exports=NM()),Kh.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var Z0;function _M(){if(Z0)return Sr;Z0=1;var t=Pl(),e=CM();function n(a){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+a,p=1;p<arguments.length;p++)u+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+a+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function i(a,u){o(a,u),o(a+"Capture",u)}function o(a,u){for(s[a]=u,a=0;a<u.length;a++)r.add(u[a])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},m={};function g(a){return d.call(m,a)?!0:d.call(h,a)?!1:f.test(a)?m[a]=!0:(h[a]=!0,!1)}function v(a,u,p,b){if(p!==null&&p.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return b?!1:p!==null?!p.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function x(a,u,p,b){if(u===null||typeof u>"u"||v(a,u,p,b))return!0;if(b)return!1;if(p!==null)switch(p.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function k(a,u,p,b,E,C,O){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=b,this.attributeNamespace=E,this.mustUseProperty=p,this.propertyName=a,this.type=u,this.sanitizeURL=C,this.removeEmptyString=O}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){w[a]=new k(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var u=a[0];w[u]=new k(u,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){w[a]=new k(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){w[a]=new k(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){w[a]=new k(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){w[a]=new k(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){w[a]=new k(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){w[a]=new k(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){w[a]=new k(a,5,!1,a.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function N(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var u=a.replace(S,N);w[u]=new k(u,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var u=a.replace(S,N);w[u]=new k(u,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var u=a.replace(S,N);w[u]=new k(u,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!1,!1)}),w.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!0,!0)});function j(a,u,p,b){var E=w.hasOwnProperty(u)?w[u]:null;(E!==null?E.type!==0:b||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(x(u,p,E,b)&&(p=null),b||E===null?g(u)&&(p===null?a.removeAttribute(u):a.setAttribute(u,""+p)):E.mustUseProperty?a[E.propertyName]=p===null?E.type===3?!1:"":p:(u=E.attributeName,b=E.attributeNamespace,p===null?a.removeAttribute(u):(E=E.type,p=E===3||E===4&&p===!0?"":""+p,b?a.setAttributeNS(b,u,p):a.setAttribute(u,p))))}var M=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),R=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),K=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),ie=Symbol.for("react.offscreen"),q=Symbol.iterator;function ue(a){return a===null||typeof a!="object"?null:(a=q&&a[q]||a["@@iterator"],typeof a=="function"?a:null)}var Y=Object.assign,A;function D(a){if(A===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);A=u&&u[1]||""}return`
34
+ `+A+a}var te=!1;function fe(a,u){if(!a||te)return"";te=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(pe){var b=pe}Reflect.construct(a,[],u)}else{try{u.call()}catch(pe){b=pe}a.call(u.prototype)}else{try{throw Error()}catch(pe){b=pe}a()}}catch(pe){if(pe&&b&&typeof pe.stack=="string"){for(var E=pe.stack.split(`
35
+ `),C=b.stack.split(`
36
+ `),O=E.length-1,H=C.length-1;1<=O&&0<=H&&E[O]!==C[H];)H--;for(;1<=O&&0<=H;O--,H--)if(E[O]!==C[H]){if(O!==1||H!==1)do if(O--,H--,0>H||E[O]!==C[H]){var Q=`
37
+ `+E[O].replace(" at new "," at ");return a.displayName&&Q.includes("<anonymous>")&&(Q=Q.replace("<anonymous>",a.displayName)),Q}while(1<=O&&0<=H);break}}}finally{te=!1,Error.prepareStackTrace=p}return(a=a?a.displayName||a.name:"")?D(a):""}function we(a){switch(a.tag){case 5:return D(a.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return a=fe(a.type,!1),a;case 11:return a=fe(a.type.render,!1),a;case 1:return a=fe(a.type,!0),a;default:return""}}function oe(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case L:return"Fragment";case R:return"Portal";case B:return"Profiler";case $:return"StrictMode";case ee:return"Suspense";case P:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case K:return(a.displayName||"Context")+".Consumer";case F:return(a._context.displayName||"Context")+".Provider";case z:var u=a.render;return a=a.displayName,a||(a=u.displayName||u.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case U:return u=a.displayName||null,u!==null?u:oe(a.type)||"Memo";case J:u=a._payload,a=a._init;try{return oe(a(u))}catch{}}return null}function Se(a){var u=a.type;switch(a.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=u.render,a=a.displayName||a.name||"",u.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return oe(u);case 8:return u===$?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function Ee(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function Le(a){var u=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function Ie(a){var u=Le(a)?"checked":"value",p=Object.getOwnPropertyDescriptor(a.constructor.prototype,u),b=""+a[u];if(!a.hasOwnProperty(u)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var E=p.get,C=p.set;return Object.defineProperty(a,u,{configurable:!0,get:function(){return E.call(this)},set:function(O){b=""+O,C.call(this,O)}}),Object.defineProperty(a,u,{enumerable:p.enumerable}),{getValue:function(){return b},setValue:function(O){b=""+O},stopTracking:function(){a._valueTracker=null,delete a[u]}}}}function Ve(a){a._valueTracker||(a._valueTracker=Ie(a))}function Te(a){if(!a)return!1;var u=a._valueTracker;if(!u)return!0;var p=u.getValue(),b="";return a&&(b=Le(a)?a.checked?"true":"false":a.value),a=b,a!==p?(u.setValue(a),!0):!1}function qe(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function pt(a,u){var p=u.checked;return Y({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??a._wrapperState.initialChecked})}function ut(a,u){var p=u.defaultValue==null?"":u.defaultValue,b=u.checked!=null?u.checked:u.defaultChecked;p=Ee(u.value!=null?u.value:p),a._wrapperState={initialChecked:b,initialValue:p,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function be(a,u){u=u.checked,u!=null&&j(a,"checked",u,!1)}function ht(a,u){be(a,u);var p=Ee(u.value),b=u.type;if(p!=null)b==="number"?(p===0&&a.value===""||a.value!=p)&&(a.value=""+p):a.value!==""+p&&(a.value=""+p);else if(b==="submit"||b==="reset"){a.removeAttribute("value");return}u.hasOwnProperty("value")?St(a,u.type,p):u.hasOwnProperty("defaultValue")&&St(a,u.type,Ee(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(a.defaultChecked=!!u.defaultChecked)}function xt(a,u,p){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var b=u.type;if(!(b!=="submit"&&b!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+a._wrapperState.initialValue,p||u===a.value||(a.value=u),a.defaultValue=u}p=a.name,p!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,p!==""&&(a.name=p)}function St(a,u,p){(u!=="number"||qe(a.ownerDocument)!==a)&&(p==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+p&&(a.defaultValue=""+p))}var At=Array.isArray;function Ye(a,u,p,b){if(a=a.options,u){u={};for(var E=0;E<p.length;E++)u["$"+p[E]]=!0;for(p=0;p<a.length;p++)E=u.hasOwnProperty("$"+a[p].value),a[p].selected!==E&&(a[p].selected=E),E&&b&&(a[p].defaultSelected=!0)}else{for(p=""+Ee(p),u=null,E=0;E<a.length;E++){if(a[E].value===p){a[E].selected=!0,b&&(a[E].defaultSelected=!0);return}u!==null||a[E].disabled||(u=a[E])}u!==null&&(u.selected=!0)}}function ct(a,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return Y({},u,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function Fe(a,u){var p=u.value;if(p==null){if(p=u.children,u=u.defaultValue,p!=null){if(u!=null)throw Error(n(92));if(At(p)){if(1<p.length)throw Error(n(93));p=p[0]}u=p}u==null&&(u=""),p=u}a._wrapperState={initialValue:Ee(p)}}function G(a,u){var p=Ee(u.value),b=Ee(u.defaultValue);p!=null&&(p=""+p,p!==a.value&&(a.value=p),u.defaultValue==null&&a.defaultValue!==p&&(a.defaultValue=p)),b!=null&&(a.defaultValue=""+b)}function ge(a){var u=a.textContent;u===a._wrapperState.initialValue&&u!==""&&u!==null&&(a.value=u)}function ne(a){switch(a){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function he(a,u){return a==null||a==="http://www.w3.org/1999/xhtml"?ne(u):a==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var me,ze=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,p,b,E){MSApp.execUnsafeLocalFunction(function(){return a(u,p,b,E)})}:a})(function(a,u){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=u;else{for(me=me||document.createElement("div"),me.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=me.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;u.firstChild;)a.appendChild(u.firstChild)}});function Ae(a,u){if(u){var p=a.firstChild;if(p&&p===a.lastChild&&p.nodeType===3){p.nodeValue=u;return}}a.textContent=u}var Xe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Qe=["Webkit","ms","Moz","O"];Object.keys(Xe).forEach(function(a){Qe.forEach(function(u){u=u+a.charAt(0).toUpperCase()+a.substring(1),Xe[u]=Xe[a]})});function tt(a,u,p){return u==null||typeof u=="boolean"||u===""?"":p||typeof u!="number"||u===0||Xe.hasOwnProperty(a)&&Xe[a]?(""+u).trim():u+"px"}function We(a,u){a=a.style;for(var p in u)if(u.hasOwnProperty(p)){var b=p.indexOf("--")===0,E=tt(p,u[p],b);p==="float"&&(p="cssFloat"),b?a.setProperty(p,E):a[p]=E}}var Ue=Y({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function st(a,u){if(u){if(Ue[a]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function mt(a,u){if(a.indexOf("-")===-1)return typeof u.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Nt=null;function Mt(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Jt=null,nn=null,at=null;function Ht(a){if(a=La(a)){if(typeof Jt!="function")throw Error(n(280));var u=a.stateNode;u&&(u=fc(u),Jt(a.stateNode,a.type,u))}}function T(a){nn?at?at.push(a):at=[a]:nn=a}function W(){if(nn){var a=nn,u=at;if(at=nn=null,Ht(a),u)for(a=0;a<u.length;a++)Ht(u[a])}}function ae(a,u){return a(u)}function I(){}var V=!1;function re(a,u,p){if(V)return a(u,p);V=!0;try{return ae(a,u,p)}finally{V=!1,(nn!==null||at!==null)&&(I(),W())}}function X(a,u){var p=a.stateNode;if(p===null)return null;var b=fc(p);if(b===null)return null;p=b[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(b=!b.disabled)||(a=a.type,b=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!b;break e;default:a=!1}if(a)return null;if(p&&typeof p!="function")throw Error(n(231,u,typeof p));return p}var le=!1;if(c)try{var ve={};Object.defineProperty(ve,"passive",{get:function(){le=!0}}),window.addEventListener("test",ve,ve),window.removeEventListener("test",ve,ve)}catch{le=!1}function Re(a,u,p,b,E,C,O,H,Q){var pe=Array.prototype.slice.call(arguments,3);try{u.apply(p,pe)}catch(Ce){this.onError(Ce)}}var ye=!1,Dt=null,Et=!1,dn=null,Xt={onError:function(a){ye=!0,Dt=a}};function ln(a,u,p,b,E,C,O,H,Q){ye=!1,Dt=null,Re.apply(Xt,arguments)}function $e(a,u,p,b,E,C,O,H,Q){if(ln.apply(this,arguments),ye){if(ye){var pe=Dt;ye=!1,Dt=null}else throw Error(n(198));Et||(Et=!0,dn=pe)}}function zt(a){var u=a,p=a;if(a.alternate)for(;u.return;)u=u.return;else{a=u;do u=a,(u.flags&4098)!==0&&(p=u.return),a=u.return;while(a)}return u.tag===3?p:null}function qn(a){if(a.tag===13){var u=a.memoizedState;if(u===null&&(a=a.alternate,a!==null&&(u=a.memoizedState)),u!==null)return u.dehydrated}return null}function fn(a){if(zt(a)!==a)throw Error(n(188))}function gr(a){var u=a.alternate;if(!u){if(u=zt(a),u===null)throw Error(n(188));return u!==a?null:a}for(var p=a,b=u;;){var E=p.return;if(E===null)break;var C=E.alternate;if(C===null){if(b=E.return,b!==null){p=b;continue}break}if(E.child===C.child){for(C=E.child;C;){if(C===p)return fn(E),a;if(C===b)return fn(E),u;C=C.sibling}throw Error(n(188))}if(p.return!==b.return)p=E,b=C;else{for(var O=!1,H=E.child;H;){if(H===p){O=!0,p=E,b=C;break}if(H===b){O=!0,b=E,p=C;break}H=H.sibling}if(!O){for(H=C.child;H;){if(H===p){O=!0,p=C,b=E;break}if(H===b){O=!0,b=C,p=E;break}H=H.sibling}if(!O)throw Error(n(189))}}if(p.alternate!==b)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?a:u}function vr(a){return a=gr(a),a!==null?_r(a):null}function _r(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var u=_r(a);if(u!==null)return u;a=a.sibling}return null}var hn=e.unstable_scheduleCallback,An=e.unstable_cancelCallback,ur=e.unstable_shouldYield,Xs=e.unstable_requestPaint,Wt=e.unstable_now,Ts=e.unstable_getCurrentPriorityLevel,Qr=e.unstable_ImmediatePriority,Kn=e.unstable_UserBlockingPriority,js=e.unstable_NormalPriority,je=e.unstable_LowPriority,et=e.unstable_IdlePriority,wt=null,kt=null;function Qt(a){if(kt&&typeof kt.onCommitFiberRoot=="function")try{kt.onCommitFiberRoot(wt,a,void 0,(a.current.flags&128)===128)}catch{}}var Zt=Math.clz32?Math.clz32:In,Tr=Math.log,Qs=Math.LN2;function In(a){return a>>>=0,a===0?32:31-(Tr(a)/Qs|0)|0}var Ln=64,ms=4194304;function Zr(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function Z(a,u){var p=a.pendingLanes;if(p===0)return 0;var b=0,E=a.suspendedLanes,C=a.pingedLanes,O=p&268435455;if(O!==0){var H=O&~E;H!==0?b=Zr(H):(C&=O,C!==0&&(b=Zr(C)))}else O=p&~E,O!==0?b=Zr(O):C!==0&&(b=Zr(C));if(b===0)return 0;if(u!==0&&u!==b&&(u&E)===0&&(E=b&-b,C=u&-u,E>=C||E===16&&(C&4194240)!==0))return u;if((b&4)!==0&&(b|=p&16),u=a.entangledLanes,u!==0)for(a=a.entanglements,u&=b;0<u;)p=31-Zt(u),E=1<<p,b|=a[p],u&=~E;return b}function xe(a,u){switch(a){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function De(a,u){for(var p=a.suspendedLanes,b=a.pingedLanes,E=a.expirationTimes,C=a.pendingLanes;0<C;){var O=31-Zt(C),H=1<<O,Q=E[O];Q===-1?((H&p)===0||(H&b)!==0)&&(E[O]=xe(H,u)):Q<=u&&(a.expiredLanes|=H),C&=~H}}function bt(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Ct(){var a=Ln;return Ln<<=1,(Ln&4194240)===0&&(Ln=64),a}function wn(a){for(var u=[],p=0;31>p;p++)u.push(a);return u}function Cn(a,u,p){a.pendingLanes|=u,u!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,u=31-Zt(u),a[u]=p}function _n(a,u){var p=a.pendingLanes&~u;a.pendingLanes=u,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=u,a.mutableReadLanes&=u,a.entangledLanes&=u,u=a.entanglements;var b=a.eventTimes;for(a=a.expirationTimes;0<p;){var E=31-Zt(p),C=1<<E;u[E]=0,b[E]=-1,a[E]=-1,p&=~C}}function Dn(a,u){var p=a.entangledLanes|=u;for(a=a.entanglements;p;){var b=31-Zt(p),E=1<<b;E&u|a[b]&u&&(a[b]|=u),p&=~E}}var _t=0;function rt(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var es,kn,Kt,Ui,gs,Hi=!1,Zs=[],Pe=null,Ke=null,vt=null,It=new Map,pn=new Map,Pn=[],mf="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Xl(a,u){switch(a){case"focusin":case"focusout":Pe=null;break;case"dragenter":case"dragleave":Ke=null;break;case"mouseover":case"mouseout":vt=null;break;case"pointerover":case"pointerout":It.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":pn.delete(u.pointerId)}}function wa(a,u,p,b,E,C){return a===null||a.nativeEvent!==C?(a={blockedOn:u,domEventName:p,eventSystemFlags:b,nativeEvent:C,targetContainers:[E]},u!==null&&(u=La(u),u!==null&&kn(u)),a):(a.eventSystemFlags|=b,u=a.targetContainers,E!==null&&u.indexOf(E)===-1&&u.push(E),a)}function V2(a,u,p,b,E){switch(u){case"focusin":return Pe=wa(Pe,a,u,p,b,E),!0;case"dragenter":return Ke=wa(Ke,a,u,p,b,E),!0;case"mouseover":return vt=wa(vt,a,u,p,b,E),!0;case"pointerover":var C=E.pointerId;return It.set(C,wa(It.get(C)||null,a,u,p,b,E)),!0;case"gotpointercapture":return C=E.pointerId,pn.set(C,wa(pn.get(C)||null,a,u,p,b,E)),!0}return!1}function Mb(a){var u=Wi(a.target);if(u!==null){var p=zt(u);if(p!==null){if(u=p.tag,u===13){if(u=qn(p),u!==null){a.blockedOn=u,gs(a.priority,function(){Kt(p)});return}}else if(u===3&&p.stateNode.current.memoizedState.isDehydrated){a.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Ql(a){if(a.blockedOn!==null)return!1;for(var u=a.targetContainers;0<u.length;){var p=vf(a.domEventName,a.eventSystemFlags,u[0],a.nativeEvent);if(p===null){p=a.nativeEvent;var b=new p.constructor(p.type,p);Nt=b,p.target.dispatchEvent(b),Nt=null}else return u=La(p),u!==null&&kn(u),a.blockedOn=p,!1;u.shift()}return!0}function Ab(a,u,p){Ql(a)&&p.delete(u)}function q2(){Hi=!1,Pe!==null&&Ql(Pe)&&(Pe=null),Ke!==null&&Ql(Ke)&&(Ke=null),vt!==null&&Ql(vt)&&(vt=null),It.forEach(Ab),pn.forEach(Ab)}function ka(a,u){a.blockedOn===u&&(a.blockedOn=null,Hi||(Hi=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,q2)))}function Sa(a){function u(E){return ka(E,a)}if(0<Zs.length){ka(Zs[0],a);for(var p=1;p<Zs.length;p++){var b=Zs[p];b.blockedOn===a&&(b.blockedOn=null)}}for(Pe!==null&&ka(Pe,a),Ke!==null&&ka(Ke,a),vt!==null&&ka(vt,a),It.forEach(u),pn.forEach(u),p=0;p<Pn.length;p++)b=Pn[p],b.blockedOn===a&&(b.blockedOn=null);for(;0<Pn.length&&(p=Pn[0],p.blockedOn===null);)Mb(p),p.blockedOn===null&&Pn.shift()}var To=M.ReactCurrentBatchConfig,Zl=!0;function K2(a,u,p,b){var E=_t,C=To.transition;To.transition=null;try{_t=1,gf(a,u,p,b)}finally{_t=E,To.transition=C}}function G2(a,u,p,b){var E=_t,C=To.transition;To.transition=null;try{_t=4,gf(a,u,p,b)}finally{_t=E,To.transition=C}}function gf(a,u,p,b){if(Zl){var E=vf(a,u,p,b);if(E===null)If(a,u,b,ec,p),Xl(a,b);else if(V2(E,a,u,p,b))b.stopPropagation();else if(Xl(a,b),u&4&&-1<mf.indexOf(a)){for(;E!==null;){var C=La(E);if(C!==null&&es(C),C=vf(a,u,p,b),C===null&&If(a,u,b,ec,p),C===E)break;E=C}E!==null&&b.stopPropagation()}else If(a,u,b,null,p)}}var ec=null;function vf(a,u,p,b){if(ec=null,a=Mt(b),a=Wi(a),a!==null)if(u=zt(a),u===null)a=null;else if(p=u.tag,p===13){if(a=qn(u),a!==null)return a;a=null}else if(p===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;a=null}else u!==a&&(a=null);return ec=a,null}function Rb(a){switch(a){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ts()){case Qr:return 1;case Kn:return 4;case js:case je:return 16;case et:return 536870912;default:return 16}default:return 16}}var ei=null,bf=null,tc=null;function Ob(){if(tc)return tc;var a,u=bf,p=u.length,b,E="value"in ei?ei.value:ei.textContent,C=E.length;for(a=0;a<p&&u[a]===E[a];a++);var O=p-a;for(b=1;b<=O&&u[p-b]===E[C-b];b++);return tc=E.slice(a,1<b?1-b:void 0)}function nc(a){var u=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&u===13&&(a=13)):a=u,a===10&&(a=13),32<=a||a===13?a:0}function rc(){return!0}function Ib(){return!1}function jr(a){function u(p,b,E,C,O){this._reactName=p,this._targetInst=E,this.type=b,this.nativeEvent=C,this.target=O,this.currentTarget=null;for(var H in a)a.hasOwnProperty(H)&&(p=a[H],this[H]=p?p(C):C[H]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?rc:Ib,this.isPropagationStopped=Ib,this}return Y(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=rc)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=rc)},persist:function(){},isPersistent:rc}),u}var jo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},yf=jr(jo),Ea=Y({},jo,{view:0,detail:0}),J2=jr(Ea),xf,wf,Na,sc=Y({},Ea,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Sf,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Na&&(Na&&a.type==="mousemove"?(xf=a.screenX-Na.screenX,wf=a.screenY-Na.screenY):wf=xf=0,Na=a),xf)},movementY:function(a){return"movementY"in a?a.movementY:wf}}),Lb=jr(sc),Y2=Y({},sc,{dataTransfer:0}),X2=jr(Y2),Q2=Y({},Ea,{relatedTarget:0}),kf=jr(Q2),Z2=Y({},jo,{animationName:0,elapsedTime:0,pseudoElement:0}),ej=jr(Z2),tj=Y({},jo,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),nj=jr(tj),rj=Y({},jo,{data:0}),Db=jr(rj),sj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ij={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},oj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function aj(a){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(a):(a=oj[a])?!!u[a]:!1}function Sf(){return aj}var lj=Y({},Ea,{key:function(a){if(a.key){var u=sj[a.key]||a.key;if(u!=="Unidentified")return u}return a.type==="keypress"?(a=nc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?ij[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Sf,charCode:function(a){return a.type==="keypress"?nc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?nc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),cj=jr(lj),uj=Y({},sc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Pb=jr(uj),dj=Y({},Ea,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Sf}),fj=jr(dj),hj=Y({},jo,{propertyName:0,elapsedTime:0,pseudoElement:0}),pj=jr(hj),mj=Y({},sc,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),gj=jr(mj),vj=[9,13,27,32],Ef=c&&"CompositionEvent"in window,Ca=null;c&&"documentMode"in document&&(Ca=document.documentMode);var bj=c&&"TextEvent"in window&&!Ca,Bb=c&&(!Ef||Ca&&8<Ca&&11>=Ca),$b=" ",Fb=!1;function zb(a,u){switch(a){case"keyup":return vj.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ub(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Mo=!1;function yj(a,u){switch(a){case"compositionend":return Ub(u);case"keypress":return u.which!==32?null:(Fb=!0,$b);case"textInput":return a=u.data,a===$b&&Fb?null:a;default:return null}}function xj(a,u){if(Mo)return a==="compositionend"||!Ef&&zb(a,u)?(a=Ob(),tc=bf=ei=null,Mo=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return Bb&&u.locale!=="ko"?null:u.data;default:return null}}var wj={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hb(a){var u=a&&a.nodeName&&a.nodeName.toLowerCase();return u==="input"?!!wj[a.type]:u==="textarea"}function Wb(a,u,p,b){T(b),u=cc(u,"onChange"),0<u.length&&(p=new yf("onChange","change",null,p,b),a.push({event:p,listeners:u}))}var _a=null,Ta=null;function kj(a){ly(a,0)}function ic(a){var u=Lo(a);if(Te(u))return a}function Sj(a,u){if(a==="change")return u}var Vb=!1;if(c){var Nf;if(c){var Cf="oninput"in document;if(!Cf){var qb=document.createElement("div");qb.setAttribute("oninput","return;"),Cf=typeof qb.oninput=="function"}Nf=Cf}else Nf=!1;Vb=Nf&&(!document.documentMode||9<document.documentMode)}function Kb(){_a&&(_a.detachEvent("onpropertychange",Gb),Ta=_a=null)}function Gb(a){if(a.propertyName==="value"&&ic(Ta)){var u=[];Wb(u,Ta,a,Mt(a)),re(kj,u)}}function Ej(a,u,p){a==="focusin"?(Kb(),_a=u,Ta=p,_a.attachEvent("onpropertychange",Gb)):a==="focusout"&&Kb()}function Nj(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return ic(Ta)}function Cj(a,u){if(a==="click")return ic(u)}function _j(a,u){if(a==="input"||a==="change")return ic(u)}function Tj(a,u){return a===u&&(a!==0||1/a===1/u)||a!==a&&u!==u}var ts=typeof Object.is=="function"?Object.is:Tj;function ja(a,u){if(ts(a,u))return!0;if(typeof a!="object"||a===null||typeof u!="object"||u===null)return!1;var p=Object.keys(a),b=Object.keys(u);if(p.length!==b.length)return!1;for(b=0;b<p.length;b++){var E=p[b];if(!d.call(u,E)||!ts(a[E],u[E]))return!1}return!0}function Jb(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Yb(a,u){var p=Jb(a);a=0;for(var b;p;){if(p.nodeType===3){if(b=a+p.textContent.length,a<=u&&b>=u)return{node:p,offset:u-a};a=b}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Jb(p)}}function Xb(a,u){return a&&u?a===u?!0:a&&a.nodeType===3?!1:u&&u.nodeType===3?Xb(a,u.parentNode):"contains"in a?a.contains(u):a.compareDocumentPosition?!!(a.compareDocumentPosition(u)&16):!1:!1}function Qb(){for(var a=window,u=qe();u instanceof a.HTMLIFrameElement;){try{var p=typeof u.contentWindow.location.href=="string"}catch{p=!1}if(p)a=u.contentWindow;else break;u=qe(a.document)}return u}function _f(a){var u=a&&a.nodeName&&a.nodeName.toLowerCase();return u&&(u==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||u==="textarea"||a.contentEditable==="true")}function jj(a){var u=Qb(),p=a.focusedElem,b=a.selectionRange;if(u!==p&&p&&p.ownerDocument&&Xb(p.ownerDocument.documentElement,p)){if(b!==null&&_f(p)){if(u=b.start,a=b.end,a===void 0&&(a=u),"selectionStart"in p)p.selectionStart=u,p.selectionEnd=Math.min(a,p.value.length);else if(a=(u=p.ownerDocument||document)&&u.defaultView||window,a.getSelection){a=a.getSelection();var E=p.textContent.length,C=Math.min(b.start,E);b=b.end===void 0?C:Math.min(b.end,E),!a.extend&&C>b&&(E=b,b=C,C=E),E=Yb(p,C);var O=Yb(p,b);E&&O&&(a.rangeCount!==1||a.anchorNode!==E.node||a.anchorOffset!==E.offset||a.focusNode!==O.node||a.focusOffset!==O.offset)&&(u=u.createRange(),u.setStart(E.node,E.offset),a.removeAllRanges(),C>b?(a.addRange(u),a.extend(O.node,O.offset)):(u.setEnd(O.node,O.offset),a.addRange(u)))}}for(u=[],a=p;a=a.parentNode;)a.nodeType===1&&u.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<u.length;p++)a=u[p],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var Mj=c&&"documentMode"in document&&11>=document.documentMode,Ao=null,Tf=null,Ma=null,jf=!1;function Zb(a,u,p){var b=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;jf||Ao==null||Ao!==qe(b)||(b=Ao,"selectionStart"in b&&_f(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Ma&&ja(Ma,b)||(Ma=b,b=cc(Tf,"onSelect"),0<b.length&&(u=new yf("onSelect","select",null,u,p),a.push({event:u,listeners:b}),u.target=Ao)))}function oc(a,u){var p={};return p[a.toLowerCase()]=u.toLowerCase(),p["Webkit"+a]="webkit"+u,p["Moz"+a]="moz"+u,p}var Ro={animationend:oc("Animation","AnimationEnd"),animationiteration:oc("Animation","AnimationIteration"),animationstart:oc("Animation","AnimationStart"),transitionend:oc("Transition","TransitionEnd")},Mf={},ey={};c&&(ey=document.createElement("div").style,"AnimationEvent"in window||(delete Ro.animationend.animation,delete Ro.animationiteration.animation,delete Ro.animationstart.animation),"TransitionEvent"in window||delete Ro.transitionend.transition);function ac(a){if(Mf[a])return Mf[a];if(!Ro[a])return a;var u=Ro[a],p;for(p in u)if(u.hasOwnProperty(p)&&p in ey)return Mf[a]=u[p];return a}var ty=ac("animationend"),ny=ac("animationiteration"),ry=ac("animationstart"),sy=ac("transitionend"),iy=new Map,oy="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ti(a,u){iy.set(a,u),i(u,[a])}for(var Af=0;Af<oy.length;Af++){var Rf=oy[Af],Aj=Rf.toLowerCase(),Rj=Rf[0].toUpperCase()+Rf.slice(1);ti(Aj,"on"+Rj)}ti(ty,"onAnimationEnd"),ti(ny,"onAnimationIteration"),ti(ry,"onAnimationStart"),ti("dblclick","onDoubleClick"),ti("focusin","onFocus"),ti("focusout","onBlur"),ti(sy,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Aa="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Oj=new Set("cancel close invalid load scroll toggle".split(" ").concat(Aa));function ay(a,u,p){var b=a.type||"unknown-event";a.currentTarget=p,$e(b,u,void 0,a),a.currentTarget=null}function ly(a,u){u=(u&4)!==0;for(var p=0;p<a.length;p++){var b=a[p],E=b.event;b=b.listeners;e:{var C=void 0;if(u)for(var O=b.length-1;0<=O;O--){var H=b[O],Q=H.instance,pe=H.currentTarget;if(H=H.listener,Q!==C&&E.isPropagationStopped())break e;ay(E,H,pe),C=Q}else for(O=0;O<b.length;O++){if(H=b[O],Q=H.instance,pe=H.currentTarget,H=H.listener,Q!==C&&E.isPropagationStopped())break e;ay(E,H,pe),C=Q}}}if(Et)throw a=dn,Et=!1,dn=null,a}function rn(a,u){var p=u[Ff];p===void 0&&(p=u[Ff]=new Set);var b=a+"__bubble";p.has(b)||(cy(u,a,2,!1),p.add(b))}function Of(a,u,p){var b=0;u&&(b|=4),cy(p,a,b,u)}var lc="_reactListening"+Math.random().toString(36).slice(2);function Ra(a){if(!a[lc]){a[lc]=!0,r.forEach(function(p){p!=="selectionchange"&&(Oj.has(p)||Of(p,!1,a),Of(p,!0,a))});var u=a.nodeType===9?a:a.ownerDocument;u===null||u[lc]||(u[lc]=!0,Of("selectionchange",!1,u))}}function cy(a,u,p,b){switch(Rb(u)){case 1:var E=K2;break;case 4:E=G2;break;default:E=gf}p=E.bind(null,u,p,a),E=void 0,!le||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(E=!0),b?E!==void 0?a.addEventListener(u,p,{capture:!0,passive:E}):a.addEventListener(u,p,!0):E!==void 0?a.addEventListener(u,p,{passive:E}):a.addEventListener(u,p,!1)}function If(a,u,p,b,E){var C=b;if((u&1)===0&&(u&2)===0&&b!==null)e:for(;;){if(b===null)return;var O=b.tag;if(O===3||O===4){var H=b.stateNode.containerInfo;if(H===E||H.nodeType===8&&H.parentNode===E)break;if(O===4)for(O=b.return;O!==null;){var Q=O.tag;if((Q===3||Q===4)&&(Q=O.stateNode.containerInfo,Q===E||Q.nodeType===8&&Q.parentNode===E))return;O=O.return}for(;H!==null;){if(O=Wi(H),O===null)return;if(Q=O.tag,Q===5||Q===6){b=C=O;continue e}H=H.parentNode}}b=b.return}re(function(){var pe=C,Ce=Mt(p),_e=[];e:{var Ne=iy.get(a);if(Ne!==void 0){var He=yf,Je=a;switch(a){case"keypress":if(nc(p)===0)break e;case"keydown":case"keyup":He=cj;break;case"focusin":Je="focus",He=kf;break;case"focusout":Je="blur",He=kf;break;case"beforeblur":case"afterblur":He=kf;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=Lb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=X2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=fj;break;case ty:case ny:case ry:He=ej;break;case sy:He=pj;break;case"scroll":He=J2;break;case"wheel":He=gj;break;case"copy":case"cut":case"paste":He=nj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=Pb}var Ze=(u&4)!==0,Sn=!Ze&&a==="scroll",ce=Ze?Ne!==null?Ne+"Capture":null:Ne;Ze=[];for(var se=pe,de;se!==null;){de=se;var Oe=de.stateNode;if(de.tag===5&&Oe!==null&&(de=Oe,ce!==null&&(Oe=X(se,ce),Oe!=null&&Ze.push(Oa(se,Oe,de)))),Sn)break;se=se.return}0<Ze.length&&(Ne=new He(Ne,Je,null,p,Ce),_e.push({event:Ne,listeners:Ze}))}}if((u&7)===0){e:{if(Ne=a==="mouseover"||a==="pointerover",He=a==="mouseout"||a==="pointerout",Ne&&p!==Nt&&(Je=p.relatedTarget||p.fromElement)&&(Wi(Je)||Je[Ms]))break e;if((He||Ne)&&(Ne=Ce.window===Ce?Ce:(Ne=Ce.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,He?(Je=p.relatedTarget||p.toElement,He=pe,Je=Je?Wi(Je):null,Je!==null&&(Sn=zt(Je),Je!==Sn||Je.tag!==5&&Je.tag!==6)&&(Je=null)):(He=null,Je=pe),He!==Je)){if(Ze=Lb,Oe="onMouseLeave",ce="onMouseEnter",se="mouse",(a==="pointerout"||a==="pointerover")&&(Ze=Pb,Oe="onPointerLeave",ce="onPointerEnter",se="pointer"),Sn=He==null?Ne:Lo(He),de=Je==null?Ne:Lo(Je),Ne=new Ze(Oe,se+"leave",He,p,Ce),Ne.target=Sn,Ne.relatedTarget=de,Oe=null,Wi(Ce)===pe&&(Ze=new Ze(ce,se+"enter",Je,p,Ce),Ze.target=de,Ze.relatedTarget=Sn,Oe=Ze),Sn=Oe,He&&Je)t:{for(Ze=He,ce=Je,se=0,de=Ze;de;de=Oo(de))se++;for(de=0,Oe=ce;Oe;Oe=Oo(Oe))de++;for(;0<se-de;)Ze=Oo(Ze),se--;for(;0<de-se;)ce=Oo(ce),de--;for(;se--;){if(Ze===ce||ce!==null&&Ze===ce.alternate)break t;Ze=Oo(Ze),ce=Oo(ce)}Ze=null}else Ze=null;He!==null&&uy(_e,Ne,He,Ze,!1),Je!==null&&Sn!==null&&uy(_e,Sn,Je,Ze,!0)}}e:{if(Ne=pe?Lo(pe):window,He=Ne.nodeName&&Ne.nodeName.toLowerCase(),He==="select"||He==="input"&&Ne.type==="file")var nt=Sj;else if(Hb(Ne))if(Vb)nt=_j;else{nt=Nj;var dt=Ej}else(He=Ne.nodeName)&&He.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(nt=Cj);if(nt&&(nt=nt(a,pe))){Wb(_e,nt,p,Ce);break e}dt&&dt(a,Ne,pe),a==="focusout"&&(dt=Ne._wrapperState)&&dt.controlled&&Ne.type==="number"&&St(Ne,"number",Ne.value)}switch(dt=pe?Lo(pe):window,a){case"focusin":(Hb(dt)||dt.contentEditable==="true")&&(Ao=dt,Tf=pe,Ma=null);break;case"focusout":Ma=Tf=Ao=null;break;case"mousedown":jf=!0;break;case"contextmenu":case"mouseup":case"dragend":jf=!1,Zb(_e,p,Ce);break;case"selectionchange":if(Mj)break;case"keydown":case"keyup":Zb(_e,p,Ce)}var ft;if(Ef)e:{switch(a){case"compositionstart":var yt="onCompositionStart";break e;case"compositionend":yt="onCompositionEnd";break e;case"compositionupdate":yt="onCompositionUpdate";break e}yt=void 0}else Mo?zb(a,p)&&(yt="onCompositionEnd"):a==="keydown"&&p.keyCode===229&&(yt="onCompositionStart");yt&&(Bb&&p.locale!=="ko"&&(Mo||yt!=="onCompositionStart"?yt==="onCompositionEnd"&&Mo&&(ft=Ob()):(ei=Ce,bf="value"in ei?ei.value:ei.textContent,Mo=!0)),dt=cc(pe,yt),0<dt.length&&(yt=new Db(yt,a,null,p,Ce),_e.push({event:yt,listeners:dt}),ft?yt.data=ft:(ft=Ub(p),ft!==null&&(yt.data=ft)))),(ft=bj?yj(a,p):xj(a,p))&&(pe=cc(pe,"onBeforeInput"),0<pe.length&&(Ce=new Db("onBeforeInput","beforeinput",null,p,Ce),_e.push({event:Ce,listeners:pe}),Ce.data=ft))}ly(_e,u)})}function Oa(a,u,p){return{instance:a,listener:u,currentTarget:p}}function cc(a,u){for(var p=u+"Capture",b=[];a!==null;){var E=a,C=E.stateNode;E.tag===5&&C!==null&&(E=C,C=X(a,p),C!=null&&b.unshift(Oa(a,C,E)),C=X(a,u),C!=null&&b.push(Oa(a,C,E))),a=a.return}return b}function Oo(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function uy(a,u,p,b,E){for(var C=u._reactName,O=[];p!==null&&p!==b;){var H=p,Q=H.alternate,pe=H.stateNode;if(Q!==null&&Q===b)break;H.tag===5&&pe!==null&&(H=pe,E?(Q=X(p,C),Q!=null&&O.unshift(Oa(p,Q,H))):E||(Q=X(p,C),Q!=null&&O.push(Oa(p,Q,H)))),p=p.return}O.length!==0&&a.push({event:u,listeners:O})}var Ij=/\r\n?/g,Lj=/\u0000|\uFFFD/g;function dy(a){return(typeof a=="string"?a:""+a).replace(Ij,`
38
+ `).replace(Lj,"")}function uc(a,u,p){if(u=dy(u),dy(a)!==u&&p)throw Error(n(425))}function dc(){}var Lf=null,Df=null;function Pf(a,u){return a==="textarea"||a==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var Bf=typeof setTimeout=="function"?setTimeout:void 0,Dj=typeof clearTimeout=="function"?clearTimeout:void 0,fy=typeof Promise=="function"?Promise:void 0,Pj=typeof queueMicrotask=="function"?queueMicrotask:typeof fy<"u"?function(a){return fy.resolve(null).then(a).catch(Bj)}:Bf;function Bj(a){setTimeout(function(){throw a})}function $f(a,u){var p=u,b=0;do{var E=p.nextSibling;if(a.removeChild(p),E&&E.nodeType===8)if(p=E.data,p==="/$"){if(b===0){a.removeChild(E),Sa(u);return}b--}else p!=="$"&&p!=="$?"&&p!=="$!"||b++;p=E}while(p);Sa(u)}function ni(a){for(;a!=null;a=a.nextSibling){var u=a.nodeType;if(u===1||u===3)break;if(u===8){if(u=a.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return a}function hy(a){a=a.previousSibling;for(var u=0;a;){if(a.nodeType===8){var p=a.data;if(p==="$"||p==="$!"||p==="$?"){if(u===0)return a;u--}else p==="/$"&&u++}a=a.previousSibling}return null}var Io=Math.random().toString(36).slice(2),vs="__reactFiber$"+Io,Ia="__reactProps$"+Io,Ms="__reactContainer$"+Io,Ff="__reactEvents$"+Io,$j="__reactListeners$"+Io,Fj="__reactHandles$"+Io;function Wi(a){var u=a[vs];if(u)return u;for(var p=a.parentNode;p;){if(u=p[Ms]||p[vs]){if(p=u.alternate,u.child!==null||p!==null&&p.child!==null)for(a=hy(a);a!==null;){if(p=a[vs])return p;a=hy(a)}return u}a=p,p=a.parentNode}return null}function La(a){return a=a[vs]||a[Ms],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Lo(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function fc(a){return a[Ia]||null}var zf=[],Do=-1;function ri(a){return{current:a}}function sn(a){0>Do||(a.current=zf[Do],zf[Do]=null,Do--)}function en(a,u){Do++,zf[Do]=a.current,a.current=u}var si={},nr=ri(si),br=ri(!1),Vi=si;function Po(a,u){var p=a.type.contextTypes;if(!p)return si;var b=a.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===u)return b.__reactInternalMemoizedMaskedChildContext;var E={},C;for(C in p)E[C]=u[C];return b&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=u,a.__reactInternalMemoizedMaskedChildContext=E),E}function yr(a){return a=a.childContextTypes,a!=null}function hc(){sn(br),sn(nr)}function py(a,u,p){if(nr.current!==si)throw Error(n(168));en(nr,u),en(br,p)}function my(a,u,p){var b=a.stateNode;if(u=u.childContextTypes,typeof b.getChildContext!="function")return p;b=b.getChildContext();for(var E in b)if(!(E in u))throw Error(n(108,Se(a)||"Unknown",E));return Y({},p,b)}function pc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||si,Vi=nr.current,en(nr,a),en(br,br.current),!0}function gy(a,u,p){var b=a.stateNode;if(!b)throw Error(n(169));p?(a=my(a,u,Vi),b.__reactInternalMemoizedMergedChildContext=a,sn(br),sn(nr),en(nr,a)):sn(br),en(br,p)}var As=null,mc=!1,Uf=!1;function vy(a){As===null?As=[a]:As.push(a)}function zj(a){mc=!0,vy(a)}function ii(){if(!Uf&&As!==null){Uf=!0;var a=0,u=_t;try{var p=As;for(_t=1;a<p.length;a++){var b=p[a];do b=b(!0);while(b!==null)}As=null,mc=!1}catch(E){throw As!==null&&(As=As.slice(a+1)),hn(Qr,ii),E}finally{_t=u,Uf=!1}}return null}var Bo=[],$o=0,gc=null,vc=0,Pr=[],Br=0,qi=null,Rs=1,Os="";function Ki(a,u){Bo[$o++]=vc,Bo[$o++]=gc,gc=a,vc=u}function by(a,u,p){Pr[Br++]=Rs,Pr[Br++]=Os,Pr[Br++]=qi,qi=a;var b=Rs;a=Os;var E=32-Zt(b)-1;b&=~(1<<E),p+=1;var C=32-Zt(u)+E;if(30<C){var O=E-E%5;C=(b&(1<<O)-1).toString(32),b>>=O,E-=O,Rs=1<<32-Zt(u)+E|p<<E|b,Os=C+a}else Rs=1<<C|p<<E|b,Os=a}function Hf(a){a.return!==null&&(Ki(a,1),by(a,1,0))}function Wf(a){for(;a===gc;)gc=Bo[--$o],Bo[$o]=null,vc=Bo[--$o],Bo[$o]=null;for(;a===qi;)qi=Pr[--Br],Pr[Br]=null,Os=Pr[--Br],Pr[Br]=null,Rs=Pr[--Br],Pr[Br]=null}var Mr=null,Ar=null,an=!1,ns=null;function yy(a,u){var p=Ur(5,null,null,0);p.elementType="DELETED",p.stateNode=u,p.return=a,u=a.deletions,u===null?(a.deletions=[p],a.flags|=16):u.push(p)}function xy(a,u){switch(a.tag){case 5:var p=a.type;return u=u.nodeType!==1||p.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(a.stateNode=u,Mr=a,Ar=ni(u.firstChild),!0):!1;case 6:return u=a.pendingProps===""||u.nodeType!==3?null:u,u!==null?(a.stateNode=u,Mr=a,Ar=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(p=qi!==null?{id:Rs,overflow:Os}:null,a.memoizedState={dehydrated:u,treeContext:p,retryLane:1073741824},p=Ur(18,null,null,0),p.stateNode=u,p.return=a,a.child=p,Mr=a,Ar=null,!0):!1;default:return!1}}function Vf(a){return(a.mode&1)!==0&&(a.flags&128)===0}function qf(a){if(an){var u=Ar;if(u){var p=u;if(!xy(a,u)){if(Vf(a))throw Error(n(418));u=ni(p.nextSibling);var b=Mr;u&&xy(a,u)?yy(b,p):(a.flags=a.flags&-4097|2,an=!1,Mr=a)}}else{if(Vf(a))throw Error(n(418));a.flags=a.flags&-4097|2,an=!1,Mr=a}}}function wy(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Mr=a}function bc(a){if(a!==Mr)return!1;if(!an)return wy(a),an=!0,!1;var u;if((u=a.tag!==3)&&!(u=a.tag!==5)&&(u=a.type,u=u!=="head"&&u!=="body"&&!Pf(a.type,a.memoizedProps)),u&&(u=Ar)){if(Vf(a))throw ky(),Error(n(418));for(;u;)yy(a,u),u=ni(u.nextSibling)}if(wy(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,u=0;a;){if(a.nodeType===8){var p=a.data;if(p==="/$"){if(u===0){Ar=ni(a.nextSibling);break e}u--}else p!=="$"&&p!=="$!"&&p!=="$?"||u++}a=a.nextSibling}Ar=null}}else Ar=Mr?ni(a.stateNode.nextSibling):null;return!0}function ky(){for(var a=Ar;a;)a=ni(a.nextSibling)}function Fo(){Ar=Mr=null,an=!1}function Kf(a){ns===null?ns=[a]:ns.push(a)}var Uj=M.ReactCurrentBatchConfig;function Da(a,u,p){if(a=p.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var b=p.stateNode}if(!b)throw Error(n(147,a));var E=b,C=""+a;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===C?u.ref:(u=function(O){var H=E.refs;O===null?delete H[C]:H[C]=O},u._stringRef=C,u)}if(typeof a!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,a))}return a}function yc(a,u){throw a=Object.prototype.toString.call(u),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":a))}function Sy(a){var u=a._init;return u(a._payload)}function Ey(a){function u(ce,se){if(a){var de=ce.deletions;de===null?(ce.deletions=[se],ce.flags|=16):de.push(se)}}function p(ce,se){if(!a)return null;for(;se!==null;)u(ce,se),se=se.sibling;return null}function b(ce,se){for(ce=new Map;se!==null;)se.key!==null?ce.set(se.key,se):ce.set(se.index,se),se=se.sibling;return ce}function E(ce,se){return ce=hi(ce,se),ce.index=0,ce.sibling=null,ce}function C(ce,se,de){return ce.index=de,a?(de=ce.alternate,de!==null?(de=de.index,de<se?(ce.flags|=2,se):de):(ce.flags|=2,se)):(ce.flags|=1048576,se)}function O(ce){return a&&ce.alternate===null&&(ce.flags|=2),ce}function H(ce,se,de,Oe){return se===null||se.tag!==6?(se=Bh(de,ce.mode,Oe),se.return=ce,se):(se=E(se,de),se.return=ce,se)}function Q(ce,se,de,Oe){var nt=de.type;return nt===L?Ce(ce,se,de.props.children,Oe,de.key):se!==null&&(se.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===J&&Sy(nt)===se.type)?(Oe=E(se,de.props),Oe.ref=Da(ce,se,de),Oe.return=ce,Oe):(Oe=Hc(de.type,de.key,de.props,null,ce.mode,Oe),Oe.ref=Da(ce,se,de),Oe.return=ce,Oe)}function pe(ce,se,de,Oe){return se===null||se.tag!==4||se.stateNode.containerInfo!==de.containerInfo||se.stateNode.implementation!==de.implementation?(se=$h(de,ce.mode,Oe),se.return=ce,se):(se=E(se,de.children||[]),se.return=ce,se)}function Ce(ce,se,de,Oe,nt){return se===null||se.tag!==7?(se=to(de,ce.mode,Oe,nt),se.return=ce,se):(se=E(se,de),se.return=ce,se)}function _e(ce,se,de){if(typeof se=="string"&&se!==""||typeof se=="number")return se=Bh(""+se,ce.mode,de),se.return=ce,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case _:return de=Hc(se.type,se.key,se.props,null,ce.mode,de),de.ref=Da(ce,null,se),de.return=ce,de;case R:return se=$h(se,ce.mode,de),se.return=ce,se;case J:var Oe=se._init;return _e(ce,Oe(se._payload),de)}if(At(se)||ue(se))return se=to(se,ce.mode,de,null),se.return=ce,se;yc(ce,se)}return null}function Ne(ce,se,de,Oe){var nt=se!==null?se.key:null;if(typeof de=="string"&&de!==""||typeof de=="number")return nt!==null?null:H(ce,se,""+de,Oe);if(typeof de=="object"&&de!==null){switch(de.$$typeof){case _:return de.key===nt?Q(ce,se,de,Oe):null;case R:return de.key===nt?pe(ce,se,de,Oe):null;case J:return nt=de._init,Ne(ce,se,nt(de._payload),Oe)}if(At(de)||ue(de))return nt!==null?null:Ce(ce,se,de,Oe,null);yc(ce,de)}return null}function He(ce,se,de,Oe,nt){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number")return ce=ce.get(de)||null,H(se,ce,""+Oe,nt);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case _:return ce=ce.get(Oe.key===null?de:Oe.key)||null,Q(se,ce,Oe,nt);case R:return ce=ce.get(Oe.key===null?de:Oe.key)||null,pe(se,ce,Oe,nt);case J:var dt=Oe._init;return He(ce,se,de,dt(Oe._payload),nt)}if(At(Oe)||ue(Oe))return ce=ce.get(de)||null,Ce(se,ce,Oe,nt,null);yc(se,Oe)}return null}function Je(ce,se,de,Oe){for(var nt=null,dt=null,ft=se,yt=se=0,Fn=null;ft!==null&&yt<de.length;yt++){ft.index>yt?(Fn=ft,ft=null):Fn=ft.sibling;var Ft=Ne(ce,ft,de[yt],Oe);if(Ft===null){ft===null&&(ft=Fn);break}a&&ft&&Ft.alternate===null&&u(ce,ft),se=C(Ft,se,yt),dt===null?nt=Ft:dt.sibling=Ft,dt=Ft,ft=Fn}if(yt===de.length)return p(ce,ft),an&&Ki(ce,yt),nt;if(ft===null){for(;yt<de.length;yt++)ft=_e(ce,de[yt],Oe),ft!==null&&(se=C(ft,se,yt),dt===null?nt=ft:dt.sibling=ft,dt=ft);return an&&Ki(ce,yt),nt}for(ft=b(ce,ft);yt<de.length;yt++)Fn=He(ft,ce,yt,de[yt],Oe),Fn!==null&&(a&&Fn.alternate!==null&&ft.delete(Fn.key===null?yt:Fn.key),se=C(Fn,se,yt),dt===null?nt=Fn:dt.sibling=Fn,dt=Fn);return a&&ft.forEach(function(pi){return u(ce,pi)}),an&&Ki(ce,yt),nt}function Ze(ce,se,de,Oe){var nt=ue(de);if(typeof nt!="function")throw Error(n(150));if(de=nt.call(de),de==null)throw Error(n(151));for(var dt=nt=null,ft=se,yt=se=0,Fn=null,Ft=de.next();ft!==null&&!Ft.done;yt++,Ft=de.next()){ft.index>yt?(Fn=ft,ft=null):Fn=ft.sibling;var pi=Ne(ce,ft,Ft.value,Oe);if(pi===null){ft===null&&(ft=Fn);break}a&&ft&&pi.alternate===null&&u(ce,ft),se=C(pi,se,yt),dt===null?nt=pi:dt.sibling=pi,dt=pi,ft=Fn}if(Ft.done)return p(ce,ft),an&&Ki(ce,yt),nt;if(ft===null){for(;!Ft.done;yt++,Ft=de.next())Ft=_e(ce,Ft.value,Oe),Ft!==null&&(se=C(Ft,se,yt),dt===null?nt=Ft:dt.sibling=Ft,dt=Ft);return an&&Ki(ce,yt),nt}for(ft=b(ce,ft);!Ft.done;yt++,Ft=de.next())Ft=He(ft,ce,yt,Ft.value,Oe),Ft!==null&&(a&&Ft.alternate!==null&&ft.delete(Ft.key===null?yt:Ft.key),se=C(Ft,se,yt),dt===null?nt=Ft:dt.sibling=Ft,dt=Ft);return a&&ft.forEach(function(wM){return u(ce,wM)}),an&&Ki(ce,yt),nt}function Sn(ce,se,de,Oe){if(typeof de=="object"&&de!==null&&de.type===L&&de.key===null&&(de=de.props.children),typeof de=="object"&&de!==null){switch(de.$$typeof){case _:e:{for(var nt=de.key,dt=se;dt!==null;){if(dt.key===nt){if(nt=de.type,nt===L){if(dt.tag===7){p(ce,dt.sibling),se=E(dt,de.props.children),se.return=ce,ce=se;break e}}else if(dt.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===J&&Sy(nt)===dt.type){p(ce,dt.sibling),se=E(dt,de.props),se.ref=Da(ce,dt,de),se.return=ce,ce=se;break e}p(ce,dt);break}else u(ce,dt);dt=dt.sibling}de.type===L?(se=to(de.props.children,ce.mode,Oe,de.key),se.return=ce,ce=se):(Oe=Hc(de.type,de.key,de.props,null,ce.mode,Oe),Oe.ref=Da(ce,se,de),Oe.return=ce,ce=Oe)}return O(ce);case R:e:{for(dt=de.key;se!==null;){if(se.key===dt)if(se.tag===4&&se.stateNode.containerInfo===de.containerInfo&&se.stateNode.implementation===de.implementation){p(ce,se.sibling),se=E(se,de.children||[]),se.return=ce,ce=se;break e}else{p(ce,se);break}else u(ce,se);se=se.sibling}se=$h(de,ce.mode,Oe),se.return=ce,ce=se}return O(ce);case J:return dt=de._init,Sn(ce,se,dt(de._payload),Oe)}if(At(de))return Je(ce,se,de,Oe);if(ue(de))return Ze(ce,se,de,Oe);yc(ce,de)}return typeof de=="string"&&de!==""||typeof de=="number"?(de=""+de,se!==null&&se.tag===6?(p(ce,se.sibling),se=E(se,de),se.return=ce,ce=se):(p(ce,se),se=Bh(de,ce.mode,Oe),se.return=ce,ce=se),O(ce)):p(ce,se)}return Sn}var zo=Ey(!0),Ny=Ey(!1),xc=ri(null),wc=null,Uo=null,Gf=null;function Jf(){Gf=Uo=wc=null}function Yf(a){var u=xc.current;sn(xc),a._currentValue=u}function Xf(a,u,p){for(;a!==null;){var b=a.alternate;if((a.childLanes&u)!==u?(a.childLanes|=u,b!==null&&(b.childLanes|=u)):b!==null&&(b.childLanes&u)!==u&&(b.childLanes|=u),a===p)break;a=a.return}}function Ho(a,u){wc=a,Gf=Uo=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&u)!==0&&(xr=!0),a.firstContext=null)}function $r(a){var u=a._currentValue;if(Gf!==a)if(a={context:a,memoizedValue:u,next:null},Uo===null){if(wc===null)throw Error(n(308));Uo=a,wc.dependencies={lanes:0,firstContext:a}}else Uo=Uo.next=a;return u}var Gi=null;function Qf(a){Gi===null?Gi=[a]:Gi.push(a)}function Cy(a,u,p,b){var E=u.interleaved;return E===null?(p.next=p,Qf(u)):(p.next=E.next,E.next=p),u.interleaved=p,Is(a,b)}function Is(a,u){a.lanes|=u;var p=a.alternate;for(p!==null&&(p.lanes|=u),p=a,a=a.return;a!==null;)a.childLanes|=u,p=a.alternate,p!==null&&(p.childLanes|=u),p=a,a=a.return;return p.tag===3?p.stateNode:null}var oi=!1;function Zf(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _y(a,u){a=a.updateQueue,u.updateQueue===a&&(u.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Ls(a,u){return{eventTime:a,lane:u,tag:0,payload:null,callback:null,next:null}}function ai(a,u,p){var b=a.updateQueue;if(b===null)return null;if(b=b.shared,(Pt&2)!==0){var E=b.pending;return E===null?u.next=u:(u.next=E.next,E.next=u),b.pending=u,Is(a,p)}return E=b.interleaved,E===null?(u.next=u,Qf(b)):(u.next=E.next,E.next=u),b.interleaved=u,Is(a,p)}function kc(a,u,p){if(u=u.updateQueue,u!==null&&(u=u.shared,(p&4194240)!==0)){var b=u.lanes;b&=a.pendingLanes,p|=b,u.lanes=p,Dn(a,p)}}function Ty(a,u){var p=a.updateQueue,b=a.alternate;if(b!==null&&(b=b.updateQueue,p===b)){var E=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var O={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?E=C=O:C=C.next=O,p=p.next}while(p!==null);C===null?E=C=u:C=C.next=u}else E=C=u;p={baseState:b.baseState,firstBaseUpdate:E,lastBaseUpdate:C,shared:b.shared,effects:b.effects},a.updateQueue=p;return}a=p.lastBaseUpdate,a===null?p.firstBaseUpdate=u:a.next=u,p.lastBaseUpdate=u}function Sc(a,u,p,b){var E=a.updateQueue;oi=!1;var C=E.firstBaseUpdate,O=E.lastBaseUpdate,H=E.shared.pending;if(H!==null){E.shared.pending=null;var Q=H,pe=Q.next;Q.next=null,O===null?C=pe:O.next=pe,O=Q;var Ce=a.alternate;Ce!==null&&(Ce=Ce.updateQueue,H=Ce.lastBaseUpdate,H!==O&&(H===null?Ce.firstBaseUpdate=pe:H.next=pe,Ce.lastBaseUpdate=Q))}if(C!==null){var _e=E.baseState;O=0,Ce=pe=Q=null,H=C;do{var Ne=H.lane,He=H.eventTime;if((b&Ne)===Ne){Ce!==null&&(Ce=Ce.next={eventTime:He,lane:0,tag:H.tag,payload:H.payload,callback:H.callback,next:null});e:{var Je=a,Ze=H;switch(Ne=u,He=p,Ze.tag){case 1:if(Je=Ze.payload,typeof Je=="function"){_e=Je.call(He,_e,Ne);break e}_e=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=Ze.payload,Ne=typeof Je=="function"?Je.call(He,_e,Ne):Je,Ne==null)break e;_e=Y({},_e,Ne);break e;case 2:oi=!0}}H.callback!==null&&H.lane!==0&&(a.flags|=64,Ne=E.effects,Ne===null?E.effects=[H]:Ne.push(H))}else He={eventTime:He,lane:Ne,tag:H.tag,payload:H.payload,callback:H.callback,next:null},Ce===null?(pe=Ce=He,Q=_e):Ce=Ce.next=He,O|=Ne;if(H=H.next,H===null){if(H=E.shared.pending,H===null)break;Ne=H,H=Ne.next,Ne.next=null,E.lastBaseUpdate=Ne,E.shared.pending=null}}while(!0);if(Ce===null&&(Q=_e),E.baseState=Q,E.firstBaseUpdate=pe,E.lastBaseUpdate=Ce,u=E.shared.interleaved,u!==null){E=u;do O|=E.lane,E=E.next;while(E!==u)}else C===null&&(E.shared.lanes=0);Xi|=O,a.lanes=O,a.memoizedState=_e}}function jy(a,u,p){if(a=u.effects,u.effects=null,a!==null)for(u=0;u<a.length;u++){var b=a[u],E=b.callback;if(E!==null){if(b.callback=null,b=p,typeof E!="function")throw Error(n(191,E));E.call(b)}}}var Pa={},bs=ri(Pa),Ba=ri(Pa),$a=ri(Pa);function Ji(a){if(a===Pa)throw Error(n(174));return a}function eh(a,u){switch(en($a,u),en(Ba,a),en(bs,Pa),a=u.nodeType,a){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:he(null,"");break;default:a=a===8?u.parentNode:u,u=a.namespaceURI||null,a=a.tagName,u=he(u,a)}sn(bs),en(bs,u)}function Wo(){sn(bs),sn(Ba),sn($a)}function My(a){Ji($a.current);var u=Ji(bs.current),p=he(u,a.type);u!==p&&(en(Ba,a),en(bs,p))}function th(a){Ba.current===a&&(sn(bs),sn(Ba))}var cn=ri(0);function Ec(a){for(var u=a;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===a)break;for(;u.sibling===null;){if(u.return===null||u.return===a)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var nh=[];function rh(){for(var a=0;a<nh.length;a++)nh[a]._workInProgressVersionPrimary=null;nh.length=0}var Nc=M.ReactCurrentDispatcher,sh=M.ReactCurrentBatchConfig,Yi=0,un=null,Rn=null,Bn=null,Cc=!1,Fa=!1,za=0,Hj=0;function rr(){throw Error(n(321))}function ih(a,u){if(u===null)return!1;for(var p=0;p<u.length&&p<a.length;p++)if(!ts(a[p],u[p]))return!1;return!0}function oh(a,u,p,b,E,C){if(Yi=C,un=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Nc.current=a===null||a.memoizedState===null?Kj:Gj,a=p(b,E),Fa){C=0;do{if(Fa=!1,za=0,25<=C)throw Error(n(301));C+=1,Bn=Rn=null,u.updateQueue=null,Nc.current=Jj,a=p(b,E)}while(Fa)}if(Nc.current=jc,u=Rn!==null&&Rn.next!==null,Yi=0,Bn=Rn=un=null,Cc=!1,u)throw Error(n(300));return a}function ah(){var a=za!==0;return za=0,a}function ys(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bn===null?un.memoizedState=Bn=a:Bn=Bn.next=a,Bn}function Fr(){if(Rn===null){var a=un.alternate;a=a!==null?a.memoizedState:null}else a=Rn.next;var u=Bn===null?un.memoizedState:Bn.next;if(u!==null)Bn=u,Rn=a;else{if(a===null)throw Error(n(310));Rn=a,a={memoizedState:Rn.memoizedState,baseState:Rn.baseState,baseQueue:Rn.baseQueue,queue:Rn.queue,next:null},Bn===null?un.memoizedState=Bn=a:Bn=Bn.next=a}return Bn}function Ua(a,u){return typeof u=="function"?u(a):u}function lh(a){var u=Fr(),p=u.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var b=Rn,E=b.baseQueue,C=p.pending;if(C!==null){if(E!==null){var O=E.next;E.next=C.next,C.next=O}b.baseQueue=E=C,p.pending=null}if(E!==null){C=E.next,b=b.baseState;var H=O=null,Q=null,pe=C;do{var Ce=pe.lane;if((Yi&Ce)===Ce)Q!==null&&(Q=Q.next={lane:0,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null}),b=pe.hasEagerState?pe.eagerState:a(b,pe.action);else{var _e={lane:Ce,action:pe.action,hasEagerState:pe.hasEagerState,eagerState:pe.eagerState,next:null};Q===null?(H=Q=_e,O=b):Q=Q.next=_e,un.lanes|=Ce,Xi|=Ce}pe=pe.next}while(pe!==null&&pe!==C);Q===null?O=b:Q.next=H,ts(b,u.memoizedState)||(xr=!0),u.memoizedState=b,u.baseState=O,u.baseQueue=Q,p.lastRenderedState=b}if(a=p.interleaved,a!==null){E=a;do C=E.lane,un.lanes|=C,Xi|=C,E=E.next;while(E!==a)}else E===null&&(p.lanes=0);return[u.memoizedState,p.dispatch]}function ch(a){var u=Fr(),p=u.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var b=p.dispatch,E=p.pending,C=u.memoizedState;if(E!==null){p.pending=null;var O=E=E.next;do C=a(C,O.action),O=O.next;while(O!==E);ts(C,u.memoizedState)||(xr=!0),u.memoizedState=C,u.baseQueue===null&&(u.baseState=C),p.lastRenderedState=C}return[C,b]}function Ay(){}function Ry(a,u){var p=un,b=Fr(),E=u(),C=!ts(b.memoizedState,E);if(C&&(b.memoizedState=E,xr=!0),b=b.queue,uh(Ly.bind(null,p,b,a),[a]),b.getSnapshot!==u||C||Bn!==null&&Bn.memoizedState.tag&1){if(p.flags|=2048,Ha(9,Iy.bind(null,p,b,E,u),void 0,null),$n===null)throw Error(n(349));(Yi&30)!==0||Oy(p,u,E)}return E}function Oy(a,u,p){a.flags|=16384,a={getSnapshot:u,value:p},u=un.updateQueue,u===null?(u={lastEffect:null,stores:null},un.updateQueue=u,u.stores=[a]):(p=u.stores,p===null?u.stores=[a]:p.push(a))}function Iy(a,u,p,b){u.value=p,u.getSnapshot=b,Dy(u)&&Py(a)}function Ly(a,u,p){return p(function(){Dy(u)&&Py(a)})}function Dy(a){var u=a.getSnapshot;a=a.value;try{var p=u();return!ts(a,p)}catch{return!0}}function Py(a){var u=Is(a,1);u!==null&&as(u,a,1,-1)}function By(a){var u=ys();return typeof a=="function"&&(a=a()),u.memoizedState=u.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ua,lastRenderedState:a},u.queue=a,a=a.dispatch=qj.bind(null,un,a),[u.memoizedState,a]}function Ha(a,u,p,b){return a={tag:a,create:u,destroy:p,deps:b,next:null},u=un.updateQueue,u===null?(u={lastEffect:null,stores:null},un.updateQueue=u,u.lastEffect=a.next=a):(p=u.lastEffect,p===null?u.lastEffect=a.next=a:(b=p.next,p.next=a,a.next=b,u.lastEffect=a)),a}function $y(){return Fr().memoizedState}function _c(a,u,p,b){var E=ys();un.flags|=a,E.memoizedState=Ha(1|u,p,void 0,b===void 0?null:b)}function Tc(a,u,p,b){var E=Fr();b=b===void 0?null:b;var C=void 0;if(Rn!==null){var O=Rn.memoizedState;if(C=O.destroy,b!==null&&ih(b,O.deps)){E.memoizedState=Ha(u,p,C,b);return}}un.flags|=a,E.memoizedState=Ha(1|u,p,C,b)}function Fy(a,u){return _c(8390656,8,a,u)}function uh(a,u){return Tc(2048,8,a,u)}function zy(a,u){return Tc(4,2,a,u)}function Uy(a,u){return Tc(4,4,a,u)}function Hy(a,u){if(typeof u=="function")return a=a(),u(a),function(){u(null)};if(u!=null)return a=a(),u.current=a,function(){u.current=null}}function Wy(a,u,p){return p=p!=null?p.concat([a]):null,Tc(4,4,Hy.bind(null,u,a),p)}function dh(){}function Vy(a,u){var p=Fr();u=u===void 0?null:u;var b=p.memoizedState;return b!==null&&u!==null&&ih(u,b[1])?b[0]:(p.memoizedState=[a,u],a)}function qy(a,u){var p=Fr();u=u===void 0?null:u;var b=p.memoizedState;return b!==null&&u!==null&&ih(u,b[1])?b[0]:(a=a(),p.memoizedState=[a,u],a)}function Ky(a,u,p){return(Yi&21)===0?(a.baseState&&(a.baseState=!1,xr=!0),a.memoizedState=p):(ts(p,u)||(p=Ct(),un.lanes|=p,Xi|=p,a.baseState=!0),u)}function Wj(a,u){var p=_t;_t=p!==0&&4>p?p:4,a(!0);var b=sh.transition;sh.transition={};try{a(!1),u()}finally{_t=p,sh.transition=b}}function Gy(){return Fr().memoizedState}function Vj(a,u,p){var b=di(a);if(p={lane:b,action:p,hasEagerState:!1,eagerState:null,next:null},Jy(a))Yy(u,p);else if(p=Cy(a,u,p,b),p!==null){var E=fr();as(p,a,b,E),Xy(p,u,b)}}function qj(a,u,p){var b=di(a),E={lane:b,action:p,hasEagerState:!1,eagerState:null,next:null};if(Jy(a))Yy(u,E);else{var C=a.alternate;if(a.lanes===0&&(C===null||C.lanes===0)&&(C=u.lastRenderedReducer,C!==null))try{var O=u.lastRenderedState,H=C(O,p);if(E.hasEagerState=!0,E.eagerState=H,ts(H,O)){var Q=u.interleaved;Q===null?(E.next=E,Qf(u)):(E.next=Q.next,Q.next=E),u.interleaved=E;return}}catch{}finally{}p=Cy(a,u,E,b),p!==null&&(E=fr(),as(p,a,b,E),Xy(p,u,b))}}function Jy(a){var u=a.alternate;return a===un||u!==null&&u===un}function Yy(a,u){Fa=Cc=!0;var p=a.pending;p===null?u.next=u:(u.next=p.next,p.next=u),a.pending=u}function Xy(a,u,p){if((p&4194240)!==0){var b=u.lanes;b&=a.pendingLanes,p|=b,u.lanes=p,Dn(a,p)}}var jc={readContext:$r,useCallback:rr,useContext:rr,useEffect:rr,useImperativeHandle:rr,useInsertionEffect:rr,useLayoutEffect:rr,useMemo:rr,useReducer:rr,useRef:rr,useState:rr,useDebugValue:rr,useDeferredValue:rr,useTransition:rr,useMutableSource:rr,useSyncExternalStore:rr,useId:rr,unstable_isNewReconciler:!1},Kj={readContext:$r,useCallback:function(a,u){return ys().memoizedState=[a,u===void 0?null:u],a},useContext:$r,useEffect:Fy,useImperativeHandle:function(a,u,p){return p=p!=null?p.concat([a]):null,_c(4194308,4,Hy.bind(null,u,a),p)},useLayoutEffect:function(a,u){return _c(4194308,4,a,u)},useInsertionEffect:function(a,u){return _c(4,2,a,u)},useMemo:function(a,u){var p=ys();return u=u===void 0?null:u,a=a(),p.memoizedState=[a,u],a},useReducer:function(a,u,p){var b=ys();return u=p!==void 0?p(u):u,b.memoizedState=b.baseState=u,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:u},b.queue=a,a=a.dispatch=Vj.bind(null,un,a),[b.memoizedState,a]},useRef:function(a){var u=ys();return a={current:a},u.memoizedState=a},useState:By,useDebugValue:dh,useDeferredValue:function(a){return ys().memoizedState=a},useTransition:function(){var a=By(!1),u=a[0];return a=Wj.bind(null,a[1]),ys().memoizedState=a,[u,a]},useMutableSource:function(){},useSyncExternalStore:function(a,u,p){var b=un,E=ys();if(an){if(p===void 0)throw Error(n(407));p=p()}else{if(p=u(),$n===null)throw Error(n(349));(Yi&30)!==0||Oy(b,u,p)}E.memoizedState=p;var C={value:p,getSnapshot:u};return E.queue=C,Fy(Ly.bind(null,b,C,a),[a]),b.flags|=2048,Ha(9,Iy.bind(null,b,C,p,u),void 0,null),p},useId:function(){var a=ys(),u=$n.identifierPrefix;if(an){var p=Os,b=Rs;p=(b&~(1<<32-Zt(b)-1)).toString(32)+p,u=":"+u+"R"+p,p=za++,0<p&&(u+="H"+p.toString(32)),u+=":"}else p=Hj++,u=":"+u+"r"+p.toString(32)+":";return a.memoizedState=u},unstable_isNewReconciler:!1},Gj={readContext:$r,useCallback:Vy,useContext:$r,useEffect:uh,useImperativeHandle:Wy,useInsertionEffect:zy,useLayoutEffect:Uy,useMemo:qy,useReducer:lh,useRef:$y,useState:function(){return lh(Ua)},useDebugValue:dh,useDeferredValue:function(a){var u=Fr();return Ky(u,Rn.memoizedState,a)},useTransition:function(){var a=lh(Ua)[0],u=Fr().memoizedState;return[a,u]},useMutableSource:Ay,useSyncExternalStore:Ry,useId:Gy,unstable_isNewReconciler:!1},Jj={readContext:$r,useCallback:Vy,useContext:$r,useEffect:uh,useImperativeHandle:Wy,useInsertionEffect:zy,useLayoutEffect:Uy,useMemo:qy,useReducer:ch,useRef:$y,useState:function(){return ch(Ua)},useDebugValue:dh,useDeferredValue:function(a){var u=Fr();return Rn===null?u.memoizedState=a:Ky(u,Rn.memoizedState,a)},useTransition:function(){var a=ch(Ua)[0],u=Fr().memoizedState;return[a,u]},useMutableSource:Ay,useSyncExternalStore:Ry,useId:Gy,unstable_isNewReconciler:!1};function rs(a,u){if(a&&a.defaultProps){u=Y({},u),a=a.defaultProps;for(var p in a)u[p]===void 0&&(u[p]=a[p]);return u}return u}function fh(a,u,p,b){u=a.memoizedState,p=p(b,u),p=p==null?u:Y({},u,p),a.memoizedState=p,a.lanes===0&&(a.updateQueue.baseState=p)}var Mc={isMounted:function(a){return(a=a._reactInternals)?zt(a)===a:!1},enqueueSetState:function(a,u,p){a=a._reactInternals;var b=fr(),E=di(a),C=Ls(b,E);C.payload=u,p!=null&&(C.callback=p),u=ai(a,C,E),u!==null&&(as(u,a,E,b),kc(u,a,E))},enqueueReplaceState:function(a,u,p){a=a._reactInternals;var b=fr(),E=di(a),C=Ls(b,E);C.tag=1,C.payload=u,p!=null&&(C.callback=p),u=ai(a,C,E),u!==null&&(as(u,a,E,b),kc(u,a,E))},enqueueForceUpdate:function(a,u){a=a._reactInternals;var p=fr(),b=di(a),E=Ls(p,b);E.tag=2,u!=null&&(E.callback=u),u=ai(a,E,b),u!==null&&(as(u,a,b,p),kc(u,a,b))}};function Qy(a,u,p,b,E,C,O){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(b,C,O):u.prototype&&u.prototype.isPureReactComponent?!ja(p,b)||!ja(E,C):!0}function Zy(a,u,p){var b=!1,E=si,C=u.contextType;return typeof C=="object"&&C!==null?C=$r(C):(E=yr(u)?Vi:nr.current,b=u.contextTypes,C=(b=b!=null)?Po(a,E):si),u=new u(p,C),a.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Mc,a.stateNode=u,u._reactInternals=a,b&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=E,a.__reactInternalMemoizedMaskedChildContext=C),u}function e0(a,u,p,b){a=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(p,b),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(p,b),u.state!==a&&Mc.enqueueReplaceState(u,u.state,null)}function hh(a,u,p,b){var E=a.stateNode;E.props=p,E.state=a.memoizedState,E.refs={},Zf(a);var C=u.contextType;typeof C=="object"&&C!==null?E.context=$r(C):(C=yr(u)?Vi:nr.current,E.context=Po(a,C)),E.state=a.memoizedState,C=u.getDerivedStateFromProps,typeof C=="function"&&(fh(a,u,C,p),E.state=a.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(u=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),u!==E.state&&Mc.enqueueReplaceState(E,E.state,null),Sc(a,p,E,b),E.state=a.memoizedState),typeof E.componentDidMount=="function"&&(a.flags|=4194308)}function Vo(a,u){try{var p="",b=u;do p+=we(b),b=b.return;while(b);var E=p}catch(C){E=`
39
+ Error generating stack: `+C.message+`
40
+ `+C.stack}return{value:a,source:u,stack:E,digest:null}}function ph(a,u,p){return{value:a,source:null,stack:p??null,digest:u??null}}function mh(a,u){try{console.error(u.value)}catch(p){setTimeout(function(){throw p})}}var Yj=typeof WeakMap=="function"?WeakMap:Map;function t0(a,u,p){p=Ls(-1,p),p.tag=3,p.payload={element:null};var b=u.value;return p.callback=function(){Pc||(Pc=!0,Mh=b),mh(a,u)},p}function n0(a,u,p){p=Ls(-1,p),p.tag=3;var b=a.type.getDerivedStateFromError;if(typeof b=="function"){var E=u.value;p.payload=function(){return b(E)},p.callback=function(){mh(a,u)}}var C=a.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(p.callback=function(){mh(a,u),typeof b!="function"&&(ci===null?ci=new Set([this]):ci.add(this));var O=u.stack;this.componentDidCatch(u.value,{componentStack:O!==null?O:""})}),p}function r0(a,u,p){var b=a.pingCache;if(b===null){b=a.pingCache=new Yj;var E=new Set;b.set(u,E)}else E=b.get(u),E===void 0&&(E=new Set,b.set(u,E));E.has(p)||(E.add(p),a=uM.bind(null,a,u,p),u.then(a,a))}function s0(a){do{var u;if((u=a.tag===13)&&(u=a.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return a;a=a.return}while(a!==null);return null}function i0(a,u,p,b,E){return(a.mode&1)===0?(a===u?a.flags|=65536:(a.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(u=Ls(-1,1),u.tag=2,ai(p,u,1))),p.lanes|=1),a):(a.flags|=65536,a.lanes=E,a)}var Xj=M.ReactCurrentOwner,xr=!1;function dr(a,u,p,b){u.child=a===null?Ny(u,null,p,b):zo(u,a.child,p,b)}function o0(a,u,p,b,E){p=p.render;var C=u.ref;return Ho(u,E),b=oh(a,u,p,b,C,E),p=ah(),a!==null&&!xr?(u.updateQueue=a.updateQueue,u.flags&=-2053,a.lanes&=~E,Ds(a,u,E)):(an&&p&&Hf(u),u.flags|=1,dr(a,u,b,E),u.child)}function a0(a,u,p,b,E){if(a===null){var C=p.type;return typeof C=="function"&&!Ph(C)&&C.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(u.tag=15,u.type=C,l0(a,u,C,b,E)):(a=Hc(p.type,null,b,u,u.mode,E),a.ref=u.ref,a.return=u,u.child=a)}if(C=a.child,(a.lanes&E)===0){var O=C.memoizedProps;if(p=p.compare,p=p!==null?p:ja,p(O,b)&&a.ref===u.ref)return Ds(a,u,E)}return u.flags|=1,a=hi(C,b),a.ref=u.ref,a.return=u,u.child=a}function l0(a,u,p,b,E){if(a!==null){var C=a.memoizedProps;if(ja(C,b)&&a.ref===u.ref)if(xr=!1,u.pendingProps=b=C,(a.lanes&E)!==0)(a.flags&131072)!==0&&(xr=!0);else return u.lanes=a.lanes,Ds(a,u,E)}return gh(a,u,p,b,E)}function c0(a,u,p){var b=u.pendingProps,E=b.children,C=a!==null?a.memoizedState:null;if(b.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},en(Ko,Rr),Rr|=p;else{if((p&1073741824)===0)return a=C!==null?C.baseLanes|p:p,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:a,cachePool:null,transitions:null},u.updateQueue=null,en(Ko,Rr),Rr|=a,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=C!==null?C.baseLanes:p,en(Ko,Rr),Rr|=b}else C!==null?(b=C.baseLanes|p,u.memoizedState=null):b=p,en(Ko,Rr),Rr|=b;return dr(a,u,E,p),u.child}function u0(a,u){var p=u.ref;(a===null&&p!==null||a!==null&&a.ref!==p)&&(u.flags|=512,u.flags|=2097152)}function gh(a,u,p,b,E){var C=yr(p)?Vi:nr.current;return C=Po(u,C),Ho(u,E),p=oh(a,u,p,b,C,E),b=ah(),a!==null&&!xr?(u.updateQueue=a.updateQueue,u.flags&=-2053,a.lanes&=~E,Ds(a,u,E)):(an&&b&&Hf(u),u.flags|=1,dr(a,u,p,E),u.child)}function d0(a,u,p,b,E){if(yr(p)){var C=!0;pc(u)}else C=!1;if(Ho(u,E),u.stateNode===null)Rc(a,u),Zy(u,p,b),hh(u,p,b,E),b=!0;else if(a===null){var O=u.stateNode,H=u.memoizedProps;O.props=H;var Q=O.context,pe=p.contextType;typeof pe=="object"&&pe!==null?pe=$r(pe):(pe=yr(p)?Vi:nr.current,pe=Po(u,pe));var Ce=p.getDerivedStateFromProps,_e=typeof Ce=="function"||typeof O.getSnapshotBeforeUpdate=="function";_e||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(H!==b||Q!==pe)&&e0(u,O,b,pe),oi=!1;var Ne=u.memoizedState;O.state=Ne,Sc(u,b,O,E),Q=u.memoizedState,H!==b||Ne!==Q||br.current||oi?(typeof Ce=="function"&&(fh(u,p,Ce,b),Q=u.memoizedState),(H=oi||Qy(u,p,H,b,Ne,Q,pe))?(_e||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(u.flags|=4194308)):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=b,u.memoizedState=Q),O.props=b,O.state=Q,O.context=pe,b=H):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),b=!1)}else{O=u.stateNode,_y(a,u),H=u.memoizedProps,pe=u.type===u.elementType?H:rs(u.type,H),O.props=pe,_e=u.pendingProps,Ne=O.context,Q=p.contextType,typeof Q=="object"&&Q!==null?Q=$r(Q):(Q=yr(p)?Vi:nr.current,Q=Po(u,Q));var He=p.getDerivedStateFromProps;(Ce=typeof He=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(H!==_e||Ne!==Q)&&e0(u,O,b,Q),oi=!1,Ne=u.memoizedState,O.state=Ne,Sc(u,b,O,E);var Je=u.memoizedState;H!==_e||Ne!==Je||br.current||oi?(typeof He=="function"&&(fh(u,p,He,b),Je=u.memoizedState),(pe=oi||Qy(u,p,pe,b,Ne,Je,Q)||!1)?(Ce||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(b,Je,Q),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(b,Je,Q)),typeof O.componentDidUpdate=="function"&&(u.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof O.componentDidUpdate!="function"||H===a.memoizedProps&&Ne===a.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||H===a.memoizedProps&&Ne===a.memoizedState||(u.flags|=1024),u.memoizedProps=b,u.memoizedState=Je),O.props=b,O.state=Je,O.context=Q,b=pe):(typeof O.componentDidUpdate!="function"||H===a.memoizedProps&&Ne===a.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||H===a.memoizedProps&&Ne===a.memoizedState||(u.flags|=1024),b=!1)}return vh(a,u,p,b,C,E)}function vh(a,u,p,b,E,C){u0(a,u);var O=(u.flags&128)!==0;if(!b&&!O)return E&&gy(u,p,!1),Ds(a,u,C);b=u.stateNode,Xj.current=u;var H=O&&typeof p.getDerivedStateFromError!="function"?null:b.render();return u.flags|=1,a!==null&&O?(u.child=zo(u,a.child,null,C),u.child=zo(u,null,H,C)):dr(a,u,H,C),u.memoizedState=b.state,E&&gy(u,p,!0),u.child}function f0(a){var u=a.stateNode;u.pendingContext?py(a,u.pendingContext,u.pendingContext!==u.context):u.context&&py(a,u.context,!1),eh(a,u.containerInfo)}function h0(a,u,p,b,E){return Fo(),Kf(E),u.flags|=256,dr(a,u,p,b),u.child}var bh={dehydrated:null,treeContext:null,retryLane:0};function yh(a){return{baseLanes:a,cachePool:null,transitions:null}}function p0(a,u,p){var b=u.pendingProps,E=cn.current,C=!1,O=(u.flags&128)!==0,H;if((H=O)||(H=a!==null&&a.memoizedState===null?!1:(E&2)!==0),H?(C=!0,u.flags&=-129):(a===null||a.memoizedState!==null)&&(E|=1),en(cn,E&1),a===null)return qf(u),a=u.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((u.mode&1)===0?u.lanes=1:a.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(O=b.children,a=b.fallback,C?(b=u.mode,C=u.child,O={mode:"hidden",children:O},(b&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=O):C=Wc(O,b,0,null),a=to(a,b,p,null),C.return=u,a.return=u,C.sibling=a,u.child=C,u.child.memoizedState=yh(p),u.memoizedState=bh,a):xh(u,O));if(E=a.memoizedState,E!==null&&(H=E.dehydrated,H!==null))return Qj(a,u,O,b,H,E,p);if(C){C=b.fallback,O=u.mode,E=a.child,H=E.sibling;var Q={mode:"hidden",children:b.children};return(O&1)===0&&u.child!==E?(b=u.child,b.childLanes=0,b.pendingProps=Q,u.deletions=null):(b=hi(E,Q),b.subtreeFlags=E.subtreeFlags&14680064),H!==null?C=hi(H,C):(C=to(C,O,p,null),C.flags|=2),C.return=u,b.return=u,b.sibling=C,u.child=b,b=C,C=u.child,O=a.child.memoizedState,O=O===null?yh(p):{baseLanes:O.baseLanes|p,cachePool:null,transitions:O.transitions},C.memoizedState=O,C.childLanes=a.childLanes&~p,u.memoizedState=bh,b}return C=a.child,a=C.sibling,b=hi(C,{mode:"visible",children:b.children}),(u.mode&1)===0&&(b.lanes=p),b.return=u,b.sibling=null,a!==null&&(p=u.deletions,p===null?(u.deletions=[a],u.flags|=16):p.push(a)),u.child=b,u.memoizedState=null,b}function xh(a,u){return u=Wc({mode:"visible",children:u},a.mode,0,null),u.return=a,a.child=u}function Ac(a,u,p,b){return b!==null&&Kf(b),zo(u,a.child,null,p),a=xh(u,u.pendingProps.children),a.flags|=2,u.memoizedState=null,a}function Qj(a,u,p,b,E,C,O){if(p)return u.flags&256?(u.flags&=-257,b=ph(Error(n(422))),Ac(a,u,O,b)):u.memoizedState!==null?(u.child=a.child,u.flags|=128,null):(C=b.fallback,E=u.mode,b=Wc({mode:"visible",children:b.children},E,0,null),C=to(C,E,O,null),C.flags|=2,b.return=u,C.return=u,b.sibling=C,u.child=b,(u.mode&1)!==0&&zo(u,a.child,null,O),u.child.memoizedState=yh(O),u.memoizedState=bh,C);if((u.mode&1)===0)return Ac(a,u,O,null);if(E.data==="$!"){if(b=E.nextSibling&&E.nextSibling.dataset,b)var H=b.dgst;return b=H,C=Error(n(419)),b=ph(C,b,void 0),Ac(a,u,O,b)}if(H=(O&a.childLanes)!==0,xr||H){if(b=$n,b!==null){switch(O&-O){case 4:E=2;break;case 16:E=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:E=32;break;case 536870912:E=268435456;break;default:E=0}E=(E&(b.suspendedLanes|O))!==0?0:E,E!==0&&E!==C.retryLane&&(C.retryLane=E,Is(a,E),as(b,a,E,-1))}return Dh(),b=ph(Error(n(421))),Ac(a,u,O,b)}return E.data==="$?"?(u.flags|=128,u.child=a.child,u=dM.bind(null,a),E._reactRetry=u,null):(a=C.treeContext,Ar=ni(E.nextSibling),Mr=u,an=!0,ns=null,a!==null&&(Pr[Br++]=Rs,Pr[Br++]=Os,Pr[Br++]=qi,Rs=a.id,Os=a.overflow,qi=u),u=xh(u,b.children),u.flags|=4096,u)}function m0(a,u,p){a.lanes|=u;var b=a.alternate;b!==null&&(b.lanes|=u),Xf(a.return,u,p)}function wh(a,u,p,b,E){var C=a.memoizedState;C===null?a.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:b,tail:p,tailMode:E}:(C.isBackwards=u,C.rendering=null,C.renderingStartTime=0,C.last=b,C.tail=p,C.tailMode=E)}function g0(a,u,p){var b=u.pendingProps,E=b.revealOrder,C=b.tail;if(dr(a,u,b.children,p),b=cn.current,(b&2)!==0)b=b&1|2,u.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=u.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&m0(a,p,u);else if(a.tag===19)m0(a,p,u);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===u)break e;for(;a.sibling===null;){if(a.return===null||a.return===u)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}b&=1}if(en(cn,b),(u.mode&1)===0)u.memoizedState=null;else switch(E){case"forwards":for(p=u.child,E=null;p!==null;)a=p.alternate,a!==null&&Ec(a)===null&&(E=p),p=p.sibling;p=E,p===null?(E=u.child,u.child=null):(E=p.sibling,p.sibling=null),wh(u,!1,E,p,C);break;case"backwards":for(p=null,E=u.child,u.child=null;E!==null;){if(a=E.alternate,a!==null&&Ec(a)===null){u.child=E;break}a=E.sibling,E.sibling=p,p=E,E=a}wh(u,!0,p,null,C);break;case"together":wh(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function Rc(a,u){(u.mode&1)===0&&a!==null&&(a.alternate=null,u.alternate=null,u.flags|=2)}function Ds(a,u,p){if(a!==null&&(u.dependencies=a.dependencies),Xi|=u.lanes,(p&u.childLanes)===0)return null;if(a!==null&&u.child!==a.child)throw Error(n(153));if(u.child!==null){for(a=u.child,p=hi(a,a.pendingProps),u.child=p,p.return=u;a.sibling!==null;)a=a.sibling,p=p.sibling=hi(a,a.pendingProps),p.return=u;p.sibling=null}return u.child}function Zj(a,u,p){switch(u.tag){case 3:f0(u),Fo();break;case 5:My(u);break;case 1:yr(u.type)&&pc(u);break;case 4:eh(u,u.stateNode.containerInfo);break;case 10:var b=u.type._context,E=u.memoizedProps.value;en(xc,b._currentValue),b._currentValue=E;break;case 13:if(b=u.memoizedState,b!==null)return b.dehydrated!==null?(en(cn,cn.current&1),u.flags|=128,null):(p&u.child.childLanes)!==0?p0(a,u,p):(en(cn,cn.current&1),a=Ds(a,u,p),a!==null?a.sibling:null);en(cn,cn.current&1);break;case 19:if(b=(p&u.childLanes)!==0,(a.flags&128)!==0){if(b)return g0(a,u,p);u.flags|=128}if(E=u.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),en(cn,cn.current),b)break;return null;case 22:case 23:return u.lanes=0,c0(a,u,p)}return Ds(a,u,p)}var v0,kh,b0,y0;v0=function(a,u){for(var p=u.child;p!==null;){if(p.tag===5||p.tag===6)a.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===u)break;for(;p.sibling===null;){if(p.return===null||p.return===u)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},kh=function(){},b0=function(a,u,p,b){var E=a.memoizedProps;if(E!==b){a=u.stateNode,Ji(bs.current);var C=null;switch(p){case"input":E=pt(a,E),b=pt(a,b),C=[];break;case"select":E=Y({},E,{value:void 0}),b=Y({},b,{value:void 0}),C=[];break;case"textarea":E=ct(a,E),b=ct(a,b),C=[];break;default:typeof E.onClick!="function"&&typeof b.onClick=="function"&&(a.onclick=dc)}st(p,b);var O;p=null;for(pe in E)if(!b.hasOwnProperty(pe)&&E.hasOwnProperty(pe)&&E[pe]!=null)if(pe==="style"){var H=E[pe];for(O in H)H.hasOwnProperty(O)&&(p||(p={}),p[O]="")}else pe!=="dangerouslySetInnerHTML"&&pe!=="children"&&pe!=="suppressContentEditableWarning"&&pe!=="suppressHydrationWarning"&&pe!=="autoFocus"&&(s.hasOwnProperty(pe)?C||(C=[]):(C=C||[]).push(pe,null));for(pe in b){var Q=b[pe];if(H=E!=null?E[pe]:void 0,b.hasOwnProperty(pe)&&Q!==H&&(Q!=null||H!=null))if(pe==="style")if(H){for(O in H)!H.hasOwnProperty(O)||Q&&Q.hasOwnProperty(O)||(p||(p={}),p[O]="");for(O in Q)Q.hasOwnProperty(O)&&H[O]!==Q[O]&&(p||(p={}),p[O]=Q[O])}else p||(C||(C=[]),C.push(pe,p)),p=Q;else pe==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,H=H?H.__html:void 0,Q!=null&&H!==Q&&(C=C||[]).push(pe,Q)):pe==="children"?typeof Q!="string"&&typeof Q!="number"||(C=C||[]).push(pe,""+Q):pe!=="suppressContentEditableWarning"&&pe!=="suppressHydrationWarning"&&(s.hasOwnProperty(pe)?(Q!=null&&pe==="onScroll"&&rn("scroll",a),C||H===Q||(C=[])):(C=C||[]).push(pe,Q))}p&&(C=C||[]).push("style",p);var pe=C;(u.updateQueue=pe)&&(u.flags|=4)}},y0=function(a,u,p,b){p!==b&&(u.flags|=4)};function Wa(a,u){if(!an)switch(a.tailMode){case"hidden":u=a.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?a.tail=null:p.sibling=null;break;case"collapsed":p=a.tail;for(var b=null;p!==null;)p.alternate!==null&&(b=p),p=p.sibling;b===null?u||a.tail===null?a.tail=null:a.tail.sibling=null:b.sibling=null}}function sr(a){var u=a.alternate!==null&&a.alternate.child===a.child,p=0,b=0;if(u)for(var E=a.child;E!==null;)p|=E.lanes|E.childLanes,b|=E.subtreeFlags&14680064,b|=E.flags&14680064,E.return=a,E=E.sibling;else for(E=a.child;E!==null;)p|=E.lanes|E.childLanes,b|=E.subtreeFlags,b|=E.flags,E.return=a,E=E.sibling;return a.subtreeFlags|=b,a.childLanes=p,u}function eM(a,u,p){var b=u.pendingProps;switch(Wf(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return sr(u),null;case 1:return yr(u.type)&&hc(),sr(u),null;case 3:return b=u.stateNode,Wo(),sn(br),sn(nr),rh(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(a===null||a.child===null)&&(bc(u)?u.flags|=4:a===null||a.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,ns!==null&&(Oh(ns),ns=null))),kh(a,u),sr(u),null;case 5:th(u);var E=Ji($a.current);if(p=u.type,a!==null&&u.stateNode!=null)b0(a,u,p,b,E),a.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!b){if(u.stateNode===null)throw Error(n(166));return sr(u),null}if(a=Ji(bs.current),bc(u)){b=u.stateNode,p=u.type;var C=u.memoizedProps;switch(b[vs]=u,b[Ia]=C,a=(u.mode&1)!==0,p){case"dialog":rn("cancel",b),rn("close",b);break;case"iframe":case"object":case"embed":rn("load",b);break;case"video":case"audio":for(E=0;E<Aa.length;E++)rn(Aa[E],b);break;case"source":rn("error",b);break;case"img":case"image":case"link":rn("error",b),rn("load",b);break;case"details":rn("toggle",b);break;case"input":ut(b,C),rn("invalid",b);break;case"select":b._wrapperState={wasMultiple:!!C.multiple},rn("invalid",b);break;case"textarea":Fe(b,C),rn("invalid",b)}st(p,C),E=null;for(var O in C)if(C.hasOwnProperty(O)){var H=C[O];O==="children"?typeof H=="string"?b.textContent!==H&&(C.suppressHydrationWarning!==!0&&uc(b.textContent,H,a),E=["children",H]):typeof H=="number"&&b.textContent!==""+H&&(C.suppressHydrationWarning!==!0&&uc(b.textContent,H,a),E=["children",""+H]):s.hasOwnProperty(O)&&H!=null&&O==="onScroll"&&rn("scroll",b)}switch(p){case"input":Ve(b),xt(b,C,!0);break;case"textarea":Ve(b),ge(b);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(b.onclick=dc)}b=E,u.updateQueue=b,b!==null&&(u.flags|=4)}else{O=E.nodeType===9?E:E.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=ne(p)),a==="http://www.w3.org/1999/xhtml"?p==="script"?(a=O.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof b.is=="string"?a=O.createElement(p,{is:b.is}):(a=O.createElement(p),p==="select"&&(O=a,b.multiple?O.multiple=!0:b.size&&(O.size=b.size))):a=O.createElementNS(a,p),a[vs]=u,a[Ia]=b,v0(a,u,!1,!1),u.stateNode=a;e:{switch(O=mt(p,b),p){case"dialog":rn("cancel",a),rn("close",a),E=b;break;case"iframe":case"object":case"embed":rn("load",a),E=b;break;case"video":case"audio":for(E=0;E<Aa.length;E++)rn(Aa[E],a);E=b;break;case"source":rn("error",a),E=b;break;case"img":case"image":case"link":rn("error",a),rn("load",a),E=b;break;case"details":rn("toggle",a),E=b;break;case"input":ut(a,b),E=pt(a,b),rn("invalid",a);break;case"option":E=b;break;case"select":a._wrapperState={wasMultiple:!!b.multiple},E=Y({},b,{value:void 0}),rn("invalid",a);break;case"textarea":Fe(a,b),E=ct(a,b),rn("invalid",a);break;default:E=b}st(p,E),H=E;for(C in H)if(H.hasOwnProperty(C)){var Q=H[C];C==="style"?We(a,Q):C==="dangerouslySetInnerHTML"?(Q=Q?Q.__html:void 0,Q!=null&&ze(a,Q)):C==="children"?typeof Q=="string"?(p!=="textarea"||Q!=="")&&Ae(a,Q):typeof Q=="number"&&Ae(a,""+Q):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(s.hasOwnProperty(C)?Q!=null&&C==="onScroll"&&rn("scroll",a):Q!=null&&j(a,C,Q,O))}switch(p){case"input":Ve(a),xt(a,b,!1);break;case"textarea":Ve(a),ge(a);break;case"option":b.value!=null&&a.setAttribute("value",""+Ee(b.value));break;case"select":a.multiple=!!b.multiple,C=b.value,C!=null?Ye(a,!!b.multiple,C,!1):b.defaultValue!=null&&Ye(a,!!b.multiple,b.defaultValue,!0);break;default:typeof E.onClick=="function"&&(a.onclick=dc)}switch(p){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}}b&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return sr(u),null;case 6:if(a&&u.stateNode!=null)y0(a,u,a.memoizedProps,b);else{if(typeof b!="string"&&u.stateNode===null)throw Error(n(166));if(p=Ji($a.current),Ji(bs.current),bc(u)){if(b=u.stateNode,p=u.memoizedProps,b[vs]=u,(C=b.nodeValue!==p)&&(a=Mr,a!==null))switch(a.tag){case 3:uc(b.nodeValue,p,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&uc(b.nodeValue,p,(a.mode&1)!==0)}C&&(u.flags|=4)}else b=(p.nodeType===9?p:p.ownerDocument).createTextNode(b),b[vs]=u,u.stateNode=b}return sr(u),null;case 13:if(sn(cn),b=u.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(an&&Ar!==null&&(u.mode&1)!==0&&(u.flags&128)===0)ky(),Fo(),u.flags|=98560,C=!1;else if(C=bc(u),b!==null&&b.dehydrated!==null){if(a===null){if(!C)throw Error(n(318));if(C=u.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[vs]=u}else Fo(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;sr(u),C=!1}else ns!==null&&(Oh(ns),ns=null),C=!0;if(!C)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=p,u):(b=b!==null,b!==(a!==null&&a.memoizedState!==null)&&b&&(u.child.flags|=8192,(u.mode&1)!==0&&(a===null||(cn.current&1)!==0?On===0&&(On=3):Dh())),u.updateQueue!==null&&(u.flags|=4),sr(u),null);case 4:return Wo(),kh(a,u),a===null&&Ra(u.stateNode.containerInfo),sr(u),null;case 10:return Yf(u.type._context),sr(u),null;case 17:return yr(u.type)&&hc(),sr(u),null;case 19:if(sn(cn),C=u.memoizedState,C===null)return sr(u),null;if(b=(u.flags&128)!==0,O=C.rendering,O===null)if(b)Wa(C,!1);else{if(On!==0||a!==null&&(a.flags&128)!==0)for(a=u.child;a!==null;){if(O=Ec(a),O!==null){for(u.flags|=128,Wa(C,!1),b=O.updateQueue,b!==null&&(u.updateQueue=b,u.flags|=4),u.subtreeFlags=0,b=p,p=u.child;p!==null;)C=p,a=b,C.flags&=14680066,O=C.alternate,O===null?(C.childLanes=0,C.lanes=a,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=O.childLanes,C.lanes=O.lanes,C.child=O.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=O.memoizedProps,C.memoizedState=O.memoizedState,C.updateQueue=O.updateQueue,C.type=O.type,a=O.dependencies,C.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),p=p.sibling;return en(cn,cn.current&1|2),u.child}a=a.sibling}C.tail!==null&&Wt()>Go&&(u.flags|=128,b=!0,Wa(C,!1),u.lanes=4194304)}else{if(!b)if(a=Ec(O),a!==null){if(u.flags|=128,b=!0,p=a.updateQueue,p!==null&&(u.updateQueue=p,u.flags|=4),Wa(C,!0),C.tail===null&&C.tailMode==="hidden"&&!O.alternate&&!an)return sr(u),null}else 2*Wt()-C.renderingStartTime>Go&&p!==1073741824&&(u.flags|=128,b=!0,Wa(C,!1),u.lanes=4194304);C.isBackwards?(O.sibling=u.child,u.child=O):(p=C.last,p!==null?p.sibling=O:u.child=O,C.last=O)}return C.tail!==null?(u=C.tail,C.rendering=u,C.tail=u.sibling,C.renderingStartTime=Wt(),u.sibling=null,p=cn.current,en(cn,b?p&1|2:p&1),u):(sr(u),null);case 22:case 23:return Lh(),b=u.memoizedState!==null,a!==null&&a.memoizedState!==null!==b&&(u.flags|=8192),b&&(u.mode&1)!==0?(Rr&1073741824)!==0&&(sr(u),u.subtreeFlags&6&&(u.flags|=8192)):sr(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function tM(a,u){switch(Wf(u),u.tag){case 1:return yr(u.type)&&hc(),a=u.flags,a&65536?(u.flags=a&-65537|128,u):null;case 3:return Wo(),sn(br),sn(nr),rh(),a=u.flags,(a&65536)!==0&&(a&128)===0?(u.flags=a&-65537|128,u):null;case 5:return th(u),null;case 13:if(sn(cn),a=u.memoizedState,a!==null&&a.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Fo()}return a=u.flags,a&65536?(u.flags=a&-65537|128,u):null;case 19:return sn(cn),null;case 4:return Wo(),null;case 10:return Yf(u.type._context),null;case 22:case 23:return Lh(),null;case 24:return null;default:return null}}var Oc=!1,ir=!1,nM=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function qo(a,u){var p=a.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(b){mn(a,u,b)}else p.current=null}function Sh(a,u,p){try{p()}catch(b){mn(a,u,b)}}var x0=!1;function rM(a,u){if(Lf=Zl,a=Qb(),_f(a)){if("selectionStart"in a)var p={start:a.selectionStart,end:a.selectionEnd};else e:{p=(p=a.ownerDocument)&&p.defaultView||window;var b=p.getSelection&&p.getSelection();if(b&&b.rangeCount!==0){p=b.anchorNode;var E=b.anchorOffset,C=b.focusNode;b=b.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var O=0,H=-1,Q=-1,pe=0,Ce=0,_e=a,Ne=null;t:for(;;){for(var He;_e!==p||E!==0&&_e.nodeType!==3||(H=O+E),_e!==C||b!==0&&_e.nodeType!==3||(Q=O+b),_e.nodeType===3&&(O+=_e.nodeValue.length),(He=_e.firstChild)!==null;)Ne=_e,_e=He;for(;;){if(_e===a)break t;if(Ne===p&&++pe===E&&(H=O),Ne===C&&++Ce===b&&(Q=O),(He=_e.nextSibling)!==null)break;_e=Ne,Ne=_e.parentNode}_e=He}p=H===-1||Q===-1?null:{start:H,end:Q}}else p=null}p=p||{start:0,end:0}}else p=null;for(Df={focusedElem:a,selectionRange:p},Zl=!1,Ge=u;Ge!==null;)if(u=Ge,a=u.child,(u.subtreeFlags&1028)!==0&&a!==null)a.return=u,Ge=a;else for(;Ge!==null;){u=Ge;try{var Je=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(Je!==null){var Ze=Je.memoizedProps,Sn=Je.memoizedState,ce=u.stateNode,se=ce.getSnapshotBeforeUpdate(u.elementType===u.type?Ze:rs(u.type,Ze),Sn);ce.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var de=u.stateNode.containerInfo;de.nodeType===1?de.textContent="":de.nodeType===9&&de.documentElement&&de.removeChild(de.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Oe){mn(u,u.return,Oe)}if(a=u.sibling,a!==null){a.return=u.return,Ge=a;break}Ge=u.return}return Je=x0,x0=!1,Je}function Va(a,u,p){var b=u.updateQueue;if(b=b!==null?b.lastEffect:null,b!==null){var E=b=b.next;do{if((E.tag&a)===a){var C=E.destroy;E.destroy=void 0,C!==void 0&&Sh(u,p,C)}E=E.next}while(E!==b)}}function Ic(a,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var p=u=u.next;do{if((p.tag&a)===a){var b=p.create;p.destroy=b()}p=p.next}while(p!==u)}}function Eh(a){var u=a.ref;if(u!==null){var p=a.stateNode;switch(a.tag){case 5:a=p;break;default:a=p}typeof u=="function"?u(a):u.current=a}}function w0(a){var u=a.alternate;u!==null&&(a.alternate=null,w0(u)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(u=a.stateNode,u!==null&&(delete u[vs],delete u[Ia],delete u[Ff],delete u[$j],delete u[Fj])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function k0(a){return a.tag===5||a.tag===3||a.tag===4}function S0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||k0(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Nh(a,u,p){var b=a.tag;if(b===5||b===6)a=a.stateNode,u?p.nodeType===8?p.parentNode.insertBefore(a,u):p.insertBefore(a,u):(p.nodeType===8?(u=p.parentNode,u.insertBefore(a,p)):(u=p,u.appendChild(a)),p=p._reactRootContainer,p!=null||u.onclick!==null||(u.onclick=dc));else if(b!==4&&(a=a.child,a!==null))for(Nh(a,u,p),a=a.sibling;a!==null;)Nh(a,u,p),a=a.sibling}function Ch(a,u,p){var b=a.tag;if(b===5||b===6)a=a.stateNode,u?p.insertBefore(a,u):p.appendChild(a);else if(b!==4&&(a=a.child,a!==null))for(Ch(a,u,p),a=a.sibling;a!==null;)Ch(a,u,p),a=a.sibling}var Gn=null,ss=!1;function li(a,u,p){for(p=p.child;p!==null;)E0(a,u,p),p=p.sibling}function E0(a,u,p){if(kt&&typeof kt.onCommitFiberUnmount=="function")try{kt.onCommitFiberUnmount(wt,p)}catch{}switch(p.tag){case 5:ir||qo(p,u);case 6:var b=Gn,E=ss;Gn=null,li(a,u,p),Gn=b,ss=E,Gn!==null&&(ss?(a=Gn,p=p.stateNode,a.nodeType===8?a.parentNode.removeChild(p):a.removeChild(p)):Gn.removeChild(p.stateNode));break;case 18:Gn!==null&&(ss?(a=Gn,p=p.stateNode,a.nodeType===8?$f(a.parentNode,p):a.nodeType===1&&$f(a,p),Sa(a)):$f(Gn,p.stateNode));break;case 4:b=Gn,E=ss,Gn=p.stateNode.containerInfo,ss=!0,li(a,u,p),Gn=b,ss=E;break;case 0:case 11:case 14:case 15:if(!ir&&(b=p.updateQueue,b!==null&&(b=b.lastEffect,b!==null))){E=b=b.next;do{var C=E,O=C.destroy;C=C.tag,O!==void 0&&((C&2)!==0||(C&4)!==0)&&Sh(p,u,O),E=E.next}while(E!==b)}li(a,u,p);break;case 1:if(!ir&&(qo(p,u),b=p.stateNode,typeof b.componentWillUnmount=="function"))try{b.props=p.memoizedProps,b.state=p.memoizedState,b.componentWillUnmount()}catch(H){mn(p,u,H)}li(a,u,p);break;case 21:li(a,u,p);break;case 22:p.mode&1?(ir=(b=ir)||p.memoizedState!==null,li(a,u,p),ir=b):li(a,u,p);break;default:li(a,u,p)}}function N0(a){var u=a.updateQueue;if(u!==null){a.updateQueue=null;var p=a.stateNode;p===null&&(p=a.stateNode=new nM),u.forEach(function(b){var E=fM.bind(null,a,b);p.has(b)||(p.add(b),b.then(E,E))})}}function is(a,u){var p=u.deletions;if(p!==null)for(var b=0;b<p.length;b++){var E=p[b];try{var C=a,O=u,H=O;e:for(;H!==null;){switch(H.tag){case 5:Gn=H.stateNode,ss=!1;break e;case 3:Gn=H.stateNode.containerInfo,ss=!0;break e;case 4:Gn=H.stateNode.containerInfo,ss=!0;break e}H=H.return}if(Gn===null)throw Error(n(160));E0(C,O,E),Gn=null,ss=!1;var Q=E.alternate;Q!==null&&(Q.return=null),E.return=null}catch(pe){mn(E,u,pe)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)C0(u,a),u=u.sibling}function C0(a,u){var p=a.alternate,b=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(is(u,a),xs(a),b&4){try{Va(3,a,a.return),Ic(3,a)}catch(Ze){mn(a,a.return,Ze)}try{Va(5,a,a.return)}catch(Ze){mn(a,a.return,Ze)}}break;case 1:is(u,a),xs(a),b&512&&p!==null&&qo(p,p.return);break;case 5:if(is(u,a),xs(a),b&512&&p!==null&&qo(p,p.return),a.flags&32){var E=a.stateNode;try{Ae(E,"")}catch(Ze){mn(a,a.return,Ze)}}if(b&4&&(E=a.stateNode,E!=null)){var C=a.memoizedProps,O=p!==null?p.memoizedProps:C,H=a.type,Q=a.updateQueue;if(a.updateQueue=null,Q!==null)try{H==="input"&&C.type==="radio"&&C.name!=null&&be(E,C),mt(H,O);var pe=mt(H,C);for(O=0;O<Q.length;O+=2){var Ce=Q[O],_e=Q[O+1];Ce==="style"?We(E,_e):Ce==="dangerouslySetInnerHTML"?ze(E,_e):Ce==="children"?Ae(E,_e):j(E,Ce,_e,pe)}switch(H){case"input":ht(E,C);break;case"textarea":G(E,C);break;case"select":var Ne=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!C.multiple;var He=C.value;He!=null?Ye(E,!!C.multiple,He,!1):Ne!==!!C.multiple&&(C.defaultValue!=null?Ye(E,!!C.multiple,C.defaultValue,!0):Ye(E,!!C.multiple,C.multiple?[]:"",!1))}E[Ia]=C}catch(Ze){mn(a,a.return,Ze)}}break;case 6:if(is(u,a),xs(a),b&4){if(a.stateNode===null)throw Error(n(162));E=a.stateNode,C=a.memoizedProps;try{E.nodeValue=C}catch(Ze){mn(a,a.return,Ze)}}break;case 3:if(is(u,a),xs(a),b&4&&p!==null&&p.memoizedState.isDehydrated)try{Sa(u.containerInfo)}catch(Ze){mn(a,a.return,Ze)}break;case 4:is(u,a),xs(a);break;case 13:is(u,a),xs(a),E=a.child,E.flags&8192&&(C=E.memoizedState!==null,E.stateNode.isHidden=C,!C||E.alternate!==null&&E.alternate.memoizedState!==null||(jh=Wt())),b&4&&N0(a);break;case 22:if(Ce=p!==null&&p.memoizedState!==null,a.mode&1?(ir=(pe=ir)||Ce,is(u,a),ir=pe):is(u,a),xs(a),b&8192){if(pe=a.memoizedState!==null,(a.stateNode.isHidden=pe)&&!Ce&&(a.mode&1)!==0)for(Ge=a,Ce=a.child;Ce!==null;){for(_e=Ge=Ce;Ge!==null;){switch(Ne=Ge,He=Ne.child,Ne.tag){case 0:case 11:case 14:case 15:Va(4,Ne,Ne.return);break;case 1:qo(Ne,Ne.return);var Je=Ne.stateNode;if(typeof Je.componentWillUnmount=="function"){b=Ne,p=Ne.return;try{u=b,Je.props=u.memoizedProps,Je.state=u.memoizedState,Je.componentWillUnmount()}catch(Ze){mn(b,p,Ze)}}break;case 5:qo(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){j0(_e);continue}}He!==null?(He.return=Ne,Ge=He):j0(_e)}Ce=Ce.sibling}e:for(Ce=null,_e=a;;){if(_e.tag===5){if(Ce===null){Ce=_e;try{E=_e.stateNode,pe?(C=E.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(H=_e.stateNode,Q=_e.memoizedProps.style,O=Q!=null&&Q.hasOwnProperty("display")?Q.display:null,H.style.display=tt("display",O))}catch(Ze){mn(a,a.return,Ze)}}}else if(_e.tag===6){if(Ce===null)try{_e.stateNode.nodeValue=pe?"":_e.memoizedProps}catch(Ze){mn(a,a.return,Ze)}}else if((_e.tag!==22&&_e.tag!==23||_e.memoizedState===null||_e===a)&&_e.child!==null){_e.child.return=_e,_e=_e.child;continue}if(_e===a)break e;for(;_e.sibling===null;){if(_e.return===null||_e.return===a)break e;Ce===_e&&(Ce=null),_e=_e.return}Ce===_e&&(Ce=null),_e.sibling.return=_e.return,_e=_e.sibling}}break;case 19:is(u,a),xs(a),b&4&&N0(a);break;case 21:break;default:is(u,a),xs(a)}}function xs(a){var u=a.flags;if(u&2){try{e:{for(var p=a.return;p!==null;){if(k0(p)){var b=p;break e}p=p.return}throw Error(n(160))}switch(b.tag){case 5:var E=b.stateNode;b.flags&32&&(Ae(E,""),b.flags&=-33);var C=S0(a);Ch(a,C,E);break;case 3:case 4:var O=b.stateNode.containerInfo,H=S0(a);Nh(a,H,O);break;default:throw Error(n(161))}}catch(Q){mn(a,a.return,Q)}a.flags&=-3}u&4096&&(a.flags&=-4097)}function sM(a,u,p){Ge=a,_0(a)}function _0(a,u,p){for(var b=(a.mode&1)!==0;Ge!==null;){var E=Ge,C=E.child;if(E.tag===22&&b){var O=E.memoizedState!==null||Oc;if(!O){var H=E.alternate,Q=H!==null&&H.memoizedState!==null||ir;H=Oc;var pe=ir;if(Oc=O,(ir=Q)&&!pe)for(Ge=E;Ge!==null;)O=Ge,Q=O.child,O.tag===22&&O.memoizedState!==null?M0(E):Q!==null?(Q.return=O,Ge=Q):M0(E);for(;C!==null;)Ge=C,_0(C),C=C.sibling;Ge=E,Oc=H,ir=pe}T0(a)}else(E.subtreeFlags&8772)!==0&&C!==null?(C.return=E,Ge=C):T0(a)}}function T0(a){for(;Ge!==null;){var u=Ge;if((u.flags&8772)!==0){var p=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:ir||Ic(5,u);break;case 1:var b=u.stateNode;if(u.flags&4&&!ir)if(p===null)b.componentDidMount();else{var E=u.elementType===u.type?p.memoizedProps:rs(u.type,p.memoizedProps);b.componentDidUpdate(E,p.memoizedState,b.__reactInternalSnapshotBeforeUpdate)}var C=u.updateQueue;C!==null&&jy(u,C,b);break;case 3:var O=u.updateQueue;if(O!==null){if(p=null,u.child!==null)switch(u.child.tag){case 5:p=u.child.stateNode;break;case 1:p=u.child.stateNode}jy(u,O,p)}break;case 5:var H=u.stateNode;if(p===null&&u.flags&4){p=H;var Q=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":Q.autoFocus&&p.focus();break;case"img":Q.src&&(p.src=Q.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var pe=u.alternate;if(pe!==null){var Ce=pe.memoizedState;if(Ce!==null){var _e=Ce.dehydrated;_e!==null&&Sa(_e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ir||u.flags&512&&Eh(u)}catch(Ne){mn(u,u.return,Ne)}}if(u===a){Ge=null;break}if(p=u.sibling,p!==null){p.return=u.return,Ge=p;break}Ge=u.return}}function j0(a){for(;Ge!==null;){var u=Ge;if(u===a){Ge=null;break}var p=u.sibling;if(p!==null){p.return=u.return,Ge=p;break}Ge=u.return}}function M0(a){for(;Ge!==null;){var u=Ge;try{switch(u.tag){case 0:case 11:case 15:var p=u.return;try{Ic(4,u)}catch(Q){mn(u,p,Q)}break;case 1:var b=u.stateNode;if(typeof b.componentDidMount=="function"){var E=u.return;try{b.componentDidMount()}catch(Q){mn(u,E,Q)}}var C=u.return;try{Eh(u)}catch(Q){mn(u,C,Q)}break;case 5:var O=u.return;try{Eh(u)}catch(Q){mn(u,O,Q)}}}catch(Q){mn(u,u.return,Q)}if(u===a){Ge=null;break}var H=u.sibling;if(H!==null){H.return=u.return,Ge=H;break}Ge=u.return}}var iM=Math.ceil,Lc=M.ReactCurrentDispatcher,_h=M.ReactCurrentOwner,zr=M.ReactCurrentBatchConfig,Pt=0,$n=null,Tn=null,Jn=0,Rr=0,Ko=ri(0),On=0,qa=null,Xi=0,Dc=0,Th=0,Ka=null,wr=null,jh=0,Go=1/0,Ps=null,Pc=!1,Mh=null,ci=null,Bc=!1,ui=null,$c=0,Ga=0,Ah=null,Fc=-1,zc=0;function fr(){return(Pt&6)!==0?Wt():Fc!==-1?Fc:Fc=Wt()}function di(a){return(a.mode&1)===0?1:(Pt&2)!==0&&Jn!==0?Jn&-Jn:Uj.transition!==null?(zc===0&&(zc=Ct()),zc):(a=_t,a!==0||(a=window.event,a=a===void 0?16:Rb(a.type)),a)}function as(a,u,p,b){if(50<Ga)throw Ga=0,Ah=null,Error(n(185));Cn(a,p,b),((Pt&2)===0||a!==$n)&&(a===$n&&((Pt&2)===0&&(Dc|=p),On===4&&fi(a,Jn)),kr(a,b),p===1&&Pt===0&&(u.mode&1)===0&&(Go=Wt()+500,mc&&ii()))}function kr(a,u){var p=a.callbackNode;De(a,u);var b=Z(a,a===$n?Jn:0);if(b===0)p!==null&&An(p),a.callbackNode=null,a.callbackPriority=0;else if(u=b&-b,a.callbackPriority!==u){if(p!=null&&An(p),u===1)a.tag===0?zj(R0.bind(null,a)):vy(R0.bind(null,a)),Pj(function(){(Pt&6)===0&&ii()}),p=null;else{switch(rt(b)){case 1:p=Qr;break;case 4:p=Kn;break;case 16:p=js;break;case 536870912:p=et;break;default:p=js}p=F0(p,A0.bind(null,a))}a.callbackPriority=u,a.callbackNode=p}}function A0(a,u){if(Fc=-1,zc=0,(Pt&6)!==0)throw Error(n(327));var p=a.callbackNode;if(Jo()&&a.callbackNode!==p)return null;var b=Z(a,a===$n?Jn:0);if(b===0)return null;if((b&30)!==0||(b&a.expiredLanes)!==0||u)u=Uc(a,b);else{u=b;var E=Pt;Pt|=2;var C=I0();($n!==a||Jn!==u)&&(Ps=null,Go=Wt()+500,Zi(a,u));do try{lM();break}catch(H){O0(a,H)}while(!0);Jf(),Lc.current=C,Pt=E,Tn!==null?u=0:($n=null,Jn=0,u=On)}if(u!==0){if(u===2&&(E=bt(a),E!==0&&(b=E,u=Rh(a,E))),u===1)throw p=qa,Zi(a,0),fi(a,b),kr(a,Wt()),p;if(u===6)fi(a,b);else{if(E=a.current.alternate,(b&30)===0&&!oM(E)&&(u=Uc(a,b),u===2&&(C=bt(a),C!==0&&(b=C,u=Rh(a,C))),u===1))throw p=qa,Zi(a,0),fi(a,b),kr(a,Wt()),p;switch(a.finishedWork=E,a.finishedLanes=b,u){case 0:case 1:throw Error(n(345));case 2:eo(a,wr,Ps);break;case 3:if(fi(a,b),(b&130023424)===b&&(u=jh+500-Wt(),10<u)){if(Z(a,0)!==0)break;if(E=a.suspendedLanes,(E&b)!==b){fr(),a.pingedLanes|=a.suspendedLanes&E;break}a.timeoutHandle=Bf(eo.bind(null,a,wr,Ps),u);break}eo(a,wr,Ps);break;case 4:if(fi(a,b),(b&4194240)===b)break;for(u=a.eventTimes,E=-1;0<b;){var O=31-Zt(b);C=1<<O,O=u[O],O>E&&(E=O),b&=~C}if(b=E,b=Wt()-b,b=(120>b?120:480>b?480:1080>b?1080:1920>b?1920:3e3>b?3e3:4320>b?4320:1960*iM(b/1960))-b,10<b){a.timeoutHandle=Bf(eo.bind(null,a,wr,Ps),b);break}eo(a,wr,Ps);break;case 5:eo(a,wr,Ps);break;default:throw Error(n(329))}}}return kr(a,Wt()),a.callbackNode===p?A0.bind(null,a):null}function Rh(a,u){var p=Ka;return a.current.memoizedState.isDehydrated&&(Zi(a,u).flags|=256),a=Uc(a,u),a!==2&&(u=wr,wr=p,u!==null&&Oh(u)),a}function Oh(a){wr===null?wr=a:wr.push.apply(wr,a)}function oM(a){for(var u=a;;){if(u.flags&16384){var p=u.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var b=0;b<p.length;b++){var E=p[b],C=E.getSnapshot;E=E.value;try{if(!ts(C(),E))return!1}catch{return!1}}}if(p=u.child,u.subtreeFlags&16384&&p!==null)p.return=u,u=p;else{if(u===a)break;for(;u.sibling===null;){if(u.return===null||u.return===a)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function fi(a,u){for(u&=~Th,u&=~Dc,a.suspendedLanes|=u,a.pingedLanes&=~u,a=a.expirationTimes;0<u;){var p=31-Zt(u),b=1<<p;a[p]=-1,u&=~b}}function R0(a){if((Pt&6)!==0)throw Error(n(327));Jo();var u=Z(a,0);if((u&1)===0)return kr(a,Wt()),null;var p=Uc(a,u);if(a.tag!==0&&p===2){var b=bt(a);b!==0&&(u=b,p=Rh(a,b))}if(p===1)throw p=qa,Zi(a,0),fi(a,u),kr(a,Wt()),p;if(p===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=u,eo(a,wr,Ps),kr(a,Wt()),null}function Ih(a,u){var p=Pt;Pt|=1;try{return a(u)}finally{Pt=p,Pt===0&&(Go=Wt()+500,mc&&ii())}}function Qi(a){ui!==null&&ui.tag===0&&(Pt&6)===0&&Jo();var u=Pt;Pt|=1;var p=zr.transition,b=_t;try{if(zr.transition=null,_t=1,a)return a()}finally{_t=b,zr.transition=p,Pt=u,(Pt&6)===0&&ii()}}function Lh(){Rr=Ko.current,sn(Ko)}function Zi(a,u){a.finishedWork=null,a.finishedLanes=0;var p=a.timeoutHandle;if(p!==-1&&(a.timeoutHandle=-1,Dj(p)),Tn!==null)for(p=Tn.return;p!==null;){var b=p;switch(Wf(b),b.tag){case 1:b=b.type.childContextTypes,b!=null&&hc();break;case 3:Wo(),sn(br),sn(nr),rh();break;case 5:th(b);break;case 4:Wo();break;case 13:sn(cn);break;case 19:sn(cn);break;case 10:Yf(b.type._context);break;case 22:case 23:Lh()}p=p.return}if($n=a,Tn=a=hi(a.current,null),Jn=Rr=u,On=0,qa=null,Th=Dc=Xi=0,wr=Ka=null,Gi!==null){for(u=0;u<Gi.length;u++)if(p=Gi[u],b=p.interleaved,b!==null){p.interleaved=null;var E=b.next,C=p.pending;if(C!==null){var O=C.next;C.next=E,b.next=O}p.pending=b}Gi=null}return a}function O0(a,u){do{var p=Tn;try{if(Jf(),Nc.current=jc,Cc){for(var b=un.memoizedState;b!==null;){var E=b.queue;E!==null&&(E.pending=null),b=b.next}Cc=!1}if(Yi=0,Bn=Rn=un=null,Fa=!1,za=0,_h.current=null,p===null||p.return===null){On=1,qa=u,Tn=null;break}e:{var C=a,O=p.return,H=p,Q=u;if(u=Jn,H.flags|=32768,Q!==null&&typeof Q=="object"&&typeof Q.then=="function"){var pe=Q,Ce=H,_e=Ce.tag;if((Ce.mode&1)===0&&(_e===0||_e===11||_e===15)){var Ne=Ce.alternate;Ne?(Ce.updateQueue=Ne.updateQueue,Ce.memoizedState=Ne.memoizedState,Ce.lanes=Ne.lanes):(Ce.updateQueue=null,Ce.memoizedState=null)}var He=s0(O);if(He!==null){He.flags&=-257,i0(He,O,H,C,u),He.mode&1&&r0(C,pe,u),u=He,Q=pe;var Je=u.updateQueue;if(Je===null){var Ze=new Set;Ze.add(Q),u.updateQueue=Ze}else Je.add(Q);break e}else{if((u&1)===0){r0(C,pe,u),Dh();break e}Q=Error(n(426))}}else if(an&&H.mode&1){var Sn=s0(O);if(Sn!==null){(Sn.flags&65536)===0&&(Sn.flags|=256),i0(Sn,O,H,C,u),Kf(Vo(Q,H));break e}}C=Q=Vo(Q,H),On!==4&&(On=2),Ka===null?Ka=[C]:Ka.push(C),C=O;do{switch(C.tag){case 3:C.flags|=65536,u&=-u,C.lanes|=u;var ce=t0(C,Q,u);Ty(C,ce);break e;case 1:H=Q;var se=C.type,de=C.stateNode;if((C.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||de!==null&&typeof de.componentDidCatch=="function"&&(ci===null||!ci.has(de)))){C.flags|=65536,u&=-u,C.lanes|=u;var Oe=n0(C,H,u);Ty(C,Oe);break e}}C=C.return}while(C!==null)}D0(p)}catch(nt){u=nt,Tn===p&&p!==null&&(Tn=p=p.return);continue}break}while(!0)}function I0(){var a=Lc.current;return Lc.current=jc,a===null?jc:a}function Dh(){(On===0||On===3||On===2)&&(On=4),$n===null||(Xi&268435455)===0&&(Dc&268435455)===0||fi($n,Jn)}function Uc(a,u){var p=Pt;Pt|=2;var b=I0();($n!==a||Jn!==u)&&(Ps=null,Zi(a,u));do try{aM();break}catch(E){O0(a,E)}while(!0);if(Jf(),Pt=p,Lc.current=b,Tn!==null)throw Error(n(261));return $n=null,Jn=0,On}function aM(){for(;Tn!==null;)L0(Tn)}function lM(){for(;Tn!==null&&!ur();)L0(Tn)}function L0(a){var u=$0(a.alternate,a,Rr);a.memoizedProps=a.pendingProps,u===null?D0(a):Tn=u,_h.current=null}function D0(a){var u=a;do{var p=u.alternate;if(a=u.return,(u.flags&32768)===0){if(p=eM(p,u,Rr),p!==null){Tn=p;return}}else{if(p=tM(p,u),p!==null){p.flags&=32767,Tn=p;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{On=6,Tn=null;return}}if(u=u.sibling,u!==null){Tn=u;return}Tn=u=a}while(u!==null);On===0&&(On=5)}function eo(a,u,p){var b=_t,E=zr.transition;try{zr.transition=null,_t=1,cM(a,u,p,b)}finally{zr.transition=E,_t=b}return null}function cM(a,u,p,b){do Jo();while(ui!==null);if((Pt&6)!==0)throw Error(n(327));p=a.finishedWork;var E=a.finishedLanes;if(p===null)return null;if(a.finishedWork=null,a.finishedLanes=0,p===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var C=p.lanes|p.childLanes;if(_n(a,C),a===$n&&(Tn=$n=null,Jn=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Bc||(Bc=!0,F0(js,function(){return Jo(),null})),C=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||C){C=zr.transition,zr.transition=null;var O=_t;_t=1;var H=Pt;Pt|=4,_h.current=null,rM(a,p),C0(p,a),jj(Df),Zl=!!Lf,Df=Lf=null,a.current=p,sM(p),Xs(),Pt=H,_t=O,zr.transition=C}else a.current=p;if(Bc&&(Bc=!1,ui=a,$c=E),C=a.pendingLanes,C===0&&(ci=null),Qt(p.stateNode),kr(a,Wt()),u!==null)for(b=a.onRecoverableError,p=0;p<u.length;p++)E=u[p],b(E.value,{componentStack:E.stack,digest:E.digest});if(Pc)throw Pc=!1,a=Mh,Mh=null,a;return($c&1)!==0&&a.tag!==0&&Jo(),C=a.pendingLanes,(C&1)!==0?a===Ah?Ga++:(Ga=0,Ah=a):Ga=0,ii(),null}function Jo(){if(ui!==null){var a=rt($c),u=zr.transition,p=_t;try{if(zr.transition=null,_t=16>a?16:a,ui===null)var b=!1;else{if(a=ui,ui=null,$c=0,(Pt&6)!==0)throw Error(n(331));var E=Pt;for(Pt|=4,Ge=a.current;Ge!==null;){var C=Ge,O=C.child;if((Ge.flags&16)!==0){var H=C.deletions;if(H!==null){for(var Q=0;Q<H.length;Q++){var pe=H[Q];for(Ge=pe;Ge!==null;){var Ce=Ge;switch(Ce.tag){case 0:case 11:case 15:Va(8,Ce,C)}var _e=Ce.child;if(_e!==null)_e.return=Ce,Ge=_e;else for(;Ge!==null;){Ce=Ge;var Ne=Ce.sibling,He=Ce.return;if(w0(Ce),Ce===pe){Ge=null;break}if(Ne!==null){Ne.return=He,Ge=Ne;break}Ge=He}}}var Je=C.alternate;if(Je!==null){var Ze=Je.child;if(Ze!==null){Je.child=null;do{var Sn=Ze.sibling;Ze.sibling=null,Ze=Sn}while(Ze!==null)}}Ge=C}}if((C.subtreeFlags&2064)!==0&&O!==null)O.return=C,Ge=O;else e:for(;Ge!==null;){if(C=Ge,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:Va(9,C,C.return)}var ce=C.sibling;if(ce!==null){ce.return=C.return,Ge=ce;break e}Ge=C.return}}var se=a.current;for(Ge=se;Ge!==null;){O=Ge;var de=O.child;if((O.subtreeFlags&2064)!==0&&de!==null)de.return=O,Ge=de;else e:for(O=se;Ge!==null;){if(H=Ge,(H.flags&2048)!==0)try{switch(H.tag){case 0:case 11:case 15:Ic(9,H)}}catch(nt){mn(H,H.return,nt)}if(H===O){Ge=null;break e}var Oe=H.sibling;if(Oe!==null){Oe.return=H.return,Ge=Oe;break e}Ge=H.return}}if(Pt=E,ii(),kt&&typeof kt.onPostCommitFiberRoot=="function")try{kt.onPostCommitFiberRoot(wt,a)}catch{}b=!0}return b}finally{_t=p,zr.transition=u}}return!1}function P0(a,u,p){u=Vo(p,u),u=t0(a,u,1),a=ai(a,u,1),u=fr(),a!==null&&(Cn(a,1,u),kr(a,u))}function mn(a,u,p){if(a.tag===3)P0(a,a,p);else for(;u!==null;){if(u.tag===3){P0(u,a,p);break}else if(u.tag===1){var b=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(ci===null||!ci.has(b))){a=Vo(p,a),a=n0(u,a,1),u=ai(u,a,1),a=fr(),u!==null&&(Cn(u,1,a),kr(u,a));break}}u=u.return}}function uM(a,u,p){var b=a.pingCache;b!==null&&b.delete(u),u=fr(),a.pingedLanes|=a.suspendedLanes&p,$n===a&&(Jn&p)===p&&(On===4||On===3&&(Jn&130023424)===Jn&&500>Wt()-jh?Zi(a,0):Th|=p),kr(a,u)}function B0(a,u){u===0&&((a.mode&1)===0?u=1:(u=ms,ms<<=1,(ms&130023424)===0&&(ms=4194304)));var p=fr();a=Is(a,u),a!==null&&(Cn(a,u,p),kr(a,p))}function dM(a){var u=a.memoizedState,p=0;u!==null&&(p=u.retryLane),B0(a,p)}function fM(a,u){var p=0;switch(a.tag){case 13:var b=a.stateNode,E=a.memoizedState;E!==null&&(p=E.retryLane);break;case 19:b=a.stateNode;break;default:throw Error(n(314))}b!==null&&b.delete(u),B0(a,p)}var $0;$0=function(a,u,p){if(a!==null)if(a.memoizedProps!==u.pendingProps||br.current)xr=!0;else{if((a.lanes&p)===0&&(u.flags&128)===0)return xr=!1,Zj(a,u,p);xr=(a.flags&131072)!==0}else xr=!1,an&&(u.flags&1048576)!==0&&by(u,vc,u.index);switch(u.lanes=0,u.tag){case 2:var b=u.type;Rc(a,u),a=u.pendingProps;var E=Po(u,nr.current);Ho(u,p),E=oh(null,u,b,a,E,p);var C=ah();return u.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,yr(b)?(C=!0,pc(u)):C=!1,u.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,Zf(u),E.updater=Mc,u.stateNode=E,E._reactInternals=u,hh(u,b,a,p),u=vh(null,u,b,!0,C,p)):(u.tag=0,an&&C&&Hf(u),dr(null,u,E,p),u=u.child),u;case 16:b=u.elementType;e:{switch(Rc(a,u),a=u.pendingProps,E=b._init,b=E(b._payload),u.type=b,E=u.tag=pM(b),a=rs(b,a),E){case 0:u=gh(null,u,b,a,p);break e;case 1:u=d0(null,u,b,a,p);break e;case 11:u=o0(null,u,b,a,p);break e;case 14:u=a0(null,u,b,rs(b.type,a),p);break e}throw Error(n(306,b,""))}return u;case 0:return b=u.type,E=u.pendingProps,E=u.elementType===b?E:rs(b,E),gh(a,u,b,E,p);case 1:return b=u.type,E=u.pendingProps,E=u.elementType===b?E:rs(b,E),d0(a,u,b,E,p);case 3:e:{if(f0(u),a===null)throw Error(n(387));b=u.pendingProps,C=u.memoizedState,E=C.element,_y(a,u),Sc(u,b,null,p);var O=u.memoizedState;if(b=O.element,C.isDehydrated)if(C={element:b,isDehydrated:!1,cache:O.cache,pendingSuspenseBoundaries:O.pendingSuspenseBoundaries,transitions:O.transitions},u.updateQueue.baseState=C,u.memoizedState=C,u.flags&256){E=Vo(Error(n(423)),u),u=h0(a,u,b,p,E);break e}else if(b!==E){E=Vo(Error(n(424)),u),u=h0(a,u,b,p,E);break e}else for(Ar=ni(u.stateNode.containerInfo.firstChild),Mr=u,an=!0,ns=null,p=Ny(u,null,b,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Fo(),b===E){u=Ds(a,u,p);break e}dr(a,u,b,p)}u=u.child}return u;case 5:return My(u),a===null&&qf(u),b=u.type,E=u.pendingProps,C=a!==null?a.memoizedProps:null,O=E.children,Pf(b,E)?O=null:C!==null&&Pf(b,C)&&(u.flags|=32),u0(a,u),dr(a,u,O,p),u.child;case 6:return a===null&&qf(u),null;case 13:return p0(a,u,p);case 4:return eh(u,u.stateNode.containerInfo),b=u.pendingProps,a===null?u.child=zo(u,null,b,p):dr(a,u,b,p),u.child;case 11:return b=u.type,E=u.pendingProps,E=u.elementType===b?E:rs(b,E),o0(a,u,b,E,p);case 7:return dr(a,u,u.pendingProps,p),u.child;case 8:return dr(a,u,u.pendingProps.children,p),u.child;case 12:return dr(a,u,u.pendingProps.children,p),u.child;case 10:e:{if(b=u.type._context,E=u.pendingProps,C=u.memoizedProps,O=E.value,en(xc,b._currentValue),b._currentValue=O,C!==null)if(ts(C.value,O)){if(C.children===E.children&&!br.current){u=Ds(a,u,p);break e}}else for(C=u.child,C!==null&&(C.return=u);C!==null;){var H=C.dependencies;if(H!==null){O=C.child;for(var Q=H.firstContext;Q!==null;){if(Q.context===b){if(C.tag===1){Q=Ls(-1,p&-p),Q.tag=2;var pe=C.updateQueue;if(pe!==null){pe=pe.shared;var Ce=pe.pending;Ce===null?Q.next=Q:(Q.next=Ce.next,Ce.next=Q),pe.pending=Q}}C.lanes|=p,Q=C.alternate,Q!==null&&(Q.lanes|=p),Xf(C.return,p,u),H.lanes|=p;break}Q=Q.next}}else if(C.tag===10)O=C.type===u.type?null:C.child;else if(C.tag===18){if(O=C.return,O===null)throw Error(n(341));O.lanes|=p,H=O.alternate,H!==null&&(H.lanes|=p),Xf(O,p,u),O=C.sibling}else O=C.child;if(O!==null)O.return=C;else for(O=C;O!==null;){if(O===u){O=null;break}if(C=O.sibling,C!==null){C.return=O.return,O=C;break}O=O.return}C=O}dr(a,u,E.children,p),u=u.child}return u;case 9:return E=u.type,b=u.pendingProps.children,Ho(u,p),E=$r(E),b=b(E),u.flags|=1,dr(a,u,b,p),u.child;case 14:return b=u.type,E=rs(b,u.pendingProps),E=rs(b.type,E),a0(a,u,b,E,p);case 15:return l0(a,u,u.type,u.pendingProps,p);case 17:return b=u.type,E=u.pendingProps,E=u.elementType===b?E:rs(b,E),Rc(a,u),u.tag=1,yr(b)?(a=!0,pc(u)):a=!1,Ho(u,p),Zy(u,b,E),hh(u,b,E,p),vh(null,u,b,!0,a,p);case 19:return g0(a,u,p);case 22:return c0(a,u,p)}throw Error(n(156,u.tag))};function F0(a,u){return hn(a,u)}function hM(a,u,p,b){this.tag=a,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ur(a,u,p,b){return new hM(a,u,p,b)}function Ph(a){return a=a.prototype,!(!a||!a.isReactComponent)}function pM(a){if(typeof a=="function")return Ph(a)?1:0;if(a!=null){if(a=a.$$typeof,a===z)return 11;if(a===U)return 14}return 2}function hi(a,u){var p=a.alternate;return p===null?(p=Ur(a.tag,u,a.key,a.mode),p.elementType=a.elementType,p.type=a.type,p.stateNode=a.stateNode,p.alternate=a,a.alternate=p):(p.pendingProps=u,p.type=a.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=a.flags&14680064,p.childLanes=a.childLanes,p.lanes=a.lanes,p.child=a.child,p.memoizedProps=a.memoizedProps,p.memoizedState=a.memoizedState,p.updateQueue=a.updateQueue,u=a.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=a.sibling,p.index=a.index,p.ref=a.ref,p}function Hc(a,u,p,b,E,C){var O=2;if(b=a,typeof a=="function")Ph(a)&&(O=1);else if(typeof a=="string")O=5;else e:switch(a){case L:return to(p.children,E,C,u);case $:O=8,E|=8;break;case B:return a=Ur(12,p,u,E|2),a.elementType=B,a.lanes=C,a;case ee:return a=Ur(13,p,u,E),a.elementType=ee,a.lanes=C,a;case P:return a=Ur(19,p,u,E),a.elementType=P,a.lanes=C,a;case ie:return Wc(p,E,C,u);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case F:O=10;break e;case K:O=9;break e;case z:O=11;break e;case U:O=14;break e;case J:O=16,b=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return u=Ur(O,p,u,E),u.elementType=a,u.type=b,u.lanes=C,u}function to(a,u,p,b){return a=Ur(7,a,b,u),a.lanes=p,a}function Wc(a,u,p,b){return a=Ur(22,a,b,u),a.elementType=ie,a.lanes=p,a.stateNode={isHidden:!1},a}function Bh(a,u,p){return a=Ur(6,a,null,u),a.lanes=p,a}function $h(a,u,p){return u=Ur(4,a.children!==null?a.children:[],a.key,u),u.lanes=p,u.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},u}function mM(a,u,p,b,E){this.tag=u,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=wn(0),this.expirationTimes=wn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wn(0),this.identifierPrefix=b,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function Fh(a,u,p,b,E,C,O,H,Q){return a=new mM(a,u,p,H,Q),u===1?(u=1,C===!0&&(u|=8)):u=0,C=Ur(3,null,null,u),a.current=C,C.stateNode=a,C.memoizedState={element:b,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zf(C),a}function gM(a,u,p){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:b==null?null:""+b,children:a,containerInfo:u,implementation:p}}function z0(a){if(!a)return si;a=a._reactInternals;e:{if(zt(a)!==a||a.tag!==1)throw Error(n(170));var u=a;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(yr(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(a.tag===1){var p=a.type;if(yr(p))return my(a,p,u)}return u}function U0(a,u,p,b,E,C,O,H,Q){return a=Fh(p,b,!0,a,E,C,O,H,Q),a.context=z0(null),p=a.current,b=fr(),E=di(p),C=Ls(b,E),C.callback=u??null,ai(p,C,E),a.current.lanes=E,Cn(a,E,b),kr(a,b),a}function Vc(a,u,p,b){var E=u.current,C=fr(),O=di(E);return p=z0(p),u.context===null?u.context=p:u.pendingContext=p,u=Ls(C,O),u.payload={element:a},b=b===void 0?null:b,b!==null&&(u.callback=b),a=ai(E,u,O),a!==null&&(as(a,E,O,C),kc(a,E,O)),O}function qc(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function H0(a,u){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var p=a.retryLane;a.retryLane=p!==0&&p<u?p:u}}function zh(a,u){H0(a,u),(a=a.alternate)&&H0(a,u)}function vM(){return null}var W0=typeof reportError=="function"?reportError:function(a){console.error(a)};function Uh(a){this._internalRoot=a}Kc.prototype.render=Uh.prototype.render=function(a){var u=this._internalRoot;if(u===null)throw Error(n(409));Vc(a,u,null,null)},Kc.prototype.unmount=Uh.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var u=a.containerInfo;Qi(function(){Vc(null,a,null,null)}),u[Ms]=null}};function Kc(a){this._internalRoot=a}Kc.prototype.unstable_scheduleHydration=function(a){if(a){var u=Ui();a={blockedOn:null,target:a,priority:u};for(var p=0;p<Pn.length&&u!==0&&u<Pn[p].priority;p++);Pn.splice(p,0,a),p===0&&Mb(a)}};function Hh(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Gc(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function V0(){}function bM(a,u,p,b,E){if(E){if(typeof b=="function"){var C=b;b=function(){var pe=qc(O);C.call(pe)}}var O=U0(u,b,a,0,null,!1,!1,"",V0);return a._reactRootContainer=O,a[Ms]=O.current,Ra(a.nodeType===8?a.parentNode:a),Qi(),O}for(;E=a.lastChild;)a.removeChild(E);if(typeof b=="function"){var H=b;b=function(){var pe=qc(Q);H.call(pe)}}var Q=Fh(a,0,!1,null,null,!1,!1,"",V0);return a._reactRootContainer=Q,a[Ms]=Q.current,Ra(a.nodeType===8?a.parentNode:a),Qi(function(){Vc(u,Q,p,b)}),Q}function Jc(a,u,p,b,E){var C=p._reactRootContainer;if(C){var O=C;if(typeof E=="function"){var H=E;E=function(){var Q=qc(O);H.call(Q)}}Vc(u,O,a,E)}else O=bM(p,u,a,E,b);return qc(O)}es=function(a){switch(a.tag){case 3:var u=a.stateNode;if(u.current.memoizedState.isDehydrated){var p=Zr(u.pendingLanes);p!==0&&(Dn(u,p|1),kr(u,Wt()),(Pt&6)===0&&(Go=Wt()+500,ii()))}break;case 13:Qi(function(){var b=Is(a,1);if(b!==null){var E=fr();as(b,a,1,E)}}),zh(a,1)}},kn=function(a){if(a.tag===13){var u=Is(a,134217728);if(u!==null){var p=fr();as(u,a,134217728,p)}zh(a,134217728)}},Kt=function(a){if(a.tag===13){var u=di(a),p=Is(a,u);if(p!==null){var b=fr();as(p,a,u,b)}zh(a,u)}},Ui=function(){return _t},gs=function(a,u){var p=_t;try{return _t=a,u()}finally{_t=p}},Jt=function(a,u,p){switch(u){case"input":if(ht(a,p),u=p.name,p.type==="radio"&&u!=null){for(p=a;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<p.length;u++){var b=p[u];if(b!==a&&b.form===a.form){var E=fc(b);if(!E)throw Error(n(90));Te(b),ht(b,E)}}}break;case"textarea":G(a,p);break;case"select":u=p.value,u!=null&&Ye(a,!!p.multiple,u,!1)}},ae=Ih,I=Qi;var yM={usingClientEntryPoint:!1,Events:[La,Lo,fc,T,W,Ih]},Ja={findFiberByHostInstance:Wi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xM={bundleType:Ja.bundleType,version:Ja.version,rendererPackageName:Ja.rendererPackageName,rendererConfig:Ja.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=vr(a),a===null?null:a.stateNode},findFiberByHostInstance:Ja.findFiberByHostInstance||vM,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Yc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Yc.isDisabled&&Yc.supportsFiber)try{wt=Yc.inject(xM),kt=Yc}catch{}}return Sr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=yM,Sr.createPortal=function(a,u){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Hh(u))throw Error(n(200));return gM(a,u,null,p)},Sr.createRoot=function(a,u){if(!Hh(a))throw Error(n(299));var p=!1,b="",E=W0;return u!=null&&(u.unstable_strictMode===!0&&(p=!0),u.identifierPrefix!==void 0&&(b=u.identifierPrefix),u.onRecoverableError!==void 0&&(E=u.onRecoverableError)),u=Fh(a,1,!1,null,null,p,!1,b,E),a[Ms]=u.current,Ra(a.nodeType===8?a.parentNode:a),new Uh(u)},Sr.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var u=a._reactInternals;if(u===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=vr(u),a=a===null?null:a.stateNode,a},Sr.flushSync=function(a){return Qi(a)},Sr.hydrate=function(a,u,p){if(!Gc(u))throw Error(n(200));return Jc(null,a,u,!0,p)},Sr.hydrateRoot=function(a,u,p){if(!Hh(a))throw Error(n(405));var b=p!=null&&p.hydratedSources||null,E=!1,C="",O=W0;if(p!=null&&(p.unstable_strictMode===!0&&(E=!0),p.identifierPrefix!==void 0&&(C=p.identifierPrefix),p.onRecoverableError!==void 0&&(O=p.onRecoverableError)),u=U0(u,null,a,1,p??null,E,!1,C,O),a[Ms]=u.current,Ra(a),b)for(a=0;a<b.length;a++)p=b[a],E=p._getVersion,E=E(p._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[p,E]:u.mutableSourceEagerHydrationData.push(p,E);return new Kc(u)},Sr.render=function(a,u,p){if(!Gc(u))throw Error(n(200));return Jc(null,a,u,!1,p)},Sr.unmountComponentAtNode=function(a){if(!Gc(a))throw Error(n(40));return a._reactRootContainer?(Qi(function(){Jc(null,null,a,!1,function(){a._reactRootContainer=null,a[Ms]=null})}),!0):!1},Sr.unstable_batchedUpdates=Ih,Sr.unstable_renderSubtreeIntoContainer=function(a,u,p,b){if(!Gc(p))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return Jc(a,u,p,!1,b)},Sr.version="18.3.1-next-f1338f8080-20240426",Sr}var ex;function ME(){if(ex)return qh.exports;ex=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),qh.exports=_M(),qh.exports}var tx;function TM(){if(tx)return Xc;tx=1;var t=ME();return Xc.createRoot=t.createRoot,Xc.hydrateRoot=t.hydrateRoot,Xc}var jM=TM();const MM=Dl(jM),AE=[{id:"charter",label:"Charter",description:"Charter serif"},{id:"source-serif",label:"Source Serif",description:"Source Serif 4"},{id:"plex-mono",label:"Plex Mono",description:"IBM Plex Mono"},{id:"crimson",label:"Crimson",description:"Crimson Pro"},{id:"inter",label:"Inter",description:"Inter sans-serif"},{id:"baskerville",label:"Baskerville",description:"Libre Baskerville"},{id:"grotesk",label:"Grotesk",description:"Space Grotesk"},{id:"literata",label:"Literata",description:"Literata serif"},{id:"dm-sans",label:"DM Sans",description:"DM Sans + Serif"}],RE=[{id:"files",label:"Files",icon:"files"},{id:"default",label:"Tree",icon:"tree"},{id:"timeline",label:"Timeline",icon:"timeline"},{id:"board",label:"Board",icon:"board"}],OE=[{id:"seamless",label:"Seamless"},{id:"outline",label:"Outline"},{id:"page",label:"Page"},{id:"paper",label:"Paper"}],IE=[{id:"default",label:"Default"},{id:"web",label:"Web"},{id:"blog",label:"Blog"},{id:"butterick",label:"Butterick"}],AM=["full","compact","minimal"],Qn={typeface:"ow-typeface",mode:"ow-theme-mode",sidebarMode:"ow-sidebar-mode",sidebarStyle:"ow-sidebar-style",sidebarDensity:"ow-sidebar-density",spacing:"ow-spacing",canvas:"ow-canvas"},RM={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function OM(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem(Qn.typeface)){const n=RM[t];n&&localStorage.setItem(Qn.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem(Qn.spacing)&&(localStorage.setItem(Qn.spacing,e),localStorage.removeItem("ow-typography"))}function LE(){const t=localStorage.getItem(Qn.typeface);return t&&AE.some(e=>e.id===t)?t:"charter"}function DE(){const t=localStorage.getItem(Qn.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function $d(){const t=localStorage.getItem(Qn.sidebarMode);return t&&RE.some(e=>e.id===t)?t:"files"}function PE(){return"cards"}function BE(){const t=localStorage.getItem(Qn.sidebarDensity);return t&&AM.includes(t)?t:"full"}function IM(t){localStorage.setItem(Qn.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function $E(){const t=localStorage.getItem(Qn.spacing);return t&&IE.some(e=>e.id===t)?t:"default"}function FE(){const t=localStorage.getItem(Qn.canvas);return t&&OE.some(e=>e.id===t)?t:"seamless"}function zE(t,e,n,r,s="default",i="seamless"){const o=document.documentElement;o.setAttribute("data-typeface",t),o.setAttribute("data-mode",e),o.setAttribute("data-sidebar-mode",n),o.setAttribute("data-sidebar-style",r),s==="default"?o.removeAttribute("data-spacing"):o.setAttribute("data-spacing",s),i==="seamless"?o.removeAttribute("data-canvas"):o.setAttribute("data-canvas",i),o.removeAttribute("data-color"),localStorage.setItem(Qn.typeface,t),localStorage.setItem(Qn.mode,e),localStorage.setItem(Qn.sidebarMode,n),localStorage.setItem(Qn.sidebarStyle,r),localStorage.setItem(Qn.spacing,s),localStorage.setItem(Qn.canvas,i)}function LM(){OM(),zE(LE(),DE(),$d(),PE(),$E(),FE()),document.documentElement.setAttribute("data-sidebar-density",BE())}const UE="ow-right-rail",hg=280,DM=220,PM=520,HE=y.createContext(null);function BM(){const t={open:!0,activeTab:"activity",width:hg};try{const e=localStorage.getItem(UE);if(!e)return t;const n=JSON.parse(e);return{open:!!n.open,activeTab:n.activeTab??null,width:WE(typeof n.width=="number"?n.width:hg)}}catch{return t}}function WE(t){return Number.isFinite(t)?Math.max(DM,Math.min(PM,t)):hg}function $M({children:t}){const[e,n]=y.useState(()=>BM()),[r,s]=y.useState(!1),[i,o]=y.useState(!1),c=y.useRef(r);c.current=r,y.useEffect(()=>{try{localStorage.setItem(UE,JSON.stringify(e))}catch{}},[e]);const d=y.useCallback(k=>{c.current?(o(!0),n(w=>({...w,activeTab:k}))):n(w=>({...w,open:!0,activeTab:k}))},[]),f=y.useCallback(()=>{c.current?o(!1):n(k=>({...k,open:!1}))},[]),h=y.useCallback(()=>{c.current?o(k=>!k):n(k=>({...k,open:!k.open}))},[]),m=y.useCallback(k=>{n(w=>({...w,width:WE(k)}))},[]),g=y.useCallback(k=>{s(w=>w===k?w:(o(!1),k))},[]),v=r?i:e.open,x=y.useMemo(()=>({...e,overlay:r,drawerOpen:i,visible:v,openTab:d,closeRail:f,toggleRail:h,setWidth:m,setOverlay:g}),[e,r,i,v,d,f,h,m,g]);return l.jsx(HE.Provider,{value:x,children:t})}function Bl(){const t=y.useContext(HE);if(!t)throw new Error("useRightRail must be used inside <RightRailProvider>");return t}var VE=ME();const FM=Dl(VE);var Jh={exports:{}},Yh={};/**
41
+ * @license React
42
+ * use-sync-external-store-shim.production.js
43
+ *
44
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */var nx;function zM(){if(nx)return Yh;nx=1;var t=Pl();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var v=g(),x=r({inst:{value:v,getSnapshot:g}}),k=x[0].inst,w=x[1];return i(function(){k.value=v,k.getSnapshot=g,d(k)&&w({inst:k})},[m,v,g]),s(function(){return d(k)&&w({inst:k}),m(function(){d(k)&&w({inst:k})})},[m]),o(v),v}function d(m){var g=m.getSnapshot;m=m.value;try{var v=g();return!n(m,v)}catch{return!0}}function f(m,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Yh.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Yh}var rx;function qE(){return rx||(rx=1,Jh.exports=zM()),Jh.exports}var KE=qE();function Xn(t){this.content=t}Xn.prototype={constructor:Xn,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Xn(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Xn(n)},addToStart:function(t,e){return new Xn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Xn(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Xn(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Xn.from(t),t.size?new Xn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Xn.from(t),t.size?new Xn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Xn.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Xn.from=function(t){if(t instanceof Xn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Xn(e)};function GE(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),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=GE(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function JE(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),c=e.child(--i),d=o.nodeSize;if(o==c){n-=d,r-=d;continue}if(!o.sameMarkup(c))return{a:n,b:r};if(o.isText&&o.text!=c.text){let f=0,h=Math.min(o.text.length,c.text.length);for(;f<h&&o.text[o.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,r--;return{a:n,b:r}}if(o.content.size||c.content.size){let f=JE(o.content,c.content,n-1,r-1);if(f)return f}n-=d,r-=d}}class ke{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,i){for(let o=0,c=0;c<n;o++){let d=this.content[o],f=c+d.nodeSize;if(f>e&&r(d,s+c,i||null,o)!==!1&&d.content.size){let h=c+1;d.nodesBetween(Math.max(0,e-h),Math.min(d.content.size,n-h),r,s+h)}c=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(c,d)=>{let f=c.isText?c.text.slice(Math.max(e,d)-d,n-d):c.isLeaf?s?typeof s=="function"?s(c):s:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&r&&(o?o=!1:i+=r),i+=f},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new ke(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 i=0,o=0;o<n;i++){let c=this.content[i],d=o+c.nodeSize;d>e&&((o<e||d>n)&&(c.isText?c=c.cut(Math.max(0,e-o),Math.min(c.text.length,n-o)):c=c.cut(Math.max(0,e-o-1),Math.min(c.content.size,n-o-1))),r.push(c),s+=c.nodeSize),o=d}return new ke(r,s)}cutByIndex(e,n){return e==n?ke.empty:e==0&&n==this.content.length?this:new ke(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new ke(s,i)}addToStart(e){return new ke([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ke(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 GE(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return JE(this,e,n,r)}findIndex(e){if(e==0)return Qc(0,e);if(e==this.size)return Qc(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),i=r+s.nodeSize;if(i>=e)return i==e?Qc(n+1,i):Qc(n,r);r=i}}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 ke.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ke(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ke.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new ke(n||e,r)}static from(e){if(!e)return ke.empty;if(e instanceof ke)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ke([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ke.empty=new ke([],0);const Xh={index:0,offset:0};function Qc(t,e){return Xh.index=t,Xh.offset=e,Xh}function zu(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!zu(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!zu(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Yt=class pg{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&zu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return pg.none;if(e instanceof pg)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Yt.none=[];class Uu extends Error{}class Be{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=XE(this.content,e+this.openStart,n);return r&&new Be(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Be(YE(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 Be.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 Be(ke.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new Be(e,r,s)}}Be.empty=new Be(ke.empty,0,0);function YE(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:c}=t.findIndex(n);if(s==e||i.isText){if(c!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(YE(i.content,e-s-1,n-s-1)))}function XE(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=XE(o.content,e-i-1,n,o);return c&&t.replaceChild(s,o.copy(c))}function UM(t,e,n){if(n.openStart>t.depth)throw new Uu("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Uu("Inconsistent open depths");return QE(t,e,n,0)}function QE(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=QE(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,c=o.content;return fo(o,c.cut(0,t.parentOffset).append(n.content).append(c.cut(e.parentOffset)))}else{let{start:o,end:c}=HM(n,t);return fo(i,eN(t,o,c,e,r))}else return fo(i,Hu(t,e,r))}function ZE(t,e){if(!e.type.compatibleContent(t.type))throw new Uu("Cannot join "+e.type.name+" onto "+t.type.name)}function mg(t,e,n){let r=t.node(n);return ZE(r,e.node(n)),r}function uo(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function fl(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(uo(t.nodeAfter,r),i++));for(let c=i;c<o;c++)uo(s.child(c),r);e&&e.depth==n&&e.textOffset&&uo(e.nodeBefore,r)}function fo(t,e){return t.type.checkContent(e),t.copy(e)}function eN(t,e,n,r,s){let i=t.depth>s&&mg(t,e,s+1),o=r.depth>s&&mg(n,r,s+1),c=[];return fl(null,t,s,c),i&&o&&e.index(s)==n.index(s)?(ZE(i,o),uo(fo(i,eN(t,e,n,r,s+1)),c)):(i&&uo(fo(i,Hu(t,e,s+1)),c),fl(e,n,s,c),o&&uo(fo(o,Hu(n,r,s+1)),c)),fl(r,null,s,c),new ke(c)}function Hu(t,e,n){let r=[];if(fl(null,t,n,r),t.depth>n){let s=mg(t,e,n+1);uo(fo(s,Hu(t,e,n+1)),r)}return fl(e,null,n,r),new ke(r)}function HM(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(ke.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class Sl{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Yt.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let c=r;r=s,s=c}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Wu(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:c,offset:d}=o.content.findIndex(i),f=i-d;if(r.push(o,c,s+d),!f||(o=o.child(c),o.isText))break;i=f-1,s+=d+1}return new Sl(n,r,i)}static resolveCached(e,n){let r=sx.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else sx.set(e,r=new WM);let s=r.elts[r.i]=Sl.resolve(e,n);return r.i=(r.i+1)%VM,s}}class WM{constructor(){this.elts=[],this.i=0}}const VM=12,sx=new WeakMap;class Wu{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const qM=Object.create(null);class us{constructor(e,n,r,s=Yt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||ke.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&zu(this.attrs,n||e.defaultAttrs||qM)&&Yt.sameSet(this.marks,r||Yt.none)}copy(e=null){return e==this.content?this:new us(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new us(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return Be.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),c=s.start(o),f=s.node(o).content.cut(s.pos-c,i.pos-c);return new Be(f,s.depth-o,i.depth-o)}replace(e,n,r){return UM(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return Sl.resolveCached(this,e)}resolveNoCache(e){return Sl.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),tN(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=ke.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let d=s;d<i;d++)if(!this.type.allowsMarks(r.child(d).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Yt.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Yt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=ke.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}us.prototype.text=void 0;class Vu extends us{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):tN(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Vu(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Vu(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function tN(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class go{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new KM(e,n);if(r.next==null)return go.empty;let s=nN(r);r.next&&r.err("Unexpected trailing text");let i=eA(ZM(s));return tA(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,c){let d=o.matchFragment(e,r);if(d&&(!n||d.validEnd))return ke.from(c.map(f=>f.createAndFill()));for(let f=0;f<o.next.length;f++){let{type:h,next:m}=o.next[f];if(!(h.isText||h.hasRequiredAttrs())&&s.indexOf(m)==-1){s.push(m);let g=i(m,c.concat(h));if(g)return g}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let c=s;c.type;c=c.via)o.push(c.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:c,next:d}=i.next[o];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!s.type||d.validEnd)&&(r.push({match:c.contentMatch,type:c,via:s}),n[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
49
+ `)}}go.empty=new go(!0);class KM{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function nN(t){let e=[];do e.push(GM(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function GM(t){let e=[];do e.push(JM(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function JM(t){let e=QM(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=YM(t,e);else break;return e}function ix(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function YM(t,e){let n=ix(t),r=n;return t.eat(",")&&(t.next!="}"?r=ix(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function XM(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function QM(t){if(t.eat("(")){let e=nN(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=XM(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ZM(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,c,d){let f={term:d,to:c};return e[o].push(f),f}function s(o,c){o.forEach(d=>d.to=c)}function i(o,c){if(o.type=="choice")return o.exprs.reduce((d,f)=>d.concat(i(f,c)),[]);if(o.type=="seq")for(let d=0;;d++){let f=i(o.exprs[d],c);if(d==o.exprs.length-1)return f;s(f,c=n())}else if(o.type=="star"){let d=n();return r(c,d),s(i(o.expr,d),d),[r(d)]}else if(o.type=="plus"){let d=n();return s(i(o.expr,c),d),s(i(o.expr,d),d),[r(d)]}else{if(o.type=="opt")return[r(c)].concat(i(o.expr,c));if(o.type=="range"){let d=c;for(let f=0;f<o.min;f++){let h=n();s(i(o.expr,d),h),d=h}if(o.max==-1)s(i(o.expr,d),d);else for(let f=o.min;f<o.max;f++){let h=n();r(d,h),s(i(o.expr,d),h),d=h}return[r(d)]}else{if(o.type=="name")return[r(c,void 0,o.value)];throw new Error("Unknown expr type")}}}}function rN(t,e){return e-t}function ox(t,e){let n=[];return r(e),n.sort(rN);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:c,to:d}=i[o];!c&&n.indexOf(d)==-1&&r(d)}}}function eA(t){let e=Object.create(null);return n(ox(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:c,to:d})=>{if(!c)return;let f;for(let h=0;h<s.length;h++)s[h][0]==c&&(f=s[h][1]);ox(t,d).forEach(h=>{f||s.push([c,f=[]]),f.indexOf(h)==-1&&f.push(h)})})});let i=e[r.join(",")]=new go(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let c=s[o][1].sort(rN);i.next.push({type:s[o][0],next:e[c.join(",")]||n(c)})}return i}}function tA(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let c=0;c<s.next.length;c++){let{type:d,next:f}=s.next[c];o.push(d.name),i&&!(d.isText||d.hasRequiredAttrs())&&(i=!1),r.indexOf(f)==-1&&r.push(f)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function sN(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function iN(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function oN(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function aN(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new rA(t,r,e[r]);return n}let ax=class lN{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=aN(e,r.attrs),this.defaultAttrs=sN(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==go.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:iN(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new us(this,this.computeAttrs(e),ke.from(n),Yt.setFrom(r))}createChecked(e=null,n,r){return n=ke.from(n),this.checkContent(n),new us(this,this.computeAttrs(e),n,Yt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ke.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(ke.empty,!0);return i?new us(this,e,n.append(i),Yt.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){oN(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Yt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new lN(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function nA(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class rA{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?nA(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Fd{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=aN(e,s.attrs),this.excluded=null;let i=sN(this.attrs);this.instance=i?new Yt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Yt(this,iN(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Fd(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){oN(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class cN{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Xn.from(e.nodes),n.marks=Xn.from(e.marks||{}),this.nodes=ax.compile(this.spec.nodes,this),this.marks=Fd.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=go.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=c=="_"?null:c?lx(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:lx(this,o.split(" "))}this.nodeFromJSON=s=>us.fromJSON(this,s),this.markFromJSON=s=>Yt.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ax){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Vu(r,r.defaultAttrs,e,Yt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function lx(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let c in t.marks){let d=t.marks[c];(s=="_"||d.spec.group&&d.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=d)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function sA(t){return t.tag!=null}function iA(t){return t.style!=null}let hl=class gg{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(sA(s))this.tags.push(s);else if(iA(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new ux(this,n,!1);return r.addAll(e,Yt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ux(this,n,!0);return r.addAll(e,Yt.none,n.from,n.to),Be.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(lA(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],c=o.style;if(!(c.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(o.getAttrs){let d=o.getAttrs(n);if(d===!1)continue;o.attrs=d||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let c=n[o];if((c.priority==null?50:c.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=dx(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=dx(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new gg(e,gg.schemaRules(e)))}};const uN={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},oA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},dN={ol:!0,ul:!0},El=1,vg=2,pl=4;function cx(t,e,n){return e!=null?(e?El:0)|(e==="full"?vg:0):t&&t.whitespace=="pre"?El|vg:n&~pl}class Zc{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Yt.none,this.match=i||(o&pl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ke.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&El)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=ke.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ke.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!uN.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ux{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=cx(null,n.preserveWhitespace,0)|(r?pl:0);s?i=new Zc(s.type,s.attrs,Yt.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Zc(null,null,Yt.none,!0,null,o):i=new Zc(e.schema.topNodeType,null,Yt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&vg?"full":this.localPreserveWS||(s.options&El)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
50
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let c=r.split(/\r?\n|\r/);for(let d=0;d<c.length;d++)d&&this.insertNode(o.linebreakReplacement.create(),n,!0),c[d]&&this.insertNode(o.text(c[d]),n,!/\S/.test(c[d]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let c=s.content[s.content.length-1],d=e.previousSibling;(!c||d&&d.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),c;dN.hasOwnProperty(o)&&this.parser.normalizeLists&&aA(e);let d=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(d?d.ignore:oA.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!d||d.skip||d.closeParent){d&&d.closeParent?this.open=Math.max(0,this.open-1):d&&d.skip.nodeType&&(e=d.skip);let f,h=this.needsBlock;if(uN.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),f=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let m=d&&d.skip?n:this.readStyles(e,n);m&&this.addAll(e,m),f&&this.sync(i),this.needsBlock=h}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,d,f,d.consuming===!1?c:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
51
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let c=void 0;;){let d=this.parser.matchStyle(i,o,this,c);if(!d)break;if(d.ignore)return null;if(d.clearMark?n=n.filter(f=>!d.clearMark(f)):n=n.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)c=d;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let d=this.enter(o,n.attrs||null,r,n.preserveWhitespace);d&&(i=!0,r=d)}else{let d=this.parser.schema.marks[n.mark];r=r.concat(d.create(n.attrs))}let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(d=>this.insertNode(d,r,!1));else{let d=e;typeof n.contentElement=="string"?d=e.querySelector(n.contentElement):typeof n.contentElement=="function"?d=n.contentElement(e):n.contentElement&&(d=n.contentElement),this.findAround(e,d,!0),this.addAll(d,r),this.findAround(e,d,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,c=s==null?null:e.childNodes[s];o!=c;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,c=0;o>=0;o--){let d=this.nodes[o],f=d.findWrapping(e);if(f&&(!s||s.length>f.length+c)&&(s=f,i=d,!f.length))break;if(d.solid){if(r)break;c+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Yt.none;for(let c of s.concat(e.marks))(i.type?i.type.allowsMarkType(c.type):fx(c.type,e.type))&&(o=c.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let c=cx(e,i,o.options);o.options&pl&&o.content.length==0&&(c|=pl);let d=Yt.none;return r=r.filter(f=>(o.type?o.type.allowsMarkType(f.type):fx(f.type,e))?(d=f.addToSet(d),!1):!0),this.nodes.push(new Zc(e,n,d,s,null,c)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=El)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(c,d)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;d>=i;d--)if(o(c-1,d))return!0;return!1}else{let h=d>0||d==0&&s?this.nodes[d].type:r&&d>=i?r.node(d-i).type:null;if(!h||h.name!=f&&!h.isInGroup(f))return!1;d--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function aA(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&dN.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function lA(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function dx(t){let e={};for(let n in t)e[n]=t[n];return e}function fx(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=c=>{i.push(c);for(let d=0;d<c.edgeCount;d++){let{type:f,next:h}=c.edge(d);if(f==e||i.indexOf(h)<0&&o(h))return!0}};if(o(s.contentMatch))return!0}}class So{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Qh(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let c=0,d=0;for(;c<i.length&&d<o.marks.length;){let f=o.marks[d];if(!this.marks[f.type.name]){d++;continue}if(!f.eq(i[c][0])||f.type.spec.spanning===!1)break;c++,d++}for(;c<i.length;)s=i.pop()[1];for(;d<o.marks.length;){let f=o.marks[d++],h=this.serializeMark(f,o.isInline,n);h&&(i.push([f,s]),s.appendChild(h.dom),s=h.contentDOM||h.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Ru(Qh(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Ru(Qh(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Ru(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new So(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hx(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hx(e.marks)}}function hx(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Qh(t){return t.document||window.document}const px=new WeakMap;function cA(t){let e=px.get(t);return e===void 0&&px.set(t,e=uA(t)),e}function uA(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Ru(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=cA(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let c,d=n?t.createElementNS(n,s):t.createElement(s),f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let m in f)if(f[m]!=null){let g=m.indexOf(" ");g>0?d.setAttributeNS(m.slice(0,g),m.slice(g+1),f[m]):m=="style"&&d.style?d.style.cssText=f[m]:d.setAttribute(m,f[m])}}for(let m=h;m<e.length;m++){let g=e[m];if(g===0){if(m<e.length-1||m>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:v,contentDOM:x}=Ru(t,g,n,r);if(d.appendChild(v),x){if(c)throw new RangeError("Multiple content holes");c=x}}}return{dom:d,contentDOM:c}}const fN=65535,hN=Math.pow(2,16);function dA(t,e){return t+e*hN}function mx(t){return t&fN}function fA(t){return(t-(t&fN))/hN}const pN=1,mN=2,Ou=4,gN=8;class bg{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&gN)>0}get deletedBefore(){return(this.delInfo&(pN|Ou))>0}get deletedAfter(){return(this.delInfo&(mN|Ou))>0}get deletedAcross(){return(this.delInfo&Ou)>0}}class Or{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Or.empty)return Or.empty}recover(e){let n=0,r=mx(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+fA(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,i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?s:0);if(d>e)break;let f=this.ranges[c+i],h=this.ranges[c+o],m=d+f;if(e<=m){let g=f?e==d?-1:e==m?1:n:n,v=d+s+(g<0?0:h);if(r)return v;let x=e==(n<0?d:m)?null:dA(c/3,e-d),k=e==d?mN:e==m?pN:Ou;return(n<0?e!=d:e!=m)&&(k|=gN),new bg(v,k,x)}s+=h-f}return r?e+s:new bg(e+s,0,null)}touches(e,n){let r=0,s=mx(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?r:0);if(d>e)break;let f=this.ranges[c+i],h=d+f;if(e<=h&&c==s*3)return!0;r+=this.ranges[c+o]-f}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],c=o-(this.inverted?i:0),d=o+(this.inverted?0:i),f=this.ranges[s+n],h=this.ranges[s+r];e(c,c+f,d,d+h),i+=h-f}}invert(){return new Or(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Or.empty:new Or(e<0?[0,-e,0]:[0,0,e])}}Or.empty=new Or([]);class Nl{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Nl(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Nl;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],c=o.mapResult(e,n);if(c.recover!=null){let d=this.getMirror(i);if(d!=null&&d>i&&d<this.to){i=d,e=this._maps[d].recover(c.recover);continue}}s|=c.delInfo,e=c.pos}return r?e:new bg(e,s,null)}}const Zh=Object.create(null);class cr{getMap(){return Or.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Zh[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 Zh)throw new RangeError("Duplicate use of step JSON ID "+e);return Zh[e]=n,n.prototype.jsonID=e,n}}class jn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new jn(e,null)}static fail(e){return new jn(null,e)}static fromReplace(e,n,r,s){try{return jn.ok(e.replace(n,r,s))}catch(i){if(i instanceof Uu)return jn.fail(i.message);throw i}}}function iv(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(iv(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return ke.fromArray(r)}class Ni extends cr{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)),i=new Be(iv(n.content,(o,c)=>!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return jn.fromReplace(e,this.from,this.to,i)}invert(){return new cs(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 Ni(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ni&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ni(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 Ni(n.from,n.to,e.markFromJSON(n.mark))}}cr.jsonID("addMark",Ni);class cs extends cr{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 Be(iv(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return jn.fromReplace(e,this.from,this.to,r)}invert(){return new Ni(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 cs(n.pos,r.pos,this.mark)}merge(e){return e instanceof cs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new cs(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 cs(n.from,n.to,e.markFromJSON(n.mark))}}cr.jsonID("removeMark",cs);class Ci extends cr{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return jn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return jn.fromReplace(e,this.pos,this.pos+1,new Be(ke.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 Ci(this.pos,n.marks[s]);return new Ci(this.pos,this.mark)}}return new vo(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ci(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 Ci(n.pos,e.markFromJSON(n.mark))}}cr.jsonID("addNodeMark",Ci);class vo extends cr{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return jn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return jn.fromReplace(e,this.pos,this.pos+1,new Be(ke.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Ci(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new vo(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 vo(n.pos,e.markFromJSON(n.mark))}}cr.jsonID("removeNodeMark",vo);class zn extends cr{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&yg(e,this.from,this.to)?jn.fail("Structure replace would overwrite content"):jn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Or([this.from,this.to-this.from,this.slice.size])}invert(e){return new zn(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 zn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof zn)||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?Be.empty:new Be(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new zn(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?Be.empty:new Be(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new zn(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 zn(n.from,n.to,Be.fromJSON(e,n.slice),!!n.structure)}}cr.jsonID("replace",zn);class Un extends cr{constructor(e,n,r,s,i,o,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=c}apply(e){if(this.structure&&(yg(e,this.from,this.gapFrom)||yg(e,this.gapTo,this.to)))return jn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return jn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?jn.fromReplace(e,this.from,this.to,r):jn.fail("Content does not fit in gap")}getMap(){return new Or([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 Un(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),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Un(n.pos,r.pos,s,i,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 Un(n.from,n.to,n.gapFrom,n.gapTo,Be.fromJSON(e,n.slice),n.insert,!!n.structure)}}cr.jsonID("replaceAround",Un);function yg(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function hA(t,e,n,r){let s=[],i=[],o,c;t.doc.nodesBetween(e,n,(d,f,h)=>{if(!d.isInline)return;let m=d.marks;if(!r.isInSet(m)&&h.type.allowsMarkType(r.type)){let g=Math.max(f,e),v=Math.min(f+d.nodeSize,n),x=r.addToSet(m);for(let k=0;k<m.length;k++)m[k].isInSet(x)||(o&&o.to==g&&o.mark.eq(m[k])?o.to=v:s.push(o=new cs(g,v,m[k])));c&&c.to==g?c.to=v:i.push(c=new Ni(g,v,r))}}),s.forEach(d=>t.step(d)),i.forEach(d=>t.step(d))}function pA(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;i++;let d=null;if(r instanceof Fd){let f=o.marks,h;for(;h=r.isInSet(f);)(d||(d=[])).push(h),f=h.removeFromSet(f)}else r?r.isInSet(o.marks)&&(d=[r]):d=o.marks;if(d&&d.length){let f=Math.min(c+o.nodeSize,n);for(let h=0;h<d.length;h++){let m=d[h],g;for(let v=0;v<s.length;v++){let x=s[v];x.step==i-1&&m.eq(s[v].style)&&(g=x)}g?(g.to=f,g.step=i):s.push({style:m,from:Math.max(c,e),to:f,step:i})}}}),s.forEach(o=>t.step(new cs(o.from,o.to,o.style)))}function ov(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],c=e+1;for(let d=0;d<i.childCount;d++){let f=i.child(d),h=c+f.nodeSize,m=r.matchType(f.type);if(!m)o.push(new zn(c,h,Be.empty));else{r=m;for(let g=0;g<f.marks.length;g++)n.allowsMarkType(f.marks[g].type)||t.step(new cs(c,h,f.marks[g]));if(s&&f.isText&&n.whitespace!="pre"){let g,v=/\r?\n|\r/g,x;for(;g=v.exec(f.text);)x||(x=new Be(ke.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),o.push(new zn(c+g.index,c+g.index+g[0].length,x))}}c=h}if(!r.validEnd){let d=r.fillBefore(ke.empty,!0);t.replace(c,c,new Be(d,0,0))}for(let d=o.length-1;d>=0;d--)t.step(o[d])}function mA(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ya(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+s,d=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(c,d,n))return r;if(r==0||o.type.spec.isolating||!mA(o,c,d))break;c&&(s=1),d<o.childCount&&(i=1)}return null}function gA(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),c=s.after(i+1),d=o,f=c,h=ke.empty,m=0;for(let x=i,k=!1;x>n;x--)k||r.index(x)>0?(k=!0,h=ke.from(r.node(x).copy(h)),m++):d--;let g=ke.empty,v=0;for(let x=i,k=!1;x>n;x--)k||s.after(x+1)<s.end(x)?(k=!0,g=ke.from(s.node(x).copy(g)),v++):f++;t.step(new Un(d,f,o,c,new Be(h.append(g),m,v),h.size-m,!0))}function av(t,e,n=null,r=t){let s=vA(t,e),i=s&&bA(r,e);return i?s.map(gx).concat({type:e,attrs:n}).concat(i.map(gx)):null}function gx(t){return{type:t,attrs:null}}function vA(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function bA(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let d=(o.length?o[o.length-1]:e).contentMatch;for(let f=r;d&&f<s;f++)d=d.matchType(n.child(f).type);return!d||!d.validEnd?null:o}function yA(t,e,n){let r=ke.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let c=n[o].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ke.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Un(s,i,s,i,new Be(r,0,0),n.length,!0))}function xA(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,c)=>{let d=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,d)&&wA(t.doc,t.mapping.slice(i).map(c),r)){let f=null;if(r.schema.linebreakReplacement){let v=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);v&&!x?f=!1:!v&&x&&(f=!0)}f===!1&&bN(t,o,c,i),ov(t,t.mapping.slice(i).map(c,1),r,void 0,f===null);let h=t.mapping.slice(i),m=h.map(c,1),g=h.map(c+o.nodeSize,1);return t.step(new Un(m,g,m+1,g-1,new Be(ke.from(r.create(d,null,o.marks)),0,0),1,!0)),f===!0&&vN(t,o,c,i),!1}})}function vN(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(s.text);){let d=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(d,d+1,e.type.schema.linebreakReplacement.create())}}})}function bN(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
52
+ `))}})}function wA(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function kA(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Un(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Be(ke.from(o),0,0),1,!0))}function qs(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let f=s.depth-1,h=n-2;f>i;f--,h--){let m=s.node(f),g=s.index(f);if(m.type.spec.isolating)return!1;let v=m.content.cutByIndex(g,m.childCount),x=r&&r[h+1];x&&(v=v.replaceChild(0,x.type.create(x.attrs)));let k=r&&r[h]||m;if(!m.canReplace(g+1,m.childCount)||!k.type.validContent(v))return!1}let c=s.indexAfter(i),d=r&&r[0];return s.node(i).canReplaceWith(c,c,d?d.type:s.node(i+1).type)}function SA(t,e,n=1,r){let s=t.doc.resolve(e),i=ke.empty,o=ke.empty;for(let c=s.depth,d=s.depth-n,f=n-1;c>d;c--,f--){i=ke.from(s.node(c).copy(i));let h=r&&r[f];o=ke.from(h?h.type.create(h.attrs,o):s.node(c).copy(o))}t.step(new zn(e,e,new Be(i.append(o),n,n),!0))}function Pi(t,e){let n=t.resolve(e),r=n.index();return yN(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function EA(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function yN(t,e){return!!(t&&e&&!t.isLeaf&&EA(t,e))}function zd(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,c=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),c++,o=r.node(s).maybeChild(c)):(i=r.node(s).maybeChild(c-1),o=r.node(s+1)),i&&!i.isTextblock&&yN(i,o)&&r.node(s).canReplace(c,c+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function NA(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let h=o.whitespace=="pre",m=!!o.contentMatch.matchType(s);h&&!m?r=!1:!h&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let h=t.doc.resolve(e+n);bN(t,h.node(),h.before(),c)}o.inlineContent&&ov(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let d=t.mapping.slice(c),f=d.map(e-n);if(t.step(new zn(f,d.map(e+n,-1),Be.empty,!0)),r===!0){let h=t.doc.resolve(f);vN(t,h.node(),h.before(),t.steps.length)}return t}function CA(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function xN(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let c=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,d=r.index(o)+(c>0?1:0),f=r.node(o),h=!1;if(i==1)h=f.canReplace(d,d,s);else{let m=f.contentMatchAt(d).findWrapping(s.firstChild.type);h=m&&f.canReplaceWith(d,d,m[0])}if(h)return c==0?r.pos:c<0?r.before(o+1):r.after(o+1)}return null}function Ud(t,e,n=e,r=Be.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return wN(s,i,r)?new zn(e,n,r):new _A(s,i,r).fit()}function wN(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class _A{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ke.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=ke.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,c=s.depth;for(;o&&c&&i.childCount==1;)i=i.firstChild.content,o--,c--;let d=new Be(i,o,c);return e>-1?new Un(r.pos,e,this.$to.pos,this.$to.end(),d,n):d.size||r.pos!=this.$to.pos?new zn(r.pos,s.pos,d):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=ep(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let c=this.depth;c>=0;c--){let{type:d,match:f}=this.frontier[c],h,m=null;if(n==1&&(o?f.matchType(o.type)||(m=f.fillBefore(ke.from(o),!1)):i&&d.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&o&&(h=f.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:h};if(i&&f.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=ep(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Be(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=ep(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new Be(il(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Be(il(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let k=0;k<i.length;k++)this.openFrontierNode(i[k]);let o=this.unplaced,c=r?r.content:o.content,d=o.openStart-e,f=0,h=[],{match:m,type:g}=this.frontier[n];if(s){for(let k=0;k<s.childCount;k++)h.push(s.child(k));m=m.matchFragment(s)}let v=c.size+e-(o.content.size-o.openEnd);for(;f<c.childCount;){let k=c.child(f),w=m.matchType(k.type);if(!w)break;f++,(f>1||d==0||k.content.size)&&(m=w,h.push(kN(k.mark(g.allowedMarks(k.marks)),f==1?d:0,f==c.childCount?v:-1)))}let x=f==c.childCount;x||(v=-1),this.placed=ol(this.placed,n,ke.from(h)),this.frontier[n].match=m,x&&v<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let k=0,w=c;k<v;k++){let S=w.lastChild;this.frontier.push({type:S.type,match:S.contentMatchAt(S.childCount)}),w=S.content}this.unplaced=x?e==0?Be.empty:new Be(il(o.content,e-1,1),e-1,v<0?o.openEnd:e-1):new Be(il(o.content,e,f),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!tp(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=tp(e,n,s,r,i);if(o){for(let c=n-1;c>=0;c--){let{match:d,type:f}=this.frontier[c],h=tp(e,c,f,d,!0);if(!h||h.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ol(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=ol(this.placed,this.depth,ke.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ke.empty,!0);n.childCount&&(this.placed=ol(this.placed,this.frontier.length,n))}}function il(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(il(t.firstChild.content,e-1,n)))}function ol(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ol(t.lastChild.content,e-1,n)))}function ep(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function kN(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,kN(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(ke.empty,!0)))),t.copy(r)}function tp(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let c=r.fillBefore(i.content,!0,o);return c&&!TA(n,i.content,o)?c:null}function TA(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function jA(t){return t.spec.defining||t.spec.definingForContent}function MA(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(wN(s,i,r))return t.step(new zn(e,n,r));let o=EN(s,i);o[o.length-1]==0&&o.pop();let c=-(s.depth+1);o.unshift(c);for(let g=s.depth,v=s.pos-1;g>0;g--,v--){let x=s.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(g)>-1?c=g:s.before(g)==v&&o.splice(1,0,-g)}let d=o.indexOf(c),f=[],h=r.openStart;for(let g=r.content,v=0;;v++){let x=g.firstChild;if(f.push(x),v==r.openStart)break;g=x.content}for(let g=h-1;g>=0;g--){let v=f[g],x=jA(v.type);if(x&&!v.sameMarkup(s.node(Math.abs(c)-1)))h=g;else if(x||!v.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let v=(g+h+1)%(r.openStart+1),x=f[v];if(x)for(let k=0;k<o.length;k++){let w=o[(k+d)%o.length],S=!0;w<0&&(S=!1,w=-w);let N=s.node(w-1),j=s.index(w-1);if(N.canReplaceWith(j,j,x.type,x.marks))return t.replace(s.before(w),S?i.after(w):n,new Be(SN(r.content,0,r.openStart,v),v,r.openEnd))}}let m=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let v=o[g];v<0||(e=s.before(v),n=i.after(v))}}function SN(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(SN(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(ke.empty,!0))}return t}function AA(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=CA(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Be(ke.from(r),0,0))}function RA(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=EN(r,s);for(let o=0;o<i.length;o++){let c=i[o],d=o==i.length-1;if(d&&c==0||r.node(c).type.contentMatch.validEnd)return t.delete(r.start(c),s.end(c));if(c>0&&(d||r.node(c-1).canReplace(r.index(c-1),s.indexAfter(c-1))))return t.delete(r.before(c),s.after(c))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function EN(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class la extends cr{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 jn.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return jn.fromReplace(e,this.pos,this.pos+1,new Be(ke.from(s),0,n.isLeaf?0:1))}getMap(){return Or.empty}invert(e){return new la(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 la(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 la(n.pos,n.attr,n.value)}}cr.jsonID("attr",la);class Cl extends cr{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 jn.ok(r)}getMap(){return Or.empty}invert(e){return new Cl(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 Cl(n.attr,n.value)}}cr.jsonID("docAttr",Cl);let da=class extends Error{};da=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};da.prototype=Object.create(Error.prototype);da.prototype.constructor=da;da.prototype.name="TransformError";class lv{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Nl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new da(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,c,d)=>{e=Math.min(e,c),n=Math.max(n,d)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Be.empty){let s=Ud(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Be(ke.from(r),0,0))}delete(e,n){return this.replace(e,n,Be.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return MA(this,e,n,r),this}replaceRangeWith(e,n,r){return AA(this,e,n,r),this}deleteRange(e,n){return RA(this,e,n),this}lift(e,n){return gA(this,e,n),this}join(e,n=1){return NA(this,e,n),this}wrap(e,n){return yA(this,e,n),this}setBlockType(e,n=e,r,s=null){return xA(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return kA(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new la(e,n,r)),this}setDocAttribute(e,n){return this.step(new Cl(e,n)),this}addNodeMark(e,n){return this.step(new Ci(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Yt)n.isInSet(r.marks)&&this.step(new vo(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new vo(e,i)),s=i.removeFromSet(s);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,r){return SA(this,e,n,r),this}addMark(e,n,r){return hA(this,e,n,r),this}removeMark(e,n,r){return pA(this,e,n,r),this}clearIncompatible(e,n,r){return ov(this,e,n,r),this}}const np=Object.create(null);class gt{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new NN(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=Be.empty){let r=n.content.lastChild,s=null;for(let c=0;c<n.openEnd;c++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let c=0;c<o.length;c++){let{$from:d,$to:f}=o[c],h=e.mapping.slice(i);e.replaceRange(h.map(d.pos),h.map(f.pos),c?Be.empty:n),c==0&&yx(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:c}=s[i],d=e.mapping.slice(r),f=d.map(o.pos),h=d.map(c.pos);i?e.deleteRange(f,h):(e.replaceRangeWith(f,h,n),yx(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new lt(e):ea(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?ea(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):ea(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Lr(e.node(0))}static atStart(e){return ea(e,e,0,0,1)||new Lr(e)}static atEnd(e){return ea(e,e,e.content.size,e.childCount,-1)||new Lr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=np[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 np)throw new RangeError("Duplicate use of selection JSON ID "+e);return np[e]=n,n.prototype.jsonID=e,n}getBookmark(){return lt.between(this.$anchor,this.$head).getBookmark()}}gt.prototype.visible=!0;class NN{constructor(e,n){this.$from=e,this.$to=n}}let vx=!1;function bx(t){!vx&&!t.parent.inlineContent&&(vx=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class lt extends gt{constructor(e,n=e){bx(e),bx(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 gt.near(r);let s=e.resolve(n.map(this.anchor));return new lt(s.parent.inlineContent?s:r,r)}replace(e,n=Be.empty){if(super.replace(e,n),n==Be.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof lt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Hd(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 lt(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 i=gt.findFrom(n,r,!0)||gt.findFrom(n,-r,!0);if(i)n=i.$head;else return gt.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(gt.findFrom(e,-r,!0)||gt.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new lt(e,n)}}gt.jsonID("text",lt);class Hd{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Hd(e.map(this.anchor),e.map(this.head))}resolve(e){return lt.between(e.resolve(this.anchor),e.resolve(this.head))}}class ot extends gt{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),i=e.resolve(s);return r?gt.near(i):new ot(i)}content(){return new Be(ke.from(this.node),0,0)}eq(e){return e instanceof ot&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new cv(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ot(e.resolve(n.anchor))}static create(e,n){return new ot(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ot.prototype.visible=!1;gt.jsonID("node",ot);class cv{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Hd(r,r):new cv(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ot.isSelectable(r)?new ot(n):gt.near(n)}}class Lr extends gt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Be.empty){if(n==Be.empty){e.delete(0,e.doc.content.size);let r=gt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Lr(e)}map(e){return new Lr(e)}eq(e){return e instanceof Lr}getBookmark(){return OA}}gt.jsonID("all",Lr);const OA={map(){return this},resolve(t){return new Lr(t)}};function ea(t,e,n,r,s,i=!1){if(e.inlineContent)return lt.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let c=e.child(o);if(c.isAtom){if(!i&&ot.isSelectable(c))return ot.create(t,n-(s<0?c.nodeSize:0))}else{let d=ea(t,c,n+s,s<0?c.childCount:0,s,i);if(d)return d}n+=c.nodeSize*s}return null}function yx(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof zn||s instanceof Un))return;let i=t.mapping.maps[r],o;i.forEach((c,d,f,h)=>{o==null&&(o=h)}),t.setSelection(gt.near(t.doc.resolve(o),n))}const xx=1,eu=2,wx=4;class IA extends lv{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|xx)&~eu,this.storedMarks=null,this}get selectionSet(){return(this.updated&xx)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=eu,this}ensureMarks(e){return Yt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&eu)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~eu,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Yt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(gt.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wx,this}get scrolledIntoView(){return(this.updated&wx)>0}}function kx(t,e){return!e||!t?t:t.bind(e)}class al{constructor(e,n,r){this.name=e,this.init=kx(n.init,r),this.apply=kx(n.apply,r)}}const LA=[new al("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new al("selection",{init(t,e){return t.selection||gt.atStart(e.doc)},apply(t){return t.selection}}),new al("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new al("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class rp{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=LA.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new al(r.key,r.spec.state,r))})}}class ia{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let c=this.config.plugins[o];if(c.spec.appendTransaction){let d=s?s[o].n:0,f=s?s[o].state:this,h=d<n.length&&c.spec.appendTransaction.call(c,d?n.slice(d):n,f,r);if(h&&r.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!s){s=[];for(let m=0;m<this.config.plugins.length;m++)s.push(m<o?{state:r,n:n.length}:{state:this,n:0})}n.push(h),r=r.applyInner(h),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ia(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new IA(this)}static create(e){let n=new rp(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ia(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new rp(this.schema,e.plugins),r=n.fields,s=new ia(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new rp(e.schema,e.plugins),i=new ia(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=us.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=gt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let d=r[c],f=d.spec.state;if(d.key==o.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[o.name]=f.fromJSON.call(d,e,n[c],i);return}}i[o.name]=o.init(e,i)}}),i}}function CN(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=CN(s,e,{})),n[r]=s}return n}class $t{constructor(e){this.spec=e,this.props={},e.props&&CN(e.props,this,this.props),this.key=e.key?e.key.key:_N("plugin")}getState(e){return e[this.key]}}const sp=Object.create(null);function _N(t){return t in sp?t+"$"+ ++sp[t]:(sp[t]=0,t+"$")}class qt{constructor(e="key"){this.key=_N(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const uv=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function TN(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const jN=(t,e,n)=>{let r=TN(t,n);if(!r)return!1;let s=dv(r);if(!s){let o=r.blockRange(),c=o&&ya(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let i=s.nodeBefore;if(BN(t,s,e,-1))return!0;if(r.parent.content.size==0&&(fa(i,"end")||ot.isSelectable(i)))for(let o=r.depth;;o--){let c=Ud(t.doc,r.before(o),r.after(o),Be.empty);if(c&&c.slice.size<c.to-c.from){if(e){let d=t.tr.step(c);d.setSelection(fa(i,"end")?gt.findFrom(d.doc.resolve(d.mapping.map(s.pos,-1)),-1):ot.create(d.doc,s.pos-i.nodeSize)),e(d.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},DA=(t,e,n)=>{let r=TN(t,n);if(!r)return!1;let s=dv(r);return s?MN(t,s,e):!1},PA=(t,e,n)=>{let r=RN(t,n);if(!r)return!1;let s=fv(r);return s?MN(t,s,e):!1};function MN(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let h=s.lastChild;if(!h)return!1;s=h}let o=e.nodeAfter,c=o,d=e.pos+1;for(;!c.isTextblock;d++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let f=Ud(t.doc,i,d,Be.empty);if(!f||f.from!=i||f instanceof zn&&f.slice.size>=d-i)return!1;if(n){let h=t.tr.step(f);h.setSelection(lt.create(h.doc,i)),n(h.scrollIntoView())}return!0}function fa(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const AN=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=dv(r)}let o=i&&i.nodeBefore;return!o||!ot.isSelectable(o)?!1:(e&&e(t.tr.setSelection(ot.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function dv(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function RN(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const ON=(t,e,n)=>{let r=RN(t,n);if(!r)return!1;let s=fv(r);if(!s)return!1;let i=s.nodeAfter;if(BN(t,s,e,1))return!0;if(r.parent.content.size==0&&(fa(i,"start")||ot.isSelectable(i))){let o=Ud(t.doc,r.before(),r.after(),Be.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(fa(i,"start")?gt.findFrom(c.doc.resolve(c.mapping.map(s.pos)),1):ot.create(c.doc,c.mapping.map(s.pos))),e(c.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},IN=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=fv(r)}let o=i&&i.nodeAfter;return!o||!ot.isSelectable(o)?!1:(e&&e(t.tr.setSelection(ot.create(t.doc,i.pos)).scrollIntoView()),!0)};function fv(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const BA=(t,e)=>{let n=t.selection,r=n instanceof ot,s;if(r){if(n.node.isTextblock||!Pi(t.doc,n.from))return!1;s=n.from}else if(s=zd(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(ot.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},$A=(t,e)=>{let n=t.selection,r;if(n instanceof ot){if(n.node.isTextblock||!Pi(t.doc,n.to))return!1;r=n.to}else if(r=zd(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},FA=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&ya(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},LN=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
53
+ `).scrollIntoView()),!0)};function hv(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const zA=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=hv(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let c=n.after(),d=t.tr.replaceWith(c,c,o.createAndFill());d.setSelection(gt.near(d.doc.resolve(c),1)),e(d.scrollIntoView())}return!0},DN=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Lr||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=hv(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,c=t.tr.insert(o,i.createAndFill());c.setSelection(lt.create(c.doc,o+1)),e(c.scrollIntoView())}return!0},PN=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(qs(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&ya(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function UA(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof ot&&e.selection.node.isBlock)return!r.parentOffset||!qs(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,c,d=!1,f=!1;for(let v=r.depth;;v--)if(r.node(v).isBlock){d=r.end(v)==r.pos+(r.depth-v),f=r.start(v)==r.pos-(r.depth-v),c=hv(r.node(v-1).contentMatchAt(r.indexAfter(v-1))),i.unshift(d&&c?{type:c}:null),o=v;break}else{if(v==1)return!1;i.unshift(null)}let h=e.tr;(e.selection instanceof lt||e.selection instanceof Lr)&&h.deleteSelection();let m=h.mapping.map(r.pos),g=qs(h.doc,m,i.length,i);if(g||(i[0]=c?{type:c}:null,g=qs(h.doc,m,i.length,i)),!g)return!1;if(h.split(m,i.length,i),!d&&f&&r.node(o).type!=c){let v=h.mapping.map(r.before(o)),x=h.doc.resolve(v);c&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,c)&&h.setNodeMarkup(h.mapping.map(r.before(o)),c)}return n&&n(h.scrollIntoView()),!0}}const HA=UA(),WA=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(ot.create(t.doc,s))),!0)};function VA(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Pi(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function BN(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,c,d=s.type.spec.isolating||i.type.spec.isolating;if(!d&&VA(t,e,n))return!0;let f=!d&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(o=(c=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&c.matchType(o[0]||i.type).validEnd){if(n){let v=e.pos+i.nodeSize,x=ke.empty;for(let S=o.length-1;S>=0;S--)x=ke.from(o[S].create(null,x));x=ke.from(s.copy(x));let k=t.tr.step(new Un(e.pos-1,v,e.pos,v,new Be(x,1,0),o.length,!0)),w=k.doc.resolve(v+2*o.length);w.nodeAfter&&w.nodeAfter.type==s.type&&Pi(k.doc,w.pos)&&k.join(w.pos),n(k.scrollIntoView())}return!0}let h=i.type.spec.isolating||r>0&&d?null:gt.findFrom(e,1),m=h&&h.$from.blockRange(h.$to),g=m&&ya(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(f&&fa(i,"start",!0)&&fa(s,"end")){let v=s,x=[];for(;x.push(v),!v.isTextblock;)v=v.lastChild;let k=i,w=1;for(;!k.isTextblock;k=k.firstChild)w++;if(v.canReplace(v.childCount,v.childCount,k.content)){if(n){let S=ke.empty;for(let j=x.length-1;j>=0;j--)S=ke.from(x[j].copy(S));let N=t.tr.step(new Un(e.pos-x.length,e.pos+i.nodeSize,e.pos+w,e.pos+i.nodeSize-w,new Be(S,x.length,0),0,!0));n(N.scrollIntoView())}return!0}}return!1}function $N(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(lt.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const qA=$N(-1),KA=$N(1);function GA(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),c=o&&av(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function Sx(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[i];n.doc.nodesBetween(o,c,(d,f)=>{if(s)return!1;if(!(!d.isTextblock||d.hasMarkup(t,e)))if(d.type==t)s=!0;else{let h=n.doc.resolve(f),m=h.index();s=h.parent.canReplaceWith(m,m+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:c},$to:{pos:d}}=n.selection.ranges[o];i.setBlockType(c,d,t,e)}r(i.scrollIntoView())}return!0}}function pv(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}pv(uv,jN,AN);pv(uv,ON,IN);pv(LN,DN,PN,HA);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function JA(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let c=r?n.tr:null;return YA(c,o,t,e)?(r&&r(c.scrollIntoView()),!0):!1}}function YA(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let d=o.resolve(e.start-2);i=new Wu(d,d,e.depth),e.endIndex<e.parent.childCount&&(e=new Wu(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let c=av(i,n,r,e);return c?(t&&XA(t,e,c,s,n),!0):!1}function XA(t,e,n,r,s){let i=ke.empty;for(let h=n.length-1;h>=0;h--)i=ke.from(n[h].type.create(n[h].attrs,i));t.step(new Un(e.start-(r?2:0),e.end,e.start,e.end,new Be(i,0,0),n.length,!0));let o=0;for(let h=0;h<n.length;h++)n[h].type==s&&(o=h+1);let c=n.length-o,d=e.start+n.length-(r?2:0),f=e.parent;for(let h=e.startIndex,m=e.endIndex,g=!0;h<m;h++,g=!1)!g&&qs(t.doc,d,c)&&(t.split(d,c),d+=2*c),d+=f.child(h).nodeSize;return t}function QA(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?ZA(e,n,t,i):eR(e,n,i):!0:!1}}function ZA(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Un(i-1,o,i,o,new Be(ke.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Wu(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const c=ya(r);if(c==null)return!1;s.lift(r,c);let d=s.doc.resolve(s.mapping.map(i,-1)-1);return Pi(s.doc,d.pos)&&d.nodeBefore.type==d.nodeAfter.type&&s.join(d.pos),e(s.scrollIntoView()),!0}function eR(t,e,n){let r=t.tr,s=n.parent;for(let v=n.end,x=n.endIndex-1,k=n.startIndex;x>k;x--)v-=s.child(x).nodeSize,r.delete(v-1,v+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,d=n.endIndex==s.childCount,f=i.node(-1),h=i.index(-1);if(!f.canReplace(h+(c?0:1),h+1,o.content.append(d?ke.empty:ke.from(s))))return!1;let m=i.pos,g=m+o.nodeSize;return r.step(new Un(m-(c?1:0),g+(d?1:0),m+1,g-1,new Be((c?ke.empty:ke.from(s.copy(ke.empty))).append(d?ke.empty:ke.from(s.copy(ke.empty))),c?0:1,d?0:1),c?0:1)),e(r.scrollIntoView()),!0}function tR(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,f=>f.childCount>0&&f.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let c=i.parent,d=c.child(o-1);if(d.type!=t)return!1;if(n){let f=d.lastChild&&d.lastChild.type==c.type,h=ke.from(f?t.create():null),m=new Be(ke.from(t.create(null,ke.from(c.type.create(null,h)))),f?3:1,0),g=i.start,v=i.end;n(e.tr.step(new Un(g-(f?3:1),v,g,v,m,1,!0)).scrollIntoView())}return!0}}const Zn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},ha=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let xg=null;const Hs=function(t,e,n){let r=xg||(xg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},nR=function(){xg=null},bo=function(t,e,n,r){return n&&(Ex(t,e,n,r,-1)||Ex(t,e,n,r,1))},rR=/^(img|br|input|textarea|hr)$/i;function Ex(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Kr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||$l(t)||rR.test(t.nodeName)||t.contentEditable=="false")return!1;e=Zn(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?Kr(t):0}else return!1}}function Kr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function sR(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Kr(t)}else if(t.parentNode&&!$l(t))e=Zn(t),t=t.parentNode;else return null}}function iR(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!$l(t))e=Zn(t)+1,t=t.parentNode;else return null}}function oR(t,e,n){for(let r=e==0,s=e==Kr(t);r||s;){if(t==n)return!0;let i=Zn(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==Kr(t)}}function $l(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Wd=function(t){return t.focusNode&&bo(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function so(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function aR(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function lR(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Kr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Kr(r.startContainer),r.startOffset)}}}const Ns=typeof navigator<"u"?navigator:null,Nx=typeof document<"u"?document:null,Bi=Ns&&Ns.userAgent||"",wg=/Edge\/(\d+)/.exec(Bi),FN=/MSIE \d/.exec(Bi),kg=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bi),Nr=!!(FN||kg||wg),Ti=FN?document.documentMode:kg?+kg[1]:wg?+wg[1]:0,Gr=!Nr&&/gecko\/(\d+)/i.test(Bi);Gr&&+(/Firefox\/(\d+)/.exec(Bi)||[0,0])[1];const Sg=!Nr&&/Chrome\/(\d+)/.exec(Bi),tr=!!Sg,zN=Sg?+Sg[1]:0,ar=!Nr&&!!Ns&&/Apple Computer/.test(Ns.vendor),pa=ar&&(/Mobile\/\w+/.test(Bi)||!!Ns&&Ns.maxTouchPoints>2),qr=pa||(Ns?/Mac/.test(Ns.platform):!1),UN=Ns?/Win/.test(Ns.platform):!1,Ws=/Android \d/.test(Bi),Fl=!!Nx&&"webkitFontSmoothing"in Nx.documentElement.style,cR=Fl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function uR(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Bs(t,e){return typeof t=="number"?t:t[e]}function dR(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Cx(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=ha(o);continue}let c=o,d=c==i.body,f=d?uR(i):dR(c),h=0,m=0;if(e.top<f.top+Bs(r,"top")?m=-(f.top-e.top+Bs(s,"top")):e.bottom>f.bottom-Bs(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+Bs(s,"top")-f.top:e.bottom-f.bottom+Bs(s,"bottom")),e.left<f.left+Bs(r,"left")?h=-(f.left-e.left+Bs(s,"left")):e.right>f.right-Bs(r,"right")&&(h=e.right-f.right+Bs(s,"right")),h||m)if(d)i.defaultView.scrollBy(h,m);else{let v=c.scrollLeft,x=c.scrollTop;m&&(c.scrollTop+=m),h&&(c.scrollLeft+=h);let k=c.scrollLeft-v,w=c.scrollTop-x;e={left:e.left-k,top:e.top-w,right:e.right-k,bottom:e.bottom-w}}let g=d?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:ha(o)}}function fR(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let c=t.root.elementFromPoint(i,o);if(!c||c==t.dom||!t.dom.contains(c))continue;let d=c.getBoundingClientRect();if(d.top>=n-20){r=c,s=d.top;break}}return{refDOM:r,refTop:s,stack:HN(t.dom)}}function HN(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=ha(r));return e}function hR({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;WN(n,r==0?0:r-e)}function WN(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Yo=null;function pR(t){if(t.setActive)return t.setActive();if(Yo)return t.focus(Yo);let e=HN(t);t.focus(Yo==null?{get preventScroll(){return Yo={preventScroll:!0},!0}}:void 0),Yo||(Yo=!1,WN(e,0))}function VN(t,e){let n,r=2e8,s,i=0,o=e.top,c=e.top,d,f;for(let h=t.firstChild,m=0;h;h=h.nextSibling,m++){let g;if(h.nodeType==1)g=h.getClientRects();else if(h.nodeType==3)g=Hs(h).getClientRects();else continue;for(let v=0;v<g.length;v++){let x=g[v];if(x.top<=o&&x.bottom>=c){o=Math.max(x.bottom,o),c=Math.min(x.top,c);let k=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(k<r){n=h,r=k,s=k&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,h.nodeType==1&&k&&(i=m+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!d&&x.left<=e.left&&x.right>=e.left&&(d=h,f={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(i=m+1)}}return!n&&d&&(n=d,s=f,r=0),n&&n.nodeType==3?mR(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:VN(n,s)}function mR(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=gi(r,1);if(o.top!=o.bottom&&mv(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function mv(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function gR(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function vR(t,e,n){let{node:r,offset:s}=VN(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function bR(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),d;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((d=c.dom.getBoundingClientRect()).width||d.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!o&&d.left>r.left||d.top>r.top?s=c.posBefore:(!o&&d.right<r.left||d.bottom<r.top)&&(s=c.posAfter),o=!0),!c.contentDOM&&s<0&&!c.node.isText))return(c.node.isBlock?r.top<(d.top+d.bottom)/2:r.left<(d.left+d.right)/2)?c.posBefore:c.posAfter;i=c.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function qN(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let c=o.getClientRects();for(let d=0;d<c.length;d++){let f=c[d];if(mv(e,f))return qN(o,e,f)}}if((i=(i+1)%r)==s)break}return t}function yR(t,e){let n=t.dom.ownerDocument,r,s=0,i=lR(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),c;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let f=t.dom.getBoundingClientRect();if(!mv(e,f)||(o=qN(t.dom,e,f),!o))return null}if(ar)for(let f=o;r&&f;f=ha(f))f.draggable&&(r=void 0);if(o=gR(o,e),r){if(Gr&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let h=r.childNodes[s],m;h.nodeName=="IMG"&&(m=h.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&s++}let f;Fl&&s&&r.nodeType==1&&(f=r.childNodes[s-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(c=bR(t,r,s,e))}c==null&&(c=vR(t,o,e));let d=t.docView.nearestDesc(o,!0);return{pos:c,inside:d?d.posAtStart-d.border:-1}}function _x(t){return t.top<t.bottom||t.left<t.right}function gi(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(_x(r))return r}return Array.prototype.find.call(n,_x)||t.getBoundingClientRect()}const xR=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function KN(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Fl||Gr;if(r.nodeType==3)if(o&&(xR.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let d=gi(Hs(r,s,s),n);if(Gr&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let f=gi(Hs(r,s-1,s-1),-1);if(f.top==d.top){let h=gi(Hs(r,s,s+1),-1);if(h.top!=d.top)return Xa(h,h.left<f.left)}}return d}else{let d=s,f=s,h=n<0?1:-1;return n<0&&!s?(f++,h=-1):n>=0&&s==r.nodeValue.length?(d--,h=1):n<0?d--:f++,Xa(gi(Hs(r,d,f),h),h<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==Kr(r))){let d=r.childNodes[s-1];if(d.nodeType==1)return ip(d.getBoundingClientRect(),!1)}if(i==null&&s<Kr(r)){let d=r.childNodes[s];if(d.nodeType==1)return ip(d.getBoundingClientRect(),!0)}return ip(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==Kr(r))){let d=r.childNodes[s-1],f=d.nodeType==3?Hs(d,Kr(d)-(o?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(f)return Xa(gi(f,1),!1)}if(i==null&&s<Kr(r)){let d=r.childNodes[s];for(;d.pmViewDesc&&d.pmViewDesc.ignoreForCoords;)d=d.nextSibling;let f=d?d.nodeType==3?Hs(d,0,o?0:1):d.nodeType==1?d:null:null;if(f)return Xa(gi(f,-1),!0)}return Xa(gi(r.nodeType==3?Hs(r):r,-n),n>=0)}function Xa(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function ip(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function GN(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function wR(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return GN(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let o=KN(t,s.pos,1);for(let c=i.firstChild;c;c=c.nextSibling){let d;if(c.nodeType==1)d=c.getClientRects();else if(c.nodeType==3)d=Hs(c,0,c.nodeValue.length).getClientRects();else continue;for(let f=0;f<d.length;f++){let h=d[f];if(h.bottom>h.top+1&&(n=="up"?o.top-h.top>(h.bottom-o.top)*2:h.bottom-o.bottom>(o.bottom-h.top)*2))return!1}}return!0})}const kR=/[\u0590-\u08ac]/;function SR(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,c=t.domSelection();return c?!kR.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:o:GN(t,e,()=>{let{focusNode:d,focusOffset:f,anchorNode:h,anchorOffset:m}=t.domSelectionRange(),g=c.caretBidiLevel;c.modify("move",n,"character");let v=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:k}=t.domSelectionRange(),w=x&&!v.contains(x.nodeType==1?x:x.parentNode)||d==x&&f==k;try{c.collapse(h,m),d&&(d!=h||f!=m)&&c.extend&&c.extend(d,f)}catch{}return g!=null&&(c.caretBidiLevel=g),w}):r.pos==r.start()||r.pos==r.end()}let Tx=null,jx=null,Mx=!1;function ER(t,e,n){return Tx==e&&jx==n?Mx:(Tx=e,jx=n,Mx=n=="up"||n=="down"?wR(t,e,n):SR(t,e,n))}const Jr=0,Ax=1,io=2,Cs=3;class zl{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Jr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Zn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let c=s.children[o];if(c.size){s=c;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],c=i+o.size;if(c>e||o instanceof YN){s=e-i;break}i=c}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof JN&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Zn(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Zn(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,c=0;;c++){let d=this.children[c],f=o+d.size;if(s==-1&&e<=f){let h=o+d.border;if(e>=h&&n<=f-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(e,n,h);e=o;for(let m=c;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){s=Zn(g.dom)+1;break}e-=g.size}s==-1&&(s=0)}if(s>-1&&(f>n||c==this.children.length-1)){n=f;for(let h=c+1;h<this.children.length;h++){let m=this.children[h];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){i=Zn(m.dom);break}n+=m.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=f}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let v=0,x=0;v<this.children.length;v++){let k=this.children[v],w=x+k.size;if(i>x&&o<w)return k.setSelection(e-x-k.border,n-x-k.border,r,s);x=w}let c=this.domFromPos(e,e?-1:1),d=n==e?c:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),h=r.domSelectionRange(),m=!1;if((Gr||ar)&&e==n){let{node:v,offset:x}=c;if(v.nodeType==3){if(m=!!(x&&v.nodeValue[x-1]==`
54
+ `),m&&x==v.nodeValue.length)for(let k=v,w;k;k=k.parentNode){if(w=k.nextSibling){w.nodeName=="BR"&&(c=d={node:w.parentNode,offset:Zn(w)+1});break}let S=k.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{let k=v.childNodes[x-1];m=k&&(k.nodeName=="BR"||k.contentEditable=="false")}}if(Gr&&h.focusNode&&h.focusNode!=d.node&&h.focusNode.nodeType==1){let v=h.focusNode.childNodes[h.focusOffset];v&&v.contentEditable=="false"&&(s=!0)}if(!(s||m&&ar)&&bo(c.node,c.offset,h.anchorNode,h.anchorOffset)&&bo(d.node,d.offset,h.focusNode,h.focusOffset))return;let g=!1;if((f.extend||e==n)&&!(m&&Gr)){f.collapse(c.node,c.offset);try{e!=n&&f.extend(d.node,d.offset),g=!0}catch{}}if(!g){if(e>n){let x=c;c=d,d=x}let v=document.createRange();v.setEnd(d.node,d.offset),v.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(v)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let c=r+i.border,d=o-i.border;if(e>=c&&n<=d){this.dirty=e==r||n==o?io:Ax,e==c&&n==d&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Cs:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?io:Cs}r=o}this.dirty=io}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?io:Ax;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class JN extends zl{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let c=document.createElement("span");c.appendChild(o),o=c}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Jr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class NR extends zl{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class yo extends zl{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=So.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new yo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Cs||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Cs&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Jr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Jr}}slice(e,n,r){let s=yo.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Ng(i,n,o,r)),e>0&&(i=Ng(i,0,e,r));for(let c=0;c<i.length;c++)i[c].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ji extends zl{constructor(e,n,r,s,i,o,c,d,f){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=c}static create(e,n,r,s,i,o){let c=i.nodeViews[n.type.name],d,f=c&&c(n,i,()=>{if(!d)return o;if(d.parent)return d.parent.posBeforeChild(d)},r,s),h=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:m}=So.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let g=h;return h=ZN(h,r,n),f?d=new CR(e,n,r,s,h,m||null,g,f,i,o+1):n.isText?new Vd(e,n,r,s,h,g,i):new ji(e,n,r,s,h,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>ke.empty)}return e}matchesNode(e,n,r){return this.dirty==Jr&&e.eq(this.node)&&qu(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,c=i&&i.pos<0,d=new TR(this,o&&o.node,e);AR(this.node,this.innerDeco,(f,h,m)=>{f.spec.marks?d.syncToMarks(f.spec.marks,r,e,h):f.type.side>=0&&!m&&d.syncToMarks(h==this.node.childCount?Yt.none:this.node.child(h).marks,r,e,h),d.placeWidget(f,e,s)},(f,h,m,g)=>{d.syncToMarks(f.marks,r,e,g);let v;d.findNodeMatch(f,h,m,g)||c&&e.state.selection.from>s&&e.state.selection.to<s+f.nodeSize&&(v=d.findIndexWithChild(i.node))>-1&&d.updateNodeAt(f,h,m,v,e)||d.updateNextNode(f,h,m,e,g,s)||d.addNode(f,h,m,e,s),s+=f.nodeSize}),d.syncToMarks([],r,e,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==io)&&(o&&this.protectLocalComposition(e,o),XN(this.contentDOM,this.children,e),pa&&RR(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof lt)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,c=OR(this.node.content,o,r-n,s-n);return c<0?null:{node:i,pos:c,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new NR(this,i,n,s);e.input.compositionNodes.push(o),this.children=Ng(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Cs||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Jr}updateOuterDeco(e){if(qu(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=QN(this.dom,this.nodeDOM,Eg(this.outerDeco,this.node,n),Eg(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Rx(t,e,n,r,s){ZN(r,e,t);let i=new ji(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Vd extends ji{constructor(e,n,r,s,i,o,c){super(e,n,r,s,i,null,o,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Cs||this.dirty!=Jr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Jr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Jr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new Vd(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Cs)}get domAtom(){return!1}isText(e){return this.node.text==e}}class YN extends zl{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Jr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class CR extends ji{constructor(e,n,r,s,i,o,c,d,f,h){super(e,n,r,s,i,o,c,f,h),this.spec=d}update(e,n,r,s){if(this.dirty==Cs)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function XN(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],c=o.dom;if(c.parentNode==t){for(;c!=r;)r=Ox(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(c,r);if(o instanceof yo){let d=r?r.previousSibling:t.lastChild;XN(o.contentDOM,o.children,n),r=d?d.nextSibling:t.firstChild}}for(;r;)r=Ox(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const ml=function(t){t&&(this.nodeName=t)};ml.prototype=Object.create(null);const oo=[new ml];function Eg(t,e,n){if(t.length==0)return oo;let r=n?oo[0]:new ml,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new ml(o.nodeName));for(let c in o){let d=o[c];d!=null&&(n&&s.length==1&&s.push(r=new ml(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+d:c=="style"?r.style=(r.style?r.style+";":"")+d:c!="nodeName"&&(r[c]=d))}}}return s}function QN(t,e,n,r){if(n==oo&&r==oo)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],c=n[i];if(i){let d;c&&c.nodeName==o.nodeName&&s!=t&&(d=s.parentNode)&&d.nodeName.toLowerCase()==o.nodeName||(d=document.createElement(o.nodeName),d.pmIsDeco=!0,d.appendChild(s),c=oo[0]),s=d}_R(s,c||oo[0],o)}return s}function _R(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function ZN(t,e,n){return QN(t,t,oo,Eg(e,n,t.nodeType!=1))}function qu(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Ox(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class TR{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=jR(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,c=Math.min(o,e.length);for(;i<c&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Jr,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let d=-1,f=this.top.children.length;s<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let h=this.index;h<f;h++){let m=this.top.children[h];if(m.matchesMark(e[o])&&!this.isLocked(m.dom)){d=h;break}}if(d>-1)d>this.index&&(this.changed=!0,this.destroyBetween(this.index,d)),this.top=this.top.children[this.index];else{let h=yo.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,h),this.top=h,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let c=this.index,d=Math.min(this.top.children.length,c+5);c<d;c++){let f=this.top.children[c];if(f.matchesNode(e,n,r)&&!this.preMatch.matched.has(f)){i=c;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Cs&&o.dom==o.contentDOM&&(o.dirty=io),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let c=this.index;c<this.top.children.length;c++){let d=this.top.children[c];if(d instanceof ji){let f=this.preMatch.matched.get(d);if(f!=null&&f!=i)return!1;let h=d.dom,m,g=this.isLocked(h)&&!(e.isText&&d.node&&d.node.isText&&d.nodeDOM.nodeValue==e.text&&d.dirty!=Cs&&qu(n,d.outerDeco));if(!g&&d.update(e,n,r,s))return this.destroyBetween(this.index,c),d.dom!=h&&(this.changed=!0),this.index++,!0;if(!g&&(m=this.recreateWrapper(d,e,n,r,s,o)))return this.destroyBetween(this.index,c),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=io,m.updateChildren(s,o+1),m.dirty=Jr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!qu(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let c=ji.create(this.top,n,r,s,i,o);if(c.contentDOM){c.children=e.children,e.children=[];for(let d of c.children)d.parent=c}return e.destroy(),c}addNode(e,n,r,s,i){let o=ji.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new JN(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof yo;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Vd)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ar||tr)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new YN(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function jR(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let c;for(;;)if(r){let f=n.children[r-1];if(f instanceof yo)n=f,r=f.children.length;else{c=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let d=c.node;if(d){if(d!=t.child(s-1))break;--s,i.set(c,s),o.push(c)}}return{index:s,matched:i,matches:o.reverse()}}function MR(t,e){return t.type.side-e.type.side}function AR(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let f=0;f<t.childCount;f++){let h=t.child(f);r(h,s,e.forChild(i,h),f),i+=h.nodeSize}return}let o=0,c=[],d=null;for(let f=0;;){let h,m;for(;o<s.length&&s[o].to==i;){let w=s[o++];w.widget&&(h?(m||(m=[h])).push(w):h=w)}if(h)if(m){m.sort(MR);for(let w=0;w<m.length;w++)n(m[w],f,!!d)}else n(h,f,!!d);let g,v;if(d)v=-1,g=d,d=null;else if(f<t.childCount)v=f,g=t.child(f++);else break;for(let w=0;w<c.length;w++)c[w].to<=i&&c.splice(w--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)c.push(s[o++]);let x=i+g.nodeSize;if(g.isText){let w=x;o<s.length&&s[o].from<w&&(w=s[o].from);for(let S=0;S<c.length;S++)c[S].to<w&&(w=c[S].to);w<x&&(d=g.cut(w-i),g=g.cut(0,w-i),x=w,v=-1)}else for(;o<s.length&&s[o].to<x;)o++;let k=g.isInline&&!g.isLeaf?c.filter(w=>!w.inline):c.slice();r(g,k,e.forChild(i,g),v),i=x}}function RR(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function OR(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),c=i;if(i+=o.nodeSize,!o.isText)continue;let d=o.text;for(;s<t.childCount;){let f=t.child(s++);if(i+=f.nodeSize,!f.isText)break;d+=f.text}if(i>=n){if(i>=r&&d.slice(r-e.length-c,r-c)==e)return r-e.length;let f=c<r?d.lastIndexOf(e,r-c-1):-1;if(f>=0&&f+e.length+c>=n)return c+f;if(n==r&&d.length>=r+e.length-c&&d.slice(r-c,r-c+e.length)==e)return r}}return-1}function Ng(t,e,n,r,s){let i=[];for(let o=0,c=0;o<t.length;o++){let d=t[o],f=c,h=c+=d.size;f>=n||h<=e?i.push(d):(f<e&&i.push(d.slice(0,e-f,r)),s&&(i.push(s),s=void 0),h>n&&i.push(d.slice(n-f,d.size,r)))}return i}function gv(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=r.resolve(o),d,f;if(Wd(n)){for(d=o;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&ot.isSelectable(m)&&s.parent&&!(m.isInline&&oR(n.focusNode,n.focusOffset,s.dom))){let g=s.posBefore;f=new ot(o==g?c:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let v=0;v<n.rangeCount;v++){let x=n.getRangeAt(v);m=Math.min(m,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(m<0)return null;[d,o]=g==t.state.selection.anchor?[g,m]:[m,g],c=r.resolve(o)}else d=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(d<0)return null}let h=r.resolve(d);if(!f){let m=e=="pointer"||t.state.selection.head<c.pos&&!i?1:-1;f=vv(t,h,c,m)}return f}function eC(t){return t.editable?t.hasFocus():nC(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ks(t,e=!1){let n=t.state.selection;if(tC(t,n),!!eC(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&tr){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&bo(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)LR(t);else{let{anchor:r,head:s}=n,i,o;Ix&&!(n instanceof lt)&&(n.$from.parent.inlineContent||(i=Lx(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Lx(t,n.to))),t.docView.setSelection(r,s,t,e),Ix&&(i&&Dx(i),o&&Dx(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&IR(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Ix=ar||tr&&zN<63;function Lx(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ar&&s&&s.contentEditable=="false")return op(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return op(s);if(i)return op(i)}}function op(t){return t.contentEditable="true",ar&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Dx(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function IR(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!eC(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function LR(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Zn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Nr&&Ti<=11&&(n.disabled=!0,n.disabled=!1)}function tC(t,e){if(e instanceof ot){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Px(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Px(t)}function Px(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function vv(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||lt.between(e,n,r)}function Bx(t){return t.editable&&!t.hasFocus()?!1:nC(t)}function nC(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function DR(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return bo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Cg(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&gt.findFrom(i,e)}function bi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function $x(t,e,n){let r=t.state.selection;if(r instanceof lt)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return bi(t,new lt(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Cg(t.state,e);return s&&s instanceof ot?bi(t,s):!1}else if(!(qr&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let c=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?ot.isSelectable(i)?bi(t,new ot(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Fl?bi(t,new lt(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ot&&r.node.isInline)return bi(t,new lt(e>0?r.$to:r.$from));{let s=Cg(t.state,e);return s?bi(t,s):!1}}}function Ku(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function gl(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Xo(t,e){return e<0?PR(t):BR(t)}function PR(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Gr&&n.nodeType==1&&r<Ku(n)&&gl(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(gl(c,-1))s=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(rC(n))break;{let c=n.previousSibling;for(;c&&gl(c,-1);)s=n.parentNode,i=Zn(c),c=c.previousSibling;if(c)n=c,r=Ku(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?_g(t,n,r):s&&_g(t,s,i)}function BR(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Ku(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let c=n.childNodes[r];if(gl(c,1))i=n,o=++r;else break}else{if(rC(n))break;{let c=n.nextSibling;for(;c&&gl(c,1);)i=c.parentNode,o=Zn(c)+1,c=c.nextSibling;if(c)n=c,r=0,s=Ku(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&_g(t,i,o)}function rC(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function $R(t,e){for(;t&&e==t.childNodes.length&&!$l(t);)e=Zn(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function FR(t,e){for(;t&&!e&&!$l(t);)e=Zn(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function _g(t,e,n){if(e.nodeType!=3){let i,o;(o=$R(e,n))?(e=o,n=0):(i=FR(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Wd(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Ks(t)},50)}function Fx(t,e){let n=t.state.doc.resolve(e);if(!(tr||UN)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function zx(t,e,n){let r=t.state.selection;if(r instanceof lt&&!r.empty||n.indexOf("s")>-1||qr&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Cg(t.state,e);if(o&&o instanceof ot)return bi(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,c=r instanceof Lr?gt.near(o,e):gt.findFrom(o,e);return c?bi(t,c):!1}return!1}function Ux(t,e){if(!(t.state.selection instanceof lt))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Hx(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function zR(t){if(!ar||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Hx(t,r,"true"),setTimeout(()=>Hx(t,r,"false"),20)}return!1}function UR(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function HR(t,e){let n=e.keyCode,r=UR(e);if(n==8||qr&&n==72&&r=="c")return Ux(t,-1)||Xo(t,-1);if(n==46&&!e.shiftKey||qr&&n==68&&r=="c")return Ux(t,1)||Xo(t,1);if(n==13||n==27)return!0;if(n==37||qr&&n==66&&r=="c"){let s=n==37?Fx(t,t.state.selection.from)=="ltr"?-1:1:-1;return $x(t,s,r)||Xo(t,s)}else if(n==39||qr&&n==70&&r=="c"){let s=n==39?Fx(t,t.state.selection.from)=="ltr"?1:-1:1;return $x(t,s,r)||Xo(t,s)}else{if(n==38||qr&&n==80&&r=="c")return zx(t,-1,r)||Xo(t,-1);if(n==40||qr&&n==78&&r=="c")return zR(t)||zx(t,1,r)||Xo(t,1);if(r==(qr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function bv(t,e){t.someProp("transformCopied",v=>{e=v(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let v=r.firstChild;n.push(v.type.name,v.attrs!=v.type.defaultAttrs?v.attrs:null),r=v.content}let o=t.someProp("clipboardSerializer")||So.fromSchema(t.state.schema),c=cC(),d=c.createElement("div");d.appendChild(o.serializeFragment(r,{document:c}));let f=d.firstChild,h,m=0;for(;f&&f.nodeType==1&&(h=lC[f.nodeName.toLowerCase()]);){for(let v=h.length-1;v>=0;v--){let x=c.createElement(h[v]);for(;d.firstChild;)x.appendChild(d.firstChild);d.appendChild(x),m++}f=d.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${s} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",v=>v(e,t))||e.content.textBetween(0,e.content.size,`
55
+
56
+ `);return{dom:d,text:g,slice:e}}function sC(t,e,n,r,s){let i=s.parent.type.spec.code,o,c;if(!n&&!e)return null;let d=!!e&&(r||i||!n);if(d){if(t.someProp("transformPastedText",g=>{e=g(e,i||r,t)}),i)return c=new Be(ke.from(t.state.schema.text(e.replace(/\r\n?/g,`
57
+ `))),0,0),t.someProp("transformPasted",g=>{c=g(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",g=>g(e,s,r,t));if(m)c=m;else{let g=s.marks(),{schema:v}=t.state,x=So.fromSchema(v);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(k=>{let w=o.appendChild(document.createElement("p"));k&&w.appendChild(x.serializeNode(v.text(k,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=KR(n),Fl&&GR(o);let f=o&&o.querySelector("[data-pm-slice]"),h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let m=+h[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||hl.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(d||h),context:s,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!WR.test(g.parentNode.nodeName)?{ignore:!0}:null}})),h)c=JR(Wx(c,+h[1],+h[2]),h[4]);else if(c=Be.maxOpen(VR(c.content,s),!0),c.openStart||c.openEnd){let m=0,g=0;for(let v=c.content.firstChild;m<c.openStart&&!v.type.spec.isolating;m++,v=v.firstChild);for(let v=c.content.lastChild;g<c.openEnd&&!v.type.spec.isolating;g++,v=v.lastChild);c=Wx(c,m,g)}return t.someProp("transformPasted",m=>{c=m(c,t,d)}),c}const WR=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function VR(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(c=>{if(!o)return;let d=s.findWrapping(c.type),f;if(!d)return o=null;if(f=o.length&&i.length&&oC(d,i,c,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=aC(o[o.length-1],i.length));let h=iC(c,d);o.push(h),s=s.matchType(h.type),i=d}}),o)return ke.from(o)}return t}function iC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ke.from(t));return t}function oC(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=oC(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(ke.from(iC(n,t,s+1))))}}function aC(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,aC(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(ke.empty,!0);return t.copy(n.append(r))}function Tg(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,c=o.content;return t.childCount>1&&(i=0),s<r-1&&(c=Tg(c,e,n,r,s+1,i)),s>=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,i<=s).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(ke.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function Wx(t,e,n){return e<t.openStart&&(t=new Be(Tg(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Be(Tg(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const lC={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Vx=null;function cC(){return Vx||(Vx=document.implementation.createHTMLDocument("title"))}let ap=null;function qR(t){let e=window.trustedTypes;return e?(ap||(ap=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ap.createHTML(t)):t}function KR(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=cC().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&lC[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=qR(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function GR(t){let e=t.querySelectorAll(tr?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function JR(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let c=r.length-2;c>=0;c-=2){let d=n.nodes[r[c]];if(!d||d.hasRequiredAttrs())break;s=ke.from(d.create(r[c+1],s)),i++,o++}return new Be(s,i,o)}const pr={},mr={},YR={touchstart:!0,touchmove:!0};class XR{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function QR(t){for(let e in pr){let n=pr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{eO(t,r)&&!yv(t,r)&&(t.editable||!(r.type in mr))&&n(t,r)},YR[e]?{passive:!0}:void 0)}ar&&t.dom.addEventListener("input",()=>null),jg(t)}function _i(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function ZR(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function jg(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>yv(t,r))})}function yv(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function eO(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function tO(t,e){!yv(t,e)&&pr[e.type]&&(t.editable||!(e.type in mr))&&pr[e.type](t,e)}mr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!dC(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ws&&tr&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),pa&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,so(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||HR(t,n)?n.preventDefault():_i(t,"key")};mr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};mr.keypress=(t,e)=>{let n=e;if(dC(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||qr&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof lt)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function qd(t){return{left:t.clientX,top:t.clientY}}function nO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function xv(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,c=>o>i.depth?c(t,n,i.nodeAfter,i.before(o),s,!0):c(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function ca(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function rO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ot.isSelectable(r)?(ca(t,new ot(n)),!0):!1}function sO(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof ot&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let c=o>i.depth?i.nodeAfter:i.node(o);if(ot.isSelectable(c)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(ca(t,ot.create(t.state.doc,s)),!0):!1}function iO(t,e,n,r,s){return xv(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?sO(t,n):rO(t,n))}function oO(t,e,n,r){return xv(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function aO(t,e,n,r){return xv(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||lO(t,n,r)}function lO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ca(t,lt.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),c=s.before(i);if(o.inlineContent)ca(t,lt.create(r,c+1,c+1+o.content.size));else if(ot.isSelectable(o))ca(t,ot.create(r,c));else continue;return!0}}function wv(t){return Gu(t)}const uC=qr?"metaKey":"ctrlKey";pr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=wv(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&nO(n,t.input.lastClick)&&!n[uC]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(qd(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new cO(t,o,n,!!r)):(i=="doubleClick"?oO:aO)(t,o.pos,o.inside,n)?n.preventDefault():_i(t,"pointer"))};class cO{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[uC],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let h=e.state.doc.resolve(n.pos);i=h.parent,o=h.depth?h.before():0}const c=s?null:r.target,d=c?e.docView.nearestDesc(c,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||f instanceof ot&&f.from<=o&&f.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Gr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),_i(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ks(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(qd(e))),this.updateAllowDefault(e),this.allowDefault||!n?_i(this.view,"pointer"):iO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ar&&this.mightDrag&&!this.mightDrag.node.isAtom||tr&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(ca(this.view,gt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):_i(this.view,"pointer")}move(e){this.updateAllowDefault(e),_i(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}pr.touchstart=t=>{t.input.lastTouch=Date.now(),wv(t),_i(t,"pointer")};pr.touchmove=t=>{t.input.lastTouch=Date.now(),_i(t,"pointer")};pr.contextmenu=t=>wv(t);function dC(t,e){return t.composing?!0:ar&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const uO=Ws?5e3:-1;mr.compositionstart=mr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof lt&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||tr&&UN&&dO(t)))t.markCursor=t.state.storedMarks||n.marks(),Gu(t,!0),t.markCursor=null;else if(Gu(t,!e.selection.empty),Gr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}fC(t,uO)};function dO(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}mr.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,fC(t,20))};function fC(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Gu(t),e))}function hC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=hO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function fO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=sR(e.focusNode,e.focusOffset),r=iR(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function hO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Gu(t,e=!1){if(!(Ws&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),hC(t),e||t.docView&&t.docView.dirty){let n=gv(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function pO(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const _l=Nr&&Ti<15||pa&&cR<604;pr.copy=mr.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=_l?null:n.clipboardData,o=r.content(),{dom:c,text:d}=bv(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",d)):pO(t,c),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function mO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function gO(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Tl(t,r.value,null,s,e):Tl(t,r.textContent,r.innerHTML,s,e)},50)}function Tl(t,e,n,r,s){let i=sC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,s,i||Be.empty)))return!0;if(!i)return!1;let o=mO(i),c=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pC(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}mr.paste=(t,e)=>{let n=e;if(t.composing&&!Ws)return;let r=_l?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Tl(t,pC(r),r.getData("text/html"),s,n)?n.preventDefault():gO(t,n)};class mC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const vO=qr?"altKey":"ctrlKey";function gC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[vO]}pr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(qd(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof ot?s.to-1:s.to))){if(r&&r.mightDrag)o=ot.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=ot.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:d,text:f,slice:h}=bv(t,c);(!n.dataTransfer.files.length||!tr||zN>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(_l?"Text":"text/html",d.innerHTML),n.dataTransfer.effectAllowed="copyMove",_l||n.dataTransfer.setData("text/plain",f),t.dragging=new mC(h,gC(t,n),o)};pr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};mr.dragover=mr.dragenter=(t,e)=>e.preventDefault();mr.drop=(t,e)=>{try{bO(t,e,t.dragging)}finally{t.dragging=null}};function bO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(qd(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",v=>{i=v(i,t,!1)}):i=sC(t,pC(e.dataTransfer),_l?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&gC(t,e));if(t.someProp("handleDrop",v=>v(t,e,i||Be.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?xN(t.state.doc,s.pos,i):s.pos;c==null&&(c=s.pos);let d=t.state.tr;if(o){let{node:v}=n;v?v.replace(d):d.deleteSelection()}let f=d.mapping.map(c),h=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=d.doc;if(h?d.replaceRangeWith(f,f,i.content.firstChild):d.replaceRange(f,f,i),d.doc.eq(m))return;let g=d.doc.resolve(f);if(h&&ot.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))d.setSelection(new ot(g));else{let v=d.mapping.map(c);d.mapping.maps[d.mapping.maps.length-1].forEach((x,k,w,S)=>v=S),d.setSelection(vv(t,g,d.doc.resolve(v)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}pr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Ks(t)},20))};pr.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};pr.beforeinput=(t,e)=>{if(tr&&Ws&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,so(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in mr)pr[t]=mr[t];function jl(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Ju{constructor(e,n){this.toDOM=e,this.spec=n||ho,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Ut(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ju&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&jl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Mi{constructor(e,n){this.attrs=e,this.spec=n||ho}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Ut(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Mi&&jl(this.attrs,e.attrs)&&jl(this.spec,e.spec)}static is(e){return e.type instanceof Mi}destroy(){}}class kv{constructor(e,n){this.attrs=e,this.spec=n||ho}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Ut(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof kv&&jl(this.attrs,e.attrs)&&jl(this.spec,e.spec)}destroy(){}}class Ut{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Ut(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Ut(e,e,new Ju(n,r))}static inline(e,n,r,s){return new Ut(e,n,new Mi(r,s))}static node(e,n,r,s){return new Ut(e,n,new kv(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Mi}get widget(){return this.type instanceof Ju}}const ta=[],ho={};class Ot{constructor(e,n){this.local=e.length?e:ta,this.children=n.length?n:ta}static create(e,n){return n.length?Yu(n,e,0,ho):or}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let c=this.local[o];c.from<=n&&c.to>=e&&(!i||i(c.spec))&&r.push(c.copy(c.from+s,c.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,r,s+c,i)}}map(e,n,r){return this==or||e.maps.length==0?this:this.mapInner(e,n,0,0,r||ho)}mapInner(e,n,r,s,i){let o;for(let c=0;c<this.local.length;c++){let d=this.local[c].map(e,r,s);d&&d.type.valid(n,d)?(o||(o=[])).push(d):i.onRemove&&i.onRemove(this.local[c].spec)}return this.children.length?yO(this.children,o||[],e,n,r,s,i):o?new Ot(o.sort(po),ta):or}add(e,n){return n.length?this==or?Ot.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((c,d)=>{let f=d+r,h;if(h=bC(n,c,f)){for(s||(s=this.children.slice());i<s.length&&s[i]<d;)i+=3;s[i]==d?s[i+2]=s[i+2].addInner(c,h,f+1):s.splice(i,0,d,d+c.nodeSize,Yu(h,c,f+1,ho)),i+=3}});let o=vC(i?yC(n):n,-r);for(let c=0;c<o.length;c++)o[c].type.valid(e,o[c])||o.splice(c--,1);return new Ot(o.length?this.local.concat(o).sort(po):this.local,s||this.children)}remove(e){return e.length==0||this==or?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,c=r[i]+n,d=r[i+1]+n;for(let h=0,m;h<e.length;h++)(m=e[h])&&m.from>c&&m.to<d&&(e[h]=null,(o||(o=[])).push(m));if(!o)continue;r==this.children&&(r=this.children.slice());let f=r[i+2].removeInner(o,c+1);f!=or?r[i+2]=f:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let c=0;c<s.length;c++)s[c].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(c--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new Ot(s,r):or}forChild(e,n){if(this==or)return this;if(n.isLeaf)return Ot.empty;let r,s;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let i=e+1,o=i+n.content.size;for(let c=0;c<this.local.length;c++){let d=this.local[c];if(d.from<o&&d.to>i&&d.type instanceof Mi){let f=Math.max(i,d.from)-i,h=Math.min(o,d.to)-i;f<h&&(s||(s=[])).push(d.copy(f,h))}}if(s){let c=new Ot(s.sort(po),ta);return r?new wi([c,r]):c}return r||or}eq(e){if(this==e)return!0;if(!(e instanceof Ot)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Sv(this.localsInner(e))}localsInner(e){if(this==or)return ta;if(e.inlineContent||!this.local.some(Mi.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Mi||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Ot.empty=new Ot([],[]);Ot.removeOverlap=Sv;const or=Ot.empty;class wi{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,ho));return wi.from(r)}forChild(e,n){if(n.isLeaf)return Ot.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=or&&(i instanceof wi?r=r.concat(i.members):r.push(i))}return wi.from(r)}eq(e){if(!(e instanceof wi)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Sv(r?n:n.sort(po)):ta}static from(e){switch(e.length){case 0:return or;case 1:return e[0];default:return new wi(e.every(n=>n instanceof Ot)?e:e.reduce((n,r)=>n.concat(r instanceof Ot?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function yO(t,e,n,r,s,i,o){let c=t.slice();for(let f=0,h=i;f<n.maps.length;f++){let m=0;n.maps[f].forEach((g,v,x,k)=>{let w=k-x-(v-g);for(let S=0;S<c.length;S+=3){let N=c[S+1];if(N<0||g>N+h-m)continue;let j=c[S]+h-m;v>=j?c[S+1]=g<=j?-2:-1:g>=h&&w&&(c[S]+=w,c[S+1]+=w)}m+=w}),h=n.maps[f].map(h,-1)}let d=!1;for(let f=0;f<c.length;f+=3)if(c[f+1]<0){if(c[f+1]==-2){d=!0,c[f+1]=-1;continue}let h=n.map(t[f]+i),m=h-s;if(m<0||m>=r.content.size){d=!0;continue}let g=n.map(t[f+1]+i,-1),v=g-s,{index:x,offset:k}=r.content.findIndex(m),w=r.maybeChild(x);if(w&&k==m&&k+w.nodeSize==v){let S=c[f+2].mapInner(n,w,h+1,t[f]+i+1,o);S!=or?(c[f]=m,c[f+1]=v,c[f+2]=S):(c[f+1]=-2,d=!0)}else d=!0}if(d){let f=xO(c,t,e,n,s,i,o),h=Yu(f,r,0,o);e=h.local;for(let m=0;m<c.length;m+=3)c[m+1]<0&&(c.splice(m,3),m-=3);for(let m=0,g=0;m<h.children.length;m+=3){let v=h.children[m];for(;g<c.length&&c[g]<v;)g+=3;c.splice(g,0,h.children[m],h.children[m+1],h.children[m+2])}}return new Ot(e.sort(po),c)}function vC(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Ut(s.from+e,s.to+e,s.type))}return n}function xO(t,e,n,r,s,i,o){function c(d,f){for(let h=0;h<d.local.length;h++){let m=d.local[h].map(r,s,f);m?n.push(m):o.onRemove&&o.onRemove(d.local[h].spec)}for(let h=0;h<d.children.length;h+=3)c(d.children[h+2],d.children[h]+f+1)}for(let d=0;d<t.length;d+=3)t[d+1]==-1&&c(t[d+2],e[d]+i+1);return n}function bC(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function yC(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Yu(t,e,n,r){let s=[],i=!1;e.forEach((c,d)=>{let f=bC(t,c,d+n);if(f){i=!0;let h=Yu(f,c,n+d+1,r);h!=or&&s.push(d,d+c.nodeSize,h)}});let o=vC(i?yC(t):t,-n).sort(po);for(let c=0;c<o.length;c++)o[c].type.valid(e,o[c])||(r.onRemove&&r.onRemove(o[c].spec),o.splice(c--,1));return o.length||s.length?new Ot(o,s):or}function po(t,e){return t.from-e.from||t.to-e.to}function Sv(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),qx(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),qx(e,s,r.copy(i.from,r.to)));break}}}return e}function qx(t,e,n){for(;e<t.length&&po(n,t[e])>0;)e++;t.splice(e,0,n)}function lp(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=or&&e.push(r)}),t.cursorWrapper&&e.push(Ot.create(t.state.doc,[t.cursorWrapper.deco])),wi.from(e)}const wO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},kO=Nr&&Ti<=11;class SO{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class EO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new SO,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Nr&&Ti<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ar&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),kO&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,wO)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Bx(this.view)){if(this.suppressingSelectionUpdates)return Ks(this.view);if(Nr&&Ti<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&bo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=ha(i))n.add(i);for(let i=e.anchorNode;i;i=ha(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Bx(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,c=!1,d=[];if(e.editable)for(let h=0;h<n.length;h++){let m=this.registerMutation(n[h],d);m&&(i=i<0?m.from:Math.min(m.from,i),o=o<0?m.to:Math.max(m.to,o),m.typeOver&&(c=!0))}if(d.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let h of d)if(h.nodeName=="BR"&&h.parentNode){let m=h.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&h.parentNode.removeChild(h)}}else if(Gr&&d.length){let h=d.filter(m=>m.nodeName=="BR");if(h.length==2){let[m,g]=h;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of h){let v=g.parentNode;v&&v.nodeName=="LI"&&(!m||_O(e,m)!=v)&&g.remove()}}}let f=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Wd(r)&&(f=gv(e))&&f.eq(gt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ks(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),NO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,TO(e,d)),this.handleDOMChange(i,o,c,d),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ks(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let m=e.addedNodes[h];n.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Nr&&Ti<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:m,nextSibling:g}=e.addedNodes[h];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(i=g)}let o=s&&s.parentNode==e.target?Zn(s)+1:0,c=r.localPosFromDOM(e.target,o,-1),d=i&&i.parentNode==e.target?Zn(i):e.target.childNodes.length,f=r.localPosFromDOM(e.target,d,1);return{from:c,to:f}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Kx=new WeakMap,Gx=!1;function NO(t){if(!Kx.has(t)&&(Kx.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Gr,Gx)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Gx=!0}}function Jx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return bo(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function CO(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Jx(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Jx(t,n):null}function _O(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function TO(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let c=o;for(;;){let d=c.firstChild;if(!d||d.nodeType!=1||d.contentEditable=="false"||/^(BR|IMG)$/.test(d.nodeName))break;c=d}c.insertBefore(i,c.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function jO(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:c}=t.docView.parseRange(e,n),d=t.domSelectionRange(),f,h=d.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)&&(f=[{node:h,offset:d.anchorOffset}],Wd(d)||f.push({node:d.focusNode,offset:d.focusOffset})),tr&&t.input.lastKeyCode===8)for(let w=i;w>s;w--){let S=r.childNodes[w-1],N=S.pmViewDesc;if(S.nodeName=="BR"&&!N){i=w;break}if(!N||N.size)break}let m=t.state.doc,g=t.someProp("domParser")||hl.fromSchema(t.state.schema),v=m.resolve(o),x=null,k=g.parse(r,{topNode:v.parent,topMatch:v.parent.contentMatchAt(v.index()),topOpen:!0,from:s,to:i,preserveWhitespace:v.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:MO,context:v});if(f&&f[0].pos!=null){let w=f[0].pos,S=f[1]&&f[1].pos;S==null&&(S=w),x={anchor:w+o,head:S+o}}return{doc:k,sel:x,from:o,to:c}}function MO(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ar&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||ar&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const AO=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function RO(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let L=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,$=gv(t,L);if($&&!t.state.selection.eq($)){if(tr&&Ws&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",F=>F(t,so(13,"Enter"))))return;let B=t.state.tr.setSelection($);L=="pointer"?B.setMeta("pointer",!0):L=="key"&&B.scrollIntoView(),i&&B.setMeta("composition",i),t.dispatch(B)}return}let o=t.state.doc.resolve(e),c=o.sharedDepth(n);e=o.before(c+1),n=t.state.doc.resolve(n).after(c+1);let d=t.state.selection,f=jO(t,e,n),h=t.state.doc,m=h.slice(f.from,f.to),g,v;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,v="end"):(g=t.state.selection.from,v="start"),t.input.lastKeyCode=null;let x=LO(m.content,f.doc.content,f.from,g,v);if(x&&t.input.domChangeCount++,(pa&&t.input.lastIOSEnter>Date.now()-225||Ws)&&s.some(L=>L.nodeType==1&&!AO.test(L.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",L=>L(t,so(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&d instanceof lt&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))x={start:d.from,endA:d.to,endB:d.to};else{if(f.sel){let L=Yx(t,t.state.doc,f.sel);if(L&&!L.eq(t.state.selection)){let $=t.state.tr.setSelection(L);i&&$.setMeta("composition",i),t.dispatch($)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof lt&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Nr&&Ti<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>f.from&&f.doc.textBetween(x.start-f.from-1,x.start-f.from+1)=="  "&&(x.start--,x.endA--,x.endB--);let k=f.doc.resolveNoCache(x.start-f.from),w=f.doc.resolveNoCache(x.endB-f.from),S=h.resolve(x.start),N=k.sameParent(w)&&k.parent.inlineContent&&S.end()>=x.endA;if((pa&&t.input.lastIOSEnter>Date.now()-225&&(!N||s.some(L=>L.nodeName=="DIV"||L.nodeName=="P"))||!N&&k.pos<f.doc.content.size&&(!k.sameParent(w)||!k.parent.inlineContent)&&k.pos<w.pos&&!/\S/.test(f.doc.textBetween(k.pos,w.pos,"","")))&&t.someProp("handleKeyDown",L=>L(t,so(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&IO(h,x.start,x.endA,k,w)&&t.someProp("handleKeyDown",L=>L(t,so(8,"Backspace")))){Ws&&tr&&t.domObserver.suppressSelectionUpdates();return}tr&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Ws&&!N&&k.start()!=w.start()&&w.parentOffset==0&&k.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==x.endA&&(x.endB-=2,w=f.doc.resolveNoCache(x.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(L){return L(t,so(13,"Enter"))})},20));let j=x.start,M=x.endA,_=L=>{let $=L||t.state.tr.replace(j,M,f.doc.slice(x.start-f.from,x.endB-f.from));if(f.sel){let B=Yx(t,$.doc,f.sel);B&&!(tr&&t.composing&&B.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(B.head==j||B.head==$.mapping.map(M)-1)||Nr&&B.empty&&B.head==j)&&$.setSelection(B)}return i&&$.setMeta("composition",i),$.scrollIntoView()},R;if(N)if(k.pos==w.pos){Nr&&Ti<=11&&k.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ks(t),20));let L=_(t.state.tr.delete(j,M)),$=h.resolve(x.start).marksAcross(h.resolve(x.endA));$&&L.ensureMarks($),t.dispatch(L)}else if(x.endA==x.endB&&(R=OO(k.parent.content.cut(k.parentOffset,w.parentOffset),S.parent.content.cut(S.parentOffset,x.endA-S.start())))){let L=_(t.state.tr);R.type=="add"?L.addMark(j,M,R.mark):L.removeMark(j,M,R.mark),t.dispatch(L)}else if(k.parent.child(k.index()).isText&&k.index()==w.index()-(w.textOffset?0:1)){let L=k.parent.textBetween(k.parentOffset,w.parentOffset),$=()=>_(t.state.tr.insertText(L,j,M));t.someProp("handleTextInput",B=>B(t,j,M,L,$))||t.dispatch($())}else t.dispatch(_());else t.dispatch(_())}function Yx(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:vv(t,e.resolve(n.anchor),e.resolve(n.head))}function OO(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,c,d;for(let h=0;h<r.length;h++)s=r[h].removeFromSet(s);for(let h=0;h<n.length;h++)i=n[h].removeFromSet(i);if(s.length==1&&i.length==0)c=s[0],o="add",d=h=>h.mark(c.addToSet(h.marks));else if(s.length==0&&i.length==1)c=i[0],o="remove",d=h=>h.mark(c.removeFromSet(h.marks));else return null;let f=[];for(let h=0;h<e.childCount;h++)f.push(d(e.child(h)));if(ke.from(f).eq(t))return{mark:c,type:o}}function IO(t,e,n,r,s){if(n-e<=s.pos-r.pos||cp(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let c=i.nodeAfter;return c!=null&&n==e+c.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(cp(i,!0,!0));return!o.parent.isTextblock||o.pos>n||cp(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function cp(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function LO(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let d=Math.max(0,i-Math.min(o,c));r-=o+d-i}if(o<i&&t.size<e.size){let d=r<=i&&r>=o?i-r:0;i-=d,i&&i<e.size&&Xx(e.textBetween(i-1,i+1))&&(i+=d?1:-1),c=i+(c-o),o=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,i&&i<t.size&&Xx(t.textBetween(i-1,i+1))&&(i+=d?1:-1),o=i+(o-c),c=i}return{start:i,endA:o,endB:c}}function Xx(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class xC{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new XR,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(nw),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=ew(this),Zx(this),this.nodeViews=tw(this),this.docView=Rx(this.state.doc,Qx(this),lp(this),this.dom,this),this.domObserver=new EO(this,(r,s,i,o)=>RO(this,r,s,i,o)),this.domObserver.start(),QR(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&jg(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(nw),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(hC(this),o=!0),this.state=e;let c=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let v=tw(this);PO(v,this.nodeViews)&&(this.nodeViews=v,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&jg(this),this.editable=ew(this),Zx(this);let d=lp(this),f=Qx(this),h=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,f,d);(m||!e.selection.eq(s.selection))&&(o=!0);let g=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&fR(this);if(o){this.domObserver.stop();let v=m&&(Nr||tr)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&DO(s.selection,e.selection);if(m){let x=tr?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=fO(this)),(i||!this.docView.update(e.doc,f,d,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=Rx(e.doc,f,d,this.dom,this)),x&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(v=!0)}v||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&DR(this))?Ks(this,v):(tC(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():g&&hR(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ot){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Cx(this,n.getBoundingClientRect(),e)}else Cx(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new mC(e.slice,e.move,s<0?void 0:ot.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let c=this.directPlugins[o].props[e];if(c!=null&&(s=n?n(c):c))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let c=i[o].props[e];if(c!=null&&(s=n?n(c):c))return s}}hasFocus(){if(Nr){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&pR(this.dom),Ks(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return yR(this,e)}coordsAtPos(e,n=1){return KN(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return ER(this,n||this.state,e)}pasteHTML(e,n){return Tl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Tl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return bv(this,e)}destroy(){this.docView&&(ZR(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],lp(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,nR())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return tO(this,e)}domSelectionRange(){let e=this.domSelection();return e?ar&&this.root.nodeType===11&&aR(this.dom.ownerDocument)==this.dom&&CO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}xC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Qx(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Ut.node(0,t.state.doc.content.size,e)]}function Zx(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ut.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ew(t){return!t.someProp("editable",e=>e(t.state)===!1)}function DO(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function tw(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function PO(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function nw(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Oi={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:"'"},Xu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},BO=typeof navigator<"u"&&/Mac/.test(navigator.platform),$O=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var er=0;er<10;er++)Oi[48+er]=Oi[96+er]=String(er);for(var er=1;er<=24;er++)Oi[er+111]="F"+er;for(var er=65;er<=90;er++)Oi[er]=String.fromCharCode(er+32),Xu[er]=String.fromCharCode(er);for(var up in Oi)Xu.hasOwnProperty(up)||(Xu[up]=Oi[up]);function FO(t){var e=BO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||$O&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Xu:Oi)[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 zO=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),UO=typeof navigator<"u"&&/Win/.test(navigator.platform);function HO(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let c=0;c<e.length-1;c++){let d=e[c];if(/^(cmd|meta|m)$/i.test(d))o=!0;else if(/^a(lt)?$/i.test(d))r=!0;else if(/^(c|ctrl|control)$/i.test(d))s=!0;else if(/^s(hift)?$/i.test(d))i=!0;else if(/^mod$/i.test(d))zO?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+d)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function WO(t){let e=Object.create(null);for(let n in t)e[HO(n)]=t[n];return e}function dp(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){return new $t({props:{handleKeyDown:Ev(t)}})}function Ev(t){let e=WO(t);return function(n,r){let s=FO(r),i,o=e[dp(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let c=e[dp(s,r,!1)];if(c&&c(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(UO&&r.ctrlKey&&r.altKey)&&(i=Oi[r.keyCode])&&i!=s){let c=e[dp(i,r)];if(c&&c(n.state,n.dispatch,n))return!0}}return!1}}var qO=Object.defineProperty,Nv=(t,e)=>{for(var n in e)qO(t,n,{get:e[n],enumerable:!0})};function Kd(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var Gd=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...f)=>{const h=c(...f)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],c=!!t,d=t||s.tr,f=()=>(!c&&e&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(d),o.every(m=>m===!0)),h={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...x)=>{const k=this.buildProps(d,e),w=g(...x)(k);return o.push(w),h}])),run:f};return h}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([c,d])=>[c,(...f)=>d(...f)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:Kd({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,d])=>[c,(...f)=>d(...f)(o)]))}};return o}},wC={};Nv(wC,{blur:()=>KO,clearContent:()=>GO,clearNodes:()=>JO,command:()=>YO,createParagraphNear:()=>XO,cut:()=>QO,deleteCurrentNode:()=>ZO,deleteNode:()=>eI,deleteRange:()=>tI,deleteSelection:()=>nI,enter:()=>rI,exitCode:()=>sI,extendMarkRange:()=>iI,first:()=>oI,focus:()=>lI,forEach:()=>cI,insertContent:()=>uI,insertContentAt:()=>hI,joinBackward:()=>gI,joinDown:()=>mI,joinForward:()=>vI,joinItemBackward:()=>bI,joinItemForward:()=>yI,joinTextblockBackward:()=>xI,joinTextblockForward:()=>wI,joinUp:()=>pI,keyboardShortcut:()=>SI,lift:()=>EI,liftEmptyBlock:()=>NI,liftListItem:()=>CI,newlineInCode:()=>_I,resetAttributes:()=>TI,scrollIntoView:()=>jI,selectAll:()=>MI,selectNodeBackward:()=>AI,selectNodeForward:()=>RI,selectParentNode:()=>OI,selectTextblockEnd:()=>II,selectTextblockStart:()=>LI,setContent:()=>DI,setMark:()=>eL,setMeta:()=>tL,setNode:()=>nL,setNodeSelection:()=>rL,setTextDirection:()=>sL,setTextSelection:()=>iL,sinkListItem:()=>oL,splitBlock:()=>aL,splitListItem:()=>lL,toggleList:()=>cL,toggleMark:()=>uL,toggleNode:()=>dL,toggleWrap:()=>fL,undoInputRule:()=>hL,unsetAllMarks:()=>pL,unsetMark:()=>mL,unsetTextDirection:()=>gL,updateAttributes:()=>vL,wrapIn:()=>bL,wrapInList:()=>yL});var KO=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),GO=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),JO=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(c,d)=>{if(c.type.isText)return;const{doc:f,mapping:h}=e,m=f.resolve(h.map(d)),g=f.resolve(h.map(d+c.nodeSize)),v=m.blockRange(g);if(!v)return;const x=ya(v);if(c.type.isTextblock){const{defaultType:k}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(v.start,k)}(x||x===0)&&e.lift(v,x)})}),!0},YO=t=>e=>t(e),XO=()=>({state:t,dispatch:e})=>DN(t,e),QO=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new lt(r.doc.resolve(Math.max(o-1,0)))),!0},ZO=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const c=s.before(i),d=s.after(i);t.delete(c,d).scrollIntoView()}return!0}return!1};function Mn(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var eI=t=>({tr:e,state:n,dispatch:r})=>{const s=Mn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const d=i.before(o),f=i.after(o);e.delete(d,f).scrollIntoView()}return!0}return!1},tI=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},nI=()=>({state:t,dispatch:e})=>uv(t,e),rI=()=>({commands:t})=>t.keyboardShortcut("Enter"),sI=()=>({state:t,dispatch:e})=>zA(t,e);function Cv(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Qu(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Cv(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function kC(t,e,n={}){return t.find(r=>r.type===e&&Qu(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function rw(t,e,n={}){return!!kC(t,e,n)}function _v(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(h=>h.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(h=>h.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!kC([...s.node.marks],e,n)))return;let o=s.index,c=t.start()+s.offset,d=o+1,f=c+s.node.nodeSize;for(;o>0&&rw([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;d<t.parent.childCount&&rw([...t.parent.child(d).marks],e,n);)f+=t.parent.child(d).nodeSize,d+=1;return{from:c,to:f}}function Gs(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var iI=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=Gs(t,r.schema),{doc:o,selection:c}=n,{$from:d,from:f,to:h}=c;if(s){const m=_v(d,i,e);if(m&&m.from<=f&&m.to>=h){const g=lt.create(o,m.from,m.to);n.setSelection(g)}}return!0},oI=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function SC(t){return t instanceof lt}function ao(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function EC(t,e=null){if(!e)return null;const n=gt.atStart(t),r=gt.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?lt.create(t,ao(0,s,i),ao(t.content.size,s,i)):lt.create(t,ao(e,s,i),ao(e,s,i))}function Mg(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ml(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function aI(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var lI=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ml()||Mg())&&r.dom.focus(),aI()&&!Ml()&&!Mg()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!SC(n.state.selection))return o(),!0;const c=EC(s.doc,t)||n.state.selection,d=n.state.selection.eq(c);return i&&(d||s.setSelection(c),d&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},cI=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),uI=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),NC=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&NC(r)}return t};function tu(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return NC(n)}function Al(t,e,n){if(t instanceof us||t instanceof ke)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return ke.fromArray(t.map(c=>e.nodeFromJSON(c)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Al("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,c="";const d=new cN({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:f=>(o=!0,c=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?hl.fromSchema(d).parseSlice(tu(t),n.parseOptions):hl.fromSchema(d).parse(tu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=hl.fromSchema(e);return n.slice?i.parseSlice(tu(t),n.parseOptions).content:i.parse(tu(t),n.parseOptions)}return Al("",e,n)}function dI(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof zn||s instanceof Un))return;const i=t.mapping.maps[r];let o=0;i.forEach((c,d,f,h)=>{o===0&&(o=h)}),t.setSelection(gt.near(t.doc.resolve(o),n))}var fI=t=>!("type"in t),hI=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const d=w=>{i.emit("contentError",{editor:i,error:w,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Al(e,i.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(w){d(w)}try{c=Al(e,i.schema,{parseOptions:f,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(w){return d(w),!1}let{from:h,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,v=!0;if((fI(c)?c:[c]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,v=v?w.isBlock:!1}),h===m&&v){const{parent:w}=r.doc.resolve(h);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(h-=1,m+=1)}let k;if(g){if(Array.isArray(e))k=e.map(w=>w.text||"").join("");else if(e instanceof ke){let w="";e.forEach(S=>{S.text&&(w+=S.text)}),k=w}else typeof e=="object"&&e&&e.text?k=e.text:k=e;r.insertText(k,h,m)}else{k=c;const w=r.doc.resolve(h),S=w.node(),N=w.parentOffset===0,j=S.isText||S.isTextblock,M=S.content.size>0;N&&j&&M&&(h=Math.max(0,h-1)),r.replaceWith(h,m,k)}n.updateSelection&&dI(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:h,text:k}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:h,text:k})}return!0},pI=()=>({state:t,dispatch:e})=>BA(t,e),mI=()=>({state:t,dispatch:e})=>$A(t,e),gI=()=>({state:t,dispatch:e})=>jN(t,e),vI=()=>({state:t,dispatch:e})=>ON(t,e),bI=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zd(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},yI=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zd(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},xI=()=>({state:t,dispatch:e})=>DA(t,e),wI=()=>({state:t,dispatch:e})=>PA(t,e);function CC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function kI(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let c=0;c<e.length-1;c+=1){const d=e[c];if(/^(cmd|meta|m)$/i.test(d))o=!0;else if(/^a(lt)?$/i.test(d))r=!0;else if(/^(c|ctrl|control)$/i.test(d))s=!0;else if(/^s(hift)?$/i.test(d))i=!0;else if(/^mod$/i.test(d))Ml()||CC()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${d}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var SI=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=kI(t).split(/-(?!$)/),o=i.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),c=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),d=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,c))});return d==null||d.steps.forEach(f=>{const h=f.map(r.mapping);h&&s&&r.maybeStep(h)}),!0};function Ii(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Mn(e,t.schema):null,c=[];t.doc.nodesBetween(r,s,(m,g)=>{if(m.isText)return;const v=Math.max(r,g),x=Math.min(s,g+m.nodeSize);c.push({node:m,from:v,to:x})});const d=s-r,f=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Qu(m.node.attrs,n,{strict:!1}));return i?!!f.length:f.reduce((m,g)=>m+g.to-g.from,0)>=d}var EI=(t,e={})=>({state:n,dispatch:r})=>{const s=Mn(t,n.schema);return Ii(n,s,e)?FA(n,r):!1},NI=()=>({state:t,dispatch:e})=>PN(t,e),CI=t=>({state:e,dispatch:n})=>{const r=Mn(t,e.schema);return QA(r)(e,n)},_I=()=>({state:t,dispatch:e})=>LN(t,e);function Jd(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function sw(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var TI=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const c=Jd(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Mn(t,r.schema)),c==="mark"&&(o=Gs(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(h,m)=>{i&&i===h.type&&(d=!0,s&&n.setNodeMarkup(m,void 0,sw(h.attrs,e))),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&(d=!0,s&&n.addMark(m,m+h.nodeSize,o.create(sw(g.attrs,e))))})})}),d},jI=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),MI=()=>({tr:t,dispatch:e})=>{if(e){const n=new Lr(t.doc);t.setSelection(n)}return!0},AI=()=>({state:t,dispatch:e})=>AN(t,e),RI=()=>({state:t,dispatch:e})=>IN(t,e),OI=()=>({state:t,dispatch:e})=>WA(t,e),II=()=>({state:t,dispatch:e})=>KA(t,e),LI=()=>({state:t,dispatch:e})=>qA(t,e);function Ag(t,e,n={},r={}){return Al(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var DI=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:c})=>{const{doc:d}=i;if(r.preserveWhitespace!=="full"){const f=Ag(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,d.content.size,f).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:d.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function _C(t,e){const n=Gs(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,d=>{o.push(...d.marks)});const c=o.find(d=>d.type.name===n.name);return c?{...c.attrs}:{}}function Tv(t,e){const n=new lv(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function PI(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Zu(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function TC(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function jC(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Yd(t){return e=>jC(e.$from,t)}function it(t,e,n){return t.config[e]===void 0&&t.parent?it(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?it(t.parent,e,n):null}):t.config[e]}function jv(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=it(e,"addExtensions",n);return r?[e,...jv(r())]:e}).flat(10)}function Mv(t,e){const n=So.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function MC(t){return typeof t=="function"}function Vt(t,e=void 0,...n){return MC(t)?e?t.bind(e)(...n):t(...n):t}function BI(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ma(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function AC(t){const e=[],{nodeExtensions:n,markExtensions:r}=ma(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const c={name:o.name,options:o.options,storage:o.storage,extensions:s},d=it(o,"addGlobalAttributes",c);if(!d)return;d().forEach(h=>{h.types.forEach(m=>{Object.entries(h.attributes).forEach(([g,v])=>{e.push({type:m,name:g,attribute:{...i,...v}})})})})}),s.forEach(o=>{const c={name:o.name,options:o.options,storage:o.storage},d=it(o,"addAttributes",c);if(!d)return;const f=d();Object.entries(f).forEach(([h,m])=>{const g={...i,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:o.name,name:h,attribute:g})})}),e}function Bt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const c=i?String(i).split(" "):[],d=r[s]?r[s].split(" "):[],f=c.filter(h=>!d.includes(h));r[s]=[...d,...f].join(" ")}else if(s==="style"){const c=i?i.split(";").map(h=>h.trim()).filter(Boolean):[],d=r[s]?r[s].split(";").map(h=>h.trim()).filter(Boolean):[],f=new Map;d.forEach(h=>{const[m,g]=h.split(":").map(v=>v.trim());f.set(m,g)}),c.forEach(h=>{const[m,g]=h.split(":").map(v=>v.trim());f.set(m,g)}),r[s]=Array.from(f.entries()).map(([h,m])=>`${h}: ${m}`).join("; ")}else r[s]=i}),r},{})}function ga(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Bt(n,r),{})}function $I(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function iw(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):$I(n.getAttribute(o.name));return c==null?i:{...i,[o.name]:c}},{});return{...r,...s}}}}function ow(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&BI(n)?!1:n!=null))}function aw(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function FI(t,e){var n;const r=AC(t),{nodeExtensions:s,markExtensions:i}=ma(t),o=(n=s.find(f=>it(f,"topNode")))==null?void 0:n.name,c=Object.fromEntries(s.map(f=>{const h=r.filter(S=>S.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((S,N)=>{const j=it(N,"extendNodeSchema",m);return{...S,...j?j(f):{}}},{}),v=ow({...g,content:Vt(it(f,"content",m)),marks:Vt(it(f,"marks",m)),group:Vt(it(f,"group",m)),inline:Vt(it(f,"inline",m)),atom:Vt(it(f,"atom",m)),selectable:Vt(it(f,"selectable",m)),draggable:Vt(it(f,"draggable",m)),code:Vt(it(f,"code",m)),whitespace:Vt(it(f,"whitespace",m)),linebreakReplacement:Vt(it(f,"linebreakReplacement",m)),defining:Vt(it(f,"defining",m)),isolating:Vt(it(f,"isolating",m)),attrs:Object.fromEntries(h.map(aw))}),x=Vt(it(f,"parseHTML",m));x&&(v.parseDOM=x.map(S=>iw(S,h)));const k=it(f,"renderHTML",m);k&&(v.toDOM=S=>k({node:S,HTMLAttributes:ga(S,h)}));const w=it(f,"renderText",m);return w&&(v.toText=w),[f.name,v]})),d=Object.fromEntries(i.map(f=>{const h=r.filter(w=>w.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((w,S)=>{const N=it(S,"extendMarkSchema",m);return{...w,...N?N(f):{}}},{}),v=ow({...g,inclusive:Vt(it(f,"inclusive",m)),excludes:Vt(it(f,"excludes",m)),group:Vt(it(f,"group",m)),spanning:Vt(it(f,"spanning",m)),code:Vt(it(f,"code",m)),attrs:Object.fromEntries(h.map(aw))}),x=Vt(it(f,"parseHTML",m));x&&(v.parseDOM=x.map(w=>iw(w,h)));const k=it(f,"renderHTML",m);return k&&(v.toDOM=w=>k({mark:w,HTMLAttributes:ga(w,h)})),[f.name,v]}));return new cN({topNode:o,nodes:c,marks:d})}function zI(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function ed(t){return t.sort((n,r)=>{const s=it(n,"priority")||100,i=it(r,"priority")||100;return s>i?-1:s<i?1:0})}function RC(t){const e=ed(jv(t)),n=zI(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function OC(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
58
+
59
+ `,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,s,(d,f,h,m)=>{var g;d.isBlock&&f>r&&(c+=i);const v=o==null?void 0:o[d.type.name];if(v)return h&&(c+=v({node:d,pos:f,parent:h,index:m,range:e})),!1;d.isText&&(c+=(g=d==null?void 0:d.text)==null?void 0:g.slice(Math.max(r,f)-f,s-f))}),c}function UI(t,e){const n={from:0,to:t.content.size};return OC(t,n,e)}function IC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function HI(t,e){const n=Mn(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,c=>{i.push(c)});const o=i.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function LC(t,e){const n=Jd(typeof e=="string"?e:e.name,t.schema);return n==="node"?HI(t,e):n==="mark"?_C(t,e):{}}function WI(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function VI(t){const e=WI(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Av(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((c,d)=>{o.push({from:c,to:d})});else{const{from:c,to:d}=n[i];if(c===void 0||d===void 0)return;o.push({from:c,to:d})}o.forEach(({from:c,to:d})=>{const f=e.slice(i).map(c,-1),h=e.slice(i).map(d),m=e.invert().map(f,-1),g=e.invert().map(h);r.push({oldRange:{from:m,to:g},newRange:{from:f,to:h}})})}),VI(r)}function Rv(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=_v(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var qI=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const c=s.node(i);(c==null?void 0:c.type.name)===e?o=c:i-=1}return[o,i]};function nu(t,e){return e.nodes[t]||e.marks[t]||null}function Iu(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var KI=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,c)=>{var d,f;const h=((f=(d=s.type.spec).toText)==null?void 0:f.call(d,{node:s,pos:i,parent:o,index:c}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?h:h.slice(0,Math.max(0,r-i))}),n};function Rg(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Gs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Qu(m.attrs,n,{strict:!1}));let o=0;const c=[];if(s.forEach(({$from:m,$to:g})=>{const v=m.pos,x=g.pos;t.doc.nodesBetween(v,x,(k,w)=>{if(!k.isText&&!k.marks.length)return;const S=Math.max(v,w),N=Math.min(x,w+k.nodeSize),j=N-S;o+=j,c.push(...k.marks.map(M=>({mark:M,from:S,to:N})))})}),o===0)return!1;const d=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Qu(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),f=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,g)=>m+g.to-g.from,0);return(d>0?d+f:d)>=o}function GI(t,e,n={}){if(!e)return Ii(t,null,n)||Rg(t,null,n);const r=Jd(e,t.schema);return r==="node"?Ii(t,e,n):r==="mark"?Rg(t,e,n):!1}var JI=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Yd(c=>c.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},YI=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function lw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function cw(t,e){const{nodeExtensions:n}=ma(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=Vt(it(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Xd(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Xd(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function DC(t){return t instanceof ot}var PC=class BC{constructor(e){this.position=e}static fromJSON(e){return new BC(e.position)}toJSON(){return{position:this.position}}};function XI(t,e){const n=e.mapping.mapResult(t.position);return{position:new PC(n.pos),mapResult:n}}function QI(t){return new PC(t)}function ZI(t,e,n){var r;const{selection:s}=e;let i=null;if(SC(s)&&(i=s.$cursor),i){const c=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(f=>f.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:c,$to:d})=>{let f=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,d.pos,(h,m,g)=>{if(f)return!1;if(h.isInline){const v=!g||g.type.allowsMarkType(n),x=!!n.isInSet(h.marks)||!h.marks.some(k=>k.type.excludes(n));f=v&&x}return!f}),f})}var eL=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:c}=i,d=Gs(t,r.schema);if(s)if(o){const f=_C(r,d);n.addStoredMark(d.create({...f,...e}))}else c.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(h,m,(g,v)=>{const x=Math.max(v,h),k=Math.min(v+g.nodeSize,m);g.marks.find(S=>S.type===d)?g.marks.forEach(S=>{d===S.type&&n.addMark(x,k,d.create({...S.attrs,...e}))}):n.addMark(x,k,d.create(e))})});return ZI(r,n,d)},tL=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),nL=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Mn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:c})=>Sx(i,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>Sx(i,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},rL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=ao(t,0,r.content.size),i=ot.create(r,s);e.setSelection(i)}return!0},sL=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,c;return typeof e=="number"?(o=e,c=e):e&&"from"in e&&"to"in e?(o=e.from,c=e.to):(o=i.from,c=i.to),s&&n.doc.nodesBetween(o,c,(d,f)=>{d.isText||n.setNodeMarkup(f,void 0,{...d.attrs,dir:t})}),!0},iL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=lt.atStart(r).from,c=lt.atEnd(r).to,d=ao(s,o,c),f=ao(i,o,c),h=lt.create(r,d,f);e.setSelection(h)}return!0},oL=t=>({state:e,dispatch:n})=>{const r=Mn(t,e.schema);return tR(r)(e,n)};function uw(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var aL=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:c,$to:d}=i,f=s.extensionManager.attributes,h=Iu(f,c.node().type.name,c.node().attrs);if(i instanceof ot&&i.node.isBlock)return!c.parentOffset||!qs(o,c.pos)?!1:(r&&(t&&uw(n,s.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=d.parentOffset===d.parent.content.size,g=c.depth===0?void 0:PI(c.node(-1).contentMatchAt(c.indexAfter(-1)));let v=m&&g?[{type:g,attrs:h}]:void 0,x=qs(e.doc,e.mapping.map(c.pos),1,v);if(!v&&!x&&qs(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(x=!0,v=g?[{type:g,attrs:h}]:void 0),r){if(x&&(i instanceof lt&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,v),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const k=e.mapping.map(c.before()),w=e.doc.resolve(k);c.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&uw(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return x},lL=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const c=Mn(t,r.schema),{$from:d,$to:f}=r.selection,h=r.selection.node;if(h&&h.isBlock||d.depth<2||!d.sameParent(f))return!1;const m=d.node(-1);if(m.type!==c)return!1;const g=i.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==c||d.index(-2)!==d.node(-2).childCount-1)return!1;if(s){let S=ke.empty;const N=d.index(-1)?1:d.index(-2)?2:3;for(let $=d.depth-N;$>=d.depth-3;$-=1)S=ke.from(d.node($).copy(S));const j=d.indexAfter(-1)<d.node(-2).childCount?1:d.indexAfter(-2)<d.node(-3).childCount?2:3,M={...Iu(g,d.node().type.name,d.node().attrs),...e},_=((o=c.contentMatch.defaultType)==null?void 0:o.createAndFill(M))||void 0;S=S.append(ke.from(c.createAndFill(null,_)||void 0));const R=d.before(d.depth-(N-1));n.replace(R,d.after(-j),new Be(S,4-N,0));let L=-1;n.doc.nodesBetween(R,n.doc.content.size,($,B)=>{if(L>-1)return!1;$.isTextblock&&$.content.size===0&&(L=B+1)}),L>-1&&n.setSelection(lt.near(n.doc.resolve(L))),n.scrollIntoView()}return!0}const v=f.pos===d.end()?m.contentMatchAt(0).defaultType:null,x={...Iu(g,m.type.name,m.attrs),...e},k={...Iu(g,d.node().type.name,d.node().attrs),...e};n.delete(d.pos,f.pos);const w=v?[{type:c,attrs:x},{type:v,attrs:k}]:[{type:c,attrs:x}];if(!qs(n.doc,d.pos,2))return!1;if(s){const{selection:S,storedMarks:N}=r,{splittableMarks:j}=i.extensionManager,M=N||S.$to.parentOffset&&S.$from.marks();if(n.split(d.pos,2,w).scrollIntoView(),!M||!s)return!0;const _=M.filter(R=>j.includes(R.type.name));n.ensureMarks(_)}return!0},fp=(t,e)=>{const n=Yd(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Pi(t.doc,n.pos)&&t.join(n.pos),!0},hp=(t,e)=>{const n=Yd(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Pi(t.doc,r)&&t.join(r),!0},cL=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:c,chain:d,commands:f,can:h})=>{const{extensions:m,splittableMarks:g}=s.extensionManager,v=Mn(t,o.schema),x=Mn(e,o.schema),{selection:k,storedMarks:w}=o,{$from:S,$to:N}=k,j=S.blockRange(N),M=w||k.$to.parentOffset&&k.$from.marks();if(!j)return!1;const _=Yd(R=>cw(R.type.name,m))(k);if(j.depth>=1&&_&&j.depth-_.depth<=1){if(_.node.type===v)return f.liftListItem(x);if(cw(_.node.type.name,m)&&v.validContent(_.node.content)&&c)return d().command(()=>(i.setNodeMarkup(_.pos,v),!0)).command(()=>fp(i,v)).command(()=>hp(i,v)).run()}return!n||!M||!c?d().command(()=>h().wrapInList(v,r)?!0:f.clearNodes()).wrapInList(v,r).command(()=>fp(i,v)).command(()=>hp(i,v)).run():d().command(()=>{const R=h().wrapInList(v,r),L=M.filter($=>g.includes($.type.name));return i.ensureMarks(L),R?!0:f.clearNodes()}).wrapInList(v,r).command(()=>fp(i,v)).command(()=>hp(i,v)).run()},uL=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Gs(t,r.schema);return Rg(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},dL=(t,e,n={})=>({state:r,commands:s})=>{const i=Mn(t,r.schema),o=Mn(e,r.schema),c=Ii(r,i,n);let d;return r.selection.$anchor.sameParent(r.selection.$head)&&(d=r.selection.$anchor.parent.attrs),c?s.setNode(o,d):s.setNode(i,{...d,...n})},fL=(t,e={})=>({state:n,commands:r})=>{const s=Mn(t,n.schema);return Ii(n,s,e)?r.lift(s):r.wrapIn(s,e)},hL=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,c=i.transform;for(let d=c.steps.length-1;d>=0;d-=1)o.step(c.steps[d].invert(c.docs[d]));if(i.text){const d=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,d))}else o.delete(i.from,i.to)}return!0}}return!1},pL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},mL=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,d=Gs(t,r.schema),{$from:f,empty:h,ranges:m}=c;if(!s)return!0;if(h&&o){let{from:g,to:v}=c;const x=(i=f.marks().find(w=>w.type===d))==null?void 0:i.attrs,k=_v(f,d,x);k&&(g=k.from,v=k.to),n.removeMark(g,v,d)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,d)});return n.removeStoredMark(d),!0},gL=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(c,d)=>{if(c.isText)return;const f={...c.attrs};delete f.dir,e.setNodeMarkup(d,void 0,f)}),!0},vL=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const c=Jd(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=Mn(t,r.schema)),c==="mark"&&(o=Gs(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;let g,v,x,k;n.selection.empty?r.doc.nodesBetween(h,m,(w,S)=>{i&&i===w.type&&(d=!0,x=Math.max(S,h),k=Math.min(S+w.nodeSize,m),g=S,v=w)}):r.doc.nodesBetween(h,m,(w,S)=>{S<h&&i&&i===w.type&&(d=!0,x=Math.max(S,h),k=Math.min(S+w.nodeSize,m),g=S,v=w),S>=h&&S<=m&&(i&&i===w.type&&(d=!0,s&&n.setNodeMarkup(S,void 0,{...w.attrs,...e})),o&&w.marks.length&&w.marks.forEach(N=>{if(o===N.type&&(d=!0,s)){const j=Math.max(S,h),M=Math.min(S+w.nodeSize,m);n.addMark(j,M,o.create({...N.attrs,...e}))}}))}),v&&(g!==void 0&&s&&n.setNodeMarkup(g,void 0,{...v.attrs,...e}),o&&v.marks.length&&v.marks.forEach(w=>{o===w.type&&s&&n.addMark(x,k,o.create({...w.attrs,...e}))}))}),d},bL=(t,e={})=>({state:n,dispatch:r})=>{const s=Mn(t,n.schema);return GA(s,e)(n,r)},yL=(t,e={})=>({state:n,dispatch:r})=>{const s=Mn(t,n.schema);return JA(s,e)(n,r)},xL=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Ul=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},wL=(t,e)=>{if(Cv(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function ru(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:c}=t,{view:d}=n;if(d.composing)return!1;const f=d.state.doc.resolve(r);if(f.parent.type.spec.code||(e=f.nodeBefore||f.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let h=!1;const m=KI(f)+i;return o.forEach(g=>{if(h)return;const v=wL(m,g.find);if(!v)return;const x=d.state.tr,k=Kd({state:d.state,transaction:x}),w={from:r-(v[0].length-i.length),to:s},{commands:S,chain:N,can:j}=new Gd({editor:n,state:k});g.handler({state:k,range:w,match:v,commands:S,chain:N,can:j})===null||!x.steps.length||(g.undoable&&x.setMeta(c,{transform:x,from:r,to:s,text:i}),d.dispatch(x),h=!0)}),h}function kL(t){const{editor:e,rules:n}=t,r=new $t({state:{init(){return null},apply(s,i,o){const c=s.getMeta(r);if(c)return c;const d=s.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:h}=d;typeof h=="string"?h=h:h=Mv(ke.from(h),o.schema);const{from:m}=d,g=m+h.length;ru({editor:e,from:m,to:g,text:h,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,c){return ru({editor:e,from:i,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ru({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ru({editor:e,from:o.pos,to:o.pos,text:`
60
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function SL(t){return Object.prototype.toString.call(t).slice(8,-1)}function su(t){return SL(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function $C(t,e){const n={...t};return su(t)&&su(e)&&Object.keys(e).forEach(r=>{su(e[r])&&su(t[r])?n[r]=$C(t[r],e[r]):n[r]=e[r]}),n}var Ov=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Vt(it(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Vt(it(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>$C(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},ds=class FC extends Ov{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new FC(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(f=>(f==null?void 0:f.type.name)===n.name))return!1;const d=o.find(f=>(f==null?void 0:f.type.name)===n.name);return d&&r.removeStoredMark(d),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function EL(t){return typeof t=="number"}var NL=class{constructor(t){this.find=t.find,this.handler=t.handler}},CL=(t,e,n)=>{if(Cv(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function _L(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:c}=t,{commands:d,chain:f,can:h}=new Gd({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,s,(v,x)=>{var k,w,S,N,j;if((w=(k=v.type)==null?void 0:k.spec)!=null&&w.code||!(v.isText||v.isTextblock||v.isInline))return;const M=(j=(N=(S=v.content)==null?void 0:S.size)!=null?N:v.nodeSize)!=null?j:0,_=Math.max(r,x),R=Math.min(s,x+M);if(_>=R)return;const L=v.isText?v.text||"":v.textBetween(_-x,R-x,void 0,"");CL(L,i.find,o).forEach(B=>{if(B.index===void 0)return;const F=_+B.index+1,K=F+B[0].length,z={from:n.tr.mapping.map(F),to:n.tr.mapping.map(K)},ee=i.handler({state:n,range:z,match:B,commands:d,chain:f,can:h,pasteEvent:o,dropEvent:c});m.push(ee)})}),m.every(v=>v!==null)}var iu=null,TL=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function jL(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const d=({state:h,from:m,to:g,rule:v,pasteEvt:x})=>{const k=h.tr,w=Kd({state:h,transaction:k});if(!(!_L({editor:e,state:w,from:Math.max(m-1,0),to:g.b-1,rule:v,pasteEvent:x,dropEvent:c})||!k.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,k}};return n.map(h=>new $t({view(m){const g=x=>{var k;r=(k=m.dom.parentElement)!=null&&k.contains(x.target)?m.dom.parentElement:null,r&&(iu=e)},v=()=>{iu&&(iu=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",v),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",v)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=r===m.dom.parentElement,c=g,!i){const v=iu;v!=null&&v.isEditable&&setTimeout(()=>{const x=v.state.selection;x&&v.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(m,g)=>{var v;const x=(v=g.clipboardData)==null?void 0:v.getData("text/html");return o=g,s=!!(x!=null&&x.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,v)=>{const x=m[0],k=x.getMeta("uiEvent")==="paste"&&!s,w=x.getMeta("uiEvent")==="drop"&&!i,S=x.getMeta("applyPasteRules"),N=!!S;if(!k&&!w&&!N)return;if(N){let{text:_}=S;typeof _=="string"?_=_:_=Mv(ke.from(_),v.schema);const{from:R}=S,L=R+_.length,$=TL(_);return d({rule:h,state:v,from:R,to:{b:L},pasteEvt:$})}const j=g.doc.content.findDiffStart(v.doc.content),M=g.doc.content.findDiffEnd(v.doc.content);if(!(!EL(j)||!M||j===M.b))return d({rule:h,state:v,from:j,to:M,pasteEvt:o})}}))}var Qd=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=RC(t),this.schema=FI(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:nu(e.name,this.schema)},r=it(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return ed([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:nu(r.name,this.schema)},i=[],o=it(r,"addKeyboardShortcuts",s);let c={};if(r.type==="mark"&&it(r,"exitable",s)&&(c.ArrowRight=()=>ds.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([v,x])=>[v,()=>x({editor:t})]));c={...c,...g}}const d=VO(c);i.push(d);const f=it(r,"addInputRules",s);if(lw(r,t.options.enableInputRules)&&f){const g=f();if(g&&g.length){const v=kL({editor:t,rules:g}),x=Array.isArray(v)?v:[v];i.push(...x)}}const h=it(r,"addPasteRules",s);if(lw(r,t.options.enablePasteRules)&&h){const g=h();if(g&&g.length){const v=jL({editor:t,rules:g});i.push(...v)}}const m=it(r,"addProseMirrorPlugins",s);if(m){const g=m();i.push(...g)}return i})}get attributes(){return AC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ma(this.extensions);return Object.fromEntries(e.filter(n=>!!it(n,"addNodeView")).map(n=>{const r=this.attributes.filter(d=>d.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Mn(n.name,this.schema)},i=it(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const c=(d,f,h,m,g)=>{const v=ga(d,r);return o({node:d,view:f,getPos:h,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:v})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return ed([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:nu(s.name,this.schema)},o=it(s,"dispatchTransaction",i);return o?c=>{o.call(i,{transaction:c,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=ma(this.extensions);return Object.fromEntries(e.filter(n=>!!it(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Gs(n.name,this.schema)},i=it(n,"addMarkView",s);if(!i)return[];const o=(c,d,f)=>{const h=ga(c,r);return i()({mark:c,view:d,inline:f,editor:t,extension:n,HTMLAttributes:h,updateAttributes:m=>{WL(c,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:nu(e.name,this.schema)};e.type==="mark"&&((n=Vt(it(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=it(e,"onBeforeCreate",r),i=it(e,"onCreate",r),o=it(e,"onUpdate",r),c=it(e,"onSelectionUpdate",r),d=it(e,"onTransaction",r),f=it(e,"onFocus",r),h=it(e,"onBlur",r),m=it(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),c&&this.editor.on("selectionUpdate",c),d&&this.editor.on("transaction",d),f&&this.editor.on("focus",f),h&&this.editor.on("blur",h),m&&this.editor.on("destroy",m)})}};Qd.resolve=RC;Qd.sort=ed;Qd.flatten=jv;var ML={};Nv(ML,{ClipboardTextSerializer:()=>UC,Commands:()=>HC,Delete:()=>WC,Drop:()=>VC,Editable:()=>qC,FocusEvents:()=>GC,Keymap:()=>JC,Paste:()=>YC,Tabindex:()=>XC,TextDirection:()=>QC,focusEventsPluginKey:()=>KC});var Lt=class zC extends Ov{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new zC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},UC=Lt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new $t({key:new qt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(h=>h.$from.pos)),c=Math.max(...i.map(h=>h.$to.pos)),d=IC(n);return OC(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),HC=Lt.create({name:"commands",addCommands(){return{...wC}}}),WC=Lt.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,c,d,f;if((f=(d=(c=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:c.filterTransaction)==null?void 0:d.call(c,t))!=null?f:t.getMeta("y-sync$"))return;const h=Tv(t.before,[t,...e]);Av(h).forEach(v=>{h.mapping.mapResult(v.oldRange.from).deletedAfter&&h.mapping.mapResult(v.oldRange.to).deletedBefore&&h.before.nodesBetween(v.oldRange.from,v.oldRange.to,(x,k)=>{const w=k+x.nodeSize-2,S=v.oldRange.from<=k&&w<=v.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:k,to:w,newFrom:h.mapping.map(k),newTo:h.mapping.map(w),deletedRange:v.oldRange,newRange:v.newRange,partial:!S,editor:this.editor,transaction:t,combinedTransform:h})})});const g=h.mapping;h.steps.forEach((v,x)=>{var k,w;if(v instanceof cs){const S=g.slice(x).map(v.from,-1),N=g.slice(x).map(v.to),j=g.invert().map(S,-1),M=g.invert().map(N),_=(k=h.doc.nodeAt(S-1))==null?void 0:k.marks.some(L=>L.eq(v.mark)),R=(w=h.doc.nodeAt(N))==null?void 0:w.marks.some(L=>L.eq(v.mark));this.editor.emit("delete",{type:"mark",mark:v.mark,from:v.from,to:v.to,deletedRange:{from:j,to:M},newRange:{from:S,to:N},partial:!!(R||_),editor:this.editor,transaction:t,combinedTransform:h})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),VC=Lt.create({name:"drop",addProseMirrorPlugins(){return[new $t({key:new qt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),qC=Lt.create({name:"editable",addProseMirrorPlugins(){return[new $t({key:new qt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),KC=new qt("focusEvents"),GC=Lt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new $t({key:KC,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),JC=Lt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:c})=>{const{selection:d,doc:f}=c,{empty:h,$anchor:m}=d,{pos:g,parent:v}=m,x=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,k=x.parent.type.spec.isolating,w=m.pos-m.parentOffset,S=k&&x.parent.childCount===1?w===m.pos:gt.atStart(f).from===g;return!h||!v.type.isTextblock||v.textContent.length||!S||S&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ml()||CC()?i:s},addProseMirrorPlugins(){return[new $t({key:new qt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(k=>k.getMeta("composition")))return;const r=t.some(k=>k.docChanged)&&!e.doc.eq(n.doc),s=t.some(k=>k.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:c}=e.selection,d=gt.atStart(e.doc).from,f=gt.atEnd(e.doc).to;if(i||!(o===d&&c===f)||!Xd(n.doc))return;const g=n.tr,v=Kd({state:n,transaction:g}),{commands:x}=new Gd({editor:this.editor,state:v});if(x.clearNodes(),!!g.steps.length)return g}})]}}),YC=Lt.create({name:"paste",addProseMirrorPlugins(){return[new $t({key:new qt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),XC=Lt.create({name:"tabindex",addProseMirrorPlugins(){return[new $t({key:new qt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),QC=Lt.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ma(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new $t({key:new qt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),AL=class ll{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ll(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ll(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ll(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,c=this.pos+r+(i?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const d=this.resolvedPos.doc.resolve(c);if(!s&&!o&&d.depth<=this.depth)return;const f=new ll(d,this.editor,s,s||o?n:null);s&&(f.actualDepth=this.depth+1),e.push(f)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let c=0;c<o.length;c+=1){const d=o[c];if(i[d]!==n[d])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(d=>n[d]===o.node.attrs[d])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},RL=`.ProseMirror {
61
+ position: relative;
62
+ }
63
+
64
+ .ProseMirror {
65
+ word-wrap: break-word;
66
+ white-space: pre-wrap;
67
+ white-space: break-spaces;
68
+ -webkit-font-variant-ligatures: none;
69
+ font-variant-ligatures: none;
70
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
71
+ }
72
+
73
+ .ProseMirror [contenteditable="false"] {
74
+ white-space: normal;
75
+ }
76
+
77
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
78
+ white-space: pre-wrap;
79
+ }
80
+
81
+ .ProseMirror pre {
82
+ white-space: pre-wrap;
83
+ }
84
+
85
+ img.ProseMirror-separator {
86
+ display: inline !important;
87
+ border: none !important;
88
+ margin: 0 !important;
89
+ width: 0 !important;
90
+ height: 0 !important;
91
+ }
92
+
93
+ .ProseMirror-gapcursor {
94
+ display: none;
95
+ pointer-events: none;
96
+ position: absolute;
97
+ margin: 0;
98
+ }
99
+
100
+ .ProseMirror-gapcursor:after {
101
+ content: "";
102
+ display: block;
103
+ position: absolute;
104
+ top: -2px;
105
+ width: 20px;
106
+ border-top: 1px solid black;
107
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
108
+ }
109
+
110
+ @keyframes ProseMirror-cursor-blink {
111
+ to {
112
+ visibility: hidden;
113
+ }
114
+ }
115
+
116
+ .ProseMirror-hideselection *::selection {
117
+ background: transparent;
118
+ }
119
+
120
+ .ProseMirror-hideselection *::-moz-selection {
121
+ background: transparent;
122
+ }
123
+
124
+ .ProseMirror-hideselection * {
125
+ caret-color: transparent;
126
+ }
127
+
128
+ .ProseMirror-focused .ProseMirror-gapcursor {
129
+ display: block;
130
+ }`;function OL(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var IL=class extends xL{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:XI,createMappablePosition:QI},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=EC(e,this.options.autofocus);this.editorState=ia.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=OL(RL,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=MC(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[qC,UC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),HC,GC,JC,XC,VC,YC,WC,QC.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Qd(r,this)}createCommandManager(){this.commandManager=new Gd({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Ag(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Ag(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new xC(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.prependClass(),this.injectCSS();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(f=>{var h;return(h=this.capturedTransaction)==null?void 0:h.step(f)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),c=o==null?void 0:o.getMeta("focus"),d=o==null?void 0:o.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:o}),d&&this.emit("blur",{editor:this,event:d.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(f=>f.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return LC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return GI(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Mv(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
131
+
132
+ `,textSerializers:n={}}=t||{};return UI(this.state.doc,{blockSeparator:e,textSerializers:{...IC(this.schema),...n}})}get isEmpty(){return Xd(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new AL(e,this)}get $doc(){return this.$pos(0)}};function xo(t){return new Ul({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Vt(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],c=r[0];if(o){const d=c.search(/\S/),f=n.from+c.indexOf(o),h=f+o.length;if(Rv(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(k=>k===t.type&&k!==v.mark.type)).filter(v=>v.to>f).length)return null;h<n.to&&i.delete(h,n.to),f>n.from&&i.delete(n.from+d,f);const g=n.from+d+o.length;i.addMark(n.from+d,g,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function ZC(t){return new Ul({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Vt(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let c=n.to;const d=t.type.create(s);if(r[1]){const f=r[0].lastIndexOf(r[1]);let h=o+f;h>c?h=c:c=h+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,o+r[0].length-1),i.replaceWith(h,c,d)}else if(r[0]){const f=t.type.isInline?o:o-1;i.insert(f,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function Og(t){return new Ul({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=Vt(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function yn(t){return new Ul({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const o=n.to;if(r[1]){const c=r[0].lastIndexOf(r[1]);s+=r[0].slice(c+r[1].length),i+=c;const d=i-o;d>0&&(s=r[0].slice(c-d,c)+s,i=o)}e.tr.insertText(s,i,o)},undoable:t.undoable})}function va(t){return new Ul({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=Vt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),d=o.doc.resolve(n.from).blockRange(),f=d&&av(d,t.type,i);if(!f)return null;if(o.wrap(d,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:v}=t.editor.extensionManager,x=g||m.$to.parentOffset&&m.$from.marks();if(x){const k=x.filter(w=>v.includes(w.type.name));o.ensureMarks(k)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(m,i).run()}const h=o.doc.resolve(n.from-1).nodeBefore;h&&h.type===t.type&&Pi(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&o.join(n.from-1)},undoable:t.undoable})}var LL=t=>"touches"in t,DL=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const d=c.clientX-this.startX,f=c.clientY-this.startY;this.handleResize(d,f)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const d=c.touches[0];if(!d)return;const f=d.clientX-this.startX,h=d.clientY-this.startY;this.handleResize(f,h)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,d=this.element.offsetHeight;this.onCommit(c,d),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,LL(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),c=t.includes("bottom"),d=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),c?s=this.startHeight+n:d&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let f=Math.max(this.minSize.width,t),h=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(f=Math.min(this.maxSize.width,f)),(s=this.maxSize)!=null&&s.height&&(h=Math.min(this.maxSize.height,h)),{width:f,height:h}}let c=t,d=e;return c<this.minSize.width&&(c=this.minSize.width,d=c/this.aspectRatio),d<this.minSize.height&&(d=this.minSize.height,c=d*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&c>this.maxSize.width&&(c=this.maxSize.width,d=c/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&d>this.maxSize.height&&(d=this.maxSize.height,c=d*this.aspectRatio),{width:c,height:d}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function PL(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ot){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}var BL={};Nv(BL,{createAtomBlockMarkdownSpec:()=>$L,createBlockMarkdownSpec:()=>FL,createInlineMarkdownSpec:()=>HL,parseAttributes:()=>Iv,parseIndentedBlocks:()=>Ig,renderNestedMarkdownContent:()=>Dv,serializeAttributes:()=>Lv});function Iv(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const f=s.map(h=>h.trim().slice(1));e.class=f.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,f,h])=>{var m;const g=parseInt(((m=h.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),v=n[g];v&&(e[f]=v.slice(1,-1))});const d=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return d&&d.split(/\s+/).filter(Boolean).forEach(h=>{h.match(/^[a-zA-Z][\w-]*$/)&&(e[h]=!0)}),e}function Lv(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function $L(t){const{nodeName:e,name:n,parseAttributes:r=Iv,serializeAttributes:s=Lv,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:c}=t,d=n||e,f=h=>{if(!c)return h;const m={};return c.forEach(g=>{g in h&&(m[g]=h[g])}),m};return{parseMarkdown:(h,m)=>{const g={...i,...h.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(h){var m;const g=new RegExp(`^:::${d}(?:\\s|$)`,"m"),v=(m=h.match(g))==null?void 0:m.index;return v!==void 0?v:-1},tokenize(h,m,g){const v=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=h.match(v);if(!x)return;const k=x[1]||"",w=r(k);if(!o.find(N=>!(N in w)))return{type:e,raw:x[0],attributes:w}}},renderMarkdown:h=>{const m=f(h.attrs||{}),g=s(m),v=g?` {${g}}`:"";return`:::${d}${v} :::`}}}function FL(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Iv,serializeAttributes:i=Lv,defaultAttributes:o={},content:c="block",allowedAttributes:d}=t,f=n||e,h=m=>{if(!d)return m;const g={};return d.forEach(v=>{v in m&&(g[v]=m[v])}),g};return{parseMarkdown:(m,g)=>{let v;if(r){const k=r(m);v=typeof k=="string"?[{type:"text",text:k}]:k}else c==="block"?v=g.parseChildren(m.tokens||[]):v=g.parseInline(m.tokens||[]);const x={...o,...m.attributes};return g.createNode(e,x,v)},markdownTokenizer:{name:e,level:"block",start(m){var g;const v=new RegExp(`^:::${f}`,"m"),x=(g=m.match(v))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(m,g,v){var x;const k=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=m.match(k);if(!w)return;const[S,N=""]=w,j=s(N);let M=1;const _=S.length;let R="";const L=/^:::([\w-]*)(\s.*)?/gm,$=m.slice(_);for(L.lastIndex=0;;){const B=L.exec($);if(B===null)break;const F=B.index,K=B[1];if(!((x=B[2])!=null&&x.endsWith(":::"))){if(K)M+=1;else if(M-=1,M===0){const z=$.slice(0,F);R=z.trim();const ee=m.slice(0,_+F+B[0].length);let P=[];if(R)if(c==="block")for(P=v.blockTokens(z),P.forEach(U=>{U.text&&(!U.tokens||U.tokens.length===0)&&(U.tokens=v.inlineTokens(U.text))});P.length>0;){const U=P[P.length-1];if(U.type==="paragraph"&&(!U.text||U.text.trim()===""))P.pop();else break}else P=v.inlineTokens(R);return{type:e,raw:ee,attributes:j,content:R,tokens:P}}}}}},renderMarkdown:(m,g)=>{const v=h(m.attrs||{}),x=i(v),k=x?` {${x}}`:"",w=g.renderChildren(m.content||[],`
133
+
134
+ `);return`:::${f}${k}
135
+
136
+ ${w}
137
+
138
+ :::`}}}function zL(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function UL(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function HL(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=zL,serializeAttributes:i=UL,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:d}=t,f=n||e,h=g=>{if(!d)return g;const v={};return d.forEach(x=>{const k=typeof x=="string"?x:x.name,w=typeof x=="string"?void 0:x.skipIfDefault;if(k in g){const S=g[k];if(w!==void 0&&S===w)return;v[k]=S}}),v},m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,v)=>{const x={...o,...g.attributes};if(c)return v.createNode(e,x);const k=r?r(g):g.content||"";return k?v.createNode(e,x,[v.createTextNode(k)]):v.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const v=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),x=g.match(v),k=x==null?void 0:x.index;return k!==void 0?k:-1},tokenize(g,v,x){const k=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),w=g.match(k);if(!w)return;let S="",N="";if(c){const[,M]=w;N=M}else{const[,M,_]=w;N=M,S=_||""}const j=s(N.trim());return{type:e,raw:w[0],content:S.trim(),attributes:j}}},renderMarkdown:g=>{let v="";r?v=r(g):g.content&&g.content.length>0&&(v=g.content.filter(S=>S.type==="text").map(S=>S.text).join(""));const x=h(g.attrs||{}),k=i(x),w=k?` ${k}`:"";return c?`[${f}${w}]`:`[${f}${w}]${v}[/${f}]`}}}function Ig(t,e,n){var r,s,i,o;const c=t.split(`
139
+ `),d=[];let f="",h=0;const m=e.baseIndentSize||2;for(;h<c.length;){const g=c[h],v=g.match(e.itemPattern);if(!v){if(d.length>0)break;if(g.trim()===""){h+=1,f=`${f}${g}
140
+ `;continue}else return}const x=e.extractItemData(v),{indentLevel:k,mainContent:w}=x;f=`${f}${g}
141
+ `;const S=[w];for(h+=1;h<c.length;){const _=c[h];if(_.trim()===""){const L=c.slice(h+1).findIndex(F=>F.trim()!=="");if(L===-1)break;if((((s=(r=c[h+1+L].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>k){S.push(_),f=`${f}${_}
142
+ `,h+=1;continue}else break}if((((o=(i=_.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>k)S.push(_),f=`${f}${_}
143
+ `,h+=1;else break}let N;const j=S.slice(1);if(j.length>0){const _=j.map(R=>R.slice(k+m)).join(`
144
+ `);_.trim()&&(e.customNestedParser?N=e.customNestedParser(_):N=n.blockTokens(_))}const M=e.createToken(x,N);d.push(M)}if(d.length!==0)return{items:d,raw:f}}function Dv(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,c=e.renderChildren([i]),d=[`${s}${c}`];return o&&o.length>0&&o.forEach(f=>{const h=e.renderChildren([f]);if(h){const m=h.split(`
145
+ `).map(g=>g?e.indent(g):"").join(`
146
+ `);d.push(m)}}),d.join(`
147
+ `)}function WL(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((c,d)=>{const f=i.mapping.map(d),h=i.mapping.map(d)+c.nodeSize;let m=null;if(c.marks.forEach(v=>{if(v!==o)return!1;m=v}),!m)return;let g=!1;if(Object.keys(n).forEach(v=>{n[v]!==m.attrs[v]&&(g=!0)}),g){const v=t.type.create({...t.attrs,...n});i.removeMark(f,h,t.type),i.addMark(f,h,v)}}),i.docChanged&&e.view.dispatch(i)}var xn=class e_ extends Ov{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new e_(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},VL=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,c;const{view:d}=this.editor,f=t.target,h=f.nodeType===3?(e=f.parentElement)==null?void 0:e.closest("[data-drag-handle]"):f.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(f)||!h)return;let m=0,g=0;if(this.dom!==h){const N=this.dom.getBoundingClientRect(),j=h.getBoundingClientRect(),M=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,_=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;m=j.x-N.x+M,g=j.y-N.y+_}const v=this.dom.cloneNode(!0);try{const N=this.dom.getBoundingClientRect();v.style.width=`${Math.round(N.width)}px`,v.style.height=`${Math.round(N.height)}px`,v.style.boxSizing="border-box",v.style.pointerEvents="none"}catch{}let x=null;try{x=document.createElement("div"),x.style.position="absolute",x.style.top="-9999px",x.style.left="-9999px",x.style.pointerEvents="none",x.appendChild(v),document.body.appendChild(x),(c=t.dataTransfer)==null||c.setDragImage(v,m,g)}finally{x&&setTimeout(()=>{try{x==null||x.remove()}catch{}},0)}const k=this.getPos();if(typeof k!="number")return;const w=ot.create(d.state.doc,k),S=d.state.tr.setSelection(w);d.dispatch(S)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!s)return!0;const{isEditable:c}=this.editor,{isDragging:d}=this,f=!!this.node.type.spec.draggable,h=ot.isSelectable(this.node),m=t.type==="copy",g=t.type==="paste",v=t.type==="cut",x=t.type==="mousedown";if(!f&&h&&s&&t.target===this.dom&&t.preventDefault(),f&&s&&!d&&t.target===this.dom)return t.preventDefault(),!1;if(f&&c&&!d&&x){const k=n.closest("[data-drag-handle]");k&&(this.dom===k||this.dom.contains(k))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(d||i||m||g||v||x&&h)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Ml()||Mg())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Li(t){return new NL({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=Vt(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,c=r[r.length-1],d=r[0];let f=n.to;if(c){const h=d.search(/\S/),m=n.from+d.indexOf(c),g=m+c.length;if(Rv(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(w=>w===t.type&&w!==x.mark.type)).filter(x=>x.to>m).length)return null;g<n.to&&o.delete(g,n.to),m>n.from&&o.delete(n.from+h,m),f=n.from+h+c.length,o.addMark(n.from+h,f,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:qL,getOwnPropertySymbols:KL}=Object,{hasOwnProperty:GL}=Object.prototype;function pp(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function ou(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),c=i.get(r);if(o&&c)return o===r&&c===n;i.set(n,r),i.set(r,n);const d=t(n,r,s);return i.delete(n),i.delete(r),d}}function JL(t){return t!=null?t[Symbol.toStringTag]:void 0}function dw(t){return qL(t).concat(KL(t))}const YL=Object.hasOwn||((t,e)=>GL.call(t,e));function Eo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const XL="__v",QL="__o",ZL="_owner",{getOwnPropertyDescriptor:fw,keys:hw}=Object;function eD(t,e){return t.byteLength===e.byteLength&&td(new Uint8Array(t),new Uint8Array(e))}function tD(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function nD(t,e){return t.byteLength===e.byteLength&&td(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function rD(t,e){return Eo(t.getTime(),e.getTime())}function sD(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function iD(t,e){return t===e}function pw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,c,d=0;for(;(o=i.next())&&!o.done;){const f=e.entries();let h=!1,m=0;for(;(c=f.next())&&!c.done;){if(s[m]){m++;continue}const g=o.value,v=c.value;if(n.equals(g[0],v[0],d,m,t,e,n)&&n.equals(g[1],v[1],g[0],v[0],t,e,n)){h=s[m]=!0;break}m++}if(!h)return!1;d++}return!0}const oD=Eo;function aD(t,e,n){const r=hw(t);let s=r.length;if(hw(e).length!==s)return!1;for(;s-- >0;)if(!t_(t,e,n,r[s]))return!1;return!0}function Qa(t,e,n){const r=dw(t);let s=r.length;if(dw(e).length!==s)return!1;let i,o,c;for(;s-- >0;)if(i=r[s],!t_(t,e,n,i)||(o=fw(t,i),c=fw(e,i),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function lD(t,e){return Eo(t.valueOf(),e.valueOf())}function cD(t,e){return t.source===e.source&&t.flags===e.flags}function mw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,c;for(;(o=i.next())&&!o.done;){const d=e.values();let f=!1,h=0;for(;(c=d.next())&&!c.done;){if(!s[h]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){f=s[h]=!0;break}h++}if(!f)return!1}return!0}function td(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function uD(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function t_(t,e,n,r){return(r===ZL||r===QL||r===XL)&&(t.$$typeof||e.$$typeof)?!0:YL(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const dD="[object ArrayBuffer]",fD="[object Arguments]",hD="[object Boolean]",pD="[object DataView]",mD="[object Date]",gD="[object Error]",vD="[object Map]",bD="[object Number]",yD="[object Object]",xD="[object RegExp]",wD="[object Set]",kD="[object String]",SD={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},ED="[object URL]",ND=Object.prototype.toString;function CD({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:d,arePrimitiveWrappersEqual:f,areRegExpsEqual:h,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:v,unknownTagComparators:x}){return function(w,S,N){if(w===S)return!0;if(w==null||S==null)return!1;const j=typeof w;if(j!==typeof S)return!1;if(j!=="object")return j==="number"?c(w,S,N):j==="function"?i(w,S,N):!1;const M=w.constructor;if(M!==S.constructor)return!1;if(M===Object)return d(w,S,N);if(Array.isArray(w))return e(w,S,N);if(M===Date)return r(w,S,N);if(M===RegExp)return h(w,S,N);if(M===Map)return o(w,S,N);if(M===Set)return m(w,S,N);const _=ND.call(w);if(_===mD)return r(w,S,N);if(_===xD)return h(w,S,N);if(_===vD)return o(w,S,N);if(_===wD)return m(w,S,N);if(_===yD)return typeof w.then!="function"&&typeof S.then!="function"&&d(w,S,N);if(_===ED)return v(w,S,N);if(_===gD)return s(w,S,N);if(_===fD)return d(w,S,N);if(SD[_])return g(w,S,N);if(_===dD)return t(w,S,N);if(_===pD)return n(w,S,N);if(_===hD||_===bD||_===kD)return f(w,S,N);if(x){let R=x[_];if(!R){const L=JL(w);L&&(R=x[L])}if(R)return R(w,S,N)}return!1}}function _D({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:eD,areArraysEqual:n?Qa:tD,areDataViewsEqual:nD,areDatesEqual:rD,areErrorsEqual:sD,areFunctionsEqual:iD,areMapsEqual:n?pp(pw,Qa):pw,areNumbersEqual:oD,areObjectsEqual:n?Qa:aD,arePrimitiveWrappersEqual:lD,areRegExpsEqual:cD,areSetsEqual:n?pp(mw,Qa):mw,areTypedArraysEqual:n?pp(td,Qa):td,areUrlsEqual:uD,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=ou(r.areArraysEqual),i=ou(r.areMapsEqual),o=ou(r.areObjectsEqual),c=ou(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:c})}return r}function TD(t){return function(e,n,r,s,i,o,c){return t(e,n,c)}}function jD({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(c,d){const{cache:f=t?new WeakMap:void 0,meta:h}=n();return e(c,d,{cache:f,equals:r,meta:h,strict:s})};if(t)return function(c,d){return e(c,d,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(c,d){return e(c,d,i)}}const MD=$i();$i({strict:!0});$i({circular:!0});$i({circular:!0,strict:!0});$i({createInternalComparator:()=>Eo});$i({strict:!0,createInternalComparator:()=>Eo});$i({circular:!0,createInternalComparator:()=>Eo});$i({circular:!0,createInternalComparator:()=>Eo,strict:!0});function $i(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=_D(t),o=CD(i),c=n?n(o):TD(o);return jD({circular:e,comparator:o,createState:r,equals:c,strict:s})}var mp={exports:{}},gp={};/**
148
+ * @license React
149
+ * use-sync-external-store-shim/with-selector.production.js
150
+ *
151
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
152
+ *
153
+ * This source code is licensed under the MIT license found in the
154
+ * LICENSE file in the root directory of this source tree.
155
+ */var gw;function AD(){if(gw)return gp;gw=1;var t=Pl(),e=qE();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,c=t.useMemo,d=t.useDebugValue;return gp.useSyncExternalStoreWithSelector=function(f,h,m,g,v){var x=i(null);if(x.current===null){var k={hasValue:!1,value:null};x.current=k}else k=x.current;x=c(function(){function S(R){if(!N){if(N=!0,j=R,R=g(R),v!==void 0&&k.hasValue){var L=k.value;if(v(L,R))return M=L}return M=R}if(L=M,r(j,R))return L;var $=g(R);return v!==void 0&&v(L,$)?(j=R,L):(j=R,M=$)}var N=!1,j,M,_=m===void 0?null:m;return[function(){return S(h())},_===null?void 0:function(){return S(_())}]},[h,m,g,v]);var w=s(f,x[0],x[1]);return o(function(){k.hasValue=!0,k.value=w},[w]),d(w),w},gp}var vw;function RD(){return vw||(vw=1,mp.exports=AD()),mp.exports}var OD=RD(),ID=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},LD=({contentComponent:t})=>{const e=KE.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return l.jsx(l.Fragment,{children:Object.values(e)})};function DD(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:FM.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var PD=class extends Ri.Component{constructor(t){var e;super(t),this.editorContentRef=Ri.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=DD(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:ID(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&l.jsx(LD,{contentComponent:t.contentComponent})]})}},BD=y.forwardRef((t,e)=>{const n=Ri.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ri.createElement(PD,{key:n,innerRef:e,...t})}),Pv=Ri.memo(BD),$D=typeof window<"u"?y.useLayoutEffect:y.useEffect,FD=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function zD(t){var e;const[n]=y.useState(()=>new FD(t.editor)),r=OD.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:MD);return $D(()=>n.watch(t.editor),[t.editor,n]),y.useDebugValue(r),r}var UD=!1,Lg=typeof window>"u",HD=Lg||!!(typeof window<"u"&&window.next),WD=class n_{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?Lg||HD?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new IL(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?n_.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function r_(t={},e=[]){const n=y.useRef(t);n.current=t;const[r]=y.useState(()=>new WD(n)),s=KE.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return y.useDebugValue(s),y.useEffect(r.onRender(e)),zD({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var s_=y.createContext({editor:null});s_.Consumer;var i_=y.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),VD=()=>y.useContext(i_),qD=Ri.forwardRef((t,e)=>{const{onDragStart:n}=VD(),r=t.as||"div";return l.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function bw(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function yw(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function KD(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function GD(t){if(bw(t)||yw(t))return!0;if(KD(t)){const e=t.type;if(e)return bw(e)||yw(e)}return!1}function JD(){try{if(y.version)return parseInt(y.version.split(".")[0],10)>=19}catch{}return!1}var YD=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?VE.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,s=JD(),i=GD(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=c=>{this.ref=c}),this.reactElement=l.jsx(e,{...o}),(t=r==null?void 0:r.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.destroyed||(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};Ri.createContext({markViewContentRef:()=>{}});var XD=class extends VL{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,s){var i;return r==="storage"?(i=t.storage[e.name])!=null?i:{}:Reflect.get(n,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(d={})=>this.updateAttributes(d),deleteNode:()=>this.deleteNode(),ref:y.createRef()};if(!this.component.displayName){const d=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=d(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:d=>{d&&this.contentDOMElement&&d.firstChild!==this.contentDOMElement&&(d.hasAttribute("data-node-view-wrapper")&&d.removeAttribute("data-node-view-wrapper"),d.appendChild(this.contentDOMElement))}},s=this.component,i=y.memo(d=>l.jsx(i_.Provider,{value:r,children:y.createElement(s,d)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:c=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new YD(i,{editor:this.editor,props:t,as:o,className:`node-${this.node.type.name} ${c}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,i=this.decorations,o=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:i,newNode:t,newDecorations:e,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=ga(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function QD(t,e){return n=>n.editor.contentComponent?new XD(t,n,e):{}}var Bv=y.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Bv.displayName="TiptapContext";var ZD=()=>y.useContext(Bv);function o_({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=y.useMemo(()=>({editor:r}),[r]),i=y.useMemo(()=>({editor:r}),[r]);return l.jsx(s_.Provider,{value:i,children:l.jsx(Bv.Provider,{value:s,children:n})})}o_.displayName="Tiptap";function a_({...t}){const{editor:e}=ZD();return l.jsx(Pv,{editor:e,...t})}a_.displayName="Tiptap.Content";Object.assign(o_,{Content:a_});var eP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,tP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,nP=ds.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",Bt(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[xo({find:eP,type:this.type})]},addPasteRules(){return[Li({find:tP,type:this.type})]}}),rP=nP,sP=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,iP=xn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Bt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",d=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",f=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return f?`![${d}](${c} "${f}")`:`![${d}](${c})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o,editor:c})=>{const d=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:d.setAttribute(m,g);break}}),d.src=o.src;const f=new DL({element:d,editor:c,node:s,getPos:i,onResize:(m,g)=>{d.style.width=`${m}px`,d.style.height=`${g}px`},onCommit:(m,g)=>{const v=i();v!==void 0&&this.editor.chain().setNodeSelection(v).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,v)=>m.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),h=f.dom;return h.style.visibility="hidden",h.style.pointerEvents="none",d.onload=()=>{h.style.visibility="",h.style.pointerEvents=""},f}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ZC({find:sP,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),$v=iP;const oP="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",aP="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Dg="numeric",Pg="ascii",Bg="alpha",vl="asciinumeric",cl="alphanumeric",$g="domain",l_="emoji",lP="scheme",cP="slashscheme",vp="whitespace";function uP(t,e){return t in e||(e[t]=[]),e[t]}function lo(t,e,n){e[Dg]&&(e[vl]=!0,e[cl]=!0),e[Pg]&&(e[vl]=!0,e[Bg]=!0),e[vl]&&(e[cl]=!0),e[Bg]&&(e[cl]=!0),e[cl]&&(e[$g]=!0),e[l_]&&(e[$g]=!0);for(const r in e){const s=uP(r,n);s.indexOf(t)<0&&s.push(t)}}function dP(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Er(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Er.groups={};Er.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Er.groups;let s;return e&&e.j?s=e:(s=new Er(e),n&&r&&lo(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Er.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,c=s.go(t);if(c?(o=new Er,Object.assign(o.j,c.j),o.jr.push.apply(o.jr,c.jr),o.jd=c.jd,o.t=c.t):o=new Er,i){if(r)if(o.t&&typeof o.t=="string"){const d=Object.assign(dP(o.t,r),n);lo(i,d,r)}else n&&lo(i,n,r);o.t=i}return s.j[t]=o,o}};const Tt=(t,e,n,r,s)=>t.ta(e,n,r,s),gn=(t,e,n,r,s)=>t.tr(e,n,r,s),xw=(t,e,n,r,s)=>t.ts(e,n,r,s),Me=(t,e,n,r,s)=>t.tt(e,n,r,s),zs="WORD",Fg="UWORD",c_="ASCIINUMERICAL",u_="ALPHANUMERICAL",Rl="LOCALHOST",zg="TLD",Ug="UTLD",Lu="SCHEME",na="SLASH_SCHEME",Fv="NUM",Hg="WS",zv="NL",bl="OPENBRACE",yl="CLOSEBRACE",nd="OPENBRACKET",rd="CLOSEBRACKET",sd="OPENPAREN",id="CLOSEPAREN",od="OPENANGLEBRACKET",ad="CLOSEANGLEBRACKET",ld="FULLWIDTHLEFTPAREN",cd="FULLWIDTHRIGHTPAREN",ud="LEFTCORNERBRACKET",dd="RIGHTCORNERBRACKET",fd="LEFTWHITECORNERBRACKET",hd="RIGHTWHITECORNERBRACKET",pd="FULLWIDTHLESSTHAN",md="FULLWIDTHGREATERTHAN",gd="AMPERSAND",vd="APOSTROPHE",bd="ASTERISK",yi="AT",yd="BACKSLASH",xd="BACKTICK",wd="CARET",ki="COLON",Uv="COMMA",kd="DOLLAR",ks="DOT",Sd="EQUALS",Hv="EXCLAMATION",Vr="HYPHEN",xl="PERCENT",Ed="PIPE",Nd="PLUS",Cd="POUND",wl="QUERY",Wv="QUOTE",d_="FULLWIDTHMIDDLEDOT",Vv="SEMI",Ss="SLASH",kl="TILDE",_d="UNDERSCORE",f_="EMOJI",Td="SYM";var h_=Object.freeze({__proto__:null,ALPHANUMERICAL:u_,AMPERSAND:gd,APOSTROPHE:vd,ASCIINUMERICAL:c_,ASTERISK:bd,AT:yi,BACKSLASH:yd,BACKTICK:xd,CARET:wd,CLOSEANGLEBRACKET:ad,CLOSEBRACE:yl,CLOSEBRACKET:rd,CLOSEPAREN:id,COLON:ki,COMMA:Uv,DOLLAR:kd,DOT:ks,EMOJI:f_,EQUALS:Sd,EXCLAMATION:Hv,FULLWIDTHGREATERTHAN:md,FULLWIDTHLEFTPAREN:ld,FULLWIDTHLESSTHAN:pd,FULLWIDTHMIDDLEDOT:d_,FULLWIDTHRIGHTPAREN:cd,HYPHEN:Vr,LEFTCORNERBRACKET:ud,LEFTWHITECORNERBRACKET:fd,LOCALHOST:Rl,NL:zv,NUM:Fv,OPENANGLEBRACKET:od,OPENBRACE:bl,OPENBRACKET:nd,OPENPAREN:sd,PERCENT:xl,PIPE:Ed,PLUS:Nd,POUND:Cd,QUERY:wl,QUOTE:Wv,RIGHTCORNERBRACKET:dd,RIGHTWHITECORNERBRACKET:hd,SCHEME:Lu,SEMI:Vv,SLASH:Ss,SLASH_SCHEME:na,SYM:Td,TILDE:kl,TLD:zg,UNDERSCORE:_d,UTLD:Ug,UWORD:Fg,WORD:zs,WS:Hg});const $s=/[a-z]/,Za=new RegExp("\\p{L}","u"),bp=new RegExp("\\p{Emoji}","u"),Fs=/\d/,yp=/\s/,ww="\r",xp=`
156
+ `,fP="️",hP="‍",wp="";let au=null,lu=null;function pP(t=[]){const e={};Er.groups=e;const n=new Er;au==null&&(au=kw(oP)),lu==null&&(lu=kw(aP)),Me(n,"'",vd),Me(n,"{",bl),Me(n,"}",yl),Me(n,"[",nd),Me(n,"]",rd),Me(n,"(",sd),Me(n,")",id),Me(n,"<",od),Me(n,">",ad),Me(n,"(",ld),Me(n,")",cd),Me(n,"「",ud),Me(n,"」",dd),Me(n,"『",fd),Me(n,"』",hd),Me(n,"<",pd),Me(n,">",md),Me(n,"&",gd),Me(n,"*",bd),Me(n,"@",yi),Me(n,"`",xd),Me(n,"^",wd),Me(n,":",ki),Me(n,",",Uv),Me(n,"$",kd),Me(n,".",ks),Me(n,"=",Sd),Me(n,"!",Hv),Me(n,"-",Vr),Me(n,"%",xl),Me(n,"|",Ed),Me(n,"+",Nd),Me(n,"#",Cd),Me(n,"?",wl),Me(n,'"',Wv),Me(n,"/",Ss),Me(n,";",Vv),Me(n,"~",kl),Me(n,"_",_d),Me(n,"\\",yd),Me(n,"・",d_);const r=gn(n,Fs,Fv,{[Dg]:!0});gn(r,Fs,r);const s=gn(r,$s,c_,{[vl]:!0}),i=gn(r,Za,u_,{[cl]:!0}),o=gn(n,$s,zs,{[Pg]:!0});gn(o,Fs,s),gn(o,$s,o),gn(s,Fs,s),gn(s,$s,s);const c=gn(n,Za,Fg,{[Bg]:!0});gn(c,$s),gn(c,Fs,i),gn(c,Za,c),gn(i,Fs,i),gn(i,$s),gn(i,Za,i);const d=Me(n,xp,zv,{[vp]:!0}),f=Me(n,ww,Hg,{[vp]:!0}),h=gn(n,yp,Hg,{[vp]:!0});Me(n,wp,h),Me(f,xp,d),Me(f,wp,h),gn(f,yp,h),Me(h,ww),Me(h,xp),gn(h,yp,h),Me(h,wp,h);const m=gn(n,bp,f_,{[l_]:!0});Me(m,"#"),gn(m,bp,m),Me(m,fP,m);const g=Me(m,hP);Me(g,"#"),gn(g,bp,m);const v=[[$s,o],[Fs,s]],x=[[$s,null],[Za,c],[Fs,i]];for(let k=0;k<au.length;k++)mi(n,au[k],zg,zs,v);for(let k=0;k<lu.length;k++)mi(n,lu[k],Ug,Fg,x);lo(zg,{tld:!0,ascii:!0},e),lo(Ug,{utld:!0,alpha:!0},e),mi(n,"file",Lu,zs,v),mi(n,"mailto",Lu,zs,v),mi(n,"http",na,zs,v),mi(n,"https",na,zs,v),mi(n,"ftp",na,zs,v),mi(n,"ftps",na,zs,v),lo(Lu,{scheme:!0,ascii:!0},e),lo(na,{slashscheme:!0,ascii:!0},e),t=t.sort((k,w)=>k[0]>w[0]?1:-1);for(let k=0;k<t.length;k++){const w=t[k][0],N=t[k][1]?{[lP]:!0}:{[cP]:!0};w.indexOf("-")>=0?N[$g]=!0:$s.test(w)?Fs.test(w)?N[vl]=!0:N[Pg]=!0:N[Dg]=!0,xw(n,w,w,N)}return xw(n,"localhost",Rl,{ascii:!0}),n.jd=new Er(Td),{start:n,tokens:Object.assign({groups:e},h_)}}function p_(t,e){const n=mP(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let c=t,d=null,f=0,h=null,m=-1,g=-1;for(;o<r&&(d=c.go(n[o]));)c=d,c.accepts()?(m=0,g=0,h=c):m>=0&&(m+=n[o].length,g++),f+=n[o].length,i+=n[o].length,o++;i-=m,o-=g,f-=m,s.push({t:h.t,v:e.slice(i-f,i),s:i-f,e:i})}return s}function mP(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function mi(t,e,n,r,s){let i;const o=e.length;for(let c=0;c<o-1;c++){const d=e[c];t.j[d]?i=t.j[d]:(i=new Er(r),i.jr=s.slice(),t.j[d]=i),t=i}return i=new Er(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function kw(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Ol={defaultProtocol:"http",events:null,format:Sw,formatHref:Sw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function qv(t,e=null){let n=Object.assign({},Ol);t&&(n=Object.assign(n,t instanceof qv?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}qv.prototype={o:Ol,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Ol[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Sw(t){return t}function m_(t,e){this.t="token",this.v=t,this.tk=e}m_.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Ol.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},c=t.get("className",n,e),d=t.get("target",n,e),f=t.get("rel",n,e),h=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=r,c&&(o.class=c),d&&(o.target=d),f&&(o.rel=f),h&&Object.assign(o,h),{tagName:s,attributes:o,content:i,eventListeners:m}}};function Zd(t,e){class n extends m_{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Ew=Zd("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Nw=Zd("text"),gP=Zd("nl"),cu=Zd("url",{isLink:!0,toHref(t=Ol.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Rl&&t[1].t===ki}}),Hr=t=>new Er(t);function vP({groups:t}){const e=t.domain.concat([gd,bd,yi,yd,xd,wd,kd,Sd,Vr,Fv,xl,Ed,Nd,Cd,Ss,Td,kl,_d]),n=[vd,ki,Uv,ks,Hv,xl,wl,Wv,Vv,od,ad,bl,yl,rd,nd,sd,id,ld,cd,ud,dd,fd,hd,pd,md],r=[gd,vd,bd,yd,xd,wd,kd,Sd,Vr,bl,yl,xl,Ed,Nd,Cd,wl,Ss,Td,kl,_d],s=Hr(),i=Me(s,kl);Tt(i,r,i),Tt(i,t.domain,i);const o=Hr(),c=Hr(),d=Hr();Tt(s,t.domain,o),Tt(s,t.scheme,c),Tt(s,t.slashscheme,d),Tt(o,r,i),Tt(o,t.domain,o);const f=Me(o,yi);Me(i,yi,f),Me(c,yi,f),Me(d,yi,f);const h=Me(i,ks);Tt(h,r,i),Tt(h,t.domain,i);const m=Hr();Tt(f,t.domain,m),Tt(m,t.domain,m);const g=Me(m,ks);Tt(g,t.domain,m);const v=Hr(Ew);Tt(g,t.tld,v),Tt(g,t.utld,v),Me(f,Rl,v);const x=Me(m,Vr);Me(x,Vr,x),Tt(x,t.domain,m),Tt(v,t.domain,m),Me(v,ks,g),Me(v,Vr,x);const k=Me(v,ki);Tt(k,t.numeric,Ew);const w=Me(o,Vr),S=Me(o,ks);Me(w,Vr,w),Tt(w,t.domain,o),Tt(S,r,i),Tt(S,t.domain,o);const N=Hr(cu);Tt(S,t.tld,N),Tt(S,t.utld,N),Tt(N,t.domain,o),Tt(N,r,i),Me(N,ks,S),Me(N,Vr,w),Me(N,yi,f);const j=Me(N,ki),M=Hr(cu);Tt(j,t.numeric,M);const _=Hr(cu),R=Hr();Tt(_,e,_),Tt(_,n,R),Tt(R,e,_),Tt(R,n,R),Me(N,Ss,_),Me(M,Ss,_);const L=Me(c,ki),$=Me(d,ki),B=Me($,Ss),F=Me(B,Ss);Tt(c,t.domain,o),Me(c,ks,S),Me(c,Vr,w),Tt(d,t.domain,o),Me(d,ks,S),Me(d,Vr,w),Tt(L,t.domain,_),Me(L,Ss,_),Me(L,wl,_),Tt(F,t.domain,_),Tt(F,e,_),Me(F,Ss,_);const K=[[bl,yl],[nd,rd],[sd,id],[od,ad],[ld,cd],[ud,dd],[fd,hd],[pd,md]];for(let z=0;z<K.length;z++){const[ee,P]=K[z],U=Me(_,ee);Me(R,ee,U),Me(U,P,_);const J=Hr(cu);Tt(U,e,J);const ie=Hr();Tt(U,n),Tt(J,e,J),Tt(J,n,ie),Tt(ie,e,J),Tt(ie,n,ie),Me(J,P,_),Me(ie,P,_)}return Me(s,Rl,N),Me(s,zv,gP),{start:s,tokens:h_}}function bP(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let c=t,d=null,f=null,h=0,m=null,g=-1;for(;s<r&&!(d=c.go(n[s].t));)o.push(n[s++]);for(;s<r&&(f=d||c.go(n[s].t));)d=null,c=f,c.accepts()?(g=0,m=c):g>=0&&g++,s++,h++;if(g<0)s-=h,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(kp(Nw,e,o)),o=[]),s-=g,h-=g;const v=m.t,x=n.slice(s-h,s);i.push(kp(v,e,x))}}return o.length>0&&i.push(kp(Nw,e,o)),i}function kp(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const yP=typeof console<"u"&&console&&console.warn||(()=>{}),xP="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",on={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function wP(){return Er.groups={},on.scanner=null,on.parser=null,on.tokenQueue=[],on.pluginQueue=[],on.customSchemes=[],on.initialized=!1,on}function Cw(t,e=!1){if(on.initialized&&yP(`linkifyjs: already initialized - will not register custom scheme "${t}" ${xP}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
157
+ 1. Must only contain digits, lowercase ASCII letters or "-"
158
+ 2. Cannot start or end with "-"
159
+ 3. "-" cannot repeat`);on.customSchemes.push([t,e])}function kP(){on.scanner=pP(on.customSchemes);for(let t=0;t<on.tokenQueue.length;t++)on.tokenQueue[t][1]({scanner:on.scanner});on.parser=vP(on.scanner.tokens);for(let t=0;t<on.pluginQueue.length;t++)on.pluginQueue[t][1]({scanner:on.scanner,parser:on.parser});return on.initialized=!0,on}function Kv(t){return on.initialized||kP(),bP(on.parser.start,t,p_(on.scanner.start,t))}Kv.scan=p_;function g_(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new qv(n),s=Kv(t),i=[];for(let o=0;o<s.length;o++){const c=s[o];c.isLink&&(!e||c.t===e)&&r.check(c)&&i.push(c.toFormattedObject(r))}return i}var Gv="[\0-   ᠎ -\u2029  ]",SP=new RegExp(Gv),EP=new RegExp(`${Gv}$`),NP=new RegExp(Gv,"g");function CP(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function _P(t){return new $t({key:new qt("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),i=e.some(f=>f.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,c=Tv(n.doc,[...e]);if(Av(c).forEach(({newRange:f})=>{const h=TC(r.doc,f,v=>v.isTextblock);let m,g;if(h.length>1)m=h[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(h.length){const v=r.doc.textBetween(f.from,f.to," "," ");if(!EP.test(v))return;m=h[0],g=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&g){const v=g.split(SP).filter(Boolean);if(v.length<=0)return!1;const x=v[v.length-1],k=m.pos+g.lastIndexOf(x);if(!x)return!1;const w=Kv(x).map(S=>S.toObject(t.defaultProtocol));if(!CP(w))return!1;w.filter(S=>S.isLink).map(S=>({...S,from:k+S.start+1,to:k+S.end+1})).filter(S=>r.schema.marks.code?!r.doc.rangeHasMark(S.from,S.to,r.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{Rv(S.from,S.to,r.doc).some(N=>N.mark.type===t.type)||o.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!o.steps.length)return o}})}function TP(t){return new $t({key:new qt("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const d=r.target;if(!d)return!1;const f=t.editor.view.dom;o=d.closest("a"),o&&!f.contains(o)&&(o=null)}if(!o)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const d=LC(e.state,t.type.name),f=(s=o.href)!=null?s:d.href,h=(i=o.target)!=null?i:d.target;f&&(window.open(f,h),c=!0)}return c}}})}function jP(t){return new $t({key:new qt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:c}=o;if(c)return!1;let d="";r.content.forEach(h=>{d+=h.textContent});const f=g_(d,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===d);return!d||!f||s!==void 0&&!s(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function no(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(NP,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var v_=ds.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Cw(t);return}Cw(t.scheme,t.optionalSlashes)})},onDestroy(){wP()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!no(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!no(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!no(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Bt(this.options.HTMLAttributes,t),0]:["a",Bt(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",d=e.renderChildren(t);return c?`[${d}](${o} "${c}")`:`[${d}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!no(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!no(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Li({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=g_(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!no(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(_P({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!no(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(TP({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(jP({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),MP=v_;function AP(t={}){return new $t({view(e){return new RP(e,t)}})}class RP{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,c=i.height/s.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let v=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(v){let x=v.getBoundingClientRect(),k=m?x.bottom:x.top;m&&g&&(k=(k+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*c;r={left:x.left,right:x.right,top:k-w,bottom:k+w}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let f,h;if(!d||d==document.body&&getComputedStyle(d).position=="static")f=-pageXOffset,h=-pageYOffset;else{let m=d.getBoundingClientRect(),g=m.width/d.offsetWidth,v=m.height/d.offsetHeight;f=m.left-d.scrollLeft*g,h=m.top-d.scrollTop*v}this.element.style.left=(r.left-f)/o+"px",this.element.style.top=(r.top-h)/c+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/c+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=xN(this.editorView.state.doc,o,this.editorView.dragging.slice);c!=null&&(o=c)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class vn extends gt{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return vn.valid(r)?new vn(r):gt.near(r)}content(){return Be.empty}eq(e){return e instanceof vn&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new vn(e.resolve(n.pos))}getBookmark(){return new Jv(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!OP(e)||!IP(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&vn.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let c=e.node(o);if(n>0?e.indexAfter(o)<c.childCount:e.index(o)>0){i=c.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let d=e.doc.resolve(s);if(vn.valid(d))return d}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!ot.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let c=e.doc.resolve(s);if(vn.valid(c))return c}return null}}}vn.prototype.visible=!1;vn.findFrom=vn.findGapCursorFrom;gt.jsonID("gapcursor",vn);class Jv{constructor(e){this.pos=e}map(e){return new Jv(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return vn.valid(n)?new vn(n):gt.near(n)}}function b_(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function OP(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||b_(s.type))return!0;if(s.inlineContent)return!1}}return!0}function IP(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||b_(s.type))return!0;if(s.inlineContent)return!1}}return!0}function LP(){return new $t({props:{decorations:$P,createSelectionBetween(t,e,n){return e.pos==n.pos&&vn.valid(n)?new vn(n):null},handleClick:PP,handleKeyDown:DP,handleDOMEvents:{beforeinput:BP}}})}const DP=Ev({ArrowLeft:uu("horiz",-1),ArrowRight:uu("horiz",1),ArrowUp:uu("vert",-1),ArrowDown:uu("vert",1)});function uu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,c=e>0?o.$to:o.$from,d=o.empty;if(o instanceof lt){if(!i.endOfTextblock(n)||c.depth==0)return!1;d=!1,c=r.doc.resolve(e>0?c.after():c.before())}let f=vn.findGapCursorFrom(c,e,d);return f?(s&&s(r.tr.setSelection(new vn(f))),!0):!1}}function PP(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!vn.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&ot.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new vn(r))),!0)}function BP(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof vn))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=ke.empty;for(let o=r.length-1;o>=0;o--)s=ke.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new Be(s,0,0));return i.setSelection(lt.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function $P(t){if(!(t.selection instanceof vn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Ot.create(t.doc,[Ut.widget(t.selection.head,e,{key:"gapcursor"})])}var jd=200,Hn=function(){};Hn.prototype.append=function(e){return e.length?(e=Hn.from(e),!this.length&&e||e.length<jd&&this.leafAppend(e)||this.length<jd&&e.leafPrepend(this)||this.appendInner(e)):this};Hn.prototype.prepend=function(e){return e.length?Hn.from(e).append(this):this};Hn.prototype.appendInner=function(e){return new FP(this,e)};Hn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Hn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Hn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Hn.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Hn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};Hn.from=function(e){return e instanceof Hn?e:e&&e.length?new y_(e):Hn.empty};var y_=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,c){for(var d=i;d<o;d++)if(s(this.values[d],c+d)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,c){for(var d=i-1;d>=o;d--)if(s(this.values[d],c+d)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=jd)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=jd)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Hn);Hn.empty=new y_([]);var FP=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var c=this.left.length;if(s<c&&this.left.forEachInner(r,s,Math.min(i,c),o)===!1||i>c&&this.right.forEachInner(r,Math.max(s-c,0),Math.min(this.length,i)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var c=this.left.length;if(s>c&&this.right.forEachInvertedInner(r,s-c,Math.max(i,c)-c,o+c)===!1||i<c&&this.left.forEachInvertedInner(r,Math.min(s,c),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Hn);const zP=500;class ls{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,c,d,f=[],h=[];return this.items.forEach((m,g)=>{if(!m.step){s||(s=this.remapping(r,g+1),i=s.maps.length),i--,h.push(m);return}if(s){h.push(new Es(m.map));let v=m.step.map(s.slice(i)),x;v&&o.maybeStep(v).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],f.push(new Es(x,void 0,void 0,f.length+h.length))),i--,x&&s.appendMap(x,i)}else o.maybeStep(m.step);if(m.selection)return c=s?m.selection.map(s.slice(i)):m.selection,d=new ls(this.items.slice(0,r).append(h.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:o,selection:c}}addTransform(e,n,r,s){let i=[],o=this.eventCount,c=this.items,d=!s&&c.length?c.get(c.length-1):null;for(let h=0;h<e.steps.length;h++){let m=e.steps[h].invert(e.docs[h]),g=new Es(e.mapping.maps[h],m,n),v;(v=d&&d.merge(g))&&(g=v,h?i.pop():c=c.slice(0,c.length-1)),i.push(g),n&&(o++,n=void 0),s||(d=g)}let f=o-r.depth;return f>HP&&(c=UP(c,f),o-=f),new ls(c.append(i),o)}remapping(e,n){let r=new Nl;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new ls(this.items.append(e.map(n=>new Es(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},s);let d=n;this.items.forEach(g=>{let v=i.getMirror(--d);if(v==null)return;o=Math.min(o,v);let x=i.maps[v];if(g.step){let k=e.steps[v].invert(e.docs[v]),w=g.selection&&g.selection.map(i.slice(d+1,v));w&&c++,r.push(new Es(x,k,w))}else r.push(new Es(x))},s);let f=[];for(let g=n;g<o;g++)f.push(new Es(i.maps[g]));let h=this.items.slice(0,s).append(f).append(r),m=new ls(h,c);return m.emptyItemCount()>zP&&(m=m.compress(this.items.length-r.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,c)=>{if(c>=e)s.push(o),o.selection&&i++;else if(o.step){let d=o.step.map(n.slice(r)),f=d&&d.getMap();if(r--,f&&n.appendMap(f,r),d){let h=o.selection&&o.selection.map(n.slice(r));h&&i++;let m=new Es(f.invert(),d,h),g,v=s.length-1;(g=s.length&&s[v].merge(m))?s[v]=g:s.push(m)}}else o.map&&r--},this.items.length,0),new ls(Hn.from(s.reverse()),i)}}ls.empty=new ls(Hn.empty,0);function UP(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Es{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Es(n.getMap().invert(),n,this.selection)}}}class xi{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const HP=20;function WP(t,e,n,r){let s=n.getMeta(mo),i;if(s)return s.historyState;n.getMeta(KP)&&(t=new xi(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(mo))return o.getMeta(mo).redo?new xi(t.done.addTransform(n,void 0,r,Du(e)),t.undone,_w(n.mapping.maps),t.prevTime,t.prevComposition):new xi(t.done,t.undone.addTransform(n,void 0,r,Du(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),d=t.prevTime==0||!o&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!VP(n,t.prevRanges)),f=o?Sp(t.prevRanges,n.mapping):_w(n.mapping.maps);return new xi(t.done.addTransform(n,d?e.selection.getBookmark():void 0,r,Du(e)),ls.empty,f,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new xi(t.done.rebased(n,i),t.undone.rebased(n,i),Sp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new xi(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Sp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function VP(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function _w(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Sp(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function qP(t,e,n){let r=Du(e),s=mo.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),c=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),d=new xi(n?c:i.remaining,n?i.remaining:c,null,0,-1);return i.transform.setSelection(o).setMeta(mo,{redo:n,historyState:d})}let Ep=!1,Tw=null;function Du(t){let e=t.plugins;if(Tw!=e){Ep=!1,Tw=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ep=!0;break}}return Ep}const mo=new qt("history"),KP=new qt("closeHistory");function GP(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new $t({key:mo,state:{init(){return new xi(ls.empty,ls.empty,null,0,-1)},apply(e,n,r){return WP(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?w_:r=="historyRedo"?k_:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function x_(t,e){return(n,r)=>{let s=mo.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=qP(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const w_=x_(!1,!0),k_=x_(!0,!0);Lt.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new $t({key:new qt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,c=0,d=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(c,d);return t=!0,f}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,d=i-r,f=c-d,h=c;return e.deleteRange(f,h),!(this.storage.characters({node:e.doc})>r)}})]}});var JP=Lt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[AP(this.options)]}});Lt.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new $t({key:new qt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return Ot.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((d,f)=>{if(d.isText)return;if(!(s>=f&&s<=f+d.nodeSize-1))return!1;o+=1});let c=0;return t.descendants((d,f)=>{if(d.isText||!(s>=f&&s<=f+d.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&o-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";i.push(Ut.node(f,f+d.nodeSize,{class:this.options.className}))}),Ot.create(t,i)}}})]}});var YP=Lt.create({name:"gapCursor",addProseMirrorPlugins(){return[LP()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Vt(it(t,"allowGapCursor",n)))!=null?e:null}}}),jw="placeholder";function XP(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var QP=Lt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:jw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${XP(this.options.dataAttribute)}`:`data-${jw}`;return[new $t({key:new qt("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,i=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((c,d)=>{const f=s>=d&&s<=d+c.nodeSize,h=!c.isLeaf&&Xd(c);if((f||!this.options.showOnlyCurrent)&&h){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=Ut.node(d,d+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:d,hasAnchor:f}):this.options.placeholder});i.push(g)}return this.options.includeChildren}),Ot.create(e,i)}}})]}});Lt.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new $t({key:new qt("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||DC(n.selection)||t.view.dragging?null:Ot.create(n.doc,[Ut.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Mw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var ZP=Lt.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new qt(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new $t({key:e,appendTransaction:(s,i,o)=>{const{doc:c,tr:d,schema:f}=o,h=e.getState(o),m=c.content.size,g=f.nodes[n];if(h)return d.insert(m,g.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Mw({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Mw({node:o,types:r})}}})]}}),e4=Lt.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>w_(t,e),redo:()=>({state:t,dispatch:e})=>k_(t,e)}},addProseMirrorPlugins(){return[GP(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),ef=QP,t4=ds.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",Bt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),n4=t4,r4=ds.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Bt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),s4=r4;let Wg,Vg;if(typeof WeakMap<"u"){let t=new WeakMap;Wg=e=>t.get(e),Vg=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Wg=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Vg=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var bn=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 i=r+1,o=s+1;for(let c=1;i<this.width&&this.map[e+c]==n;c++)i++;for(let c=1;o<this.height&&this.map[e+this.width*c]==n;c++)o++;return{left:r,top:s,right:i,bottom:o}}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:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:c,top:d,bottom:f}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,d),right:Math.max(r,c),bottom:Math.max(i,f)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const c=(t+1)*this.width;for(;o<c&&this.map[o]<s;)o++;return o==c?i-1:this.map[o]}s=i}}static get(t){return Wg(t)||Vg(t,i4(t))}};function i4(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=o4(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let f=0,h=e*n;f<h;f++)r[f]=0;for(let f=0,h=0;f<n;f++){const m=t.child(f);h++;for(let x=0;;x++){for(;s<r.length&&r[s]!=0;)s++;if(x==m.childCount)break;const k=m.child(x),{colspan:w,rowspan:S,colwidth:N}=k.attrs;for(let j=0;j<S;j++){if(j+f>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:h,n:S-j});break}const M=s+j*e;for(let _=0;_<w;_++){r[M+_]==0?r[M+_]=h:(i||(i=[])).push({type:"collision",row:f,pos:h,n:w-_});const R=N&&N[_];if(R){const L=(M+_)%e*2,$=o[L];$==null||$!=R&&o[L+1]==1?(o[L]=R,o[L+1]=1):$==R&&o[L+1]++}}}s+=w,h+=k.nodeSize}const g=(f+1)*e;let v=0;for(;s<g;)r[s++]==0&&v++;v&&(i||(i=[])).push({type:"missing",row:f,n:v}),h++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const c=new bn(e,n,r,i);let d=!1;for(let f=0;!d&&f<o.length;f+=2)o[f]!=null&&o[f+1]<n&&(d=!0);return d&&a4(c,o,t),c}function o4(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const c=t.child(o);for(let d=0;d<c.childCount;d++){const f=c.child(d);o+f.attrs.rowspan>r&&(i+=f.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const c=s.child(o);i+=c.attrs.colspan,c.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function a4(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let c=null;const d=o.attrs;for(let f=0;f<d.colspan;f++){const h=e[(s+f)%t.width*2];h!=null&&(!d.colwidth||d.colwidth[f]!=h)&&((c||(c=l4(d)))[f]=h)}c&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:c})}}function l4(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function lr(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}const Si=new qt("selectingCells");function wo(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 c4(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function fs(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 tf(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=wo(e.$head)||u4(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function u4(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 qg(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function d4(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Yv(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function S_(t,e,n){const r=t.node(-1),s=bn.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function ko(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}function E_(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function f4(t,e,n){const r=lr(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var tn=class Us extends gt{constructor(e,n=e){const r=e.node(-1),s=bn.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),c=e.node(0),d=s.cellsInRect(o).filter(h=>h!=n.pos-i);d.unshift(n.pos-i);const f=d.map(h=>{const m=r.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const g=i+h+1;return new NN(c.resolve(g),c.resolve(g+m.content.size))});super(f[0].$from,f[0].$to,f),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(qg(r)&&qg(s)&&Yv(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Us.rowSelection(r,s):i&&this.isColSelection()?Us.colSelection(r,s):new Us(r,s)}return lt.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=bn.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let d=s.top;d<s.bottom;d++){const f=[];for(let h=d*n.width+s.left,m=s.left;m<s.right;m++,h++){const g=n.map[h];if(i[g])continue;i[g]=!0;const v=n.findCell(g);let x=e.nodeAt(g);if(!x)throw new RangeError(`No cell with offset ${g} found`);const k=s.left-v.left,w=v.right-s.right;if(k>0||w>0){let S=x.attrs;if(k>0&&(S=ko(S,0,k)),w>0&&(S=ko(S,S.colspan-w,w)),v.left<s.left){if(x=x.type.createAndFill(S),!x)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(S)}`)}else x=x.type.create(S,x.content)}if(v.top<s.top||v.bottom>s.bottom){const S={...x.attrs,rowspan:Math.min(v.bottom,s.bottom)-Math.max(v.top,s.top)};v.top<s.top?x=x.type.createAndFill(S):x=x.type.create(S,x.content)}f.push(x)}o.push(e.child(d).copy(ke.from(f)))}const c=this.isColSelection()&&this.isRowSelection()?e:o;return new Be(ke.from(c),1,1)}replace(e,n=Be.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:c,$to:d}=s[o],f=e.mapping.slice(r);e.replace(f.map(c.pos),f.map(d.pos),o?Be.empty:n)}const i=gt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Be(ke.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=bn.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}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=bn.get(r),i=e.start(-1),o=s.findCell(e.pos-i),c=s.findCell(n.pos-i),d=e.node(0);return o.top<=c.top?(o.top>0&&(e=d.resolve(i+s.map[o.left])),c.bottom<s.height&&(n=d.resolve(i+s.map[s.width*(s.height-1)+c.right-1]))):(c.top>0&&(n=d.resolve(i+s.map[c.left])),o.bottom<s.height&&(e=d.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Us(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=bn.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,c=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,c)==n.width}eq(e){return e instanceof Us&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=bn.get(r),i=e.start(-1),o=s.findCell(e.pos-i),c=s.findCell(n.pos-i),d=e.node(0);return o.left<=c.left?(o.left>0&&(e=d.resolve(i+s.map[o.top*s.width])),c.right<s.width&&(n=d.resolve(i+s.map[s.width*(c.top+1)-1]))):(c.left>0&&(n=d.resolve(i+s.map[c.top*s.width])),o.right<s.width&&(e=d.resolve(i+s.map[s.width*(o.top+1)-1]))),new Us(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Us(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Us(e.resolve(n),e.resolve(r))}getBookmark(){return new h4(this.$anchorCell.pos,this.$headCell.pos)}};tn.prototype.visible=!1;gt.jsonID("cell",tn);var h4=class N_{constructor(e,n){this.anchor=e,this.head=n}map(e){return new N_(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&&Yv(n,r)?new tn(n,r):gt.near(r,1)}};function p4(t){if(!(t.selection instanceof tn))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Ut.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Ot.create(t.doc,e)}function m4({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function g4({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function v4(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof ot&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=tn.create(s,r.from);else if(o=="row"){const c=s.resolve(r.from+1);i=tn.rowSelection(c,c)}else if(!n){const c=bn.get(r.node),d=r.from+1,f=d+c.map[c.width*c.height-1];i=tn.create(s,d+1,f)}}else r instanceof lt&&m4(r)?i=lt.create(s,r.from):r instanceof lt&&g4(r)&&(i=lt.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const b4=new qt("fix-tables");function C_(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,c=0;o<i;o++){const d=e.child(o);for(let f=c,h=Math.min(s,o+3);f<h;f++)if(t.child(f)==d){c=f+1,n+=d.nodeSize;continue e}r(d,n),c<s&&t.child(c).sameMarkup(d)?C_(t.child(c),d,n+1,r):d.nodesBetween(0,d.content.size,r,n+1),n+=d.nodeSize}}function __(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=y4(t,s,i,n))};return e?e.doc!=t.doc&&C_(e.doc,t.doc,0,r):t.doc.descendants(r),n}function y4(t,e,n,r){const s=bn.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let d=0;d<s.height;d++)i.push(0);for(let d=0;d<s.problems.length;d++){const f=s.problems[d];if(f.type=="collision"){const h=e.nodeAt(f.pos);if(!h)continue;const m=h.attrs;for(let g=0;g<m.rowspan;g++)i[f.row+g]+=f.n;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,ko(m,m.colspan-f.n,f.n))}else if(f.type=="missing")i[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const h=r.mapping.map(n);r.delete(h,h+e.nodeSize)}}let o,c;for(let d=0;d<i.length;d++)i[d]&&(o==null&&(o=d),c=d);for(let d=0,f=n+1;d<s.height;d++){const h=e.child(d),m=f+h.nodeSize,g=i[d];if(g>0){let v="cell";h.firstChild&&(v=h.firstChild.type.spec.tableRole);const x=[];for(let w=0;w<g;w++){const S=lr(t.schema)[v].createAndFill();S&&x.push(S)}const k=(d==0||o==d-1)&&c==d?f+1:m-1;r.insert(r.mapping.map(k),x)}f=m}return r.setMeta(b4,{fixTables:!0})}function _s(t){const e=t.selection,n=tf(t),r=n.node(-1),s=n.start(-1),i=bn.get(r);return{...e instanceof tn?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function T_(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;f4(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const c=o*e.width+s;if(s>0&&s<e.width&&e.map[c-1]==e.map[c]){const d=e.map[c],f=r.nodeAt(d);t.setNodeMarkup(t.mapping.map(n+d),null,E_(f.attrs,s-e.colCount(d))),o+=f.attrs.rowspan-1}else{const d=i==null?lr(r.type.schema).cell:r.nodeAt(e.map[c+i]).type,f=e.positionAt(o,s,r);t.insert(t.mapping.map(n+f),d.createAndFill())}}return t}function x4(t,e){if(!fs(t))return!1;if(e){const n=_s(t);e(T_(t.tr,n,n.left))}return!0}function w4(t,e){if(!fs(t))return!1;if(e){const n=_s(t);e(T_(t.tr,n,n.right))}return!0}function k4(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const c=o*e.width+s,d=e.map[c],f=n.nodeAt(d),h=f.attrs;if(s>0&&e.map[c-1]==d||s<e.width-1&&e.map[c+1]==d)t.setNodeMarkup(t.mapping.slice(i).map(r+d),null,ko(h,s-e.colCount(d)));else{const m=t.mapping.slice(i).map(r+d);t.delete(m,m+f.nodeSize)}o+=h.rowspan}}function S4(t,e){if(!fs(t))return!1;if(e){const n=_s(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;k4(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=bn.get(i)}e(r)}return!0}function E4(t,e,n){var r;const s=lr(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function j_(t,{map:e,tableStart:n,table:r},s){let i=n;for(let f=0;f<s;f++)i+=r.child(f).nodeSize;const o=[];let c=s>0?-1:0;E4(e,r,s+c)&&(c=s==0||s==e.height?null:0);for(let f=0,h=e.width*s;f<e.width;f++,h++)if(s>0&&s<e.height&&e.map[h]==e.map[h-e.width]){const m=e.map[h],g=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var d;const m=c==null?lr(r.type.schema).cell:(d=r.nodeAt(e.map[h+c*e.width]))===null||d===void 0?void 0:d.type,g=m==null?void 0:m.createAndFill();g&&o.push(g)}return t.insert(i,lr(r.type.schema).row.create(null,o)),t}function N4(t,e){if(!fs(t))return!1;if(e){const n=_s(t);e(j_(t.tr,n,n.top))}return!0}function C4(t,e){if(!fs(t))return!1;if(e){const n=_s(t);e(j_(t.tr,n,n.bottom))}return!0}function _4(t,{map:e,table:n,tableStart:r},s){let i=0;for(let f=0;f<s;f++)i+=n.child(f).nodeSize;const o=i+n.child(s).nodeSize,c=t.mapping.maps.length;t.delete(i+r,o+r);const d=new Set;for(let f=0,h=s*e.width;f<e.width;f++,h++){const m=e.map[h];if(!d.has(m)){if(d.add(m),s>0&&m==e.map[h-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g,rowspan:g.rowspan-1}),f+=g.colspan-1}else if(s<e.height&&m==e.map[h+e.width]){const g=n.nodeAt(m),v=g.attrs,x=g.type.create({...v,rowspan:g.attrs.rowspan-1},g.content),k=e.positionAt(s+1,f,n);t.insert(t.mapping.slice(c).map(r+k),x),f+=v.colspan-1}}}}function T4(t,e){if(!fs(t))return!1;if(e){const n=_s(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;_4(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=bn.get(n.table)}e(r)}return!0}function Aw(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function j4({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,c=s+(r.right-r.left-1);for(let d=r.top;d<r.bottom;d++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[c]==n[c+1])return!0;i+=t,c+=t}for(let d=r.left;d<r.right;d++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Rw(t,e){const n=t.selection;if(!(n instanceof tn)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=_s(t),{map:s}=r;if(j4(s,r))return!1;if(e){const i=t.tr,o={};let c=ke.empty,d,f;for(let h=r.top;h<r.bottom;h++)for(let m=r.left;m<r.right;m++){const g=s.map[h*s.width+m],v=r.table.nodeAt(g);if(!(o[g]||!v))if(o[g]=!0,d==null)d=g,f=v;else{Aw(v)||(c=c.append(v.content));const x=i.mapping.map(g+r.tableStart);i.delete(x,x+v.nodeSize)}}if(d==null||f==null)return!0;if(i.setNodeMarkup(d+r.tableStart,null,{...E_(f.attrs,f.attrs.colspan,r.right-r.left-f.attrs.colspan),rowspan:r.bottom-r.top}),c.size>0){const h=d+1+f.content.size,m=Aw(f)?d+1:h;i.replaceWith(m+r.tableStart,h+r.tableStart,c)}i.setSelection(new tn(i.doc.resolve(d+r.tableStart))),e(i)}return!0}function Ow(t,e){const n=lr(t.schema);return M4(({node:r})=>n[r.type.spec.tableRole])(t,e)}function M4(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof tn){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=c4(r.$from),!s)return!1;i=(o=wo(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let c=s.attrs;const d=[],f=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const h=_s(e),m=e.tr;for(let v=0;v<h.right-h.left;v++)d.push(f?{...c,colwidth:f&&f[v]?[f[v]]:null}:c);let g;for(let v=h.top;v<h.bottom;v++){let x=h.map.positionAt(v,h.left,h.table);v==h.top&&(x+=s.nodeSize);for(let k=h.left,w=0;k<h.right;k++,w++)k==h.left&&v==h.top||m.insert(g=m.mapping.map(x+h.tableStart,1),t({node:s,row:v,col:k}).createAndFill(d[w]))}m.setNodeMarkup(i,t({node:s,row:h.top,col:h.left}),d[0]),r instanceof tn&&m.setSelection(new tn(m.doc.resolve(r.$anchorCell.pos),g?m.doc.resolve(g):void 0)),n(m)}return!0}}function A4(t,e){return function(n,r){if(!fs(n))return!1;const s=tf(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof tn?n.selection.forEachCell((o,c)=>{o.attrs[t]!==e&&i.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function R4(t){return function(e,n){if(!fs(e))return!1;if(n){const r=lr(e.schema),s=_s(e),i=e.tr,o=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),c=o.map(d=>s.table.nodeAt(d));for(let d=0;d<o.length;d++)c[d].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[d],r.cell,c[d].attrs);if(i.steps.length===0)for(let d=0;d<o.length;d++)i.setNodeMarkup(s.tableStart+o[d],r.header_cell,c[d].attrs);n(i)}return!0}}function Iw(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 i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Il(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?R4(t):function(n,r){if(!fs(n))return!1;if(r){const s=lr(n.schema),i=_s(n),o=n.tr,c=Iw("row",i,s),d=Iw("column",i,s),f=(t==="column"?c:t==="row"&&d)?1:0,h=t=="column"?{left:0,top:f,right:1,bottom:i.map.height}:t=="row"?{left:f,top:0,right:i.map.width,bottom:1}:i,m=t=="column"?d?s.cell:s.header_cell:t=="row"?c?s.cell:s.header_cell:s.cell;i.map.cellsInRect(h).forEach(g=>{const v=g+i.tableStart,x=o.doc.nodeAt(v);x&&o.setNodeMarkup(v,m,x.attrs)}),r(o)}return!0}}Il("row",{useDeprecatedLogic:!0});Il("column",{useDeprecatedLogic:!0});const O4=Il("cell",{useDeprecatedLogic:!0});function I4(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Lw(t){return function(e,n){if(!fs(e))return!1;const r=I4(tf(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(lt.between(s,d4(s))).scrollIntoView())}return!0}}function L4(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function du(t,e){const n=t.selection;if(!(n instanceof tn))return!1;if(e){const r=t.tr,s=lr(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new Be(s,0,0))}),r.docChanged&&e(r)}return!0}function D4(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,c=[];if(i=="row")for(let d=0;d<e.childCount;d++){let f=e.child(d).content;const h=d?0:Math.max(0,n-1),m=d<e.childCount-1?0:Math.max(0,r-1);(h||m)&&(f=Kg(lr(o).row,new Be(f,h,m)).content),c.push(f)}else if(i=="cell"||i=="header_cell")c.push(n||r?Kg(lr(o).row,new Be(e,n,r)).content:e);else return null;return P4(o,c)}function P4(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:c,colspan:d}=i.child(o).attrs;for(let f=s;f<s+c;f++)n[f]=(n[f]||0)+d}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(ke.empty),n[s]<r){const i=lr(t).cell.createAndFill(),o=[];for(let c=n[s];c<r;c++)o.push(i);e[s]=e[s].append(ke.from(o))}return{height:e.length,width:r,rows:e}}function Kg(t,e){const n=t.createAndFill();return new lv(n).replace(0,n.content.size,e).doc}function B4({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let c=0;c<n.length;c++){const d=n[c],f=[];for(let h=i[c]||0,m=0;h<r;m++){let g=d.child(m%d.childCount);h+g.attrs.colspan>r&&(g=g.type.createChecked(ko(g.attrs,g.attrs.colspan,h+g.attrs.colspan-r),g.content)),f.push(g),h+=g.attrs.colspan;for(let v=1;v<g.attrs.rowspan;v++)i[c+v]=(i[c+v]||0)+g.attrs.colspan}o.push(ke.from(f))}n=o,t=r}if(e!=s){const i=[];for(let o=0,c=0;o<s;o++,c++){const d=[],f=n[c%e];for(let h=0;h<f.childCount;h++){let m=f.child(h);o+m.attrs.rowspan>s&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,s-m.attrs.rowspan)},m.content)),d.push(m)}i.push(ke.from(d))}n=i,e=s}return{width:t,height:e,rows:n}}function $4(t,e,n,r,s,i,o){const c=t.doc.type.schema,d=lr(c);let f,h;if(s>e.width)for(let m=0,g=0;m<e.height;m++){const v=n.child(m);g+=v.nodeSize;const x=[];let k;v.lastChild==null||v.lastChild.type==d.cell?k=f||(f=d.cell.createAndFill()):k=h||(h=d.header_cell.createAndFill());for(let w=e.width;w<s;w++)x.push(k);t.insert(t.mapping.slice(o).map(g-1+r),x)}if(i>e.height){const m=[];for(let x=0,k=(e.height-1)*e.width;x<Math.max(e.width,s);x++){const w=x>=e.width?!1:n.nodeAt(e.map[k+x]).type==d.header_cell;m.push(w?h||(h=d.header_cell.createAndFill()):f||(f=d.cell.createAndFill()))}const g=d.row.create(null,ke.from(m)),v=[];for(let x=e.height;x<i;x++)v.push(g);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),v)}return!!(f||h)}function Dw(t,e,n,r,s,i,o,c){if(o==0||o==e.height)return!1;let d=!1;for(let f=s;f<i;f++){const h=o*e.width+f,m=e.map[h];if(e.map[h-e.width]==m){d=!0;const g=n.nodeAt(m),{top:v,left:x}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...g.attrs,rowspan:o-v}),t.insert(t.mapping.slice(c).map(e.positionAt(o,x,n)),g.type.createAndFill({...g.attrs,rowspan:v+g.attrs.rowspan-o})),f+=g.attrs.colspan-1}}return d}function Pw(t,e,n,r,s,i,o,c){if(o==0||o==e.width)return!1;let d=!1;for(let f=s;f<i;f++){const h=f*e.width+o,m=e.map[h];if(e.map[h-1]==m){d=!0;const g=n.nodeAt(m),v=e.colCount(m),x=t.mapping.slice(c).map(m+r);t.setNodeMarkup(x,null,ko(g.attrs,o-v,g.attrs.colspan-(o-v))),t.insert(x+g.nodeSize,g.type.createAndFill(ko(g.attrs,0,o-v))),f+=g.attrs.rowspan-1}}return d}function Bw(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=bn.get(i);const{top:c,left:d}=r,f=d+s.width,h=c+s.height,m=t.tr;let g=0;function v(){if(i=n?m.doc.nodeAt(n-1):m.doc,!i)throw new Error("No table found");o=bn.get(i),g=m.mapping.maps.length}$4(m,o,i,n,f,h,g)&&v(),Dw(m,o,i,n,d,f,c,g)&&v(),Dw(m,o,i,n,d,f,h,g)&&v(),Pw(m,o,i,n,c,h,d,g)&&v(),Pw(m,o,i,n,c,h,f,g)&&v();for(let x=c;x<h;x++){const k=o.positionAt(x,d,i),w=o.positionAt(x,f,i);m.replace(m.mapping.slice(g).map(k+n),m.mapping.slice(g).map(w+n),new Be(s.rows[x-c],0,0))}v(),m.setSelection(new tn(m.doc.resolve(n+o.positionAt(c,d,i)),m.doc.resolve(n+o.positionAt(h-1,f-1,i)))),e(m)}const F4=Ev({ArrowLeft:fu("horiz",-1),ArrowRight:fu("horiz",1),ArrowUp:fu("vert",-1),ArrowDown:fu("vert",1),"Shift-ArrowLeft":hu("horiz",-1),"Shift-ArrowRight":hu("horiz",1),"Shift-ArrowUp":hu("vert",-1),"Shift-ArrowDown":hu("vert",1),Backspace:du,"Mod-Backspace":du,Delete:du,"Mod-Delete":du});function Pu(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function fu(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof tn)return Pu(n,r,gt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=M_(s,t,e);if(o==null)return!1;if(t=="horiz")return Pu(n,r,gt.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(o),d=S_(c,t,e);let f;return d?f=gt.near(d,1):e<0?f=gt.near(n.doc.resolve(c.before(-1)),-1):f=gt.near(n.doc.resolve(c.after(-1)),1),Pu(n,r,f)}}}function hu(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof tn)o=i;else{const d=M_(s,t,e);if(d==null)return!1;o=new tn(n.doc.resolve(d))}const c=S_(o.$headCell,t,e);return c?Pu(n,r,new tn(o.$anchorCell,c)):!1}}function z4(t,e){const n=t.state.doc,r=wo(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new tn(r))),!0):!1}function U4(t,e,n){if(!fs(t.state))return!1;let r=D4(n);const s=t.state.selection;if(s instanceof tn){r||(r={width:1,height:1,rows:[ke.from(Kg(lr(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),c=bn.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=B4(r,c.right-c.left,c.bottom-c.top),Bw(t.state,t.dispatch,o,c,r),!0}else if(r){const i=tf(t.state),o=i.start(-1);return Bw(t.state,t.dispatch,o,bn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function H4(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=$w(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof tn)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=wo(t.state.selection.$anchor))!=null&&((n=Np(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(d,f){let h=Np(t,f);const m=Si.getState(t.state)==null;if(!h||!Yv(d,h))if(m)h=d;else return;const g=new tn(d,h);if(m||!t.state.selection.eq(g)){const v=t.state.tr.setSelection(g);m&&v.setMeta(Si,d.pos),t.dispatch(v)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),Si.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Si,-1))}function c(d){const f=d,h=Si.getState(t.state);let m;if(h!=null)m=t.state.doc.resolve(h);else if($w(t,f.target)!=r&&(m=Np(t,e),!m))return o();m&&i(m,f)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",c)}function M_(t,e,n){if(!(t.state.selection instanceof lt))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function $w(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Np(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&wo(t.state.doc.resolve(r))||wo(t.state.doc.resolve(s))}var W4=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Gg(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Gg(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Gg(t,e,n,r,s,i){let o=0,c=!0,d=e.firstChild;const f=t.firstChild;if(f){for(let m=0,g=0;m<f.childCount;m++){const{colspan:v,colwidth:x}=f.child(m).attrs;for(let k=0;k<v;k++,g++){const w=s==g?i:x&&x[k],S=w?w+"px":"";if(o+=w||r,w||(c=!1),d)d.style.width!=S&&(d.style.width=S),d=d.nextSibling;else{const N=document.createElement("col");N.style.width=S,e.appendChild(N)}}}for(;d;){var h;const m=d.nextSibling;(h=d.parentNode)===null||h===void 0||h.removeChild(d),d=m}c?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Ir=new qt("tableColumnResizing");function V4({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=W4,lastColumnResizable:s=!0}={}){const i=new $t({key:Ir,state:{init(o,c){var d;const f=(d=i.spec)===null||d===void 0||(d=d.props)===null||d===void 0?void 0:d.nodeViews,h=lr(c.schema).table.name;return r&&f&&(f[h]=(m,g)=>new r(m,n,g)),new q4(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=Ir.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{K4(o,c,t,s)},mouseleave:o=>{G4(o)},mousedown:(o,c)=>{J4(o,c,e,n)}},decorations:o=>{const c=Ir.getState(o);if(c&&c.activeHandle>-1)return e3(o,c.activeHandle)},nodeViews:{}}});return i}var q4=class Bu{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ir);if(r&&r.setHandle!=null)return new Bu(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Bu(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return qg(e.doc.resolve(s))||(s=-1),new Bu(s,n.dragging)}return n}};function K4(t,e,n,r){if(!t.editable)return;const s=Ir.getState(t.state);if(s&&!s.dragging){const i=X4(e.target);let o=-1;if(i){const{left:c,right:d}=i.getBoundingClientRect();e.clientX-c<=n?o=Fw(t,e,"left",n):d-e.clientX<=n&&(o=Fw(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),d=c.node(-1),f=bn.get(d),h=c.start(-1);if(f.colCount(c.pos-h)+c.nodeAfter.attrs.colspan-1==f.width-1)return}A_(t,o)}}}function G4(t){if(!t.editable)return;const e=Ir.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&A_(t,-1)}function J4(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Ir.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),d=Y4(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Ir,{setDragging:{startX:e.clientX,startWidth:d}}));function f(m){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",h);const g=Ir.getState(t.state);g!=null&&g.dragging&&(Q4(t,g.activeHandle,zw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Ir,{setDragging:null})))}function h(m){if(!m.which)return f(m);const g=Ir.getState(t.state);if(g&&g.dragging){const v=zw(g.dragging,m,n);Uw(t,g.activeHandle,v,r)}}return Uw(t,o.activeHandle,d,r),i.addEventListener("mouseup",f),i.addEventListener("mousemove",h),e.preventDefault(),!0}function Y4(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,c=n;if(r)for(let d=0;d<n;d++)r[d]&&(o-=r[d],c--);return o/c}function X4(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Fw(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,c=wo(t.state.doc.resolve(o));if(!c)return-1;if(n=="right")return c.pos;const d=bn.get(c.node(-1)),f=c.start(-1),h=d.map.indexOf(c.pos-f);return h%d.width==0?-1:f+d.map[h-1]}function zw(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function A_(t,e){t.dispatch(t.state.tr.setMeta(Ir,{setHandle:e}))}function Q4(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=bn.get(s),o=r.start(-1),c=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,d=t.state.tr;for(let f=0;f<i.height;f++){const h=f*i.width+c;if(f&&i.map[h]==i.map[h-i.width])continue;const m=i.map[h],g=s.nodeAt(m).attrs,v=g.colspan==1?0:c-i.colCount(m);if(g.colwidth&&g.colwidth[v]==n)continue;const x=g.colwidth?g.colwidth.slice():Z4(g.colspan);x[v]=n,d.setNodeMarkup(o+m,null,{...g,colwidth:x})}d.docChanged&&t.dispatch(d)}function Uw(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),c=bn.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let d=t.domAtPos(s.start(-1)).node;for(;d&&d.nodeName!="TABLE";)d=d.parentNode;d&&Gg(i,d.firstChild,d,r,c,n)}function Z4(t){return Array(t).fill(0)}function e3(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return Ot.empty;const i=bn.get(s),o=r.start(-1),c=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<i.height;f++){const h=c+f*i.width;if((c==i.width-1||i.map[h]!=i.map[h+1])&&(f==0||i.map[h]!=i.map[h-i.width])){var d;const m=i.map[h],g=o+m+s.nodeAt(m).nodeSize-1,v=document.createElement("div");v.className="column-resize-handle",!((d=Ir.getState(t))===null||d===void 0)&&d.dragging&&n.push(Ut.node(o+m,o+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(Ut.widget(g,v))}}return Ot.create(t.doc,n)}function t3({allowTableNodeSelection:t=!1}={}){return new $t({key:Si,state:{init(){return null},apply(e,n){const r=e.getMeta(Si);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:p4,handleDOMEvents:{mousedown:H4},createSelectionBetween(e){return Si.getState(e.state)!=null?e.state.selection:null},handleTripleClick:z4,handleKeyDown:F4,handlePaste:U4},appendTransaction(e,n,r){return v4(r,__(r,n),t)}})}var R_=xn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const c=i[o].getAttribute("width");return c?[parseInt(c,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Bt(this.options.HTMLAttributes,t),0]}}),O_=xn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Bt(this.options.HTMLAttributes,t),0]}}),I_=xn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Bt(this.options.HTMLAttributes,t),0]}});function Jg(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Hw(t,e,n,r,s,i){var o;let c=0,d=!0,f=e.firstChild;const h=t.firstChild;if(h!==null)for(let g=0,v=0;g<h.childCount;g+=1){const{colspan:x,colwidth:k}=h.child(g).attrs;for(let w=0;w<x;w+=1,v+=1){const S=s===v?i:k&&k[w],N=S?`${S}px`:"";if(c+=S||r,S||(d=!1),f){if(f.style.width!==N){const[j,M]=Jg(r,S);f.style.setProperty(j,M)}f=f.nextSibling}else{const j=document.createElement("col"),[M,_]=Jg(r,S);j.style.setProperty(M,_),e.appendChild(j)}}}for(;f;){const g=f.nextSibling;(o=f.parentNode)==null||o.removeChild(f),f=g}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);d&&!m?(n.style.width=`${c}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${c}px`)}var n3=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Hw(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,Hw(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function r3(t,e,n,r){let s=0,i=!0;const o=[],c=t.firstChild;if(!c)return{};for(let m=0,g=0;m<c.childCount;m+=1){const{colspan:v,colwidth:x}=c.child(m).attrs;for(let k=0;k<v;k+=1,g+=1){const w=n===g?r:x&&x[k];s+=w||e,w||(i=!1);const[S,N]=Jg(e,w);o.push(["col",{style:`${S}: ${N}`}])}}const d=i?`${s}px`:"",f=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:d,tableMinWidth:f}}function Ww(t,e){return t.createAndFill()}function s3(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function i3(t,e,n,r,s){const i=s3(t),o=[],c=[];for(let f=0;f<n;f+=1){const h=Ww(i.cell);if(h&&c.push(h),r){const m=Ww(i.header_cell);m&&o.push(m)}}const d=[];for(let f=0;f<e;f+=1)d.push(i.row.createChecked(null,r&&f===0?o:c));return i.table.createChecked(null,d)}function o3(t){return t instanceof tn}var pu=({editor:t})=>{const{selection:e}=t.state;if(!o3(e))return!1;let n=0;const r=jC(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},a3="";function l3(t){return(t||"").replace(/\s+/g," ").trim()}function c3(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:a3;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(x=>{const k=[];x.content&&x.content.forEach(w=>{let S="";w.content&&Array.isArray(w.content)&&w.content.length>1?S=w.content.map(_=>e.renderChildren(_)).join(s):S=w.content?e.renderChildren(w.content):"";const N=l3(S),j=w.type==="tableHeader";k.push({text:N,isHeader:j})}),i.push(k)});const o=i.reduce((x,k)=>Math.max(x,k.length),0);if(o===0)return"";const c=new Array(o).fill(0);i.forEach(x=>{var k;for(let w=0;w<o;w+=1){const N=(((k=x[w])==null?void 0:k.text)||"").length;N>c[w]&&(c[w]=N),c[w]<3&&(c[w]=3)}});const d=(x,k)=>x+" ".repeat(Math.max(0,k-x.length)),f=i[0],h=f.some(x=>x.isHeader);let m=`
160
+ `;const g=new Array(o).fill(0).map((x,k)=>h&&f[k]&&f[k].text||"");return m+=`| ${g.map((x,k)=>d(x,c[k])).join(" | ")} |
161
+ `,m+=`| ${c.map(x=>"-".repeat(Math.max(3,x))).join(" | ")} |
162
+ `,(h?i.slice(1):i).forEach(x=>{m+=`| ${new Array(o).fill(0).map((k,w)=>d(x[w]&&x[w].text||"",c[w])).join(" | ")} |
163
+ `}),m}var u3=c3,L_=xn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:n3,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=r3(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const c=["table",Bt(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>u3(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=i3(i.schema,t,e,n);if(s){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(lt.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>x4(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>w4(t,e),deleteColumn:()=>({state:t,dispatch:e})=>S4(t,e),addRowBefore:()=>({state:t,dispatch:e})=>N4(t,e),addRowAfter:()=>({state:t,dispatch:e})=>C4(t,e),deleteRow:()=>({state:t,dispatch:e})=>T4(t,e),deleteTable:()=>({state:t,dispatch:e})=>L4(t,e),mergeCells:()=>({state:t,dispatch:e})=>Rw(t,e),splitCell:()=>({state:t,dispatch:e})=>Ow(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Il("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Il("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>O4(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Rw(t,e)?!0:Ow(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>A4(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Lw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Lw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&__(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=tn.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:pu,"Mod-Backspace":pu,Delete:pu,"Mod-Delete":pu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[V4({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],t3({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Vt(it(t,"tableRole",e))}}});Lt.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(L_.configure(this.options.table)),this.options.tableCell!==!1&&t.push(R_.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(O_.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(I_.configure(this.options.tableRow)),t}});var d3=Object.defineProperty,f3=(t,e)=>{for(var n in e)d3(t,n,{get:e[n],enumerable:!0})},h3="listItem",Vw="textStyle",qw=/^\s*([-+*])\s$/,D_=xn.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Bt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
164
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(h3,this.editor.getAttributes(Vw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=va({find:qw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=va({find:qw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vw),editor:this.editor})),[t]}}),P_=xn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Bt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),c=e.parseChildren(o);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Dv(t,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),p3={};f3(p3,{findListItemPos:()=>Hl,getNextListDepth:()=>Xv,handleBackspace:()=>Yg,handleDelete:()=>Xg,hasListBefore:()=>B_,hasListItemAfter:()=>m3,hasListItemBefore:()=>$_,listItemHasSubList:()=>F_,nextListIsDeeper:()=>z_,nextListIsHigher:()=>U_});var Hl=(t,e)=>{const{$from:n}=e.selection,r=Mn(t,e.schema);let s=null,i=n.depth,o=n.pos,c=null;for(;i>0&&c===null;)s=n.node(i),s.type===r?c=i:(i-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},Xv=(t,e)=>{const n=Hl(t,e);if(!n)return!1;const[,r]=qI(e,t,n.$pos.pos+4);return r},B_=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},$_=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},F_=(t,e,n)=>{if(!n)return!1;const r=Mn(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},Yg=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ii(t.state,e)&&B_(t.state,e,n)){const{$anchor:c}=t.state.selection,d=t.state.doc.resolve(c.before()-1),f=[];d.node().descendants((g,v)=>{g.type.name===e&&f.push({node:g,pos:v})});const h=f.at(-1);if(!h)return!1;const m=t.state.doc.resolve(d.start()+h.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Ii(t.state,e)||!YI(t.state))return!1;const r=Hl(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=F_(e,t.state,i);return $_(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},z_=(t,e)=>{const n=Xv(t,e),r=Hl(t,e);return!r||!n?!1:n>r.depth},U_=(t,e)=>{const n=Xv(t,e),r=Hl(t,e);return!r||!n?!1:n<r.depth},Xg=(t,e)=>{if(!Ii(t.state,e)||!JI(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:z_(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():U_(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},m3=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},H_=Lt.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Xg(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Xg(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Yg(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Yg(t,n,r)&&(e=!0)}),e}}}}),Kw=/^(\s*)(\d+)\.\s+(.*)$/,g3=/^\s/;function v3(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Kw);if(!i)break;const[,o,c,d]=i,f=o.length;let h=d,m=n+1;const g=[s];for(;m<t.length;){const v=t[m];if(v.match(Kw))break;if(v.trim()==="")g.push(v),h+=`
165
+ `,m+=1;else if(v.match(g3))g.push(v),h+=`
166
+ ${v.slice(f+2)}`,m+=1;else break}e.push({indent:f,number:parseInt(c,10),content:h.trim(),raw:g.join(`
167
+ `)}),r=m,n=m}return[e,r]}function W_(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const c=o.content.split(`
168
+ `),d=((r=c[0])==null?void 0:r.trim())||"",f=[];d&&f.push({type:"paragraph",raw:d,tokens:n.inlineTokens(d)});const h=c.slice(1).join(`
169
+ `).trim();if(h){const v=n.blockTokens(h);f.push(...v)}let m=i+1;const g=[];for(;m<t.length&&t[m].indent>e;)g.push(t[m]),m+=1;if(g.length>0){const v=Math.min(...g.map(k=>k.indent)),x=W_(g,v,n);f.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(k=>k.raw).join(`
170
+ `)})}s.push({type:"list_item",raw:o.raw,tokens:f}),i=m}else i+=1}return s}function b3(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var y3="listItem",Gw="textStyle",Jw=/^(\d+)\.\s$/,V_=xn.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Bt(this.options.HTMLAttributes,n),0]:["ol",Bt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?b3(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
171
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
172
+ `),[i,o]=v3(s);if(i.length===0)return;const c=W_(i,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:c,raw:s.slice(0,o).join(`
173
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(y3,this.editor.getAttributes(Gw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=va({find:Jw,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=va({find:Jw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Gw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),x3=/^\s*(\[([( |x])?\])\s$/,q_=xn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Bt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Dv(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),c=document.createElement("input"),d=document.createElement("div"),f=m=>{var g,v;c.ariaLabel=((v=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:v.call(g,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};f(t),i.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:v})=>{const x=n();if(typeof x!="number")return!1;const k=v.doc.nodeAt(x);return v.setNodeMarkup(x,void 0,{...k==null?void 0:k.attrs,checked:g}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{s.setAttribute(m,g)}),s.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,o),s.append(i,d),Object.entries(e).forEach(([m,g])=>{s.setAttribute(m,g)});let h=new Set(Object.keys(e));return{dom:s,contentDOM:d,update:m=>{if(m.type!==this.type)return!1;s.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,f(m);const g=r.extensionManager.attributes,v=ga(m,g),x=new Set(Object.keys(v)),k=this.options.HTMLAttributes;return h.forEach(w=>{x.has(w)||(w in k?s.setAttribute(w,k[w]):s.removeAttribute(w))}),Object.entries(v).forEach(([w,S])=>{S==null?w in k?s.setAttribute(w,k[w]):s.removeAttribute(w):s.setAttribute(w,S)}),h=x,!0}}}},addInputRules(){return[va({find:x3,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),K_=xn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Bt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
174
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=Ig(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,d)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:d}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=Ig(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Lt.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(D_.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(P_.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(H_.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(V_.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(q_.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(K_.configure(this.options.taskList)),t}});var w3=q_,k3=K_,S3=20,G_=(t,e=0)=>{const n=[];return!t.children.length||e>S3||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...G_(r,e+1))}),n},E3=t=>{if(!t.children.length)return;const e=G_(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},J_=ds.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&E3(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Bt(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),N3=Lt.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),c=i.slice(1).join(":").trim();if(o==="background-color")return c.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),C3=Lt.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),c=i.slice(1).join(":").trim();if(o==="color")return c.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),_3=Lt.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),T3=Lt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),j3=Lt.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Lt.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(N3.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(C3.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(_3.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(T3.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(j3.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(J_.configure(this.options.textStyle)),t}});var M3=t=>yn({find:/--$/,replace:t??"—"}),A3=t=>yn({find:/\.\.\.$/,replace:t??"…"}),R3=t=>yn({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),O3=t=>yn({find:/"$/,replace:t??"”"}),I3=t=>yn({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),L3=t=>yn({find:/'$/,replace:t??"’"}),D3=t=>yn({find:/<-$/,replace:t??"←"}),P3=t=>yn({find:/->$/,replace:t??"→"}),B3=t=>yn({find:/\(c\)$/,replace:t??"©"}),$3=t=>yn({find:/\(tm\)$/,replace:t??"™"}),F3=t=>yn({find:/\(sm\)$/,replace:t??"℠"}),z3=t=>yn({find:/\(r\)$/,replace:t??"®"}),U3=t=>yn({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),H3=t=>yn({find:/\+\/-$/,replace:t??"±"}),W3=t=>yn({find:/!=$/,replace:t??"≠"}),V3=t=>yn({find:/<<$/,replace:t??"«"}),q3=t=>yn({find:/>>$/,replace:t??"»"}),K3=t=>yn({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),G3=t=>yn({find:/\^2$/,replace:t??"²"}),J3=t=>yn({find:/\^3$/,replace:t??"³"}),Y3=t=>yn({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),X3=t=>yn({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),Q3=Lt.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(M3(this.options.emDash)),this.options.ellipsis!==!1&&t.push(A3(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(R3(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(O3(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(I3(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(L3(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(D3(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(P3(this.options.rightArrow)),this.options.copyright!==!1&&t.push(B3(this.options.copyright)),this.options.trademark!==!1&&t.push($3(this.options.trademark)),this.options.servicemark!==!1&&t.push(F3(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(z3(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(U3(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(H3(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(W3(this.options.notEqual)),this.options.laquo!==!1&&t.push(V3(this.options.laquo)),this.options.raquo!==!1&&t.push(q3(this.options.raquo)),this.options.multiplication!==!1&&t.push(K3(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(G3(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(J3(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(Y3(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(X3(this.options.threeQuarters)),t}}),Z3=Q3,Y_=ds.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Bt(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),e6=Y_,Yn=[];for(var Cp=0;Cp<256;++Cp)Yn.push((Cp+256).toString(16).slice(1));function t6(t,e=0){return(Yn[t[e+0]]+Yn[t[e+1]]+Yn[t[e+2]]+Yn[t[e+3]]+"-"+Yn[t[e+4]]+Yn[t[e+5]]+"-"+Yn[t[e+6]]+Yn[t[e+7]]+"-"+Yn[t[e+8]]+Yn[t[e+9]]+"-"+Yn[t[e+10]]+Yn[t[e+11]]+Yn[t[e+12]]+Yn[t[e+13]]+Yn[t[e+14]]+Yn[t[e+15]]).toLowerCase()}var mu,n6=new Uint8Array(16);function r6(){if(!mu&&(mu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!mu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return mu(n6)}var s6=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Yw={randomUUID:s6};function i6(t,e,n){if(Yw.randomUUID&&!t)return Yw.randomUUID();t=t||{};var r=t.random||(t.rng||r6)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,t6(r)}function o6(t){const e=new Set,n=new Set;return t.forEach(r=>{e.has(r)?n.add(r):e.add(r)}),Array.from(n)}var a6=Lt.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>i6(),filterTransaction:null,updateDocument:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>t[this.options.attributeName]?{[`data-${this.options.attributeName}`]:t[this.options.attributeName]}:{}}}}]},onCreate(){var t;if(!this.options.updateDocument)return;const e=this.editor.extensionManager.extensions.find(c=>c.name==="collaboration"),n=this.editor.extensionManager.extensions.find(c=>c.name==="collaborationCaret"),s=[e,n].filter(Boolean).find(c=>{var d;return(d=c==null?void 0:c.options)==null?void 0:d.provider}),i=(t=s==null?void 0:s.options)==null?void 0:t.provider,o=()=>{const{view:c,state:d}=this.editor,{tr:f,doc:h}=d,{types:m,attributeName:g,generateID:v}=this.options;Zu(h,k=>m.includes(k.type.name)&&k.attrs[g]===null).forEach(({node:k,pos:w})=>{f.setNodeMarkup(w,void 0,{...k.attrs,[g]:v({node:k,pos:w})})}),f.setMeta("addToHistory",!1),c.dispatch(f),i&&i.off("synced",o)};if(s){if(!i)return o();i.on("synced",o)}else return o()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new $t({key:new qt("uniqueID"),appendTransaction:(n,r,s)=>{const i=n.some(k=>k.docChanged)&&!r.doc.eq(s.doc),o=this.options.filterTransaction&&n.some(k=>{var w,S;return!((S=(w=this.options).filterTransaction)!=null&&S.call(w,k))});if(n.find(k=>k.getMeta("y-sync$"))||!i||o)return;const{tr:d}=s,{types:f,attributeName:h,generateID:m}=this.options,g=Tv(r.doc,n),{mapping:v}=g;if(Av(g).forEach(({newRange:k})=>{const w=TC(s.doc,k,N=>f.includes(N.type.name)),S=w.map(({node:N})=>N.attrs[h]).filter(N=>N!==null);w.forEach(({node:N,pos:j},M)=>{var _;const R=(_=d.doc.nodeAt(j))==null?void 0:_.attrs[h];if(R===null){d.setNodeMarkup(j,void 0,{...N.attrs,[h]:m({node:N,pos:j})});return}const L=w[M+1];if(L&&N.content.size===0){const K=d.doc.nodeAt(L.pos);if(K!=null&&K.attrs[h]&&K.attrs[h]!==R)return;d.setNodeMarkup(L.pos,void 0,{...L.node.attrs,[h]:R}),S[M+1]=R;const z=m({node:N,pos:j});return d.setNodeMarkup(j,void 0,{...N.attrs,[h]:z}),S[M]=z,d}const $=o6(S),{deleted:B}=v.invert().mapResult(j);B&&$.includes(R)&&d.setNodeMarkup(j,void 0,{...N.attrs,[h]:m({node:N,pos:j})})})}),!!d.steps.length)return d.setStoredMarks(s.tr.storedMarks),d.setMeta("__uniqueIDTransaction",!0),d},view(n){const r=s=>{var i;t=(i=n.dom.parentElement)!=null&&i.contains(s.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",r),{destroy(){window.removeEventListener("dragstart",r)}}},props:{handleDOMEvents:{drop:(n,r)=>{var s,i;return(t!==n.dom.parentElement||((s=r.dataTransfer)==null?void 0:s.effectAllowed)==="copyMove"||((i=r.dataTransfer)==null?void 0:i.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:n=>{if(!e)return n;const{types:r,attributeName:s}=this.options,i=o=>{const c=[];return o.forEach(d=>{if(d.isText){c.push(d);return}if(!r.includes(d.type.name)){c.push(d.copy(i(d.content)));return}const f=d.type.create({...d.attrs,[s]:null},i(d.content),d.marks);c.push(f)}),ke.from(c)};return e=!1,new Be(i(n.content),n.openStart,n.openEnd)}}})]}}),Qv=a6,Md=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},l6=/^\s*>\s$/,c6=xn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Md("blockquote",{...Bt(this.options.HTMLAttributes,t),children:Md("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const c=e.renderChildren([s]).split(`
175
+ `).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(c.join(`
176
+ `))}),r.join(`
177
+ ${n}
178
+ `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[va({find:l6,type:this.type})]}}),u6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,d6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,f6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,h6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,p6=ds.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Md("strong",{...Bt(this.options.HTMLAttributes,t),children:Md("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[xo({find:u6,type:this.type}),xo({find:f6,type:this.type})]},addPasteRules(){return[Li({find:d6,type:this.type}),Li({find:h6,type:this.type})]}}),m6=/(^|[^`])`([^`]+)`(?!`)$/,g6=/(^|[^`])`([^`]+)`(?!`)/g,v6=ds.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Bt(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[xo({find:m6,type:this.type})]},addPasteRules(){return[Li({find:g6,type:this.type})]}}),_p=4,b6=/^```([a-z]+)?[\s\n]$/,y6=/^~~~([a-z]+)?[\s\n]$/,X_=xn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:_p,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Bt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
179
+ `):r=`\`\`\`${s}
180
+
181
+ \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:_p,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const c=" ".repeat(n);return o?t.commands.insertContent(c):t.commands.command(({tr:d})=>{const{from:f,to:h}=s,v=r.doc.textBetween(f,h,`
182
+ `,`
183
+ `).split(`
184
+ `).map(x=>c+x).join(`
185
+ `);return d.replaceWith(f,h,r.schema.text(v)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:_p,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:c})=>{var d;const{pos:f}=i,h=i.start(),m=i.end(),v=r.doc.textBetween(h,m,`
186
+ `,`
187
+ `).split(`
188
+ `);let x=0,k=0;const w=f-h;for(let R=0;R<v.length;R+=1){if(k+v[R].length>=w){x=R;break}k+=v[R].length+1}const N=((d=v[x].match(/^ */))==null?void 0:d[0])||"",j=Math.min(N.length,n);if(j===0)return!0;let M=h;for(let R=0;R<x;R+=1)M+=v[R].length+1;return c.delete(M,M+j),f-M<=j&&c.setSelection(lt.create(c.doc,M)),!0}):t.commands.command(({tr:c})=>{const{from:d,to:f}=s,g=r.doc.textBetween(d,f,`
189
+ `,`
190
+ `).split(`
191
+ `).map(v=>{var x;const k=((x=v.match(/^ */))==null?void 0:x[0])||"",w=Math.min(k.length,n);return v.slice(w)}).join(`
192
+ `);return c.replaceWith(d,f,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
193
+
194
+ `);return!i||!o?!1:t.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const c=s.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:f})=>(f.setSelection(gt.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Og({find:b6,type:this.type,getAttributes:t=>({language:t[1]})}),Og({find:y6,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new $t({key:new qt("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!n||!i)return!1;const{tr:o,schema:c}=t.state,d=c.text(n.replace(/\r\n?/g,`
195
+ `));return o.replaceSelectionWith(this.type.create({language:i},d)),o.selection.$from.parent.type!==this.type&&o.setSelection(lt.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),x6=X_,w6=xn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
196
+
197
+ `):""}),k6=xn.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Bt(this.options.HTMLAttributes,t)]},renderText(){return`
198
+ `},renderMarkdown:()=>`
199
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=r.extensionManager,d=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:h})=>{if(h&&d&&o){const m=d.filter(g=>c.includes(g.type.name));f.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),S6=xn.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Bt(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Og({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),E6=xn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Bt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!PL(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return DC(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:c})=>{if(c){const{$to:d}=o.selection,f=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?o.setSelection(lt.create(o.doc,d.pos+1)):d.nodeAfter.isBlock?o.setSelection(ot.create(o.doc,d.pos)):o.setSelection(lt.create(o.doc,d.pos));else{const h=i.schema.nodes[this.options.nextNodeType]||d.parent.type.contentMatch.defaultType,m=h==null?void 0:h.create();m&&(o.insert(f,m),o.setSelection(lt.create(o.doc,f+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ZC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),N6=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,C6=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,_6=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,T6=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,j6=ds.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Bt(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[xo({find:N6,type:this.type}),xo({find:_6,type:this.type})]},addPasteRules(){return[Li({find:C6,type:this.type}),Li({find:T6,type:this.type})]}}),Xw="&nbsp;",M6=" ",A6=xn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Bt(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===Xw||r[0].text===M6)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?Xw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),R6=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,O6=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,I6=ds.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Bt(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[xo({find:R6,type:this.type})]},addPasteRules(){return[Li({find:O6,type:this.type})]}}),L6=xn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),D6=Lt.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(p6.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(c6.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(D_.configure(this.options.bulletList)),this.options.code!==!1&&s.push(v6.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(X_.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(w6.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(JP.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(YP.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(k6.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(S6.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(e4.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(E6.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(j6.configure(this.options.italic)),this.options.listItem!==!1&&s.push(P_.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(H_.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(v_.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(V_.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(A6.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(I6.configure(this.options.strike)),this.options.text!==!1&&s.push(L6.configure(this.options.text)),this.options.underline!==!1&&s.push(Y_.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(ZP.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),Zv=D6,Tp,Qw;function P6(){if(Qw)return Tp;Qw=1;function t(T){return T instanceof Map?T.clear=T.delete=T.set=function(){throw new Error("map is read-only")}:T instanceof Set&&(T.add=T.clear=T.delete=function(){throw new Error("set is read-only")}),Object.freeze(T),Object.getOwnPropertyNames(T).forEach(W=>{const ae=T[W],I=typeof ae;(I==="object"||I==="function")&&!Object.isFrozen(ae)&&t(ae)}),T}class e{constructor(W){W.data===void 0&&(W.data={}),this.data=W.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(T){return T.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(T,...W){const ae=Object.create(null);for(const I in T)ae[I]=T[I];return W.forEach(function(I){for(const V in I)ae[V]=I[V]}),ae}const s="</span>",i=T=>!!T.scope,o=(T,{prefix:W})=>{if(T.startsWith("language:"))return T.replace("language:","language-");if(T.includes(".")){const ae=T.split(".");return[`${W}${ae.shift()}`,...ae.map((I,V)=>`${I}${"_".repeat(V+1)}`)].join(" ")}return`${W}${T}`};class c{constructor(W,ae){this.buffer="",this.classPrefix=ae.classPrefix,W.walk(this)}addText(W){this.buffer+=n(W)}openNode(W){if(!i(W))return;const ae=o(W.scope,{prefix:this.classPrefix});this.span(ae)}closeNode(W){i(W)&&(this.buffer+=s)}value(){return this.buffer}span(W){this.buffer+=`<span class="${W}">`}}const d=(T={})=>{const W={children:[]};return Object.assign(W,T),W};class f{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(W){this.top.children.push(W)}openNode(W){const ae=d({scope:W});this.add(ae),this.stack.push(ae)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(W){return this.constructor._walk(W,this.rootNode)}static _walk(W,ae){return typeof ae=="string"?W.addText(ae):ae.children&&(W.openNode(ae),ae.children.forEach(I=>this._walk(W,I)),W.closeNode(ae)),W}static _collapse(W){typeof W!="string"&&W.children&&(W.children.every(ae=>typeof ae=="string")?W.children=[W.children.join("")]:W.children.forEach(ae=>{f._collapse(ae)}))}}class h extends f{constructor(W){super(),this.options=W}addText(W){W!==""&&this.add(W)}startScope(W){this.openNode(W)}endScope(){this.closeNode()}__addSublanguage(W,ae){const I=W.root;ae&&(I.scope=`language:${ae}`),this.add(I)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(T){return T?typeof T=="string"?T:T.source:null}function g(T){return k("(?=",T,")")}function v(T){return k("(?:",T,")*")}function x(T){return k("(?:",T,")?")}function k(...T){return T.map(ae=>m(ae)).join("")}function w(T){const W=T[T.length-1];return typeof W=="object"&&W.constructor===Object?(T.splice(T.length-1,1),W):{}}function S(...T){return"("+(w(T).capture?"":"?:")+T.map(I=>m(I)).join("|")+")"}function N(T){return new RegExp(T.toString()+"|").exec("").length-1}function j(T,W){const ae=T&&T.exec(W);return ae&&ae.index===0}const M=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _(T,{joinWith:W}){let ae=0;return T.map(I=>{ae+=1;const V=ae;let re=m(I),X="";for(;re.length>0;){const le=M.exec(re);if(!le){X+=re;break}X+=re.substring(0,le.index),re=re.substring(le.index+le[0].length),le[0][0]==="\\"&&le[1]?X+="\\"+String(Number(le[1])+V):(X+=le[0],le[0]==="("&&ae++)}return X}).map(I=>`(${I})`).join(W)}const R=/\b\B/,L="[a-zA-Z]\\w*",$="[a-zA-Z_]\\w*",B="\\b\\d+(\\.\\d+)?",F="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",K="\\b(0b[01]+)",z="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ee=(T={})=>{const W=/^#![ ]*\//;return T.binary&&(T.begin=k(W,/.*\b/,T.binary,/\b.*/)),r({scope:"meta",begin:W,end:/$/,relevance:0,"on:begin":(ae,I)=>{ae.index!==0&&I.ignoreMatch()}},T)},P={begin:"\\\\[\\s\\S]",relevance:0},U={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[P]},J={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[P]},ie={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},q=function(T,W,ae={}){const I=r({scope:"comment",begin:T,end:W,contains:[]},ae);I.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const V=S("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return I.contains.push({begin:k(/[ ]+/,"(",V,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),I},ue=q("//","$"),Y=q("/\\*","\\*/"),A=q("#","$"),D={scope:"number",begin:B,relevance:0},te={scope:"number",begin:F,relevance:0},fe={scope:"number",begin:K,relevance:0},we={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[P,{begin:/\[/,end:/\]/,relevance:0,contains:[P]}]},oe={scope:"title",begin:L,relevance:0},Se={scope:"title",begin:$,relevance:0},Ee={begin:"\\.\\s*"+$,relevance:0};var Ie=Object.freeze({__proto__:null,APOS_STRING_MODE:U,BACKSLASH_ESCAPE:P,BINARY_NUMBER_MODE:fe,BINARY_NUMBER_RE:K,COMMENT:q,C_BLOCK_COMMENT_MODE:Y,C_LINE_COMMENT_MODE:ue,C_NUMBER_MODE:te,C_NUMBER_RE:F,END_SAME_AS_BEGIN:function(T){return Object.assign(T,{"on:begin":(W,ae)=>{ae.data._beginMatch=W[1]},"on:end":(W,ae)=>{ae.data._beginMatch!==W[1]&&ae.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:L,MATCH_NOTHING_RE:R,METHOD_GUARD:Ee,NUMBER_MODE:D,NUMBER_RE:B,PHRASAL_WORDS_MODE:ie,QUOTE_STRING_MODE:J,REGEXP_MODE:we,RE_STARTERS_RE:z,SHEBANG:ee,TITLE_MODE:oe,UNDERSCORE_IDENT_RE:$,UNDERSCORE_TITLE_MODE:Se});function Ve(T,W){T.input[T.index-1]==="."&&W.ignoreMatch()}function Te(T,W){T.className!==void 0&&(T.scope=T.className,delete T.className)}function qe(T,W){W&&T.beginKeywords&&(T.begin="\\b("+T.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",T.__beforeBegin=Ve,T.keywords=T.keywords||T.beginKeywords,delete T.beginKeywords,T.relevance===void 0&&(T.relevance=0))}function pt(T,W){Array.isArray(T.illegal)&&(T.illegal=S(...T.illegal))}function ut(T,W){if(T.match){if(T.begin||T.end)throw new Error("begin & end are not supported with match");T.begin=T.match,delete T.match}}function be(T,W){T.relevance===void 0&&(T.relevance=1)}const ht=(T,W)=>{if(!T.beforeMatch)return;if(T.starts)throw new Error("beforeMatch cannot be used with starts");const ae=Object.assign({},T);Object.keys(T).forEach(I=>{delete T[I]}),T.keywords=ae.keywords,T.begin=k(ae.beforeMatch,g(ae.begin)),T.starts={relevance:0,contains:[Object.assign(ae,{endsParent:!0})]},T.relevance=0,delete ae.beforeMatch},xt=["of","and","for","in","not","or","if","then","parent","list","value"],St="keyword";function At(T,W,ae=St){const I=Object.create(null);return typeof T=="string"?V(ae,T.split(" ")):Array.isArray(T)?V(ae,T):Object.keys(T).forEach(function(re){Object.assign(I,At(T[re],W,re))}),I;function V(re,X){W&&(X=X.map(le=>le.toLowerCase())),X.forEach(function(le){const ve=le.split("|");I[ve[0]]=[re,Ye(ve[0],ve[1])]})}}function Ye(T,W){return W?Number(W):ct(T)?0:1}function ct(T){return xt.includes(T.toLowerCase())}const Fe={},G=T=>{console.error(T)},ge=(T,...W)=>{console.log(`WARN: ${T}`,...W)},ne=(T,W)=>{Fe[`${T}/${W}`]||(console.log(`Deprecated as of ${T}. ${W}`),Fe[`${T}/${W}`]=!0)},he=new Error;function me(T,W,{key:ae}){let I=0;const V=T[ae],re={},X={};for(let le=1;le<=W.length;le++)X[le+I]=V[le],re[le+I]=!0,I+=N(W[le-1]);T[ae]=X,T[ae]._emit=re,T[ae]._multi=!0}function ze(T){if(Array.isArray(T.begin)){if(T.skip||T.excludeBegin||T.returnBegin)throw G("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),he;if(typeof T.beginScope!="object"||T.beginScope===null)throw G("beginScope must be object"),he;me(T,T.begin,{key:"beginScope"}),T.begin=_(T.begin,{joinWith:""})}}function Ae(T){if(Array.isArray(T.end)){if(T.skip||T.excludeEnd||T.returnEnd)throw G("skip, excludeEnd, returnEnd not compatible with endScope: {}"),he;if(typeof T.endScope!="object"||T.endScope===null)throw G("endScope must be object"),he;me(T,T.end,{key:"endScope"}),T.end=_(T.end,{joinWith:""})}}function Xe(T){T.scope&&typeof T.scope=="object"&&T.scope!==null&&(T.beginScope=T.scope,delete T.scope)}function Qe(T){Xe(T),typeof T.beginScope=="string"&&(T.beginScope={_wrap:T.beginScope}),typeof T.endScope=="string"&&(T.endScope={_wrap:T.endScope}),ze(T),Ae(T)}function tt(T){function W(X,le){return new RegExp(m(X),"m"+(T.case_insensitive?"i":"")+(T.unicodeRegex?"u":"")+(le?"g":""))}class ae{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(le,ve){ve.position=this.position++,this.matchIndexes[this.matchAt]=ve,this.regexes.push([ve,le]),this.matchAt+=N(le)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const le=this.regexes.map(ve=>ve[1]);this.matcherRe=W(_(le,{joinWith:"|"}),!0),this.lastIndex=0}exec(le){this.matcherRe.lastIndex=this.lastIndex;const ve=this.matcherRe.exec(le);if(!ve)return null;const Re=ve.findIndex((Dt,Et)=>Et>0&&Dt!==void 0),ye=this.matchIndexes[Re];return ve.splice(0,Re),Object.assign(ve,ye)}}class I{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(le){if(this.multiRegexes[le])return this.multiRegexes[le];const ve=new ae;return this.rules.slice(le).forEach(([Re,ye])=>ve.addRule(Re,ye)),ve.compile(),this.multiRegexes[le]=ve,ve}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(le,ve){this.rules.push([le,ve]),ve.type==="begin"&&this.count++}exec(le){const ve=this.getMatcher(this.regexIndex);ve.lastIndex=this.lastIndex;let Re=ve.exec(le);if(this.resumingScanAtSamePosition()&&!(Re&&Re.index===this.lastIndex)){const ye=this.getMatcher(0);ye.lastIndex=this.lastIndex+1,Re=ye.exec(le)}return Re&&(this.regexIndex+=Re.position+1,this.regexIndex===this.count&&this.considerAll()),Re}}function V(X){const le=new I;return X.contains.forEach(ve=>le.addRule(ve.begin,{rule:ve,type:"begin"})),X.terminatorEnd&&le.addRule(X.terminatorEnd,{type:"end"}),X.illegal&&le.addRule(X.illegal,{type:"illegal"}),le}function re(X,le){const ve=X;if(X.isCompiled)return ve;[Te,ut,Qe,ht].forEach(ye=>ye(X,le)),T.compilerExtensions.forEach(ye=>ye(X,le)),X.__beforeBegin=null,[qe,pt,be].forEach(ye=>ye(X,le)),X.isCompiled=!0;let Re=null;return typeof X.keywords=="object"&&X.keywords.$pattern&&(X.keywords=Object.assign({},X.keywords),Re=X.keywords.$pattern,delete X.keywords.$pattern),Re=Re||/\w+/,X.keywords&&(X.keywords=At(X.keywords,T.case_insensitive)),ve.keywordPatternRe=W(Re,!0),le&&(X.begin||(X.begin=/\B|\b/),ve.beginRe=W(ve.begin),!X.end&&!X.endsWithParent&&(X.end=/\B|\b/),X.end&&(ve.endRe=W(ve.end)),ve.terminatorEnd=m(ve.end)||"",X.endsWithParent&&le.terminatorEnd&&(ve.terminatorEnd+=(X.end?"|":"")+le.terminatorEnd)),X.illegal&&(ve.illegalRe=W(X.illegal)),X.contains||(X.contains=[]),X.contains=[].concat(...X.contains.map(function(ye){return Ue(ye==="self"?X:ye)})),X.contains.forEach(function(ye){re(ye,ve)}),X.starts&&re(X.starts,le),ve.matcher=V(ve),ve}if(T.compilerExtensions||(T.compilerExtensions=[]),T.contains&&T.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return T.classNameAliases=r(T.classNameAliases||{}),re(T)}function We(T){return T?T.endsWithParent||We(T.starts):!1}function Ue(T){return T.variants&&!T.cachedVariants&&(T.cachedVariants=T.variants.map(function(W){return r(T,{variants:null},W)})),T.cachedVariants?T.cachedVariants:We(T)?r(T,{starts:T.starts?r(T.starts):null}):Object.isFrozen(T)?r(T):T}var st="11.11.1";class mt extends Error{constructor(W,ae){super(W),this.name="HTMLInjectionError",this.html=ae}}const Nt=n,Mt=r,Jt=Symbol("nomatch"),nn=7,at=function(T){const W=Object.create(null),ae=Object.create(null),I=[];let V=!0;const re="Could not find the language '{}', did you forget to load/include a language module?",X={disableAutodetect:!0,name:"Plain text",contains:[]};let le={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function ve(je){return le.noHighlightRe.test(je)}function Re(je){let et=je.className+" ";et+=je.parentNode?je.parentNode.className:"";const wt=le.languageDetectRe.exec(et);if(wt){const kt=An(wt[1]);return kt||(ge(re.replace("{}",wt[1])),ge("Falling back to no-highlight mode for this block.",je)),kt?wt[1]:"no-highlight"}return et.split(/\s+/).find(kt=>ve(kt)||An(kt))}function ye(je,et,wt){let kt="",Qt="";typeof et=="object"?(kt=je,wt=et.ignoreIllegals,Qt=et.language):(ne("10.7.0","highlight(lang, code, ...args) has been deprecated."),ne("10.7.0",`Please use highlight(code, options) instead.
200
+ https://github.com/highlightjs/highlight.js/issues/2277`),Qt=je,kt=et),wt===void 0&&(wt=!0);const Zt={code:kt,language:Qt};Kn("before:highlight",Zt);const Tr=Zt.result?Zt.result:Dt(Zt.language,Zt.code,wt);return Tr.code=Zt.code,Kn("after:highlight",Tr),Tr}function Dt(je,et,wt,kt){const Qt=Object.create(null);function Zt(Pe,Ke){return Pe.keywords[Ke]}function Tr(){if(!rt.keywords){kn.addText(Kt);return}let Pe=0;rt.keywordPatternRe.lastIndex=0;let Ke=rt.keywordPatternRe.exec(Kt),vt="";for(;Ke;){vt+=Kt.substring(Pe,Ke.index);const It=_n.case_insensitive?Ke[0].toLowerCase():Ke[0],pn=Zt(rt,It);if(pn){const[Pn,mf]=pn;if(kn.addText(vt),vt="",Qt[It]=(Qt[It]||0)+1,Qt[It]<=nn&&(Ui+=mf),Pn.startsWith("_"))vt+=Ke[0];else{const Xl=_n.classNameAliases[Pn]||Pn;Ln(Ke[0],Xl)}}else vt+=Ke[0];Pe=rt.keywordPatternRe.lastIndex,Ke=rt.keywordPatternRe.exec(Kt)}vt+=Kt.substring(Pe),kn.addText(vt)}function Qs(){if(Kt==="")return;let Pe=null;if(typeof rt.subLanguage=="string"){if(!W[rt.subLanguage]){kn.addText(Kt);return}Pe=Dt(rt.subLanguage,Kt,!0,es[rt.subLanguage]),es[rt.subLanguage]=Pe._top}else Pe=dn(Kt,rt.subLanguage.length?rt.subLanguage:null);rt.relevance>0&&(Ui+=Pe.relevance),kn.__addSublanguage(Pe._emitter,Pe.language)}function In(){rt.subLanguage!=null?Qs():Tr(),Kt=""}function Ln(Pe,Ke){Pe!==""&&(kn.startScope(Ke),kn.addText(Pe),kn.endScope())}function ms(Pe,Ke){let vt=1;const It=Ke.length-1;for(;vt<=It;){if(!Pe._emit[vt]){vt++;continue}const pn=_n.classNameAliases[Pe[vt]]||Pe[vt],Pn=Ke[vt];pn?Ln(Pn,pn):(Kt=Pn,Tr(),Kt=""),vt++}}function Zr(Pe,Ke){return Pe.scope&&typeof Pe.scope=="string"&&kn.openNode(_n.classNameAliases[Pe.scope]||Pe.scope),Pe.beginScope&&(Pe.beginScope._wrap?(Ln(Kt,_n.classNameAliases[Pe.beginScope._wrap]||Pe.beginScope._wrap),Kt=""):Pe.beginScope._multi&&(ms(Pe.beginScope,Ke),Kt="")),rt=Object.create(Pe,{parent:{value:rt}}),rt}function Z(Pe,Ke,vt){let It=j(Pe.endRe,vt);if(It){if(Pe["on:end"]){const pn=new e(Pe);Pe["on:end"](Ke,pn),pn.isMatchIgnored&&(It=!1)}if(It){for(;Pe.endsParent&&Pe.parent;)Pe=Pe.parent;return Pe}}if(Pe.endsWithParent)return Z(Pe.parent,Ke,vt)}function xe(Pe){return rt.matcher.regexIndex===0?(Kt+=Pe[0],1):(Zs=!0,0)}function De(Pe){const Ke=Pe[0],vt=Pe.rule,It=new e(vt),pn=[vt.__beforeBegin,vt["on:begin"]];for(const Pn of pn)if(Pn&&(Pn(Pe,It),It.isMatchIgnored))return xe(Ke);return vt.skip?Kt+=Ke:(vt.excludeBegin&&(Kt+=Ke),In(),!vt.returnBegin&&!vt.excludeBegin&&(Kt=Ke)),Zr(vt,Pe),vt.returnBegin?0:Ke.length}function bt(Pe){const Ke=Pe[0],vt=et.substring(Pe.index),It=Z(rt,Pe,vt);if(!It)return Jt;const pn=rt;rt.endScope&&rt.endScope._wrap?(In(),Ln(Ke,rt.endScope._wrap)):rt.endScope&&rt.endScope._multi?(In(),ms(rt.endScope,Pe)):pn.skip?Kt+=Ke:(pn.returnEnd||pn.excludeEnd||(Kt+=Ke),In(),pn.excludeEnd&&(Kt=Ke));do rt.scope&&kn.closeNode(),!rt.skip&&!rt.subLanguage&&(Ui+=rt.relevance),rt=rt.parent;while(rt!==It.parent);return It.starts&&Zr(It.starts,Pe),pn.returnEnd?0:Ke.length}function Ct(){const Pe=[];for(let Ke=rt;Ke!==_n;Ke=Ke.parent)Ke.scope&&Pe.unshift(Ke.scope);Pe.forEach(Ke=>kn.openNode(Ke))}let wn={};function Cn(Pe,Ke){const vt=Ke&&Ke[0];if(Kt+=Pe,vt==null)return In(),0;if(wn.type==="begin"&&Ke.type==="end"&&wn.index===Ke.index&&vt===""){if(Kt+=et.slice(Ke.index,Ke.index+1),!V){const It=new Error(`0 width match regex (${je})`);throw It.languageName=je,It.badRule=wn.rule,It}return 1}if(wn=Ke,Ke.type==="begin")return De(Ke);if(Ke.type==="illegal"&&!wt){const It=new Error('Illegal lexeme "'+vt+'" for mode "'+(rt.scope||"<unnamed>")+'"');throw It.mode=rt,It}else if(Ke.type==="end"){const It=bt(Ke);if(It!==Jt)return It}if(Ke.type==="illegal"&&vt==="")return Kt+=`
201
+ `,1;if(Hi>1e5&&Hi>Ke.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Kt+=vt,vt.length}const _n=An(je);if(!_n)throw G(re.replace("{}",je)),new Error('Unknown language: "'+je+'"');const Dn=tt(_n);let _t="",rt=kt||Dn;const es={},kn=new le.__emitter(le);Ct();let Kt="",Ui=0,gs=0,Hi=0,Zs=!1;try{if(_n.__emitTokens)_n.__emitTokens(et,kn);else{for(rt.matcher.considerAll();;){Hi++,Zs?Zs=!1:rt.matcher.considerAll(),rt.matcher.lastIndex=gs;const Pe=rt.matcher.exec(et);if(!Pe)break;const Ke=et.substring(gs,Pe.index),vt=Cn(Ke,Pe);gs=Pe.index+vt}Cn(et.substring(gs))}return kn.finalize(),_t=kn.toHTML(),{language:je,value:_t,relevance:Ui,illegal:!1,_emitter:kn,_top:rt}}catch(Pe){if(Pe.message&&Pe.message.includes("Illegal"))return{language:je,value:Nt(et),illegal:!0,relevance:0,_illegalBy:{message:Pe.message,index:gs,context:et.slice(gs-100,gs+100),mode:Pe.mode,resultSoFar:_t},_emitter:kn};if(V)return{language:je,value:Nt(et),illegal:!1,relevance:0,errorRaised:Pe,_emitter:kn,_top:rt};throw Pe}}function Et(je){const et={value:Nt(je),illegal:!1,relevance:0,_top:X,_emitter:new le.__emitter(le)};return et._emitter.addText(je),et}function dn(je,et){et=et||le.languages||Object.keys(W);const wt=Et(je),kt=et.filter(An).filter(Xs).map(In=>Dt(In,je,!1));kt.unshift(wt);const Qt=kt.sort((In,Ln)=>{if(In.relevance!==Ln.relevance)return Ln.relevance-In.relevance;if(In.language&&Ln.language){if(An(In.language).supersetOf===Ln.language)return 1;if(An(Ln.language).supersetOf===In.language)return-1}return 0}),[Zt,Tr]=Qt,Qs=Zt;return Qs.secondBest=Tr,Qs}function Xt(je,et,wt){const kt=et&&ae[et]||wt;je.classList.add("hljs"),je.classList.add(`language-${kt}`)}function ln(je){let et=null;const wt=Re(je);if(ve(wt))return;if(Kn("before:highlightElement",{el:je,language:wt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(le.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(je)),le.throwUnescapedHTML))throw new mt("One of your code blocks includes unescaped HTML.",je.innerHTML);et=je;const kt=et.textContent,Qt=wt?ye(kt,{language:wt,ignoreIllegals:!0}):dn(kt);je.innerHTML=Qt.value,je.dataset.highlighted="yes",Xt(je,wt,Qt.language),je.result={language:Qt.language,re:Qt.relevance,relevance:Qt.relevance},Qt.secondBest&&(je.secondBest={language:Qt.secondBest.language,relevance:Qt.secondBest.relevance}),Kn("after:highlightElement",{el:je,result:Qt,text:kt})}function $e(je){le=Mt(le,je)}const zt=()=>{gr(),ne("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function qn(){gr(),ne("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let fn=!1;function gr(){function je(){gr()}if(document.readyState==="loading"){fn||window.addEventListener("DOMContentLoaded",je,!1),fn=!0;return}document.querySelectorAll(le.cssSelector).forEach(ln)}function vr(je,et){let wt=null;try{wt=et(T)}catch(kt){if(G("Language definition for '{}' could not be registered.".replace("{}",je)),V)G(kt);else throw kt;wt=X}wt.name||(wt.name=je),W[je]=wt,wt.rawDefinition=et.bind(null,T),wt.aliases&&ur(wt.aliases,{languageName:je})}function _r(je){delete W[je];for(const et of Object.keys(ae))ae[et]===je&&delete ae[et]}function hn(){return Object.keys(W)}function An(je){return je=(je||"").toLowerCase(),W[je]||W[ae[je]]}function ur(je,{languageName:et}){typeof je=="string"&&(je=[je]),je.forEach(wt=>{ae[wt.toLowerCase()]=et})}function Xs(je){const et=An(je);return et&&!et.disableAutodetect}function Wt(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=et=>{je["before:highlightBlock"](Object.assign({block:et.el},et))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=et=>{je["after:highlightBlock"](Object.assign({block:et.el},et))})}function Ts(je){Wt(je),I.push(je)}function Qr(je){const et=I.indexOf(je);et!==-1&&I.splice(et,1)}function Kn(je,et){const wt=je;I.forEach(function(kt){kt[wt]&&kt[wt](et)})}function js(je){return ne("10.7.0","highlightBlock will be removed entirely in v12.0"),ne("10.7.0","Please use highlightElement now."),ln(je)}Object.assign(T,{highlight:ye,highlightAuto:dn,highlightAll:gr,highlightElement:ln,highlightBlock:js,configure:$e,initHighlighting:zt,initHighlightingOnLoad:qn,registerLanguage:vr,unregisterLanguage:_r,listLanguages:hn,getLanguage:An,registerAliases:ur,autoDetection:Xs,inherit:Mt,addPlugin:Ts,removePlugin:Qr}),T.debugMode=function(){V=!1},T.safeMode=function(){V=!0},T.versionString=st,T.regex={concat:k,lookahead:g,either:S,optional:x,anyNumberOfTimes:v};for(const je in Ie)typeof Ie[je]=="object"&&t(Ie[je]);return Object.assign(T,Ie),T},Ht=at({});return Ht.newInstance=()=>at({}),Tp=Ht,Ht.HighlightJS=Ht,Ht.default=Ht,Tp}var B6=P6();const Q_=Dl(B6);function Z_(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?Z_(n.children,r):{text:n.value,classes:r}})}function Zw(t){return t.value||t.children||[]}function $6(t){return!!Q_.getLanguage(t)}function ek({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return Zu(t,i=>i.type.name===e).forEach(i=>{var o;let c=i.pos+1;const d=i.node.attrs.language||r,f=n.listLanguages(),h=d&&(f.includes(d)||$6(d)||(o=n.registered)!=null&&o.call(n,d))?Zw(n.highlight(d,i.node.textContent)):Zw(n.highlightAuto(i.node.textContent));Z_(h).forEach(m=>{const g=c+m.text.length;if(m.classes.length){const v=Ut.inline(c,g,{class:m.classes.join(" ")});s.push(v)}c=g})}),Ot.create(t,s)}function F6(t){return typeof t=="function"}function z6({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>F6(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new $t({key:new qt("lowlight"),state:{init:(s,{doc:i})=>ek({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,c)=>{const d=o.selection.$head.parent.type.name,f=c.selection.$head.parent.type.name,h=Zu(o.doc,g=>g.type.name===t),m=Zu(c.doc,g=>g.type.name===t);return s.docChanged&&([d,f].includes(t)||m.length!==h.length||s.steps.some(g=>g.from!==void 0&&g.to!==void 0&&h.some(v=>v.pos>=g.from&&v.pos+v.node.nodeSize<=g.to)))?ek({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var U6=x6.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],z6({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),H6=U6;function W6(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={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})"/})]},h={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},m={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(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},v=e.optional(s)+t.IDENT_RE+"\\s*\\(",x=["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"],k=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["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"],S=["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"],M={type:k,keyword:x,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},_={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[_,m,c,n,t.C_BLOCK_COMMENT_MODE,h,f],L={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:M,contains:R.concat([{begin:/\(/,end:/\)/,keywords:M,contains:R.concat(["self"]),relevance:0}]),relevance:0},$={className:"function",begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:M,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:M,relevance:0},{begin:v,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,c,{begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:M,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(L,$,_,R,[m,{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:M,contains:["self",c]},{begin:t.IDENT_RE+"::",keywords:M},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function V6(t){const e={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=W6(t),r=n.keywords;return r.type=[...r.type,...e.type],r.literal=[...r.literal,...e.literal],r.built_in=[...r.built_in,...e.built_in],r._hints=e._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function q6(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(c);const d={match:/\\"/},f={className:"string",begin:/'/,end:/'/},h={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],v=t.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),x={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},k=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],w=["true","false"],S={match:/(\/[a-z._-]+)+/},N=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],j=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],M=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],_=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:k,literal:w,built_in:[...N,...j,"set","shopt",...M,..._]},contains:[v,t.SHEBANG(),x,m,i,o,S,c,d,f,h,n]}}function K6(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},f={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})"/})]},h={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},m={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(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},v=e.optional(s)+t.IDENT_RE+"\\s*\\(",w={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"},S=[m,c,n,t.C_BLOCK_COMMENT_MODE,h,f],N={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:S.concat([{begin:/\(/,end:/\)/,keywords:w,contains:S.concat(["self"]),relevance:0}]),relevance:0},j={begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:w,relevance:0},{begin:v,returnBegin:!0,contains:[t.inherit(g,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,c,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C",aliases:["h"],keywords:w,disableAutodetect:!0,illegal:"</",contains:[].concat(N,j,S,[m,{begin:t.IDENT_RE+"::",keywords:w},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:m,strings:f,keywords:w}}}function G6(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={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})"/})]},h={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},m={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(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},v=e.optional(s)+t.IDENT_RE+"\\s*\\(",x=["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"],k=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["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"],S=["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"],M={type:k,keyword:x,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},_={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[_,m,c,n,t.C_BLOCK_COMMENT_MODE,h,f],L={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:M,contains:R.concat([{begin:/\(/,end:/\)/,keywords:M,contains:R.concat(["self"]),relevance:0}]),relevance:0},$={className:"function",begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:M,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:M,relevance:0},{begin:v,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,c,{begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:M,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(L,$,_,R,[m,{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:M,contains:["self",c]},{begin:t.IDENT_RE+"::",keywords:M},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function J6(t){const e=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],s=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],i=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],o={keyword:s.concat(i),built_in:e,literal:r},c=t.inherit(t.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),d={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},f={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},h={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},m=t.inherit(h,{illegal:/\n/}),g={className:"subst",begin:/\{/,end:/\}/,keywords:o},v=t.inherit(g,{illegal:/\n/}),x={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,v]},k={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]},w=t.inherit(k,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},v]});g.contains=[k,x,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.C_BLOCK_COMMENT_MODE],v.contains=[w,x,m,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const S={variants:[f,k,x,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},N={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},j=t.IDENT_RE+"(<"+t.IDENT_RE+"(\\s*,\\s*"+t.IDENT_RE+")*>)?(\\[\\])?",M={begin:"@"+t.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,illegal:/::/,contains:[t.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},S,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,N,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,N,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+j+"\\s+)+"+t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:o,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[t.TITLE_MODE,N],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[S,d,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},M]}}const Y6=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_-]*/}}),X6=["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"],Q6=["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"],Z6=[...X6,...Q6],eB=["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(),tB=["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(),nB=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),rB=["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 sB(t){const e=t.regex,n=Y6(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",c=[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:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+tB.join("|")+")"},{begin:":(:)?("+nB.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+rB.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:eB.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+Z6.join("|")+")\\b"}]}}function iB(t){const e=t.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:e.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:e.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function oB(t){const i={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:i,illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"string",variants:[t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[t.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:i,illegal:/["']/}]}]}}function aB(t){const e=t.regex,n=/[_A-Za-z][_0-9A-Za-z]*/;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[t.HASH_COMMENT_MODE,t.QUOTE_STRING_MODE,t.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:e.concat(n,e.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function lB(t){const e=t.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:t.NUMBER_RE}]},r=t.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},o={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,i,s,o,n,"self"],relevance:0},d=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,h=/'[^']*'/,m=e.either(d,f,h),g=e.concat(m,"(\\s*\\.\\s*",m,")*",e.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,c,i,s,o,n]}}]}}var ra="[0-9](_*[0-9])*",gu=`\\.(${ra})`,vu="[0-9a-fA-F](_*[0-9a-fA-F])*",tk={className:"number",variants:[{begin:`(\\b(${ra})((${gu})|\\.)?|(${gu}))[eE][+-]?(${ra})[fFdD]?\\b`},{begin:`\\b(${ra})((${gu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${gu})[fFdD]?\\b`},{begin:`\\b(${ra})[fFdD]\\b`},{begin:`\\b0[xX]((${vu})\\.?|(${vu})?\\.(${vu}))[pP][+-]?(${ra})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${vu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function eT(t,e,n){return n===-1?"":t.replace(e,r=>eT(t,e,n-1))}function cB(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+eT("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),d={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"]},f={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},h={className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:d,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:[h,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:d,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[f,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,tk,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},tk,f]}}const nk="[A-Za-z$_][0-9A-Za-z$_]*",uB=["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"],dB=["true","false","null","undefined","NaN","Infinity"],tT=["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"],nT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],rT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],fB=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],hB=[].concat(rT,tT,nT);function pB(t){const e=t.regex,n=(q,{after:ue})=>{const Y="</"+q[0].slice(1);return q.input.indexOf(Y,ue)!==-1},r=nk,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(q,ue)=>{const Y=q[0].length+q.index,A=q.input[Y];if(A==="<"||A===","){ue.ignoreMatch();return}A===">"&&(n(q,{after:Y})||ue.ignoreMatch());let D;const te=q.input.substring(Y);if(D=te.match(/^\s*=/)){ue.ignoreMatch();return}if((D=te.match(/^\s+extends\s+/))&&D.index===0){ue.ignoreMatch();return}}},c={$pattern:nk,keyword:uB,literal:dB,built_in:hB,"variable.language":fB},d="[0-9](_?[0-9])*",f=`\\.(${d})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\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},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},x={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},N={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]},j=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,{match:/\$\d+/},m];g.contains=j.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(j)});const M=[].concat(N,g.contains),_=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(M)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:_},L={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"}}]},$={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:{_:[...tT,...nT]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},F={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},K={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function z(q){return e.concat("(?!",q.join("|"),")")}const ee={match:e.concat(/\b/,z([...rT,"super","import"].map(q=>`${q}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},U={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},J="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(J)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:$},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,N,{match:/\$\d+/},m,$,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,t.REGEXP_MODE,{className:"function",begin:J,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:c,contains:_}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},F,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},ee,K,L,U,{match:/\$[(.]/}]}}function mB(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var sa="[0-9](_*[0-9])*",bu=`\\.(${sa})`,yu="[0-9a-fA-F](_*[0-9a-fA-F])*",gB={className:"number",variants:[{begin:`(\\b(${sa})((${bu})|\\.)?|(${bu}))[eE][+-]?(${sa})[fFdD]?\\b`},{begin:`\\b(${sa})((${bu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${bu})[fFdD]?\\b`},{begin:`\\b(${sa})[fFdD]\\b`},{begin:`\\b0[xX]((${yu})\\.?|(${yu})?\\.(${yu}))[pP][+-]?(${sa})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${yu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function vB(t){const e={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"@"},s={className:"subst",begin:/\$\{/,end:/\}/,contains:[t.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+t.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,s]},{begin:"'",end:"'",illegal:/\n/,contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[t.BACKSLASH_ESCAPE,i,s]}]};s.contains.push(o);const c={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+t.UNDERSCORE_IDENT_RE+")?"},d={className:"meta",begin:"@"+t.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[t.inherit(o,{className:"string"}),"self"]}]},f=gB,h=t.COMMENT("/\\*","\\*/",{contains:[t.C_BLOCK_COMMENT_MODE]}),m={variants:[{className:"type",begin:t.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},g=m;return g.variants[1].contains=[m],m.variants[1].contains=[g],{name:"Kotlin",aliases:["kt","kts"],keywords:e,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),t.C_LINE_COMMENT_MODE,h,n,r,c,d,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:e,relevance:5,contains:[{begin:t.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[t.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:e,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[m,t.C_LINE_COMMENT_MODE,h],relevance:0},t.C_LINE_COMMENT_MODE,h,c,d,o,t.C_NUMBER_MODE]},h]},{begin:[/class|interface|trait/,/\s+/,t.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},t.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},c,d]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
202
+ `},f]}}const bB=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_-]*/}}),yB=["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"],xB=["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"],wB=[...yB,...xB],kB=["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(),sT=["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(),iT=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),SB=["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(),EB=sT.concat(iT).sort().reverse();function NB(t){const e=bB(t),n=EB,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",o=[],c=[],d=function(j){return{className:"string",begin:"~?"+j+".*?"+j}},f=function(j,M,_){return{className:j,begin:M,relevance:_}},h={$pattern:/[a-z-]+/,keyword:r,attribute:kB.join(" ")},m={begin:"\\(",end:"\\)",contains:c,keywords:h,relevance:0};c.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,d("'"),d('"'),e.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},e.HEXCOLOR,m,f("variable","@@?"+s,10),f("variable","@\\{"+s+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:s+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},e.IMPORTANT,{beginKeywords:"and not"},e.FUNCTION_DISPATCH);const g=c.concat({begin:/\{/,end:/\}/,contains:o}),v={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(c)},x={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+SB.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},k={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:c,relevance:0}},w={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:g}},S={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,v,f("keyword","all\\b"),f("variable","@\\{"+s+"\\}"),{begin:"\\b("+wB.join("|")+")\\b",className:"selector-tag"},e.CSS_NUMBER_MODE,f("selector-tag",i,0),f("selector-id","#"+i),f("selector-class","\\."+i,0),f("selector-tag","&",0),e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+sT.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+iT.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:g},{begin:"!important"},e.FUNCTION_DISPATCH]},N={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return o.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,k,w,N,x,S,v,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function CB(t){const e="\\[=*\\[",n="\\]=*\\]",r={begin:e,end:n,contains:["self"]},s=[t.COMMENT("--(?!"+e+")","$"),t.COMMENT("--"+e,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:t.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:s.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[t.inherit(t.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:s}].concat(s)},t.C_NUMBER_MODE,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{className:"string",begin:e,end:n,contains:[r],relevance:5}])}}function _B(t){const e={className:"variable",variants:[{begin:"\\$\\("+t.UNDERSCORE_IDENT_RE+"\\)",contains:[t.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,e]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[e,n]},s={begin:"^"+t.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},i={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},o={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[e]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[t.HASH_COMMENT_MODE,e,n,r,s,i,o]}}function TB(t){const e=t.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},s={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=t.inherit(f,{contains:[]}),g=t.inherit(h,{contains:[]});f.contains.push(g),h.contains.push(m);let v=[n,d];return[f,h,m,g].forEach(S=>{S.contains=S.contains.concat(v)}),v=v.concat(f,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:v},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:v}]}]},n,i,f,h,{className:"quote",begin:"^>\\s+",contains:v,end:"$"},s,r,d,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function jB(t){const e={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},d={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,illegal:"</",contains:[e,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,t.C_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+d.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:d,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}function MB(t){const e=t.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,keyword:n.join(" ")},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},o={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},d={scope:"variable",variants:[{begin:/\$\d/},{begin:e.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},h=[t.BACKSLASH_ESCAPE,i,d],m=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],g=(k,w,S="\\1")=>{const N=S==="\\1"?S:e.concat(S,w);return e.concat(e.concat("(?:",k,")"),w,/(?:\\.|[^\\\/])*?/,N,/(?:\\.|[^\\\/])*?/,S,r)},v=(k,w,S)=>e.concat(e.concat("(?:",k,")"),w,/(?:\\.|[^\\\/])*?/,S,r),x=[d,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:h,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+t.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[t.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:g("s|tr|y",e.either(...m,{capture:!0}))},{begin:g("s|tr|y","\\(","\\)")},{begin:g("s|tr|y","\\[","\\]")},{begin:g("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:v("(?:m|qr)?",/\//,/\//)},{begin:v("m|qr",e.either(...m,{capture:!0}),/\1/)},{begin:v("m|qr",/\(/,/\)/)},{begin:v("m|qr",/\[/,/\]/)},{begin:v("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=x,o.contains=x,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:x}}function AB(t){const e=t.regex,n=/(?![A-Za-z0-9])(?![$])/,r=e.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),s=e.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),i=e.concat(/[A-Z]+/,n),o={scope:"variable",match:"\\$+"+r},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},d={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=t.inherit(t.APOS_STRING_MODE,{illegal:null}),h=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(d)}),m={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(d),"on:begin":(P,U)=>{U.data._beginMatch=P[1]||P[2]},"on:end":(P,U)=>{U.data._beginMatch!==P[1]&&U.ignoreMatch()}},g=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),v=`[
203
+ ]`,x={scope:"string",variants:[h,f,m,g]},k={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},w=["false","null","true"],S=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],N=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],M={keyword:S,literal:(P=>{const U=[];return P.forEach(J=>{U.push(J),J.toLowerCase()===J?U.push(J.toUpperCase()):U.push(J.toLowerCase())}),U})(w),built_in:N},_=P=>P.map(U=>U.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,e.concat(v,"+"),e.concat("(?!",_(N).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},L=e.concat(r,"\\b(?!\\()"),$={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),L],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,e.concat(/::/,e.lookahead(/(?!class\b)/)),L],scope:{1:"title.class",3:"variable.constant"}},{match:[s,e.concat("::",e.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},B={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},F={relevance:0,begin:/\(/,end:/\)/,keywords:M,contains:[B,o,$,t.C_BLOCK_COMMENT_MODE,x,k,R]},K={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",_(S).join("\\b|"),"|",_(N).join("\\b|"),"\\b)"),r,e.concat(v,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[F]};F.contains.push(K);const z=[B,$,t.C_BLOCK_COMMENT_MODE,x,k,R],ee={begin:e.concat(/#\[\s*\\?/,e.either(s,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:w,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:w,keyword:["new","array"]},contains:["self",...z]},...z,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:M,contains:[ee,t.HASH_COMMENT_MODE,t.COMMENT("//","$"),t.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:t.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},c,{scope:"variable.language",match:/\$this\b/},o,K,$,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},R,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},t.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:M,contains:["self",ee,o,$,t.C_BLOCK_COMMENT_MODE,x,k]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[t.inherit(t.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},t.UNDERSCORE_TITLE_MODE]},x,k]}}function RB(t){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},t.inherit(t.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),t.inherit(t.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function OB(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function IB(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"],c={$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"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},h={begin:/\{\{/,relevance:0},m={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d,h,f]},{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,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,h,f]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",v=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,x=`\\b|${r.join("|")}`,k={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${v}))[eE][+-]?(${g})[jJ]?(?=${x})`},{begin:`(${v})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${x})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${x})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${x})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${x})`},{begin:`\\b(${g})[jJ](?=${x})`}]},w={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},S={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",d,k,m,t.HASH_COMMENT_MODE]}]};return f.contains=[m,k,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[d,k,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,w,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[S]},{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:[k,S,m]}]}}function LB(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function DB(t){const e=t.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=e.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=e.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[t.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:e.lookahead(e.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),t.HASH_COMMENT_MODE,{scope:"string",contains:[t.BACKSLASH_ESCAPE],variants:[t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[i,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function PB(t){const e=t.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=e.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),s=e.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},d={begin:"#<",end:">"},f=[t.COMMENT("#","$",{contains:[c]}),t.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:o},m={className:"string",contains:[t.BACKSLASH_ESCAPE,h],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:e.concat(/<<[-~]?'?/,e.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[t.BACKSLASH_ESCAPE,h]})]}]},g="[1-9](_?[0-9])*|0",v="[0-9](_?[0-9])*",x={className:"number",relevance:0,variants:[{begin:`\\b(${g})(\\.(${v}))?([eE][+-]?(${v})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},k={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},R=[m,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:o},{relevance:0,match:[s,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[k]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[m,{begin:n}],relevance:0},x,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,h],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(d,f),relevance:0}].concat(d,f);h.contains=R,k.contains=R;const F=[{begin:/^\s*=>/,starts:{end:"$",contains:R}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:R}}];return f.unshift(d),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(F).concat(f).concat(R)}}function BB(t){const e=t.regex,n=/(r#)?/,r=e.concat(n,t.UNDERSCORE_IDENT_RE),s=e.concat(n,t.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:e.concat(/\b/,/(?!let|for|while|if|else|match\b)/,s,e.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],d=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:h,keyword:c,literal:d,built_in:f},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:h}},{className:"punctuation",begin:"->"},i]}}const $B=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_-]*/}}),FB=["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"],zB=["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"],UB=[...FB,...zB],HB=["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(),WB=["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(),VB=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),qB=["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 KB(t){const e=$B(t),n=VB,r=WB,s="@[a-z-]+",i="and or not only",c={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,e.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+UB.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},c,{begin:/\(/,end:/\)/,contains:[e.CSS_NUMBER_MODE]},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+qB.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[e.BLOCK_COMMENT,c,e.HEXCOLOR,e.CSS_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.IMPORTANT,e.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:HB.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},c,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.HEXCOLOR,e.CSS_NUMBER_MODE]},e.FUNCTION_DISPATCH]}}function GB(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function JB(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],c=["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"],d=["add","asc","collation","desc","final","first","last","view"],f=["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"],h=["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"],m=["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"],g=["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"],v=h,x=[...f,...d].filter(_=>!h.includes(_)),k={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},w={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},S={match:e.concat(/\b/,e.either(...v),/\s*\(/),relevance:0,keywords:{built_in:v}};function N(_){return e.concat(/\b/,e.either(..._.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const j={scope:"keyword",match:N(g),relevance:0};function M(_,{exceptions:R,when:L}={}){const $=L;return R=R||[],_.map(B=>B.match(/\|\d+$/)||R.includes(B)?B:$(B)?`${B}|0`:B)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:M(x,{when:_=>_.length<3}),literal:i,type:c,built_in:m},contains:[{scope:"type",match:N(o)},j,S,k,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,w]}}function oT(t){return t?typeof t=="string"?t:t.source:null}function el(t){return Gt("(?=",t,")")}function Gt(...t){return t.map(n=>oT(n)).join("")}function YB(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function hr(...t){return"("+(YB(t).capture?"":"?:")+t.map(r=>oT(r)).join("|")+")"}const eb=t=>Gt(/\b/,t,/\w$/.test(t)?/\b/:/\B/),XB=["Protocol","Type"].map(eb),rk=["init","self"].map(eb),QB=["Any","Self"],jp=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],sk=["false","nil","true"],ZB=["assignment","associativity","higherThan","left","lowerThan","none","right"],e5=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],ik=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],aT=hr(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),lT=hr(aT,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Mp=Gt(aT,lT,"*"),cT=hr(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Ad=hr(cT,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ws=Gt(cT,Ad,"*"),xu=Gt(/[A-Z]/,Ad,"*"),t5=["attached","autoclosure",Gt(/convention\(/,hr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",Gt(/objc\(/,ws,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],n5=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function r5(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],s={match:[/\./,hr(...XB,...rk)],className:{2:"keyword"}},i={match:Gt(/\./,hr(...jp)),relevance:0},o=jp.filter(be=>typeof be=="string").concat(["_|0"]),c=jp.filter(be=>typeof be!="string").concat(QB).map(eb),d={variants:[{className:"keyword",match:hr(...c,...rk)}]},f={$pattern:hr(/\b\w+/,/#\w+/),keyword:o.concat(e5),literal:sk},h=[s,i,d],m={match:Gt(/\./,hr(...ik)),relevance:0},g={className:"built_in",match:Gt(/\b/,hr(...ik),/(?=\()/)},v=[m,g],x={match:/->/,relevance:0},k={className:"operator",relevance:0,variants:[{match:Mp},{match:`\\.(\\.|${lT})+`}]},w=[x,k],S="([0-9]_*)+",N="([0-9a-fA-F]_*)+",j={className:"number",relevance:0,variants:[{match:`\\b(${S})(\\.(${S}))?([eE][+-]?(${S}))?\\b`},{match:`\\b0x(${N})(\\.(${N}))?([pP][+-]?(${S}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},M=(be="")=>({className:"subst",variants:[{match:Gt(/\\/,be,/[0\\tnr"']/)},{match:Gt(/\\/,be,/u\{[0-9a-fA-F]{1,8}\}/)}]}),_=(be="")=>({className:"subst",match:Gt(/\\/,be,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(be="")=>({className:"subst",label:"interpol",begin:Gt(/\\/,be,/\(/),end:/\)/}),L=(be="")=>({begin:Gt(be,/"""/),end:Gt(/"""/,be),contains:[M(be),_(be),R(be)]}),$=(be="")=>({begin:Gt(be,/"/),end:Gt(/"/,be),contains:[M(be),R(be)]}),B={className:"string",variants:[L(),L("#"),L("##"),L("###"),$(),$("#"),$("##"),$("###")]},F=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],K={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:F},z=be=>{const ht=Gt(be,/\//),xt=Gt(/\//,be);return{begin:ht,end:xt,contains:[...F,{scope:"comment",begin:`#(?!.*${xt})`,end:/$/}]}},ee={scope:"regexp",variants:[z("###"),z("##"),z("#"),K]},P={match:Gt(/`/,ws,/`/)},U={className:"variable",match:/\$\d+/},J={className:"variable",match:`\\$${Ad}+`},ie=[P,U,J],q={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:n5,contains:[...w,j,B]}]}},ue={scope:"keyword",match:Gt(/@/,hr(...t5),el(hr(/\(/,/\s+/)))},Y={scope:"meta",match:Gt(/@/,ws)},A=[q,ue,Y],D={match:el(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:Gt(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Ad,"+")},{className:"type",match:xu,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:Gt(/\s+&\s+/,el(xu)),relevance:0}]},te={begin:/</,end:/>/,keywords:f,contains:[...r,...h,...A,x,D]};D.contains.push(te);const fe={match:Gt(ws,/\s*:/),keywords:"_|0",relevance:0},we={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",fe,...r,ee,...h,...v,...w,j,B,...ie,...A,D]},oe={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,D]},Se={begin:hr(el(Gt(ws,/\s*:/)),el(Gt(ws,/\s+/,ws,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ws}]},Ee={begin:/\(/,end:/\)/,keywords:f,contains:[Se,...r,...h,...w,j,B,...A,D,we],endsParent:!0,illegal:/["']/},Le={match:[/(func|macro)/,/\s+/,hr(P.match,ws,Mp)],className:{1:"keyword",3:"title.function"},contains:[oe,Ee,e],illegal:[/\[/,/%/]},Ie={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[oe,Ee,e],illegal:/\[|%/},Ve={match:[/operator/,/\s+/,Mp],className:{1:"keyword",3:"title"}},Te={begin:[/precedencegroup/,/\s+/,xu],className:{1:"keyword",3:"title"},contains:[D],keywords:[...ZB,...sk],end:/}/},qe={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},pt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},ut={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,ws,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[oe,...h,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:xu},...h],relevance:0}]};for(const be of B.variants){const ht=be.contains.find(St=>St.label==="interpol");ht.keywords=f;const xt=[...h,...v,...w,j,B,...ie];ht.contains=[...xt,{begin:/\(/,end:/\)/,contains:["self",...xt]}]}return{name:"Swift",keywords:f,contains:[...r,Le,Ie,qe,pt,ut,Ve,Te,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},ee,...h,...v,...w,j,B,...ie,...A,D,we]}}const Rd="[A-Za-z$_][0-9A-Za-z$_]*",uT=["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"],dT=["true","false","null","undefined","NaN","Infinity"],fT=["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"],hT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],pT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],mT=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],gT=[].concat(pT,fT,hT);function s5(t){const e=t.regex,n=(q,{after:ue})=>{const Y="</"+q[0].slice(1);return q.input.indexOf(Y,ue)!==-1},r=Rd,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(q,ue)=>{const Y=q[0].length+q.index,A=q.input[Y];if(A==="<"||A===","){ue.ignoreMatch();return}A===">"&&(n(q,{after:Y})||ue.ignoreMatch());let D;const te=q.input.substring(Y);if(D=te.match(/^\s*=/)){ue.ignoreMatch();return}if((D=te.match(/^\s+extends\s+/))&&D.index===0){ue.ignoreMatch();return}}},c={$pattern:Rd,keyword:uT,literal:dT,built_in:gT,"variable.language":mT},d="[0-9](_?[0-9])*",f=`\\.(${d})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\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},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},x={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},N={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]},j=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,{match:/\$\d+/},m];g.contains=j.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(j)});const M=[].concat(N,g.contains),_=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(M)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:_},L={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"}}]},$={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:{_:[...fT,...hT]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},F={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},K={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function z(q){return e.concat("(?!",q.join("|"),")")}const ee={match:e.concat(/\b/,z([...pT,"super","import"].map(q=>`${q}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},P={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},U={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},J="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(J)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:$},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,N,{match:/\$\d+/},m,$,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,t.REGEXP_MODE,{className:"function",begin:J,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:c,contains:_}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},F,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},P,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},ee,K,L,U,{match:/\$[(.]/}]}}function i5(t){const e=t.regex,n=s5(t),r=Rd,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:Rd,keyword:uT.concat(d),literal:dT,built_in:gT.concat(s),"variable.language":mT},h={className:"meta",begin:"@"+r},m=(k,w,S)=>{const N=k.contains.findIndex(j=>j.label===w);if(N===-1)throw new Error("can not find mode to replace");k.contains.splice(N,1,S)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const g=n.contains.find(k=>k.scope==="attr"),v=Object.assign({},g,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,v]),n.contains=n.contains.concat([h,i,o,v]),m(n,"shebang",t.SHEBANG()),m(n,"use_strict",c);const x=n.contains.find(k=>k.label==="func.def");return x.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function o5(t){const e=t.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,d={className:"literal",variants:[{begin:e.concat(/# */,e.either(i,s),/ *#/)},{begin:e.concat(/# */,c,/ *#/)},{begin:e.concat(/# */,o,/ *#/)},{begin:e.concat(/# */,e.either(i,s),/ +/,e.either(o,c),/ *#/)}]},f={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},h={className:"label",begin:/^\w+:/},m=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),g=t.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,d,f,h,m,g,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[g]}]}}function a5(t){t.regex;const e=t.COMMENT(/\(;/,/;\)/);e.contains.push("self");const n=t.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],s={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},i={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},d={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,e,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},i,o,s,t.QUOTE_STRING_MODE,d,f,c]}}function l5(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]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),c=t.inherit(t.APOS_STRING_MODE,{className:"string"}),d=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),f={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:[i,d,c,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,d,c]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],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:f}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function c5(t){const e="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,s]},c=t.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},v={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},x={begin:/\{/,end:/\}/,contains:[v],illegal:"\\n",relevance:0},k={begin:"\\[",end:"\\]",contains:[v],illegal:"\\n",relevance:0},w=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},g,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},x,k,i,o],S=[...w];return S.pop(),S.push(c),v.contains=S,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:w}}const u5={arduino:V6,bash:q6,c:K6,cpp:G6,csharp:J6,css:sB,diff:iB,go:oB,graphql:aB,ini:lB,java:cB,javascript:pB,json:mB,kotlin:vB,less:NB,lua:CB,makefile:_B,markdown:TB,objectivec:jB,perl:MB,php:AB,"php-template":RB,plaintext:OB,python:IB,"python-repl":LB,r:DB,ruby:PB,rust:BB,scss:KB,shell:GB,sql:JB,swift:r5,typescript:i5,vbnet:o5,wasm:a5,xml:l5,yaml:c5},ok={},d5="hljs-";function f5(t){const e=Q_.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:c};function n(d,f,h){const m=h||ok,g=typeof m.prefix=="string"?m.prefix:d5;if(!e.getLanguage(d))throw new Error("Unknown language: `"+d+"` is not registered");e.configure({__emitter:h5,classPrefix:g});const v=e.highlight(f,{ignoreIllegals:!0,language:d});if(v.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:v.errorRaised});const x=v._emitter.root,k=x.data;return k.language=v.language,k.relevance=v.relevance,x}function r(d,f){const m=(f||ok).subset||s();let g=-1,v=0,x;for(;++g<m.length;){const k=m[g];if(!e.getLanguage(k))continue;const w=n(k,d,f);w.data&&w.data.relevance!==void 0&&w.data.relevance>v&&(v=w.data.relevance,x=w)}return x||{type:"root",children:[],data:{language:void 0,relevance:v}}}function s(){return e.listLanguages()}function i(d,f){if(typeof d=="string")e.registerLanguage(d,f);else{let h;for(h in d)Object.hasOwn(d,h)&&e.registerLanguage(h,d[h])}}function o(d,f){if(typeof d=="string")e.registerAliases(typeof f=="string"?f:[...f],{languageName:d});else{let h;for(h in d)if(Object.hasOwn(d,h)){const m=d[h];e.registerAliases(typeof m=="string"?m:[...m],{languageName:h})}}}function c(d){return!!e.getLanguage(d)}}class h5{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,c){return c?o+"_".repeat(c):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const p5=new qt("blurredLoadingNode"),tb=Lt.create({name:"blurredLoadingNode",addStorage(){return{loadingNodes:{}}},addCommands(){return{applyLoadingEffect:(t,e,n,r="paragraph")=>({editor:s})=>{const i={...this.storage.loadingNodes};return i[t]={from:e,to:n,id:t,active:!0,type:r},this.storage.loadingNodes=i,s.view.dispatch(s.view.state.tr),setTimeout(()=>{s.isFocused&&s.commands.setTextSelection({from:e,to:e})},0),!0},removeLoadingEffect:t=>({editor:e})=>{const n={...this.storage.loadingNodes};return n[t]&&(delete n[t],this.storage.loadingNodes=n,e.view.dispatch(e.view.state.tr),e.isFocused||setTimeout(()=>{e.commands.focus()},0)),!0}}},addProseMirrorPlugins(){return[new $t({key:p5,props:{decorations:t=>{const e=this.storage.loadingNodes,n=[];return Object.entries(e).forEach(([,r])=>{const s=r;if(!s.active)return;const{from:i,to:o,type:c}=s;c==="selection"?n.push(Ut.inline(i,o,{class:"node-blur-selection"})):t.doc.nodesBetween(i,o,(d,f)=>["paragraph","heading","blockquote","listItem","codeBlock"].includes(d.type.name)?(n.push(Ut.node(f,f+d.nodeSize,{class:"node-blur-effect"})),!1):!0)}),Ot.create(t.doc,n)}}})]}}),nb=xn.create({name:"imageLoading",group:"block",atom:!0,addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:'div[data-type="image-loading"]'}]},renderHTML(){return["div",{"data-type":"image-loading",class:"image-loading-placeholder",contenteditable:"false"}]}}),m5=new qt("insertionLoadingNode"),wu=new Map,rb=Lt.create({name:"insertionLoadingNode",addStorage(){return{insertionPoints:{}}},addCommands(){return{showInsertionLoading:(t,e)=>({editor:n})=>(this.storage.insertionPoints={},wu.clear(),this.storage.insertionPoints={[t]:{position:e,id:t,active:!0}},n.view.dom.classList.add("has-insertion-loading"),n.view.dispatch(n.view.state.tr),!0),removeInsertionLoading:t=>({editor:e})=>{const n={...this.storage.insertionPoints};return n[t]&&(delete n[t],this.storage.insertionPoints=n,wu.delete(t),Object.keys(n).length===0&&e.view.dom.classList.remove("has-insertion-loading"),e.view.dispatch(e.view.state.tr)),!0}}},addProseMirrorPlugins(){return[new $t({key:m5,props:{decorations:t=>{const e=this.storage.insertionPoints,n=[];return Object.entries(e).forEach(([,r])=>{const s=r;s.active&&n.push(Ut.widget(s.position,()=>{const i=wu.get(s.id);if(i)return i;const o=document.createElement("span");o.className="inline-insertion-indicator";const c=document.createElement("span");c.className="inline-insertion-spinner";const d=document.createElement("div");d.className="bounce1";const f=document.createElement("div");f.className="bounce2";const h=document.createElement("div");return c.appendChild(d),c.appendChild(f),c.appendChild(h),o.appendChild(c),wu.set(s.id,o),o},{id:`insertion-${s.id}`}))}),Ot.create(t.doc,n)}}})]}}),g5=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],sb=Lt.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:g5,attributes:{pendingStatus:{default:null,parseHTML:t=>t.getAttribute("data-pending-status")||null,renderHTML:t=>t.pendingStatus?{"data-pending-status":t.pendingStatus}:{}},pendingOriginalContent:{default:null,rendered:!1},pendingSelectionFrom:{default:null,rendered:!1},pendingSelectionTo:{default:null,rendered:!1},pendingOriginalFrom:{default:null,rendered:!1},pendingOriginalTo:{default:null,rendered:!1},pendingGroupId:{default:null,rendered:!1},pendingOrphan:{default:null,rendered:!1},pendingStaleBaseline:{default:null,rendered:!1}}}]}}),v5=xn.create({name:"footnoteReference",group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{label:{default:"",parseHTML:t=>t.getAttribute("data-label")||"",renderHTML:t=>({"data-label":t.label})}}},parseHTML(){return[{tag:"sup.footnote-ref",getAttrs:t=>{const e=t.getAttribute("data-label");return e?{label:e}:!1}}]},renderHTML({HTMLAttributes:t}){return["sup",Bt({class:"footnote-ref"},t)]},addKeyboardShortcuts(){return{"Mod-Shift-f":()=>(vT(this.editor),!0)}}}),b5=xn.create({name:"footnoteSection",group:"block",content:"footnoteDefinition+",defining:!0,isolating:!0,addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:"section.footnotes"}]},renderHTML({HTMLAttributes:t}){return["section",Bt({class:"footnotes"},t),0]}}),y5=xn.create({name:"footnoteDefinition",group:"block",content:"paragraph+",defining:!0,isolating:!0,addAttributes(){return{id:{default:null},label:{default:"",parseHTML:t=>t.getAttribute("data-label")||"",renderHTML:t=>({"data-label":t.label})}}},parseHTML(){return[{tag:"div.footnote-def",getAttrs:t=>{const e=t.getAttribute("data-label");return e?{label:e}:!1}}]},renderHTML({HTMLAttributes:t}){return["div",Bt({class:"footnote-def"},t),0]}});function vT(t){const{state:e}=t,{schema:n,doc:r}=e,s=n.nodes.footnoteReference,i=n.nodes.footnoteSection,o=n.nodes.footnoteDefinition,c=n.nodes.paragraph;if(!s||!i||!o||!c)return;const d=new Set;r.descendants(j=>{(j.type.name==="footnoteReference"||j.type.name==="footnoteDefinition")&&j.attrs.label&&d.add(String(j.attrs.label))});let f=1;for(;d.has(String(f));)f++;const h=String(f);let m=-1,g=null;r.forEach((j,M)=>{j.type.name==="footnoteSection"&&(m=M,g=j)});const v=o.create({label:h},c.create()),x=s.create({label:h}),k=e.selection.to,w=e.tr;w.insert(k,x);let S;if(m>=0&&g){const j=x.nodeSize,_=(k<=m?m+j+g.nodeSize:m+g.nodeSize)-1;w.insert(_,v),S=_+2}else{const j=i.create(null,v),M=w.doc.content.size;w.insert(M,j),S=M+3}const N=Math.min(S,w.doc.content.size);w.setSelection(lt.near(w.doc.resolve(N))),w.scrollIntoView(),t.view.dispatch(w),t.view.focus()}function x5({node:t,deleteNode:e}){return l.jsxs(qD,{as:"div",className:"tweet-image-card",draggable:!0,"data-drag-handle":!0,children:[l.jsx("img",{className:"tweet-image-card-img",src:t.attrs.src,alt:t.attrs.alt||"",draggable:!1}),l.jsx("button",{className:"tweet-image-card-remove",onClick:e,title:"Remove image",contentEditable:!1,children:"×"})]})}const w5=$v.extend({addNodeView(){return QD(x5)}}),k5=f5(u5),ib=MP.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),target:{default:null}}},renderHTML({HTMLAttributes:t}){var r;const{target:e,...n}=t;if((r=n.href)!=null&&r.startsWith("doc:")){const{href:s,...i}=n;return["span",{...i,"data-doc":s.slice(4),class:"doc-link"},0]}return["a",Bt(this.options.HTMLAttributes,n),0]}}),S5=[Zv.configure({codeBlock:!1,link:!1,underline:!1}),H6.configure({lowlight:k5}),ib.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),J_,e6,rP,n4,s4,k3,w3.configure({nested:!0}),$v,Z3,L_.configure({resizable:!1}),I_,O_,R_,tb,nb,rb,sb,v5,b5,y5,ef.configure({placeholder:"Start writing..."}),Qv.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","tableRow","tableHeader","tableCell","taskList","taskItem","image","imageLoading","footnoteSection","footnoteDefinition"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],E5=[Zv.configure({codeBlock:!1,horizontalRule:!0,heading:{levels:[1,2,3]},link:!1,underline:!1}),ib.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),$v,tb,nb,rb,sb,ef.configure({placeholder:"Start writing..."}),Qv.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image","imageLoading","horizontalRule"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],N5=Lt.create({name:"tweetEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>{const{state:t}=this.editor,{$from:e}=t.selection,n=e.pos,r=n>0?t.doc.resolve(n).nodeBefore:null;if((r==null?void 0:r.type.name)==="hardBreak"){const{tr:s}=t;return s.delete(n-r.nodeSize,n),s.split(s.mapping.map(n)),this.editor.view.dispatch(s),!0}return this.editor.commands.setHardBreak()}}}}),bT=[Zv.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),ib.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),w5,tb,nb,rb,sb,N5,Qv.configure({types:["paragraph","image","imageLoading"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...bT,ef.configure({placeholder:"What is happening?!"})];function Wr({onClick:t,active:e,disabled:n,title:r,children:s}){return l.jsx("button",{className:`floating-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function ak(){return l.jsx("div",{className:"floating-toolbar__divider"})}function C5({editor:t}){const[e,n]=y.useState(!1),[r,s]=y.useState({top:0,left:0}),[,i]=y.useState(0),o=y.useRef(-1),c=y.useRef(-1),d=y.useRef(!1);return y.useEffect(()=>{const f=t.view.dom,h=()=>{d.current=!0},m=()=>{if(!d.current)return;d.current=!1;const{from:g,to:v}=t.state.selection,x=g!==v&&t.state.selection.node;if(g!==v&&!x){const k=t.isActive("codeBlock"),w=!!document.querySelector(".context-menu");if(!k&&!w){o.current=g,c.current=v;const S=t.view.coordsAtPos(g),N=t.view.coordsAtPos(v,1),j=(S.left+N.right)/2;s({top:S.top,left:j}),n(!0)}}};return f.addEventListener("mousedown",h),document.addEventListener("mouseup",m),()=>{f.removeEventListener("mousedown",h),document.removeEventListener("mouseup",m)}},[t]),y.useEffect(()=>{const f=()=>{d.current=!1,n(!1),o.current=-1,c.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),y.useEffect(()=>{const f=()=>{const{from:h,to:m}=t.state.selection,g=h===m,v=t.isActive("codeBlock"),x=!!document.querySelector(".context-menu"),k=t.view.hasFocus(),w=!g&&t.state.selection.node;if(g||w||v||x||!k)n(!1),o.current=-1,c.current=-1;else if(!d.current&&(n(!0),h!==o.current||m!==c.current)){o.current=h,c.current=m;const S=t.view.coordsAtPos(h),N=t.view.coordsAtPos(m,1),j=(S.left+N.right)/2;s({top:S.top,left:j})}i(S=>S+1)};return t.on("transaction",f),()=>{t.off("transaction",f)}},[t]),e?l.jsxs("div",{className:"floating-toolbar",style:{position:"fixed",top:r.top,left:r.left,transform:"translate(-50%, -100%) translateY(-8px)",zIndex:1500},children:[l.jsx(Wr,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})})}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),l.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),l.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),l.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),l.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),l.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),l.jsx(Wr,{onClick:()=>{const f=t.getAttributes("link").href||"",h=window.prompt("Link URL:",f);h!==null&&(h===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:h}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),l.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),l.jsx(ak,{}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 12h8"}),l.jsx("path",{d:"M4 18V6"}),l.jsx("path",{d:"M12 18V6"}),l.jsx("path",{d:"m17 12 3-2v8"})]})}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 12h8"}),l.jsx("path",{d:"M4 18V6"}),l.jsx("path",{d:"M12 18V6"}),l.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 12h8"}),l.jsx("path",{d:"M4 18V6"}),l.jsx("path",{d:"M12 18V6"}),l.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),l.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),l.jsx(ak,{}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M3 12h.01"}),l.jsx("path",{d:"M3 18h.01"}),l.jsx("path",{d:"M3 6h.01"}),l.jsx("path",{d:"M8 12h13"}),l.jsx("path",{d:"M8 18h13"}),l.jsx("path",{d:"M8 6h13"})]})}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M11 12h9"}),l.jsx("path",{d:"M11 18h9"}),l.jsx("path",{d:"M11 6h9"}),l.jsx("path",{d:"M4 10V4h1"}),l.jsx("path",{d:"M4 10h2"}),l.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),l.jsx(Wr,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M17 6H3"}),l.jsx("path",{d:"M21 12H8"}),l.jsx("path",{d:"M21 18H8"}),l.jsx("path",{d:"M3 12v6"})]})}),l.jsx(Wr,{onClick:()=>vT(t),title:"Footnote (Ctrl+Shift+F)",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 6h12"}),l.jsx("path",{d:"M4 12h12"}),l.jsx("path",{d:"M4 18h8"}),l.jsx("text",{x:"18",y:"9",fontSize:"9",fontWeight:"bold",stroke:"none",fill:"currentColor",children:"N"})]})})]}):null}const _5=new qt("pendingDecoration");let yT=null,xT=null;function lk(t,e){yT=t,xT=e??null}let Od=!1,wT=null,ob=null,kT=null;function ab(){return Od}function T5(){return ob}function j5(){return kT}function ul(t,e,n,r){Od=t,wT=t?e??null:null,ob=t?r??null:null,kT=t?n??null:null}function M5(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function ck(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const o=t.child(i);if(o.isText){if(r+o.text.length>=n)return s+(n-r);r+=o.text.length,s+=o.nodeSize}else{const c=o.type.name==="hardBreak"?1:o.type.spec.leafText?o.type.spec.leafText(o).length:0;if(c>0&&r+c>=n)return s;r+=c,s+=o.nodeSize}}return n===r?s:null}function uk(t){const e=[];return t.descendants((n,r)=>{var w,S,N,j,M,_,R,L,$;const s=(w=n.attrs)==null?void 0:w.pendingStatus;if(!s)return!0;const i=(S=n.attrs)==null?void 0:S.id,o=(N=n.attrs)==null?void 0:N.pendingGroupId,c=o&&o===xT,f=Od&&i===wT||o&&Od&&o===ob,h=f?(j=n.attrs)==null?void 0:j.pendingOriginalFrom:(M=n.attrs)==null?void 0:M.pendingSelectionFrom,m=f?(_=n.attrs)==null?void 0:_.pendingOriginalTo:(R=n.attrs)==null?void 0:R.pendingSelectionTo,g=h!=null&&m!=null,v=f?"pending-original":M5(s),x=[];(L=n.attrs)!=null&&L.pendingOrphan&&x.push("pending-orphan"),($=n.attrs)!=null&&$.pendingStaleBaseline&&x.push("pending-stale");const k=v+(x.length?" "+x.join(" "):"");if(g&&n.isTextblock&&k){const B=ck(n,r,h),F=ck(n,r,m);B!==null&&F!==null&&B<F&&e.push(Ut.inline(B,F,{class:k}))}else k&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(Ut.inline(r+1,r+n.nodeSize-1,{class:k})):e.push(Ut.node(r,r+n.nodeSize,{class:k})));if(i&&(i===yT||c)){const B=f?"original":s;e.push(Ut.node(r,r+n.nodeSize,{class:`pending-active pending-active--${B}`}))}return!0}),Ot.create(t,e)}function ST(){return new $t({key:_5,state:{init(t,e){return uk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?uk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function lb(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const A5=new qt("commentDecoration");let oa=[];function dk(t){oa=t}function $u(){return oa}function ET(t){return{class:"ow-comment","data-comment-id":t.id}}function fk(t,e,n){const s=e.textContent.indexOf(t.text);if(s===-1)return null;const i=aa(e,n,s),o=aa(e,n,s+t.text.length);return i===null||o===null||i>=o?null:Ut.inline(i,o,ET(t))}function R5(t,e){const n=t.nodeIds,r=t.text.split(`
204
+ `),s=ET(t),i=[];if(r.length===n.length)for(let o=0;o<n.length;o++){const c=r[o];if(!c)continue;const d=e.get(n[o]);if(!d)continue;const h=d.node.textContent.indexOf(c);if(h===-1)continue;const m=aa(d.node,d.pos,h),g=aa(d.node,d.pos,h+c.length);m!==null&&g!==null&&m<g&&i.push(Ut.inline(m,g,s))}else{let o=0;for(const c of n){if(o>=r.length)break;const d=e.get(c);if(!d)continue;const f=r[o];if(!f){o++;continue}const m=d.node.textContent.indexOf(f);if(m===-1)continue;const g=aa(d.node,d.pos,m),v=aa(d.node,d.pos,m+f.length);g!==null&&v!==null&&g<v&&(i.push(Ut.inline(g,v,s)),o++)}}return i}function hk(t){if(oa.length===0)return Ot.empty;const e=[],n=new Set,r=new Map;t.descendants((i,o)=>{var c;return i.isTextblock&&((c=i.attrs)!=null&&c.id)&&r.set(i.attrs.id,{node:i,pos:o}),!0});for(const i of oa)if(i.nodeIds&&i.nodeIds.length>1){const o=R5(i,r);o.length>0&&(n.add(i.id),e.push(...o))}for(const i of oa){if(n.has(i.id))continue;const o=r.get(i.nodeId);if(!o)continue;const c=fk(i,o.node,o.pos);c&&(n.add(i.id),e.push(c))}const s=oa.filter(i=>!n.has(i.id));return s.length>0&&t.descendants((i,o)=>{if(!i.isTextblock)return!0;for(const c of s){if(n.has(c.id))continue;const d=fk(c,i,o);d&&(n.add(c.id),e.push(d))}return!0}),Ot.create(t,e)}function aa(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const o=t.child(i);if(o.isText){if(r+o.text.length>=n)return s+(n-r);r+=o.text.length,s+=o.nodeSize}else{const c=o.type.spec.leafText?o.type.spec.leafText(o).length:0;if(c>0&&r+c>=n)return s;r+=c,s+=o.nodeSize}}return n===r?s:null}function NT(){return new $t({key:A5,state:{init(t,e){return hk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceCommentUpdate")?hk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function pk(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceCommentUpdate",!0);n(r)}const O5=new qt("backlinkDecoration");let Id=[];function mk(t){Id=Array.isArray(t)?t:[]}function I5(t){const e=new Map;for(const n of t){if(!n.to_node)continue;const r=e.get(n.to_node)??[];r.push(n),e.set(n.to_node,r)}return e}function gk(t){if(Id.length===0)return Ot.empty;const e=I5(Id);if(e.size===0)return Ot.empty;const n=[];return t.descendants((r,s)=>{var c;if(!r.isTextblock)return!0;const i=(c=r.attrs)==null?void 0:c.id;if(!i)return!0;const o=e.get(i);return o&&n.push(Ut.node(s,s+r.nodeSize,{class:"linked-paragraph","data-backlinks-count":String(o.length),"data-backlinks-node":i})),!0}),Ot.create(t,n)}function L5(){return new $t({key:O5,state:{init(t,e){return gk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceBacklinkUpdate")?gk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function D5(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceBacklinkUpdate",!0);n(r)}function P5(t){return Id.filter(e=>e.to_node===t)}const B5=new qt("attributionDecoration");let CT={},_T=!1;function vk(t){CT=t&&typeof t=="object"?t:{}}function $5(t){_T=t}function bk(t){if(!_T)return Ot.empty;const e=[];return t.descendants((n,r)=>{var o;if(!n.isTextblock)return!0;const s=(o=n.attrs)==null?void 0:o.id;if(!s)return!0;const i=CT[s]??"unknown";return e.push(Ut.node(r,r+n.nodeSize,{class:`attr-block attr-${i}`,"data-attr-origin":i})),!0}),Ot.create(t,e)}function F5(){return new $t({key:B5,state:{init(t,e){return bk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceAttributionUpdate")?bk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function yk(t){if(!t)return;const{state:e,dispatch:n}=t;n(e.tr.setMeta("forceAttributionUpdate",!0))}const cb=new WeakMap;function z5(t,e){cb.set(t,e)}async function TT(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json(),i=cb.get(e);if(!i||i.getPreviewImages().length>=4)return;i.addToPreview(s)}catch{}}async function U5(t,e){try{const n=await fetch("/api/download-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!n.ok)return;const{src:r}=await n.json(),s=cb.get(e);if(!s||s.getPreviewImages().length>=4)return;s.addToPreview(r)}catch{}}function H5(t){const e=[],n=/<img[^>]+src=["']([^"']+)["']/gi;let r;for(;(r=n.exec(t))!==null;){const s=r[1];(s.startsWith("http://")||s.startsWith("https://"))&&e.push(s)}return e}function jT(t,e){var s,i;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n)return!1;for(const o of n)if(o.type.startsWith("image/")){e.preventDefault();const c=o.getAsFile();return c&&TT(c,t),!0}const r=(i=e.clipboardData)==null?void 0:i.getData("text/html");if(r){const o=H5(r);if(o.length>0){e.preventDefault();for(const c of o)U5(c,t);return!0}}return!1}function MT(t,e){var r;const n=(r=e.dataTransfer)==null?void 0:r.files;if(!(n!=null&&n.length))return!1;for(const s of n)if(s.type.startsWith("image/"))return e.preventDefault(),TT(s,t),!0;return!1}const W5=["<!--StartFragment-->","<span"," style="," class="];function V5(t){return W5.some(e=>t.includes(e))||/<p[^>]*>\s*(<br\s*\/?>)?\s*<\/p>/i.test(t)}function q5(t){var i;if(!V5(t))return t;const e=t.match(/<!--StartFragment-->([\s\S]*?)<!--EndFragment-->/),n=e?e[1]:t,r=new DOMParser().parseFromString(`<div>${n}</div>`,"text/html"),s=r.body.firstChild;if(!s)return n;for(const o of Array.from(s.querySelectorAll("span"))){const c=o.getAttribute("style")||"",d=/font-weight:\s*(bold|[6-9]00)/i.test(c),f=/font-style:\s*italic/i.test(c),h=/text-decoration:[^;]*underline/i.test(c);if(d||f||h){let m=o.innerHTML;d&&(m=`<strong>${m}</strong>`),f&&(m=`<em>${m}</em>`),h&&(m=`<u>${m}</u>`);const g=r.createElement("div");g.innerHTML=m,o.replaceWith(...Array.from(g.childNodes))}else o.replaceWith(...Array.from(o.childNodes))}for(const o of Array.from(s.querySelectorAll("*")))o.removeAttribute("style"),o.removeAttribute("class"),o.removeAttribute("id");for(const o of Array.from(s.querySelectorAll("p"))){const c=(o.textContent||"").replace(/ /g,"").trim(),d=o.children.length===1&&((i=o.firstElementChild)==null?void 0:i.tagName)==="BR";!c&&(o.children.length===0||d)&&o.remove()}return s.innerHTML}const xk=/^[a-f0-9]{8}$/;function AT(t){if(!t.startsWith("doc:"))return null;const e=t.slice(4);let n=e,r=null;const s=e.indexOf("?q=");if(s>=0){n=e.slice(0,s);try{r=decodeURIComponent(e.slice(s+3))}catch{r=e.slice(s+3)}}let i=null;const o=n.indexOf("#");if(o>=0){const d=n.slice(o+1);i=xk.test(d)?d:null,n=n.slice(0,o)}const c=xk.test(n);return{docId:c?n:null,filename:c?null:n,nodeId:i,quote:r}}function Ap(t){const e=t.docId||t.filename;if(!e)throw new Error("formatLinkHref: docId or filename required");let n=`doc:${e}`;return t.nodeId&&(n+=`#${t.nodeId}`),t.quote&&(n+=`?q=${encodeURIComponent(t.quote)}`),n}function K5(t){const e=AT(t);return e?e.docId||e.filename:null}function tl({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:s}){const i=y.useRef(s);i.current=s;const o=r_({extensions:e||S5,content:t||"<p></p>",onUpdate:({editor:d})=>{ab()||n==null||n(d.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:jT,handleDrop:MT,transformPastedHTML:q5}},[]),c=y.useRef(t);return y.useEffect(()=>{if(!o||!t||c.current===t)return;c.current=t;const d=performance.now();o.commands.setContent(t,{emitUpdate:!1});const f=performance.now(),h=window.__lastSwitch;h&&h.tClick?console.log(`[Editor] setContent t=${f.toFixed(0)} duration=${(f-d).toFixed(1)}ms fromClick=${(f-h.tClick).toFixed(1)}ms fromReceive=${h.tReceive?(f-h.tReceive).toFixed(1):"?"}ms`):console.log(`[Editor] setContent t=${f.toFixed(0)} duration=${(f-d).toFixed(1)}ms (no matching switch)`)},[o,t]),y.useEffect(()=>{o&&console.log(`[Editor] first mount t=${performance.now().toFixed(0)}`)},[o]),y.useEffect(()=>{if(!o)return;const d=o.view.dom,f=h=>{var k;const m=h.target,g=m.closest("span.doc-link[data-doc]");if(g){const w=g.getAttribute("data-doc"),S=AT(`doc:${w}`);if(!S)return;(k=i.current)==null||k.call(i,S);return}const v=m.closest("a[href]");if(!v)return;const x=v.getAttribute("href")||"";/^(https?:|mailto:|tel:)/i.test(x)&&(h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),window.open(x,"_blank","noopener,noreferrer")))};return d.addEventListener("click",f,!0),()=>d.removeEventListener("click",f,!0)},[o]),y.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="pendingDecoration$"))return;const f=ST(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),y.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="commentDecoration$"))return;const f=NT(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),y.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="backlinkDecoration$"))return;const f=L5(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),y.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="attributionDecoration$"))return;const f=F5(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),y.useEffect(()=>{o&&(r==null||r(o))},[o,r]),o?l.jsxs(l.Fragment,{children:[l.jsx(Pv,{editor:o}),l.jsx(C5,{editor:o})]}):null}function En({onClick:t,active:e,disabled:n,title:r,children:s}){return l.jsx("button",{className:`format-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function Qo(){return l.jsx("div",{className:"format-toolbar__divider"})}async function G5(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json();e.chain().focus().setImage({src:s,alt:t.name}).run()}catch{}}function J5({editor:t}){const[,e]=y.useState(0),n=y.useRef(null);y.useEffect(()=>{const s=()=>e(i=>i+1);return t.on("transaction",s),()=>{t.off("transaction",s)}},[t]);const r=s=>{var o;const i=(o=s.target.files)==null?void 0:o[0];i&&G5(i,t),s.target.value=""};return l.jsxs("div",{className:"format-toolbar",children:[l.jsxs("div",{className:"format-toolbar__group",children:[l.jsx(En,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),l.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),l.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),l.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),l.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),l.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline Code",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"m16 18 6-6-6-6"}),l.jsx("path",{d:"m8 6-6 6 6 6"})]})})]}),l.jsx(Qo,{}),l.jsxs("div",{className:"format-toolbar__group",children:[l.jsx(En,{onClick:()=>t.chain().focus().toggleHighlight().run(),active:t.isActive("highlight"),title:"Highlight",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),l.jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"m4 5 8 8"}),l.jsx("path",{d:"m12 5-8 8"}),l.jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"m4 19 8-8"}),l.jsx("path",{d:"m12 19-8-8"}),l.jsx("path",{d:"M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})})]}),l.jsx(Qo,{}),l.jsxs("div",{className:"format-toolbar__group",children:[l.jsx(En,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 12h8"}),l.jsx("path",{d:"M4 18V6"}),l.jsx("path",{d:"M12 18V6"}),l.jsx("path",{d:"m17 12 3-2v8"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 12h8"}),l.jsx("path",{d:"M4 18V6"}),l.jsx("path",{d:"M12 18V6"}),l.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 12h8"}),l.jsx("path",{d:"M4 18V6"}),l.jsx("path",{d:"M12 18V6"}),l.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),l.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().setParagraph().run(),active:t.isActive("paragraph")&&!t.isActive("heading"),title:"Paragraph",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M13 4v16"}),l.jsx("path",{d:"M17 4v16"}),l.jsx("path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13"})]})})]}),l.jsx(Qo,{}),l.jsxs("div",{className:"format-toolbar__group",children:[l.jsx(En,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M3 12h.01"}),l.jsx("path",{d:"M3 18h.01"}),l.jsx("path",{d:"M3 6h.01"}),l.jsx("path",{d:"M8 12h13"}),l.jsx("path",{d:"M8 18h13"}),l.jsx("path",{d:"M8 6h13"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M11 12h9"}),l.jsx("path",{d:"M11 18h9"}),l.jsx("path",{d:"M11 6h9"}),l.jsx("path",{d:"M4 10V4h1"}),l.jsx("path",{d:"M4 10h2"}),l.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleTaskList().run(),active:t.isActive("taskList"),title:"Task List",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"m3 17 2 2 4-4"}),l.jsx("path",{d:"m3 7 2 2 4-4"}),l.jsx("path",{d:"M13 6h8"}),l.jsx("path",{d:"M13 12h8"}),l.jsx("path",{d:"M13 18h8"})]})})]}),l.jsx(Qo,{}),l.jsx("div",{className:"format-toolbar__group",children:l.jsx(En,{onClick:()=>{const s=t.getAttributes("link").href||"",i=window.prompt("Link URL:",s);i!==null&&(i===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:i}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),l.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}),l.jsx(Qo,{}),l.jsxs("div",{className:"format-toolbar__group",children:[l.jsx(En,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M17 6H3"}),l.jsx("path",{d:"M21 12H8"}),l.jsx("path",{d:"M21 18H8"}),l.jsx("path",{d:"M3 12v6"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),active:t.isActive("codeBlock"),title:"Code Block",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),l.jsx("path",{d:"m10 9-3 3 3 3"}),l.jsx("path",{d:"m14 15 3-3-3-3"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:l.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M5 12h14"})})})]}),l.jsx(Qo,{}),l.jsxs("div",{className:"format-toolbar__group",children:[l.jsx(En,{onClick:()=>{var s;return(s=n.current)==null?void 0:s.click()},title:"Insert Image",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),l.jsx("circle",{cx:"9",cy:"9",r:"2"}),l.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),l.jsx(En,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table",children:l.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),l.jsx("path",{d:"M12 3v18"}),l.jsx("path",{d:"M3 9h18"}),l.jsx("path",{d:"M3 15h18"})]})})]}),l.jsx("input",{ref:n,type:"file",accept:"image/*",className:"format-toolbar__file-input",onChange:r})]})}const Nn={strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round"},Y5=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",...Nn}),l.jsx("path",{d:"M21 12c0 4.97-4.03 9-9 9s-9-4.03-9-9 4.03-9 9-9c2.3 0 4.4.86 6 2.27",stroke:"currentColor",...Nn})]}),X5=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",...Nn}),l.jsx("path",{d:"M12 7v5l3 3",stroke:"currentColor",...Nn})]}),Q5=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:l.jsx("path",{d:"M4 10v4M8 6v12M12 9v6M16 4v16M20 10v4",stroke:"currentColor",...Nn})}),Z5=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:"currentColor",...Nn}),l.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:"currentColor",...Nn})]}),e$=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",stroke:"currentColor",...Nn}),l.jsx("polyline",{points:"7 10 12 15 17 10",stroke:"currentColor",...Nn}),l.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3",stroke:"currentColor",...Nn})]}),t$=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:l.jsx("path",{d:"M3 12h3l3-8 4 16 3-8h5",stroke:"currentColor",...Nn})}),n$=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M12 22v-5",stroke:"currentColor",...Nn}),l.jsx("path",{d:"M9 8V2",stroke:"currentColor",...Nn}),l.jsx("path",{d:"M15 8V2",stroke:"currentColor",...Nn}),l.jsx("path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",stroke:"currentColor",...Nn})]}),r$=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("circle",{cx:"12",cy:"5",r:"3",stroke:"currentColor",...Nn}),l.jsx("circle",{cx:"5",cy:"19",r:"3",stroke:"currentColor",...Nn}),l.jsx("circle",{cx:"19",cy:"19",r:"3",stroke:"currentColor",...Nn}),l.jsx("line",{x1:"12",y1:"8",x2:"5",y2:"16",stroke:"currentColor",...Nn}),l.jsx("line",{x1:"12",y1:"8",x2:"19",y2:"16",stroke:"currentColor",...Nn})]}),s$=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",stroke:"currentColor",...Nn}),l.jsx("circle",{cx:"13.5",cy:"6.5",r:"1",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"17.5",cy:"10.5",r:"1",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"6.5",cy:"12.5",r:"1",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"8.5",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]}),RT=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:l.jsx("path",{d:"M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),i$=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M15 3v18",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M9 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),o$=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M15 3v18",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M10 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function a$({title:t,onTitleChange:e,onToggleSidebar:n,canGoBack:r,canGoForward:s,onGoBack:i,onGoForward:o,editor:c,onToggleToolbar:d,toolbarOpen:f,focusMode:h,onToggleFocusMode:m}){const{visible:g,openTab:v,activeTab:x}=Bl(),[k,w]=y.useState(!1),[,S]=y.useState(0),N=y.useRef(null),[j,M]=y.useState(null);y.useEffect(()=>{fetch("/api/update-info").then($=>$.json()).then($=>{$.updateAvailable&&M({currentVersion:$.currentVersion,latestVersion:$.updateAvailable,updateCommand:$.updateCommand||"npm update -g openwriter"})}).catch(()=>{})},[]);const _=y.useCallback(()=>{w(!0),setTimeout(()=>{var $;return($=N.current)==null?void 0:$.select()},0)},[]),R=y.useCallback(()=>{w(!1)},[]),L=y.useCallback($=>{$.key==="Enter"&&w(!1),$.key==="Escape"&&w(!1)},[]);return y.useEffect(()=>{if(!c)return;const $=()=>S(B=>B+1);return c.on("transaction",$),()=>{c.off("transaction",$)}},[c]),l.jsxs("div",{className:"titlebar",children:[l.jsxs("div",{className:"titlebar-left",children:[n&&l.jsx("button",{className:"titlebar-menu-btn",onClick:n,title:"Open sidebar",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M14 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),i&&l.jsx("button",{className:"titlebar-nav-btn",onClick:i,disabled:!r,title:"Go back (Alt+Left)",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),o&&l.jsx("button",{className:"titlebar-nav-btn",onClick:o,disabled:!s,title:"Go forward (Alt+Right)",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),c&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"titlebar-divider"}),l.jsx("button",{className:"titlebar-nav-btn",onClick:()=>c.chain().focus().undo().run(),disabled:!c.can().undo(),title:"Undo (Ctrl+Z)",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M3 10h10a5 5 0 0 1 0 10H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M7 6L3 10l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),l.jsx("button",{className:"titlebar-nav-btn",onClick:()=>c.chain().focus().redo().run(),disabled:!c.can().redo(),title:"Redo (Ctrl+Y)",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M21 10H11a5 5 0 0 0 0 10h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M17 6l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),l.jsxs("div",{className:"titlebar-center",children:[k?l.jsx("input",{ref:N,className:"titlebar-input",value:t,onChange:$=>e($.target.value),onBlur:R,onKeyDown:L,autoFocus:!0}):l.jsx("span",{className:"titlebar-title",onDoubleClick:_,children:t}),j&&l.jsxs("span",{className:"titlebar-update-badge",title:`Update available: v${j.currentVersion} → v${j.latestVersion}
205
+ Run: ${j.updateCommand}`,children:["v",j.latestVersion]})]}),l.jsxs("div",{className:"titlebar-right",children:[!g&&m&&l.jsx("button",{className:`titlebar-nav-btn${h?" titlebar-nav-btn--active":""}`,onClick:m,title:"Focus mode","aria-label":"Focus mode","aria-pressed":h,children:l.jsx(RT,{})}),!g&&d&&l.jsx("button",{className:`titlebar-nav-btn${f?" titlebar-nav-btn--active":""}`,onClick:d,title:"Toggle format toolbar","aria-label":"Toggle format toolbar","aria-pressed":f,children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 20h16"}),l.jsx("path",{d:"m6 16 6-12 6 12"}),l.jsx("path",{d:"M8 12h8"})]})}),!g&&l.jsx("button",{className:"titlebar-nav-btn",onClick:()=>v(x||"activity"),title:"Show right rail","aria-label":"Show right rail",children:l.jsx(o$,{})})]})]})}const wk="ow-update-dismissed";function l$(){const[t,e]=y.useState(null);if(y.useEffect(()=>{fetch("/api/update-info").then(r=>r.json()).then(r=>{if(!r.updateAvailable)return;let s="";try{s=localStorage.getItem(wk)||""}catch{}s!==r.updateAvailable&&e({currentVersion:r.currentVersion,latestVersion:r.updateAvailable,updateCommand:r.updateCommand||"npm update -g openwriter"})}).catch(()=>{})},[]),!t)return null;const n=()=>{try{localStorage.setItem(wk,t.latestVersion)}catch{}e(null)};return l.jsxs("div",{className:"editor-update-banner",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"editor-update-dot","aria-hidden":"true"}),l.jsxs("span",{children:["OpenWriter ",l.jsxs("strong",{children:["v",t.latestVersion]})," is available"," ","(you're on v",t.currentVersion,") — update with"," ",l.jsx("code",{className:"editor-update-cmd",children:t.updateCommand})]}),l.jsx("button",{type:"button",className:"editor-update-dismiss",onClick:n,"aria-label":"Dismiss update notification",children:"×"})]})}function Wn(t,e){let n=null;return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function nf(t,e){const n=[];return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.pendingGroupId)===e&&n.push({nodeId:r.attrs.id,pos:s,node:r}),!0}),n}function ua(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function Ld(t){return t?Array.isArray(t)?t.map(Ld).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>Ld(e)).join(""):"":""}const c$=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function Dd(t,e){for(const n of t)n.type&&c$.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&Dd(n.content,e)}function Qg(t,e,n,r){const s=Array.isArray(n)?n:[n],i=(r==null?void 0:r.autoAccept)===!0;if(e.nodeId&&!e.afterNodeId&&!e.beforeNodeId){const m=Wn(t,e.nodeId);if(!m)return{success:!1,error:`Node ${e.nodeId} not found`};const g=s.map((v,x)=>{var k;return{...v,attrs:{...v.attrs,id:((k=v.attrs)==null?void 0:k.id)||(x===0?e.nodeId:ua())}}});i||Dd(g,"insert");try{return t.chain().deleteRange({from:m.pos,to:m.pos+m.node.nodeSize}).insertContentAt(m.pos,g).run(),{success:!0,nodeId:e.nodeId}}catch(v){return{success:!1,error:`Failed to replace empty node: ${v}`}}}if(!e.afterNodeId&&!e.beforeNodeId)return{success:!1,error:"Insert requires afterNodeId, beforeNodeId, or nodeId"};const o=e.afterNodeId||e.beforeNodeId,c=!!e.afterNodeId,d=Wn(t,o);if(!d)return{success:!1,error:`Anchor node ${o} not found`};if(!i){const m=Ld(n),g=c?d.pos+d.node.nodeSize:0,v=c?d.pos+d.node.nodeSize+5e3:d.pos;let x=null;if(t.state.doc.nodesBetween(g,Math.min(v,t.state.doc.content.size),k=>{var w,S;return((w=k.attrs)==null?void 0:w.pendingStatus)==="insert"&&((S=k.attrs)!=null&&S.id)&&(k.textContent||"")===m?(x=k.attrs.id,!1):!0}),x)return{success:!0,nodeId:x}}const f=s.map(m=>{var g;return{...m,attrs:{...m.attrs,id:((g=m.attrs)==null?void 0:g.id)||ua()}}});i||Dd(f,"insert");const h=c?d.pos+d.node.nodeSize:d.pos;try{return t.chain().insertContentAt(h,f).run(),{success:!0,nodeId:f[0].attrs.id}}catch(m){return{success:!1,error:`Failed to insert content: ${m}`}}}function ub(t,e,n,r,s){var w,S,N,j,M,_;const i=Wn(t,e);if(!i)return{success:!1,error:`Node ${e} not found`};const{node:o,pos:c}=i,d=Array.isArray(n)?n:[n],f=(s==null?void 0:s.autoAccept)===!0,m=!((w=o.attrs)!=null&&w.pendingOriginalContent)?o.toJSON():o.attrs.pendingOriginalContent,v=((S=d[0])==null?void 0:S.type)==="listItem"&&((_=(M=(j=(N=d[0])==null?void 0:N.content)==null?void 0:j[0])==null?void 0:M.attrs)==null?void 0:_.pendingStatus)!=null?{...d[0],attrs:{...d[0].attrs,id:e}}:{...d[0],attrs:f?{...d[0].attrs,id:e}:{...d[0].attrs,id:e,pendingStatus:"rewrite",pendingOriginalContent:m,...r?{pendingSelectionFrom:r.selectionFrom,pendingSelectionTo:r.selectionTo,pendingOriginalFrom:r.originalFrom,pendingOriginalTo:r.originalTo}:{}}},x=d.slice(1).map(R=>{var L;return{...R,attrs:{...R.attrs,id:((L=R.attrs)==null?void 0:L.id)||ua()}}});f||Dd(x,"insert");const k=[v,...x];try{return t.chain().command(({tr:R})=>{const L=k.map($=>t.state.schema.nodeFromJSON($));return R.replaceWith(c,c+o.nodeSize,L),!0}).run(),{success:!0,nodeId:e}}catch(R){return{success:!1,error:`Failed to rewrite: ${R}`}}}function u$(t,e,n){if(e.length===0)return{success:!1,error:"Range rewrite requires original IDs"};if(!n||n.length===0)return{success:!1,error:"Range rewrite requires new content (received empty)"};if(n.map(m=>Ld(m)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const s=Wn(t,e[0]),i=Wn(t,e[e.length-1]);if(!s||!i)return{success:!1,error:"Could not find original nodes for range rewrite"};const o=[];for(const m of e){const g=Wn(t,m);g&&o.push(g.node.toJSON())}const c=s.pos,d=i.pos+i.node.nodeSize,f=ua()+ua(),h=n.map((m,g)=>{var v;return{...m,attrs:{...m.attrs,id:((v=m.attrs)==null?void 0:v.id)||ua(),pendingStatus:"rewrite",pendingGroupId:f,...g===0?{pendingOriginalContent:o}:{}}}});try{return t.chain().deleteRange({from:c,to:d}).insertContentAt(c,h).run(),{success:!0,nodeId:h[0].attrs.id}}catch(m){return{success:!1,error:`Failed to apply range rewrite: ${m}`}}}function OT(t,e,n){var c;const r=Wn(t,e);if(!r)return{success:!1,error:`Node ${e} not found`};const{node:s,pos:i}=r,o=(n==null?void 0:n.autoAccept)===!0;if(!o&&((c=s.attrs)==null?void 0:c.pendingStatus)==="delete")return{success:!0,nodeId:e};try{return o?t.chain().deleteRange({from:i,to:i+s.nodeSize}).run():t.chain().command(({tr:d})=>(d.setNodeMarkup(i,void 0,{...s.attrs,pendingStatus:"delete"}),!0)).run(),{success:!0,nodeId:e}}catch(d){return{success:!1,error:`Failed to ${o?"delete":"mark for deletion"}: ${d}`}}}function d$(t,e){const n=e.autoAccept?{autoAccept:!0}:void 0;if(e.operation==="rewrite"&&e.nodeId&&e.content){const r=ub(t,e.nodeId,e.content,null,n);return{success:r.success,error:r.error}}if(e.operation==="insert"&&e.content){let r=null;if(e.nodeId&&!e.afterNodeId?r={nodeId:e.nodeId}:e.afterNodeId&&(r={afterNodeId:e.afterNodeId}),!r)return{success:!1,error:"Insert requires afterNodeId or nodeId"};const s=Qg(t,r,e.content,n);return{success:s.success,error:s.error}}if(e.operation==="delete"&&e.nodeId){const r=OT(t,e.nodeId,n);return{success:r.success,error:r.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function Rp(t,e){if(e.length===0)return;if(e.length===1){d$(t,e[0]);return}const n=t.state.schema;t.chain().command(({tr:r})=>{var s;for(const i of e)try{const o=i.autoAccept===!0;if(i.operation==="rewrite"&&i.nodeId&&i.content){const c=nl(r.doc,i.nodeId);if(!c){console.warn("[openwriter] rewrite skipped — node id not found in editor",{nodeId:i.nodeId});continue}const f=(Array.isArray(i.content)?i.content:[i.content]).map(h=>n.nodeFromJSON(h));r.replaceWith(c.pos,c.pos+c.node.nodeSize,f)}else if(i.operation==="insert"&&i.content){const d=(Array.isArray(i.content)?i.content:[i.content]).map(f=>n.nodeFromJSON(f));if(!o){const f=d.map(h=>h.textContent||"").join("");if(f&&i.afterNodeId){const h=nl(r.doc,i.afterNodeId);if(h){const m=h.pos+h.node.nodeSize,g=Math.min(m+5e3,r.doc.content.size);let v=!1;if(r.doc.nodesBetween(m,g,x=>{var k;return v?!1:((k=x.attrs)==null?void 0:k.pendingStatus)==="insert"&&(x.textContent||"")===f?(v=!0,!1):!0}),v)continue}}}if(i.nodeId&&!i.afterNodeId){const f=nl(r.doc,i.nodeId);if(!f){console.warn("[openwriter] insert (replace) skipped — node id not found in editor",{nodeId:i.nodeId});continue}r.replaceWith(f.pos,f.pos+f.node.nodeSize,d)}else if(i.afterNodeId){const f=nl(r.doc,i.afterNodeId);if(!f){console.warn("[openwriter] insert (after) skipped — anchor id not found in editor",{afterNodeId:i.afterNodeId});continue}const h=f.pos+f.node.nodeSize;r.insert(h,ke.fromArray(d))}}else if(i.operation==="delete"&&i.nodeId){const c=nl(r.doc,i.nodeId);if(!c){console.warn("[openwriter] delete skipped — node id not found in editor",{nodeId:i.nodeId});continue}if(o)r.delete(c.pos,c.pos+c.node.nodeSize);else{if(((s=c.node.attrs)==null?void 0:s.pendingStatus)==="delete")continue;r.setNodeMarkup(c.pos,void 0,{...c.node.attrs,pendingStatus:"delete"})}}}catch{continue}return!0}).run()}function nl(t,e){let n=null;return t.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function f$(t,e){if(!e||e.length===0||t.isDestroyed)return;const n=new Map(e.map(r=>[r.oldId,r.newId]));t.chain().command(({tr:r})=>{const s=[];r.doc.descendants((i,o)=>{var d;const c=(d=i.attrs)==null?void 0:d.id;c&&n.has(c)&&s.push({pos:o,attrs:{...i.attrs,id:n.get(c)}})});for(const{pos:i,attrs:o}of s)r.setNodeMarkup(i,void 0,o);return!0}).run()}function h$(t,e,n,r){const s=[];if(r==="delete"){for(const o of n)s.push(OT(t,o));return s}if(r==="insert"){const o=n[n.length-1];return o&&e.length>0&&s.push(Qg(t,{nodeId:o},e)),s}if(n.length>1){const o=u$(t,n,e);return s.push(o),s}const i=ub(t,n[0],e[0]);if(s.push(i),e.length>1){const o=e.slice(1);s.push(Qg(t,{afterNodeId:n[0]},o))}return s}const kk="[[START_SELECTION]]",Sk="[[END_SELECTION]]";function p$(t){if(!(t!=null&&t.content)||!Array.isArray(t.content))return 0;let e=0;for(const n of t.content)n.type==="text"&&typeof n.text=="string"?e+=n.text.length:n.type==="hardBreak"&&(e+=1);return e}function ku(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=p$(t);let s=Math.max(0,Math.min(e,r));for(let i=0;i<t.content.length;i++){const o=t.content[i];if(o.type==="text"&&typeof o.text=="string"){if(s<=o.text.length){const c=Math.max(0,Math.min(o.text.length,s));o.text=o.text.slice(0,c)+n+o.text.slice(c);return}s-=o.text.length;continue}if(o.type==="hardBreak"){if(s===0){t.content.splice(i+1,0,{type:"text",text:n});return}s-=1;continue}if(s===0){t.content.splice(i,0,{type:"text",text:n});return}}t.content.push({type:"text",text:n})}function m$(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(ku(r[0],n,Sk),ku(r[0],e,kk),r):(ku(r[0],e,kk),ku(r[r.length-1],n,Sk),r)}function g$(t){const e=r=>r.replace(/\[\[(START|END)_SELECTION]]/g,""),n=r=>{r.type==="text"&&typeof r.text=="string"&&(r.text=e(r.text)),r.content&&Array.isArray(r.content)&&r.content.forEach(n)};Array.isArray(t)?t.forEach(n):n(t)}let vi=null;function v$(){return vi&&document.body.contains(vi)||(vi=document.createElement("div"),vi.style.cssText=["position:fixed","left:50%","bottom:32px","transform:translateX(-50%)","z-index:99999","display:flex","flex-direction:column","gap:8px","align-items:center","pointer-events:none"].join(";"),document.body.appendChild(vi)),vi}function Ai(t,e="info",n=3500,r){const s=v$(),i=document.createElement("div");i.style.cssText=["background:var(--bg-surface)","border:1px solid var(--border)",e==="error"?"border-left:3px solid var(--color-pending-delete)":"","color:var(--ink-dark)","font-family:var(--font-body)","padding:10px 14px","border-radius:8px","font-size:13px","line-height:1.4","max-width:420px","box-shadow:0 4px 20px rgba(0,0,0,0.15)","pointer-events:auto","opacity:0","transition:opacity 160ms ease, transform 160ms ease","transform:translateY(6px)",r?"display:flex;align-items:center;gap:12px":""].filter(Boolean).join(";");const o=document.createElement("span");if(o.textContent=t,i.appendChild(o),r){const d=document.createElement("button");d.textContent=r.label,d.style.cssText=["flex-shrink:0","padding:4px 12px","border-radius:6px","border:1px solid var(--accent)","background:var(--accent)","color:var(--bg-surface)","font-family:var(--font-body)","font-size:12px","font-weight:600","cursor:pointer"].join(";"),d.addEventListener("click",()=>{try{r.onClick()}finally{c()}}),i.appendChild(d)}function c(){i.style.opacity="0",i.style.transform="translateY(6px)",setTimeout(()=>{i.remove(),s.childElementCount===0&&(s.remove(),vi=null)},200)}s.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"}),setTimeout(c,n)}function b$(t){return`$${(t/100).toFixed(2)}`}async function y$(){try{const t=await fetch("/api/voice/billing");return t.ok?await t.json():null}catch{return null}}async function x$(){try{const t=await fetch("/api/voice/billing/topup-options");if(!t.ok)return[];const e=await t.json();return Array.isArray(e==null?void 0:e.options)?e.options:[]}catch{return[]}}async function IT(t){try{const e=await fetch("/api/voice/billing/topup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:t})});if(!e.ok){Ai("Could not start top-up. Please try again.","error");return}const n=await e.json();n!=null&&n.url?window.open(n.url,"_blank"):Ai("Could not start top-up. Please try again.","error")}catch{Ai("Could not start top-up. Please try again.","error")}}const Ek=5e3;function Nk(t,e){return t.docId&&e.includes(t.docId)?!0:e.includes(t.filename)}const w$=[{action:"comment",label:"Comment",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function k$({editorRef:t,allEditors:e,documentId:n}){const[r,s]=y.useState(!1),[i,o]=y.useState({x:0,y:0}),[c,d]=y.useState(!1),[f,h]=y.useState(""),[m,g]=y.useState(!1),[v,x]=y.useState(""),[k,w]=y.useState(!1),[S,N]=y.useState([]),[j,M]=y.useState([]),[_,R]=y.useState(!1),[L,$]=y.useState(""),[B,F]=y.useState([]),[K,z]=y.useState(!1),[ee,P]=y.useState(""),[U,J]=y.useState(null),[ie,q]=y.useState(null),[ue,Y]=y.useState(null),[A,D]=y.useState(!1),[te,fe]=y.useState(null),[we,oe]=y.useState(null),Se=y.useRef(null),Ee=y.useRef(null),Le=y.useRef(null),Ie=y.useCallback(ne=>{if(e&&e.length>0){for(const me of e)if(me.view.dom.contains(ne))return me}const he=t.current;return he&&he.view.dom.contains(ne)?he:null},[e,t]);y.useLayoutEffect(()=>{const ne=Se.current;if(!ne||!r)return;const he=ne.getBoundingClientRect(),me=8;let{x:ze,y:Ae}=i;Ae+he.height+me>window.innerHeight&&(Ae=i.y-he.height),ze+he.width+me>window.innerWidth&&(ze=i.x-he.width),Ae<me&&(Ae=me),ze<me&&(ze=me),(ze!==i.x||Ae!==i.y)&&o({x:ze,y:Ae})},[r,i]);const Ve=y.useCallback(()=>{fetch("/api/plugins").then(ne=>ne.json()).then(ne=>{const he=[];for(const me of ne.plugins||[]){const ze=me.displayName||void 0;for(const Ae of me.contextMenuItems||[])he.push({...Ae,pluginDisplayName:ze})}F(he)}).catch(()=>{})},[]);y.useEffect(()=>{Ve()},[Ve]),y.useEffect(()=>{const ne=()=>Ve();return window.addEventListener("ow-plugins-changed",ne),()=>window.removeEventListener("ow-plugins-changed",ne)},[Ve]),y.useEffect(()=>{const ne=he=>{Se.current&&!Se.current.contains(he.target)&&(s(!1),g(!1),w(!1),z(!1),P(""),J(null),q(null),fe(null))};return document.addEventListener("mousedown",ne),()=>document.removeEventListener("mousedown",ne)},[]);const Te=y.useCallback(()=>{const ne=Le.current||t.current;return ne?ne.isActive("link"):!1},[t]),qe=y.useCallback(()=>{const ne=Le.current||t.current,he=Ee.current;if(!ne||!he)return!1;const{from:me,to:ze}=he;let Ae=!1;return ne.state.doc.nodesBetween(me,ze,Xe=>{var Qe;return(Qe=Xe.attrs)!=null&&Qe.pendingStatus&&(Ae=!0),!Ae}),Ae},[t]),pt=y.useCallback(()=>{const ne=Le.current||t.current,he=Ee.current,me=(he==null?void 0:he.from)??0,ze=(he==null?void 0:he.to)??0,Ae=me!==ze,Xe=(()=>{if(!ne)return!1;try{return ne.state.doc.resolve(me).parent.content.size===0}catch{return!1}})(),Qe=qe(),tt=[];for(const We of B)We.condition==="has-selection"&&!Ae||We.condition==="empty-node"&&!Xe||tt.push({action:We.action,label:We.label,shortcut:We.shortcut,isPlugin:!0,promptForInput:We.promptForInput,pluginDisplayName:We.pluginDisplayName});for(const We of w$)We.condition==="has-selection"&&(!Ae||Qe)||tt.push(We);if(Ae&&tt.push({action:"link",label:"Link to doc",shortcut:"L"}),Te()&&tt.push({action:"unlink",label:"Unlink"}),ue&&ue.entries.length>0&&tt.unshift({action:"see-connections",label:`See connections (${ue.entries.length})`}),te){const We=te.title?`Go to "${te.title}"`:"Go to target";tt.unshift({action:"go-to-target",label:We})}return tt},[t,Te,B,qe,ue,te]);y.useEffect(()=>{const ne=me=>{var We;if(me.button!==2)return;const ze=Ie(me.target);if(!ze)return;Le.current=ze;const{from:Ae,to:Xe}=ze.state.selection,Qe=[],tt=[];if(Ae!==Xe&&ze.state.doc.nodesBetween(Ae,Xe,Ue=>{Ue.isBlock&&Ue.type.name!=="doc"&&(Qe.push(Ue.toJSON()),Ue.attrs.id&&tt.push(Ue.attrs.id))}),Qe.length===0){const{$from:Ue}=ze.state.selection,st=Ue.parent;st&&st.type.name!=="doc"&&(Qe.push(st.toJSON()),(We=st.attrs)!=null&&We.id&&tt.push(st.attrs.id))}Ee.current={from:Ae,to:Xe,nodes:Qe,nodeIds:tt}},he=me=>{var st,mt,Nt,Mt,Jt,nn;if(!Ie(me.target)||me.shiftKey)return;const Ae=(mt=(st=me.target)==null?void 0:st.closest)==null?void 0:mt.call(st,"[data-comment-id]"),Xe=(Ae==null?void 0:Ae.getAttribute("data-comment-id"))||null,Qe=(Mt=(Nt=me.target)==null?void 0:Nt.closest)==null?void 0:Mt.call(Nt,".linked-paragraph[data-backlinks-node]"),tt=(Qe==null?void 0:Qe.getAttribute("data-backlinks-node"))||null,We=(nn=(Jt=me.target)==null?void 0:Jt.closest)==null?void 0:nn.call(Jt,"span.doc-link[data-doc]"),Ue=(We==null?void 0:We.getAttribute("data-doc"))||null;if(me.preventDefault(),o({x:me.clientX,y:me.clientY}),s(!0),g(!1),w(!1),D(!1),z(!1),P(""),J(null),Xe){const at=Ee.current;if(!(!!at&&at.from!==at.to)){const T=$u().find(W=>W.id===Xe);if(T){q({id:T.id,text:T.text,note:T.note}),Y(null);return}}}if(q(null),tt){const at=P5(tt);Y(at.length>0?{nodeId:tt,entries:at}:null)}else Y(null);if(Ue){const at=Ue.indexOf("?"),Ht=at>=0?Ue.slice(0,at):Ue,[T,W]=Ht.split("#"),ae=T&&/^[a-f0-9]{8}$/.test(T)?T:null,I=W&&/^[a-f0-9]{8}$/.test(W)?W:null;if(ae){const V=S.find(re=>re.docId===ae);fe({docId:ae,nodeId:I,title:(V==null?void 0:V.title)||null}),V||fetch("/api/documents").then(re=>re.json()).then(re=>{if(Array.isArray(re)){const X=re.map(ve=>({filename:ve.filename,title:ve.title,docId:ve.docId}));N(X);const le=X.find(ve=>ve.docId===ae);le&&fe(ve=>ve&&ve.docId===ae?{...ve,title:le.title}:ve)}}).catch(()=>{})}else fe(null)}else fe(null)};return document.addEventListener("mousedown",ne,!0),document.addEventListener("contextmenu",he),()=>{document.removeEventListener("mousedown",ne,!0),document.removeEventListener("contextmenu",he)}},[Ie]);const ut=y.useCallback(async(ne,he)=>{var mt,Nt,Mt,Jt,nn;const me=Le.current||t.current;if(!me)return;const ze=Ee.current;if(!ze||ze.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",ne);return}let{nodes:Ae,nodeIds:Xe}=ze;const{from:Qe,to:tt}=ze;d(!0),s(!1),g(!1);const We=`ctx-${Date.now()}`,Ue=ne.includes(":")?ne.split(":").slice(1).join(":"):ne,st=["insert","fill","fill-sentence"].includes(Ue);if(st)me.commands.showInsertionLoading(We,Qe);else{const at=me.state.doc.resolve(Qe),Ht=me.state.doc.resolve(tt),T=at.sameParent(Ht)&&Qe!==tt;me.commands.applyLoadingEffect(We,Qe,tt,T?"selection":"paragraph")}try{const at=[],Ht=[],T=new Set(Xe);let W=!1;const ae=me.state.doc;for(let $e=0;$e<ae.childCount;$e++){const zt=ae.child($e),qn=(mt=zt.attrs)==null?void 0:mt.id;if(qn&&T.has(qn))W=!0;else if(W){const fn=zt.textContent.trim();fn&&Ht.push(fn)}else{const fn=zt.textContent.trim();fn&&at.push(fn)}}let I=Ae,V=!1,re=0,X=0;const le=Qe!==tt?me.state.doc.resolve(Qe):null,ve=Qe!==tt?me.state.doc.resolve(tt):null;if((le&&ve?le.sameParent(ve):!1)&&le&&Ae.length===1){const $e=le.start(le.depth);re=Qe-$e,X=tt-$e;const zt=((Mt=(Nt=Ae[0])==null?void 0:Nt.content)==null?void 0:Mt.reduce((qn,fn)=>{var gr;return qn+(((gr=fn.text)==null?void 0:gr.length)||(fn.type==="hardBreak"?1:0))},0))??0;(re>0||X<zt)&&(I=m$(Ae,re,X),V=!0)}const ye=me.state.doc.textContent,Dt={nodes:I,action:Ue,nodeIds:Xe,contextBefore:at.slice(-3),contextAfter:Ht.slice(0,3),fullDocument:ye,documentId:n,debug:!0};V&&(Dt.hasSelectionMarkers=!0),he&&(Dt.instruction=he);const dn=((Ae||[]).map($e=>Array.isArray($e==null?void 0:$e.content)?$e.content.map(zt=>(zt==null?void 0:zt.text)||"").join(" "):"").join(" ").match(/\S+/g)||[]).length;if(dn>Ek){Ai(`Selection too large: ${dn.toLocaleString()} words (max ${Ek.toLocaleString()}). Select a smaller section.`,"error"),st?me.commands.removeInsertionLoading(We):me.commands.removeLoadingEffect(We);return}const Xt=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Dt)});if(!Xt.ok){const $e=await Xt.json().catch(()=>({}));console.error("[ContextMenu] API error:",Xt.status,$e);const zt=typeof($e==null?void 0:$e.message)=="string"&&$e.message||typeof($e==null?void 0:$e.error)=="string"&&$e.error||`Enhance failed (${Xt.status}). Please try again.`;Xt.status===402&&($e==null?void 0:$e.error)==="insufficient_balance"?Ai(zt,"error",9e3,{label:"Top up",onClick:()=>IT(5)}):Ai(zt,"error");return}const ln=await Xt.json();if(ln.success&&ln.nodes){let $e=ln.nodes;if($e.length===1&&Array.isArray($e[0])&&($e=$e[0]),g$($e),V&&$e.length===1&&Xe.length===1){const zt=ur=>(ur??[]).reduce((Xs,Wt)=>Xs+(typeof Wt.text=="string"?Wt.text:Wt.type==="hardBreak"?`
206
+ `:""),""),qn=zt((Jt=Ae[0])==null?void 0:Jt.content),fn=zt((nn=$e[0])==null?void 0:nn.content),gr=Math.min(qn.length,fn.length);let vr=0;for(;vr<gr&&qn[vr]===fn[vr];)vr++;let _r=0;const hn=gr-vr;for(;_r<hn&&qn[qn.length-1-_r]===fn[fn.length-1-_r];)_r++;const An={selectionFrom:vr,selectionTo:fn.length-_r,originalFrom:vr,originalTo:qn.length-_r};ub(me,Xe[0],$e[0],An)}else h$(me,$e,Xe,Ue);window.dispatchEvent(new CustomEvent("ow-pending-write-applied")),ln.debug&&fetch("/api/prompt-debug",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:Ue,debug:ln.debug,metadata:ln.metadata})}).catch(()=>{})}else console.warn("[ContextMenu] Unexpected response:",ln)}catch(at){console.error("[ContextMenu] Plugin action failed:",at)}finally{st?me.commands.removeInsertionLoading(We):me.commands.removeLoadingEffect(We),d(!1)}},[t]),be=y.useCallback(async ne=>{const he=Le.current||t.current;if(!he)return;const{$from:me}=he.state.selection,ze=me.before(me.depth),Ae=me.after(me.depth),Xe=me.parent.content.size===0;d(!0),s(!1),g(!1),Xe?he.chain().focus().deleteRange({from:ze,to:Ae}).insertContentAt(ze,{type:"imageLoading"}).run():he.chain().focus().insertContentAt(Ae,{type:"imageLoading"}).run();let Qe=-1;he.state.doc.descendants((tt,We)=>{if(tt.type.name==="imageLoading"&&Qe===-1)return Qe=We,tt.nodeSize,!1});try{const tt=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:ne})}),We=await tt.json().catch(()=>({success:!1,error:`Generation failed (${tt.status})`}));if(We.success&&We.src){let Ue=-1,st=0;if(he.state.doc.descendants((mt,Nt)=>{if(mt.type.name==="imageLoading"&&Ue===-1)return Ue=Nt,st=mt.nodeSize,!1}),Ue>=0){const{tr:mt}=he.state;mt.replaceWith(Ue,Ue+st,he.schema.nodes.image.create({src:We.src,alt:ne})),he.view.dispatch(mt)}}else{console.error("[ContextMenu] Image generation failed:",We.error);let Ue=-1,st=0;if(he.state.doc.descendants((mt,Nt)=>{if(mt.type.name==="imageLoading"&&Ue===-1)return Ue=Nt,st=mt.nodeSize,!1}),Ue>=0){const{tr:mt}=he.state;mt.delete(Ue,Ue+st),he.view.dispatch(mt)}}}catch(tt){console.error("[ContextMenu] Image generation failed:",tt);let We=-1,Ue=0;if(he.state.doc.descendants((st,mt)=>{if(st.type.name==="imageLoading"&&We===-1)return We=mt,Ue=st.nodeSize,!1}),We>=0){const{tr:st}=he.state;st.delete(We,We+Ue),he.view.dispatch(st)}}finally{d(!1)}},[t]),ht=y.useCallback(ne=>{const{action:he,isPlugin:me,promptForInput:ze}=ne;if(me&&ze){x(he),g(!0);return}if(me){if(he.startsWith("img:"))return;ut(he);return}if(he==="comment"){z(!0);return}if(he==="delete"){const Ae=Le.current||t.current,Xe=Ee.current;if(Ae&&Xe&&Xe.nodeIds.length>0){const{tr:Qe}=Ae.state,tt=new Set(Xe.nodeIds),We=[];Ae.state.doc.descendants((Ue,st)=>{var mt;if((mt=Ue.attrs)!=null&&mt.id&&tt.has(Ue.attrs.id))return We.push({from:st,to:st+Ue.nodeSize}),!1});for(const Ue of We.reverse())Qe.delete(Ue.from,Ue.to);We.length>0&&Ae.view.dispatch(Qe)}s(!1);return}if(he==="link"){const Ae=Le.current||t.current;if(Ae){const Xe=[];Ae.state.doc.descendants(Qe=>{var tt;(tt=Qe.marks)==null||tt.forEach(We=>{var Ue,st;if(We.type.name==="link"&&((st=(Ue=We.attrs)==null?void 0:Ue.href)!=null&&st.startsWith("doc:"))){const mt=K5(We.attrs.href);mt&&!Xe.includes(mt)&&Xe.push(mt)}})}),M(Xe)}fetch("/api/documents").then(Xe=>Xe.json()).then(Xe=>{Array.isArray(Xe)&&N(Xe.map(Qe=>({filename:Qe.filename,title:Qe.title,docId:Qe.docId}))),R(!1),$(""),w(!0)}).catch(()=>{});return}if(he==="unlink"){const Ae=Le.current||t.current;Ae&&Ae.chain().focus().unsetLink().run(),s(!1);return}if(he==="see-connections"){fetch("/api/documents").then(Ae=>Ae.json()).then(Ae=>{Array.isArray(Ae)&&N(Ae.map(Xe=>({filename:Xe.filename,title:Xe.title,docId:Xe.docId})))}).catch(()=>{}),D(!0);return}if(he==="go-to-target"){te&&window.dispatchEvent(new CustomEvent("ow-navigate-to-link",{detail:{docId:te.docId,nodeId:te.nodeId,filename:null,quote:null}})),s(!1),fe(null);return}},[ut,t,te]),xt=y.useCallback(()=>{f.trim()&&(v.startsWith("img:")?be(f.trim()):ut(v,f.trim()),h(""),x(""))},[ut,be,v,f]),St=y.useCallback(()=>{if(!n)return;if(U){fetch("/api/comments",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,id:U.id,note:ee.trim()})}).then(()=>{s(!1),z(!1),P(""),J(null)}).catch(Qe=>{console.error("[ContextMenu] Comment edit failed:",Qe)});return}const ne=Le.current||t.current,he=Ee.current;if(!ne||!he)return;const{from:me,to:ze,nodeIds:Ae}=he;if(me===ze||Ae.length===0)return;const Xe=ne.state.doc.textBetween(me,ze,`
207
+ `);Xe.trim()&&fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,text:Xe,note:ee.trim(),nodeId:Ae[Ae.length-1],nodeIds:Ae})}).then(()=>{s(!1),z(!1),P("")}).catch(Qe=>{console.error("[ContextMenu] Comment create failed:",Qe)})},[t,n,ee,U]),At=y.useCallback(()=>{ie&&(J({id:ie.id,text:ie.text}),P(ie.note),z(!0),q(null))},[ie]),Ye=y.useCallback(()=>{ie&&fetch("/api/comments/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[ie.id]})}).then(()=>{s(!1),q(null)}).catch(ne=>{console.error("[ContextMenu] Comment resolve failed:",ne)})},[ie]),ct=y.useCallback(()=>{ie&&fetch("/api/comments",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[ie.id]})}).then(()=>{s(!1),q(null)}).catch(ne=>{console.error("[ContextMenu] Comment delete failed:",ne)})},[ie]),Fe=y.useCallback((ne,he)=>{const me=Le.current||t.current;if(me){const ze=ne.docId?Ap({docId:ne.docId,nodeId:he==null?void 0:he.nodeId,quote:he==null?void 0:he.quote}):Ap({filename:ne.filename});me.chain().focus().setLink({href:ze}).run()}fetch("/api/auto-tag-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetFile:ne.filename})}).catch(()=>{}),s(!1),w(!1),oe(null)},[t]),G=y.useCallback(ne=>{if(!ne.docId){Fe(ne);return}oe({docId:ne.docId,filename:ne.filename,title:ne.title,paragraphs:[],loading:!0}),fetch(`/api/documents/by-doc-id/${ne.docId}/paragraphs`).then(he=>he.json()).then(he=>{oe(me=>me&&me.docId===ne.docId?{...me,paragraphs:Array.isArray(he.paragraphs)?he.paragraphs:[],loading:!1}:me)}).catch(()=>{oe(he=>he&&he.docId===ne.docId?{...he,paragraphs:[],loading:!1}:he)})},[Fe]),ge=y.useCallback(()=>{const ne=L.trim();if(!ne)return;const he=Le.current||t.current;he&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:ne})}).then(me=>me.json()).then(me=>{if(me.filename){const ze=Ap(me.docId?{docId:me.docId}:{filename:me.filename});he.chain().focus().setLink({href:ze}).run()}}).catch(()=>{}),s(!1),w(!1),R(!1),$(""))},[t,L]);return r?l.jsx("div",{ref:Se,className:"context-menu",style:{left:i.x,top:i.y},children:c?l.jsx("div",{className:"context-menu-loading",children:"Applying..."}):K?l.jsxs("div",{className:"context-menu-comment-editor",children:[(()=>{const ne=(U==null?void 0:U.text)??(()=>{const he=Le.current||t.current,me=Ee.current;return!he||!me||me.from===me.to?"":he.state.doc.textBetween(me.from,me.to,`
208
+ `)})();return ne?l.jsx("div",{className:"context-menu-comment-quote",children:ne}):null})(),l.jsx("textarea",{autoFocus:!0,className:"context-menu-comment-textarea",value:ee,onChange:ne=>P(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&(ne.metaKey||ne.ctrlKey)&&(ne.preventDefault(),St()),ne.key==="Escape"&&(s(!1),z(!1),P(""),J(null))},placeholder:"Note for agent (optional)...",rows:4}),l.jsxs("div",{className:"context-menu-comment-actions",children:[l.jsx("span",{className:"context-menu-comment-hint",children:"⌘↵ to save · Esc to cancel"}),l.jsx("button",{onClick:St,children:U?"Save":"Comment"})]})]}):ie?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"context-menu-item",onClick:At,children:l.jsx("span",{children:"Edit comment"})}),l.jsx("button",{className:"context-menu-item",onClick:Ye,children:l.jsx("span",{children:"Resolve comment"})}),l.jsx("button",{className:"context-menu-item",onClick:ct,children:l.jsx("span",{children:"Delete comment"})})]}):m?l.jsxs("div",{className:"context-menu-custom",children:[l.jsx("input",{autoFocus:!0,value:f,onChange:ne=>h(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&xt(),ne.key==="Escape"&&s(!1)},placeholder:"Custom instruction..."}),l.jsx("button",{onClick:xt,children:"Apply"})]}):we?l.jsxs("div",{className:"context-menu-link-picker",children:[l.jsxs("div",{className:"context-menu-link-header",children:[l.jsx("button",{className:"context-menu-link-back",onClick:()=>oe(null),title:"Back to doc list",children:"←"}),l.jsxs("span",{children:['Pick paragraph in "',we.title,'"']})]}),l.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>Fe({filename:we.filename,docId:we.docId}),children:l.jsx("span",{children:"Link whole doc"})}),l.jsx("div",{className:"context-menu-link-list",children:we.loading?l.jsx("div",{className:"context-menu-loading",children:"Loading…"}):we.paragraphs.length===0?l.jsx("div",{className:"context-menu-loading",children:"No paragraphs"}):we.paragraphs.map(ne=>{const he=ne.preview.replace(/…$/,"").slice(0,50),me=ne.type==="heading"?Math.max(0,(ne.level||1)-1)*12:12;return l.jsx("button",{className:`context-menu-item context-menu-paragraph-row context-menu-paragraph-row--${ne.type}`,style:{paddingLeft:8+me},onClick:()=>Fe({filename:we.filename,docId:we.docId},{nodeId:ne.nodeId,quote:he}),children:l.jsx("span",{children:ne.preview})},ne.nodeId)})})]}):A&&ue?l.jsxs("div",{className:"context-menu-link-picker",children:[l.jsxs("div",{className:"context-menu-link-header",children:["Linked from ",ue.entries.length," ",ue.entries.length===1?"place":"places"]}),l.jsx("div",{className:"context-menu-link-list",children:ue.entries.map((ne,he)=>{const me=S.find(Ae=>Ae.docId===ne.from_doc),ze=(me==null?void 0:me.title)||ne.from_doc;return l.jsxs("button",{className:"context-menu-item",onClick:()=>{window.dispatchEvent(new CustomEvent("ow-navigate-to-link",{detail:{docId:ne.from_doc,nodeId:ne.from_node,filename:null,quote:null}})),s(!1),D(!1)},children:[l.jsx("span",{children:ze}),l.jsxs("span",{className:"context-menu-shortcut",children:['"',ne.text,'"']})]},`${ne.from_doc}-${ne.from_node}-${he}`)})})]}):k?l.jsxs("div",{className:"context-menu-link-picker",children:[l.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),_?l.jsxs("div",{className:"context-menu-custom",children:[l.jsx("input",{autoFocus:!0,value:L,onChange:ne=>$(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&ge(),ne.key==="Escape"&&R(!1)},placeholder:"New document title..."}),l.jsx("button",{onClick:ge,children:"Create"})]}):l.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>R(!0),children:l.jsx("span",{children:"+ New link doc"})}),l.jsxs("div",{className:"context-menu-link-list",children:[j.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-section-header",children:"Linked in this doc"}),S.filter(ne=>Nk(ne,j)).map(ne=>l.jsxs("div",{className:"context-menu-link-row",children:[l.jsx("button",{className:"context-menu-item context-menu-link-row__main",onClick:()=>Fe(ne),children:l.jsx("span",{children:ne.title})}),ne.docId&&l.jsx("button",{className:"context-menu-link-row__drill",title:"Pick a paragraph in this doc",onClick:()=>G(ne),children:"▸"})]},`linked-${ne.filename}`))]}),l.jsx("div",{className:"context-menu-section-header",children:"All documents"}),S.filter(ne=>!Nk(ne,j)).map(ne=>l.jsxs("div",{className:"context-menu-link-row",children:[l.jsx("button",{className:"context-menu-item context-menu-link-row__main",onClick:()=>Fe(ne),children:l.jsx("span",{children:ne.title})}),ne.docId&&l.jsx("button",{className:"context-menu-link-row__drill",title:"Pick a paragraph in this doc",onClick:()=>G(ne),children:"▸"})]},ne.filename)),S.length===0&&l.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const ne=pt();let he;return ne.map((me,ze)=>{const Ae=me.isPlugin&&me.pluginDisplayName&&me.pluginDisplayName!==he,Xe=he!==void 0;me.isPlugin?he=me.pluginDisplayName:he=void 0;const Qe=!me.isPlugin&&Xe;return l.jsxs("span",{children:[Ae&&l.jsx("div",{className:"context-menu-section-header",children:me.pluginDisplayName}),Qe&&l.jsx("div",{className:"context-menu-divider"}),l.jsxs("button",{className:"context-menu-item",onClick:()=>ht(me),children:[l.jsx("span",{children:me.label}),me.shortcut&&l.jsx("span",{className:"context-menu-shortcut",children:me.shortcut})]})]},me.action)})})()}):null}const S$=80,Op=8,Zo=8,E$=400;function Ck(t){return t.nodeIds&&t.nodeIds.length>0?t.nodeIds:[t.nodeId]}function _k(t,e){const n=new Set(e);return t.every(r=>n.has(r))}function N$(t,e){const n=e.find(s=>s.id===t);if(!n)return[];const r=Ck(n);return e.filter(s=>{if(s.id===n.id)return!0;const i=Ck(s);return _k(i,r)||_k(r,i)}).sort((s,i)=>(s.createdAt||"").localeCompare(i.createdAt||""))}function C$({documentId:t}){const[e,n]=y.useState(null),[r,s]=y.useState({kind:"view"}),[i,o]=y.useState(""),[c,d]=y.useState(0),[f,h]=y.useState({left:0,top:0,placement:"above"}),m=y.useRef(null),g=y.useRef(null),v=y.useRef(null),x=y.useRef(null),k=y.useRef({kind:"view"});y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{k.current=r},[r]),y.useEffect(()=>{const ee=()=>d(P=>P+1);return window.addEventListener("ow-comments-changed",ee),()=>window.removeEventListener("ow-comments-changed",ee)},[]);const w=y.useCallback(()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),S=y.useCallback(()=>{w(),v.current=window.setTimeout(()=>{k.current.kind==="view"&&n(null)},S$)},[w]),N=y.useCallback(()=>{w(),n(null),s({kind:"view"}),o("")},[w]),j=y.useMemo(()=>e?N$(e.commentId,$u()):[],[e,c]);y.useEffect(()=>{e&&j.length===0&&N()},[e,j.length,N]),y.useLayoutEffect(()=>{if(!e)return;const ee=m.current;if(!ee)return;const P=ee.getBoundingClientRect(),{rect:U}=e,J=U.top,ie=window.innerHeight-U.bottom,q=J>=P.height+Op||J>=ie?"above":"below",ue=q==="above"?Math.max(Zo,U.top-P.height-Op):Math.min(window.innerHeight-P.height-Zo,U.bottom+Op);let Y=U.left;Y+P.width>window.innerWidth-Zo&&(Y=window.innerWidth-P.width-Zo),Y<Zo&&(Y=Zo),h({left:Y,top:ue,placement:q})},[e,r,j.length,c]),y.useEffect(()=>{const ee=ie=>{var Y,A,D;const q=ie.target,ue=(Y=q==null?void 0:q.closest)==null?void 0:Y.call(q,"[data-comment-id]");if(ue){const te=ue.getAttribute("data-comment-id");if(!te)return;if(((A=x.current)==null?void 0:A.commentId)===te){w();return}w(),s({kind:"view"}),o(""),n({commentId:te,rect:ue.getBoundingClientRect()});return}if((D=m.current)!=null&&D.contains(q)){w();return}x.current&&S()},P=ie=>{var ue,Y;const q=ie.relatedTarget;if(q&&((ue=m.current)!=null&&ue.contains(q))){w();return}q&&((Y=q.closest)!=null&&Y.call(q,"[data-comment-id]"))||x.current&&S()},U=ie=>{if(ie.key==="Escape"&&x.current){if(ie.preventDefault(),k.current.kind!=="view"){s({kind:"view"}),o("");return}N()}},J=ie=>{var q;x.current&&k.current.kind==="view"&&((q=m.current)!=null&&q.contains(ie.target)||N())};return document.addEventListener("mouseover",ee),document.addEventListener("mouseout",P),document.addEventListener("keydown",U),document.addEventListener("scroll",J,!0),()=>{document.removeEventListener("mouseover",ee),document.removeEventListener("mouseout",P),document.removeEventListener("keydown",U),document.removeEventListener("scroll",J,!0),w()}},[w,S,N]),y.useEffect(()=>{var ee;r.kind!=="view"&&((ee=g.current)==null||ee.focus())},[r]);const M=y.useCallback(ee=>{const P=$u().find(U=>U.id===ee);P&&(o(P.note||""),s({kind:"edit",commentId:ee}))},[]),_=y.useCallback(ee=>{o(""),s({kind:"compose",parentCommentId:ee})},[]),R=y.useCallback(()=>{s({kind:"view"}),o("")},[]),L=y.useCallback(()=>{r.kind!=="edit"||!t||fetch("/api/comments",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:t,id:r.commentId,note:i.trim()})}).then(()=>{s({kind:"view"}),o("")}).catch(ee=>console.error("[CommentPopover] Save failed:",ee))},[r,t,i]),$=y.useCallback(()=>{if(r.kind!=="compose"||!t)return;const ee=$u().find(P=>P.id===r.parentCommentId);ee&&fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:t,text:ee.text,note:i.trim(),nodeId:ee.nodeId,nodeIds:ee.nodeIds})}).then(()=>{s({kind:"view"}),o("")}).catch(P=>console.error("[CommentPopover] Create failed:",P))},[r,t,i]),B=y.useCallback(ee=>{fetch("/api/comments/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[ee]})}).catch(P=>console.error("[CommentPopover] Resolve failed:",P))},[]),F=y.useCallback(ee=>{fetch("/api/comments",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[ee]})}).catch(P=>console.error("[CommentPopover] Delete failed:",P))},[]);if(!e||j.length===0)return null;const K=r.kind!=="view",z=r.kind==="compose"?"Adding a new comment on the same range":null;return l.jsx("div",{ref:m,className:`ow-comment-popover ow-comment-popover-${f.placement}`,style:{left:f.left,top:f.top,maxHeight:E$},onMouseEnter:w,onMouseLeave:S,children:K?l.jsxs(l.Fragment,{children:[z&&l.jsx("div",{className:"ow-comment-popover-empty",children:z}),l.jsx("textarea",{ref:g,className:"ow-comment-popover-textarea",value:i,onChange:ee=>o(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)&&(ee.preventDefault(),r.kind==="edit"?L():r.kind==="compose"&&$()),ee.key==="Escape"&&(ee.preventDefault(),R())},rows:4,placeholder:"Note for agent (optional)..."}),l.jsxs("div",{className:"ow-comment-popover-actions",children:[l.jsx("span",{className:"ow-comment-popover-hint",children:"⌘↵ to save · Esc to cancel"}),l.jsx("button",{className:"ow-icon-btn",onClick:r.kind==="edit"?L:$,title:"Save",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M20 6 9 17l-5-5"})})})]})]}):l.jsx("div",{className:"ow-comment-popover-stack",children:j.map((ee,P)=>l.jsxs("div",{className:`ow-comment-popover-card${P>0?" ow-comment-popover-card-divider":""}`,children:[ee.note?l.jsx("div",{className:"ow-comment-popover-text",children:ee.note}):l.jsx("div",{className:"ow-comment-popover-empty",children:"No note"}),l.jsxs("div",{className:"ow-comment-popover-actions",children:[l.jsx("button",{className:"ow-icon-btn",onClick:()=>M(ee.id),title:"Edit comment",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M12 20h9"}),l.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}),l.jsx("button",{className:"ow-icon-btn",onClick:()=>_(ee.id),title:"Add another comment on this range",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M12 5v14"}),l.jsx("path",{d:"M5 12h14"})]})}),l.jsx("button",{className:"ow-icon-btn",onClick:()=>B(ee.id),title:"Resolve (mark addressed)",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M20 6 9 17l-5-5"})})}),l.jsx("button",{className:"ow-icon-btn ow-icon-btn-danger",onClick:()=>F(ee.id),title:"Delete (remove permanently)",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M18 6 6 18"}),l.jsx("path",{d:"m6 6 12 12"})]})})]})]},ee.id))})})}function Su(t){return t.type==="doc"?t.file:t.id}function Ll(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&Ll(n.items,e)}function LT(t,e,n,r){for(const s of t){if(s.type==="doc"&&s.file===e)return n||r;if(s.type==="container"){const i=s.autoAccept===!0,o=LT(s.items,e,n,r||i);if(o!==null)return o}}return null}function Pd(t,e){for(const n of t){const r=n.workspace;if(!r)continue;const s=r.autoAccept===!0;if(LT(r.root,e,s,!1)===!0)return!0}return!1}function ba(t){const e=new Date(t),n=Date.now()-e.getTime();return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<6048e5?`${Math.floor(n/864e5)}d ago`:e.toLocaleDateString()}function Vs(t){return/^[A-Z]:[/\\]|^\//.test(t)}function DT(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function _$(t){const e=new Date(t),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),s=new Date(r.getTime()-864e5),i=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i.getTime()===r.getTime()?"Today":i.getTime()===s.getTime()?"Yesterday":n.getTime()-i.getTime()<6048e5?e.toLocaleDateString(void 0,{weekday:"long"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function T$(t,e){const[n,r]=y.useState([]),[s,i]=y.useState([]),o=y.useRef(null),c=y.useRef(new Set),d=y.useCallback(g=>{c.current.add(g)},[]),f=y.useMemo(()=>{const g=new Set;for(const v of s)v.workspace&&Ll(v.workspace.root,g);return g},[s]),h=y.useCallback(()=>{fetch("/api/documents").then(g=>g.json()).then(g=>{if(!Array.isArray(g))return;const v=c.current;if(v.size>0){const k=new Set(g.map(w=>w.filename));for(const w of[...v])k.has(w)||v.delete(w)}const x=v.size>0?g.filter(k=>!v.has(k.filename)):g;r(x)}).catch(()=>{})},[]),m=y.useCallback(()=>{fetch("/api/workspaces").then(g=>g.json()).then(async g=>{if(!Array.isArray(g))return;const v=await Promise.all(g.map(async x=>{try{const w=await(await fetch(`/api/workspaces/${encodeURIComponent(x.filename)}`)).json();return{...x,workspace:w}}catch{return x}}));i(v)}).catch(()=>{})},[]);return y.useEffect(()=>{h()},[h,t]),y.useEffect(()=>{m()},[m,e]),{docs:n,setDocs:r,workspaces:s,setWorkspaces:i,assignedFiles:f,fetchDocs:h,fetchWorkspaces:m,scrollRef:o,markPendingDelete:d}}function Zg(t,e){return t.filter(n=>!e(n)).map(n=>n.type==="container"?{...n,items:Zg(n.items,e)}:n)}function PT(t,e,n){return t.map(r=>r.type==="container"&&r.id===e?{...r,name:n}:r.type==="container"?{...r,items:PT(r.items,e,n)}:r)}function j$(t,e,n,r,s,i){const o=y.useCallback(_=>{n(R=>R.filter(L=>L.filename!==_)),i==null||i(_),fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>t())},[n,t]),c=y.useCallback(_=>{n(R=>R.filter(L=>L.filename!==_)),fetch(`/api/documents/${encodeURIComponent(_)}/archive`,{method:"POST"}).catch(()=>t())},[n,t]),d=y.useCallback(_=>{n(R=>R.filter(L=>L.filename!==_)),fetch(`/api/documents/${encodeURIComponent(_)}/unarchive`,{method:"POST"}).catch(()=>t())},[n,t]),f=y.useCallback((_,R,L)=>{!L.trim()||L.trim()===R||(n($=>$.map(B=>B.filename===_?{...B,title:L.trim()}:B)),fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:L.trim()})}).catch(()=>t()))},[n,t]),h=y.useCallback(_=>{r(R=>R.filter(L=>L.filename!==_)),fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>e())},[r,e]),m=y.useCallback((_,R)=>{R.trim()&&(r(L=>L.map($=>$.filename===_?{...$,title:R.trim()}:$)),fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:R.trim()})}).catch(()=>e()))},[r,e]),g=y.useCallback((_,R)=>{r(L=>L.map($=>$.filename!==_||!$.workspace?$:{...$,docCount:Math.max(0,$.docCount-1),workspace:{...$.workspace,root:Zg($.workspace.root,B=>B.type==="doc"&&B.file===R)}})),fetch(`/api/workspaces/${encodeURIComponent(_)}/docs/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>e())},[r,e]),v=y.useCallback((_,R,L=!1)=>{r(B=>B.map(F=>F.filename!==_||!F.workspace?F:{...F,workspace:{...F.workspace,root:Zg(F.workspace.root,K=>K.type==="container"&&K.id===R)}}));const $=`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(R)}${L?"?cascade=true":""}`;fetch($,{method:"DELETE"}).then(()=>{L&&t()}).catch(()=>e())},[r,e,t]),x=y.useCallback((_,R,L)=>{L.trim()&&(r($=>$.map(B=>B.filename!==_||!B.workspace?B:{...B,workspace:{...B.workspace,root:PT(B.workspace.root,R,L.trim())}})),fetch(`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(R)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:L.trim()})}).catch(()=>e()))},[r,e]),k=y.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),w=y.useCallback((_,R,L)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L?{metadata:L}:{})}).then($=>$.json()).then($=>{if($.filename)return fetch(`/api/workspaces/${encodeURIComponent(_)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:$.filename,title:$.title||"Untitled",containerId:R})})}).catch(()=>{})},[]),S=y.useCallback((_,R)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:R})}).catch(()=>{})},[]),N=y.useCallback(_=>{const R=s.find(L=>L.filename===_);return(R==null?void 0:R.tags)??[]},[s]),j=y.useCallback((_,R)=>{const L=R.trim();L&&(n($=>$.map(B=>{if(B.filename!==_)return B;const F=B.tags??[];return F.includes(L)?B:{...B,tags:[...F,L]}})),fetch(`/api/doc-tags/${encodeURIComponent(_)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:L})}).catch(()=>{}))},[n]),M=y.useCallback((_,R)=>{n(L=>L.map($=>{if($.filename!==_)return $;const B=$.tags??[],F=B.filter(K=>K!==R);return F.length===B.length?$:F.length>0?{...$,tags:F}:{...$,tags:void 0}})),fetch(`/api/doc-tags/${encodeURIComponent(_)}/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[n]);return{fetchDocs:t,handleDelete:o,handleArchive:c,handleUnarchive:d,handleRename:f,handleCreateWorkspace:k,handleDeleteWorkspace:h,handleCreateInWorkspace:w,handleRemoveFromWorkspace:g,handleCreateContainer:S,handleDeleteContainer:v,handleRenameContainer:x,handleRenameWorkspace:m,getDocTags:N,handleAddTag:j,handleRemoveTag:M}}function BT({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:s}){const[i,o]=y.useState(null),[c,d]=y.useState(null),f=y.useRef(null),h=y.useRef(null),m=y.useRef(null),g=y.useRef(null),v=y.useRef(null),x=5,k=(F,K,z)=>z==="before"?K>0?Su(F[K-1]):null:Su(F[K]),w=y.useCallback((F,K)=>{if(K===null){const P=t.filter(J=>!n.has(J.filename)).map(J=>({type:"doc",file:J.filename,title:J.title})),U=P.findIndex(J=>Su(J)===F);return U>=0?{siblings:P,index:U,containerId:null}:null}const z=e.find(P=>P.filename===K);if(!(z!=null&&z.workspace))return null;const ee=(P,U)=>{for(let J=0;J<P.length;J++){if(Su(P[J])===F)return{siblings:P,index:J,containerId:U};if(P[J].type==="container"){const ie=ee(P[J].items,P[J].id);if(ie)return ie}}return null};return ee(z.workspace.root,null)},[t,n,e]),S=y.useCallback(()=>{o(null),d(null),v.current=null,g.current=null,m.current&&(m.current.remove(),m.current=null),f.current&&(clearTimeout(f.current),f.current=null),h.current&&(cancelAnimationFrame(h.current),h.current=null),document.body.style.userSelect=""},[]),N=y.useCallback((F,K)=>{if(!F||!K)return;if(F.type==="workspace"){const q=K.itemId;if(q===F.filename)return;const ue=e.map(D=>D.filename),Y=ue.indexOf(F.filename);if(Y<0)return;ue.splice(Y,1);let A=ue.indexOf(q);if(A<0)return;K.position==="after"&&(A+=1),ue.splice(A,0,F.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:ue})}).catch(()=>{});return}const{wsFilename:z,containerId:ee,afterId:P}=K,U=F.type==="doc"?F.file:F.id,J=F.sourceWs;if(K.itemId===U)return;if(F.type==="container"){if(z===null&&ee===null&&K.itemId!=="__section__"){const q=K.itemId,ue=K.position==="after"?q:(()=>{const Y=e.findIndex(A=>A.filename===q);return Y>0?e[Y-1].filename:null})();fetch("/api/workspaces/promote-container",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:J,containerId:U,afterWorkspaceFilename:ue})}).catch(()=>{});return}if(J!==z&&z){fetch(`/api/workspaces/${encodeURIComponent(z)}/containers/${encodeURIComponent(U)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:J,targetContainerId:ee??null,afterIdentifier:P})}).catch(()=>{});return}if(!z)return;fetch(`/api/workspaces/${encodeURIComponent(z)}/docs/${encodeURIComponent(U)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:ee??null,afterFile:P})}).catch(()=>{});return}const ie=F.file;if(J===null&&z===null){const q=t.filter(te=>!n.has(te.filename)).map(te=>te.filename),ue=q.indexOf(ie);if(ue<0)return;q.splice(ue,1);let Y=P?q.indexOf(P):-1;Y>=0?Y+=1:Y=0,q.splice(Y,0,ie);const A=[];let D=0;for(const te of t)n.has(te.filename)?A.push(te.filename):A.push(q[D++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:A})}).catch(()=>{});return}if(J===null&&z!==null){fetch(`/api/workspaces/${encodeURIComponent(z)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:ie,title:ie.replace(/\.md$/,""),containerId:ee??null,afterFile:P})}).catch(()=>{});return}if(J!==null&&z===null){fetch(`/api/workspaces/${encodeURIComponent(J)}/docs/${encodeURIComponent(ie)}`,{method:"DELETE"}).catch(()=>{});return}if(J===z&&z!==null){fetch(`/api/workspaces/${encodeURIComponent(z)}/docs/${encodeURIComponent(ie)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:ee??null,afterFile:P})}).catch(()=>{});return}J!==null&&z!==null&&fetch(`/api/workspaces/${encodeURIComponent(z)}/docs/${encodeURIComponent(ie)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:J,containerId:ee??null,afterFile:P,title:ie.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),j=y.useCallback((F,K)=>{const z=m.current;z&&(z.style.display="none");const ee=document.elementFromPoint(F,K);if(z&&(z.style.display=""),!ee)return null;if((i==null?void 0:i.type)==="workspace"||(i==null?void 0:i.type)==="container"){const te=ee.closest("[data-ws-drag]");if(te){const fe=te.dataset.wsDrag,we=te.getBoundingClientRect(),oe=(K-we.top)/we.height;return{itemId:fe,position:oe<.5?"before":"after",wsFilename:null,containerId:null,afterId:null}}if((i==null?void 0:i.type)==="workspace")return null}if((i==null?void 0:i.type)==="doc"){const te=ee.closest("[data-ws-drag]");if(te)return{itemId:"__section__",position:"inside",wsFilename:te.dataset.wsDrag,containerId:null,afterId:null}}const P=ee.closest("[data-drag-id]");if(!P){const te=ee.closest("[data-drop-ws]");return te?{itemId:"__section__",position:"inside",wsFilename:te.dataset.dropWs==="__docs__"?null:te.dataset.dropWs,containerId:te.dataset.dropContainer||null,afterId:null}:null}const U=P.dataset.dragId,J=P.dataset.dragType,ie=P.dataset.dragWs==="__docs__"?null:P.dataset.dragWs,q=P.getBoundingClientRect(),ue=(K-q.top)/q.height;if(J==="container-header"){const te=U,fe=P.dataset.dragParent||null,we=w(te,ie);if(!we)return null;const oe=(i==null?void 0:i.type)==="container"?.33:.25;return ue<oe?{itemId:te,position:"before",wsFilename:ie,containerId:fe,afterId:k(we.siblings,we.index,"before")}:ue>1-oe?{itemId:te,position:"after",wsFilename:ie,containerId:fe,afterId:k(we.siblings,we.index,"after")}:{itemId:te,position:"inside",wsFilename:ie,containerId:te,afterId:null}}const Y=P.dataset.dragContainer||null,A=w(U,ie);if(!A)return null;const D=ue<.5?"before":"after";return{itemId:U,position:D,wsFilename:ie,containerId:Y,afterId:k(A.siblings,A.index,D)}},[w,i]),M=y.useCallback(F=>{const K=r.current;if(!K)return;const z=K.getBoundingClientRect(),ee=80,P=18;let U=0;if(F<z.top+ee?U=-P*Math.max(0,1-(F-z.top)/ee):F>z.bottom-ee&&(U=P*Math.max(0,1-(z.bottom-F)/ee)),h.current&&(cancelAnimationFrame(h.current),h.current=null),U!==0){const J=()=>{K.scrollTop+=U,h.current=requestAnimationFrame(J)};h.current=requestAnimationFrame(J)}},[r]),_=y.useCallback((F,K)=>{const z=m.current;z&&(z.style.display="none");const ee=document.elementFromPoint(F,K);z&&(z.style.display="");const P=ee==null?void 0:ee.closest("[data-section-key]");if(!P){f.current&&(clearTimeout(f.current),f.current=null);return}const U=P.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{s(J=>{if(!J.has(U))return J;const ie=new Set(J);return ie.delete(U),ie})},500)},[s]);y.useEffect(()=>{if(!i)return;const F=z=>{m.current&&(m.current.style.left=`${z.clientX+12}px`,m.current.style.top=`${z.clientY-8}px`),d(j(z.clientX,z.clientY)),M(z.clientY),_(z.clientX,z.clientY)},K=z=>{N(i,j(z.clientX,z.clientY)),S()};return window.addEventListener("pointermove",F),window.addEventListener("pointerup",K),()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",K)}},[i,j,N,S,M,_]);const R=y.useCallback((F,K,z)=>{if(F.button!==0||F.target.closest("input, button, .sidebar-tag-remove, .sidebar-tag-add, .sidebar-container-actions, .sidebar-delete-btn, .sidebar-confirm-delete, .sidebar-inline-confirm"))return;g.current={x:F.clientX,y:F.clientY},v.current=K;const P=J=>{if(!g.current||!v.current)return;const ie=J.clientX-g.current.x,q=J.clientY-g.current.y;if(Math.abs(ie)+Math.abs(q)>=x){document.body.style.userSelect="none",window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",U),o(v.current),v.current=null;const ue=document.createElement("div");ue.style.cssText="position:fixed;pointer-events:none;z-index:9999;padding:4px 10px;background:var(--bg-surface, white);border:1px solid var(--border, #cbd5e1);border-radius:6px;font-size:12px;box-shadow:0 2px 8px rgba(0,0,0,0.12);max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-dark, #334155);",ue.textContent=z,document.body.appendChild(ue),m.current=ue,ue.style.left=`${J.clientX+12}px`,ue.style.top=`${J.clientY-8}px`}},U=()=>{window.removeEventListener("pointermove",P),window.removeEventListener("pointerup",U),g.current=null,v.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",P),window.addEventListener("pointerup",U)},[]);return{draggedItem:i,dropIndicator:c,handlePointerDown:R,dropClass:F=>!c||c.itemId!==F?"":c.position==="before"?"drop-before":c.position==="after"?"drop-after":c.position==="inside"?"drop-inside":"",isDragging:F=>i?i.type==="doc"?i.file===F:i.type==="workspace"?i.filename===F:i.id===F:!1,isContainerDropTarget:F=>!c||!i?!1:c.containerId===F}}function Wl(t,e,n,r){var h;const s=y.useRef(e);s.current=e;const i=y.useRef(r);i.current=r;const o=y.useRef(null),c=y.useRef(null),d=y.useCallback(m=>{var v,x;const g=m||((v=s.current.find(k=>k.isActive))==null?void 0:v.filename);g&&((x=i.current)==null||x.call(i,g),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{const k=t.current;if(!k)return;const w=k.querySelector(`[data-drag-id="${CSS.escape(g)}"]`)||k.querySelector(".active");if(!w||w.offsetParent===null)return;const S=o.current===g,N=w.getBoundingClientRect(),j=k.getBoundingClientRect(),M=N.top<j.top||N.bottom>j.bottom;if(S||M){const _=N.top-j.top-(j.height/2-N.height/2);k.scrollTop+=_}S&&(o.current=null,w.classList.remove("reveal-pulse"),w.offsetWidth,w.classList.add("reveal-pulse"),setTimeout(()=>w.classList.remove("reveal-pulse"),1200))},60))},[t]),f=(h=e.find(m=>m.isActive))==null?void 0:h.filename;y.useEffect(()=>{d(f)},[f,n,d]),y.useEffect(()=>{const m=g=>{var x,k;const v=((x=g.detail)==null?void 0:x.filename)||((k=s.current.find(w=>w.isActive))==null?void 0:k.filename);v&&(o.current=v,d(v))};return window.addEventListener("ow-reveal-active-doc",m),()=>window.removeEventListener("ow-reveal-active-doc",m)},[d]),y.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[])}const M$=[{key:"document",label:"Document"},{key:"tweet",label:"Tweet"},{key:"article",label:"Article"},{key:"linkedin",label:"LinkedIn"},{key:"newsletter",label:"Newsletter"},{key:"blog",label:"Blog"}];function A$({onPick:t}){const[e,n]=y.useState(!1),r=y.useRef(null),s=y.useRef(null),[i,o]=y.useState({});return y.useLayoutEffect(()=>{if(!e||!r.current||!s.current)return;const c=s.current.getBoundingClientRect(),d=r.current.getBoundingClientRect(),f=8;let h=c.right-4,m=c.top-4;h+d.width+f>window.innerWidth&&(h=c.left-d.width+4),m+d.height+f>window.innerHeight&&(m=window.innerHeight-d.height-f),m<f&&(m=f),o({position:"fixed",left:h,top:m})},[e]),l.jsxs("span",{onMouseLeave:()=>n(!1),children:[l.jsx("div",{className:"context-menu-divider"}),l.jsxs("button",{ref:s,className:"context-menu-item context-menu-submenu-trigger",onMouseEnter:()=>n(!0),onClick:()=>n(c=>!c),children:[l.jsx("span",{children:"Create variant"}),l.jsx("span",{className:"context-menu-submenu-arrow",children:"▸"})]}),e&&l.jsx("div",{ref:r,className:"context-menu context-menu-submenu",style:i,children:M$.map(c=>l.jsx("button",{className:"context-menu-item",onClick:()=>t(c.key),children:l.jsx("span",{children:c.label})},c.key))})]})}function Tk({items:t,onAction:e}){const[n,r]=y.useState(null),s=y.useRef(null),i=y.useRef({}),o=y.useMemo(()=>{const h=new Map;for(const m of t){const g=m.pluginDisplayName||"_ungrouped",v=h.get(g)||[];v.push(m),h.set(g,v)}return h},[t]),[c,d]=y.useState({});y.useLayoutEffect(()=>{const h=n?i.current[n]:null;if(!n||!s.current||!h)return;const m=h.getBoundingClientRect(),g=s.current.getBoundingClientRect(),v=8;let x=m.right-4,k=m.top-4;x+g.width+v>window.innerWidth&&(x=m.left-g.width+4),k+g.height+v>window.innerHeight&&(k=window.innerHeight-g.height-v),k<v&&(k=v),d({position:"fixed",left:x,top:k})},[n]);const f=[];for(const[h,m]of o)if(h!=="_ungrouped"&&m.length>=3)f.push(l.jsxs("span",{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsxs("button",{ref:g=>{i.current[h]=g},className:"context-menu-item context-menu-submenu-trigger",onMouseEnter:()=>r(h),onClick:()=>r(n===h?null:h),children:[l.jsx("span",{children:"Transform"}),l.jsx("span",{className:"context-menu-submenu-arrow",children:"▸"})]}),n===h&&l.jsx("div",{ref:s,className:"context-menu context-menu-submenu",style:c,onMouseLeave:()=>r(null),children:m.map(g=>l.jsx("button",{className:"context-menu-item",onClick:()=>e(g),children:l.jsx("span",{children:g.label})},g.action))})]},`sub-${h}`));else{let g=!0;for(const v of m){const x=g&&h!=="_ungrouped";g=!1,f.push(l.jsxs("span",{children:[x&&l.jsx("div",{className:"context-menu-divider"}),x&&l.jsx("div",{className:"context-menu-section-header",children:h}),l.jsx("button",{className:"context-menu-item",onClick:()=>e(v),children:l.jsx("span",{children:v.label})})]},v.action))}}return l.jsx(l.Fragment,{children:f})}function Bd({x:t,y:e,filename:n,title:r,onClose:s,onDuplicate:i,onCreateVariant:o,onRename:c,onArchive:d,onDelete:f,onPluginAction:h,pluginItems:m,onSchedulePost:g,onPostNow:v,isAlreadyPublished:x,onViewAnalytics:k,viewAnalyticsLabel:w,onMarkSent:S,isAlreadySent:N,isApproved:j,onToggleApprove:M,isAutoAccept:_,onToggleAutoAccept:R,sortState:L,sortProposalLabel:$,sortProposalReasoning:B,onRequestSort:F,onCancelSort:K,onAcceptSortProposal:z,onRejectSortProposal:ee,folderMode:P,onNewDoc:U,onNewContainer:J,onAcceptAll:ie,onRejectAll:q,folderAutoAccept:ue,onToggleFolderAutoAccept:Y,folderAutoAcceptLabel:A,onRequestSortAll:D,folderDocCount:te,onDeleteWithDocs:fe,bulkCount:we,onBulkDelete:oe,onBulkRequestSort:Se}){const Ee=y.useRef(null),[Le,Ie]=y.useState(!1),[Ve,Te]=y.useState(!1),[qe,pt]=y.useState({left:t,top:e});y.useLayoutEffect(()=>{const be=Ee.current;if(!be)return;const ht=be.getBoundingClientRect(),xt=8;let St=t,At=e;e+ht.height+xt>window.innerHeight&&(At=e-ht.height),t+ht.width+xt>window.innerWidth&&(St=t-ht.width),At<xt&&(At=xt),St<xt&&(St=xt),pt({left:St,top:At})},[t,e]),y.useEffect(()=>{const be=ht=>{Ee.current&&!Ee.current.contains(ht.target)&&s()};return document.addEventListener("mousedown",be),()=>document.removeEventListener("mousedown",be)},[s]),y.useEffect(()=>{const be=ht=>{ht.key==="Escape"&&s()};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[s]);const ut=y.useCallback(be=>{h(be.action,be),s()},[h,s]);return we&&we>1&&oe?l.jsxs("div",{ref:Ee,className:"context-menu",style:{left:qe.left,top:qe.top},children:[l.jsxs("div",{className:"context-menu-section-header",children:[we," selected"]}),Se&&l.jsx("button",{className:"context-menu-item",onClick:()=>{Se(),s()},children:l.jsxs("span",{children:["Request sort (",we,")"]})}),Le?l.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:be=>be.stopPropagation(),children:[l.jsxs("span",{children:["Delete ",we,"?"]}),l.jsx("button",{onClick:()=>{oe(),s()},children:"Yes"}),l.jsx("button",{onClick:()=>Ie(!1),children:"No"})]}):l.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>Ie(!0),children:l.jsxs("span",{children:["Delete (",we,")"]})})]}):P?l.jsxs("div",{ref:Ee,className:"context-menu",style:{left:qe.left,top:qe.top},children:[l.jsx("button",{className:"context-menu-item",onClick:()=>{c(),s()},children:l.jsx("span",{children:"Rename"})}),U&&l.jsx("button",{className:"context-menu-item",onClick:be=>{U(be),s()},children:l.jsx("span",{children:"New Document"})}),J&&l.jsx("button",{className:"context-menu-item",onClick:()=>{J(),s()},children:l.jsx("span",{children:"New Container"})}),(ie||q)&&l.jsx("div",{className:"context-menu-divider"}),ie&&l.jsx("button",{className:"context-menu-item",onClick:()=>{ie(),s()},children:l.jsx("span",{children:"Accept All Changes"})}),q&&l.jsx("button",{className:"context-menu-item",onClick:()=>{q(),s()},children:l.jsx("span",{children:"Reject All Changes"})}),Y&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{Y(),s()},children:l.jsx("span",{children:ue?`Turn off auto-accept${A?" "+A:""}`:`Turn on auto-accept${A?" "+A:""}`})})]}),D&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{D(),s()},children:l.jsx("span",{children:"Request sort all"})})]}),m.length>0&&l.jsx(Tk,{items:m,onAction:ut}),l.jsx("div",{className:"context-menu-divider"}),Le?te&&te>0&&fe?l.jsxs("div",{className:"sidebar-ctx-folder-delete",onClick:be=>be.stopPropagation(),children:[l.jsx("div",{className:"sidebar-ctx-folder-delete-prompt",children:"Delete this folder?"}),l.jsxs("button",{className:"context-menu-item sidebar-ctx-delete-option",onClick:()=>{f(),s()},children:[l.jsx("span",{children:"Folder only"}),l.jsxs("span",{className:"sidebar-ctx-delete-hint",children:[te," doc",te===1?"":"s"," → Documents"]})]}),l.jsxs("button",{className:"context-menu-item sidebar-ctx-delete-option sidebar-ctx-delete",onClick:()=>{fe(),s()},children:[l.jsxs("span",{children:["Folder + ",te," doc",te===1?"":"s"]}),l.jsx("span",{className:"sidebar-ctx-delete-hint",children:"permanently deletes files"})]}),l.jsx("button",{className:"context-menu-item sidebar-ctx-delete-cancel",onClick:()=>Ie(!1),children:l.jsx("span",{children:"Cancel"})})]}):l.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:be=>be.stopPropagation(),children:[l.jsx("span",{children:"Delete?"}),l.jsx("button",{onClick:()=>{f(),s()},children:"Yes"}),l.jsx("button",{onClick:()=>Ie(!1),children:"No"})]}):l.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>Ie(!0),children:l.jsx("span",{children:"Delete"})})]}):l.jsxs("div",{ref:Ee,className:"context-menu",style:{left:qe.left,top:qe.top},children:[l.jsx("button",{className:"context-menu-item",onClick:()=>{i(),s()},children:l.jsx("span",{children:"Duplicate"})}),o&&l.jsx(A$,{onPick:be=>{o(be),s()}}),l.jsx("button",{className:"context-menu-item",onClick:()=>{c(),s()},children:l.jsx("span",{children:"Rename"})}),Ve?l.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:be=>be.stopPropagation(),children:[l.jsx("span",{children:"Archive?"}),l.jsx("button",{onClick:()=>{d(),s()},children:"Yes"}),l.jsx("button",{onClick:()=>Te(!1),children:"No"})]}):l.jsx("button",{className:"context-menu-item",onClick:()=>{Ie(!1),Te(!0)},children:l.jsx("span",{children:"Archive"})}),Le?l.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:be=>be.stopPropagation(),children:[l.jsx("span",{children:Vs(n)?"Remove?":"Delete?"}),l.jsx("button",{onClick:()=>{f(),s()},children:"Yes"}),l.jsx("button",{onClick:()=>Ie(!1),children:"No"})]}):l.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>{Te(!1),Ie(!0)},children:l.jsx("span",{children:Vs(n)?"Remove":"Delete"})}),M&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{M(),s()},children:l.jsx("span",{children:j?"Remove Approval":"Approve"})})]}),R&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{R(),s()},children:l.jsx("span",{children:_?"Turn off auto-accept":"Turn on auto-accept"})})]}),L==="proposal"&&z&&ee&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsxs("div",{className:"sidebar-ctx-sort-proposal",onClick:be=>be.stopPropagation(),children:[l.jsxs("div",{className:"sidebar-ctx-sort-proposal-label",children:["Sort to ",$]}),B&&l.jsx("div",{className:"sidebar-ctx-sort-proposal-reason",children:B}),l.jsxs("div",{className:"sidebar-ctx-sort-proposal-actions",children:[l.jsx("button",{onClick:()=>{z(),s()},children:"Accept"}),l.jsx("button",{onClick:()=>{ee(),s()},children:"Reject"})]})]})]}),L==="pending"&&K&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsxs("div",{className:"sidebar-ctx-sort-pending",onClick:be=>be.stopPropagation(),children:[l.jsx("span",{className:"sidebar-ctx-sort-pending-label",children:"Sort requested"}),l.jsx("button",{onClick:()=>{K(),s()},children:"Cancel"})]})]}),L==="none"&&F&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{F(),s()},children:l.jsx("span",{children:"Request sort"})})]}),g&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{g(),s()},children:l.jsx("span",{children:"Schedule Post"})})]}),v&&l.jsx("button",{className:"context-menu-item",onClick:()=>{v(),s()},children:l.jsx("span",{children:x?"Republish to Blog":"Post to Blog Now"})}),S&&!N&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{S(),s()},children:l.jsx("span",{children:"Mark as Sent"})})]}),k&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"context-menu-divider"}),l.jsx("button",{className:"context-menu-item",onClick:()=>{k(),s()},children:l.jsx("span",{children:w||"View Analytics"})})]}),m.length>0&&l.jsx(Tk,{items:m,onAction:ut})]})}const jk=5e3;function $T(t,e){return!t.promptForFocus||!e?!1:e.wordCount>jk?(Ai(`Document too large to transform: ${e.wordCount.toLocaleString()} words (max ${jk.toLocaleString()}). Trim it down first.`,"error"),!0):!1}function FT({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[s,i]=y.useState(""),o=y.useRef(null);y.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]),y.useEffect(()=>{const d=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const c=y.useCallback(()=>{n(s.trim())},[s,n]);return l.jsx("div",{className:"focus-modal-overlay",onClick:r,children:l.jsxs("div",{className:"focus-modal",onClick:d=>d.stopPropagation(),children:[l.jsxs("div",{className:"focus-modal-header",children:[l.jsx("h2",{children:t}),l.jsx("button",{className:"focus-modal-close",onClick:r,children:"×"})]}),l.jsxs("div",{className:"focus-modal-body",children:[l.jsxs("label",{children:['Focus instructions for "',e,'"',l.jsx("textarea",{ref:o,value:s,onChange:d=>i(d.target.value.slice(0,500)),placeholder:"Optional: guide the transformation (e.g. 'focus on the intro section', 'keep it professional')...",onKeyDown:d=>{d.key==="Enter"&&(d.ctrlKey||d.metaKey)&&c()}})]}),l.jsxs("div",{className:"focus-modal-hint",children:[s.length,"/500"]}),l.jsxs("div",{className:"focus-modal-actions",children:[l.jsx("button",{className:"focus-modal-btn secondary",onClick:r,children:"Cancel"}),l.jsx("button",{className:"focus-modal-btn primary",onClick:c,children:"Go"})]})]})]})})}function Ip(t,e){if(!e)return[t];const n=[],r=t.toLowerCase(),s=e.toLowerCase();let i=0;for(;i<t.length;){const o=r.indexOf(s,i);if(o===-1){n.push(t.slice(i));break}o>i&&n.push(t.slice(i,o)),n.push(l.jsx("mark",{children:t.slice(o,o+e.length)},o)),i=o+e.length}return n}function Mk({r:t,query:e,onClick:n}){return l.jsxs("div",{className:`sidebar-item search-result-item ${t.isActive?"active":""} ${t.isArchived?"search-result-archived":""}`,onClick:n,children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-item-title-text",children:t.matchType==="title"?Ip(t.title,e):t.title}),t.isArchived&&l.jsx("span",{className:"search-archived-badge",children:"archived"})]}),t.matchType==="tag"&&t.matchedTag&&l.jsxs("div",{className:"search-result-tag",children:["Tag: ",Ip(t.matchedTag,e)]}),t.matchType==="content"&&t.snippet&&l.jsx("div",{className:"search-result-snippet",children:Ip(t.snippet,e)}),l.jsxs("div",{className:"sidebar-item-meta",children:[t.wordCount.toLocaleString()," words · ",ba(t.lastModified)]})]})}function rf({results:t,query:e,onSwitchDocument:n,actions:r}){if(t.length===0)return l.jsx("div",{className:"sidebar-scroll",children:l.jsxs("div",{className:"search-empty",children:['No results for "',e,'"']})});const s=t.filter(o=>!o.isArchived),i=t.filter(o=>o.isArchived);return l.jsx("div",{className:"sidebar-scroll",children:l.jsxs("div",{className:"search-results",children:[s.map(o=>l.jsx(Mk,{r:o,query:e,onClick:()=>n(o.filename)},o.filename)),i.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"search-archived-divider",children:l.jsx("span",{children:"Archived"})}),i.map(o=>l.jsx(Mk,{r:o,query:e,onClick:()=>r.handleUnarchive(o.filename)},o.filename))]})]})})}async function Lp(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();return(i=(s=r.content)==null?void 0:s[0])!=null&&i.text?JSON.parse(r.content[0].text):r}function Dp(t,e){return e?(t/e*100).toFixed(1)+"%":"0%"}function Ak(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Rk(t,e=50){try{const n=new URL(t),r=n.hostname+n.pathname+n.search;return r.length>e?r.slice(0,e)+"...":r}catch{return t.length>e?t.slice(0,e)+"...":t}}function zT({docId:t,title:e,onClose:n}){const[r,s]=y.useState("loading"),[i,o]=y.useState([]),[c,d]=y.useState(""),[f,h]=y.useState(null),[m,g]=y.useState(null),[v,x]=y.useState("links"),[k,w]=y.useState("all"),[S,N]=y.useState(!1),[j,M]=y.useState(!1),[_,R]=y.useState(""),[L,$]=y.useState(!1),[B,F]=y.useState(null),K=y.useRef(null);y.useEffect(()=>{let oe=!1;return(async()=>{try{const Se=await Lp("list_newsletter_issues",{limit:20});if(oe)return;if(!Se.issues||Se.issues.length===0){s("no-data");return}o(Se.issues);const Ee=Se.issues[0].id;d(Ee)}catch(Se){oe||(g(Se.message),s("error"))}})(),()=>{oe=!0}},[]),y.useEffect(()=>{if(!c)return;let oe=!1;return N(!0),M(!1),F(null),R(""),(async()=>{try{const Se=await Lp("get_newsletter_analytics",{issue_id:c});if(oe)return;if(Se.error){g(Se.error),s("error");return}h(Se),s("loaded")}catch(Se){oe||(g(Se.message),s("error"))}finally{oe||N(!1)}})(),()=>{oe=!0}},[c]),y.useEffect(()=>{const oe=Se=>{K.current&&!K.current.contains(Se.target)&&n()};return document.addEventListener("mousedown",oe),()=>document.removeEventListener("mousedown",oe)},[n]),y.useEffect(()=>{const oe=Se=>{Se.key==="Escape"&&n()};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[n]);const z=f?O$(f.subscriber_events):[],ee=(f==null?void 0:f.issue.recipient_count)??0,P=f?f.stats.delivered||ee-f.stats.bounces:0,U=f?new Set(f.subscriber_events.filter(oe=>{var Se;return oe.event_type==="click"&&((Se=oe.url)==null?void 0:Se.includes("/newsletter/unsubscribe/"))}).map(oe=>oe.email)).size:0,J=f?f.stats.unsubscribes||U:0,ie=f?f.subscriber_events.filter(oe=>oe.event_type==="dropped").length:0,q=f?Math.max(0,ee-f.stats.unique_opens):0,ue=f!=null&&f.issue.sent_at?Date.now()-new Date(f.issue.sent_at).getTime():0,Y=Math.floor(ue/36e5),A=!!(f!=null&&f.issue.resent_at||B),D=oe=>{const Se=Math.floor(oe/36e5);return Se<1?"just now":Se<24?`${Se}h ago`:`${Math.floor(Se/24)}d ${Se%24}h ago`},te=async()=>{if(!(!_.trim()||L)){$(!0);try{const oe=await Lp("resend_to_unopened",{issue_id:c,subject:_});oe.error?(g(oe.error),s("error")):(F({sent:oe.sent,failed:oe.failed}),M(!1))}catch(oe){g(oe.message),s("error")}finally{$(!1)}}},fe=oe=>{var Se;return oe.event_type==="unsubscribe"||oe.event_type==="click"&&!!((Se=oe.url)!=null&&Se.includes("/newsletter/unsubscribe/"))},we=f?R$(f.subscriber_events.filter(oe=>k==="all"?!0:k==="unsubscribe"?fe(oe):oe.event_type===k)):[];return l.jsx("div",{className:"newsletter-modal-overlay",children:l.jsxs("div",{className:"na-modal",ref:K,children:[l.jsxs("div",{className:"na-header",children:[l.jsx("h3",{children:"Newsletter Analytics"}),l.jsx("button",{className:"newsletter-modal__close",onClick:n,children:"×"})]}),r==="loading"&&!f&&l.jsx("div",{className:"na-body",children:l.jsxs("div",{className:"newsletter-modal__status",children:[l.jsx("div",{className:"newsletter-modal__spinner"}),l.jsx("span",{children:"Loading analytics..."})]})}),r==="no-data"&&l.jsxs("div",{className:"na-body",children:[l.jsx("div",{className:"newsletter-modal__status",children:l.jsx("span",{children:"No newsletter sends found yet."})}),l.jsx("div",{className:"newsletter-modal__actions",children:l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="error"&&l.jsxs("div",{className:"na-body",children:[l.jsx("div",{className:"newsletter-modal__error",children:m}),l.jsx("div",{className:"newsletter-modal__actions",children:l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="loaded"&&f&&l.jsxs("div",{className:"na-body",children:[i.length>1&&l.jsx("select",{className:"newsletter-modal__select na-issue-select",value:c,onChange:oe=>d(oe.target.value),children:i.map(oe=>l.jsxs("option",{value:oe.id,children:[oe.subject," — ",Ak(oe.sent_at)]},oe.id))}),S?l.jsxs("div",{className:"newsletter-modal__status",children:[l.jsx("div",{className:"newsletter-modal__spinner"}),l.jsx("span",{children:"Loading..."})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"na-kpi-row",children:[l.jsxs("div",{className:"na-kpi",children:[l.jsx("div",{className:"na-kpi__value",children:P.toLocaleString()}),l.jsx("div",{className:"na-kpi__label",children:"Delivered"}),l.jsxs("div",{className:"na-kpi__sub",children:[ee.toLocaleString()," sent"]})]}),l.jsxs("div",{className:"na-kpi",children:[l.jsx("div",{className:"na-kpi__value",children:Dp(f.stats.unique_opens,P)}),l.jsx("div",{className:"na-kpi__label",children:"Open rate"}),l.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_opens.toLocaleString()," opens"]})]}),l.jsxs("div",{className:"na-kpi",children:[l.jsx("div",{className:"na-kpi__value",children:Dp(f.stats.unique_clicks,P)}),l.jsx("div",{className:"na-kpi__label",children:"Click rate"}),l.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_clicks.toLocaleString()," clicks"]})]})]}),l.jsxs("div",{className:"na-kpi-row na-kpi-row--secondary",children:[l.jsxs("div",{className:"na-kpi na-kpi--sm",children:[l.jsx("span",{className:"na-kpi__value--sm",children:f.stats.bounces}),l.jsx("span",{className:"na-kpi__label--sm",children:"Bounces"})]}),l.jsxs("div",{className:"na-kpi na-kpi--sm",children:[l.jsx("span",{className:"na-kpi__value--sm",children:J}),l.jsx("span",{className:"na-kpi__label--sm",children:"Unsubs"})]}),l.jsxs("div",{className:"na-kpi na-kpi--sm",children:[l.jsx("span",{className:"na-kpi__value--sm",children:ie}),l.jsx("span",{className:"na-kpi__label--sm",children:"Dropped"})]}),f.stats.complaints>0&&l.jsxs("div",{className:"na-kpi na-kpi--sm",children:[l.jsx("span",{className:"na-kpi__value--sm",children:f.stats.complaints}),l.jsx("span",{className:"na-kpi__label--sm",children:"Spam"})]})]}),q>0&&!A&&l.jsx("div",{className:"na-resend",children:j?l.jsxs("div",{className:"na-resend-panel",children:[l.jsxs("div",{className:"na-resend-label-row",children:[l.jsx("span",{className:"na-resend-label",children:"New subject line"}),l.jsxs("span",{className:"na-resend-meta",children:["sent ",D(ue),Y<48?" · consider waiting 48h":""]})]}),l.jsx("input",{className:"na-resend-input",type:"text",value:_,onChange:oe=>R(oe.target.value),placeholder:"Try a different angle"}),l.jsxs("div",{className:"na-resend-actions",children:[l.jsx("button",{className:"na-resend-cancel",onClick:()=>M(!1),children:"Cancel"}),l.jsx("button",{className:"na-resend-send",onClick:te,disabled:L||!_.trim(),children:L?"Sending...":`Send to ${q.toLocaleString()}`})]})]}):l.jsxs("button",{className:"na-resend-toggle",onClick:()=>{M(!0),R(f.issue.subject)},children:["Resend to ",q.toLocaleString()," non-openers ",l.jsx("span",{style:{float:"right"},children:"›"})]})}),A&&l.jsxs("div",{className:"na-resend-done",children:["Resent ",f.issue.resent_at?D(Date.now()-new Date(f.issue.resent_at).getTime()):"just now",B?` — ${B.sent} sent`:"",f.issue.resend_subject?` — "${f.issue.resend_subject}"`:""]}),l.jsxs("div",{className:"na-tabs",children:[l.jsxs("button",{className:`na-tab${v==="links"?" active":""}`,onClick:()=>x("links"),children:["Links (",z.length,")"]}),l.jsxs("button",{className:`na-tab${v==="activity"?" active":""}`,onClick:()=>x("activity"),children:["Activity (",f.subscriber_events.length,")"]})]}),v==="links"&&l.jsx("div",{className:"na-table-wrap",children:z.length===0?l.jsx("div",{className:"na-empty",children:"No link clicks recorded yet."}):l.jsxs("table",{className:"na-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:"Link"}),l.jsx("th",{children:"Unique"}),l.jsx("th",{children:"Total"}),l.jsx("th",{children:"CTR"})]})}),l.jsx("tbody",{children:z.map(oe=>l.jsxs("tr",{children:[l.jsx("td",{className:"na-table__url",title:oe.url,children:l.jsx("a",{href:oe.url,target:"_blank",rel:"noopener noreferrer",children:Rk(oe.url)})}),l.jsx("td",{children:oe.uniqueClicks}),l.jsx("td",{children:oe.totalClicks}),l.jsx("td",{children:Dp(oe.uniqueClicks,P)})]},oe.url))})]})}),v==="activity"&&l.jsxs("div",{className:"na-activity",children:[l.jsx("div",{className:"na-filter-row",children:["all","open","click","bounce","dropped","unsubscribe"].map(oe=>l.jsx("button",{className:`na-filter-btn${k===oe?" active":""}`,onClick:()=>w(oe),children:oe==="all"?"All":oe.charAt(0).toUpperCase()+oe.slice(1)+"s"},oe))}),l.jsxs("div",{className:"na-table-wrap",children:[we.length===0?l.jsxs("div",{className:"na-empty",children:["No ",k==="all"?"":k+" ","events recorded."]}):l.jsxs("table",{className:"na-table",children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:"Email"}),l.jsx("th",{children:"Event"}),l.jsx("th",{children:"Detail"}),l.jsx("th",{children:"Time"})]})}),l.jsx("tbody",{children:we.slice(0,100).map(oe=>l.jsxs("tr",{children:[l.jsx("td",{className:"na-table__email",children:oe.email}),l.jsxs("td",{children:[l.jsx("span",{className:`na-badge na-badge--${oe.event_type}`,children:oe.event_type}),oe.count>1&&l.jsxs("span",{className:"na-count",children:[oe.count,"x"]})]}),l.jsx("td",{className:"na-table__url",children:oe.url?l.jsx("a",{href:oe.url,target:"_blank",rel:"noopener noreferrer",children:Rk(oe.url,35)}):"—"}),l.jsx("td",{className:"na-table__time",children:Ak(oe.latestTimestamp)})]},oe.key))})]}),we.length>100&&l.jsxs("div",{className:"na-truncated",children:["Showing 100 of ",we.length," events"]})]})]})]})]})]})})}function R$(t){const e=new Map;for(const n of t){const r=`${n.email}|${n.event_type}|${n.url||""}`,s=e.get(r);s?(s.count++,n.timestamp>s.latestTimestamp&&(s.latestTimestamp=n.timestamp)):e.set(r,{key:r,email:n.email,event_type:n.event_type,url:n.url,latestTimestamp:n.timestamp,count:1})}return Array.from(e.values()).sort((n,r)=>new Date(r.latestTimestamp).getTime()-new Date(n.latestTimestamp).getTime())}function O$(t){const e=t.filter(r=>r.event_type==="click"&&r.url),n=new Map;for(const r of e){const s=r.url;let i=n.get(s);i||(i={emails:new Set,total:0},n.set(s,i)),i.emails.add(r.email),i.total++}return Array.from(n.entries()).map(([r,{emails:s,total:i}])=>({url:r,uniqueClicks:s.size,totalClicks:i})).sort((r,s)=>s.uniqueClicks-r.uniqueClicks)}function I$(t){return t.tweetContext?"tweet":t.articleContext?"article":t.linkedinContext?"linkedin":t.newsletterContext?"newsletter":t.blogContext?"blog":"tweet"}function Vl({filename:t,title:e,onClose:n}){const[r,s]=y.useState("queue"),[i,o]=y.useState(null),[c,d]=y.useState(null),[f,h]=y.useState(""),[m,g]=y.useState(!1),[v,x]=y.useState(null),[k,w]=y.useState(null);y.useEffect(()=>{fetch(`/api/documents/${encodeURIComponent(t)}/text`).then(j=>{if(!j.ok)throw new Error("Failed to load document");return j.json()}).then(j=>{d(j.text||""),o(I$(j.meta||{}))}).catch(j=>w(j.message))},[t]);const S=async()=>{var j;if(!(!c||!i)){g(!0);try{const M={content:c,content_type:i,mode:r};r==="custom"&&f&&(M.scheduled_at=new Date(f).toISOString());const _=await fetch("/api/scheduler/queue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)}),R=await _.json();if(_.ok){const L=(j=R.item)!=null&&j.scheduled_at?new Date(R.item.scheduled_at).toLocaleString():"now";x({success:!0,message:`Scheduled for ${L}`})}else x({success:!1,message:R.error||"Failed to schedule"})}catch(M){x({success:!1,message:M.message})}finally{g(!1)}}},N=i===null&&!k;return l.jsx("div",{className:"schedule-post-overlay",onClick:n,children:l.jsxs("div",{className:"schedule-post-modal",onClick:j=>j.stopPropagation(),children:[l.jsxs("div",{className:"schedule-post-modal-header",children:[l.jsx("h3",{children:"Schedule Post"}),l.jsx("button",{className:"schedule-post-modal-close",onClick:n,children:"×"})]}),l.jsx("div",{className:"schedule-post-modal-doc",children:e}),k?l.jsxs("div",{className:"schedule-post-modal-result error",children:[k,l.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):v?l.jsxs("div",{className:`schedule-post-modal-result ${v.success?"success":"error"}`,children:[v.message,l.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"schedule-post-modal-field",children:[l.jsx("label",{children:"Content Type"}),l.jsx("div",{className:"schedule-post-modal-type",children:N?"...":i})]}),l.jsxs("div",{className:"schedule-post-modal-field",children:[l.jsx("label",{children:"Mode"}),l.jsxs("div",{className:"schedule-post-modal-modes",children:[l.jsx("button",{className:`schedule-post-mode ${r==="queue"?"active":""}`,onClick:()=>s("queue"),children:"Queue Next"}),l.jsx("button",{className:`schedule-post-mode ${r==="now"?"active":""}`,onClick:()=>s("now"),children:"Post Now"}),l.jsx("button",{className:`schedule-post-mode ${r==="custom"?"active":""}`,onClick:()=>s("custom"),children:"Custom Time"})]})]}),r==="custom"&&l.jsxs("div",{className:"schedule-post-modal-field",children:[l.jsx("label",{children:"Date & Time"}),l.jsx("input",{type:"datetime-local",value:f,onChange:j=>h(j.target.value)})]}),l.jsxs("div",{className:"schedule-post-modal-actions",children:[l.jsx("button",{className:"schedule-post-modal-cancel",onClick:n,children:"Cancel"}),l.jsx("button",{className:"schedule-post-modal-submit",onClick:S,disabled:m||N||r==="custom"&&!f,children:m?"Scheduling...":r==="now"?"Post Now":"Schedule"})]})]})]})})}const Ok=[{key:"document",label:"Document"},{key:"tweet",label:"Tweet",metadata:{content_type:"tweet",tweetContext:{mode:"tweet"}}},{key:"reply",label:"Reply",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{content_type:"reply",tweetContext:{mode:"reply"}}},{key:"quote",label:"Quote Tweet",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{content_type:"quote",tweetContext:{mode:"quote"}}},{key:"article",label:"Article",metadata:{content_type:"article",articleContext:{active:!0}}},{key:"linkedin",label:"LinkedIn",metadata:{content_type:"linkedin",linkedinContext:{active:!0}}},{key:"newsletter",label:"Newsletter",metadata:{content_type:"newsletter",newsletterContext:{active:!0}}},{key:"blog",label:"Blog",metadata:{content_type:"blog",blogContext:{active:!0}}},{key:"manuscript",label:"Manuscript",metadata:{content_type:"manuscript",manuscriptContext:{active:!0}}}];function UT({anchorRect:t,onSelect:e,onClose:n}){const r=y.useRef(null),[s,i]=y.useState(null),[o,c]=y.useState(""),d=y.useRef(null),[f,h]=y.useState({left:t.left,top:t.bottom+4});y.useLayoutEffect(()=>{const x=r.current;if(!x)return;const k=x.getBoundingClientRect(),w=8;let S=t.left,N=t.bottom+4;N+k.height+w>window.innerHeight&&(N=t.top-k.height-4),S+k.width+w>window.innerWidth&&(S=t.right-k.width),N<w&&(N=w),S<w&&(S=w),h({left:S,top:N})},[t]),y.useEffect(()=>{const x=k=>{r.current&&!r.current.contains(k.target)&&n()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[n]),y.useEffect(()=>{const x=k=>{k.key==="Escape"&&n()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[n]),y.useEffect(()=>{s&&setTimeout(()=>{var x;return(x=d.current)==null?void 0:x.focus()},0)},[s]);const m=x=>{if(x.needsUrl){i(x.key),c("");return}e(x.metadata)},g=()=>{if(!s||!o.trim())return;const x=o.trim();if(!x.includes("x.com")&&!x.includes("twitter.com"))return;const k=Ok.find(S=>S.key===s);if(!(k!=null&&k.metadata))return;const w=JSON.parse(JSON.stringify(k.metadata));w.tweetContext&&(w.tweetContext.url=x),e(w)},v=o.trim().includes("x.com")||o.trim().includes("twitter.com");return l.jsx("div",{ref:r,className:"create-doc-dropdown",style:{left:f.left,top:f.top},children:Ok.map(x=>l.jsxs("div",{children:[l.jsx("button",{className:`create-doc-dropdown-item${s===x.key?" active":""}`,onClick:()=>m(x),children:x.label}),s===x.key&&l.jsxs("div",{className:"create-doc-dropdown-url",children:[l.jsx("input",{ref:d,type:"text",placeholder:x.urlPlaceholder,value:o,onChange:k=>c(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),g()),k.key==="Escape"&&(i(null),c(""))}}),l.jsx("button",{onClick:g,disabled:!v,children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})]},x.key))})}const L$=[{id:"full",label:"Full"},{id:"compact",label:"Compact"},{id:"minimal",label:"Minimal"}];function ev(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=ev(n.items,e);if(r)return[n.id,...r]}}return null}function D$({docs:t,archivedDocs:e,workspaces:n,assignedFiles:r,pendingDocs:s,onSwitchDocument:i,onCreateDocument:o,actions:c,scrollRef:d,writingTitle:f,writingTarget:h,pendingWriteFilenames:m,searchQuery:g,searchResults:v,onSearchChange:x}){const k=I=>!!m&&m.has(I),[w,S]=y.useState(null),[N,j]=y.useState(""),[M,_]=y.useState(null),[R,L]=y.useState(()=>{try{const I=localStorage.getItem("ow-collapsed-sections");return I?new Set(JSON.parse(I)):new Set}catch{return new Set}}),[$,B]=y.useState(null),[F,K]=y.useState(null),[z,ee]=y.useState(""),[P,U]=y.useState(null),[J,ie]=y.useState(""),[q,ue]=y.useState(null),[Y,A]=y.useState(""),[D,te]=y.useState(null),[fe,we]=y.useState(null),[oe,Se]=y.useState([]),[Ee,Le]=y.useState(!1),[Ie,Ve]=y.useState(null),[Te,qe]=y.useState(null),[pt,ut]=y.useState(null),[be,ht]=y.useState(null),[xt,St]=y.useState(null),[At,Ye]=y.useState(BE),ct=y.useRef(null);y.useEffect(()=>{if(!xt)return;const I=V=>{ct.current&&!ct.current.contains(V.target)&&St(null)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[xt]);const Fe=I=>{Ye(I),IM(I),St(null)},G=I=>{I.preventDefault(),St({x:I.clientX,y:I.clientY})},ge=y.useCallback((I,V)=>{fetch("/api/documents/batch-resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:I,action:V})}).catch(()=>{})},[]),{draggedItem:ne,dropIndicator:he,handlePointerDown:me,dropClass:ze,isDragging:Ae,isContainerDropTarget:Xe}=BT({docs:t,workspaces:n,assignedFiles:r,scrollRef:d,setCollapsedSections:L}),Qe=y.useCallback(()=>{fetch("/api/plugins").then(I=>I.json()).then(I=>{const V=[];let re=!1;for(const X of I.plugins||[]){const le=X.displayName||void 0;for(const ve of X.sidebarMenuItems||[])V.push({...ve,pluginDisplayName:le});X.name==="@openwriter/plugin-publish"&&X.enabled&&(re=!0)}Se(V),Le(re)}).catch(()=>{})},[]);y.useEffect(()=>{Qe()},[Qe]),y.useEffect(()=>{const I=()=>Qe();return window.addEventListener("ow-plugins-changed",I),()=>window.removeEventListener("ow-plugins-changed",I)},[Qe]);const{variantsByMaster:tt,variantFilenames:We}=y.useMemo(()=>{const I=new Map,V=new Set;for(const re of t)if(re.masterDocId){const X=I.get(re.masterDocId)||[];X.push(re),I.set(re.masterDocId,X),V.add(re.filename)}return{variantsByMaster:I,variantFilenames:V}},[t]),Ue=y.useCallback((I,V)=>{I.preventDefault(),I.stopPropagation(),te({x:I.clientX,y:I.clientY,filename:V.filename,title:V.title,docId:V.docId,lastSent:V.lastSent,postedUrl:V.postedUrl,isNewsletter:V.isNewsletter})},[]),st=y.useCallback(I=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:I})}).catch(()=>{})},[]),mt=y.useCallback((I,V,re)=>{fetch("/api/documents/variant",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:I,masterDocId:V,variantType:re})}).catch(()=>{})},[]),Nt=y.useCallback((I,V,re,X,le)=>{if(!$T(V,t.find(ve=>ve.filename===re))){if(V.promptForFocus&&le===void 0){Ve({action:I,label:V.label,filename:re,title:X});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:I,filename:re,title:X,instructions:le||"",label:V.label})}).catch(()=>{})}},[t]),Mt=I=>{L(V=>{const re=new Set(V);return re.has(I)?re.delete(I):re.add(I),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...re])),re})},Jt=y.useRef(n);Jt.current=n;const nn=y.useCallback(I=>{var V;for(const re of Jt.current){const X=ev(((V=re.workspace)==null?void 0:V.root)||[],I);if(X){L(le=>{const ve=[re.filename,...X.map(ye=>`container-${ye}`)];if(ve.every(ye=>!le.has(ye)))return le;const Re=new Set(le);for(const ye of ve)Re.delete(ye);return localStorage.setItem("ow-collapsed-sections",JSON.stringify([...Re])),Re});break}}},[]);Wl(d,t,n.length,nn);const at=y.useMemo(()=>{var X;const I=t.find(le=>le.isActive);if(!I)return null;const V=I.masterDocId?t.find(le=>le.docId===I.masterDocId):void 0,re=(V==null?void 0:V.filename)??I.filename;for(const le of n){const ve=ev(((X=le.workspace)==null?void 0:X.root)||[],re);if(ve)return{wsFilename:le.filename,containerKeys:new Set(ve.map(Re=>`container-${Re}`)),masterDocId:(V==null?void 0:V.docId)??null}}return{wsFilename:null,containerKeys:new Set,masterDocId:(V==null?void 0:V.docId)??null}},[t,n]);if(v!==null)return l.jsx(rf,{results:v,query:g,onSwitchDocument:i,actions:c});const Ht=t.filter(I=>!r.has(I.filename)&&!We.has(I.filename)),T=(I,V,re,X,le,ve=!1)=>l.jsxs("div",{className:`sidebar-item ${I.isActive?"active":""} ${Ae(I.filename)?"dragging":""} ${ze(I.filename)}`,"data-drag-id":I.filename,"data-drag-type":"doc","data-drag-ws":V||"__docs__","data-drag-container":re||"",onPointerDown:Re=>me(Re,{type:"doc",file:I.filename,sourceWs:V||null},I.title),onClick:()=>!I.isActive&&!ne&&i(I.filename),onDoubleClick:()=>{S(I.filename),j(I.title)},onContextMenu:Re=>Ue(Re,I),children:[w===I.filename?l.jsx("input",{className:"sidebar-rename-input",value:N,onChange:Re=>j(Re.target.value),onBlur:()=>{c.handleRename(I.filename,I.title,N),S(null)},onKeyDown:Re=>{Re.key==="Enter"&&(c.handleRename(I.filename,I.title,N),S(null)),Re.key==="Escape"&&S(null)},autoFocus:!0,onClick:Re=>Re.stopPropagation()}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-item-title-text",children:I.title}),I.variantType&&l.jsx("span",{className:"files-badge-variant",children:I.variantType}),c.getDocTags(I.filename).includes("✓")&&l.jsx("svg",{className:"sidebar-approved-icon",title:"Approved",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),I.lastSent&&l.jsx("svg",{className:"sidebar-sent-icon",title:"Sent",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),(I.autoAccept===!0||I.autoAccept!==!1&&ve)&&l.jsx("span",{className:"sidebar-auto-accept-dot",title:I.autoAccept===!0?"Auto-accept on":"Auto-accept inherited"}),s.filenames.includes(I.filename)&&l.jsx("span",{className:"sidebar-pending-dot"})]}),Vs(I.filename)&&l.jsx("div",{className:"sidebar-item-context",children:DT(I.filename)}),l.jsxs("div",{className:"sidebar-item-meta",children:[I.wordCount.toLocaleString()," words · ",ba(I.lastModified)]}),l.jsxs("div",{className:"sidebar-tags",children:[c.getDocTags(I.filename).filter(Re=>Re!=="✓").map(Re=>l.jsxs("span",{className:"sidebar-tag",onClick:ye=>ye.stopPropagation(),children:[Re,l.jsx("span",{className:"sidebar-tag-remove",onClick:ye=>{ye.stopPropagation(),c.handleRemoveTag(I.filename,Re)},children:"×"})]},Re)),q===I.filename?l.jsx("input",{className:"sidebar-tag-input",value:Y,onChange:Re=>A(Re.target.value),onBlur:()=>{Y.trim()&&c.handleAddTag(I.filename,Y),ue(null)},onKeyDown:Re=>{Re.key==="Enter"&&(c.handleAddTag(I.filename,Y),ue(null),A("")),Re.key==="Escape"&&(ue(null),A(""))},autoFocus:!0,onClick:Re=>Re.stopPropagation(),placeholder:"tag..."}):l.jsx("button",{className:"sidebar-tag-add",onClick:Re=>{Re.stopPropagation(),ue(I.filename),A("")},children:"+"})]})]}),M===I.filename?l.jsxs("div",{className:"sidebar-confirm-delete",onClick:Re=>Re.stopPropagation(),children:[l.jsx("span",{children:Vs(I.filename)?"Remove?":"Delete?"}),l.jsx("button",{onClick:()=>{c.handleDelete(I.filename),_(null)},children:"Yes"}),l.jsx("button",{onClick:()=>_(null),children:"No"})]}):l.jsx("button",{className:"sidebar-delete-btn",onClick:Re=>{Re.stopPropagation(),_(I.filename)},title:Vs(I.filename)?"Remove document":"Delete document",children:"×"})]},I.filename),W=(I,V,re,X,le,ve=!1)=>{const Re=I.docId?tt.get(I.docId):void 0,ye=f&&(h==null?void 0:h.parentDocId)&&h.parentDocId===I.docId;if(!(Re&&Re.length>0||ye))return T(I,V,re,X,le,ve);const Et=`variants-${I.docId}`,dn=!R.has(Et);return l.jsxs("div",{className:"sidebar-variant-group",children:[l.jsxs("div",{className:`sidebar-variant-master${!dn&&(at==null?void 0:at.masterDocId)===I.docId?" active-within":""}`,onClick:Xt=>{Xt.target.closest(".sidebar-variant-chevron")&&(Xt.stopPropagation(),Mt(Et))},children:[T(I,V,re,X,le,ve),l.jsx("span",{className:`sidebar-variant-chevron${dn?"":" collapsed"}`,children:l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),dn&&l.jsxs("div",{className:"sidebar-variant-children",children:[Re==null?void 0:Re.map((Xt,ln)=>T(Xt,V,re,X,ln,ve)),ye&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:f})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]})]})]},`vg-${I.filename}`)},ae=(I,V,re,X,le,ve,Re=!1)=>{if(I.type==="doc"){const $e=t.find(zt=>zt.filename===I.file);return $e?We.has($e.filename)?l.jsx(l.Fragment,{}):W($e,re,X,le,ve,Re):Vs(I.file)?l.jsx("div",{className:"sidebar-item sidebar-unavailable",children:l.jsxs("div",{className:"sidebar-item-title",children:[I.title||I.file," (unavailable)"]})},I.file):l.jsxs("div",{className:"sidebar-item sidebar-missing",children:[l.jsxs("div",{className:"sidebar-item-title",children:[I.title||I.file," (missing)"]}),l.jsx("button",{className:"sidebar-delete-btn",onClick:()=>c.handleRemoveFromWorkspace(re,I.file),title:"Remove",children:"×"})]},I.file)}const ye=I,Dt=`container-${ye.id}`,Et=R.has(Dt),dn=V<=2?`depth-${V}`:"depth-2",Xt=ye.autoAccept===!0,ln=Xt||Re;return l.jsxs("div",{className:`sidebar-container ${dn} ${Et?"collapsed":""} ${ze(ye.id)} ${Xe(ye.id)?"drop-inside":""}`,children:[l.jsxs("div",{className:`sidebar-container-header${Et&&(at!=null&&at.containerKeys.has(Dt))?" active-within":""} ${(he==null?void 0:he.itemId)===ye.id&&he.position==="inside"?"drop-inside":""}`,"data-drag-id":ye.id,"data-drag-type":"container-header","data-drag-ws":re,"data-drag-parent":X||"","data-section-key":Dt,onPointerDown:$e=>me($e,{type:"container",id:ye.id,sourceWs:re},ye.name),onClick:()=>!ne&&Mt(Dt),onContextMenu:$e=>{$e.preventDefault(),$e.stopPropagation(),ht({x:$e.clientX,y:$e.clientY,type:"container",wsFilename:re,containerId:ye.id,title:ye.name,nodes:ye.items,autoAccept:Xt})},children:[l.jsx("span",{className:`sidebar-chevron ${Et?"collapsed":""}`,children:"▾"}),F===ye.id?l.jsx("input",{className:"sidebar-rename-input",value:z,onChange:$e=>ee($e.target.value),onBlur:()=>{c.handleRenameContainer(re,ye.id,z),K(null)},onKeyDown:$e=>{$e.key==="Enter"&&(c.handleRenameContainer(re,ye.id,z),K(null)),$e.key==="Escape"&&K(null)},autoFocus:!0,onClick:$e=>$e.stopPropagation()}):l.jsx("span",{className:"sidebar-container-name",onDoubleClick:$e=>{$e.stopPropagation(),K(ye.id),ee(ye.name)},children:ye.name}),ln&&l.jsx("span",{className:"sidebar-auto-accept-dot",title:Xt?"Auto-accept on for this container":"Auto-accept inherited from workspace"}),l.jsxs("div",{className:"sidebar-container-actions",children:[l.jsx("button",{className:"sidebar-new-btn",onClick:$e=>{$e.stopPropagation(),ut({anchor:$e.target.getBoundingClientRect(),wsFilename:re,containerId:ye.id})},title:"New doc",children:"+"}),V<2&&l.jsx("button",{className:"sidebar-new-btn",onClick:$e=>{$e.stopPropagation(),c.handleCreateContainer(re,ye.id)},title:"New sub-container",children:"☐"}),l.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:$e=>{$e.stopPropagation(),c.handleDeleteContainer(re,ye.id)},title:"Delete container",children:"×"})]})]}),!Et&&l.jsxs("div",{className:"sidebar-container-list","data-drop-ws":re,"data-drop-container":ye.id,children:[f&&!(h!=null&&h.parentDocId)&&(h==null?void 0:h.wsFilename)===re&&h.containerId===ye.id&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:f})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),ye.items.filter($e=>$e.type!=="doc"?!0:!(k($e.file)||f&&(h==null?void 0:h.wsFilename)===re&&h.containerId===ye.id&&$e.title===f)).map(($e,zt)=>ae($e,V+1,re,ye.id,ye.items,zt,ln)),ye.items.length===0&&!f&&l.jsx("div",{className:"sidebar-empty",children:ne?"Drop here":"Empty"})]})]},ye.id)};return l.jsxs("div",{className:"sidebar-scroll",ref:d,children:[l.jsxs("div",{className:`sidebar-section sidebar-docs-section ${R.has("docs")?"docs-collapsed":""}`,children:[l.jsxs("div",{className:`sidebar-section-header${R.has("docs")&&at!==null&&at.wsFilename===null?" active-within":""}`,"data-section-key":"docs",onClick:()=>Mt("docs"),onContextMenu:G,children:[l.jsx("span",{className:`sidebar-chevron ${R.has("docs")?"collapsed":""}`,children:"▾"}),l.jsx("span",{className:"sidebar-label",children:"Documents"}),l.jsx("button",{className:"sidebar-new-btn",onClick:I=>{I.stopPropagation(),ut({anchor:I.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),!R.has("docs")&&l.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[f&&!(h!=null&&h.parentDocId)&&(!h||!n.some(I=>I.filename===(h==null?void 0:h.wsFilename)))&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:f})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),Ht.filter(I=>!k(I.filename)&&(!f||I.title!==f)).map((I,V)=>{const re=Ht.map(X=>({type:"doc",file:X.filename,title:X.title}));return W(I,void 0,null,re,V)}),Ht.length===0&&l.jsx("div",{className:"sidebar-empty",children:ne?"Drop here to unassign":"No unassigned documents"})]})]}),n.map(I=>{var le,ve,Re;const V=((le=I.workspace)==null?void 0:le.root)||[],re=R.has(I.filename),X=((ve=I.workspace)==null?void 0:ve.autoAccept)===!0||I.autoAccept===!0;return l.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${re?"ws-collapsed":""} ${Ae(I.filename)?"dragging":""} ${(he==null?void 0:he.itemId)===I.filename?he.position==="before"?"drop-before":"drop-after":""}`,children:[l.jsxs("div",{className:`sidebar-section-header${re&&(at==null?void 0:at.wsFilename)===I.filename?" active-within":""}`,"data-section-key":I.filename,"data-ws-drag":I.filename,onPointerDown:ye=>me(ye,{type:"workspace",filename:I.filename},I.title),onClick:()=>!ne&&Mt(I.filename),onContextMenu:ye=>{var Dt;ye.preventDefault(),ye.stopPropagation(),ht({x:ye.clientX,y:ye.clientY,type:"workspace",wsFilename:I.filename,title:I.title,nodes:V,autoAccept:((Dt=I.workspace)==null?void 0:Dt.autoAccept)===!0||I.autoAccept===!0})},children:[l.jsx("span",{className:`sidebar-chevron ${re?"collapsed":""}`,children:"▾"}),P===I.filename?l.jsx("input",{className:"sidebar-rename-input",value:J,onChange:ye=>ie(ye.target.value),onBlur:()=>{c.handleRenameWorkspace(I.filename,J),U(null)},onKeyDown:ye=>{ye.key==="Enter"&&(c.handleRenameWorkspace(I.filename,J),U(null)),ye.key==="Escape"&&U(null)},autoFocus:!0,onClick:ye=>ye.stopPropagation()}):l.jsx("span",{className:"sidebar-label sidebar-workspace-label",onDoubleClick:ye=>{ye.stopPropagation(),U(I.filename),ie(I.title)},children:I.title}),(((Re=I.workspace)==null?void 0:Re.autoAccept)===!0||I.autoAccept===!0)&&l.jsx("span",{className:"sidebar-auto-accept-dot",title:"Auto-accept on for this workspace"}),l.jsxs("div",{className:"sidebar-workspace-actions",children:[l.jsx("button",{className:"sidebar-new-btn",onClick:ye=>{ye.stopPropagation(),ut({anchor:ye.target.getBoundingClientRect(),wsFilename:I.filename,containerId:null})},title:"New document",children:"+"}),l.jsx("button",{className:"sidebar-new-btn",onClick:ye=>{ye.stopPropagation(),c.handleCreateContainer(I.filename,null)},title:"New container",children:"☐"}),$===I.filename?l.jsxs("span",{className:"sidebar-inline-confirm",onClick:ye=>ye.stopPropagation(),children:[l.jsx("button",{onClick:()=>{c.handleDeleteWorkspace(I.filename),B(null)},children:"Yes"}),l.jsx("button",{onClick:()=>B(null),children:"No"})]}):l.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:ye=>{ye.stopPropagation(),B(I.filename)},title:"Delete workspace",children:"×"})]})]}),!re&&l.jsxs("div",{className:"sidebar-section-list","data-drop-ws":I.filename,children:[f&&!(h!=null&&h.parentDocId)&&(h==null?void 0:h.wsFilename)===I.filename&&h.containerId===null&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:f})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),V.filter(ye=>ye.type!=="doc"?!0:!(k(ye.file)||f&&(h==null?void 0:h.wsFilename)===I.filename&&h.containerId===null&&ye.title===f)).map((ye,Dt)=>ae(ye,0,I.filename,null,V,Dt,X)),V.length===0&&!f&&l.jsx("div",{className:"sidebar-empty",children:ne?"Drop here to add":"Empty workspace"})]})]},I.filename)}),l.jsx("div",{className:"sidebar-new-workspace",children:l.jsx("button",{onClick:c.handleCreateWorkspace,children:"+ New Workspace"})}),be&&l.jsx(Bd,{x:be.x,y:be.y,filename:be.wsFilename,title:be.title,onClose:()=>ht(null),onDuplicate:()=>{},onRename:()=>{be.type==="workspace"?(U(be.wsFilename),ie(be.title)):be.containerId&&(K(be.containerId),ee(be.title)),ht(null)},onArchive:()=>{},onDelete:()=>{be.type==="workspace"?c.handleDeleteWorkspace(be.wsFilename):be.containerId&&c.handleDeleteContainer(be.wsFilename,be.containerId)},onPluginAction:()=>{},pluginItems:[],folderMode:!0,onNewDoc:I=>{ut({anchor:I.target.getBoundingClientRect(),wsFilename:be.wsFilename,containerId:be.type==="container"?be.containerId:null}),ht(null)},onNewContainer:()=>{c.handleCreateContainer(be.wsFilename,be.type==="container"?be.containerId:null),ht(null)},onAcceptAll:()=>{const I=new Set;Ll(be.nodes,I),I.size&&ge([...I],"accept"),ht(null)},onRejectAll:()=>{const I=new Set;Ll(be.nodes,I),I.size&&ge([...I],"reject"),ht(null)},folderAutoAccept:be.autoAccept,folderAutoAcceptLabel:be.type==="workspace"?"for workspace":"for container",onToggleFolderAutoAccept:()=>{fetch("/api/auto-accept/inherit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wsFile:be.wsFilename,...be.type==="container"?{containerId:be.containerId}:{},enabled:!be.autoAccept})}).catch(()=>{})}}),D&&l.jsx(Bd,{x:D.x,y:D.y,filename:D.filename,title:D.title,onClose:()=>te(null),onDuplicate:()=>st(D.filename),onCreateVariant:D.docId?I=>mt(D.filename,D.docId,I):void 0,onRename:()=>{S(D.filename),j(D.title)},onArchive:()=>c.handleArchive(D.filename),onDelete:()=>c.handleDelete(D.filename),onPluginAction:(I,V)=>Nt(I,V,D.filename,D.title),pluginItems:oe,onSchedulePost:Ee?()=>{qe({filename:D.filename,title:D.title}),te(null)}:void 0,onViewAnalytics:D.docId&&D.lastSent&&(D.postedUrl||D.isNewsletter)?()=>{D.isNewsletter?we({docId:D.docId,title:D.title}):D.postedUrl&&window.open(D.postedUrl,"_blank"),te(null)}:void 0,viewAnalyticsLabel:D.isNewsletter?"View Analytics":D.postedUrl?"View on X":"View Analytics",isApproved:c.getDocTags(D.filename).includes("✓"),onToggleApprove:()=>{c.getDocTags(D.filename).includes("✓")?c.handleRemoveTag(D.filename,"✓"):(c.handleAddTag(D.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAutoAccept:(()=>{var V;const I=(V=t.find(re=>re.filename===D.filename))==null?void 0:V.autoAccept;return I===!0?!0:I===!1?!1:Pd(n,D.filename)})(),onToggleAutoAccept:()=>{var re;const I=(re=t.find(X=>X.filename===D.filename))==null?void 0:re.autoAccept,V=I===!0?!0:I===!1?!1:Pd(n,D.filename);fetch("/api/auto-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:D.filename,enabled:!V})}).then(()=>c.fetchDocs()).catch(()=>{})},isAlreadySent:!!D.lastSent,onMarkSent:()=>{const I=D.filename;c.getDocTags(I).includes("✓")&&c.handleRemoveTag(I,"✓"),i(I),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>c.fetchDocs()).catch(()=>{})},100),te(null)}}),Ie&&l.jsx(FT,{actionLabel:Ie.label,docTitle:Ie.title,onClose:()=>Ve(null),onConfirm:I=>{const V=oe.find(re=>re.action===Ie.action);V&&Nt(Ie.action,V,Ie.filename,Ie.title,I),Ve(null)}}),fe&&l.jsx(zT,{docId:fe.docId,title:fe.title,onClose:()=>we(null)}),Te&&l.jsx(Vl,{filename:Te.filename,title:Te.title,onClose:()=>qe(null)}),pt&&l.jsx(UT,{anchorRect:pt.anchor,onClose:()=>ut(null),onSelect:I=>{ut(null),pt.wsFilename?c.handleCreateInWorkspace(pt.wsFilename,pt.containerId??null,I):I?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:I})}).catch(()=>{}):o()}}),xt&&l.jsx("div",{ref:ct,className:"sidebar-density-dropdown",style:{position:"fixed",left:xt.x,top:xt.y,zIndex:200},children:L$.map(I=>l.jsx("button",{className:`sidebar-density-option ${At===I.id?"active":""}`,onClick:()=>Fe(I.id),children:I.label},I.id))})]})}function P$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:o,scrollRef:c,searchQuery:d,searchResults:f}){const[h,m]=y.useState(null);if(Wl(c,t,e.length),f!==null)return l.jsx(rf,{results:f,query:d,onSwitchDocument:s});const g=[...t].sort((w,S)=>new Date(S.lastModified).getTime()-new Date(w.lastModified).getTime()),v=[];let x="";for(const w of g){const S=_$(w.lastModified);S!==x&&(v.push({label:S,docs:[]}),x=S),v[v.length-1].docs.push(w)}const k=w=>{for(const S of e){if(!S.workspace)continue;const N=j=>{for(const M of j)if(M.type==="doc"&&M.file===w||M.type==="container"&&N(M.items))return!0;return!1};if(N(S.workspace.root))return S.title}return null};return l.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:c,children:[l.jsxs("div",{className:"tl-header",children:[l.jsx("span",{className:"tl-title",children:"Timeline"}),l.jsx("button",{className:"sidebar-new-btn",onClick:i,title:"New document",children:"+"})]}),v.map(w=>l.jsxs("div",{className:"tl-group",children:[l.jsx("div",{className:"tl-date",children:w.label}),w.docs.map(S=>{const N=k(S.filename);return l.jsxs("div",{className:`tl-item ${S.isActive?"active":""}`,onClick:()=>!S.isActive&&s(S.filename),children:[l.jsx("div",{className:"tl-dot"}),l.jsxs("div",{className:"tl-content",children:[l.jsxs("div",{className:"tl-item-title",children:[l.jsx("span",{children:S.title}),r.filenames.includes(S.filename)&&l.jsx("span",{className:"sidebar-pending-dot"})]}),Vs(S.filename)&&l.jsx("div",{className:"tl-item-context",children:DT(S.filename)}),l.jsxs("div",{className:"tl-item-meta",children:[S.wordCount.toLocaleString()," words · ",ba(S.lastModified)]}),N&&l.jsx("div",{className:"tl-badge",children:N})]}),h===S.filename?l.jsxs("div",{className:"sidebar-confirm-delete",onClick:j=>j.stopPropagation(),children:[l.jsx("span",{children:Vs(S.filename)?"Remove?":"Delete?"}),l.jsx("button",{onClick:()=>{o.handleDelete(S.filename),m(null)},children:"Yes"}),l.jsx("button",{onClick:()=>m(null),children:"No"})]}):l.jsx("button",{className:"sidebar-delete-btn",onClick:j=>{j.stopPropagation(),m(S.filename)},title:Vs(S.filename)?"Remove":"Delete",children:"×"})]},S.filename)})]},w.label)),t.length===0&&l.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function B$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:c,searchResults:d,onSearchChange:f}){const[h,m]=y.useState([]),[g,v]=y.useState(null);Wl(o,t,e.length);const[x,k]=y.useState(null),w=y.useRef(null);y.useEffect(()=>{if(!g)return;const A=D=>{w.current&&!w.current.contains(D.target)&&v(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[g]);const S=(A,D)=>{for(const te of A)if(te.type==="container"){if(te.id===D)return te;const fe=S(te.items,D);if(fe)return fe}return null},N=A=>{let D=0;for(const te of A)te.type==="doc"?D++:te.type==="container"&&(D+=N(te.items));return D},j=A=>{const D=[];for(const te of A)te.type==="doc"?D.push(te.file):te.type==="container"&&D.push(...j(te.items));return D},M=y.useMemo(()=>{if(h.length===0)return[];const A=h[h.length-1],D=e.find(fe=>fe.filename===A.wsFilename);if(!(D!=null&&D.workspace))return[];if(A.type==="workspace")return D.workspace.root;const te=S(D.workspace.root,A.key);return te?te.items:[]},[h,e]),_=M.filter(A=>A.type==="container"),R=y.useMemo(()=>{const A=M.filter(D=>D.type==="doc").map(D=>D.file);return t.filter(D=>A.includes(D.filename))},[M,t]),L=A=>{const D=j(A.items);return t.filter(te=>D.includes(te.filename))},$=A=>{const D=e.find(fe=>fe.filename===A);if(!(D!=null&&D.workspace))return[];const te=j(D.workspace.root);return t.filter(fe=>te.includes(fe.filename))},B=y.useMemo(()=>t.filter(A=>!n.has(A.filename)),[t,n]),F=A=>{m(D=>[...D,A]),v(null)},K=()=>{m(A=>A.slice(0,-1)),v(null)},z=(A,D)=>{if(g===A){v(null);return}const fe=D.currentTarget.getBoundingClientRect();k({top:fe.bottom+4,left:fe.left}),v(A)},ee=A=>{s(A),v(null)},P=h.length>1?h[h.length-2].title:"All",U=y.useRef(null),J=y.useRef(null),[ie,q]=y.useState(null),ue=y.useCallback(A=>{const te=A.currentTarget.getBoundingClientRect();q({top:te.bottom+4,left:te.left})},[]);y.useEffect(()=>{if(!d)return;const A=D=>{J.current&&!J.current.contains(D.target)&&U.current&&!U.current.contains(D.target)&&f("")};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[d,f]);const Y=()=>{if(!g)return[];if(g==="__unassigned__")return B;if(g==="__level-docs__")return R;const A=e.find(D=>D.filename===g);if(A)return $(A.filename);for(const D of e){if(!D.workspace)continue;const te=S(D.workspace.root,g);if(te)return L(te)}return[]};return l.jsxs("div",{className:"board-scroll",ref:o,children:[l.jsxs("div",{className:"board-search-pill",children:[l.jsxs("svg",{className:"board-search-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"11",cy:"11",r:"8"}),l.jsx("path",{d:"m21 21-4.3-4.3"})]}),l.jsx("input",{ref:U,className:"board-search-input",type:"text",placeholder:"Search...",value:c,onChange:A=>f(A.target.value),onFocus:ue}),c&&l.jsx("button",{className:"board-search-clear",onClick:()=>f(""),children:"×"})]}),h.length===0?l.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):l.jsxs("button",{className:"board-back",onClick:K,title:`Back to ${P}`,children:["← ",P]}),h.length===0&&l.jsxs(l.Fragment,{children:[B.length>0&&l.jsxs("button",{className:`board-chip ${g==="__unassigned__"?"open":""}`,onClick:A=>z("__unassigned__",A),children:["Documents ",l.jsx("span",{className:"board-chip-count",children:B.length})]}),e.map(A=>{var te;const D=(te=A.workspace)==null?void 0:te.root.some(fe=>fe.type==="container");return l.jsxs("button",{className:`board-chip ${g===A.filename?"open":""}`,onClick:fe=>D?F({type:"workspace",key:A.filename,title:A.title,wsFilename:A.filename}):z(A.filename,fe),children:[A.title," ",l.jsx("span",{className:"board-chip-count",children:A.docCount}),D&&l.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.filename)}),l.jsx("button",{className:"board-chip board-chip-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),h.length>0&&l.jsxs(l.Fragment,{children:[R.length>0&&l.jsxs("button",{className:`board-chip board-chip-docs ${g==="__level-docs__"?"open":""}`,onClick:A=>z("__level-docs__",A),children:["Docs ",l.jsx("span",{className:"board-chip-count",children:R.length})]}),_.map(A=>{const D=A.items.some(te=>te.type==="container");return l.jsxs("button",{className:`board-chip ${g===A.id?"open":""}`,onClick:te=>D?F({type:"container",key:A.id,title:A.name,wsFilename:h[h.length-1].wsFilename}):z(A.id,te),children:[A.name," ",l.jsx("span",{className:"board-chip-count",children:N(A.items)}),D&&l.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.id)})]}),g&&x&&(()=>{const A=Y();return l.jsxs("div",{className:"board-dropdown",ref:w,style:{position:"fixed",top:x.top,left:x.left},children:[A.map(D=>l.jsxs("div",{className:`board-dropdown-item ${D.isActive?"active":""}`,onClick:()=>ee(D.filename),children:[l.jsxs("span",{className:"board-dropdown-title",children:[D.title,r.filenames.includes(D.filename)&&l.jsx("span",{className:"board-pending-dot"})]}),l.jsxs("span",{className:"board-dropdown-meta",children:[D.wordCount.toLocaleString()," words · ",ba(D.lastModified)]})]},D.filename)),A.length===0&&l.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})(),d&&ie&&l.jsxs("div",{className:"board-dropdown board-search-dropdown",ref:J,style:{position:"fixed",top:ie.top,left:ie.left},children:[d.map(A=>l.jsxs("div",{className:`board-dropdown-item ${A.isActive?"active":""}`,onClick:()=>{s(A.filename),f("")},children:[l.jsx("span",{className:"board-dropdown-title",children:A.title}),A.matchType==="tag"&&A.matchedTag&&l.jsxs("span",{className:"board-dropdown-meta",children:["Tag: ",A.matchedTag]}),A.matchType==="content"&&A.snippet&&l.jsx("span",{className:"board-dropdown-meta board-search-snippet",children:A.snippet}),l.jsxs("span",{className:"board-dropdown-meta",children:[A.wordCount.toLocaleString()," words · ",ba(A.lastModified)]})]},A.filename)),d.length===0&&l.jsx("div",{className:"board-dropdown-empty",children:"No results"})]})]})}function $$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:c,searchResults:d}){const[f,h]=y.useState([]);if(Wl(o,t,e.length),d!==null)return l.jsx(rf,{results:d,query:c,onSwitchDocument:s});const m=(M,_)=>{for(const R of M)if(R.type==="container"){if(R.id===_)return R;const L=m(R.items,_);if(L)return L}return null},g=M=>{let _=0;for(const R of M)R.type==="doc"?_++:R.type==="container"&&(_+=g(R.items));return _},v=y.useMemo(()=>{if(f.length===0)return[];const M=f[f.length-1],_=e.find(L=>L.filename===M.wsFilename);if(!(_!=null&&_.workspace))return[];if(M.type==="workspace")return _.workspace.root;const R=m(_.workspace.root,M.key);return R?R.items:[]},[f,e]),x=v.filter(M=>M.type==="container"),k=y.useMemo(()=>{if(f.length===0)return t.filter(_=>!n.has(_.filename));const M=v.filter(_=>_.type==="doc").map(_=>_.file);return t.filter(_=>M.includes(_.filename))},[f,v,t,n]),w=M=>h(_=>[..._,M]),S=()=>h(M=>M.slice(0,-1)),N=f.length>1?f[f.length-2].title:"Shelf",j=f.length>0?f[f.length-1].title:"Documents";return l.jsxs("div",{className:"shelf-wrapper",children:[l.jsxs("div",{className:"shelf-spines",ref:o,children:[f.length>0&&l.jsxs("button",{className:"shelf-back",onClick:S,title:`Back to ${N}`,children:[l.jsx("span",{className:"shelf-back-arrow",children:"←"}),l.jsx("span",{className:"shelf-back-label",children:N})]}),f.length===0&&l.jsxs(l.Fragment,{children:[e.map(M=>l.jsxs("div",{className:"shelf-section-spine",onClick:()=>w({type:"workspace",key:M.filename,title:M.title,wsFilename:M.filename}),title:M.title,children:[l.jsx("span",{className:"shelf-section-title",children:M.title}),l.jsx("span",{className:"shelf-section-count",children:M.docCount})]},M.filename)),l.jsx("button",{className:"shelf-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),f.length>0&&x.map(M=>l.jsxs("div",{className:"shelf-section-spine shelf-section-container",onClick:()=>w({type:"container",key:M.id,title:M.name,wsFilename:f[f.length-1].wsFilename}),title:M.name,children:[l.jsx("span",{className:"shelf-section-title",children:M.name}),l.jsx("span",{className:"shelf-section-count",children:g(M.items)})]},M.id))]}),l.jsxs("div",{className:"shelf-docs",children:[l.jsx("div",{className:"shelf-docs-header",children:j}),l.jsxs("div",{className:"shelf-docs-list",children:[k.map(M=>l.jsxs("div",{className:`shelf-doc-item ${M.isActive?"active":""}`,onClick:()=>s(M.filename),children:[l.jsxs("div",{className:"shelf-doc-title",children:[l.jsx("span",{children:M.title}),r.filenames.includes(M.filename)&&l.jsx("span",{className:"shelf-pending-dot"})]}),l.jsxs("div",{className:"shelf-doc-meta",children:[M.wordCount.toLocaleString()," words · ",ba(M.lastModified)]})]},M.filename)),k.length===0&&l.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}async function Ik(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();if((i=(s=r==null?void 0:r.content)==null?void 0:s[0])!=null&&i.text)try{return JSON.parse(r.content[0].text)}catch{return r.content[0].text}return r}function HT({filename:t,title:e,isActive:n,onSwitchDocument:r,onClose:s}){const[i,o]=y.useState("loading"),[c,d]=y.useState([]),[f,h]=y.useState(null),[m,g]=y.useState(null),[v,x]=y.useState(null);y.useEffect(()=>{Ik("list_blog_sites").then(S=>{if(S.error){g(S.error),o("error");return}const N=S.sites||[];d(N),N.length===0?o("pick"):N.length===1?(h(N[0].id),o("confirm")):o("pick")}).catch(S=>{g((S==null?void 0:S.message)||"Failed to load blog sites"),o("error")})},[]);const k=c.find(S=>S.id===f)||null,w=async()=>{if(k){o("posting"),g(null),n||(r(t),await new Promise(S=>setTimeout(S,350)));try{const S=await Ik("post_to_blog",{site_id:k.id});if(S!=null&&S.error){g(S.error),o("error");return}const N=S.commit?`https://github.com/${k.owner}/${k.repo}/commit/${S.commit}`:void 0;x({message:S.message,file:S.file,commit:S.commit,images_committed:S.images_committed,liveUrl:S.live_url,commitUrl:N,warning:S.warning}),o("done")}catch(S){g((S==null?void 0:S.message)||"Publish failed"),o("error")}}};return l.jsx("div",{className:"post-blog-overlay",onClick:()=>{i!=="posting"&&s()},children:l.jsxs("div",{className:"post-blog-modal",onClick:S=>S.stopPropagation(),children:[l.jsxs("div",{className:"post-blog-modal-header",children:[l.jsx("h3",{children:"Post to Blog"}),l.jsx("button",{className:"post-blog-modal-close",onClick:s,disabled:i==="posting",children:"×"})]}),l.jsx("div",{className:"post-blog-modal-doc",children:e}),i==="loading"&&l.jsx("div",{className:"post-blog-modal-loading",children:"Loading blog sites…"}),i==="pick"&&c.length===0&&l.jsxs("div",{className:"post-blog-modal-empty",children:["No blog sites registered. Add one in ",l.jsx("strong",{children:"Settings → Plugins → GitHub"})," first.",l.jsx("button",{className:"post-blog-modal-done",onClick:s,children:"Close"})]}),i==="pick"&&c.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"post-blog-modal-label",children:"Choose a destination"}),l.jsx("div",{className:"post-blog-modal-sites",children:c.map(S=>l.jsxs("button",{className:`post-blog-modal-site${f===S.id?" post-blog-modal-site--selected":""}`,onClick:()=>{h(S.id),o("confirm")},children:[l.jsx("div",{className:"post-blog-modal-site-label",children:S.label}),l.jsxs("div",{className:"post-blog-modal-site-repo",children:[S.owner,"/",S.repo,"@",S.branch]})]},S.id))})]}),i==="confirm"&&k&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"post-blog-modal-confirm",children:["Publish to ",l.jsxs("strong",{children:[k.owner,"/",k.repo,"@",k.branch]}),"?",l.jsxs("div",{className:"post-blog-modal-target-dir",children:["→ ",k.content_dir]})]}),l.jsxs("div",{className:"post-blog-modal-actions",children:[l.jsx("button",{className:"post-blog-modal-btn post-blog-modal-btn--primary",onClick:w,children:"Publish now"}),c.length>1&&l.jsx("button",{className:"post-blog-modal-btn",onClick:()=>o("pick"),children:"Back"}),l.jsx("button",{className:"post-blog-modal-btn",onClick:s,children:"Cancel"})]})]}),i==="posting"&&l.jsx("div",{className:"post-blog-modal-loading",children:"Publishing…"}),i==="done"&&v&&l.jsxs("div",{className:"post-blog-modal-result post-blog-modal-result--success",children:[l.jsx("div",{children:v.message||"Published"}),v.file&&l.jsx("div",{className:"post-blog-modal-meta",children:v.file}),typeof v.images_committed=="number"&&v.images_committed>0&&l.jsxs("div",{className:"post-blog-modal-meta",children:[v.images_committed," image",v.images_committed===1?"":"s"," committed"]}),v.warning&&l.jsx("div",{className:"post-blog-modal-warning",children:v.warning}),l.jsxs("div",{className:"post-blog-modal-actions",children:[v.liveUrl?l.jsx("button",{className:"post-blog-modal-btn post-blog-modal-btn--primary",onClick:()=>window.open(v.liveUrl,"_blank"),children:"View Post"}):v.commitUrl?l.jsx("button",{className:"post-blog-modal-btn post-blog-modal-btn--primary",onClick:()=>window.open(v.commitUrl,"_blank"),children:"View commit"}):null,l.jsx("button",{className:"post-blog-modal-btn",onClick:s,children:"Done"})]}),v.liveUrl&&v.commitUrl&&l.jsx("button",{className:"post-blog-modal-commit-link",onClick:()=>window.open(v.commitUrl,"_blank"),children:"View commit"})]}),i==="error"&&l.jsxs("div",{className:"post-blog-modal-result post-blog-modal-result--error",children:[l.jsx("div",{children:m||"Publish failed"}),l.jsx("div",{className:"post-blog-modal-actions",children:l.jsx("button",{className:"post-blog-modal-btn",onClick:s,children:"Close"})})]})]})})}const F$=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h4l2 2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2z"}),l.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14",opacity:"0.5"})]}),z$=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),l.jsx("polyline",{points:"14 2 14 8 20 8"}),l.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),l.jsx("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]}),U$=()=>l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:l.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),H$=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[l.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),l.jsx("path",{d:"M7 15l-4-3.5L7 8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),W$=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[l.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),l.jsx("path",{d:"M3 8V6.5C3 5.67 3.67 5 4.5 5h2C7.33 5 8 5.67 8 6.5V8c0 2-1.5 3-3 3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),V$=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[l.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),l.jsx("rect",{x:"2",y:"16",width:"8",height:"7",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("line",{x1:"4",y1:"18.5",x2:"8",y2:"18.5",stroke:"currentColor",strokeWidth:"1",opacity:"0.7"}),l.jsx("line",{x1:"4",y1:"20.5",x2:"7",y2:"20.5",stroke:"currentColor",strokeWidth:"1",opacity:"0.7"})]}),q$=()=>l.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:l.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),K$=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),l.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),G$=()=>l.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("path",{d:"M2 12h20"}),l.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),Lk=()=>l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})});function J$({type:t}){switch(t){case"tweet":return l.jsx(U$,{});case"reply":return l.jsx(H$,{});case"quote":return l.jsx(W$,{});case"article":return l.jsx(V$,{});case"linkedin":return l.jsx(q$,{});case"newsletter":return l.jsx(K$,{});case"blog":return l.jsx(G$,{});default:return l.jsx(z$,{})}}function Fu(t){let e=0;for(const n of t)n.type==="doc"?e++:n.type==="container"&&(e+=Fu(n.items));return e}function tv(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=tv(n.items,e);if(r)return[n.id,...r]}}return null}function Eu(t){const e=new Set;return Ll(t,e),[...e]}function WT(t,e,n=0){for(const r of t)if(r.type==="container"){if(r.id===e)return n;const s=WT(r.items,e,n+1);if(s>=0)return s}return-1}function Y$(t,e){if(!e)return 12;for(const n of t){if(!n.workspace)continue;const r=WT(n.workspace.root,e);if(r>=0)return 12+(r+1)*16}return 12}function X$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:o,scrollRef:c,writingTitle:d,writingTarget:f,pendingWriteFilenames:h,searchQuery:m,searchResults:g,onSearchChange:v}){var nn,at,Ht;const x=T=>!!h&&h.has(T),[k,w]=y.useState(()=>{try{const T=localStorage.getItem("ow-files-collapsed");return T?new Set(JSON.parse(T)):new Set}catch{return new Set}}),{draggedItem:S,dropIndicator:N,handlePointerDown:j,dropClass:M,isDragging:_,isContainerDropTarget:R}=BT({docs:t,workspaces:e,assignedFiles:n,scrollRef:c,setCollapsedSections:w}),L=T=>!N||N.itemId!==T||N.position==="inside"?void 0:{"--drop-indent":`${Y$(e,N.containerId)}px`},{variantsByMaster:$,variantFilenames:B}=y.useMemo(()=>{const T=new Map,W=new Set;for(const ae of t)if(ae.masterDocId){const I=T.get(ae.masterDocId)||[];I.push(ae),T.set(ae.masterDocId,I),W.add(ae.filename)}return{variantsByMaster:T,variantFilenames:W}},[t]),[F,K]=y.useState(null),[z,ee]=y.useState(null),[P,U]=y.useState(new Set),[J,ie]=y.useState(null),[q,ue]=y.useState([]),[Y,A]=y.useState(!1),[D,te]=y.useState(null),[fe,we]=y.useState(null),[oe,Se]=y.useState(null),[Ee,Le]=y.useState(null),[Ie,Ve]=y.useState(null),[Te,qe]=y.useState(null),[pt,ut]=y.useState(new Set);y.useEffect(()=>{ut(new Set)},[r]);const be=y.useCallback(()=>{fetch("/api/plugins").then(T=>T.json()).then(T=>{const W=[];let ae=!1;for(const I of T.plugins||[]){const V=I.displayName||void 0;for(const re of I.sidebarMenuItems||[])W.push({...re,pluginDisplayName:V});I.name==="@openwriter/plugin-publish"&&I.enabled&&(ae=!0)}ue(W),A(ae)}).catch(()=>{})},[]);y.useEffect(()=>{be()},[be]),y.useEffect(()=>{const T=()=>be();return window.addEventListener("ow-plugins-changed",T),()=>window.removeEventListener("ow-plugins-changed",T)},[be]);const ht=y.useCallback((T,W)=>{if(T.preventDefault(),T.stopPropagation(),P.has(W.filename)&&P.size>1){ee({x:T.clientX,y:T.clientY,filename:W.filename,title:W.title,bulkCount:P.size});return}P.size>0&&!P.has(W.filename)&&U(new Set),ee({x:T.clientX,y:T.clientY,filename:W.filename,title:W.title,docId:W.docId,lastSent:W.lastSent,postedUrl:W.postedUrl,isNewsletter:W.isNewsletter,contentType:W.contentType,sortRequest:W.sortRequest})},[P]),xt=y.useCallback(T=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:T})}).catch(()=>{})},[]),St=y.useCallback((T,W,ae,I,V)=>{if(!$T(W,t.find(re=>re.filename===ae))){if(W.promptForFocus&&V===void 0){te({action:T,label:W.label,filename:ae,title:I});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:T,filename:ae,title:I,instructions:V||"",label:W.label})}).catch(()=>{})}},[t]),At=y.useCallback((T,W,ae)=>{for(const I of Eu(ae)){const V=t.find(re=>re.filename===I);fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:T,filename:I,title:(V==null?void 0:V.title)||I,instructions:"",label:W.label})}).catch(()=>{})}},[t]),Ye=y.useCallback((T,W)=>{ut(ae=>{const I=new Set(ae);for(const V of T)I.add(V);return I}),fetch("/api/documents/batch-resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:T,action:W})}).catch(()=>{})},[]),ct=T=>{w(W=>{const ae=new Set(W);return ae.has(T)?ae.delete(T):ae.add(T),localStorage.setItem("ow-files-collapsed",JSON.stringify([...ae])),ae})},Fe=(T,W,ae,I)=>{K({type:T,key:W,value:ae,wsFilename:I})},G=()=>{if(!F)return;const{type:T,key:W,value:ae,wsFilename:I}=F;T==="doc"?o.handleRename(W,"",ae):T==="workspace"?o.handleRenameWorkspace(W,ae):T==="container"&&I&&o.handleRenameContainer(I,W,ae),K(null)},ge=t.find(T=>T.isActive),ne=y.useMemo(()=>{var I;const T=t.find(V=>V.isActive);if(!T)return null;const W=T.masterDocId?t.find(V=>V.docId===T.masterDocId):void 0,ae=(W==null?void 0:W.filename)??T.filename;for(const V of e){const re=tv(((I=V.workspace)==null?void 0:I.root)||[],ae);if(re)return{wsFilename:V.filename,containerKeys:new Set(re.map(X=>`container-${X}`)),masterDocId:(W==null?void 0:W.docId)??null}}return{wsFilename:null,containerKeys:new Set,masterDocId:(W==null?void 0:W.docId)??null}},[t,e]),he=y.useRef(e);he.current=e;const me=y.useCallback(T=>{var W;for(const ae of he.current){const I=tv(((W=ae.workspace)==null?void 0:W.root)||[],T);if(I){w(V=>{const re=[ae.filename,...I.map(le=>`container-${le}`)];if(re.every(le=>!V.has(le)))return V;const X=new Set(V);for(const le of re)X.delete(le);return localStorage.setItem("ow-files-collapsed",JSON.stringify([...X])),X});break}}},[]);Wl(c,t,e.length,me);const ze=y.useMemo(()=>t.filter(T=>!n.has(T.filename)&&!B.has(T.filename)&&!x(T.filename)),[t,n,B,h]),Ae=y.useMemo(()=>{var I;const T=[],W=V=>{T.push(V.filename);const re=V.docId?$.get(V.docId):void 0,X=V.docId&&!k.has(`variants-${V.docId}`);if(re&&X)for(const le of re)T.push(le.filename)},ae=V=>{for(const re of V)if(re.type==="doc"){const X=t.find(le=>le.filename===re.file);X&&!B.has(X.filename)&&W(X)}else k.has(`container-${re.id}`)||ae(re.items)};k.has("docs")||ze.forEach(W);for(const V of e)k.has(V.filename)||ae(((I=V.workspace)==null?void 0:I.root)||[]);return T},[t,e,ze,B,$,k]),Xe=y.useCallback(()=>{U(new Set)},[]),Qe=y.useCallback((T,W)=>{if(S)return;const ae=T.shiftKey,I=T.ctrlKey||T.metaKey;if(ae){const re=J||(ge==null?void 0:ge.filename)||W,X=Ae.indexOf(re),le=Ae.indexOf(W);if(X<0||le<0){U(new Set([W])),ie(W);return}const[ve,Re]=X<le?[X,le]:[le,X];U(new Set(Ae.slice(ve,Re+1)));return}if(I){U(re=>{const X=new Set(re);return X.has(W)?X.delete(W):X.add(W),X}),ie(W);return}U(new Set),ie(W);const V=t.find(re=>re.filename===W);V&&!V.isActive&&s(W)},[S,J,ge==null?void 0:ge.filename,Ae,s,t]);y.useEffect(()=>{if(P.size===0)return;const T=W=>{W.key==="Escape"&&Xe()};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[P.size,Xe]);const tt=y.useCallback(()=>{for(const T of P)o.handleDelete(T);U(new Set),ie(null)},[P,o]),We=y.useCallback(T=>{T.length!==0&&fetch("/api/documents/sort-request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:T})}).then(()=>o.fetchDocs()).catch(()=>{})},[o]),Ue=y.useCallback(T=>{fetch("/api/documents/sort-reject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:T})}).then(()=>o.fetchDocs()).catch(()=>{})},[o]),st=y.useCallback(T=>{fetch("/api/documents/sort-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:T})}).then(()=>o.fetchDocs()).catch(()=>{})},[o]);if(g!==null)return l.jsx(rf,{results:g,query:m,onSwitchDocument:s,actions:o});const mt=T=>l.jsx("input",{className:"sidebar-rename-input",value:F.value,onChange:W=>K(ae=>ae?{...ae,value:W.target.value}:null),onBlur:T,onKeyDown:W=>{W.key==="Enter"&&T(),W.key==="Escape"&&K(null)},autoFocus:!0,onClick:W=>W.stopPropagation()}),Nt=(T,W,ae,I,V,re=!1)=>l.jsxs("div",{className:`files-row${T.isActive?" active":""}${T.docId&&(ne==null?void 0:ne.masterDocId)===T.docId&&k.has(`variants-${T.docId}`)?" active-within":""}${P.has(T.filename)?" selected":""} ${_(T.filename)?"dragging":""} ${M(T.filename)}${T.masterDocId?" is-variant":""}`,style:{paddingLeft:W,...L(T.filename)},"data-drag-id":T.filename,"data-drag-type":"doc","data-drag-ws":ae||"__docs__","data-drag-container":I||"",onPointerDown:X=>j(X,{type:"doc",file:T.filename,sourceWs:ae||null},T.title),onClick:X=>Qe(X,T.filename),onDoubleClick:()=>Fe("doc",T.filename,T.title),onContextMenu:X=>ht(X,T),children:[l.jsx("span",{className:"files-row-icon",children:l.jsx(J$,{type:T.contentType})}),(F==null?void 0:F.type)==="doc"&&F.key===T.filename?mt(G):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"files-row-label",children:T.title}),T.variantType&&l.jsx("span",{className:"files-badge-variant",children:T.variantType}),(T.autoAccept===!0||T.autoAccept!==!1&&re)&&l.jsx("span",{className:"sidebar-auto-accept-dot",title:T.autoAccept===!0?"Auto-accept on":"Auto-accept inherited"}),r.filenames.includes(T.filename)&&!pt.has(T.filename)&&l.jsx("span",{className:"files-badge-pending"}),T.sortRequest&&(T.sortRequest.proposal?l.jsx("span",{className:"files-badge-sort-proposal",title:"Sort proposal ready — right-click to review"}):l.jsx("span",{className:"files-badge-sort-pending",title:"Sort requested"})),o.getDocTags(T.filename).includes("✓")&&l.jsx("span",{className:"files-badge-approved",children:l.jsx(Lk,{})}),T.lastSent&&l.jsx("span",{className:"files-badge-sent",children:l.jsx(Lk,{})}),V&&l.jsx("span",{className:`files-row-chevron${k.has(`variants-${T.docId}`)?" collapsed":""}`,onClick:X=>{X.stopPropagation(),ct(`variants-${T.docId}`)},children:l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})})]})]},T.filename),Mt=(T,W,ae,I,V=!1)=>{const re=T.docId?$.get(T.docId):void 0,X=!!(re&&re.length>0),le=d&&(f==null?void 0:f.parentDocId)&&f.parentDocId===T.docId,ve=X||le,Re=!k.has(`variants-${T.docId}`);return ve?l.jsxs("div",{className:"files-variant-group",children:[Nt(T,W,ae,I,X,V),Re&&(re==null?void 0:re.map(ye=>Nt(ye,W+16,ae,I,!1,V))),le&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:W+16},children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:d})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]})]},`vg-${T.filename}`):Nt(T,W,ae,I,!1,V)},Jt=(T,W,ae,I,V=!1)=>{const re=12+W*16;if(T.type==="doc"){const Et=t.find(dn=>dn.filename===T.file);return!Et||B.has(Et.filename)?null:Mt(Et,re,ae,I,V)}const X=T,le=`container-${X.id}`,ve=k.has(le),Re=Fu(X.items),ye=X.autoAccept===!0,Dt=ye||V;return l.jsxs("div",{className:`${M(X.id)} ${R(X.id)?"files-drop-inside":""}`,children:[l.jsxs("div",{className:`files-row is-container${ve&&(ne!=null&&ne.containerKeys.has(le))?" active-within":""} ${_(X.id)?"dragging":""} ${M(X.id)}`,style:{paddingLeft:re,...L(X.id)},"data-drag-id":X.id,"data-drag-type":"container-header","data-drag-ws":ae,"data-drag-parent":I||"","data-section-key":le,onPointerDown:Et=>j(Et,{type:"container",id:X.id,sourceWs:ae},X.name),onClick:()=>!S&&ct(le),onDoubleClick:Et=>{Et.stopPropagation(),Fe("container",X.id,X.name,ae)},onContextMenu:Et=>{Et.preventDefault(),Et.stopPropagation(),qe({x:Et.clientX,y:Et.clientY,type:"container",wsFilename:ae,containerId:X.id,title:X.name,nodes:X.items,autoAccept:ye})},children:[l.jsx("span",{className:"files-row-icon",children:l.jsx(F$,{})}),(F==null?void 0:F.type)==="container"&&F.key===X.id?mt(G):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"files-row-label",children:X.name}),Dt&&l.jsx("span",{className:"sidebar-auto-accept-dot",title:ye?"Auto-accept on for this container":"Auto-accept inherited from workspace"}),l.jsx("span",{className:"files-row-count",children:Re})]})]}),l.jsxs("div",{className:`files-children${ve?" collapsed":""}`,"data-drop-ws":ae,"data-drop-container":X.id,children:[d&&!(f!=null&&f.parentDocId)&&(f==null?void 0:f.wsFilename)===ae&&f.containerId===X.id&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:12+(W+1)*16},children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:d})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),X.items.filter(Et=>Et.type!=="doc"||!x(Et.file)).map(Et=>Jt(Et,W+1,ae,X.id,Dt))]})]},X.id)};return l.jsxs("div",{className:"files-scroll",ref:c,children:[l.jsxs("div",{className:"files-section",children:[l.jsxs("div",{className:`files-row is-section${k.has("docs")&&ne!==null&&ne.wsFilename===null?" active-within":""}`,"data-section-key":"docs",onClick:()=>ct("docs"),children:[l.jsx("span",{className:`files-row-chevron leading${k.has("docs")?" collapsed":""}`,children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})}),l.jsx("span",{className:"files-row-label",children:"Documents"}),l.jsx("button",{className:"files-section-btn",onClick:T=>{T.stopPropagation(),Ve({anchor:T.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),l.jsxs("div",{className:`files-section-list files-children${k.has("docs")?" collapsed":""}`,"data-drop-ws":"__docs__",children:[d&&!(f!=null&&f.parentDocId)&&(!f||!e.some(T=>T.filename===(f==null?void 0:f.wsFilename)))&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:28},children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:d})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),ze.map(T=>Mt(T,28))]})]}),e.map(T=>{var re,X,le;const W=((re=T.workspace)==null?void 0:re.root)||[],ae=k.has(T.filename),I=Fu(W),V=((X=T.workspace)==null?void 0:X.autoAccept)===!0||T.autoAccept===!0;return l.jsxs("div",{className:`files-section ${_(T.filename)?"dragging":""} ${(N==null?void 0:N.itemId)===T.filename?N.position==="before"?"files-ws-drop-before":"files-ws-drop-after":""}`,children:[l.jsx("div",{className:`files-row is-section${ae&&(ne==null?void 0:ne.wsFilename)===T.filename?" active-within":""}${(N==null?void 0:N.itemId)==="__section__"&&N.wsFilename===T.filename&&N.position==="inside"?" files-ws-drop-target":""}`,"data-section-key":T.filename,"data-ws-drag":T.filename,onPointerDown:ve=>j(ve,{type:"workspace",filename:T.filename},T.title),onClick:()=>!S&&ct(T.filename),onDoubleClick:ve=>{ve.stopPropagation(),Fe("workspace",T.filename,T.title)},onContextMenu:ve=>{var Re;ve.preventDefault(),ve.stopPropagation(),qe({x:ve.clientX,y:ve.clientY,type:"workspace",wsFilename:T.filename,title:T.title,nodes:W,autoAccept:((Re=T.workspace)==null?void 0:Re.autoAccept)===!0||T.autoAccept===!0})},children:(F==null?void 0:F.type)==="workspace"&&F.key===T.filename?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`files-row-chevron leading${ae?" collapsed":""}`,children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})}),mt(G)]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`files-row-chevron leading${ae?" collapsed":""}`,children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})}),l.jsx("span",{className:"files-row-label",children:T.title}),(((le=T.workspace)==null?void 0:le.autoAccept)===!0||T.autoAccept===!0)&&l.jsx("span",{className:"sidebar-auto-accept-dot",title:"Auto-accept on for this workspace"}),l.jsx("span",{className:"files-row-count",children:I}),l.jsxs("div",{className:"files-section-actions",children:[l.jsx("button",{className:"files-section-btn",onClick:ve=>{ve.stopPropagation(),Ve({anchor:ve.target.getBoundingClientRect(),wsFilename:T.filename,containerId:null})},title:"New document",children:"+"}),l.jsx("button",{className:"files-section-btn",onClick:ve=>{ve.stopPropagation(),o.handleCreateContainer(T.filename,null)},title:"New container",children:"☐"})]})]})}),l.jsxs("div",{className:`files-section-list files-children${ae?" collapsed":""}`,"data-drop-ws":T.filename,children:[d&&!(f!=null&&f.parentDocId)&&(f==null?void 0:f.wsFilename)===T.filename&&f.containerId===null&&l.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:28},children:[l.jsxs("div",{className:"sidebar-item-title",children:[l.jsx("span",{className:"sidebar-writing-spinner"}),l.jsx("span",{className:"sidebar-item-title-text",children:d})]}),l.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),W.filter(ve=>ve.type!=="doc"||!x(ve.file)).map(ve=>Jt(ve,1,T.filename,null,V))]})]},T.filename)}),l.jsx("div",{className:"files-new-ws",children:l.jsx("button",{onClick:o.handleCreateWorkspace,children:"+ New Workspace"})}),Te&&l.jsx(Bd,{x:Te.x,y:Te.y,filename:Te.wsFilename,title:Te.title,onClose:()=>qe(null),onDuplicate:()=>{},onRename:()=>{Te.type==="workspace"?Fe("workspace",Te.wsFilename,Te.title):Te.containerId&&Fe("container",Te.containerId,Te.title,Te.wsFilename),qe(null)},onArchive:()=>{},onDelete:()=>{Te.type==="workspace"?o.handleDeleteWorkspace(Te.wsFilename):Te.containerId&&o.handleDeleteContainer(Te.wsFilename,Te.containerId,!1)},folderDocCount:Te.type==="container"?Fu(Te.nodes):0,onDeleteWithDocs:Te.type==="container"&&Te.containerId?()=>{o.handleDeleteContainer(Te.wsFilename,Te.containerId,!0)}:void 0,onPluginAction:(T,W)=>At(T,W,Te.nodes),pluginItems:q.filter(T=>T.folderCapable),folderMode:!0,onNewDoc:T=>{Ve({anchor:T.target.getBoundingClientRect(),wsFilename:Te.wsFilename,containerId:Te.type==="container"?Te.containerId:null}),qe(null)},onNewContainer:()=>{o.handleCreateContainer(Te.wsFilename,Te.type==="container"?Te.containerId:null),qe(null)},onAcceptAll:()=>{const T=Eu(Te.nodes);T.length&&Ye(T,"accept"),qe(null)},onRejectAll:()=>{const T=Eu(Te.nodes);T.length&&Ye(T,"reject"),qe(null)},folderAutoAccept:Te.autoAccept,folderAutoAcceptLabel:Te.type==="workspace"?"for workspace":"for container",onToggleFolderAutoAccept:()=>{fetch("/api/auto-accept/inherit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wsFile:Te.wsFilename,...Te.type==="container"?{containerId:Te.containerId}:{},enabled:!Te.autoAccept})}).catch(()=>{})},onRequestSortAll:()=>{const T=Eu(Te.nodes);T.length&&We(T)}}),z&&l.jsx(Bd,{x:z.x,y:z.y,filename:z.filename,title:z.title,bulkCount:z.bulkCount,onBulkDelete:tt,onBulkRequestSort:z.bulkCount?()=>We([...P]):void 0,onClose:()=>ee(null),onDuplicate:()=>xt(z.filename),onCreateVariant:z.docId?T=>{fetch("/api/documents/variant",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:z.filename,masterDocId:z.docId,variantType:T})}).catch(()=>{})}:void 0,onRename:()=>{Fe("doc",z.filename,z.title),ee(null)},onArchive:()=>o.handleArchive(z.filename),onDelete:()=>o.handleDelete(z.filename),onPluginAction:(T,W)=>St(T,W,z.filename,z.title),pluginItems:q,onSchedulePost:Y?()=>{we({filename:z.filename,title:z.title}),ee(null)}:void 0,onPostNow:z.contentType==="blog"?()=>{const T=(ge==null?void 0:ge.filename)===z.filename;Se({filename:z.filename,title:z.title,isActive:T}),ee(null)}:void 0,isAlreadyPublished:z.contentType==="blog"&&!!z.postedUrl,onViewAnalytics:z.docId&&z.lastSent&&(z.postedUrl||z.isNewsletter)?()=>{z.isNewsletter?Le({docId:z.docId,title:z.title}):z.postedUrl&&window.open(z.postedUrl,"_blank"),ee(null)}:void 0,viewAnalyticsLabel:z.isNewsletter?"View Analytics":z.contentType==="blog"&&z.postedUrl?"View Post":z.postedUrl?"View on X":"View Analytics",isApproved:o.getDocTags(z.filename).includes("✓"),onToggleApprove:()=>{o.getDocTags(z.filename).includes("✓")?o.handleRemoveTag(z.filename,"✓"):(o.handleAddTag(z.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAutoAccept:(()=>{var W;const T=(W=t.find(ae=>ae.filename===z.filename))==null?void 0:W.autoAccept;return T===!0?!0:T===!1?!1:Pd(e,z.filename)})(),onToggleAutoAccept:()=>{var ae;const T=(ae=t.find(I=>I.filename===z.filename))==null?void 0:ae.autoAccept,W=T===!0?!0:T===!1?!1:Pd(e,z.filename);fetch("/api/auto-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:z.filename,enabled:!W})}).then(()=>o.fetchDocs()).catch(()=>{})},isAlreadySent:!!z.lastSent,onMarkSent:()=>{const T=z.filename;o.getDocTags(T).includes("✓")&&o.handleRemoveTag(T,"✓"),s(T),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>o.fetchDocs()).catch(()=>{})},100),ee(null)},sortState:z.bulkCount?void 0:(nn=z.sortRequest)!=null&&nn.proposal?"proposal":z.sortRequest?"pending":"none",sortProposalLabel:(()=>{var re;const T=(re=z.sortRequest)==null?void 0:re.proposal;if(!T)return;const W=e.find(X=>X.filename===T.wsFilename),ae=(W==null?void 0:W.title)||T.wsFilename;if(!T.containerId)return ae;const I=X=>{for(const le of X){if(le.type==="container"&&le.id===T.containerId)return le.name;if(le.type==="container"){const ve=I(le.items);if(ve)return ve}}return null},V=W!=null&&W.workspace?I(W.workspace.root):null;return V?`${ae} / ${V}`:ae})(),sortProposalReasoning:(Ht=(at=z.sortRequest)==null?void 0:at.proposal)==null?void 0:Ht.reasoning,onRequestSort:z.bulkCount?void 0:()=>We([z.filename]),onCancelSort:()=>Ue(z.filename),onAcceptSortProposal:()=>st(z.filename),onRejectSortProposal:()=>Ue(z.filename)}),D&&l.jsx(FT,{actionLabel:D.label,docTitle:D.title,onClose:()=>te(null),onConfirm:T=>{const W=q.find(ae=>ae.action===D.action);W&&St(D.action,W,D.filename,D.title,T),te(null)}}),Ee&&l.jsx(zT,{docId:Ee.docId,title:Ee.title,onClose:()=>Le(null)}),fe&&l.jsx(Vl,{filename:fe.filename,title:fe.title,onClose:()=>we(null)}),oe&&l.jsx(HT,{filename:oe.filename,title:oe.title,isActive:oe.isActive,onSwitchDocument:s,onClose:()=>Se(null)}),Ie&&l.jsx(UT,{anchorRect:Ie.anchor,onClose:()=>Ve(null),onSelect:T=>{Ve(null),Ie.wsFilename?o.handleCreateInWorkspace(Ie.wsFilename,Ie.containerId??null,T):T?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:T})}).catch(()=>{}):i()}})]})}const Q$=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Z$=[{value:"any",label:"Any"},{value:"content_type",label:"Content Type"},{value:"connection",label:"Connection"}],VT=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Anchorage","Pacific/Honolulu","America/Phoenix","America/Toronto","America/Vancouver","America/Sao_Paulo","America/Mexico_City","Europe/London","Europe/Paris","Europe/Berlin","Europe/Amsterdam","Europe/Rome","Europe/Madrid","Europe/Moscow","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Asia/Singapore","Asia/Seoul","Australia/Sydney","Australia/Melbourne","Pacific/Auckland"];function Dk(t){var e;try{const n=new Date,i=((e=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(n).find(c=>c.type==="timeZoneName"))==null?void 0:e.value)||"";return`${t.split("/").pop().replace(/_/g," ")} (${i})`}catch{return t}}function e8(t){if(t.length>0)return t[0].timezone;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(VT.includes(e))return e}catch{}return"America/New_York"}function t8({slots:t,onBack:e}){const[n,r]=y.useState(t),[s,i]=y.useState(()=>e8(t)),[o,c]=y.useState(!1),[d,f]=y.useState("09:00"),[h,m]=y.useState(["default"]),[g,v]=y.useState("any"),[x,k]=y.useState(!1),w=y.useRef(null);y.useEffect(()=>{if(!o)return;function _(R){w.current&&!w.current.contains(R.target)&&c(!1)}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[o]);async function S(_){i(_);const R=[];for(const L of n){const $=await fetch(`/api/scheduler/slots/${L.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({timezone:_})});if($.ok){const B=await $.json();R.push(B.slot)}else R.push(L)}R.length>0&&r(R)}async function N(){const _=await fetch("/api/scheduler/slots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:d,days:h.includes("default")?["default"]:h,filter_type:g,timezone:s})});if(_.ok){const R=await _.json();r(L=>[...L,R.slot]),k(!1),f("09:00"),m(["default"]),v("any")}}async function j(_){(await fetch(`/api/scheduler/slots/${_}`,{method:"DELETE"})).ok&&r(L=>L.filter($=>$.id!==_))}function M(_){m(R=>{if(_==="default")return["default"];const L=R.filter($=>$!=="default");if(L.includes(_)){const $=L.filter(B=>B!==_);return $.length===0?["default"]:$}return[...L,_]})}return l.jsxs("div",{className:"sidebar-schedule",children:[l.jsxs("div",{className:"sidebar-schedule-header",children:[l.jsx("button",{className:"sidebar-schedule-btn",onClick:e,title:"Back",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"m15 18-6-6 6-6"})})}),l.jsx("h3",{children:"Slot Settings"}),l.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>k(!x),children:x?"Cancel":"+ Add"})]}),l.jsxs("div",{className:"slot-tz",ref:w,children:[l.jsx("label",{className:"slot-tz-label",children:"Timezone"}),l.jsxs("button",{className:"slot-tz-trigger",onClick:()=>c(!o),children:[l.jsx("span",{children:Dk(s)}),l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`slot-tz-chevron ${o?"slot-tz-chevron--open":""}`,children:l.jsx("path",{d:"m6 9 6 6 6-6"})})]}),o&&l.jsx("div",{className:"slot-tz-dropdown",children:VT.map(_=>l.jsx("div",{className:`slot-tz-option ${_===s?"active":""}`,onClick:()=>{S(_),c(!1)},children:Dk(_)},_))})]}),x&&l.jsxs("div",{className:"slot-add-form",children:[l.jsxs("div",{className:"slot-add-row",children:[l.jsx("input",{type:"time",className:"slot-input",value:d,onChange:_=>f(_.target.value)}),l.jsx("select",{className:"slot-input",value:g,onChange:_=>v(_.target.value),children:Z$.map(_=>l.jsx("option",{value:_.value,children:_.label},_.value))})]}),l.jsxs("div",{className:"slot-add-days",children:[l.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${h.includes("default")?"sidebar-schedule-btn--active":""}`,onClick:()=>M("default"),children:"Every day"}),Q$.map(_=>l.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${h.includes(_.toLowerCase())?"sidebar-schedule-btn--active":""}`,onClick:()=>M(_.toLowerCase()),children:_},_))]}),l.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active slot-create-btn",onClick:N,children:"Create Slot"})]}),l.jsx("div",{className:"slot-list",children:n.length===0?l.jsxs("div",{className:"schedule-empty",children:[l.jsx("div",{className:"schedule-empty-title",children:"No slots"}),l.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):n.map(_=>l.jsxs("div",{className:"schedule-item slot-item",children:[l.jsx("div",{className:"schedule-item-time slot-item-time",children:n8(_.time)}),l.jsxs("div",{className:"schedule-item-content",children:[l.jsx("div",{className:"schedule-item-text",children:_.days.includes("default")?"Every day":_.days.join(", ")}),l.jsxs("div",{className:"schedule-item-meta",children:[l.jsxs("span",{children:["Filter: ",_.filter_type]}),_.filter_value&&l.jsxs("span",{children:["(",_.filter_value,")"]})]})]}),l.jsx("button",{className:"schedule-item-action schedule-item-action--danger slot-delete-btn",onClick:()=>j(_.id),title:"Delete slot",children:"×"})]},_.id))})]})}function n8(t){const[e,n]=t.split(":").map(Number),r=e>=12?"PM":"AM";return`${e%12||12}:${String(n).padStart(2,"0")} ${r}`}function r8({onBack:t}){const[e,n]=y.useState([]),[r,s]=y.useState([]),[i,o]=y.useState(null),[c,d]=y.useState(!1),[f,h]=y.useState(!0),m=y.useCallback(async()=>{try{const[S,N]=await Promise.all([fetch("/api/scheduler/autoplugs/goals"),fetch("/api/scheduler/autoplugs/tracking")]);if(S.ok){const j=await S.json();n(j.goals||[])}if(N.ok){const j=await N.json();s(j.tracking||[])}}catch{}h(!1)},[]);y.useEffect(()=>{m()},[m]);const g=async S=>{(await fetch(`/api/scheduler/autoplugs/goals/${S.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!S.enabled})})).ok&&n(j=>j.map(M=>M.id===S.id?{...M,enabled:!M.enabled}:M))},v=async S=>{(await fetch(`/api/scheduler/autoplugs/goals/${S}`,{method:"DELETE"})).ok&&(n(j=>j.filter(M=>M.id!==S)),o(null))},x=async S=>{(await fetch(`/api/scheduler/autoplugs/tracking/${S}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipped:!0})})).ok&&s(j=>j.map(M=>M.id===S?{...M,skipped:!0}:M))},k=e.reduce((S,N)=>N.rule&&N.enabled?Math.min(S,N.rule.threshold):S,1/0),w=k===1/0?50:k;return l.jsxs("div",{className:"sidebar-schedule",children:[l.jsxs("div",{className:"sidebar-schedule-header",children:[l.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"m15 18-6-6 6-6"})})}),l.jsx("h3",{children:"Autoplugs"}),l.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!c),children:c?"Cancel":"+ Add"})]}),c&&l.jsx(i8,{onCreated:S=>{n(N=>[...N,S]),d(!1)}}),f?null:l.jsxs(l.Fragment,{children:[e.length===0?l.jsxs("div",{className:"schedule-empty",children:[l.jsx("div",{className:"schedule-empty-title",children:"No goals"}),l.jsx("div",{className:"schedule-empty-desc",children:"Create a goal to start autoplugging your tweets."})]}):e.map(S=>l.jsxs("div",{children:[l.jsxs("div",{className:"schedule-item",onClick:()=>o(i===S.id?null:S.id),children:[l.jsxs("div",{className:"schedule-item-content",children:[l.jsx("div",{className:"schedule-item-text",children:S.name}),l.jsx("div",{className:"schedule-item-meta",children:s8(S).map((N,j)=>l.jsx("span",{children:N},j))})]}),l.jsx("button",{className:`autoplug-toggle ${S.enabled?"autoplug-toggle--on":"autoplug-toggle--off"}`,onClick:N=>{N.stopPropagation(),g(S)},title:S.enabled?"Disable":"Enable"})]}),i===S.id&&l.jsx(o8,{goal:S,onSaved:N=>{n(j=>j.map(M=>M.id===N.id?N:M))},onDeleted:()=>v(S.id),onRefresh:m})]},S.id)),l.jsx("div",{className:"schedule-day-header",children:"Tracking"}),r.length===0?l.jsxs("div",{className:"schedule-empty",children:[l.jsx("div",{className:"schedule-empty-title",children:"No tracked tweets"}),l.jsx("div",{className:"schedule-empty-desc",children:"Tweets will appear here after posting."})]}):r.map(S=>l.jsxs("div",{className:"schedule-item",children:[l.jsxs("div",{className:"schedule-item-content",children:[l.jsx("div",{className:"schedule-item-text",children:S.original_text||`Tweet ${S.tweet_id}`}),l.jsxs("div",{className:"schedule-item-meta",children:[l.jsx("span",{children:a8(S.posted_at)}),l.jsxs("span",{children:[S.likes," likes"]}),l.jsxs("span",{children:[S.retweets," RTs"]}),S.views>0&&l.jsxs("span",{children:[l8(S.views)," views"]})]}),S.triggered?l.jsxs("div",{className:"autoplug-tracking-triggered",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Autoplugged ",S.goal_name?`→ ${S.goal_name}`:""]}):S.skipped?l.jsx("div",{className:"autoplug-tracking-skipped",children:"Skipped"}):l.jsx("div",{className:"autoplug-tracking-bar",children:l.jsx("div",{className:"autoplug-tracking-bar-fill",style:{width:`${Math.min(100,S.likes/w*100)}%`}})})]}),!S.triggered&&!S.skipped&&l.jsx("button",{className:"autoplug-tracking-skip",onClick:()=>x(S.id),title:"Skip autoplug for this tweet",children:"×"})]},S.id))]})]})}function s8(t){const e=[];return t.rule&&(e.push(`${t.rule.threshold}+ ${t.rule.metric}`),e.push(t.rule.mode.charAt(0).toUpperCase()+t.rule.mode.slice(1)),t.rule.delay_minutes>0&&e.push(`${t.rule.delay_minutes}m delay`)),e.push(`${t.pool_count} msg${t.pool_count!==1?"s":""}`),e}function i8({onCreated:t}){const[e,n]=y.useState(""),[r,s]=y.useState(""),[i,o]=y.useState(""),[c,d]=y.useState("likes"),[f,h]=y.useState(50),[m,g]=y.useState(30),[v,x]=y.useState("static"),[k,w]=y.useState(!1),S=async()=>{if(e.trim()){w(!0);try{const N=await fetch("/api/scheduler/autoplugs/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.trim(),link:r.trim()||null,description:i.trim()||null})});if(!N.ok){w(!1);return}const{goal:j}=await N.json();await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:j.id,metric:c,threshold:f,delay_minutes:m,mode:v})});const M=await fetch("/api/scheduler/autoplugs/goals");if(M.ok){const R=((await M.json()).goals||[]).find(L=>L.id===j.id);if(R){t(R);return}}t({...j,rule_count:1,pool_count:0,rule:{metric:c,threshold:f,delay_minutes:m,mode:v,id:""}})}finally{w(!1)}}};return l.jsxs("div",{className:"autoplug-editor",children:[l.jsxs("label",{children:["Name",l.jsx("input",{value:e,onChange:N=>n(N.target.value),placeholder:"Newsletter, Course..."})]}),l.jsxs("label",{children:["Link",l.jsx("input",{value:r,onChange:N=>s(N.target.value),placeholder:"https://..."})]}),l.jsxs("label",{children:["Description (context for LLM)",l.jsx("textarea",{value:i,onChange:N=>o(N.target.value),placeholder:"Weekly engineering insights...",rows:2})]}),l.jsxs("div",{className:"autoplug-editor-row",children:[l.jsx("input",{type:"number",value:f,onChange:N=>h(Number(N.target.value)),min:1}),l.jsxs("select",{value:c,onChange:N=>d(N.target.value),children:[l.jsx("option",{value:"likes",children:"likes"}),l.jsx("option",{value:"retweets",children:"retweets"}),l.jsx("option",{value:"views",children:"views"})]}),l.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),l.jsx("input",{type:"number",value:m,onChange:N=>g(Number(N.target.value)),min:0,className:"autoplug-delay-input"}),l.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),l.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(N=>l.jsx("button",{className:v===N?"active":"",onClick:()=>x(N),children:N==="llm"?"LLM":N.charAt(0).toUpperCase()+N.slice(1)},N))}),l.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active autoplug-create-btn",onClick:S,disabled:k||!e.trim(),children:k?"Creating...":"Create Goal"})]})}function o8({goal:t,onSaved:e,onDeleted:n,onRefresh:r}){var K,z,ee,P;const[s,i]=y.useState(t.name),[o,c]=y.useState(t.link||""),[d,f]=y.useState(t.description||""),[h,m]=y.useState(((K=t.rule)==null?void 0:K.metric)||"likes"),[g,v]=y.useState(((z=t.rule)==null?void 0:z.threshold)||50),[x,k]=y.useState(((ee=t.rule)==null?void 0:ee.delay_minutes)||30),[w,S]=y.useState(((P=t.rule)==null?void 0:P.mode)||"static"),[N,j]=y.useState([]),[M,_]=y.useState(""),[R,L]=y.useState(!1);y.useEffect(()=>{fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`).then(U=>U.json()).then(U=>j(U.pool||[])).catch(()=>{})},[t.id]);const $=async()=>{var U;L(!0);try{await fetch(`/api/scheduler/autoplugs/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,link:o||null,description:d||null})}),(U=t.rule)!=null&&U.id?await fetch(`/api/scheduler/autoplugs/rules/${t.rule.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({metric:h,threshold:g,delay_minutes:x,mode:w})}):await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:t.id,metric:h,threshold:g,delay_minutes:x,mode:w})}),r()}finally{L(!1)}},B=async()=>{if(!M.trim())return;const U=await fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:M.trim()})});if(U.ok){const J=await U.json();j(ie=>[...ie,J.message]),_("")}},F=async U=>{(await fetch(`/api/scheduler/autoplugs/pool/${U}`,{method:"DELETE"})).ok&&j(ie=>ie.filter(q=>q.id!==U))};return l.jsxs("div",{className:"autoplug-editor",children:[l.jsxs("label",{children:["Name",l.jsx("input",{value:s,onChange:U=>i(U.target.value)})]}),l.jsxs("label",{children:["Link",l.jsx("input",{value:o,onChange:U=>c(U.target.value),placeholder:"https://..."})]}),l.jsxs("label",{children:["Description",l.jsx("textarea",{value:d,onChange:U=>f(U.target.value),rows:2})]}),l.jsx("div",{className:"autoplug-editor-section-label",children:"Trigger"}),l.jsxs("div",{className:"autoplug-editor-row",children:[l.jsx("input",{type:"number",value:g,onChange:U=>v(Number(U.target.value)),min:1}),l.jsxs("select",{value:h,onChange:U=>m(U.target.value),children:[l.jsx("option",{value:"likes",children:"likes"}),l.jsx("option",{value:"retweets",children:"retweets"}),l.jsx("option",{value:"views",children:"views"})]}),l.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),l.jsx("input",{type:"number",value:x,onChange:U=>k(Number(U.target.value)),min:0,className:"autoplug-delay-input"}),l.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),l.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(U=>l.jsx("button",{className:w===U?"active":"",onClick:()=>S(U),children:U==="llm"?"LLM":U.charAt(0).toUpperCase()+U.slice(1)},U))}),l.jsxs("div",{className:"autoplug-pool-section",children:[l.jsx("div",{className:"autoplug-editor-section-label",children:"Static Pool"}),N.map(U=>l.jsxs("div",{className:"autoplug-pool-item",children:[l.jsx("span",{children:U.content}),l.jsx("button",{onClick:()=>F(U.id),title:"Remove",children:"×"})]},U.id)),l.jsxs("div",{className:"autoplug-pool-add",children:[l.jsx("input",{value:M,onChange:U=>_(U.target.value),placeholder:"Add message... (use {{link}} for link)",onKeyDown:U=>U.key==="Enter"&&B()}),l.jsx("button",{onClick:B,children:"+"})]})]}),(w==="llm"||w==="hybrid")&&l.jsx("div",{className:"autoplug-llm-hint",children:"LLM mode uses Author's Voice to generate contextual replies referencing the original tweet."}),l.jsxs("div",{className:"autoplug-editor-actions",children:[l.jsx("button",{className:"schedule-item-action",onClick:$,disabled:R,children:R?"Saving...":"Save"}),l.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:n,children:"Delete"})]})]})}function a8(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/6e4);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function l8(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function c8({onBack:t}){const[e,n]=y.useState([]),[r,s]=y.useState([]),[i,o]=y.useState(!1),[c,d]=y.useState(!1),[f,h]=y.useState(null),[m,g]=y.useState(!0),v=y.useCallback(async()=>{try{const[w,S]=await Promise.all([fetch("/api/scheduler/queue"),fetch("/api/scheduler/slots"),fetch("/api/scheduler/sync",{method:"POST"})]);if(w.ok){const N=await w.json();n(N.items||[])}if(S.ok){const N=await S.json();s(N.slots||[])}}catch{}g(!1)},[]);y.useEffect(()=>{v()},[v]);const x=async w=>{(await fetch(`/api/scheduler/queue/${w}`,{method:"DELETE"})).ok&&(n(N=>N.filter(j=>j.id!==w)),h(null))};if(c)return l.jsx(r8,{onBack:()=>{d(!1),v()}});if(i)return l.jsx(t8,{slots:r,onBack:()=>{o(!1),v()}});const k=u8(r,e);return l.jsxs("div",{className:"sidebar-schedule",children:[l.jsxs("div",{className:"sidebar-schedule-header",children:[l.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back to documents",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"m15 18-6-6 6-6"})})}),l.jsx("h3",{children:"Schedule"}),l.jsxs("div",{className:"sidebar-schedule-actions",children:[l.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!0),title:"Autoplugs",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}),l.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>o(!0),title:"Manage slots",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),l.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),m?null:r.length===0?l.jsxs("div",{className:"schedule-empty",children:[l.jsx("div",{className:"schedule-empty-title",children:"No time slots"}),l.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):k.map(({label:w,entries:S})=>l.jsxs("div",{className:"schedule-day",children:[l.jsx("div",{className:"schedule-day-header",children:w}),S.map((N,j)=>{var M,_,R,L,$;return N.type==="empty"?l.jsxs("div",{className:"schedule-slot-empty",children:[l.jsx("div",{className:"schedule-item-time",children:Bk(N.time)}),l.jsx("div",{className:"schedule-slot-empty-label",children:((M=N.slot)==null?void 0:M.filter_type)==="any"?"Open slot":`${(_=N.slot)==null?void 0:_.filter_type}: ${((R=N.slot)==null?void 0:R.filter_value)||"any"}`})]},`empty-${j}`):l.jsxs("div",{children:[l.jsxs("div",{className:"schedule-item",onClick:()=>h(f===N.item.id?null:N.item.id),children:[l.jsx("div",{className:"schedule-item-time",children:Bk(N.time)}),l.jsxs("div",{className:"schedule-item-content",children:[l.jsx("div",{className:"schedule-item-text",children:((L=N.item.content)==null?void 0:L.text)||JSON.stringify(N.item.content)}),l.jsxs("div",{className:"schedule-item-meta",children:[l.jsx("span",{className:`schedule-item-status schedule-item-status--${N.item.status}`}),l.jsx("span",{children:N.item.status}),N.item.connection_name&&l.jsx("span",{children:N.item.connection_name}),N.item.provider&&l.jsx("span",{children:N.item.provider})]})]})]}),f===N.item.id&&l.jsxs("div",{className:"schedule-item-expanded",children:[l.jsx("div",{className:"schedule-item-full-text",children:(($=N.item.content)==null?void 0:$.text)||JSON.stringify(N.item.content,null,2)}),l.jsx("div",{className:"schedule-item-actions",children:l.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>x(N.item.id),children:"Cancel"})})]})]},N.item.id)})]},w))]})}function u8(t,e){const n=new Date,r=[];for(let c=0;c<7;c++){const d=new Date(n);d.setDate(d.getDate()+c),d.setHours(0,0,0,0);let f;c===0?f="Today":c===1?f="Tomorrow":f=d.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),r.push({label:f,date:d})}const s=new Map;for(const c of e){const d=new Date(c.scheduled_at),f=`${d.getFullYear()}-${d.getMonth()}-${d.getDate()}-${d.getHours()}-${d.getMinutes()}`;s.set(f,c)}const i=new Set,o=[];for(const{label:c,date:d}of r){const f=[],h=d.getDay(),g=["sun","mon","tue","wed","thu","fri","sat"][h];for(const v of t){if(!(v.days.includes("default")||v.days.includes(g)))continue;const[k,w]=v.time.split(":").map(Number),S=new Date(d);if(S.setHours(k,w,0,0),Pk(d,n)&&S<n)continue;const N=`${S.getFullYear()}-${S.getMonth()}-${S.getDate()}-${k}-${w}`,j=s.get(N);j?(f.push({type:"filled",time:S,item:j,slot:v}),i.add(j.id)):f.push({type:"empty",time:S,slot:v})}for(const v of e){if(i.has(v.id))continue;const x=new Date(v.scheduled_at);Pk(x,d)&&(f.push({type:"filled",time:x,item:v}),i.add(v.id))}f.sort((v,x)=>v.time.getTime()-x.time.getTime()),f.length>0&&o.push({label:c,entries:f})}return o}function Pk(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Bk(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function d8({onBack:t}){const[e,n]=y.useState([]),[r,s]=y.useState(""),[i,o]=y.useState(null),[c,d]=y.useState(!1),f=y.useRef(null),h=y.useCallback(async()=>{try{const w=await fetch("/api/tasks");if(w.ok){const S=await w.json();n(S.tasks||[])}}catch{}},[]);y.useEffect(()=>{h()},[h]);const m=async()=>{const w=r.trim();if(w){s("");try{const S=await fetch("/api/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:w})});if(S.ok){const N=await S.json();n(j=>[...j,N.task])}}catch{}}},g=w=>{o(w),fetch(`/api/tasks/${w}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({completed:!0})}).catch(()=>{}),setTimeout(()=>{n(S=>S.filter(N=>N.id!==w)),o(null)},400)},v=async w=>{try{(await fetch(`/api/tasks/${w}`,{method:"DELETE"})).ok&&n(N=>N.filter(j=>j.id!==w))}catch{}},x=()=>{d(!0),setTimeout(()=>{var w;return(w=f.current)==null?void 0:w.focus()},0)},k=e.filter(w=>!w.completed);return l.jsxs("div",{className:"sidebar-tasks",children:[l.jsxs("div",{className:"sidebar-tasks-header",children:[l.jsx("button",{className:"sidebar-tasks-back",onClick:t,title:"Back to documents",children:l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"m15 18-6-6 6-6"})})}),l.jsx("h3",{children:"Tasks"}),l.jsx("button",{className:"sidebar-tasks-add-btn",onClick:x,title:"Add task",children:"+"})]}),k.length===0&&!c?l.jsxs("div",{className:"sidebar-tasks-empty",children:[l.jsx("div",{className:"sidebar-tasks-empty-title",children:"No tasks"}),l.jsx("div",{className:"sidebar-tasks-empty-desc",children:"Add tasks to track your checklist."})]}):l.jsx("div",{className:"sidebar-tasks-list",children:k.map(w=>l.jsxs("div",{className:`sidebar-tasks-item${i===w.id?" completing":""}`,children:[l.jsx("input",{type:"checkbox",className:"sidebar-tasks-checkbox",checked:i===w.id,onChange:()=>g(w.id)}),l.jsx("span",{className:`sidebar-tasks-text${i===w.id?" completed":""}`,children:w.text}),l.jsx("button",{className:"sidebar-tasks-delete",onClick:()=>v(w.id),title:"Remove",children:"×"})]},w.id))}),c&&l.jsx("div",{className:"sidebar-tasks-add",children:l.jsx("input",{ref:f,type:"text",placeholder:"New task...",value:r,onChange:w=>s(w.target.value),onKeyDown:w=>{w.key==="Enter"&&m(),w.key==="Escape"&&(d(!1),s(""))},onBlur:()=>{r.trim()||d(!1)}})})]})}function f8({profiles:t,activeProfile:e,trashedProfiles:n,onSwitch:r,onCreate:s,onDelete:i,onRestore:o}){const[c,d]=y.useState(!1),[f,h]=y.useState(!1),[m,g]=y.useState(""),[v,x]=y.useState(null),k=y.useRef(null),w=y.useRef(null);y.useEffect(()=>{if(!c)return;const N=j=>{k.current&&!k.current.contains(j.target)&&(d(!1),h(!1),g(""),x(null))};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[c]),y.useEffect(()=>{f&&w.current&&w.current.focus()},[f]);const S=()=>{const N=m.trim();N&&(s(N),g(""),h(!1))};return l.jsxs("div",{className:"sidebar-profile-wrapper",ref:k,children:[l.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>d(!c),title:`Profile: ${e}`,children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"8",r:"4"}),l.jsx("path",{d:"M5.5 21a8.38 8.38 0 0 1 13 0"})]})}),c&&l.jsxs("div",{className:"sidebar-profile-dropdown",children:[t.map(N=>l.jsxs("div",{className:"sidebar-profile-row",children:[v===N?l.jsxs("div",{className:"sidebar-profile-confirm",children:[l.jsx("span",{children:"Delete?"}),l.jsxs("div",{className:"sidebar-inline-confirm",children:[l.jsx("button",{onClick:()=>{i(N),x(null)},children:"Yes"}),l.jsx("button",{onClick:()=>x(null),children:"No"})]})]}):l.jsx(l.Fragment,{children:l.jsxs("button",{className:`sidebar-profile-option ${N===e?"active":""}`,onClick:()=>{N!==e&&r(N),d(!1)},children:[l.jsx("span",{className:"sidebar-profile-check",children:N===e?"✓":""}),l.jsx("span",{children:N})]})}),N!=="Default"&&N!==e&&v!==N&&l.jsx("button",{className:"sidebar-profile-delete-btn",onClick:j=>{j.stopPropagation(),x(N)},title:"Delete profile",children:"×"})]},N)),n.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"sidebar-profile-divider"}),l.jsx("div",{className:"sidebar-profile-trash-label",children:"Trash"}),n.map(N=>l.jsxs("div",{className:"sidebar-profile-row sidebar-profile-trashed",children:[l.jsx("span",{className:"sidebar-profile-trash-name",children:N}),l.jsx("button",{className:"sidebar-profile-restore-btn",onClick:()=>o(N),children:"Restore"})]},N))]}),l.jsx("div",{className:"sidebar-profile-divider"}),f?l.jsx("div",{className:"sidebar-profile-add-input",children:l.jsx("input",{ref:w,type:"text",value:m,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&S(),N.key==="Escape"&&(h(!1),g(""))},placeholder:"Profile name..."})}):l.jsxs("button",{className:"sidebar-profile-option sidebar-profile-add",onClick:()=>h(!0),children:[l.jsx("span",{className:"sidebar-profile-check",children:"+"}),l.jsx("span",{children:"New Profile"})]})]})]})}const qT=200,KT=600,nv=260;function $k({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,docTagsRefreshKey:s,workspacesRefreshKey:i,pendingDocs:o,writingTitle:c,writingTarget:d,pendingWriteFilenames:f,activeFilename:h,onClose:m,width:g,onWidthChange:v,floating:x}){const{docs:k,setDocs:w,workspaces:S,setWorkspaces:N,assignedFiles:j,fetchDocs:M,fetchWorkspaces:_,scrollRef:R,markPendingDelete:L}=T$(r,i),$=j$(M,_,w,N,k,L),B=$d(),F=y.useRef(!1),K=y.useCallback(Ye=>{Ye.preventDefault(),F.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let ct=g;const Fe=ge=>{F.current&&(ct=Math.min(KT,Math.max(qT,ge.clientX)),v(ct))},G=()=>{F.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",Fe),window.removeEventListener("pointerup",G);try{localStorage.setItem("ow-sidebar-width",String(ct))}catch{}};window.addEventListener("pointermove",Fe),window.addEventListener("pointerup",G)},[g,v]),z=y.useCallback(Ye=>{w(ct=>ct.map(Fe=>({...Fe,isActive:Fe.filename===Ye}))),e(Ye)},[w,e]);y.useEffect(()=>{h&&w(Ye=>Ye.some(ct=>ct.filename===h?!ct.isActive:ct.isActive)?Ye.map(ct=>({...ct,isActive:ct.filename===h})):Ye)},[h,w,r]);const[ee,P]=y.useState(!1),[U,J]=y.useState(!1),[ie,q]=y.useState([]),[ue,Y]=y.useState("Default"),A=y.useCallback(async()=>{try{const Ye=await fetch("/api/profiles");if(Ye.ok){const ct=await Ye.json();q(ct.profiles),Y(ct.active)}}catch{}},[]);y.useEffect(()=>{A()},[A]);const D=y.useCallback(async Ye=>{try{(await fetch("/api/profiles/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Ye})})).ok&&(Y(Ye),A())}catch{}},[A]),te=y.useCallback(async Ye=>{try{(await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Ye})})).ok&&A()}catch{}},[A]),[fe,we]=y.useState([]),oe=y.useCallback(async()=>{try{const Ye=await fetch("/api/profiles/trash");if(Ye.ok){const ct=await Ye.json();we(ct.profiles)}}catch{}},[]);y.useEffect(()=>{oe()},[oe]);const Se=y.useCallback(async Ye=>{try{(await fetch(`/api/profiles/${encodeURIComponent(Ye)}`,{method:"DELETE"})).ok&&(A(),oe())}catch{}},[A,oe]),Ee=y.useCallback(async Ye=>{try{(await fetch("/api/profiles/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Ye})})).ok&&(A(),oe())}catch{}},[A,oe]),[Le,Ie]=y.useState(""),[Ve,Te]=y.useState(null),qe=y.useRef(),pt=y.useRef(null),ut=y.useCallback(Ye=>{if(Ie(Ye),qe.current&&clearTimeout(qe.current),!Ye.trim()){Te(null);return}qe.current=setTimeout(async()=>{try{const ct=await fetch(`/api/documents/search?q=${encodeURIComponent(Ye.trim())}&archived=true`);ct.ok&&Te(await ct.json())}catch{}},250)},[]);y.useEffect(()=>()=>{qe.current&&clearTimeout(qe.current)},[]);const be={docs:k,archivedDocs:[],workspaces:S,assignedFiles:j,pendingDocs:o,writingTitle:c,writingTarget:d,pendingWriteFilenames:f,onSwitchDocument:z,onCreateDocument:n,actions:$,scrollRef:R,searchQuery:Le,searchResults:Ve,onSearchChange:ut},ht=()=>{switch(B){case"files":return l.jsx(X$,{...be});case"timeline":return l.jsx(P$,{...be});case"board":return l.jsx(B$,{...be});case"shelf":return l.jsx($$,{...be});default:return l.jsx(D$,{...be})}},xt=l.jsxs("div",{className:"sidebar-search",children:[l.jsxs("svg",{className:"sidebar-search-icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"10.5",cy:"10.5",r:"7"}),l.jsx("path",{d:"m20 20-4.5-4.5"})]}),l.jsx("input",{ref:pt,className:"sidebar-search-input",type:"text",placeholder:"Search...",value:Le,onChange:Ye=>ut(Ye.target.value)}),Le&&l.jsx("button",{className:"sidebar-search-clear",onClick:()=>ut(""),title:"Clear search",children:"×"})]}),St=t?{width:`${g}px`,minWidth:`${g}px`}:void 0,At=t&&!x?l.jsx("div",{className:"sidebar-resize-handle",onPointerDown:K,onDoubleClick:()=>{v(nv);try{localStorage.setItem("ow-sidebar-width",String(nv))}catch{}},title:"Drag to resize · double-click to reset"}):null;return B==="board"?l.jsxs("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,style:St,children:[ht(),At]}):l.jsxs("div",{className:`sidebar ${t?"open":""}`,style:St,children:[l.jsxs("div",{className:"sidebar-topbar",children:[l.jsxs("div",{className:"sidebar-logo",children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M17 3a2.83 2.83 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M15 5l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),l.jsx("span",{className:"sidebar-logo-text",children:"OpenWriter"})]}),l.jsxs("div",{className:"sidebar-topbar-actions",children:[l.jsx(f8,{profiles:ie,activeProfile:ue,trashedProfiles:fe,onSwitch:D,onCreate:te,onDelete:Se,onRestore:Ee}),l.jsx("button",{className:`sidebar-collapse-btn${ee?" sidebar-collapse-btn--active":""}`,onClick:()=>{P(!ee),J(!1)},title:"Schedule",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),l.jsx("line",{x1:"16",x2:"16",y1:"1",y2:"5"}),l.jsx("line",{x1:"8",x2:"8",y1:"1",y2:"5"}),l.jsx("line",{x1:"3",x2:"21",y1:"9",y2:"9"})]})}),l.jsx("button",{className:`sidebar-collapse-btn${U?" sidebar-collapse-btn--active":""}`,onClick:()=>{J(!U),P(!1)},title:"Tasks",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),l.jsx("path",{d:"m9 12 2 2 4-4"})]})}),m&&l.jsx("button",{className:"sidebar-collapse-btn",onClick:m,title:"Close sidebar",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),l.jsx("path",{d:"M15 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),U?l.jsx(d8,{onBack:()=>J(!1)}):ee?l.jsx(c8,{onBack:()=>P(!1)}):l.jsxs(l.Fragment,{children:[xt,ht()]}),At]})}function db(t,e,n){let r=t.resolve(e);for(;r.depth>0;){const s=r.node(r.depth),i=r.before(r.depth),o=i+s.nodeSize;if(s.childCount===1)e=i,n=o,r=t.resolve(e);else break}return{from:e,to:n}}function h8(t,e){const n=Wn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function p8(t,e){const n=Wn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null,pendingOriginalContent:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run(),!0}function m8(t,e){var o;const n=Wn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="delete")return!0;const i=db(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function g8(t,e){var o;const n=Wn(t,e);if(!n)return!0;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="insert")return!0;const i=db(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function v8(t,e){var o,c;const n=Wn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="rewrite")return!0;const i=(c=r.attrs)==null?void 0:c.pendingOriginalContent;if(i)t.chain().deleteRange({from:s,to:s+r.nodeSize}).insertContentAt(s,i).run();else{const d=db(t.state.doc,s,s+r.nodeSize);t.chain().deleteRange(d).run()}return!0}function b8(t,e){var i;const n=Wn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return((i=r.attrs)==null?void 0:i.pendingStatus)!=="delete"||t.chain().command(({tr:o})=>(o.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function y8(t,e){const n=nf(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const s=Wn(t,r.nodeId);s&&t.chain().command(({tr:i})=>(i.setNodeMarkup(s.pos,void 0,{...s.node.attrs,pendingStatus:null,pendingOriginalContent:null,pendingGroupId:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run()}return!0}function x8(t,e){var c;const n=nf(t,e);if(n.length===0)return!1;const r=(c=n[0].node.attrs)==null?void 0:c.pendingOriginalContent,s=n[0].pos,i=n[n.length-1],o=i.pos+i.node.nodeSize;try{return r&&Array.isArray(r)&&r.length>0?t.chain().deleteRange({from:s,to:o}).insertContentAt(s,r).run():t.chain().deleteRange({from:s,to:o}).run(),!0}catch{return!1}}function GT(t,e){var i,o;const n=Wn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return y8(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return h8(t,e);case"rewrite":return p8(t,e);case"delete":return m8(t,e);default:return!1}}function JT(t,e){var i,o;const n=Wn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return x8(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return g8(t,e);case"rewrite":return v8(t,e);case"delete":return b8(t,e);default:return!1}}function w8(t){const e=YT(t).reverse();for(const n of e)GT(t,n);t.view&&lb(t.view)}function k8(t){const e=YT(t).reverse();for(const n of e)JT(t,n);t.view&&lb(t.view)}function fb(t){const e=[],n=new Set;return t.state.doc.descendants((r,s)=>{var o,c,d;const i=(o=r.attrs)==null?void 0:o.pendingStatus;if(i&&((c=r.attrs)!=null&&c.id)){const f=(d=r.attrs)==null?void 0:d.pendingGroupId;if(f){if(n.has(f))return!0;n.add(f)}e.push({nodeId:r.attrs.id,pos:s,pendingStatus:i,groupId:f,editor:t})}return!0}),e}function Pp(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...fb(n));return e}function YT(t){return fb(t).map(e=>e.nodeId)}function S8(t){let e=0,n=0,r=0;for(const s of t)s.pendingStatus==="insert"?e++:s.pendingStatus==="rewrite"?n++:s.pendingStatus==="delete"&&r++;return{insert:e,rewrite:n,delete:r,total:t.length}}function rl(t,e){if(t.isDestroyed)return;let n=-1;if(t.state.doc.descendants((i,o)=>{var c;return((c=i.attrs)==null?void 0:c.id)===e?(n=o,!1):!0}),n===-1)return;const r=t.view.nodeDOM(n),s=r instanceof HTMLElement?r:r==null?void 0:r.parentElement;if(s){s.scrollIntoView({behavior:"smooth",block:"center"});return}try{const i=t.view.coordsAtPos(n),o=t.view.dom.closest(".editor-container");if(o){const c=o.getBoundingClientRect(),d=i.top-c.top+o.scrollTop-o.clientHeight/2;o.scrollTo({top:d,behavior:"smooth"})}}catch{}}function E8(t){const[e,n]=y.useState([]),[r,s]=y.useState(0),i=y.useRef(),o=y.useRef(new Set),c=y.useCallback(()=>{const S=t.filter(R=>R&&!R.isDestroyed);if(S.length===0){n([]),o.current=new Set;return}const N=Pp(S);n(N);const j=o.current,M=new Set(N.map(R=>R.nodeId));let _=-1;if(j.size>0){for(let R=0;R<N.length;R++)if(!j.has(N[R].nodeId)){_=R;break}}o.current=M,_>=0?(s(_),rl(N[_].editor,N[_].nodeId)):N.length===0?s(0):s(R=>Math.min(R,N.length-1))},[t]);y.useEffect(()=>{const S=t.filter(M=>M&&!M.isDestroyed);if(S.length===0)return;const N=()=>{clearTimeout(i.current),i.current=setTimeout(c,50)};for(const M of S)M.on("transaction",N);c();const j=setTimeout(()=>{const M=Pp(S.filter(_=>!_.isDestroyed));M.length>0&&rl(M[0].editor,M[0].nodeId)},150);return()=>{for(const M of S)M.isDestroyed||M.off("transaction",N);clearTimeout(i.current),clearTimeout(j)}},[t,c]),y.useEffect(()=>{const S=e[r]??null;return lk((S==null?void 0:S.nodeId)??null,(S==null?void 0:S.groupId)??null),S!=null&&S.editor&&!S.editor.isDestroyed&&S.editor.view&&lb(S.editor.view),()=>{lk(null)}},[r,e]);const d=S8(e),f=e[r]??null,h=y.useCallback(()=>{if(e.length===0)return;const S=(r+1)%e.length;s(S),e[S]&&rl(e[S].editor,e[S].nodeId)},[e,r]),m=y.useCallback(()=>{if(e.length===0)return;const S=(r-1+e.length)%e.length;s(S),e[S]&&rl(e[S].editor,e[S].nodeId)},[e,r]),g=y.useCallback(()=>{const S=t.filter(M=>M&&!M.isDestroyed),N=Pp(S);if(N.length===0)return;const j=Math.min(r,N.length-1);rl(N[j].editor,N[j].nodeId)},[t,r]),v=y.useCallback(()=>{f&&(GT(f.editor,f.nodeId),c(),g())},[f,c,g]),x=y.useCallback(()=>{f&&(JT(f.editor,f.nodeId),c(),g())},[f,c,g]),k=y.useCallback(()=>{const S=t.filter(N=>N&&!N.isDestroyed);for(const N of S)w8(N);c()},[t,c]),w=y.useCallback(()=>{const S=t.filter(N=>N&&!N.isDestroyed);for(const N of S)k8(N);c()},[t,c]);return{pendingNodes:e,counts:d,currentNode:f,currentIndex:r,hasPending:d.total>0,goToNext:h,goToPrevious:m,acceptCurrent:v,rejectCurrent:x,acceptAll:k,rejectAll:w,refresh:c}}const N8=[{fmt:"epub",label:"EPUB"},{fmt:"html",label:"HTML"},{fmt:"docx",label:"DOCX"},{fmt:"md",label:"MD"}];function Fk({contentType:t,docId:e,manuscriptStyle:n,onSwitchDocument:r}){const[s,i]=y.useState([]),[o,c]=y.useState("manifest"),d=t==="manuscript",f=n==="indented"?"indented":"spaced",[h,m]=y.useState(null),g=h??f;y.useEffect(()=>{m(null)},[n,e]);const v=S=>{S!==g&&(m(S),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manuscriptContext:{paragraphStyle:S}})}).then(()=>{window.dispatchEvent(new CustomEvent("ow-manuscript-restyle"))}).catch(()=>m(null)))};y.useEffect(()=>{let S=!1;const N=()=>{fetch("/api/manuscripts").then(j=>j.json()).then(j=>{S||i(j.manuscripts||[])}).catch(()=>{})};return N(),window.addEventListener("ow-documents-changed",N),()=>{S=!0,window.removeEventListener("ow-documents-changed",N)}},[]),y.useEffect(()=>{c("manifest")},[e]);const x=S=>{c(S),window.dispatchEvent(new CustomEvent(S==="preview"?"ow-manuscript-preview":"ow-manuscript-manifest"))},k=S=>`/api/manuscript/export?docId=${encodeURIComponent(e||"")}&format=${S}`,w=S=>`review-panel__toggle-btn${S?" review-panel__toggle-btn--active":""}`;return l.jsxs(l.Fragment,{children:[d&&e&&l.jsxs("div",{className:"review-tab__section",children:[l.jsx("div",{className:"review-tab__section-label",children:"This Manuscript"}),l.jsxs("div",{className:"review-tab__toggle",role:"tablist","aria-label":"Manuscript view",children:[l.jsx("button",{type:"button",className:w(o==="manifest"),onClick:()=>x("manifest"),children:"Manifest"}),l.jsx("button",{type:"button",className:w(o==="preview"),onClick:()=>x("preview"),title:o==="preview"?"Re-render":"Preview the compiled book",children:"Preview"})]}),l.jsx("div",{className:"ms-style-label",children:"Paragraph style"}),l.jsxs("div",{className:"review-tab__toggle",role:"tablist","aria-label":"Paragraph style",children:[l.jsx("button",{type:"button",className:w(g==="spaced"),onClick:()=>v("spaced"),title:"Blank line between paragraphs, no indent",children:"Spaced"}),l.jsx("button",{type:"button",className:w(g==="indented"),onClick:()=>v("indented"),title:"First-line indent, no gap — traditional print",children:"Indented"})]}),l.jsx("div",{className:"ms-dl-row",children:N8.map(S=>l.jsx("a",{className:"ms-dl-btn",href:k(S.fmt),download:!0,children:S.label},S.fmt))})]}),l.jsxs("div",{className:"review-tab__section",children:[l.jsx("div",{className:"review-tab__section-label",children:"Manuscripts"}),s.length===0?l.jsx("div",{className:"ms-empty",children:"None yet — create one from the “+” menu."}):l.jsx("ul",{className:"ms-list",children:s.map(S=>l.jsx("li",{children:l.jsx("button",{type:"button",className:S.docId===e?"ms-item ms-item--active":"ms-item",onClick:()=>r(S.filename),title:S.title,children:S.title})},S.docId))})]})]})}const XT="ow-review-scope";function C8(){try{return localStorage.getItem(XT)==="workspace"?"workspace":"all"}catch{return"all"}}function _8(t){try{localStorage.setItem(XT,t)}catch{}}function QT(t){if(!t)return[];const e=[];for(const n of t)n.type==="doc"&&n.file&&e.push(n.file),n.type==="container"&&n.items&&e.push(...QT(n.items));return e}function ZT(t,e){if(!t)return!1;for(const n of t)if(n.type==="doc"&&n.file===e||n.type==="container"&&n.items&&ZT(n.items,e))return!0;return!1}const Di={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},T8=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",...Di})}),j8=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",...Di})}),M8=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M3 10l5-5 5 5",stroke:"currentColor",...Di})}),A8=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M3 6l5 5 5-5",stroke:"currentColor",...Di})}),R8=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M3 8.5l3.5 3.5L13 5",stroke:"currentColor",...Di})}),O8=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[l.jsx("path",{d:"M1 8.5l3.5 3.5L11 5",stroke:"currentColor",...Di}),l.jsx("path",{d:"M8 12l.5.5L15 6",stroke:"currentColor",...Di})]}),zk=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",...Di})});function e2(t,e,n){const r=Wn(t,e);if(!r)return!1;const{pos:s,node:i}=r,o={type:n.type||i.type.name,attrs:{...n.attrs||{},id:i.attrs.id,pendingStatus:i.attrs.pendingStatus,pendingOriginalContent:i.attrs.pendingOriginalContent,pendingSelectionFrom:i.attrs.pendingSelectionFrom,pendingSelectionTo:i.attrs.pendingSelectionTo,pendingOriginalFrom:i.attrs.pendingOriginalFrom,pendingOriginalTo:i.attrs.pendingOriginalTo},content:n.content};try{return t.chain().command(({tr:c})=>(c.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:s+i.nodeSize}).insertContentAt(s,o).run(),!0}catch{return!1}}function t2(t,e,n){const r=nf(t,e);if(r.length===0)return!1;const s=r[0].pos,i=r[r.length-1].pos+r[r.length-1].node.nodeSize;try{return t.chain().command(({tr:o})=>(o.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:i}).insertContentAt(s,n).run(),!0}catch{return!1}}function Nu(t,e){if(!ab()||!e)return!1;const n=j5();return T5()&&n&&Array.isArray(n)?t2(t,e,n):n&&e2(t,e,n),ul(!1),!0}function I8(t,e){return t.indexOf(e)}function L8({editors:t,pendingDocs:e,currentFilename:n,docId:r,contentType:s,manuscriptStyle:i,pendingTitle:o,onSwitchDocument:c,sendMessage:d,getDocument:f,docVersionRef:h}){const{counts:m,currentNode:g,currentIndex:v,hasPending:x,goToNext:k,goToPrevious:w,acceptCurrent:S,rejectCurrent:N,acceptAll:j,rejectAll:M}=E8(t),[_,R]=y.useState(o?"title":"body");y.useEffect(()=>{o&&_!=="title"&&m.total===0?R("title"):!o&&_==="title"&&R("body")},[o,m.total,_]);const L=!!o,$=m.total+(L?1:0),B=_==="title"?0:(L?1:0)+v,[F,K]=y.useState(!1);y.useEffect(()=>{_!=="title"&&K(!1)},[_]),y.useEffect(()=>{const G=!!o&&_==="title",ge={docId:r,titleFocused:G,titleShowOriginal:G&&F};return window.dispatchEvent(new CustomEvent("ow-pending-review-cursor",{detail:ge})),()=>{window.dispatchEvent(new CustomEvent("ow-pending-review-cursor",{detail:{docId:r,titleFocused:!1,titleShowOriginal:!1}}))}},[r,o,_,F]);const z=y.useCallback(()=>{r&&d({type:"accept-pending-title",docId:r})},[r,d]),ee=y.useCallback(()=>{r&&d({type:"reject-pending-title",docId:r})},[r,d]),P=y.useRef(null),U=y.useRef(null),[J,ie]=y.useState(()=>C8()),[q,ue]=y.useState([]);y.useEffect(()=>{let G=!1;async function ge(){try{const me=await(await fetch("/api/workspaces")).json();if(!Array.isArray(me))return;const ze=await Promise.all(me.map(async Ae=>{try{const Qe=await(await fetch(`/api/workspaces/${encodeURIComponent(Ae.filename)}`)).json();return{...Ae,workspace:Qe}}catch{return Ae}}));G||ue(ze)}catch{}}ge();const ne=()=>ge();return window.addEventListener("ow-workspaces-changed",ne),()=>{G=!0,window.removeEventListener("ow-workspaces-changed",ne)}},[]);const Y=y.useMemo(()=>{var ge;if(q.length===0||!n)return null;const G=q.find(ne=>{var he;return ZT((he=ne.workspace)==null?void 0:he.root,n)});return G?new Set(QT((ge=G.workspace)==null?void 0:ge.root)):null},[q,n]),A=y.useMemo(()=>J==="all"||!Y?e.filenames:e.filenames.filter(G=>Y.has(G)),[J,e.filenames,Y]),D=y.useCallback(G=>{ie(G),_8(G)},[]),te=A.length,fe=I8(A,n),we=(g==null?void 0:g.pendingStatus)==="rewrite",oe=!!(g!=null&&g.groupId),Se=we,Ee=y.useCallback(()=>{var ge,ne;const G=g==null?void 0:g.editor;if(!(!G||!g||g.pendingStatus!=="rewrite"))if(F)U.current&&Nu(U.current,P.current),P.current=null,U.current=null,K(!1);else if(oe&&g.groupId){const he=nf(G,g.groupId);if(he.length===0)return;const me=(ge=he[0].node.attrs)==null?void 0:ge.pendingOriginalContent;if(!me||!Array.isArray(me))return;const ze=he.map(Qe=>Qe.node.toJSON()),Ae=me.map((Qe,tt)=>({...Qe,attrs:{...Qe.attrs||{},pendingStatus:"rewrite",pendingGroupId:g.groupId,...tt===0?{pendingOriginalContent:me}:{}}}));if(ul(!0,g.nodeId,ze,g.groupId),!t2(G,g.groupId,Ae)){ul(!1);return}P.current=g.nodeId,U.current=G,K(!0)}else{const he=Wn(G,g.nodeId);if(!he)return;const{node:me}=he,ze=(ne=me.attrs)==null?void 0:ne.pendingOriginalContent;if(!ze)return;const Ae=me.toJSON();if(ul(!0,g.nodeId,Ae),!e2(G,g.nodeId,ze)){ul(!1);return}P.current=g.nodeId,U.current=G,K(!0)}},[g,F,oe]);y.useEffect(()=>{if(!F)return;const G=P.current,ge=U.current;G&&ge&&(g==null?void 0:g.nodeId)!==G&&(Nu(ge,G),P.current=null,U.current=null,K(!1))},[g==null?void 0:g.nodeId,F]),y.useEffect(()=>{if(t.length!==0)return()=>{ab()&&P.current&&U.current&&(Nu(U.current,P.current),P.current=null,U.current=null)}},[t]);const Le=y.useCallback(G=>{if(!n)return;if(!t.some(ne=>!ne||ne.isDestroyed?!1:fb(ne).length>0)){const ne=f==null?void 0:f();ne&&d({type:"doc-update",document:ne,filename:n,version:(h==null?void 0:h.current)??0}),d({type:"pending-resolved",filename:n,action:G})}},[t,n,d,f,h]),Ie=y.useCallback(()=>{U.current&&F&&P.current&&(Nu(U.current,P.current),P.current=null,U.current=null,K(!1))},[F]),Ve=y.useCallback(()=>{if(_==="title"&&o){z(),m.total>0&&R("body");return}Ie(),S(),Le("accept")},[_,o,z,m.total,Ie,S,Le]),Te=y.useCallback(()=>{if(_==="title"&&o){ee(),m.total>0&&R("body");return}Ie(),N(),Le("reject")},[_,o,ee,m.total,Ie,N,Le]),qe=y.useCallback(()=>{Ie(),o&&z(),j(),Le("accept")},[Ie,o,z,j,Le]);y.useEffect(()=>{const G=()=>qe();return window.addEventListener("ow-accept-all",G),()=>window.removeEventListener("ow-accept-all",G)},[qe]);const pt=y.useCallback(()=>{Ie(),o&&ee(),M(),Le("reject")},[Ie,o,ee,M,Le]),ut=y.useCallback(()=>{if(!($<=1)){if(_==="title"){R("body");return}if(L&&v>=m.total-1){k(),R("title");return}k()}},[$,_,L,v,m.total,k]),be=y.useCallback(()=>{if(!($<=1)){if(_==="title"){w(),R("body");return}if(L&&v===0){R("title");return}w()}},[$,_,L,v,w]),ht=y.useCallback(()=>{if(te===0||te===1&&fe===0)return;const G=fe<=0?te-1:fe-1;c(A[G])},[te,fe,A,c]),xt=y.useCallback(()=>{if(te===0||te===1&&fe===0)return;const G=fe>=te-1?0:fe+1;c(A[G])},[te,fe,A,c]);y.useEffect(()=>{if(!x&&!o)return;const G=ge=>{if(!(ge.target instanceof HTMLInputElement||ge.target instanceof HTMLTextAreaElement)&&!(ge.target instanceof HTMLElement&&ge.target.closest("[contenteditable]")))switch(ge.key){case"j":case"ArrowDown":!ge.metaKey&&!ge.ctrlKey&&(ge.preventDefault(),ut());break;case"k":case"ArrowUp":!ge.metaKey&&!ge.ctrlKey&&(ge.preventDefault(),be());break;case"h":case"ArrowLeft":!ge.metaKey&&!ge.ctrlKey&&!ge.altKey&&(ge.preventDefault(),ht());break;case"l":case"ArrowRight":!ge.metaKey&&!ge.ctrlKey&&!ge.altKey&&(ge.preventDefault(),xt());break;case"a":!ge.metaKey&&!ge.ctrlKey&&!ge.shiftKey&&(ge.preventDefault(),Ve());break;case"r":!ge.metaKey&&!ge.ctrlKey&&(ge.preventDefault(),Te());break;case"A":ge.shiftKey&&!ge.metaKey&&!ge.ctrlKey&&(ge.preventDefault(),qe());break;case"R":ge.shiftKey&&!ge.metaKey&&!ge.ctrlKey&&(ge.preventDefault(),pt());break;case"o":!ge.metaKey&&!ge.ctrlKey&&!ge.shiftKey&&(ge.preventDefault(),_==="title"?K(ne=>!ne):Ee());break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[x,o,ut,be,ht,xt,Ve,Te,qe,pt,Ee]);const St=fe>=0?`${fe+1} / ${te}`:`— / ${te}`,At=e.filenames.length,Ye=!Y,Fe=At>0?l.jsxs("div",{className:"review-tab__section",children:[l.jsx("div",{className:"review-tab__section-label",children:"Scope"}),l.jsxs("div",{className:"review-tab__toggle",children:[l.jsx("button",{type:"button",className:`review-panel__toggle-btn${J==="all"?" review-panel__toggle-btn--active":""}`,onClick:()=>D("all"),title:"Cycle every pending doc in the profile",children:"All"}),l.jsx("button",{type:"button",className:`review-panel__toggle-btn${J==="workspace"?" review-panel__toggle-btn--active":""}`,onClick:()=>!Ye&&D("workspace"),disabled:Ye,title:Ye?"Current doc is not in a workspace":"Only cycle pending docs in this workspace",children:"Workspace"})]})]}):null;return!x&&!o?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"review-tab__empty",children:[l.jsx("div",{className:"review-tab__empty-title",children:"All caught up"}),l.jsx("div",{className:"review-tab__empty-note",children:"No pending agent changes. New writes from agents will land here for review."})]}),l.jsx("div",{className:"review-tab",children:l.jsx(Fk,{contentType:s,docId:r,manuscriptStyle:i,onSwitchDocument:c})})]}):l.jsxs("div",{className:"review-tab",children:[Fe,te>1&&l.jsxs("div",{className:"review-tab__section",children:[l.jsx("div",{className:"review-tab__section-label",children:"Document"}),l.jsxs("div",{className:"review-tab__row",children:[l.jsx("button",{className:"review-panel__btn",onClick:ht,title:"Previous doc (h)",children:l.jsx(T8,{})}),l.jsx("button",{className:"review-panel__btn",onClick:xt,title:"Next doc (l)",children:l.jsx(j8,{})}),l.jsx("span",{className:"review-panel__counter",children:St})]})]}),l.jsx("div",{className:"review-tab__section review-tab__section--actions",children:l.jsxs("div",{className:"review-tab__toggle",children:[l.jsx("button",{className:`review-panel__toggle-btn${(Se||_==="title")&&!F?" review-panel__toggle-btn--active":""}`,onClick:()=>{_==="title"?F&&K(!1):Se&&F&&Ee()},disabled:!Se&&_!=="title",title:"Show modified (o)",children:"Modified"}),l.jsx("button",{className:`review-panel__toggle-btn${(Se||_==="title")&&F?" review-panel__toggle-btn--active":""}`,onClick:()=>{_==="title"?F||K(!0):Se&&!F&&Ee()},disabled:!Se&&_!=="title",title:"Show original (o)",children:"Original"})]})}),l.jsxs("div",{className:"review-tab__section",children:[l.jsx("div",{className:"review-tab__section-label",children:_==="title"?"Title":"Change"}),l.jsxs("div",{className:"review-tab__row",children:[l.jsx("button",{className:"review-panel__btn",onClick:be,disabled:$<=1,title:"Previous (k)",children:l.jsx(M8,{})}),l.jsx("button",{className:"review-panel__btn",onClick:ut,disabled:$<=1,title:"Next (j)",children:l.jsx(A8,{})}),l.jsxs("span",{className:"review-panel__counter",children:[B+1," / ",$]})]})]}),l.jsx("div",{className:"review-tab__section",children:l.jsxs("div",{className:"review-tab__row",children:[l.jsxs("button",{className:"review-tab__judge-btn review-tab__judge-btn--accept",onClick:Ve,title:"Accept (a)",children:[l.jsx(R8,{}),l.jsx("span",{children:"Accept"})]}),l.jsxs("button",{className:"review-tab__judge-btn review-tab__judge-btn--reject",onClick:Te,title:"Reject (r)",children:[l.jsx(zk,{}),l.jsx("span",{children:"Reject"})]})]})}),l.jsx("div",{className:"review-tab__section",children:l.jsxs("div",{className:"review-tab__row",children:[l.jsxs("button",{className:"review-tab__bulk-btn review-tab__bulk-btn--accept",onClick:qe,title:"Accept all (Shift+A)",children:[l.jsx(O8,{}),l.jsx("span",{children:"Accept all"})]}),l.jsxs("button",{className:"review-tab__bulk-btn review-tab__bulk-btn--reject",onClick:pt,title:"Reject all (Shift+R)",children:[l.jsx(zk,{}),l.jsx("span",{children:"Reject all"})]})]})}),l.jsx(Fk,{contentType:s,docId:r,manuscriptStyle:i,onSwitchDocument:c})]})}const D8={"agent-finished":"Agent finished",accept:"Accepted",manual:"Saved"};function P8(t){const e=Date.now()-t,n=Math.floor(e/1e3);if(n<60)return"Just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const s=Math.floor(r/60);if(s<24)return`${s}h ago`;const i=Math.floor(s/24);return i<7?`${i}d ago`:new Date(t).toLocaleDateString()}function Uk(t){return t==="human"?"you":t}function B8({docId:t}){const[e,n]=y.useState([]),[r,s]=y.useState(null),[i,o]=y.useState(!1),c=y.useCallback(()=>{if(!t){n([]);return}fetch(`/api/commits/${t}`).then(h=>h.ok?h.json():{commits:[]}).then(h=>n(Array.isArray(h.commits)?h.commits:[])).catch(()=>n([]))},[t]);y.useEffect(()=>{c()},[c]);const d=y.useCallback(async()=>{if(!t||i)return;const h=window.prompt('Save version — optional note (e.g. "first full draft"):')??void 0;o(!0);try{(await(await fetch("/api/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({docId:t,note:h||void 0})})).json().catch(()=>({}))).committed||window.setTimeout(()=>{},0),c()}catch{}o(!1)},[t,i,c]),f=y.useCallback(async h=>{if(!i){o(!0);try{(await fetch(`/api/versions/${h}/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"full"})})).ok&&c()}catch{}o(!1)}},[i,c]);return l.jsxs("div",{className:"versions-tab",children:[l.jsx("div",{className:"versions-tab__actions",children:l.jsx("button",{className:"versions-tab__save-btn",disabled:!t||i,onClick:d,children:"+ Save version"})}),l.jsx("div",{className:"versions-tab__list",children:e.length===0?l.jsx("div",{className:"versions-tab__empty",children:'No versions yet. A version is committed when an agent finishes writing, when you accept changes, or when you hit "Save version."'}):e.map(h=>l.jsxs("div",{className:`commit-row${r===h.ts?" commit-row--expanded":""}`,onClick:()=>s(r===h.ts?null:h.ts),children:[l.jsxs("div",{className:"commit-row__head",children:[l.jsx("span",{className:"commit-row__time",children:P8(h.ts)}),l.jsx("span",{className:"commit-row__authors",children:h.actors.map(m=>l.jsx("span",{className:`commit-badge commit-badge--${m}`,children:Uk(m)},m))})]}),l.jsx("div",{className:"commit-row__label",children:h.label}),h.note&&l.jsxs("div",{className:"commit-row__note",children:["“",h.note,"”"]}),r===h.ts&&l.jsxs("div",{className:"commit-row__detail",onClick:m=>m.stopPropagation(),children:[l.jsx("div",{className:"commit-row__trigger",children:D8[h.trigger]??h.trigger}),l.jsx("ul",{className:"commit-row__breakdown",children:Object.keys(h.summary.byActor).map(m=>{const g=h.summary.byActor[m];return l.jsxs("li",{children:[l.jsx("span",{className:`commit-badge commit-badge--${m}`,children:Uk(m)}),g.added>0&&l.jsxs("span",{children:[" ",g.added," added"]}),g.edited>0&&l.jsxs("span",{children:[" ",g.edited," edited"]}),g.removed>0&&l.jsxs("span",{children:[" ",g.removed," removed"]})]},m)})}),l.jsx("button",{className:"commit-row__restore",disabled:i||!h.restorable,title:h.restorable?"Restore the document to this version":"Snapshot pruned — cannot restore",onClick:()=>f(h.snapshotTs),children:"Restore this version"})]})]},h.ts))})]})}function $8({docId:t,currentFilename:e,onSwitchDocument:n}){const[r,s]=y.useState(new Map),[i,o]=y.useState([]),[c,d]=y.useState([]),[f,h]=y.useState(!0),[m,g]=y.useState(!1);y.useEffect(()=>{let w=!1;const S=async()=>{try{const M=await(await fetch("/api/documents")).json();if(w)return;const _=new Map;if(Array.isArray(M))for(const R of M)R!=null&&R.docId&&_.set(R.docId,{docId:R.docId,filename:R.filename,title:R.title||R.filename});s(_)}catch{}finally{w||h(!1)}};S();const N=()=>S();return window.addEventListener("ow-documents-changed",N),()=>{w=!0,window.removeEventListener("ow-documents-changed",N)}},[]),y.useEffect(()=>{if(!t){o([]);return}let w=!1;const S=()=>{g(!0),fetch(`/api/backlinks/${t}`).then(j=>j.ok?j.json():[]).then(j=>{w||o(Array.isArray(j)?j:[])}).catch(()=>{w||o([])}).finally(()=>{w||g(!1)})};S();const N=()=>S();return window.addEventListener("ow-metadata-changed",N),()=>{w=!0,window.removeEventListener("ow-metadata-changed",N)}},[t]),y.useEffect(()=>{let w=!1;const S=()=>{fetch("/api/document").then(j=>j.json()).then(j=>{var _;if(w)return;const M=(_=j==null?void 0:j.metadata)==null?void 0:_.references;d(Array.isArray(M)?M:[])}).catch(()=>{w||d([])})};S();const N=()=>S();return window.addEventListener("ow-metadata-changed",N),()=>{w=!0,window.removeEventListener("ow-metadata-changed",N)}},[e,t]);const v=y.useMemo(()=>i.map(w=>{const S=r.get(w.from_doc);return S?{docId:w.from_doc,title:S.title,filename:S.filename,snippet:w.text}:null}).filter(w=>w!==null),[i,r]),x=y.useMemo(()=>c.map(w=>{const S=r.get(w);return S?{docId:w,title:S.title,filename:S.filename}:null}).filter(w=>w!==null),[c,r]);if(!t)return l.jsxs("div",{className:"backlinks-tab__empty",children:[l.jsx("div",{className:"backlinks-tab__empty-title",children:"No document open"}),l.jsx("div",{className:"backlinks-tab__empty-note",children:"Open a doc to see what links to it and what it links out to."})]});const k=f||m;return l.jsxs("div",{className:"backlinks-tab",children:[l.jsxs("div",{className:"backlinks-tab__group",children:[l.jsxs("div",{className:"backlinks-tab__group-label",children:["Inbound ",l.jsx("span",{className:"backlinks-tab__count",children:v.length})]}),k&&v.length===0?l.jsx("div",{className:"backlinks-tab__empty-note backlinks-tab__inline-note",children:"Loading…"}):v.length===0?l.jsx("div",{className:"backlinks-tab__empty-note backlinks-tab__inline-note",children:"No docs link to this one yet."}):v.map(w=>l.jsxs("button",{type:"button",className:"backlinks-tab__entry",onClick:()=>n(w.filename),children:[l.jsx("div",{className:"backlinks-tab__entry-title",children:w.title}),w.snippet&&l.jsx("div",{className:"backlinks-tab__entry-snippet",children:w.snippet})]},w.docId))]}),l.jsxs("div",{className:"backlinks-tab__group",children:[l.jsxs("div",{className:"backlinks-tab__group-label",children:["Outbound ",l.jsx("span",{className:"backlinks-tab__count",children:x.length})]}),x.length===0?l.jsx("div",{className:"backlinks-tab__empty-note backlinks-tab__inline-note",children:"This doc doesn’t reference others yet."}):x.map(w=>l.jsx("button",{type:"button",className:"backlinks-tab__entry",onClick:()=>n(w.filename),children:l.jsx("div",{className:"backlinks-tab__entry-title",children:w.title})},w.docId))]})]})}const F8=[{key:"md",label:"Markdown",desc:"Plain .md file",icon:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),l.jsx("path",{d:"M14 2v6h6"})]})},{key:"html",label:"HTML",desc:"Styled web page",icon:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("polyline",{points:"16 18 22 12 16 6"}),l.jsx("polyline",{points:"8 6 2 12 8 18"})]})},{key:"docx",label:"Word",desc:"Microsoft Word .docx",icon:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),l.jsx("path",{d:"M14 2v6h6"}),l.jsx("path",{d:"M16 13H8"}),l.jsx("path",{d:"M16 17H8"}),l.jsx("path",{d:"M10 9H8"})]})},{key:"txt",label:"Plain Text",desc:"Unformatted .txt file",icon:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M17 6.1H3"}),l.jsx("path",{d:"M21 12.1H3"}),l.jsx("path",{d:"M15.1 18H3"})]})},{key:"pdf",label:"PDF",desc:"Print preview for save as PDF",icon:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),l.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),l.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}];function z8(t){const e=n=>{if(n==="pdf"){window.open("/api/export?format=pdf","_blank");return}const r=document.createElement("a");r.href=`/api/export?format=${n}`,r.download="",document.body.appendChild(r),r.click(),document.body.removeChild(r)};return l.jsx("div",{className:"exports-tab",children:l.jsx("div",{className:"exports-tab__list",children:F8.map(n=>l.jsxs("button",{type:"button",className:"exports-tab__item",onClick:()=>e(n.key),children:[l.jsx("span",{className:"exports-tab__item-icon",children:n.icon}),l.jsxs("span",{className:"exports-tab__item-text",children:[l.jsx("span",{className:"exports-tab__item-label",children:n.label}),l.jsx("span",{className:"exports-tab__item-desc",children:n.desc})]})]},n.key))})})}const U8=3e4,H8=500;let Ei={entries:[],freshKeys:new Set};const rv=new Set;function n2(t){return`${t.ts}:${t.kind}:${t.headline}`}function W8(){for(const t of rv)t(Ei)}function sv(t){Ei=t,W8()}function V8(t){return rv.add(t),()=>{rv.delete(t)}}function q8(){return Ei}function K8(t){const e=t.detail;e!=null&&e.entries&&sv({entries:e.entries,freshKeys:new Set})}function G8(t){const e=t.detail;if(!(e!=null&&e.event))return;const n=e.event,r=n2(n),s={entries:[n,...Ei.entries].slice(0,H8),freshKeys:new Set([...Ei.freshKeys,r])};sv(s),window.setTimeout(()=>{if(Ei.freshKeys.has(r)){const i=new Set(Ei.freshKeys);i.delete(r),sv({...Ei,freshKeys:i})}},U8)}typeof window<"u"&&(window.addEventListener("ow-activity-seed",K8),window.addEventListener("ow-activity-event",G8));function J8(){const[t,e]=y.useState(q8);return y.useEffect(()=>V8(e),[]),t}function Y8(){const[t,e]=y.useState(()=>({byDocId:new Map,filenameSet:new Set}));return y.useEffect(()=>{let n=!1;const r=()=>{fetch("/api/documents").then(s=>s.json()).then(s=>{if(n||!Array.isArray(s))return;const i=new Map,o=new Set;for(const c of s)c.filename&&o.add(c.filename),c.docId&&c.filename&&i.set(c.docId,c.filename);e({byDocId:i,filenameSet:o})}).catch(()=>{})};return r(),window.addEventListener("ow-documents-changed",r),()=>{n=!0,window.removeEventListener("ow-documents-changed",r)}},[]),t}function X8(t,e){return t.docId?e.byDocId.get(t.docId)??null:t.filename&&e.filenameSet.has(t.filename)?t.filename:null}function Q8(t,e){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const s=Math.floor(r/60);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);if(i<24)return`${i}h ago`;const o=Math.floor(i/24);return o<7?`${o}d ago`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Z8({onSwitchDocument:t}){const{entries:e,freshKeys:n}=J8(),r=Y8(),[s,i]=y.useState(()=>Date.now());y.useEffect(()=>{const c=setInterval(()=>i(Date.now()),3e4);return()=>clearInterval(c)},[]);const o=y.useMemo(()=>eF(e,s),[e,s]);return e.length===0?l.jsxs("div",{className:"activity-tab__empty",children:[l.jsx("div",{className:"activity-tab__empty-title",children:"No activity yet"}),l.jsx("div",{className:"activity-tab__empty-note",children:"Agent actions — writes, enrichment, backlink propagation — will appear here as they happen."})]}):l.jsx("div",{className:"activity-tab",children:o.map(c=>l.jsxs("div",{className:"activity-tab__group",children:[l.jsx("div",{className:"activity-tab__group-label",children:c.label}),c.entries.map(d=>{const f=n2(d),h=n.has(f),m=d.kind==="doc-deleted"?null:X8(d,r),g=m!==null,v=!g,x=v&&d.kind!=="doc-deleted"?"Doc no longer available":void 0,k=()=>{m&&t(m)};return l.jsxs("div",{className:`activity-tab__entry${h?" activity-tab__entry--fresh":""}${g?" activity-tab__entry--clickable":""}${v?" activity-tab__entry--muted":""}`,role:g?"button":void 0,tabIndex:g?0:void 0,title:x,onClick:k,onKeyDown:w=>{g&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),k())},children:[l.jsx("span",{className:`activity-tab__kind-dot activity-tab__kind-dot--${d.kind}`,"aria-hidden":"true"}),l.jsxs("div",{className:"activity-tab__entry-body",children:[l.jsx("div",{className:"activity-tab__headline",children:d.headline}),d.detail&&l.jsx("div",{className:"activity-tab__detail",children:d.detail})]}),l.jsx("div",{className:"activity-tab__ts",title:new Date(d.ts).toLocaleString(),children:Q8(d.ts,s)})]},f)})]},c.label))})}function eF(t,e){if(t.length===0)return[];const n=Hk(e),r=n-1440*60*1e3,s=[];let i=null;for(const o of t){const c=Hk(o.ts);let d;c===n?d="Today":c===r?d="Yesterday":d=new Date(o.ts).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"}),(!i||i.label!==d)&&(i={label:d,entries:[]},s.push(i)),i.entries.push(o)}return s}function Hk(t){const e=new Date(t);return e.setHours(0,0,0,0),e.getTime()}async function Cu(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();if((i=(s=r==null?void 0:r.content)==null?void 0:s[0])!=null&&i.text)try{return JSON.parse(r.content[0].text)}catch{return r.content[0].text}return r}function tF(){const[t,e]=y.useState([]),[n,r]=y.useState(!0),[s,i]=y.useState("closed"),[o,c]=y.useState(""),[d,f]=y.useState(!1),[h,m]=y.useState(null),[g,v]=y.useState(null),[x,k]=y.useState(null),w=y.useCallback(async()=>{r(!0);try{const _=await Cu("list_blog_sites");e((_==null?void 0:_.sites)||[])}finally{r(!1)}},[]);y.useEffect(()=>{w()},[w]);const S=()=>{i("closed"),c(""),m(null),v(null),k(null)},N=async()=>{if(o.trim()){f(!0),m(null);try{const _=await Cu("inspect_blog_repo",{repo_url:o.trim()});if(_.error){m(_.error);return}v({..._,label:_.repo,branch:"main",site_url:_.site_url||"",blog_url_pattern:_.blog_url_pattern||"/blog/{slug}/"}),i("review")}catch(_){m((_==null?void 0:_.message)||"Inspection failed")}finally{f(!1)}}},j=async()=>{if(g){i("saving"),k(null);try{const _=await Cu("add_blog_site",{label:g.label,owner:g.owner,repo:g.repo,branch:g.branch||"main",content_dir:g.content_dir,image_dir:g.image_dir,image_public_prefix:g.image_public_prefix,framework:g.framework,frontmatter_defaults:g.frontmatter_defaults||{},frontmatter_field_map:g.frontmatter_field_map||{},frontmatter_schema:g.frontmatter_schema||[],site_url:g.site_url||"",blog_url_pattern:g.blog_url_pattern||"/blog/{slug}/"});if(_!=null&&_.error){k(_.error),i("review");return}S(),await w()}catch(_){k((_==null?void 0:_.message)||"Save failed"),i("review")}}},M=async _=>{if(!window.confirm(`Remove "${_.label}" (${_.owner}/${_.repo})?
209
+
210
+ This only removes the OpenWriter registration. Your GitHub repo is untouched.`))return;const L=await Cu("remove_blog_site",{id:_.id});if(L!=null&&L.error){alert(`Remove failed: ${L.error}`);return}await w()};return l.jsxs("div",{className:"github-plugin-settings",children:[l.jsxs("div",{className:"github-plugin-settings__header",children:[l.jsx("span",{className:"github-plugin-settings__title",children:"Blog repos"}),s==="closed"&&l.jsx("button",{className:"github-plugin-settings__add-btn",onClick:()=>i("url"),children:"+ Add"})]}),n?l.jsx("div",{className:"github-plugin-settings__loading",children:"Loading…"}):t.length===0&&s==="closed"?l.jsxs("div",{className:"github-plugin-settings__empty",children:["Connect a GitHub repo to publish blog posts via local git — no PATs, no Workers. Uses your existing ",l.jsx("code",{children:"gh auth login"}),"."]}):l.jsx("div",{className:"github-plugin-settings__list",children:t.map(_=>l.jsxs("div",{className:"github-plugin-settings__site",children:[l.jsxs("div",{className:"github-plugin-settings__site-info",children:[l.jsxs("div",{className:"github-plugin-settings__site-row1",children:[l.jsx("span",{className:"github-plugin-settings__site-label",children:_.label}),l.jsx("span",{className:`github-plugin-settings__site-framework github-plugin-settings__site-framework--${_.framework}`,children:_.framework})]}),l.jsxs("div",{className:"github-plugin-settings__site-repo",children:[_.owner,"/",_.repo,"@",_.branch]}),l.jsxs("div",{className:"github-plugin-settings__site-dirs",children:[l.jsx("span",{title:"content_dir",children:_.content_dir}),l.jsx("span",{className:"github-plugin-settings__site-sep",children:"·"}),l.jsx("span",{title:"image_public_prefix",children:_.image_public_prefix})]})]}),l.jsx("button",{className:"github-plugin-settings__remove-btn",onClick:()=>M(_),title:"Remove",children:"×"})]},_.id))}),s==="url"&&l.jsxs("div",{className:"github-plugin-settings__form",children:[l.jsx("label",{className:"github-plugin-settings__label",children:"GitHub repo"}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",placeholder:"owner/repo or https://github.com/owner/repo",value:o,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!d&&N()},autoFocus:!0}),h&&l.jsx("div",{className:"github-plugin-settings__error",children:h}),l.jsxs("div",{className:"github-plugin-settings__form-buttons",children:[l.jsx("button",{className:"github-plugin-settings__btn github-plugin-settings__btn--primary",onClick:N,disabled:d||!o.trim(),children:d?"Inspecting…":"Inspect"}),l.jsx("button",{className:"github-plugin-settings__btn",onClick:S,disabled:d,children:"Cancel"})]})]}),(s==="review"||s==="saving")&&g&&l.jsxs("div",{className:"github-plugin-settings__form",children:[l.jsxs("div",{className:"github-plugin-settings__form-meta",children:[l.jsxs("span",{children:["Detected: ",g.framework]}),l.jsx("span",{children:"·"}),l.jsxs("span",{children:[g.markdown_files_found," posts"]}),l.jsx("span",{children:"·"}),l.jsxs("span",{className:`github-plugin-settings__confidence github-plugin-settings__confidence--${g.confidence}`,children:[g.confidence," confidence"]})]}),l.jsx("label",{className:"github-plugin-settings__label",children:"Label"}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.label,onChange:_=>v({...g,label:_.target.value})}),l.jsx("label",{className:"github-plugin-settings__label",children:"Branch"}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.branch,onChange:_=>v({...g,branch:_.target.value})}),l.jsx("label",{className:"github-plugin-settings__label",children:"Content directory"}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.content_dir,onChange:_=>v({...g,content_dir:_.target.value})}),l.jsx("label",{className:"github-plugin-settings__label",children:"Image directory"}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.image_dir,onChange:_=>v({...g,image_dir:_.target.value})}),l.jsx("label",{className:"github-plugin-settings__label",children:"Image public prefix"}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.image_public_prefix,onChange:_=>v({...g,image_public_prefix:_.target.value})}),l.jsxs("label",{className:"github-plugin-settings__label",children:["Site URL ",l.jsx("span",{className:"github-plugin-settings__hint",children:"— optional, used for the live link after publish"})]}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",placeholder:"https://example.com",value:g.site_url||"",onChange:_=>v({...g,site_url:_.target.value})}),l.jsxs("label",{className:"github-plugin-settings__label",children:["Blog URL pattern ",l.jsxs("span",{className:"github-plugin-settings__hint",children:["— uses ","{slug}"," placeholder"]})]}),l.jsx("input",{className:"github-plugin-settings__input",type:"text",placeholder:"/blog/{slug}/",value:g.blog_url_pattern||"",onChange:_=>v({...g,blog_url_pattern:_.target.value})}),l.jsx("label",{className:"github-plugin-settings__label",children:"Framework"}),l.jsxs("select",{className:"github-plugin-settings__input",value:g.framework,onChange:_=>v({...g,framework:_.target.value}),children:[l.jsx("option",{value:"astro",children:"Astro"}),l.jsx("option",{value:"next",children:"Next"}),l.jsx("option",{value:"jekyll",children:"Jekyll"}),l.jsx("option",{value:"hugo",children:"Hugo"}),l.jsx("option",{value:"unknown",children:"Unknown"})]}),g.frontmatter_schema.length>0&&l.jsxs("div",{className:"github-plugin-settings__schema",children:[l.jsxs("span",{className:"github-plugin-settings__label",children:["Frontmatter keys detected (",g.samples_analyzed," ",g.samples_analyzed===1?"sample":"samples",")"]}),l.jsx("code",{children:g.frontmatter_schema.join(", ")})]}),Object.keys(g.frontmatter_defaults||{}).length>0&&l.jsxs("div",{className:"github-plugin-settings__schema",children:[l.jsx("span",{className:"github-plugin-settings__label",children:"Frontmatter defaults (constants applied to every post)"}),l.jsx("code",{children:Object.entries(g.frontmatter_defaults).map(([_,R])=>l.jsxs("div",{children:[_,": ",typeof R=="string"?R:JSON.stringify(R)]},_))})]}),Object.keys(g.frontmatter_field_map||{}).length>0&&l.jsxs("div",{className:"github-plugin-settings__schema",children:[l.jsx("span",{className:"github-plugin-settings__label",children:"Field name mapping (openwriter → site)"}),l.jsx("code",{children:Object.entries(g.frontmatter_field_map).map(([_,R])=>l.jsxs("div",{children:[_," → ",R]},_))})]}),x&&l.jsx("div",{className:"github-plugin-settings__error",children:x}),l.jsxs("div",{className:"github-plugin-settings__form-buttons",children:[l.jsx("button",{className:"github-plugin-settings__btn github-plugin-settings__btn--primary",onClick:j,disabled:s==="saving"||!g.label.trim(),children:s==="saving"?"Saving…":"Add site"}),l.jsx("button",{className:"github-plugin-settings__btn",onClick:S,disabled:s==="saving",children:"Cancel"})]})]})]})}const nF={none:"No Plan",free:"No Plan",creator:"Publish — $19/mo",growth:"Publish+Email — $49/mo"},rF=[{plan:"creator",label:"Publish $19/mo"},{plan:"growth",label:"Publish+Email $49/mo"}];function sF(){var d,f;const[t,e]=y.useState(null),[n,r]=y.useState(!0);y.useEffect(()=>{fetch("/api/billing").then(h=>h.json()).then(h=>e(h)).catch(()=>{}).finally(()=>r(!1))},[]);const s=y.useCallback(async h=>{const m=await fetch("/api/billing/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:h})});if(m.ok){const g=await m.json();g.url&&window.open(g.url,"_blank")}},[]),i=y.useCallback(async()=>{const h=await fetch("/api/billing/portal",{method:"POST",headers:{"Content-Type":"application/json"}});if(h.ok){const m=await h.json();m.url&&window.open(m.url,"_blank")}},[]);if(n)return l.jsx("div",{className:"billing-section",children:l.jsx("div",{className:"billing-loading",children:"Loading..."})});if(!(t!=null&&t.authenticated))return null;const o=t.plan||"free",c=rF.filter(h=>{const m=["free","creator","growth"];return m.indexOf(h.plan)>m.indexOf(o)});return l.jsxs("div",{className:"billing-section",children:[l.jsxs("div",{className:"billing-plan",children:[l.jsx("span",{className:"billing-plan-label",children:"Plan"}),l.jsx("span",{className:`billing-plan-badge billing-plan-badge--${o}`,children:nF[o]||o})]}),((d=t.billing)==null?void 0:d.paymentFailed)&&l.jsx("div",{className:"billing-warning",children:"Payment failed — update card to keep your plan."}),c.length>0&&l.jsx("div",{className:"billing-upgrades",children:c.map(h=>l.jsxs("button",{className:"billing-upgrade-btn",onClick:()=>s(h.plan),children:["Upgrade to ",h.label]},h.plan))}),((f=t.billing)==null?void 0:f.hasPaymentMethod)&&l.jsx("button",{className:"billing-manage-btn",onClick:i,children:"Manage Billing"})]})}const iF=[{label:"Fast",cost:"free"},{label:"Fast+",cost:"$"},{label:"Sonnet",cost:"$$"},{label:"Opus",cost:"$$$"}];function oF(){const[t,e]=y.useState(null),[n,r]=y.useState([]),[s,i]=y.useState(!0),[o,c]=y.useState(!1),d=y.useCallback(()=>{Promise.all([y$(),x$()]).then(([f,h])=>{f!=null&&f.wallet&&e(f.wallet.balanceCents),r(h)}).finally(()=>i(!1))},[]);return y.useEffect(()=>{d()},[d]),y.useEffect(()=>{const f=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[d]),s?l.jsx("div",{className:"billing-section",children:l.jsx("div",{className:"billing-loading",children:"Loading…"})}):t===null&&n.length===0?null:l.jsxs("div",{className:"billing-section",children:[l.jsxs("div",{className:"billing-plan",children:[l.jsx("span",{className:"billing-plan-label",children:"Balance"}),l.jsx("span",{className:"av-credits-balance",children:t===null?"—":b$(t)})]}),l.jsx("div",{className:"av-credits-legend",children:iF.map(f=>l.jsxs("span",{className:"av-credits-legend-item",children:[l.jsx("span",{className:"av-credits-model",children:f.label}),l.jsx("span",{className:"av-credits-cost",children:f.cost})]},f.label))}),n.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"av-credits-topup-toggle",onClick:()=>c(f=>!f),children:[l.jsx("svg",{className:`plugin-config-chevron${o?" plugin-config-chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Add balance"]}),o&&l.jsx("div",{className:"billing-upgrades",children:n.map(f=>l.jsxs("button",{className:"billing-upgrade-btn",onClick:()=>IT(f.amountDollars),children:["Add $",f.amountDollars]},f.priceId))})]})]})}function Wk(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function aF({status:t}){return t==="saving"?l.jsx("span",{className:"plugin-config-status plugin-config-status--saving",children:"Saving…"}):t==="saved"?l.jsxs("span",{className:"plugin-config-status plugin-config-status--saved",children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Saved"]}):t==="error"?l.jsxs("span",{className:"plugin-config-status plugin-config-status--error",children:[l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#ef4444",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Failed"]}):null}function lF(t){const[e,n]=y.useState([]),[r,s]=y.useState(null),[i,o]=y.useState(new Set),[c,d]=y.useState({}),f=y.useCallback(()=>{fetch("/api/available-plugins").then(g=>g.json()).then(g=>n(g.plugins||[])).catch(()=>{})},[]);y.useEffect(()=>{f()},[f]),y.useEffect(()=>{const g=()=>f();return window.addEventListener("ow-plugins-changed",g),()=>window.removeEventListener("ow-plugins-changed",g)},[f]);const h=y.useCallback(async(g,v)=>{s(g);try{(await fetch(v?"/api/plugins/disable":"/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})})).ok&&f()}catch{}finally{s(null)}},[f]),m=y.useCallback(async(g,v,x)=>{const k=`${g}:${v}`;d(w=>({...w,[k]:"saving"}));try{const w=await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,config:{[v]:x}})});if(!w.ok)throw new Error(`save failed (${w.status})`);d(S=>({...S,[k]:"saved"})),setTimeout(()=>{d(S=>S[k]==="saved"?{...S,[k]:"idle"}:S)},2e3)}catch{d(w=>({...w,[k]:"error"}))}},[]);return l.jsx("div",{className:"plugins-tab",children:e.length===0?l.jsx("div",{className:"plugin-empty",children:"No plugins found"}):e.map(g=>l.jsxs("div",{className:"plugin-item",children:[l.jsxs("div",{className:"plugin-item-header",children:[l.jsxs("div",{className:"plugin-item-info",children:[l.jsxs("div",{className:"plugin-item-name",children:[Wk(g.name),l.jsxs("span",{className:"plugin-item-version",children:["v",g.version]})]}),g.description&&l.jsx("div",{className:"plugin-item-desc",children:g.description})]}),l.jsxs("label",{className:`plugin-toggle${r===g.name?" loading":""}`,children:[l.jsx("input",{type:"checkbox",checked:g.enabled,disabled:r===g.name,onChange:()=>h(g.name,g.enabled)}),l.jsx("span",{className:"plugin-toggle-track"}),l.jsx("span",{className:"plugin-toggle-thumb"})]})]}),g.enabled&&(()=>{const v=Object.entries(g.configSchema||{}),x=v.filter(([,j])=>j.type==="select"),k=v.filter(([,j])=>j.type!=="select"),w=v.some(([j,M])=>M.required&&!g.config[j]),S=g.name==="@openwriter/plugin-authors-voice"?l.jsx(oF,{}):g.name==="@openwriter/plugin-publish"?l.jsx(sF,{}):g.name==="@openwriter/plugin-github"?l.jsx(tF,{}):null,N=(j,M)=>{const _=c[`${g.name}:${j}`]||"idle";return l.jsxs("div",{className:"plugin-config-field",children:[l.jsxs("label",{className:"plugin-config-label",children:[M.description||j,l.jsx(aF,{status:_})]}),M.options?l.jsxs("select",{className:"plugin-config-input",defaultValue:g.config[j]||"",onChange:R=>m(g.name,j,R.target.value),children:[!M.required&&!M.options.some(R=>R.value==="")&&l.jsx("option",{value:"",children:"—"}),M.options.map(R=>l.jsx("option",{value:R.value,children:R.label},R.value))]}):l.jsx("input",{className:"plugin-config-input",type:j.toLowerCase().includes("key")||j.toLowerCase().includes("secret")||j.toLowerCase().includes("token")?"password":"text",defaultValue:g.config[j]||"",placeholder:M.env?`$${M.env}`:"",onBlur:R=>m(g.name,j,R.target.value)})]},j)};return v.length===0&&!S?null:l.jsxs("div",{className:"plugin-config-section",children:[w&&l.jsxs("div",{className:"plugin-setup-hint",children:["Ask your agent: “set up ",Wk(g.name),"”"]}),x.length>0&&l.jsx("div",{className:"plugin-config",children:x.map(([j,M])=>N(j,M))}),S,k.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"plugin-config-toggle",onClick:()=>o(j=>{const M=new Set(j);return M.has(g.name)?M.delete(g.name):M.add(g.name),M}),children:[l.jsx("svg",{className:`plugin-config-chevron${i.has(g.name)?" plugin-config-chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Settings"]}),i.has(g.name)&&l.jsx("div",{className:"plugin-config",children:k.map(([j,M])=>N(j,M))})]})]})})()]},g.name))})}function cF({existingConnection:t,onClose:e,onSaved:n}){const[r,s]=y.useState("form"),[i,o]=y.useState(null),[c,d]=y.useState((t==null?void 0:t.domain)||""),[f,h]=y.useState(""),[m,g]=y.useState((t==null?void 0:t.from_name)||""),[v,x]=y.useState(""),[k,w]=y.useState((t==null?void 0:t.id)||""),[S,N]=y.useState({dns_verified:!1,sender_verified:!1}),j=y.useRef(null),M=y.useRef(null);y.useEffect(()=>{const K=z=>{r!=="submitting"&&r!=="verifying"&&M.current&&!M.current.contains(z.target)&&e()};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[e,r]),y.useEffect(()=>{const K=z=>{z.key==="Escape"&&r!=="submitting"&&r!=="verifying"&&e()};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[e,r]),y.useEffect(()=>()=>{j.current&&clearInterval(j.current)},[]);async function _(){var K,z;s("submitting"),o(null);try{const P=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:c,from_email:f,from_name:m||void 0,physical_address:v}})})).json(),U=(z=(K=P.content)==null?void 0:K[0])!=null&&z.text?JSON.parse(P.content[0].text):P;if(U.error){o(U.error),s("error");return}const J=U.connectionId||U.connection_id||k;J&&w(J),L(J)}catch(ee){o(ee.message),s("error")}}async function R(){var K,z;s("submitting"),o(null);try{const P=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:c,from_email:f||void 0,from_name:m||void 0,physical_address:v||void 0}})})).json(),U=(z=(K=P.content)==null?void 0:K[0])!=null&&z.text?JSON.parse(P.content[0].text):P;if(U.error){o(U.error),s("error");return}s("done")}catch(ee){o(ee.message),s("error")}}function L(K){s("verifying"),j.current=setInterval(async()=>{var z,ee;try{const U=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"check_domain_status",arguments:{connectionId:K}})})).json(),J=(ee=(z=U.content)==null?void 0:z[0])!=null&&ee.text?JSON.parse(U.content[0].text):U,ie=!!J.dns_verified,q=!!J.sender_verified;N({dns_verified:ie,sender_verified:q}),ie&&q&&(j.current&&clearInterval(j.current),j.current=null,s("done"))}catch{}},5e3)}function $(){k&&fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"resend_domain_verification",arguments:{connectionId:k}})}).catch(()=>{})}const B=!!t,F=c.trim()&&f.trim()&&v.trim();return l.jsx("div",{className:"newsletter-modal-overlay",children:l.jsxs("div",{className:"newsletter-modal newsletter-modal--setup",ref:M,children:[l.jsxs("div",{className:"newsletter-modal__header",children:[l.jsx("h3",{children:B?"Newsletter Settings":"Set Up Newsletter"}),l.jsx("button",{className:"newsletter-modal__close",onClick:e,children:"×"})]}),l.jsxs("div",{className:"newsletter-modal__body",children:[r==="form"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"newsletter-modal__field",children:[l.jsx("label",{className:"newsletter-modal__label",children:"Domain"}),l.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"yourdomain.com",value:c,onChange:K=>d(K.target.value),disabled:B,autoComplete:"off"})]}),l.jsxs("div",{className:"newsletter-modal__field",children:[l.jsx("label",{className:"newsletter-modal__label",children:"From Email"}),l.jsx("input",{className:"newsletter-modal__input",type:"email",placeholder:"newsletter@yourdomain.com",value:f,onChange:K=>h(K.target.value),autoComplete:"off"})]}),l.jsxs("div",{className:"newsletter-modal__field",children:[l.jsxs("label",{className:"newsletter-modal__label",children:["From Name ",l.jsx("span",{className:"newsletter-modal__optional",children:"(optional)"})]}),l.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"Your Name or Brand",value:m,onChange:K=>g(K.target.value),autoComplete:"off"})]}),l.jsxs("div",{className:"newsletter-modal__field",children:[l.jsxs("label",{className:"newsletter-modal__label",children:["Physical Address ",l.jsx("span",{className:"newsletter-modal__required",children:"*"})]}),l.jsx("textarea",{className:"newsletter-modal__input newsletter-modal__textarea",rows:2,placeholder:"123 Main St, City, State 12345",value:v,onChange:K=>x(K.target.value)}),l.jsx("span",{className:"newsletter-modal__hint",children:"Required by CAN-SPAM. Included in email footer."})]}),l.jsxs("div",{className:"newsletter-modal__actions",children:[l.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:B?R:_,disabled:!F,children:B?"Save":"Set Up Domain"})]})]}),r==="submitting"&&l.jsxs("div",{className:"newsletter-modal__status",children:[l.jsx("div",{className:"newsletter-modal__spinner"}),l.jsx("span",{children:B?"Saving...":"Setting up domain..."})]}),r==="verifying"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"newsletter-modal__verify",children:[l.jsx("p",{className:"newsletter-modal__verify-title",children:"Verifying domain setup..."}),l.jsxs("div",{className:"newsletter-modal__verify-checks",children:[l.jsxs("div",{className:`newsletter-modal__verify-item${S.dns_verified?" newsletter-modal__verify-item--done":""}`,children:[S.dns_verified?"✓":l.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),l.jsx("span",{children:"DNS records"})]}),l.jsxs("div",{className:`newsletter-modal__verify-item${S.sender_verified?" newsletter-modal__verify-item--done":""}`,children:[S.sender_verified?"✓":l.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),l.jsx("span",{children:"Sender verification"})]})]}),l.jsx("p",{className:"newsletter-modal__hint",children:"This may take a few minutes. You can close and check back later."})]}),l.jsxs("div",{className:"newsletter-modal__actions",children:[l.jsx("button",{className:"newsletter-modal__btn",onClick:$,children:"Resend Verification"}),l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Close"})]})]}),r==="done"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:B?"Settings saved!":"Newsletter domain configured!"}),l.jsx("div",{className:"newsletter-modal__actions",children:l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Done"})})]}),r==="error"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"newsletter-modal__error",children:i}),l.jsxs("div",{className:"newsletter-modal__actions",children:[l.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s("form"),children:"Try Again"})]})]})]})]})})}const uF={x:[],linkedin:[]};function dF({connectionId:t,provider:e,displayName:n,onClose:r,onSaved:s}){const[i,o]=y.useState("loading"),[c,d]=y.useState({}),[f,h]=y.useState(null),m=y.useRef(null),g=uF[e]||[];y.useEffect(()=>{fetch(`/api/connections/${t}/config`).then(k=>k.json()).then(k=>{d(k.config||{}),o("form")}).catch(k=>{h(k.message),o("error")})},[t]),y.useEffect(()=>{const k=w=>{i!=="saving"&&m.current&&!m.current.contains(w.target)&&r()};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[r,i]),y.useEffect(()=>{const k=w=>{w.key==="Escape"&&i!=="saving"&&r()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[r,i]);async function v(){o("saving"),h(null);try{const k=await fetch(`/api/connections/${t}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),w=await k.json();if(!k.ok)throw new Error(w.error||"Failed to save");o("saved"),s(),setTimeout(r,800)}catch(k){h(k.message),o("error")}}function x(k){switch(k){case"x":return"X (Twitter)";case"linkedin":return"LinkedIn";default:return k}}return l.jsx("div",{className:"conn-config-overlay",children:l.jsxs("div",{className:"conn-config-modal",ref:m,children:[l.jsxs("div",{className:"conn-config-modal__header",children:[l.jsxs("div",{className:"conn-config-modal__title",children:[x(e)," Settings"]}),l.jsx("div",{className:"conn-config-modal__subtitle",children:n})]}),i==="loading"&&l.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[l.jsx("div",{className:"conn-config-spinner"}),l.jsx("span",{children:"Loading configuration..."})]}),(i==="form"||i==="error")&&g.length>0&&l.jsxs("div",{className:"conn-config-modal__body",children:[g.map(k=>l.jsxs("div",{className:"conn-config-field",children:[l.jsxs("label",{className:"conn-config-field__label",children:[k.label,k.readonly&&l.jsx("span",{className:"conn-config-field__badge",children:"read-only"})]}),l.jsx("input",{className:"conn-config-field__input",value:c[k.key]||"",placeholder:k.placeholder,readOnly:k.readonly,onChange:w=>d(S=>({...S,[k.key]:w.target.value}))})]},k.key)),f&&l.jsx("div",{className:"conn-config-modal__error",children:f})]}),(i==="form"||i==="error")&&g.length===0&&l.jsx("div",{className:"conn-config-modal__body conn-config-modal__center",children:l.jsxs("span",{className:"conn-config-modal__empty",children:["No configuration needed for ",x(e),"."]})}),i==="saving"&&l.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[l.jsx("div",{className:"conn-config-spinner"}),l.jsx("span",{children:"Saving..."})]}),i==="saved"&&l.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[l.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),l.jsx("span",{children:"Saved"})]}),l.jsxs("div",{className:"conn-config-modal__footer",children:[l.jsx("button",{className:"conn-config-btn conn-config-btn--secondary",onClick:r,children:i==="saved"?"Close":"Cancel"}),g.length>0&&(i==="form"||i==="error")&&l.jsx("button",{className:"conn-config-btn conn-config-btn--primary",onClick:v,children:"Save"})]})]})})}const fF=[{id:"x",label:"X (Twitter)",oauth:!0},{id:"linkedin",label:"LinkedIn",oauth:!0},{id:"newsletter",label:"Newsletter",oauth:!1}];function Bp(t){switch(t){case"x":return l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})});case"linkedin":return l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})});case"newsletter":return l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),l.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]});default:return l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("circle",{cx:"12",cy:"12",r:"10"})})}}function hF(t){return t==="active"?"connections-status--active":t==="expired"?"connections-status--expired":t==="revoked"?"connections-status--revoked":"connections-status--pending"}function pF(t){const[e,n]=y.useState([]),[r,s]=y.useState(null),[i,o]=y.useState(null),[c,d]=y.useState(null),[f,h]=y.useState(null),[m,g]=y.useState(null),v=y.useRef(null);async function x(){try{const R=await(await fetch("/api/connections")).json();s(R.authenticated!==!1);const L=(R.connections||[]).filter($=>$&&$.id&&$.provider);return n(L),L}catch{return[]}}y.useEffect(()=>{x()},[]),y.useEffect(()=>()=>{v.current&&clearInterval(v.current)},[]);async function k(_){d(_);try{const R=await fetch(`/api/connections/oauth/${_}/start`,{method:"POST"}),L=await R.json();if(!R.ok||!L.url){d(null);return}window.open(L.url,"_blank","width=600,height=700"),v.current=setInterval(async()=>{try{const B=await(await fetch(`/api/connections/oauth/${_}/status/${L.state}`)).json();if(B.status==="completed"){v.current&&clearInterval(v.current),v.current=null,d(null);const F=await x();if(_==="x"){const K=F.find(z=>z.provider==="x"&&z.status==="active");if(K!=null&&K.display_name){const z=K.display_name.replace("@","");localStorage.setItem("ow-x-handle",z),window.dispatchEvent(new StorageEvent("storage",{key:"ow-x-handle",newValue:z}))}}}else B.status==="failed"&&(v.current&&clearInterval(v.current),v.current=null,d(null))}catch{}},2e3)}catch{d(null)}}async function w(_){try{const R=await fetch(`/api/connections/${_}`,{method:"DELETE"});if(!R.ok){const L=await R.json().catch(()=>({error:"Delete failed"}));console.error("[Connections] Delete failed:",L.error)}}catch(R){console.error("[Connections] Delete error:",R)}o(null),await x()}const S=new Map,N=new Map;for(const _ of e){S.has(_.provider)||S.set(_.provider,_);const R=N.get(_.provider)||[];R.push(_),N.set(_.provider,R)}const j=new Set,M=r===!1;return l.jsxs("div",{className:"connections-tab",children:[m&&l.jsx(dF,{connectionId:m.id,provider:m.provider,displayName:m.display_name,onClose:()=>g(null),onSaved:()=>x()}),f&&l.jsx(cF,{existingConnection:f==="edit"?S.get("newsletter"):null,onClose:()=>h(null),onSaved:()=>x()}),M?l.jsxs("div",{className:"connections-dropdown__upsell",children:[l.jsx("p",{children:"Connect your X, LinkedIn, and other accounts to publish directly from OpenWriter."}),l.jsxs("p",{children:["Set up the ",l.jsx("strong",{children:"Publish"})," plugin to get started."]})]}):l.jsx("div",{className:"connections-dropdown__list",children:fF.flatMap(_=>{const R=j.has(_.id),L=N.get(_.id)||[],$=F=>i===F.id?l.jsxs("div",{className:"connections-dropdown__confirm",children:[l.jsxs("span",{children:["Disconnect ",F.display_name||_.label,"?"]}),l.jsxs("div",{className:"connections-dropdown__confirm-btns",children:[l.jsx("button",{onClick:()=>w(F.id),children:"Yes"}),l.jsx("button",{onClick:()=>o(null),children:"No"})]})]},F.id):l.jsxs("div",{className:"connections-dropdown__item",children:[l.jsx("div",{className:"connections-dropdown__icon",children:Bp(_.id)}),l.jsxs("div",{className:"connections-dropdown__info",children:[l.jsx("div",{className:"connections-dropdown__name",children:F.display_name||F.domain||_.label}),l.jsxs("div",{className:"connections-dropdown__type",children:[l.jsx("span",{className:`connections-status ${hF(F.status)}`}),"Connected"]})]}),l.jsxs("div",{className:"connections-dropdown__actions",children:[l.jsx("button",{className:"connections-dropdown__action-btn",onClick:()=>{_.id==="newsletter"?h("edit"):g({id:F.id,provider:_.id,display_name:F.display_name||_.label})},title:"Settings",children:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),l.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),l.jsx("button",{className:"connections-dropdown__action-btn connections-dropdown__action-btn--delete",onClick:()=>o(F.id),title:"Disconnect",children:"×"})]})]},F.id),B=L.map($);return R?(B.push(l.jsx("div",{className:"connections-dropdown__add-row",children:l.jsx("button",{className:"connections-dropdown__add-btn",onClick:()=>k(_.id),disabled:c!==null,children:c===_.id?"Connecting…":`+ Add ${_.label} repo`})},`${_.id}__add`)),B):L.length>0?B:_.oauth?[l.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[l.jsx("div",{className:"connections-dropdown__icon",children:Bp(_.id)}),l.jsxs("div",{className:"connections-dropdown__info",children:[l.jsx("div",{className:"connections-dropdown__name",children:_.label}),l.jsx("div",{className:"connections-dropdown__type",children:"Not connected"})]}),l.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>k(_.id),disabled:c!==null,children:c===_.id?"Connecting…":"Connect"})]},_.id)]:[l.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[l.jsx("div",{className:"connections-dropdown__icon",children:Bp(_.id)}),l.jsxs("div",{className:"connections-dropdown__info",children:[l.jsx("div",{className:"connections-dropdown__name",children:_.label}),l.jsx("div",{className:"connections-dropdown__type",children:"Built-in · Not configured"})]}),l.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>h("new"),children:"Configure"})]},_.id)]})})]})}const mF={tree:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M3 3h7v7H3zM14 3h7v4h-7zM14 10h7v4h-7zM3 13h7v8H3z"})}),files:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),l.jsx("polyline",{points:"14 2 14 8 20 8"})]}),timeline:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22"}),l.jsx("circle",{cx:"12",cy:"6",r:"2"}),l.jsx("circle",{cx:"12",cy:"12",r:"2"}),l.jsx("circle",{cx:"12",cy:"18",r:"2"}),l.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"}),l.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"}),l.jsx("line",{x1:"14",y1:"18",x2:"20",y2:"18"})]}),board:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{x:"3",y:"3",width:"5",height:"18",rx:"1"}),l.jsx("rect",{x:"10",y:"3",width:"5",height:"12",rx:"1"}),l.jsx("rect",{x:"17",y:"3",width:"5",height:"15",rx:"1"})]}),shelf:l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 19V5"}),l.jsx("path",{d:"M8 19V7"}),l.jsx("path",{d:"M12 19V4"}),l.jsx("path",{d:"M16 19V8"}),l.jsx("path",{d:"M20 19V6"}),l.jsx("line",{x1:"2",y1:"20",x2:"22",y2:"20"})]})};function gF(t){const[e,n]=y.useState(LE),[r,s]=y.useState(DE),[i,o]=y.useState($d),c=PE(),[d,f]=y.useState($E),[h,m]=y.useState(FE),g=(N=e,j=r,M=i,_=c,R=d,L=h)=>{zE(N,j,M,_,R,L)},v=N=>{n(N),g(N)},x=()=>{const N=r==="light"?"dark":"light";s(N),g(void 0,N)},k=N=>{o(N),g(void 0,void 0,N),window.dispatchEvent(new CustomEvent("ow-sidebar-mode-change",{detail:N}))},w=N=>{f(N),g(void 0,void 0,void 0,void 0,N)},S=N=>{m(N),g(void 0,void 0,void 0,void 0,void 0,N)};return l.jsxs("div",{className:"appearance-tab",children:[l.jsx("div",{className:"appearance-section",children:l.jsxs("div",{className:"appearance-section-header",children:[l.jsx("span",{className:"appearance-section-title",children:"Mode"}),l.jsxs("button",{className:"appearance-mode-btn",onClick:x,title:r==="light"?"Switch to dark":"Switch to light",children:[r==="light"?l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"5"}),l.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),l.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),l.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),l.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),l.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),l.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),l.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),l.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):l.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),l.jsx("span",{children:r==="light"?"Light":"Dark"})]})]})}),l.jsxs("div",{className:"appearance-section",children:[l.jsx("div",{className:"appearance-section-header",children:l.jsx("span",{className:"appearance-section-title",children:"Typography"})}),l.jsx("div",{className:"appearance-typeface-grid",children:AE.map(N=>l.jsx("button",{className:`appearance-style-option ${e===N.id?"active":""}`,onClick:()=>v(N.id),title:N.description,children:N.label},N.id))})]}),l.jsxs("div",{className:"appearance-section",children:[l.jsx("div",{className:"appearance-section-header",children:l.jsx("span",{className:"appearance-section-title",children:"Spacing"})}),l.jsx("div",{className:"appearance-typography-grid",children:IE.map(N=>l.jsx("button",{className:`appearance-style-option ${d===N.id?"active":""}`,onClick:()=>w(N.id),children:N.label},N.id))})]}),l.jsxs("div",{className:"appearance-section",children:[l.jsx("div",{className:"appearance-section-header",children:l.jsx("span",{className:"appearance-section-title",children:"Canvas"})}),l.jsx("div",{className:"appearance-style-grid",children:OE.map(N=>l.jsx("button",{className:`appearance-style-option ${h===N.id?"active":""}`,onClick:()=>S(N.id),children:N.label},N.id))})]}),l.jsxs("div",{className:"appearance-section",children:[l.jsx("div",{className:"appearance-section-header",children:l.jsx("span",{className:"appearance-section-title",children:"Layout"})}),l.jsx("div",{className:"appearance-mode-grid",children:RE.map(N=>l.jsxs("button",{className:`appearance-mode-option ${i===N.id?"active":""}`,onClick:()=>k(N.id),children:[mF[N.icon],l.jsx("span",{children:N.label})]},N.id))})]})]})}const r2=[{id:"review",label:"Review",scope:"doc",icon:l.jsx(Y5,{}),Component:L8},{id:"activity",label:"Activity",scope:"workspace",icon:l.jsx(t$,{}),Component:Z8},{id:"backlinks",label:"Backlinks",scope:"doc",icon:l.jsx(Z5,{}),Component:$8},{id:"exports",label:"Export",scope:"doc",icon:l.jsx(e$,{}),Component:z8},{id:"versions",label:"Versions",scope:"doc",icon:l.jsx(X5,{}),Component:B8},{id:"plugins",label:"Plugins",scope:"settings",icon:l.jsx(n$,{}),Component:lF},{id:"connections",label:"Connections",scope:"settings",icon:l.jsx(r$,{}),Component:pF},{id:"appearance",label:"Appearance",scope:"settings",icon:l.jsx(s$,{}),Component:gF}];function vF(t){return t?r2.find(e=>e.id===t)??null:null}let Vk=0;function bF({pendingDocs:t}){const{visible:e,activeTab:n,openTab:r}=Bl(),[s,i]=y.useState(!1),[o,c]=y.useState(!1);return y.useEffect(()=>{const d=t.filenames.length,f=Vk;Vk=d,f===0&&d>0&&r("review")},[t.filenames.length,r]),y.useEffect(()=>{const d=()=>r("review");return window.addEventListener("ow-pending-write-applied",d),()=>window.removeEventListener("ow-pending-write-applied",d)},[r]),y.useEffect(()=>{const d=()=>{if(!(e&&n==="activity")){i(!0),window.setTimeout(()=>i(!1),500);try{localStorage.getItem("ow-bell-hint-seen")||(c(!0),localStorage.setItem("ow-bell-hint-seen","1"),window.setTimeout(()=>c(!1),6e3))}catch{}}};return window.addEventListener("ow-activity-event",d),()=>window.removeEventListener("ow-activity-event",d)},[e,n]),l.jsx("div",{className:"rail-icon-strip",role:"tablist","aria-label":"Right rail tabs",children:r2.map(d=>{const f=e&&n===d.id,h=d.id==="activity";return l.jsxs("button",{type:"button",role:"tab","aria-selected":f,className:["rail-icon-btn",f?"rail-icon-btn--active":"",`rail-icon-btn--scope-${d.scope}`,h&&s?"rail-icon-btn--pulsing":""].filter(Boolean).join(" "),onClick:()=>r(d.id),title:d.label,"aria-label":d.label,children:[d.icon,h&&o&&l.jsxs("div",{className:"rail-icon-hint",role:"tooltip",children:[l.jsx("span",{children:"Agent activity lives here."}),l.jsx("button",{type:"button",className:"rail-icon-hint-close",onClick:m=>{m.stopPropagation(),c(!1)},"aria-label":"Dismiss",children:"×"})]})]},d.id)})})}function yF(t){const{activeTab:e}=Bl(),n=vF(e);return l.jsx("div",{className:"rail-body",role:"tabpanel",children:n?l.jsx(n.Component,{...t}):null})}const xF=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:l.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),wF=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M9 14l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),kF=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M12 16v-5M9.5 13.5L12 11l2.5 2.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),SF=()=>l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[l.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),l.jsx("path",{d:"M14 14l-4 4M10 14l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function EF({syncStatus:t,onSync:e}){const[n,r]=y.useState(!1),[s,i]=y.useState([]),[o,c]=y.useState(!1),d=y.useRef(null),f=y.useCallback(()=>{if(n){r(!1);return}r(!0),c(!0),fetch("/api/sync/pending").then(h=>h.json()).then(h=>i(h)).catch(()=>i([])).finally(()=>c(!1))},[n]);return y.useEffect(()=>{t.state!=="pending"&&r(!1)},[t.state]),y.useEffect(()=>{if(!n)return;const h=m=>{d.current&&!d.current.contains(m.target)&&r(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n]),l.jsxs("div",{className:"sync-btn-group",ref:d,children:[l.jsxs("button",{className:`titlebar-btn sync-btn-state sync-${t.state}`,onClick:e,disabled:t.state==="syncing",title:t.lastSyncTime?`Last synced: ${new Date(t.lastSyncTime).toLocaleString()}`:"Sync to GitHub",children:[t.state==="unconfigured"&&l.jsxs(l.Fragment,{children:[l.jsx(xF,{})," Sync"]}),t.state==="synced"&&l.jsxs(l.Fragment,{children:[l.jsx(wF,{})," Synced"]}),t.state==="pending"&&l.jsxs(l.Fragment,{children:[l.jsx(kF,{})," Sync",t.pendingFiles?` (${t.pendingFiles})`:""]}),t.state==="syncing"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"sync-btn-spinner"})," Syncing..."]}),t.state==="error"&&l.jsxs(l.Fragment,{children:[l.jsx(SF,{})," Retry"]})]}),t.state==="pending"&&t.pendingFiles&&t.pendingFiles>0&&l.jsx("button",{className:"sync-details-btn",onClick:f,title:"View pending changes",children:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:l.jsx("path",{d:n?"M3 7.5L6 4.5L9 7.5":"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n&&l.jsxs("div",{className:"sync-pending-dropdown",children:[l.jsx("div",{className:"sync-pending-header",children:"Changes to push"}),o?l.jsx("div",{className:"sync-pending-loading",children:"Loading..."}):s.length===0?l.jsx("div",{className:"sync-pending-loading",children:"No changes"}):l.jsx("div",{className:"sync-pending-list",children:s.map((h,m)=>l.jsxs("div",{className:`sync-pending-item sync-file-${h.status}`,children:[l.jsx("span",{className:"sync-file-badge",children:h.status[0].toUpperCase()}),l.jsx("span",{className:"sync-file-name",children:h.file})]},m))})]})]})}function NF(t){const{syncStatus:e,onSync:n,onToggleToolbar:r,toolbarOpen:s,focusMode:i,onToggleFocusMode:o,heatmapOn:c,onToggleHeatmap:d,heatmapAvailable:f,heatmapTitle:h,...m}=t,{open:g,visible:v,overlay:x,activeTab:k,width:w,setWidth:S,closeRail:N,openTab:j}=Bl(),M=y.useRef(null),_=y.useRef(null),R=y.useRef(i);y.useEffect(()=>{if(i!==R.current)if(R.current=i,i)_.current={open:g,activeTab:k},g&&N();else{const B=_.current;_.current=null,!x&&(B!=null&&B.open)&&B.activeTab&&j(B.activeTab)}},[i]);const L=y.useCallback(B=>{B.preventDefault();const F=B.clientX,K=w,z=P=>{const U=F-P.clientX;S(K+U)},ee=()=>{window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",ee)};window.addEventListener("pointermove",z),window.addEventListener("pointerup",ee)},[w,S]);y.useEffect(()=>{if(!g)return;const B=F=>{F.key==="Escape"&&M.current&&M.current.contains(document.activeElement)&&(F.preventDefault(),N())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[g,N]);const $=!v;return l.jsxs("aside",{ref:M,className:`right-rail-column${$?"":" open"}`,style:$?void 0:{width:w,minWidth:w},"aria-label":"Right rail",children:[!x&&!$&&l.jsx("div",{className:"right-rail-resize-handle",onPointerDown:L,"aria-hidden":"true"}),l.jsxs("div",{className:"right-rail-topbar",children:[l.jsxs("div",{className:"right-rail-topbar-actions right-rail-topbar-actions--start",children:[l.jsx("button",{type:"button",className:"right-rail-topbar-btn",onClick:N,title:"Hide rail","aria-label":"Hide rail",children:l.jsx(i$,{})}),l.jsx("button",{type:"button",className:`right-rail-topbar-btn${i?" right-rail-topbar-btn--active":""}`,onClick:o,title:"Focus mode","aria-label":"Focus mode","aria-pressed":i,children:l.jsx(RT,{})}),l.jsx("button",{type:"button",className:`right-rail-topbar-btn${s?" right-rail-topbar-btn--active":""}`,onClick:r,title:"Toggle format toolbar","aria-label":"Toggle format toolbar","aria-pressed":s,children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M4 20h16"}),l.jsx("path",{d:"m6 16 6-12 6 12"}),l.jsx("path",{d:"M8 12h8"})]})}),f&&l.jsx("button",{type:"button",className:`right-rail-topbar-btn${c?" right-rail-topbar-btn--active":""}`,onClick:d,title:h,"aria-label":"Voice heatmap (human vs agent)","aria-pressed":c,children:l.jsx(Q5,{})})]}),l.jsx("div",{className:"right-rail-topbar-actions right-rail-topbar-actions--end",children:l.jsx(EF,{syncStatus:e,onSync:n})})]}),l.jsx(bF,{pendingDocs:m.pendingDocs}),l.jsx(yF,{...m})]})}function CF({onClose:t,onSetupComplete:e}){const[n,r]=y.useState("detecting"),[s,i]=y.useState(null),[o,c]=y.useState("gh"),[d,f]=y.useState("openwriter-docs"),[h,m]=y.useState(!0),[g,v]=y.useState(""),[x,k]=y.useState(""),[w,S]=y.useState(""),[N,j]=y.useState("");y.useEffect(()=>{fetch("/api/sync/capabilities").then(_=>_.json()).then(_=>{i(_),_.ghAuthenticated?c("gh"):(_.gitInstalled,c("pat")),r("setup")}).catch(()=>{S("Failed to detect git capabilities"),r("error")})},[]);const M=y.useCallback(async()=>{r("progress"),j(o==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const _={method:o,repoName:d,isPrivate:h};o==="pat"&&(_.pat=g),o==="connect"&&(_.remoteUrl=x,_.pat=g||void 0);const R=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!R.ok){const L=await R.json().catch(()=>({}));throw new Error(L.error||`Setup failed (${R.status})`)}r("done"),e()}catch(_){S(_.message),r("error")}},[o,d,h,g,x,e]);return l.jsx("div",{className:"sync-modal-overlay",onClick:t,children:l.jsxs("div",{className:"sync-modal",onClick:_=>_.stopPropagation(),children:[l.jsxs("div",{className:"sync-modal-header",children:[l.jsx("h2",{children:"Sync to GitHub"}),l.jsx("button",{className:"sync-modal-close",onClick:t,children:"×"})]}),n==="detecting"&&l.jsxs("div",{className:"sync-modal-body",children:[l.jsx("div",{className:"sync-spinner"}),l.jsx("p",{children:"Detecting git configuration..."})]}),n==="setup"&&s&&l.jsxs("div",{className:"sync-modal-body",children:[!s.gitInstalled&&l.jsxs("div",{className:"sync-warning",children:["Git is not installed. Please ",l.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",children:"install git"})," first."]}),s.gitInstalled&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"sync-tabs",children:[s.ghAuthenticated&&l.jsx("button",{className:`sync-tab${o==="gh"?" active":""}`,onClick:()=>c("gh"),children:"GitHub CLI"}),l.jsx("button",{className:`sync-tab${o==="pat"?" active":""}`,onClick:()=>c("pat"),children:"Personal Access Token"}),l.jsx("button",{className:`sync-tab${o==="connect"?" active":""}`,onClick:()=>c("connect"),children:"Connect Existing"})]}),o==="gh"&&l.jsxs("div",{className:"sync-form",children:[l.jsxs("label",{children:["Repository name",l.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),l.jsxs("label",{className:"sync-checkbox",children:[l.jsx("input",{type:"checkbox",checked:h,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),o==="pat"&&l.jsxs("div",{className:"sync-form",children:[!s.ghAuthenticated&&!s.ghInstalled&&l.jsxs("p",{className:"sync-hint",children:["Create a ",l.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=OpenWriter",target:"_blank",rel:"noreferrer",children:"Personal Access Token"})," with ",l.jsx("code",{children:"repo"})," scope."]}),l.jsxs("label",{children:["Personal Access Token",l.jsx("input",{type:"password",value:g,onChange:_=>v(_.target.value),placeholder:"ghp_..."})]}),l.jsxs("label",{children:["Repository name",l.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),l.jsxs("label",{className:"sync-checkbox",children:[l.jsx("input",{type:"checkbox",checked:h,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),o==="connect"&&l.jsxs("div",{className:"sync-form",children:[l.jsxs("label",{children:["Remote URL",l.jsx("input",{type:"text",value:x,onChange:_=>k(_.target.value),placeholder:"https://github.com/user/repo.git"})]}),l.jsxs("label",{children:["PAT (optional, for private repos)",l.jsx("input",{type:"password",value:g,onChange:_=>v(_.target.value),placeholder:"ghp_..."})]})]}),l.jsxs("div",{className:"sync-modal-actions",children:[l.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Cancel"}),l.jsx("button",{className:"sync-btn primary",onClick:M,disabled:o==="pat"&&!g||o==="connect"&&!x||o!=="connect"&&!d,children:o==="connect"?"Connect & Sync":"Create & Sync"})]})]})]}),n==="progress"&&l.jsxs("div",{className:"sync-modal-body",children:[l.jsx("div",{className:"sync-spinner"}),l.jsx("p",{children:N})]}),n==="done"&&l.jsxs("div",{className:"sync-modal-body",children:[l.jsx("div",{className:"sync-success-icon",children:"✓"}),l.jsx("p",{children:"Successfully synced to GitHub!"}),l.jsx("div",{className:"sync-modal-actions",children:l.jsx("button",{className:"sync-btn primary",onClick:t,children:"Done"})})]}),n==="error"&&l.jsxs("div",{className:"sync-modal-body",children:[l.jsx("div",{className:"sync-error-msg",children:w}),l.jsxs("div",{className:"sync-modal-actions",children:[l.jsx("button",{className:"sync-btn secondary",onClick:()=>r("setup"),children:"Back"}),l.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Close"})]})]})]})})}function _F({onNodeChanges:t,onAgentStatus:e,onDocumentSwitched:n,onDocumentReloaded:r,onDocumentsChanged:s,onWorkspacesChanged:i,onTitleChanged:o,onPendingDocsChanged:c,onMetadataChanged:d,onSyncStatus:f,onWritingStarted:h,onWritingFinished:m,onIdRewrites:g,onPendingFilenamesChanged:v,getEditorState:x}){const k=y.useRef(null),[w,S]=y.useState(!1),N=y.useRef(0),j=y.useRef(new Set),M=()=>{var A;return(A=ie.current)==null?void 0:A.call(ie,new Set(j.current))},_=y.useRef(t),R=y.useRef(e),L=y.useRef(n),$=y.useRef(s),B=y.useRef(i),F=y.useRef(o),K=y.useRef(c),z=y.useRef(f),ee=y.useRef(d),P=y.useRef(h),U=y.useRef(m),J=y.useRef(g),ie=y.useRef(v),q=y.useRef(r),ue=y.useRef(x);_.current=t,R.current=e,L.current=n,$.current=s,B.current=i,F.current=o,K.current=c,ee.current=d,z.current=f,P.current=h,U.current=m,J.current=g,ie.current=v,q.current=r,ue.current=x,y.useEffect(()=>{const D=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let te,fe=!1,we=1e3;function oe(){const Ee=new WebSocket(D);k.current=Ee,Ee.onopen=()=>{S(!0),we=1e3,fe&&Ee.send(JSON.stringify({type:"request-document"})),fe=!0},Ee.onmessage=Le=>{var Ie,Ve,Te,qe,pt,ut,be,ht,xt,St,At,Ye,ct,Fe;try{const G=JSON.parse(Le.data);if(G.type==="node-changes"&&G.changes&&((Ie=_.current)==null||Ie.call(_,G.changes),typeof G.version=="number"&&(N.current=G.version)),G.type==="id-rewrites"&&Array.isArray(G.rewrites)&&((Ve=J.current)==null||Ve.call(J,G.rewrites)),G.type==="agent-status"&&((Te=R.current)==null||Te.call(R,!!G.agentConnected)),G.type==="document-switched"&&(N.current=typeof G.version=="number"?G.version:0,(qe=L.current)==null||qe.call(L,{document:G.document,title:G.title,filename:G.filename,docId:G.docId,metadata:G.metadata,pendingMetadata:G.pendingMetadata??null}),window.dispatchEvent(new CustomEvent("ow-pending-metadata-changed",{detail:{docId:G.docId,pendingMetadata:G.pendingMetadata??null}}))),G.type==="pending-metadata-changed"&&window.dispatchEvent(new CustomEvent("ow-pending-metadata-changed",{detail:{docId:G.docId,pendingMetadata:G.pendingMetadata??null}})),G.type==="document-reloaded"&&(typeof G.version=="number"&&(N.current=G.version),(pt=q.current)==null||pt.call(q,{document:G.document,title:G.title,filename:G.filename,docId:G.docId,metadata:G.metadata,orphanCount:typeof G.orphanCount=="number"?G.orphanCount:0,staleBaselineCount:typeof G.staleBaselineCount=="number"?G.staleBaselineCount:0})),G.type==="metadata-changed"&&G.metadata&&((ut=ee.current)==null||ut.call(ee,G.metadata)),G.type==="documents-changed"&&((be=$.current)==null||be.call($)),G.type==="workspaces-changed"&&((ht=B.current)==null||ht.call(B)),G.type==="title-changed"&&G.title&&((xt=F.current)==null||xt.call(F,G.title)),G.type==="pending-docs-changed"&&G.pendingDocs&&((St=K.current)==null||St.call(K,G.pendingDocs)),G.type==="sync-status"&&((At=z.current)==null||At.call(z,{state:G.state,lastSyncTime:G.lastSyncTime,pendingFiles:G.pendingFiles,error:G.error})),G.type==="writing-started"&&G.title&&(typeof G.key=="string"&&(j.current.add(G.key),M()),(Ye=P.current)==null||Ye.call(P,G.title,G.target||null)),G.type==="writing-finished"&&(typeof G.key=="string"&&G.key?j.current.delete(G.key):j.current.clear(),M(),(ct=U.current)==null||ct.call(U)),G.type==="pending-writes-sync"&&Array.isArray(G.writes)&&(j.current=new Set(G.writes.map(ge=>ge.key).filter(Boolean)),M(),G.writes.length>0)){const ge=G.writes.reduce((ne,he)=>ne.startedAt>he.startedAt?ne:he);ge!=null&&ge.title&&((Fe=P.current)==null||Fe.call(P,ge.title,ge.target||null))}if(G.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),G.type==="comments-changed"&&G.filename&&window.dispatchEvent(new CustomEvent("ow-comments-changed",{detail:{filename:G.filename}})),G.type==="documents-changed"&&window.dispatchEvent(new CustomEvent("ow-documents-changed")),G.type==="metadata-changed"&&window.dispatchEvent(new CustomEvent("ow-metadata-changed",{detail:{metadata:G.metadata}})),G.type==="activity-log"&&Array.isArray(G.entries)&&window.dispatchEvent(new CustomEvent("ow-activity-seed",{detail:{entries:G.entries}})),G.type==="activity-event"&&G.event&&window.dispatchEvent(new CustomEvent("ow-activity-event",{detail:{event:G.event}})),G.type==="toast"&&typeof G.message=="string"){const ge=G.kind==="error"?"error":"info";Ai(G.message,ge,typeof G.durationMs=="number"?G.durationMs:ge==="error"?9e3:3500)}}catch{}},Ee.onclose=()=>{S(!1),te=setTimeout(oe,we),we=Math.min(we*1.5,8e3)},Ee.onerror=()=>{Ee.close()}}oe();function Se(){var Ee;document.visibilityState==="visible"&&((Ee=k.current)==null?void 0:Ee.readyState)!==WebSocket.OPEN&&(clearTimeout(te),we=1e3,oe())}return document.addEventListener("visibilitychange",Se),()=>{clearTimeout(te),document.removeEventListener("visibilitychange",Se),k.current&&(k.current.onclose=null,k.current.close())}},[]);const Y=y.useCallback(A=>{var D;((D=k.current)==null?void 0:D.readyState)===WebSocket.OPEN&&k.current.send(JSON.stringify(A))},[]);return{connected:w,sendMessage:Y,docVersionRef:N}}function TF(t){const[e,n]=y.useState(null),[r,s]=y.useState(!1),[i,o]=y.useState(null),c=y.useRef(void 0);return y.useEffect(()=>{if(!t){n(null),s(!1),o(null),c.current=void 0;return}t!==c.current&&(c.current=t,s(!0),o(null),fetch(`/api/tweet-embed?url=${encodeURIComponent(t)}`).then(d=>d.ok?d.json():d.json().then(f=>Promise.reject(new Error(f.error||`HTTP ${d.status}`)))).then(d=>{n(d),s(!1)}).catch(d=>{o(d.message),s(!1)}))},[t]),{tweet:e,loading:r,error:i}}function jF(t){var r;const e=t.view.dom,n=[];for(const s of e.children){const i=(r=s.innerText)==null?void 0:r.trim();i&&n.push(i)}return n.join(`
211
+
212
+ `)}function MF(t){const e=n=>{var r;if(n.type==="image"&&((r=n.attrs)!=null&&r.src))return n.attrs.src;if(n.content)for(const s of n.content){const i=e(s);if(i)return i}return null};return e(t.getJSON())}async function AF(t){try{const e=await fetch(t);if(!e.ok)return null;const n=await e.blob();return n.type==="image/png"?n:new Promise(r=>{const s=new Image,i=URL.createObjectURL(n);s.onload=()=>{const o=document.createElement("canvas");o.width=s.naturalWidth,o.height=s.naturalHeight,o.getContext("2d").drawImage(s,0,0),o.toBlob(c=>{URL.revokeObjectURL(i),r(c)},"image/png")},s.onerror=()=>{URL.revokeObjectURL(i),r(null)},s.src=i})}catch{return null}}function RF(t,e){const[n,r]=y.useState("idle"),s=y.useRef();return{copyText:y.useCallback(async()=>{const o=t.current[e];if(!o)return;const c=jF(o),d=MF(o);if(!(!c&&!d)){try{const f={};if(c&&(f["text/plain"]=new Blob([c],{type:"text/plain"})),d){const h=await AF(d);h&&(f["image/png"]=h)}Object.keys(f).length>0&&await navigator.clipboard.write([new ClipboardItem(f)])}catch{if(c){const f=document.createElement("textarea");f.value=c,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.select(),document.execCommand("copy"),document.body.removeChild(f)}}r("copied"),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r("idle"),2e3)}},[t,e]),copyState:n}}function $p(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e4?`${(t/1e3).toFixed(0)}K`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function OF(t){try{const e=Date.now(),n=new Date(t).getTime(),r=Math.floor((e-n)/1e3);if(r<60)return`${r}s`;const s=Math.floor(r/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<24?`${i}h`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return""}}const IF=()=>l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{fill:"currentColor",d:"M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z"})}),LF=()=>l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{fill:"currentColor",d:"M4.5 3.88l4.432 4.14-1.364 1.46L5.5 7.55V16c0 1.1.896 2 2 2H13v2H7.5c-2.209 0-4-1.79-4-4V7.55L1.432 9.48.068 8.02 4.5 3.88zM16.5 6H11V4h5.5c2.209 0 4 1.79 4 4v8.45l2.068-1.93 1.364 1.46-4.432 4.14-4.432-4.14 1.364-1.46 2.068 1.93V8c0-1.1-.896-2-2-2z"})}),DF=()=>l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{fill:"currentColor",d:"M16.697 5.5c-1.222-.06-2.679.51-3.89 2.16l-.805 1.09-.806-1.09C9.984 6.01 8.526 5.44 7.304 5.5c-1.243.07-2.349.78-2.91 1.91-.552 1.12-.633 2.78.479 4.82 1.074 1.97 3.257 4.27 7.129 6.61 3.87-2.34 6.052-4.64 7.126-6.61 1.111-2.04 1.03-3.7.477-4.82-.561-1.13-1.666-1.84-2.908-1.91zm4.187 7.69c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z"})}),PF=()=>l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{fill:"currentColor",d:"M4 4.5C4 3.12 5.119 2 6.5 2h11C18.881 2 20 3.12 20 4.5v18.44l-8-5.71-8 5.71V4.5zM6.5 4c-.276 0-.5.22-.5.5v14.56l6-4.29 6 4.29V4.5c0-.28-.224-.5-.5-.5h-11z"})}),BF=()=>l.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{fill:"currentColor",d:"M12 2.59l5.7 5.7-1.41 1.42L13 6.41V16h-2V6.41l-3.3 3.3-1.41-1.42L12 2.59zM21 15l-.02 3.51c0 1.38-1.12 2.49-2.5 2.49H5.5C4.11 21 3 19.88 3 18.5V15h2v3.5c0 .28.22.5.5.5h12.98c.28 0 .5-.22.5-.5L19 15h2z"})});function s2({tweet:t,nested:e,url:n}){const r=OF(t.createdAt);return l.jsxs("div",{className:`tweet-embed-card${e?" tweet-embed-nested":""}${n?" tweet-embed-card--clickable":""}`,onClick:n?()=>window.open(n,"_blank","noopener,noreferrer"):void 0,role:n?"link":void 0,children:[l.jsxs("div",{className:"tweet-author-row",children:[t.author.avatarUrl?l.jsx("img",{className:"tweet-avatar",src:t.author.avatarUrl,alt:""}):l.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),l.jsxs("div",{className:"tweet-author-info",children:[l.jsx("span",{className:"tweet-author-name",children:t.author.name}),l.jsxs("span",{className:"tweet-author-handle",children:["@",t.author.username]}),r&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"tweet-author-separator",children:"·"}),l.jsx("span",{className:"tweet-author-timestamp",children:r})]})]})]}),l.jsx("div",{className:"tweet-text",children:t.text}),t.media&&t.media.length>0&&l.jsx("div",{className:"tweet-media","data-count":t.media.length,children:t.media.map((s,i)=>s.type==="photo"?l.jsx("img",{className:"tweet-media-img",src:s.url,alt:"",loading:"lazy"},i):s.type==="video"||s.type==="gif"?l.jsx("div",{className:"tweet-media-video-placeholder",children:l.jsx("span",{children:"Video"})},i):null)}),t.quoteTweet&&l.jsx(s2,{tweet:t.quoteTweet,nested:!0}),!e&&l.jsxs("div",{className:"tweet-actions-row",children:[l.jsxs("span",{className:"tweet-action tweet-action-reply",children:[l.jsx(IF,{}),t.metrics.replies>0&&$p(t.metrics.replies)]}),l.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[l.jsx(LF,{}),t.metrics.retweets>0&&$p(t.metrics.retweets)]}),l.jsxs("span",{className:"tweet-action tweet-action-like",children:[l.jsx(DF,{}),t.metrics.likes>0&&$p(t.metrics.likes)]}),l.jsx("span",{className:"tweet-action tweet-action-bookmark",children:l.jsx(PF,{})}),l.jsx("span",{className:"tweet-action tweet-action-share",children:l.jsx(BF,{})})]})]})}function qk({tweet:t,url:e}){return l.jsx(s2,{tweet:t,url:e})}function $F({initialContent:t,initialPreviewImages:e,placeholder:n="What is happening?!",onUpdate:r,onReady:s,onFocus:i,onPreviewImagesChange:o}){const[c,d]=y.useState(e||[]),f=y.useRef(e||[]),h=y.useRef(!1),m=y.useRef(s);m.current=s;const g=y.useRef(o);g.current=o;const v=y.useCallback(S=>{var j;const N=S.slice(0,4);f.current=N,d(N),(j=g.current)==null||j.call(g,N)},[]),x=y.useCallback(S=>{if(h.current)return;const N=[],j=[];if(S.state.doc.descendants((L,$)=>{var B;L.type.name==="image"&&((B=L.attrs)!=null&&B.src)&&(N.push(L.attrs.src),j.push({from:$,to:$+L.nodeSize}))}),N.length===0)return;h.current=!0;const{tr:M}=S.state;for(let L=j.length-1;L>=0;L--)M.delete(j[L].from,j[L].to);S.view.dispatch(M);const _=f.current,R=4-_.length;R>0&&v([..._,...N.slice(0,R)]),h.current=!1},[v]),k=r_({extensions:[...bT,ef.configure({placeholder:n})],content:t||"<p></p>",onCreate:({editor:S})=>{x(S)},onUpdate:({editor:S})=>{x(S),r==null||r(S)},onFocus:()=>{i==null||i()},editorProps:{handlePaste:jT,handleDrop:MT}},[t]);y.useEffect(()=>{k&&z5(k.view,{addToPreview:S=>{const N=f.current;N.length>=4||v([...N,S])},getPreviewImages:()=>f.current})},[k,v]),y.useEffect(()=>{if(!k)return;const{state:S}=k.view;if(S.plugins.some(M=>M.key==="pendingDecoration$"))return;const N=ST(),j=S.reconfigure({plugins:[...S.plugins,N]});k.view.updateState(j)},[k]),y.useEffect(()=>{if(!k)return;const{state:S}=k.view;if(S.plugins.some(M=>M.key==="commentDecoration$"))return;const N=NT(),j=S.reconfigure({plugins:[...S.plugins,N]});k.view.updateState(j)},[k]),y.useEffect(()=>{var S;k&&((S=m.current)==null||S.call(m,k))},[k]);const w=y.useCallback(S=>{v(f.current.filter((N,j)=>j!==S))},[v]);return k?l.jsxs(l.Fragment,{children:[l.jsx(Pv,{editor:k}),c.length>0&&l.jsx("div",{className:"tweet-preview-grid","data-count":c.length,children:c.map((S,N)=>l.jsxs("div",{className:"tweet-image-card",children:[l.jsx("img",{className:"tweet-image-card-img",src:S,alt:"",draggable:!1}),l.jsx("button",{className:"tweet-image-card-remove",onClick:()=>w(N),title:"Remove image",children:"×"})]},S))})]}):null}function FF({count:t,softLimit:e=280}){const n=e-t,r=Math.min(t/e,1),s=n<=20,i=s?30:26,o=2,c=(i-o)/2,d=2*Math.PI*c,f=d*(1-r);let h="var(--x-blue, #1d9bf0)";return n<=0?h="var(--x-red, #f4212e)":n<=20&&(h="var(--x-yellow, #ffd400)"),t===0?null:l.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:i,height:i},children:[l.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[l.jsx("circle",{cx:i/2,cy:i/2,r:c,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:o}),l.jsx("circle",{cx:i/2,cy:i/2,r:c,fill:"none",stroke:h,strokeWidth:o,strokeDasharray:d,strokeDashoffset:f,strokeLinecap:"round",transform:`rotate(-90 ${i/2} ${i/2})`,style:{transition:"stroke-dashoffset 0.15s ease, stroke 0.15s ease"}})]}),s&&l.jsx("span",{className:"tweet-char-number",style:{color:h,fontSize:n<-9||n>9?10:11},children:n})]})}const Kk="@openwriter/plugin-x-api",Gk=[{key:"api-key",label:"API Key",env:"X_API_KEY"},{key:"api-secret",label:"API Secret",env:"X_API_SECRET"},{key:"access-token",label:"Access Token",env:"X_ACCESS_TOKEN"},{key:"access-token-secret",label:"Access Token Secret",env:"X_ACCESS_TOKEN_SECRET"}];function zF({onConnected:t,onCancel:e}){const[n,r]=y.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[s,i]=y.useState(!1),[o,c]=y.useState(""),d=Gk.every(h=>n[h.key].trim()),f=async()=>{i(!0),c("");try{if(!(await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Kk,config:n})})).ok)throw new Error("Failed to save config");const g=await(await fetch("/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Kk})})).json();if(!g.success)throw new Error(g.error||"Failed to enable plugin");const x=await(await fetch("/api/x/status")).json();x.connected?t():c(x.error||"Could not verify X credentials. Check your API keys.")}catch(h){c(h.message||"Connection failed")}finally{i(!1)}};return l.jsxs("div",{className:"x-connect-prompt",children:[l.jsxs("div",{className:"x-connect-header",children:[l.jsx("span",{className:"x-connect-title",children:"Connect your X account to post"}),l.jsx("button",{className:"x-connect-cancel",onClick:e,title:"Cancel",children:l.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",children:l.jsx("path",{fill:"currentColor",d:"M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z"})})})]}),l.jsx("div",{className:"x-connect-fields",children:Gk.map(h=>l.jsxs("div",{className:"x-connect-field",children:[l.jsx("label",{className:"x-connect-label",children:h.label}),l.jsx("input",{type:"password",className:"x-connect-input",value:n[h.key],onChange:m=>r(g=>({...g,[h.key]:m.target.value})),placeholder:h.env,spellCheck:!1,autoComplete:"off"})]},h.key))}),o&&l.jsx("div",{className:"x-connect-error",children:o}),l.jsxs("div",{className:"x-connect-actions",children:[l.jsx("a",{className:"x-connect-dev-link",href:"https://developer.x.com/en/portal/dashboard",target:"_blank",rel:"noopener noreferrer",children:"Get credentials"}),l.jsx("button",{className:"x-connect-btn",onClick:f,disabled:!d||s,children:s?"Connecting...":"Connect"})]})]})}var Jk={},Fp,Yk;function Js(){return Yk||(Yk=1,Fp=function(t){return typeof t=="object"?t!==null:typeof t=="function"}),Fp}var zp,Xk;function Dr(){if(Xk)return zp;Xk=1;var t=Js();return zp=function(e){if(!t(e))throw TypeError(e+" is not an object!");return e},zp}var Up,Qk;function sf(){return Qk||(Qk=1,Up=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}),Up}var Hp,Zk;function Fi(){if(Zk)return Hp;Zk=1;var t=sf();return Hp=function(e){return Object(t(e))},Hp}var Wp,e1;function of(){if(e1)return Wp;e1=1;var t=Math.ceil,e=Math.floor;return Wp=function(n){return isNaN(n=+n)?0:(n>0?e:t)(n)},Wp}var Vp,t1;function No(){if(t1)return Vp;t1=1;var t=of(),e=Math.min;return Vp=function(n){return n>0?e(t(n),9007199254740991):0},Vp}var qp,n1;function i2(){if(n1)return qp;n1=1;var t=of(),e=sf();return qp=function(n){return function(r,s){var i=String(e(r)),o=t(s),c=i.length,d,f;return o<0||o>=c?n?"":void 0:(d=i.charCodeAt(o),d<55296||d>56319||o+1===c||(f=i.charCodeAt(o+1))<56320||f>57343?n?i.charAt(o):d:n?i.slice(o,o+2):(d-55296<<10)+(f-56320)+65536)}},qp}var Kp,r1;function hb(){if(r1)return Kp;r1=1;var t=i2()(!0);return Kp=function(e,n,r){return n+(r?t(e,n).length:1)},Kp}var Gp,s1;function af(){if(s1)return Gp;s1=1;var t={}.toString;return Gp=function(e){return t.call(e).slice(8,-1)},Gp}var Jp={exports:{}},Yp={exports:{}},Xp={exports:{}},i1;function xa(){if(i1)return Xp.exports;i1=1;var t=Xp.exports={version:"2.6.12"};return typeof __e=="number"&&(__e=t),Xp.exports}var Qp={exports:{}},o1;function Yr(){if(o1)return Qp.exports;o1=1;var t=Qp.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();return typeof __g=="number"&&(__g=t),Qp.exports}var Zp,a1;function lf(){return a1||(a1=1,Zp=!1),Zp}var l1;function cf(){if(l1)return Yp.exports;l1=1;var t=xa(),e=Yr(),n="__core-js_shared__",r=e[n]||(e[n]={});return(Yp.exports=function(s,i){return r[s]||(r[s]=i!==void 0?i:{})})("versions",[]).push({version:t.version,mode:lf()?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"}),Yp.exports}var em,c1;function ql(){if(c1)return em;c1=1;var t=0,e=Math.random();return em=function(n){return"Symbol(".concat(n===void 0?"":n,")_",(++t+e).toString(36))},em}var u1;function Vn(){if(u1)return Jp.exports;u1=1;var t=cf()("wks"),e=ql(),n=Yr().Symbol,r=typeof n=="function",s=Jp.exports=function(i){return t[i]||(t[i]=r&&n[i]||(r?n:e)("Symbol."+i))};return s.store=t,Jp.exports}var tm,d1;function pb(){if(d1)return tm;d1=1;var t=af(),e=Vn()("toStringTag"),n=t((function(){return arguments})())=="Arguments",r=function(s,i){try{return s[i]}catch{}};return tm=function(s){var i,o,c;return s===void 0?"Undefined":s===null?"Null":typeof(o=r(i=Object(s),e))=="string"?o:n?t(i):(c=t(i))=="Object"&&typeof i.callee=="function"?"Arguments":c},tm}var nm,f1;function mb(){if(f1)return nm;f1=1;var t=pb(),e=RegExp.prototype.exec;return nm=function(n,r){var s=n.exec;if(typeof s=="function"){var i=s.call(n,r);if(typeof i!="object")throw new TypeError("RegExp exec method returned something other than an Object or null");return i}if(t(n)!=="RegExp")throw new TypeError("RegExp#exec called on incompatible receiver");return e.call(n,r)},nm}var h1={},rm,p1;function uf(){if(p1)return rm;p1=1;var t=Dr();return rm=function(){var e=t(this),n="";return e.global&&(n+="g"),e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),e.sticky&&(n+="y"),n},rm}var sm,m1;function gb(){if(m1)return sm;m1=1;var t=uf(),e=RegExp.prototype.exec,n=String.prototype.replace,r=e,s="lastIndex",i=(function(){var d=/a/,f=/b*/g;return e.call(d,"a"),e.call(f,"a"),d[s]!==0||f[s]!==0})(),o=/()??/.exec("")[1]!==void 0,c=i||o;return c&&(r=function(f){var h=this,m,g,v,x;return o&&(g=new RegExp("^"+h.source+"$(?!\\s)",t.call(h))),i&&(m=h[s]),v=e.call(h,f),i&&v&&(h[s]=h.global?v.index+v[0].length:m),o&&v&&v.length>1&&n.call(v[0],g,function(){for(x=1;x<arguments.length-2;x++)arguments[x]===void 0&&(v[x]=void 0)}),v}),sm=r,sm}var im={},om,g1;function hs(){return g1||(g1=1,om=function(t){try{return!!t()}catch{return!0}}),om}var am,v1;function Xr(){return v1||(v1=1,am=!hs()(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})),am}var lm,b1;function o2(){if(b1)return lm;b1=1;var t=Js(),e=Yr().document,n=t(e)&&t(e.createElement);return lm=function(r){return n?e.createElement(r):{}},lm}var cm,y1;function a2(){return y1||(y1=1,cm=!Xr()&&!hs()(function(){return Object.defineProperty(o2()("div"),"a",{get:function(){return 7}}).a!=7})),cm}var um,x1;function vb(){if(x1)return um;x1=1;var t=Js();return um=function(e,n){if(!t(e))return e;var r,s;if(n&&typeof(r=e.toString)=="function"&&!t(s=r.call(e))||typeof(r=e.valueOf)=="function"&&!t(s=r.call(e))||!n&&typeof(r=e.toString)=="function"&&!t(s=r.call(e)))return s;throw TypeError("Can't convert object to primitive value")},um}var w1;function ps(){if(w1)return im;w1=1;var t=Dr(),e=a2(),n=vb(),r=Object.defineProperty;return im.f=Xr()?Object.defineProperty:function(i,o,c){if(t(i),o=n(o,!0),t(c),e)try{return r(i,o,c)}catch{}if("get"in c||"set"in c)throw TypeError("Accessors not supported!");return"value"in c&&(i[o]=c.value),i},im}var dm,k1;function Kl(){return k1||(k1=1,dm=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}),dm}var fm,S1;function zi(){if(S1)return fm;S1=1;var t=ps(),e=Kl();return fm=Xr()?function(n,r,s){return t.f(n,r,e(1,s))}:function(n,r,s){return n[r]=s,n},fm}var hm={exports:{}},pm,E1;function Co(){if(E1)return pm;E1=1;var t={}.hasOwnProperty;return pm=function(e,n){return t.call(e,n)},pm}var mm,N1;function UF(){return N1||(N1=1,mm=cf()("native-function-to-string",Function.toString)),mm}var C1;function Ys(){if(C1)return hm.exports;C1=1;var t=Yr(),e=zi(),n=Co(),r=ql()("src"),s=UF(),i="toString",o=(""+s).split(i);return xa().inspectSource=function(c){return s.call(c)},(hm.exports=function(c,d,f,h){var m=typeof f=="function";m&&(n(f,"name")||e(f,"name",d)),c[d]!==f&&(m&&(n(f,r)||e(f,r,c[d]?""+c[d]:o.join(String(d)))),c===t?c[d]=f:h?c[d]?c[d]=f:e(c,d,f):(delete c[d],e(c,d,f)))})(Function.prototype,i,function(){return typeof this=="function"&&this[r]||s.call(this)}),hm.exports}var gm,_1;function df(){return _1||(_1=1,gm=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}),gm}var vm,T1;function ff(){if(T1)return vm;T1=1;var t=df();return vm=function(e,n,r){if(t(e),n===void 0)return e;switch(r){case 1:return function(s){return e.call(n,s)};case 2:return function(s,i){return e.call(n,s,i)};case 3:return function(s,i,o){return e.call(n,s,i,o)}}return function(){return e.apply(n,arguments)}},vm}var bm,j1;function Cr(){if(j1)return bm;j1=1;var t=Yr(),e=xa(),n=zi(),r=Ys(),s=ff(),i="prototype",o=function(c,d,f){var h=c&o.F,m=c&o.G,g=c&o.S,v=c&o.P,x=c&o.B,k=m?t:g?t[d]||(t[d]={}):(t[d]||{})[i],w=m?e:e[d]||(e[d]={}),S=w[i]||(w[i]={}),N,j,M,_;m&&(f=d);for(N in f)j=!h&&k&&k[N]!==void 0,M=(j?k:f)[N],_=x&&j?s(M,t):v&&typeof M=="function"?s(Function.call,M):M,k&&r(k,N,M,c&o.U),w[N]!=M&&n(w,N,_),v&&S[N]!=M&&(S[N]=M)};return t.core=e,o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,o.U=64,o.R=128,bm=o,bm}var M1;function HF(){if(M1)return h1;M1=1;var t=gb();return Cr()({target:"RegExp",proto:!0,forced:t!==/./.exec},{exec:t}),h1}var ym,A1;function bb(){if(A1)return ym;A1=1,HF();var t=Ys(),e=zi(),n=hs(),r=sf(),s=Vn(),i=gb(),o=s("species"),c=!n(function(){var f=/./;return f.exec=function(){var h=[];return h.groups={a:"7"},h},"".replace(f,"$<a>")!=="7"}),d=(function(){var f=/(?:)/,h=f.exec;f.exec=function(){return h.apply(this,arguments)};var m="ab".split(f);return m.length===2&&m[0]==="a"&&m[1]==="b"})();return ym=function(f,h,m){var g=s(f),v=!n(function(){var j={};return j[g]=function(){return 7},""[f](j)!=7}),x=v?!n(function(){var j=!1,M=/a/;return M.exec=function(){return j=!0,null},f==="split"&&(M.constructor={},M.constructor[o]=function(){return M}),M[g](""),!j}):void 0;if(!v||!x||f==="replace"&&!c||f==="split"&&!d){var k=/./[g],w=m(r,g,""[f],function(M,_,R,L,$){return _.exec===i?v&&!$?{done:!0,value:k.call(_,R,L)}:{done:!0,value:M.call(R,_,L)}:{done:!1}}),S=w[0],N=w[1];t(String.prototype,f,S),e(RegExp.prototype,g,h==2?function(j,M){return N.call(j,this,M)}:function(j){return N.call(j,this)})}},ym}var R1;function WF(){if(R1)return Jk;R1=1;var t=Dr(),e=Fi(),n=No(),r=of(),s=hb(),i=mb(),o=Math.max,c=Math.min,d=Math.floor,f=/\$([$&`']|\d\d?|<[^>]*>)/g,h=/\$([$&`']|\d\d?)/g,m=function(g){return g===void 0?g:String(g)};return bb()("replace",2,function(g,v,x,k){return[function(N,j){var M=g(this),_=N==null?void 0:N[v];return _!==void 0?_.call(N,M,j):x.call(String(M),N,j)},function(S,N){var j=k(x,S,this,N);if(j.done)return j.value;var M=t(S),_=String(this),R=typeof N=="function";R||(N=String(N));var L=M.global;if(L){var $=M.unicode;M.lastIndex=0}for(var B=[];;){var F=i(M,_);if(F===null||(B.push(F),!L))break;var K=String(F[0]);K===""&&(M.lastIndex=s(_,n(M.lastIndex),$))}for(var z="",ee=0,P=0;P<B.length;P++){F=B[P];for(var U=String(F[0]),J=o(c(r(F.index),_.length),0),ie=[],q=1;q<F.length;q++)ie.push(m(F[q]));var ue=F.groups;if(R){var Y=[U].concat(ie,J,_);ue!==void 0&&Y.push(ue);var A=String(N.apply(void 0,Y))}else A=w(U,_,J,ie,ue,N);J>=ee&&(z+=_.slice(ee,J)+A,ee=J+U.length)}return z+_.slice(ee)}];function w(S,N,j,M,_,R){var L=j+S.length,$=M.length,B=h;return _!==void 0&&(_=e(_),B=f),x.call(R,B,function(F,K){var z;switch(K.charAt(0)){case"$":return"$";case"&":return S;case"`":return N.slice(0,j);case"'":return N.slice(L);case"<":z=_[K.slice(1,-1)];break;default:var ee=+K;if(ee===0)return F;if(ee>$){var P=d(ee/10);return P===0?F:P<=$?M[P-1]===void 0?K.charAt(1):M[P-1]+K.charAt(1):F}z=M[ee-1]}return z===void 0?"":z})}}),Jk}WF();var O1={},xm,I1;function yb(){if(I1)return xm;I1=1;var t=af();return xm=Object("z").propertyIsEnumerable(0)?Object:function(e){return t(e)=="String"?e.split(""):Object(e)},xm}var wm,L1;function _o(){if(L1)return wm;L1=1;var t=yb(),e=sf();return wm=function(n){return t(e(n))},wm}var km,D1;function VF(){if(D1)return km;D1=1;var t=of(),e=Math.max,n=Math.min;return km=function(r,s){return r=t(r),r<0?e(r+s,0):n(r,s)},km}var Sm,P1;function l2(){if(P1)return Sm;P1=1;var t=_o(),e=No(),n=VF();return Sm=function(r){return function(s,i,o){var c=t(s),d=e(c.length),f=n(o,d),h;if(r&&i!=i){for(;d>f;)if(h=c[f++],h!=h)return!0}else for(;d>f;f++)if((r||f in c)&&c[f]===i)return r||f||0;return!r&&-1}},Sm}var Em,B1;function Gl(){if(B1)return Em;B1=1;var t=hs();return Em=function(e,n){return!!e&&t(function(){n?e.call(null,function(){},1):e.call(null)})},Em}var $1;function qF(){if($1)return O1;$1=1;var t=Cr(),e=l2()(!1),n=[].indexOf,r=!!n&&1/[1].indexOf(1,-0)<0;return t(t.P+t.F*(r||!Gl()(n)),"Array",{indexOf:function(i){return r?n.apply(this,arguments)||0:e(this,i,arguments[1])}}),O1}qF();var KF=/[a-z]{1,6}(?:[._][a-z]{1,2})?/i,c2=/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$/,F1={},Nm={},Cm={},z1;function xb(){return z1||(z1=1,Cm.f={}.propertyIsEnumerable),Cm}var U1;function wb(){if(U1)return Nm;U1=1;var t=xb(),e=Kl(),n=_o(),r=vb(),s=Co(),i=a2(),o=Object.getOwnPropertyDescriptor;return Nm.f=Xr()?o:function(d,f){if(d=n(d),f=r(f,!0),i)try{return o(d,f)}catch{}if(s(d,f))return e(!t.f.call(d,f),d[f])},Nm}var _m,H1;function GF(){if(H1)return _m;H1=1;var t=Js(),e=Dr(),n=function(r,s){if(e(r),!t(s)&&s!==null)throw TypeError(s+": can't set as prototype!")};return _m={set:Object.setPrototypeOf||("__proto__"in{}?(function(r,s,i){try{i=ff()(Function.call,wb().f(Object.prototype,"__proto__").set,2),i(r,[]),s=!(r instanceof Array)}catch{s=!0}return function(c,d){return n(c,d),s?c.__proto__=d:i(c,d),c}})({},!1):void 0),check:n},_m}var Tm,W1;function JF(){if(W1)return Tm;W1=1;var t=Js(),e=GF().set;return Tm=function(n,r,s){var i=r.constructor,o;return i!==s&&typeof i=="function"&&(o=i.prototype)!==s.prototype&&t(o)&&e&&e(n,o),n},Tm}var jm={},Mm,V1;function kb(){if(V1)return Mm;V1=1;var t=cf()("keys"),e=ql();return Mm=function(n){return t[n]||(t[n]=e(n))},Mm}var Am,q1;function u2(){if(q1)return Am;q1=1;var t=Co(),e=_o(),n=l2()(!1),r=kb()("IE_PROTO");return Am=function(s,i){var o=e(s),c=0,d=[],f;for(f in o)f!=r&&t(o,f)&&d.push(f);for(;i.length>c;)t(o,f=i[c++])&&(~n(d,f)||d.push(f));return d},Am}var Rm,K1;function Sb(){return K1||(K1=1,Rm="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")),Rm}var G1;function hf(){if(G1)return jm;G1=1;var t=u2(),e=Sb().concat("length","prototype");return jm.f=Object.getOwnPropertyNames||function(r){return t(r,e)},jm}var Om,J1;function d2(){if(J1)return Om;J1=1;var t=Js(),e=af(),n=Vn()("match");return Om=function(r){var s;return t(r)&&((s=r[n])!==void 0?!!s:e(r)=="RegExp")},Om}var Im,Y1;function YF(){if(Y1)return Im;Y1=1;var t=Yr(),e=ps(),n=Xr(),r=Vn()("species");return Im=function(s){var i=t[s];n&&i&&!i[r]&&e.f(i,r,{configurable:!0,get:function(){return this}})},Im}var X1;function XF(){if(X1)return F1;X1=1;var t=Yr(),e=JF(),n=ps().f,r=hf().f,s=d2(),i=uf(),o=t.RegExp,c=o,d=o.prototype,f=/a/g,h=/a/g,m=new o(f)!==f;if(Xr()&&(!m||hs()(function(){return h[Vn()("match")]=!1,o(f)!=f||o(h)==h||o(f,"i")!="/a/i"}))){o=function(w,S){var N=this instanceof o,j=s(w),M=S===void 0;return!N&&j&&w.constructor===o&&M?w:e(m?new c(j&&!M?w.source:w,S):c((j=w instanceof o)?w.source:w,j&&M?i.call(w):S),N?this:d,o)};for(var g=function(k){k in o||n(o,k,{configurable:!0,get:function(){return c[k]},set:function(w){c[k]=w}})},v=r(c),x=0;v.length>x;)g(v[x++]);d.constructor=o,o.prototype=d,Ys()(t,"RegExp",o)}return YF()("RegExp"),F1}XF();function jt(t,e,n){return n=n||"",typeof t!="string"&&(t.global&&n.indexOf("g")<0&&(n+="g"),t.ignoreCase&&n.indexOf("i")<0&&(n+="i"),t.multiline&&n.indexOf("m")<0&&(n+="m"),t=t.source),new RegExp(t.replace(/#\{(\w+)\}/g,function(r,s){var i=e[s]||"";return typeof i!="string"&&(i=i.source),i}),n)}var f2=/\x09-\x0D\x20\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000/;const h2=jt(/[#{spacesGroup}]/,{spacesGroup:f2});jt("(^|#{spaces})(\\$)(#{cashtag})(?=$|\\s|[#{punct}])",{cashtag:KF,spaces:h2,punct:c2},"gi");var Q1={},Z1;function QF(){if(Z1)return Q1;Z1=1;var t=Dr(),e=No(),n=hb(),r=mb();return bb()("match",1,function(s,i,o,c){return[function(f){var h=s(this),m=f==null?void 0:f[i];return m!==void 0?m.call(f,h):new RegExp(f)[i](String(h))},function(d){var f=c(o,d,this);if(f.done)return f.value;var h=t(d),m=String(this);if(!h.global)return r(h,m);var g=h.unicode;h.lastIndex=0;for(var v=[],x=0,k;(k=r(h,m))!==null;){var w=String(k[0]);v[x]=w,w===""&&(h.lastIndex=n(m,e(h.lastIndex),g)),x++}return x===0?null:v}]}),Q1}QF();var p2=/[##]/;jt(/^(?:#{hashSigns}|:\/\/)/,{hashSigns:p2});var m2=jt(RegExp("(?:(?:한국|香港|澳門|新加坡|台灣|台湾|中國|中国|გე|ລາວ|ไทย|ලංකා|ഭാരതം|ಭಾರತ|భారత్|சிங்கப்பூர்|இலங்கை|இந்தியா|ଭାରତ|ભારત|ਭਾਰਤ|ভাৰত|ভারত|বাংলা|भारोत|भारतम्|भारत|ڀارت|پاکستان|موريتانيا|مليسيا|مصر|قطر|فلسطين|عمان|عراق|سورية|سودان|تونس|بھارت|بارت|ایران|امارات|المغرب|السعودية|الجزائر|البحرين|الاردن|հայ|қаз|укр|срб|рф|мон|мкд|ею|бел|бг|ευ|ελ|zw|zm|za|yt|ye|ws|wf|vu|vn|vi|vg|ve|vc|va|uz|uy|us|um|uk|ug|ua|tz|tw|tv|tt|tr|tp|to|tn|tm|tl|tk|tj|th|tg|tf|td|tc|sz|sy|sx|sv|su|st|ss|sr|so|sn|sm|sl|sk|sj|si|sh|sg|se|sd|sc|sb|sa|rw|ru|rs|ro|re|qa|py|pw|pt|ps|pr|pn|pm|pl|pk|ph|pg|pf|pe|pa|om|nz|nu|nr|np|no|nl|ni|ng|nf|ne|nc|na|mz|my|mx|mw|mv|mu|mt|ms|mr|mq|mp|mo|mn|mm|ml|mk|mh|mg|mf|me|md|mc|ma|ly|lv|lu|lt|ls|lr|lk|li|lc|lb|la|kz|ky|kw|kr|kp|kn|km|ki|kh|kg|ke|jp|jo|jm|je|it|is|ir|iq|io|in|im|il|ie|id|hu|ht|hr|hn|hm|hk|gy|gw|gu|gt|gs|gr|gq|gp|gn|gm|gl|gi|gh|gg|gf|ge|gd|gb|ga|fr|fo|fm|fk|fj|fi|eu|et|es|er|eh|eg|ee|ec|dz|do|dm|dk|dj|de|cz|cy|cx|cw|cv|cu|cr|co|cn|cm|cl|ck|ci|ch|cg|cf|cd|cc|ca|bz|by|bw|bv|bt|bs|br|bq|bo|bn|bm|bl|bj|bi|bh|bg|bf|be|bd|bb|ba|az|ax|aw|au|at|as|ar|aq|ao|an|am|al|ai|ag|af|ae|ad|ac)(?=[^0-9a-zA-Z@+-]|$))")),g2=/\u202A-\u202E\u061C\u200E\u200F\u2066\u2067\u2068\u2069/,Eb=/\uFFFE\uFEFF\uFFFF/;function ZF(t,e){return t.replace(/#\{(\w+)\}/g,function(n,r){return e[r]||""})}var ez=ZF("#{punct}#{spacesGroup}#{invalidCharsGroup}#{directionalMarkersGroup}",{punct:c2,spacesGroup:f2,invalidCharsGroup:Eb,directionalMarkersGroup:g2}),v2=jt(/[^#{invalidDomainChars}]/,{invalidDomainChars:ez}),tz=jt(/(?:(?:#{validDomainChars}(?:-|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:v2}),b2=jt(RegExp("(?:(?:삼성|닷컴|닷넷|香格里拉|餐厅|食品|飞利浦|電訊盈科|集团|通販|购物|谷歌|诺基亚|联通|网络|网站|网店|网址|组织机构|移动|珠宝|点看|游戏|淡马锡|机构|書籍|时尚|新闻|政府|政务|招聘|手表|手机|我爱你|慈善|微博|广东|工行|家電|娱乐|天主教|大拿|大众汽车|在线|嘉里大酒店|嘉里|商标|商店|商城|公益|公司|八卦|健康|信息|佛山|企业|中文网|中信|世界|ポイント|ファッション|セール|ストア|コム|グーグル|クラウド|みんな|คอม|संगठन|नेट|कॉम|همراه|موقع|موبايلي|كوم|كاثوليك|عرب|شبكة|بيتك|بازار|العليان|ارامكو|اتصالات|ابوظبي|קום|сайт|рус|орг|онлайн|москва|ком|католик|дети|zuerich|zone|zippo|zip|zero|zara|zappos|yun|youtube|you|yokohama|yoga|yodobashi|yandex|yamaxun|yahoo|yachts|xyz|xxx|xperia|xin|xihuan|xfinity|xerox|xbox|wtf|wtc|wow|world|works|work|woodside|wolterskluwer|wme|winners|wine|windows|win|williamhill|wiki|wien|whoswho|weir|weibo|wedding|wed|website|weber|webcam|weatherchannel|weather|watches|watch|warman|wanggou|wang|walter|walmart|wales|vuelos|voyage|voto|voting|vote|volvo|volkswagen|vodka|vlaanderen|vivo|viva|vistaprint|vista|vision|visa|virgin|vip|vin|villas|viking|vig|video|viajes|vet|versicherung|vermögensberatung|vermögensberater|verisign|ventures|vegas|vanguard|vana|vacations|ups|uol|uno|university|unicom|uconnect|ubs|ubank|tvs|tushu|tunes|tui|tube|trv|trust|travelersinsurance|travelers|travelchannel|travel|training|trading|trade|toys|toyota|town|tours|total|toshiba|toray|top|tools|tokyo|today|tmall|tkmaxx|tjx|tjmaxx|tirol|tires|tips|tiffany|tienda|tickets|tiaa|theatre|theater|thd|teva|tennis|temasek|telefonica|telecity|tel|technology|tech|team|tdk|tci|taxi|tax|tattoo|tatar|tatamotors|target|taobao|talk|taipei|tab|systems|symantec|sydney|swiss|swiftcover|swatch|suzuki|surgery|surf|support|supply|supplies|sucks|style|study|studio|stream|store|storage|stockholm|stcgroup|stc|statoil|statefarm|statebank|starhub|star|staples|stada|srt|srl|spreadbetting|spot|sport|spiegel|space|soy|sony|song|solutions|solar|sohu|software|softbank|social|soccer|sncf|smile|smart|sling|skype|sky|skin|ski|site|singles|sina|silk|shriram|showtime|show|shouji|shopping|shop|shoes|shiksha|shia|shell|shaw|sharp|shangrila|sfr|sexy|sex|sew|seven|ses|services|sener|select|seek|security|secure|seat|search|scot|scor|scjohnson|science|schwarz|schule|school|scholarships|schmidt|schaeffler|scb|sca|sbs|sbi|saxo|save|sas|sarl|sapo|sap|sanofi|sandvikcoromant|sandvik|samsung|samsclub|salon|sale|sakura|safety|safe|saarland|ryukyu|rwe|run|ruhr|rugby|rsvp|room|rogers|rodeo|rocks|rocher|rmit|rip|rio|ril|rightathome|ricoh|richardli|rich|rexroth|reviews|review|restaurant|rest|republican|report|repair|rentals|rent|ren|reliance|reit|reisen|reise|rehab|redumbrella|redstone|red|recipes|realty|realtor|realestate|read|raid|radio|racing|qvc|quest|quebec|qpon|pwc|pub|prudential|pru|protection|property|properties|promo|progressive|prof|productions|prod|pro|prime|press|praxi|pramerica|post|porn|politie|poker|pohl|pnc|plus|plumbing|playstation|play|place|pizza|pioneer|pink|ping|pin|pid|pictures|pictet|pics|piaget|physio|photos|photography|photo|phone|philips|phd|pharmacy|pfizer|pet|pccw|pay|passagens|party|parts|partners|pars|paris|panerai|panasonic|pamperedchef|page|ovh|ott|otsuka|osaka|origins|orientexpress|organic|org|orange|oracle|open|ooo|onyourside|online|onl|ong|one|omega|ollo|oldnavy|olayangroup|olayan|okinawa|office|off|observer|obi|nyc|ntt|nrw|nra|nowtv|nowruz|now|norton|northwesternmutual|nokia|nissay|nissan|ninja|nikon|nike|nico|nhk|ngo|nfl|nexus|nextdirect|next|news|newholland|new|neustar|network|netflix|netbank|net|nec|nba|navy|natura|nationwide|name|nagoya|nadex|nab|mutuelle|mutual|museum|mtr|mtpc|mtn|msd|movistar|movie|mov|motorcycles|moto|moscow|mortgage|mormon|mopar|montblanc|monster|money|monash|mom|moi|moe|moda|mobily|mobile|mobi|mma|mls|mlb|mitsubishi|mit|mint|mini|mil|microsoft|miami|metlife|merckmsd|meo|menu|men|memorial|meme|melbourne|meet|media|med|mckinsey|mcdonalds|mcd|mba|mattel|maserati|marshalls|marriott|markets|marketing|market|map|mango|management|man|makeup|maison|maif|madrid|macys|luxury|luxe|lupin|lundbeck|ltda|ltd|lplfinancial|lpl|love|lotto|lotte|london|lol|loft|locus|locker|loans|loan|llp|llc|lixil|living|live|lipsy|link|linde|lincoln|limo|limited|lilly|like|lighting|lifestyle|lifeinsurance|life|lidl|liaison|lgbt|lexus|lego|legal|lefrak|leclerc|lease|lds|lawyer|law|latrobe|latino|lat|lasalle|lanxess|landrover|land|lancome|lancia|lancaster|lamer|lamborghini|ladbrokes|lacaixa|kyoto|kuokgroup|kred|krd|kpn|kpmg|kosher|komatsu|koeln|kiwi|kitchen|kindle|kinder|kim|kia|kfh|kerryproperties|kerrylogistics|kerryhotels|kddi|kaufen|juniper|juegos|jprs|jpmorgan|joy|jot|joburg|jobs|jnj|jmp|jll|jlc|jio|jewelry|jetzt|jeep|jcp|jcb|java|jaguar|iwc|iveco|itv|itau|istanbul|ist|ismaili|iselect|irish|ipiranga|investments|intuit|international|intel|int|insure|insurance|institute|ink|ing|info|infiniti|industries|inc|immobilien|immo|imdb|imamat|ikano|iinet|ifm|ieee|icu|ice|icbc|ibm|hyundai|hyatt|hughes|htc|hsbc|how|house|hotmail|hotels|hoteles|hot|hosting|host|hospital|horse|honeywell|honda|homesense|homes|homegoods|homedepot|holiday|holdings|hockey|hkt|hiv|hitachi|hisamitsu|hiphop|hgtv|hermes|here|helsinki|help|healthcare|health|hdfcbank|hdfc|hbo|haus|hangout|hamburg|hair|guru|guitars|guide|guge|gucci|guardian|group|grocery|gripe|green|gratis|graphics|grainger|gov|got|gop|google|goog|goodyear|goodhands|goo|golf|goldpoint|gold|godaddy|gmx|gmo|gmbh|gmail|globo|global|gle|glass|glade|giving|gives|gifts|gift|ggee|george|genting|gent|gea|gdn|gbiz|gay|garden|gap|games|game|gallup|gallo|gallery|gal|fyi|futbol|furniture|fund|fun|fujixerox|fujitsu|ftr|frontier|frontdoor|frogans|frl|fresenius|free|fox|foundation|forum|forsale|forex|ford|football|foodnetwork|food|foo|fly|flsmidth|flowers|florist|flir|flights|flickr|fitness|fit|fishing|fish|firmdale|firestone|fire|financial|finance|final|film|fido|fidelity|fiat|ferrero|ferrari|feedback|fedex|fast|fashion|farmers|farm|fans|fan|family|faith|fairwinds|fail|fage|extraspace|express|exposed|expert|exchange|everbank|events|eus|eurovision|etisalat|esurance|estate|esq|erni|ericsson|equipment|epson|epost|enterprises|engineering|engineer|energy|emerck|email|education|edu|edeka|eco|eat|earth|dvr|dvag|durban|dupont|duns|dunlop|duck|dubai|dtv|drive|download|dot|doosan|domains|doha|dog|dodge|doctor|docs|dnp|diy|dish|discover|discount|directory|direct|digital|diet|diamonds|dhl|dev|design|desi|dentist|dental|democrat|delta|deloitte|dell|delivery|degree|deals|dealer|deal|dds|dclk|day|datsun|dating|date|data|dance|dad|dabur|cyou|cymru|cuisinella|csc|cruises|cruise|crs|crown|cricket|creditunion|creditcard|credit|cpa|courses|coupons|coupon|country|corsica|coop|cool|cookingchannel|cooking|contractors|contact|consulting|construction|condos|comsec|computer|compare|company|community|commbank|comcast|com|cologne|college|coffee|codes|coach|clubmed|club|cloud|clothing|clinique|clinic|click|cleaning|claims|cityeats|city|citic|citi|citadel|cisco|circle|cipriani|church|chrysler|chrome|christmas|chloe|chintai|cheap|chat|chase|charity|channel|chanel|cfd|cfa|cern|ceo|center|ceb|cbs|cbre|cbn|cba|catholic|catering|cat|casino|cash|caseih|case|casa|cartier|cars|careers|career|care|cards|caravan|car|capitalone|capital|capetown|canon|cancerresearch|camp|camera|cam|calvinklein|call|cal|cafe|cab|bzh|buzz|buy|business|builders|build|bugatti|budapest|brussels|brother|broker|broadway|bridgestone|bradesco|box|boutique|bot|boston|bostik|bosch|boots|booking|book|boo|bond|bom|bofa|boehringer|boats|bnpparibas|bnl|bmw|bms|blue|bloomberg|blog|blockbuster|blanco|blackfriday|black|biz|bio|bingo|bing|bike|bid|bible|bharti|bet|bestbuy|best|berlin|bentley|beer|beauty|beats|bcn|bcg|bbva|bbt|bbc|bayern|bauhaus|basketball|baseball|bargains|barefoot|barclays|barclaycard|barcelona|bar|bank|band|bananarepublic|banamex|baidu|baby|azure|axa|aws|avianca|autos|auto|author|auspost|audio|audible|audi|auction|attorney|athleta|associates|asia|asda|arte|art|arpa|army|archi|aramco|arab|aquarelle|apple|app|apartments|aol|anz|anquan|android|analytics|amsterdam|amica|amfam|amex|americanfamily|americanexpress|alstom|alsace|ally|allstate|allfinanz|alipay|alibaba|alfaromeo|akdn|airtel|airforce|airbus|aigo|aig|agency|agakhan|africa|afl|afamilycompany|aetna|aero|aeg|adult|ads|adac|actor|active|aco|accountants|accountant|accenture|academy|abudhabi|abogado|able|abc|abbvie|abbott|abb|abarth|aarp|aaa|onion)(?=[^0-9a-zA-Z@+-]|$))")),y2=/(?:xn--[\-0-9a-z]+)/,nz=jt(/(?:(?:#{validDomainChars}(?:[_-]|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:v2}),rz=jt(/(?:#{validSubdomain}*#{validDomainName}(?:#{validGTLD}|#{validCCTLD}|#{validPunycode}))/,{validDomainName:tz,validSubdomain:nz,validGTLD:b2,validCCTLD:m2,validPunycode:y2}),sz=/[0-9]+/,x2=/\u0400-\u04FF/,pf=/\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u024F\u0253\u0254\u0256\u0257\u0259\u025B\u0263\u0268\u026F\u0272\u0289\u028B\u02BB\u0300-\u036F\u1E00-\u1EFF/,w2=jt(/[a-z#{cyrillicLettersAndMarks}0-9!\*';:=\+,\.\$\/%#\[\]\-\u2013_~@\|&#{latinAccentChars}]/i,{cyrillicLettersAndMarks:x2,latinAccentChars:pf}),k2=jt("\\((?:#{validGeneralUrlPathChars}+|(?:#{validGeneralUrlPathChars}*\\(#{validGeneralUrlPathChars}+\\)#{validGeneralUrlPathChars}*))\\)",{validGeneralUrlPathChars:w2},"i"),iz=jt(/[\+\-a-z#{cyrillicLettersAndMarks}0-9=_#\/#{latinAccentChars}]|(?:#{validUrlBalancedParens})/i,{cyrillicLettersAndMarks:x2,latinAccentChars:pf,validUrlBalancedParens:k2}),oz=jt("(?:(?:#{validGeneralUrlPathChars}*(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*#{validUrlPathEndingChars})|(?:@#{validGeneralUrlPathChars}+/))",{validGeneralUrlPathChars:w2,validUrlBalancedParens:k2,validUrlPathEndingChars:iz},"i"),az=jt(/(?:[^A-Za-z0-9@@$###{invalidCharsGroup}]|[#{directionalMarkersGroup}]|^)/,{invalidCharsGroup:Eb,directionalMarkersGroup:g2}),S2=/[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i,E2=/[a-z0-9\-_&=#\/]/i,eS=jt("((#{validUrlPrecedingChars})((https?:\\/\\/)?(#{validDomain})(?::(#{validPortNumber}))?(\\/#{validUrlPath}*)?(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?))",{validUrlPrecedingChars:az,validDomain:rz,validPortNumber:sz,validUrlPath:oz,validUrlQueryChars:S2,validUrlQueryEndingChars:E2},"gi"),lz=/[-_.\/]$/,tS={},Lm,nS;function cz(){if(nS)return Lm;nS=1;var t=Dr(),e=df(),n=Vn()("species");return Lm=function(r,s){var i=t(r).constructor,o;return i===void 0||(o=t(i)[n])==null?s:e(o)},Lm}var rS;function uz(){if(rS)return tS;rS=1;var t=d2(),e=Dr(),n=cz(),r=hb(),s=No(),i=mb(),o=gb(),c=hs(),d=Math.min,f=[].push,h="split",m="length",g="lastIndex",v=4294967295,x=!c(function(){});return bb()("split",2,function(k,w,S,N){var j;return"abbc"[h](/(b)*/)[1]=="c"||"test"[h](/(?:)/,-1)[m]!=4||"ab"[h](/(?:ab)*/)[m]!=2||"."[h](/(.?)(.?)/)[m]!=4||"."[h](/()()/)[m]>1||""[h](/.?/)[m]?j=function(M,_){var R=String(this);if(M===void 0&&_===0)return[];if(!t(M))return S.call(R,M,_);for(var L=[],$=(M.ignoreCase?"i":"")+(M.multiline?"m":"")+(M.unicode?"u":"")+(M.sticky?"y":""),B=0,F=_===void 0?v:_>>>0,K=new RegExp(M.source,$+"g"),z,ee,P;(z=o.call(K,R))&&(ee=K[g],!(ee>B&&(L.push(R.slice(B,z.index)),z[m]>1&&z.index<R[m]&&f.apply(L,z.slice(1)),P=z[0][m],B=ee,L[m]>=F)));)K[g]===z.index&&K[g]++;return B===R[m]?(P||!K.test(""))&&L.push(""):L.push(R.slice(B)),L[m]>F?L.slice(0,F):L}:"0"[h](void 0,0)[m]?j=function(M,_){return M===void 0&&_===0?[]:S.call(this,M,_)}:j=S,[function(_,R){var L=k(this),$=_==null?void 0:_[w];return $!==void 0?$.call(_,L,R):j.call(String(L),_,R)},function(M,_){var R=N(j,M,this,_,j!==S);if(R.done)return R.value;var L=e(M),$=String(this),B=n(L,RegExp),F=L.unicode,K=(L.ignoreCase?"i":"")+(L.multiline?"m":"")+(L.unicode?"u":"")+(x?"y":"g"),z=new B(x?L:"^(?:"+L.source+")",K),ee=_===void 0?v:_>>>0;if(ee===0)return[];if($.length===0)return i(z,$)===null?[$]:[];for(var P=0,U=0,J=[];U<$.length;){z.lastIndex=x?U:0;var ie=i(z,x?$:$.slice(U)),q;if(ie===null||(q=d(s(z.lastIndex+(x?0:U)),$.length))===P)U=r($,U,F);else{if(J.push($.slice(P,U)),J.length===ee)return J;for(var ue=1;ue<=ie.length-1;ue++)if(J.push(ie[ue]),J.length===ee)return J;U=P=q}}return J.push($.slice(P)),J}]}),tS}uz();var dl={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var dz=dl.exports,sS;function fz(){return sS||(sS=1,(function(t,e){(function(n){var r=e&&!e.nodeType&&e,s=t&&!t.nodeType&&t,i=typeof q0=="object"&&q0;(i.global===i||i.window===i||i.self===i)&&(n=i);var o,c=2147483647,d=36,f=1,h=26,m=38,g=700,v=72,x=128,k="-",w=/^xn--/,S=/[^\x20-\x7E]/,N=/[\x2E\u3002\uFF0E\uFF61]/g,j={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=d-f,_=Math.floor,R=String.fromCharCode,L;function $(Y){throw new RangeError(j[Y])}function B(Y,A){for(var D=Y.length,te=[];D--;)te[D]=A(Y[D]);return te}function F(Y,A){var D=Y.split("@"),te="";D.length>1&&(te=D[0]+"@",Y=D[1]),Y=Y.replace(N,".");var fe=Y.split("."),we=B(fe,A).join(".");return te+we}function K(Y){for(var A=[],D=0,te=Y.length,fe,we;D<te;)fe=Y.charCodeAt(D++),fe>=55296&&fe<=56319&&D<te?(we=Y.charCodeAt(D++),(we&64512)==56320?A.push(((fe&1023)<<10)+(we&1023)+65536):(A.push(fe),D--)):A.push(fe);return A}function z(Y){return B(Y,function(A){var D="";return A>65535&&(A-=65536,D+=R(A>>>10&1023|55296),A=56320|A&1023),D+=R(A),D}).join("")}function ee(Y){return Y-48<10?Y-22:Y-65<26?Y-65:Y-97<26?Y-97:d}function P(Y,A){return Y+22+75*(Y<26)-((A!=0)<<5)}function U(Y,A,D){var te=0;for(Y=D?_(Y/g):Y>>1,Y+=_(Y/A);Y>M*h>>1;te+=d)Y=_(Y/M);return _(te+(M+1)*Y/(Y+m))}function J(Y){var A=[],D=Y.length,te,fe=0,we=x,oe=v,Se,Ee,Le,Ie,Ve,Te,qe,pt,ut;for(Se=Y.lastIndexOf(k),Se<0&&(Se=0),Ee=0;Ee<Se;++Ee)Y.charCodeAt(Ee)>=128&&$("not-basic"),A.push(Y.charCodeAt(Ee));for(Le=Se>0?Se+1:0;Le<D;){for(Ie=fe,Ve=1,Te=d;Le>=D&&$("invalid-input"),qe=ee(Y.charCodeAt(Le++)),(qe>=d||qe>_((c-fe)/Ve))&&$("overflow"),fe+=qe*Ve,pt=Te<=oe?f:Te>=oe+h?h:Te-oe,!(qe<pt);Te+=d)ut=d-pt,Ve>_(c/ut)&&$("overflow"),Ve*=ut;te=A.length+1,oe=U(fe-Ie,te,Ie==0),_(fe/te)>c-we&&$("overflow"),we+=_(fe/te),fe%=te,A.splice(fe++,0,we)}return z(A)}function ie(Y){var A,D,te,fe,we,oe,Se,Ee,Le,Ie,Ve,Te=[],qe,pt,ut,be;for(Y=K(Y),qe=Y.length,A=x,D=0,we=v,oe=0;oe<qe;++oe)Ve=Y[oe],Ve<128&&Te.push(R(Ve));for(te=fe=Te.length,fe&&Te.push(k);te<qe;){for(Se=c,oe=0;oe<qe;++oe)Ve=Y[oe],Ve>=A&&Ve<Se&&(Se=Ve);for(pt=te+1,Se-A>_((c-D)/pt)&&$("overflow"),D+=(Se-A)*pt,A=Se,oe=0;oe<qe;++oe)if(Ve=Y[oe],Ve<A&&++D>c&&$("overflow"),Ve==A){for(Ee=D,Le=d;Ie=Le<=we?f:Le>=we+h?h:Le-we,!(Ee<Ie);Le+=d)be=Ee-Ie,ut=d-Ie,Te.push(R(P(Ie+be%ut,0))),Ee=_(be/ut);Te.push(R(P(Ee,0))),we=U(D,pt,te==fe),D=0,++te}++D,++A}return Te.join("")}function q(Y){return F(Y,function(A){return w.test(A)?J(A.slice(4).toLowerCase()):A})}function ue(Y){return F(Y,function(A){return S.test(A)?"xn--"+ie(A):A})}if(o={version:"1.4.1",ucs2:{decode:K,encode:z},decode:J,encode:ie,toASCII:ue,toUnicode:q},r&&s)if(t.exports==r)s.exports=o;else for(L in o)o.hasOwnProperty(L)&&(r[L]=o[L]);else n.punycode=o})(dz)})(dl,dl.exports)),dl.exports}var hz=fz();const pz=Dl(hz);var N2=jt(/(?:(?:[\-a-z0-9#{latinAccentChars}]+)\.)+(?:#{validGTLD}|#{validCCTLD}|#{validPunycode})/gi,{latinAccentChars:pf,validGTLD:b2,validCCTLD:m2,validPunycode:y2}),mz=63,gz="xn--",vz={toAscii:function(e){if(!(e.substring(0,4)===gz&&!e.match(N2))){for(var n=e.split("."),r=0;r<n.length;r++){var s=n[r],i=pz.toASCII(s);if(i.length<1||i.length>mz)return}return n.join(".")}}},bz=jt(/^https?:\/\/t\.co\/([a-z0-9]+)(?:\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?/,{validUrlQueryChars:S2,validUrlQueryEndingChars:E2},"i"),yz="https://",xz={extractUrlsWithoutProtocol:!0},wz=4096,kz=40,Sz=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:xz;if(!e||(n.extractUrlsWithoutProtocol?!e.match(/\./):!e.match(/:/)))return[];for(var r=[],s=function(){var c=RegExp.$2,d=RegExp.$3,f=RegExp.$4,h=RegExp.$5,m=RegExp.$7,g=eS.lastIndex,v=g-d.length;if(!Ez(d,f||yz,h))return"continue";if(f){if(d.match(bz)){var w=RegExp.$1;if(w&&w.length>kz)return"continue";d=RegExp.lastMatch,g=v+d.length}r.push({url:d,indices:[v,g]})}else{if(!n.extractUrlsWithoutProtocol||c.match(lz))return"continue";var x=null,k=0;if(h.replace(N2,function(S){var N=h.indexOf(S,k);k=N+S.length,x={url:S,indices:[v+N,v+k]},r.push(x)}),x==null)return"continue";m&&(x.url=d.replace(h,x.url),x.indices[1]=g)}};eS.exec(e);)var i=s();return r},Ez=function(e,n,r){var s=e.length,i=vz.toAscii(r);return!i||!i.length?!1:(s=s+i.length-r.length,n.length+s<=wz)},iS={},oS;function Nz(){if(oS)return iS;oS=1;var t=Cr(),e=df(),n=Fi(),r=hs(),s=[].sort,i=[1,2,3];return t(t.P+t.F*(r(function(){i.sort(void 0)})||!r(function(){i.sort(null)})||!Gl()(s)),"Array",{sort:function(c){return c===void 0?s.call(n(this)):s.call(n(this),e(c))}}),iS}Nz();var C2=/\ud800[\udc00-\udc0b\udc0d-\udc26\udc28-\udc3a\udc3c\udc3d\udc3f-\udc4d\udc50-\udc5d\udc80-\udcfa\uddfd\ude80-\ude9c\udea0-\uded0\udee0\udf00-\udf1f\udf30-\udf40\udf42-\udf49\udf50-\udf7a\udf80-\udf9d\udfa0-\udfc3\udfc8-\udfcf]|\ud801[\udc00-\udc9d\udd00-\udd27\udd30-\udd63\ude00-\udf36\udf40-\udf55\udf60-\udf67]|\ud802[\udc00-\udc05\udc08\udc0a-\udc35\udc37\udc38\udc3c\udc3f-\udc55\udc60-\udc76\udc80-\udc9e\udd00-\udd15\udd20-\udd39\udd80-\uddb7\uddbe\uddbf\ude00-\ude03\ude05\ude06\ude0c-\ude13\ude15-\ude17\ude19-\ude33\ude38-\ude3a\ude3f\ude60-\ude7c\ude80-\ude9c\udec0-\udec7\udec9-\udee6\udf00-\udf35\udf40-\udf55\udf60-\udf72\udf80-\udf91]|\ud803[\udc00-\udc48]|\ud804[\udc00-\udc46\udc7f-\udcba\udcd0-\udce8\udd00-\udd34\udd50-\udd73\udd76\udd80-\uddc4\uddda\ude00-\ude11\ude13-\ude37\udeb0-\udeea\udf01-\udf03\udf05-\udf0c\udf0f\udf10\udf13-\udf28\udf2a-\udf30\udf32\udf33\udf35-\udf39\udf3c-\udf44\udf47\udf48\udf4b-\udf4d\udf57\udf5d-\udf63\udf66-\udf6c\udf70-\udf74]|\ud805[\udc80-\udcc5\udcc7\udd80-\uddb5\uddb8-\uddc0\ude00-\ude40\ude44\ude80-\udeb7]|\ud806[\udca0-\udcdf\udcff\udec0-\udef8]|\ud808[\udc00-\udf98]|\ud80c[\udc00-\udfff]|\ud80d[\udc00-\udc2e]|\ud81a[\udc00-\ude38\ude40-\ude5e\uded0-\udeed\udef0-\udef4\udf00-\udf36\udf40-\udf43\udf63-\udf77\udf7d-\udf8f]|\ud81b[\udf00-\udf44\udf50-\udf7e\udf8f-\udf9f]|\ud82c[\udc00\udc01]|\ud82f[\udc00-\udc6a\udc70-\udc7c\udc80-\udc88\udc90-\udc99\udc9d\udc9e]|\ud834[\udd65-\udd69\udd6d-\udd72\udd7b-\udd82\udd85-\udd8b\uddaa-\uddad\ude42-\ude44]|\ud835[\udc00-\udc54\udc56-\udc9c\udc9e\udc9f\udca2\udca5\udca6\udca9-\udcac\udcae-\udcb9\udcbb\udcbd-\udcc3\udcc5-\udd05\udd07-\udd0a\udd0d-\udd14\udd16-\udd1c\udd1e-\udd39\udd3b-\udd3e\udd40-\udd44\udd46\udd4a-\udd50\udd52-\udea5\udea8-\udec0\udec2-\udeda\udedc-\udefa\udefc-\udf14\udf16-\udf34\udf36-\udf4e\udf50-\udf6e\udf70-\udf88\udf8a-\udfa8\udfaa-\udfc2\udfc4-\udfcb]|\ud83a[\udc00-\udcc4\udcd0-\udcd6]|\ud83b[\ude00-\ude03\ude05-\ude1f\ude21\ude22\ude24\ude27\ude29-\ude32\ude34-\ude37\ude39\ude3b\ude42\ude47\ude49\ude4b\ude4d-\ude4f\ude51\ude52\ude54\ude57\ude59\ude5b\ude5d\ude5f\ude61\ude62\ude64\ude67-\ude6a\ude6c-\ude72\ude74-\ude77\ude79-\ude7c\ude7e\ude80-\ude89\ude8b-\ude9b\udea1-\udea3\udea5-\udea9\udeab-\udebb]|\ud840[\udc00-\udfff]|\ud841[\udc00-\udfff]|\ud842[\udc00-\udfff]|\ud843[\udc00-\udfff]|\ud844[\udc00-\udfff]|\ud845[\udc00-\udfff]|\ud846[\udc00-\udfff]|\ud847[\udc00-\udfff]|\ud848[\udc00-\udfff]|\ud849[\udc00-\udfff]|\ud84a[\udc00-\udfff]|\ud84b[\udc00-\udfff]|\ud84c[\udc00-\udfff]|\ud84d[\udc00-\udfff]|\ud84e[\udc00-\udfff]|\ud84f[\udc00-\udfff]|\ud850[\udc00-\udfff]|\ud851[\udc00-\udfff]|\ud852[\udc00-\udfff]|\ud853[\udc00-\udfff]|\ud854[\udc00-\udfff]|\ud855[\udc00-\udfff]|\ud856[\udc00-\udfff]|\ud857[\udc00-\udfff]|\ud858[\udc00-\udfff]|\ud859[\udc00-\udfff]|\ud85a[\udc00-\udfff]|\ud85b[\udc00-\udfff]|\ud85c[\udc00-\udfff]|\ud85d[\udc00-\udfff]|\ud85e[\udc00-\udfff]|\ud85f[\udc00-\udfff]|\ud860[\udc00-\udfff]|\ud861[\udc00-\udfff]|\ud862[\udc00-\udfff]|\ud863[\udc00-\udfff]|\ud864[\udc00-\udfff]|\ud865[\udc00-\udfff]|\ud866[\udc00-\udfff]|\ud867[\udc00-\udfff]|\ud868[\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|\ud86a[\udc00-\udfff]|\ud86b[\udc00-\udfff]|\ud86c[\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d]|\ud87e[\udc00-\ude1d]|\udb40[\udd00-\uddef]/,_2=/A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u052f\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07ca-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0-\u08b2\u08e4-\u0963\u0971-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09f0\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a70-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0c00-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c81-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0cf1\u0cf2\u0d01-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u103f\u1050-\u108f\u109a-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16f1-\u16f8\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u180b-\u180d\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191e\u1920-\u192b\u1930-\u193b\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f\u1aa7\u1ab0-\u1abe\u1b00-\u1b4b\u1b6b-\u1b73\u1b80-\u1baf\u1bba-\u1bf3\u1c00-\u1c37\u1c4d-\u1c4f\u1c5a-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1cf8\u1cf9\u1d00-\u1df5\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u20d0-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2183\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005\u3006\u302a-\u302f\u3031-\u3035\u303b\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua672\ua674-\ua67d\ua67f-\ua69d\ua69f-\ua6e5\ua6f0\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua7ad\ua7b0\ua7b1\ua7f7-\ua827\ua840-\ua873\ua880-\ua8c4\ua8e0-\ua8f7\ua8fb\ua90a-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf\ua9e0-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa36\uaa40-\uaa4d\uaa60-\uaa76\uaa7a-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab5f\uab64\uab65\uabc0-\uabea\uabec\uabed\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf870-\uf87f\uf882\uf884-\uf89f\uf8b8\uf8c1-\uf8d6\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe2d\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc/,T2=/[\uD800-\uDBFF][\uDC00-\uDFFF]/gm,Cz=jt(/(?:[#{bmpLetterAndMarks}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}))/,{bmpLetterAndMarks:_2,nonBmpCodePairs:T2,astralLetterAndMarks:C2}),_z=/\ud801[\udca0-\udca9]|\ud804[\udc66-\udc6f\udcf0-\udcf9\udd36-\udd3f\uddd0-\uddd9\udef0-\udef9]|\ud805[\udcd0-\udcd9\ude50-\ude59\udec0-\udec9]|\ud806[\udce0-\udce9]|\ud81a[\ude60-\ude69\udf50-\udf59]|\ud835[\udfce-\udfff]/,Tz=/0-9\u0660-\u0669\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0de6-\u0def\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\ua9f0-\ua9f9\uaa50-\uaa59\uabf0-\uabf9\uff10-\uff19/,jz=/_\u200c\u200d\ua67e\u05be\u05f3\u05f4\uff5e\u301c\u309b\u309c\u30a0\u30fb\u3003\u0f0b\u0f0c\xb7/,j2=jt(/(?:[#{bmpLetterAndMarks}#{bmpNumerals}#{hashtagSpecialChars}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}|#{astralNumerals}))/,{bmpLetterAndMarks:_2,bmpNumerals:Tz,hashtagSpecialChars:jz,nonBmpCodePairs:T2,astralLetterAndMarks:C2,astralNumerals:_z}),Mz=/(?:[^\uD800-\uDFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF])/,Az=jt(/(?:^|\uFE0E|\uFE0F|$|(?!#{hashtagAlphaNumeric}|&)#{codePoint})/,{codePoint:Mz,hashtagAlphaNumeric:j2});jt(/(#{hashtagBoundary})(#{hashSigns})(?!\uFE0F|\u20E3)(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi,{hashtagBoundary:Az,hashSigns:p2,hashtagAlphaNumeric:j2,hashtagAlpha:Cz});var Nb=/[@@]/;jt(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/\/)/,{atSigns:Nb,latinAccentChars:pf});var Rz=/(?:^|[^a-zA-Z0-9_!#$%&*@@]|(?:^|[^a-zA-Z0-9_+~.-])(?:rt|RT|rT|Rt):?)/,Oz=jt("(#{validMentionPrecedingChars})(#{atSigns})([a-zA-Z0-9_]{1,20})(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?",{validMentionPrecedingChars:Rz,atSigns:Nb},"g"),aS={},lS={},cS;function Iz(){return cS||(cS=1,Xr()&&/./g.flags!="g"&&ps().f(RegExp.prototype,"flags",{configurable:!0,get:uf()})),lS}var uS;function Lz(){if(uS)return aS;uS=1,Iz();var t=Dr(),e=uf(),n=Xr(),r="toString",s=/./[r],i=function(o){Ys()(RegExp.prototype,r,o,!0)};return hs()(function(){return s.call({source:"a",flags:"b"})!="/a/b"})?i(function(){var c=t(this);return"/".concat(c.source,"/","flags"in c?c.flags:!n&&c instanceof RegExp?e.call(c):void 0)}):s.name!=r&&i(function(){return s.call(this)}),aS}Lz();var dS={},fS;function Dz(){if(fS)return dS;fS=1;var t=Date.prototype,e="Invalid Date",n="toString",r=t[n],s=t.getTime;return new Date(NaN)+""!=e&&Ys()(t,n,function(){var o=s.call(this);return o===o?r.call(this):e}),dS}Dz();var hS={},pS;function Pz(){if(pS)return hS;pS=1;var t=pb(),e={};return e[Vn()("toStringTag")]="z",e+""!="[object z]"&&Ys()(Object.prototype,"toString",function(){return"[object "+t(this)+"]"},!0),hS}Pz();const mS={defaults:{version:3,maxWeightedTweetLength:280,scale:100,defaultWeight:200,emojiParsingEnabled:!0,transformedURLLength:23,ranges:[{start:0,end:4351,weight:100},{start:8192,end:8205,weight:100},{start:8208,end:8223,weight:100},{start:8242,end:8247,weight:100}]}};jt(/^(?:#{spaces})*#{atSigns}([a-zA-Z0-9_]{1,20})/,{atSigns:Nb,spaces:h2});var gS={},Dm,vS;function Cb(){if(vS)return Dm;vS=1;var t=af();return Dm=Array.isArray||function(n){return t(n)=="Array"},Dm}var bS;function Bz(){if(bS)return gS;bS=1;var t=Cr();return t(t.S,"Array",{isArray:Cb()}),gS}Bz();var $z=function(e,n){var r=n.defaultWeight,s=n.ranges,i=r,o=e.charCodeAt(0);if(Array.isArray(s))for(var c=0,d=s.length;c<d;c++){var f=s[c];if(o>=f.start&&o<=f.end){i=f.weight;break}}return i},yS={},Pm,xS;function Fz(){if(xS)return Pm;xS=1;var t=df(),e=Fi(),n=yb(),r=No();return Pm=function(s,i,o,c,d){t(i);var f=e(s),h=n(f),m=r(f.length),g=d?m-1:0,v=d?-1:1;if(o<2)for(;;){if(g in h){c=h[g],g+=v;break}if(g+=v,d?g<0:m<=g)throw TypeError("Reduce of empty array with no initial value")}for(;d?g>=0:m>g;g+=v)g in h&&(c=i(c,h[g],g,f));return c},Pm}var wS;function zz(){if(wS)return yS;wS=1;var t=Cr(),e=Fz();return t(t.P+t.F*!Gl()([].reduce,!0),"Array",{reduce:function(r){return e(this,r,arguments.length,arguments[1],!1)}}),yS}zz();var kS={},Bm,SS;function Uz(){if(SS)return Bm;SS=1;var t=Vn()("unscopables"),e=Array.prototype;return e[t]==null&&zi()(e,t,{}),Bm=function(n){e[t][n]=!0},Bm}var $m,ES;function Hz(){return ES||(ES=1,$m=function(t,e){return{value:e,done:!!t}}),$m}var Fm,NS;function Jl(){return NS||(NS=1,Fm={}),Fm}var zm,CS;function Yl(){if(CS)return zm;CS=1;var t=u2(),e=Sb();return zm=Object.keys||function(r){return t(r,e)},zm}var Um,_S;function M2(){if(_S)return Um;_S=1;var t=ps(),e=Dr(),n=Yl();return Um=Xr()?Object.defineProperties:function(s,i){e(s);for(var o=n(i),c=o.length,d=0,f;c>d;)t.f(s,f=o[d++],i[f]);return s},Um}var Hm,TS;function Wz(){if(TS)return Hm;TS=1;var t=Yr().document;return Hm=t&&t.documentElement,Hm}var Wm,jS;function A2(){if(jS)return Wm;jS=1;var t=Dr(),e=M2(),n=Sb(),r=kb()("IE_PROTO"),s=function(){},i="prototype",o=function(){var c=o2()("iframe"),d=n.length,f="<",h=">",m;for(c.style.display="none",Wz().appendChild(c),c.src="javascript:",m=c.contentWindow.document,m.open(),m.write(f+"script"+h+"document.F=Object"+f+"/script"+h),m.close(),o=m.F;d--;)delete o[i][n[d]];return o()};return Wm=Object.create||function(d,f){var h;return d!==null?(s[i]=t(d),h=new s,s[i]=null,h[r]=d):h=o(),f===void 0?h:e(h,f)},Wm}var Vm,MS;function _b(){if(MS)return Vm;MS=1;var t=ps().f,e=Co(),n=Vn()("toStringTag");return Vm=function(r,s,i){r&&!e(r=i?r:r.prototype,n)&&t(r,n,{configurable:!0,value:s})},Vm}var qm,AS;function Vz(){if(AS)return qm;AS=1;var t=A2(),e=Kl(),n=_b(),r={};return zi()(r,Vn()("iterator"),function(){return this}),qm=function(s,i,o){s.prototype=t(r,{next:e(1,o)}),n(s,i+" Iterator")},qm}var Km,RS;function qz(){if(RS)return Km;RS=1;var t=Co(),e=Fi(),n=kb()("IE_PROTO"),r=Object.prototype;return Km=Object.getPrototypeOf||function(s){return s=e(s),t(s,n)?s[n]:typeof s.constructor=="function"&&s instanceof s.constructor?s.constructor.prototype:s instanceof Object?r:null},Km}var Gm,OS;function R2(){if(OS)return Gm;OS=1;var t=lf(),e=Cr(),n=Ys(),r=zi(),s=Jl(),i=Vz(),o=_b(),c=qz(),d=Vn()("iterator"),f=!([].keys&&"next"in[].keys()),h="@@iterator",m="keys",g="values",v=function(){return this};return Gm=function(x,k,w,S,N,j,M){i(w,k,S);var _=function(ie){if(!f&&ie in B)return B[ie];switch(ie){case m:return function(){return new w(this,ie)};case g:return function(){return new w(this,ie)}}return function(){return new w(this,ie)}},R=k+" Iterator",L=N==g,$=!1,B=x.prototype,F=B[d]||B[h]||N&&B[N],K=F||_(N),z=N?L?_("entries"):K:void 0,ee=k=="Array"&&B.entries||F,P,U,J;if(ee&&(J=c(ee.call(new x)),J!==Object.prototype&&J.next&&(o(J,R,!0),!t&&typeof J[d]!="function"&&r(J,d,v))),L&&F&&F.name!==g&&($=!0,K=function(){return F.call(this)}),(!t||M)&&(f||$||!B[d])&&r(B,d,K),s[k]=K,s[R]=v,N)if(P={values:L?K:_(g),keys:j?K:_(m),entries:z},M)for(U in P)U in B||n(B,U,P[U]);else e(e.P+e.F*(f||$),k,P);return P},Gm}var Jm,IS;function O2(){if(IS)return Jm;IS=1;var t=Uz(),e=Hz(),n=Jl(),r=_o();return Jm=R2()(Array,"Array",function(s,i){this._t=r(s),this._i=0,this._k=i},function(){var s=this._t,i=this._k,o=this._i++;return!s||o>=s.length?(this._t=void 0,e(1)):i=="keys"?e(0,o):i=="values"?e(0,s[o]):e(0,[o,s[o]])},"values"),n.Arguments=n.Array,t("keys"),t("values"),t("entries"),Jm}var LS;function Kz(){if(LS)return kS;LS=1;for(var t=O2(),e=Yl(),n=Ys(),r=Yr(),s=zi(),i=Jl(),o=Vn(),c=o("iterator"),d=o("toStringTag"),f=i.Array,h={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},m=e(h),g=0;g<m.length;g++){var v=m[g],x=h[v],k=r[v],w=k&&k.prototype,S;if(w&&(w[c]||s(w,c,f),w[d]||s(w,d,v),i[v]=f,x))for(S in t)w[S]||n(w,S,t[S],!0)}return kS}Kz();O2();var DS={},Ym,PS;function Gz(){if(PS)return Ym;PS=1;var t=Cr(),e=xa(),n=hs();return Ym=function(r,s){var i=(e.Object||{})[r]||Object[r],o={};o[r]=s(i),t(t.S+t.F*n(function(){i(1)}),"Object",o)},Ym}var BS;function Jz(){if(BS)return DS;BS=1;var t=Fi(),e=Yl();return Gz()("keys",function(){return function(r){return e(t(r))}}),DS}Jz();var Yz=jt(/[#{invalidCharsGroup}]/,{invalidCharsGroup:Eb});function Xz(t){return Yz.test(t)}var ro={},_u={},$S;function Qz(){return $S||($S=1,Object.defineProperty(_u,"__esModule",{value:!0}),_u.default=/(?:\ud83d[\udc68\udc69])(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddb0-\uddb3])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddb5\uddb6\uddb8\uddb9\uddd1-\udddd]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a-\udc6d\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\udeeb\udeec\udef4-\udef9]|\ud83e[\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd40-\udd45\udd47-\udd70\udd73-\udd76\udd7a\udd7c-\udda2\uddb4\uddb7\uddc0-\uddc2\uddd0\uddde-\uddff]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g),_u}var FS;function Zz(){if(FS)return ro;FS=1,Object.defineProperty(ro,"__esModule",{value:!0}),ro.TypeName=void 0,ro.parse=s,ro.toCodePoints=d;var t=Qz(),e=n(t);function n(f){return f&&f.__esModule?f:{default:f}}var r=ro.TypeName="emoji";function s(f,h){var m=h&&h.assetType?h.assetType:"svg",g=h&&h.buildUrl?h.buildUrl:function(S,N){return N==="png"?"https://twemoji.maxcdn.com/2/72x72/"+S+".png":"https://twemoji.maxcdn.com/2/svg/"+S+".svg"},v=[];for(e.default.lastIndex=0;;){var x=e.default.exec(f);if(!x)break;var k=x[0],w=d(c(k)).join("-");v.push({url:w?g(w,m):"",indices:[x.index,e.default.lastIndex],text:k,type:r})}return v}var i=/\uFE0F/g,o="‍",c=function(h){return h.indexOf(o)<0?h.replace(i,""):h};function d(f){for(var h=[],m=0,g=0,v=0;v<f.length;)m=f.charCodeAt(v++),g?(h.push((65536+(g-55296<<10)+(m-56320)).toString(16)),g=0):m>55296&&m<=56319?g=m:h.push(m.toString(16));return h}return ro}var eU=Zz(),tU=function(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mS.defaults,r=Object.keys(n).length?n:mS.defaults,s=r.defaultWeight,i=r.emojiParsingEnabled,o=r.scale,c=r.maxWeightedTweetLength,d=r.transformedURLLength,f=typeof String.prototype.normalize=="function"?e.normalize():e,h=zS(Sz(f)),m=i?zS(eU.parse(f)):[],g=f.length,v=0,x=0,k=!0,w=0;w<g;w++){if(h[w]){var S=h[w],N=S.url;S.indices,v+=d*o,w+=N.length-1}else if(i&&m[w]){var j=m[w],M=j.text;j.indices,v+=s,w+=M.length-1}else w+=nU(f,w)?1:0,v+=$z(f.charAt(w),r);k&&(k=!Xz(f.substring(w,w+1))),k&&v<=c*o&&(x=w)}v=v/o,k=k&&v>0&&v<=c;var _=Math.floor(v/c*1e3),R=e.length-f.length;return x+=R,{weightedLength:v,valid:k,permillage:_,validRangeStart:0,validRangeEnd:x,displayRangeStart:0,displayRangeEnd:e.length>0?e.length-1:0}},zS=function(e){return e.reduce(function(n,r){return n[r.indices[0]]=r,n},{})},nU=function(e,n){if(n<e.length-1){var r=e.charCodeAt(n),s=e.charCodeAt(n+1);return 55296<=r&&r<=56319&&56320<=s&&s<=57343}return!1},US={},HS;function rU(){if(HS)return US;HS=1;var t=Cr();return t(t.S+t.F*!Xr(),"Object",{defineProperty:ps().f}),US}rU();var WS={},VS;function sU(){if(VS)return WS;VS=1;var t=Cr();return t(t.S+t.F*!Xr(),"Object",{defineProperties:M2()}),WS}sU();var qS={},Xm={},KS;function Tb(){return KS||(KS=1,Xm.f=Object.getOwnPropertySymbols),Xm}var Qm,GS;function iU(){if(GS)return Qm;GS=1;var t=hf(),e=Tb(),n=Dr(),r=Yr().Reflect;return Qm=r&&r.ownKeys||function(i){var o=t.f(n(i)),c=e.f;return c?o.concat(c(i)):o},Qm}var Zm,JS;function I2(){if(JS)return Zm;JS=1;var t=ps(),e=Kl();return Zm=function(n,r,s){r in n?t.f(n,r,e(0,s)):n[r]=s},Zm}var YS;function oU(){if(YS)return qS;YS=1;var t=Cr(),e=iU(),n=_o(),r=wb(),s=I2();return t(t.S,"Object",{getOwnPropertyDescriptors:function(o){for(var c=n(o),d=r.f,f=e(c),h={},m=0,g,v;f.length>m;)v=d(c,g=f[m++]),v!==void 0&&s(h,g,v);return h}}),qS}oU();var XS={},eg,QS;function aU(){if(QS)return eg;QS=1;var t=Js(),e=Cb(),n=Vn()("species");return eg=function(r){var s;return e(r)&&(s=r.constructor,typeof s=="function"&&(s===Array||e(s.prototype))&&(s=void 0),t(s)&&(s=s[n],s===null&&(s=void 0))),s===void 0?Array:s},eg}var tg,ZS;function lU(){if(ZS)return tg;ZS=1;var t=aU();return tg=function(e,n){return new(t(e))(n)},tg}var ng,eE;function L2(){if(eE)return ng;eE=1;var t=ff(),e=yb(),n=Fi(),r=No(),s=lU();return ng=function(i,o){var c=i==1,d=i==2,f=i==3,h=i==4,m=i==6,g=i==5||m,v=o||s;return function(x,k,w){for(var S=n(x),N=e(S),j=t(k,w,3),M=r(N.length),_=0,R=c?v(x,M):d?v(x,0):void 0,L,$;M>_;_++)if((g||_ in N)&&(L=N[_],$=j(L,_,S),i)){if(c)R[_]=$;else if($)switch(i){case 3:return!0;case 5:return L;case 6:return _;case 2:R.push(L)}else if(h)return!1}return m?-1:f||h?h:R}},ng}var tE;function cU(){if(tE)return XS;tE=1;var t=Cr(),e=L2()(0),n=Gl()([].forEach,!0);return t(t.P+t.F*!n,"Array",{forEach:function(s){return e(this,s,arguments[1])}}),XS}cU();var nE={},rE;function uU(){if(rE)return nE;rE=1;var t=Cr(),e=L2()(2);return t(t.P+t.F*!Gl()([].filter,!0),"Array",{filter:function(r){return e(this,r,arguments[1])}}),nE}uU();var sE={},rg={exports:{}},iE;function dU(){if(iE)return rg.exports;iE=1;var t=ql()("meta"),e=Js(),n=Co(),r=ps().f,s=0,i=Object.isExtensible||function(){return!0},o=!hs()(function(){return i(Object.preventExtensions({}))}),c=function(g){r(g,t,{value:{i:"O"+ ++s,w:{}}})},d=function(g,v){if(!e(g))return typeof g=="symbol"?g:(typeof g=="string"?"S":"P")+g;if(!n(g,t)){if(!i(g))return"F";if(!v)return"E";c(g)}return g[t].i},f=function(g,v){if(!n(g,t)){if(!i(g))return!0;if(!v)return!1;c(g)}return g[t].w},h=function(g){return o&&m.NEED&&i(g)&&!n(g,t)&&c(g),g},m=rg.exports={KEY:t,NEED:!1,fastKey:d,getWeak:f,onFreeze:h};return rg.exports}var sg={},oE;function D2(){return oE||(oE=1,sg.f=Vn()),sg}var ig,aE;function fU(){if(aE)return ig;aE=1;var t=Yr(),e=xa(),n=lf(),r=D2(),s=ps().f;return ig=function(i){var o=e.Symbol||(e.Symbol=n?{}:t.Symbol||{});i.charAt(0)!="_"&&!(i in o)&&s(o,i,{value:r.f(i)})},ig}var og,lE;function hU(){if(lE)return og;lE=1;var t=Yl(),e=Tb(),n=xb();return og=function(r){var s=t(r),i=e.f;if(i)for(var o=i(r),c=n.f,d=0,f;o.length>d;)c.call(r,f=o[d++])&&s.push(f);return s},og}var ag={},cE;function pU(){if(cE)return ag;cE=1;var t=_o(),e=hf().f,n={}.toString,r=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(i){try{return e(i)}catch{return r.slice()}};return ag.f=function(o){return r&&n.call(o)=="[object Window]"?s(o):e(t(o))},ag}var uE;function mU(){if(uE)return sE;uE=1;var t=Yr(),e=Co(),n=Xr(),r=Cr(),s=Ys(),i=dU().KEY,o=hs(),c=cf(),d=_b(),f=ql(),h=Vn(),m=D2(),g=fU(),v=hU(),x=Cb(),k=Dr(),w=Js(),S=Fi(),N=_o(),j=vb(),M=Kl(),_=A2(),R=pU(),L=wb(),$=Tb(),B=ps(),F=Yl(),K=L.f,z=B.f,ee=R.f,P=t.Symbol,U=t.JSON,J=U&&U.stringify,ie="prototype",q=h("_hidden"),ue=h("toPrimitive"),Y={}.propertyIsEnumerable,A=c("symbol-registry"),D=c("symbols"),te=c("op-symbols"),fe=Object[ie],we=typeof P=="function"&&!!$.f,oe=t.QObject,Se=!oe||!oe[ie]||!oe[ie].findChild,Ee=n&&o(function(){return _(z({},"a",{get:function(){return z(this,"a",{value:7}).a}})).a!=7})?function(Fe,G,ge){var ne=K(fe,G);ne&&delete fe[G],z(Fe,G,ge),ne&&Fe!==fe&&z(fe,G,ne)}:z,Le=function(Fe){var G=D[Fe]=_(P[ie]);return G._k=Fe,G},Ie=we&&typeof P.iterator=="symbol"?function(Fe){return typeof Fe=="symbol"}:function(Fe){return Fe instanceof P},Ve=function(G,ge,ne){return G===fe&&Ve(te,ge,ne),k(G),ge=j(ge,!0),k(ne),e(D,ge)?(ne.enumerable?(e(G,q)&&G[q][ge]&&(G[q][ge]=!1),ne=_(ne,{enumerable:M(0,!1)})):(e(G,q)||z(G,q,M(1,{})),G[q][ge]=!0),Ee(G,ge,ne)):z(G,ge,ne)},Te=function(G,ge){k(G);for(var ne=v(ge=N(ge)),he=0,me=ne.length,ze;me>he;)Ve(G,ze=ne[he++],ge[ze]);return G},qe=function(G,ge){return ge===void 0?_(G):Te(_(G),ge)},pt=function(G){var ge=Y.call(this,G=j(G,!0));return this===fe&&e(D,G)&&!e(te,G)?!1:ge||!e(this,G)||!e(D,G)||e(this,q)&&this[q][G]?ge:!0},ut=function(G,ge){if(G=N(G),ge=j(ge,!0),!(G===fe&&e(D,ge)&&!e(te,ge))){var ne=K(G,ge);return ne&&e(D,ge)&&!(e(G,q)&&G[q][ge])&&(ne.enumerable=!0),ne}},be=function(G){for(var ge=ee(N(G)),ne=[],he=0,me;ge.length>he;)!e(D,me=ge[he++])&&me!=q&&me!=i&&ne.push(me);return ne},ht=function(G){for(var ge=G===fe,ne=ee(ge?te:N(G)),he=[],me=0,ze;ne.length>me;)e(D,ze=ne[me++])&&(!ge||e(fe,ze))&&he.push(D[ze]);return he};we||(P=function(){if(this instanceof P)throw TypeError("Symbol is not a constructor!");var G=f(arguments.length>0?arguments[0]:void 0),ge=function(ne){this===fe&&ge.call(te,ne),e(this,q)&&e(this[q],G)&&(this[q][G]=!1),Ee(this,G,M(1,ne))};return n&&Se&&Ee(fe,G,{configurable:!0,set:ge}),Le(G)},s(P[ie],"toString",function(){return this._k}),L.f=ut,B.f=Ve,hf().f=R.f=be,xb().f=pt,$.f=ht,n&&!lf()&&s(fe,"propertyIsEnumerable",pt,!0),m.f=function(Fe){return Le(h(Fe))}),r(r.G+r.W+r.F*!we,{Symbol:P});for(var xt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),St=0;xt.length>St;)h(xt[St++]);for(var At=F(h.store),Ye=0;At.length>Ye;)g(At[Ye++]);r(r.S+r.F*!we,"Symbol",{for:function(Fe){return e(A,Fe+="")?A[Fe]:A[Fe]=P(Fe)},keyFor:function(G){if(!Ie(G))throw TypeError(G+" is not a symbol!");for(var ge in A)if(A[ge]===G)return ge},useSetter:function(){Se=!0},useSimple:function(){Se=!1}}),r(r.S+r.F*!we,"Object",{create:qe,defineProperty:Ve,defineProperties:Te,getOwnPropertyDescriptor:ut,getOwnPropertyNames:be,getOwnPropertySymbols:ht});var ct=o(function(){$.f(1)});return r(r.S+r.F*ct,"Object",{getOwnPropertySymbols:function(G){return $.f(S(G))}}),U&&r(r.S+r.F*(!we||o(function(){var Fe=P();return J([Fe])!="[null]"||J({a:Fe})!="{}"||J(Object(Fe))!="{}"})),"JSON",{stringify:function(G){for(var ge=[G],ne=1,he,me;arguments.length>ne;)ge.push(arguments[ne++]);if(me=he=ge[1],!(!w(he)&&G===void 0||Ie(G)))return x(he)||(he=function(ze,Ae){if(typeof me=="function"&&(Ae=me.call(this,ze,Ae)),!Ie(Ae))return Ae}),ge[1]=he,J.apply(U,ge)}}),P[ie][ue]||zi()(P[ie],ue,P[ie].valueOf),d(P,"Symbol"),d(Math,"Math",!0),d(t.JSON,"JSON",!0),sE}mU();jt(/^#{validMentionOrList}$/,{validMentionOrList:Oz});var P2=/[a-z\u0400-\u04FF0-9\-._~]/i,B2=/(?:%[0-9a-f]{2})/i,$2=/[!$&'()*+,;=]/i,F2=jt("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|:)*",{validateUrlUnreserved:P2,validateUrlPctEncoded:B2,validateUrlSubDelims:$2},"i"),gU=/(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)/i,vU=/(?:[a-z](?:[a-z0-9\-]*[a-z0-9])?)/i,bU=/(?:[a-z0-9](?:[a-z0-9_\-]*[a-z0-9])?)/i,yU=jt(/(?:(?:#{validateUrlSubDomainSegment}\.)*(?:#{validateUrlDomainSegment}\.)#{validateUrlDomainTld})/i,{validateUrlSubDomainSegment:bU,validateUrlDomainSegment:gU,validateUrlDomainTld:vU}),xU=/(?:[0-9]|(?:[1-9][0-9])|(?:1[0-9]{2})|(?:2[0-4][0-9])|(?:25[0-5]))/i,wU=jt(/(?:#{validateUrlDecOctet}(?:\.#{validateUrlDecOctet}){3})/i,{validateUrlDecOctet:xU}),kU=/(?:\[[a-f0-9:\.]+\])/i,z2=jt("(?:#{validateUrlIpv4}|#{validateUrlIpv6})",{validateUrlIpv4:wU,validateUrlIpv6:kU},"i"),SU=jt("(?:#{validateUrlIp}|#{validateUrlDomain})",{validateUrlIp:z2,validateUrlDomain:yU},"i"),U2=/[0-9]{1,5}/;jt("(?:(#{validateUrlUserinfo})@)?(#{validateUrlHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:F2,validateUrlHost:SU,validateUrlPort:U2},"i");var jb=jt("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|[:|@])",{validateUrlUnreserved:P2,validateUrlPctEncoded:B2,validateUrlSubDelims:$2},"i");jt(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:jb});jt(/(\/#{validateUrlPchar}*)*/i,{validateUrlPchar:jb});jt(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:jb});jt("^(?:([^:/?#]+):\\/\\/)?([^/?#]*)([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$","i");var EU=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9_\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,NU=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,CU=/(?:(?:[a-z]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,_U=jt(/(?:(?:#{validateUrlUnicodeSubDomainSegment}\.)*(?:#{validateUrlUnicodeDomainSegment}\.)#{validateUrlUnicodeDomainTld})/i,{validateUrlUnicodeSubDomainSegment:EU,validateUrlUnicodeDomainSegment:NU,validateUrlUnicodeDomainTld:CU}),TU=jt("(?:#{validateUrlIp}|#{validateUrlUnicodeDomain})",{validateUrlIp:z2,validateUrlUnicodeDomain:_U},"i");jt("(?:(#{validateUrlUserinfo})@)?(#{validateUrlUnicodeHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:F2,validateUrlUnicodeHost:TU,validateUrlPort:U2},"i");var dE={},fE;function jU(){if(fE)return dE;fE=1;var t=i2()(!0);return R2()(String,"String",function(e){this._t=String(e),this._i=0},function(){var e=this._t,n=this._i,r;return n>=e.length?{value:void 0,done:!0}:(r=t(e,n),this._i+=r.length,{value:r,done:!1})}),dE}jU();var hE={},lg,pE;function MU(){if(pE)return lg;pE=1;var t=Dr();return lg=function(e,n,r,s){try{return s?n(t(r)[0],r[1]):n(r)}catch(o){var i=e.return;throw i!==void 0&&t(i.call(e)),o}},lg}var cg,mE;function AU(){if(mE)return cg;mE=1;var t=Jl(),e=Vn()("iterator"),n=Array.prototype;return cg=function(r){return r!==void 0&&(t.Array===r||n[e]===r)},cg}var ug,gE;function RU(){if(gE)return ug;gE=1;var t=pb(),e=Vn()("iterator"),n=Jl();return ug=xa().getIteratorMethod=function(r){if(r!=null)return r[e]||r["@@iterator"]||n[t(r)]},ug}var dg,vE;function OU(){if(vE)return dg;vE=1;var t=Vn()("iterator"),e=!1;try{var n=[7][t]();n.return=function(){e=!0},Array.from(n,function(){throw 2})}catch{}return dg=function(r,s){if(!s&&!e)return!1;var i=!1;try{var o=[7],c=o[t]();c.next=function(){return{done:i=!0}},o[t]=function(){return c},r(o)}catch{}return i},dg}var bE;function IU(){if(bE)return hE;bE=1;var t=ff(),e=Cr(),n=Fi(),r=MU(),s=AU(),i=No(),o=I2(),c=RU();return e(e.S+e.F*!OU()(function(d){Array.from(d)}),"Array",{from:function(f){var h=n(f),m=typeof this=="function"?this:Array,g=arguments.length,v=g>1?arguments[1]:void 0,x=v!==void 0,k=0,w=c(h),S,N,j,M;if(x&&(v=t(v,g>2?arguments[2]:void 0,2)),w!=null&&!(m==Array&&s(w)))for(M=w.call(h),N=new m;!(j=M.next()).done;k++)o(N,k,x?r(M,v,[j.value,k],!0):j.value);else for(S=i(h.length),N=new m(S);S>k;k++)o(N,k,x?v(h[k],k):h[k]);return N.length=k,N}}),hE}IU();const LU={parseTweet:tU},{parseTweet:DU}=LU;function yE(t){return DU(t).weightedLength}const xE="ow-x-handle";function PU(){const[t,e]=y.useState(()=>localStorage.getItem(xE)||""),[n,r]=y.useState(!1),[s,i]=y.useState(""),o=y.useRef(null),c=y.useRef(null),d=()=>{const m=s.replace(/^@/,"").trim();m&&(localStorage.setItem(xE,m),e(m)),r(!1)},f=()=>{i(t),r(!0),setTimeout(()=>{var m;return(m=o.current)==null?void 0:m.focus()},0)};y.useEffect(()=>{if(!n)return;const m=g=>{c.current&&!c.current.contains(g.target)&&d()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n,s]);const h=t?`https://unavatar.io/twitter/${t}`:"";return l.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:c,children:[t?l.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:h,alt:`@${t}`,onClick:f,title:`@${t} — click to change`}):l.jsx("div",{className:"tweet-compose-avatar",onClick:f,title:"Set your @handle"}),n&&l.jsx("div",{className:"tweet-handle-popover",children:l.jsx("input",{ref:o,className:"tweet-handle-input",value:s,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&d(),m.key==="Escape"&&r(!1)},placeholder:"your_handle",spellCheck:!1})})]})}const BU={tweet:!0,reply:!0,quote:!1};function wE(){return l.jsxs("div",{className:"tweet-skeleton",children:[l.jsxs("div",{className:"tweet-author-row",children:[l.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder tweet-pulse"}),l.jsxs("div",{className:"tweet-author-info",children:[l.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:120}}),l.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:80}})]})]}),l.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"100%",height:16,marginTop:12}}),l.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"75%",height:16,marginTop:8}})]})}function $U(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function Tu(t){if(!t)return[null];if(typeof t=="string"){const e=t.split(/<hr\s*\/?>/i).map(n=>n.trim()).filter(Boolean);return e.length?e:[null]}if((t==null?void 0:t.type)==="doc"&&Array.isArray(t.content)){const e=[[]];for(const r of t.content)r.type==="horizontalRule"?e.push([]):e[e.length-1].push(r);const n=e.map(r=>r.length?{type:"doc",content:r}:null).filter(Boolean);return n.length?n:[null]}return[t]}function ju(t){var n;if(!t||typeof t=="string"||!t.content)return[];const e=[];for(let r=t.content.length-1;r>=0&&(t.content[r].type==="image"&&((n=t.content[r].attrs)!=null&&n.src));r--)e.unshift(t.content[r].attrs.src);return e}function kE(t,e){if(!t||typeof t=="string"||!t.content||e===0)return t;const n=t.content.slice(0,t.content.length-e);return n.length===0?{type:"doc",content:[{type:"paragraph",content:[]}]}:{...t,content:n}}function Mu(t,e){const n=[];let r=0;return t.forEach((s,i)=>{if(!s)return;r>0&&n.push({type:"horizontalRule"});const o=s.getJSON();o.content&&n.push(...o.content);const c=e==null?void 0:e[i];if(c)for(const d of c){const f=crypto.randomUUID().replace(/-/g,"").slice(0,8);n.push({type:"image",attrs:{src:d,id:f}})}r++}),{type:"doc",content:n}}function SE(t,e){const n=[],r=s=>{var i;s.type==="image"&&((i=s.attrs)!=null&&i.src)&&n.push(s.attrs.src),s.content&&s.content.forEach(r)};return r(t.getJSON()),e&&n.push(...e),n.slice(0,4)}function sl(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tweetContext:t}),keepalive:!0}).catch(()=>{})}function FU({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:s,onActiveEditorChange:i,filename:o,title:c,autoplug:d}){var ae;const{tweet:f,loading:h,error:m}=TF(t==null?void 0:t.url),[g,v]=y.useState(()=>Tu(e).map(V=>{const re=ju(V);return kE(V,re.length)})),[x,k]=y.useState(0),w=y.useRef([]),S=y.useRef(null),N=y.useRef(!0),j=y.useRef(!1),M=y.useRef(g.length),[_,R]=y.useState(()=>g.map(()=>0)),[L,$]=y.useState(0),[B,F]=y.useState(0),K=y.useRef(Tu(e).map(I=>ju(I))),[z,ee]=y.useState(()=>Tu(e).map(V=>ju(V).length)),[P,U]=y.useState(null),[J,ie]=y.useState(),[q,ue]=y.useState(!1),[Y,A]=y.useState("idle"),[D,te]=y.useState(""),fe=y.useRef(),{copyText:we,copyState:oe}=RF(w,L),[Se,Ee]=y.useState(!1),Le=BU[(t==null?void 0:t.mode)??"tweet"],Ie=!!((ae=t==null?void 0:t.lastPost)!=null&&ae.postedAt),[Ve,Te]=y.useState(!1),[qe,pt]=y.useState(""),ut=y.useRef(null),be=y.useRef(null);y.useEffect(()=>{if(!Ve)return;setTimeout(()=>{var V;return(V=ut.current)==null?void 0:V.focus()},0);const I=V=>{be.current&&!be.current.contains(V.target)&&(Te(!1),pt(""))};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[Ve]);const ht=()=>{var X;const I=qe.trim();if(!(!I||I.includes("x.com")||I.includes("twitter.com")))return;const re=(X=t==null?void 0:t.lastPost)==null?void 0:X.postedAt;sl({lastPost:{postedAt:re??new Date().toISOString(),tweetUrl:I||void 0}}),Te(!1),pt("")},xt=()=>{sl({lastPost:null})},[St,At]=y.useState(!1),[Ye,ct]=y.useState(""),Fe=y.useRef(null),G=y.useRef(null);y.useEffect(()=>{if(!St)return;setTimeout(()=>{var V;return(V=Fe.current)==null?void 0:V.focus()},0);const I=V=>{G.current&&!G.current.contains(V.target)&&At(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[St]);const ge=()=>{ct((t==null?void 0:t.url)||""),At(!0)},ne=()=>{const I=Ye.trim();!I||!(I.includes("x.com")||I.includes("twitter.com"))||(sl({url:I}),At(!1))},he=d!==!1,me=()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoplug:!he}),keepalive:!0}).catch(()=>{})};y.useEffect(()=>{let I=!1;return(async()=>{try{const V=await fetch("/api/x/status");if(I)return;if(V.ok){const re=await V.json();U(re.connected),ie(re.username)}else U(!1)}catch{I||U(!1)}})(),()=>{I=!0}},[]),y.useEffect(()=>{if(N.current){N.current=!1;return}if(!e||JSON.stringify(e)===S.current)return;const V=Tu(e),re=V.map(le=>ju(le)),X=V.map((le,ve)=>kE(le,re[ve].length));j.current=!0,M.current=X.length,w.current=[],K.current=re,v(X),R(X.map(()=>0)),ee(re.map(le=>le.length)),k(le=>le+1)},[e]);const ze=y.useCallback((I,V)=>{if(w.current[I]=V,R(X=>{const le=[...X];return le[I]=yE(V.getText()),le}),j.current)return;const re=Mu(w.current,K.current);S.current=JSON.stringify(re),n==null||n(re)},[n]),Ae=y.useCallback((I,V)=>{if(w.current[I]=V,R(re=>{const X=[...re];return X[I]=yE(V.getText()),X}),F(re=>re+1),j.current&&w.current.filter(Boolean).length>=M.current){j.current=!1;const X=Mu(w.current,K.current);S.current=JSON.stringify(X)}I===0&&(r==null||r(V)),s==null||s(w.current.filter(Boolean))},[r,s]),Xe=g.length>1;_.reduce((I,V)=>I+V,0);const Qe=y.useCallback(()=>{const I=L+1;v(V=>[...V.slice(0,I),"<p></p>",...V.slice(I)]),R(V=>[...V.slice(0,I),0,...V.slice(I)]),K.current.splice(I,0,[]),ee(V=>[...V.slice(0,I),0,...V.slice(I)]),$(I)},[L]),tt=y.useCallback(I=>{I!==0&&(w.current.splice(I,1),K.current.splice(I,1),v(V=>V.filter((re,X)=>X!==I)),R(V=>V.filter((re,X)=>X!==I)),ee(V=>V.filter((re,X)=>X!==I)),setTimeout(()=>{const V=Mu(w.current,K.current);n==null||n(V),s==null||s(w.current.filter(Boolean))},0))},[n,s]),We=!!(t!=null&&t.url),Ue=(t==null?void 0:t.mode)==="reply",st=(()=>{const V=w.current.filter(Boolean).some(X=>X.getText().trim()||SE(X).length>0),re=z.some(X=>X>0);return V||re})(),mt=P&&st&&Y==="idle",Nt=async()=>{if(!P){ue(!0);return}if(mt){A("uploading"),te("");try{const I=[];for(let re=0;re<w.current.length;re++){const X=w.current[re];if(!X)continue;const le=X.getText().trim(),ve=SE(X,K.current[re]);if(!le&&ve.length===0)continue;const Re=[];for(const ye of ve){const Et=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:ye})})).json();if(!Et.success)throw new Error(Et.error||"Image upload failed");Re.push(Et.mediaId)}I.push({text:le,mediaIds:Re})}if(I.length===0)return;A("posting");const V=$U(t==null?void 0:t.url);if(I.length===1){const re={};I[0].text&&(re.text=I[0].text),I[0].mediaIds.length>0&&(re.mediaIds=I[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&V?re.replyTo=V:(t==null?void 0:t.mode)==="quote"&&V&&(re.quoteTweetId=V);const le=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(re)})).json();le.success?(sl({lastPost:{postedAt:new Date().toISOString(),tweetUrl:le.tweetUrl}}),A("success"),fe.current=setTimeout(()=>A("idle"),2500)):(console.error("[TweetCompose] Post error:",le.error),te(le.error||"Post failed"),A("error"),setTimeout(()=>A("idle"),3e3))}else{const X={tweets:I.map(Re=>({text:Re.text,...Re.mediaIds.length>0?{mediaIds:Re.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&V&&(X.replyTo=V);const ve=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X)})).json();ve.success?(sl({lastPost:{postedAt:new Date().toISOString(),tweetUrl:ve.threadUrl}}),A("success"),fe.current=setTimeout(()=>A("idle"),2500)):(te(ve.error||"Thread post failed"),A("error"),setTimeout(()=>A("idle"),3e3))}}catch(I){te(I.message||"Network error"),A("error"),setTimeout(()=>A("idle"),3e3)}}};y.useEffect(()=>()=>{fe.current&&clearTimeout(fe.current)},[]);const Mt=()=>{U(!0),ue(!1),fetch("/api/x/status").then(I=>I.json()).then(I=>{I.username&&ie(I.username)}).catch(()=>{})},Jt=Y==="uploading"?"Uploading...":Y==="posting"?"Posting...":Y==="success"?"Posted!":Y==="error"?"Failed":Xe?L===0?"Post Thread":"Post All":"Post",nn=g.map((I,V)=>V===0?Ue?"Post your reply":"What is happening?!":"Add another tweet"),at=I=>{var V;return l.jsxs("div",{className:`tweet-compose-footer${I?" tweet-compose-footer--inline":""}`,children:[L===0&&((V=t==null?void 0:t.lastPost)==null?void 0:V.postedAt)&&l.jsxs("a",{className:"tweet-posted-status",href:t.lastPost.tweetUrl,target:"_blank",rel:"noopener noreferrer",title:t.lastPost.tweetUrl||"Posted to X",children:[l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Posted ",new Date(t.lastPost.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),Y==="error"&&D&&l.jsx("span",{className:"tweet-post-error",children:D}),Xe&&l.jsxs("span",{className:"tweet-thread-counter",children:[L+1,"/",g.length]}),l.jsx(FF,{count:_[L]||0}),l.jsx("button",{className:"tweet-thread-add",onClick:Qe,title:"Add another tweet",children:l.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[l.jsx("line",{x1:"10",y1:"4",x2:"10",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),l.jsx("line",{x1:"4",y1:"10",x2:"16",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),l.jsx("button",{className:`tweet-copy-btn${oe==="copied"?" tweet-copy-btn--copied":""}`,disabled:!st,onClick:we,title:"Copy tweet text to clipboard",children:oe==="copied"?l.jsxs(l.Fragment,{children:[l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:l.jsx("path",{d:"M3 8.5L6.5 12L13 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied!"]}):l.jsxs(l.Fragment,{children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[l.jsx("rect",{x:"5.5",y:"2",width:"8.5",height:"10.5",rx:"1.5",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("path",{d:"M3.5 5H2.5A1.5 1.5 0 001 6.5V13a1.5 1.5 0 001.5 1.5H9A1.5 1.5 0 0010.5 13v-1",stroke:"currentColor",strokeWidth:"1.5"})]}),"Copy"]})}),L===0&&!Le&&(()=>{var le;const re=((le=t==null?void 0:t.lastPost)==null?void 0:le.tweetUrl)??"",X=()=>{if(Ie){xt(),Te(!1),pt("");return}pt(re),Te(!0)};return l.jsxs("div",{className:"tweet-mark-sent-wrap",ref:be,children:[l.jsx("button",{className:`tweet-mark-sent-btn${Ie?" tweet-mark-sent-btn--done":""}`,onClick:X,title:Ie?re?`Posted — click to unmark (${re})`:"Posted — click to unmark":"Mark as manually posted",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:Ie?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polyline",{points:"8 12 11 15 16 9",stroke:Ie?"#fff":"currentColor"})]})}),Ve&&(()=>{const ve=qe.trim(),Re=!ve||ve.includes("x.com")||ve.includes("twitter.com");return l.jsxs("div",{className:"tweet-mark-sent-url",children:[l.jsx("input",{ref:ut,type:"text",placeholder:"Paste posted tweet URL...",value:qe,onChange:ye=>pt(ye.target.value),onKeyDown:ye=>{ye.key==="Enter"&&(ye.preventDefault(),ht()),ye.key==="Escape"&&(Te(!1),pt(""))}}),l.jsx("button",{onClick:ht,disabled:!Re,title:ve?"Save URL":"Mark posted without URL",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})})()]})})(),l.jsx("button",{className:`tweet-autoplug-toggle${he?" tweet-autoplug-toggle--on":""}`,onClick:me,title:he?"Auto-plug ON — engagement autoplugs may reply to this post with your configured promo. Click to opt out.":"Auto-plug OFF — this post is excluded from autoplugs. Click to opt in.",children:he?"Auto-plug on":"Auto-plug off"}),o&&!Ie&&l.jsx("button",{className:"tweet-schedule-btn",onClick:()=>Ee(!0),title:"Schedule post",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polyline",{points:"12 6 12 12 16 14"})]})}),Le&&l.jsx("button",{className:`tweet-post-btn${mt||!P&&P!==null?" tweet-post-btn--active":""}${Y==="success"?" tweet-post-btn--success":""}${Y==="error"?" tweet-post-btn--error":""}`,disabled:P?!mt:!1,onClick:Nt,title:P?J?`Post as @${J}`:"Post to X":"Connect X to post",children:Jt})]})},Ht=We&&!Ue,T=()=>l.jsx("div",{className:"tweet-thread-editors",children:g.map((I,V)=>l.jsxs("div",{className:`tweet-thread-item${V===L?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[l.jsxs("div",{className:"tweet-thread-item-left",children:[l.jsx(PU,{}),V<g.length-1&&l.jsx("div",{className:"tweet-thread-line"})]}),l.jsxs("div",{className:"tweet-thread-item-right",children:[V>0&&l.jsx("button",{className:"tweet-thread-remove",onClick:()=>tt(V),title:"Remove this tweet",children:"×"}),l.jsx("div",{className:`tweet-compose-box${V===0&&!Xe?" tweet-compose-box--standalone":""}`,children:l.jsx($F,{initialContent:I,initialPreviewImages:K.current[V],placeholder:nn[V],onUpdate:re=>ze(V,re),onReady:re=>Ae(V,re),onFocus:()=>{$(V);const re=w.current[V];re&&(i==null||i(re))},onPreviewImagesChange:re=>{if(K.current[V]=re,ee(X=>{const le=[...X];return le[V]=re.length,le}),!j.current){const X=Mu(w.current,K.current);S.current=JSON.stringify(X),n==null||n(X)}}})}),V===L&&!Ht&&at(V<g.length-1)]})]},`${x}-${V}`))}),W=()=>{const I=Ye.trim(),V=!!I&&(I.includes("x.com")||I.includes("twitter.com"));return l.jsx("div",{className:"tweet-change-link",ref:G,children:St?l.jsxs("div",{className:"tweet-change-link-edit",children:[l.jsx("input",{ref:Fe,type:"text",placeholder:"Paste tweet URL...",value:Ye,onChange:re=>ct(re.target.value),onKeyDown:re=>{re.key==="Enter"&&(re.preventDefault(),ne()),re.key==="Escape"&&At(!1)}}),l.jsx("button",{onClick:ne,disabled:!V,title:"Update tweet link",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}):l.jsxs("button",{className:"tweet-change-link-btn",onClick:ge,title:"Replace the quoted/replied tweet URL",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M12 20h9"}),l.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),"Change link"]})})};return l.jsxs("div",{className:"tweet-compose-wrapper",children:[We&&Ue&&l.jsxs(l.Fragment,{children:[h&&l.jsx("div",{className:"tweet-context-section",children:l.jsx(wE,{})}),m&&l.jsx("div",{className:"tweet-context-section",children:l.jsxs("div",{className:"tweet-embed-error",children:[l.jsx("span",{children:"Could not load tweet"}),l.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url}),W()]})}),f&&l.jsxs("div",{className:"tweet-reply-parent-section",children:[l.jsx("div",{className:"tweet-reply-parent-card",children:l.jsx(qk,{tweet:f,url:t==null?void 0:t.url})}),l.jsxs("div",{className:"tweet-replying-to",children:["Replying to ",l.jsxs("span",{className:"tweet-reply-handle",children:["@",f.author.username]})]}),W()]}),T()]}),Ht&&l.jsxs(l.Fragment,{children:[T(),l.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[h&&l.jsx(wE,{}),m&&l.jsxs("div",{className:"tweet-embed-error",children:[l.jsx("span",{children:"Could not load tweet"}),l.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url}),W()]}),f&&l.jsxs(l.Fragment,{children:[l.jsx(qk,{tweet:f,url:t==null?void 0:t.url}),W()]})]}),l.jsx("div",{className:"tweet-quote-footer",children:at()})]}),!We&&T(),q&&l.jsx(zF,{onConnected:Mt,onCancel:()=>ue(!1)}),Se&&o&&l.jsx(Vl,{filename:o,title:c||"Untitled",onClose:()=>Ee(!1)})]})}function zU(){const[t,e]=y.useState("idle"),n=y.useRef();return{copyAsHtml:y.useCallback(async()=>{const s=document.querySelector(".ProseMirror");if(!s)return;const i=s.cloneNode(!0);i.querySelectorAll(".ProseMirror-widget, [data-widget], .ProseMirror-gapcursor").forEach(h=>h.remove());let o="";const c=document.querySelector(".article-title-input");c!=null&&c.value&&c.value!=="Untitled"&&(o+=`<h1>${c.value}</h1>
213
+ `);const d=o+i.innerHTML,f=UU(i);try{const h=new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([f],{type:"text/plain"})});await navigator.clipboard.write([h])}catch{try{await navigator.clipboard.writeText(f)}catch{const h=document.createElement("textarea");h.value=f,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}}e("copied"),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e("idle"),2e3)},[]),copyState:t}}function UU(t){var n;const e=[];for(const r of t.children){const s=(n=r.innerText)==null?void 0:n.trim();s&&e.push(s)}return e.join(`
214
+
215
+ `)}function H2(t,e){const n=y.useRef(null),r=y.useCallback(()=>{const o=n.current;o&&(o.style.height="auto",o.style.height=`${o.scrollHeight}px`)},[]);y.useLayoutEffect(()=>{r()},[t,r]);const s=y.useCallback(o=>{e(o.target.value.replace(/[\r\n]+/g," ")),r()},[e,r]),i=y.useCallback(o=>{var c;o.key==="Enter"&&(o.preventDefault(),(c=n.current)==null||c.blur())},[]);return{ref:n,onChange:s,onKeyDown:i}}function W2({pendingTitle:t,docId:e,baseClass:n,children:r}){const[s,i]=y.useState(!1),[o,c]=y.useState(!1);return y.useEffect(()=>{function d(f){const h=f.detail;h&&(e&&h.docId&&h.docId!==e||(i(!!h.titleFocused),c(!!h.titleShowOriginal)))}return window.addEventListener("ow-pending-review-cursor",d),()=>window.removeEventListener("ow-pending-review-cursor",d)},[e]),t?o?l.jsx("div",{className:`${n} ${n}--pending${s?" pending-active pending-active--original":""}`,title:`Showing original title. Toggle back to Modified to see the agent's proposal "${t.to}".`,"aria-label":`Original title ${t.from} (agent proposed ${t.to})`,children:l.jsx("span",{className:"pending-original",children:t.from})}):l.jsx("div",{className:`${n} ${n}--pending${s?" pending-active pending-active--insert":""}`,title:`Agent proposed rename from "${t.from}". Accept or reject in the Review panel.`,"aria-label":`Pending title rename from ${t.from} to ${t.to}`,children:l.jsx("span",{className:"pending-insert",children:t.to})}):l.jsx(l.Fragment,{children:r})}const fg="ow-x-handle",EE="ow-x-name",HU=new Set(["Untitled","New Document","Article"]);function WU({src:t,coverImages:e}){const[n,r]=y.useState(t?"display":"empty"),[s,i]=y.useState(t||""),[o,c]=y.useState(e||(t?[t]:[])),[d,f]=y.useState(""),[h,m]=y.useState(""),g=y.useRef(null);y.useEffect(()=>{t?(i(t),r("display")):e&&e.length>0?(i(e[0]),r("display")):(i(""),r("empty"),f(""),m(""))},[t,e]),y.useEffect(()=>{e&&e.length>0?c(e):c(t?[t]:[])},[e]);const v=s?o.indexOf(s):-1,x=o.length,k=x>1,w=y.useCallback(B=>{const F=o[B];F&&(i(F),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:F,coverImages:o}})}).catch(()=>{}))},[o]),S=y.useCallback(()=>{v>0&&w(v-1)},[v,w]),N=y.useCallback(()=>{v<x-1&&w(v+1)},[v,x,w]),j=y.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const B=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})});if(!B.ok){const K=await B.json().catch(()=>null);m((K==null?void 0:K.error)||`Generation failed (${B.status})`),r("prompt");return}const F=await B.json();if(F.success&&F.src){const K=[...o,F.src];c(K),i(F.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:F.src,coverImages:K}})}).catch(()=>{})}else m(F.error||"Generation failed"),r("prompt")}catch(B){m(B.message||"Network error"),r("prompt")}}},[d,o]),M=B=>{B.key==="Enter"&&j(),B.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var B;return(B=g.current)==null?void 0:B.focus()},0)},R=()=>{const B=o.filter(F=>F!==s);if(c(B),B.length>0){const F=Math.min(v,B.length-1),K=B[F];i(K),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:K,coverImages:B}})}).catch(()=>{})}else i(""),r("empty"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:null,coverImages:null}})}).catch(()=>{})},L=()=>{r("prompt"),setTimeout(()=>{var B;return(B=g.current)==null?void 0:B.focus()},0)},$=()=>{const B=document.createElement("a");B.href=s,B.download=`cover-${v+1}.png`,B.click()};return n==="display"&&s?l.jsxs("div",{className:"article-cover article-cover--display",children:[l.jsx("img",{className:"article-cover-img",src:s,alt:"Cover"}),l.jsxs("div",{className:"article-cover-overlay",children:[k&&l.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:S,disabled:v<=0,children:l.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"15 18 9 12 15 6"})})}),l.jsxs("div",{className:"article-cover-overlay-center",children:[l.jsxs("button",{className:"article-cover-overlay-btn",onClick:L,children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("polyline",{points:"23 4 23 10 17 10"}),l.jsx("polyline",{points:"1 20 1 14 7 14"}),l.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),l.jsxs("button",{className:"article-cover-overlay-btn",onClick:$,children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"7 10 12 15 17 10"}),l.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),l.jsxs("button",{className:"article-cover-overlay-btn article-cover-overlay-btn--danger",onClick:R,children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),k&&l.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:N,disabled:v>=x-1,children:l.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})}),k&&l.jsxs("div",{className:"article-cover-counter",children:[v+1," / ",x]})]})]}):n==="loading"?l.jsxs("div",{className:"article-cover article-cover--loading",children:[l.jsx("div",{className:"article-cover-spinner"}),l.jsx("span",{className:"article-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?l.jsxs("div",{className:"article-cover article-cover--prompt",children:[l.jsxs("div",{className:"article-cover-prompt-row",children:[l.jsx("input",{ref:g,className:"article-cover-prompt-input",value:d,onChange:B=>f(B.target.value),onKeyDown:M,placeholder:"Describe your cover image...",spellCheck:!1}),l.jsx("button",{className:"article-cover-prompt-btn",onClick:j,disabled:!d.trim(),children:"Generate"}),l.jsx("button",{className:"article-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h&&l.jsx("div",{className:"article-cover-error",children:h})]}):l.jsxs("div",{className:"article-cover article-cover--empty",onClick:_,children:[l.jsxs("svg",{className:"article-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),l.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),l.jsx("polyline",{points:"21 15 16 10 5 21"})]}),l.jsx("span",{className:"article-cover-hint",children:"We recommend an image with a 5:2 aspect ratio for best results."})]})}function VU(){const[t,e]=y.useState(()=>localStorage.getItem(fg)||""),[n,r]=y.useState(()=>localStorage.getItem(EE)||""),[s,i]=y.useState(!1),[o,c]=y.useState(""),d=y.useRef(null),f=y.useRef(null),h=()=>{const x=o.replace(/^@/,"").trim();x&&(localStorage.setItem(fg,x),e(x)),i(!1)},m=()=>{c(t),i(!0),setTimeout(()=>{var x;return(x=d.current)==null?void 0:x.focus()},0)};y.useEffect(()=>{if(!s)return;const x=k=>{f.current&&!f.current.contains(k.target)&&h()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[s,o]),y.useEffect(()=>{const x=()=>{e(localStorage.getItem(fg)||""),r(localStorage.getItem(EE)||"")};return window.addEventListener("storage",x),()=>window.removeEventListener("storage",x)},[]);const g=t?`https://unavatar.io/twitter/${t}`:"",v=n||t||"Set your @handle";return l.jsxs("div",{className:"article-byline",ref:f,children:[l.jsxs("div",{className:"article-byline-row",onClick:m,title:t?`@${t} — click to change`:"Set your @handle",children:[t?l.jsx("img",{className:"article-byline-avatar",src:g,alt:`@${t}`}):l.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),l.jsx("span",{className:"article-byline-name",children:v}),t&&l.jsxs("span",{className:"article-byline-handle",children:["@",t]})]}),s&&l.jsx("div",{className:"article-byline-popover",children:l.jsx("input",{ref:d,className:"article-byline-input",value:o,onChange:x=>c(x.target.value),onKeyDown:x=>{x.key==="Enter"&&h(),x.key==="Escape"&&i(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function qU({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:s,lastPost:i,pendingTitle:o,docId:c,autoplug:d}){const{copyAsHtml:f,copyState:h}=zU(),[m,g]=y.useState(i?"done":"idle"),v=HU.has(e||"")?"":e||"",x=H2(v,F=>n==null?void 0:n(F||"Untitled")),[k,w]=y.useState(!1),[S,N]=y.useState(""),j=y.useRef(null),M=y.useRef(null);y.useEffect(()=>{g(i?"done":"idle")},[i]),y.useEffect(()=>{if(!k)return;setTimeout(()=>{var K;return(K=j.current)==null?void 0:K.focus()},0);const F=K=>{M.current&&!M.current.contains(K.target)&&(w(!1),N(""))};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[k]);const _=y.useCallback(()=>{const F=S.trim();if(!(!F||F.includes("x.com")||F.includes("twitter.com")))return;const z=(i==null?void 0:i.postedAt)??new Date().toISOString();fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{lastPost:F?{postedAt:z,tweetUrl:F}:{postedAt:z}}}),keepalive:!0}).catch(()=>{}),g("done"),w(!1),N("")},[S,i==null?void 0:i.postedAt]),R=y.useCallback(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{lastPost:null}}),keepalive:!0}).catch(()=>{}),g("idle")},[]),L=d!==!1,$=()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoplug:!L}),keepalive:!0}).catch(()=>{})},B=y.useCallback(()=>{if(m==="done"){R(),w(!1),N("");return}N((i==null?void 0:i.tweetUrl)??""),w(!0)},[m,i==null?void 0:i.tweetUrl,R]);return l.jsxs("div",{className:"article-compose-wrapper",children:[l.jsx(WU,{src:r,coverImages:s}),l.jsxs("div",{className:"article-compose-content",children:[l.jsx(W2,{pendingTitle:o,docId:c,baseClass:"article-title-input",children:l.jsx("textarea",{className:"article-title-input",ref:x.ref,value:v,onChange:x.onChange,onKeyDown:x.onKeyDown,placeholder:"Add a title",rows:1,spellCheck:!1})}),l.jsx(VU,{}),l.jsx("div",{className:"article-compose-body",children:t})]}),l.jsxs("div",{className:"article-compose-footer",children:[l.jsxs("div",{className:"article-mark-sent-wrap",ref:M,children:[l.jsx("button",{className:`article-mark-sent-btn${m==="done"?" article-mark-sent-btn--done":""}`,onClick:B,title:m==="done"?i!=null&&i.tweetUrl?`Posted — click to unmark (${i.tweetUrl})`:"Posted — click to unmark":"Mark as manually posted",children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:m==="done"?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polyline",{points:"8 12 11 15 16 9",stroke:m==="done"?"#fff":"currentColor"})]})}),k&&(()=>{const F=S.trim(),K=!F||F.includes("x.com")||F.includes("twitter.com");return l.jsxs("div",{className:"article-mark-sent-url",children:[l.jsx("input",{ref:j,type:"text",placeholder:"Paste posted tweet URL...",value:S,onChange:z=>N(z.target.value),onKeyDown:z=>{z.key==="Enter"&&(z.preventDefault(),_()),z.key==="Escape"&&(w(!1),N(""))}}),l.jsx("button",{onClick:_,disabled:!K,title:F?"Save URL":"Mark posted without URL",children:l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})})()]}),l.jsx("button",{className:`article-autoplug-toggle${L?" article-autoplug-toggle--on":""}`,onClick:$,title:L?"Auto-plug ON — engagement autoplugs may reply to this post with your configured promo. Click to opt out.":"Auto-plug OFF — this post is excluded from autoplugs. Click to opt in.",children:L?"Auto-plug on":"Auto-plug off"}),m==="done"&&i&&(i.tweetUrl?l.jsxs("a",{className:"article-sent-status",href:i.tweetUrl,target:"_blank",rel:"noopener noreferrer",children:["Posted ",new Date(i.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}):l.jsxs("span",{className:"article-sent-status",children:["Posted ",new Date(i.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]})),l.jsx("button",{className:`article-copy-btn${h==="copied"?" article-copy-btn--copied":""}`,onClick:f,children:h==="copied"?l.jsxs(l.Fragment,{children:[l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Copied!"]}):l.jsxs(l.Fragment,{children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Copy as HTML"]})})]})]})}const NE=new Set(["Untitled","New Document","Blog"]),KU=[];function GU(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function CE(){return new Date().toISOString().split("T")[0]}function co(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:t})}).catch(()=>{})}function JU({src:t,coverImages:e}){const[n,r]=y.useState(t?"display":"empty"),[s,i]=y.useState(t||""),[o,c]=y.useState(e||(t?[t]:[])),[d,f]=y.useState(""),[h,m]=y.useState(""),g=y.useRef(null);y.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),y.useEffect(()=>{e&&e.length>0?c(e):c(t?[t]:[])},[e]);const v=s?o.indexOf(s):-1,x=o.length,k=x>1,w=y.useCallback(B=>{const F=o[B];F&&(i(F),co({coverImage:F,coverImages:o}))},[o]),S=y.useCallback(()=>{v>0&&w(v-1)},[v,w]),N=y.useCallback(()=>{v<x-1&&w(v+1)},[v,x,w]),j=y.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const B=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})});if(!B.ok){const K=await B.json().catch(()=>null);m((K==null?void 0:K.error)||`Generation failed (${B.status})`),r("prompt");return}const F=await B.json();if(F.success&&F.src){const K=[...o,F.src];c(K),i(F.src),r("display"),f(""),co({coverImage:F.src,coverImages:K})}else m(F.error||"Generation failed"),r("prompt")}catch(B){m(B.message||"Network error"),r("prompt")}}},[d,o]),M=B=>{B.key==="Enter"&&j(),B.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var B;return(B=g.current)==null?void 0:B.focus()},0)},R=()=>{const B=o.filter(F=>F!==s);if(c(B),B.length>0){const F=Math.min(v,B.length-1),K=B[F];i(K),co({coverImage:K,coverImages:B})}else i(""),r("empty"),co({coverImage:void 0,coverImages:void 0})},L=()=>{r("prompt"),setTimeout(()=>{var B;return(B=g.current)==null?void 0:B.focus()},0)},$=()=>{const B=document.createElement("a");B.href=s,B.download=`cover-${v+1}.png`,B.click()};return n==="display"&&s?l.jsxs("div",{className:"blog-cover blog-cover--display",children:[l.jsx("img",{className:"blog-cover-img",src:s,alt:"Cover"}),l.jsxs("div",{className:"blog-cover-overlay",children:[k&&l.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--left",onClick:S,disabled:v<=0,children:l.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"15 18 9 12 15 6"})})}),l.jsxs("div",{className:"blog-cover-overlay-center",children:[l.jsxs("button",{className:"blog-cover-btn",onClick:L,children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("polyline",{points:"23 4 23 10 17 10"}),l.jsx("polyline",{points:"1 20 1 14 7 14"}),l.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),l.jsxs("button",{className:"blog-cover-btn",onClick:$,children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),l.jsx("polyline",{points:"7 10 12 15 17 10"}),l.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),l.jsxs("button",{className:"blog-cover-btn blog-cover-btn--danger",onClick:R,children:[l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),k&&l.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--right",onClick:N,disabled:v>=x-1,children:l.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})}),k&&l.jsxs("div",{className:"blog-cover-counter",children:[v+1," / ",x]})]})]}):n==="loading"?l.jsxs("div",{className:"blog-cover blog-cover--loading",children:[l.jsx("div",{className:"blog-cover-spinner"}),l.jsx("span",{className:"blog-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?l.jsxs("div",{className:"blog-cover blog-cover--prompt",children:[l.jsxs("div",{className:"blog-cover-prompt-row",children:[l.jsx("input",{ref:g,className:"blog-cover-prompt-input",value:d,onChange:B=>f(B.target.value),onKeyDown:M,placeholder:"Describe your cover image...",spellCheck:!1}),l.jsx("button",{className:"blog-cover-prompt-btn",onClick:j,disabled:!d.trim(),children:"Generate"}),l.jsx("button",{className:"blog-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:l.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h&&l.jsx("div",{className:"blog-cover-error",children:h})]}):l.jsxs("div",{className:"blog-cover blog-cover--empty",onClick:_,children:[l.jsxs("svg",{className:"blog-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),l.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),l.jsx("polyline",{points:"21 15 16 10 5 21"})]}),l.jsx("span",{className:"blog-cover-hint",children:"Add a featured image"})]})}function YU({tags:t,onChange:e}){const[n,r]=y.useState(""),s=y.useRef(null),i=d=>{const f=d.trim().toLowerCase();f&&!t.includes(f)&&e([...t,f]),r("")},o=d=>e(t.filter(f=>f!==d)),c=d=>{(d.key==="Enter"||d.key===",")&&(d.preventDefault(),i(n)),d.key==="Backspace"&&!n&&t.length>0&&o(t[t.length-1])};return l.jsxs("div",{className:"blog-tags",onClick:()=>{var d;return(d=s.current)==null?void 0:d.focus()},children:[t.map(d=>l.jsxs("span",{className:"blog-tag",children:[d,l.jsx("button",{className:"blog-tag-remove",onClick:f=>{f.stopPropagation(),o(d)},children:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},d)),l.jsx("input",{ref:s,className:"blog-tag-input",value:n,onChange:d=>r(d.target.value),onKeyDown:c,onBlur:()=>{n.trim()&&i(n)},placeholder:t.length===0?"Add tags...":"",spellCheck:!1})]})}function XU({children:t,title:e,onTitleChange:n,blogContext:r,filename:s,pendingTitle:i,docId:o}){var ue,Y;const c=r||{},d=!!(r!=null&&r.active),f=NE.has(e||"")?"":e||"",h=H2(f,A=>n==null?void 0:n(A||"Untitled")),[m,g]=y.useState(c.description||""),[v,x]=y.useState(c.date||CE()),[k,w]=y.useState(c.author||""),[S,N]=y.useState(c.slug||""),[j,M]=y.useState(!!c.slug),[_,R]=y.useState(!1),[L,$]=y.useState(!1),[B,F]=y.useState(!1),[K,z]=y.useState(!1),ee=c.tags||KU,P=c.draft??!1;y.useEffect(()=>{g(c.description||""),x(c.date||CE()),w(c.author||""),N(c.slug||""),M(!!c.slug)},[s]),y.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_blog_sites",arguments:{}})}).then(A=>A.json()).then(A=>{var te,fe;const D=(fe=(te=A==null?void 0:A.content)==null?void 0:te[0])!=null&&fe.text?JSON.parse(A.content[0].text):A;F(Array.isArray(D==null?void 0:D.sites)&&D.sites.length>0)}).catch(()=>{})},[]),y.useEffect(()=>{!j&&e&&!NE.has(e)&&N(GU(e))},[e,j]);const U=y.useCallback(()=>{d&&co({description:m,date:v,author:k,slug:S})},[d,m,v,k,S]),J=m.length,ie=J>160;return l.jsxs("div",{className:"blog-compose-wrapper",children:[l.jsx(JU,{src:c.coverImage,coverImages:c.coverImages}),l.jsxs("div",{className:"blog-compose-content",children:[((ue=c.lastPublish)==null?void 0:ue.publishedAt)&&l.jsxs("a",{className:"blog-published-status",href:c.lastPublish.publishedUrl,target:"_blank",rel:"noopener noreferrer",title:c.lastPublish.publishedUrl||"Published",children:[l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Published ",new Date(c.lastPublish.publishedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),l.jsx(W2,{pendingTitle:i,docId:o,baseClass:"blog-title-input",children:l.jsx("textarea",{className:"blog-title-input",ref:h.ref,value:f,onChange:h.onChange,onKeyDown:h.onKeyDown,placeholder:"Post title",rows:1,spellCheck:!1})}),l.jsxs("div",{className:"blog-description-wrap",children:[l.jsx("textarea",{className:`blog-description-input${ie?" over-limit":""}`,value:m,onChange:A=>g(A.target.value),onBlur:U,placeholder:"Write a short description for SEO and social previews...",rows:2,spellCheck:!1}),l.jsxs("span",{className:`blog-description-count${ie?" over-limit":""}`,children:[J,"/160"]})]}),l.jsxs("div",{className:"blog-meta-toggle",onClick:()=>$(A=>!A),children:[l.jsx("svg",{className:`blog-meta-chevron${L?" open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"9 18 15 12 9 6"})}),l.jsx("span",{children:"Metadata"}),P&&l.jsx("span",{className:"blog-draft-badge",children:"Draft"})]}),L&&l.jsxs("div",{className:"blog-meta-fields",children:[l.jsxs("div",{className:"blog-meta-row",children:[l.jsx("label",{className:"blog-meta-label",children:"Date"}),l.jsx("input",{type:"date",className:"blog-meta-input",value:v,onChange:A=>x(A.target.value),onBlur:U})]}),l.jsxs("div",{className:"blog-meta-row",children:[l.jsx("label",{className:"blog-meta-label",children:"Author"}),l.jsx("input",{type:"text",className:"blog-meta-input",value:k,onChange:A=>w(A.target.value),onBlur:U,placeholder:"Author name",spellCheck:!1})]}),l.jsxs("div",{className:"blog-meta-row",children:[l.jsx("label",{className:"blog-meta-label",children:"Slug"}),l.jsx("input",{type:"text",className:"blog-meta-input",value:S,onChange:A=>{M(!0),N(A.target.value)},onBlur:U,placeholder:"auto-generated-from-title",spellCheck:!1})]}),l.jsxs("div",{className:"blog-meta-row",children:[l.jsx("label",{className:"blog-meta-label",children:"Tags"}),l.jsx(YU,{tags:ee,onChange:A=>{d&&co({tags:A})}})]}),l.jsxs("div",{className:"blog-meta-row",children:[l.jsx("label",{className:"blog-meta-label",children:"Draft"}),l.jsx("button",{className:`blog-draft-toggle${P?" active":""}`,onClick:()=>{d&&co({draft:!P})},children:l.jsx("div",{className:"blog-draft-toggle-knob"})})]})]}),l.jsx("div",{className:"blog-compose-body",children:t})]}),l.jsx("div",{className:"blog-compose-footer",children:s&&l.jsxs("div",{className:"blog-footer-actions",children:[B&&l.jsxs("button",{className:"blog-footer-btn blog-footer-btn--primary",onClick:()=>z(!0),children:[l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"})}),(Y=c.lastPublish)!=null&&Y.publishedUrl?"Republish":"Publish"]}),l.jsxs("button",{className:"blog-footer-btn",onClick:()=>R(!0),children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]})}),_&&s&&l.jsx(Vl,{filename:s,title:e||"Untitled",onClose:()=>R(!1)}),K&&s&&l.jsx(HT,{filename:s,title:e||"Untitled",isActive:!0,onSwitchDocument:()=>{},onClose:()=>z(!1)})]})}function QU({connectionId:t,subject:e,filename:n,onBeforeSend:r,onClose:s}){const[i,o]=y.useState("confirm"),[c,d]=y.useState("html"),[f,h]=y.useState(""),[m,g]=y.useState(null),[v,x]=y.useState(null),[k,w]=y.useState(0),[S,N]=y.useState(null),[j,M]=y.useState(null),[_,R]=y.useState("all"),[L,$]=y.useState([]),[B,F]=y.useState(""),K=y.useRef(null),z=L.find(J=>J.id===B),ee=_==="exclude_issue"&&z&&j!=null?Math.max(0,j-z.recipient_count):j;y.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_subscribers",arguments:{limit:1}})}).then(J=>J.json()).then(J=>{var q,ue;const ie=(ue=(q=J.content)==null?void 0:q[0])!=null&&ue.text?JSON.parse(J.content[0].text):J;ie.count!=null&&M(ie.count)}).catch(()=>{}),fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_newsletter_issues",arguments:{limit:10}})}).then(J=>J.json()).then(J=>{var q,ue;const ie=(ue=(q=J.content)==null?void 0:q[0])!=null&&ue.text?JSON.parse(J.content[0].text):J;ie.issues&&$(ie.issues)}).catch(()=>{})},[]);const P=()=>i==="sent"?{sentCount:k,issueId:S,sentAt:new Date().toISOString()}:void 0;y.useEffect(()=>{const J=ie=>{i!=="sending"&&i!=="testing"&&K.current&&!K.current.contains(ie.target)&&s(P())};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[s,i,k,S]),y.useEffect(()=>{const J=ie=>{ie.key==="Escape"&&i!=="sending"&&i!=="testing"&&s(P())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[s,i,k,S]);async function U(J){var ie,q;o(J?"testing":"sending"),x(null);try{r&&await r();const ue={subject:e,connectionId:t,format:c};J&&(ue.test_email=J),!J&&_==="exclude_issue"&&B&&(ue.exclude_issue_id=B);const A=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"send_newsletter",arguments:ue})})).json(),D=(q=(ie=A.content)==null?void 0:ie[0])!=null&&q.text?JSON.parse(A.content[0].text):A;if(D.error){x(D.error),o("error");return}if(D.test){g(D.sent_to),o("confirm");return}const te=D.sent||0,fe=D.issueId||null,we=new Date().toISOString();w(te),N(fe),o("sent"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{lastSend:{sentCount:te,sentAt:we,issueId:fe||void 0}}})}).catch(()=>{})}catch(ue){x(ue.message),o("error")}}return l.jsx("div",{className:"newsletter-modal-overlay",children:l.jsxs("div",{className:"newsletter-modal",ref:K,children:[l.jsxs("div",{className:"newsletter-modal__header",children:[l.jsx("h3",{children:"Send Newsletter"}),l.jsx("button",{className:"newsletter-modal__close",onClick:()=>s(P()),children:"×"})]}),l.jsxs("div",{className:"newsletter-modal__body",children:[i==="confirm"&&l.jsxs(l.Fragment,{children:[l.jsxs("p",{className:"newsletter-modal__confirm-text",style:ee==null?{visibility:"hidden"}:void 0,children:['Send "',l.jsx("strong",{children:e}),'" to ',ee!=null?ee.toLocaleString():0," subscriber",ee!==1?"s":"","?"]}),l.jsxs("div",{className:"newsletter-modal__audience",children:[l.jsx("label",{className:"newsletter-modal__label",children:"Audience"}),l.jsxs("select",{className:"newsletter-modal__select",value:_,onChange:J=>{const ie=J.target.value;R(ie),ie==="all"&&F("")},children:[l.jsx("option",{value:"all",children:"All subscribers"}),L.length>0&&l.jsx("option",{value:"exclude_issue",children:"Exclude who received..."})]}),_==="exclude_issue"&&l.jsxs("select",{className:"newsletter-modal__select",value:B,onChange:J=>F(J.target.value),children:[l.jsx("option",{value:"",children:"Select a past issue"}),L.map(J=>l.jsxs("option",{value:J.id,children:[J.subject," (",J.recipient_count," sent)"]},J.id))]})]}),l.jsxs("div",{className:"newsletter-modal__format-toggle",children:[l.jsx("button",{className:`newsletter-modal__format-btn${c==="html"?" active":""}`,onClick:()=>d("html"),children:"HTML"}),l.jsx("button",{className:`newsletter-modal__format-btn${c==="plaintext"?" active":""}`,onClick:()=>d("plaintext"),children:"Plaintext"})]}),l.jsxs("div",{className:"newsletter-modal__test-section",children:[l.jsxs("div",{className:"newsletter-modal__test-row",children:[l.jsx("input",{type:"email",className:"newsletter-modal__test-input",placeholder:"Test email address",value:f,onChange:J=>h(J.target.value),onKeyDown:J=>{J.key==="Enter"&&f.trim()&&U(f.trim())}}),l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--test",disabled:!f.trim(),onClick:()=>U(f.trim()),children:"Send Test"})]}),m&&l.jsxs("p",{className:"newsletter-modal__test-success",children:["Test sent to ",m]})]}),l.jsxs("div",{className:"newsletter-modal__actions",children:[l.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",disabled:_==="exclude_issue"&&!B,onClick:()=>U(),children:"Send Now"})]})]}),(i==="sending"||i==="testing")&&l.jsxs("div",{className:"newsletter-modal__status",children:[l.jsx("div",{className:"newsletter-modal__spinner"}),l.jsx("span",{children:i==="testing"?"Sending test...":"Sending..."})]}),i==="sent"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:["Sent to ",k," subscriber",k!==1?"s":"","!"]}),l.jsx("div",{className:"newsletter-modal__actions",children:l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s({sentCount:k,issueId:S,sentAt:new Date().toISOString()}),children:"Done"})})]}),i==="error"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"newsletter-modal__error",children:v}),l.jsxs("div",{className:"newsletter-modal__actions",children:[l.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),l.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>U(),children:"Retry"})]})]})]})]})})}function _E(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:t})}).catch(()=>{})}function ZU({children:t,newsletterContext:e,filename:n,title:r,onTitleChange:s,onBeforeSend:i}){var P;const o=e||{},[c,d]=y.useState(o.subject||""),[f,h]=y.useState(o.previewText||""),[m,g]=y.useState([]),[v,x]=y.useState(null),[k,w]=y.useState(!1),[S,N]=y.useState((P=o.lastSend)!=null&&P.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null),j=y.useRef(null),M=y.useRef(n),_=y.useRef(o.subject||""),R=y.useRef(o.previewText||"");y.useEffect(()=>{var U;if(M.current!==n)d(o.subject||""),h(o.previewText||""),_.current=o.subject||"",R.current=o.previewText||"",M.current=n;else{const J=o.subject||"",ie=o.previewText||"";J!==_.current&&(d(J),_.current=J),ie!==R.current&&(h(ie),R.current=ie)}N((U=o.lastSend)!=null&&U.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null)},[e,n]),y.useEffect(()=>{fetch("/api/connections").then(U=>U.json()).then(U=>{const J=(U.connections||[]).filter(ie=>ie.provider==="newsletter"&&ie.status==="active");g(J)}).catch(()=>{})},[]);const L=!!(e!=null&&e.active),$=y.useRef();y.useEffect(()=>{if($.current&&clearTimeout($.current),!(!s||!c.trim()))return $.current=setTimeout(async()=>{const U=r,J=!U||U==="Untitled",ie=j.current!==null&&U===j.current;if(J||ie){try{await fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{subject:c}})})}catch{}s(c.trim()),j.current=c.trim()}},500),()=>{$.current&&clearTimeout($.current)}},[c,r,s]);const B=y.useCallback(()=>{L&&(_.current=c,R.current=f,_E({subject:c,previewText:f}))},[L,c,f]),F=f.length,K=F>=90,z=F>150,ee=()=>{m.length===1&&x(m[0].id),m.length>1&&x(m[0].id)};return l.jsxs("div",{className:"nl-compose-wrapper",children:[S&&l.jsxs("div",{className:"nl-sent-status",children:[l.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent ",new Date(S.sentAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," to ",S.sentCount," subscriber",S.sentCount!==1?"s":""]}),l.jsxs("div",{className:"nl-compose-content",children:[l.jsx("input",{className:"nl-subject-input",type:"text",value:c,onChange:U=>d(U.target.value),onBlur:B,placeholder:"Subject line (defaults to title if empty)",autoComplete:"off","data-lpignore":"true","data-1p-ignore":!0,spellCheck:!1}),l.jsxs("div",{className:"nl-preview-wrap",children:[l.jsx("textarea",{className:`nl-preview-input${z?" over-limit":""}`,value:f,onChange:U=>h(U.target.value),onBlur:B,placeholder:"Preview text shown in inbox before opening...",rows:2,spellCheck:!1}),l.jsxs("span",{className:`nl-preview-count${z?" over-limit":K?" full":""}`,children:[F,"/90"]})]}),l.jsx("div",{className:"nl-compose-body",children:t})]}),n&&l.jsxs("div",{className:"nl-compose-footer",children:[m.length>0&&l.jsxs("button",{className:"nl-footer-btn nl-footer-btn--primary",onClick:ee,children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),l.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),"Send"]}),l.jsxs("button",{className:"nl-footer-btn",onClick:()=>w(!0),children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l.jsx("circle",{cx:"12",cy:"12",r:"10"}),l.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]}),v&&n&&l.jsx(QU,{connectionId:v,subject:c||r||"Untitled",filename:n,onBeforeSend:i,onClose:U=>{x(null),U&&(N(U),_E({lastSend:{sentCount:U.sentCount,sentAt:U.sentAt,issueId:U.issueId||void 0}}))}}),k&&n&&l.jsx(Vl,{filename:n,title:r||"Untitled",onClose:()=>w(!1)})]})}function e9({iframeRef:t,previewKey:e}){const[n,r]=y.useState([]),[s,i]=y.useState(0),o=y.useRef([]);y.useEffect(()=>{const d=t.current;if(!d)return;let f=null,h=null;const m=()=>{try{const k=d.contentDocument;if(f=d.contentWindow,!k||!f)return!1;const w=Array.from(k.querySelectorAll(".book-page > h1:not(.book-title)"));return w.length===0?!1:(o.current=w,r(w.map(S=>(S.textContent||"").trim())),h=()=>{const S=f==null?void 0:f.document.querySelectorAll(".book-page > h1:not(.book-title)");if(!S||S.length===0)return;let N=0;for(let j=0;j<S.length&&S[j].getBoundingClientRect().top<=80;j++)N=j;i(N)},f.addEventListener("scroll",h,{passive:!0}),h(),!0)}catch{return!1}},g=()=>m();d.addEventListener("load",g);let v=0;const x=window.setInterval(()=>{(m()||++v>25)&&window.clearInterval(x)},150);return()=>{d.removeEventListener("load",g),window.clearInterval(x),f&&h&&f.removeEventListener("scroll",h)}},[t,e]);const c=d=>{var v,x;const f=(v=t.current)==null?void 0:v.contentDocument,h=(x=t.current)==null?void 0:x.contentWindow;if(!f||!h)return;const g=f.querySelectorAll(".book-page > h1:not(.book-title)")[d];g&&(h.scrollTo(0,Math.max(0,g.getBoundingClientRect().top+h.scrollY-8)),i(d))};return n.length<2?null:l.jsx("nav",{className:"ch-tickrail","aria-label":"Chapters",children:n.map((d,f)=>l.jsxs("button",{type:"button",className:`ch-tick${f===s?" ch-tick--active":""}`,onClick:()=>c(f),title:d,"aria-current":f===s?"true":void 0,children:[l.jsx("span",{className:"ch-tick__line"}),l.jsx("span",{className:"ch-tick__label",children:d})]},f))})}function TE(){return document.documentElement.getAttribute("data-mode")==="dark"?"dark":"light"}function t9({children:t,docId:e,filename:n,title:r}){const[s,i]=y.useState("manifest"),[o,c]=y.useState(0),[d,f]=y.useState(TE),h=y.useRef(null);y.useEffect(()=>{const v=new MutationObserver(()=>{f(x=>{const k=TE();return k!==x&&c(w=>w+1),k})});return v.observe(document.documentElement,{attributes:!0,attributeFilter:["data-mode"]}),()=>v.disconnect()},[]),y.useEffect(()=>{i("manifest")},[n]);const m=y.useRef(s);y.useEffect(()=>{m.current=s},[s]),y.useEffect(()=>{const v=()=>{i("preview"),c(w=>w+1)},x=()=>i("manifest"),k=()=>{m.current==="preview"&&c(w=>w+1)};return window.addEventListener("ow-manuscript-preview",v),window.addEventListener("ow-manuscript-manifest",x),window.addEventListener("ow-manuscript-restyle",k),()=>{window.removeEventListener("ow-manuscript-preview",v),window.removeEventListener("ow-manuscript-manifest",x),window.removeEventListener("ow-manuscript-restyle",k)}},[]);const g=e?`/api/manuscript/preview?docId=${encodeURIComponent(e)}&mode=${d}&v=${o}`:"about:blank";return l.jsxs("div",{className:"ms-compose",children:[l.jsx("div",{className:"ms-compose-body",style:{display:s==="manifest"?"block":"none"},children:t}),s==="preview"&&l.jsxs(l.Fragment,{children:[l.jsx("iframe",{ref:h,className:"ms-preview-frame",src:g,title:r?`${r} — preview`:"Manuscript preview"},o),l.jsx(e9,{iframeRef:h,previewKey:o})]})]})}const jE=600,n9=48;function Au(t){return t!=null&&typeof t=="object"&&Object.keys(t).length>0}function r9(t){const e=typeof(t==null?void 0:t.content_type)=="string"&&t.content_type||typeof(t==null?void 0:t.contentType)=="string"&&t.contentType||"";return e||(Au(t==null?void 0:t.blogContext)?"blog":t!=null&&t.newsletterContext&&(t.newsletterContext.active===!0||Au(t.newsletterContext))?"newsletter":Au(t==null?void 0:t.articleContext)?"article":t!=null&&t.tweetContext?t.tweetContext.mode||"tweet":Au(t==null?void 0:t.linkedinContext)?"linkedin":"document")}function s9(){var In,Ln,ms,Zr;const t=y.useRef(null),e=y.useRef([]),[n,r]=y.useState(null),[s,i]=y.useState(null),[o,c]=y.useState([]),[d,f]=y.useState("Untitled"),[h,m]=y.useState(null),[g,v]=y.useState(void 0),[x,k]=y.useState(0),[w,S]=y.useState(!0),[N,j]=y.useState(0),[M,_]=y.useState(0),[R,L]=y.useState(0),[$,B]=y.useState({filenames:[],counts:{}}),[F,K]=y.useState({state:"unconfigured"}),[z,ee]=y.useState(!1),[P,U]=y.useState({}),[J,ie]=y.useState(!1),[q,ue]=y.useState(null),[Y,A]=y.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[D,te]=y.useState(!1),fe=y.useRef(null),we=y.useRef(null),[oe,Se]=y.useState(0),[Ee,Le]=y.useState(!1),[Ie,Ve]=y.useState(!1),[Te,qe]=y.useState(()=>{try{const Z=localStorage.getItem("ow-sidebar-width");if(Z){const xe=parseInt(Z,10);if(!isNaN(xe)&&xe>=qT&&xe<=KT)return xe}}catch{}return nv}),{open:pt,width:ut,visible:be,setOverlay:ht,closeRail:xt}=Bl(),St=$d()==="board";y.useEffect(()=>{const Z=we.current;if(!Z)return;Se(Z.clientWidth);const xe=new ResizeObserver(De=>{for(const bt of De)Se(bt.contentRect.width)});return xe.observe(Z),()=>xe.disconnect()},[]),y.useEffect(()=>{if(St||oe===0){Le(!1);return}const Z=oe-(w?Te:0)-(pt?ut:0);Le(xe=>xe?Z<jE+n9:Z<jE)},[oe,w,Te,pt,ut,St]),y.useLayoutEffect(()=>{ht(Ee),Ve(!1)},[Ee,ht]),y.useEffect(()=>{if(!Ee)return;const Z=xe=>{xe.key==="Escape"&&(Ie||be)&&(Ve(!1),xt())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[Ee,Ie,be,xt]);const At=Ee?Ie:w,[Ye,ct]=y.useState(null),[Fe,G]=y.useState(null),[ge,ne]=y.useState(new Set),he=y.useRef(0),me=y.useRef(null),ze=1500,Ae=y.useCallback((Z,xe)=>{me.current&&(clearTimeout(me.current),me.current=null),he.current=Date.now(),ct(Z),G(xe)},[]),Xe=y.useCallback(()=>{if(me.current)return;const Z=Date.now()-he.current,xe=ze-Z;xe<=0?(ct(null),G(null)):me.current=setTimeout(()=>{me.current=null,ct(null),G(null)},xe)},[]),[,Qe]=y.useState(0),[tt,We]=y.useState(null),Ue=y.useRef(null),st=y.useRef(null),mt=y.useRef(null),Nt=y.useRef([]),Mt=y.useRef(-1),Jt=y.useRef(null),nn=y.useRef(!1),at=y.useRef(""),Ht=y.useRef(""),[T,W]=y.useState(""),[ae,I]=y.useState(!1),[V,re]=y.useState(!1);function X(){const Z=document.querySelector(".editor-container");return(Z==null?void 0:Z.scrollTop)||0}function le(){if(Mt.current<0)return;const Z=Nt.current[Mt.current];Z&&(Z.scrollTop=X())}const ve=r9(P),Re=ve==="article",ye=ve==="blog",Dt=ve==="newsletter",Et=ve==="tweet"||ve==="reply"||ve==="quote",dn=ve==="manuscript";y.useEffect(()=>(Re?document.documentElement.setAttribute("data-view","article"):ye?document.documentElement.setAttribute("data-view","blog"):Dt?document.documentElement.setAttribute("data-view","newsletter"):Et?document.documentElement.setAttribute("data-view","tweet"):dn?document.documentElement.setAttribute("data-view","manuscript"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[Et,Re,ye,Dt,dn]),y.useEffect(()=>{const Z=()=>Qe(xe=>xe+1);return window.addEventListener("ow-sidebar-mode-change",Z),()=>window.removeEventListener("ow-sidebar-mode-change",Z)},[]),y.useEffect(()=>{fetch("/api/document",{cache:"no-store"}).then(Z=>Z.json()).then(Z=>{Z.document&&(v(Z.document),st.current=Z.document),Z.title&&f(Z.title),Z.metadata&&U(Z.metadata)}).catch(()=>{v(void 0)}),fetch("/api/pending-docs").then(Z=>Z.json()).then(Z=>B(Z)).catch(()=>{}),fetch("/api/sync/status").then(Z=>Z.json()).then(Z=>K(Z)).catch(()=>{})},[]);const Xt=y.useCallback(Z=>{t.current=Z,r(Z),i(null),e.current=[Z],c([Z])},[]),ln=y.useRef([]),$e=y.useCallback(Z=>{if(e.current=Z,c(Z),ln.current.length>0&&Z.length>0){const xe=ln.current;ln.current=[];for(const De of Z)De.isDestroyed||Rp(De,xe)}},[]),zt=y.useCallback(Z=>{var Dn,_t;const xe=performance.now(),De=window.__lastSwitch;De&&De.filename===Z.filename?(De.tReceive=xe,console.log(`[Switch] RECEIVE filename=${Z.filename} sendToReceive=${(xe-De.tSend).toFixed(1)}ms (server round-trip)`)):console.log(`[Switch] RECEIVE filename=${Z.filename} (no matching CLICK — agent or initial-load switch)`);const bt=at.current==="",Ct=at.current,wn=Z.docId?Z.docId===Ht.current:Z.filename===Ct,Cn=wn&&!bt&&Z.filename!==Ct;Cn||(Ue.current&&(clearTimeout(Ue.current),Ue.current=null),st.current=Z.document,mt.current=JSON.stringify(Z.document)),at.current=Z.filename,Ht.current=Z.docId??"",W(Z.filename),Cn||v(Z.document),f(Z.title),U(Z.metadata||{}),m(((Dn=Z.pendingMetadata)==null?void 0:Dn.title)??null),!wn&&!bt&&((_t=Z.metadata)!=null&&_t.tweetContext)&&k(rt=>rt+1),De&&De.filename===Z.filename&&requestAnimationFrame(()=>{const rt=performance.now();De.tCommit=rt,console.log(`[Switch] COMMIT filename=${Z.filename} receiveToCommit=${(rt-xe).toFixed(1)}ms totalClickToPaint=${(rt-De.tClick).toFixed(1)}ms`)});const _n=Jt.current??"push";if(Jt.current=null,Nt.current.length===0?(Nt.current=[{filename:Z.filename,scrollTop:0}],Mt.current=0):_n==="back"?Mt.current=Math.max(0,Mt.current-1):_n==="forward"?Mt.current=Math.min(Nt.current.length-1,Mt.current+1):wn||(Nt.current=Nt.current.slice(0,Mt.current+1),Nt.current.push({filename:Z.filename,scrollTop:0}),Mt.current=Nt.current.length-1),!nn.current){const rt=`#${encodeURIComponent(Z.filename)}`,es={ow:{filename:Z.filename,navIndex:Mt.current}};Nt.current.length===1||wn?window.history.replaceState(es,"",rt):window.history.pushState(es,"",rt)}if(nn.current=!1,_n==="back"||_n==="forward"){const rt=Nt.current[Mt.current];rt&&setTimeout(()=>{const es=document.querySelector(".editor-container");es&&(es.scrollTop=rt.scrollTop)},50)}I(Mt.current>0),re(Mt.current<Nt.current.length-1)},[]),qn=y.useCallback(Z=>{Ue.current&&(clearTimeout(Ue.current),Ue.current=null),st.current=Z.document,mt.current=JSON.stringify(Z.document),v(Z.document),f(Z.title),U(Z.metadata||{}),We(xe=>xe?{filename:Z.filename,orphanCount:xe.orphanCount+Z.orphanCount,staleBaselineCount:xe.staleBaselineCount+Z.staleBaselineCount,reloadCount:xe.reloadCount+1}:{filename:Z.filename,orphanCount:Z.orphanCount,staleBaselineCount:Z.staleBaselineCount,reloadCount:1})},[]),fn=y.useCallback(()=>{j(Z=>Z+1),_(Z=>Z+1)},[]),gr=y.useCallback(()=>{L(Z=>Z+1)},[]),vr=y.useCallback(Z=>{B(Z)},[]),{connected:_r,sendMessage:hn,docVersionRef:An}=_F({onNodeChanges:Z=>{const xe=e.current;if(xe.length<=1){const De=t.current;if(!De)return;Rp(De,Z)}else{if(xe.some(bt=>bt.isDestroyed)){ln.current.push(...Z);return}for(const bt of xe)Rp(bt,Z)}},onDocumentSwitched:zt,onDocumentReloaded:qn,onDocumentsChanged:fn,onWorkspacesChanged:gr,onPendingDocsChanged:vr,onMetadataChanged:Z=>U(Z),onWritingStarted:(Z,xe)=>Ae(Z,xe),onWritingFinished:()=>Xe(),onIdRewrites:Z=>{const xe=e.current,De=xe.length>0?xe:t.current?[t.current]:[];for(const Ct of De)Ct.isDestroyed||f$(Ct,Z);const bt=st.current;if(bt&&Array.isArray(Z)&&Z.length>0){const Ct=new Map(Z.map(Cn=>[Cn.oldId,Cn.newId])),wn=Cn=>{var _n;if(Array.isArray(Cn))for(const Dn of Cn){const _t=(_n=Dn==null?void 0:Dn.attrs)==null?void 0:_n.id;_t&&Ct.has(_t)&&(Dn.attrs={...Dn.attrs,id:Ct.get(_t)}),Dn!=null&&Dn.content&&wn(Dn.content)}};wn(bt.content||[])}},onPendingFilenamesChanged:Z=>ne(Z),onSyncStatus:Z=>K(Z),onTitleChanged:Z=>f(Z),getEditorState:()=>{var xe;const Z=st.current||((xe=t.current)==null?void 0:xe.getJSON());return Z?{document:Z}:null}}),ur=y.useCallback(()=>{var De;Ue.current&&(clearTimeout(Ue.current),Ue.current=null);const Z=st.current||((De=t.current)==null?void 0:De.getJSON());if(!Z)return;const xe=JSON.stringify(Z);xe!==mt.current&&(hn({type:"doc-update",document:Z,filename:at.current,version:An.current}),mt.current=xe)},[hn,An]),Xs=y.useCallback(async()=>{var xe;const Z=st.current||((xe=t.current)==null?void 0:xe.getJSON());Z&&await fetch("/api/documents/sync-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:Z,filename:at.current})})},[]);y.useEffect(()=>{const Z=()=>{var Ct;Ue.current&&(clearTimeout(Ue.current),Ue.current=null);const De=st.current||((Ct=t.current)==null?void 0:Ct.getJSON());if(!De)return;const bt=JSON.stringify({type:"flush",document:De});navigator.sendBeacon("/api/flush",new Blob([bt],{type:"application/json"}))},xe=()=>{document.visibilityState==="hidden"&&Z()};return window.addEventListener("beforeunload",Z),document.addEventListener("visibilitychange",xe),()=>{window.removeEventListener("beforeunload",Z),document.removeEventListener("visibilitychange",xe)}},[]);const Wt=y.useCallback(()=>{ur(),hn({type:"create-document"})},[ur,hn]),Ts=y.useCallback(Z=>{if(Z===at.current)return;const xe=performance.now();window.__lastSwitch={filename:Z,tClick:xe,tSend:0,tReceive:0,tCommit:0},console.log(`[Switch] CLICK filename=${Z} t=${xe.toFixed(0)}`),le(),Jt.current="push",ur(),hn({type:"switch-document",filename:Z});const De=performance.now();window.__lastSwitch.tSend=De,console.log(`[Switch] SEND filename=${Z} clickToSend=${(De-xe).toFixed(1)}ms`)},[ur,hn]),Qr=y.useRef(null),Kn=y.useCallback(async Z=>{let xe=null;if(Z.docId)try{const De=await fetch("/api/documents").then(bt=>bt.json());if(Array.isArray(De)){const bt=De.find(Ct=>Ct.docId===Z.docId);bt&&(xe=bt.filename)}}catch{}if(!xe&&Z.filename&&(xe=Z.filename),!xe){console.warn("[link] could not resolve doc: target",Z);return}Z.nodeId||Z.quote?Qr.current={nodeId:Z.nodeId||void 0,quote:Z.quote||void 0}:Qr.current={toTop:!0},Ts(xe),setTimeout(()=>{window.dispatchEvent(new CustomEvent("ow-reveal-active-doc",{detail:{filename:xe}}))},0)},[Ts]);y.useEffect(()=>{const Z=xe=>{const De=xe.detail;De&&Kn(De)};return window.addEventListener("ow-navigate-to-link",Z),()=>window.removeEventListener("ow-navigate-to-link",Z)},[Kn]);const js=y.useRef(!1);y.useEffect(()=>{if(js.current)return;js.current=!0;const Z=window.location.pathname.match(/^\/d\/([a-f0-9]{8})\/?$/);if(!Z)return;const xe=Z[1],De=window.location.hash.match(/^#node=([a-f0-9]{8})$/),bt=De?De[1]:null;Kn({docId:xe,filename:null,nodeId:bt,quote:null})},[Kn]),y.useEffect(()=>{if(!n||!Qr.current)return;const Z=Qr.current;Qr.current=null,setTimeout(()=>{if(Z.toTop){const bt=document.querySelector(".editor-container");bt&&(bt.scrollTop=0);return}let xe=null;if(Z.nodeId&&n.state.doc.descendants((bt,Ct)=>{var wn;return xe!==null?!1:((wn=bt.attrs)==null?void 0:wn.id)===Z.nodeId?(xe=Ct+1,!1):!0}),xe===null&&Z.quote){const bt=Z.quote;n.state.doc.descendants((Ct,wn)=>{if(xe!==null)return!1;if(Ct.isTextblock){const Cn=Ct.textContent.indexOf(bt);if(Cn>=0)return xe=wn+1+Cn,!1}return!0})}if(xe===null)return;n.chain().focus().setTextSelection({from:xe,to:xe}).scrollIntoView().run();const De=n.view.nodeDOM(xe-1);De!=null&&De.classList&&(De.classList.add("scroll-target-flash"),setTimeout(()=>De.classList.remove("scroll-target-flash"),1200))},100)},[n,T]);const je=y.useCallback(()=>{Mt.current<=0||window.history.back()},[]),et=y.useCallback(()=>{Mt.current>=Nt.current.length-1||window.history.forward()},[]);y.useEffect(()=>{const Z=xe=>{const De=xe.state&&xe.state.ow;De!=null&&De.filename&&De.filename!==at.current&&(le(),Jt.current=De.navIndex<Mt.current?"back":"forward",nn.current=!0,ur(),hn({type:"switch-document",filename:De.filename}))};return window.addEventListener("popstate",Z),()=>window.removeEventListener("popstate",Z)},[ur,hn]);const wt=y.useCallback(()=>{const Z=at.current,xe=t.current;if(!Z||!xe)return;const De=()=>{const bt=e.current;if(bt.length>1)for(const Ct of bt)Ct!=null&&Ct.view&&pk(Ct.view);else xe!=null&&xe.view&&pk(xe.view)};fetch(`/api/comments/${encodeURIComponent(Z)}`).then(bt=>bt.json()).then(bt=>{dk(bt.comments||[]),De()}).catch(()=>{dk([]),De()})},[]);y.useEffect(()=>{wt()},[T,n,wt]),y.useEffect(()=>{const Z=xe=>{const De=xe.detail;(De==null?void 0:De.filename)===at.current&&wt()};return window.addEventListener("ow-comments-changed",Z),()=>window.removeEventListener("ow-comments-changed",Z)},[wt]),y.useEffect(()=>{function Z(xe){var Ct;const De=xe.detail;if(!De)return;const bt=P==null?void 0:P.docId;bt&&De.docId&&De.docId!==bt||m(((Ct=De.pendingMetadata)==null?void 0:Ct.title)??null)}return window.addEventListener("ow-pending-metadata-changed",Z),()=>window.removeEventListener("ow-pending-metadata-changed",Z)},[P==null?void 0:P.docId]),y.useEffect(()=>{const Z=P==null?void 0:P.docId;if(!Z){mk([]);return}let xe=!1;return fetch(`/api/backlinks/${Z}`).then(De=>De.ok?De.json():[]).then(De=>{if(xe)return;mk(Array.isArray(De)?De:[]);const bt=e.current.length>0?e.current:n?[n]:[];for(const Ct of bt)Ct!=null&&Ct.view&&D5(Ct.view)}).catch(()=>{}),()=>{xe=!0}},[P,n]),y.useEffect(()=>{const Z=P==null?void 0:P.docId;if(!Z){ue(null),vk({});return}let xe=!1;return fetch(`/api/attribution/${Z}`).then(De=>De.ok?De.json():null).then(De=>{if(xe||!De)return;ue({percent:De.percent,nodeOrigins:De.nodeOrigins||{},tracked:!!De.tracked}),vk(De.nodeOrigins||{});const bt=e.current.length>0?e.current:n?[n]:[];for(const Ct of bt)Ct!=null&&Ct.view&&yk(Ct.view)}).catch(()=>{}),()=>{xe=!0}},[P,n]),y.useEffect(()=>{$5(J);const Z=e.current.length>0?e.current:n?[n]:[];for(const xe of Z)xe!=null&&xe.view&&yk(xe.view)},[J,n]),y.useEffect(()=>{const Z=xe=>{xe.altKey&&xe.key==="ArrowLeft"&&(xe.preventDefault(),je()),xe.altKey&&xe.key==="ArrowRight"&&(xe.preventDefault(),et())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[je,et]);const kt=y.useCallback(Z=>{st.current=Z,Ue.current&&clearTimeout(Ue.current),Ue.current=setTimeout(()=>{const xe=st.current||Z,De=JSON.stringify(xe);De!==mt.current&&(hn({type:"doc-update",document:xe,filename:at.current,version:An.current}),mt.current=De)},1e3)},[hn,An]),Qt=y.useCallback(Z=>{f(Z),hn({type:"title-update",title:Z})},[hn]),Zt=y.useCallback(()=>{A(Z=>(localStorage.setItem("ow-toolbar",Z?"hidden":"visible"),!Z))},[]),Tr=y.useCallback(()=>{te(Z=>{if(!Z)return fe.current={sidebarOpen:w,showToolbar:Y},S(!1),Ve(!1),A(!1),!0;const xe=fe.current;return xe&&(S(xe.sidebarOpen),A(xe.showToolbar),fe.current=null),!1})},[w,Y]),Qs=y.useCallback(()=>{if(F.state==="unconfigured"){ee(!0);return}ur(),hn({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[F.state,ur,hn]);return l.jsxs("div",{className:`app${Ee?" app--overlay":""}`,ref:we,children:[!St&&l.jsx($k,{open:At,floating:Ee,width:Te,onWidthChange:qe,onSwitchDocument:Ts,onCreateDocument:Wt,refreshKey:N,docTagsRefreshKey:M,workspacesRefreshKey:R,pendingDocs:$,writingTitle:Ye,writingTarget:Fe,pendingWriteFilenames:ge,activeFilename:T,onClose:()=>Ee?Ve(!1):S(!1)}),l.jsxs("div",{className:"app-main",children:[l.jsx(a$,{title:d,onTitleChange:Qt,onToggleSidebar:!St&&!At?()=>Ee?Ve(!0):S(!0):void 0,canGoBack:ae,canGoForward:V,onGoBack:je,onGoForward:et,editor:n,onToggleToolbar:Zt,toolbarOpen:Y,focusMode:D,onToggleFocusMode:Tr}),Y&&n&&l.jsx(J5,{editor:s||n}),St&&l.jsx($k,{open:!0,width:Te,onWidthChange:qe,onSwitchDocument:Ts,onCreateDocument:Wt,refreshKey:N,docTagsRefreshKey:M,workspacesRefreshKey:R,pendingDocs:$,writingTitle:Ye,writingTarget:Fe,pendingWriteFilenames:ge}),l.jsx(l$,{}),!_r&&l.jsxs("div",{className:"connection-banner",children:[l.jsx("div",{className:"connection-banner-spinner"}),l.jsx("span",{children:"Reconnecting to server..."})]}),(P==null?void 0:P.autoAccept)===!0&&l.jsxs("div",{className:"editor-auto-accept-banner",title:"Agent edits skip the review step. Right-click the doc in the sidebar to turn off.",children:[l.jsx("span",{className:"editor-auto-accept-dot"}),"Auto-accept on — agent edits skip review"]}),tt&&l.jsxs("div",{className:"editor-reload-banner",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"editor-reload-dot","aria-hidden":"true"}),l.jsx("span",{children:tt.reloadCount>1?`Document reloaded from disk ${tt.reloadCount}× since you last looked`:"Document reloaded from disk (external write detected)"}),(tt.orphanCount>0||tt.staleBaselineCount>0)&&l.jsxs("span",{className:"editor-reload-detail",children:[tt.orphanCount>0&&l.jsxs("span",{className:"editor-reload-tag editor-reload-tag--orphan",children:[tt.orphanCount," orphan",tt.orphanCount===1?"":"s"]}),tt.staleBaselineCount>0&&l.jsxs("span",{className:"editor-reload-tag editor-reload-tag--stale",children:[tt.staleBaselineCount," stale-baseline"]})]}),l.jsx("button",{type:"button",className:"editor-reload-dismiss",onClick:()=>We(null),"aria-label":"Dismiss reload notification",children:"×"})]}),l.jsx("div",{className:"editor-container",children:Re?l.jsx(qU,{title:d,onTitleChange:Qt,coverImage:(In=P==null?void 0:P.articleContext)==null?void 0:In.coverImage,coverImages:(Ln=P==null?void 0:P.articleContext)==null?void 0:Ln.coverImages,lastPost:(ms=P==null?void 0:P.articleContext)==null?void 0:ms.lastPost,pendingTitle:h,docId:(P==null?void 0:P.docId)||void 0,autoplug:P==null?void 0:P.autoplug,children:l.jsx(tl,{initialContent:g,extensions:E5,onUpdate:kt,onReady:Xt,onLinkClick:Kn})}):ye?l.jsx(XU,{title:d,onTitleChange:Qt,blogContext:P==null?void 0:P.blogContext,filename:T,pendingTitle:h,docId:(P==null?void 0:P.docId)||void 0,children:l.jsx(tl,{initialContent:g,onUpdate:kt,onReady:Xt,onLinkClick:Kn})}):Dt?l.jsx(ZU,{newsletterContext:P==null?void 0:P.newsletterContext,filename:T,title:d,onTitleChange:Qt,onBeforeSend:Xs,children:l.jsx(tl,{initialContent:g,onUpdate:kt,onReady:Xt,onLinkClick:Kn})}):dn?l.jsx(t9,{docId:(P==null?void 0:P.docId)||void 0,filename:T,title:d,children:l.jsx(tl,{initialContent:g,onUpdate:kt,onReady:Xt,onLinkClick:Kn})}):Et&&(P!=null&&P.tweetContext)?l.jsx(FU,{tweetContext:P.tweetContext,initialContent:g,onUpdate:kt,onEditorReady:Xt,onEditorsChange:$e,onActiveEditorChange:i,filename:T,title:d,autoplug:P==null?void 0:P.autoplug},x):l.jsx(tl,{initialContent:g,onUpdate:kt,onReady:Xt,onLinkClick:Kn})})]}),Ee&&(Ie||be)&&l.jsx("div",{className:"ow-scrim",onClick:()=>{Ve(!1),xt()},"aria-hidden":"true"}),l.jsx(NF,{editors:o,pendingDocs:$,currentFilename:T,docId:(P==null?void 0:P.docId)||null,contentType:ve,manuscriptStyle:(Zr=P==null?void 0:P.manuscriptContext)==null?void 0:Zr.paragraphStyle,pendingTitle:h,onSwitchDocument:Ts,sendMessage:hn,getDocument:()=>st.current,docVersionRef:An,syncStatus:F,onSync:Qs,onToggleToolbar:Zt,toolbarOpen:Y,focusMode:D,onToggleFocusMode:Tr,heatmapOn:J,onToggleHeatmap:()=>ie(Z=>!Z),heatmapAvailable:!!(P!=null&&P.docId),heatmapTitle:q!=null&&q.tracked?`Voice heatmap — ${q.percent.human}% human · ${q.percent.agent}% agent${q.percent.unknown?` · ${q.percent.unknown}% unknown`:""}`:"Voice heatmap — attribution starts on the next edit"}),l.jsx(k$,{editorRef:t,allEditors:o,documentId:T}),l.jsx(C$,{documentId:T}),z&&l.jsx(CF,{onClose:()=>ee(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(Z=>Z.json()).then(K).catch(()=>{})}})]})}LM();MM.createRoot(document.getElementById("root")).render(l.jsx(Ri.StrictMode,{children:l.jsx($M,{children:l.jsx(s9,{})})}));