@bitux/review-layer-react 0.1.0 → 0.1.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.
- package/README.md +15 -5
- package/dist/ReviewProvider.d.ts +5 -2
- package/dist/index.d.ts +1 -1
- package/dist/review-layer-react.js +567 -565
- package/dist/review-layer-react.js.map +1 -1
- package/dist/review-layer-react.umd.cjs +10 -10
- package/dist/review-layer-react.umd.cjs.map +1 -1
- package/package.json +5 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(U,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(U=typeof globalThis<"u"?globalThis:U||self,l(U.ReviewLayerReact={},U.React,U.ReactDOM))})(this,function(U,l,Te){"use strict";var ye={exports:{}},te={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Pe;function rt(){if(Pe)return te;Pe=1;var t=l,o=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function y(h,E,S){var v,_={},w=null,L=null;S!==void 0&&(w=""+S),E.key!==void 0&&(w=""+E.key),E.ref!==void 0&&(L=E.ref);for(v in E)a.call(E,v)&&!d.hasOwnProperty(v)&&(_[v]=E[v]);if(h&&h.defaultProps)for(v in E=h.defaultProps,E)_[v]===void 0&&(_[v]=E[v]);return{$$typeof:o,type:h,key:w,ref:L,props:_,_owner:i.current}}return te.Fragment=r,te.jsx=y,te.jsxs=y,te}var ne={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var De;function
|
|
18
|
-
`+we+e}}var Re=!1,he;{var
|
|
19
|
-
`),
|
|
20
|
-
`),T=
|
|
21
|
-
`+
|
|
17
|
+
*/var De;function ot(){return De||(De=1,process.env.NODE_ENV!=="production"&&function(){var t=l,o=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),h=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),L=Symbol.for("react.offscreen"),j=Symbol.iterator,I="@@iterator";function M(e){if(e===null||typeof e!="object")return null;var n=j&&e[j]||e[I];return typeof n=="function"?n:null}var c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var n=arguments.length,s=new Array(n>1?n-1:0),f=1;f<n;f++)s[f-1]=arguments[f];D("error",e,s)}}function D(e,n,s){{var f=c.ReactDebugCurrentFrame,b=f.getStackAddendum();b!==""&&(n+="%s",s=s.concat([b]));var R=s.map(function(m){return String(m)});R.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,R)}}var Y=!1,X=!1,q=!1,C=!1,k=!1,z;z=Symbol.for("react.module.reference");function W(e){return!!(typeof e=="string"||typeof e=="function"||e===a||e===d||k||e===i||e===S||e===v||C||e===L||Y||X||q||typeof e=="object"&&e!==null&&(e.$$typeof===w||e.$$typeof===_||e.$$typeof===y||e.$$typeof===h||e.$$typeof===E||e.$$typeof===z||e.getModuleId!==void 0))}function oe(e,n,s){var f=e.displayName;if(f)return f;var b=n.displayName||n.name||"";return b!==""?s+"("+b+")":s}function G(e){return e.displayName||"Context"}function V(e){if(e==null)return null;if(typeof e.tag=="number"&&p("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 a:return"Fragment";case r:return"Portal";case d:return"Profiler";case i:return"StrictMode";case S:return"Suspense";case v:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case h:var n=e;return G(n)+".Consumer";case y:var s=e;return G(s._context)+".Provider";case E:return oe(e,e.render,"ForwardRef");case _:var f=e.displayName||null;return f!==null?f:V(e.type)||"Memo";case w:{var b=e,R=b._payload,m=b._init;try{return V(m(R))}catch{return null}}}return null}var H=Object.assign,Z=0,ae,ie,x,Q,se,le,ue;function Ve(){}Ve.__reactDisabledLog=!0;function Kt(){{if(Z===0){ae=console.log,ie=console.info,x=console.warn,Q=console.error,se=console.group,le=console.groupCollapsed,ue=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Z++}}function qt(){{if(Z--,Z===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:H({},e,{value:ae}),info:H({},e,{value:ie}),warn:H({},e,{value:x}),error:H({},e,{value:Q}),group:H({},e,{value:se}),groupCollapsed:H({},e,{value:le}),groupEnd:H({},e,{value:ue})})}Z<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var be=c.ReactCurrentDispatcher,we;function pe(e,n,s){{if(we===void 0)try{throw Error()}catch(b){var f=b.stack.trim().match(/\n( *(at )?)/);we=f&&f[1]||""}return`
|
|
18
|
+
`+we+e}}var Re=!1,he;{var $t=typeof WeakMap=="function"?WeakMap:Map;he=new $t}function Be(e,n){if(!e||Re)return"";{var s=he.get(e);if(s!==void 0)return s}var f;Re=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var R;R=be.current,be.current=null,Kt();try{if(n){var m=function(){throw Error()};if(Object.defineProperty(m.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(m,[])}catch(F){f=F}Reflect.construct(e,[],m)}else{try{m.call()}catch(F){f=F}e.call(m.prototype)}}else{try{throw Error()}catch(F){f=F}e()}}catch(F){if(F&&f&&typeof F.stack=="string"){for(var g=F.stack.split(`
|
|
19
|
+
`),A=f.stack.split(`
|
|
20
|
+
`),T=g.length-1,P=A.length-1;T>=1&&P>=0&&g[T]!==A[P];)P--;for(;T>=1&&P>=0;T--,P--)if(g[T]!==A[P]){if(T!==1||P!==1)do if(T--,P--,P<0||g[T]!==A[P]){var B=`
|
|
21
|
+
`+g[T].replace(" at new "," at ");return e.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",e.displayName)),typeof e=="function"&&he.set(e,B),B}while(T>=1&&P>=0);break}}}finally{Re=!1,be.current=R,qt(),Error.prepareStackTrace=b}var ee=e?e.displayName||e.name:"",K=ee?pe(ee):"";return typeof e=="function"&&he.set(e,K),K}function en(e,n,s){return Be(e,!1)}function tn(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function ve(e,n,s){if(e==null)return"";if(typeof e=="function")return Be(e,tn(e));if(typeof e=="string")return pe(e);switch(e){case S:return pe("Suspense");case v:return pe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case E:return en(e.render);case _:return ve(e.type,n,s);case w:{var f=e,b=f._payload,R=f._init;try{return ve(R(b),n,s)}catch{}}}return""}var ce=Object.prototype.hasOwnProperty,Ye={},Ue=c.ReactDebugCurrentFrame;function ge(e){if(e){var n=e._owner,s=ve(e.type,e._source,n?n.type:null);Ue.setExtraStackFrame(s)}else Ue.setExtraStackFrame(null)}function nn(e,n,s,f,b){{var R=Function.call.bind(ce);for(var m in e)if(R(e,m)){var g=void 0;try{if(typeof e[m]!="function"){var A=Error((f||"React class")+": "+s+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}g=e[m](n,m,f,s,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(T){g=T}g&&!(g instanceof Error)&&(ge(b),p("%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).",f||"React class",s,m,typeof g),ge(null)),g instanceof Error&&!(g.message in Ye)&&(Ye[g.message]=!0,ge(b),p("Failed %s type: %s",s,g.message),ge(null))}}}var rn=Array.isArray;function Se(e){return rn(e)}function on(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,s=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return s}}function an(e){try{return He(e),!1}catch{return!0}}function He(e){return""+e}function Xe(e){if(an(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",on(e)),He(e)}var Ge=c.ReactCurrentOwner,sn={key:!0,ref:!0,__self:!0,__source:!0},Je,Ze;function ln(e){if(ce.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function un(e){if(ce.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function cn(e,n){typeof e.ref=="string"&&Ge.current}function fn(e,n){{var s=function(){Je||(Je=!0,p("%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)",n))};s.isReactWarning=!0,Object.defineProperty(e,"key",{get:s,configurable:!0})}}function dn(e,n){{var s=function(){Ze||(Ze=!0,p("%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)",n))};s.isReactWarning=!0,Object.defineProperty(e,"ref",{get:s,configurable:!0})}}var pn=function(e,n,s,f,b,R,m){var g={$$typeof:o,type:e,key:n,ref:s,props:m,_owner:R};return g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(g,"_self",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.defineProperty(g,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g};function hn(e,n,s,f,b){{var R,m={},g=null,A=null;s!==void 0&&(Xe(s),g=""+s),un(n)&&(Xe(n.key),g=""+n.key),ln(n)&&(A=n.ref,cn(n,b));for(R in n)ce.call(n,R)&&!sn.hasOwnProperty(R)&&(m[R]=n[R]);if(e&&e.defaultProps){var T=e.defaultProps;for(R in T)m[R]===void 0&&(m[R]=T[R])}if(g||A){var P=typeof e=="function"?e.displayName||e.name||"Unknown":e;g&&fn(m,P),A&&dn(m,P)}return pn(e,g,A,b,f,Ge.current,m)}}var Ce=c.ReactCurrentOwner,Qe=c.ReactDebugCurrentFrame;function $(e){if(e){var n=e._owner,s=ve(e.type,e._source,n?n.type:null);Qe.setExtraStackFrame(s)}else Qe.setExtraStackFrame(null)}var _e;_e=!1;function je(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function Ke(){{if(Ce.current){var e=V(Ce.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function vn(e){return""}var qe={};function gn(e){{var n=Ke();if(!n){var s=typeof e=="string"?e:e.displayName||e.name;s&&(n=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+s+">.")}return n}}function $e(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var s=gn(n);if(qe[s])return;qe[s]=!0;var f="";e&&e._owner&&e._owner!==Ce.current&&(f=" It was passed a child from "+V(e._owner.type)+"."),$(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',s,f),$(null)}}function et(e,n){{if(typeof e!="object")return;if(Se(e))for(var s=0;s<e.length;s++){var f=e[s];je(f)&&$e(f,n)}else if(je(e))e._store&&(e._store.validated=!0);else if(e){var b=M(e);if(typeof b=="function"&&b!==e.entries)for(var R=b.call(e),m;!(m=R.next()).done;)je(m.value)&&$e(m.value,n)}}}function yn(e){{var n=e.type;if(n==null||typeof n=="string")return;var s;if(typeof n=="function")s=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===E||n.$$typeof===_))s=n.propTypes;else return;if(s){var f=V(n);nn(s,e.props,"prop",f,e)}else if(n.PropTypes!==void 0&&!_e){_e=!0;var b=V(n);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function mn(e){{for(var n=Object.keys(e.props),s=0;s<n.length;s++){var f=n[s];if(f!=="children"&&f!=="key"){$(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),$(null);break}}e.ref!==null&&($(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),$(null))}}var tt={};function nt(e,n,s,f,b,R){{var m=W(e);if(!m){var g="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(g+=" 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 A=vn();A?g+=A:g+=Ke();var T;e===null?T="null":Se(e)?T="array":e!==void 0&&e.$$typeof===o?(T="<"+(V(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):T=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",T,g)}var P=hn(e,n,s,b,R);if(P==null)return P;if(m){var B=n.children;if(B!==void 0)if(f)if(Se(B)){for(var ee=0;ee<B.length;ee++)et(B[ee],e);Object.freeze&&Object.freeze(B)}else p("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 et(B,e)}if(ce.call(n,"key")){var K=V(e),F=Object.keys(n).filter(function(Sn){return Sn!=="key"}),ke=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!tt[K+ke]){var Rn=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";p(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,_e,Q,wn,Q),et[Q+_e]=!0}}return e===a?yn(D):gn(D),D}}function mn(e,r,i){return tt(e,r,i,!0)}function En(e,r,i){return tt(e,r,i,!1)}var xn=En,bn=mn;te.Fragment=a,te.jsx=xn,te.jsxs=bn}()),te}process.env.NODE_ENV==="production"?ye.exports=nt():ye.exports=rt();var l=ye.exports;function ot(t){if(t.id&&/^[a-zA-Z][\w-]*$/.test(t.id))return`#${t.id}`;const o=[];let n=t;for(;n&&n.nodeType===Node.ELEMENT_NODE;){let a=n.nodeName.toLowerCase();if(n.id&&/^[a-zA-Z][\w-]*$/.test(n.id)){o.unshift(`#${n.id}`);break}if(n.className&&typeof n.className=="string"){const u=n.className.trim().split(/\s+/).filter(Boolean);if(u.length>0){const f=u.filter(g=>/^[a-zA-Z][\w-]*$/.test(g)).slice(0,2).map(g=>`.${g}`).join("");f&&(a+=f)}}if(o.length>0){const u=n.parentElement;if(u){const f=Array.from(u.children).filter(g=>g.nodeName===n.nodeName);if(f.length>1){const g=f.indexOf(n)+1;a+=`:nth-child(${g})`}}}o.unshift(a),n=n.parentElement}return o.join(" > ")}function Oe(t){if(typeof document>"u"||!(t!=null&&t.trim()))return null;try{const o=document.querySelector(t);return o?o.getBoundingClientRect():null}catch{return null}}function at(t){if(typeof window>"u")return{relativeX:0,relativeY:0};const o=window.innerWidth,n=window.innerHeight;return{relativeX:o>0?t.left/o:0,relativeY:n>0?t.top/n:0}}function it(t){if(typeof window>"u")return{x:t.x??0,y:t.y??0};const o=t.relativeX??null,n=t.relativeY??null;return o!=null&&n!=null?{x:o*window.innerWidth,y:n*window.innerHeight}:{x:t.x??0,y:t.y??0}}function fe(t){if(t.selector){const o=Oe(t.selector);if(o!=null)return{x:o.left,y:o.top}}return it(t)}const O={PENDING:"pending",DEV_FIXED:"dev_fixed",VALIDATED:"validated"};function ne(t){return{"Content-Type":"application/json","x-review-key":t}}async function st(t,o,n){const a=await fetch(`${t}/reviewers`,{headers:ne(o),signal:n==null?void 0:n.signal});if(!a.ok)throw new Error("Failed to fetch reviewers");return(await a.json()).data??[]}async function lt(t,o,n){const a=await fetch(`${t}/comments`,{method:"POST",headers:ne(o),body:JSON.stringify(n)});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.message||"Failed to create comment")}return(await a.json()).data}async function ut(t,o,n,a){const u=new URLSearchParams({url:n}),f=await fetch(`${t}/comments?${u}`,{headers:ne(o),signal:a==null?void 0:a.signal});if(!f.ok)throw new Error("Failed to fetch comments");return(await f.json()).data??[]}async function ct(t,o,n,a){const u=await fetch(`${t}/comments/${n}/status`,{method:"PATCH",headers:ne(o),body:JSON.stringify({status:a})});if(!u.ok){const g=await u.json().catch(()=>({}));throw new Error(g.message||"Failed to update comment status")}return(await u.json()).data}async function ft(t,o,n){const a=await fetch(`${t}/comments/${n}`,{method:"DELETE",headers:ne(o)});if(!a.ok){const u=await a.json().catch(()=>({}));throw new Error(u.message||"Failed to delete comment")}}const dt={position:"fixed",inset:0,zIndex:999997,backgroundColor:"transparent"},pt={position:"fixed",minWidth:320,maxWidth:400,padding:16,backgroundColor:"#fff",border:"1px solid #e8e8e8",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.15)",zIndex:999998},ht={width:"100%",minHeight:80,padding:"8px 12px",marginBottom:12,border:"1px solid #d9d9d9",borderRadius:6,fontSize:14,resize:"vertical",boxSizing:"border-box"},vt={width:"100%",padding:"8px 12px",marginBottom:12,border:"1px solid #d9d9d9",borderRadius:6,fontSize:14},gt={padding:"8px 16px",backgroundColor:"#ff4d4f",color:"#fff",border:"none",borderRadius:6,fontSize:14,cursor:"pointer",fontWeight:500};function yt({apiUrl:t,apiKey:o,reviewers:n,position:a,payload:u,onClose:f,onSuccess:g}){var m;const[d,b]=s.useState(""),[R,y]=s.useState(((m=n[0])==null?void 0:m.id)??0),[k,S]=s.useState(!1),[_,L]=s.useState(null);s.useEffect(()=>{n.length>0&&!R&&y(n[0].id)},[n,R]);const I=async p=>{if(p.preventDefault(),!(!d.trim()||!R)){S(!0),L(null);try{await lt(t,o,{...u,message:d.trim(),reviewerId:R}),g(),f()}catch(h){L(h instanceof Error?h.message:"Failed to send comment")}finally{S(!1)}}};return l.jsxs(l.Fragment,{children:[l.jsx("div",{role:"presentation",style:dt,onClick:f,onKeyDown:p=>p.key==="Escape"&&f()}),l.jsx("div",{style:{...pt,left:Math.min(a.x,typeof window<"u"?window.innerWidth-420:a.x),top:a.y+12},onClick:p=>p.stopPropagation(),children:l.jsxs("form",{onSubmit:I,children:[l.jsx("textarea",{placeholder:"Escribe tu comentario...",value:d,onChange:p=>b(p.target.value),style:ht,required:!0,autoFocus:!0}),l.jsxs("select",{value:R,onChange:p=>y(Number(p.target.value)),style:vt,required:!0,disabled:n.length===0,children:[l.jsx("option",{value:"",children:n.length===0?"No hay revisores (ejecuta php artisan db:seed en la API)":"Selecciona revisor"}),n.map(p=>l.jsx("option",{value:p.id,children:p.name},p.id))]}),_&&l.jsx("div",{style:{color:"#ff4d4f",fontSize:12,marginBottom:8},children:_}),l.jsx("button",{type:"submit",style:gt,disabled:k||n.length===0,children:k?"Enviando...":"Enviar comentario"})]})})]})}const mt={position:"fixed",outline:"2px solid #ff4d4f",outlineOffset:"2px",pointerEvents:"none",zIndex:999997,boxSizing:"border-box"};function Et({selector:t,active:o}){const[n,a]=s.useState(null),u=s.useCallback(()=>{if(!o||!(t!=null&&t.trim())){a(null);return}const f=Oe(t);a(f)},[t,o]);return s.useEffect(()=>{u()},[u]),s.useEffect(()=>{if(!(!o||!(t!=null&&t.trim())))return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[o,t,u]),!o||n==null?null:l.jsx("div",{"aria-hidden":!0,style:{...mt,left:n.left,top:n.top,width:n.width,height:n.height}})}const me=32,Ie=5e6,M={cardBg:"#ffffff",textDark:"#333333",textMuted:"#888888",border:"#cccccc",shadow:"0 4px 16px rgba(0, 0, 0, 0.12)"},xt={[O.PENDING]:"Pendiente",[O.DEV_FIXED]:"Corregido Desarrollo",[O.VALIDATED]:"Validado"},bt={[O.PENDING]:"PENDIENTE",[O.DEV_FIXED]:"CORREGIDO DESARROLLO",[O.VALIDATED]:"VALIDADO"},J={[O.PENDING]:"rgb(240, 69, 69)",[O.DEV_FIXED]:"rgb(235, 179, 8)",[O.VALIDATED]:"rgb(33, 196, 94)"};function wt(t){const o=t.trim().split(/\s+/);return o.length>=2?(o[0][0]+o[o.length-1][0]).toUpperCase():t.slice(0,2).toUpperCase()||"?"}const Rt=()=>l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{marginRight:4,flexShrink:0},children:l.jsx("path",{d:"M10 3L4.5 8.5L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),St=({color:t})=>l.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[l.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),l.jsx("path",{d:"M8 10h.01M12 10h.01M16 10h.01",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ct=t=>({position:"fixed",width:me,height:me,borderRadius:"50%",backgroundColor:J[t]??J[O.PENDING],color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontFamily:"'Inter', sans-serif",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",zIndex:999998,border:"2px solid #fff"}),jt={position:"fixed",maxWidth:320,padding:"16px 14px",backgroundColor:M.cardBg,borderRadius:12,boxShadow:M.shadow,fontSize:13,fontFamily:"'Inter', sans-serif",zIndex:999999,pointerEvents:"auto"},kt={display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,marginBottom:12},_t=t=>({width:40,height:40,borderRadius:"50%",backgroundColor:J[t]??J[O.PENDING],color:"#fff",border:"2px solid #fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:700,flexShrink:0}),Pt={flexShrink:0,width:24,height:24,padding:0,border:"none",borderRadius:6,backgroundColor:"transparent",color:M.textDark,cursor:"pointer",fontSize:18,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},Tt=t=>{const o=t===O.DEV_FIXED;return{display:"inline-flex",alignItems:"center",marginBottom:10,padding:"4px 10px",borderRadius:9999,fontSize:10,fontWeight:700,fontFamily:"'Inter', sans-serif",textTransform:"uppercase",letterSpacing:"0.02em",backgroundColor:J[t]??J[O.PENDING],color:o?M.textDark:"#fff"}},Dt={display:"block",marginTop:12,marginBottom:6,fontSize:10,fontWeight:600,fontFamily:"'Inter', sans-serif",color:M.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},Ot={width:"100%",padding:"8px 12px",paddingRight:32,fontSize:13,fontFamily:"'Inter', sans-serif",borderRadius:8,border:`1px solid ${M.border}`,backgroundColor:M.cardBg,color:M.textDark,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L2 4h8z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center"},It={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,marginTop:14,paddingTop:12,borderTop:`1px solid ${M.border}`},Le={minWidth:100,padding:"8px 14px",fontSize:13,fontWeight:600,fontFamily:"'Inter', sans-serif",borderRadius:8,cursor:"pointer",border:"none"},Lt={...Le,backgroundColor:"transparent",color:M.textDark},At={...Le,backgroundColor:J[O.VALIDATED],color:"#fff"};function Ft({comment:t,offset:o={dx:0,dy:0},apiUrl:n,apiKey:a,onStatusChange:u}){var ae,ie;const[f,g]=s.useState(!1),[d,b]=s.useState(!1),[R,y]=s.useState(()=>fe(t)),[k,S]=s.useState(!1),[_,L]=s.useState(null),I=s.useRef(null),m=s.useRef(null),p=s.useRef(null),h=s.useCallback(()=>{y(fe(t))},[t]);s.useEffect(()=>{h()},[h]),s.useEffect(()=>{if(!(typeof window>"u"))return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}},[h]);const A=s.useCallback(()=>{I.current!==null&&(clearTimeout(I.current),I.current=null)},[]),X=s.useCallback(()=>{A(),g(!0)},[A]),re=s.useCallback(()=>{d||(I.current=setTimeout(()=>{I.current=null,g(!1)},Ie))},[d]),K=s.useCallback(()=>{A(),g(!0)},[A]),j=s.useCallback(()=>{d||(I.current=setTimeout(()=>{I.current=null,g(!1)},Ie))},[d]),P=s.useCallback(()=>{d?(b(!1),g(!1)):(b(!0),g(!0))},[d]);s.useEffect(()=>{if(!d)return;const x=Z=>{var le,ue;const se=Z.target;(le=m.current)!=null&&le.contains(se)||(ue=p.current)!=null&&ue.contains(se)||(b(!1),g(!1))};return document.addEventListener("mousedown",x,!0),()=>document.removeEventListener("mousedown",x,!0)},[d]),s.useEffect(()=>()=>A(),[A]);const z=R.x+o.dx,W=R.y+o.dy,oe=f,G=s.useCallback(()=>{b(!1),g(!1)},[]),V=async x=>{if(x!==t.status){L(null),S(!0);try{await ct(n,a,t.id,x),u()}catch(Z){L(Z instanceof Error?Z.message:"Error al actualizar")}finally{S(!1)}}},H=async()=>{L(null),S(!0);try{await ft(n,a,t.id),u(),G()}catch(x){L(x instanceof Error?x.message:"Error al eliminar")}finally{S(!1)}},U=["pending","dev_fixed","validated"];return l.jsxs(l.Fragment,{children:[l.jsx(Et,{selector:t.selector,active:oe}),l.jsx("div",{ref:m,role:"button",tabIndex:0,"aria-label":`Comentario: ${t.message.slice(0,30)}...`,"aria-expanded":f,style:{...Ct(t.status),left:z,top:W,transform:"translate(-50%, -50%)"},onMouseEnter:X,onMouseLeave:re,onClick:P,children:l.jsx(St,{color:"#fff"})}),f&&l.jsxs("div",{ref:p,role:"dialog","aria-label":"Detalle del comentario",style:{...jt,left:z+me/2+6,top:W},onMouseEnter:K,onMouseLeave:j,children:[l.jsxs("div",{style:kt,children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1,minWidth:0},children:[l.jsx("div",{style:_t(t.status),children:wt(((ae=t.reviewer)==null?void 0:ae.name)??"Revisor")}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:700,fontSize:14,color:M.textDark},children:((ie=t.reviewer)==null?void 0:ie.name)??"Revisor"}),l.jsx("div",{style:{fontSize:12,color:M.textMuted},children:"Revisor"})]})]}),l.jsx("button",{type:"button","aria-label":t.status===O.VALIDATED?"Eliminar comentario":"Cerrar",style:Pt,disabled:k,onClick:x=>{x.stopPropagation(),t.status===O.VALIDATED?H():G()},onMouseDown:x=>x.stopPropagation(),children:"✕"})]}),l.jsxs("div",{style:Tt(t.status),children:[t.status===O.VALIDATED&&l.jsx(Rt,{}),bt[t.status]??t.status]}),l.jsx("div",{style:{color:M.textDark,lineHeight:1.5},children:t.message}),l.jsx("label",{style:Dt,htmlFor:`comment-status-${t.id}`,children:"Cambiar estado"}),l.jsx("select",{id:`comment-status-${t.id}`,style:Ot,value:t.status,disabled:k,onChange:x=>V(x.target.value),onMouseDown:x=>x.stopPropagation(),"aria-label":"Cambiar estado del comentario",children:U.map(x=>l.jsx("option",{value:x,children:xt[x]},x))}),_&&l.jsx("div",{style:{marginTop:8,fontSize:11,color:"rgb(240, 69, 69)"},children:_}),l.jsxs("div",{style:It,children:[l.jsx("button",{type:"button",style:Lt,onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),G()},children:"Cerrar"}),t.status!==O.VALIDATED&&l.jsx("button",{type:"button",style:At,disabled:k,onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),V("validated")},children:"Resolver hilo"})]})]})]})}const Nt=25,Mt=36;function zt(t){const o=new Map;for(let n=0;n<t.length;n++){const a=t[n],{x:u,y:f}=fe(a);let g=0;for(let d=0;d<n;d++){const b=t[d],{x:R,y}=fe(b);Math.hypot(u-R,f-y)<Nt&&g++}o.set(a.id,{dx:g*Mt,dy:0})}return o}function Wt(){return typeof window>"u"?"":`${window.innerWidth}x${window.innerHeight}`}function Vt({apiUrl:t,apiKey:o,reviewMode:n,reviewers:a,comments:u,loadComments:f,commentsLoadFailed:g=!1}){const[d,b]=s.useState(null),R=s.useRef(null),[y,k]=s.useState(null),S=s.useCallback(()=>{d&&(d.style.outline="",d.style.outlineOffset="",b(null))},[d]),_=s.useCallback(()=>{R.current&&(R.current.style.outline="",R.current.style.outlineOffset="",R.current=null)},[]);s.useEffect(()=>{n||(S(),_())},[n,S,_]),s.useEffect(()=>{if(typeof document>"u")return;const j=document.body.style.cursor;return y?document.body.style.cursor="default":n&&(document.body.style.cursor="crosshair"),()=>{document.body.style.cursor=j}},[n,y]);const L=s.useCallback(j=>{if(!n||y)return;const P=j.target.nodeType===Node.ELEMENT_NODE?j.target:j.target.parentElement;P&&(S(),b(P),P.style.outline="2px solid #ff4d4f",P.style.outlineOffset="2px")},[n,y,S]),I=s.useCallback(j=>{var z;if(y)return;const P=j.relatedTarget;d&&(!P||!d.contains(P))&&!(P&&((z=d.contains)!=null&&z.call(d,P)))&&S()},[d,y,S]),m=s.useCallback(j=>{if(!n||y)return;j.preventDefault(),j.stopPropagation();const P=j.target;if(!P||P.closest("[data-review-layer-pin]")||P.closest("[data-review-layer-modal]"))return;S();const z=P;R.current=z,z.style.outline="2px solid #ff4d4f",z.style.outlineOffset="2px";const W=z.getBoundingClientRect(),oe=ot(P),{relativeX:G,relativeY:V}=at(W);k({position:{x:W.left+W.width/2,y:W.bottom},payload:{selector:oe,x:Math.round(W.left),y:Math.round(W.top),relativeX:G,relativeY:V,width:Math.round(W.width),height:Math.round(W.height),url:typeof window<"u"&&window.location.pathname||"/",viewport:Wt(),userAgent:typeof navigator<"u"?navigator.userAgent:"",pageTitle:typeof document<"u"?document.title:""}})},[n,y,S]);s.useEffect(()=>{if(n)return document.addEventListener("mouseover",L,!0),document.addEventListener("mouseout",I,!0),document.addEventListener("click",m,!0),()=>{document.removeEventListener("mouseover",L,!0),document.removeEventListener("mouseout",I,!0),document.removeEventListener("click",m,!0)}},[n,L,I,m]);const[p,h]=s.useState(0);s.useEffect(()=>{if(typeof window>"u")return;const j=()=>h(P=>P+1);return window.addEventListener("resize",j),window.addEventListener("scroll",j,!0),()=>{window.removeEventListener("resize",j),window.removeEventListener("scroll",j,!0)}},[]);const A=s.useMemo(()=>zt(u),[u,p]),X={position:"fixed",inset:0,zIndex:999999,pointerEvents:"none",cursor:n?"crosshair":void 0},re=l.jsxs("div",{style:X,"aria-hidden":!0,children:[n&&l.jsx("div",{style:{position:"fixed",top:10,left:10,zIndex:1e6,padding:"6px 12px",backgroundColor:"#ff4d4f",color:"#fff",borderRadius:6,fontSize:12,fontWeight:500,pointerEvents:"auto"},children:"Modo revisión (Shift+R para salir)"}),g&&l.jsxs("div",{style:{position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:10,padding:"8px 14px",backgroundColor:"#fff",border:"1px solid #e8e8e8",borderRadius:8,boxShadow:"0 2px 12px rgba(0,0,0,0.1)",fontSize:12,color:"#333",zIndex:999997,pointerEvents:"auto"},children:[l.jsx("span",{children:"No se pudo conectar. Mostrando últimos datos guardados. Reintentar no garantiza respuesta hasta que el servicio esté activo."}),l.jsx("button",{type:"button",onClick:()=>f(),style:{padding:"4px 10px",fontSize:12,fontWeight:600,backgroundColor:"rgb(33, 196, 94)",color:"#fff",border:"none",borderRadius:6,cursor:"pointer"},children:"Reintentar"})]}),u.map(j=>l.jsx("div",{"data-review-layer-pin":!0,style:{pointerEvents:"auto"},children:l.jsx(Ft,{comment:j,offset:A.get(j.id),apiUrl:t,apiKey:o,onStatusChange:f})},j.id)),y&&l.jsx("div",{"data-review-layer-modal":!0,style:{pointerEvents:"auto"},children:l.jsx(yt,{apiUrl:t,apiKey:o,reviewers:a,position:y.position,payload:y.payload,onClose:()=>{_(),k(null)},onSuccess:f})})]}),K=typeof document<"u"?document.body:null;return K?Pe.createPortal(re,K):null}function Bt(t,o,n){const a=s.useCallback(()=>{t&&n(u=>!u)},[t,n]);s.useEffect(()=>{if(!t)return;const u=f=>{(f.key==="r"||f.key==="R"||f.code==="KeyR")&&f.shiftKey&&(f.preventDefault(),a())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[t,a])}const Yt="review_layer:v1:";function Ht(t,o){if(t==null)return o;try{return JSON.parse(t)??o}catch{return o}}function de(t,o,n,a){const u=`${Yt}${Xt(t)}:${n}`;return a!=null?`${u}:${a}`:u}function Xt(t){return t.replace(/\/+$/,"")||"/"}function Ae(t){if(typeof localStorage>"u")return null;const o=localStorage.getItem(t);return Ht(o,null)}function Fe(t,o){if(!(typeof localStorage>"u"))try{localStorage.setItem(t,JSON.stringify({data:o,at:Date.now()}))}catch{}}function Ee(t,o,n){const a=Ae(de(t,o,"comments",n));return(a==null?void 0:a.data)??null}function Gt(t,o,n,a){Fe(de(t,o,"comments",n),a)}function Ne(t,o){const n=Ae(de(t,o,"reviewers"));return(n==null?void 0:n.data)??null}function Jt(t,o,n){Fe(de(t,o,"reviewers"),n)}function Me(){return typeof window>"u"?"/":window.location.pathname||"/"}const ze=s.createContext(null);let xe=null;function Ut(){const t=s.useContext(ze);if(!t)throw new Error("useReview must be used within ReviewProvider");return t}function Zt({children:t,enabled:o=!0,apiUrl:n,apiKey:a}){const[u,f]=s.useState(!1),[g,d]=s.useState([]),[b,R]=s.useState([]),[y,k]=s.useState(!1);Bt(o,u,f);const S=s.useCallback(async m=>{if(!(!o||!n||!a))try{const p=await st(n,a,{signal:m});m!=null&&m.aborted||(d(p),Jt(n,a,p))}catch(p){if(p instanceof Error&&p.name==="AbortError")return;if(!(m!=null&&m.aborted)){const h=Ne(n,a);h!=null&&d(h)}}},[o,n,a]),_=s.useCallback(async m=>{if(!o||!n||!a)return;const p=Me(),h=Ee(n,a,p);h!=null&&R(h);try{k(!1);const A=await ut(n,a,p,{signal:m});m!=null&&m.aborted||(R(A),Gt(n,a,p,A))}catch(A){if(A instanceof Error&&A.name==="AbortError")return;if(!(m!=null&&m.aborted)){k(!0);const X=Ee(n,a,p);X!=null&&R(X)}}},[o,n,a]);s.useEffect(()=>{if(!o||!n||!a)return;const m=Me(),p=Ne(n,a),h=Ee(n,a,m);p!=null&&d(p),h!=null&&R(h)},[o,n,a]),s.useEffect(()=>{if(!o||!n||!a)return;const m=`${n}:${a}`;if(xe!==m)return xe=m,S(),_(),()=>{setTimeout(()=>{xe=null},0)}},[o,n,a,S,_]),s.useEffect(()=>{if(!o)return;const m=()=>_();return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[o,_]);const L={apiUrl:n,apiKey:a,reviewMode:u,setReviewMode:f,reviewers:g,comments:b,loadComments:_,commentsLoadFailed:y},I=o&&typeof document<"u"?Pe.createPortal(l.jsx(Vt,{apiUrl:n,apiKey:a,reviewMode:u,reviewers:g,comments:b,loadComments:_,commentsLoadFailed:y}),document.body):null;return l.jsxs(ze.Provider,{value:L,children:[t,I]})}Y.ReviewProvider=Zt,Y.useReview=Ut,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|
|
30
|
+
<%s key={someKey} {...props} />`,ke,K,Rn,K),tt[K+ke]=!0}}return e===a?mn(P):yn(P),P}}function En(e,n,s){return nt(e,n,s,!0)}function xn(e,n,s){return nt(e,n,s,!1)}var bn=xn,wn=En;ne.Fragment=a,ne.jsx=bn,ne.jsxs=wn}()),ne}process.env.NODE_ENV==="production"?ye.exports=rt():ye.exports=ot();var u=ye.exports;function at(t){if(t.id&&/^[a-zA-Z][\w-]*$/.test(t.id))return`#${t.id}`;const o=[];let r=t;for(;r&&r.nodeType===Node.ELEMENT_NODE;){let a=r.nodeName.toLowerCase();if(r.id&&/^[a-zA-Z][\w-]*$/.test(r.id)){o.unshift(`#${r.id}`);break}if(r.className&&typeof r.className=="string"){const i=r.className.trim().split(/\s+/).filter(Boolean);if(i.length>0){const d=i.filter(y=>/^[a-zA-Z][\w-]*$/.test(y)).slice(0,2).map(y=>`.${y}`).join("");d&&(a+=d)}}if(o.length>0){const i=r.parentElement;if(i){const d=Array.from(i.children).filter(y=>y.nodeName===r.nodeName);if(d.length>1){const y=d.indexOf(r)+1;a+=`:nth-child(${y})`}}}o.unshift(a),r=r.parentElement}return o.join(" > ")}function Oe(t){if(typeof document>"u"||!(t!=null&&t.trim()))return null;try{const o=document.querySelector(t);return o?o.getBoundingClientRect():null}catch{return null}}function it(t){if(typeof window>"u")return{relativeX:0,relativeY:0};const o=window.innerWidth,r=window.innerHeight;return{relativeX:o>0?t.left/o:0,relativeY:r>0?t.top/r:0}}function st(t){if(typeof window>"u")return{x:t.x??0,y:t.y??0};const o=t.relativeX??null,r=t.relativeY??null;return o!=null&&r!=null?{x:o*window.innerWidth,y:r*window.innerHeight}:{x:t.x??0,y:t.y??0}}function fe(t){if(t.selector){const o=Oe(t.selector);if(o!=null)return{x:o.left,y:o.top}}return st(t)}const O={PENDING:"pending",DEV_FIXED:"dev_fixed",VALIDATED:"validated"};function re(t){return{"Content-Type":"application/json","x-review-key":t}}async function lt(t,o,r){const a=await fetch(`${t}/reviewers`,{headers:re(o),signal:r==null?void 0:r.signal});if(!a.ok)throw new Error("Failed to fetch reviewers");return(await a.json()).data??[]}async function ut(t,o,r){const a=await fetch(`${t}/comments`,{method:"POST",headers:re(o),body:JSON.stringify(r)});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Error(d.message||"Failed to create comment")}return(await a.json()).data}async function ct(t,o,r,a){const i=new URLSearchParams({url:r}),d=await fetch(`${t}/comments?${i}`,{headers:re(o),signal:a==null?void 0:a.signal});if(!d.ok)throw new Error("Failed to fetch comments");return(await d.json()).data??[]}async function ft(t,o,r,a){const i=await fetch(`${t}/comments/${r}/status`,{method:"PATCH",headers:re(o),body:JSON.stringify({status:a})});if(!i.ok){const y=await i.json().catch(()=>({}));throw new Error(y.message||"Failed to update comment status")}return(await i.json()).data}async function dt(t,o,r){const a=await fetch(`${t}/comments/${r}`,{method:"DELETE",headers:re(o)});if(!a.ok){const i=await a.json().catch(()=>({}));throw new Error(i.message||"Failed to delete comment")}}const pt={position:"fixed",inset:0,zIndex:999997,backgroundColor:"transparent"},ht={position:"fixed",minWidth:320,maxWidth:400,padding:16,backgroundColor:"#fff",border:"1px solid #e8e8e8",borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.15)",zIndex:999998},vt={width:"100%",minHeight:80,padding:"8px 12px",marginBottom:12,border:"1px solid #d9d9d9",borderRadius:6,fontSize:14,resize:"vertical",boxSizing:"border-box"},gt={width:"100%",padding:"8px 12px",marginBottom:12,border:"1px solid #d9d9d9",borderRadius:6,fontSize:14},yt={padding:"8px 16px",backgroundColor:"#ff4d4f",color:"#fff",border:"none",borderRadius:6,fontSize:14,cursor:"pointer",fontWeight:500};function mt({apiUrl:t,apiKey:o,reviewers:r,position:a,payload:i,onClose:d,onSuccess:y}){var M;const[h,E]=l.useState(""),[S,v]=l.useState(((M=r[0])==null?void 0:M.id)??0),[_,w]=l.useState(!1),[L,j]=l.useState(null);l.useEffect(()=>{r.length>0&&!S&&v(r[0].id)},[r,S]);const I=async c=>{if(c.preventDefault(),!(!h.trim()||!S)){w(!0),j(null);try{await ut(t,o,{...i,message:h.trim(),reviewerId:S}),y(),d()}catch(p){j(p instanceof Error?p.message:"Failed to send comment")}finally{w(!1)}}};return u.jsxs(u.Fragment,{children:[u.jsx("div",{role:"presentation",style:pt,onClick:d,onKeyDown:c=>c.key==="Escape"&&d()}),u.jsx("div",{style:{...ht,left:Math.min(a.x,typeof window<"u"?window.innerWidth-420:a.x),top:a.y+12},onClick:c=>c.stopPropagation(),children:u.jsxs("form",{onSubmit:I,children:[u.jsx("textarea",{placeholder:"Escribe tu comentario...",value:h,onChange:c=>E(c.target.value),style:vt,required:!0,autoFocus:!0}),u.jsxs("select",{value:S,onChange:c=>v(Number(c.target.value)),style:gt,required:!0,disabled:r.length===0,children:[u.jsx("option",{value:"",children:r.length===0?"No hay revisores (ejecuta php artisan db:seed en la API)":"Selecciona revisor"}),r.map(c=>u.jsx("option",{value:c.id,children:c.name},c.id))]}),L&&u.jsx("div",{style:{color:"#ff4d4f",fontSize:12,marginBottom:8},children:L}),u.jsx("button",{type:"submit",style:yt,disabled:_||r.length===0,children:_?"Enviando...":"Enviar comentario"})]})})]})}const Et={position:"fixed",outline:"2px solid #ff4d4f",outlineOffset:"2px",pointerEvents:"none",zIndex:999997,boxSizing:"border-box"};function xt({selector:t,active:o}){const[r,a]=l.useState(null),i=l.useCallback(()=>{if(!o||!(t!=null&&t.trim())){a(null);return}const d=Oe(t);a(d)},[t,o]);return l.useEffect(()=>{i()},[i]),l.useEffect(()=>{if(!(!o||!(t!=null&&t.trim())))return window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[o,t,i]),!o||r==null?null:u.jsx("div",{"aria-hidden":!0,style:{...Et,left:r.left,top:r.top,width:r.width,height:r.height}})}const me=32,Le=5e6,N={cardBg:"#ffffff",textDark:"#333333",textMuted:"#888888",border:"#cccccc",shadow:"0 4px 16px rgba(0, 0, 0, 0.12)"},bt={[O.PENDING]:"Pendiente",[O.DEV_FIXED]:"Corregido Desarrollo",[O.VALIDATED]:"Validado"},wt={[O.PENDING]:"PENDIENTE",[O.DEV_FIXED]:"CORREGIDO DESARROLLO",[O.VALIDATED]:"VALIDADO"},J={[O.PENDING]:"rgb(240, 69, 69)",[O.DEV_FIXED]:"rgb(235, 179, 8)",[O.VALIDATED]:"rgb(33, 196, 94)"};function Rt(t){const o=t.trim().split(/\s+/);return o.length>=2?(o[0][0]+o[o.length-1][0]).toUpperCase():t.slice(0,2).toUpperCase()||"?"}const St=()=>u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{marginRight:4,flexShrink:0},children:u.jsx("path",{d:"M10 3L4.5 8.5L2 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Ct=({color:t})=>u.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:[u.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z",stroke:t,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),u.jsx("path",{d:"M8 10h.01M12 10h.01M16 10h.01",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round"})]}),_t=t=>({position:"fixed",width:me,height:me,borderRadius:"50%",backgroundColor:J[t]??J[O.PENDING],color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontFamily:"'Inter', sans-serif",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",zIndex:999998,border:"2px solid #fff"}),jt={position:"fixed",maxWidth:320,padding:"16px 14px",backgroundColor:N.cardBg,borderRadius:12,boxShadow:N.shadow,fontSize:13,fontFamily:"'Inter', sans-serif",zIndex:999999,pointerEvents:"auto"},kt={display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,marginBottom:12},Tt=t=>({width:40,height:40,borderRadius:"50%",backgroundColor:J[t]??J[O.PENDING],color:"#fff",border:"2px solid #fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:700,flexShrink:0}),Pt={flexShrink:0,width:24,height:24,padding:0,border:"none",borderRadius:6,backgroundColor:"transparent",color:N.textDark,cursor:"pointer",fontSize:18,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},Dt=t=>{const o=t===O.DEV_FIXED;return{display:"inline-flex",alignItems:"center",marginBottom:10,padding:"4px 10px",borderRadius:9999,fontSize:10,fontWeight:700,fontFamily:"'Inter', sans-serif",textTransform:"uppercase",letterSpacing:"0.02em",backgroundColor:J[t]??J[O.PENDING],color:o?N.textDark:"#fff"}},Ot={display:"block",marginTop:12,marginBottom:6,fontSize:10,fontWeight:600,fontFamily:"'Inter', sans-serif",color:N.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},Lt={width:"100%",padding:"8px 12px",paddingRight:32,fontSize:13,fontFamily:"'Inter', sans-serif",borderRadius:8,border:`1px solid ${N.border}`,backgroundColor:N.cardBg,color:N.textDark,cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L2 4h8z'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center"},It={display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,marginTop:14,paddingTop:12,borderTop:`1px solid ${N.border}`},Ie={minWidth:100,padding:"8px 14px",fontSize:13,fontWeight:600,fontFamily:"'Inter', sans-serif",borderRadius:8,cursor:"pointer",border:"none"},At={...Ie,backgroundColor:"transparent",color:N.textDark},Ft={...Ie,backgroundColor:J[O.VALIDATED],color:"#fff"};function Nt({comment:t,offset:o={dx:0,dy:0},apiUrl:r,apiKey:a,onStatusChange:i}){var ae,ie;const[d,y]=l.useState(!1),[h,E]=l.useState(!1),[S,v]=l.useState(()=>fe(t)),[_,w]=l.useState(!1),[L,j]=l.useState(null),I=l.useRef(null),M=l.useRef(null),c=l.useRef(null),p=l.useCallback(()=>{v(fe(t))},[t]);l.useEffect(()=>{p()},[p]),l.useEffect(()=>{if(!(typeof window>"u"))return window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}},[p]);const D=l.useCallback(()=>{I.current!==null&&(clearTimeout(I.current),I.current=null)},[]),Y=l.useCallback(()=>{D(),y(!0)},[D]),X=l.useCallback(()=>{h||(I.current=setTimeout(()=>{I.current=null,y(!1)},Le))},[h]),q=l.useCallback(()=>{D(),y(!0)},[D]),C=l.useCallback(()=>{h||(I.current=setTimeout(()=>{I.current=null,y(!1)},Le))},[h]),k=l.useCallback(()=>{h?(E(!1),y(!1)):(E(!0),y(!0))},[h]);l.useEffect(()=>{if(!h)return;const x=Q=>{var le,ue;const se=Q.target;(le=M.current)!=null&&le.contains(se)||(ue=c.current)!=null&&ue.contains(se)||(E(!1),y(!1))};return document.addEventListener("mousedown",x,!0),()=>document.removeEventListener("mousedown",x,!0)},[h]),l.useEffect(()=>()=>D(),[D]);const z=S.x+o.dx,W=S.y+o.dy,oe=d,G=l.useCallback(()=>{E(!1),y(!1)},[]),V=async x=>{if(x!==t.status){j(null),w(!0);try{await ft(r,a,t.id,x),i()}catch(Q){j(Q instanceof Error?Q.message:"Error al actualizar")}finally{w(!1)}}},H=async()=>{j(null),w(!0);try{await dt(r,a,t.id),i(),G()}catch(x){j(x instanceof Error?x.message:"Error al eliminar")}finally{w(!1)}},Z=["pending","dev_fixed","validated"];return u.jsxs(u.Fragment,{children:[u.jsx(xt,{selector:t.selector,active:oe}),u.jsx("div",{ref:M,role:"button",tabIndex:0,"aria-label":`Comentario: ${t.message.slice(0,30)}...`,"aria-expanded":d,style:{..._t(t.status),left:z,top:W,transform:"translate(-50%, -50%)"},onMouseEnter:Y,onMouseLeave:X,onClick:k,children:u.jsx(Ct,{color:"#fff"})}),d&&u.jsxs("div",{ref:c,role:"dialog","aria-label":"Detalle del comentario",style:{...jt,left:z+me/2+6,top:W},onMouseEnter:q,onMouseLeave:C,children:[u.jsxs("div",{style:kt,children:[u.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flex:1,minWidth:0},children:[u.jsx("div",{style:Tt(t.status),children:Rt(((ae=t.reviewer)==null?void 0:ae.name)??"Revisor")}),u.jsxs("div",{children:[u.jsx("div",{style:{fontWeight:700,fontSize:14,color:N.textDark},children:((ie=t.reviewer)==null?void 0:ie.name)??"Revisor"}),u.jsx("div",{style:{fontSize:12,color:N.textMuted},children:"Revisor"})]})]}),u.jsx("button",{type:"button","aria-label":t.status===O.VALIDATED?"Eliminar comentario":"Cerrar",style:Pt,disabled:_,onClick:x=>{x.stopPropagation(),t.status===O.VALIDATED?H():G()},onMouseDown:x=>x.stopPropagation(),children:"✕"})]}),u.jsxs("div",{style:Dt(t.status),children:[t.status===O.VALIDATED&&u.jsx(St,{}),wt[t.status]??t.status]}),u.jsx("div",{style:{color:N.textDark,lineHeight:1.5},children:t.message}),u.jsx("label",{style:Ot,htmlFor:`comment-status-${t.id}`,children:"Cambiar estado"}),u.jsx("select",{id:`comment-status-${t.id}`,style:Lt,value:t.status,disabled:_,onChange:x=>V(x.target.value),onMouseDown:x=>x.stopPropagation(),"aria-label":"Cambiar estado del comentario",children:Z.map(x=>u.jsx("option",{value:x,children:bt[x]},x))}),L&&u.jsx("div",{style:{marginTop:8,fontSize:11,color:"rgb(240, 69, 69)"},children:L}),u.jsxs("div",{style:It,children:[u.jsx("button",{type:"button",style:At,onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),G()},children:"Cerrar"}),t.status!==O.VALIDATED&&u.jsx("button",{type:"button",style:Ft,disabled:_,onMouseDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),V("validated")},children:"Resolver hilo"})]})]})]})}const Mt=25,zt=36;function Wt(t){const o=new Map;for(let r=0;r<t.length;r++){const a=t[r],{x:i,y:d}=fe(a);let y=0;for(let h=0;h<r;h++){const E=t[h],{x:S,y:v}=fe(E);Math.hypot(i-S,d-v)<Mt&&y++}o.set(a.id,{dx:y*zt,dy:0})}return o}function Vt(){return typeof window>"u"?"":`${window.innerWidth}x${window.innerHeight}`}function Bt({apiUrl:t,apiKey:o,reviewMode:r,reviewers:a,comments:i,loadComments:d,commentsLoadFailed:y=!1}){const[h,E]=l.useState(null),S=l.useRef(null),[v,_]=l.useState(null),w=l.useCallback(()=>{h&&(h.style.outline="",h.style.outlineOffset="",E(null))},[h]),L=l.useCallback(()=>{S.current&&(S.current.style.outline="",S.current.style.outlineOffset="",S.current=null)},[]);l.useEffect(()=>{r||(w(),L())},[r,w,L]),l.useEffect(()=>{if(typeof document>"u")return;const C=document.body.style.cursor;return v?document.body.style.cursor="default":r&&(document.body.style.cursor="crosshair"),()=>{document.body.style.cursor=C}},[r,v]);const j=l.useCallback(C=>{if(!r||v)return;const k=C.target.nodeType===Node.ELEMENT_NODE?C.target:C.target.parentElement;k&&(w(),E(k),k.style.outline="2px solid #ff4d4f",k.style.outlineOffset="2px")},[r,v,w]),I=l.useCallback(C=>{var z;if(v)return;const k=C.relatedTarget;h&&(!k||!h.contains(k))&&!(k&&((z=h.contains)!=null&&z.call(h,k)))&&w()},[h,v,w]),M=l.useCallback(C=>{if(!r||v)return;C.preventDefault(),C.stopPropagation();const k=C.target;if(!k||k.closest("[data-review-layer-pin]")||k.closest("[data-review-layer-modal]"))return;w();const z=k;S.current=z,z.style.outline="2px solid #ff4d4f",z.style.outlineOffset="2px";const W=z.getBoundingClientRect(),oe=at(k),{relativeX:G,relativeY:V}=it(W);_({position:{x:W.left+W.width/2,y:W.bottom},payload:{selector:oe,x:Math.round(W.left),y:Math.round(W.top),relativeX:G,relativeY:V,width:Math.round(W.width),height:Math.round(W.height),url:typeof window<"u"&&window.location.pathname||"/",viewport:Vt(),userAgent:typeof navigator<"u"?navigator.userAgent:"",pageTitle:typeof document<"u"?document.title:""}})},[r,v,w]);l.useEffect(()=>{if(r)return document.addEventListener("mouseover",j,!0),document.addEventListener("mouseout",I,!0),document.addEventListener("click",M,!0),()=>{document.removeEventListener("mouseover",j,!0),document.removeEventListener("mouseout",I,!0),document.removeEventListener("click",M,!0)}},[r,j,I,M]);const[c,p]=l.useState(0);l.useEffect(()=>{if(typeof window>"u")return;const C=()=>p(k=>k+1);return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[]);const D=l.useMemo(()=>Wt(i),[i,c]),Y={position:"fixed",inset:0,zIndex:999999,pointerEvents:"none",cursor:r?"crosshair":void 0},X=u.jsxs("div",{style:Y,"aria-hidden":!0,children:[r&&u.jsx("div",{style:{position:"fixed",top:10,left:10,zIndex:1e6,padding:"6px 12px",backgroundColor:"#ff4d4f",color:"#fff",borderRadius:6,fontSize:12,fontWeight:500,pointerEvents:"auto"},children:"Modo revisión (Shift+R para salir)"}),y&&u.jsxs("div",{style:{position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:10,padding:"8px 14px",backgroundColor:"#fff",border:"1px solid #e8e8e8",borderRadius:8,boxShadow:"0 2px 12px rgba(0,0,0,0.1)",fontSize:12,color:"#333",zIndex:999997,pointerEvents:"auto"},children:[u.jsx("span",{children:"No se pudo conectar. Mostrando últimos datos guardados. Reintentar no garantiza respuesta hasta que el servicio esté activo."}),u.jsx("button",{type:"button",onClick:()=>d(),style:{padding:"4px 10px",fontSize:12,fontWeight:600,backgroundColor:"rgb(33, 196, 94)",color:"#fff",border:"none",borderRadius:6,cursor:"pointer"},children:"Reintentar"})]}),i.map(C=>u.jsx("div",{"data-review-layer-pin":!0,style:{pointerEvents:"auto"},children:u.jsx(Nt,{comment:C,offset:D.get(C.id),apiUrl:t,apiKey:o,onStatusChange:d})},C.id)),v&&u.jsx("div",{"data-review-layer-modal":!0,style:{pointerEvents:"auto"},children:u.jsx(mt,{apiUrl:t,apiKey:o,reviewers:a,position:v.position,payload:v.payload,onClose:()=>{L(),_(null)},onSuccess:d})})]}),q=typeof document<"u"?document.body:null;return q?Te.createPortal(X,q):null}function Yt(t,o,r){const a=l.useCallback(()=>{t&&r(i=>!i)},[t,r]);l.useEffect(()=>{if(!t)return;const i=d=>{(d.key==="r"||d.key==="R"||d.code==="KeyR")&&d.shiftKey&&(d.preventDefault(),a())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t,a])}const Ut="review_layer:v1:";function Ht(t,o){if(t==null)return o;try{return JSON.parse(t)??o}catch{return o}}function de(t,o,r,a){const i=`${Ut}${Xt(t)}:${r}`;return a!=null?`${i}:${a}`:i}function Xt(t){return t.replace(/\/+$/,"")||"/"}function Ae(t){if(typeof localStorage>"u")return null;const o=localStorage.getItem(t);return Ht(o,null)}function Fe(t,o){if(!(typeof localStorage>"u"))try{localStorage.setItem(t,JSON.stringify({data:o,at:Date.now()}))}catch{}}function Ee(t,o,r){const a=Ae(de(t,o,"comments",r));return(a==null?void 0:a.data)??null}function Gt(t,o,r,a){Fe(de(t,o,"comments",r),a)}function Ne(t,o){const r=Ae(de(t,o,"reviewers"));return(r==null?void 0:r.data)??null}function Jt(t,o,r){Fe(de(t,o,"reviewers"),r)}const Me="https://review-layer-api.onrender.com/api";function ze(){return typeof window>"u"?"/":window.location.pathname||"/"}const We=l.createContext(null);let xe=null;function Zt(){const t=l.useContext(We);if(!t)throw new Error("useReview must be used within ReviewProvider");return t}function Qt({children:t,enabled:o=!0,apiUrl:r,apiKey:a}){const i=(r==null?void 0:r.trim())||Me,[d,y]=l.useState(!1),[h,E]=l.useState([]),[S,v]=l.useState([]),[_,w]=l.useState(!1);Yt(o,d,y);const L=l.useCallback(async c=>{if(!(!o||!i||!a))try{const p=await lt(i,a,{signal:c});c!=null&&c.aborted||(E(p),Jt(i,a,p))}catch(p){if(p instanceof Error&&p.name==="AbortError")return;if(!(c!=null&&c.aborted)){const D=Ne(i,a);D!=null&&E(D)}}},[o,i,a]),j=l.useCallback(async c=>{if(!o||!i||!a)return;const p=ze(),D=Ee(i,a,p);D!=null&&v(D);try{w(!1);const Y=await ct(i,a,p,{signal:c});c!=null&&c.aborted||(v(Y),Gt(i,a,p,Y))}catch(Y){if(Y instanceof Error&&Y.name==="AbortError")return;if(!(c!=null&&c.aborted)){w(!0);const X=Ee(i,a,p);X!=null&&v(X)}}},[o,i,a]);l.useEffect(()=>{if(!o||!i||!a)return;const c=ze(),p=Ne(i,a),D=Ee(i,a,c);p!=null&&E(p),D!=null&&v(D)},[o,i,a]),l.useEffect(()=>{if(!o||!i||!a)return;const c=`${i}:${a}`;if(xe!==c)return xe=c,L(),j(),()=>{setTimeout(()=>{xe=null},0)}},[o,i,a,L,j]),l.useEffect(()=>{if(!o)return;const c=()=>j();return window.addEventListener("popstate",c),()=>window.removeEventListener("popstate",c)},[o,j]);const I={apiUrl:i,apiKey:a,reviewMode:d,setReviewMode:y,reviewers:h,comments:S,loadComments:j,commentsLoadFailed:_},M=o&&typeof document<"u"?Te.createPortal(u.jsx(Bt,{apiUrl:i,apiKey:a,reviewMode:d,reviewers:h,comments:S,loadComments:j,commentsLoadFailed:_}),document.body):null;return u.jsxs(We.Provider,{value:I,children:[t,M]})}U.DEFAULT_API_URL=Me,U.ReviewProvider=Qt,U.useReview=Zt,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|
|
31
31
|
//# sourceMappingURL=review-layer-react.umd.cjs.map
|