@qwanyx/stack 0.2.107 → 0.2.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -45,11 +45,11 @@ ${s}
45
45
  `+ge+T}}var he=!1,J;{var xe=typeof WeakMap=="function"?WeakMap:Map;J=new xe}function se(T,q){if(!T||he)return"";{var ne=J.get(T);if(ne!==void 0)return ne}var me;he=!0;var Me=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ie;Ie=fe.current,fe.current=null,ie();try{if(q){var Ne=function(){throw Error()};if(Object.defineProperty(Ne.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ne,[])}catch(vt){me=vt}Reflect.construct(T,[],Ne)}else{try{Ne.call()}catch(vt){me=vt}T.call(Ne.prototype)}}else{try{throw Error()}catch(vt){me=vt}T()}}catch(vt){if(vt&&me&&typeof vt.stack=="string"){for(var Be=vt.stack.split(`
46
46
  `),pt=me.stack.split(`
47
47
  `),et=Be.length-1,rt=pt.length-1;et>=1&&rt>=0&&Be[et]!==pt[rt];)rt--;for(;et>=1&&rt>=0;et--,rt--)if(Be[et]!==pt[rt]){if(et!==1||rt!==1)do if(et--,rt--,rt<0||Be[et]!==pt[rt]){var Nt=`
48
- `+Be[et].replace(" at new "," at ");return T.displayName&&Nt.includes("<anonymous>")&&(Nt=Nt.replace("<anonymous>",T.displayName)),typeof T=="function"&&J.set(T,Nt),Nt}while(et>=1&&rt>=0);break}}}finally{he=!1,fe.current=Ie,de(),Error.prepareStackTrace=Me}var Or=T?T.displayName||T.name:"",vr=Or?be(Or):"";return typeof T=="function"&&J.set(T,vr),vr}function ve(T,q,ne){return se(T,!1)}function Ce(T){var q=T.prototype;return!!(q&&q.isReactComponent)}function _e(T,q,ne){if(T==null)return"";if(typeof T=="function")return se(T,Ce(T));if(typeof T=="string")return be(T);switch(T){case u:return be("Suspense");case c:return be("SuspenseList")}if(typeof T=="object")switch(T.$$typeof){case a:return ve(T.render);case d:return _e(T.type,q,ne);case f:{var me=T,Me=me._payload,Ie=me._init;try{return _e(Ie(Me),q,ne)}catch{}}}return""}var Le=Object.prototype.hasOwnProperty,je={},qe=v.ReactDebugCurrentFrame;function V(T){if(T){var q=T._owner,ne=_e(T.type,T._source,q?q.type:null);qe.setExtraStackFrame(ne)}else qe.setExtraStackFrame(null)}function O(T,q,ne,me,Me){{var Ie=Function.call.bind(Le);for(var Ne in T)if(Ie(T,Ne)){var Be=void 0;try{if(typeof T[Ne]!="function"){var pt=Error((me||"React class")+": "+ne+" type `"+Ne+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof T[Ne]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw pt.name="Invariant Violation",pt}Be=T[Ne](q,Ne,me,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(et){Be=et}Be&&!(Be instanceof Error)&&(V(Me),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",me||"React class",ne,Ne,typeof Be),V(null)),Be instanceof Error&&!(Be.message in je)&&(je[Be.message]=!0,V(Me),b("Failed %s type: %s",ne,Be.message),V(null))}}}var ze=Array.isArray;function He(T){return ze(T)}function H(T){{var q=typeof Symbol=="function"&&Symbol.toStringTag,ne=q&&T[Symbol.toStringTag]||T.constructor.name||"Object";return ne}}function te(T){try{return ce(T),!1}catch{return!0}}function ce(T){return""+T}function ke(T){if(te(T))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",H(T)),ce(T)}var Ee=v.ReactCurrentOwner,xt={key:!0,ref:!0,__self:!0,__source:!0},bt,ae;function pe(T){if(Le.call(T,"ref")){var q=Object.getOwnPropertyDescriptor(T,"ref").get;if(q&&q.isReactWarning)return!1}return T.ref!==void 0}function Ve(T){if(Le.call(T,"key")){var q=Object.getOwnPropertyDescriptor(T,"key").get;if(q&&q.isReactWarning)return!1}return T.key!==void 0}function Ke(T,q){typeof T.ref=="string"&&Ee.current}function Ue(T,q){{var ne=function(){bt||(bt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};ne.isReactWarning=!0,Object.defineProperty(T,"key",{get:ne,configurable:!0})}}function ct(T,q){{var ne=function(){ae||(ae=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};ne.isReactWarning=!0,Object.defineProperty(T,"ref",{get:ne,configurable:!0})}}var X=function(T,q,ne,me,Me,Ie,Ne){var Be={$$typeof:e,type:T,key:q,ref:ne,props:Ne,_owner:Ie};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:me}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Me}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function B(T,q,ne,me,Me){{var Ie,Ne={},Be=null,pt=null;ne!==void 0&&(ke(ne),Be=""+ne),Ve(q)&&(ke(q.key),Be=""+q.key),pe(q)&&(pt=q.ref,Ke(q,Me));for(Ie in q)Le.call(q,Ie)&&!xt.hasOwnProperty(Ie)&&(Ne[Ie]=q[Ie]);if(T&&T.defaultProps){var et=T.defaultProps;for(Ie in et)Ne[Ie]===void 0&&(Ne[Ie]=et[Ie])}if(Be||pt){var rt=typeof T=="function"?T.displayName||T.name||"Unknown":T;Be&&Ue(Ne,rt),pt&&ct(Ne,rt)}return X(T,Be,pt,Me,me,Ee.current,Ne)}}var Z=v.ReactCurrentOwner,le=v.ReactDebugCurrentFrame;function $(T){if(T){var q=T._owner,ne=_e(T.type,T._source,q?q.type:null);le.setExtraStackFrame(ne)}else le.setExtraStackFrame(null)}var we;we=!1;function ye(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function Se(){{if(Z.current){var T=F(Z.current.type);if(T)return`
48
+ `+Be[et].replace(" at new "," at ");return T.displayName&&Nt.includes("<anonymous>")&&(Nt=Nt.replace("<anonymous>",T.displayName)),typeof T=="function"&&J.set(T,Nt),Nt}while(et>=1&&rt>=0);break}}}finally{he=!1,fe.current=Ie,de(),Error.prepareStackTrace=Me}var Or=T?T.displayName||T.name:"",vr=Or?be(Or):"";return typeof T=="function"&&J.set(T,vr),vr}function ve(T,q,ne){return se(T,!1)}function Ce(T){var q=T.prototype;return!!(q&&q.isReactComponent)}function _e(T,q,ne){if(T==null)return"";if(typeof T=="function")return se(T,Ce(T));if(typeof T=="string")return be(T);switch(T){case u:return be("Suspense");case c:return be("SuspenseList")}if(typeof T=="object")switch(T.$$typeof){case a:return ve(T.render);case d:return _e(T.type,q,ne);case f:{var me=T,Me=me._payload,Ie=me._init;try{return _e(Ie(Me),q,ne)}catch{}}}return""}var Le=Object.prototype.hasOwnProperty,je={},qe=v.ReactDebugCurrentFrame;function V(T){if(T){var q=T._owner,ne=_e(T.type,T._source,q?q.type:null);qe.setExtraStackFrame(ne)}else qe.setExtraStackFrame(null)}function O(T,q,ne,me,Me){{var Ie=Function.call.bind(Le);for(var Ne in T)if(Ie(T,Ne)){var Be=void 0;try{if(typeof T[Ne]!="function"){var pt=Error((me||"React class")+": "+ne+" type `"+Ne+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof T[Ne]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw pt.name="Invariant Violation",pt}Be=T[Ne](q,Ne,me,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(et){Be=et}Be&&!(Be instanceof Error)&&(V(Me),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",me||"React class",ne,Ne,typeof Be),V(null)),Be instanceof Error&&!(Be.message in je)&&(je[Be.message]=!0,V(Me),b("Failed %s type: %s",ne,Be.message),V(null))}}}var ze=Array.isArray;function He(T){return ze(T)}function H(T){{var q=typeof Symbol=="function"&&Symbol.toStringTag,ne=q&&T[Symbol.toStringTag]||T.constructor.name||"Object";return ne}}function te(T){try{return ce(T),!1}catch{return!0}}function ce(T){return""+T}function ke(T){if(te(T))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",H(T)),ce(T)}var Ee=v.ReactCurrentOwner,xt={key:!0,ref:!0,__self:!0,__source:!0},bt,ae;function pe(T){if(Le.call(T,"ref")){var q=Object.getOwnPropertyDescriptor(T,"ref").get;if(q&&q.isReactWarning)return!1}return T.ref!==void 0}function Ve(T){if(Le.call(T,"key")){var q=Object.getOwnPropertyDescriptor(T,"key").get;if(q&&q.isReactWarning)return!1}return T.key!==void 0}function Ke(T,q){typeof T.ref=="string"&&Ee.current}function Ue(T,q){{var ne=function(){bt||(bt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};ne.isReactWarning=!0,Object.defineProperty(T,"key",{get:ne,configurable:!0})}}function ct(T,q){{var ne=function(){ae||(ae=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};ne.isReactWarning=!0,Object.defineProperty(T,"ref",{get:ne,configurable:!0})}}var X=function(T,q,ne,me,Me,Ie,Ne){var Be={$$typeof:e,type:T,key:q,ref:ne,props:Ne,_owner:Ie};return Be._store={},Object.defineProperty(Be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:me}),Object.defineProperty(Be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Me}),Object.freeze&&(Object.freeze(Be.props),Object.freeze(Be)),Be};function B(T,q,ne,me,Me){{var Ie,Ne={},Be=null,pt=null;ne!==void 0&&(ke(ne),Be=""+ne),Ve(q)&&(ke(q.key),Be=""+q.key),pe(q)&&(pt=q.ref,Ke(q,Me));for(Ie in q)Le.call(q,Ie)&&!xt.hasOwnProperty(Ie)&&(Ne[Ie]=q[Ie]);if(T&&T.defaultProps){var et=T.defaultProps;for(Ie in et)Ne[Ie]===void 0&&(Ne[Ie]=et[Ie])}if(Be||pt){var rt=typeof T=="function"?T.displayName||T.name||"Unknown":T;Be&&Ue(Ne,rt),pt&&ct(Ne,rt)}return X(T,Be,pt,Me,me,Ee.current,Ne)}}var ee=v.ReactCurrentOwner,le=v.ReactDebugCurrentFrame;function $(T){if(T){var q=T._owner,ne=_e(T.type,T._source,q?q.type:null);le.setExtraStackFrame(ne)}else le.setExtraStackFrame(null)}var we;we=!1;function ye(T){return typeof T=="object"&&T!==null&&T.$$typeof===e}function Se(){{if(ee.current){var T=F(ee.current.type);if(T)return`
49
49
 
50
50
  Check the render method of \``+T+"`."}return""}}function Re(T){return""}var We={};function De(T){{var q=Se();if(!q){var ne=typeof T=="string"?T:T.displayName||T.name;ne&&(q=`
51
51
 
52
- Check the top-level render call using <`+ne+">.")}return q}}function Ae(T,q){{if(!T._store||T._store.validated||T.key!=null)return;T._store.validated=!0;var ne=De(q);if(We[ne])return;We[ne]=!0;var me="";T&&T._owner&&T._owner!==Z.current&&(me=" It was passed a child from "+F(T._owner.type)+"."),$(T),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,me),$(null)}}function tt(T,q){{if(typeof T!="object")return;if(He(T))for(var ne=0;ne<T.length;ne++){var me=T[ne];ye(me)&&Ae(me,q)}else if(ye(T))T._store&&(T._store.validated=!0);else if(T){var Me=x(T);if(typeof Me=="function"&&Me!==T.entries)for(var Ie=Me.call(T),Ne;!(Ne=Ie.next()).done;)ye(Ne.value)&&Ae(Ne.value,q)}}}function st(T){{var q=T.type;if(q==null||typeof q=="string")return;var ne;if(typeof q=="function")ne=q.propTypes;else if(typeof q=="object"&&(q.$$typeof===a||q.$$typeof===d))ne=q.propTypes;else return;if(ne){var me=F(q);O(ne,T.props,"prop",me,T)}else if(q.PropTypes!==void 0&&!we){we=!0;var Me=F(q);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Me||"Unknown")}typeof q.getDefaultProps=="function"&&!q.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ye(T){{for(var q=Object.keys(T.props),ne=0;ne<q.length;ne++){var me=q[ne];if(me!=="children"&&me!=="key"){$(T),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",me),$(null);break}}T.ref!==null&&($(T),b("Invalid attribute `ref` supplied to `React.Fragment`."),$(null))}}var Oe={};function dt(T,q,ne,me,Me,Ie){{var Ne=k(T);if(!Ne){var Be="";(T===void 0||typeof T=="object"&&T!==null&&Object.keys(T).length===0)&&(Be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var pt=Re();pt?Be+=pt:Be+=Se();var et;T===null?et="null":He(T)?et="array":T!==void 0&&T.$$typeof===e?(et="<"+(F(T.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):et=typeof T,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",et,Be)}var rt=B(T,q,ne,Me,Ie);if(rt==null)return rt;if(Ne){var Nt=q.children;if(Nt!==void 0)if(me)if(He(Nt)){for(var Or=0;Or<Nt.length;Or++)tt(Nt[Or],T);Object.freeze&&Object.freeze(Nt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else tt(Nt,T)}if(Le.call(q,"key")){var vr=F(T),vt=Object.keys(q).filter(function(Md){return Md!=="key"}),Si=vt.length>0?"{key: someKey, "+vt.join(": ..., ")+": ...}":"{key: someKey}";if(!Oe[vr+Si]){var jd=vt.length>0?"{"+vt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
52
+ Check the top-level render call using <`+ne+">.")}return q}}function Ae(T,q){{if(!T._store||T._store.validated||T.key!=null)return;T._store.validated=!0;var ne=De(q);if(We[ne])return;We[ne]=!0;var me="";T&&T._owner&&T._owner!==ee.current&&(me=" It was passed a child from "+F(T._owner.type)+"."),$(T),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,me),$(null)}}function tt(T,q){{if(typeof T!="object")return;if(He(T))for(var ne=0;ne<T.length;ne++){var me=T[ne];ye(me)&&Ae(me,q)}else if(ye(T))T._store&&(T._store.validated=!0);else if(T){var Me=x(T);if(typeof Me=="function"&&Me!==T.entries)for(var Ie=Me.call(T),Ne;!(Ne=Ie.next()).done;)ye(Ne.value)&&Ae(Ne.value,q)}}}function st(T){{var q=T.type;if(q==null||typeof q=="string")return;var ne;if(typeof q=="function")ne=q.propTypes;else if(typeof q=="object"&&(q.$$typeof===a||q.$$typeof===d))ne=q.propTypes;else return;if(ne){var me=F(q);O(ne,T.props,"prop",me,T)}else if(q.PropTypes!==void 0&&!we){we=!0;var Me=F(q);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Me||"Unknown")}typeof q.getDefaultProps=="function"&&!q.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ye(T){{for(var q=Object.keys(T.props),ne=0;ne<q.length;ne++){var me=q[ne];if(me!=="children"&&me!=="key"){$(T),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",me),$(null);break}}T.ref!==null&&($(T),b("Invalid attribute `ref` supplied to `React.Fragment`."),$(null))}}var Oe={};function dt(T,q,ne,me,Me,Ie){{var Ne=k(T);if(!Ne){var Be="";(T===void 0||typeof T=="object"&&T!==null&&Object.keys(T).length===0)&&(Be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var pt=Re();pt?Be+=pt:Be+=Se();var et;T===null?et="null":He(T)?et="array":T!==void 0&&T.$$typeof===e?(et="<"+(F(T.type)||"Unknown")+" />",Be=" Did you accidentally export a JSX literal instead of a component?"):et=typeof T,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",et,Be)}var rt=B(T,q,ne,Me,Ie);if(rt==null)return rt;if(Ne){var Nt=q.children;if(Nt!==void 0)if(me)if(He(Nt)){for(var Or=0;Or<Nt.length;Or++)tt(Nt[Or],T);Object.freeze&&Object.freeze(Nt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else tt(Nt,T)}if(Le.call(q,"key")){var vr=F(T),vt=Object.keys(q).filter(function(Md){return Md!=="key"}),Si=vt.length>0?"{key: someKey, "+vt.join(": ..., ")+": ...}":"{key: someKey}";if(!Oe[vr+Si]){var jd=vt.length>0?"{"+vt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
53
53
  let props = %s;
54
54
  <%s {...props} />
55
55
  React keys must be passed directly to JSX without using spread:
@@ -80,19 +80,19 @@ React keys must be passed directly to JSX without using spread:
80
80
  flex items-center gap-4 p-4 border-b border-gray-200
81
81
  hover:bg-gray-50 transition-colors
82
82
  ${e?"cursor-pointer":""}
83
- `,children:[a&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:a,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),l&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&h.jsx("div",{className:"flex-shrink-0 text-gray-400",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function wf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return h.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:h.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&h.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"p-6",children:[o&&h.jsx("div",{className:"mb-6",children:h.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&h.jsx("div",{className:"space-y-4",children:s.map((l,a)=>{const u=l.value(r);return u==null||u===""?null:h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},a)})}),s.length===0&&h.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&h.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:h.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Cf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function Sf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var k,N;const[l]=y.useState(()=>{if(r.length===0)return[[],[]];const j=Cf(r),F=Math.ceil(j.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:j.slice(0,F).map(C=>C.title),right:j.slice(F).map(C=>C.title)}),[j.slice(0,F),j.slice(F)]}),[a,u]=y.useState(()=>{const j=Ea[s];if(typeof window>"u")return j.base;const F=window.innerWidth;return"lg"in j&&F>=1024?j.lg:F>=768?j.md:F>=640?j.sm:j.base});y.useEffect(()=>{const j=()=>{const F=Ea[s],C=window.innerWidth;"lg"in F&&C>=1024?u(F.lg):C>=768?u(F.md):C>=640?u(F.sm):u(F.base)};return window.addEventListener("resize",j),j(),()=>window.removeEventListener("resize",j)},[s]);const[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(!1),[b,_]=y.useState(!1),[S,A]=y.useState(!1);y.useEffect(()=>{if(l[0].length<=1)return;const j=setInterval(()=>{m(F=>!F),setTimeout(()=>{d(F=>(F+1)%l[0].length),_(F=>!F)},250)},e+Math.random()*(t-e));return()=>clearInterval(j)},[l,e,t]),y.useEffect(()=>{if(l[1].length<=1)return;let j=null;const F=setTimeout(()=>{j=setInterval(()=>{v(C=>!C),setTimeout(()=>{p(C=>(C+1)%l[1].length),A(C=>!C)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(F),j&&clearInterval(j)}},[l,e,t]);const E=(k=l[0])==null?void 0:k[c],w=(N=l[1])==null?void 0:N[f];if(r.length===0||!E)return h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No images available"})});const D=i==="2:3"?a*1.5:a,R=(j,F,C)=>h.jsx("div",{className:"relative",style:{width:a,height:D,perspective:"1000px"},onClick:()=>n==null?void 0:n(j),children:h.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${F?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:h.jsxs("div",{className:"w-full h-full",style:{transform:C?"scaleX(-1)":"none"},children:[h.jsx("img",{src:j.data.image,alt:j.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:j.title})})]})})});return h.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[R(E,g,b),w&&R(w,x,S)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(l,a)=>String.fromCharCode(parseInt(a,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const kf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Ef({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:l=!0,searchQuery:a,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:v,renderDetail:b,renderActions:_,renderEmpty:S,renderLoading:A,theme:E={}}){const w={...kf,...E},[D,R]=y.useState([]),[k,N]=y.useState(!1),[j,F]=y.useState(null),[C,M]=y.useState(new Set),[L,I]=y.useState(null),[W,Q]=y.useState(null),[re,U]=y.useState(null),[Y,P]=y.useState(!1),[ie,de]=y.useState(""),fe=a!==void 0?a:ie,ge=ae=>{u?u(ae):de(ae)},be=y.useMemo(()=>{if(!fe.trim())return D;const ae=fe.toLowerCase();return D.filter(pe=>$r(pe.from).toLowerCase().includes(ae)||$r(pe.subject).toLowerCase().includes(ae))},[D,fe]),he=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),J=y.useCallback(async()=>{if(he){N(!0),F(null);try{const ae=await he.listEmails(t,n,s);ae!=null&&ae.messages&&(R(ae.messages),x==null||x(ae.messages))}catch(ae){const pe=ae instanceof Error?ae:new Error("Failed to fetch emails");F(pe.message),m==null||m(pe)}N(!1)}},[he,t,n,s,m,x]);y.useEffect(()=>{R([]),M(new Set),Q(null),F(null),a===void 0&&de(""),d&&J()},[s,d]);const xe=y.useCallback(async ae=>{if(he){Q(ae),U(null),P(!0);try{const pe=await he.getEmailParsed(t,ae.uid,s||"INBOX");pe!=null&&pe.body&&U(pe.body)}catch(pe){console.error("Failed to fetch email body:",pe)}P(!1)}},[he,t,s]),se=y.useCallback(ae=>{f==null||f(ae),o&&xe(ae)},[f,o,xe]),ve=y.useCallback((ae,pe,Ve)=>{if(!i){f==null||f(ae),o&&xe(ae);return}const Ke=ae.uid;if(Ve.shiftKey&&L!==null){const Ue=Math.min(L,pe),ct=Math.max(L,pe),X=D.slice(Ue,ct+1).map(Z=>Z.uid),B=new Set(X);M(B),p==null||p(Array.from(B))}else if(Ve.ctrlKey||Ve.metaKey)M(Ue=>{const ct=new Set(Ue);return ct.has(Ke)?ct.delete(Ke):ct.add(Ke),p==null||p(Array.from(ct)),ct}),I(pe);else{const Ue=new Set([Ke]);M(Ue),I(pe),p==null||p(Array.from(Ue))}},[i,L,D,C,f,p,o]),Ce=y.useCallback(async()=>{if(!he||C.size===0)return;const ae=s||"INBOX";try{const pe=await he.trashEmails(t,Array.from(C),ae);if(console.log("Trash result:",pe),pe.success&&pe.moved>0){R(Ke=>Ke.filter(Ue=>!C.has(Ue.uid)));const Ve=Array.from(C);M(new Set),g==null||g(Ve)}else F("Failed to move emails to trash")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Trash failed");console.error("Trash error:",Ve),F(Ve.message),m==null||m(Ve)}},[he,t,C,s,g,m]),_e=y.useCallback(async()=>{if(!he||C.size===0)return;const ae=s||"INBOX";try{const pe=await he.archiveEmails(t,Array.from(C),ae);if(console.log("Archive result:",pe),pe.success&&pe.archived>0){R(Ke=>Ke.filter(Ue=>!C.has(Ue.uid)));const Ve=Array.from(C);M(new Set),g==null||g(Ve)}else F("Failed to archive emails")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Archive failed");console.error("Archive error:",Ve),F(Ve.message),m==null||m(Ve)}},[he,t,C,s,g,m]),Le=y.useCallback(()=>{if(C.size===D.length)M(new Set),p==null||p([]);else{const ae=new Set(D.map(pe=>pe.uid));M(ae),p==null||p(Array.from(ae))}},[D,C.size,p]),je=y.useCallback(()=>{M(new Set),p==null||p([])},[p]),qe={delete:Ce,archive:_e,refresh:J,selectAll:Le,clearSelection:je},V=ae=>{if(!ae)return"";const pe=new Date(ae),Ve=new Date;return pe.toDateString()===Ve.toDateString()?pe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe.toLocaleDateString([],{month:"short",day:"numeric"})},O=(ae,pe)=>h.jsx("div",{style:{padding:"12px 16px",background:pe?w.selectedBackground:ae.seen?w.cardBackground:w.unreadBackground,borderBottom:`1px solid ${w.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:ae.seen?400:600,color:w.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:ae.seen?400:500,color:ae.seen?w.textSecondary:w.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:w.textSecondary,flexShrink:0},children:V(ae.date)})]})}),ze=ae=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:w.text},children:$r(ae.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:w.textSecondary,marginBottom:"16px"},children:["From: ",$r(ae.from)," • ",new Date(ae.date).toLocaleString()]}),Y?h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"Loading..."}):re?h.jsx("div",{style:{fontSize:"14px",color:w.text},dangerouslySetInnerHTML:{__html:re}}):h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"No content available"})]}),He=(ae,pe)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:w.cardBackground,borderBottom:`1px solid ${w.border}`},children:[h.jsx("button",{onClick:pe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:w.text},children:ae.length===D.length?"Deselect All":"Select All"}),ae.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:w.textSecondary},children:[ae.length," selected"]}),h.jsx("button",{onClick:pe.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:pe.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:pe.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),H=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:c}),te=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:"Loading..."}),ce=v||O,ke=b||ze,Ee=_||He,xt=S||H,bt=A||te;return k&&D.length===0?h.jsx("div",{style:{background:w.background,width:"100%",height:"100%"},children:bt()}):h.jsxs("div",{style:{display:"flex",background:w.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&W?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&W?`1px solid ${w.border}`:"none",overflow:"hidden"},children:[i&&Ee(Array.from(C),qe),l&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${w.border}`,background:w.background},children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:w.textSecondary,strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"8"}),h.jsx("path",{d:"M21 21l-4.35-4.35"})]}),h.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:fe,onChange:ae=>ge(ae.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:w.text}}),fe&&h.jsx("button",{onClick:()=>ge(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:w.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),j&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:w.danger,fontSize:"14px",borderBottom:`1px solid ${w.border}`},children:j}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:be.length===0?xt():be.map((ae,pe)=>h.jsx("div",{onClick:Ve=>ve(ae,pe,Ve),onDoubleClick:()=>se(ae),children:ce(ae,C.has(ae.uid))},ae.uid))})]}),o&&W&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ke(W)})]})}function Df({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=y.useState(new Set),[d,f]=y.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(S=>{c(A=>{const E=new Set(A);return E.has(S)?E.delete(S):E.add(S),t==null||t(Array.from(E)),E})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const S=new Set(r.map(A=>A.id));c(S),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(A=>A.id))}},[r,u.size,t,n]),v=y.useCallback(()=>{if(p.length===0)return;const S=d<=0?p.length-1:d-1;f(S),n==null||n(p[S],S)},[p,d,n]),b=y.useCallback(()=>{if(p.length===0)return;const S=d>=p.length-1?0:d+1;f(S),n==null||n(p[S],S)},[p,d,n]),_=y.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return y.useEffect(()=>{p.length===0?f(-1):d>=p.length?f(p.length-1):d<0&&p.length>0&&(f(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?h.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${a}`,children:o}):h.jsxs("div",{className:`space-y-2 ${a}`,children:[h.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[l&&h.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[h.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),h.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&h.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:v,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),h.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),h.jsx("button",{onClick:b,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),h.jsx("div",{className:"space-y-1",children:r.map(S=>{const A=u.has(S.id),E=(g==null?void 0:g.id)===S.id;return h.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${E?"bg-blue-50 ring-1 ring-blue-200":A?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.id),children:[h.jsx("span",{className:`material-icons text-lg ${A?"text-blue-500":"text-neutral-300"}`,children:A?"check_box":"check_box_outline_blank"}),h.jsx("div",{className:"flex-1 min-w-0",children:e(S,A,E)})]},S.id)})}),i.length>0&&u.size>0&&h.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(S=>{var E;const A=((E=S.disabled)==null?void 0:E.call(S,p))??!1;return h.jsxs("button",{onClick:()=>_(S.id),disabled:A,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${A?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[S.icon&&h.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function Af(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tf=Af(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const pu=y.createContext(null);function Nf(r,e){return{getTheme:function(){return e??null}}}function Ot(){const r=y.useContext(pu);return r==null&&Tf(8),r}function Hn(r){return{}}const Bo={},Bf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},It={},jo={},Mo={},jf={},mu={},Mf={},yu={},Rf={},xu={},bu={},Ns={},Ff={},vu={},_u={},wu={},Lf={},Pf={},If={},Da={},Cu={},zf={},Su={},ku={},Of={},ii={},Ro={},Yi={},$f={},qf={},as={},ls={},Uf={},Wf={},Hf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vf=$t&&"documentMode"in document?document.documentMode:null,Mt=$t&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=$t&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!$t||!("InputEvent"in window)||Vf)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Gf=$t&&/Android/.test(navigator.userAgent),Eu=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Kf=$t&&Gf&&Eu,Fo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,xr=3,Nr=0,Du=1,Zr=2,Yf=0,Qf=1,Jf=2,js=4,Ms=8,Lo=128,Xf=112|(3|js|Ms)|Lo,Po=1,Io=2,zo=3,Oo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"​",sr=`
83
+ `,children:[a&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:a,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),l&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&h.jsx("div",{className:"flex-shrink-0 text-gray-400",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function wf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return h.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:h.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&h.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"p-6",children:[o&&h.jsx("div",{className:"mb-6",children:h.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&h.jsx("div",{className:"space-y-4",children:s.map((l,a)=>{const u=l.value(r);return u==null||u===""?null:h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},a)})}),s.length===0&&h.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&h.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:h.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Cf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function Sf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var k,N;const[l]=y.useState(()=>{if(r.length===0)return[[],[]];const j=Cf(r),F=Math.ceil(j.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:j.slice(0,F).map(C=>C.title),right:j.slice(F).map(C=>C.title)}),[j.slice(0,F),j.slice(F)]}),[a,u]=y.useState(()=>{const j=Ea[s];if(typeof window>"u")return j.base;const F=window.innerWidth;return"lg"in j&&F>=1024?j.lg:F>=768?j.md:F>=640?j.sm:j.base});y.useEffect(()=>{const j=()=>{const F=Ea[s],C=window.innerWidth;"lg"in F&&C>=1024?u(F.lg):C>=768?u(F.md):C>=640?u(F.sm):u(F.base)};return window.addEventListener("resize",j),j(),()=>window.removeEventListener("resize",j)},[s]);const[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(!1),[b,_]=y.useState(!1),[S,A]=y.useState(!1);y.useEffect(()=>{if(l[0].length<=1)return;const j=setInterval(()=>{m(F=>!F),setTimeout(()=>{d(F=>(F+1)%l[0].length),_(F=>!F)},250)},e+Math.random()*(t-e));return()=>clearInterval(j)},[l,e,t]),y.useEffect(()=>{if(l[1].length<=1)return;let j=null;const F=setTimeout(()=>{j=setInterval(()=>{v(C=>!C),setTimeout(()=>{p(C=>(C+1)%l[1].length),A(C=>!C)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(F),j&&clearInterval(j)}},[l,e,t]);const E=(k=l[0])==null?void 0:k[c],w=(N=l[1])==null?void 0:N[f];if(r.length===0||!E)return h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No images available"})});const D=i==="2:3"?a*1.5:a,R=(j,F,C)=>h.jsx("div",{className:"relative",style:{width:a,height:D,perspective:"1000px"},onClick:()=>n==null?void 0:n(j),children:h.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${F?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:h.jsxs("div",{className:"w-full h-full",style:{transform:C?"scaleX(-1)":"none"},children:[h.jsx("img",{src:j.data.image,alt:j.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:j.title})})]})})});return h.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[R(E,g,b),w&&R(w,x,S)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(l,a)=>String.fromCharCode(parseInt(a,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const kf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Ef({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:l=!0,searchQuery:a,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:v,renderDetail:b,renderActions:_,renderEmpty:S,renderLoading:A,theme:E={}}){const w={...kf,...E},[D,R]=y.useState([]),[k,N]=y.useState(!1),[j,F]=y.useState(null),[C,M]=y.useState(new Set),[L,I]=y.useState(null),[W,Q]=y.useState(null),[re,U]=y.useState(null),[Y,P]=y.useState(!1),[ie,de]=y.useState(""),fe=a!==void 0?a:ie,ge=ae=>{u?u(ae):de(ae)},be=y.useMemo(()=>{if(!fe.trim())return D;const ae=fe.toLowerCase();return D.filter(pe=>$r(pe.from).toLowerCase().includes(ae)||$r(pe.subject).toLowerCase().includes(ae))},[D,fe]),he=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),J=y.useCallback(async()=>{if(he){N(!0),F(null);try{const ae=await he.listEmails(t,n,s);ae!=null&&ae.messages&&(R(ae.messages),x==null||x(ae.messages))}catch(ae){const pe=ae instanceof Error?ae:new Error("Failed to fetch emails");F(pe.message),m==null||m(pe)}N(!1)}},[he,t,n,s,m,x]);y.useEffect(()=>{R([]),M(new Set),Q(null),F(null),a===void 0&&de(""),d&&J()},[s,d]);const xe=y.useCallback(async ae=>{if(he){Q(ae),U(null),P(!0);try{const pe=await he.getEmailParsed(t,ae.uid,s||"INBOX");pe!=null&&pe.body&&U(pe.body)}catch(pe){console.error("Failed to fetch email body:",pe)}P(!1)}},[he,t,s]),se=y.useCallback(ae=>{f==null||f(ae),o&&xe(ae)},[f,o,xe]),ve=y.useCallback((ae,pe,Ve)=>{if(!i){f==null||f(ae),o&&xe(ae);return}const Ke=ae.uid;if(Ve.shiftKey&&L!==null){const Ue=Math.min(L,pe),ct=Math.max(L,pe),X=D.slice(Ue,ct+1).map(ee=>ee.uid),B=new Set(X);M(B),p==null||p(Array.from(B))}else if(Ve.ctrlKey||Ve.metaKey)M(Ue=>{const ct=new Set(Ue);return ct.has(Ke)?ct.delete(Ke):ct.add(Ke),p==null||p(Array.from(ct)),ct}),I(pe);else{const Ue=new Set([Ke]);M(Ue),I(pe),p==null||p(Array.from(Ue))}},[i,L,D,C,f,p,o]),Ce=y.useCallback(async()=>{if(!he||C.size===0)return;const ae=s||"INBOX";try{const pe=await he.trashEmails(t,Array.from(C),ae);if(console.log("Trash result:",pe),pe.success&&pe.moved>0){R(Ke=>Ke.filter(Ue=>!C.has(Ue.uid)));const Ve=Array.from(C);M(new Set),g==null||g(Ve)}else F("Failed to move emails to trash")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Trash failed");console.error("Trash error:",Ve),F(Ve.message),m==null||m(Ve)}},[he,t,C,s,g,m]),_e=y.useCallback(async()=>{if(!he||C.size===0)return;const ae=s||"INBOX";try{const pe=await he.archiveEmails(t,Array.from(C),ae);if(console.log("Archive result:",pe),pe.success&&pe.archived>0){R(Ke=>Ke.filter(Ue=>!C.has(Ue.uid)));const Ve=Array.from(C);M(new Set),g==null||g(Ve)}else F("Failed to archive emails")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Archive failed");console.error("Archive error:",Ve),F(Ve.message),m==null||m(Ve)}},[he,t,C,s,g,m]),Le=y.useCallback(()=>{if(C.size===D.length)M(new Set),p==null||p([]);else{const ae=new Set(D.map(pe=>pe.uid));M(ae),p==null||p(Array.from(ae))}},[D,C.size,p]),je=y.useCallback(()=>{M(new Set),p==null||p([])},[p]),qe={delete:Ce,archive:_e,refresh:J,selectAll:Le,clearSelection:je},V=ae=>{if(!ae)return"";const pe=new Date(ae),Ve=new Date;return pe.toDateString()===Ve.toDateString()?pe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe.toLocaleDateString([],{month:"short",day:"numeric"})},O=(ae,pe)=>h.jsx("div",{style:{padding:"12px 16px",background:pe?w.selectedBackground:ae.seen?w.cardBackground:w.unreadBackground,borderBottom:`1px solid ${w.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:ae.seen?400:600,color:w.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:ae.seen?400:500,color:ae.seen?w.textSecondary:w.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ae.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:w.textSecondary,flexShrink:0},children:V(ae.date)})]})}),ze=ae=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:w.text},children:$r(ae.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:w.textSecondary,marginBottom:"16px"},children:["From: ",$r(ae.from)," • ",new Date(ae.date).toLocaleString()]}),Y?h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"Loading..."}):re?h.jsx("div",{style:{fontSize:"14px",color:w.text},dangerouslySetInnerHTML:{__html:re}}):h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"No content available"})]}),He=(ae,pe)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:w.cardBackground,borderBottom:`1px solid ${w.border}`},children:[h.jsx("button",{onClick:pe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:w.text},children:ae.length===D.length?"Deselect All":"Select All"}),ae.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:w.textSecondary},children:[ae.length," selected"]}),h.jsx("button",{onClick:pe.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:pe.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:pe.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),H=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:c}),te=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:"Loading..."}),ce=v||O,ke=b||ze,Ee=_||He,xt=S||H,bt=A||te;return k&&D.length===0?h.jsx("div",{style:{background:w.background,width:"100%",height:"100%"},children:bt()}):h.jsxs("div",{style:{display:"flex",background:w.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&W?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&W?`1px solid ${w.border}`:"none",overflow:"hidden"},children:[i&&Ee(Array.from(C),qe),l&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${w.border}`,background:w.background},children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:w.textSecondary,strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"8"}),h.jsx("path",{d:"M21 21l-4.35-4.35"})]}),h.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:fe,onChange:ae=>ge(ae.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:w.text}}),fe&&h.jsx("button",{onClick:()=>ge(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:w.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),j&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:w.danger,fontSize:"14px",borderBottom:`1px solid ${w.border}`},children:j}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:be.length===0?xt():be.map((ae,pe)=>h.jsx("div",{onClick:Ve=>ve(ae,pe,Ve),onDoubleClick:()=>se(ae),children:ce(ae,C.has(ae.uid))},ae.uid))})]}),o&&W&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ke(W)})]})}function Df({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=y.useState(new Set),[d,f]=y.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(S=>{c(A=>{const E=new Set(A);return E.has(S)?E.delete(S):E.add(S),t==null||t(Array.from(E)),E})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const S=new Set(r.map(A=>A.id));c(S),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(A=>A.id))}},[r,u.size,t,n]),v=y.useCallback(()=>{if(p.length===0)return;const S=d<=0?p.length-1:d-1;f(S),n==null||n(p[S],S)},[p,d,n]),b=y.useCallback(()=>{if(p.length===0)return;const S=d>=p.length-1?0:d+1;f(S),n==null||n(p[S],S)},[p,d,n]),_=y.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return y.useEffect(()=>{p.length===0?f(-1):d>=p.length?f(p.length-1):d<0&&p.length>0&&(f(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?h.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${a}`,children:o}):h.jsxs("div",{className:`space-y-2 ${a}`,children:[h.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[l&&h.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[h.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),h.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&h.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:v,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),h.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),h.jsx("button",{onClick:b,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),h.jsx("div",{className:"space-y-1",children:r.map(S=>{const A=u.has(S.id),E=(g==null?void 0:g.id)===S.id;return h.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${E?"bg-blue-50 ring-1 ring-blue-200":A?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.id),children:[h.jsx("span",{className:`material-icons text-lg ${A?"text-blue-500":"text-neutral-300"}`,children:A?"check_box":"check_box_outline_blank"}),h.jsx("div",{className:"flex-1 min-w-0",children:e(S,A,E)})]},S.id)})}),i.length>0&&u.size>0&&h.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(S=>{var E;const A=((E=S.disabled)==null?void 0:E.call(S,p))??!1;return h.jsxs("button",{onClick:()=>_(S.id),disabled:A,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${A?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[S.icon&&h.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function Af(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tf=Af(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const pu=y.createContext(null);function Nf(r,e){return{getTheme:function(){return e??null}}}function Ot(){const r=y.useContext(pu);return r==null&&Tf(8),r}function Hn(r){return{}}const Bo={},Bf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},It={},jo={},Mo={},jf={},mu={},Mf={},yu={},Rf={},xu={},bu={},Ns={},Ff={},vu={},_u={},wu={},Lf={},Pf={},If={},Da={},Cu={},zf={},Su={},ku={},Of={},ii={},Ro={},Yi={},$f={},qf={},as={},ls={},Uf={},Wf={},Hf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vf=$t&&"documentMode"in document?document.documentMode:null,Mt=$t&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=$t&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!$t||!("InputEvent"in window)||Vf)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Gf=$t&&/Android/.test(navigator.userAgent),Eu=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Kf=$t&&Gf&&Eu,Fo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,xr=3,Nr=0,Du=1,Zr=2,Yf=0,Qf=1,Jf=2,js=4,Ms=8,Lo=128,Xf=112|(3|js|Ms)|Lo,Po=1,Io=2,zo=3,Oo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"​",sr=`
84
84
 
85
- `,Zf=mr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",eh=new RegExp("^[^"+Tu+"]*["+Au+"]"),th=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},rh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:Oo,left:Po,right:zo,start:$o},nh={[Io]:"center",[qo]:"end",[Oo]:"justify",[Po]:"left",[zo]:"right",[$o]:"start"},sh={normal:0,segmented:2,token:1},ih={[Yf]:"normal",[Jf]:"segmented",[Qf]:"token"};function oh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K=oh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Rs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const ah=100;let Qi=!1,Uo=0;function lh(r){Uo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function uh(r,e,t){const n=Bt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function ch(r,e,t){if(G(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function dh(r,e,t,n){for(let s=r;s&&!Sh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=ht(i,t);if(o)return $e(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>ah;try{Et(r,()=>{const s=ue()||function(f){return f.getEditorState().read(()=>{const p=ue();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),l=r._editorState,a=r._blockCursorElement;let u=!1,c="";for(let f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=dh(m,r,l,o);if(!x)continue;const[v,b]=x;if(g==="characterData")n&&ee(b)&&ch(s,m,b)&&uh(m,b,r);else if(g==="childList"){u=!0;const _=p.addedNodes;for(let E=0;E<_.length;E++){const w=_[E],D=Lu(w),R=w.parentNode;if(R!=null&&w!==a&&D===null&&!Bi(w,R,r)){if(mr){const k=w.innerText||w.nodeValue;k&&(c+=k)}R.removeChild(w)}}const S=p.removedNodes,A=S.length;if(A>0){let E=0;for(let w=0;w<A;w++){const D=S[w];(Bi(D,m,r)||a===D)&&(m.appendChild(D),E++)}A!==E&&i.set(v,b)}}}if(i.size>0)for(const[f,p]of i)p.reconcileObservedMutation(f,r);const d=t.takeRecords();if(d.length>0){for(let f=0;f<d.length;f++){const p=d[f],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const v=g[x],b=v.parentNode;b==null||v.nodeName!=="BR"||Bi(v,m,r)||b.removeChild(v)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Kt(s)),mr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",lh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,l=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==l)}function Na(r,e){const t=r.mergeWithSibling(e),n=Ze()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&ee(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&ee(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),ee(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!z(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let fh=1;const hh=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return $e(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function ph(r){return r.nodeType===xr}function Fs(r){let e=r;for(;e!=null;){if(ph(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Fu(r){return ee(r)||Ar(r)||$e(r)}function gh(r,e){if(e!=null)return void(r.__key=e);wt(),uc();const t=Ze(),n=ar(),s=""+fh++;n._nodeMap.set(s,r),z(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const l=i.getWritable();l.__prev=o.__key,o.__next=l.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const l=s.getWritable();l.__next=o.__key,o.__prev=l.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=ar(),s=Ze(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(a,u,c){let d=a;for(;d!==null;){if(c.has(d))return;const f=u.get(d);if(f===void 0)break;c.set(d,!1),d=f.__parent}}(t,i,o);const l=e.__key;s._dirtyType=Du,z(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function ut(r){wt();const e=Ze(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=ht(t);n!==null&&n.getWritable()}if(r!==null){const n=ht(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:Ze()._compositionKey}function ht(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,Ze());return t!==void 0?ht(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Qe().getTextContent())}function Qe(){return Iu(ar())}function Iu(r){return r._nodeMap.get("root")}function Kt(r){wt();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=Ze(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?ht("root"):null:ht(t)}function Ra(r,e){return e?r.getTextContentSize():0}function zu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Bt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=$u(s);const a=en(s);if(l!==null&&ee(a)){if(l===ai&&t){const u=t.length;l=t,i=u,o=u}l!==null&&Ko(a,l,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let l=e;(o||s)&&e[e.length-1]===ai&&(l=e.slice(0,-1));const a=i.getTextContent();if(s||l!==a){if(l===""){if(ut(null),oi||Vn||Fo)i.remove();else{const m=Ze();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!o||G(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=ue();if(!G(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=it(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function mh(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(i){const o=i.getPreviousSibling();return(ee(o)||z(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Mt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function yh(){const r=Qe();Kt(Mu(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,l=e.get(i);l===void 0&&K(33,i);const a=l.klass;let u=r.get(a);u===void 0&&(u=new Map,r.set(a,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function za(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return za(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?za(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function oe(r,e,t){return fc(r,e,t)}function ci(r){return!mt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&K(75,e),t}function Yn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&K(78),e}function xh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return mt(r)||z(r)&&r.isShadowRoot()}function Jt(r){const e=Ze(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&K(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),l=o.constructor;return i!==null?o instanceof i||K(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||K(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&K(203,r.constructor.name,t,l.name,l.getType()),o}return r}function ji(r,e){!mt(r.getParent())||z(e)||$e(e)||K(99)}function Mi(r){return($e(r)||z(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function bh(r,e,t){let n=r._blockCursorElement;if(G(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let l=!1,a=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(l=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(l=!0,a=r.getElementByKey(u.__key))}}if(l){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,f=document.createElement("div");f.contentEditable="false",f.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Rs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(a===null?u.appendChild(n):u.insertBefore(n,a))}}n!==null&&Qo(n,r,e)}function Bt(r){return $t?(r||window).getSelection():null}function vh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Ji(r){const e=new RegExp(/^(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|#text)$/,"i");return r.nodeName.match(e)!==null}function zs(r){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return r.nodeName.match(e)!==null}function cr(r){if($e(r)&&!r.isInline())return!0;if(!z(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function _h(){return Ze()}const $a=new WeakMap,wh=new Map;function Ch(r){if(!r._readOnly&&r.isEmpty())return wh;r._readOnly||K(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function Sh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(z(o)&&Uu(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,yt,In,fi,Xi,Zi,jr,zt,eo,zn,ot="",gt="",Ut=null,Rt="",rr="",Wu=!1,On=!1,_s=null;function Os(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(zt.has(r)||yt._keyToDOMMap.delete(r),z(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(zn,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&Os(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const kh="40px";function Hu(r,e){const t=yr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||kh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===zo?_r(t,"right"):e===Oo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=zt.get(r);t===void 0&&K(60);const n=t.createDOM(yr,yt);if(function(s,i,o){const l=o._keyToDOMMap;(function(a,u,c){a[`__lexicalKey_${u._key}`]=c})(i,o,s),l.set(s,i)}(r,n,yt),ee(t)?n.setAttribute("data-lexical-text","true"):$e(t)&&n.setAttribute("data-lexical-decorator","true"),z(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const f=gt;gt="",ro(a,c,0,u,c.getDOMSlot(d)),Ku(c,d),gt=f})(qs(t,zt),l,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(ot+=sr,rr+=sr)}else{const s=t.getTextContent();if($e(t)){const i=t.decorate(yt,yr);i!==null&&Yu(r,i),n.contentEditable="false"}else ee(t)&&(t.isDirectionless()||(gt+=s));ot+=s,rr+=s}return e!==null&&e.insertChild(n),Yo(zn,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=ot;ot="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=zt.get(r[o]);l!==null&&ee(l)&&(Ut===null&&(Ut=l.getFormat()),Rt===""&&(Rt=l.getStyle()))}ci(e)&&(ot+=sr),s.element.__lexicalTextContent=ot,ot=i+ot}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":$e(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,zt);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==gt||n!==_s){const i=gt==="",o=i?_s:(s=gt,eh.test(s)?"rtl":th.test(s)?"ltr":null);if(o!==n){const l=e.classList,a=yr.theme;let u=n!==null?a[n]:void 0,c=o!==null?a[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=a[n]=d}l.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}On||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=gt,e.__lexicalDir=o}var s}function Eh(r,e,t){const n=gt;var s;gt="",Ut=null,Rt="",function(i,o,l){const a=ot,u=i.__size,c=o.__size;ot="";const d=l.element;if(u===1&&c===1){const f=i.__first,p=o.__first;if(f===p)_n(f,d);else{const m=no(f),x=$s(p,null);try{d.replaceChild(x,m)}catch(v){if(typeof v=="object"&&v!=null){const b=`${v.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(b)}throw v}Os(f,null)}const g=zt.get(p);ee(g)&&(Ut===null&&(Ut=g.getFormat()),Rt===""&&(Rt=g.getStyle()))}else{const f=qs(i,jr),p=qs(o,zt);if(f.length!==u&&K(227),p.length!==c&&K(228),u===0)c!==0&&ro(p,o,0,c-1,l);else if(c===0){if(u!==0){const g=l.after==null&&l.before==null&&l.element.__lexicalLineBreak==null;to(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,v,b,_){const S=v-1,A=b-1;let E,w,D=_.getFirstChild(),R=0,k=0;for(;R<=S&&k<=A;){const F=m[R],C=x[k];if(F===C)D=Ri(_n(C,_.element)),R++,k++;else{E===void 0&&(E=new Set(m)),w===void 0&&(w=new Set(x));const L=w.has(F),I=E.has(C);if(L)if(I){const W=Is(yt,C);W===D?D=Ri(_n(C,_.element)):(_.withBefore(D).insertChild(W),_n(C,_.element)),R++,k++}else $s(C,_.withBefore(D)),k++;else D=Ri(no(F)),Os(F,_.element),R++}const M=zt.get(C);M!==null&&ee(M)&&(Ut===null&&(Ut=M.getFormat()),Rt===""&&(Rt=M.getStyle()))}const N=R>S,j=k>A;if(N&&!j){const F=x[A+1],C=F===void 0?null:yt.getElementByKey(F);ro(x,g,k,A,_.withBefore(C))}else j&&!N&&to(m,R,S,_.element)})(o,f,p,u,c,l)}ci(o)&&(ot+=sr),d.__lexicalTextContent=ot,ot=a+ot}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!On&&(s.setTextFormat(Ut),s.setTextStyle(Rt)),function(i){tn(i)&&Rt!==""&&Rt!==i.__textStyle&&!On&&i.setTextStyle(Rt)}(e),gt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&K(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=zt.get(r);t!==void 0&&n!==void 0||K(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(yt,r);if(t===n&&!s){if(z(t)){const o=i.__lexicalTextContent;o!==void 0&&(ot+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(gt+=l)}else{const o=t.getTextContent();ee(t)&&!t.isDirectionless()&&(gt+=o),rr+=o,ot+=o}return i}if(t!==n&&s&&Yo(zn,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&K(62),e.replaceChild(o,i),Os(r,null),o}if(z(t)&&z(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const l=n.__format;l!==t.__format&&Vu(i,l),s&&(Eh(t,n,i),mt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(ot+=sr,rr+=sr)}else{const o=n.getTextContent();if($e(n)){const l=n.decorate(yt,yr);l!==null&&Yu(r,l)}else ee(n)&&!n.isDirectionless()&&(gt+=o);ot+=o,rr+=o}if(!On&&mt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Yu(r,e){let t=yt._pendingDecorators;const n=yt._decorators;if(t===null){if(n[r]===e)return;t=Pu(yt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===yt._blockCursorElement&&(e=e.nextSibling),e}function Dh(r,e,t,n,s,i){ot="",rr="",gt="",Wu=n===Zr,_s=null,yt=t,yr=t._config,In=t._nodes,fi=yt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,zt=e._nodeMap,On=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return zn=o,_n("root",null),yt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,zt=void 0,yr=void 0,eo=void 0,zn=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&K(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!oe(e,jf,r)&&t!=null){if(function(l,a,u,c){return La(l)&&!a&&!c&&!u}(t,s,o,i))oe(e,mu,r);else if(function(l,a,u,c,d){return La(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))oe(e,Mf,r);else if(function(l,a,u,c){return Fa(l)&&!a&&!c&&!u}(t,s,o,i))oe(e,yu,r);else if(function(l,a,u,c,d){return Fa(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))oe(e,Rf,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))oe(e,xu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))oe(e,bu,r);else if(function(l,a){return Pa(l)&&a}(t,n))Bn=!0,oe(e,Ns,r);else if(function(l){return l===" "}(t))oe(e,Ff,r);else if(function(l,a){return Mt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,oe(e,Kr,!0);else if(function(l,a){return Pa(l)&&!a}(t,n))Bn=!1,oe(e,Ns,r);else if(function(l,a,u,c){return Mt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?oe(e,vu,r):(r.preventDefault(),oe(e,Er,!0));else if(function(l){return l==="Escape"}(t))oe(e,_u,r);else if(function(l,a,u,c,d){return Mt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?oe(e,wu,r):(r.preventDefault(),oe(e,Er,!1));else if(function(l,a,u){return fn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!0);else if(function(l,a,u){return hn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!1);else if(function(l,a){return Mt&&a&&fn(l)}(t,i))r.preventDefault(),oe(e,Ln,!0);else if(function(l,a){return Mt&&a&&hn(l)}(t,i))r.preventDefault(),oe(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))oe(e,Lf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&vn(u,c)}(t,n,i,s))r.preventDefault(),oe(e,jo,void 0);else if(function(l,a,u,c){return Mt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),oe(e,Mo,void 0);else{const l=e._editorState._selection;l===null||G(l)?!mr&&Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&oe(e,Hf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Et(e,()=>{$e(en(t))||(ao=!0)})}],["compositionstart",function(r,e){Et(e,()=>{const t=ue();if(G(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ut(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||ee(s)&&s.getStyle()!==t.style)&&oe(e,Yr,Zf)}})}],["compositionend",function(r,e){mr?gn=!0:Et(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Et(e,()=>{const t=ue(),n=r.data,s=ec(r);if(n!=null&&G(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Bt(e._window);if(o===null)return;const l=t.isBackward(),a=l?t.anchor.offset:t.focus.offset,u=l?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&ee(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===$u(o.anchorNode)||oe(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ut(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);wt(),Bu(Ze())}),Wr=null}],["click",function(r,e){Et(e,()=>{const t=ue(),n=Bt(e._window),s=Zn();if(n){if(G(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!mt(o)&&Qe().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(z(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Gn||o===xr)&&Kt(ea(s,n,e,r))}}}oe(e,gu,r)})}],["cut",er],["copy",er],["dragstart",er],["dragover",er],["dragend",er],["paste",er],["focus",er],["blur",er],["drop",er]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||mr&&qu(n)||s!=="insertCompositionText"&&Et(n,()=>{const o=ue();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!G(p))return;Kt(p.clone())}if(G(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Qu==="MediaLast"&&l<Nn+so&&n.isComposing()&&p){if(ut(null),Nn=0,setTimeout(()=>{Et(n,()=>{ut(null)})},so),G(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),ee(g)||K(142),o.style=g.getStyle()}}else{ut(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),v=o.anchor.offset===0&&o.focus.offset===m.length;Kf&&p&&!v&&x||oe(n,Er,!0)}return}}var l;if(!G(o))return;const a=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||mt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),f=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":oe(n,Yr,t);break;case"insertFromComposition":ut(null),oe(n,Yr,t);break;case"insertLineBreak":ut(null),oe(n,Kr,!1);break;case"insertParagraph":ut(null),Bn&&!Vn?(Bn=!1,oe(n,Kr,!1)):oe(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":oe(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||z(p)||z(g)||!p.isToken()||!g.isToken()})(d,f)&&oe(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":oe(n,Ki,t);break;case"deleteContent":oe(n,Er,!1);break;case"deleteWordBackward":oe(n,Fn,!0);break;case"deleteWordForward":oe(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":oe(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":oe(n,Ln,!1);break;case"formatStrikeThrough":oe(n,It,"strikethrough");break;case"formatBold":oe(n,It,"bold");break;case"formatItalic":oe(n,It,"italic");break;case"formatUnderline":oe(n,It,"underline");break;case"historyUndo":oe(n,jo,void 0);break;case"historyRedo":oe(n,Mo,void 0)}else{if(a===`
86
- `)t.preventDefault(),oe(n,Kr,!1);else if(a===sr)t.preventDefault(),oe(n,Rn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Zu(o,i,a,t.timeStamp,!0)?(t.preventDefault(),oe(n,Yr,a)):Wr=a;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=Ze(),u=Bt(a._window),c=u!==null?u.anchorNode:null,d=i.key,f=a.getElementByKey(d),p=t.length;return d!==o.key||!ee(l)||(!s&&(!Bs||Ju<n+50)||l.isDirty()&&p<2||zu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&f!==null&&!l.isComposing()&&c!==Fs(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||mh(r,l)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||Et(e,()=>{if(!t)return void Kt(null);if(!Kn(e,n,i))return;const l=ue();if(G(l)){const a=l.anchor,u=a.getNode();if(l.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(l.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[f,p,g,m,x]=Xu,v=Qe(),b=e.isComposing()===!1&&v.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=f,l.style=p;else if(a.type==="text")ee(u)||K(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!b){const _=a.getNode();l.style="",_ instanceof on&&_.getChildrenSize()===0?(l.format=_.getTextFormat(),l.style=_.getTextStyle()):l.format=0}}else{const c=a.key,d=l.focus.key,f=l.getNodes(),p=f.length,g=l.isBackward(),m=g?o:s,x=g?s:o,v=g?d:c,b=g?c:d;let _=Xf,S=!1;for(let A=0;A<p;A++){const E=f[A],w=E.getTextContentSize();if(ee(E)&&w!==0&&!(A===0&&E.__key===v&&m===w||A===p-1&&E.__key===b&&x===0)&&(S=!0,_&=E.getFormat(),_===0))break}l.format=S?_:0}}oe(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ut(null),t!==null&&e!=null){if(e===""){const n=ht(t),s=Fs(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&ee(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
- `){const n=ue();if(G(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void oe(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=Bt(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Ru(t.anchorNode);if(n===null)return;ao&&(ao=!1,Et(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==xr||Kt(ea(u,t,n,r))}));const s=Vo(n),i=s[s.length-1],o=i._key,l=Qr.get(o),a=l||i;a!==n&&Wa(t,a,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):l&&Qr.delete(o)}function Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Ah(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&K(162);const n=t-1;n>=0||K(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const l=Vo(o),a=l[l.length-1]._key;Qr.get(a)===o&&Qr.delete(a)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&K(198);const i=tc(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){wt();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=ue();if(!G(a)||!z(l))return a;const{anchor:u,focus:c}=a,d=u.getNode(),f=c.getNode();return Tn(d,l)&&u.set(l.__key,0,"element"),Tn(f,l)&&c.set(l.__key,0,"element"),a}(r);let o=!1;if(G(i)&&e){const l=i.anchor,a=i.focus;l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Wt(i)&&e&&r.isSelected()&&r.selectPrevious();if(G(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Yt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&mt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){K(64,this.name)}static clone(e){K(65,this.name)}afterCloneFrom(e){this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev}constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,gh(this,e)}getType(){return this.__type}isInline(){K(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=ht(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||ue();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(ee(this))return n;if(G(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if($e(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return e===null?null:ht(e)}getParentOrThrow(){const e=this.getParent();return e===null&&K(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Yt(t))return z(e)||e===this&&$e(e)||K(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&K(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return e===null?null:ht(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return e===null?null:ht(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=this.getParents(),n=e.getParents();z(this)&&t.unshift(this),z(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let l=0;l<s;l++){const a=t[l];if(o.has(a))return a}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const l=z(i)?t?i.getFirstChild():i.getLastChild():null;if(l!==null){i=l;continue}const a=t?i.getNextSibling():i.getPreviousSibling();if(a!==null){i=a;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&K(68),c=t?d.getNextSibling():d.getPreviousSibling(),d=d.getParent(),d===null)break;c!==null||s.has(d.__key)||n.push(d)}while(c===null);i=c}return t||n.reverse(),n}isDirty(){const e=Ze()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=ht(this.__key);return e===null&&K(113),e}getWritable(){wt();const e=ar(),t=Ze(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=ue();if(l!==null&&l.setCachedNodes(null),o.has(s))return Ps(i),i;const a=Jo(i);return o.add(s),Ps(a),n.set(s,a),a}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){K(70)}updateDOM(e,t,n){K(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){K(72)}static importJSON(e){K(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){wt();let n=ue();n!==null&&(n=n.clone()),ji(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,l=e.getWritable(),a=this.getParentOrThrow().getWritable(),u=a.__size;Dr(l);const c=s.getPreviousSibling(),d=s.getNextSibling(),f=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?a.__first=o:c.getWritable().__next=o,l.__prev=f,d===null?a.__last=o:d.getWritable().__prev=o,l.__next=p,l.__parent=g,a.__size=u,t&&(z(this)&&z(l)||K(139),this.getChildren().forEach(m=>{l.append(m)})),G(n)){Kt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,l),x.key===i&&Qa(x,l)}return hr()===i&&ut(o),l}insertAfter(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=ue();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),G(o)){const g=i.__key,m=o.anchor,x=o.focus;l=m.type==="element"&&m.key===g&&m.offset===p+1,a=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,f=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=f,s.__prev=n.__key,s.__parent=n.__parent,t&&G(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;l&&o.anchor.set(g,p+2,"element"),a&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),a=n.__prev,u=this.getIndexWithinParent();o===null?l.__first=i:o.getWritable().__next=i,l.__size++,n.__prev=i,s.__prev=a,s.__next=n.__key,s.__parent=n.__parent;const c=ue();return t&&G(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return nt()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){wt();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(z(n))return n.select();if(!ee(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){wt();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(z(n))return n.select(0,0);if(!ee(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Qn extends hi{static getType(){return"linebreak"}static clone(e){return new Qn(e.__key)}constructor(e){super(e)}getTextContent(){return`
85
+ `,Zf=mr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",eh=new RegExp("^[^"+Tu+"]*["+Au+"]"),th=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},rh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:Oo,left:Po,right:zo,start:$o},nh={[Io]:"center",[qo]:"end",[Oo]:"justify",[Po]:"left",[zo]:"right",[$o]:"start"},sh={normal:0,segmented:2,token:1},ih={[Yf]:"normal",[Jf]:"segmented",[Qf]:"token"};function oh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K=oh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Rs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const ah=100;let Qi=!1,Uo=0;function lh(r){Uo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function uh(r,e,t){const n=Bt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function ch(r,e,t){if(G(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function dh(r,e,t,n){for(let s=r;s&&!Sh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=ht(i,t);if(o)return $e(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>ah;try{Et(r,()=>{const s=ue()||function(f){return f.getEditorState().read(()=>{const p=ue();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),l=r._editorState,a=r._blockCursorElement;let u=!1,c="";for(let f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=dh(m,r,l,o);if(!x)continue;const[v,b]=x;if(g==="characterData")n&&Z(b)&&ch(s,m,b)&&uh(m,b,r);else if(g==="childList"){u=!0;const _=p.addedNodes;for(let E=0;E<_.length;E++){const w=_[E],D=Lu(w),R=w.parentNode;if(R!=null&&w!==a&&D===null&&!Bi(w,R,r)){if(mr){const k=w.innerText||w.nodeValue;k&&(c+=k)}R.removeChild(w)}}const S=p.removedNodes,A=S.length;if(A>0){let E=0;for(let w=0;w<A;w++){const D=S[w];(Bi(D,m,r)||a===D)&&(m.appendChild(D),E++)}A!==E&&i.set(v,b)}}}if(i.size>0)for(const[f,p]of i)p.reconcileObservedMutation(f,r);const d=t.takeRecords();if(d.length>0){for(let f=0;f<d.length;f++){const p=d[f],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const v=g[x],b=v.parentNode;b==null||v.nodeName!=="BR"||Bi(v,m,r)||b.removeChild(v)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Kt(s)),mr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",lh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,l=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==l)}function Na(r,e){const t=r.mergeWithSibling(e),n=Ze()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&Z(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&Z(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),Z(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!z(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let fh=1;const hh=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return $e(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function ph(r){return r.nodeType===xr}function Fs(r){let e=r;for(;e!=null;){if(ph(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Fu(r){return Z(r)||Ar(r)||$e(r)}function gh(r,e){if(e!=null)return void(r.__key=e);wt(),uc();const t=Ze(),n=ar(),s=""+fh++;n._nodeMap.set(s,r),z(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const l=i.getWritable();l.__prev=o.__key,o.__next=l.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const l=s.getWritable();l.__next=o.__key,o.__prev=l.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=ar(),s=Ze(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(a,u,c){let d=a;for(;d!==null;){if(c.has(d))return;const f=u.get(d);if(f===void 0)break;c.set(d,!1),d=f.__parent}}(t,i,o);const l=e.__key;s._dirtyType=Du,z(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function ut(r){wt();const e=Ze(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=ht(t);n!==null&&n.getWritable()}if(r!==null){const n=ht(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:Ze()._compositionKey}function ht(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,Ze());return t!==void 0?ht(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Qe().getTextContent())}function Qe(){return Iu(ar())}function Iu(r){return r._nodeMap.get("root")}function Kt(r){wt();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=Ze(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?ht("root"):null:ht(t)}function Ra(r,e){return e?r.getTextContentSize():0}function zu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Bt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=$u(s);const a=en(s);if(l!==null&&Z(a)){if(l===ai&&t){const u=t.length;l=t,i=u,o=u}l!==null&&Ko(a,l,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let l=e;(o||s)&&e[e.length-1]===ai&&(l=e.slice(0,-1));const a=i.getTextContent();if(s||l!==a){if(l===""){if(ut(null),oi||Vn||Fo)i.remove();else{const m=Ze();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!o||G(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=ue();if(!G(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=it(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function mh(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(i){const o=i.getPreviousSibling();return(Z(o)||z(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Mt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function yh(){const r=Qe();Kt(Mu(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,l=e.get(i);l===void 0&&K(33,i);const a=l.klass;let u=r.get(a);u===void 0&&(u=new Map,r.set(a,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function za(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return za(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?za(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function oe(r,e,t){return fc(r,e,t)}function ci(r){return!mt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&K(75,e),t}function Yn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&K(78),e}function xh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return mt(r)||z(r)&&r.isShadowRoot()}function Jt(r){const e=Ze(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&K(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),l=o.constructor;return i!==null?o instanceof i||K(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||K(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&K(203,r.constructor.name,t,l.name,l.getType()),o}return r}function ji(r,e){!mt(r.getParent())||z(e)||$e(e)||K(99)}function Mi(r){return($e(r)||z(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function bh(r,e,t){let n=r._blockCursorElement;if(G(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let l=!1,a=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(l=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(l=!0,a=r.getElementByKey(u.__key))}}if(l){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,f=document.createElement("div");f.contentEditable="false",f.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Rs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(a===null?u.appendChild(n):u.insertBefore(n,a))}}n!==null&&Qo(n,r,e)}function Bt(r){return $t?(r||window).getSelection():null}function vh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Ji(r){const e=new RegExp(/^(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|#text)$/,"i");return r.nodeName.match(e)!==null}function zs(r){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return r.nodeName.match(e)!==null}function cr(r){if($e(r)&&!r.isInline())return!0;if(!z(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||Z(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function _h(){return Ze()}const $a=new WeakMap,wh=new Map;function Ch(r){if(!r._readOnly&&r.isEmpty())return wh;r._readOnly||K(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function Sh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(z(o)&&Uu(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,yt,In,fi,Xi,Zi,jr,zt,eo,zn,ot="",gt="",Ut=null,Rt="",rr="",Wu=!1,On=!1,_s=null;function Os(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(zt.has(r)||yt._keyToDOMMap.delete(r),z(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(zn,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&Os(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const kh="40px";function Hu(r,e){const t=yr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||kh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===zo?_r(t,"right"):e===Oo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=zt.get(r);t===void 0&&K(60);const n=t.createDOM(yr,yt);if(function(s,i,o){const l=o._keyToDOMMap;(function(a,u,c){a[`__lexicalKey_${u._key}`]=c})(i,o,s),l.set(s,i)}(r,n,yt),Z(t)?n.setAttribute("data-lexical-text","true"):$e(t)&&n.setAttribute("data-lexical-decorator","true"),z(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const f=gt;gt="",ro(a,c,0,u,c.getDOMSlot(d)),Ku(c,d),gt=f})(qs(t,zt),l,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(ot+=sr,rr+=sr)}else{const s=t.getTextContent();if($e(t)){const i=t.decorate(yt,yr);i!==null&&Yu(r,i),n.contentEditable="false"}else Z(t)&&(t.isDirectionless()||(gt+=s));ot+=s,rr+=s}return e!==null&&e.insertChild(n),Yo(zn,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=ot;ot="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=zt.get(r[o]);l!==null&&Z(l)&&(Ut===null&&(Ut=l.getFormat()),Rt===""&&(Rt=l.getStyle()))}ci(e)&&(ot+=sr),s.element.__lexicalTextContent=ot,ot=i+ot}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":$e(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,zt);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==gt||n!==_s){const i=gt==="",o=i?_s:(s=gt,eh.test(s)?"rtl":th.test(s)?"ltr":null);if(o!==n){const l=e.classList,a=yr.theme;let u=n!==null?a[n]:void 0,c=o!==null?a[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=a[n]=d}l.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}On||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=gt,e.__lexicalDir=o}var s}function Eh(r,e,t){const n=gt;var s;gt="",Ut=null,Rt="",function(i,o,l){const a=ot,u=i.__size,c=o.__size;ot="";const d=l.element;if(u===1&&c===1){const f=i.__first,p=o.__first;if(f===p)_n(f,d);else{const m=no(f),x=$s(p,null);try{d.replaceChild(x,m)}catch(v){if(typeof v=="object"&&v!=null){const b=`${v.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(b)}throw v}Os(f,null)}const g=zt.get(p);Z(g)&&(Ut===null&&(Ut=g.getFormat()),Rt===""&&(Rt=g.getStyle()))}else{const f=qs(i,jr),p=qs(o,zt);if(f.length!==u&&K(227),p.length!==c&&K(228),u===0)c!==0&&ro(p,o,0,c-1,l);else if(c===0){if(u!==0){const g=l.after==null&&l.before==null&&l.element.__lexicalLineBreak==null;to(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,v,b,_){const S=v-1,A=b-1;let E,w,D=_.getFirstChild(),R=0,k=0;for(;R<=S&&k<=A;){const F=m[R],C=x[k];if(F===C)D=Ri(_n(C,_.element)),R++,k++;else{E===void 0&&(E=new Set(m)),w===void 0&&(w=new Set(x));const L=w.has(F),I=E.has(C);if(L)if(I){const W=Is(yt,C);W===D?D=Ri(_n(C,_.element)):(_.withBefore(D).insertChild(W),_n(C,_.element)),R++,k++}else $s(C,_.withBefore(D)),k++;else D=Ri(no(F)),Os(F,_.element),R++}const M=zt.get(C);M!==null&&Z(M)&&(Ut===null&&(Ut=M.getFormat()),Rt===""&&(Rt=M.getStyle()))}const N=R>S,j=k>A;if(N&&!j){const F=x[A+1],C=F===void 0?null:yt.getElementByKey(F);ro(x,g,k,A,_.withBefore(C))}else j&&!N&&to(m,R,S,_.element)})(o,f,p,u,c,l)}ci(o)&&(ot+=sr),d.__lexicalTextContent=ot,ot=a+ot}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!On&&(s.setTextFormat(Ut),s.setTextStyle(Rt)),function(i){tn(i)&&Rt!==""&&Rt!==i.__textStyle&&!On&&i.setTextStyle(Rt)}(e),gt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&K(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=zt.get(r);t!==void 0&&n!==void 0||K(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(yt,r);if(t===n&&!s){if(z(t)){const o=i.__lexicalTextContent;o!==void 0&&(ot+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(gt+=l)}else{const o=t.getTextContent();Z(t)&&!t.isDirectionless()&&(gt+=o),rr+=o,ot+=o}return i}if(t!==n&&s&&Yo(zn,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&K(62),e.replaceChild(o,i),Os(r,null),o}if(z(t)&&z(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const l=n.__format;l!==t.__format&&Vu(i,l),s&&(Eh(t,n,i),mt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(ot+=sr,rr+=sr)}else{const o=n.getTextContent();if($e(n)){const l=n.decorate(yt,yr);l!==null&&Yu(r,l)}else Z(n)&&!n.isDirectionless()&&(gt+=o);ot+=o,rr+=o}if(!On&&mt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Yu(r,e){let t=yt._pendingDecorators;const n=yt._decorators;if(t===null){if(n[r]===e)return;t=Pu(yt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===yt._blockCursorElement&&(e=e.nextSibling),e}function Dh(r,e,t,n,s,i){ot="",rr="",gt="",Wu=n===Zr,_s=null,yt=t,yr=t._config,In=t._nodes,fi=yt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,zt=e._nodeMap,On=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return zn=o,_n("root",null),yt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,zt=void 0,yr=void 0,eo=void 0,zn=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&K(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!oe(e,jf,r)&&t!=null){if(function(l,a,u,c){return La(l)&&!a&&!c&&!u}(t,s,o,i))oe(e,mu,r);else if(function(l,a,u,c,d){return La(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))oe(e,Mf,r);else if(function(l,a,u,c){return Fa(l)&&!a&&!c&&!u}(t,s,o,i))oe(e,yu,r);else if(function(l,a,u,c,d){return Fa(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))oe(e,Rf,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))oe(e,xu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))oe(e,bu,r);else if(function(l,a){return Pa(l)&&a}(t,n))Bn=!0,oe(e,Ns,r);else if(function(l){return l===" "}(t))oe(e,Ff,r);else if(function(l,a){return Mt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,oe(e,Kr,!0);else if(function(l,a){return Pa(l)&&!a}(t,n))Bn=!1,oe(e,Ns,r);else if(function(l,a,u,c){return Mt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?oe(e,vu,r):(r.preventDefault(),oe(e,Er,!0));else if(function(l){return l==="Escape"}(t))oe(e,_u,r);else if(function(l,a,u,c,d){return Mt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?oe(e,wu,r):(r.preventDefault(),oe(e,Er,!1));else if(function(l,a,u){return fn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!0);else if(function(l,a,u){return hn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!1);else if(function(l,a){return Mt&&a&&fn(l)}(t,i))r.preventDefault(),oe(e,Ln,!0);else if(function(l,a){return Mt&&a&&hn(l)}(t,i))r.preventDefault(),oe(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))oe(e,Lf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&vn(u,c)}(t,n,i,s))r.preventDefault(),oe(e,jo,void 0);else if(function(l,a,u,c){return Mt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),oe(e,Mo,void 0);else{const l=e._editorState._selection;l===null||G(l)?!mr&&Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&oe(e,Hf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Et(e,()=>{$e(en(t))||(ao=!0)})}],["compositionstart",function(r,e){Et(e,()=>{const t=ue();if(G(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ut(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||Z(s)&&s.getStyle()!==t.style)&&oe(e,Yr,Zf)}})}],["compositionend",function(r,e){mr?gn=!0:Et(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Et(e,()=>{const t=ue(),n=r.data,s=ec(r);if(n!=null&&G(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Bt(e._window);if(o===null)return;const l=t.isBackward(),a=l?t.anchor.offset:t.focus.offset,u=l?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&Z(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===$u(o.anchorNode)||oe(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ut(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);wt(),Bu(Ze())}),Wr=null}],["click",function(r,e){Et(e,()=>{const t=ue(),n=Bt(e._window),s=Zn();if(n){if(G(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!mt(o)&&Qe().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(z(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Gn||o===xr)&&Kt(ea(s,n,e,r))}}}oe(e,gu,r)})}],["cut",er],["copy",er],["dragstart",er],["dragover",er],["dragend",er],["paste",er],["focus",er],["blur",er],["drop",er]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||mr&&qu(n)||s!=="insertCompositionText"&&Et(n,()=>{const o=ue();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!G(p))return;Kt(p.clone())}if(G(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Qu==="MediaLast"&&l<Nn+so&&n.isComposing()&&p){if(ut(null),Nn=0,setTimeout(()=>{Et(n,()=>{ut(null)})},so),G(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),Z(g)||K(142),o.style=g.getStyle()}}else{ut(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),v=o.anchor.offset===0&&o.focus.offset===m.length;Kf&&p&&!v&&x||oe(n,Er,!0)}return}}var l;if(!G(o))return;const a=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||mt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),f=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":oe(n,Yr,t);break;case"insertFromComposition":ut(null),oe(n,Yr,t);break;case"insertLineBreak":ut(null),oe(n,Kr,!1);break;case"insertParagraph":ut(null),Bn&&!Vn?(Bn=!1,oe(n,Kr,!1)):oe(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":oe(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||z(p)||z(g)||!p.isToken()||!g.isToken()})(d,f)&&oe(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":oe(n,Ki,t);break;case"deleteContent":oe(n,Er,!1);break;case"deleteWordBackward":oe(n,Fn,!0);break;case"deleteWordForward":oe(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":oe(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":oe(n,Ln,!1);break;case"formatStrikeThrough":oe(n,It,"strikethrough");break;case"formatBold":oe(n,It,"bold");break;case"formatItalic":oe(n,It,"italic");break;case"formatUnderline":oe(n,It,"underline");break;case"historyUndo":oe(n,jo,void 0);break;case"historyRedo":oe(n,Mo,void 0)}else{if(a===`
86
+ `)t.preventDefault(),oe(n,Kr,!1);else if(a===sr)t.preventDefault(),oe(n,Rn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Zu(o,i,a,t.timeStamp,!0)?(t.preventDefault(),oe(n,Yr,a)):Wr=a;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=Ze(),u=Bt(a._window),c=u!==null?u.anchorNode:null,d=i.key,f=a.getElementByKey(d),p=t.length;return d!==o.key||!Z(l)||(!s&&(!Bs||Ju<n+50)||l.isDirty()&&p<2||zu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&f!==null&&!l.isComposing()&&c!==Fs(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||mh(r,l)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||Et(e,()=>{if(!t)return void Kt(null);if(!Kn(e,n,i))return;const l=ue();if(G(l)){const a=l.anchor,u=a.getNode();if(l.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(l.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[f,p,g,m,x]=Xu,v=Qe(),b=e.isComposing()===!1&&v.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=f,l.style=p;else if(a.type==="text")Z(u)||K(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!b){const _=a.getNode();l.style="",_ instanceof on&&_.getChildrenSize()===0?(l.format=_.getTextFormat(),l.style=_.getTextStyle()):l.format=0}}else{const c=a.key,d=l.focus.key,f=l.getNodes(),p=f.length,g=l.isBackward(),m=g?o:s,x=g?s:o,v=g?d:c,b=g?c:d;let _=Xf,S=!1;for(let A=0;A<p;A++){const E=f[A],w=E.getTextContentSize();if(Z(E)&&w!==0&&!(A===0&&E.__key===v&&m===w||A===p-1&&E.__key===b&&x===0)&&(S=!0,_&=E.getFormat(),_===0))break}l.format=S?_:0}}oe(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ut(null),t!==null&&e!=null){if(e===""){const n=ht(t),s=Fs(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&Z(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
+ `){const n=ue();if(G(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void oe(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=Bt(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Ru(t.anchorNode);if(n===null)return;ao&&(ao=!1,Et(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==xr||Kt(ea(u,t,n,r))}));const s=Vo(n),i=s[s.length-1],o=i._key,l=Qr.get(o),a=l||i;a!==n&&Wa(t,a,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):l&&Qr.delete(o)}function Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Ah(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&K(162);const n=t-1;n>=0||K(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const l=Vo(o),a=l[l.length-1]._key;Qr.get(a)===o&&Qr.delete(a)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&K(198);const i=tc(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){wt();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=ue();if(!G(a)||!z(l))return a;const{anchor:u,focus:c}=a,d=u.getNode(),f=c.getNode();return Tn(d,l)&&u.set(l.__key,0,"element"),Tn(f,l)&&c.set(l.__key,0,"element"),a}(r);let o=!1;if(G(i)&&e){const l=i.anchor,a=i.focus;l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Wt(i)&&e&&r.isSelected()&&r.selectPrevious();if(G(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Yt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&mt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){K(64,this.name)}static clone(e){K(65,this.name)}afterCloneFrom(e){this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev}constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,gh(this,e)}getType(){return this.__type}isInline(){K(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=ht(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||ue();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(Z(this))return n;if(G(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if($e(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return e===null?null:ht(e)}getParentOrThrow(){const e=this.getParent();return e===null&&K(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Yt(t))return z(e)||e===this&&$e(e)||K(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&K(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return e===null?null:ht(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return e===null?null:ht(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=this.getParents(),n=e.getParents();z(this)&&t.unshift(this),z(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let l=0;l<s;l++){const a=t[l];if(o.has(a))return a}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const l=z(i)?t?i.getFirstChild():i.getLastChild():null;if(l!==null){i=l;continue}const a=t?i.getNextSibling():i.getPreviousSibling();if(a!==null){i=a;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&K(68),c=t?d.getNextSibling():d.getPreviousSibling(),d=d.getParent(),d===null)break;c!==null||s.has(d.__key)||n.push(d)}while(c===null);i=c}return t||n.reverse(),n}isDirty(){const e=Ze()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=ht(this.__key);return e===null&&K(113),e}getWritable(){wt();const e=ar(),t=Ze(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=ue();if(l!==null&&l.setCachedNodes(null),o.has(s))return Ps(i),i;const a=Jo(i);return o.add(s),Ps(a),n.set(s,a),a}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){K(70)}updateDOM(e,t,n){K(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){K(72)}static importJSON(e){K(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){wt();let n=ue();n!==null&&(n=n.clone()),ji(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,l=e.getWritable(),a=this.getParentOrThrow().getWritable(),u=a.__size;Dr(l);const c=s.getPreviousSibling(),d=s.getNextSibling(),f=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?a.__first=o:c.getWritable().__next=o,l.__prev=f,d===null?a.__last=o:d.getWritable().__prev=o,l.__next=p,l.__parent=g,a.__size=u,t&&(z(this)&&z(l)||K(139),this.getChildren().forEach(m=>{l.append(m)})),G(n)){Kt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,l),x.key===i&&Qa(x,l)}return hr()===i&&ut(o),l}insertAfter(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=ue();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),G(o)){const g=i.__key,m=o.anchor,x=o.focus;l=m.type==="element"&&m.key===g&&m.offset===p+1,a=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,f=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=f,s.__prev=n.__key,s.__parent=n.__parent,t&&G(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;l&&o.anchor.set(g,p+2,"element"),a&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),a=n.__prev,u=this.getIndexWithinParent();o===null?l.__first=i:o.getWritable().__next=i,l.__size++,n.__prev=i,s.__prev=a,s.__next=n.__key,s.__parent=n.__parent;const c=ue();return t&&G(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return nt()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){wt();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(z(n))return n.select();if(!Z(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){wt();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(z(n))return n.select(0,0);if(!Z(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Qn extends hi{static getType(){return"linebreak"}static clone(e){return new Qn(e.__key)}constructor(e){super(e)}getTextContent(){return`
88
88
  `}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}return!1}(e)?null:{conversion:Th,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Th(r){return{node:Mr()}}function Mr(){return Jt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===xr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let l=!1;const a=e&Ms&&e&js;o!==void 0&&(t&Ms&&t&js?(l=!0,a||i.add(...o)):a&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(l&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!a||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function sc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||mr){const[l,a,u]=function(c,d){const f=c.length,p=d.length;let g=0,m=0;for(;g<f&&g<p&&c[g]===d[g];)g++;for(;m+g<f&&m+g<p&&c[f-m-1]===d[p-m-1];)m++;return[g,f-g-m,d.slice(g,p-m)]}(o,i);a!==0&&n.deleteData(l,a),n.insertData(l,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return ih[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===hr()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Br[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Ls(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=Li(0,n),i=Pi(0,n),o=s===null?i:s,l=document.createElement(o);let a=l;this.hasFormat("code")&&l.setAttribute("spellcheck","false"),s!==null&&(a=document.createElement(i),l.appendChild(a)),Ga(a,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(l.style.cssText=u),l}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,l=Li(0,i),a=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((l===null?u:l)!==(a===null?c:a))return!0;if(l===a&&u!==c){const m=t.firstChild;m==null&&K(48);const x=document.createElement(c);return Ga(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;a!==null&&l!==null&&(d=t.firstChild,d==null&&K(49)),sc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&nc(0,i,o,d,f);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Mh,priority:0}),b:()=>({conversion:Bh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:Nh,priority:0}),strong:()=>({conversion:ur,priority:0}),sub:()=>({conversion:ur,priority:0}),sup:()=>({conversion:ur,priority:0}),u:()=>({conversion:ur,priority:0})}}static importJSON(e){const t=it(e.text);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportDOM(e){let{element:t}=super.exportDOM(e);return t!==null&&or(t)||K(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=cs(t,"b")),this.hasFormat("italic")&&(t=cs(t,"i")),this.hasFormat("strikethrough")&&(t=cs(t,"s")),this.hasFormat("underline")&&(t=cs(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,t){}setFormat(e){const t=this.getWritable();return t.__format=typeof e=="string"?Br[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail=typeof e=="string"?rh[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Ls(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const t=sh[e];if(this.__mode===t)return this;const n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;const t=this.getWritable();return t.__text=e,t}select(e,t){wt();let n=e,s=t;const i=ue(),o=this.getTextContent(),l=this.__key;if(typeof o=="string"){const a=o.length;n===void 0&&(n=a),s===void 0&&(s=a)}else n=0,s=0;if(!G(i))return ac(l,n,l,s,"text","text");{const a=hr();a!==i.anchor.key&&a!==i.focus.key||ut(l),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,l=n.length;let a=e;a<0&&(a=l+a,a<0&&(a=0));const u=ue();if(s&&G(u)){const d=e+l;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,a)+n+o.slice(a+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){wt();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),l=[],a=n.length;let u="";for(let A=0;A<a;A++)u!==""&&o.has(A)&&(l.push(u),u=""),u+=n[A];u!==""&&l.push(u);const c=l.length;if(c===0)return[];if(l[0]===n)return[t];const d=l[0],f=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let v=!1;t.isSegmented()?(p=it(d),p.__format=g,p.__style=m,p.__detail=x,v=!0):(p=t.getWritable(),p.__text=d);const b=ue(),_=[p];let S=d.length;for(let A=1;A<c;A++){const E=l[A],w=E.length,D=it(E).getWritable();D.__format=g,D.__style=m,D.__detail=x;const R=D.__key,k=S+w;if(G(b)){const N=b.anchor,j=b.focus;N.key===s&&N.type==="text"&&N.offset>S&&N.offset<=k&&(N.key=R,N.offset-=S,b.dirty=!0),j.key===s&&j.type==="text"&&j.offset>S&&j.offset<=k&&(j.key=R,j.offset-=S,b.dirty=!0)}i===s&&ut(R),S=k,_.push(D)}if(f!==null){(function(w){const D=w.getPreviousSibling(),R=w.getNextSibling();D!==null&&Ps(D),R!==null&&Ps(R)})(this);const A=f.getWritable(),E=this.getIndexWithinParent();v?(A.splice(E,0,_),this.remove()):A.splice(E,1,_),G(b)&&Ws(b,f,E,c-1)}return _}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||K(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;hr()===s&&ut(n);const l=ue();if(G(l)){const d=l.anchor,f=l.focus;d!==null&&d.key===s&&(nl(d,t,n,e,o),l.dirty=!0),f!==null&&f.key===s&&(nl(f,t,n,e,o),l.dirty=!0)}const a=e.__text,u=t?a+i:i+a;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Nh(r){return{forChild:Zo(r.style),node:null}}function Bh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function jh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Mh(r){const e=r;r.parentElement===null&&K(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ka.get(i))===void 0&&!jh(i);)o.push(i),i=i.parentNode;const l=s===void 0?i:s;for(let a=0;a<o.length;a++)Ka.set(o[a],l);return l}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const l=n[o];l===`
89
89
  `||l===`\r
90
- `?s.push(Mr()):l===" "?s.push(Xn()):l!==""&&s.push(it(l))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:it(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===xr)return t;if(t.nodeName==="BR")return null}}const Rh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Rh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function it(r=""){return Jt(new sn(r))}function ee(r){return r instanceof sn}function Zo(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",l=n.includes("underline"),a=r.verticalAlign;return u=>(ee(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),l&&!u.hasFormat("underline")&&u.toggleFormat("underline"),a!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),a!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){K(126)}setDetail(e){K(127)}setMode(e){K(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Jt(new Jn)}function Fh(r){return r instanceof Jn}class Lh{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode();const s=this.offset,i=e.offset;if(z(t)){const o=t.getDescendantByIndex(s);t=o??t}if(z(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=ht(this.key);return e===null&&K(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,es()||(hr()===i&&ut(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Qt(r,e,t){return new Lh(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(ee(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!z(e)){const i=e.getNextSibling();if(ee(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Qa(r,e){if(z(e)){const t=e.getLastDescendant();z(t)||ee(t)?Ii(r,t):Ii(r,e)}else Ii(r,e)}function dr(r,e,t,n){r.key=e,r.offset=t,r.type=n}class pi{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Wt(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(s=>n.has(s))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new pi(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,s=t[n-1];let i;if(ee(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=ht(s);i!==null&&n.push(i)}return es()||(this._cachedNodes=n),n}getTextContent(){const e=this.getNodes();let t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}}function G(r){return r instanceof br}class br{constructor(e,t,n,s){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=s,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!G(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),i=s?t:n,o=s?n:t;let l=i.getNode(),a=o.getNode();const u=i.offset,c=o.offset;if(z(l)){const f=l.getDescendantByIndex(u);l=f??l}if(z(a)){let f=a.getDescendantByIndex(c);f!==null&&f!==l&&a.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),a=f??a}let d;return d=l.is(a)?z(l)&&l.getChildrenSize()>0?[]:[l]:l.getNodesBetween(a),es()||(this._cachedNodes=d),d}setTextNodeRange(e,t,n,s){dr(this.anchor,e.__key,t,"text"),dr(this.focus,n.__key,s,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){const e=this.getNodes();if(e.length===0)return"";const t=e[0],n=e[e.length-1],s=this.anchor,i=this.focus,o=s.isBefore(i),[l,a]=uo(this);let u="",c=!0;for(let d=0;d<e.length;d++){const f=e[d];if(z(f)&&!f.isInline())c||(u+=`
91
- `),c=!f.isEmpty();else if(c=!1,ee(f)){let p=f.getTextContent();f===t?f===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=l<a?p.slice(l,a):p.slice(a,l)):p=o?p.slice(l):p.slice(a):f===n&&(p=o?p.slice(0,a):p.slice(0,l)),u+=p}else!$e(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=Ze(),n=t.getEditorState()._selection,s=oc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;dr(this.anchor,i.key,i.offset,i.type),dr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new br(Qt(e.key,e.offset,e.type),Qt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Ls(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Br[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];o===`
90
+ `?s.push(Mr()):l===" "?s.push(Xn()):l!==""&&s.push(it(l))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:it(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===xr)return t;if(t.nodeName==="BR")return null}}const Rh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Rh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function it(r=""){return Jt(new sn(r))}function Z(r){return r instanceof sn}function Zo(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",l=n.includes("underline"),a=r.verticalAlign;return u=>(Z(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),l&&!u.hasFormat("underline")&&u.toggleFormat("underline"),a!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),a!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){K(126)}setDetail(e){K(127)}setMode(e){K(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Jt(new Jn)}function Fh(r){return r instanceof Jn}class Lh{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode();const s=this.offset,i=e.offset;if(z(t)){const o=t.getDescendantByIndex(s);t=o??t}if(z(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=ht(this.key);return e===null&&K(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,es()||(hr()===i&&ut(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Qt(r,e,t){return new Lh(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(Z(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!z(e)){const i=e.getNextSibling();if(Z(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Qa(r,e){if(z(e)){const t=e.getLastDescendant();z(t)||Z(t)?Ii(r,t):Ii(r,e)}else Ii(r,e)}function dr(r,e,t,n){r.key=e,r.offset=t,r.type=n}class pi{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Wt(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(s=>n.has(s))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new pi(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,s=t[n-1];let i;if(Z(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=ht(s);i!==null&&n.push(i)}return es()||(this._cachedNodes=n),n}getTextContent(){const e=this.getNodes();let t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}}function G(r){return r instanceof br}class br{constructor(e,t,n,s){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=s,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!G(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),i=s?t:n,o=s?n:t;let l=i.getNode(),a=o.getNode();const u=i.offset,c=o.offset;if(z(l)){const f=l.getDescendantByIndex(u);l=f??l}if(z(a)){let f=a.getDescendantByIndex(c);f!==null&&f!==l&&a.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),a=f??a}let d;return d=l.is(a)?z(l)&&l.getChildrenSize()>0?[]:[l]:l.getNodesBetween(a),es()||(this._cachedNodes=d),d}setTextNodeRange(e,t,n,s){dr(this.anchor,e.__key,t,"text"),dr(this.focus,n.__key,s,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){const e=this.getNodes();if(e.length===0)return"";const t=e[0],n=e[e.length-1],s=this.anchor,i=this.focus,o=s.isBefore(i),[l,a]=uo(this);let u="",c=!0;for(let d=0;d<e.length;d++){const f=e[d];if(z(f)&&!f.isInline())c||(u+=`
91
+ `),c=!f.isEmpty();else if(c=!1,Z(f)){let p=f.getTextContent();f===t?f===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=l<a?p.slice(l,a):p.slice(a,l)):p=o?p.slice(l):p.slice(a):f===n&&(p=o?p.slice(0,a):p.slice(0,l)),u+=p}else!$e(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=Ze(),n=t.getEditorState()._selection,s=oc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;dr(this.anchor,i.key,i.offset,i.type),dr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new br(Qt(e.key,e.offset,e.type),Qt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Ls(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Br[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];o===`
92
92
  `||o===`\r
93
- `?n.push(Mr()):o===" "?n.push(Xn()):n.push(it(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,l=t),o.type==="element"&&function(x,v,b,_){const S=x.getNode(),A=S.getChildAtIndex(x.offset),E=it(),w=mt(S)?nt().append(E):E;E.setFormat(b),E.setStyle(_),A===null?S.append(w):A.insertBefore(w),x.is(v)&&v.set(E.__key,0,"text"),x.set(E.__key,0,"text")}(o,l,s,i);const a=o.offset;let u=l.offset;const c=this.getNodes(),d=c.length;let f=c[0];ee(f)||K(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=p,l.set(o.key,u,"text")),this.isCollapsed()&&a===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(ee(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=it(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?f.insertAfter(x):g.insertAfter(x)),x.select(0,0),f=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(ee(x)&&!Cr(x)||(x=it(),x.setFormat(s),g.canInsertTextBefore()?f.insertBefore(x):g.insertBefore(x)),x.select(),f=x,e!=="")return void this.insertText(e)}else if(f.isSegmented()&&a!==p){const x=it(f.getTextContent());x.setFormat(s),f.replace(x),f=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||z(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const _=it(e);return _.select(),void f.replace(_)}const x=f.getFormat(),v=f.getStyle();if(a!==u||x===s&&v===i){if(Fh(f)){const _=it(e);return _.setFormat(s),_.setStyle(i),_.select(),void f.replace(_)}}else{if(f.getTextContent()!==""){const _=it(e);if(_.setFormat(s),_.setStyle(i),_.select(),a===0)f.insertBefore(_,!1);else{const[S]=f.splitText(a);S.insertAfter(_,!1)}return void(_.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const b=u-a;f=f.spliceText(a,b,e,!0),f.getTextContent()===""?f.remove():this.anchor.type==="text"&&(f.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=v))}else{const x=new Set([...f.getParentKeys(),...m.getParentKeys()]),v=z(f)?f:f.getParentOrThrow();let b=z(m)?m:m.getParentOrThrow(),_=m;if(!v.is(b)&&b.isInline())do _=b,b=b.getParentOrThrow();while(b.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(ee(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const D=it(m.getTextContent());m.replace(D),m=D}mt(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const D=m.getParentOrThrow();D.canBeEmpty()||D.getChildrenSize()!==1?m.remove():D.remove()}else x.add(m.__key);const S=b.getChildren(),A=new Set(c),E=v.is(b),w=v.isInline()&&f.getNextSibling()===null?v:f;for(let D=S.length-1;D>=0;D--){const R=S[D];if(R.is(f)||z(R)&&R.isParentOf(f))break;R.isAttached()&&(!A.has(R)||R.is(_)?E||w.insertAfter(R,!1):R.remove())}if(!E){let D=b,R=null;for(;D!==null;){const k=D.getChildren(),N=k.length;(N===0||k[N-1].is(R))&&(x.delete(D.__key),R=D),D=D.getParent()}}if(f.isToken())if(a===p)f.select();else{const D=it(e);D.select(),f.replace(D)}else f=f.spliceText(a,p-a,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let D=1;D<d;D++){const R=c[D],k=R.__key;x.has(k)||R.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),l=i.getNode();const a=pn(o,cr),u=pn(l,cr);ee(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&ee(l)&&l.isToken()&&(i.offset=l.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(l,d)||d.getKey()===o.getKey()||d.getKey()===l.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=it(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&ee(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(ee(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}ee(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&ee(o)?o.selectEnd():l.isAttached()&&ee(l)&&l.selectStart(),z(a)&&z(u)&&a!==u&&(a.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ut(null);const n=this.getNodes(),s=[];for(const S of n)ee(S)&&s.push(S);const i=S=>{n.forEach(A=>{if(tn(A)){const E=A.getFormatFlags(e,S);A.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),ut(null),void i(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let f=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(f=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let v=s[x];const b=d.type==="text"?d.offset:v.getTextContentSize();if(p.is(v)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,b),A=g===0?S[0]:S[1];A.setFormat(m),c.type==="text"&&c.set(A.__key,0,"text"),d.type==="text"&&d.set(A.__key,b-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const _=v.getFormatFlags(e,m);b>0&&(b===v.getTextContentSize()||Cr(v)||([v]=v.splitText(b)),v.setFormat(_));for(let S=f+1;S<x;S++){const A=s[S],E=A.getFormatFlags(e,_);A.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(v.__key,b,"text"),this.format=m|_}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ue();return G(g)||K(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,cr),s=e[e.length-1];if(z(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=zi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(z(g)||$e(g))&&!g.isInline())){z(n)||K(211,t.constructor.name,t.getType());const g=zi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=nt();let x=null;for(let v=0;v<g.length;v++){const b=g[v],_=Ar(b);if(_||$e(b)&&b.isInline()||z(b)&&b.isInline()||ee(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),_))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),l=i.getChildren(),a=!z(n)||!n.isEmpty()?this.insertParagraph():null,u=l[l.length-1];let c=l[0];var d;z(d=c)&&cr(d)&&!d.isEmpty()&&z(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(z(n)||K(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&K(212,t.constructor.name,t.getType()),function(g,m,x){const v=m.getParentOrThrow().getLastChild();let b=m;const _=[m];for(;b!==v;)b.getNextSibling()||K(140),b=b.getNextSibling(),_.push(b);let S=g;for(const A of _)S=S.insertAfter(A)}(n,c));const f=pn(o,cr);a&&z(f)&&(a.canMergeWhenEmpty()||cr(u))&&(f.append(...a.getChildren()),a.remove()),z(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=z(n)?n.getLastChild():null;Ar(p)&&f!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=nt();return Qe().splice(this.anchor.offset,0,[o]),o.select(),o}const e=zi(this),t=pn(this.anchor.getNode(),cr);z(t)||K(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],l=e[n];const[a,u]=uo(this);if(t===0)return[];if(t===1){if(ee(o)&&!this.isCollapsed()){const d=a>u?u:a,f=a>u?a:u,p=o.splitText(d,f),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(ee(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(ee(l)){const d=l.getTextContent().length,f=c?u:a;f===0?e.pop():f!==d&&([l]=l.splitText(f),e[n]=l)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",l=Pn(s,t);if($e(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=tl();return p.add(l.__key),void Kt(p)}const f=t?l.getPreviousSibling():l.getNextSibling();if(ee(f)){const p=f.__key,g=t?f.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=l.getParentOrThrow();let g,m;return z(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=l.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const a=Ze(),u=Bt(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!z(l)||l.isInline()||l.canBeEmpty()||Qo(c,a,d),function(f,p,g,m){f.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const f=u.getRangeAt(0),p=this.anchor.getNode(),g=mt(p)?p:xh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let v=!1;for(let b=0;b<m.length;b++){const _=m[b];Tn(_,g)?x.push(_):v=!0}if(v&&x.length>0)if(t){const b=x[0];z(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];z(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(b){const _=b.focus,S=b.anchor,A=S.key,E=S.offset,w=S.type;dr(S,_.key,_.offset,_.type),dr(_,A,E,w),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&z(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if(z(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const i=this.focus,o=Pn(i,e);if($e(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&z(s)&&s.getChildrenSize()===0){s.remove();const l=tl();l.add(o.__key),Kt(l)}else o.remove(),Ze().dispatchCommand(Bo,void 0);return}if(!e&&z(o)&&z(s)&&s.isEmpty())return s.remove(),void o.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const l=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const a=i.offset,u=l.getTextContentSize();if(l.is(s)||e&&a!==u||!e&&a!==0)return void Xa(l,e,a)}else if(s!==null&&s.isSegmented()){const a=n.offset,u=s.getTextContentSize();if(s.is(l)||e&&a!==0||!e&&a!==u)return void Xa(s,e,a)}(function(a,u){const c=a.anchor,d=a.focus,f=c.getNode(),p=d.getNode();if(f===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,v=x?g:m,b=x?m:g,_=b-1;v!==_&&(zu(f.getTextContent().slice(v,b))||(u?d.offset=_:c.offset=_))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&mt(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Wt(r){return r instanceof pi}function Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,l=0;for(let u=0;u<i;u++){const c=u===i-1;if(l=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(l=void 0);break}}const a=s.join("").trim();a===""?n.remove():(n.setTextContent(a),n.select(l,l))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const l=r.childNodes,a=l.length,u=n._blockCursorElement;i===a&&(o=!0,i=a-1);let c=l[i],d=!1;if(c===u)c=l[i+1],d=!0;else if(u!==null){const f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Hr(c),ee(s))i=Ra(s,o);else{let f=Hr(r);if(f===null)return null;if(z(f)){const p=n.getElementByKey(f.getKey());p===null&&K(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),z(f)||K(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(z(m)&&function(x,v,b){const _=x.getParent();return b===null||_===null||!_.canBeEmpty()||_!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?f=m:(m=x,f=z(m)?m:m.getParentOrThrow()),i=0}ee(m)?(s=m,f=null,i=Ra(m,o)):m!==f&&o&&!d&&(z(f)||K(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&$e(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(z(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return ee(s)?Qt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&z(o)&&o.isInline()){const l=o.getPreviousSibling();ee(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else z(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):ee(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&z(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&z(o)&&o.isInline()&&!o.canInsertTextAfter()){const l=o.getNextSibling();ee(l)&&(r.key=l.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=Ze();if(i.isComposing()&&i._compositionKey!==r.key&&G(t)){const o=t.anchor,l=t.focus;dr(r,o.key,o.offset,o.type),dr(e,l.key,l.offset,l.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,G(i)?i.anchor:null,s);if(o===null)return null;const l=Za(t,n,G(i)?i.focus:null,s);if(l===null)return null;if(o.type==="element"&&l.type==="element"){const a=Hr(r),u=Hr(t);if($e(a)&&$e(u))return null}return ic(o,l,i),[o,l]}function co(r){return z(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=ar(),l=new br(Qt(r,e,s),Qt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Ph(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,l=o==="selectionchange",a=!Qi&&(l||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,f;if(G(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&G(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,G(r)?r.format:0,G(r)?r.style:"")}function ue(){return ar()._selection}function Zn(){return Ze()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),l=i.getNode();if(!e.is(o)&&!e.is(l))return;const a=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(a,c,"element"),i.set(a,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),f=u?s:i,p=f.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(a,Math.max(0,g+n),"element")}if(e.is(p)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(a,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!z(i))return;const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(ee(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(z(i)){const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(ee(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(z(o)){const l=o.getChildrenSize(),a=s>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(s);if(ee(u)){let c=0;a&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,l=null;n!==null?(i=n.__key,ee(n)?(o=n.getTextContentSize(),l="text"):z(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,ee(s)?l="text":z(s)&&(l="element")),i!==null&&l!==null?r.set(i,o,l):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Ih(r,e,t,n,s,i,o){const l=n.anchorNode,a=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!G(e))return void(r!==null&&Kn(t,l,a)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),v=Is(t,m),b=f.offset,_=p.offset,S=e.format,A=e.style,E=e.isCollapsed();let w=x,D=v,R=!1;if(f.type==="text"){w=Fs(x);const M=f.getNode();R=M.getFormat()!==S||M.getStyle()!==A}else G(r)&&r.anchor.type==="text"&&(R=!0);var k,N,j,F,C;if(p.type==="text"&&(D=Fs(v)),w!==null&&D!==null&&(E&&(r===null||R||G(r)&&(r.format!==S||r.style!==A))&&(k=S,N=A,j=b,F=g,C=performance.now(),Xu=[k,N,j,F,C]),u!==b||c!==_||l!==w||a!==D||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(w,b,D,_)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const M=e instanceof br&&e.anchor.type==="element"?w.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(M!==null){let L;if(M instanceof Text){const I=document.createRange();I.selectNode(M),L=I.getBoundingClientRect()}else L=M.getBoundingClientRect();(function(I,W,Q){const re=Q.ownerDocument,U=re.defaultView;if(U===null)return;let{top:Y,bottom:P}=W,ie=0,de=0,fe=Q;for(;fe!==null;){const ge=fe===re.body;if(ge)ie=0,de=di(I).innerHeight;else{const he=fe.getBoundingClientRect();ie=he.top,de=he.bottom}let be=0;if(Y<ie?be=-(ie-Y):P>de&&(be=P-de),be!==0)if(ge)U.scrollBy(0,be);else{const he=fe.scrollTop;fe.scrollTop+=be;const J=fe.scrollTop-he;Y-=J,P-=J}if(ge)break;fe=Yn(fe)}})(t,L,i)}}oo=!0}}function lc(r){let e=ue()||Zn();e===null&&(e=Qe().selectEnd()),e.insertNodes(r)}function zi(r){let e=r;r.isCollapsed()||e.removeText();const t=ue();G(t)&&(e=t),G(e)||K(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=zh(s,i);return i}function zh(r,e){const t=r.getParent();if(!t){const s=nt();return Qe().append(s),s.select(),[Qe(),0]}if(ee(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!z(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new br(Qt(r.__key,e,"element"),Qt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let at=null,lt=null,St=!1,Oi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return St||at!==null&&at._readOnly}function wt(){St&&K(13)}function uc(){ws>99&&K(14)}function ar(){return at===null&&K(195,cc()),at}function Ze(){return lt===null&&K(196,cc()),lt}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function Oh(){return lt}function il(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&K(30,a),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let l=0;l<o&&(i[l](e),e.isAttached());l++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function $h(r){return ta(r,Ze()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&K(17,t);const s=n.klass;r.type!==s.getType()&&K(18,s.name);const i=s.importJSON(r),o=r.children;if(z(i)&&Array.isArray(o))for(let l=0;l<o.length;l++){const a=ta(o[l],e);i.append(a)}return i}function al(r,e,t){const n=at,s=St,i=lt;at=e,St=!0,lt=r;try{return t()}finally{at=n,St=s,lt=i}}function pr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,l=t._selection,a=r._dirtyType!==Nr,u=at,c=St,d=lt,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){lt=r,at=t,St=!1,r._updating=!0;try{const E=r._dirtyType,w=r._dirtyElements,D=r._dirtyLeaves;p.disconnect(),g=Dh(i,t,r,E,w,D)}catch(E){if(E instanceof Error&&r._onError(E),Oi)throw E;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,Oi=!0,pr(r,i),void(Oi=!1)}finally{p.observe(n,sl),r._updating=f,at=u,St=c,lt=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,v=r._normalizedNodes,b=r._updateTags,_=r._deferred;a&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(E,w){const D=E._decorators;let R=E._pendingDecorators||D;const k=w._nodeMap;let N;for(N in R)k.has(N)||(R===D&&(R=Pu(E)),delete R[N])}(r,t);const S=s?null:Bt(r._window);if(r._editable&&S!==null&&(a||l===null||l.dirty)){lt=r,at=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),Ih(o,l,r,S,b,n)}bh(r,n,l),p!==null&&p.observe(n,sl)}finally{lt=d,at=u}}g!==null&&function(E,w,D,R,k){const N=Array.from(E._listeners.mutation),j=N.length;for(let F=0;F<j;F++){const[C,M]=N[F],L=w.get(M);L!==void 0&&C(L,{dirtyLeaves:R,prevEditorState:k,updateTags:D})}}(r,g,b,m,i),G(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Bo,void 0);const A=r._pendingDecorators;A!==null&&(r._decorators=A,r._pendingDecorators=null,jn("decorator",r,!0,A)),function(E,w,D){const R=Ma(w),k=Ma(D);R!==k&&jn("textcontent",E,!0,k)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:v,prevEditorState:e||i,tags:b}),function(E,w){if(E._deferred=[],w.length!==0){const D=E._updating;E._updating=!0;try{for(let R=0;R<w.length;R++)w[R]()}finally{E._updating=D}}}(r,_),function(E){const w=E._updates;if(w.length!==0){const D=w.shift();if(D){const[R,k]=D;hc(E,R,k)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||lt!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const l=o[s];if(l!==void 0){const a=Array.from(l),u=a.length;for(let c=0;c<u;c++)if(a[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let l;if(o!==void 0){if(l=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const a=r._pendingEditorState;a===null&&K(191),a._flushSync=!0}l&&r._deferred.push(l),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let a=r._pendingEditorState,u=!1;(a===null||a._readOnly)&&(a=r._pendingEditorState=pc(a||l),u=!0),a._flushSync=o;const c=at,d=St,f=lt,p=r._updating;at=a,St=!1,r._updating=!0,lt=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(v){const b=v.getEditorState()._selection,_=Bt(v._window);return G(b)||b==null?ea(b,_,v,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(v,b){const _=b.getEditorState()._selection,S=v._selection;if(G(S)){const A=S.anchor,E=S.focus;let w;if(A.type==="text"&&(w=A.getNode(),w.selectionTransform(_,S)),E.type==="text"){const D=E.getNode();w!==D&&D.selectionTransform(_,S)}}}(a,r),r._dirtyType!==Nr&&(i?function(v,b){const _=b._dirtyLeaves,S=v._nodeMap;for(const A of _){const E=S.get(A);ee(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Ba(E)}}(a,r):function(v,b){const _=b._dirtyLeaves,S=b._dirtyElements,A=v._nodeMap,E=hr(),w=new Map;let D=_,R=D.size,k=S,N=k.size;for(;R>0||N>0;){if(R>0){b._dirtyLeaves=new Set;for(const j of D){const F=A.get(j);ee(F)&&F.isAttached()&&F.isSimpleText()&&!F.isUnmergeable()&&Ba(F),F!==void 0&&ol(F,E)&&il(b,F,w),_.add(j)}if(D=b._dirtyLeaves,R=D.size,R>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const j of k){const F=j[0],C=j[1];if(F!=="root"&&!C)continue;const M=A.get(F);M!==void 0&&ol(M,E)&&il(b,M,w),S.set(F,C)}D=b._dirtyLeaves,R=D.size,k=b._dirtyElements,N=k.size,ws++}b._dirtyLeaves=_,b._dirtyElements=S}(a,r),ll(r),function(v,b,_,S){const A=v._nodeMap,E=b._nodeMap,w=[];for(const[D]of S){const R=E.get(D);R!==void 0&&(R.isAttached()||(z(R)&&Uu(R,D,A,E,w,S),A.has(D)||S.delete(D),w.push(D)))}for(const D of w)E.delete(D);for(const D of _){const R=E.get(D);R===void 0||R.isAttached()||(A.has(D)||_.delete(D),E.delete(D))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(G(x)){const v=a._nodeMap,b=x.anchor.key,_=x.focus.key;v.get(b)!==void 0&&v.get(_)!==void 0||K(19)}else Wt(x)&&x._nodes.size===0&&(a._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{at=c,St=d,lt=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const v=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(v))return!0}else if(v!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&hh(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Et(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&K(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&K(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&K(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Vn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let l=e.getIndexWithinParent();for(let a=0;a<o.length;a++){const u=i[a],c=o[a];if(u===void 0||u<c)break;if(u>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&K(225),t.reverse()}class lr extends hi{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return nh[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=Ze()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(ee(t)&&e.push(t),z(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;z(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;z(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const i=t[n-1];return z(i)&&i.getLastDescendant()||i||null}const s=t[e];return z(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:ht(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&K(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:ht(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&K(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContent(),z(i)&&s!==n-1&&!i.isInline()&&(e+=sr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),z(i)&&s!==n-1&&!i.isInline()&&(e+=sr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){wt();const n=ue();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(ee(a)||z(a))return a.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const a=this.getLastChild();if(ee(a)||z(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return G(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):ac(l,s,l,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Aa[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||K(226,String(e),String(t),String(i));const l=o.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,f=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&K(100);const x=g.getNextSibling(),v=g.__key;Dr(g.getWritable()),u.push(v),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===l&&f--,Dr(x);const v=m.__key;if(p===null)o.__first=v,x.__prev=null;else{const b=p.getWritable();b.__next=v,x.__prev=b.__key}m.__key===l&&K(76),x.__parent=l,a.push(v),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=f,u.length){const g=ue();if(G(g)){const m=new Set(u),x=new Set(a),{anchor:v,focus:b}=g;cl(v,m,x)&&Hs(v,v.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),f!==0||this.canBeEmpty()||Yt(this)||this.remove()}}return o}getDOMSlot(e){return new Mn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function z(r){return r instanceof lr}function cl(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class ra extends hi{constructor(e){super(e)}decorate(e,t){K(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function $e(r){return r instanceof ra}class ts extends lr{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){K(51)}getTextContent(){const e=this.__cachedText;return!es()&&Ze()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){K(52)}replace(e){K(53)}insertBefore(e){K(54)}insertAfter(e){K(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];z(n)||$e(n)||K(56)}return super.append(...e)}static importJSON(e){const t=Qe();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function mt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&K(130,t.name),z(r)){const n=e.children;Array.isArray(n)||K(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(Qe())}))}}class sa extends lr{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends lr{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:qh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=nt();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=nt();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||ee(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function qh(r){const e=nt();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function nt(){return Jt(new on)}function tn(r){return r instanceof on}const Pe=0,Vr=1,Uh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Wh(r){const e=r||{},t=Oh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),l=e.namespace||(s!==null?s._config.namespace:Ou()),a=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,f=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],v=null,b=null;if(typeof x!="function"){const E=x;x=E.replace,v=E.with,b=E.withKlass||null}const _=x.getType(),S=x.transform(),A=new Set;S!==null&&A.add(S),p.set(_,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:v,replaceWithKlass:b,transforms:A})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const v=new Map,b=new Set,_=S=>{Object.keys(S).forEach(A=>{let E=v.get(A);E===void 0&&(E=[],v.set(A,E)),E.push(S[A])})};return m.forEach(S=>{const A=S.klass.importDOM;if(A==null||b.has(A))return;b.add(A);const E=A.call(S.klass);E!==null&&_(E)}),x&&_(x),v}(p,d?d.import:void 0),f);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ou(),this._onError=i,this._htmlConversions=o,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&K(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&K(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&K(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Ch(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const a=this.registerNodeTransformToKlass(i,t);s.push(a)}var o,l;return o=this,l=e.getType(),Et(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void Qe().markDirty();const u=a._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(a=>a.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return oe(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Ah(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(l){const a=l.ownerDocument;return a&&a.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(l,a){const u=l.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=tc(l);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Va(x))return;Ha(x);const v=a.isEditable();switch(p){case"cut":return v&&oe(a,Ro,x);case"copy":return oe(a,ii,x);case"paste":return v&&oe(a,si,x);case"dragstart":return v&&oe(a,Su,x);case"dragover":return v&&oe(a,ku,x);case"dragend":return v&&oe(a,Of,x);case"focus":return v&&oe(a,Uf,x);case"blur":return v&&oe(a,Wf,x);case"drop":return v&&oe(a,Cu,x)}};l.addEventListener(p,m),d.push(()=>{l.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&K(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),pr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||pr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),l=at,a=St,u=lt,c=s._dirtyElements,d=s._dirtyLeaves,f=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,at=o,St=!1,lt=s;try{const g=s._nodes;ta(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=f,s._dirtyType=p,at=l,St=a,lt=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return pr(this),this.getEditorState().read(e,{editor:this})}update(e,t){Et(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Et(this,()=>{const s=ue(),i=Qe();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Bt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Hh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Vh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=Nf(null,n),c=Wh({editable:r.editable,html:a,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,f){if(f!==null){if(f===void 0)d.update(()=>{const p=Qe();if(p.isEmpty()){const g=nt();p.append(g);const m=yc?document.activeElement:null;(ue()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,ds);break}case"object":d.setEditorState(f,ds);break;case"function":d.update(()=>{Qe().isEmpty()&&f(d)},ds)}}}(c,l),[c,u]},[]);return Hh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(pu.Provider,{value:t,children:e})}const Gh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Kh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Yh(){return function(r){const[e]=Ot(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Gh(()=>{const{initialValueFn:o,subscribe:l}=t,a=o();return i.current!==a&&(i.current=a,s(a)),l(u=>{i.current=u,s(u)})},[t,r]),n}(Kh)}function Qh(){return Qe().getTextContent()}function Jh(r,e=!0){if(r)return!1;let t=Qh();return e&&(t=t.trim()),t===""}function Xh(r){if(!Jh(r,!1))return!1;const e=Qe().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if($e(s))return!1;if(z(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let l=0;l<o;l++){const a=i[n];if(!ee(a))return!1}}}return!0}function xc(r){return()=>Xh(r)}function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Zh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var tp=ep(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const rp=new Map;function np(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),l=s.getNode(),a=e.is(o),u=e.is(l);if(a||u){const[c,d]=uo(r),f=o.is(l),p=e.is(i?l:o),g=e.is(i?o:l);let m,x=0;return f?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function sp(r){const e=r.getStyle(),t=np(e);rp.set(e,t)}function ip(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),l=Qe(),a=l.getFirstChild();return void(a?a.replace(o,!0):l.append(o))}const s=r.getNodes(),i=n!==null&&function(o,l){let a=o;for(;a!==null&&a.getParent()!==null&&!l(a);)a=a.getParentOrThrow();return l(a)?a:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const l=s[o];if(!hl(l))continue;z(l)||tp(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function dl(r,e){const t=Pn(r.focus,e);return $e(t)&&!t.isIsolated()||z(t)&&!t.isInline()&&!t.canBeEmpty()}function op(r,e,t,n){r.modify(e?"extend":"move",t,n)}function ap(r){const e=r.anchor.getNode();return(mt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=ap(r);op(r,e,t?!n:n,"character")}function hl(r){if($e(r)||!z(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function lp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var up=lp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||cp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function dp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function fp(r){const e=yi(r,t=>z(t)&&!t.isInline());return z(e)||up(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Qe()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function gr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function hp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const l=o.payload;if(l&&l.functionId==="makeChanges"){const a=l.args;if(a){const[u,c,d,f,p,g]=a;r.update(()=>{const m=ue();if(G(m)){const x=m.anchor;let v=x.getNode(),b=0,_=0;if(ee(v)&&u>=0&&c>=0&&(b=u,_=u+c,m.setTextNodeRange(v,b,v,_)),b===_&&d===""||(m.insertRawText(d),v=x.getNode()),ee(v)){b=f,_=f+p;const S=v.getTextContentSize();b=b>S?S:b,_=_>S?S:_,m.setTextNodeRange(v,b,v,_)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const l=Dc(o,r,s,!1);l!==null&&(n=n.concat(l))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const l=o.getChildren();for(const a of l)o.insertBefore(a);o.remove()}}(s),n}function Sc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Qe().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=z(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=ee(p)&&n!==null?bc(n,p):p,o=p}const l=z(o)?o.getChildren():[],a=r._nodes.get(o.getType());let u;u=a&&a.exportDOM!==void 0?a.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const f=document.createDocumentFragment();for(let p=0;p<l.length;p++){const g=l[p],m=kc(r,g,f,n);!s&&z(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||Oa(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,v=m._htmlConversions.get(x.toLowerCase());let b=null;if(v!==void 0)for(const _ of v){const S=_(g);S!==null&&(b===null||(b.priority||0)<=(S.priority||0))&&(b=S)}return b!==null?b.conversion:null}(r,e),u=a?a(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(l=Array.isArray(g)?g[g.length-1]:g,l!==null){for(const[,m]of s)if(l=m(l,i),!l)break;l&&o.push(...Array.isArray(g)?g:[l])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const p=(l==null||!Yt(l))&&(l!=null&&co(l)||n);for(let g=0;g<d.length;g++)f.push(...Dc(d[g],e,t,p,new Map(s),l));return c!=null&&(f=c(f)),zs(r)&&(f=pp(r,f,p?()=>{const g=new sa;return t.push(g),g}:nt)),l==null?f.length>0?o=o.concat(f):zs(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):z(l)&&l.append(...f),o}function pp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const l=e[o];if(co(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(i.push(l),o===e.length-1||o<e.length-1&&co(e[o+1])){const a=t();a.setFormat(n),a.append(...i),s.push(a),i=[]}}return s}function gp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=gp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function mp(r,e=ue()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function yp(r,e=ue()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(xp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,bp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:a=>a}).createHTML(l):l}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(G(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let l=0;l<o.length;l++){const a=ue();if(G(a)){const u=o[l];u===`
93
+ `?n.push(Mr()):o===" "?n.push(Xn()):n.push(it(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,l=t),o.type==="element"&&function(x,v,b,_){const S=x.getNode(),A=S.getChildAtIndex(x.offset),E=it(),w=mt(S)?nt().append(E):E;E.setFormat(b),E.setStyle(_),A===null?S.append(w):A.insertBefore(w),x.is(v)&&v.set(E.__key,0,"text"),x.set(E.__key,0,"text")}(o,l,s,i);const a=o.offset;let u=l.offset;const c=this.getNodes(),d=c.length;let f=c[0];Z(f)||K(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=p,l.set(o.key,u,"text")),this.isCollapsed()&&a===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(Z(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=it(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?f.insertAfter(x):g.insertAfter(x)),x.select(0,0),f=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(Z(x)&&!Cr(x)||(x=it(),x.setFormat(s),g.canInsertTextBefore()?f.insertBefore(x):g.insertBefore(x)),x.select(),f=x,e!=="")return void this.insertText(e)}else if(f.isSegmented()&&a!==p){const x=it(f.getTextContent());x.setFormat(s),f.replace(x),f=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||z(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const _=it(e);return _.select(),void f.replace(_)}const x=f.getFormat(),v=f.getStyle();if(a!==u||x===s&&v===i){if(Fh(f)){const _=it(e);return _.setFormat(s),_.setStyle(i),_.select(),void f.replace(_)}}else{if(f.getTextContent()!==""){const _=it(e);if(_.setFormat(s),_.setStyle(i),_.select(),a===0)f.insertBefore(_,!1);else{const[S]=f.splitText(a);S.insertAfter(_,!1)}return void(_.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const b=u-a;f=f.spliceText(a,b,e,!0),f.getTextContent()===""?f.remove():this.anchor.type==="text"&&(f.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=v))}else{const x=new Set([...f.getParentKeys(),...m.getParentKeys()]),v=z(f)?f:f.getParentOrThrow();let b=z(m)?m:m.getParentOrThrow(),_=m;if(!v.is(b)&&b.isInline())do _=b,b=b.getParentOrThrow();while(b.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(Z(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const D=it(m.getTextContent());m.replace(D),m=D}mt(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const D=m.getParentOrThrow();D.canBeEmpty()||D.getChildrenSize()!==1?m.remove():D.remove()}else x.add(m.__key);const S=b.getChildren(),A=new Set(c),E=v.is(b),w=v.isInline()&&f.getNextSibling()===null?v:f;for(let D=S.length-1;D>=0;D--){const R=S[D];if(R.is(f)||z(R)&&R.isParentOf(f))break;R.isAttached()&&(!A.has(R)||R.is(_)?E||w.insertAfter(R,!1):R.remove())}if(!E){let D=b,R=null;for(;D!==null;){const k=D.getChildren(),N=k.length;(N===0||k[N-1].is(R))&&(x.delete(D.__key),R=D),D=D.getParent()}}if(f.isToken())if(a===p)f.select();else{const D=it(e);D.select(),f.replace(D)}else f=f.spliceText(a,p-a,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let D=1;D<d;D++){const R=c[D],k=R.__key;x.has(k)||R.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),l=i.getNode();const a=pn(o,cr),u=pn(l,cr);Z(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&Z(l)&&l.isToken()&&(i.offset=l.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(l,d)||d.getKey()===o.getKey()||d.getKey()===l.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=it(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&Z(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(Z(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}Z(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&Z(o)?o.selectEnd():l.isAttached()&&Z(l)&&l.selectStart(),z(a)&&z(u)&&a!==u&&(a.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ut(null);const n=this.getNodes(),s=[];for(const S of n)Z(S)&&s.push(S);const i=S=>{n.forEach(A=>{if(tn(A)){const E=A.getFormatFlags(e,S);A.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),ut(null),void i(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let f=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(f=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let v=s[x];const b=d.type==="text"?d.offset:v.getTextContentSize();if(p.is(v)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,b),A=g===0?S[0]:S[1];A.setFormat(m),c.type==="text"&&c.set(A.__key,0,"text"),d.type==="text"&&d.set(A.__key,b-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const _=v.getFormatFlags(e,m);b>0&&(b===v.getTextContentSize()||Cr(v)||([v]=v.splitText(b)),v.setFormat(_));for(let S=f+1;S<x;S++){const A=s[S],E=A.getFormatFlags(e,_);A.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(v.__key,b,"text"),this.format=m|_}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ue();return G(g)||K(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,cr),s=e[e.length-1];if(z(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=zi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(z(g)||$e(g))&&!g.isInline())){z(n)||K(211,t.constructor.name,t.getType());const g=zi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=nt();let x=null;for(let v=0;v<g.length;v++){const b=g[v],_=Ar(b);if(_||$e(b)&&b.isInline()||z(b)&&b.isInline()||Z(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),_))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),l=i.getChildren(),a=!z(n)||!n.isEmpty()?this.insertParagraph():null,u=l[l.length-1];let c=l[0];var d;z(d=c)&&cr(d)&&!d.isEmpty()&&z(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(z(n)||K(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&K(212,t.constructor.name,t.getType()),function(g,m,x){const v=m.getParentOrThrow().getLastChild();let b=m;const _=[m];for(;b!==v;)b.getNextSibling()||K(140),b=b.getNextSibling(),_.push(b);let S=g;for(const A of _)S=S.insertAfter(A)}(n,c));const f=pn(o,cr);a&&z(f)&&(a.canMergeWhenEmpty()||cr(u))&&(f.append(...a.getChildren()),a.remove()),z(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=z(n)?n.getLastChild():null;Ar(p)&&f!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=nt();return Qe().splice(this.anchor.offset,0,[o]),o.select(),o}const e=zi(this),t=pn(this.anchor.getNode(),cr);z(t)||K(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],l=e[n];const[a,u]=uo(this);if(t===0)return[];if(t===1){if(Z(o)&&!this.isCollapsed()){const d=a>u?u:a,f=a>u?a:u,p=o.splitText(d,f),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(Z(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(Z(l)){const d=l.getTextContent().length,f=c?u:a;f===0?e.pop():f!==d&&([l]=l.splitText(f),e[n]=l)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",l=Pn(s,t);if($e(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=tl();return p.add(l.__key),void Kt(p)}const f=t?l.getPreviousSibling():l.getNextSibling();if(Z(f)){const p=f.__key,g=t?f.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=l.getParentOrThrow();let g,m;return z(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=l.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const a=Ze(),u=Bt(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!z(l)||l.isInline()||l.canBeEmpty()||Qo(c,a,d),function(f,p,g,m){f.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const f=u.getRangeAt(0),p=this.anchor.getNode(),g=mt(p)?p:xh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let v=!1;for(let b=0;b<m.length;b++){const _=m[b];Tn(_,g)?x.push(_):v=!0}if(v&&x.length>0)if(t){const b=x[0];z(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];z(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(b){const _=b.focus,S=b.anchor,A=S.key,E=S.offset,w=S.type;dr(S,_.key,_.offset,_.type),dr(_,A,E,w),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&z(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if(z(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const i=this.focus,o=Pn(i,e);if($e(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&z(s)&&s.getChildrenSize()===0){s.remove();const l=tl();l.add(o.__key),Kt(l)}else o.remove(),Ze().dispatchCommand(Bo,void 0);return}if(!e&&z(o)&&z(s)&&s.isEmpty())return s.remove(),void o.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const l=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const a=i.offset,u=l.getTextContentSize();if(l.is(s)||e&&a!==u||!e&&a!==0)return void Xa(l,e,a)}else if(s!==null&&s.isSegmented()){const a=n.offset,u=s.getTextContentSize();if(s.is(l)||e&&a!==0||!e&&a!==u)return void Xa(s,e,a)}(function(a,u){const c=a.anchor,d=a.focus,f=c.getNode(),p=d.getNode();if(f===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,v=x?g:m,b=x?m:g,_=b-1;v!==_&&(zu(f.getTextContent().slice(v,b))||(u?d.offset=_:c.offset=_))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&mt(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Wt(r){return r instanceof pi}function Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,l=0;for(let u=0;u<i;u++){const c=u===i-1;if(l=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(l=void 0);break}}const a=s.join("").trim();a===""?n.remove():(n.setTextContent(a),n.select(l,l))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const l=r.childNodes,a=l.length,u=n._blockCursorElement;i===a&&(o=!0,i=a-1);let c=l[i],d=!1;if(c===u)c=l[i+1],d=!0;else if(u!==null){const f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Hr(c),Z(s))i=Ra(s,o);else{let f=Hr(r);if(f===null)return null;if(z(f)){const p=n.getElementByKey(f.getKey());p===null&&K(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),z(f)||K(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(z(m)&&function(x,v,b){const _=x.getParent();return b===null||_===null||!_.canBeEmpty()||_!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?f=m:(m=x,f=z(m)?m:m.getParentOrThrow()),i=0}Z(m)?(s=m,f=null,i=Ra(m,o)):m!==f&&o&&!d&&(z(f)||K(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&$e(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(z(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return Z(s)?Qt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&z(o)&&o.isInline()){const l=o.getPreviousSibling();Z(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else z(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):Z(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&z(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&z(o)&&o.isInline()&&!o.canInsertTextAfter()){const l=o.getNextSibling();Z(l)&&(r.key=l.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=Ze();if(i.isComposing()&&i._compositionKey!==r.key&&G(t)){const o=t.anchor,l=t.focus;dr(r,o.key,o.offset,o.type),dr(e,l.key,l.offset,l.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,G(i)?i.anchor:null,s);if(o===null)return null;const l=Za(t,n,G(i)?i.focus:null,s);if(l===null)return null;if(o.type==="element"&&l.type==="element"){const a=Hr(r),u=Hr(t);if($e(a)&&$e(u))return null}return ic(o,l,i),[o,l]}function co(r){return z(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=ar(),l=new br(Qt(r,e,s),Qt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Ph(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,l=o==="selectionchange",a=!Qi&&(l||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,f;if(G(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&G(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,G(r)?r.format:0,G(r)?r.style:"")}function ue(){return ar()._selection}function Zn(){return Ze()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),l=i.getNode();if(!e.is(o)&&!e.is(l))return;const a=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(a,c,"element"),i.set(a,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),f=u?s:i,p=f.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(a,Math.max(0,g+n),"element")}if(e.is(p)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(a,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!z(i))return;const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(Z(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(z(i)){const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(Z(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(z(o)){const l=o.getChildrenSize(),a=s>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(s);if(Z(u)){let c=0;a&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,l=null;n!==null?(i=n.__key,Z(n)?(o=n.getTextContentSize(),l="text"):z(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,Z(s)?l="text":z(s)&&(l="element")),i!==null&&l!==null?r.set(i,o,l):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Ih(r,e,t,n,s,i,o){const l=n.anchorNode,a=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!G(e))return void(r!==null&&Kn(t,l,a)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),v=Is(t,m),b=f.offset,_=p.offset,S=e.format,A=e.style,E=e.isCollapsed();let w=x,D=v,R=!1;if(f.type==="text"){w=Fs(x);const M=f.getNode();R=M.getFormat()!==S||M.getStyle()!==A}else G(r)&&r.anchor.type==="text"&&(R=!0);var k,N,j,F,C;if(p.type==="text"&&(D=Fs(v)),w!==null&&D!==null&&(E&&(r===null||R||G(r)&&(r.format!==S||r.style!==A))&&(k=S,N=A,j=b,F=g,C=performance.now(),Xu=[k,N,j,F,C]),u!==b||c!==_||l!==w||a!==D||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(w,b,D,_)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const M=e instanceof br&&e.anchor.type==="element"?w.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(M!==null){let L;if(M instanceof Text){const I=document.createRange();I.selectNode(M),L=I.getBoundingClientRect()}else L=M.getBoundingClientRect();(function(I,W,Q){const re=Q.ownerDocument,U=re.defaultView;if(U===null)return;let{top:Y,bottom:P}=W,ie=0,de=0,fe=Q;for(;fe!==null;){const ge=fe===re.body;if(ge)ie=0,de=di(I).innerHeight;else{const he=fe.getBoundingClientRect();ie=he.top,de=he.bottom}let be=0;if(Y<ie?be=-(ie-Y):P>de&&(be=P-de),be!==0)if(ge)U.scrollBy(0,be);else{const he=fe.scrollTop;fe.scrollTop+=be;const J=fe.scrollTop-he;Y-=J,P-=J}if(ge)break;fe=Yn(fe)}})(t,L,i)}}oo=!0}}function lc(r){let e=ue()||Zn();e===null&&(e=Qe().selectEnd()),e.insertNodes(r)}function zi(r){let e=r;r.isCollapsed()||e.removeText();const t=ue();G(t)&&(e=t),G(e)||K(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=zh(s,i);return i}function zh(r,e){const t=r.getParent();if(!t){const s=nt();return Qe().append(s),s.select(),[Qe(),0]}if(Z(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!z(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new br(Qt(r.__key,e,"element"),Qt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let at=null,lt=null,St=!1,Oi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return St||at!==null&&at._readOnly}function wt(){St&&K(13)}function uc(){ws>99&&K(14)}function ar(){return at===null&&K(195,cc()),at}function Ze(){return lt===null&&K(196,cc()),lt}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function Oh(){return lt}function il(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&K(30,a),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let l=0;l<o&&(i[l](e),e.isAttached());l++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function $h(r){return ta(r,Ze()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&K(17,t);const s=n.klass;r.type!==s.getType()&&K(18,s.name);const i=s.importJSON(r),o=r.children;if(z(i)&&Array.isArray(o))for(let l=0;l<o.length;l++){const a=ta(o[l],e);i.append(a)}return i}function al(r,e,t){const n=at,s=St,i=lt;at=e,St=!0,lt=r;try{return t()}finally{at=n,St=s,lt=i}}function pr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,l=t._selection,a=r._dirtyType!==Nr,u=at,c=St,d=lt,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){lt=r,at=t,St=!1,r._updating=!0;try{const E=r._dirtyType,w=r._dirtyElements,D=r._dirtyLeaves;p.disconnect(),g=Dh(i,t,r,E,w,D)}catch(E){if(E instanceof Error&&r._onError(E),Oi)throw E;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,Oi=!0,pr(r,i),void(Oi=!1)}finally{p.observe(n,sl),r._updating=f,at=u,St=c,lt=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,v=r._normalizedNodes,b=r._updateTags,_=r._deferred;a&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(E,w){const D=E._decorators;let R=E._pendingDecorators||D;const k=w._nodeMap;let N;for(N in R)k.has(N)||(R===D&&(R=Pu(E)),delete R[N])}(r,t);const S=s?null:Bt(r._window);if(r._editable&&S!==null&&(a||l===null||l.dirty)){lt=r,at=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),Ih(o,l,r,S,b,n)}bh(r,n,l),p!==null&&p.observe(n,sl)}finally{lt=d,at=u}}g!==null&&function(E,w,D,R,k){const N=Array.from(E._listeners.mutation),j=N.length;for(let F=0;F<j;F++){const[C,M]=N[F],L=w.get(M);L!==void 0&&C(L,{dirtyLeaves:R,prevEditorState:k,updateTags:D})}}(r,g,b,m,i),G(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Bo,void 0);const A=r._pendingDecorators;A!==null&&(r._decorators=A,r._pendingDecorators=null,jn("decorator",r,!0,A)),function(E,w,D){const R=Ma(w),k=Ma(D);R!==k&&jn("textcontent",E,!0,k)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:v,prevEditorState:e||i,tags:b}),function(E,w){if(E._deferred=[],w.length!==0){const D=E._updating;E._updating=!0;try{for(let R=0;R<w.length;R++)w[R]()}finally{E._updating=D}}}(r,_),function(E){const w=E._updates;if(w.length!==0){const D=w.shift();if(D){const[R,k]=D;hc(E,R,k)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||lt!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const l=o[s];if(l!==void 0){const a=Array.from(l),u=a.length;for(let c=0;c<u;c++)if(a[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let l;if(o!==void 0){if(l=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const a=r._pendingEditorState;a===null&&K(191),a._flushSync=!0}l&&r._deferred.push(l),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let a=r._pendingEditorState,u=!1;(a===null||a._readOnly)&&(a=r._pendingEditorState=pc(a||l),u=!0),a._flushSync=o;const c=at,d=St,f=lt,p=r._updating;at=a,St=!1,r._updating=!0,lt=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(v){const b=v.getEditorState()._selection,_=Bt(v._window);return G(b)||b==null?ea(b,_,v,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(v,b){const _=b.getEditorState()._selection,S=v._selection;if(G(S)){const A=S.anchor,E=S.focus;let w;if(A.type==="text"&&(w=A.getNode(),w.selectionTransform(_,S)),E.type==="text"){const D=E.getNode();w!==D&&D.selectionTransform(_,S)}}}(a,r),r._dirtyType!==Nr&&(i?function(v,b){const _=b._dirtyLeaves,S=v._nodeMap;for(const A of _){const E=S.get(A);Z(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Ba(E)}}(a,r):function(v,b){const _=b._dirtyLeaves,S=b._dirtyElements,A=v._nodeMap,E=hr(),w=new Map;let D=_,R=D.size,k=S,N=k.size;for(;R>0||N>0;){if(R>0){b._dirtyLeaves=new Set;for(const j of D){const F=A.get(j);Z(F)&&F.isAttached()&&F.isSimpleText()&&!F.isUnmergeable()&&Ba(F),F!==void 0&&ol(F,E)&&il(b,F,w),_.add(j)}if(D=b._dirtyLeaves,R=D.size,R>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const j of k){const F=j[0],C=j[1];if(F!=="root"&&!C)continue;const M=A.get(F);M!==void 0&&ol(M,E)&&il(b,M,w),S.set(F,C)}D=b._dirtyLeaves,R=D.size,k=b._dirtyElements,N=k.size,ws++}b._dirtyLeaves=_,b._dirtyElements=S}(a,r),ll(r),function(v,b,_,S){const A=v._nodeMap,E=b._nodeMap,w=[];for(const[D]of S){const R=E.get(D);R!==void 0&&(R.isAttached()||(z(R)&&Uu(R,D,A,E,w,S),A.has(D)||S.delete(D),w.push(D)))}for(const D of w)E.delete(D);for(const D of _){const R=E.get(D);R===void 0||R.isAttached()||(A.has(D)||_.delete(D),E.delete(D))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(G(x)){const v=a._nodeMap,b=x.anchor.key,_=x.focus.key;v.get(b)!==void 0&&v.get(_)!==void 0||K(19)}else Wt(x)&&x._nodes.size===0&&(a._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{at=c,St=d,lt=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const v=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(v))return!0}else if(v!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&hh(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Et(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&K(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&K(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&K(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Vn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let l=e.getIndexWithinParent();for(let a=0;a<o.length;a++){const u=i[a],c=o[a];if(u===void 0||u<c)break;if(u>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&K(225),t.reverse()}class lr extends hi{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return nh[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=Ze()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(Z(t)&&e.push(t),z(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;z(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;z(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const i=t[n-1];return z(i)&&i.getLastDescendant()||i||null}const s=t[e];return z(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:ht(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&K(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:ht(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&K(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContent(),z(i)&&s!==n-1&&!i.isInline()&&(e+=sr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),z(i)&&s!==n-1&&!i.isInline()&&(e+=sr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){wt();const n=ue();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(Z(a)||z(a))return a.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const a=this.getLastChild();if(Z(a)||z(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return G(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):ac(l,s,l,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Aa[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||K(226,String(e),String(t),String(i));const l=o.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,f=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&K(100);const x=g.getNextSibling(),v=g.__key;Dr(g.getWritable()),u.push(v),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===l&&f--,Dr(x);const v=m.__key;if(p===null)o.__first=v,x.__prev=null;else{const b=p.getWritable();b.__next=v,x.__prev=b.__key}m.__key===l&&K(76),x.__parent=l,a.push(v),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=f,u.length){const g=ue();if(G(g)){const m=new Set(u),x=new Set(a),{anchor:v,focus:b}=g;cl(v,m,x)&&Hs(v,v.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),f!==0||this.canBeEmpty()||Yt(this)||this.remove()}}return o}getDOMSlot(e){return new Mn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function z(r){return r instanceof lr}function cl(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class ra extends hi{constructor(e){super(e)}decorate(e,t){K(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function $e(r){return r instanceof ra}class ts extends lr{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){K(51)}getTextContent(){const e=this.__cachedText;return!es()&&Ze()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){K(52)}replace(e){K(53)}insertBefore(e){K(54)}insertAfter(e){K(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];z(n)||$e(n)||K(56)}return super.append(...e)}static importJSON(e){const t=Qe();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function mt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&K(130,t.name),z(r)){const n=e.children;Array.isArray(n)||K(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(Qe())}))}}class sa extends lr{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends lr{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:qh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=nt();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=nt();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||Z(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function qh(r){const e=nt();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function nt(){return Jt(new on)}function tn(r){return r instanceof on}const Pe=0,Vr=1,Uh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Wh(r){const e=r||{},t=Oh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),l=e.namespace||(s!==null?s._config.namespace:Ou()),a=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,f=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],v=null,b=null;if(typeof x!="function"){const E=x;x=E.replace,v=E.with,b=E.withKlass||null}const _=x.getType(),S=x.transform(),A=new Set;S!==null&&A.add(S),p.set(_,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:v,replaceWithKlass:b,transforms:A})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const v=new Map,b=new Set,_=S=>{Object.keys(S).forEach(A=>{let E=v.get(A);E===void 0&&(E=[],v.set(A,E)),E.push(S[A])})};return m.forEach(S=>{const A=S.klass.importDOM;if(A==null||b.has(A))return;b.add(A);const E=A.call(S.klass);E!==null&&_(E)}),x&&_(x),v}(p,d?d.import:void 0),f);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ou(),this._onError=i,this._htmlConversions=o,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&K(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&K(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&K(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Ch(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const a=this.registerNodeTransformToKlass(i,t);s.push(a)}var o,l;return o=this,l=e.getType(),Et(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void Qe().markDirty();const u=a._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(a=>a.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return oe(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Ah(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(l){const a=l.ownerDocument;return a&&a.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(l,a){const u=l.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=tc(l);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Va(x))return;Ha(x);const v=a.isEditable();switch(p){case"cut":return v&&oe(a,Ro,x);case"copy":return oe(a,ii,x);case"paste":return v&&oe(a,si,x);case"dragstart":return v&&oe(a,Su,x);case"dragover":return v&&oe(a,ku,x);case"dragend":return v&&oe(a,Of,x);case"focus":return v&&oe(a,Uf,x);case"blur":return v&&oe(a,Wf,x);case"drop":return v&&oe(a,Cu,x)}};l.addEventListener(p,m),d.push(()=>{l.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&K(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),pr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||pr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),l=at,a=St,u=lt,c=s._dirtyElements,d=s._dirtyLeaves,f=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,at=o,St=!1,lt=s;try{const g=s._nodes;ta(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=f,s._dirtyType=p,at=l,St=a,lt=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return pr(this),this.getEditorState().read(e,{editor:this})}update(e,t){Et(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Et(this,()=>{const s=ue(),i=Qe();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Bt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Hh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Vh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=Nf(null,n),c=Wh({editable:r.editable,html:a,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,f){if(f!==null){if(f===void 0)d.update(()=>{const p=Qe();if(p.isEmpty()){const g=nt();p.append(g);const m=yc?document.activeElement:null;(ue()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,ds);break}case"object":d.setEditorState(f,ds);break;case"function":d.update(()=>{Qe().isEmpty()&&f(d)},ds)}}}(c,l),[c,u]},[]);return Hh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(pu.Provider,{value:t,children:e})}const Gh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Kh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Yh(){return function(r){const[e]=Ot(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Gh(()=>{const{initialValueFn:o,subscribe:l}=t,a=o();return i.current!==a&&(i.current=a,s(a)),l(u=>{i.current=u,s(u)})},[t,r]),n}(Kh)}function Qh(){return Qe().getTextContent()}function Jh(r,e=!0){if(r)return!1;let t=Qh();return e&&(t=t.trim()),t===""}function Xh(r){if(!Jh(r,!1))return!1;const e=Qe().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if($e(s))return!1;if(z(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let l=0;l<o;l++){const a=i[n];if(!Z(a))return!1}}}return!0}function xc(r){return()=>Xh(r)}function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Zh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var tp=ep(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const rp=new Map;function np(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),l=s.getNode(),a=e.is(o),u=e.is(l);if(a||u){const[c,d]=uo(r),f=o.is(l),p=e.is(i?l:o),g=e.is(i?o:l);let m,x=0;return f?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function sp(r){const e=r.getStyle(),t=np(e);rp.set(e,t)}function ip(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),l=Qe(),a=l.getFirstChild();return void(a?a.replace(o,!0):l.append(o))}const s=r.getNodes(),i=n!==null&&function(o,l){let a=o;for(;a!==null&&a.getParent()!==null&&!l(a);)a=a.getParentOrThrow();return l(a)?a:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const l=s[o];if(!hl(l))continue;z(l)||tp(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function dl(r,e){const t=Pn(r.focus,e);return $e(t)&&!t.isIsolated()||z(t)&&!t.isInline()&&!t.canBeEmpty()}function op(r,e,t,n){r.modify(e?"extend":"move",t,n)}function ap(r){const e=r.anchor.getNode();return(mt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=ap(r);op(r,e,t?!n:n,"character")}function hl(r){if($e(r)||!z(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||Z(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function lp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var up=lp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||cp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function dp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function fp(r){const e=yi(r,t=>z(t)&&!t.isInline());return z(e)||up(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Qe()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function gr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function hp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const l=o.payload;if(l&&l.functionId==="makeChanges"){const a=l.args;if(a){const[u,c,d,f,p,g]=a;r.update(()=>{const m=ue();if(G(m)){const x=m.anchor;let v=x.getNode(),b=0,_=0;if(Z(v)&&u>=0&&c>=0&&(b=u,_=u+c,m.setTextNodeRange(v,b,v,_)),b===_&&d===""||(m.insertRawText(d),v=x.getNode()),Z(v)){b=f,_=f+p;const S=v.getTextContentSize();b=b>S?S:b,_=_>S?S:_,m.setTextNodeRange(v,b,v,_)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const l=Dc(o,r,s,!1);l!==null&&(n=n.concat(l))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const l=o.getChildren();for(const a of l)o.insertBefore(a);o.remove()}}(s),n}function Sc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Qe().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=z(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=Z(p)&&n!==null?bc(n,p):p,o=p}const l=z(o)?o.getChildren():[],a=r._nodes.get(o.getType());let u;u=a&&a.exportDOM!==void 0?a.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const f=document.createDocumentFragment();for(let p=0;p<l.length;p++){const g=l[p],m=kc(r,g,f,n);!s&&z(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||Oa(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,v=m._htmlConversions.get(x.toLowerCase());let b=null;if(v!==void 0)for(const _ of v){const S=_(g);S!==null&&(b===null||(b.priority||0)<=(S.priority||0))&&(b=S)}return b!==null?b.conversion:null}(r,e),u=a?a(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(l=Array.isArray(g)?g[g.length-1]:g,l!==null){for(const[,m]of s)if(l=m(l,i),!l)break;l&&o.push(...Array.isArray(g)?g:[l])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const p=(l==null||!Yt(l))&&(l!=null&&co(l)||n);for(let g=0;g<d.length;g++)f.push(...Dc(d[g],e,t,p,new Map(s),l));return c!=null&&(f=c(f)),zs(r)&&(f=pp(r,f,p?()=>{const g=new sa;return t.push(g),g}:nt)),l==null?f.length>0?o=o.concat(f):zs(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):z(l)&&l.append(...f),o}function pp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const l=e[o];if(co(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(i.push(l),o===e.length-1||o<e.length-1&&co(e[o+1])){const a=t();a.setFormat(n),a.append(...i),s.push(a),i=[]}}return s}function gp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=gp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function mp(r,e=ue()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function yp(r,e=ue()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(xp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,bp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:a=>a}).createHTML(l):l}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(G(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let l=0;l<o.length;l++){const a=ue();if(G(a)){const u=o[l];u===`
94
94
  `||u===`\r
95
- `?a.insertParagraph():u===" "?a.insertNodes([Xn()]):a.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(Bf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=z(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=ee(u)&&e!==null?bc(e,u):u,o=u}const l=z(o)?o.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),z(u)){const f=c.children;Array.isArray(f)||Vs(59,d.name)}return c}(o);if(ee(o)){const u=o.__text;u.length>0?a.text=u:s=!1}for(let u=0;u<l.length;u++){const c=l[u],d=Ac(r,e,c,a.children);!s&&z(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(a);else if(Array.isArray(a.children))for(let u=0;u<a.children.length;u++){const c=a.children[u];n.push(c)}return s}function xp(r,e){const t=[],n=Qe().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function bp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=$h(n);ee(s)&&sp(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Bt(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const l=new Range;return l.setStart(o,0),l.setEnd(o,1),i.removeAllRanges(),i.addRange(l),new Promise((a,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),a(yl(r,d,t))),!0),Uh);qr=window.setTimeout(()=>{c(),qr=null,a(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Bt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const l=ue();if(l===null)return!1;t=_p(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(wp(n,t),!0)}const vp=[["text/html",mp],["application/x-lexical-editor",yp]];function _p(r=ue()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=_h();for(const[n,s]of vp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function wp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Cp=an&&"documentMode"in document?document.documentMode:null,Sp=!(!an||!("InputEvent"in window)||Cp)&&"getTargetRanges"in new window.InputEvent("input"),kp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ep=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Dp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ep,vl=Hn();class xi extends lr{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Ap,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=ia();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=nt(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=nt();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Jt(new xi)}class bi extends lr{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?nt():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=nt();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?nt():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Ap(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Jt(new bi(r))}function fs(r){let e=null;if(gr(r,DragEvent)?e=r.dataTransfer:gr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function wl(r){const e=ue();if(!G(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const l=yi(i,u=>z(u)&&!u.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),r(l))}return t.size>0}function hs(r){const e=en(r);return $e(e)}function Tp(r){return Pr(r.registerCommand(gu,e=>{const t=ue();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ue();return!!G(t)&&(t.deleteCharacter(e),!0)},Pe),r.registerCommand(Fn,e=>{const t=ue();return!!G(t)&&(t.deleteWord(e),!0)},Pe),r.registerCommand(Ln,e=>{const t=ue();return!!G(t)&&(t.deleteLine(e),!0)},Pe),r.registerCommand(Yr,e=>{const t=ue();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(G(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Pe),r.registerCommand(Ki,()=>{const e=ue();return!!G(e)&&(e.removeText(),!0)},Pe),r.registerCommand(It,e=>{const t=ue();return!!G(t)&&(t.formatText(e),!0)},Pe),r.registerCommand(zf,e=>{const t=ue();if(!G(t)&&!Wt(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>z(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},Pe),r.registerCommand(Kr,e=>{const t=ue();return!!G(t)&&(t.insertLineBreak(e),!0)},Pe),r.registerCommand(Rn,()=>{const e=ue();return!!G(e)&&(e.insertParagraph(),!0)},Pe),r.registerCommand(Pf,()=>(lc([Xn()]),!0),Pe),r.registerCommand(If,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Pe),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Pe),r.registerCommand(xu,e=>{const t=ue();if(Wt(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(G(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Pe),r.registerCommand(bu,e=>{const t=ue();if(Wt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(G(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Qe().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Pe),r.registerCommand(yu,e=>{const t=ue();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!G(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},Pe),r.registerCommand(mu,e=>{const t=ue();if(Wt(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!G(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},Pe),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ue();if(!G(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!mt(s)&&fp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},Pe),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ue();return!!G(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},Pe),r.registerCommand(Ns,e=>{const t=ue();if(!G(t))return!1;if(e!==null){if((bl||kp||Dp)&&Sp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},Pe),r.registerCommand(_u,()=>{const e=ue();return!!G(e)&&(r.blur(),!0)},Pe),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,l=en(o);if(l!==null){const a=Ph();if(ee(l))a.anchor.set(l.getKey(),i,"text"),a.focus.set(l.getKey(),i,"text");else{const c=l.getParentOrThrow().getKey(),d=l.getIndexWithinParent()+1;a.anchor.set(c,d,"element"),a.focus.set(c,d,"element")}const u=Mu(a);Kt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ue();return!!G(n)},Pe),r.registerCommand(Su,e=>{const[t]=fs(e),n=ue();return!(t&&!G(n))},Pe),r.registerCommand(ku,e=>{const[t]=fs(e),n=ue();if(t&&!G(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);$e(i)&&e.preventDefault()}return!0},Pe),r.registerCommand(Yi,()=>(yh(),!0),Pe),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),Pe),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ue();G(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Pe),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ue()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ue(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&pl(l,o,i)},{tag:"paste"})}(e,r),!0)},Pe))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Np({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=Ot(),s=function(i,o){const[l,a]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{a(u)})}),[i]),y.useEffect(()=>{a(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(y.Suspense,{fallback:null,children:l[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,l,i])}(n,t);return function(i){fo(()=>Pr(Tp(i),hp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Bp,{content:e}),s]})}function Bp({content:r}){const[e]=Ot(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function l(){const a=Cl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=Yh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function jp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:v=!0,style:b,tabIndex:_,"data-testid":S,...A},E){const[w,D]=y.useState(r.isEditable()),R=y.useCallback(N=>{N&&N.ownerDocument&&N.ownerDocument.defaultView?r.setRootElement(N):r.setRootElement(null)},[r]),k=y.useMemo(()=>function(...N){return j=>{N.forEach(F=>{typeof F=="function"?F(j):F!=null&&(F.current=j)})}}(E,R),[R,E]);return Tc(()=>(D(r.isEditable()),r.registerEditableListener(N=>{D(N)})),[r]),h.jsx("div",{"aria-activedescendant":w?e:void 0,"aria-autocomplete":w?t:"none","aria-controls":w?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":w&&x==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":w?d:void 0,"aria-readonly":!w||void 0,"aria-required":f,autoCapitalize:p,className:g,contentEditable:w,"data-testid":S,id:m,ref:k,role:w?x:void 0,spellCheck:v,style:b,tabIndex:_,...A})}const Mp=y.forwardRef(jp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Rp=y.forwardRef(Fp);function Fp(r,e){const{placeholder:t,...n}=r,[s]=Ot();return h.jsxs(h.Fragment,{children:[h.jsx(Mp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Lp,{editor:s,content:t})]})}function Lp({content:r,editor:e}){const t=function(o){const[l,a]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:h.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Ft=0,Pp=1,kl=2,Ip=3,zp=4;function Op(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ft;const i=e._selection,o=r._selection;if(s)return Pp;if(!(G(i)&&G(o)&&o.isCollapsed()&&i.isCollapsed()))return Ft;const l=function(v,b,_){const S=v._nodeMap,A=[];for(const E of b){const w=S.get(E);w!==void 0&&A.push(w)}for(const[E,w]of _){if(!w)continue;const D=S.get(E);D===void 0||mt(D)||A.push(D)}return A}(e,t,n);if(l.length===0)return Ft;if(l.length>1){const v=e._nodeMap,b=v.get(i.anchor.key),_=v.get(o.anchor.key);return b&&_&&!r._nodeMap.has(b.__key)&&ee(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Ft}const a=l[0],u=r._nodeMap.get(a.__key);if(!ee(u)||!ee(a)||u.__mode!==a.__mode)return Ft;const c=u.__text,d=a.__text;if(c===d)return Ft;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Ft;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?Ip:x===-1&&m===g?zp:Ft}function $p(r,e){let t=Date.now(),n=Ft;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=Ft,t=c,po;const d=Op(s,i,l,a,r.isComposing()),f=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return ps;if(s===null)return ho;const m=i._selection;return l.size>0||a.size>0?g===!1&&d!==Ft&&d===n&&c<t+e&&p||l.size===1&&function(x,v,b){const _=v._nodeMap.get(x),S=b._nodeMap.get(x),A=v._selection,E=b._selection;return!(G(A)&&G(E)&&A.anchor.type==="element"&&A.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!ee(_)||!ee(S)||_.__parent!==S.__parent)&&JSON.stringify(v.read(()=>_.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(l)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function qp(r,e,t){const n=$p(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(a.length!==0){const u=o.current,c=a.pop();u!==null&&(l.push(u),i.dispatchCommand(as,!0)),a.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Pe),r.registerCommand(Mo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(l.length!==0){const u=o.current;u!==null&&(a.push(u),i.dispatchCommand(ls,!0));const c=l.pop();l.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Pe),r.registerCommand($f,()=>(El(e),!1),Pe),r.registerCommand(qf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),Pe),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,l,a,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(as,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Up(){return{current:null,redoStack:[],undoStack:[]}}function Wp({delay:r,externalHistoryState:e}){const[t]=Ot();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Up(),[s]);y.useEffect(()=>qp(n,o,i),[i,n,o])}(t,e,r),null}const Hp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Vp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=Ot();return Hp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:l,tags:a})=>{e&&i.size===0&&o.size===0||r&&a.has("history-merge")||l.isEmpty()||t(s,n,a)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Gp=function(r){var e,t;function n(){for(var i,o=arguments.length,l=new Array(o),a=0;a<o;a++)l[a]=arguments[a];return(i=r.call.apply(r,[this].concat(l))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,go(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(Dl)},s.componentDidCatch=function(i,o){var l,a;(l=(a=this.props).onError)==null||l.call(a,i,o)},s.componentDidUpdate=function(i,o){var l,a,u,c,d=this.state.error,f=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=f)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((l=(a=this.props).onResetKeysChange)==null||l.call(a,i.resetKeys,f),this.reset())},s.render=function(){var i=this.state.error,o=this.props,l=o.fallbackRender,a=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof l=="function")return l(c);if(a)return ki.createElement(a,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Kp({children:r,onError:e}){return h.jsx(Gp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Yp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Yp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Qp(r){let e=1,t=r.getParent();for(;t!=null;){if(Xe(t)){const n=t.getParent();if(Fe(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Fe(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Fe(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(Xe);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Fe(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Vt(r){return Xe(r)&&Fe(r.getFirstChild())}function Al(r){return Dt().append(r)}function Bc(r,e){return Xe(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ue();if(t!==null){const n=t.getNodes();if(G(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Bc(l,n)){const u=kt(e);if(Yt(a)){l.replace(u);const c=Dt();z(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Xe(l)){const c=l.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!z(o)||!o.isEmpty()||Xe(o)||s.has(o.getKey())){if(Fu(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(Fe(l)){if(!s.has(a)){const u=kt(e);Rr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Yt(u)&&!s.has(a)){s.add(a),Nl(l,e);break}l=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Fe(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Dt();let i;if(Rr(s,r.getChildren()),Fe(t)&&e===t.getListType())t.append(s),Fe(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(Fe(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=kt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Jp(r){r.update(()=>{const e=ue();if(G(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const l=dp(o,Ir);l!=null&&t.add(mo(l))}}for(const i of t){let o=i;const l=Nc(i);for(const a of l){const u=nt();Rr(u,a.getChildren()),o.insertAfter(u),o=u,a.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),a.remove()}i.remove()}}})}function Xp(r){const e=new Set;if(Vt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Vt(n)&&Vt(s)){const i=s.getFirstChild();if(Fe(i)){i.append(r);const o=n.getFirstChild();Fe(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Fe(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Fe(i)&&i.append(r)}else if(Fe(t)){const i=Dt(),o=kt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Zp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Fe(t?t.getParent():void 0)&&Xe(t)&&Fe(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const i=e.getListType(),o=Dt(),l=kt(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=Dt(),u=kt(i);a.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function eg(){const r=ue();if(!G(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Xe(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Fe(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=nt(),t.insertAfter(i);else{if(!Xe(s))return!1;i=Dt(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=kt(n.getListType());if(tn(i))i.insertAfter(l);else{const a=Dt();a.append(l),i.insertAfter(a)}o.forEach(a=>{a.remove(),l.append(a)})}return function(l){let a=l;for(;a.getNextSibling()==null&&a.getPreviousSibling()==null;){const u=a.getParent();if(u==null||!Xe(a)&&!Fe(a))break;a=u}a.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Ir extends lr{static getType(){return"listitem"}static clone(e){return new Ir(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return Fe(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Fe(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(Xe(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Fe(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tg,priority:0})}}static importJSON(e){const t=Dt();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(z(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(Xe(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Fe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=kt(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&(z(e)||Ht(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Fe(n)||Ht(39),Xe(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=kt(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Dt(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=nt();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Xe(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,l=e.focus,a=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(a,o.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(a,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Fe(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;Xe(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ht(117),(e=Math.floor(e))>=0||Ht(199);let t=this.getIndent();for(;t!==e;)t<e?(Xp(this),t++):(Zp(this),t--);return this}canInsertAfter(e){return Xe(e)}canReplaceWith(e){return Xe(e)}canMergeWith(e){return tn(e)||Xe(e)}extractWithChild(e,t){if(!G(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return kt("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let l;if(i&&i.nested&&(l=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const a=t.getParent(),u=Fe(a)&&a.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(l!==void 0){const a=Gs(l);t.getChildren().some(u=>Fe(u))?n.push(...a):s.push(...a)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){Fe(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function tg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return rg(t)}const e=r.getAttribute("aria-checked");return{node:Dt(e==="true"||e!=="false"&&void 0)}}function rg(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Dt(r.hasAttribute("checked"))}}function Dt(r){return Jt(new Ir(void 0,r))}function Xe(r){return r instanceof Ir}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{Fe(e)||Ht(163),function(t){const n=t.getNextSibling();Fe(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())Xe(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Fe(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=kt(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&or(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(Xe(n))super.append(n);else{const s=Dt();if(Fe(n))s.append(n);else if(z(n))if(n.isInline())s.append(n);else{const i=it(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Xe(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Qp(t)-1,a=l%o.length,u=o[a],c=i[t.__tag];let d;const f=i.nested,p=i.checklist;if(f!==void 0&&f.list&&(d=f.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==a&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);l>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function ng(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Xe(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Fe(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=kt("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(or(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?kt("check"):kt("bullet")),{after:ng,node:t}}const Fl={ol:"number",ul:"bullet"};function kt(r,e=1){return Jt(new ln(r,e))}function Fe(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),sg=Hn();function ig(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(sg,()=>(Jp(r),!0),Vr),r.registerCommand(Rn,()=>!!eg(),Vr))}function og(){const[r]=Ot();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>ig(e),[e])}(r),null}const ag=new Set(["http:","https:","mailto:","sms:","tel:"]);class zr extends lr{static getType(){return"link"}static clone(e){return new zr(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),rs(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:lg,priority:1})}}static importJSON(e){const t=Ks(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!ag.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Ks(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!G(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function lg(r){let e=null;if(vh(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Jt(new zr(r,e))}function mn(r){return r instanceof zr}class ns extends zr{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new ns(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=Ll(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(z(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Jt(new ns(r,e))}function ug(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ue();if(!G(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!ug(u)&&mn(u));if(a){const u=a.getChildren();for(let c=0;c<u.length;c++)a.insertBefore(u[c]);a.remove()}});else{if(o.length===1){const u=function(c,d){let f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let l=null,a=null;o.forEach(u=>{const c=u.getParent();if(c!==a&&c!==null&&(!z(u)||u.isInline())){if(mn(c))return a=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n));if(c.is(l)||(l=c,a=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(a):c.insertAfter(a):u.insertBefore(a)),mn(u)){if(u.is(a))return;if(a!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function cg({validateUrl:r,attributes:e}){const[t]=Ot();return y.useEffect(()=>{if(!t.hasNodes([zr]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:l}=n;return $i(s,{...e,rel:o,target:i,title:l}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ue();if(!G(s)||s.isCollapsed()||!gr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(l=>z(l))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function dg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function fg({src:r,alt:e,width:t,height:n}){return h.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class vi extends ra{constructor(t,n,s,i,o){super(o);_t(this,"__src");_t(this,"__altText");_t(this,"__width");_t(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new vi(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Rc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:dg,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return h.jsx(fg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var hg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?hg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
95
+ `?a.insertParagraph():u===" "?a.insertNodes([Xn()]):a.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(Bf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=z(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=Z(u)&&e!==null?bc(e,u):u,o=u}const l=z(o)?o.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),z(u)){const f=c.children;Array.isArray(f)||Vs(59,d.name)}return c}(o);if(Z(o)){const u=o.__text;u.length>0?a.text=u:s=!1}for(let u=0;u<l.length;u++){const c=l[u],d=Ac(r,e,c,a.children);!s&&z(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(a);else if(Array.isArray(a.children))for(let u=0;u<a.children.length;u++){const c=a.children[u];n.push(c)}return s}function xp(r,e){const t=[],n=Qe().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function bp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=$h(n);Z(s)&&sp(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Bt(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const l=new Range;return l.setStart(o,0),l.setEnd(o,1),i.removeAllRanges(),i.addRange(l),new Promise((a,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),a(yl(r,d,t))),!0),Uh);qr=window.setTimeout(()=>{c(),qr=null,a(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Bt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const l=ue();if(l===null)return!1;t=_p(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(wp(n,t),!0)}const vp=[["text/html",mp],["application/x-lexical-editor",yp]];function _p(r=ue()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=_h();for(const[n,s]of vp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function wp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Cp=an&&"documentMode"in document?document.documentMode:null,Sp=!(!an||!("InputEvent"in window)||Cp)&&"getTargetRanges"in new window.InputEvent("input"),kp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ep=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Dp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ep,vl=Hn();class xi extends lr{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Ap,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=ia();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=nt(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=nt();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Jt(new xi)}class bi extends lr{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?nt():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=nt();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?nt():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Ap(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Jt(new bi(r))}function fs(r){let e=null;if(gr(r,DragEvent)?e=r.dataTransfer:gr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function wl(r){const e=ue();if(!G(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const l=yi(i,u=>z(u)&&!u.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),r(l))}return t.size>0}function hs(r){const e=en(r);return $e(e)}function Tp(r){return Pr(r.registerCommand(gu,e=>{const t=ue();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ue();return!!G(t)&&(t.deleteCharacter(e),!0)},Pe),r.registerCommand(Fn,e=>{const t=ue();return!!G(t)&&(t.deleteWord(e),!0)},Pe),r.registerCommand(Ln,e=>{const t=ue();return!!G(t)&&(t.deleteLine(e),!0)},Pe),r.registerCommand(Yr,e=>{const t=ue();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(G(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Pe),r.registerCommand(Ki,()=>{const e=ue();return!!G(e)&&(e.removeText(),!0)},Pe),r.registerCommand(It,e=>{const t=ue();return!!G(t)&&(t.formatText(e),!0)},Pe),r.registerCommand(zf,e=>{const t=ue();if(!G(t)&&!Wt(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>z(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},Pe),r.registerCommand(Kr,e=>{const t=ue();return!!G(t)&&(t.insertLineBreak(e),!0)},Pe),r.registerCommand(Rn,()=>{const e=ue();return!!G(e)&&(e.insertParagraph(),!0)},Pe),r.registerCommand(Pf,()=>(lc([Xn()]),!0),Pe),r.registerCommand(If,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Pe),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Pe),r.registerCommand(xu,e=>{const t=ue();if(Wt(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(G(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Pe),r.registerCommand(bu,e=>{const t=ue();if(Wt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(G(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Qe().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Pe),r.registerCommand(yu,e=>{const t=ue();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!G(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},Pe),r.registerCommand(mu,e=>{const t=ue();if(Wt(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!G(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},Pe),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ue();if(!G(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!mt(s)&&fp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},Pe),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ue();return!!G(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},Pe),r.registerCommand(Ns,e=>{const t=ue();if(!G(t))return!1;if(e!==null){if((bl||kp||Dp)&&Sp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},Pe),r.registerCommand(_u,()=>{const e=ue();return!!G(e)&&(r.blur(),!0)},Pe),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,l=en(o);if(l!==null){const a=Ph();if(Z(l))a.anchor.set(l.getKey(),i,"text"),a.focus.set(l.getKey(),i,"text");else{const c=l.getParentOrThrow().getKey(),d=l.getIndexWithinParent()+1;a.anchor.set(c,d,"element"),a.focus.set(c,d,"element")}const u=Mu(a);Kt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ue();return!!G(n)},Pe),r.registerCommand(Su,e=>{const[t]=fs(e),n=ue();return!(t&&!G(n))},Pe),r.registerCommand(ku,e=>{const[t]=fs(e),n=ue();if(t&&!G(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);$e(i)&&e.preventDefault()}return!0},Pe),r.registerCommand(Yi,()=>(yh(),!0),Pe),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),Pe),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ue();G(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Pe),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ue()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ue(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&pl(l,o,i)},{tag:"paste"})}(e,r),!0)},Pe))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Np({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=Ot(),s=function(i,o){const[l,a]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{a(u)})}),[i]),y.useEffect(()=>{a(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(y.Suspense,{fallback:null,children:l[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,l,i])}(n,t);return function(i){fo(()=>Pr(Tp(i),hp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Bp,{content:e}),s]})}function Bp({content:r}){const[e]=Ot(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function l(){const a=Cl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=Yh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function jp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:v=!0,style:b,tabIndex:_,"data-testid":S,...A},E){const[w,D]=y.useState(r.isEditable()),R=y.useCallback(N=>{N&&N.ownerDocument&&N.ownerDocument.defaultView?r.setRootElement(N):r.setRootElement(null)},[r]),k=y.useMemo(()=>function(...N){return j=>{N.forEach(F=>{typeof F=="function"?F(j):F!=null&&(F.current=j)})}}(E,R),[R,E]);return Tc(()=>(D(r.isEditable()),r.registerEditableListener(N=>{D(N)})),[r]),h.jsx("div",{"aria-activedescendant":w?e:void 0,"aria-autocomplete":w?t:"none","aria-controls":w?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":w&&x==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":w?d:void 0,"aria-readonly":!w||void 0,"aria-required":f,autoCapitalize:p,className:g,contentEditable:w,"data-testid":S,id:m,ref:k,role:w?x:void 0,spellCheck:v,style:b,tabIndex:_,...A})}const Mp=y.forwardRef(jp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Rp=y.forwardRef(Fp);function Fp(r,e){const{placeholder:t,...n}=r,[s]=Ot();return h.jsxs(h.Fragment,{children:[h.jsx(Mp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Lp,{editor:s,content:t})]})}function Lp({content:r,editor:e}){const t=function(o){const[l,a]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:h.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Ft=0,Pp=1,kl=2,Ip=3,zp=4;function Op(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ft;const i=e._selection,o=r._selection;if(s)return Pp;if(!(G(i)&&G(o)&&o.isCollapsed()&&i.isCollapsed()))return Ft;const l=function(v,b,_){const S=v._nodeMap,A=[];for(const E of b){const w=S.get(E);w!==void 0&&A.push(w)}for(const[E,w]of _){if(!w)continue;const D=S.get(E);D===void 0||mt(D)||A.push(D)}return A}(e,t,n);if(l.length===0)return Ft;if(l.length>1){const v=e._nodeMap,b=v.get(i.anchor.key),_=v.get(o.anchor.key);return b&&_&&!r._nodeMap.has(b.__key)&&Z(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Ft}const a=l[0],u=r._nodeMap.get(a.__key);if(!Z(u)||!Z(a)||u.__mode!==a.__mode)return Ft;const c=u.__text,d=a.__text;if(c===d)return Ft;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Ft;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?Ip:x===-1&&m===g?zp:Ft}function $p(r,e){let t=Date.now(),n=Ft;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=Ft,t=c,po;const d=Op(s,i,l,a,r.isComposing()),f=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return ps;if(s===null)return ho;const m=i._selection;return l.size>0||a.size>0?g===!1&&d!==Ft&&d===n&&c<t+e&&p||l.size===1&&function(x,v,b){const _=v._nodeMap.get(x),S=b._nodeMap.get(x),A=v._selection,E=b._selection;return!(G(A)&&G(E)&&A.anchor.type==="element"&&A.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!Z(_)||!Z(S)||_.__parent!==S.__parent)&&JSON.stringify(v.read(()=>_.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(l)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function qp(r,e,t){const n=$p(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(a.length!==0){const u=o.current,c=a.pop();u!==null&&(l.push(u),i.dispatchCommand(as,!0)),a.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Pe),r.registerCommand(Mo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(l.length!==0){const u=o.current;u!==null&&(a.push(u),i.dispatchCommand(ls,!0));const c=l.pop();l.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Pe),r.registerCommand($f,()=>(El(e),!1),Pe),r.registerCommand(qf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),Pe),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,l,a,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(as,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Up(){return{current:null,redoStack:[],undoStack:[]}}function Wp({delay:r,externalHistoryState:e}){const[t]=Ot();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Up(),[s]);y.useEffect(()=>qp(n,o,i),[i,n,o])}(t,e,r),null}const Hp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Vp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=Ot();return Hp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:l,tags:a})=>{e&&i.size===0&&o.size===0||r&&a.has("history-merge")||l.isEmpty()||t(s,n,a)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Gp=function(r){var e,t;function n(){for(var i,o=arguments.length,l=new Array(o),a=0;a<o;a++)l[a]=arguments[a];return(i=r.call.apply(r,[this].concat(l))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,go(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(Dl)},s.componentDidCatch=function(i,o){var l,a;(l=(a=this.props).onError)==null||l.call(a,i,o)},s.componentDidUpdate=function(i,o){var l,a,u,c,d=this.state.error,f=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=f)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((l=(a=this.props).onResetKeysChange)==null||l.call(a,i.resetKeys,f),this.reset())},s.render=function(){var i=this.state.error,o=this.props,l=o.fallbackRender,a=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof l=="function")return l(c);if(a)return ki.createElement(a,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Kp({children:r,onError:e}){return h.jsx(Gp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Yp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Yp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Qp(r){let e=1,t=r.getParent();for(;t!=null;){if(Xe(t)){const n=t.getParent();if(Fe(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Fe(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Fe(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(Xe);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Fe(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Vt(r){return Xe(r)&&Fe(r.getFirstChild())}function Al(r){return Dt().append(r)}function Bc(r,e){return Xe(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ue();if(t!==null){const n=t.getNodes();if(G(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Bc(l,n)){const u=kt(e);if(Yt(a)){l.replace(u);const c=Dt();z(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Xe(l)){const c=l.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!z(o)||!o.isEmpty()||Xe(o)||s.has(o.getKey())){if(Fu(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(Fe(l)){if(!s.has(a)){const u=kt(e);Rr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Yt(u)&&!s.has(a)){s.add(a),Nl(l,e);break}l=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Fe(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Dt();let i;if(Rr(s,r.getChildren()),Fe(t)&&e===t.getListType())t.append(s),Fe(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(Fe(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=kt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Jp(r){r.update(()=>{const e=ue();if(G(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const l=dp(o,Ir);l!=null&&t.add(mo(l))}}for(const i of t){let o=i;const l=Nc(i);for(const a of l){const u=nt();Rr(u,a.getChildren()),o.insertAfter(u),o=u,a.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),a.remove()}i.remove()}}})}function Xp(r){const e=new Set;if(Vt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Vt(n)&&Vt(s)){const i=s.getFirstChild();if(Fe(i)){i.append(r);const o=n.getFirstChild();Fe(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Fe(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Fe(i)&&i.append(r)}else if(Fe(t)){const i=Dt(),o=kt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Zp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Fe(t?t.getParent():void 0)&&Xe(t)&&Fe(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const i=e.getListType(),o=Dt(),l=kt(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=Dt(),u=kt(i);a.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function eg(){const r=ue();if(!G(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Xe(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Fe(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=nt(),t.insertAfter(i);else{if(!Xe(s))return!1;i=Dt(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=kt(n.getListType());if(tn(i))i.insertAfter(l);else{const a=Dt();a.append(l),i.insertAfter(a)}o.forEach(a=>{a.remove(),l.append(a)})}return function(l){let a=l;for(;a.getNextSibling()==null&&a.getPreviousSibling()==null;){const u=a.getParent();if(u==null||!Xe(a)&&!Fe(a))break;a=u}a.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Ir extends lr{static getType(){return"listitem"}static clone(e){return new Ir(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return Fe(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Fe(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(Xe(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Fe(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tg,priority:0})}}static importJSON(e){const t=Dt();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(z(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(Xe(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Fe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=kt(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&(z(e)||Ht(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Fe(n)||Ht(39),Xe(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=kt(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Dt(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=nt();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Xe(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,l=e.focus,a=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(a,o.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(a,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Fe(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;Xe(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ht(117),(e=Math.floor(e))>=0||Ht(199);let t=this.getIndent();for(;t!==e;)t<e?(Xp(this),t++):(Zp(this),t--);return this}canInsertAfter(e){return Xe(e)}canReplaceWith(e){return Xe(e)}canMergeWith(e){return tn(e)||Xe(e)}extractWithChild(e,t){if(!G(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return kt("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let l;if(i&&i.nested&&(l=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const a=t.getParent(),u=Fe(a)&&a.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(l!==void 0){const a=Gs(l);t.getChildren().some(u=>Fe(u))?n.push(...a):s.push(...a)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){Fe(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function tg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return rg(t)}const e=r.getAttribute("aria-checked");return{node:Dt(e==="true"||e!=="false"&&void 0)}}function rg(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Dt(r.hasAttribute("checked"))}}function Dt(r){return Jt(new Ir(void 0,r))}function Xe(r){return r instanceof Ir}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{Fe(e)||Ht(163),function(t){const n=t.getNextSibling();Fe(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())Xe(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Fe(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=kt(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&or(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(Xe(n))super.append(n);else{const s=Dt();if(Fe(n))s.append(n);else if(z(n))if(n.isInline())s.append(n);else{const i=it(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Xe(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Qp(t)-1,a=l%o.length,u=o[a],c=i[t.__tag];let d;const f=i.nested,p=i.checklist;if(f!==void 0&&f.list&&(d=f.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==a&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);l>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function ng(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Xe(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Fe(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=kt("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(or(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?kt("check"):kt("bullet")),{after:ng,node:t}}const Fl={ol:"number",ul:"bullet"};function kt(r,e=1){return Jt(new ln(r,e))}function Fe(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),sg=Hn();function ig(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(sg,()=>(Jp(r),!0),Vr),r.registerCommand(Rn,()=>!!eg(),Vr))}function og(){const[r]=Ot();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>ig(e),[e])}(r),null}const ag=new Set(["http:","https:","mailto:","sms:","tel:"]);class zr extends lr{static getType(){return"link"}static clone(e){return new zr(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),rs(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:lg,priority:1})}}static importJSON(e){const t=Ks(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!ag.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Ks(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!G(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function lg(r){let e=null;if(vh(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Jt(new zr(r,e))}function mn(r){return r instanceof zr}class ns extends zr{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new ns(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=Ll(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(z(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Jt(new ns(r,e))}function ug(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ue();if(!G(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!ug(u)&&mn(u));if(a){const u=a.getChildren();for(let c=0;c<u.length;c++)a.insertBefore(u[c]);a.remove()}});else{if(o.length===1){const u=function(c,d){let f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let l=null,a=null;o.forEach(u=>{const c=u.getParent();if(c!==a&&c!==null&&(!z(u)||u.isInline())){if(mn(c))return a=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n));if(c.is(l)||(l=c,a=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(a):c.insertAfter(a):u.insertBefore(a)),mn(u)){if(u.is(a))return;if(a!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function cg({validateUrl:r,attributes:e}){const[t]=Ot();return y.useEffect(()=>{if(!t.hasNodes([zr]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:l}=n;return $i(s,{...e,rel:o,target:i,title:l}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ue();if(!G(s)||s.isCollapsed()||!gr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(l=>z(l))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function dg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function fg({src:r,alt:e,width:t,height:n}){return h.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class vi extends ra{constructor(t,n,s,i,o){super(o);_t(this,"__src");_t(this,"__altText");_t(this,"__width");_t(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new vi(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Rc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:dg,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return h.jsx(fg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var hg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?hg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
96
96
  * @license QR Code generator library (TypeScript)
97
97
  * Copyright (c) Project Nayuki.
98
98
  * SPDX-License-Identifier: MIT
@@ -175,12 +175,12 @@ React keys must be passed directly to JSX without using spread:
175
175
  from { transform: rotate(0deg); }
176
176
  to { transform: rotate(360deg); }
177
177
  }
178
- `;return h.jsxs("div",{className:o,style:{border:`1px solid ${v.border}`,borderRadius:"8px",background:v.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[h.jsx("style",{children:re}),x,h.jsxs(Vh,{initialConfig:W,children:[h.jsx(Dg,{theme:v,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:N,aiProcessingAction:j,onAiAction:L,hasContent:I}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Np,{contentEditable:h.jsx(Rp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:v.text}}),placeholder:h.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Kp})}),h.jsx(og,{}),h.jsx(cg,{}),h.jsx(Wp,{}),h.jsx(Vp,{onChange:Q}),h.jsx(Ag,{html:b?A:r,isExternalUpdate:b,onImportComplete:F}),h.jsx(Tg,{text:u,trigger:c})]}),n&&h.jsx(Ng,{replyTo:n,theme:v})]})}const Bg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function jg({to:r="",cc:e="",bcc:t="",subject:n="",body:s="",replyTo:i,onSend:o,onCancel:l,onBodyChange:a,externalUpdate:u,insertText:c,insertTextTrigger:d,theme:f={},disabled:p=!1,showCcBcc:g=!1,placeholder:m="Write your message...",className:x="",hideToField:v=!1,minHeight:b="200px",hideCancelButton:_=!1,onAiRestructure:S,onAiProofread:A,onAiRewrite:E,onAiGenerate:w,renderAboveToolbar:D,onPickContact:R}){const k={...Bg,...f},[N,j]=y.useState(r),[F,C]=y.useState(e),[M,L]=y.useState(t),[I,W]=y.useState(n),[Q,re]=y.useState(s),[U,Y]=y.useState([]),[P,ie]=y.useState(!1),[de,fe]=y.useState(""),[ge,be]=y.useState(g||!!e||!!t),[he,J]=y.useState("message"),[xe,se]=y.useState(""),[ve,Ce]=y.useState(!1),[_e,Le]=y.useState(!0),[je,qe]=y.useState(!0);y.useEffect(()=>{j(r)},[r]),y.useEffect(()=>{C(e),e&&be(!0)},[e]),y.useEffect(()=>{L(t),t&&be(!0)},[t]);const[V,O]=y.useState(!1),ze=y.useRef(void 0);y.useEffect(()=>{u!==void 0&&u!==ze.current&&(ze.current=u,re(s),O(!0))},[u,s]);const He=B=>{re(B),O(!1),a==null||a(B)},H=y.useRef(null),[te,ce]=y.useState(!1),ke=B=>{const Z=B.target.files;if(Z){const le=Array.from(Z);console.log("[MailComposer] Files selected:",le.map($=>({name:$.name,size:$.size,type:$.type}))),Y($=>[...$,...le])}H.current&&(H.current.value="")},Ee=B=>{B.preventDefault(),B.stopPropagation(),ce(!0)},xt=B=>{B.preventDefault(),B.stopPropagation(),ce(!1)},bt=B=>{if(B.preventDefault(),B.stopPropagation(),ce(!1),B.dataTransfer.files&&B.dataTransfer.files.length>0){const Z=Array.from(B.dataTransfer.files);console.log("[MailComposer] Files dropped:",Z.map(le=>({name:le.name,size:le.size,type:le.type}))),Y(le=>[...le,...Z])}else console.log("[MailComposer] Drop event but no files:",B.dataTransfer.types)},ae=B=>B.type.startsWith("image/")?"image":B.type==="application/pdf"?"picture_as_pdf":B.type.includes("spreadsheet")||B.type.includes("excel")?"table_chart":B.type.includes("document")||B.type.includes("word")?"description":"attach_file",pe=B=>{Y(Z=>Z.filter((le,$)=>$!==B))},Ve=B=>B<1024?`${B} B`:B<1024*1024?`${(B/1024).toFixed(1)} KB`:`${(B/(1024*1024)).toFixed(1)} MB`,Ke=async()=>{if(!N.trim()){fe("Recipient email is required");return}if(!I.trim()){fe("Subject is required");return}ie(!0),fe("");try{const B=await Promise.all(U.map(async $=>{const we=await $.arrayBuffer(),ye=btoa(new Uint8Array(we).reduce((Se,Re)=>Se+String.fromCharCode(Re),""));return{filename:$.name,content_type:$.type||"application/octet-stream",data:ye,size:$.size}})),Z=Q.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),le={to:N.trim(),cc:F.trim()||void 0,bcc:M.trim()||void 0,subject:I.trim(),html:Z,attachments:B,inReplyTo:i==null?void 0:i.messageId};console.log("[MailComposer] Sending email - to:",le.to,"subject:",le.subject,"attachmentsCount:",le.attachments.length),le.attachments.length>0&&le.attachments.forEach(($,we)=>{var ye;console.log(`[MailComposer] Attachment ${we+1}:`,$.filename,"size:",$.size,"type:",$.content_type,"data length:",((ye=$.data)==null?void 0:ye.length)||0)}),await o(le),j(""),C(""),L(""),W(""),re(""),Y([])}catch(B){fe(B instanceof Error?B.message:"Failed to send email")}finally{ie(!1)}},Ue={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none"},ct={display:"block",fontSize:"12px",fontWeight:500,color:k.textSecondary,marginBottom:"4px",textTransform:"uppercase"},X=(B,Z=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:Z?"not-allowed":"pointer",opacity:Z?.6:1,background:B?k.buttonPrimary:k.buttonSecondary,color:B?"#ffffff":k.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:x,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:k.background},children:[de&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:de}),!v&&h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"To"}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("input",{type:"email",value:N,onChange:B=>j(B.target.value),placeholder:"recipient@example.com",disabled:p||P,style:{...Ue,flex:1}}),R&&h.jsx("button",{type:"button",onClick:async()=>{const B=await R("to");B&&j(Z=>Z?`${Z}, ${B}`:B)},disabled:p||P,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.buttonSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:k.textSecondary},children:"person_add"})})]})]}),!ge&&h.jsx("button",{type:"button",onClick:()=>be(!0),disabled:p||P,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:k.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),ge&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"CC"}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("input",{type:"email",value:F,onChange:B=>C(B.target.value),placeholder:"cc@example.com",disabled:p||P,style:{...Ue,flex:1}}),R&&h.jsx("button",{type:"button",onClick:async()=>{const B=await R("cc");B&&C(Z=>Z?`${Z}, ${B}`:B)},disabled:p||P,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.buttonSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:k.textSecondary},children:"person_add"})})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"BCC"}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("input",{type:"email",value:M,onChange:B=>L(B.target.value),placeholder:"bcc@example.com",disabled:p||P,style:{...Ue,flex:1}}),R&&h.jsx("button",{type:"button",onClick:async()=>{const B=await R("bcc");B&&L(Z=>Z?`${Z}, ${B}`:B)},disabled:p||P,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.buttonSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:k.textSecondary},children:"person_add"})})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"Subject"}),h.jsx("input",{type:"text",value:I,onChange:B=>W(B.target.value),placeholder:"Email subject",disabled:p||P,style:Ue})]}),h.jsx("input",{ref:H,type:"file",multiple:!0,onChange:ke,style:{display:"none"}}),h.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${k.border}`,marginBottom:"0"},children:[h.jsx("button",{type:"button",onClick:()=>J("message"),disabled:p||P,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:he==="message"?`2px solid ${k.primary}`:"2px solid transparent",color:he==="message"?k.primary:k.textSecondary,fontWeight:he==="message"?600:400,cursor:p||P?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),h.jsxs("button",{type:"button",onClick:()=>J("attachments"),disabled:p||P,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:he==="attachments"?`2px solid ${k.primary}`:"2px solid transparent",color:he==="attachments"?k.primary:k.textSecondary,fontWeight:he==="attachments"?600:400,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",U.length>0&&h.jsx("span",{style:{background:k.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:U.length})]}),w&&h.jsx("button",{type:"button",onClick:()=>J("prompt"),disabled:p||P,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:he==="prompt"?`2px solid ${k.primary}`:"2px solid transparent",color:he==="prompt"?k.primary:k.textSecondary,fontWeight:he==="prompt"?600:400,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:"Prompt"}),he==="message"&&h.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{type:"button",onClick:()=>{var B;return(B=H.current)==null?void 0:B.click()},disabled:p||P,title:"Add attachment",style:{padding:"6px 10px",border:"none",background:"none",color:k.textSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})}),h.jsx("button",{type:"button",onClick:Ke,disabled:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim(),title:"Send email",style:{padding:"6px 10px",border:"none",background:"none",color:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim()?k.textSecondary:k.primary,cursor:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim()?"not-allowed":"pointer",opacity:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim()?.4:1,display:"flex",alignItems:"center",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:P?"spin 1s linear infinite":"none"},children:P?"sync":"send"})})]})]}),he==="message"&&h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Gc,{value:Q,onChange:He,placeholder:m,replyTo:i,theme:k,disabled:p||P,minHeight:b,externalUpdate:V?u:void 0,insertText:c,insertTextTrigger:d,onAiRestructure:S,onAiProofread:A,onAiRewrite:E,renderAboveToolbar:D})})}),he==="attachments"&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[h.jsxs("div",{onClick:()=>{var B;return(B=H.current)==null?void 0:B.click()},onDragOver:Ee,onDragLeave:xt,onDrop:bt,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${te?k.primary:k.border}`,borderRadius:"8px",background:te?`${k.primary}10`:"transparent",color:te?k.primary:k.textSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:te?"file_download":"cloud_upload"}),h.jsx("span",{style:{fontSize:"14px"},children:te?"Drop files here":"Drop files or click to add"})]}),h.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:U.length>0?h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:U.map((B,Z)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${k.border}`,gap:"12px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:k.textSecondary},children:ae(B)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:k.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.name}),h.jsx("div",{style:{fontSize:"12px",color:k.textSecondary},children:Ve(B.size)})]}),h.jsx("button",{type:"button",onClick:()=>pe(Z),disabled:p||P,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||P?"not-allowed":"pointer",color:k.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${B.name}-${Z}`))}):h.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:k.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),he==="prompt"&&w&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,gap:"12px"},children:[h.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"14px",color:k.text},children:[h.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[h.jsx("input",{type:"checkbox",checked:_e,onChange:B=>Le(B.target.checked),disabled:p||P||ve,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Utiliser notes"]}),h.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[h.jsx("input",{type:"checkbox",checked:je,onChange:B=>qe(B.target.checked),disabled:p||P||ve,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Ajouter signature"]})]}),h.jsx("textarea",{value:xe,onChange:B=>se(B.target.value),placeholder:"Décrivez le mail que vous souhaitez envoyer...",disabled:p||P||ve,style:{flex:1,padding:"12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none",resize:"none",minHeight:"150px"}}),h.jsxs("button",{type:"button",onClick:async()=>{if(!(!xe.trim()||!w)){Ce(!0);try{const B=await w(xe,{to:N,subject:I},{useNotes:_e,addSignature:je});re(B),J("message"),se("")}catch(B){console.error("AI generation failed:",B)}finally{Ce(!1)}}},disabled:p||P||ve||!xe.trim(),style:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:p||P||ve||!xe.trim()?"not-allowed":"pointer",opacity:p||P||ve||!xe.trim()?.6:1,background:k.buttonPrimary,color:"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:ve?"spin 1s linear infinite":"none"},children:ve?"sync":"auto_awesome"}),ve?"Génération...":"Générer"]})]}),!_&&l&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx("button",{type:"button",onClick:l,disabled:p||P,style:X(!1,p||P),children:"Cancel"})}),h.jsx("style",{children:`
178
+ `;return h.jsxs("div",{className:o,style:{border:`1px solid ${v.border}`,borderRadius:"8px",background:v.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[h.jsx("style",{children:re}),x,h.jsxs(Vh,{initialConfig:W,children:[h.jsx(Dg,{theme:v,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:N,aiProcessingAction:j,onAiAction:L,hasContent:I}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Np,{contentEditable:h.jsx(Rp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:v.text}}),placeholder:h.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Kp})}),h.jsx(og,{}),h.jsx(cg,{}),h.jsx(Wp,{}),h.jsx(Vp,{onChange:Q}),h.jsx(Ag,{html:b?A:r,isExternalUpdate:b,onImportComplete:F}),h.jsx(Tg,{text:u,trigger:c})]}),n&&h.jsx(Ng,{replyTo:n,theme:v})]})}const Bg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function jg({to:r="",cc:e="",bcc:t="",subject:n="",body:s="",replyTo:i,onSend:o,onCancel:l,onBodyChange:a,externalUpdate:u,insertText:c,insertTextTrigger:d,theme:f={},disabled:p=!1,showCcBcc:g=!1,placeholder:m="Write your message...",className:x="",hideToField:v=!1,minHeight:b="200px",hideCancelButton:_=!1,onAiRestructure:S,onAiProofread:A,onAiRewrite:E,onAiGenerate:w,renderAboveToolbar:D,onPickContact:R}){const k={...Bg,...f},[N,j]=y.useState(r),[F,C]=y.useState(e),[M,L]=y.useState(t),[I,W]=y.useState(n),[Q,re]=y.useState(s),[U,Y]=y.useState([]),[P,ie]=y.useState(!1),[de,fe]=y.useState(""),[ge,be]=y.useState(g||!!e||!!t),[he,J]=y.useState("message"),[xe,se]=y.useState(""),[ve,Ce]=y.useState(!1),[_e,Le]=y.useState(!0),[je,qe]=y.useState(!0);y.useEffect(()=>{j(r)},[r]),y.useEffect(()=>{C(e),e&&be(!0)},[e]),y.useEffect(()=>{L(t),t&&be(!0)},[t]);const[V,O]=y.useState(!1),ze=y.useRef(void 0);y.useEffect(()=>{u!==void 0&&u!==ze.current&&(ze.current=u,re(s),O(!0))},[u,s]);const He=B=>{re(B),O(!1),a==null||a(B)},H=y.useRef(null),[te,ce]=y.useState(!1),ke=B=>{const ee=B.target.files;if(ee){const le=Array.from(ee);console.log("[MailComposer] Files selected:",le.map($=>({name:$.name,size:$.size,type:$.type}))),Y($=>[...$,...le])}H.current&&(H.current.value="")},Ee=B=>{B.preventDefault(),B.stopPropagation(),ce(!0)},xt=B=>{B.preventDefault(),B.stopPropagation(),ce(!1)},bt=B=>{if(B.preventDefault(),B.stopPropagation(),ce(!1),B.dataTransfer.files&&B.dataTransfer.files.length>0){const ee=Array.from(B.dataTransfer.files);console.log("[MailComposer] Files dropped:",ee.map(le=>({name:le.name,size:le.size,type:le.type}))),Y(le=>[...le,...ee])}else console.log("[MailComposer] Drop event but no files:",B.dataTransfer.types)},ae=B=>B.type.startsWith("image/")?"image":B.type==="application/pdf"?"picture_as_pdf":B.type.includes("spreadsheet")||B.type.includes("excel")?"table_chart":B.type.includes("document")||B.type.includes("word")?"description":"attach_file",pe=B=>{Y(ee=>ee.filter((le,$)=>$!==B))},Ve=B=>B<1024?`${B} B`:B<1024*1024?`${(B/1024).toFixed(1)} KB`:`${(B/(1024*1024)).toFixed(1)} MB`,Ke=async()=>{if(!N.trim()){fe("Recipient email is required");return}if(!I.trim()){fe("Subject is required");return}ie(!0),fe("");try{const B=await Promise.all(U.map(async $=>{const we=await $.arrayBuffer(),ye=btoa(new Uint8Array(we).reduce((Se,Re)=>Se+String.fromCharCode(Re),""));return{filename:$.name,content_type:$.type||"application/octet-stream",data:ye,size:$.size}})),ee=Q.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),le={to:N.trim(),cc:F.trim()||void 0,bcc:M.trim()||void 0,subject:I.trim(),html:ee,attachments:B,inReplyTo:i==null?void 0:i.messageId};console.log("[MailComposer] Sending email - to:",le.to,"subject:",le.subject,"attachmentsCount:",le.attachments.length),le.attachments.length>0&&le.attachments.forEach(($,we)=>{var ye;console.log(`[MailComposer] Attachment ${we+1}:`,$.filename,"size:",$.size,"type:",$.content_type,"data length:",((ye=$.data)==null?void 0:ye.length)||0)}),await o(le),j(""),C(""),L(""),W(""),re(""),Y([])}catch(B){fe(B instanceof Error?B.message:"Failed to send email")}finally{ie(!1)}},Ue={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none"},ct={display:"block",fontSize:"12px",fontWeight:500,color:k.textSecondary,marginBottom:"4px",textTransform:"uppercase"},X=(B,ee=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:ee?"not-allowed":"pointer",opacity:ee?.6:1,background:B?k.buttonPrimary:k.buttonSecondary,color:B?"#ffffff":k.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:x,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:k.background},children:[de&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:de}),!v&&h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"To"}),h.jsx("input",{type:"email",value:N,onChange:B=>j(B.target.value),placeholder:"recipient@example.com",disabled:p||P,style:Ue})]}),!ge&&h.jsx("button",{type:"button",onClick:()=>be(!0),disabled:p||P,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:k.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),ge&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"CC"}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("input",{type:"email",value:F,onChange:B=>C(B.target.value),placeholder:"cc@example.com",disabled:p||P,style:{...Ue,flex:1}}),R&&h.jsx("button",{type:"button",onClick:async()=>{const B=await R("cc");B&&C(ee=>ee?`${ee}, ${B}`:B)},disabled:p||P,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.buttonSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:k.textSecondary},children:"person_add"})})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"BCC"}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("input",{type:"email",value:M,onChange:B=>L(B.target.value),placeholder:"bcc@example.com",disabled:p||P,style:{...Ue,flex:1}}),R&&h.jsx("button",{type:"button",onClick:async()=>{const B=await R("bcc");B&&L(ee=>ee?`${ee}, ${B}`:B)},disabled:p||P,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.buttonSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:k.textSecondary},children:"person_add"})})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:ct,children:"Subject"}),h.jsx("input",{type:"text",value:I,onChange:B=>W(B.target.value),placeholder:"Email subject",disabled:p||P,style:Ue})]}),h.jsx("input",{ref:H,type:"file",multiple:!0,onChange:ke,style:{display:"none"}}),h.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${k.border}`,marginBottom:"0"},children:[h.jsx("button",{type:"button",onClick:()=>J("message"),disabled:p||P,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:he==="message"?`2px solid ${k.primary}`:"2px solid transparent",color:he==="message"?k.primary:k.textSecondary,fontWeight:he==="message"?600:400,cursor:p||P?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),h.jsxs("button",{type:"button",onClick:()=>J("attachments"),disabled:p||P,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:he==="attachments"?`2px solid ${k.primary}`:"2px solid transparent",color:he==="attachments"?k.primary:k.textSecondary,fontWeight:he==="attachments"?600:400,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",U.length>0&&h.jsx("span",{style:{background:k.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:U.length})]}),w&&h.jsx("button",{type:"button",onClick:()=>J("prompt"),disabled:p||P,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:he==="prompt"?`2px solid ${k.primary}`:"2px solid transparent",color:he==="prompt"?k.primary:k.textSecondary,fontWeight:he==="prompt"?600:400,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:"Prompt"}),he==="message"&&h.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{type:"button",onClick:()=>{var B;return(B=H.current)==null?void 0:B.click()},disabled:p||P,title:"Add attachment",style:{padding:"6px 10px",border:"none",background:"none",color:k.textSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",alignItems:"center",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})}),h.jsx("button",{type:"button",onClick:Ke,disabled:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim(),title:"Send email",style:{padding:"6px 10px",border:"none",background:"none",color:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim()?k.textSecondary:k.primary,cursor:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim()?"not-allowed":"pointer",opacity:p||P||!N.trim()||!I.trim()||!Q.replace(/<[^>]*>/g,"").trim()?.4:1,display:"flex",alignItems:"center",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:P?"spin 1s linear infinite":"none"},children:P?"sync":"send"})})]})]}),he==="message"&&h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Gc,{value:Q,onChange:He,placeholder:m,replyTo:i,theme:k,disabled:p||P,minHeight:b,externalUpdate:V?u:void 0,insertText:c,insertTextTrigger:d,onAiRestructure:S,onAiProofread:A,onAiRewrite:E,renderAboveToolbar:D})})}),he==="attachments"&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[h.jsxs("div",{onClick:()=>{var B;return(B=H.current)==null?void 0:B.click()},onDragOver:Ee,onDragLeave:xt,onDrop:bt,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${te?k.primary:k.border}`,borderRadius:"8px",background:te?`${k.primary}10`:"transparent",color:te?k.primary:k.textSecondary,cursor:p||P?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:te?"file_download":"cloud_upload"}),h.jsx("span",{style:{fontSize:"14px"},children:te?"Drop files here":"Drop files or click to add"})]}),h.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:U.length>0?h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:U.map((B,ee)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${k.border}`,gap:"12px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:k.textSecondary},children:ae(B)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:k.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.name}),h.jsx("div",{style:{fontSize:"12px",color:k.textSecondary},children:Ve(B.size)})]}),h.jsx("button",{type:"button",onClick:()=>pe(ee),disabled:p||P,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||P?"not-allowed":"pointer",color:k.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${B.name}-${ee}`))}):h.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:k.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),he==="prompt"&&w&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,gap:"12px"},children:[h.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"14px",color:k.text},children:[h.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[h.jsx("input",{type:"checkbox",checked:_e,onChange:B=>Le(B.target.checked),disabled:p||P||ve,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Utiliser notes"]}),h.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[h.jsx("input",{type:"checkbox",checked:je,onChange:B=>qe(B.target.checked),disabled:p||P||ve,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Ajouter signature"]})]}),h.jsx("textarea",{value:xe,onChange:B=>se(B.target.value),placeholder:"Décrivez le mail que vous souhaitez envoyer...",disabled:p||P||ve,style:{flex:1,padding:"12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none",resize:"none",minHeight:"150px"}}),h.jsxs("button",{type:"button",onClick:async()=>{if(!(!xe.trim()||!w)){Ce(!0);try{const B=await w(xe,{to:N,subject:I},{useNotes:_e,addSignature:je});re(B),J("message"),se("")}catch(B){console.error("AI generation failed:",B)}finally{Ce(!1)}}},disabled:p||P||ve||!xe.trim(),style:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:p||P||ve||!xe.trim()?"not-allowed":"pointer",opacity:p||P||ve||!xe.trim()?.6:1,background:k.buttonPrimary,color:"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:ve?"spin 1s linear infinite":"none"},children:ve?"sync":"auto_awesome"}),ve?"Génération...":"Générer"]})]}),!_&&l&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx("button",{type:"button",onClick:l,disabled:p||P,style:X(!1,p||P),children:"Cancel"})}),h.jsx("style",{children:`
179
179
  @keyframes spin {
180
180
  from { transform: rotate(0deg); }
181
181
  to { transform: rotate(360deg); }
182
182
  }
183
- `})]})}const Mg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Rg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Mg,...d},[g,m]=y.useState(!1),[x,v]=y.useState(""),b=y.useRef(null),_=y.useRef(null);y.useEffect(()=>{function N(j){b.current&&!b.current.contains(j.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const S=r.filter(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),A=s&&x.trim()&&!r.some(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase())===x.toLowerCase()}),E=e.map(N=>r.find(j=>j.id===N)).filter(Boolean),w=y.useCallback(N=>{var j;c>0&&e.length>=c||(t([...e,N]),v(""),c===1?m(!1):(j=_.current)==null||j.focus())},[e,t,c]),D=y.useCallback(N=>{t(e.filter(j=>j!==N))},[e,t]),R=y.useCallback(async()=>{if(!A)return;const N=await(i==null?void 0:i(x.trim()));N&&w(N.id),v("")},[A,x,i,w]),k=y.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),A?R():S.length>0&&w(S[0].id)):N.key==="Backspace"&&!x&&e.length>0?D(e[e.length-1]):N.key==="Escape"&&(m(!1),v(""))},[A,S,x,e,R,w,D]);return h.jsxs("div",{ref:b,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[E.map(N=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||p.chipBackground,color:N.color?"#fff":p.chipText},children:[N.label,!u&&h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),D(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),h.jsx("input",{ref:_,type:"text",value:x,onChange:N=>{v(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:k,placeholder:E.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:S.length===0&&!A?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[S.map(N=>h.jsxs("div",{onClick:()=>w(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:j=>{j.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:j=>{j.currentTarget.style.background=""},children:[N.label,o&&l&&h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:j=>{j.currentTarget.style.opacity="1",j.currentTarget.style.color="#ef4444"},onMouseLeave:j=>{j.currentTarget.style.opacity="0.5",j.currentTarget.style.color=p.textSecondary||""},children:"×"})]},N.id)),A&&h.jsxs("div",{onClick:R,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Fg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Lg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Fg,...u},[d,f]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),v=y.useMemo(()=>e&&r.find(D=>D.id===e)||null,[e,r]),b=y.useMemo(()=>{if(!d.trim())return r;const D=d.toLowerCase();return r.filter(R=>{var k,N;return((k=R.label)==null?void 0:k.toLowerCase().includes(D))||((N=R.notes)==null?void 0:N.toLowerCase().includes(D))})},[r,d]);y.useEffect(()=>{const D=R=>{m.current&&!m.current.contains(R.target)&&g(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const _=D=>{s&&s(D),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},A=()=>{g(!0)},E=D=>{f(D.target.value),p||g(!0)},w=D=>{D.key==="Enter"?(D.preventDefault(),b.length>0&&s?(s(b[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):D.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:v&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.label}),v.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.notes})]}),i&&h.jsx("button",{onClick:D=>{D.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:E,onFocus:A,onKeyDown:w,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:S,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:D=>{D.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:D=>{D.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:b.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):b.map((D,R)=>h.jsxs("div",{onClick:()=>_(D),style:{padding:"10px 14px",cursor:"pointer",borderBottom:R<b.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:k=>{k.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:k=>{k.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.color||c.text,marginBottom:D.notes?"2px":0},children:D.label}),D.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:D.notes})]},D.id))})]})}function Pg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=y.useState(null),[x,v]=y.useState(null),[b,_]=y.useState(null),S=y.useRef(null),A=e.reduce((j,F)=>{let C=r.filter(M=>n(M)===F.id);return s&&(C=C.sort((M,L)=>s(M)-s(L))),j[F.id]=C,j},{}),E=y.useCallback((j,F)=>{const C=t(F),M=n(F);m(C),S.current=M,j.dataTransfer.effectAllowed="move",j.dataTransfer.setData("text/plain",C),requestAnimationFrame(()=>{const L=j.target;L.style.opacity="0.5"})},[t,n]),w=y.useCallback(j=>{const F=j.target;F.style.opacity="1",m(null),v(null),_(null),S.current=null},[]),D=y.useCallback((j,F,C)=>{j.preventDefault(),j.dataTransfer.dropEffect="move",v(F),_(C)},[]),R=y.useCallback(j=>{const F=j.relatedTarget;F!=null&&F.closest("[data-kanban-column]")||(v(null),_(null))},[]),k=y.useCallback((j,F,C)=>{if(j.preventDefault(),!g)return;const M=S.current;M===F?l==null||l(g,F,C):M&&o(g,M,F,C),m(null),v(null),_(null),S.current=null},[g,o,l]),N=(j,F)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[j.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:j.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:j.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:F})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(j=>{const F=A[j.id]||[],C=x===j.id;return h.jsxs("div",{"data-kanban-column":j.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:M=>{M.preventDefault(),g&&!C&&v(j.id)},onDragLeave:R,onDrop:M=>k(M,j.id,b??F.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(j,F.length):N(j,F.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${C?"bg-blue-50":""}`,children:[F.map((M,L)=>{const I=t(M),W=g===I,Q=C&&b===L&&!W;return h.jsxs("div",{children:[Q&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:re=>E(re,M),onDragEnd:w,onDragOver:re=>D(re,j.id,L),onClick:()=>a==null?void 0:a(M),className:`cursor-grab active:cursor-grabbing transition-all ${W?"opacity-50 scale-95":""} ${p}`,children:i(M,W)})]},I)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:M=>{M.preventDefault(),D(M,j.id,F.length)},children:C&&b===F.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),F.length===0&&C&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(j)})]},j.id)})})}function Kc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function Ig(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function zg(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function Og(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const $g={"1:1":1,"2:3":1.5,"16:9":.5625};function Yc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Kc(r),o=$g[e],l=e==="2:3"?160:e==="16:9"?280:180,a=e==="2:3"||e==="16:9"?l*o:l;return h.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:l,height:a,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?h.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:h.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Qc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[l,a]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(a(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const f=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:h.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[h.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),h.jsxs("div",{style:{position:"relative"},children:[l&&h.jsx("button",{onClick:()=>f("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&h.jsx("button",{onClick:()=>f("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),h.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>h.jsx(Yc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Jc({node:r,onClose:e}){const t=Kc(r),n=Ig(r),s=zg(r),i=Og(r);return y.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),h.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:h.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),h.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[h.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?h.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),h.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:h.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),h.jsxs("div",{style:{padding:"0 32px 32px"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&h.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&h.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&h.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&h.jsxs("div",{style:{marginTop:24},children:[h.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),h.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,l])=>h.jsxs("div",{children:[h.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),h.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(l)})]},o))})]})]})]})]})})}function qg({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),l=u=>{n?n(u):i(u)},a=()=>{i(null)};return h.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>h.jsx(Qc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:l},u.id)),o.every(u=>u.nodes.length===0)&&h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[h.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),h.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&h.jsx(Jc,{node:s,onClose:a})]})}const Ug={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Wg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Hg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Vg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Gg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Ug,...g},{allDayItems:x,timedItems:v}=y.useMemo(()=>{const w=[],D=[];for(const R of r)l(R)?w.push(R):D.push(R);return{allDayItems:w,timedItems:D}},[r,l]),b=y.useMemo(()=>{const w=[];for(let D=t;D<=n;D++)w.push(D);return w},[t,n]),_=(n-t+1)*s,S=y.useCallback(w=>{const D=i(w);if(!D)return null;const R=Wg(D);if(!R)return null;const{hours:k,minutes:N}=R,j=Math.max(t,Math.min(n,k)),F=k<t?0:N,C=(j-t)*s+F/60*s,M=o(w),L=Math.max(20,M/60*s);return{top:C,height:L}},[i,o,t,n,s]),A=y.useMemo(()=>{if(!f||!Vg(e))return null;const w=new Date,D=w.getHours(),R=w.getMinutes();return D<t||D>n?null:(D-t)*s+R/60*s},[e,f,t,n,s]),E=y.useCallback(w=>{if(!d)return;const D=w.currentTarget.getBoundingClientRect(),k=(w.clientY-D.top)/s*60,N=Math.floor(k/60)+t,j=Math.round(k%60/15)*15,F=Math.min(n,Math.max(t,N)),C=j>=60?0:j,M=`${F.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`;d(M)},[d,s,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(w=>h.jsx("div",{onClick:()=>c==null?void 0:c(w),style:{cursor:c?"pointer":"default"},children:u(w)},a(w)))})]}),h.jsxs("div",{style:{position:"relative",height:_},children:[b.map((w,D)=>h.jsxs("div",{style:{position:"absolute",top:D*s,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Hg(w)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),D<b.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},w)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),A!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:A,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),v.map(w=>{const D=S(w);return D?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:D.top,height:D.height,zIndex:10,cursor:c?"pointer":"default"},onClick:R=>{R.stopPropagation(),c==null||c(w)},children:u(w)},a(w)):null})]})]})}function Xc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=y.useState("idle"),[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(0),[b,_]=y.useState(null),[S,A]=y.useState(!1),[E,w]=y.useState(null),[D,R]=y.useState(!0),[k,N]=y.useState([]),[j,F]=y.useState({completed:0,total:0}),C=y.useRef(!1),M=y.useRef(!0);y.useEffect(()=>{M.current=D},[D]);const L=y.useRef(null),I=y.useRef(null),W=y.useRef(null),Q=y.useRef(null),re=y.useRef(null),U=y.useRef([]),Y=y.useRef(null),P=y.useRef(null),ie=y.useRef(null),de=y.useRef(null),fe=y.useRef(!1),ge=y.useRef([]),be=y.useRef(null),he=y.useRef(null),J=y.useRef([]),xe=y.useRef([]),se=y.useRef("insert"),ve=y.useRef(!1),Ce=y.useRef(0),_e=y.useRef(0),Le=y.useRef(0),je=X=>{const B=Math.floor(X/60),Z=Math.floor(X%60);return`${B.toString().padStart(2,"0")}:${Z.toString().padStart(2,"0")}`},qe=async X=>{const B=await X.arrayBuffer(),Z=new AudioContext,le=await Z.decodeAudioData(B);return await Z.close(),le},V=X=>{const B=X.numberOfChannels,Z=X.sampleRate,le=1,$=16,we=$/8,ye=B*we,Se=Z*ye,Re=X.length*ye,We=new ArrayBuffer(44+Re),De=new DataView(We),Ae=(Ye,Oe)=>{for(let dt=0;dt<Oe.length;dt++)De.setUint8(Ye+dt,Oe.charCodeAt(dt))};Ae(0,"RIFF"),De.setUint32(4,36+Re,!0),Ae(8,"WAVE"),Ae(12,"fmt "),De.setUint32(16,16,!0),De.setUint16(20,le,!0),De.setUint16(22,B,!0),De.setUint32(24,Z,!0),De.setUint32(28,Se,!0),De.setUint16(32,ye,!0),De.setUint16(34,$,!0),Ae(36,"data"),De.setUint32(40,Re,!0);const tt=[];for(let Ye=0;Ye<B;Ye++)tt.push(X.getChannelData(Ye));let st=44;for(let Ye=0;Ye<X.length;Ye++)for(let Oe=0;Oe<B;Oe++){const dt=Math.max(-1,Math.min(1,tt[Oe][Ye])),ft=dt<0?dt*32768:dt*32767;De.setInt16(st,ft,!0),st+=2}return new Blob([We],{type:"audio/wav"})},O=async(X,B,Z,le)=>{const $=new AudioContext,we=X.sampleRate,ye=Math.max(X.numberOfChannels,B.numberOfChannels),Se=Math.min(Z,X.length),Re=Math.max(0,X.length-Z),We=le==="insert"?Se+B.length+Re:Se+B.length,De=$.createBuffer(ye,We,we);for(let Ae=0;Ae<ye;Ae++){const tt=De.getChannelData(Ae),st=Ae<X.numberOfChannels?X.getChannelData(Ae):X.getChannelData(0);for(let Oe=0;Oe<Se;Oe++)tt[Oe]=st[Oe];const Ye=Ae<B.numberOfChannels?B.getChannelData(Ae):B.getChannelData(0);for(let Oe=0;Oe<B.length;Oe++)tt[Se+Oe]=Ye[Oe];if(le==="insert")for(let Oe=0;Oe<Re;Oe++)tt[Se+B.length+Oe]=st[Z+Oe]}return await $.close(),De},ze=y.useCallback(()=>{const X=L.current;if(!X)return;const B=X.getContext("2d");if(!B)return;const Z=X.getBoundingClientRect(),le=Z.width,$=Z.height,we=ge.current,ye=f||c||1,Se=a==="recording"?c:x;B.fillStyle="#2d3b35",B.fillRect(0,0,le,$);const Re=8,We="rgba(0, 0, 0, 0.4)",De=B.createLinearGradient(0,0,0,Re);De.addColorStop(0,We),De.addColorStop(1,"transparent"),B.fillStyle=De,B.fillRect(0,0,le,Re);const Ae=B.createLinearGradient(0,$-Re,0,$);Ae.addColorStop(0,"transparent"),Ae.addColorStop(1,We),B.fillStyle=Ae,B.fillRect(0,$-Re,le,Re);const tt=B.createLinearGradient(0,0,Re,0);tt.addColorStop(0,We),tt.addColorStop(1,"transparent"),B.fillStyle=tt,B.fillRect(0,0,Re,$);const st=B.createLinearGradient(le-Re,0,le,0);st.addColorStop(0,"transparent"),st.addColorStop(1,We),B.fillStyle=st,B.fillRect(le-Re,0,Re,$),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,$/2),B.lineTo(le,$/2),B.stroke();const Ye=le/2;if(we.length>0)if(a==="recording")for(let ft=0;ft<we.length;ft++){const Tt=we.length-1-ft,Zt=Ye-Tt*4;if(Zt<-3||Zt>le)continue;const jt=we[ft]*($/2-12),T=$/2-jt;B.fillStyle="#10b981",B.fillRect(Zt,T,3,jt*2)}else{const ft=ye>0?Se/ye*we.length:0;for(let Tt=0;Tt<we.length;Tt++){const Zt=ft-Tt,jt=Ye-Zt*4;if(jt<-3||jt>le)continue;const T=we[Tt]*($/2-12),q=$/2-T;B.fillStyle=Tt<=ft?"#10b981":"#4b5563",B.fillRect(jt,q,3,T*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(Ye,0),B.lineTo(Ye,$),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(je(Se),Ye,$-6),a==="recording"&&(B.fillStyle="#ef4444",B.beginPath(),B.arc(20,20,8,0,Math.PI*2),B.fill(),B.fillStyle="#fff",B.font="10px sans-serif",B.textAlign="left",B.fillText("REC",34,24)),B.textAlign="left"},[a,x,c,f]),He=()=>{const X=re.current;if(!X||!fe.current)return;const B=X.frequencyBinCount,Z=new Uint8Array(B);X.getByteTimeDomainData(Z);let le=0;for(let ye=0;ye<B;ye++){const Se=(Z[ye]-128)/128;le+=Se*Se}const $=Math.sqrt(le/B),we=Math.min(1,$*3);ge.current.push(we),ze(),fe.current&&(P.current=requestAnimationFrame(He))},H=async()=>{try{_(null),A(!1),be.current===null&&(ge.current=[]);const X=await navigator.mediaDevices.getUserMedia({audio:!0});W.current=X;const B=new AudioContext;Q.current=B;const Z=B.createAnalyser();Z.fftSize=2048,re.current=Z,B.createMediaStreamSource(X).connect(Z);const $=new MediaRecorder(X);I.current=$,U.current=[],$.ondataavailable=we=>{we.data.size>0&&U.current.push(we.data)},$.onstop=async()=>{try{if(fe.current=!1,U.current.length===0){_("No audio was recorded. Please try again."),u("idle"),X.getTracks().forEach(De=>De.stop());return}const we=new Blob(U.current,{type:"audio/webm"});let ye,Se;if(be.current!==null&&he.current)try{const De=await qe(we),Ae=he.current.sampleRate,tt=Math.floor(be.current*Ae),st=await O(he.current,De,tt,se.current);ye=V(st),Se=st.length/st.sampleRate,se.current==="insert"&&(ge.current=[...ge.current,...xe.current]),be.current=null,he.current=null,J.current=[],xe.current=[]}catch{ye=we,Se=Ce.current>0?Ce.current:1}else ye=we,Se=Ce.current>0?Ce.current:1;if(de.current=ye,X.getTracks().forEach(De=>De.stop()),M.current&&t){N(De=>[...De,ye]),F(De=>({...De,total:De.total+1})),de.current=null,ge.current=[],v(0),p(0),d(0),u("idle");return}const Re=URL.createObjectURL(ye),We=new Audio(Re);We.ontimeupdate=()=>{v(We.currentTime)},We.onended=()=>{m(!1)},ie.current=We,p(Se),v(Se),u("editing")}catch{_("Failed to process recording"),u("idle")}},$.start(100),fe.current=!0,u("recording"),d(0),Ce.current=0,Y.current=setInterval(()=>{Ce.current+=1,d(Ce.current),Ce.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),fe.current=!1,w(null),Y.current&&(clearInterval(Y.current),Y.current=null),P.current&&(cancelAnimationFrame(P.current),P.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{_("Could not access microphone. Please allow microphone access.")}},te=()=>{fe.current=!1,A(!1),w(null),P.current&&(cancelAnimationFrame(P.current),P.current=null),Y.current&&(clearInterval(Y.current),Y.current=null),I.current&&I.current.state!=="inactive"&&I.current.stop()},ce=X=>{const B=L.current;if(!B)return;const Z=f||c;if(Z<=0)return;const le=ge.current;if(le.length===0)return;const $=B.getBoundingClientRect(),we=X-_e.current,ye=4,Se=$.width/B.width,Re=le.length/Z*ye,We=-we/(Re*Se),De=Le.current+We,Ae=Math.max(0,Math.min(De,Z));ie.current&&(ie.current.currentTime=Ae),v(Ae)},ke=()=>{ie.current&&(ie.current.currentTime=0),v(0)},Ee=()=>{const X=f||c;ie.current&&(ie.current.currentTime=X),v(X)},xt=()=>{const X=ie.current;X&&(g?(X.pause(),v(X.currentTime),m(!1)):(X.currentTime=x,X.play().catch(()=>{}),m(!0)))},bt=async X=>{if(!de.current){H();return}try{ie.current&&(ie.current.pause(),m(!1)),se.current=X,he.current=await qe(de.current);const B=f||c;be.current=x;const Z=B>0?x/B:0,le=Math.floor(Z*ge.current.length);J.current=ge.current.slice(0,le),xe.current=ge.current.slice(le),ge.current=[...J.current],H()}catch{_("Failed to prepare recording. Please try again.")}},ae=()=>{ie.current&&(ie.current.pause(),ie.current=null),de.current=null,he.current=null,be.current=null,J.current=[],m(!1),v(0),p(0),d(0),H()},pe=()=>{de.current?r(de.current,f||c):alert("No audio recorded yet!")};y.useEffect(()=>{a==="recording"&&L.current&&re.current&&fe.current&&(P.current=requestAnimationFrame(He))},[a]),y.useEffect(()=>{const X=L.current;if(!X)return;const B=()=>{const Z=window.devicePixelRatio||1,le=X.getBoundingClientRect();X.width=le.width*Z,X.height=le.height*Z;const $=X.getContext("2d");$&&$.scale(Z,Z)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),y.useEffect(()=>{if(a==="idle"){const X=L.current;if(!X)return;const B=X.getContext("2d");if(!B)return;const Z=X.getBoundingClientRect(),le=Z.width,$=Z.height;B.fillStyle="#2d3b35",B.fillRect(0,0,le,$);const we=8,ye="rgba(0, 0, 0, 0.4)",Se=B.createLinearGradient(0,0,0,we);Se.addColorStop(0,ye),Se.addColorStop(1,"transparent"),B.fillStyle=Se,B.fillRect(0,0,le,we);const Re=B.createLinearGradient(0,$-we,0,$);Re.addColorStop(0,"transparent"),Re.addColorStop(1,ye),B.fillStyle=Re,B.fillRect(0,$-we,le,we);const We=B.createLinearGradient(0,0,we,0);We.addColorStop(0,ye),We.addColorStop(1,"transparent"),B.fillStyle=We,B.fillRect(0,0,we,$);const De=B.createLinearGradient(le-we,0,le,0);De.addColorStop(0,"transparent"),De.addColorStop(1,ye),B.fillStyle=De,B.fillRect(le-we,0,we,$),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,$/2),B.lineTo(le,$/2),B.stroke();const Ae=le/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(Ae,0),B.lineTo(Ae,$),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",Ae,$-6)}},[a]);const Ve=y.useCallback(X=>{N(B=>[...B,X]),F(B=>({...B,total:B.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(C.current||k.length===0||!t)return;C.current=!0;const B=k[0];try{const Z=await t(B);Z&&n&&n(Z)}catch(Z){console.error("Transcription failed:",Z)}finally{N(Z=>Z.slice(1)),F(Z=>({...Z,completed:Z.completed+1})),C.current=!1}})()},[k,t,n]),y.useEffect(()=>()=>{fe.current=!1,Y.current&&clearInterval(Y.current),P.current&&cancelAnimationFrame(P.current),W.current&&W.current.getTracks().forEach(X=>X.stop()),Q.current&&Q.current.state!=="closed"&&Q.current.close()},[]),y.useEffect(()=>{if(a==="editing"&&g){let X;const B=()=>{const Z=ie.current;if(Z&&g){const le=L.current;if(le){const $=le.getContext("2d");if($){const we=le.getBoundingClientRect(),ye=we.width,Se=we.height,Re=ge.current,We=f||c||1,De=Z.currentTime;$.fillStyle="#2d3b35",$.fillRect(0,0,ye,Se);const Ae=8,tt="rgba(0, 0, 0, 0.4)",st=$.createLinearGradient(0,0,0,Ae);st.addColorStop(0,tt),st.addColorStop(1,"transparent"),$.fillStyle=st,$.fillRect(0,0,ye,Ae);const Ye=$.createLinearGradient(0,Se-Ae,0,Se);Ye.addColorStop(0,"transparent"),Ye.addColorStop(1,tt),$.fillStyle=Ye,$.fillRect(0,Se-Ae,ye,Ae);const Oe=$.createLinearGradient(0,0,Ae,0);Oe.addColorStop(0,tt),Oe.addColorStop(1,"transparent"),$.fillStyle=Oe,$.fillRect(0,0,Ae,Se);const dt=$.createLinearGradient(ye-Ae,0,ye,0);dt.addColorStop(0,"transparent"),dt.addColorStop(1,tt),$.fillStyle=dt,$.fillRect(ye-Ae,0,Ae,Se),$.strokeStyle="#5a6b62",$.lineWidth=1,$.beginPath(),$.moveTo(0,Se/2),$.lineTo(ye,Se/2),$.stroke();const ft=ye/2,Tt=3,Zt=4,jt=We>0?De/We*Re.length:0;for(let ne=0;ne<Re.length;ne++){const me=jt-ne,Me=ft-me*Zt;if(Me<-Tt||Me>ye)continue;const Ie=Re[ne]*(Se/2-12),Ne=Se/2-Ie;$.fillStyle=ne<=jt?"#10b981":"#4b5563",$.fillRect(Me,Ne,Tt,Ie*2)}$.strokeStyle="#ef4444",$.lineWidth=1,$.beginPath(),$.moveTo(ft,0),$.lineTo(ft,Se),$.stroke(),$.fillStyle="#fff",$.font="bold 18px monospace",$.textAlign="center";const T=Math.floor(De/60),q=Math.floor(De%60);$.fillText(`${T.toString().padStart(2,"0")}:${q.toString().padStart(2,"0")}`,ft,Se-6),$.textAlign="left"}}X=requestAnimationFrame(B)}};return X=requestAnimationFrame(B),()=>cancelAnimationFrame(X)}},[a,g,f,c]),y.useEffect(()=>{a==="editing"&&!g&&ze()},[a,x,g,ze]),b)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:b}),h.jsx("button",{onClick:()=>{_(null),H()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Ke={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Ue={...Ke,opacity:.3,cursor:"not-allowed"},ct=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:ct,children:[h.jsx("canvas",{ref:L,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:X=>{if(a==="editing"){ve.current=!0,_e.current=X.clientX,Le.current=x;const B=le=>{ve.current&&ce(le.clientX)},Z=()=>{ve.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",Z)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",Z)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:ke,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ue:Ke,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const X=I.current;X&&(X.state==="recording"?(X.pause(),A(!0)):X.state==="paused"&&(X.resume(),A(!1)))}else xt()},disabled:a==="idle",style:a==="idle"?Ue:Ke,title:g||a==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ee,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ue:Ke,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),h.jsx("button",{onClick:()=>{E==="insert"?te():a==="idle"?(w("insert"),H()):a==="editing"&&(w("insert"),bt("insert"))},disabled:a==="recording"&&E!=="insert"||g,style:a==="recording"&&E!=="insert"||g?Ue:Ke,title:E==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{M.current||(E==="mic"?te():a==="idle"?(w("mic"),H()):a==="editing"&&(w("mic"),bt("replace")))},onMouseDown:()=>{M.current&&a==="idle"&&!g&&(w("mic"),H())},onMouseUp:()=>{M.current&&a==="recording"&&E==="mic"&&te()},onMouseLeave:()=>{M.current&&a==="recording"&&E==="mic"&&te()},onTouchStart:X=>{X.preventDefault(),M.current&&a==="idle"&&!g&&(w("mic"),H())},onTouchEnd:X=>{X.preventDefault(),M.current&&a==="recording"&&E==="mic"&&te()},disabled:a==="recording"&&E!=="mic"||g,style:a==="recording"&&E!=="mic"||g?Ue:Ke,title:D?"Hold to record (walkie-talkie)":E==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{E==="startover"?te():a==="editing"&&(w("startover"),ae())},disabled:a==="idle"||a==="recording"&&E!=="startover"||g,style:a==="idle"||a==="recording"&&E!=="startover"||g?Ue:Ke,title:E==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[j.total>0&&j.completed<j.total&&h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),j.completed,"/",j.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>R(!D),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:D?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:D?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:D?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&de.current&&Ve(de.current)},disabled:a!=="editing",style:a!=="editing"?Ue:Ke,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:D?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:pe,disabled:a!=="editing",style:a!=="editing"?Ue:Ke,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),j.total>0&&j.completed<j.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${j.completed/j.total*100}%`,transition:"width 0.3s ease"}})})]})}function Kg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,placeholder:o="Type or record...",className:l="",rows:a,llmClient:u,graphClient:c,nodeId:d,audioFilename:f,existingAudio:p,existingVoice:g,onAudioGenerated:m,onGenerateTTS:x,audioUrl:v,voice:b="coral",onVoiceChange:_,generateButton:S,generatePrompt:A,generateSourceText:E,generateSourceError:w}){const[D,R]=y.useState(!1),[k,N]=y.useState(null),[j,F]=y.useState(!1),[C,M]=y.useState(""),[L,I]=y.useState(!1),[W,Q]=y.useState(!1),[re,U]=y.useState(null),[Y,P]=y.useState(g||b),[ie,de]=y.useState(p),[fe,ge]=y.useState(Date.now()),be=y.useRef(null),he=y.useRef(null),J=!!(u&&c&&d&&f);y.useEffect(()=>{p!==void 0&&de(p)},[p]),y.useEffect(()=>{g!==void 0&&P(g)},[g]);const xe=J&&ie&&c&&d?`${c.getFileUrl(d,ie)}?v=${fe}`:v,se=V=>{t(e?`${e}
183
+ `})]})}const Mg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Rg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Mg,...d},[g,m]=y.useState(!1),[x,v]=y.useState(""),b=y.useRef(null),_=y.useRef(null);y.useEffect(()=>{function N(j){b.current&&!b.current.contains(j.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const S=r.filter(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),A=s&&x.trim()&&!r.some(N=>{var j;return((j=N.label)==null?void 0:j.toLowerCase())===x.toLowerCase()}),E=e.map(N=>r.find(j=>j.id===N)).filter(Boolean),w=y.useCallback(N=>{var j;c>0&&e.length>=c||(t([...e,N]),v(""),c===1?m(!1):(j=_.current)==null||j.focus())},[e,t,c]),D=y.useCallback(N=>{t(e.filter(j=>j!==N))},[e,t]),R=y.useCallback(async()=>{if(!A)return;const N=await(i==null?void 0:i(x.trim()));N&&w(N.id),v("")},[A,x,i,w]),k=y.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),A?R():S.length>0&&w(S[0].id)):N.key==="Backspace"&&!x&&e.length>0?D(e[e.length-1]):N.key==="Escape"&&(m(!1),v(""))},[A,S,x,e,R,w,D]);return h.jsxs("div",{ref:b,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[E.map(N=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||p.chipBackground,color:N.color?"#fff":p.chipText},children:[N.label,!u&&h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),D(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),h.jsx("input",{ref:_,type:"text",value:x,onChange:N=>{v(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:k,placeholder:E.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:S.length===0&&!A?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[S.map(N=>h.jsxs("div",{onClick:()=>w(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:j=>{j.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:j=>{j.currentTarget.style.background=""},children:[N.label,o&&l&&h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:j=>{j.currentTarget.style.opacity="1",j.currentTarget.style.color="#ef4444"},onMouseLeave:j=>{j.currentTarget.style.opacity="0.5",j.currentTarget.style.color=p.textSecondary||""},children:"×"})]},N.id)),A&&h.jsxs("div",{onClick:R,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Fg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Lg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Fg,...u},[d,f]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),v=y.useMemo(()=>e&&r.find(D=>D.id===e)||null,[e,r]),b=y.useMemo(()=>{if(!d.trim())return r;const D=d.toLowerCase();return r.filter(R=>{var k,N;return((k=R.label)==null?void 0:k.toLowerCase().includes(D))||((N=R.notes)==null?void 0:N.toLowerCase().includes(D))})},[r,d]);y.useEffect(()=>{const D=R=>{m.current&&!m.current.contains(R.target)&&g(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const _=D=>{s&&s(D),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},A=()=>{g(!0)},E=D=>{f(D.target.value),p||g(!0)},w=D=>{D.key==="Enter"?(D.preventDefault(),b.length>0&&s?(s(b[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):D.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:v&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.label}),v.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.notes})]}),i&&h.jsx("button",{onClick:D=>{D.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:E,onFocus:A,onKeyDown:w,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:S,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:D=>{D.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:D=>{D.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:b.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):b.map((D,R)=>h.jsxs("div",{onClick:()=>_(D),style:{padding:"10px 14px",cursor:"pointer",borderBottom:R<b.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:k=>{k.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:k=>{k.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.color||c.text,marginBottom:D.notes?"2px":0},children:D.label}),D.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:D.notes})]},D.id))})]})}function Pg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=y.useState(null),[x,v]=y.useState(null),[b,_]=y.useState(null),S=y.useRef(null),A=e.reduce((j,F)=>{let C=r.filter(M=>n(M)===F.id);return s&&(C=C.sort((M,L)=>s(M)-s(L))),j[F.id]=C,j},{}),E=y.useCallback((j,F)=>{const C=t(F),M=n(F);m(C),S.current=M,j.dataTransfer.effectAllowed="move",j.dataTransfer.setData("text/plain",C),requestAnimationFrame(()=>{const L=j.target;L.style.opacity="0.5"})},[t,n]),w=y.useCallback(j=>{const F=j.target;F.style.opacity="1",m(null),v(null),_(null),S.current=null},[]),D=y.useCallback((j,F,C)=>{j.preventDefault(),j.dataTransfer.dropEffect="move",v(F),_(C)},[]),R=y.useCallback(j=>{const F=j.relatedTarget;F!=null&&F.closest("[data-kanban-column]")||(v(null),_(null))},[]),k=y.useCallback((j,F,C)=>{if(j.preventDefault(),!g)return;const M=S.current;M===F?l==null||l(g,F,C):M&&o(g,M,F,C),m(null),v(null),_(null),S.current=null},[g,o,l]),N=(j,F)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[j.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:j.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:j.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:F})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(j=>{const F=A[j.id]||[],C=x===j.id;return h.jsxs("div",{"data-kanban-column":j.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:M=>{M.preventDefault(),g&&!C&&v(j.id)},onDragLeave:R,onDrop:M=>k(M,j.id,b??F.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(j,F.length):N(j,F.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${C?"bg-blue-50":""}`,children:[F.map((M,L)=>{const I=t(M),W=g===I,Q=C&&b===L&&!W;return h.jsxs("div",{children:[Q&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:re=>E(re,M),onDragEnd:w,onDragOver:re=>D(re,j.id,L),onClick:()=>a==null?void 0:a(M),className:`cursor-grab active:cursor-grabbing transition-all ${W?"opacity-50 scale-95":""} ${p}`,children:i(M,W)})]},I)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:M=>{M.preventDefault(),D(M,j.id,F.length)},children:C&&b===F.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),F.length===0&&C&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(j)})]},j.id)})})}function Kc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function Ig(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function zg(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function Og(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const $g={"1:1":1,"2:3":1.5,"16:9":.5625};function Yc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Kc(r),o=$g[e],l=e==="2:3"?160:e==="16:9"?280:180,a=e==="2:3"||e==="16:9"?l*o:l;return h.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:l,height:a,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?h.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:h.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Qc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[l,a]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(a(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const f=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:h.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[h.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),h.jsxs("div",{style:{position:"relative"},children:[l&&h.jsx("button",{onClick:()=>f("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&h.jsx("button",{onClick:()=>f("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),h.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>h.jsx(Yc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Jc({node:r,onClose:e}){const t=Kc(r),n=Ig(r),s=zg(r),i=Og(r);return y.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),h.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:h.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),h.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[h.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?h.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),h.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:h.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),h.jsxs("div",{style:{padding:"0 32px 32px"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&h.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&h.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&h.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&h.jsxs("div",{style:{marginTop:24},children:[h.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),h.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,l])=>h.jsxs("div",{children:[h.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),h.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(l)})]},o))})]})]})]})]})})}function qg({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),l=u=>{n?n(u):i(u)},a=()=>{i(null)};return h.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>h.jsx(Qc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:l},u.id)),o.every(u=>u.nodes.length===0)&&h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[h.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),h.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&h.jsx(Jc,{node:s,onClose:a})]})}const Ug={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Wg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Hg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Vg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Gg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Ug,...g},{allDayItems:x,timedItems:v}=y.useMemo(()=>{const w=[],D=[];for(const R of r)l(R)?w.push(R):D.push(R);return{allDayItems:w,timedItems:D}},[r,l]),b=y.useMemo(()=>{const w=[];for(let D=t;D<=n;D++)w.push(D);return w},[t,n]),_=(n-t+1)*s,S=y.useCallback(w=>{const D=i(w);if(!D)return null;const R=Wg(D);if(!R)return null;const{hours:k,minutes:N}=R,j=Math.max(t,Math.min(n,k)),F=k<t?0:N,C=(j-t)*s+F/60*s,M=o(w),L=Math.max(20,M/60*s);return{top:C,height:L}},[i,o,t,n,s]),A=y.useMemo(()=>{if(!f||!Vg(e))return null;const w=new Date,D=w.getHours(),R=w.getMinutes();return D<t||D>n?null:(D-t)*s+R/60*s},[e,f,t,n,s]),E=y.useCallback(w=>{if(!d)return;const D=w.currentTarget.getBoundingClientRect(),k=(w.clientY-D.top)/s*60,N=Math.floor(k/60)+t,j=Math.round(k%60/15)*15,F=Math.min(n,Math.max(t,N)),C=j>=60?0:j,M=`${F.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`;d(M)},[d,s,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(w=>h.jsx("div",{onClick:()=>c==null?void 0:c(w),style:{cursor:c?"pointer":"default"},children:u(w)},a(w)))})]}),h.jsxs("div",{style:{position:"relative",height:_},children:[b.map((w,D)=>h.jsxs("div",{style:{position:"absolute",top:D*s,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Hg(w)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),D<b.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},w)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),A!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:A,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),v.map(w=>{const D=S(w);return D?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:D.top,height:D.height,zIndex:10,cursor:c?"pointer":"default"},onClick:R=>{R.stopPropagation(),c==null||c(w)},children:u(w)},a(w)):null})]})]})}function Xc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=y.useState("idle"),[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(0),[b,_]=y.useState(null),[S,A]=y.useState(!1),[E,w]=y.useState(null),[D,R]=y.useState(!0),[k,N]=y.useState([]),[j,F]=y.useState({completed:0,total:0}),C=y.useRef(!1),M=y.useRef(!0);y.useEffect(()=>{M.current=D},[D]);const L=y.useRef(null),I=y.useRef(null),W=y.useRef(null),Q=y.useRef(null),re=y.useRef(null),U=y.useRef([]),Y=y.useRef(null),P=y.useRef(null),ie=y.useRef(null),de=y.useRef(null),fe=y.useRef(!1),ge=y.useRef([]),be=y.useRef(null),he=y.useRef(null),J=y.useRef([]),xe=y.useRef([]),se=y.useRef("insert"),ve=y.useRef(!1),Ce=y.useRef(0),_e=y.useRef(0),Le=y.useRef(0),je=X=>{const B=Math.floor(X/60),ee=Math.floor(X%60);return`${B.toString().padStart(2,"0")}:${ee.toString().padStart(2,"0")}`},qe=async X=>{const B=await X.arrayBuffer(),ee=new AudioContext,le=await ee.decodeAudioData(B);return await ee.close(),le},V=X=>{const B=X.numberOfChannels,ee=X.sampleRate,le=1,$=16,we=$/8,ye=B*we,Se=ee*ye,Re=X.length*ye,We=new ArrayBuffer(44+Re),De=new DataView(We),Ae=(Ye,Oe)=>{for(let dt=0;dt<Oe.length;dt++)De.setUint8(Ye+dt,Oe.charCodeAt(dt))};Ae(0,"RIFF"),De.setUint32(4,36+Re,!0),Ae(8,"WAVE"),Ae(12,"fmt "),De.setUint32(16,16,!0),De.setUint16(20,le,!0),De.setUint16(22,B,!0),De.setUint32(24,ee,!0),De.setUint32(28,Se,!0),De.setUint16(32,ye,!0),De.setUint16(34,$,!0),Ae(36,"data"),De.setUint32(40,Re,!0);const tt=[];for(let Ye=0;Ye<B;Ye++)tt.push(X.getChannelData(Ye));let st=44;for(let Ye=0;Ye<X.length;Ye++)for(let Oe=0;Oe<B;Oe++){const dt=Math.max(-1,Math.min(1,tt[Oe][Ye])),ft=dt<0?dt*32768:dt*32767;De.setInt16(st,ft,!0),st+=2}return new Blob([We],{type:"audio/wav"})},O=async(X,B,ee,le)=>{const $=new AudioContext,we=X.sampleRate,ye=Math.max(X.numberOfChannels,B.numberOfChannels),Se=Math.min(ee,X.length),Re=Math.max(0,X.length-ee),We=le==="insert"?Se+B.length+Re:Se+B.length,De=$.createBuffer(ye,We,we);for(let Ae=0;Ae<ye;Ae++){const tt=De.getChannelData(Ae),st=Ae<X.numberOfChannels?X.getChannelData(Ae):X.getChannelData(0);for(let Oe=0;Oe<Se;Oe++)tt[Oe]=st[Oe];const Ye=Ae<B.numberOfChannels?B.getChannelData(Ae):B.getChannelData(0);for(let Oe=0;Oe<B.length;Oe++)tt[Se+Oe]=Ye[Oe];if(le==="insert")for(let Oe=0;Oe<Re;Oe++)tt[Se+B.length+Oe]=st[ee+Oe]}return await $.close(),De},ze=y.useCallback(()=>{const X=L.current;if(!X)return;const B=X.getContext("2d");if(!B)return;const ee=X.getBoundingClientRect(),le=ee.width,$=ee.height,we=ge.current,ye=f||c||1,Se=a==="recording"?c:x;B.fillStyle="#2d3b35",B.fillRect(0,0,le,$);const Re=8,We="rgba(0, 0, 0, 0.4)",De=B.createLinearGradient(0,0,0,Re);De.addColorStop(0,We),De.addColorStop(1,"transparent"),B.fillStyle=De,B.fillRect(0,0,le,Re);const Ae=B.createLinearGradient(0,$-Re,0,$);Ae.addColorStop(0,"transparent"),Ae.addColorStop(1,We),B.fillStyle=Ae,B.fillRect(0,$-Re,le,Re);const tt=B.createLinearGradient(0,0,Re,0);tt.addColorStop(0,We),tt.addColorStop(1,"transparent"),B.fillStyle=tt,B.fillRect(0,0,Re,$);const st=B.createLinearGradient(le-Re,0,le,0);st.addColorStop(0,"transparent"),st.addColorStop(1,We),B.fillStyle=st,B.fillRect(le-Re,0,Re,$),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,$/2),B.lineTo(le,$/2),B.stroke();const Ye=le/2;if(we.length>0)if(a==="recording")for(let ft=0;ft<we.length;ft++){const Tt=we.length-1-ft,Zt=Ye-Tt*4;if(Zt<-3||Zt>le)continue;const jt=we[ft]*($/2-12),T=$/2-jt;B.fillStyle="#10b981",B.fillRect(Zt,T,3,jt*2)}else{const ft=ye>0?Se/ye*we.length:0;for(let Tt=0;Tt<we.length;Tt++){const Zt=ft-Tt,jt=Ye-Zt*4;if(jt<-3||jt>le)continue;const T=we[Tt]*($/2-12),q=$/2-T;B.fillStyle=Tt<=ft?"#10b981":"#4b5563",B.fillRect(jt,q,3,T*2)}}B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(Ye,0),B.lineTo(Ye,$),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText(je(Se),Ye,$-6),a==="recording"&&(B.fillStyle="#ef4444",B.beginPath(),B.arc(20,20,8,0,Math.PI*2),B.fill(),B.fillStyle="#fff",B.font="10px sans-serif",B.textAlign="left",B.fillText("REC",34,24)),B.textAlign="left"},[a,x,c,f]),He=()=>{const X=re.current;if(!X||!fe.current)return;const B=X.frequencyBinCount,ee=new Uint8Array(B);X.getByteTimeDomainData(ee);let le=0;for(let ye=0;ye<B;ye++){const Se=(ee[ye]-128)/128;le+=Se*Se}const $=Math.sqrt(le/B),we=Math.min(1,$*3);ge.current.push(we),ze(),fe.current&&(P.current=requestAnimationFrame(He))},H=async()=>{try{_(null),A(!1),be.current===null&&(ge.current=[]);const X=await navigator.mediaDevices.getUserMedia({audio:!0});W.current=X;const B=new AudioContext;Q.current=B;const ee=B.createAnalyser();ee.fftSize=2048,re.current=ee,B.createMediaStreamSource(X).connect(ee);const $=new MediaRecorder(X);I.current=$,U.current=[],$.ondataavailable=we=>{we.data.size>0&&U.current.push(we.data)},$.onstop=async()=>{try{if(fe.current=!1,U.current.length===0){_("No audio was recorded. Please try again."),u("idle"),X.getTracks().forEach(De=>De.stop());return}const we=new Blob(U.current,{type:"audio/webm"});let ye,Se;if(be.current!==null&&he.current)try{const De=await qe(we),Ae=he.current.sampleRate,tt=Math.floor(be.current*Ae),st=await O(he.current,De,tt,se.current);ye=V(st),Se=st.length/st.sampleRate,se.current==="insert"&&(ge.current=[...ge.current,...xe.current]),be.current=null,he.current=null,J.current=[],xe.current=[]}catch{ye=we,Se=Ce.current>0?Ce.current:1}else ye=we,Se=Ce.current>0?Ce.current:1;if(de.current=ye,X.getTracks().forEach(De=>De.stop()),M.current&&t){N(De=>[...De,ye]),F(De=>({...De,total:De.total+1})),de.current=null,ge.current=[],v(0),p(0),d(0),u("idle");return}const Re=URL.createObjectURL(ye),We=new Audio(Re);We.ontimeupdate=()=>{v(We.currentTime)},We.onended=()=>{m(!1)},ie.current=We,p(Se),v(Se),u("editing")}catch{_("Failed to process recording"),u("idle")}},$.start(100),fe.current=!0,u("recording"),d(0),Ce.current=0,Y.current=setInterval(()=>{Ce.current+=1,d(Ce.current),Ce.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),fe.current=!1,w(null),Y.current&&(clearInterval(Y.current),Y.current=null),P.current&&(cancelAnimationFrame(P.current),P.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{_("Could not access microphone. Please allow microphone access.")}},te=()=>{fe.current=!1,A(!1),w(null),P.current&&(cancelAnimationFrame(P.current),P.current=null),Y.current&&(clearInterval(Y.current),Y.current=null),I.current&&I.current.state!=="inactive"&&I.current.stop()},ce=X=>{const B=L.current;if(!B)return;const ee=f||c;if(ee<=0)return;const le=ge.current;if(le.length===0)return;const $=B.getBoundingClientRect(),we=X-_e.current,ye=4,Se=$.width/B.width,Re=le.length/ee*ye,We=-we/(Re*Se),De=Le.current+We,Ae=Math.max(0,Math.min(De,ee));ie.current&&(ie.current.currentTime=Ae),v(Ae)},ke=()=>{ie.current&&(ie.current.currentTime=0),v(0)},Ee=()=>{const X=f||c;ie.current&&(ie.current.currentTime=X),v(X)},xt=()=>{const X=ie.current;X&&(g?(X.pause(),v(X.currentTime),m(!1)):(X.currentTime=x,X.play().catch(()=>{}),m(!0)))},bt=async X=>{if(!de.current){H();return}try{ie.current&&(ie.current.pause(),m(!1)),se.current=X,he.current=await qe(de.current);const B=f||c;be.current=x;const ee=B>0?x/B:0,le=Math.floor(ee*ge.current.length);J.current=ge.current.slice(0,le),xe.current=ge.current.slice(le),ge.current=[...J.current],H()}catch{_("Failed to prepare recording. Please try again.")}},ae=()=>{ie.current&&(ie.current.pause(),ie.current=null),de.current=null,he.current=null,be.current=null,J.current=[],m(!1),v(0),p(0),d(0),H()},pe=()=>{de.current?r(de.current,f||c):alert("No audio recorded yet!")};y.useEffect(()=>{a==="recording"&&L.current&&re.current&&fe.current&&(P.current=requestAnimationFrame(He))},[a]),y.useEffect(()=>{const X=L.current;if(!X)return;const B=()=>{const ee=window.devicePixelRatio||1,le=X.getBoundingClientRect();X.width=le.width*ee,X.height=le.height*ee;const $=X.getContext("2d");$&&$.scale(ee,ee)};return B(),window.addEventListener("resize",B),()=>window.removeEventListener("resize",B)},[]),y.useEffect(()=>{if(a==="idle"){const X=L.current;if(!X)return;const B=X.getContext("2d");if(!B)return;const ee=X.getBoundingClientRect(),le=ee.width,$=ee.height;B.fillStyle="#2d3b35",B.fillRect(0,0,le,$);const we=8,ye="rgba(0, 0, 0, 0.4)",Se=B.createLinearGradient(0,0,0,we);Se.addColorStop(0,ye),Se.addColorStop(1,"transparent"),B.fillStyle=Se,B.fillRect(0,0,le,we);const Re=B.createLinearGradient(0,$-we,0,$);Re.addColorStop(0,"transparent"),Re.addColorStop(1,ye),B.fillStyle=Re,B.fillRect(0,$-we,le,we);const We=B.createLinearGradient(0,0,we,0);We.addColorStop(0,ye),We.addColorStop(1,"transparent"),B.fillStyle=We,B.fillRect(0,0,we,$);const De=B.createLinearGradient(le-we,0,le,0);De.addColorStop(0,"transparent"),De.addColorStop(1,ye),B.fillStyle=De,B.fillRect(le-we,0,we,$),B.strokeStyle="#5a6b62",B.lineWidth=1,B.beginPath(),B.moveTo(0,$/2),B.lineTo(le,$/2),B.stroke();const Ae=le/2;B.strokeStyle="#ef4444",B.lineWidth=1,B.beginPath(),B.moveTo(Ae,0),B.lineTo(Ae,$),B.stroke(),B.fillStyle="#fff",B.font="bold 18px monospace",B.textAlign="center",B.fillText("00:00",Ae,$-6)}},[a]);const Ve=y.useCallback(X=>{N(B=>[...B,X]),F(B=>({...B,total:B.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(C.current||k.length===0||!t)return;C.current=!0;const B=k[0];try{const ee=await t(B);ee&&n&&n(ee)}catch(ee){console.error("Transcription failed:",ee)}finally{N(ee=>ee.slice(1)),F(ee=>({...ee,completed:ee.completed+1})),C.current=!1}})()},[k,t,n]),y.useEffect(()=>()=>{fe.current=!1,Y.current&&clearInterval(Y.current),P.current&&cancelAnimationFrame(P.current),W.current&&W.current.getTracks().forEach(X=>X.stop()),Q.current&&Q.current.state!=="closed"&&Q.current.close()},[]),y.useEffect(()=>{if(a==="editing"&&g){let X;const B=()=>{const ee=ie.current;if(ee&&g){const le=L.current;if(le){const $=le.getContext("2d");if($){const we=le.getBoundingClientRect(),ye=we.width,Se=we.height,Re=ge.current,We=f||c||1,De=ee.currentTime;$.fillStyle="#2d3b35",$.fillRect(0,0,ye,Se);const Ae=8,tt="rgba(0, 0, 0, 0.4)",st=$.createLinearGradient(0,0,0,Ae);st.addColorStop(0,tt),st.addColorStop(1,"transparent"),$.fillStyle=st,$.fillRect(0,0,ye,Ae);const Ye=$.createLinearGradient(0,Se-Ae,0,Se);Ye.addColorStop(0,"transparent"),Ye.addColorStop(1,tt),$.fillStyle=Ye,$.fillRect(0,Se-Ae,ye,Ae);const Oe=$.createLinearGradient(0,0,Ae,0);Oe.addColorStop(0,tt),Oe.addColorStop(1,"transparent"),$.fillStyle=Oe,$.fillRect(0,0,Ae,Se);const dt=$.createLinearGradient(ye-Ae,0,ye,0);dt.addColorStop(0,"transparent"),dt.addColorStop(1,tt),$.fillStyle=dt,$.fillRect(ye-Ae,0,Ae,Se),$.strokeStyle="#5a6b62",$.lineWidth=1,$.beginPath(),$.moveTo(0,Se/2),$.lineTo(ye,Se/2),$.stroke();const ft=ye/2,Tt=3,Zt=4,jt=We>0?De/We*Re.length:0;for(let ne=0;ne<Re.length;ne++){const me=jt-ne,Me=ft-me*Zt;if(Me<-Tt||Me>ye)continue;const Ie=Re[ne]*(Se/2-12),Ne=Se/2-Ie;$.fillStyle=ne<=jt?"#10b981":"#4b5563",$.fillRect(Me,Ne,Tt,Ie*2)}$.strokeStyle="#ef4444",$.lineWidth=1,$.beginPath(),$.moveTo(ft,0),$.lineTo(ft,Se),$.stroke(),$.fillStyle="#fff",$.font="bold 18px monospace",$.textAlign="center";const T=Math.floor(De/60),q=Math.floor(De%60);$.fillText(`${T.toString().padStart(2,"0")}:${q.toString().padStart(2,"0")}`,ft,Se-6),$.textAlign="left"}}X=requestAnimationFrame(B)}};return X=requestAnimationFrame(B),()=>cancelAnimationFrame(X)}},[a,g,f,c]),y.useEffect(()=>{a==="editing"&&!g&&ze()},[a,x,g,ze]),b)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:b}),h.jsx("button",{onClick:()=>{_(null),H()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Ke={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Ue={...Ke,opacity:.3,cursor:"not-allowed"},ct=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:ct,children:[h.jsx("canvas",{ref:L,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:X=>{if(a==="editing"){ve.current=!0,_e.current=X.clientX,Le.current=x;const B=le=>{ve.current&&ce(le.clientX)},ee=()=>{ve.current=!1,window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",ee)};window.addEventListener("mousemove",B),window.addEventListener("mouseup",ee)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:ke,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ue:Ke,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const X=I.current;X&&(X.state==="recording"?(X.pause(),A(!0)):X.state==="paused"&&(X.resume(),A(!1)))}else xt()},disabled:a==="idle",style:a==="idle"?Ue:Ke,title:g||a==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ee,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ue:Ke,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),h.jsx("button",{onClick:()=>{E==="insert"?te():a==="idle"?(w("insert"),H()):a==="editing"&&(w("insert"),bt("insert"))},disabled:a==="recording"&&E!=="insert"||g,style:a==="recording"&&E!=="insert"||g?Ue:Ke,title:E==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{M.current||(E==="mic"?te():a==="idle"?(w("mic"),H()):a==="editing"&&(w("mic"),bt("replace")))},onMouseDown:()=>{M.current&&a==="idle"&&!g&&(w("mic"),H())},onMouseUp:()=>{M.current&&a==="recording"&&E==="mic"&&te()},onMouseLeave:()=>{M.current&&a==="recording"&&E==="mic"&&te()},onTouchStart:X=>{X.preventDefault(),M.current&&a==="idle"&&!g&&(w("mic"),H())},onTouchEnd:X=>{X.preventDefault(),M.current&&a==="recording"&&E==="mic"&&te()},disabled:a==="recording"&&E!=="mic"||g,style:a==="recording"&&E!=="mic"||g?Ue:Ke,title:D?"Hold to record (walkie-talkie)":E==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{E==="startover"?te():a==="editing"&&(w("startover"),ae())},disabled:a==="idle"||a==="recording"&&E!=="startover"||g,style:a==="idle"||a==="recording"&&E!=="startover"||g?Ue:Ke,title:E==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[j.total>0&&j.completed<j.total&&h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),j.completed,"/",j.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>R(!D),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:D?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:D?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:D?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&de.current&&Ve(de.current)},disabled:a!=="editing",style:a!=="editing"?Ue:Ke,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:D?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:pe,disabled:a!=="editing",style:a!=="editing"?Ue:Ke,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),j.total>0&&j.completed<j.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${j.completed/j.total*100}%`,transition:"width 0.3s ease"}})})]})}function Kg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,placeholder:o="Type or record...",className:l="",rows:a,llmClient:u,graphClient:c,nodeId:d,audioFilename:f,existingAudio:p,existingVoice:g,onAudioGenerated:m,onGenerateTTS:x,audioUrl:v,voice:b="coral",onVoiceChange:_,generateButton:S,generatePrompt:A,generateSourceText:E,generateSourceError:w}){const[D,R]=y.useState(!1),[k,N]=y.useState(null),[j,F]=y.useState(!1),[C,M]=y.useState(""),[L,I]=y.useState(!1),[W,Q]=y.useState(!1),[re,U]=y.useState(null),[Y,P]=y.useState(g||b),[ie,de]=y.useState(p),[fe,ge]=y.useState(Date.now()),be=y.useRef(null),he=y.useRef(null),J=!!(u&&c&&d&&f);y.useEffect(()=>{p!==void 0&&de(p)},[p]),y.useEffect(()=>{g!==void 0&&P(g)},[g]);const xe=J&&ie&&c&&d?`${c.getFileUrl(d,ie)}?v=${fe}`:v,se=V=>{t(e?`${e}
184
184
 
185
185
  ${V}`:V)},ve=async V=>{if(!(!(typeof e=="string"?e:"").trim()||D||!s)){R(!0),N(V),F(!1);try{const O=await s(V,e);t(O)}catch(O){console.error(`${V} failed:`,O)}finally{R(!1),N(null)}}},Ce=()=>{setTimeout(()=>{var V;(V=be.current)!=null&&V.contains(document.activeElement)||F(!1)},150)},_e=async()=>{if(!(!C.trim()||D||!i)){R(!0),N(C);try{const V=await i(C,e);t(V),M("")}catch(V){console.error("AI prompt failed:",V)}finally{R(!1),N(null)}}},Le=async()=>{if(!(typeof e=="string"?e:"").trim()||L)return;if(!(J||x)){console.warn("TTS: No generation mode available",{integratedTTS:J,hasCallback:!!x,llmClient:!!u,graphClient:!!c,nodeId:d,audioFilename:f}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}he.current&&(he.current.pause(),he.current.currentTime=0),I(!0);try{if(J&&u&&c&&d&&f){console.log("TTS: Generating audio...",{voice:Y,textLength:e.length});const O=await u.tts(e,{voice:Y});console.log("TTS: Audio generated, uploading...",{audioLength:O==null?void 0:O.length});const ze=atob(O),He=new Uint8Array(ze.length);for(let ce=0;ce<ze.length;ce++)He[ce]=ze.charCodeAt(ce);const H=new Blob([He],{type:"audio/mpeg"}),te=new File([H],f,{type:"audio/mpeg"});await c.uploadFile(d,f,te),console.log("TTS: Upload complete",{nodeId:d,audioFilename:f}),ge(Date.now()),de(f),m==null||m(f,Y)}else x&&(await x(e,Y),ge(Date.now()))}catch(O){console.error("TTS generation failed:",O),alert("Erreur TTS: "+(O instanceof Error?O.message:"Erreur inconnue"))}finally{I(!1)}},je=async()=>{if(!(!u||!A||W)){if(!(E!=null&&E.trim())){U(w||"Le texte source est requis pour la génération.");return}Q(!0),U(null);try{const V=await u.chat([{role:"system",content:A},{role:"user",content:E}]);t(V)}catch(V){U(V instanceof Error?V.message:"Erreur de génération")}finally{Q(!1)}}},qe=V=>{P(V),_==null||_(V)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${l}`,children:[h.jsx(Xc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:se,hideSaveButton:!0,variant:"div"}),i&&h.jsxs("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200",children:[h.jsx("textarea",{value:C,onChange:V=>M(V.target.value),onKeyDown:V=>{V.stopPropagation(),V.key==="Enter"&&V.ctrlKey&&(V.preventDefault(),_e())},placeholder:"Instructions AI... (Ctrl+Enter pour envoyer)",disabled:D,rows:5,className:"flex-1 pl-0 pr-2 py-2 text-sm border-0 resize-y min-h-[80px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50"}),h.jsx("button",{type:"button",onClick:_e,disabled:D||!C.trim(),className:"self-start p-2 text-neutral-700 hover:text-neutral-900 transition-colors disabled:opacity-30",title:"Envoyer (Ctrl+Enter)",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:D?"hourglass_empty":"smart_toy"})})]}),(r||s||(typeof e=="string"?e:"").trim()||J||x||S)&&h.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[r&&h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),S&&u&&A&&h.jsxs("button",{type:"button",onClick:je,disabled:W,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:S.label,children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:W?"hourglass_empty":S.icon||"auto_awesome"}),S.label]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?e:"").trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),(J||x)&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("select",{value:Y,onChange:V=>qe(V.target.value),disabled:L,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(V=>h.jsxs("option",{value:V.id,children:[V.name," - ",V.description]},V.id))}),h.jsx("button",{type:"button",onClick:Le,disabled:L||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:L?"Génération en cours...":"Générer audio TTS",children:h.jsx("span",{className:`material-icons ${L?"animate-pulse text-blue-600":xe?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:L?"hourglass_empty":"record_voice_over"})}),xe&&h.jsxs(h.Fragment,{children:[h.jsx("audio",{ref:he,src:xe,controls:!0,className:"h-6 w-32"},fe),h.jsx("button",{type:"button",onClick:()=>{he.current&&he.current.pause(),de(void 0),m==null||m("",Y)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:h.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]}),s&&h.jsxs("div",{className:"relative",ref:be,children:[h.jsx("button",{type:"button",onClick:()=>F(!j),disabled:D||!(typeof e=="string"?e:"").trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:D?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),k==="restructure"&&"Restructuring...",k==="proofread"&&"Proofreading...",k==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),j&&!D&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:Ce,children:[h.jsxs("button",{type:"button",onClick:()=>ve("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>ve("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>ve("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:V=>t(V.target.value),onKeyDown:V=>V.stopPropagation(),placeholder:o,rows:a,disabled:D||W,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),re&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),h.jsx("p",{className:"text-sm text-neutral-600",children:re})]})]}),h.jsx("div",{className:"mt-4 flex justify-end",children:h.jsx("button",{type:"button",onClick:()=>U(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Yg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=y.useRef(null),a=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[f,p]=y.useState(null),[g,m]=y.useState(n),[x,v]=y.useState(0),[b,_]=y.useState({x:0,y:0,width:100,height:100}),[S,A]=y.useState(!1),[E,w]=y.useState(null),[D,R]=y.useState({x:0,y:0}),[k,N]=y.useState({x:0,y:0,width:100,height:100}),j=o==="dark",F=y.useCallback(()=>{const J=u.current;return J?x===90||x===270?{width:J.height,height:J.width}:{width:J.width,height:J.height}:{width:100,height:100}},[x]),C=y.useCallback((J,xe)=>{const se=J/xe,ve=.05;for(const[Ce,_e]of Object.entries(gs))if(_e!==null&&Math.abs(se-_e)/_e<ve)return Ce;return"free"},[]);y.useEffect(()=>{const J=new Image;J.crossOrigin="anonymous",J.onload=()=>{u.current=J;const xe=C(J.width,J.height);m(xe),d(!1)},J.onerror=()=>{p("Failed to load image"),d(!1)},J.src=r},[r,C]);const M=y.useCallback(()=>{const{width:J,height:xe}=F(),se=gs[g];if(se===null){_({x:0,y:0,width:100,height:100});return}const ve=J/xe;let Ce,_e;ve>se?(_e=100,Ce=se/ve*100):(Ce=100,_e=ve/se*100);const Le=(100-Ce)/2,je=(100-_e)/2;_({x:Le,y:je,width:Ce,height:_e})},[g,F]);y.useEffect(()=>{u.current&&M()},[g,x,M]),y.useEffect(()=>{const J=a.current,xe=u.current;if(!J||!xe||c)return;const se=J.getContext("2d");if(!se)return;const ve=l.current;if(!ve)return;const Ce=ve.clientWidth,_e=ve.clientHeight-140,{width:Le,height:je}=F(),qe=Le/je;let V,O;Ce/_e>qe?(O=Math.min(_e,je),V=O*qe):(V=Math.min(Ce,Le),O=V/qe),V>Ce&&(V=Ce,O=V/qe),O>_e&&(O=_e,V=O*qe),J.width=V,J.height=O,se.clearRect(0,0,V,O),se.save(),se.translate(V/2,O/2),se.rotate(x*Math.PI/180);let ze,He;x===90||x===270?(ze=O,He=V):(ze=V,He=O),se.drawImage(xe,-ze/2,-He/2,ze,He),se.restore(),se.fillStyle="rgba(0, 0, 0, 0.6)";const H=b.x/100*V,te=b.y/100*O,ce=b.width/100*V,ke=b.height/100*O;se.fillRect(0,0,V,te),se.fillRect(0,te+ke,V,O-te-ke),se.fillRect(0,te,H,ke),se.fillRect(H+ce,te,V-H-ce,ke),se.strokeStyle="#fff",se.lineWidth=2,se.strokeRect(H,te,ce,ke),se.strokeStyle="rgba(255, 255, 255, 0.3)",se.lineWidth=1,se.beginPath(),se.moveTo(H+ce/3,te),se.lineTo(H+ce/3,te+ke),se.moveTo(H+ce*2/3,te),se.lineTo(H+ce*2/3,te+ke),se.moveTo(H,te+ke/3),se.lineTo(H+ce,te+ke/3),se.moveTo(H,te+ke*2/3),se.lineTo(H+ce,te+ke*2/3),se.stroke();const Ee=14;se.fillStyle="#fff",se.strokeStyle="#333",se.lineWidth=1,[{x:H,y:te},{x:H+ce,y:te},{x:H,y:te+ke},{x:H+ce,y:te+ke}].forEach(bt=>{se.fillRect(bt.x-Ee/2,bt.y-Ee/2,Ee,Ee),se.strokeRect(bt.x-Ee/2,bt.y-Ee/2,Ee,Ee)})},[b,x,c,F]);const L=J=>{const xe=a.current;if(!xe)return;const se=xe.getBoundingClientRect(),ve=(J.clientX-se.left)/se.width*100,Ce=(J.clientY-se.top)/se.height*100,_e=4,Le=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const je of Le)if(Math.abs(ve-je.x)<_e&&Math.abs(Ce-je.y)<_e){w(je.name),R({x:ve,y:Ce}),N({...b});return}ve>=b.x&&ve<=b.x+b.width&&Ce>=b.y&&Ce<=b.y+b.height&&(A(!0),R({x:ve,y:Ce}),N({...b}))},I=J=>{const xe=a.current;if(!xe)return;const se=xe.getBoundingClientRect(),ve=(J.clientX-se.left)/se.width*100,Ce=(J.clientY-se.top)/se.height*100;if(S){const _e=ve-D.x,Le=Ce-D.y;let je=k.x+_e,qe=k.y+Le;je=Math.max(0,Math.min(je,100-k.width)),qe=Math.max(0,Math.min(qe,100-k.height)),_({...k,x:je,y:qe})}else if(E){const _e=gs[g],{width:Le,height:je}=F(),qe=Le/je,V=_e?_e/qe:null;let O={...k};const ze=ve-D.x,He=Ce-D.y;if(E==="se")O.width=Math.max(10,Math.min(100-O.x,k.width+ze)),V?(O.height=O.width/V,O.y+O.height>100&&(O.height=100-O.y,O.width=O.height*V)):O.height=Math.max(10,Math.min(100-O.y,k.height+He));else if(E==="sw"){const H=-ze,te=Math.max(10,k.width+H),ce=k.x+k.width-te;ce>=0&&(O.width=te,O.x=ce,V?(O.height=O.width/V,O.y+O.height>100&&(O.height=100-O.y,O.width=O.height*V,O.x=k.x+k.width-O.width)):O.height=Math.max(10,Math.min(100-O.y,k.height+He)))}else if(E==="ne")if(O.width=Math.max(10,Math.min(100-O.x,k.width+ze)),V){const H=O.width/V,te=k.y+k.height-H;te>=0?(O.height=H,O.y=te):(O.y=0,O.height=k.y+k.height,O.width=O.height*V)}else{const H=-He,te=Math.max(10,k.height+H),ce=k.y+k.height-te;ce>=0&&(O.height=te,O.y=ce)}else if(E==="nw"){const H=-ze,te=Math.max(10,k.width+H),ce=k.x+k.width-te;if(ce>=0)if(O.width=te,O.x=ce,V){const ke=O.width/V,Ee=k.y+k.height-ke;Ee>=0?(O.height=ke,O.y=Ee):(O.y=0,O.height=k.y+k.height,O.width=O.height*V,O.x=k.x+k.width-O.width)}else{const ke=-He,Ee=Math.max(10,k.height+ke),xt=k.y+k.height-Ee;xt>=0&&(O.height=Ee,O.y=xt)}}O.x=Math.max(0,O.x),O.y=Math.max(0,O.y),O.width=Math.min(O.width,100-O.x),O.height=Math.min(O.height,100-O.y),_(O)}},W=()=>{A(!1),w(null)},Q=J=>{v(xe=>J==="right"?(xe+90)%360:(xe-90+360)%360)},re=()=>{const J=u.current;if(!J)return;const{width:xe,height:se}=F(),ve=b.x/100*xe,Ce=b.y/100*se,_e=b.width/100*xe,Le=b.height/100*se,je=document.createElement("canvas"),qe=je.getContext("2d");if(!qe)return;je.width=_e,je.height=Le;const V=document.createElement("canvas"),O=V.getContext("2d");O&&(V.width=xe,V.height=se,O.save(),O.translate(xe/2,se/2),O.rotate(x*Math.PI/180),O.drawImage(J,-J.width/2,-J.height/2,J.width,J.height),O.restore(),qe.drawImage(V,ve,Ce,_e,Le,0,0,_e,Le),je.toBlob(ze=>{ze&&e(ze)},s,i))},U={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:j?"#1a1a1a":"#f5f5f5",overflow:"hidden"},Y={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},P={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${j?"#333":"#ddd"}`,background:j?"#242424":"#fff",flexShrink:0},ie={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},de={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},fe={...de,background:"#E67E22",color:"#fff"},ge={...de,background:j?"#333":"#e5e5e5",color:j?"#fff":"#333"},be={padding:"10px",borderRadius:"8px",border:"none",background:j?"#333":"#e5e5e5",color:j?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},he=J=>({padding:"8px 14px",borderRadius:"6px",border:J?"2px solid #E67E22":"2px solid transparent",background:J?"#E67E22":j?"#333":"#e5e5e5",color:J?"#fff":j?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...U,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:j?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...U,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...ge,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:U,children:[h.jsx("div",{style:Y,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":E?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:L,onMouseMove:I,onMouseUp:W,onMouseLeave:W})}),h.jsxs("div",{style:P,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(J=>h.jsx("button",{onClick:()=>m(J),style:he(g===J),children:J==="free"?"Libre":J},J))}),h.jsxs("div",{style:ie,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>Q("left"),style:be,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>Q("right"),style:be,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:ge,children:"Annuler"}),h.jsx("button",{onClick:re,style:fe,children:"Enregistrer"})]})]})]})]})}var Qg={value:()=>{}};function la(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function Jg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Jg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Xg(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=zl(t[s],r.name,e);else if(e==null)for(s in t)t[s]=zl(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function Xg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function zl(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Qg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Ol={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _i(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[e],local:r}:r}function Zg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function e0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Zc(r){var e=_i(r);return(e.local?e0:Zg)(e)}function t0(){}function ua(r){return r==null?t0:function(){return this.querySelector(r)}}function r0(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=new Array(o),a,u,c=0;c<o;++c)(a=i[c])&&(u=r.call(a,a.__data__,c,i))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new At(n,this._parents)}function n0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function s0(){return[]}function ed(r){return r==null?s0:function(){return this.querySelectorAll(r)}}function i0(r){return function(){return n0(r.apply(this,arguments))}}function o0(r){typeof r=="function"?r=i0(r):r=ed(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),s.push(a));return new At(n,s)}function td(r){return function(){return this.matches(r)}}function rd(r){return function(e){return e.matches(r)}}var a0=Array.prototype.find;function l0(r){return function(){return a0.call(this.children,r)}}function u0(){return this.firstElementChild}function c0(r){return this.select(r==null?u0:l0(typeof r=="function"?r:rd(r)))}var d0=Array.prototype.filter;function f0(){return Array.from(this.children)}function h0(r){return function(){return d0.call(this.children,r)}}function p0(r){return this.selectAll(r==null?f0:h0(typeof r=="function"?r:rd(r)))}function g0(r){typeof r!="function"&&(r=td(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new At(n,this._parents)}function nd(r){return new Array(r.length)}function m0(){return new At(this._enter||this._groups.map(nd),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function y0(r){return function(){return r}}function x0(r,e,t,n,s,i){for(var o=0,l,a=e.length,u=i.length;o<u;++o)(l=e[o])?(l.__data__=i[o],n[o]=l):t[o]=new Qs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function b0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?s[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,i[l],l,i)+"",(a=u.get(p))?(n[l]=a,a.__data__=i[l],u.delete(p)):t[l]=new Qs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function v0(r){return r.__data__}function _0(r,e){if(!arguments.length)return Array.from(this,v0);var t=e?b0:x0,n=this._parents,s=this._groups;typeof r!="function"&&(r=y0(r));for(var i=s.length,o=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=w0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),v=a[u]=new Array(f);t(c,d,m,x,v,p,e);for(var b=0,_=0,S,A;b<g;++b)if(S=m[b]){for(b>=_&&(_=b+1);!(A=x[_])&&++_<g;);S._next=A||null}}return o=new At(o,n),o._enter=l,o._exit=a,o}function w0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function C0(){return new At(this._exit||this._groups.map(nd),this._parents)}function S0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function k0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),l=new Array(s),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<s;++a)l[a]=t[a];return new At(l,this._parents)}function E0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function D0(r){r||(r=A0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],l=o.length,a=s[i]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new At(s,this._parents).order()}function A0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function T0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function N0(){return Array.from(this)}function B0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function j0(){let r=0;for(const e of this)++r;return r}function M0(){return!this.node()}function R0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,l;i<o;++i)(l=s[i])&&r.call(l,l.__data__,i,s);return this}function F0(r){return function(){this.removeAttribute(r)}}function L0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function P0(r,e){return function(){this.setAttribute(r,e)}}function I0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function z0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function $0(r,e){var t=_i(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?L0:F0:typeof e=="function"?t.local?O0:z0:t.local?I0:P0)(t,e))}function sd(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function q0(r){return function(){this.style.removeProperty(r)}}function U0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function W0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function H0(r,e,t){return arguments.length>1?this.each((e==null?q0:typeof e=="function"?W0:U0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||sd(r).getComputedStyle(r,null).getPropertyValue(e)}function V0(r){return function(){delete this[r]}}function G0(r,e){return function(){this[r]=e}}function K0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Y0(r,e){return arguments.length>1?this.each((e==null?V0:typeof e=="function"?K0:G0)(r,e)):this.node()[r]}function id(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new od(r)}function od(r){this._node=r,this._names=id(r.getAttribute("class")||"")}od.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function ad(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function Q0(r){return function(){ad(this,r)}}function J0(r){return function(){ld(this,r)}}function X0(r,e){return function(){(e.apply(this,arguments)?ad:ld)(this,r)}}function Z0(r,e){var t=id(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?X0:e?Q0:J0)(t,e))}function em(){this.textContent=""}function tm(r){return function(){this.textContent=r}}function rm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function nm(r){return arguments.length?this.each(r==null?em:(typeof r=="function"?rm:tm)(r)):this.node().textContent}function sm(){this.innerHTML=""}function im(r){return function(){this.innerHTML=r}}function om(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function am(r){return arguments.length?this.each(r==null?sm:(typeof r=="function"?om:im)(r)):this.node().innerHTML}function lm(){this.nextSibling&&this.parentNode.appendChild(this)}function um(){return this.each(lm)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function dm(){return this.each(cm)}function fm(r){var e=typeof r=="function"?r:Zc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function hm(){return null}function pm(r,e){var t=typeof r=="function"?r:Zc(r),n=e==null?hm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function gm(){var r=this.parentNode;r&&r.removeChild(this)}function mm(){return this.each(gm)}function ym(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function xm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(r){return this.select(r?xm:ym)}function vm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function _m(r){return function(e){r.call(this,e,this.__data__)}}function wm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Cm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function Sm(r,e,t){return function(){var n=this.__on,s,i=_m(e);if(n){for(var o=0,l=n.length;o<l;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function km(r,e,t){var n=wm(r+""),s,i=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(s=0,c=l[a];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?Sm:Cm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function ud(r,e,t){var n=sd(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function Em(r,e){return function(){return ud(this,r,e)}}function Dm(r,e){return function(){return ud(this,r,e.apply(this,arguments))}}function Am(r,e){return this.each((typeof e=="function"?Dm:Em)(r,e))}function*Tm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var cd=[null];function At(r,e){this._groups=r,this._parents=e}function ss(){return new At([[document.documentElement]],cd)}function Nm(){return this}At.prototype=ss.prototype={constructor:At,select:r0,selectAll:o0,selectChild:c0,selectChildren:p0,filter:g0,data:_0,enter:m0,exit:C0,join:S0,merge:k0,selection:Nm,order:E0,sort:D0,call:T0,nodes:N0,node:B0,size:j0,empty:M0,each:R0,attr:$0,style:H0,property:Y0,classed:Z0,text:nm,html:am,raise:um,lower:dm,append:fm,insert:pm,remove:mm,clone:bm,datum:vm,on:km,dispatch:Am,[Symbol.iterator]:Tm};function Lt(r){return typeof r=="string"?new At([[document.querySelector(r)]],[document.documentElement]):new At([[r]],cd)}function Bm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=Bm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const vo={capture:!0,passive:!1};function _o(r){r.preventDefault(),r.stopImmediatePropagation()}function jm(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",_o,vo);"onselectstart"in e?t.on("selectstart.drag",_o,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Mm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",_o,vo),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function dd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rm=/^#([0-9a-f]{3,8})$/,Fm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Lm=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Pm=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),Im=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),zm=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Om=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:$m,formatHsl:qm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function $m(){return this.rgb().formatHex8()}function qm(){return fd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Rm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new Ct(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Fm.exec(r))?new Ct(e[1],e[2],e[3],1):(e=Lm.exec(r))?new Ct(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Pm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Im.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=zm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new Ct(NaN,NaN,NaN,0):null}function Wl(r){return new Ct(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new Ct(r,e,t,n)}function Um(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new Ct(r.r,r.g,r.b,r.opacity)):new Ct}function wo(r,e,t,n){return arguments.length===1?Um(r):new Ct(r,e,t,n??1)}function Ct(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(Ct,wo,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new Ct(Tr(this.r),Tr(this.g),Tr(this.b),Xs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Wm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Wm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function fd(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,l=i-s,a=(i+s)/2;return l?(e===i?o=(t-n)/l+(t<n)*6:t===i?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?i+s:2-i-s,o*=60):l=a>0&&a<1?0:o,new Pt(o,l,a,r.opacity)}function Hm(r,e,t,n){return arguments.length===1?fd(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Pt,Hm,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new Ct(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Pt(Kl(this.h),ys(this.s),ys(this.l),Xs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Xs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const hd=r=>()=>r;function Vm(r,e){return function(t){return r+t*e}}function Gm(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Km(r){return(r=+r)==1?pd:function(e,t){return t-e?Gm(e,t,r):hd(isNaN(e)?t:e)}}function pd(r,e){var t=e-r;return t?Vm(r,t):hd(isNaN(r)?e:r)}const Yl=function r(e){var t=Km(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=pd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Ym(r){return function(){return r}}function Qm(r){return function(e){return r(e)+""}}function Jm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,a.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?Qm(a[0].x):Ym(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gd(r,e,t,n,s,i){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(a)*Ql,scaleX:o,scaleY:l}}var xs;function Xm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:gd(e.a,e.b,e.c,e.d,e.e,e.f)}function Zm(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,gd(r.a,r.b,r.c,r.d,r.e,r.f))}function md(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var ey=md(Xm,"px, ","px)","deg)"),ty=md(Zm,", ",")",")"),ry=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function ny(r){return((r=Math.exp(r))-1/r)/2}function sy(r){return((r=Math.exp(2*r))-1)/(r+1)}const iy=function r(e,t,n){function s(i,o){var l=i[0],a=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,v;if(m<ry)v=Math.log(f/u)/e,x=function(w){return[l+w*p,a+w*g,u*Math.exp(e*w*v)]};else{var b=Math.sqrt(m),_=(f*f-u*u+n*m)/(2*u*t*b),S=(f*f-u*u-n*m)/(2*f*t*b),A=Math.log(Math.sqrt(_*_+1)-_),E=Math.log(Math.sqrt(S*S+1)-S);v=(E-A)/e,x=function(w){var D=w*v,R=Jl(A),k=u/(t*b)*(R*sy(e*D+A)-ny(A));return[l+k*p,a+k*g,u*R/Jl(e*D+A)]}}return x.duration=v*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),l=o*o,a=l*l;return r(o,l,a)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,yd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,xd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(xd(oy),Lr=Wn.now()+wi)}function oy(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=bd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function bd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function ay(){fa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{ay()}finally{nn=0,uy(),Lr=0}}function ly(){var r=Wn.now(),e=r-ei;e>yd&&(wi-=e,ei=r)}function uy(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,ko(n)}function ko(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(ly,yd)),nn=1,xd(Xl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var cy=la("start","end","cancel","interrupt"),dy=[],vd=0,eu=1,Eo=2,Ss=3,tu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;fy(r,t,{name:e,index:n,group:s,on:cy,tween:dy,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vd})}function ha(r,e){var t=qt(r,e);if(t.state>vd)throw new Error("too late; already scheduled");return t}function Xt(r,e){var t=qt(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function fy(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=bd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==eu)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Do,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function hy(r){return this.each(function(){Es(this,r)})}function py(r,e){var t,n;return function(){var s=Xt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function gy(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Xt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var l={name:e,value:t},a=0,u=s.length;a<u;++a)if(s[a].name===e){s[a]=l;break}a===u&&s.push(l)}i.tween=s}}function my(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?py:gy)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Xt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return qt(s,n).value[e]}}function _d(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Jm)(r,e)}function yy(r){return function(){this.removeAttribute(r)}}function xy(r){return function(){this.removeAttributeNS(r.space,r.local)}}function by(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function vy(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function _y(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function wy(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function Cy(r,e){var t=_i(r),n=t==="transform"?ty:_d;return this.attrTween(r,typeof e=="function"?(t.local?wy:_y)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?xy:yy)(t):(t.local?vy:by)(t,n,e))}function Sy(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function ky(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function Ey(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ky(r,i)),t}return s._value=e,s}function Dy(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Sy(r,i)),t}return s._value=e,s}function Ay(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=_i(r);return this.tween(t,(n.local?Ey:Dy)(n,e))}function Ty(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function Ny(r,e){return e=+e,function(){ha(this,r).delay=e}}function By(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?Ty:Ny)(e,r)):qt(this.node(),e).delay}function jy(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function My(r,e){return e=+e,function(){Xt(this,r).duration=e}}function Ry(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?jy:My)(e,r)):qt(this.node(),e).duration}function Fy(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function Ly(r){var e=this._id;return arguments.length?this.each(Fy(e,r)):qt(this.node(),e).ease}function Py(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function Iy(r){if(typeof r!="function")throw new Error;return this.each(Py(this._id,r))}function zy(r){typeof r!="function"&&(r=td(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new ir(n,this._parents,this._name,this._id)}function Oy(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),l=0;l<i;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function $y(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function qy(r,e,t){var n,s,i=$y(e)?ha:Xt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function Uy(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(qy(t,r,e))}function Wy(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function Hy(){return this.on("end.remove",Wy(this._id))}function Vy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var l=n[o],a=l.length,u=i[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function Gy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ed(r));for(var n=this._groups,s=n.length,i=[],o=[],l=0;l<s;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=qt(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var Ky=ss.prototype.constructor;function Yy(){return new Ky(this._groups,this._parents)}function Qy(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function wd(r){return function(){this.style.removeProperty(r)}}function Jy(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function Xy(r,e,t){var n,s,i;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l))}}function Zy(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Xt(this,r),u=a.on,c=a.value[i]==null?l||(l=wd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function e2(r,e,t){var n=(r+="")=="transform"?ey:_d;return e==null?this.styleTween(r,Qy(r,n)).on("end.style."+r,wd(r)):typeof e=="function"?this.styleTween(r,Xy(r,n,pa(this,"style."+r,e))).each(Zy(this._id,r)):this.styleTween(r,Jy(r,n,e),t).on("end.style."+r,null)}function t2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function r2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&t2(r,o,t)),n}return i._value=e,i}function n2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,r2(r,e,t??""))}function s2(r){return function(){this.textContent=r}}function i2(r){return function(){var e=r(this);this.textContent=e??""}}function o2(r){return this.tween("text",typeof r=="function"?i2(pa(this,"text",r)):s2(r==null?"":r+""))}function a2(r){return function(e){this.textContent=r.call(this,e)}}function l2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&a2(s)),e}return n._value=r,n}function u2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,l2(r))}function c2(){for(var r=this._name,e=this._id,t=Cd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=qt(a,e);Ci(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function d2(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var l={value:o},a={value:function(){--s===0&&i()}};t.each(function(){var u=Xt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),s===0&&i()})}var f2=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Cd(){return++f2}var tr=ss.prototype;ir.prototype={constructor:ir,select:Vy,selectAll:Gy,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:zy,merge:Oy,selection:Yy,transition:c2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:Uy,attr:Cy,attrTween:Ay,style:e2,styleTween:n2,text:o2,textTween:u2,remove:Hy,tween:my,delay:By,duration:Ry,ease:Ly,easeVarying:Iy,end:d2,[Symbol.iterator]:tr[Symbol.iterator]};function h2(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var p2={time:null,delay:0,duration:250,ease:h2};function g2(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function m2(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=Cd(),(t=p2).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ci(a,r,e,u,o,t||g2(a,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=hy;ss.prototype.transition=m2;const bs=r=>()=>r;function y2(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new nr(1,0,0);nr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function x2(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function b2(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function v2(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function _2(){return navigator.maxTouchPoints||"ontouchstart"in this}function w2(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function C2(){var r=x2,e=b2,t=w2,n=v2,s=_2,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=iy,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function v(C){C.property("__zoom",ru).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",k).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(C,M,L,I){var W=C.selection?C.selection():C;W.property("__zoom",ru),C!==W?A(C,M,L,I):W.interrupt().each(function(){E(this,arguments).event(I).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},v.scaleBy=function(C,M,L,I){v.scaleTo(C,function(){var W=this.__zoom.k,Q=typeof M=="function"?M.apply(this,arguments):M;return W*Q},L,I)},v.scaleTo=function(C,M,L,I){v.transform(C,function(){var W=e.apply(this,arguments),Q=this.__zoom,re=L==null?S(W):typeof L=="function"?L.apply(this,arguments):L,U=Q.invert(re),Y=typeof M=="function"?M.apply(this,arguments):M;return t(_(b(Q,Y),re,U),W,o)},L,I)},v.translateBy=function(C,M,L,I){v.transform(C,function(){return t(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof L=="function"?L.apply(this,arguments):L),e.apply(this,arguments),o)},null,I)},v.translateTo=function(C,M,L,I,W){v.transform(C,function(){var Q=e.apply(this,arguments),re=this.__zoom,U=I==null?S(Q):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(U[0],U[1]).scale(re.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof L=="function"?-L.apply(this,arguments):-L),Q,o)},I,W)};function b(C,M){return M=Math.max(i[0],Math.min(i[1],M)),M===C.k?C:new nr(M,C.x,C.y)}function _(C,M,L){var I=M[0]-L[0]*C.k,W=M[1]-L[1]*C.k;return I===C.x&&W===C.y?C:new nr(C.k,I,W)}function S(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,M,L,I){C.on("start.zoom",function(){E(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(I).end()}).tween("zoom",function(){var W=this,Q=arguments,re=E(W,Q).event(I),U=e.apply(W,Q),Y=L==null?S(U):typeof L=="function"?L.apply(W,Q):L,P=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),ie=W.__zoom,de=typeof M=="function"?M.apply(W,Q):M,fe=a(ie.invert(Y).concat(P/ie.k),de.invert(Y).concat(P/de.k));return function(ge){if(ge===1)ge=de;else{var be=fe(ge),he=P/be[2];ge=new nr(he,Y[0]-be[0]*he,Y[1]-be[1]*he)}re.zoom(null,ge)}})}function E(C,M,L){return!L&&C.__zooming||new w(C,M)}function w(C,M){this.that=C,this.args=M,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,M),this.taps=0}w.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,M){return this.mouse&&C!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var M=Lt(this.that).datum();u.call(C,this.that,new y2(C,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),M)}};function D(C,...M){if(!r.apply(this,arguments))return;var L=E(this,M).event(C),I=this.__zoom,W=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),Q=wr(C);if(L.wheel)(L.mouse[0][0]!==Q[0]||L.mouse[0][1]!==Q[1])&&(L.mouse[1]=I.invert(L.mouse[0]=Q)),clearTimeout(L.wheel);else{if(I.k===W)return;L.mouse=[Q,I.invert(Q)],Es(this),L.start()}xn(C),L.wheel=setTimeout(re,g),L.zoom("mouse",t(_(b(I,W),L.mouse[0],L.mouse[1]),L.extent,o));function re(){L.wheel=null,L.end()}}function R(C,...M){if(f||!r.apply(this,arguments))return;var L=C.currentTarget,I=E(this,M,!0).event(C),W=Lt(C.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",P,!0),Q=wr(C,L),re=C.clientX,U=C.clientY;jm(C.view),Wi(C),I.mouse=[Q,this.__zoom.invert(Q)],Es(this),I.start();function Y(ie){if(xn(ie),!I.moved){var de=ie.clientX-re,fe=ie.clientY-U;I.moved=de*de+fe*fe>m}I.event(ie).zoom("mouse",t(_(I.that.__zoom,I.mouse[0]=wr(ie,L),I.mouse[1]),I.extent,o))}function P(ie){W.on("mousemove.zoom mouseup.zoom",null),Mm(ie.view,I.moved),xn(ie),I.event(ie).end()}}function k(C,...M){if(r.apply(this,arguments)){var L=this.__zoom,I=wr(C.changedTouches?C.changedTouches[0]:C,this),W=L.invert(I),Q=L.k*(C.shiftKey?.5:2),re=t(_(b(L,Q),I,W),e.apply(this,M),o);xn(C),l>0?Lt(this).transition().duration(l).call(A,re,I,C):Lt(this).call(v.transform,re,I,C)}}function N(C,...M){if(r.apply(this,arguments)){var L=C.touches,I=L.length,W=E(this,M,C.changedTouches.length===I).event(C),Q,re,U,Y;for(Wi(C),re=0;re<I;++re)U=L[re],Y=wr(U,this),Y=[Y,this.__zoom.invert(Y),U.identifier],W.touch0?!W.touch1&&W.touch0[2]!==Y[2]&&(W.touch1=Y,W.taps=0):(W.touch0=Y,Q=!0,W.taps=1+!!c);c&&(c=clearTimeout(c)),Q&&(W.taps<2&&(d=Y[0],c=setTimeout(function(){c=null},p)),Es(this),W.start())}}function j(C,...M){if(this.__zooming){var L=E(this,M).event(C),I=C.changedTouches,W=I.length,Q,re,U,Y;for(xn(C),Q=0;Q<W;++Q)re=I[Q],U=wr(re,this),L.touch0&&L.touch0[2]===re.identifier?L.touch0[0]=U:L.touch1&&L.touch1[2]===re.identifier&&(L.touch1[0]=U);if(re=L.that.__zoom,L.touch1){var P=L.touch0[0],ie=L.touch0[1],de=L.touch1[0],fe=L.touch1[1],ge=(ge=de[0]-P[0])*ge+(ge=de[1]-P[1])*ge,be=(be=fe[0]-ie[0])*be+(be=fe[1]-ie[1])*be;re=b(re,Math.sqrt(ge/be)),U=[(P[0]+de[0])/2,(P[1]+de[1])/2],Y=[(ie[0]+fe[0])/2,(ie[1]+fe[1])/2]}else if(L.touch0)U=L.touch0[0],Y=L.touch0[1];else return;L.zoom("touch",t(_(re,U,Y),L.extent,o))}}function F(C,...M){if(this.__zooming){var L=E(this,M).event(C),I=C.changedTouches,W=I.length,Q,re;for(Wi(C),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),Q=0;Q<W;++Q)re=I[Q],L.touch0&&L.touch0[2]===re.identifier?delete L.touch0:L.touch1&&L.touch1[2]===re.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(re=wr(re,this),Math.hypot(d[0]-re[0],d[1]-re[1])<x)){var U=Lt(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return v.wheelDelta=function(C){return arguments.length?(n=typeof C=="function"?C:bs(+C),v):n},v.filter=function(C){return arguments.length?(r=typeof C=="function"?C:bs(!!C),v):r},v.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:bs(!!C),v):s},v.extent=function(C){return arguments.length?(e=typeof C=="function"?C:bs([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),v):e},v.scaleExtent=function(C){return arguments.length?(i[0]=+C[0],i[1]=+C[1],v):[i[0],i[1]]},v.translateExtent=function(C){return arguments.length?(o[0][0]=+C[0][0],o[1][0]=+C[1][0],o[0][1]=+C[0][1],o[1][1]=+C[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(C){return arguments.length?(t=C,v):t},v.duration=function(C){return arguments.length?(l=+C,v):l},v.interpolate=function(C){return arguments.length?(a=C,v):a},v.on=function(){var C=u.on.apply(u,arguments);return C===u?v:C},v.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,v):Math.sqrt(m)},v.tapDistance=function(C){return arguments.length?(x=+C,v):x},v}function Sd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=y.useRef(null),a=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!l.current)return;const x=C2().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const _={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(_),o==null||o(_)});a.current=x;const v=Lt(l.current);return v.call(x),v.on("dblclick.zoom",null),n&&v.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{v.on(".zoom",null)}},[e,t,s,i]),y.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const v={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(v),o==null||o(v)})},[o]);const d=y.useCallback((x,v,b,_=!0)=>{if(!l.current||!a.current)return;const S=Lt(l.current),A=ri.translate(x,v).scale(b);S.call(a.current.transform,A)},[]),f=y.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,v=50)=>{if(!l.current||!a.current||x.length===0)return;const _=l.current.getBoundingClientRect();let S=1/0,A=1/0,E=-1/0,w=-1/0;for(const I of x){const W=I.width||200,Q=I.height||100;S=Math.min(S,I.x),A=Math.min(A,I.y),E=Math.max(E,I.x+W),w=Math.max(w,I.y+Q)}const D=E-S,R=w-A,k=(_.width-v*2)/D,N=(_.height-v*2)/R,j=Math.min(k,N,t),F=(S+E)/2,C=(A+w)/2,M=_.width/2-F*j,L=_.height/2-C*j;d(M,L,j,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function kd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=y.useState(null),[a,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),f=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((_,S)=>{const A=g.current;return{x:(_-A.x)/A.k,y:(S-A.y)/A.k}},[]),x=y.useCallback((_,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const A=S.currentTarget,E=parseFloat(A.dataset.x||"0"),w=parseFloat(A.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:E,nodeY:w},p.current={x:E,y:w},l(_),u(!0),d({x:0,y:0}),t==null||t(_)},[i,m,t]),v=y.useCallback(_=>{if(!a||!o||!f.current)return;const S=g.current,A=f.current,E=_.clientX-A.x,w=_.clientY-A.y,D=E/S.k,R=w/S.k,k=A.nodeX+D,N=A.nodeY+R;p.current={x:k,y:N},d({x:D,y:R}),n==null||n(o,k,N,D,R)},[a,o,n]),b=y.useCallback(()=>{if(!a||!o)return;const _=p.current;s==null||s(o,_.x,_.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return y.useEffect(()=>{if(!a)return;const _=A=>{v(A)},S=()=>{b()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",S)}},[a,v,b]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:v,endDrag:b}}function Ed(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,l]=y.useState(new Set),a=s!==void 0,u=a?new Set(s):o,c=a?k=>{const N=typeof k=="function"?k(u):k;i==null||i(Array.from(N))}:l,[d,f]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),v=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{v.current=t},[t]);const b=y.useCallback((k,N)=>{const j=x.current;return{x:(k-j.x)/j.k,y:(N-j.y)/j.k}},[]),_=y.useCallback((k,N)=>{const j=v.current.get(k);if(!j)return!1;const F=j.width||200,C=j.height||100;return j.x<N.x+N.width&&j.x+F>N.x&&j.y<N.y+N.height&&j.y+C>N.y},[]),S=y.useCallback(k=>{if(n||k.target.closest("[data-qmap-node]"))return;k.preventDefault();const j=b(k.clientX,k.clientY);m.current=j,f({x:j.x,y:j.y,width:0,height:0}),g(!0),k.shiftKey||c(new Set)},[n,b]),A=y.useCallback(k=>{if(!p||!m.current)return;const N=m.current,j=b(k.clientX,k.clientY),F={x:Math.min(N.x,j.x),y:Math.min(N.y,j.y),width:Math.abs(j.x-N.x),height:Math.abs(j.y-N.y)};f(F);const C=new Set;for(const[M]of v.current)_(M,F)&&C.add(M);c(C)},[p,b,_]),E=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const k=j=>{A(j)},N=()=>{E()};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",N)}},[p,A,E]);const w=y.useCallback((k,N=!1)=>{c(j=>{const F=new Set(N?j:[]);return j.has(k)&&N?F.delete(k):F.add(k),i==null||i(Array.from(F)),F})},[i]),D=y.useCallback(()=>{const k=new Set(v.current.keys());c(k),i==null||i(Array.from(k))},[i]),R=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:A,endSelection:E,toggleSelect:w,selectAll:D,clearSelection:R}}const Dd=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,nodeRef:c,children:d}){const f=y.useCallback(v=>{i&&v.button===0&&o(e,v)},[e,i,o]),p=y.useCallback(v=>{s||l==null||l(v)},[s,l]),g=y.useCallback(v=>{v.stopPropagation(),a==null||a(v)},[a]),m=y.useCallback(v=>{v.preventDefault(),v.stopPropagation(),u==null||u(v)},[u]),x=t.rotation||0;return h.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:f,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Ad(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return k2(n,s);case"bezier":default:return S2(n,s)}}function S2(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+i*Math.sign(t),a=r.y,u=e.x-i*Math.sign(t),c=e.y):(l=r.x,a=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function k2(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function E2(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const l=t/2,a=n/2,u=Math.abs(o/(i||.001)),c=a/l;let d,f;return u<c?(d=s.x+(i>0?l:-l),f=s.y+o*l/Math.abs(i)):(f=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:f}}function D2(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return ga(r)}}function A2(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function T2(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function N2(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,l=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+l)}return{x:e,y:t,width:n-e,height:s-t}}function B2(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function j2(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Td=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=y.useState(!1),c=y.useMemo(()=>Ad(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=y.useCallback(()=>{u(!0)},[]),p=y.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(M2,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function M2({pathD:r,label:e,color:t}){const n=y.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Nd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=y.useMemo(()=>e.filter(a=>t.has(a.source)&&t.has(a.target)),[e,t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(a=>{const u=t.get(a.source),c=t.get(a.target);return h.jsx(Td,{edge:a,sourcePosition:u,targetPosition:c,style:a.style||n,color:a.color||s,width:a.width||i,onClick:o},a.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Bd=y.memo(function({box:e,transform:t}){const n=y.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return h.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),R2=200,F2=100,L2="bezier",P2="#94a3b8",I2=2,z2=.1,O2=4;function $2({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=R2,defaultNodeHeight:i=F2,onNodeMove:o,onNodeDrag:l,onNodeClick:a,onNodeDoubleClick:u,onNodeContextMenu:c,selectedIds:d,onSelectionChange:f,onEdgeClick:p,onViewChange:g,onTransformChange:m,minZoom:x=z2,maxZoom:v=O2,initialTransform:b,defaultEdgeStyle:_=L2,defaultEdgeColor:S=P2,defaultEdgeWidth:A=I2,draggable:E=!0,selectable:w=!0,zoomable:D=!0,pannable:R=!0,className:k="",style:N,background:j="#f8fafc",showGrid:F=!1,gridSize:C=20}){const M=r.data||{positions:{}},L=M.positions||{},I=y.useMemo(()=>{const H=new Map;for(const te of e){const ce=L[te._id]||{x:0,y:0};H.set(te._id,{x:ce.x,y:ce.y,width:ce.width||s,height:ce.height||i,rotation:ce.rotation||0})}return H},[e,L,s,i]),{transform:W,containerRef:Q,zoomIn:re,zoomOut:U,resetZoom:Y,fitToContent:P}=Sd({minZoom:x,maxZoom:v,initialTransform:b||M.transform,zoomable:D,pannable:R,onTransformChange:H=>{m==null||m(H);const te={...M,transform:H};g==null||g(te)}}),[ie,de]=y.useState(new Map),[fe,ge]=y.useState(new Map),be=y.useRef(new Map);y.useEffect(()=>{const H=new Map;be.current.forEach((ce,ke)=>{if(ce){const Ee=ce.getBoundingClientRect();H.set(ke,{width:Ee.width,height:Ee.height})}}),e.some(ce=>{const ke=H.get(ce._id),Ee=fe.get(ce._id);return ke?Ee?ke.width!==Ee.width||ke.height!==Ee.height:!0:!1})&&ge(H)},[e,fe]);const{draggedNodeId:he,startDrag:J}=kd({transform:W,disabled:!E,onDragStart:H=>{const te=I.get(H);te&&de(new Map([[H,{x:te.x,y:te.y}]]))},onDragMove:(H,te,ce)=>{de(new Map([[H,{x:te,y:ce}]])),l==null||l(H,te,ce)},onDragEnd:(H,te,ce)=>{de(new Map),o==null||o(H,te,ce)}}),{selectedIds:xe,selectionBox:se,isSelecting:ve,startSelection:Ce,toggleSelect:_e,clearSelection:Le}=Ed({transform:W,nodePositions:I,disabled:!w,controlledSelectedIds:d,onSelectionChange:f}),je=y.useCallback(H=>{const te=I.get(H)||{x:0,y:0,width:s,height:i},ce=ie.get(H),ke=fe.get(H),Ee=(ke==null?void 0:ke.width)||te.width||s,xt=(ke==null?void 0:ke.height)||te.height||i;return ce?{...te,x:ce.x,y:ce.y,width:Ee,height:xt}:{...te,width:Ee,height:xt}},[I,ie,fe,s,i]),qe=y.useMemo(()=>{const H=new Map;for(const te of I.keys())H.set(te,je(te));return H},[I,je]),V=y.useCallback((H,te)=>{_e(H._id,te.shiftKey),a==null||a(H,te)},[_e,a]),O=y.useCallback(H=>{H.target.closest("[data-qmap-node]")||Le()},[Le]),ze=y.useCallback(H=>{H.button===0&&(H.target.closest("[data-qmap-node]")||Ce(H))},[Ce]),He=F?`
186
186
  linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),