@sg-front-core/store-v1 1.0.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.
@@ -0,0 +1,15 @@
1
+ (function(N,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],p):(N=typeof globalThis<"u"?globalThis:N||self,p(N.coreStore={},N.react))})(this,(function(N,p){"use strict";var se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ce={exports:{}},te={};var er;function $r(){if(er)return te;er=1;var e=p,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function c(v,d,o){var s,l={},b=null,g=null;o!==void 0&&(b=""+o),d.key!==void 0&&(b=""+d.key),d.ref!==void 0&&(g=d.ref);for(s in d)a.call(d,s)&&!u.hasOwnProperty(s)&&(l[s]=d[s]);if(v&&v.defaultProps)for(s in d=v.defaultProps,d)l[s]===void 0&&(l[s]=d[s]);return{$$typeof:t,type:v,key:b,ref:g,props:l,_owner:i.current}}return te.Fragment=n,te.jsx=c,te.jsxs=c,te}var ne={};var rr;function et(){return rr||(rr=1,process.env.NODE_ENV!=="production"&&(function(){var e=p,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),v=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),o=Symbol.for("react.suspense"),s=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),h=Symbol.iterator,E="@@iterator";function F(r){if(r===null||typeof r!="object")return null;var f=h&&r[h]||r[E];return typeof f=="function"?f:null}var I=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(r){{for(var f=arguments.length,m=new Array(f>1?f-1:0),y=1;y<f;y++)m[y-1]=arguments[y];W("error",r,m)}}function W(r,f,m){{var y=I.ReactDebugCurrentFrame,T=y.getStackAddendum();T!==""&&(f+="%s",m=m.concat([T]));var w=m.map(function(S){return String(S)});w.unshift("Warning: "+f),Function.prototype.apply.call(console[r],console,w)}}var U=!1,Y=!1,J=!1,V=!1,M=!1,Q;Q=Symbol.for("react.module.reference");function ae(r){return!!(typeof r=="string"||typeof r=="function"||r===a||r===u||M||r===i||r===o||r===s||V||r===g||U||Y||J||typeof r=="object"&&r!==null&&(r.$$typeof===b||r.$$typeof===l||r.$$typeof===c||r.$$typeof===v||r.$$typeof===d||r.$$typeof===Q||r.getModuleId!==void 0))}function oe(r,f,m){var y=r.displayName;if(y)return y;var T=f.displayName||f.name||"";return T!==""?m+"("+T+")":m}function K(r){return r.displayName||"Context"}function _(r){if(r==null)return null;if(typeof r.tag=="number"&&O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case a:return"Fragment";case n:return"Portal";case u:return"Profiler";case i:return"StrictMode";case o:return"Suspense";case s:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case v:var f=r;return K(f)+".Consumer";case c:var m=r;return K(m._context)+".Provider";case d:return oe(r,r.render,"ForwardRef");case l:var y=r.displayName||null;return y!==null?y:_(r.type)||"Memo";case b:{var T=r,w=T._payload,S=T._init;try{return _(S(w))}catch{return null}}}return null}var C=Object.assign,P=0,H,ie,$,Fr,Ir,Dr,Mr;function Lr(){}Lr.__reactDisabledLog=!0;function Kt(){{if(P===0){H=console.log,ie=console.info,$=console.warn,Fr=console.error,Ir=console.group,Dr=console.groupCollapsed,Mr=console.groupEnd;var r={configurable:!0,enumerable:!0,value:Lr,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}P++}}function Xt(){{if(P--,P===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},r,{value:H}),info:C({},r,{value:ie}),warn:C({},r,{value:$}),error:C({},r,{value:Fr}),group:C({},r,{value:Ir}),groupCollapsed:C({},r,{value:Dr}),groupEnd:C({},r,{value:Mr})})}P<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var He=I.ReactCurrentDispatcher,ze;function be(r,f,m){{if(ze===void 0)try{throw Error()}catch(T){var y=T.stack.trim().match(/\n( *(at )?)/);ze=y&&y[1]||""}return`
2
+ `+ze+r}}var Je=!1,ge;{var Zt=typeof WeakMap=="function"?WeakMap:Map;ge=new Zt}function Nr(r,f){if(!r||Je)return"";{var m=ge.get(r);if(m!==void 0)return m}var y;Je=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=He.current,He.current=null,Kt();try{if(f){var S=function(){throw Error()};if(Object.defineProperty(S.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(S,[])}catch(L){y=L}Reflect.construct(r,[],S)}else{try{S.call()}catch(L){y=L}r.call(S.prototype)}}else{try{throw Error()}catch(L){y=L}r()}}catch(L){if(L&&y&&typeof L.stack=="string"){for(var R=L.stack.split(`
3
+ `),D=y.stack.split(`
4
+ `),j=R.length-1,x=D.length-1;j>=1&&x>=0&&R[j]!==D[x];)x--;for(;j>=1&&x>=0;j--,x--)if(R[j]!==D[x]){if(j!==1||x!==1)do if(j--,x--,x<0||R[j]!==D[x]){var G=`
5
+ `+R[j].replace(" at new "," at ");return r.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",r.displayName)),typeof r=="function"&&ge.set(r,G),G}while(j>=1&&x>=0);break}}}finally{Je=!1,He.current=w,Xt(),Error.prepareStackTrace=T}var re=r?r.displayName||r.name:"",q=re?be(re):"";return typeof r=="function"&&ge.set(r,q),q}function Qt(r,f,m){return Nr(r,!1)}function qt(r){var f=r.prototype;return!!(f&&f.isReactComponent)}function ye(r,f,m){if(r==null)return"";if(typeof r=="function")return Nr(r,qt(r));if(typeof r=="string")return be(r);switch(r){case o:return be("Suspense");case s:return be("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case d:return Qt(r.render);case l:return ye(r.type,f,m);case b:{var y=r,T=y._payload,w=y._init;try{return ye(w(T),f,m)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,Wr={},Ur=I.ReactDebugCurrentFrame;function Re(r){if(r){var f=r._owner,m=ye(r.type,r._source,f?f.type:null);Ur.setExtraStackFrame(m)}else Ur.setExtraStackFrame(null)}function $t(r,f,m,y,T){{var w=Function.call.bind(ue);for(var S in r)if(w(r,S)){var R=void 0;try{if(typeof r[S]!="function"){var D=Error((y||"React class")+": "+m+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}R=r[S](f,S,y,m,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(j){R=j}R&&!(R instanceof Error)&&(Re(T),O("%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",m,S,typeof R),Re(null)),R instanceof Error&&!(R.message in Wr)&&(Wr[R.message]=!0,Re(T),O("Failed %s type: %s",m,R.message),Re(null))}}}var en=Array.isArray;function Ke(r){return en(r)}function rn(r){{var f=typeof Symbol=="function"&&Symbol.toStringTag,m=f&&r[Symbol.toStringTag]||r.constructor.name||"Object";return m}}function tn(r){try{return Gr(r),!1}catch{return!0}}function Gr(r){return""+r}function Br(r){if(tn(r))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",rn(r)),Gr(r)}var Yr=I.ReactCurrentOwner,nn={key:!0,ref:!0,__self:!0,__source:!0},Vr,Hr;function an(r){if(ue.call(r,"ref")){var f=Object.getOwnPropertyDescriptor(r,"ref").get;if(f&&f.isReactWarning)return!1}return r.ref!==void 0}function on(r){if(ue.call(r,"key")){var f=Object.getOwnPropertyDescriptor(r,"key").get;if(f&&f.isReactWarning)return!1}return r.key!==void 0}function un(r,f){typeof r.ref=="string"&&Yr.current}function sn(r,f){{var m=function(){Vr||(Vr=!0,O("%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)",f))};m.isReactWarning=!0,Object.defineProperty(r,"key",{get:m,configurable:!0})}}function cn(r,f){{var m=function(){Hr||(Hr=!0,O("%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)",f))};m.isReactWarning=!0,Object.defineProperty(r,"ref",{get:m,configurable:!0})}}var fn=function(r,f,m,y,T,w,S){var R={$$typeof:t,type:r,key:f,ref:m,props:S,_owner:w};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function ln(r,f,m,y,T){{var w,S={},R=null,D=null;m!==void 0&&(Br(m),R=""+m),on(f)&&(Br(f.key),R=""+f.key),an(f)&&(D=f.ref,un(f,T));for(w in f)ue.call(f,w)&&!nn.hasOwnProperty(w)&&(S[w]=f[w]);if(r&&r.defaultProps){var j=r.defaultProps;for(w in j)S[w]===void 0&&(S[w]=j[w])}if(R||D){var x=typeof r=="function"?r.displayName||r.name||"Unknown":r;R&&sn(S,x),D&&cn(S,x)}return fn(r,R,D,T,y,Yr.current,S)}}var Xe=I.ReactCurrentOwner,zr=I.ReactDebugCurrentFrame;function ee(r){if(r){var f=r._owner,m=ye(r.type,r._source,f?f.type:null);zr.setExtraStackFrame(m)}else zr.setExtraStackFrame(null)}var Ze;Ze=!1;function Qe(r){return typeof r=="object"&&r!==null&&r.$$typeof===t}function Jr(){{if(Xe.current){var r=_(Xe.current.type);if(r)return`
6
+
7
+ Check the render method of \``+r+"`."}return""}}function dn(r){return""}var Kr={};function vn(r){{var f=Jr();if(!f){var m=typeof r=="string"?r:r.displayName||r.name;m&&(f=`
8
+
9
+ Check the top-level render call using <`+m+">.")}return f}}function Xr(r,f){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var m=vn(f);if(Kr[m])return;Kr[m]=!0;var y="";r&&r._owner&&r._owner!==Xe.current&&(y=" It was passed a child from "+_(r._owner.type)+"."),ee(r),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,y),ee(null)}}function Zr(r,f){{if(typeof r!="object")return;if(Ke(r))for(var m=0;m<r.length;m++){var y=r[m];Qe(y)&&Xr(y,f)}else if(Qe(r))r._store&&(r._store.validated=!0);else if(r){var T=F(r);if(typeof T=="function"&&T!==r.entries)for(var w=T.call(r),S;!(S=w.next()).done;)Qe(S.value)&&Xr(S.value,f)}}}function mn(r){{var f=r.type;if(f==null||typeof f=="string")return;var m;if(typeof f=="function")m=f.propTypes;else if(typeof f=="object"&&(f.$$typeof===d||f.$$typeof===l))m=f.propTypes;else return;if(m){var y=_(f);$t(m,r.props,"prop",y,r)}else if(f.PropTypes!==void 0&&!Ze){Ze=!0;var T=_(f);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof f.getDefaultProps=="function"&&!f.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function pn(r){{for(var f=Object.keys(r.props),m=0;m<f.length;m++){var y=f[m];if(y!=="children"&&y!=="key"){ee(r),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",y),ee(null);break}}r.ref!==null&&(ee(r),O("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}var Qr={};function qr(r,f,m,y,T,w){{var S=ae(r);if(!S){var R="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(R+=" 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 D=dn();D?R+=D:R+=Jr();var j;r===null?j="null":Ke(r)?j="array":r!==void 0&&r.$$typeof===t?(j="<"+(_(r.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):j=typeof r,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,R)}var x=ln(r,f,m,T,w);if(x==null)return x;if(S){var G=f.children;if(G!==void 0)if(y)if(Ke(G)){for(var re=0;re<G.length;re++)Zr(G[re],r);Object.freeze&&Object.freeze(G)}else O("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 Zr(G,r)}if(ue.call(f,"key")){var q=_(r),L=Object.keys(f).filter(function(Sn){return Sn!=="key"}),qe=L.length>0?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}";if(!Qr[q+qe]){var Rn=L.length>0?"{"+L.join(": ..., ")+": ...}":"{}";O(`A props object containing a "key" prop is being spread into JSX:
10
+ let props = %s;
11
+ <%s {...props} />
12
+ React keys must be passed directly to JSX without using spread:
13
+ let props = %s;
14
+ <%s key={someKey} {...props} />`,qe,q,Rn,q),Qr[q+qe]=!0}}return r===a?pn(x):mn(x),x}}function hn(r,f,m){return qr(r,f,m,!0)}function bn(r,f,m){return qr(r,f,m,!1)}var gn=bn,yn=hn;ne.Fragment=a,ne.jsx=gn,ne.jsxs=yn})()),ne}var tr;function rt(){return tr||(tr=1,process.env.NODE_ENV==="production"?ce.exports=$r():ce.exports=et()),ce.exports}var z=rt();class Se{constructor(t){this.hook=t}hook;subscribers=new Set;data;notify(){for(const t of this.subscribers)t(this.data)}}function nr(e,t){const n=p.useRef(t);n.current=t;const a=p.useRef(n.current?.(e.data)||[]);return p.useSyncExternalStore(i=>{function u(){if(!n.current)i();else{const c=a.current,v=n.current(e.data);tt(c,v)&&i(),a.current=v}}return e.subscribers.add(u),()=>{e.subscribers.delete(u)}},()=>e.data)}function tt(e,t){if(e.length!==t.length)return!0;for(const n in t)if(e[n]!==t[n])return!0;return!1}const ar=new Se(()=>{});function nt(e,t){const n=t?.memo??!0,a=p.createContext(ar),i=p.createContext({}),u=s=>z.jsx(i.Provider,{value:{},children:s.children}),c=p.memo(s=>(p.useContext(i),z.jsx(z.Fragment,{children:s.children}))),v=p.memo(s=>{const{children:l,...b}=s,[g]=p.useState(()=>new Se(e));return g.data=e(b),p.useEffect(()=>{g.notify()}),z.jsx(a.Provider,{value:g,children:l})}),d=s=>z.jsx(u,{children:z.jsx(v,{...s,children:z.jsx(c,{children:s.children})})});function o(s){const l=p.useContext(a);return l===ar&&console.error("Failed to retrieve the store data from context. Seems like you didn't render a StoreProvider."),nr(l,s)}return[o,n?p.memo(d):d]}let Ee=[];const Te=new Set;function at(e){Ee=[...Ee,e],Te.forEach(t=>t())}const or=e=>{const t=p.useSyncExternalStore(n=>(Te.add(n),()=>{Te.delete(n)}),()=>Ee);return z.jsxs(z.Fragment,{children:[t.map((n,a)=>z.jsx(n,{},a)),e.children]})};function ir(e){let t=null;function n(){if(!t)throw new Error("Failed to retrieve data from global container. Please make sure you have rendered HoxRoot.");return t}const a=p.memo(()=>{const[c]=p.useState(()=>new Se(e));return t=c,c.data=e(),p.useEffect(()=>{c.notify()}),null});at(a);function i(c){return nr(n(),c)}function u(){return n().data}return[i,u]}function ur(){const e=p.useRef([]),[t,n]=p.useState({}),a=(...u)=>u.some(c=>t[c]),i=p.useMemo(()=>u=>new Proxy(u,{get(c,v){const d=v;return d in t||(e.current.push(d),queueMicrotask(()=>{const o=e.current;e.current=[],o.length&&n(s=>{const l={...s};for(const b of o)l[b]=!0;return l})})),c[v]}}),[t]);return{ready:a,proxy:i}}var ot=function(e){return function(t,n){var a=p.useRef(!1);e(function(){return function(){a.current=!1}},[]),e(function(){if(!a.current)a.current=!0;else return t()},n)}},B=function(){return B=Object.assign||function(t){for(var n,a=1,i=arguments.length;a<i;a++){n=arguments[a];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(t[u]=n[u])}return t},B.apply(this,arguments)};function sr(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(e);i<a.length;i++)t.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(n[a[i]]=e[a[i]]);return n}function it(e,t,n,a){function i(u){return u instanceof n?u:new n(function(c){c(u)})}return new(n||(n=Promise))(function(u,c){function v(s){try{o(a.next(s))}catch(l){c(l)}}function d(s){try{o(a.throw(s))}catch(l){c(l)}}function o(s){s.done?u(s.value):i(s.value).then(v,d)}o((a=a.apply(e,t||[])).next())})}function ut(e,t){var n={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},a,i,u,c=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return c.next=v(0),c.throw=v(1),c.return=v(2),typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function v(o){return function(s){return d([o,s])}}function d(o){if(a)throw new TypeError("Generator is already executing.");for(;c&&(c=0,o[0]&&(n=0)),n;)try{if(a=1,i&&(u=o[0]&2?i.return:o[0]?i.throw||((u=i.return)&&u.call(i),0):i.next)&&!(u=u.call(i,o[1])).done)return u;switch(i=0,u&&(o=[o[0]&2,u.value]),o[0]){case 0:case 1:u=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if(u=n.trys,!(u=u.length>0&&u[u.length-1])&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!u||o[1]>u[0]&&o[1]<u[3])){n.label=o[1];break}if(o[0]===6&&n.label<u[1]){n.label=u[1],u=o;break}if(u&&n.label<u[2]){n.label=u[2],n.ops.push(o);break}u[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(s){o=[6,s],i=0}finally{a=u=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function A(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),i,u=[],c;try{for(;(t===void 0||t-- >0)&&!(i=a.next()).done;)u.push(i.value)}catch(v){c={error:v}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(c)throw c.error}}return u}function k(e,t,n){if(n||arguments.length===2)for(var a=0,i=t.length,u;a<i;a++)(u||!(a in t))&&(u||(u=Array.prototype.slice.call(t,0,a)),u[a]=t[a]);return e.concat(u||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var fe=function(e){return typeof e=="function"},le=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test",X=function(e){le&&(fe(e)||console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof e)));var t=p.useRef(e);t.current=p.useMemo(function(){return e},[e]);var n=p.useRef(void 0);return n.current||(n.current=function(){for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];return t.current.apply(this,a)}),n.current};const _e=ot(p.useEffect);var cr=function(e,t){var n=t.manual,a=t.ready,i=a===void 0?!0:a,u=t.defaultParams,c=u===void 0?[]:u,v=t.refreshDeps,d=v===void 0?[]:v,o=t.refreshDepsAction,s=p.useRef(!1);return s.current=!1,_e(function(){!n&&i&&(s.current=!0,e.run.apply(e,k([],A(c),!1)))},[i]),_e(function(){s.current||n||(s.current=!0,o?o():e.refresh())},k([],A(d),!1)),{onBefore:function(){if(!i)return{stopNow:!0}}}};cr.onInit=function(e){var t=e.ready,n=t===void 0?!0:t,a=e.manual;return{loading:!a&&n}};function st(e,t){if(e===t)return!0;for(var n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}var fr=function(e,t){var n=p.useRef({deps:t,obj:void 0,initialized:!1}).current;return(n.initialized===!1||!st(n.deps,t))&&(n.deps=t,n.obj=e(),n.initialized=!0),n.obj};function lr(e){var t=p.useRef(e);return t.current=e,t}var we=function(e){le&&(fe(e)||console.error("useUnmount expected parameter is a function, got ".concat(typeof e)));var t=lr(e);p.useEffect(function(){return function(){t.current()}},[])},de=new Map,ct=function(e,t,n){var a=de.get(e);a?.timer&&clearTimeout(a.timer);var i=void 0;t>-1&&(i=setTimeout(function(){de.delete(e)},t)),de.set(e,B(B({},n),{timer:i}))},ft=function(e){return de.get(e)},ve=new Map,lt=function(e){return ve.get(e)},dt=function(e,t){ve.set(e,t),t.then(function(n){return ve.delete(e),n}).catch(function(){ve.delete(e)})},Z={},vt=function(e,t){Z[e]&&Z[e].forEach(function(n){return n(t)})},Oe=function(e,t){return Z[e]||(Z[e]=[]),Z[e].push(t),function(){var a=Z[e].indexOf(t);Z[e].splice(a,1)}},mt=function(e,t){var n=t.cacheKey,a=t.cacheTime,i=a===void 0?300*1e3:a,u=t.staleTime,c=u===void 0?0:u,v=t.setCache,d=t.getCache,o=p.useRef(void 0),s=p.useRef(void 0),l=function(g,h){v?v(h):ct(g,i,h),vt(g,h.data)},b=function(g,h){return h===void 0&&(h=[]),d?d(h):ft(g)};return fr(function(){if(n){var g=b(n);g&&Object.hasOwnProperty.call(g,"data")&&(e.state.data=g.data,e.state.params=g.params,(c===-1||Date.now()-g.time<=c)&&(e.state.loading=!1)),o.current=Oe(n,function(h){e.setState({data:h})})}},[]),we(function(){var g;(g=o.current)===null||g===void 0||g.call(o)}),n?{onBefore:function(g){var h=b(n,g);return!h||!Object.hasOwnProperty.call(h,"data")?{}:c===-1||Date.now()-h.time<=c?{loading:!1,data:h?.data,error:void 0,returnNow:!0}:{data:h?.data,error:void 0}},onRequest:function(g,h){var E=lt(n);return E&&E!==s.current?{servicePromise:E}:(E=g.apply(void 0,k([],A(h),!1)),s.current=E,dt(n,E),{servicePromise:E})},onSuccess:function(g,h){var E;n&&((E=o.current)===null||E===void 0||E.call(o),l(n,{data:g,params:h,time:Date.now()}),o.current=Oe(n,function(F){e.setState({data:F})}))},onMutate:function(g){var h;n&&((h=o.current)===null||h===void 0||h.call(o),l(n,{data:g,params:e.state.params,time:Date.now()}),o.current=Oe(n,function(E){e.setState({data:E})}))}}:{}},Pe,dr;function je(){if(dr)return Pe;dr=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Pe=e,Pe}var xe,vr;function pt(){if(vr)return xe;vr=1;var e=typeof se=="object"&&se&&se.Object===Object&&se;return xe=e,xe}var Ce,mr;function pr(){if(mr)return Ce;mr=1;var e=pt(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Ce=n,Ce}var Ae,hr;function ht(){if(hr)return Ae;hr=1;var e=pr(),t=function(){return e.Date.now()};return Ae=t,Ae}var ke,br;function bt(){if(br)return ke;br=1;var e=/\s/;function t(n){for(var a=n.length;a--&&e.test(n.charAt(a)););return a}return ke=t,ke}var Fe,gr;function gt(){if(gr)return Fe;gr=1;var e=bt(),t=/^\s+/;function n(a){return a&&a.slice(0,e(a)+1).replace(t,"")}return Fe=n,Fe}var Ie,yr;function Rr(){if(yr)return Ie;yr=1;var e=pr(),t=e.Symbol;return Ie=t,Ie}var De,Sr;function yt(){if(Sr)return De;Sr=1;var e=Rr(),t=Object.prototype,n=t.hasOwnProperty,a=t.toString,i=e?e.toStringTag:void 0;function u(c){var v=n.call(c,i),d=c[i];try{c[i]=void 0;var o=!0}catch{}var s=a.call(c);return o&&(v?c[i]=d:delete c[i]),s}return De=u,De}var Me,Er;function Rt(){if(Er)return Me;Er=1;var e=Object.prototype,t=e.toString;function n(a){return t.call(a)}return Me=n,Me}var Le,Tr;function St(){if(Tr)return Le;Tr=1;var e=Rr(),t=yt(),n=Rt(),a="[object Null]",i="[object Undefined]",u=e?e.toStringTag:void 0;function c(v){return v==null?v===void 0?i:a:u&&u in Object(v)?t(v):n(v)}return Le=c,Le}var Ne,_r;function Et(){if(_r)return Ne;_r=1;function e(t){return t!=null&&typeof t=="object"}return Ne=e,Ne}var We,wr;function Tt(){if(wr)return We;wr=1;var e=St(),t=Et(),n="[object Symbol]";function a(i){return typeof i=="symbol"||t(i)&&e(i)==n}return We=a,We}var Ue,Or;function _t(){if(Or)return Ue;Or=1;var e=gt(),t=je(),n=Tt(),a=NaN,i=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,c=/^0o[0-7]+$/i,v=parseInt;function d(o){if(typeof o=="number")return o;if(n(o))return a;if(t(o)){var s=typeof o.valueOf=="function"?o.valueOf():o;o=t(s)?s+"":s}if(typeof o!="string")return o===0?o:+o;o=e(o);var l=u.test(o);return l||c.test(o)?v(o.slice(2),l?2:8):i.test(o)?a:+o}return Ue=d,Ue}var Ge,Pr;function jr(){if(Pr)return Ge;Pr=1;var e=je(),t=ht(),n=_t(),a="Expected a function",i=Math.max,u=Math.min;function c(v,d,o){var s,l,b,g,h,E,F=0,I=!1,O=!1,W=!0;if(typeof v!="function")throw new TypeError(a);d=n(d)||0,e(o)&&(I=!!o.leading,O="maxWait"in o,b=O?i(n(o.maxWait)||0,d):b,W="trailing"in o?!!o.trailing:W);function U(_){var C=s,P=l;return s=l=void 0,F=_,g=v.apply(P,C),g}function Y(_){return F=_,h=setTimeout(M,d),I?U(_):g}function J(_){var C=_-E,P=_-F,H=d-C;return O?u(H,b-P):H}function V(_){var C=_-E,P=_-F;return E===void 0||C>=d||C<0||O&&P>=b}function M(){var _=t();if(V(_))return Q(_);h=setTimeout(M,J(_))}function Q(_){return h=void 0,W&&s?U(_):(s=l=void 0,g)}function ae(){h!==void 0&&clearTimeout(h),F=0,s=E=l=h=void 0}function oe(){return h===void 0?g:Q(t())}function K(){var _=t(),C=V(_);if(s=arguments,l=this,E=_,C){if(h===void 0)return Y(E);if(O)return clearTimeout(h),h=setTimeout(M,d),U(E)}return h===void 0&&(h=setTimeout(M,d)),g}return K.cancel=ae,K.flush=oe,K}return Ge=c,Ge}var wt=jr();const Ot=$e(wt);var Pt=function(e,t){var n=t.debounceWait,a=t.debounceLeading,i=t.debounceTrailing,u=t.debounceMaxWait,c=p.useRef(void 0),v=p.useMemo(function(){var d={};return a!==void 0&&(d.leading=a),i!==void 0&&(d.trailing=i),u!==void 0&&(d.maxWait=u),d},[a,i,u]);return p.useEffect(function(){if(n){var d=e.runAsync.bind(e);return c.current=Ot(function(o){o()},n,v),e.runAsync=function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];return new Promise(function(l,b){var g;(g=c.current)===null||g===void 0||g.call(c,function(){d.apply(void 0,k([],A(o),!1)).then(l).catch(b)})})},function(){var o;(o=c.current)===null||o===void 0||o.cancel(),e.runAsync=d}}},[n,v]),n?{onCancel:function(){var d;(d=c.current)===null||d===void 0||d.cancel()}}:{}},jt=function(e,t){var n=t.loadingDelay,a=t.ready,i=p.useRef(void 0);if(!n)return{};var u=function(){i.current&&clearTimeout(i.current)};return{onBefore:function(){return u(),a!==!1&&(i.current=setTimeout(function(){e.setState({loading:!0})},n)),{loading:!1}},onFinally:function(){u()},onCancel:function(){u()}}},me=!!(typeof window<"u"&&window.document&&window.document.createElement);function Be(){return me?document.visibilityState!=="hidden":!0}var pe=new Set;function xt(e){return pe.add(e),function(){pe.has(e)&&pe.delete(e)}}if(me){var Ct=function(){Be()&&pe.forEach(function(e){return e()})};window.addEventListener("visibilitychange",Ct,!1)}var At=function(e,t){var n=t.pollingInterval,a=t.pollingWhenHidden,i=a===void 0?!0:a,u=t.pollingErrorRetryCount,c=u===void 0?-1:u,v=p.useRef(void 0),d=p.useRef(void 0),o=p.useRef(0),s=function(){var l;v.current&&clearTimeout(v.current),(l=d.current)===null||l===void 0||l.call(d)};return _e(function(){n||s()},[n]),n?{onBefore:function(){s()},onError:function(){o.current+=1},onSuccess:function(){o.current=0},onFinally:function(){c===-1||c!==-1&&o.current<=c?v.current=setTimeout(function(){!i&&!Be()?d.current=xt(function(){e.refresh()}):e.refresh()},n):o.current=0},onCancel:function(){s()}}:{}};function kt(e,t){var n=!1;return function(){for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];n||(n=!0,e.apply(void 0,k([],A(a),!1)),setTimeout(function(){n=!1},t))}}var Ft=function(){return me&&typeof navigator.onLine<"u"?navigator.onLine:!0},he=new Set;function It(e){return he.add(e),function(){he.has(e)&&he.delete(e)}}if(me){var xr=function(){!Be()||!Ft()||he.forEach(function(e){return e()})};window.addEventListener("visibilitychange",xr,!1),window.addEventListener("focus",xr,!1)}var Dt=function(e,t){var n=t.refreshOnWindowFocus,a=t.focusTimespan,i=a===void 0?5e3:a,u=p.useRef(void 0),c=function(){var v;(v=u.current)===null||v===void 0||v.call(u)};return p.useEffect(function(){if(n){var v=kt(e.refresh.bind(e),i);u.current=It(function(){v()})}return function(){c()}},[n,i]),we(function(){c()}),{}},Mt=function(e,t){var n=t.retryInterval,a=t.retryCount,i=p.useRef(void 0),u=p.useRef(0),c=p.useRef(!1);return a?{onBefore:function(){c.current||(u.current=0),c.current=!1,i.current&&clearTimeout(i.current)},onSuccess:function(){u.current=0},onError:function(){if(u.current+=1,a===-1||u.current<=a){var v=n??Math.min(1e3*Math.pow(2,u.current),3e4);i.current=setTimeout(function(){c.current=!0,e.refresh()},v)}else u.current=0},onCancel:function(){u.current=0,i.current&&clearTimeout(i.current)}}:{}},Ye,Cr;function Lt(){if(Cr)return Ye;Cr=1;var e=jr(),t=je(),n="Expected a function";function a(i,u,c){var v=!0,d=!0;if(typeof i!="function")throw new TypeError(n);return t(c)&&(v="leading"in c?!!c.leading:v,d="trailing"in c?!!c.trailing:d),e(i,u,{leading:v,maxWait:u,trailing:d})}return Ye=a,Ye}var Nt=Lt();const Wt=$e(Nt);var Ut=function(e,t){var n=t.throttleWait,a=t.throttleLeading,i=t.throttleTrailing,u=p.useRef(void 0),c={};return a!==void 0&&(c.leading=a),i!==void 0&&(c.trailing=i),p.useEffect(function(){if(n){var v=e.runAsync.bind(e);return u.current=Wt(function(d){d()},n,c),e.runAsync=function(){for(var d=[],o=0;o<arguments.length;o++)d[o]=arguments[o];return new Promise(function(s,l){var b;(b=u.current)===null||b===void 0||b.call(u,function(){v.apply(void 0,k([],A(d),!1)).then(s).catch(l)})})},function(){var d;e.runAsync=v,(d=u.current)===null||d===void 0||d.cancel()}}},[n,a,i]),n?{onCancel:function(){var v;(v=u.current)===null||v===void 0||v.cancel()}}:{}},Gt=function(e){le&&(fe(e)||console.error('useMount: parameter `fn` expected to be a function, but got "'.concat(typeof e,'".'))),p.useEffect(function(){var t=e?.();if(!(t&&typeof t=="object"&&typeof t.then=="function"))return t},[])},Bt=function(){var e=A(p.useState({}),2),t=e[1];return X(function(){return t({})})},Yt=(function(){function e(t,n,a,i){i===void 0&&(i={}),this.serviceRef=t,this.options=n,this.subscribe=a,this.initState=i,this.pluginImpls=[],this.count=0,this.state={loading:!1,params:void 0,data:void 0,error:void 0},this.state=B(B(B({},this.state),{loading:!n.manual}),i)}return e.prototype.setState=function(t){t===void 0&&(t={}),this.state=B(B({},this.state),t),this.subscribe()},e.prototype.runPluginHandler=function(t){for(var n=[],a=1;a<arguments.length;a++)n[a-1]=arguments[a];var i=this.pluginImpls.map(function(u){var c;return(c=u[t])===null||c===void 0?void 0:c.call.apply(c,k([u],A(n),!1))}).filter(Boolean);return Object.assign.apply(Object,k([{}],A(i),!1))},e.prototype.runAsync=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return it(this,void 0,void 0,function(){var a,i,u,c,v,d,o,s,l,b,g,h,E,F,I,O,W,U,Y,J,V;return ut(this,function(M){switch(M.label){case 0:if(this.count+=1,a=this.count,i=this.runPluginHandler("onBefore",t),u=i.stopNow,c=u===void 0?!1:u,v=i.returnNow,d=v===void 0?!1:v,o=sr(i,["stopNow","returnNow"]),c)return[2,Promise.resolve(o.data)];if(this.setState(B({loading:!0,params:t},o)),d)return[2,Promise.resolve(o.data)];(E=(h=this.options).onBefore)===null||E===void 0||E.call(h,t),M.label=1;case 1:return M.trys.push([1,3,,4]),s=this.runPluginHandler("onRequest",this.serviceRef.current,t).servicePromise,s||(s=(g=this.serviceRef).current.apply(g,k([],A(t),!1))),[4,s];case 2:return l=M.sent(),a!==this.count?[2,new Promise(function(){})]:(this.setState({data:l,error:void 0,loading:!1}),(I=(F=this.options).onSuccess)===null||I===void 0||I.call(F,l,t),this.runPluginHandler("onSuccess",l,t),(W=(O=this.options).onFinally)===null||W===void 0||W.call(O,t,l,void 0),a===this.count&&this.runPluginHandler("onFinally",t,l,void 0),[2,l]);case 3:if(b=M.sent(),a!==this.count)return[2,new Promise(function(){})];throw this.setState({error:b,loading:!1}),(Y=(U=this.options).onError)===null||Y===void 0||Y.call(U,b,t),this.runPluginHandler("onError",b,t),(V=(J=this.options).onFinally)===null||V===void 0||V.call(J,t,void 0,b),a===this.count&&this.runPluginHandler("onFinally",t,void 0,b),b;case 4:return[2]}})})},e.prototype.run=function(){for(var t=this,n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];this.runAsync.apply(this,k([],A(n),!1)).catch(function(i){t.options.onError||console.error(i)})},e.prototype.cancel=function(){this.count+=1,this.setState({loading:!1}),this.runPluginHandler("onCancel")},e.prototype.refresh=function(){this.run.apply(this,k([],A(this.state.params||[]),!1))},e.prototype.refreshAsync=function(){return this.runAsync.apply(this,k([],A(this.state.params||[]),!1))},e.prototype.mutate=function(t){var n=fe(t)?t(this.state.data):t;this.runPluginHandler("onMutate",n),this.setState({data:n})},e})();function Vt(e,t,n){t===void 0&&(t={}),n===void 0&&(n=[]);var a=t.manual,i=a===void 0?!1:a,u=t.ready,c=u===void 0?!0:u,v=sr(t,["manual","ready"]);le&&t.defaultParams&&!Array.isArray(t.defaultParams)&&console.warn("expected defaultParams is array, got ".concat(typeof t.defaultParams));var d=B({manual:i,ready:c},v),o=lr(e),s=Bt(),l=fr(function(){var b=n.map(function(g){var h;return(h=g?.onInit)===null||h===void 0?void 0:h.call(g,d)}).filter(Boolean);return new Yt(o,d,s,Object.assign.apply(Object,k([{}],A(b),!1)))},[]);return l.options=d,l.pluginImpls=n.map(function(b){return b(l,d)}),Gt(function(){if(!i&&c){var b=l.state.params||t.defaultParams||[];l.run.apply(l,k([],A(b),!1))}}),we(function(){l.cancel()}),{loading:l.state.loading,data:l.state.data,error:l.state.error,params:l.state.params||[],cancel:X(l.cancel.bind(l)),refresh:X(l.refresh.bind(l)),refreshAsync:X(l.refreshAsync.bind(l)),run:X(l.run.bind(l)),runAsync:X(l.runAsync.bind(l)),mutate:X(l.mutate.bind(l))}}function Ar(e,t,n){return Vt(e,t,k(k([],A([]),!1),[Pt,jt,At,Dt,Ut,cr,mt,Mt],!1))}var kr=(e=>(e[e.userReq=1]="userReq",e[e.menuReq=2]="menuReq",e))(kr||{});const Ht=[{path:"userinfo",component:"userinfo/index",meta:{title:"个人信息"},menuType:"C"},{path:"404",component:"404/index",meta:{title:"404"},menuType:"C"},{path:"lowcode/flow",component:"lowcode/flow/index",meta:{title:"工作流"}},{path:"home",component:"home/index",meta:{title:"首页"},menuType:"C"}],zt={userId:"",userName:"",deptId:"",deptName:"",phone:"",roles:"",rolePermis:[]},Ve=e=>{if(p.isValidElement(e))return p.cloneElement(e);if(Array.isArray(e))return e.map(Ve);if(!e||typeof e!="object")return e;const t={};for(const n of Object.keys(e))t[n]=Ve(e[n]);return t};function Jt(e){const t=()=>{const o=e.routesConfig??[],s=o.findIndex(l=>l?.path==="/");return s>=0?o[s]:void 0},n=()=>{const o=t(),s=o?.children;!o||!Array.isArray(s)||(o.children=s.filter(l=>l?.path==="userinfo"||l?.path==="home"||l?.path==="*"))},a=o=>{const s=t();if(!s)return;const l=Array.isArray(o)?[...o].reverse():o;e.transConfig(l,s)},i=()=>{const s=t()?.children;return Array.isArray(s)?(e.transMenu(Ve(s))??[]).filter(b=>b).filter(b=>b?.key!=="*"):[]},u=o=>{const s=o?.data,l=s?.user;l&&e.userLocal.set({userId:l.userName,userName:l.nickName,deptId:l.dept?.id,deptName:l.dept?.deptName,phone:l.phonenumber,permissions:s.permissions,roles:s.roleNames,rolePermis:JSON.stringify(s.rolePermis)})},[c,v]=ir(()=>{const{proxy:o}=ur(),s=Ar(()=>e.request({url:"v1/system/login/getInfo",method:"get"}),{manual:!0,debounceWait:200}),l=p.useMemo(()=>s.data?.code===200?(u(s.data),e.userLocal.get()):e.userLocal.get()||zt,[s.data]),b=Ar(()=>e.request({url:"v1/system/login/getPzptRouters",method:"get"}),{manual:!0,debounceWait:200}),g=p.useMemo(()=>(b.data?.code===200&&a(b.data.data),e.routesConfig),[b.data]),h=p.useMemo(()=>b.data?.code===200?i():[],[b.data]),[E,F]=p.useState(""),[I,O]=p.useState(e.menuStyle),[W,U]=p.useState(e.initPane),[Y,J]=p.useState("home"),[V,M]=p.useState([]),Q=p.useMemo(()=>h.map(P=>({label:P.label,key:P.key})),[h]),ae=p.useMemo(()=>h.length?h.find(H=>H?.key===E)?.children||[]:[],[E,h]),oe=P=>M(H=>[...H,P]),K=p.useMemo(()=>{if(b.data?.code===200){const P=Array.isArray(b.data.data)?b.data.data:[];return e.flattenRoutesFormat([...P,...Ht,...V])}return[]},[b.data,V]);return o({1:s,2:b,userReq:s,menuReq:b,Routes:g,menus:h,user:l,activeTopLabel:E,setActiveTopLabel:F,dynamicFlatternRouteScale:oe,layoutStyle:I,setLayoutStyle:O,topRootMenus:Q,activeLeftMenuChildren:ae,flattenRoutes:K,panes:W,setPanes:U,resetTabs:()=>{F("home"),J("home"),U(e.initPane)},activeKey:Y,setActiveKey:J,closeTab:()=>{const P=W;if(P?.length>=2){const H=P.findIndex($=>$.key===Y),ie=P.filter($=>$.key!==Y);U(ie),J(ie[Math.max(0,H-1)]?.key??"home")}},recoverConfig:n})}),d=()=>{};return{StoreProvider:or,useSystemStore:c,getSystemStore:v,useLazilyStore:c,getLazilyStore:v,useAppDispatch:d,useAppSelector:d,injectReducer:d,removeReducer:d,registerPersistSlice:d,unregisterPersistSlice:d}}N.HoxRoot=or,N.LazilyKey=kr,N.createGlobalStore=ir,N.createSgTemplateSystemStore=Jt,N.createStore=nt,N.useLazily=ur,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
15
+ //# sourceMappingURL=core-store.umd.cjs.map