rayo-editor 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +563 -0
  2. package/dist/components/BlogEditor.d.ts +4 -0
  3. package/dist/components/BlogEditor.d.ts.map +1 -0
  4. package/dist/components/DiffOverlay.d.ts +4 -0
  5. package/dist/components/DiffOverlay.d.ts.map +1 -0
  6. package/dist/components/ImageGenerationLoader.d.ts +5 -0
  7. package/dist/components/ImageGenerationLoader.d.ts.map +1 -0
  8. package/dist/components/RayoEditor.d.ts +74 -0
  9. package/dist/components/RayoEditor.d.ts.map +1 -0
  10. package/dist/components/ReviewButtons.d.ts +4 -0
  11. package/dist/components/ReviewButtons.d.ts.map +1 -0
  12. package/dist/components/TitleTextarea.d.ts +4 -0
  13. package/dist/components/TitleTextarea.d.ts.map +1 -0
  14. package/dist/components/index.d.ts +7 -0
  15. package/dist/components/index.d.ts.map +1 -0
  16. package/dist/hooks/index.d.ts +3 -0
  17. package/dist/hooks/index.d.ts.map +1 -0
  18. package/dist/hooks/useContentProcessing.d.ts +83 -0
  19. package/dist/hooks/useContentProcessing.d.ts.map +1 -0
  20. package/dist/hooks/useEditorDiff.d.ts +65 -0
  21. package/dist/hooks/useEditorDiff.d.ts.map +1 -0
  22. package/dist/index.d.ts +213 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.mjs +1011 -0
  25. package/dist/index.umd.js +32 -0
  26. package/dist/styles.css +1150 -0
  27. package/dist/types/diff.types.d.ts +84 -0
  28. package/dist/types/diff.types.d.ts.map +1 -0
  29. package/dist/types/editor.types.d.ts +59 -0
  30. package/dist/types/editor.types.d.ts.map +1 -0
  31. package/dist/utils/contentProcessing.d.ts +81 -0
  32. package/dist/utils/contentProcessing.d.ts.map +1 -0
  33. package/dist/utils/diffDetection.d.ts +85 -0
  34. package/dist/utils/diffDetection.d.ts.map +1 -0
  35. package/dist/utils/errorHandling.d.ts +57 -0
  36. package/dist/utils/errorHandling.d.ts.map +1 -0
  37. package/dist/utils/imageHandling.d.ts +52 -0
  38. package/dist/utils/imageHandling.d.ts.map +1 -0
  39. package/dist/utils/index.d.ts +6 -0
  40. package/dist/utils/index.d.ts.map +1 -0
  41. package/dist/utils/proximityMatching.d.ts +80 -0
  42. package/dist/utils/proximityMatching.d.ts.map +1 -0
  43. package/package.json +70 -0
@@ -0,0 +1,32 @@
1
+ (function(g,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],y):(g=typeof globalThis<"u"?globalThis:g||self,y(g.RayoEditor={},g.React))})(this,function(g,y){"use strict";var J={exports:{}},N={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var re;function Ae(){if(re)return N;re=1;var a=y,o=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function x(p,m,_){var b,j={},w=null,D=null;_!==void 0&&(w=""+_),m.key!==void 0&&(w=""+m.key),m.ref!==void 0&&(D=m.ref);for(b in m)s.call(m,b)&&!l.hasOwnProperty(b)&&(j[b]=m[b]);if(p&&p.defaultProps)for(b in m=p.defaultProps,m)j[b]===void 0&&(j[b]=m[b]);return{$$typeof:o,type:p,key:w,ref:D,props:j,_owner:i.current}}return N.Fragment=n,N.jsx=x,N.jsxs=x,N}var W={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var ne;function Me(){return ne||(ne=1,process.env.NODE_ENV!=="production"&&function(){var a=y,o=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),x=Symbol.for("react.provider"),p=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),ce=Symbol.iterator,et="@@iterator";function tt(e){if(e===null||typeof e!="object")return null;var t=ce&&e[ce]||e[et];return typeof t=="function"?t:null}var F=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),u=1;u<t;u++)r[u-1]=arguments[u];rt("error",e,r)}}function rt(e,t,r){{var u=F.ReactDebugCurrentFrame,d=u.getStackAddendum();d!==""&&(t+="%s",r=r.concat([d]));var h=r.map(function(f){return String(f)});h.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,h)}}var nt=!1,at=!1,ot=!1,it=!1,st=!1,fe;fe=Symbol.for("react.module.reference");function ut(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===l||st||e===i||e===_||e===b||it||e===D||nt||at||ot||typeof e=="object"&&e!==null&&(e.$$typeof===w||e.$$typeof===j||e.$$typeof===x||e.$$typeof===p||e.$$typeof===m||e.$$typeof===fe||e.getModuleId!==void 0))}function lt(e,t,r){var u=e.displayName;if(u)return u;var d=t.displayName||t.name||"";return d!==""?r+"("+d+")":r}function de(e){return e.displayName||"Context"}function O(e){if(e==null)return null;if(typeof e.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case s:return"Fragment";case n:return"Portal";case l:return"Profiler";case i:return"StrictMode";case _:return"Suspense";case b:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var t=e;return de(t)+".Consumer";case x:var r=e;return de(r._context)+".Provider";case m:return lt(e,e.render,"ForwardRef");case j:var u=e.displayName||null;return u!==null?u:O(e.type)||"Memo";case w:{var d=e,h=d._payload,f=d._init;try{return O(f(h))}catch{return null}}}return null}var k=Object.assign,L=0,ve,ge,pe,he,me,ye,be;function Re(){}Re.__reactDisabledLog=!0;function ct(){{if(L===0){ve=console.log,ge=console.info,pe=console.warn,he=console.error,me=console.group,ye=console.groupCollapsed,be=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Re,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}L++}}function ft(){{if(L--,L===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},e,{value:ve}),info:k({},e,{value:ge}),warn:k({},e,{value:pe}),error:k({},e,{value:he}),group:k({},e,{value:me}),groupCollapsed:k({},e,{value:ye}),groupEnd:k({},e,{value:be})})}L<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var K=F.ReactCurrentDispatcher,H;function z(e,t,r){{if(H===void 0)try{throw Error()}catch(d){var u=d.stack.trim().match(/\n( *(at )?)/);H=u&&u[1]||""}return`
18
+ `+H+e}}var X=!1,B;{var dt=typeof WeakMap=="function"?WeakMap:Map;B=new dt}function Ee(e,t){if(!e||X)return"";{var r=B.get(e);if(r!==void 0)return r}var u;X=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var h;h=K.current,K.current=null,ct();try{if(t){var f=function(){throw Error()};if(Object.defineProperty(f.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(f,[])}catch(C){u=C}Reflect.construct(e,[],f)}else{try{f.call()}catch(C){u=C}e.call(f.prototype)}}else{try{throw Error()}catch(C){u=C}e()}}catch(C){if(C&&u&&typeof C.stack=="string"){for(var c=C.stack.split(`
19
+ `),T=u.stack.split(`
20
+ `),R=c.length-1,E=T.length-1;R>=1&&E>=0&&c[R]!==T[E];)E--;for(;R>=1&&E>=0;R--,E--)if(c[R]!==T[E]){if(R!==1||E!==1)do if(R--,E--,E<0||c[R]!==T[E]){var P=`
21
+ `+c[R].replace(" at new "," at ");return e.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",e.displayName)),typeof e=="function"&&B.set(e,P),P}while(R>=1&&E>=0);break}}}finally{X=!1,K.current=h,ft(),Error.prepareStackTrace=d}var M=e?e.displayName||e.name:"",I=M?z(M):"";return typeof e=="function"&&B.set(e,I),I}function vt(e,t,r){return Ee(e,!1)}function gt(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function U(e,t,r){if(e==null)return"";if(typeof e=="function")return Ee(e,gt(e));if(typeof e=="string")return z(e);switch(e){case _:return z("Suspense");case b:return z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case m:return vt(e.render);case j:return U(e.type,t,r);case w:{var u=e,d=u._payload,h=u._init;try{return U(h(d),t,r)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,xe={},_e=F.ReactDebugCurrentFrame;function G(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);_e.setExtraStackFrame(r)}else _e.setExtraStackFrame(null)}function pt(e,t,r,u,d){{var h=Function.call.bind(V);for(var f in e)if(h(e,f)){var c=void 0;try{if(typeof e[f]!="function"){var T=Error((u||"React class")+": "+r+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw T.name="Invariant Violation",T}c=e[f](t,f,u,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(R){c=R}c&&!(c instanceof Error)&&(G(d),S("%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).",u||"React class",r,f,typeof c),G(null)),c instanceof Error&&!(c.message in xe)&&(xe[c.message]=!0,G(d),S("Failed %s type: %s",r,c.message),G(null))}}}var ht=Array.isArray;function Z(e){return ht(e)}function mt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function yt(e){try{return je(e),!1}catch{return!0}}function je(e){return""+e}function we(e){if(yt(e))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",mt(e)),je(e)}var Y=F.ReactCurrentOwner,bt={key:!0,ref:!0,__self:!0,__source:!0},Se,Te,Q;Q={};function Rt(e){if(V.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Et(e){if(V.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function xt(e,t){if(typeof e.ref=="string"&&Y.current&&t&&Y.current.stateNode!==t){var r=O(Y.current.type);Q[r]||(S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',O(Y.current.type),e.ref),Q[r]=!0)}}function _t(e,t){{var r=function(){Se||(Se=!0,S("%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)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function jt(e,t){{var r=function(){Te||(Te=!0,S("%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)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var wt=function(e,t,r,u,d,h,f){var c={$$typeof:o,type:e,key:t,ref:r,props:f,_owner:h};return c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function St(e,t,r,u,d){{var h,f={},c=null,T=null;r!==void 0&&(we(r),c=""+r),Et(t)&&(we(t.key),c=""+t.key),Rt(t)&&(T=t.ref,xt(t,d));for(h in t)V.call(t,h)&&!bt.hasOwnProperty(h)&&(f[h]=t[h]);if(e&&e.defaultProps){var R=e.defaultProps;for(h in R)f[h]===void 0&&(f[h]=R[h])}if(c||T){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;c&&_t(f,E),T&&jt(f,E)}return wt(e,c,T,d,u,Y.current,f)}}var $=F.ReactCurrentOwner,Ce=F.ReactDebugCurrentFrame;function A(e){if(e){var t=e._owner,r=U(e.type,e._source,t?t.type:null);Ce.setExtraStackFrame(r)}else Ce.setExtraStackFrame(null)}var q;q=!1;function ee(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function Pe(){{if($.current){var e=O($.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function Tt(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),r=e.lineNumber;return`
24
+
25
+ Check your code at `+t+":"+r+"."}return""}}var Oe={};function Ct(e){{var t=Pe();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
26
+
27
+ Check the top-level render call using <`+r+">.")}return t}}function De(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Ct(t);if(Oe[r])return;Oe[r]=!0;var u="";e&&e._owner&&e._owner!==$.current&&(u=" It was passed a child from "+O(e._owner.type)+"."),A(e),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,u),A(null)}}function ke(e,t){{if(typeof e!="object")return;if(Z(e))for(var r=0;r<e.length;r++){var u=e[r];ee(u)&&De(u,t)}else if(ee(e))e._store&&(e._store.validated=!0);else if(e){var d=tt(e);if(typeof d=="function"&&d!==e.entries)for(var h=d.call(e),f;!(f=h.next()).done;)ee(f.value)&&De(f.value,t)}}}function Pt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===m||t.$$typeof===j))r=t.propTypes;else return;if(r){var u=O(t);pt(r,e.props,"prop",u,e)}else if(t.PropTypes!==void 0&&!q){q=!0;var d=O(t);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ot(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var u=t[r];if(u!=="children"&&u!=="key"){A(e),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",u),A(null);break}}e.ref!==null&&(A(e),S("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}var Ie={};function Fe(e,t,r,u,d,h){{var f=ut(e);if(!f){var c="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(c+=" 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 T=Tt(d);T?c+=T:c+=Pe();var R;e===null?R="null":Z(e)?R="array":e!==void 0&&e.$$typeof===o?(R="<"+(O(e.type)||"Unknown")+" />",c=" Did you accidentally export a JSX literal instead of a component?"):R=typeof e,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,c)}var E=St(e,t,r,d,h);if(E==null)return E;if(f){var P=t.children;if(P!==void 0)if(u)if(Z(P)){for(var M=0;M<P.length;M++)ke(P[M],e);Object.freeze&&Object.freeze(P)}else S("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 ke(P,e)}if(V.call(t,"key")){var I=O(e),C=Object.keys(t).filter(function(Mt){return Mt!=="key"}),te=C.length>0?"{key: someKey, "+C.join(": ..., ")+": ...}":"{key: someKey}";if(!Ie[I+te]){var At=C.length>0?"{"+C.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
28
+ let props = %s;
29
+ <%s {...props} />
30
+ React keys must be passed directly to JSX without using spread:
31
+ let props = %s;
32
+ <%s key={someKey} {...props} />`,te,I,At,I),Ie[I+te]=!0}}return e===s?Ot(E):Pt(E),E}}function Dt(e,t,r){return Fe(e,t,r,!0)}function kt(e,t,r){return Fe(e,t,r,!1)}var It=kt,Ft=Dt;W.Fragment=s,W.jsx=It,W.jsxs=Ft}()),W}process.env.NODE_ENV==="production"?J.exports=Ae():J.exports=Me();var v=J.exports;const ae=({title:a,onTitleChange:o,readOnly:n})=>{const s=y.useRef(null),i=y.useCallback(()=>{const l=s.current;l&&(l.style.height="auto",l.style.height=`${l.scrollHeight}px`)},[]);return y.useEffect(()=>{i()},[a,i]),v.jsx("textarea",{ref:s,value:a,onChange:l=>{o==null||o(l.target.value),i()},placeholder:"Enter blog title...",className:"w-full text-2xl font-bold outline-none resize-none",readOnly:n,rows:1,"data-testid":"title-textarea"})},oe=({diffPairs:a,overlayHoleRect:o,onPairHover:n,onPairClick:s})=>a.length===0?null:v.jsxs("div",{className:"fixed inset-0 pointer-events-none","data-testid":"diff-overlay",style:{zIndex:40},children:[a.map((i,l)=>v.jsx("div",{className:"absolute border-2 border-green-400",style:{top:`${i.rect.top}px`,left:`${i.rect.left}px`,width:`${i.rect.width}px`,height:`${i.rect.bottom-i.rect.top}px`},onMouseEnter:()=>n==null?void 0:n(l),onClick:()=>s==null?void 0:s(l),"data-testid":`diff-pair-${l}`},l)),o&&v.jsx("div",{className:"absolute pointer-events-auto",style:{top:`${o.top}px`,bottom:`${o.bottom}px`,left:0,right:0,zIndex:50},"data-testid":"overlay-hole"})]}),Ne=()=>v.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[v.jsx("path",{d:"M9 15.75C5.27175 15.75 2.25 12.7282 2.25 9C2.25 5.27175 5.27175 2.25 9 2.25C12.7282 2.25 15.75 5.27175 15.75 9C15.75 12.7282 12.7282 15.75 9 15.75Z",stroke:"white",strokeWidth:"1.5"}),v.jsx("path",{d:"M12 7.5L8.25 11.25L6 9",stroke:"white",strokeWidth:"1.5"})]}),We=()=>v.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:v.jsx("path",{d:"M2.25 15.75V2.25H12.5325L15.75 5.4675V15.75H2.25ZM5.99625 2.25V5.99625M5.99625 2.25H11.9962M11.9962 2.25V5.99625M5.25 15.75V9H12.75V15.75",stroke:"#AFB0B6",strokeWidth:"1.5"})}),ie=({onAccept:a,onReject:o,position:n})=>v.jsxs("div",{className:"fixed flex gap-2 z-50",style:{top:`${n.top}px`,left:`${n.left}px`},"data-testid":"review-buttons",children:[v.jsx("button",{onClick:a,className:"p-2 bg-green-500 rounded hover:bg-green-600",title:"Accept changes","data-testid":"accept-button",children:v.jsx(Ne,{})}),v.jsx("button",{onClick:o,className:"p-2 bg-red-500 rounded hover:bg-red-600",title:"Reject changes","data-testid":"reject-button",children:v.jsx(We,{})})]}),se=(a,o)=>{const[n,s]=y.useState([]),[i,l]=y.useState(-1),[x,p]=y.useState(-1),[m,_]=y.useState(null),b=y.useRef(!1),j=y.useRef(0),w=y.useCallback(()=>{if(!(b.current||Date.now()-j.current<500))try{b.current=!0,s([])}finally{b.current=!1,j.current=Date.now()}},[]);return y.useEffect(()=>{w()},[w]),{diffPairs:n,setDiffPairs:s,activePairIndex:i,setActivePairIndex:l,hoverPairIndex:x,setHoverPairIndex:p,overlayHoleRect:m,setOverlayHoleRect:_,updateDiffRanges:w}},ue=({content:a,title:o,onChange:n,onTitleChange:s,isLoading:i,showDiffs:l,focusMode:x,readOnly:p,editorRef:m})=>{const[_]=y.useState({top:0,left:0}),{diffPairs:b,overlayHoleRect:j,setActivePairIndex:w}=se();return v.jsxs("div",{className:`rayo-blog-editor ${x?"focus-mode":""}`,"data-testid":"blog-editor",children:[v.jsx("div",{className:"mb-6","data-testid":"title-section",children:v.jsx(ae,{title:o,onTitleChange:s,readOnly:p})}),v.jsxs("div",{className:"relative","data-testid":"content-section",children:[v.jsx("textarea",{value:a,onChange:D=>n(D.target.value),className:"w-full min-h-96 p-4 border rounded font-mono text-sm",placeholder:"Blog content...",readOnly:p,"data-testid":"content-textarea"}),l&&b.length>0&&v.jsxs(v.Fragment,{children:[v.jsx(oe,{diffPairs:b,overlayHoleRect:j,onPairClick:w}),v.jsx(ie,{onAccept:()=>n(a),onReject:()=>n(a),position:_})]})]}),i&&v.jsx("div",{className:"mt-4 p-4 bg-gray-100 rounded","data-testid":"loading-state",children:"Loading..."})]})},Le=a=>v.jsx("div",{className:"rayo-editor","data-testid":"rayo-editor",children:v.jsx(ue,{...a})}),Ve=({isLoading:a})=>a?v.jsxs("div",{className:"flex items-center justify-center p-4","data-testid":"image-loader",children:[v.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),v.jsx("span",{className:"ml-2",children:"Generating image..."})]}):null,Ye=(a="")=>{const[o,n]=y.useState(a),[s,i]=y.useState(!1),[l,x]=y.useState(null),p=y.useCallback(m=>{try{i(!0),x(null),n(m)}catch(_){x(_ instanceof Error?_:new Error("Unknown error"))}finally{i(!1)}},[]);return{content:o,setContent:n,isProcessing:s,error:l,processContent:p}},ze=a=>{try{const o=/<(ins|del)\b/i.test(a)||/data-color="#c7f0d6ff"/i.test(a)||/data-color="#fecaca"/i.test(a)||/data-pending-delete="true"/i.test(a)||/data-pending-insert="true"/i.test(a),n=[];if(!o)return{hasDiffs:!1,markers:[]};const s=/<ins\b[^>]*>([\s\S]*?)<\/ins>/gi;let i;for(;(i=s.exec(a))!==null;)n.push({type:"insertion",from:i.index,to:i.index+i[0].length});const l=/<del\b[^>]*>([\s\S]*?)<\/del>/gi;for(;(i=l.exec(a))!==null;)n.push({type:"deletion",from:i.index,to:i.index+i[0].length});return/data-color="#c7f0d6ff"/i.test(a)&&n.push({type:"highlight",color:"#c7f0d6ff"}),/data-color="#fecaca"/i.test(a)&&n.push({type:"highlight",color:"#fecaca"}),{hasDiffs:!0,markers:n}}catch(o){return console.warn("Diff detection failed:",o),{hasDiffs:!1,markers:[]}}},Be=a=>{try{return a.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[\u2010-\u2015\u2212\uFE58\uFE63\uFF0D]/g,"-").replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000]/g," ").replace(/[\u2018\u2019\u201A\u201B]/g,"'").replace(/[\u201C\u201D\u201E\u201F]/g,'"').replace(/[\u200B-\u200D\uFEFF]/g,"").replace(/\s+/g," ").trim()}catch(o){return console.warn("Text normalization failed:",o),a}},Ue=a=>[];function le(a){if(a.length===0)return[];const o=[...a].sort((i,l)=>i.from-l.from),n=[];let s=o[0];for(let i=1;i<o.length;i++){const l=o[i];l.from<=s.to?s={from:s.from,to:Math.max(s.to,l.to)}:(n.push(s),s=l)}return n.push(s),n}function Ge(a,o){return a.substring(o.from,o.to)}function Je(a){const o=a.filter(n=>n.from<n.to);return le(o)}const Ke=a=>{if(a.length===0)return[];const o=[];let n=[];for(const s of a)if(n.length===0)n.push(s);else{const i=n[n.length-1];s.pos===i.pos+i.nodeSize?n.push(s):(o.push(n),n=[s])}return n.length>0&&o.push(n),o},He=(a,o)=>{const n=[],s=new Set;for(const i of a){const l=[];let x=i.pos+i.nodeSize;for(let p=0;p<o.length;p++)s.has(p)||o[p].pos===x&&(l.push(o[p]),s.add(p),x=o[p].pos+o[p].nodeSize);l.length>0?n.push({redRange:{from:i.pos,to:i.pos+i.nodeSize},greenRange:{from:l[0].pos,to:l[l.length-1].pos+l[l.length-1].nodeSize},rect:i.rect,lastGreenRect:l[l.length-1].rect,isImageReplacement:!0,newImagesCount:l.length}):n.push({redRange:{from:i.pos,to:i.pos+i.nodeSize},greenRange:void 0,rect:i.rect,lastGreenRect:i.rect,isImageDeletion:!0})}return n},Xe=(a,o)=>{const n=Math.abs(a.from-o.to),s=Math.abs(o.from-a.to);return Math.min(n,s)},Ze=(a,o,n)=>{var l,x,p,m;if(n.length<=1)return n[0]||null;let s=null,i=1/0;for(const _ of n){const b=Math.min(((l=_.redRange)==null?void 0:l.from)??1/0,((x=_.greenRange)==null?void 0:x.from)??1/0),j=Math.max(((p=_.redRange)==null?void 0:p.to)??0,((m=_.greenRange)==null?void 0:m.to)??0),w=Math.min(Math.abs(a-b),Math.abs(a-j));w<i&&(i=w,s=_)}return s},Qe=a=>{if(a.length===0)return[];const o=[];let n=[];for(const s of a)if(n.length===0)n.push(s);else{const i=n[n.length-1];s.pos===i.pos+i.nodeSize?n.push(s):(o.push(n),n=[s])}return n.length>0&&o.push(n),o};class $e extends Error{constructor(o,n){super(o),this.context=n,this.name="DiffProcessingError"}}const qe=(a,o)=>{try{return a()}catch(n){return console.warn("Error in diff processing:",n),o}};g.BlogEditor=ue,g.DiffOverlay=oe,g.DiffProcessingError=$e,g.ImageGenerationLoader=Ve,g.RayoEditor=Le,g.ReviewButtons=ie,g.TitleTextarea=ae,g.calculateProximity=Xe,g.detectDiffMarkers=ze,g.extractDiffRanges=Ue,g.extractTextContent=Ge,g.findOwnerTextPair=Ze,g.groupConsecutiveImages=Ke,g.groupConsecutiveItems=Qe,g.matchImageReplacements=He,g.mergeConsecutiveRanges=le,g.normalizeDiffText=Be,g.optimizeRanges=Je,g.safeExecute=qe,g.useContentProcessing=Ye,g.useEditorDiff=se,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});