@qwanyx/stack 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -0
- package/dist/index.cjs.js +11 -11
- package/dist/index.esm.js +1184 -750
- package/package.json +4 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Qwanyx Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Philippe Coenen / Qwanyx
|
|
4
|
+
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
PERMITTED USE:
|
|
8
|
+
- Use this package to build applications for the Qwanyx platform
|
|
9
|
+
|
|
10
|
+
PROHIBITED:
|
|
11
|
+
- Redistribute this package in any form
|
|
12
|
+
- Sell, sublicense, or commercially exploit this package
|
|
13
|
+
- Modify, adapt, or create derivative works
|
|
14
|
+
- Use this package outside of Qwanyx applications
|
|
15
|
+
- Use this package to create competing products or services
|
|
16
|
+
- Remove or alter any copyright notices
|
|
17
|
+
|
|
18
|
+
NO WARRANTY:
|
|
19
|
+
This package is provided "as is" without warranty of any kind, express or
|
|
20
|
+
implied, including but not limited to the warranties of merchantability,
|
|
21
|
+
fitness for a particular purpose, and noninfringement. In no event shall
|
|
22
|
+
the author be liable for any claim, damages, or other liability arising
|
|
23
|
+
from the use of this package.
|
|
24
|
+
|
|
25
|
+
For licensing inquiries: phil@qwanyx.com
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var wt=Object.defineProperty;var _t=(f,t,r)=>t in f?wt(f,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):f[t]=r;var be=(f,t,r)=>_t(f,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react");class jt{constructor(t){be(this,"config");if(!t.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=t}async callGraph(t,r={}){const n={coprocessor:"graph",method:t,system_id:this.config.system_id,params:r};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o}catch(i){throw console.error("Graph API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(t){return(await this.callGraph("get_children",{parent_id:t})).result||[]}async getNode(t){return(await this.callGraph("get_node",{node_id:t})).result||null}async addNode(t){const r={...t,created:t.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",r);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(t,r){const n={node_id:t,updates:{...r,modified:new Date().toISOString()}},i=await this.callGraph("update_node",n);if(!i.result)throw new Error("Failed to update node");return i.result}async deleteNode(t,r=!1){return(await this.callGraph("delete_node",{node_id:t,cascade:r})).success===!0}async getChildrenWithEdges(t,r="children",n,i){return(await this.callGraph("get_children_with_edges",{node_id:t,display_mode:r,edge_type:n,node_type:i})).result||[]}async addEdge(t,r,n="link",i){return await this.callGraph("add_edge",{source_id:t,target_id:r,edge_type:n,data:i})}async deleteEdge(t,r,n){return await this.callGraph("delete_edge",{source_id:t,target_id:r,edge_type:n})}async getEdges(t,r){return(await this.callGraph("get_edges",{source_id:t,edge_type:r})).result||[]}async getAncestors(t){return(await this.callGraph("get_ancestors",{node_id:t})).ancestors||[]}async getTree(t,r=10){return(await this.callGraph("get_tree",{root_id:t,max_depth:r})).tree||[]}async moveNode(t,r){const n=await this.callGraph("move",{node_id:t,new_parent_id:r});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(t,r){return(await this.callGraph("search",{query:t,type:r})).nodes||[]}}class Qe{constructor(t){be(this,"config");if(!t.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=t}async callMail(t,r={}){const n={coprocessor:"mail",method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...r}};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("Mail API call failed:",i),i}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(t){await this.callMail("save_email_settings",{accounts:t})}async listEmails(t,r=20){return this.callMail("list_emails",{account_id:t,limit:r})}async deleteEmails(t,r,n=!0){return this.callMail("delete_emails",{account_id:t,uids:r,expunge:n})}async imapExec(t,r){return this.callMail("imap_exec",{account_id:t,commands:r})}async trashEmails(t,r){const n=["SELECT INBOX",...r.map(l=>`UID MOVE ${l} [Gmail]/Trash`)],o=(await this.imapExec(t,n)).responses.filter(l=>l.ok&&l.command==="UID MOVE").length;return{success:o>0,moved:o}}async archiveEmails(t,r){const n=["SELECT INBOX",...r.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(t,n)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:o>0,archived:o}}async listFolders(t){const n=(await this.imapExec(t,['LIST "" *'])).responses.find(i=>i.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}}const Ae="qwanyx_auth_token",$e="qwanyx_refresh_token";class He{static setToken(t){typeof window<"u"&&localStorage.setItem(Ae,t)}static getToken(){return typeof window<"u"?localStorage.getItem(Ae):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Ae),localStorage.removeItem($e))}static setRefreshToken(t){typeof window<"u"&&localStorage.setItem($e,t)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem($e):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const t=this.getToken();return t?{Authorization:`Bearer ${t}`}:{}}}class Ze{constructor(t){be(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...t}}buildQueryString(t){if(!t||Object.keys(t).length===0)return"";const r=new URLSearchParams;Object.entries(t).forEach(([i,o])=>{o!=null&&r.append(i,String(o))});const n=r.toString();return n?`?${n}`:""}async request(t,r={}){const{method:n="GET",headers:i={},body:o,params:l}=r,v=`${this.config.baseUrl}/${t}${this.buildQueryString(l)}`,u={...this.config.headers,...He.getAuthHeader(),...i},h={method:n,headers:u};o&&n!=="GET"&&(h.body=JSON.stringify(o));try{const x=new AbortController,j=setTimeout(()=>x.abort(),this.config.timeout),O=await fetch(v,{...h,signal:x.signal});if(clearTimeout(j),!O.ok){const D=await O.json().catch(()=>({message:O.statusText}));throw new Error(D.message||`HTTP ${O.status}`)}return await O.json()}catch(x){throw x instanceof Error?x:new Error("An unexpected error occurred")}}async get(t,r){return this.request(t,{method:"GET",params:r})}async post(t,r,n){return this.request(t,{method:"POST",body:r,params:n})}async put(t,r,n){return this.request(t,{method:"PUT",body:r,params:n})}async patch(t,r,n){return this.request(t,{method:"PATCH",body:r,params:n})}async delete(t,r){return this.request(t,{method:"DELETE",params:r})}setBaseUrl(t){this.config.baseUrl=t}getBaseUrl(){return this.config.baseUrl}}let je=null;function Et(f){return je=new Ze(f),je}function Me(){if(!je)throw new Error("API client not initialized. Call initializeApiClient() first.");return je}function et(f,t,r={}){const{enabled:n=!0,refetchOnMount:i=!0,onSuccess:o,onError:l}=r,[v,u]=b.useState(null),[h,x]=b.useState(n),[j,O]=b.useState(null),D=b.useCallback(async()=>{if(n){x(!0),O(null);try{const C=await Me().get(f,t);u(C),o==null||o(C)}catch(P){const C=P instanceof Error?P:new Error("Unknown error");O(C),l==null||l(C)}finally{x(!1)}}},[f,JSON.stringify(t),n,o,l]);return b.useEffect(()=>{i&&D()},[D,i]),{data:v,loading:h,error:j,refetch:D}}function St(f,t="POST",r={}){const{onSuccess:n,onError:i}=r,[o,l]=b.useState(null),[v,u]=b.useState(!1),[h,x]=b.useState(null),j=b.useCallback(async D=>{u(!0),x(null);try{const P=Me();let C;switch(t){case"POST":C=await P.post(f,D);break;case"PUT":C=await P.put(f,D);break;case"PATCH":C=await P.patch(f,D);break;case"DELETE":C=await P.delete(f);break;default:throw new Error(`Unsupported method: ${t}`)}return l(C),n==null||n(C,D),C}catch(P){const C=P instanceof Error?P:new Error("Unknown error");return x(C),i==null||i(C,D),null}finally{u(!1)}},[f,t,n,i]),O=b.useCallback(()=>{l(null),x(null),u(!1)},[]);return{data:o,loading:v,error:h,mutate:j,reset:O}}var De={exports:{}},ce={};/**
|
|
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 Ke;function kt(){if(Ke)return ce;Ke=1;var f=b,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(v,u,h){var x,j={},O=null,D=null;h!==void 0&&(O=""+h),u.key!==void 0&&(O=""+u.key),u.ref!==void 0&&(D=u.ref);for(x in u)n.call(u,x)&&!o.hasOwnProperty(x)&&(j[x]=u[x]);if(v&&v.defaultProps)for(x in u=v.defaultProps,u)j[x]===void 0&&(j[x]=u[x]);return{$$typeof:t,type:v,key:O,ref:D,props:j,_owner:i.current}}return ce.Fragment=r,ce.jsx=l,ce.jsxs=l,ce}var ue={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,21 +14,21 @@
|
|
|
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
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var Xe;function Rt(){return Xe||(Xe=1,process.env.NODE_ENV!=="production"&&function(){var f=b,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),v=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),P=Symbol.iterator,C="@@iterator";function X(e){if(e===null||typeof e!="object")return null;var a=P&&e[P]||e[C];return typeof a=="function"?a:null}var z=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function g(e){{for(var a=arguments.length,c=new Array(a>1?a-1:0),y=1;y<a;y++)c[y-1]=arguments[y];I("error",e,c)}}function I(e,a,c){{var y=z.ReactDebugCurrentFrame,N=y.getStackAddendum();N!==""&&(a+="%s",c=c.concat([N]));var A=c.map(function(k){return String(k)});A.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,A)}}var V=!1,Q=!1,m=!1,T=!1,$=!1,p;p=Symbol.for("react.module.reference");function R(e){return!!(typeof e=="string"||typeof e=="function"||e===n||e===o||$||e===i||e===h||e===x||T||e===D||V||Q||m||typeof e=="object"&&e!==null&&(e.$$typeof===O||e.$$typeof===j||e.$$typeof===l||e.$$typeof===v||e.$$typeof===u||e.$$typeof===p||e.getModuleId!==void 0))}function E(e,a,c){var y=e.displayName;if(y)return y;var N=a.displayName||a.name||"";return N!==""?c+"("+N+")":c}function H(e){return e.displayName||"Context"}function B(e){if(e==null)return null;if(typeof e.tag=="number"&&g("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 n:return"Fragment";case r:return"Portal";case o:return"Profiler";case i:return"StrictMode";case h:return"Suspense";case x:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case v:var a=e;return H(a)+".Consumer";case l:var c=e;return H(c._context)+".Provider";case u:return E(e,e.render,"ForwardRef");case j:var y=e.displayName||null;return y!==null?y:B(e.type)||"Memo";case O:{var N=e,A=N._payload,k=N._init;try{return B(k(A))}catch{return null}}}return null}var S=Object.assign,M=0,Y,de,fe,pe,he,ge,ye;function xe(){}xe.__reactDisabledLog=!0;function Ee(){{if(M===0){Y=console.log,de=console.info,fe=console.warn,pe=console.error,he=console.group,ge=console.groupCollapsed,ye=console.groupEnd;var e={configurable:!0,enumerable:!0,value:xe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}M++}}function Se(){{if(M--,M===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:S({},e,{value:Y}),info:S({},e,{value:de}),warn:S({},e,{value:fe}),error:S({},e,{value:pe}),group:S({},e,{value:he}),groupCollapsed:S({},e,{value:ge}),groupEnd:S({},e,{value:ye})})}M<0&&g("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=z.ReactCurrentDispatcher,ie;function te(e,a,c){{if(ie===void 0)try{throw Error()}catch(N){var y=N.stack.trim().match(/\n( *(at )?)/);ie=y&&y[1]||""}return`
|
|
18
|
+
`+ie+e}}var oe=!1,re;{var ke=typeof WeakMap=="function"?WeakMap:Map;re=new ke}function me(e,a){if(!e||oe)return"";{var c=re.get(e);if(c!==void 0)return c}var y;oe=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var A;A=ae.current,ae.current=null,Ee();try{if(a){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(q){y=q}Reflect.construct(e,[],k)}else{try{k.call()}catch(q){y=q}e.call(k.prototype)}}else{try{throw Error()}catch(q){y=q}e()}}catch(q){if(q&&y&&typeof q.stack=="string"){for(var _=q.stack.split(`
|
|
19
|
+
`),G=y.stack.split(`
|
|
20
|
+
`),F=_.length-1,U=G.length-1;F>=1&&U>=0&&_[F]!==G[U];)U--;for(;F>=1&&U>=0;F--,U--)if(_[F]!==G[U]){if(F!==1||U!==1)do if(F--,U--,U<0||_[F]!==G[U]){var K=`
|
|
21
|
+
`+_[F].replace(" at new "," at ");return e.displayName&&K.includes("<anonymous>")&&(K=K.replace("<anonymous>",e.displayName)),typeof e=="function"&&re.set(e,K),K}while(F>=1&&U>=0);break}}}finally{oe=!1,ae.current=A,Se(),Error.prepareStackTrace=N}var se=e?e.displayName||e.name:"",ee=se?te(se):"";return typeof e=="function"&&re.set(e,ee),ee}function Re(e,a,c){return me(e,!1)}function d(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function w(e,a,c){if(e==null)return"";if(typeof e=="function")return me(e,d(e));if(typeof e=="string")return te(e);switch(e){case h:return te("Suspense");case x:return te("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case u:return Re(e.render);case j:return w(e.type,a,c);case O:{var y=e,N=y._payload,A=y._init;try{return w(A(N),a,c)}catch{}}}return""}var L=Object.prototype.hasOwnProperty,W={},Z=z.ReactDebugCurrentFrame;function J(e){if(e){var a=e._owner,c=w(e.type,e._source,a?a.type:null);Z.setExtraStackFrame(c)}else Z.setExtraStackFrame(null)}function Te(e,a,c,y,N){{var A=Function.call.bind(L);for(var k in e)if(A(e,k)){var _=void 0;try{if(typeof e[k]!="function"){var G=Error((y||"React class")+": "+c+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw G.name="Invariant Violation",G}_=e[k](a,k,y,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(F){_=F}_&&!(_ instanceof Error)&&(J(N),g("%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).",y||"React class",c,k,typeof _),J(null)),_ instanceof Error&&!(_.message in W)&&(W[_.message]=!0,J(N),g("Failed %s type: %s",c,_.message),J(null))}}}var ve=Array.isArray;function le(e){return ve(e)}function tt(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,c=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c}}function rt(e){try{return Fe(e),!1}catch{return!0}}function Fe(e){return""+e}function Ie(e){if(rt(e))return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",tt(e)),Fe(e)}var Ue=z.ReactCurrentOwner,nt={key:!0,ref:!0,__self:!0,__source:!0},Be,Le;function st(e){if(L.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function at(e){if(L.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function it(e,a){typeof e.ref=="string"&&Ue.current}function ot(e,a){{var c=function(){Be||(Be=!0,g("%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)",a))};c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}}function lt(e,a){{var c=function(){Le||(Le=!0,g("%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)",a))};c.isReactWarning=!0,Object.defineProperty(e,"ref",{get:c,configurable:!0})}}var ct=function(e,a,c,y,N,A,k){var _={$$typeof:t,type:e,key:a,ref:c,props:k,_owner:A};return _._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(_,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(_,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_};function ut(e,a,c,y,N){{var A,k={},_=null,G=null;c!==void 0&&(Ie(c),_=""+c),at(a)&&(Ie(a.key),_=""+a.key),st(a)&&(G=a.ref,it(a,N));for(A in a)L.call(a,A)&&!nt.hasOwnProperty(A)&&(k[A]=a[A]);if(e&&e.defaultProps){var F=e.defaultProps;for(A in F)k[A]===void 0&&(k[A]=F[A])}if(_||G){var U=typeof e=="function"?e.displayName||e.name||"Unknown":e;_&&ot(k,U),G&<(k,U)}return ct(e,_,G,N,y,Ue.current,k)}}var Oe=z.ReactCurrentOwner,ze=z.ReactDebugCurrentFrame;function ne(e){if(e){var a=e._owner,c=w(e.type,e._source,a?a.type:null);ze.setExtraStackFrame(c)}else ze.setExtraStackFrame(null)}var Ce;Ce=!1;function Ne(e){return typeof e=="object"&&e!==null&&e.$$typeof===t}function We(){{if(Oe.current){var e=B(Oe.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 dt(e){return""}var Ge={};function ft(e){{var a=We();if(!a){var c=typeof e=="string"?e:e.displayName||e.name;c&&(a=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+c+">.")}return a}}function Ye(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=ft(a);if(Ge[c])return;Ge[c]=!0;var y="";e&&e._owner&&e._owner!==Oe.current&&(y=" It was passed a child from "+B(e._owner.type)+"."),ne(e),g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,y),ne(null)}}function qe(e,a){{if(typeof e!="object")return;if(le(e))for(var c=0;c<e.length;c++){var y=e[c];Ne(y)&&Ye(y,a)}else if(Ne(e))e._store&&(e._store.validated=!0);else if(e){var N=X(e);if(typeof N=="function"&&N!==e.entries)for(var A=N.call(e),k;!(k=A.next()).done;)Ne(k.value)&&Ye(k.value,a)}}}function pt(e){{var a=e.type;if(a==null||typeof a=="string")return;var c;if(typeof a=="function")c=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===u||a.$$typeof===j))c=a.propTypes;else return;if(c){var y=B(a);Te(c,e.props,"prop",y,e)}else if(a.PropTypes!==void 0&&!Ce){Ce=!0;var N=B(a);g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ht(e){{for(var a=Object.keys(e.props),c=0;c<a.length;c++){var y=a[c];if(y!=="children"&&y!=="key"){ne(e),g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",y),ne(null);break}}e.ref!==null&&(ne(e),g("Invalid attribute `ref` supplied to `React.Fragment`."),ne(null))}}var Ve={};function Je(e,a,c,y,N,A){{var k=R(e);if(!k){var _="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(_+=" 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 G=dt();G?_+=G:_+=We();var F;e===null?F="null":le(e)?F="array":e!==void 0&&e.$$typeof===t?(F="<"+(B(e.type)||"Unknown")+" />",_=" Did you accidentally export a JSX literal instead of a component?"):F=typeof e,g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",F,_)}var U=ut(e,a,c,N,A);if(U==null)return U;if(k){var K=a.children;if(K!==void 0)if(y)if(le(K)){for(var se=0;se<K.length;se++)qe(K[se],e);Object.freeze&&Object.freeze(K)}else g("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 qe(K,e)}if(L.call(a,"key")){var ee=B(e),q=Object.keys(a).filter(function(bt){return bt!=="key"}),Pe=q.length>0?"{key: someKey, "+q.join(": ..., ")+": ...}":"{key: someKey}";if(!Ve[ee+Pe]){var vt=q.length>0?"{"+q.join(": ..., ")+": ...}":"{}";g(`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} />`,
|
|
30
|
+
<%s key={someKey} {...props} />`,Pe,ee,vt,ee),Ve[ee+Pe]=!0}}return e===n?ht(U):pt(U),U}}function gt(e,a,c){return Je(e,a,c,!0)}function yt(e,a,c){return Je(e,a,c,!1)}var xt=yt,mt=gt;ue.Fragment=n,ue.jsx=xt,ue.jsxs=mt}()),ue}process.env.NODE_ENV==="production"?De.exports=kt():De.exports=Rt();var s=De.exports;class _e{static filter(t,r){return t.filter(r)}static filterBy(t,r,n){return t.filter(i=>i[r]===n)}static filterByFields(t,r){return t.filter(n=>Object.entries(r).every(([i,o])=>n[i]===o))}static sort(t,r,n="asc"){return[...t].sort((i,o)=>{const l=i[r],v=o[r];if(l===v)return 0;let u=0;return l>v&&(u=1),l<v&&(u=-1),n==="asc"?u:-u})}static search(t,r,n){if(!r.trim())return t;const i=r.toLowerCase();return t.filter(o=>n.some(l=>{const v=o[l];return v==null?!1:String(v).toLowerCase().includes(i)}))}static paginate(t,r,n){const i=(r-1)*n,o=i+n;return{data:t.slice(i,o),total:t.length,page:r,totalPages:Math.ceil(t.length/n)}}static groupBy(t,r){return t.reduce((n,i)=>{const o=String(i[r]);return n[o]||(n[o]=[]),n[o].push(i),n},{})}static unique(t,r){const n=t.map(i=>i[r]);return[...new Set(n)]}static countBy(t,r){return t.reduce((n,i)=>{const o=String(i[r]);return n[o]=(n[o]||0)+1,n},{})}static pipe(t,r){return r.reduce((n,i)=>i(n),t)}}function Tt({endpoint:f,params:t,layout:r="list",title:n,emptyMessage:i="No items found",renderItem:o,keyExtractor:l=(C,X)=>C.id||C._id||String(X),searchable:v=!1,searchFields:u=[],searchPlaceholder:h="Search...",filters:x=[],pageSize:j=20,onItemClick:O,onRefresh:D,theme:P={}}){const{data:C,loading:X,error:z,refetch:g}=et(f,t),[I,V]=b.useState(""),[Q,m]=b.useState({}),[T,$]=b.useState(1),p=b.useMemo(()=>{if(!C)return{data:[],total:0,totalPages:0};let S=C;return v&&I&&u.length>0&&(S=_e.search(S,I,u)),Object.keys(Q).length>0&&(S=_e.filterByFields(S,Q)),_e.paginate(S,T,j)},[C,I,Q,T,j,v,u]);b.useEffect(()=>{$(1)},[I,Q]);const R=()=>{V(""),m({}),$(1),g(),D==null||D()},E={background:P.background||"#ffffff",cardBackground:P.cardBackground||"#f9fafb",text:P.text||"#111827",textSecondary:P.textSecondary||"#6b7280",border:P.border||"#e5e7eb",primary:P.primary||"#3b82f6"},B=o||(S=>s.jsxs("div",{style:{padding:"16px",cursor:O?"pointer":"default"},children:[s.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:E.text},children:S.title||S.name||S.label||"Untitled"}),S.description&&s.jsx("div",{style:{fontSize:"13px",color:E.textSecondary,marginTop:"4px"},children:S.description})]}));return X&&!C?s.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:E.textSecondary},children:"Loading..."}):z?s.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[s.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),s.jsx("div",{style:{fontSize:"14px"},children:z.message}),s.jsx("button",{onClick:R,style:{marginTop:"16px",padding:"8px 16px",background:E.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):s.jsxs("div",{style:{background:E.background,borderRadius:"12px",overflow:"hidden"},children:[(n||v||x.length>0)&&s.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${E.border}`},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:v||x.length>0?"12px":"0"},children:[n&&s.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:E.text},children:n}),s.jsx("button",{onClick:R,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${E.border}`,borderRadius:"6px",color:E.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),v&&s.jsx("input",{type:"text",placeholder:h,value:I,onChange:S=>V(S.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${E.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),s.jsx("div",{style:{display:r==="grid"?"grid":"flex",flexDirection:r==="list"?"column":void 0,gridTemplateColumns:r==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:r==="list"?"0":"16px",padding:r==="list"?"0":"16px"},children:p.data.length===0?s.jsx("div",{style:{padding:"48px",textAlign:"center",color:E.textSecondary},children:i}):p.data.map((S,M)=>s.jsx("div",{onClick:()=>O==null?void 0:O(S),style:{background:E.cardBackground,borderRadius:r==="list"?"0":"8px",borderBottom:r==="list"?`1px solid ${E.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:Y=>{O&&(Y.currentTarget.style.background=E.border)},onMouseLeave:Y=>{Y.currentTarget.style.background=E.cardBackground},children:B(S,M)},l(S,M)))}),p.totalPages>1&&s.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${E.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[s.jsxs("div",{style:{fontSize:"13px",color:E.textSecondary},children:["Page ",T," of ",p.totalPages]}),s.jsxs("div",{style:{display:"flex",gap:"8px"},children:[s.jsx("button",{onClick:()=>$(S=>Math.max(1,S-1)),disabled:T===1,style:{padding:"6px 12px",border:`1px solid ${E.border}`,borderRadius:"6px",background:"white",cursor:T===1?"not-allowed":"pointer",opacity:T===1?.5:1},children:"Previous"}),s.jsx("button",{onClick:()=>$(S=>Math.min(p.totalPages,S+1)),disabled:T===p.totalPages,style:{padding:"6px 12px",border:`1px solid ${E.border}`,borderRadius:"6px",background:"white",cursor:T===p.totalPages?"not-allowed":"pointer",opacity:T===p.totalPages?.5:1},children:"Next"})]})]})]})}function Ot({item:f,onClick:t,title:r=l=>l.title||l.name||l.label||"Untitled",subtitle:n=l=>l.description||l.subtitle||"",image:i=l=>l.image||l.thumbnail||l.photo,badge:o=l=>l.badge||l.tag||l.type}){const l=r(f),v=n(f),u=i(f),h=o(f);return s.jsxs("div",{onClick:t,className:`
|
|
31
31
|
flex items-center gap-4 p-4 border-b border-gray-200
|
|
32
32
|
hover:bg-gray-50 transition-colors
|
|
33
33
|
${t?"cursor-pointer":""}
|
|
34
|
-
`,children:[d&&i.jsx("div",{className:"flex-shrink-0",children:i.jsx("img",{src:d,alt:c,className:"w-16 h-16 object-cover rounded-lg"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h3",{className:"font-medium text-gray-900 truncate",children:c}),_&&i.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:_})]}),h&&i.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:h})]}),t&&i.jsx("div",{className:"flex-shrink-0 text-gray-400",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function kt({item:u,onClose:t,title:n=l=>l.title||l.name||l.label||"Detail",image:a=l=>l.image||l.thumbnail||l.photo,fields:o=[]}){if(!u)return null;const l=n(u),c=a(u);return i.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:i.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[i.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[i.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:l}),t&&i.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{className:"p-6",children:[c&&i.jsx("div",{className:"mb-6",children:i.jsx("img",{src:c,alt:l,className:"w-full h-64 object-cover rounded-lg"})}),o.length>0&&i.jsx("div",{className:"space-y-4",children:o.map((h,d)=>{const _=h.value(u);return _==null||_===""?null:i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:h.label}),i.jsx("div",{className:"text-base text-gray-900",children:typeof _=="object"?JSON.stringify(_,null,2):String(_)})]},d)})}),o.length===0&&i.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(u,null,2)})]}),t&&i.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:i.jsx("button",{onClick:t,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 Ct={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function Ot({nodes:u,cardCount:t=2,minInterval:n=1e3,maxInterval:a=3e3,onCardClick:o,cardSize:l="medium",className:c=""}){const h=Math.min(Math.max(t,1),5),[d,_]=R.useState([]),[v,O]=R.useState([]),[E,P]=R.useState(Array(h).fill(!1)),[k,j]=R.useState(Array(h).fill(!1)),Y=R.useRef([]),F=R.useCallback(p=>{const S=u.filter(y=>!p.includes(y._id));if(S.length===0)return null;const $=Math.floor(Math.random()*S.length);return S[$]},[u]),A=R.useCallback(()=>Math.random()*(a-n)+n,[n,a]);R.useEffect(()=>{if(u.length===0){_([]),O([]);return}const p=[],S=[],$=[];for(let y=0;y<h&&y<u.length;y++){const C=F($);C&&(p.push(C),$.push(C._id))}for(let y=0;y<p.length;y++){const C=[p[y]._id,...p.filter((z,U)=>U!==y).map(z=>z._id)],b=F(C);b?S.push(b):S.push(p[y])}_(p),O(S)},[u,h,F]);const B=R.useCallback(p=>{const S=A(),$=setTimeout(()=>{P(y=>{const C=[...y];return C[p]=!C[p],C}),setTimeout(()=>{j(y=>{const C=[...y];return C[p]=!C[p],C}),setTimeout(()=>{const y=!k[p];y&&_(C=>{const b=[...C];return b[p]=v[p],b}),O(C=>{const b=[...C],U=[(y?v[p]:d[p])._id,...d.filter((I,G)=>G!==p).map(I=>I._id),...C.filter((I,G)=>G!==p).map(I=>I._id)],m=F(U);return m&&(b[p]=m),b}),setTimeout(()=>{B(p)},150)},200)},150)},S);Y.current[p]=$},[A,F,d,v,k]),q=R.useRef(!1);R.useEffect(()=>{if(!(d.length===0||u.length<=1)&&!q.current){q.current=!0;for(let p=0;p<d.length;p++)B(p);return()=>{Y.current.forEach(p=>clearTimeout(p)),Y.current=[],q.current=!1}}},[d.length,u.length]);const V=p=>{o&&o(p)};return u.length===0?i.jsx("div",{className:`flex items-center justify-center p-8 ${c}`,children:i.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):d.length===0?i.jsx("div",{className:`flex items-center justify-center p-8 ${c}`,children:i.jsx("p",{className:"text-gray-500",children:"Loading..."})}):i.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${c}`,children:d.map((p,S)=>{const $=v[S],y=k[S];return i.jsx("div",{className:`relative ${Ct[l]}`,style:{perspective:"1000px"},onClick:()=>V(y?$:p),children:i.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${E[S]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[i.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:y?0:1},children:i.jsxs("div",{style:{transform:E[S]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[i.jsx("img",{src:p.data.image,alt:p.title,className:"w-full h-full object-cover"}),i.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:i.jsx("p",{className:"text-white text-sm font-medium truncate",children:p.title})})]})}),$&&i.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:y?1:0},children:i.jsxs("div",{style:{transform:E[S]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[i.jsx("img",{src:$.data.image,alt:$.title,className:"w-full h-full object-cover"}),i.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:i.jsx("p",{className:"text-white text-sm font-medium truncate",children:$.title})})]})})]})},`slot-${S}`)})})}exports.AnimatedCardFlip=Ot;exports.ApiClient=Ye;exports.AuthManager=Ge;exports.Card=Tt;exports.DataOperations=ae;exports.Detail=kt;exports.GraphClient=wt;exports.Stack=Rt;exports.getApiClient=xe;exports.initializeApiClient=_t;exports.useMutation=Et;exports.useQuery=qe;
|
|
34
|
+
`,children:[u&&s.jsx("div",{className:"flex-shrink-0",children:s.jsx("img",{src:u,alt:l,className:"w-16 h-16 object-cover rounded-lg"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"font-medium text-gray-900 truncate",children:l}),h&&s.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:h})]}),v&&s.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:v})]}),t&&s.jsx("div",{className:"flex-shrink-0 text-gray-400",children:s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function Ct({item:f,onClose:t,title:r=o=>o.title||o.name||o.label||"Detail",image:n=o=>o.image||o.thumbnail||o.photo,fields:i=[]}){if(!f)return null;const o=r(f),l=n(f);return s.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:s.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[s.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[s.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:o}),t&&s.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:s.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{className:"p-6",children:[l&&s.jsx("div",{className:"mb-6",children:s.jsx("img",{src:l,alt:o,className:"w-full h-64 object-cover rounded-lg"})}),i.length>0&&s.jsx("div",{className:"space-y-4",children:i.map((v,u)=>{const h=v.value(f);return h==null||h===""?null:s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:v.label}),s.jsx("div",{className:"text-base text-gray-900",children:typeof h=="object"?JSON.stringify(h,null,2):String(h)})]},u)})}),i.length===0&&s.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(f,null,2)})]}),t&&s.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:s.jsx("button",{onClick:t,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 Nt={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function Pt({nodes:f,cardCount:t=2,minInterval:r=1e3,maxInterval:n=3e3,onCardClick:i,cardSize:o="medium",className:l=""}){const v=Math.min(Math.max(t,1),5),[u,h]=b.useState([]),[x,j]=b.useState([]),[O,D]=b.useState(Array(v).fill(!1)),[P,C]=b.useState(Array(v).fill(!1)),X=b.useRef([]),z=b.useCallback(m=>{const T=f.filter(p=>!m.includes(p._id));if(T.length===0)return null;const $=Math.floor(Math.random()*T.length);return T[$]},[f]),g=b.useCallback(()=>Math.random()*(n-r)+r,[r,n]);b.useEffect(()=>{if(f.length===0){h([]),j([]);return}const m=[],T=[],$=[];for(let p=0;p<v&&p<f.length;p++){const R=z($);R&&(m.push(R),$.push(R._id))}for(let p=0;p<m.length;p++){const R=[m[p]._id,...m.filter((H,B)=>B!==p).map(H=>H._id)],E=z(R);E?T.push(E):T.push(m[p])}h(m),j(T)},[f,v,z]);const I=b.useCallback(m=>{const T=g(),$=setTimeout(()=>{D(p=>{const R=[...p];return R[m]=!R[m],R}),setTimeout(()=>{C(p=>{const R=[...p];return R[m]=!R[m],R}),setTimeout(()=>{const p=!P[m];p&&h(R=>{const E=[...R];return E[m]=x[m],E}),j(R=>{const E=[...R],B=[(p?x[m]:u[m])._id,...u.filter((M,Y)=>Y!==m).map(M=>M._id),...R.filter((M,Y)=>Y!==m).map(M=>M._id)],S=z(B);return S&&(E[m]=S),E}),setTimeout(()=>{I(m)},150)},200)},150)},T);X.current[m]=$},[g,z,u,x,P]),V=b.useRef(!1);b.useEffect(()=>{if(!(u.length===0||f.length<=1)&&!V.current){V.current=!0;for(let m=0;m<u.length;m++)I(m);return()=>{X.current.forEach(m=>clearTimeout(m)),X.current=[],V.current=!1}}},[u.length,f.length]);const Q=m=>{i&&i(m)};return f.length===0?s.jsx("div",{className:`flex items-center justify-center p-8 ${l}`,children:s.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):u.length===0?s.jsx("div",{className:`flex items-center justify-center p-8 ${l}`,children:s.jsx("p",{className:"text-gray-500",children:"Loading..."})}):s.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${l}`,children:u.map((m,T)=>{const $=x[T],p=P[T];return s.jsx("div",{className:`relative ${Nt[o]}`,style:{perspective:"1000px"},onClick:()=>Q(p?$:m),children:s.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${O[T]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[s.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:p?0:1},children:s.jsxs("div",{style:{transform:O[T]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[s.jsx("img",{src:m.data.image,alt:m.title,className:"w-full h-full object-cover"}),s.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:s.jsx("p",{className:"text-white text-sm font-medium truncate",children:m.title})})]})}),$&&s.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:p?1:0},children:s.jsxs("div",{style:{transform:O[T]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[s.jsx("img",{src:$.data.image,alt:$.title,className:"w-full h-full object-cover"}),s.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:s.jsx("p",{className:"text-white text-sm font-medium truncate",children:$.title})})]})})]})},`slot-${T}`)})})}function we(f){if(!f)return"";const t=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return f.replace(t,(r,n,i,o)=>{try{if(i.toUpperCase()==="B"){const l=atob(o);return decodeURIComponent(escape(l))}else if(i.toUpperCase()==="Q"){const l=o.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(v,u)=>String.fromCharCode(parseInt(u,16)));return decodeURIComponent(escape(l))}}catch(l){console.warn("MIME decode error:",l)}return r}).replace(/\s+/g," ").trim()}const At={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function $t({baseUrl:f,systemId:t,accountId:r,limit:n=30,selectable:i=!0,showDetail:o=!1,emptyMessage:l="No emails",autoLoad:v=!0,onSelect:u,onSelectionChange:h,onDelete:x,onError:j,renderItem:O,renderDetail:D,renderActions:P,renderEmpty:C,renderLoading:X,theme:z={}}){const g={...At,...z},[I,V]=b.useState([]),[Q,m]=b.useState(!1),[T,$]=b.useState(null),[p,R]=b.useState(new Set),[E,H]=b.useState(null),[B,S]=b.useState(null),M=b.useMemo(()=>t?new Qe({baseUrl:f,system_id:t}):null,[f,t]),Y=b.useCallback(async()=>{if(M){m(!0),$(null);try{const d=await M.listEmails(r,n);if(d!=null&&d.messages){const w=[...d.messages].sort((L,W)=>new Date(W.date).getTime()-new Date(L.date).getTime());V(w)}}catch(d){const w=d instanceof Error?d:new Error("Failed to fetch emails");$(w.message),j==null||j(w)}m(!1)}},[M,r,n,j]);b.useEffect(()=>{v&&Y()},[v,Y]);const de=b.useCallback((d,w,L)=>{if(!i){u==null||u(d),o&&S(d);return}const W=d.uid;if(L.shiftKey&&E!==null){const Z=Math.min(E,w),J=Math.max(E,w),Te=I.slice(Z,J+1).map(le=>le.uid),ve=new Set(Te);R(ve),h==null||h(Array.from(ve))}else if(L.ctrlKey||L.metaKey)R(Z=>{const J=new Set(Z);return J.has(W)?J.delete(W):J.add(W),h==null||h(Array.from(J)),J}),H(w);else if(p.size===1&&p.has(W))u==null||u(d),o&&S(d);else{const Z=new Set([W]);R(Z),H(w),h==null||h(Array.from(Z))}},[i,E,I,p,u,h,o]),fe=b.useCallback(async()=>{if(!(!M||p.size===0))try{const d=await M.trashEmails(r,Array.from(p));if(console.log("Trash result:",d),d.success&&d.moved>0){V(L=>L.filter(W=>!p.has(W.uid)));const w=Array.from(p);R(new Set),x==null||x(w)}else $("Failed to move emails to trash")}catch(d){const w=d instanceof Error?d:new Error("Trash failed");console.error("Trash error:",w),$(w.message),j==null||j(w)}},[M,r,p,x,j]),pe=b.useCallback(async()=>{if(!(!M||p.size===0))try{const d=await M.archiveEmails(r,Array.from(p));if(console.log("Archive result:",d),d.success&&d.archived>0){V(L=>L.filter(W=>!p.has(W.uid)));const w=Array.from(p);R(new Set),x==null||x(w)}else $("Failed to archive emails")}catch(d){const w=d instanceof Error?d:new Error("Archive failed");console.error("Archive error:",w),$(w.message),j==null||j(w)}},[M,r,p,x,j]),he=b.useCallback(()=>{if(p.size===I.length)R(new Set),h==null||h([]);else{const d=new Set(I.map(w=>w.uid));R(d),h==null||h(Array.from(d))}},[I,p.size,h]),ge=b.useCallback(()=>{R(new Set),h==null||h([])},[h]),ye={delete:fe,archive:pe,refresh:Y,selectAll:he,clearSelection:ge},xe=d=>{if(!d)return"";const w=new Date(d),L=new Date;return w.toDateString()===L.toDateString()?w.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):w.toLocaleDateString([],{month:"short",day:"numeric"})},Ee=(d,w)=>s.jsx("div",{style:{padding:"12px 16px",background:w?g.selectedBackground:d.seen?g.cardBackground:g.unreadBackground,borderBottom:`1px solid ${g.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsx("div",{style:{fontSize:"14px",fontWeight:d.seen?400:600,color:g.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:we(d.from).split("@")[0]}),s.jsx("div",{style:{fontSize:"14px",fontWeight:d.seen?400:500,color:d.seen?g.textSecondary:g.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:we(d.subject)||"(No subject)"})]}),s.jsx("div",{style:{fontSize:"12px",color:g.textSecondary,flexShrink:0},children:xe(d.date)})]})}),Se=d=>s.jsxs("div",{style:{padding:"24px"},children:[s.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:g.text},children:we(d.subject)||"(No subject)"}),s.jsxs("div",{style:{fontSize:"14px",color:g.textSecondary,marginBottom:"16px"},children:["From: ",we(d.from)," • ",new Date(d.date).toLocaleString()]}),s.jsx("div",{style:{fontSize:"14px",color:g.text},children:"Email body not loaded. Implement getEmail(uid) to fetch full content."})]}),ae=(d,w)=>s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:g.cardBackground,borderBottom:`1px solid ${g.border}`},children:[s.jsx("button",{onClick:w.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:g.text},children:d.length===I.length?"Deselect All":"Select All"}),d.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{style:{fontSize:"13px",color:g.textSecondary},children:[d.length," selected"]}),s.jsx("button",{onClick:w.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:s.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),s.jsx("button",{onClick:w.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:s.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),s.jsx("div",{style:{flex:1}}),s.jsx("button",{onClick:w.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${g.border}`,borderRadius:"6px",cursor:"pointer",color:g.textSecondary},children:s.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),ie=()=>s.jsx("div",{style:{padding:"48px",textAlign:"center",color:g.textSecondary},children:l}),te=()=>s.jsx("div",{style:{padding:"48px",textAlign:"center",color:g.textSecondary},children:"Loading..."}),oe=O||Ee,re=D||Se,ke=P||ae,me=C||ie,Re=X||te;return Q&&I.length===0?s.jsx("div",{style:{background:g.background,width:"100%",height:"100%"},children:Re()}):s.jsxs("div",{style:{display:"flex",background:g.background,width:"100%",height:"100%"},children:[s.jsxs("div",{style:{flex:o&&B?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&B?`1px solid ${g.border}`:"none",overflow:"hidden"},children:[i&&ke(Array.from(p),ye),T&&s.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:g.danger,fontSize:"14px",borderBottom:`1px solid ${g.border}`},children:T}),s.jsx("div",{style:{flex:1,overflowY:"auto"},children:I.length===0?me():I.map((d,w)=>s.jsx("div",{onClick:L=>de(d,w,L),children:oe(d,p.has(d.uid))},d.uid))})]}),o&&B&&s.jsx("div",{style:{flex:1,overflowY:"auto"},children:re(B)})]})}exports.AnimatedCardFlip=Pt;exports.ApiClient=Ze;exports.AuthManager=He;exports.Card=Ot;exports.DataOperations=_e;exports.Detail=Ct;exports.GraphClient=jt;exports.Mail=$t;exports.MailClient=Qe;exports.Stack=Tt;exports.getApiClient=Me;exports.initializeApiClient=Et;exports.useMutation=St;exports.useQuery=et;
|