@apia/api 0.0.7 → 0.1.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/README.md +1 -1
- package/cleanDist.json +3 -0
- package/dist/index.d.ts +84 -68
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1557 -4
- package/dist/index.js.map +1 -1
- package/package.json +25 -16
package/dist/index.js
CHANGED
|
@@ -1,4 +1,1557 @@
|
|
|
1
|
-
"use strict";var ln=Object.create;var ge=Object.defineProperty,fn=Object.defineProperties,un=Object.getOwnPropertyDescriptor,cn=Object.getOwnPropertyDescriptors,pn=Object.getOwnPropertyNames,xe=Object.getOwnPropertySymbols,yn=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var Tt=(t,e,r)=>e in t?ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,S=(t,e)=>{for(var r in e||(e={}))We.call(e,r)&&Tt(t,r,e[r]);if(xe)for(var r of xe(e))bt.call(e,r)&&Tt(t,r,e[r]);return t},D=(t,e)=>fn(t,cn(e));var me=(t,e)=>{var r={};for(var n in t)We.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&xe)for(var n of xe(t))e.indexOf(n)<0&&bt.call(t,n)&&(r[n]=t[n]);return r};var R=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),dn=(t,e)=>{for(var r in e)ge(t,r,{get:e[r],enumerable:!0})},xt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of pn(e))!We.call(t,a)&&a!==r&&ge(t,a,{get:()=>e[a],enumerable:!(n=un(e,a))||n.enumerable});return t};var ve=(t,e,r)=>(r=t!=null?ln(yn(t)):{},xt(e||!t||!t.__esModule?ge(r,"default",{value:t,enumerable:!0}):r,t)),gn=t=>xt(ge({},"__esModule",{value:!0}),t);var N=(t,e,r)=>new Promise((n,a)=>{var o=l=>{try{i(r.next(l))}catch(f){a(f)}},s=l=>{try{i(r.throw(l))}catch(f){a(f)}},i=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,s);i((r=r.apply(t,e)).next())});var Et=R((Oa,Rt)=>{"use strict";Rt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var a=42;e[r]=a;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(e,r);if(s.value!==a||s.enumerable!==!0)return!1}return!0}});var Ct=R((Pa,Pt)=>{"use strict";var Ot=typeof Symbol!="undefined"&&Symbol,mn=Et();Pt.exports=function(){return typeof Ot!="function"||typeof Symbol!="function"||typeof Ot("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:mn()}});var It=R((Ca,Mt)=>{"use strict";var vn="Function.prototype.bind called on incompatible ",_e=Array.prototype.slice,hn=Object.prototype.toString,An="[object Function]";Mt.exports=function(e){var r=this;if(typeof r!="function"||hn.call(r)!==An)throw new TypeError(vn+r);for(var n=_e.call(arguments,1),a,o=function(){if(this instanceof a){var c=r.apply(this,n.concat(_e.call(arguments)));return Object(c)===c?c:this}else return r.apply(e,n.concat(_e.call(arguments)))},s=Math.max(0,r.length-n.length),i=[],l=0;l<s;l++)i.push("$"+l);if(a=Function("binder","return function ("+i.join(",")+"){ return binder.apply(this,arguments); }")(o),r.prototype){var f=function(){};f.prototype=r.prototype,a.prototype=new f,f.prototype=null}return a}});var Re=R((Ma,Dt)=>{"use strict";var Sn=It();Dt.exports=Function.prototype.bind||Sn});var kt=R((Ia,Lt)=>{"use strict";var wn=Re();Lt.exports=wn.call(Function.call,Object.prototype.hasOwnProperty)});var Pe=R((Da,Ut)=>{"use strict";var m,se=SyntaxError,qt=Function,ie=TypeError,Ge=function(t){try{return qt('"use strict"; return ('+t+").constructor;")()}catch(e){}},Y=Object.getOwnPropertyDescriptor;if(Y)try{Y({},"")}catch(t){Y=null}var ze=function(){throw new ie},Tn=Y?function(){try{return arguments.callee,ze}catch(t){try{return Y(arguments,"callee").get}catch(e){return ze}}}():ze,oe=Ct()(),q=Object.getPrototypeOf||function(t){return t.__proto__},ae={},bn=typeof Uint8Array=="undefined"?m:q(Uint8Array),Z={"%AggregateError%":typeof AggregateError=="undefined"?m:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?m:ArrayBuffer,"%ArrayIteratorPrototype%":oe?q([][Symbol.iterator]()):m,"%AsyncFromSyncIteratorPrototype%":m,"%AsyncFunction%":ae,"%AsyncGenerator%":ae,"%AsyncGeneratorFunction%":ae,"%AsyncIteratorPrototype%":ae,"%Atomics%":typeof Atomics=="undefined"?m:Atomics,"%BigInt%":typeof BigInt=="undefined"?m:BigInt,"%BigInt64Array%":typeof BigInt64Array=="undefined"?m:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array=="undefined"?m:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?m:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?m:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?m:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?m:FinalizationRegistry,"%Function%":qt,"%GeneratorFunction%":ae,"%Int8Array%":typeof Int8Array=="undefined"?m:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?m:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?m:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":oe?q(q([][Symbol.iterator]())):m,"%JSON%":typeof JSON=="object"?JSON:m,"%Map%":typeof Map=="undefined"?m:Map,"%MapIteratorPrototype%":typeof Map=="undefined"||!oe?m:q(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?m:Promise,"%Proxy%":typeof Proxy=="undefined"?m:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?m:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?m:Set,"%SetIteratorPrototype%":typeof Set=="undefined"||!oe?m:q(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?m:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":oe?q(""[Symbol.iterator]()):m,"%Symbol%":oe?Symbol:m,"%SyntaxError%":se,"%ThrowTypeError%":Tn,"%TypedArray%":bn,"%TypeError%":ie,"%Uint8Array%":typeof Uint8Array=="undefined"?m:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?m:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?m:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?m:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?m:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?m:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?m:WeakSet};try{null.error}catch(t){Ft=q(q(t)),Z["%Error.prototype%"]=Ft}var Ft,xn=function t(e){var r;if(e==="%AsyncFunction%")r=Ge("async function () {}");else if(e==="%GeneratorFunction%")r=Ge("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Ge("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var a=t("%AsyncGenerator%");a&&(r=q(a.prototype))}return Z[e]=r,r},$t={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},he=Re(),Ee=kt(),Rn=he.call(Function.call,Array.prototype.concat),En=he.call(Function.apply,Array.prototype.splice),Nt=he.call(Function.call,String.prototype.replace),Oe=he.call(Function.call,String.prototype.slice),On=he.call(Function.call,RegExp.prototype.exec),Pn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Cn=/\\(\\)?/g,Mn=function(e){var r=Oe(e,0,1),n=Oe(e,-1);if(r==="%"&&n!=="%")throw new se("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new se("invalid intrinsic syntax, expected opening `%`");var a=[];return Nt(e,Pn,function(o,s,i,l){a[a.length]=i?Nt(l,Cn,"$1"):s||o}),a},In=function(e,r){var n=e,a;if(Ee($t,n)&&(a=$t[n],n="%"+a[0]+"%"),Ee(Z,n)){var o=Z[n];if(o===ae&&(o=xn(n)),typeof o=="undefined"&&!r)throw new ie("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:a,name:n,value:o}}throw new se("intrinsic "+e+" does not exist!")};Ut.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new ie("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new ie('"allowMissing" argument must be a boolean');if(On(/^%?[^%]*%?$/,e)===null)throw new se("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Mn(e),a=n.length>0?n[0]:"",o=In("%"+a+"%",r),s=o.name,i=o.value,l=!1,f=o.alias;f&&(a=f[0],En(n,Rn([0,1],f)));for(var c=1,g=!0;c<n.length;c+=1){var p=n[c],y=Oe(p,0,1),d=Oe(p,-1);if((y==='"'||y==="'"||y==="`"||d==='"'||d==="'"||d==="`")&&y!==d)throw new se("property names with quotes must have matching quotes");if((p==="constructor"||!g)&&(l=!0),a+="."+p,s="%"+a+"%",Ee(Z,s))i=Z[s];else if(i!=null){if(!(p in i)){if(!r)throw new ie("base intrinsic for "+e+" exists, but the property is not available.");return}if(Y&&c+1>=n.length){var h=Y(i,p);g=!!h,g&&"get"in h&&!("originalValue"in h.get)?i=h.get:i=i[p]}else g=Ee(i,p),i=i[p];g&&!l&&(Z[s]=i)}}return i}});var zt=R((La,Ce)=>{"use strict";var Ve=Re(),le=Pe(),Wt=le("%Function.prototype.apply%"),_t=le("%Function.prototype.call%"),Gt=le("%Reflect.apply%",!0)||Ve.call(_t,Wt),Bt=le("%Object.getOwnPropertyDescriptor%",!0),ee=le("%Object.defineProperty%",!0),Dn=le("%Math.max%");if(ee)try{ee({},"a",{value:1})}catch(t){ee=null}Ce.exports=function(e){var r=Gt(Ve,_t,arguments);if(Bt&&ee){var n=Bt(r,"length");n.configurable&&ee(r,"length",{value:1+Dn(0,e.length-(arguments.length-1))})}return r};var Ht=function(){return Gt(Ve,Wt,arguments)};ee?ee(Ce.exports,"apply",{value:Ht}):Ce.exports.apply=Ht});var Xt=R((ka,Jt)=>{"use strict";var Vt=Pe(),Qt=zt(),Ln=Qt(Vt("String.prototype.indexOf"));Jt.exports=function(e,r){var n=Vt(e,!!r);return typeof n=="function"&&Ln(e,".prototype.")>-1?Qt(n):n}});var jt=R((Fa,Kt)=>{Kt.exports=require("util").inspect});var vr=R(($a,mr)=>{var rt=typeof Map=="function"&&Map.prototype,Qe=Object.getOwnPropertyDescriptor&&rt?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ie=rt&&Qe&&typeof Qe.get=="function"?Qe.get:null,Yt=rt&&Map.prototype.forEach,nt=typeof Set=="function"&&Set.prototype,Je=Object.getOwnPropertyDescriptor&&nt?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,De=nt&&Je&&typeof Je.get=="function"?Je.get:null,Zt=nt&&Set.prototype.forEach,kn=typeof WeakMap=="function"&&WeakMap.prototype,Se=kn?WeakMap.prototype.has:null,Fn=typeof WeakSet=="function"&&WeakSet.prototype,we=Fn?WeakSet.prototype.has:null,$n=typeof WeakRef=="function"&&WeakRef.prototype,er=$n?WeakRef.prototype.deref:null,Nn=Boolean.prototype.valueOf,qn=Object.prototype.toString,Un=Function.prototype.toString,Bn=String.prototype.match,ot=String.prototype.slice,J=String.prototype.replace,Hn=String.prototype.toUpperCase,tr=String.prototype.toLowerCase,ur=RegExp.prototype.test,rr=Array.prototype.concat,U=Array.prototype.join,Wn=Array.prototype.slice,nr=Math.floor,je=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Xe=Object.getOwnPropertySymbols,Ye=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,fe=typeof Symbol=="function"&&typeof Symbol.iterator=="object",M=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===fe||"symbol")?Symbol.toStringTag:null,cr=Object.prototype.propertyIsEnumerable,or=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function ar(t,e){if(t===1/0||t===-1/0||t!==t||t&&t>-1e3&&t<1e3||ur.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof t=="number"){var n=t<0?-nr(-t):nr(t);if(n!==t){var a=String(n),o=ot.call(e,a.length+1);return J.call(a,r,"$&_")+"."+J.call(J.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return J.call(e,r,"$&_")}var Ze=jt(),ir=Ze.custom,sr=yr(ir)?ir:null;mr.exports=function t(e,r,n,a){var o=r||{};if(Q(o,"quoteStyle")&&o.quoteStyle!=="single"&&o.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Q(o,"maxStringLength")&&(typeof o.maxStringLength=="number"?o.maxStringLength<0&&o.maxStringLength!==1/0:o.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var s=Q(o,"customInspect")?o.customInspect:!0;if(typeof s!="boolean"&&s!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Q(o,"indent")&&o.indent!==null&&o.indent!==" "&&!(parseInt(o.indent,10)===o.indent&&o.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Q(o,"numericSeparator")&&typeof o.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var i=o.numericSeparator;if(typeof e=="undefined")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return gr(e,o);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return i?ar(e,l):l}if(typeof e=="bigint"){var f=String(e)+"n";return i?ar(e,f):f}var c=typeof o.depth=="undefined"?5:o.depth;if(typeof n=="undefined"&&(n=0),n>=c&&c>0&&typeof e=="object")return et(e)?"[Array]":"[Object]";var g=io(o,n);if(typeof a=="undefined")a=[];else if(dr(a,e)>=0)return"[Circular]";function p($,V,_){if(V&&(a=Wn.call(a),a.push(V)),_){var de={depth:o.depth};return Q(o,"quoteStyle")&&(de.quoteStyle=o.quoteStyle),t($,de,n+1,a)}return t($,o,n+1,a)}if(typeof e=="function"&&!lr(e)){var y=jn(e),d=Me(e,p);return"[Function"+(y?": "+y:" (anonymous)")+"]"+(d.length>0?" { "+U.call(d,", ")+" }":"")}if(yr(e)){var h=fe?J.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ye.call(e);return typeof e=="object"&&!fe?Ae(h):h}if(no(e)){for(var T="<"+tr.call(String(e.nodeName)),u=e.attributes||[],v=0;v<u.length;v++)T+=" "+u[v].name+"="+pr(_n(u[v].value),"double",o);return T+=">",e.childNodes&&e.childNodes.length&&(T+="..."),T+="</"+tr.call(String(e.nodeName))+">",T}if(et(e)){if(e.length===0)return"[]";var b=Me(e,p);return g&&!ao(b)?"["+tt(b,g)+"]":"[ "+U.call(b,", ")+" ]"}if(zn(e)){var A=Me(e,p);return!("cause"in Error.prototype)&&"cause"in e&&!cr.call(e,"cause")?"{ ["+String(e)+"] "+U.call(rr.call("[cause]: "+p(e.cause),A),", ")+" }":A.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+U.call(A,", ")+" }"}if(typeof e=="object"&&s){if(sr&&typeof e[sr]=="function"&&Ze)return Ze(e,{depth:c-n});if(s!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(Yn(e)){var P=[];return Yt&&Yt.call(e,function($,V){P.push(p(V,e,!0)+" => "+p($,e))}),fr("Map",Ie.call(e),P,g)}if(to(e)){var C=[];return Zt&&Zt.call(e,function($){C.push(p($,e))}),fr("Set",De.call(e),C,g)}if(Zn(e))return Ke("WeakMap");if(ro(e))return Ke("WeakSet");if(eo(e))return Ke("WeakRef");if(Qn(e))return Ae(p(Number(e)));if(Xn(e))return Ae(p(je.call(e)));if(Jn(e))return Ae(Nn.call(e));if(Vn(e))return Ae(p(String(e)));if(!Gn(e)&&!lr(e)){var I=Me(e,p),F=or?or(e)===Object.prototype:e instanceof Object||e.constructor===Object,L=e instanceof Object?"":"null prototype",W=!F&&M&&Object(e)===e&&M in e?ot.call(X(e),8,-1):L?"Object":"",j=F||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",ne=j+(W||L?"["+U.call(rr.call([],W||[],L||[]),": ")+"] ":"");return I.length===0?ne+"{}":g?ne+"{"+tt(I,g)+"}":ne+"{ "+U.call(I,", ")+" }"}return String(e)};function pr(t,e,r){var n=(r.quoteStyle||e)==="double"?'"':"'";return n+t+n}function _n(t){return J.call(String(t),/"/g,""")}function et(t){return X(t)==="[object Array]"&&(!M||!(typeof t=="object"&&M in t))}function Gn(t){return X(t)==="[object Date]"&&(!M||!(typeof t=="object"&&M in t))}function lr(t){return X(t)==="[object RegExp]"&&(!M||!(typeof t=="object"&&M in t))}function zn(t){return X(t)==="[object Error]"&&(!M||!(typeof t=="object"&&M in t))}function Vn(t){return X(t)==="[object String]"&&(!M||!(typeof t=="object"&&M in t))}function Qn(t){return X(t)==="[object Number]"&&(!M||!(typeof t=="object"&&M in t))}function Jn(t){return X(t)==="[object Boolean]"&&(!M||!(typeof t=="object"&&M in t))}function yr(t){if(fe)return t&&typeof t=="object"&&t instanceof Symbol;if(typeof t=="symbol")return!0;if(!t||typeof t!="object"||!Ye)return!1;try{return Ye.call(t),!0}catch(e){}return!1}function Xn(t){if(!t||typeof t!="object"||!je)return!1;try{return je.call(t),!0}catch(e){}return!1}var Kn=Object.prototype.hasOwnProperty||function(t){return t in this};function Q(t,e){return Kn.call(t,e)}function X(t){return qn.call(t)}function jn(t){if(t.name)return t.name;var e=Bn.call(Un.call(t),/^function\s*([\w$]+)/);return e?e[1]:null}function dr(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}function Yn(t){if(!Ie||!t||typeof t!="object")return!1;try{Ie.call(t);try{De.call(t)}catch(e){return!0}return t instanceof Map}catch(e){}return!1}function Zn(t){if(!Se||!t||typeof t!="object")return!1;try{Se.call(t,Se);try{we.call(t,we)}catch(e){return!0}return t instanceof WeakMap}catch(e){}return!1}function eo(t){if(!er||!t||typeof t!="object")return!1;try{return er.call(t),!0}catch(e){}return!1}function to(t){if(!De||!t||typeof t!="object")return!1;try{De.call(t);try{Ie.call(t)}catch(e){return!0}return t instanceof Set}catch(e){}return!1}function ro(t){if(!we||!t||typeof t!="object")return!1;try{we.call(t,we);try{Se.call(t,Se)}catch(e){return!0}return t instanceof WeakSet}catch(e){}return!1}function no(t){return!t||typeof t!="object"?!1:typeof HTMLElement!="undefined"&&t instanceof HTMLElement?!0:typeof t.nodeName=="string"&&typeof t.getAttribute=="function"}function gr(t,e){if(t.length>e.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return gr(ot.call(t,0,e.maxStringLength),e)+n}var a=J.call(J.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,oo);return pr(a,"single",e)}function oo(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+Hn.call(e.toString(16))}function Ae(t){return"Object("+t+")"}function Ke(t){return t+" { ? }"}function fr(t,e,r,n){var a=n?tt(r,n):U.call(r,", ");return t+" ("+e+") {"+a+"}"}function ao(t){for(var e=0;e<t.length;e++)if(dr(t[e],`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`+e.prev}function Me(t,e){var r=et(t),n=[];if(r){n.length=t.length;for(var a=0;a<t.length;a++)n[a]=Q(t,a)?e(t[a],t):""}var o=typeof Xe=="function"?Xe(t):[],s;if(fe){s={};for(var i=0;i<o.length;i++)s["$"+o[i]]=o[i]}for(var l in t)Q(t,l)&&(r&&String(Number(l))===l&&l<t.length||fe&&s["$"+l]instanceof Symbol||(ur.call(/[^\w$]/,l)?n.push(e(l,t)+": "+e(t[l],t)):n.push(l+": "+e(t[l],t))));if(typeof Xe=="function")for(var f=0;f<o.length;f++)cr.call(t,o[f])&&n.push("["+e(o[f])+"]: "+e(t[o[f]],t));return n}});var Ar=R((Na,hr)=>{"use strict";var at=Pe(),ue=Xt(),so=vr(),lo=at("%TypeError%"),Le=at("%WeakMap%",!0),ke=at("%Map%",!0),fo=ue("WeakMap.prototype.get",!0),uo=ue("WeakMap.prototype.set",!0),co=ue("WeakMap.prototype.has",!0),po=ue("Map.prototype.get",!0),yo=ue("Map.prototype.set",!0),go=ue("Map.prototype.has",!0),it=function(t,e){for(var r=t,n;(n=r.next)!==null;r=n)if(n.key===e)return r.next=n.next,n.next=t.next,t.next=n,n},mo=function(t,e){var r=it(t,e);return r&&r.value},vo=function(t,e,r){var n=it(t,e);n?n.value=r:t.next={key:e,next:t.next,value:r}},ho=function(t,e){return!!it(t,e)};hr.exports=function(){var e,r,n,a={assert:function(o){if(!a.has(o))throw new lo("Side channel does not contain "+so(o))},get:function(o){if(Le&&o&&(typeof o=="object"||typeof o=="function")){if(e)return fo(e,o)}else if(ke){if(r)return po(r,o)}else if(n)return mo(n,o)},has:function(o){if(Le&&o&&(typeof o=="object"||typeof o=="function")){if(e)return co(e,o)}else if(ke){if(r)return go(r,o)}else if(n)return ho(n,o);return!1},set:function(o,s){Le&&o&&(typeof o=="object"||typeof o=="function")?(e||(e=new Le),uo(e,o,s)):ke?(r||(r=new ke),yo(r,o,s)):(n||(n={key:{},next:null}),vo(n,o,s))}};return a}});var Fe=R((qa,Sr)=>{"use strict";var Ao=String.prototype.replace,So=/%20/g,st={RFC1738:"RFC1738",RFC3986:"RFC3986"};Sr.exports={default:st.RFC3986,formatters:{RFC1738:function(t){return Ao.call(t,So,"+")},RFC3986:function(t){return String(t)}},RFC1738:st.RFC1738,RFC3986:st.RFC3986}});var ft=R((Ua,Tr)=>{"use strict";var wo=Fe(),lt=Object.prototype.hasOwnProperty,te=Array.isArray,B=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),To=function(e){for(;e.length>1;){var r=e.pop(),n=r.obj[r.prop];if(te(n)){for(var a=[],o=0;o<n.length;++o)typeof n[o]!="undefined"&&a.push(n[o]);r.obj[r.prop]=a}}},wr=function(e,r){for(var n=r&&r.plainObjects?Object.create(null):{},a=0;a<e.length;++a)typeof e[a]!="undefined"&&(n[a]=e[a]);return n},bo=function t(e,r,n){if(!r)return e;if(typeof r!="object"){if(te(e))e.push(r);else if(e&&typeof e=="object")(n&&(n.plainObjects||n.allowPrototypes)||!lt.call(Object.prototype,r))&&(e[r]=!0);else return[e,r];return e}if(!e||typeof e!="object")return[e].concat(r);var a=e;return te(e)&&!te(r)&&(a=wr(e,n)),te(e)&&te(r)?(r.forEach(function(o,s){if(lt.call(e,s)){var i=e[s];i&&typeof i=="object"&&o&&typeof o=="object"?e[s]=t(i,o,n):e.push(o)}else e[s]=o}),e):Object.keys(r).reduce(function(o,s){var i=r[s];return lt.call(o,s)?o[s]=t(o[s],i,n):o[s]=i,o},a)},xo=function(e,r){return Object.keys(r).reduce(function(n,a){return n[a]=r[a],n},e)},Ro=function(t,e,r){var n=t.replace(/\+/g," ");if(r==="iso-8859-1")return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(a){return n}},Eo=function(e,r,n,a,o){if(e.length===0)return e;var s=e;if(typeof e=="symbol"?s=Symbol.prototype.toString.call(e):typeof e!="string"&&(s=String(e)),n==="iso-8859-1")return escape(s).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});for(var i="",l=0;l<s.length;++l){var f=s.charCodeAt(l);if(f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||o===wo.RFC1738&&(f===40||f===41)){i+=s.charAt(l);continue}if(f<128){i=i+B[f];continue}if(f<2048){i=i+(B[192|f>>6]+B[128|f&63]);continue}if(f<55296||f>=57344){i=i+(B[224|f>>12]+B[128|f>>6&63]+B[128|f&63]);continue}l+=1,f=65536+((f&1023)<<10|s.charCodeAt(l)&1023),i+=B[240|f>>18]+B[128|f>>12&63]+B[128|f>>6&63]+B[128|f&63]}return i},Oo=function(e){for(var r=[{obj:{o:e},prop:"o"}],n=[],a=0;a<r.length;++a)for(var o=r[a],s=o.obj[o.prop],i=Object.keys(s),l=0;l<i.length;++l){var f=i[l],c=s[f];typeof c=="object"&&c!==null&&n.indexOf(c)===-1&&(r.push({obj:s,prop:f}),n.push(c))}return To(r),e},Po=function(e){return Object.prototype.toString.call(e)==="[object RegExp]"},Co=function(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},Mo=function(e,r){return[].concat(e,r)},Io=function(e,r){if(te(e)){for(var n=[],a=0;a<e.length;a+=1)n.push(r(e[a]));return n}return r(e)};Tr.exports={arrayToObject:wr,assign:xo,combine:Mo,compact:Oo,decode:Ro,encode:Eo,isBuffer:Co,isRegExp:Po,maybeMap:Io,merge:bo}});var Pr=R((Ba,Or)=>{"use strict";var Rr=Ar(),ct=ft(),Te=Fe(),Do=Object.prototype.hasOwnProperty,br={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,r){return e+"["+r+"]"},repeat:function(e){return e}},G=Array.isArray,Lo=String.prototype.split,ko=Array.prototype.push,Er=function(t,e){ko.apply(t,G(e)?e:[e])},Fo=Date.prototype.toISOString,xr=Te.default,E={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:ct.encode,encodeValuesOnly:!1,format:xr,formatter:Te.formatters[xr],indices:!1,serializeDate:function(e){return Fo.call(e)},skipNulls:!1,strictNullHandling:!1},$o=function(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"},ut={},No=function t(e,r,n,a,o,s,i,l,f,c,g,p,y,d,h,T){for(var u=e,v=T,b=0,A=!1;(v=v.get(ut))!==void 0&&!A;){var P=v.get(e);if(b+=1,typeof P!="undefined"){if(P===b)throw new RangeError("Cyclic object value");A=!0}typeof v.get(ut)=="undefined"&&(b=0)}if(typeof l=="function"?u=l(r,u):u instanceof Date?u=g(u):n==="comma"&&G(u)&&(u=ct.maybeMap(u,function(He){return He instanceof Date?g(He):He})),u===null){if(o)return i&&!d?i(r,E.encoder,h,"key",p):r;u=""}if($o(u)||ct.isBuffer(u)){if(i){var C=d?r:i(r,E.encoder,h,"key",p);if(n==="comma"&&d){for(var I=Lo.call(String(u),","),F="",L=0;L<I.length;++L)F+=(L===0?"":",")+y(i(I[L],E.encoder,h,"value",p));return[y(C)+(a&&G(u)&&I.length===1?"[]":"")+"="+F]}return[y(C)+"="+y(i(u,E.encoder,h,"value",p))]}return[y(r)+"="+y(String(u))]}var W=[];if(typeof u=="undefined")return W;var j;if(n==="comma"&&G(u))j=[{value:u.length>0?u.join(",")||null:void 0}];else if(G(l))j=l;else{var ne=Object.keys(u);j=f?ne.sort(f):ne}for(var $=a&&G(u)&&u.length===1?r+"[]":r,V=0;V<j.length;++V){var _=j[V],de=typeof _=="object"&&typeof _.value!="undefined"?_.value:u[_];if(!(s&&de===null)){var sn=G(u)?typeof n=="function"?n($,_):$:$+(c?"."+_:"["+_+"]");T.set(e,b);var wt=Rr();wt.set(ut,T),Er(W,t(de,sn,n,a,o,s,i,l,f,c,g,p,y,d,h,wt))}}return W},qo=function(e){if(!e)return E;if(e.encoder!==null&&typeof e.encoder!="undefined"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");var r=e.charset||E.charset;if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=Te.default;if(typeof e.format!="undefined"){if(!Do.call(Te.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var a=Te.formatters[n],o=E.filter;return(typeof e.filter=="function"||G(e.filter))&&(o=e.filter),{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:E.addQueryPrefix,allowDots:typeof e.allowDots=="undefined"?E.allowDots:!!e.allowDots,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:E.charsetSentinel,delimiter:typeof e.delimiter=="undefined"?E.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:E.encode,encoder:typeof e.encoder=="function"?e.encoder:E.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:E.encodeValuesOnly,filter:o,format:n,formatter:a,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:E.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:E.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:E.strictNullHandling}};Or.exports=function(t,e){var r=t,n=qo(e),a,o;typeof n.filter=="function"?(o=n.filter,r=o("",r)):G(n.filter)&&(o=n.filter,a=o);var s=[];if(typeof r!="object"||r===null)return"";var i;e&&e.arrayFormat in br?i=e.arrayFormat:e&&"indices"in e?i=e.indices?"indices":"repeat":i="indices";var l=br[i];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var f=l==="comma"&&e&&e.commaRoundTrip;a||(a=Object.keys(r)),n.sort&&a.sort(n.sort);for(var c=Rr(),g=0;g<a.length;++g){var p=a[g];n.skipNulls&&r[p]===null||Er(s,No(r[p],p,l,f,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,c))}var y=s.join(n.delimiter),d=n.addQueryPrefix===!0?"?":"";return n.charsetSentinel&&(n.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),y.length>0?d+y:""}});var Ir=R((Ha,Mr)=>{"use strict";var ce=ft(),pt=Object.prototype.hasOwnProperty,Uo=Array.isArray,x={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:ce.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Bo=function(t){return t.replace(/&#(\d+);/g,function(e,r){return String.fromCharCode(parseInt(r,10))})},Cr=function(t,e){return t&&typeof t=="string"&&e.comma&&t.indexOf(",")>-1?t.split(","):t},Ho="utf8=%26%2310003%3B",Wo="utf8=%E2%9C%93",_o=function(e,r){var n={},a=r.ignoreQueryPrefix?e.replace(/^\?/,""):e,o=r.parameterLimit===1/0?void 0:r.parameterLimit,s=a.split(r.delimiter,o),i=-1,l,f=r.charset;if(r.charsetSentinel)for(l=0;l<s.length;++l)s[l].indexOf("utf8=")===0&&(s[l]===Wo?f="utf-8":s[l]===Ho&&(f="iso-8859-1"),i=l,l=s.length);for(l=0;l<s.length;++l)if(l!==i){var c=s[l],g=c.indexOf("]="),p=g===-1?c.indexOf("="):g+1,y,d;p===-1?(y=r.decoder(c,x.decoder,f,"key"),d=r.strictNullHandling?null:""):(y=r.decoder(c.slice(0,p),x.decoder,f,"key"),d=ce.maybeMap(Cr(c.slice(p+1),r),function(h){return r.decoder(h,x.decoder,f,"value")})),d&&r.interpretNumericEntities&&f==="iso-8859-1"&&(d=Bo(d)),c.indexOf("[]=")>-1&&(d=Uo(d)?[d]:d),pt.call(n,y)?n[y]=ce.combine(n[y],d):n[y]=d}return n},Go=function(t,e,r,n){for(var a=n?e:Cr(e,r),o=t.length-1;o>=0;--o){var s,i=t[o];if(i==="[]"&&r.parseArrays)s=[].concat(a);else{s=r.plainObjects?Object.create(null):{};var l=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,f=parseInt(l,10);!r.parseArrays&&l===""?s={0:a}:!isNaN(f)&&i!==l&&String(f)===l&&f>=0&&r.parseArrays&&f<=r.arrayLimit?(s=[],s[f]=a):l!=="__proto__"&&(s[l]=a)}a=s}return a},zo=function(e,r,n,a){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/,i=/(\[[^[\]]*])/g,l=n.depth>0&&s.exec(o),f=l?o.slice(0,l.index):o,c=[];if(f){if(!n.plainObjects&&pt.call(Object.prototype,f)&&!n.allowPrototypes)return;c.push(f)}for(var g=0;n.depth>0&&(l=i.exec(o))!==null&&g<n.depth;){if(g+=1,!n.plainObjects&&pt.call(Object.prototype,l[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(l[1])}return l&&c.push("["+o.slice(l.index)+"]"),Go(c,r,n,a)}},Vo=function(e){if(!e)return x;if(e.decoder!==null&&e.decoder!==void 0&&typeof e.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=typeof e.charset=="undefined"?x.charset:e.charset;return{allowDots:typeof e.allowDots=="undefined"?x.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:x.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:x.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:x.arrayLimit,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:x.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:x.comma,decoder:typeof e.decoder=="function"?e.decoder:x.decoder,delimiter:typeof e.delimiter=="string"||ce.isRegExp(e.delimiter)?e.delimiter:x.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:x.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:x.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:x.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:x.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:x.strictNullHandling}};Mr.exports=function(t,e){var r=Vo(e);if(t===""||t===null||typeof t=="undefined")return r.plainObjects?Object.create(null):{};for(var n=typeof t=="string"?_o(t,r):t,a=r.plainObjects?Object.create(null):{},o=Object.keys(n),s=0;s<o.length;++s){var i=o[s],l=zo(i,n[i],r,typeof t=="string");a=ce.merge(a,l,r)}return r.allowSparse===!0?a:ce.compact(a)}});var Lr=R((Wa,Dr)=>{"use strict";var Qo=Pr(),Jo=Ir(),Xo=Fe();Dr.exports={formats:Xo,parse:Jo,stringify:Qo}});var Ur=R((_a,qr)=>{"use strict";var yt=Object.defineProperty,Ko=Object.getOwnPropertyDescriptor,jo=Object.getOwnPropertyNames,Yo=Object.prototype.hasOwnProperty,Zo=(t,e)=>{for(var r in e)yt(t,r,{get:e[r],enumerable:!0})},ea=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of jo(e))!Yo.call(t,a)&&a!==r&&yt(t,a,{get:()=>e[a],enumerable:!(n=Ko(e,a))||n.enumerable});return t},ta=t=>ea(yt({},"__esModule",{value:!0}),t),Fr=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},ra=(t,e,r)=>(Fr(t,e,"read from private field"),r?r.call(t):e.get(t)),na=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},oa=(t,e,r,n)=>(Fr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),$r={};Zo($r,{SessionStatus:()=>Nr,session:()=>ia});qr.exports=ta($r);var aa=require("@apia/util"),Nr=(t=>(t[t.Alive=0]="Alive",t[t.Dead=1]="Dead",t))(Nr||{}),$e,kr,ia=new(kr=class extends aa.EventEmitter{constructor(){super(...arguments),na(this,$e,!0)}get isAlive(){return ra(this,$e)}invalidate(){oa(this,$e,!1),this.emit("change",1)}},$e=new WeakMap,kr)});var Ra={};dn(Ra,{ApiaApi:()=>an,makeApiaUrl:()=>Be});module.exports=gn(Ra);var St=ve(require("axios")),Yr=require("lodash-es"),Ue=ve(Lr()),Zr=ve(Ur()),H=require("@apia/util"),K=require("@apia/notifications");var w=ve(require("react")),Vr=require("theme-ui"),O=require("@apia/util"),gt=require("@apia/notifications"),Qr=require("@apia/validations"),pe=require("@apia/components"),Jr=require("@apia/theme");var Br=require("react"),Hr=ve(require("react")),_r=require("theme-ui/jsx-runtime"),sa;var la=(0,Br.createContext)("apiaApi"),fa=({children:t,id:e})=>(sa=e,(0,_r.jsx)(la.Provider,{value:e,children:t})),Wr=Hr.memo(fa);var k=require("theme-ui/jsx-runtime"),mt=new class extends O.EventEmitter{},vt=new class extends O.EventEmitter{},dt="ApiaApiForm",Gr={};function zr(t,e){return N(this,null,function*(){return new Promise(r=>{var n,a,o;try{let s=/^\/?([\w\d_-]+)\/?(?:\(([^)]*)\))?$/,i=t.match(s);if(i){let l=i[1],f=i[2],c=[...(o=(a=(n=e.configuration)==null?void 0:n.methodsPath)==null?void 0:a.split("/").filter(y=>!!y))!=null?o:[],l].join("/"),g=y=>{typeof y.default!="function"&&p();let d=y.default;Gr[l]=h=>{var T;return d(e,D(S({},h),{inlineArguments:(T=f==null?void 0:f.split(",").map(u=>u.startsWith("'")||u.startsWith('"')?u.slice(1,u.length-1):u))!=null?T:[]}))},r(Gr[l])},p=()=>{throw new Error(`${l}.ts not found at ${c}.ts nor ./${l}.ts`)};import(`/api/methods/${c}.ts`).then(g).catch(()=>{var y;((y=e.configuration)==null?void 0:y.methodsPath)!==void 0?import(`/api/methods/${l}.ts`).then(g).catch(p):p()})}}catch(s){console.error(s),e.reset(),e.setError({type:"danger",message:"Error while loading current method."})}})})}function ua(t){return typeof t.canClose=="boolean"&&typeof t.type=="string"&&!!t.form}function ca(t){return typeof t.canClose=="boolean"&&typeof t.type=="string"&&!!t.function}function pa(t){return!!(typeof t.canClose=="boolean"&&typeof t.type=="string"&&typeof t.text=="object"&&t.text&&typeof t.text.label=="string")}var ht=new O.WithEventsValue;function ya(){let[,t,e]=(0,O.useStateRef)(void 0),r=w.useCallback(n=>{t(n)},[t]);return(0,O.useMount)(()=>{ht.on("update",r)}),(0,O.useUnmount)(()=>ht.off("update",r)),e}var da,At=new class extends O.EventEmitter{emit(e,r){super.emit(e,r),da=r}};function Xr(t,e,r){return ht.value=r,ua(t)?(At.emit("form",t),!0):ca(t)?(vt.emit("method",{name:t.function.name,props:{messages:t.function.messages,attributes:t.function,currentUrl:e}}),!0):pa(t)?(mt.emit("message",{predicate:t.text.label,title:t.text.title}),!0):!1}var Ne={disabled:!1,isLoading:!1,isMultipart:!1,progress:0,errors:{}},ga=()=>{var d,h,T;let t=ya(),[e,r]=w.useState(D(S({},Ne),{windowIndex:-1})),[n,a]=w.useState(void 0);w.useEffect(()=>At.on("form",a),[]);let o=w.useCallback((u,v)=>Qr.validationsStore.setFieldValue(dt,u,v),[]);w.useEffect(()=>{var P,C,I;if(!n)return;let u=(0,O.arrayOrArray)((I=(C=(P=n==null?void 0:n.form)==null?void 0:P.elements)==null?void 0:C.element)!=null?I:[]),v=!1,b=Object.values(u),A=0;for(;A<b.length&&!v;)b[A++].type==="file"&&(v=!0);r(F=>D(S(S({},F),Ne),{isMultipart:v}))},[n]);let y=(0,pe.useModal)(),{show:s,onClose:i}=y,l=me(y,["show","onClose"]),f=w.useCallback(()=>{var u,v;i(),At.emit("form",void 0),r(b=>S(S({},b),Ne)),(v=(u=t.current)==null?void 0:u.modalConfiguration)!=null&&v.onClose&&t.current.modalConfiguration.onClose()},[i,t]),c=w.useRef(null);w.useEffect(()=>{var v;let u=(v=c.current)==null?void 0:v.querySelectorAll("a,input,textarea,button");(u==null?void 0:u.length)===1&&pe.focus.on([...u][0])});let g=w.useCallback(u=>{(0,gt.notify)(S({},u))},[]),p=w.useCallback(()=>({alert,close:f,configuration:t.current,formDefinition:n,reset:()=>r(v=>S(S({},v),Ne)),setError:g,setMessage:v=>{var b,A;(A=(b=t.current)==null?void 0:b.modalConfiguration)!=null&&A.onMessage&&t.current.modalConfiguration.onMessage(v)},setState:r,state:e,setValue:o}),[f,t,n,g,e,o]);return w.useEffect(()=>{let u=F=>N(void 0,[F],function*({name:A,props:{messages:P,attributes:C,currentUrl:I}}){let L=yield zr(`${A}`,p());L&&L({messages:P,attributes:C,currentUrl:I})}),v=A=>{var I,F,L,W;let P=p();(0,gt.notify)({message:A.predicate,type:"warning",onClose:(F=(I=P.configuration)==null?void 0:I.modalConfiguration)==null?void 0:F.onMessageClose});let C=(W=(L=P.configuration)==null?void 0:L.modalConfiguration)==null?void 0:W.onMessage;C&&C(A)},b=A=>N(void 0,null,function*(){if(A.toDo==="ajaxHiddeAll"&&f(),A.toDo==="functionTimedCall"){let P=yield zr((0,O.arrayOrArray)(A.param)[1],p());P&&setTimeout(()=>{var C;return P({currentUrl:(C=n==null?void 0:n.form.action)!=null?C:"noUrl"})},Number(A.param[0]))}});return mt.on("message",v),vt.on("method",u),qe.on("action",b),()=>{mt.off("message",v),vt.off("method",u),qe.off("action",b)}},[e.windowIndex,i,f]),w.useEffect(()=>{n&&s()},[n]),(0,k.jsx)(Wr,{id:dt,children:(0,k.jsx)(pe.Modal,D(S({ref:c,onClose:f,id:dt,title:(T=(h=(d=t.current)==null?void 0:d.modalConfiguration)==null?void 0:h.modalTitle)!=null?T:n==null?void 0:n.form.title,size:"md-fixed",shouldCloseOnEsc:!e.disabled,shouldCloseOnOverlayClick:!e.disabled,initialFocusGetter:w.useCallback(u=>u==null?void 0:u.querySelector(O.focusSelector),[])},l),{children:n&&(0,k.jsxs)(Vr.Box,D(S({},(0,Jr.getVariant)("layout.common.modals.apiaApi")),{children:["NO EST\xC1 IMPLEMENTADA LA PROPIEDAD handleLoad. Falta pasar:",(0,k.jsxs)("ul",{children:[(0,k.jsx)("li",{children:"todos los componentes de validaci\xF3n (input, check, etc)"}),(0,k.jsxs)("li",{children:["M\xE9todos y componentes del apiaApiHandler (./fields, ./buttons, etc)"," ",(0,k.jsx)("strong",{children:"Ver que quiz\xE1s no es necesario pasar todos los m\xE9todos en este momento"}),", sino solamente aquellos que sean necesarios al momento de realizar alguna acci\xF3n particular."," ",(0,k.jsx)("strong",{children:"De hecho es un buen momento para hacer limpieza y refactoreo"})]})]}),"En cambio ",(0,k.jsx)("strong",{children:"el validationsStore si est\xE1 pasado"}),". Solamente faltan los componentes."]}))}))})},ti=w.memo(ga);H.debugDispatcher.on("parseXml",e=>N(void 0,[e],function*([t]){let r=yield(0,H.parseXmlAsync)(t);console.info(r)}),"Acepta un par\xE1metro de tipo string y realiza un parseo como si fuera xml, convirti\xE9ndolo a objeto javascript.");var ye={debug:!0,colors:{exception:"red",alert:"yellow",message:"lightgreen"},handleLoad:!1},ma="ApiaApiConfig",en={},Kr=localStorage.getItem(ma);Kr&&(en=JSON.parse(Kr));function re(t){return(0,Yr.merge)({},ye,t,en)}function tn(t,e,r){let n=t,a=n.indexOf("?");a===-1?n+="?":a!==n.length-1&&!n.endsWith("&")&&(n+="&");let o=`${n}${e?Ue.default.stringify(e,r):""}`;return(o.endsWith("&")||o.endsWith("?"))&&(o=o.slice(0,o.length-1)),o}var rn=t=>{var r;let e=(r=t.match(/action=(\w+)/))==null?void 0:r[1];return e!=null?e:"noAction"},qe=new class extends H.EventEmitter{};function z(t,e=(r=>(r=ye.colors)!=null?r:{exception:"red",alert:"yellow",message:"green"})()){return e[t]}var be=t=>{let e;typeof t!="string"?t.message?e=t.message:e=t.toString():e=t,(0,K.notify)({type:"danger",message:t.message}),console.log("%c ","font-size:10vh"),console.log("%cError in ApiaApi","color:red;font-size:2em;font-weight:bold"),console.log(`red/${e}`,{error:t}),console.log("%c ","font-size:10vh")};function va(t){return t.headers["content-type"].match("application/json")}function ha(t){return t.headers["content-type"].match(/(?:application|text)?\/xml/)}function Aa(t){return t.headers["content-type"].match(/(?:application|text)?\/html/)}function Sa(t){var e,r;t&&(re().debug&&console.log("%cHandled actions: ",`color: ${(r=(e=re().colors)==null?void 0:e.message)!=null?r:"green"}`,{actions:t}),(0,H.arrayOrArray)(t.action).forEach(a=>{qe.emit("action",D(S({},a),{param:(0,H.arrayOrArray)(a.param)}))}))}function jr({exceptions:t,onClose:e,sysExceptions:r,sysMessages:n}){try{import(`/api/onClose/${e}.ts`).then(a=>{if(t||r||n){let o=(0,K.getNotificationMessageObj)({exceptions:t,onClose:e,sysExceptions:r,sysMessages:n});o?o.forEach(s=>{(0,K.notify)(D(S({},s),{onClose:a.default}))}):a.default()}else a.default()},a=>{(0,K.notify)({message:`onClose action not found: ${String(a)}`,type:"danger"})})}catch(a){nn({exceptions:t,sysExceptions:r,sysMessages:n}),console.error("Error while handling onClose"),console.error(a)}}function nn(t){if(!t)return;let{exceptions:e,sysMessages:r,sysExceptions:n}=t;if(e||n||r)try{(0,K.dispatchNotifications)({exceptions:e,sysExceptions:n,sysMessages:r})}catch(a){be(new Error(a))}}var wa=(n,a,...o)=>N(void 0,[n,a,...o],function*(t,e,r=ye){var l;let s=re(r),i;if(va(t))typeof t.data=="string"?i=JSON.parse(t.data.trim()):typeof t.data=="object"&&t.data&&(i=t.data);else if(ha(t))i=yield(0,H.parseXmlAsync)(t.data).catch(c=>{be(new Error(c))});else if(Aa(t))return console.error("El contenido devuelto es Html, no se esperaba esa respuesta"),null;if(s.validateResponse){let c=yield s.validateResponse(D(S({},t),{data:(l=i==null?void 0:i.load)!=null?l:i}));if(typeof c=="string")throw new Error(`Validation error: ${c}`);if(!c)throw new Error("Error")}if(i){let f=i,{actions:c,onClose:g,exceptions:p,sysExceptions:y,sysMessages:d,load:h}=f,T=me(f,["actions","onClose","exceptions","sysExceptions","sysMessages","load"]);return T.code==="-1"&&p?(Zr.session.invalidate(),null):(p&&s.debug&&console.log(`${z("exception",s.colors)}/parseSuccessfulResponse`,{exceptions:p}),y&&s.debug&&console.log(`${z("exception",s.colors)}/parseSuccessfulResponse`,{sysExceptions:y}),d&&s.debug&&console.log(`${z("alert",s.colors)}/parseSuccessfulResponse`,{sysMessages:d}),Sa(c),s.handleLoad&&g?jr({exceptions:p,onClose:g,sysExceptions:y,sysMessages:d}):nn({exceptions:p,sysExceptions:y,sysMessages:d}),h?(s.handleLoad&&(console.log(`${z("message",s.colors)}/handleLoad`,{load:h}),Xr(h,e,{methodsPath:r.methodsPath,modalConfiguration:D(S({},s.modalConfiguration),{onClose:()=>{var u,v;g&&jr({exceptions:p,onClose:g,sysExceptions:y,sysMessages:d}),(u=s.modalConfiguration)!=null&&u.onClose&&((v=s.modalConfiguration)==null||v.onClose())}})})||console.log(`${z("exception",s.colors)}/unhandledLoad -> There is no handler defined`,{load:h})),D(S({},h),{sysMessages:d,exceptions:p,sysExceptions:y})):D(S({},T),{sysMessages:d,exceptions:p,sysExceptions:y}))}return null});function on(n,a){return N(this,arguments,function*(t,e,r=ye){var s;let o=re(r);try{if(!t||t.data===void 0)o.debug&&console.log(`${z("alert",o.colors)}/ApiaApi wrong response`);else{let i=yield wa(t,e,o),l=rn(e);return o.debug&&console.log(`${z("message",o.colors)}/ <- ApiaApi.${(s=t.config.method)!=null?s:""} ${l} `,{data:i}),D(S({},t),{data:i,hasError:!!(i!=null&&i.exceptions)||!!(i!=null&&i.sysExceptions),hasMessages:!!(i!=null&&i.sysMessages)})}}catch(i){return be(new Error(i)),null}return null})}function Ta(t,e){return N(this,null,function*(){let r=typeof t!="string"?Be():t,n=typeof t=="string"?e!=null?e:ye:t,a=D(S({},re(n)),{postData:n.postDataTreatement==="stringify"?Ue.default.stringify(n.postData,n.stringifyOptions):n.postData}),o=tn(r,a.queryData,a.stringifyOptions);if(a.debug){let i=r.split("&"),l=rn(r);console.log(`${z("message",a.colors)}/ApiaApi.post ${l}`,{url:o,queryDataInURL:[...i],queryData:a.queryData,formData:a.postData,stringifyOptiopns:a.stringifyOptions})}let s=yield St.default.post(o,a.postData,a.axiosConfig).catch(i=>{be(new Error(i))});return s?on(s,r,a):null})}function ba(t,e){return N(this,null,function*(){let r=typeof t!="string"?Be():t,n=re(typeof t=="string"?e!=null?e:ye:t),a=tn(r,n.queryData,n.stringifyOptions);n.debug&&console.log(`${z("message",n.colors)}/ApiaApi.get`,{url:a});let o=yield St.default.get(a,n.axiosConfig).catch(s=>{be(new Error(s))});return o?yield on(o,r,n):null})}var xa={get:ba,getConfig:re,post:Ta};function Be(t){var f,c;let e={};if(t){let l=t,{ajaxUrl:g,queryString:p,stringifyOptions:y,shouldAvoidTabId:d,preventAsXmlParameter:h,avoidTabId:T}=l,u=me(l,["ajaxUrl","queryString","stringifyOptions","shouldAvoidTabId","preventAsXmlParameter","avoidTabId"]);e=S({},u)}let r=Ue.default.stringify(e,(f=t==null?void 0:t.stringifyOptions)!=null?f:{arrayFormat:"repeat",encodeValuesOnly:!1}),n=(c=t==null?void 0:t.ajaxUrl)!=null?c:window.URL_REQUEST_AJAX;n.indexOf("?")===n.length-1&&(n=n.slice(0,n.length-1)),n.startsWith("/")||(n=`/${n}`);let a=window.TAB_ID_REQUEST.match(/tokenId=(\w+)/),o=(a!=null?a:[])[1],s=(t!=null&&t.tabId?`&tabId=${t.tabId}&tokenId=${o}`:window.TAB_ID_REQUEST).slice(1);t!=null&&t.avoidTabId&&(s="");let{CONTEXT:i}=window;return i!=null&&i.endsWith("/")&&(i+=i.slice(0,i.length-1)),`${i}${n}?${t!=null&&t.preventAsXmlParameter?"":"asXml=true&"}${t!=null&&t.queryString?`${t.queryString}&`:""}${r?`${r}&`:""}${s}`}var an=xa;0&&(module.exports={ApiaApi,makeApiaUrl});
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default, { createContext, useMemo } from 'react';
|
|
4
|
+
import { Box } from 'theme-ui';
|
|
5
|
+
import { debugDispatcher, EventEmitter, parseXmlAsync, arrayOrArray, useMount, encrypt, WithEventsValue, focus, focusSelector, useStateRef, useUnmount } from '@apia/util';
|
|
6
|
+
import { notify, getNotificationMessageObj, dispatchNotifications } from '@apia/notifications';
|
|
7
|
+
import { classToValidate, Checkbox, FileInput, classToValidationFunction, Input, Radio, Select, useFormContext, validationsStore, hasSucceedFormValidation, Form } from '@apia/validations';
|
|
8
|
+
import { SimpleButton, useModal, Modal, ProgressBar } from '@apia/components';
|
|
9
|
+
import { getVariant } from '@apia/theme';
|
|
10
|
+
import axios from 'axios';
|
|
11
|
+
import { merge, uniqueId } from 'lodash';
|
|
12
|
+
import QueryString from 'qs';
|
|
13
|
+
import { session } from '@apia/session';
|
|
14
|
+
|
|
15
|
+
const ApiaApiId = createContext("apiaApi");
|
|
16
|
+
const ApiaApiContext = ({
|
|
17
|
+
children,
|
|
18
|
+
id
|
|
19
|
+
}) => {
|
|
20
|
+
return /* @__PURE__ */ jsx(ApiaApiId.Provider, { value: id, children });
|
|
21
|
+
};
|
|
22
|
+
var ApiaApiContext$1 = React.memo(ApiaApiContext);
|
|
23
|
+
|
|
24
|
+
var __defProp$8 = Object.defineProperty;
|
|
25
|
+
var __defProps$4 = Object.defineProperties;
|
|
26
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
27
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
28
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
29
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
30
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
31
|
+
var __spreadValues$8 = (a, b) => {
|
|
32
|
+
for (var prop in b || (b = {}))
|
|
33
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
34
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
35
|
+
if (__getOwnPropSymbols$8)
|
|
36
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
37
|
+
if (__propIsEnum$8.call(b, prop))
|
|
38
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
39
|
+
}
|
|
40
|
+
return a;
|
|
41
|
+
};
|
|
42
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
43
|
+
var __objRest$1 = (source, exclude) => {
|
|
44
|
+
var target = {};
|
|
45
|
+
for (var prop in source)
|
|
46
|
+
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
47
|
+
target[prop] = source[prop];
|
|
48
|
+
if (source != null && __getOwnPropSymbols$8)
|
|
49
|
+
for (var prop of __getOwnPropSymbols$8(source)) {
|
|
50
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
|
|
51
|
+
target[prop] = source[prop];
|
|
52
|
+
}
|
|
53
|
+
return target;
|
|
54
|
+
};
|
|
55
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
var fulfilled = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
step(generator.next(value));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
reject(e);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var rejected = (value) => {
|
|
65
|
+
try {
|
|
66
|
+
step(generator.throw(value));
|
|
67
|
+
} catch (e) {
|
|
68
|
+
reject(e);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
72
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
debugDispatcher.on(
|
|
76
|
+
"parseXml",
|
|
77
|
+
(_0) => __async$2(void 0, [_0], function* ([text]) {
|
|
78
|
+
const result = yield parseXmlAsync(text);
|
|
79
|
+
console.info(result);
|
|
80
|
+
}),
|
|
81
|
+
"Acepta un par\xE1metro de tipo string y realiza un parseo como si fuera xml, convirti\xE9ndolo a objeto javascript."
|
|
82
|
+
);
|
|
83
|
+
const defaultConfig = {
|
|
84
|
+
debug: true,
|
|
85
|
+
colors: {
|
|
86
|
+
exception: "red",
|
|
87
|
+
alert: "yellow",
|
|
88
|
+
message: "lightgreen"
|
|
89
|
+
},
|
|
90
|
+
handleLoad: false
|
|
91
|
+
};
|
|
92
|
+
const STORED_CONFIG = "ApiaApiConfig";
|
|
93
|
+
let forcedConfig = {};
|
|
94
|
+
const storedConfig = localStorage.getItem(STORED_CONFIG);
|
|
95
|
+
if (storedConfig)
|
|
96
|
+
forcedConfig = JSON.parse(storedConfig);
|
|
97
|
+
function getConfig(outerBehaveConfig) {
|
|
98
|
+
return merge({}, defaultConfig, outerBehaveConfig, forcedConfig);
|
|
99
|
+
}
|
|
100
|
+
function makeUrl(url, queryData, stringifyOptions) {
|
|
101
|
+
let finalUrl = url;
|
|
102
|
+
const questionMarkIndex = finalUrl.indexOf("?");
|
|
103
|
+
if (questionMarkIndex === -1)
|
|
104
|
+
finalUrl += "?";
|
|
105
|
+
else if (questionMarkIndex !== finalUrl.length - 1 && !finalUrl.endsWith("&"))
|
|
106
|
+
finalUrl += "&";
|
|
107
|
+
let parsedUrl = `${finalUrl}${queryData ? QueryString.stringify(queryData, stringifyOptions) : ""}`;
|
|
108
|
+
if (parsedUrl.endsWith("&") || parsedUrl.endsWith("?")) {
|
|
109
|
+
parsedUrl = parsedUrl.slice(0, parsedUrl.length - 1);
|
|
110
|
+
}
|
|
111
|
+
return parsedUrl;
|
|
112
|
+
}
|
|
113
|
+
const getURLActionName = (url) => {
|
|
114
|
+
var _a;
|
|
115
|
+
const actionIdx = (_a = url.match(/action=(\w+)/)) == null ? void 0 : _a[1];
|
|
116
|
+
return actionIdx != null ? actionIdx : "noAction";
|
|
117
|
+
};
|
|
118
|
+
const ApiaActions = new class ApiaActions2 extends EventEmitter {
|
|
119
|
+
}();
|
|
120
|
+
function getColor(color, colors = ((_a) => (_a = defaultConfig.colors) != null ? _a : {
|
|
121
|
+
exception: "red",
|
|
122
|
+
alert: "yellow",
|
|
123
|
+
message: "green"
|
|
124
|
+
})()) {
|
|
125
|
+
return colors[color];
|
|
126
|
+
}
|
|
127
|
+
const handleWrongResponse = (error) => {
|
|
128
|
+
let errorMessage;
|
|
129
|
+
if (typeof error !== "string") {
|
|
130
|
+
if (error.message)
|
|
131
|
+
errorMessage = error.message;
|
|
132
|
+
else
|
|
133
|
+
errorMessage = error.toString();
|
|
134
|
+
} else
|
|
135
|
+
errorMessage = error;
|
|
136
|
+
notify({
|
|
137
|
+
type: "danger",
|
|
138
|
+
message: error.message.replaceAll("AxiosError", "Error")
|
|
139
|
+
});
|
|
140
|
+
console.log("%c ", "font-size:10vh");
|
|
141
|
+
console.log("%cError in ApiaApi", "color:red;font-size:2em;font-weight:bold");
|
|
142
|
+
console.log(`red/${errorMessage}`, { error });
|
|
143
|
+
console.log("%c ", "font-size:10vh");
|
|
144
|
+
};
|
|
145
|
+
function isJsonResponse(response) {
|
|
146
|
+
return response.headers["content-type"].match("application/json");
|
|
147
|
+
}
|
|
148
|
+
function isXmlResponse(response) {
|
|
149
|
+
return response.headers["content-type"].match(
|
|
150
|
+
/(?:application|text)?\/xml/
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
function isHtmlResponse(response) {
|
|
154
|
+
return response.headers["content-type"].match(
|
|
155
|
+
/(?:application|text)?\/html/
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
function handleActions(actions) {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
if (actions) {
|
|
161
|
+
if (getConfig().debug)
|
|
162
|
+
console.log(
|
|
163
|
+
"%cHandled actions: ",
|
|
164
|
+
`color: ${(_b = (_a = getConfig().colors) == null ? void 0 : _a.message) != null ? _b : "green"}`,
|
|
165
|
+
{ actions }
|
|
166
|
+
);
|
|
167
|
+
const actionsArray = arrayOrArray(actions.action);
|
|
168
|
+
actionsArray.forEach((action) => {
|
|
169
|
+
ApiaActions.emit("action", __spreadProps$4(__spreadValues$8({}, action), {
|
|
170
|
+
param: arrayOrArray(action.param)
|
|
171
|
+
}));
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function handleOnClose({
|
|
176
|
+
exceptions,
|
|
177
|
+
onClose,
|
|
178
|
+
sysExceptions,
|
|
179
|
+
sysMessages
|
|
180
|
+
}) {
|
|
181
|
+
try {
|
|
182
|
+
import(
|
|
183
|
+
/* webpackChunkName: "api-[request]" */
|
|
184
|
+
`/api/onClose/${onClose}.ts`
|
|
185
|
+
).then(
|
|
186
|
+
(func) => {
|
|
187
|
+
if (exceptions || sysExceptions || sysMessages) {
|
|
188
|
+
const notificationsObject = getNotificationMessageObj({
|
|
189
|
+
exceptions,
|
|
190
|
+
onClose,
|
|
191
|
+
sysExceptions,
|
|
192
|
+
sysMessages
|
|
193
|
+
});
|
|
194
|
+
if (notificationsObject)
|
|
195
|
+
notificationsObject.forEach((notification) => {
|
|
196
|
+
notify(__spreadProps$4(__spreadValues$8({}, notification), {
|
|
197
|
+
onClose: func.default
|
|
198
|
+
}));
|
|
199
|
+
});
|
|
200
|
+
else
|
|
201
|
+
func.default();
|
|
202
|
+
} else
|
|
203
|
+
func.default();
|
|
204
|
+
},
|
|
205
|
+
(e) => {
|
|
206
|
+
notify({
|
|
207
|
+
message: `onClose action not found: ${String(e)}`,
|
|
208
|
+
type: "danger"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
} catch (e) {
|
|
213
|
+
parseMessages({ exceptions, sysExceptions, sysMessages });
|
|
214
|
+
console.error("Error while handling onClose");
|
|
215
|
+
console.error(e);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function parseMessages(response) {
|
|
219
|
+
if (!response)
|
|
220
|
+
return;
|
|
221
|
+
const { exceptions, sysMessages, sysExceptions } = response;
|
|
222
|
+
if (exceptions || sysExceptions || sysMessages) {
|
|
223
|
+
try {
|
|
224
|
+
dispatchNotifications({
|
|
225
|
+
exceptions,
|
|
226
|
+
sysExceptions,
|
|
227
|
+
sysMessages
|
|
228
|
+
});
|
|
229
|
+
} catch (e) {
|
|
230
|
+
handleWrongResponse(new Error(e));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
const parseSuccessfulResponse = (_0, _1, ..._2) => __async$2(void 0, [_0, _1, ..._2], function* (response, currentUrl, outerBehaveConfig = defaultConfig) {
|
|
235
|
+
var _a;
|
|
236
|
+
const behaveConfig = getConfig(outerBehaveConfig);
|
|
237
|
+
let parsedObj;
|
|
238
|
+
if (isJsonResponse(response)) {
|
|
239
|
+
if (typeof response.data === "string")
|
|
240
|
+
parsedObj = JSON.parse(
|
|
241
|
+
response.data.trim()
|
|
242
|
+
);
|
|
243
|
+
else if (typeof response.data === "object" && response.data)
|
|
244
|
+
parsedObj = response.data;
|
|
245
|
+
} else if (isXmlResponse(response)) {
|
|
246
|
+
parsedObj = yield parseXmlAsync(response.data).catch(
|
|
247
|
+
(e) => {
|
|
248
|
+
handleWrongResponse(new Error(e));
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
} else if (isHtmlResponse(response)) {
|
|
252
|
+
console.error(
|
|
253
|
+
"El contenido devuelto es Html, no se esperaba esa respuesta"
|
|
254
|
+
);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
if (behaveConfig.validateResponse) {
|
|
258
|
+
const validateResult = yield behaveConfig.validateResponse(__spreadProps$4(__spreadValues$8({}, response), {
|
|
259
|
+
data: (_a = parsedObj == null ? void 0 : parsedObj.load) != null ? _a : parsedObj
|
|
260
|
+
}));
|
|
261
|
+
if (typeof validateResult === "string")
|
|
262
|
+
throw new Error(`Validation error: ${validateResult}`);
|
|
263
|
+
else if (!validateResult) {
|
|
264
|
+
throw new Error("Error");
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (parsedObj) {
|
|
268
|
+
const _b = parsedObj, {
|
|
269
|
+
actions,
|
|
270
|
+
onClose,
|
|
271
|
+
exceptions,
|
|
272
|
+
sysExceptions,
|
|
273
|
+
sysMessages,
|
|
274
|
+
load
|
|
275
|
+
} = _b, rest = __objRest$1(_b, [
|
|
276
|
+
"actions",
|
|
277
|
+
"onClose",
|
|
278
|
+
"exceptions",
|
|
279
|
+
"sysExceptions",
|
|
280
|
+
"sysMessages",
|
|
281
|
+
"load"
|
|
282
|
+
]);
|
|
283
|
+
if (rest.code === "-1" && exceptions) {
|
|
284
|
+
session.invalidate();
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
if (exceptions && behaveConfig.debug) {
|
|
288
|
+
console.log(
|
|
289
|
+
`%cparseSuccessfulResponse`,
|
|
290
|
+
`color: ${getColor("exception", behaveConfig.colors)}`,
|
|
291
|
+
{
|
|
292
|
+
exceptions
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
if (sysExceptions && behaveConfig.debug) {
|
|
297
|
+
console.log(
|
|
298
|
+
`%cparseSuccessfulResponse`,
|
|
299
|
+
`color: ${getColor("exception", behaveConfig.colors)}`,
|
|
300
|
+
{
|
|
301
|
+
sysExceptions
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
if (sysMessages && behaveConfig.debug) {
|
|
306
|
+
console.log(
|
|
307
|
+
`%cparseSuccessfulResponse`,
|
|
308
|
+
`color: ${getColor("alert", behaveConfig.colors)}`,
|
|
309
|
+
{
|
|
310
|
+
sysMessages
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
handleActions(actions);
|
|
315
|
+
if (behaveConfig.handleLoad && onClose)
|
|
316
|
+
handleOnClose({
|
|
317
|
+
exceptions,
|
|
318
|
+
onClose,
|
|
319
|
+
sysExceptions,
|
|
320
|
+
sysMessages
|
|
321
|
+
});
|
|
322
|
+
else
|
|
323
|
+
parseMessages({ exceptions, sysExceptions, sysMessages });
|
|
324
|
+
if (load) {
|
|
325
|
+
if (behaveConfig.handleLoad) {
|
|
326
|
+
console.log(
|
|
327
|
+
`%chandleLoad`,
|
|
328
|
+
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
329
|
+
{
|
|
330
|
+
load
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
if (!handle(load, currentUrl, {
|
|
334
|
+
methodsPath: outerBehaveConfig.methodsPath,
|
|
335
|
+
modalConfiguration: __spreadProps$4(__spreadValues$8({}, behaveConfig.modalConfiguration), {
|
|
336
|
+
onClose: () => {
|
|
337
|
+
var _a2, _b2;
|
|
338
|
+
if (onClose)
|
|
339
|
+
handleOnClose({
|
|
340
|
+
exceptions,
|
|
341
|
+
onClose,
|
|
342
|
+
sysExceptions,
|
|
343
|
+
sysMessages
|
|
344
|
+
});
|
|
345
|
+
if ((_a2 = behaveConfig.modalConfiguration) == null ? void 0 : _a2.onClose)
|
|
346
|
+
(_b2 = behaveConfig.modalConfiguration) == null ? void 0 : _b2.onClose();
|
|
347
|
+
}
|
|
348
|
+
})
|
|
349
|
+
})) {
|
|
350
|
+
console.log(
|
|
351
|
+
`%cunhandledLoad -> There is no handler defined`,
|
|
352
|
+
`color: ${getColor("exception", behaveConfig.colors)}`,
|
|
353
|
+
{
|
|
354
|
+
load
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return __spreadProps$4(__spreadValues$8({}, load), { sysMessages, exceptions, sysExceptions });
|
|
360
|
+
}
|
|
361
|
+
return __spreadProps$4(__spreadValues$8({}, rest), { sysMessages, exceptions, sysExceptions });
|
|
362
|
+
}
|
|
363
|
+
return null;
|
|
364
|
+
});
|
|
365
|
+
function handleResponse(_0, _1) {
|
|
366
|
+
return __async$2(this, arguments, function* (result, currentUrl, outerBehaveConfig = defaultConfig) {
|
|
367
|
+
var _a;
|
|
368
|
+
const behaveConfig = getConfig(outerBehaveConfig);
|
|
369
|
+
try {
|
|
370
|
+
if (!result || result.data === void 0) {
|
|
371
|
+
if (behaveConfig.debug)
|
|
372
|
+
console.log(
|
|
373
|
+
`%cApiaApi wrong response`,
|
|
374
|
+
`color: ${getColor("alert", behaveConfig.colors)}`
|
|
375
|
+
);
|
|
376
|
+
} else {
|
|
377
|
+
const parsedResponse = yield parseSuccessfulResponse(
|
|
378
|
+
result,
|
|
379
|
+
currentUrl,
|
|
380
|
+
behaveConfig
|
|
381
|
+
);
|
|
382
|
+
const action = getURLActionName(currentUrl);
|
|
383
|
+
if (behaveConfig.debug)
|
|
384
|
+
console.log(
|
|
385
|
+
`%c <- ApiaApi.${(_a = result.config.method) != null ? _a : ""} ${action} `,
|
|
386
|
+
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
387
|
+
{
|
|
388
|
+
data: parsedResponse
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
return __spreadProps$4(__spreadValues$8({}, result), {
|
|
392
|
+
data: parsedResponse,
|
|
393
|
+
hasError: !!(parsedResponse == null ? void 0 : parsedResponse.exceptions) || !!(parsedResponse == null ? void 0 : parsedResponse.sysExceptions),
|
|
394
|
+
hasMessages: !!(parsedResponse == null ? void 0 : parsedResponse.sysMessages)
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
} catch (e) {
|
|
398
|
+
handleWrongResponse(new Error(e));
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
return null;
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
function post(par1, par2) {
|
|
405
|
+
return __async$2(this, null, function* () {
|
|
406
|
+
const actualUrl = typeof par1 !== "string" ? makeApiaUrl() : par1;
|
|
407
|
+
const configParameter = typeof par1 === "string" ? par2 != null ? par2 : defaultConfig : par1;
|
|
408
|
+
const behaveConfig = __spreadProps$4(__spreadValues$8({}, getConfig(configParameter)), {
|
|
409
|
+
postData: configParameter.postDataTreatement === "stringify" ? QueryString.stringify(
|
|
410
|
+
configParameter.postData,
|
|
411
|
+
configParameter.stringifyOptions
|
|
412
|
+
) : configParameter.postData
|
|
413
|
+
});
|
|
414
|
+
const parsedUrl = makeUrl(
|
|
415
|
+
actualUrl,
|
|
416
|
+
behaveConfig.queryData,
|
|
417
|
+
behaveConfig.stringifyOptions
|
|
418
|
+
);
|
|
419
|
+
if (behaveConfig.debug) {
|
|
420
|
+
const queryString = actualUrl.split("&");
|
|
421
|
+
const action = getURLActionName(actualUrl);
|
|
422
|
+
console.log(
|
|
423
|
+
`%cApiaApi.post ${action}`,
|
|
424
|
+
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
425
|
+
{
|
|
426
|
+
url: parsedUrl,
|
|
427
|
+
queryDataInURL: [...queryString],
|
|
428
|
+
queryData: behaveConfig.queryData,
|
|
429
|
+
formData: behaveConfig.postData,
|
|
430
|
+
stringifyOptiopns: behaveConfig.stringifyOptions
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
const response = yield axios.post(
|
|
435
|
+
parsedUrl,
|
|
436
|
+
behaveConfig.postData,
|
|
437
|
+
behaveConfig.axiosConfig
|
|
438
|
+
).catch((e) => {
|
|
439
|
+
handleWrongResponse(new Error(e));
|
|
440
|
+
});
|
|
441
|
+
if (response) {
|
|
442
|
+
const result = handleResponse(response, actualUrl, behaveConfig);
|
|
443
|
+
return result;
|
|
444
|
+
}
|
|
445
|
+
return null;
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function get(par1, par2) {
|
|
449
|
+
return __async$2(this, null, function* () {
|
|
450
|
+
const actualUrl = typeof par1 !== "string" ? makeApiaUrl() : par1;
|
|
451
|
+
const behaveConfig = getConfig(
|
|
452
|
+
typeof par1 === "string" ? par2 != null ? par2 : defaultConfig : par1
|
|
453
|
+
);
|
|
454
|
+
const parsedUrl = makeUrl(
|
|
455
|
+
actualUrl,
|
|
456
|
+
behaveConfig.queryData,
|
|
457
|
+
behaveConfig.stringifyOptions
|
|
458
|
+
);
|
|
459
|
+
if (behaveConfig.debug)
|
|
460
|
+
console.log(
|
|
461
|
+
`%cApiaApi.get`,
|
|
462
|
+
`color: ${getColor("message", behaveConfig.colors)}`,
|
|
463
|
+
{
|
|
464
|
+
url: parsedUrl
|
|
465
|
+
}
|
|
466
|
+
);
|
|
467
|
+
const response = yield axios.get(parsedUrl, behaveConfig.axiosConfig).catch((e) => {
|
|
468
|
+
handleWrongResponse(new Error(e));
|
|
469
|
+
});
|
|
470
|
+
if (response) {
|
|
471
|
+
const result = yield handleResponse(
|
|
472
|
+
response,
|
|
473
|
+
actualUrl,
|
|
474
|
+
behaveConfig
|
|
475
|
+
);
|
|
476
|
+
return result;
|
|
477
|
+
}
|
|
478
|
+
return null;
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
const ApiaApi = {
|
|
482
|
+
get,
|
|
483
|
+
getConfig,
|
|
484
|
+
post
|
|
485
|
+
};
|
|
486
|
+
function makeApiaUrl(props) {
|
|
487
|
+
var _b, _c;
|
|
488
|
+
let actualQueryData = {};
|
|
489
|
+
if (props) {
|
|
490
|
+
const _a = props, rest = __objRest$1(_a, [
|
|
491
|
+
"ajaxUrl",
|
|
492
|
+
"queryString",
|
|
493
|
+
"stringifyOptions",
|
|
494
|
+
"shouldAvoidTabId",
|
|
495
|
+
"preventAsXmlParameter",
|
|
496
|
+
"avoidTabId"
|
|
497
|
+
]);
|
|
498
|
+
actualQueryData = __spreadValues$8({}, rest);
|
|
499
|
+
}
|
|
500
|
+
const queryString = QueryString.stringify(
|
|
501
|
+
actualQueryData,
|
|
502
|
+
(_b = props == null ? void 0 : props.stringifyOptions) != null ? _b : {
|
|
503
|
+
arrayFormat: "repeat",
|
|
504
|
+
encodeValuesOnly: false
|
|
505
|
+
}
|
|
506
|
+
);
|
|
507
|
+
let actualAjaxUrl = (_c = props == null ? void 0 : props.ajaxUrl) != null ? _c : window.URL_REQUEST_AJAX;
|
|
508
|
+
if (actualAjaxUrl.indexOf("?") === actualAjaxUrl.length - 1)
|
|
509
|
+
actualAjaxUrl = actualAjaxUrl.slice(0, actualAjaxUrl.length - 1);
|
|
510
|
+
if (!actualAjaxUrl.startsWith("/"))
|
|
511
|
+
actualAjaxUrl = `/${actualAjaxUrl}`;
|
|
512
|
+
const match = window.TAB_ID_REQUEST.match(/tokenId=(\w+)/);
|
|
513
|
+
const currentTokenId = (match != null ? match : [])[1];
|
|
514
|
+
let tabId = ((props == null ? void 0 : props.tabId) ? `&tabId=${props.tabId}&tokenId=${currentTokenId}` : window.TAB_ID_REQUEST).slice(1);
|
|
515
|
+
if (props == null ? void 0 : props.avoidTabId)
|
|
516
|
+
tabId = "";
|
|
517
|
+
let { CONTEXT } = window;
|
|
518
|
+
if (CONTEXT == null ? void 0 : CONTEXT.endsWith("/"))
|
|
519
|
+
CONTEXT += CONTEXT.slice(0, CONTEXT.length - 1);
|
|
520
|
+
return `${CONTEXT}${actualAjaxUrl}?${!(props == null ? void 0 : props.preventAsXmlParameter) ? "asXml=true&" : ""}${(props == null ? void 0 : props.queryString) ? `${props.queryString}&` : ""}${queryString ? `${queryString}&` : ""}${tabId}`;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var __defProp$7 = Object.defineProperty;
|
|
524
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
525
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
526
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
527
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
528
|
+
var __spreadValues$7 = (a, b) => {
|
|
529
|
+
for (var prop in b || (b = {}))
|
|
530
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
531
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
532
|
+
if (__getOwnPropSymbols$7)
|
|
533
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
534
|
+
if (__propIsEnum$7.call(b, prop))
|
|
535
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
536
|
+
}
|
|
537
|
+
return a;
|
|
538
|
+
};
|
|
539
|
+
const ApiaApiCheckbox = (props) => {
|
|
540
|
+
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
541
|
+
const className = React__default.useMemo(
|
|
542
|
+
() => element.class ? `handler__checkbox ${element.class}` : "handler__checkbox",
|
|
543
|
+
[element.class]
|
|
544
|
+
);
|
|
545
|
+
const validationRules = React__default.useMemo(
|
|
546
|
+
() => __spreadValues$7({
|
|
547
|
+
required: element.mandatory
|
|
548
|
+
}, classToValidate(element.class)),
|
|
549
|
+
[element.class, element.mandatory]
|
|
550
|
+
);
|
|
551
|
+
const submitValueParser = React__default.useCallback(
|
|
552
|
+
(value) => value === "on" || value === true,
|
|
553
|
+
[]
|
|
554
|
+
);
|
|
555
|
+
return /* @__PURE__ */ jsx(
|
|
556
|
+
Checkbox,
|
|
557
|
+
{
|
|
558
|
+
className,
|
|
559
|
+
name: element.id || element.name,
|
|
560
|
+
label: element.text,
|
|
561
|
+
title: element.title || element.text,
|
|
562
|
+
initialValue: String(element.selected) === "true",
|
|
563
|
+
disabled: element.readonly || element.disabled,
|
|
564
|
+
validationRules,
|
|
565
|
+
onChange: element.onChange,
|
|
566
|
+
submitValueParser
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
var __defProp$6 = Object.defineProperty;
|
|
572
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
573
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
574
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
575
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
576
|
+
var __spreadValues$6 = (a, b) => {
|
|
577
|
+
for (var prop in b || (b = {}))
|
|
578
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
579
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
580
|
+
if (__getOwnPropSymbols$6)
|
|
581
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
582
|
+
if (__propIsEnum$6.call(b, prop))
|
|
583
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
584
|
+
}
|
|
585
|
+
return a;
|
|
586
|
+
};
|
|
587
|
+
const ApiaApiFileInput = (props) => {
|
|
588
|
+
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
589
|
+
const className = React__default.useMemo(
|
|
590
|
+
() => element.class ? `handler__file ${element.class}` : "handler__file",
|
|
591
|
+
[element.class]
|
|
592
|
+
);
|
|
593
|
+
const validationRules = React__default.useMemo(
|
|
594
|
+
() => __spreadValues$6({
|
|
595
|
+
required: element.mandatory
|
|
596
|
+
}, classToValidate(element.class)),
|
|
597
|
+
[element.class, element.mandatory]
|
|
598
|
+
);
|
|
599
|
+
return /* @__PURE__ */ jsx(
|
|
600
|
+
FileInput,
|
|
601
|
+
{
|
|
602
|
+
className,
|
|
603
|
+
name: element.id || element.name,
|
|
604
|
+
label: element.text,
|
|
605
|
+
title: element.title || element.text,
|
|
606
|
+
readOnly: element.readonly,
|
|
607
|
+
disabled: element.disabled,
|
|
608
|
+
validationRules
|
|
609
|
+
}
|
|
610
|
+
);
|
|
611
|
+
};
|
|
612
|
+
ApiaApiFileInput.displayName = "ApiaApiFileInput";
|
|
613
|
+
|
|
614
|
+
var __defProp$5 = Object.defineProperty;
|
|
615
|
+
var __defProps$3 = Object.defineProperties;
|
|
616
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
617
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
618
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
619
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
620
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
621
|
+
var __spreadValues$5 = (a, b) => {
|
|
622
|
+
for (var prop in b || (b = {}))
|
|
623
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
624
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
625
|
+
if (__getOwnPropSymbols$5)
|
|
626
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
627
|
+
if (__propIsEnum$5.call(b, prop))
|
|
628
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
629
|
+
}
|
|
630
|
+
return a;
|
|
631
|
+
};
|
|
632
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
633
|
+
const ApiaApiInput = (props) => {
|
|
634
|
+
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
635
|
+
const getModal = React__default.useCallback((path) => {
|
|
636
|
+
return React__default.lazy(() => {
|
|
637
|
+
return new Promise((resolve) => {
|
|
638
|
+
import(
|
|
639
|
+
/* webpackChunkName: "handlerModal" */
|
|
640
|
+
/* webpackInclude: /\.tsx?$/ */
|
|
641
|
+
`/api/modals/${path}`
|
|
642
|
+
).then((result) => {
|
|
643
|
+
resolve(
|
|
644
|
+
result
|
|
645
|
+
);
|
|
646
|
+
}).catch((error) => {
|
|
647
|
+
resolve({
|
|
648
|
+
default: () => {
|
|
649
|
+
console.error(error);
|
|
650
|
+
throw new Error(
|
|
651
|
+
`The above error ocurred at component ApiaApiHandler/${path}, does it exist?`
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
}, []);
|
|
659
|
+
const [Submodal, setSubmodal] = React__default.useState(null);
|
|
660
|
+
useMount(() => {
|
|
661
|
+
if (element.modalFunction) {
|
|
662
|
+
const found = element.modalFunction.match(/(?:fnc)?(\w+)\(?\)?$/);
|
|
663
|
+
if (found) {
|
|
664
|
+
const modalName = found[found.length - 1];
|
|
665
|
+
setSubmodal(getModal(modalName));
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
const className = React__default.useMemo(
|
|
670
|
+
() => element.class ? `handler__${element.type} ${element.class}` : `handler__${element.type}`,
|
|
671
|
+
[element.class, element.type]
|
|
672
|
+
);
|
|
673
|
+
const validationRules = React__default.useMemo(
|
|
674
|
+
() => __spreadValues$5({
|
|
675
|
+
required: element.mandatory,
|
|
676
|
+
maxLength: element.maxlength ? Number(element.maxlength) : void 0,
|
|
677
|
+
pattern: element.regExp,
|
|
678
|
+
patternMessage: element.regExpMessage
|
|
679
|
+
}, classToValidate(element.class)),
|
|
680
|
+
[
|
|
681
|
+
element.class,
|
|
682
|
+
element.mandatory,
|
|
683
|
+
element.maxlength,
|
|
684
|
+
element.regExp,
|
|
685
|
+
element.regExpMessage
|
|
686
|
+
]
|
|
687
|
+
);
|
|
688
|
+
const validationFunction = React__default.useMemo(
|
|
689
|
+
() => classToValidationFunction(element.class),
|
|
690
|
+
[element.class]
|
|
691
|
+
);
|
|
692
|
+
const submitValueParser = React__default.useCallback(
|
|
693
|
+
(value) => {
|
|
694
|
+
if (element.type === "password") {
|
|
695
|
+
return encrypt(
|
|
696
|
+
window.SALT,
|
|
697
|
+
window.IV,
|
|
698
|
+
window.PASSPHRASE,
|
|
699
|
+
value,
|
|
700
|
+
Number(window.KEY_SIZE),
|
|
701
|
+
Number(window.ITERATION_COUNT)
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
return value;
|
|
705
|
+
},
|
|
706
|
+
[element.type]
|
|
707
|
+
);
|
|
708
|
+
if (element.modalFunction) {
|
|
709
|
+
if (Submodal) {
|
|
710
|
+
return /* @__PURE__ */ jsx(React__default.Suspense, { children: /* @__PURE__ */ jsx(Submodal, __spreadProps$3(__spreadValues$5({}, props), { element })) });
|
|
711
|
+
}
|
|
712
|
+
return null;
|
|
713
|
+
}
|
|
714
|
+
return /* @__PURE__ */ jsx(
|
|
715
|
+
Input,
|
|
716
|
+
{
|
|
717
|
+
type: element.type,
|
|
718
|
+
className,
|
|
719
|
+
name: element.id || element.name,
|
|
720
|
+
label: element.text,
|
|
721
|
+
title: element.title || element.text,
|
|
722
|
+
value: element.value,
|
|
723
|
+
readOnly: element.readonly,
|
|
724
|
+
disabled: element.disabled,
|
|
725
|
+
validationFunction,
|
|
726
|
+
validationRules,
|
|
727
|
+
submitValueParser,
|
|
728
|
+
onChange: element.onChange,
|
|
729
|
+
autoComplete: element.type === "password" ? "new-password" : void 0
|
|
730
|
+
}
|
|
731
|
+
);
|
|
732
|
+
};
|
|
733
|
+
ApiaApiInput.displayName = "ApiaApiInput";
|
|
734
|
+
|
|
735
|
+
var __defProp$4 = Object.defineProperty;
|
|
736
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
737
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
738
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
739
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
740
|
+
var __spreadValues$4 = (a, b) => {
|
|
741
|
+
for (var prop in b || (b = {}))
|
|
742
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
743
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
744
|
+
if (__getOwnPropSymbols$4)
|
|
745
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
746
|
+
if (__propIsEnum$4.call(b, prop))
|
|
747
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
748
|
+
}
|
|
749
|
+
return a;
|
|
750
|
+
};
|
|
751
|
+
const ApiaApiRadio = (props) => {
|
|
752
|
+
var _a;
|
|
753
|
+
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
754
|
+
const className = React__default.useMemo(
|
|
755
|
+
() => element.class ? `handler__radio ${element.class}` : "handler__radio",
|
|
756
|
+
[element.class]
|
|
757
|
+
);
|
|
758
|
+
const options = React__default.useMemo(
|
|
759
|
+
() => {
|
|
760
|
+
var _a2;
|
|
761
|
+
return arrayOrArray((_a2 = element.options) == null ? void 0 : _a2.option).map((currOption) => {
|
|
762
|
+
return { value: currOption.value, label: currOption.content };
|
|
763
|
+
});
|
|
764
|
+
},
|
|
765
|
+
[(_a = element.options) == null ? void 0 : _a.option]
|
|
766
|
+
);
|
|
767
|
+
const validationRules = React__default.useMemo(
|
|
768
|
+
() => __spreadValues$4({
|
|
769
|
+
required: element.mandatory
|
|
770
|
+
}, classToValidate(element.class)),
|
|
771
|
+
[element.class, element.mandatory]
|
|
772
|
+
);
|
|
773
|
+
return /* @__PURE__ */ jsx(
|
|
774
|
+
Radio,
|
|
775
|
+
{
|
|
776
|
+
className,
|
|
777
|
+
name: element.id || element.name,
|
|
778
|
+
label: element.text,
|
|
779
|
+
title: element.title || element.text,
|
|
780
|
+
value: element.value,
|
|
781
|
+
disabled: element.readonly || element.disabled,
|
|
782
|
+
validationRules,
|
|
783
|
+
options,
|
|
784
|
+
onChange: element.onChange
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
};
|
|
788
|
+
ApiaApiRadio.displayName = "ApiaApiRadio";
|
|
789
|
+
|
|
790
|
+
var __defProp$3 = Object.defineProperty;
|
|
791
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
792
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
793
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
794
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
795
|
+
var __spreadValues$3 = (a, b) => {
|
|
796
|
+
for (var prop in b || (b = {}))
|
|
797
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
798
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
799
|
+
if (__getOwnPropSymbols$3)
|
|
800
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
801
|
+
if (__propIsEnum$3.call(b, prop))
|
|
802
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
803
|
+
}
|
|
804
|
+
return a;
|
|
805
|
+
};
|
|
806
|
+
const ApiaApiSelect = (props) => {
|
|
807
|
+
var _a;
|
|
808
|
+
const element = React__default.useMemo(() => props.element, [props.element]);
|
|
809
|
+
const className = React__default.useMemo(
|
|
810
|
+
() => element.class ? `handler__select ${element.class}` : "handler__select",
|
|
811
|
+
[element.class]
|
|
812
|
+
);
|
|
813
|
+
const options = React__default.useMemo(
|
|
814
|
+
() => {
|
|
815
|
+
var _a2;
|
|
816
|
+
return arrayOrArray((_a2 = element.options) == null ? void 0 : _a2.option).map((currOption) => {
|
|
817
|
+
return { value: currOption.value, label: currOption.content };
|
|
818
|
+
});
|
|
819
|
+
},
|
|
820
|
+
[(_a = element.options) == null ? void 0 : _a.option]
|
|
821
|
+
);
|
|
822
|
+
const validationRules = React__default.useMemo(
|
|
823
|
+
() => __spreadValues$3({
|
|
824
|
+
required: element.mandatory
|
|
825
|
+
}, classToValidate(element.class)),
|
|
826
|
+
[element.class, element.mandatory]
|
|
827
|
+
);
|
|
828
|
+
const initialValue = useMemo(
|
|
829
|
+
() => {
|
|
830
|
+
var _a2, _b, _c, _d;
|
|
831
|
+
return (_d = (_c = (_a2 = options.find((current) => current.value === props.element.value)) == null ? void 0 : _a2.value) != null ? _c : (_b = options[0]) == null ? void 0 : _b.value) != null ? _d : "";
|
|
832
|
+
},
|
|
833
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
834
|
+
[]
|
|
835
|
+
);
|
|
836
|
+
return /* @__PURE__ */ jsx(
|
|
837
|
+
Select,
|
|
838
|
+
{
|
|
839
|
+
className,
|
|
840
|
+
name: element.id || element.name,
|
|
841
|
+
label: element.text,
|
|
842
|
+
title: element.title || element.text,
|
|
843
|
+
value: element.value,
|
|
844
|
+
disabled: element.readonly || element.disabled,
|
|
845
|
+
validationRules,
|
|
846
|
+
options,
|
|
847
|
+
onChange: element.onChange,
|
|
848
|
+
initialValue
|
|
849
|
+
}
|
|
850
|
+
);
|
|
851
|
+
};
|
|
852
|
+
ApiaApiSelect.displayName = "ApiaApiSelect";
|
|
853
|
+
|
|
854
|
+
var __defProp$2 = Object.defineProperty;
|
|
855
|
+
var __defProps$2 = Object.defineProperties;
|
|
856
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
857
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
858
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
859
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
860
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
861
|
+
var __spreadValues$2 = (a, b) => {
|
|
862
|
+
for (var prop in b || (b = {}))
|
|
863
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
864
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
865
|
+
if (__getOwnPropSymbols$2)
|
|
866
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
867
|
+
if (__propIsEnum$2.call(b, prop))
|
|
868
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
869
|
+
}
|
|
870
|
+
return a;
|
|
871
|
+
};
|
|
872
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
873
|
+
const ApiaApiFieldsContainer = (props) => {
|
|
874
|
+
var _a, _b;
|
|
875
|
+
const elements = React__default.useMemo(
|
|
876
|
+
() => {
|
|
877
|
+
var _a2, _b2, _c;
|
|
878
|
+
return arrayOrArray((_c = (_b2 = (_a2 = props == null ? void 0 : props.definition) == null ? void 0 : _a2.form.elements) == null ? void 0 : _b2.element) != null ? _c : []);
|
|
879
|
+
},
|
|
880
|
+
[(_b = (_a = props == null ? void 0 : props.definition) == null ? void 0 : _a.form.elements) == null ? void 0 : _b.element]
|
|
881
|
+
);
|
|
882
|
+
const getSections = React__default.useCallback(() => {
|
|
883
|
+
var _a2;
|
|
884
|
+
const removeEndingSpacers = (sectionElements) => {
|
|
885
|
+
if (sectionElements.length > 1) {
|
|
886
|
+
for (let i = sectionElements.length - 1; i >= 0; i--) {
|
|
887
|
+
if (sectionElements[i].type === "empty") {
|
|
888
|
+
sectionElements.pop();
|
|
889
|
+
} else {
|
|
890
|
+
return sectionElements;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return sectionElements;
|
|
895
|
+
};
|
|
896
|
+
const sectionIndexes = [];
|
|
897
|
+
if (((_a2 = elements[0]) == null ? void 0 : _a2.type) !== "2columnTitle") {
|
|
898
|
+
sectionIndexes.push(-1);
|
|
899
|
+
}
|
|
900
|
+
elements.forEach((element, index) => {
|
|
901
|
+
if (element.type === "2columnTitle") {
|
|
902
|
+
sectionIndexes.push(index);
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
const sections2 = [];
|
|
906
|
+
sectionIndexes.forEach((sectionIndex, arrayIndex) => {
|
|
907
|
+
const start = sectionIndex + 1 < elements.length ? sectionIndex + 1 : elements.length - 1;
|
|
908
|
+
const end = arrayIndex + 1 < sectionIndexes.length ? sectionIndexes[arrayIndex + 1] : void 0;
|
|
909
|
+
sections2.push({
|
|
910
|
+
sectionHeader: sectionIndex !== -1 ? elements[sectionIndex] : void 0,
|
|
911
|
+
sectionElements: removeEndingSpacers(elements.slice(start, end))
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
return sections2;
|
|
915
|
+
}, [elements]);
|
|
916
|
+
const sections = getSections();
|
|
917
|
+
const renderSectionContent = React__default.useCallback(
|
|
918
|
+
(sectionElements) => {
|
|
919
|
+
const isVisible = sectionElements.findIndex((element) => element.type !== "hidden") !== -1;
|
|
920
|
+
return /* @__PURE__ */ jsx(
|
|
921
|
+
Box,
|
|
922
|
+
{
|
|
923
|
+
className: isVisible ? "handler__form__elements__section__content" : `handler__form__elements__section__content handler__hidden`,
|
|
924
|
+
children: sectionElements.map((current) => {
|
|
925
|
+
const element = __spreadProps$2(__spreadValues$2({}, current), {
|
|
926
|
+
onChange() {
|
|
927
|
+
getFunction(current.onChange, props).then((onChangeMethod) => {
|
|
928
|
+
if (onChangeMethod) {
|
|
929
|
+
onChangeMethod();
|
|
930
|
+
}
|
|
931
|
+
}).catch(console.error);
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
const elementKey = element.id || element.name || uniqueId();
|
|
935
|
+
switch (element.type) {
|
|
936
|
+
case "table": {
|
|
937
|
+
const data = JSON.parse(element.text);
|
|
938
|
+
return /* @__PURE__ */ jsx(
|
|
939
|
+
Box,
|
|
940
|
+
__spreadProps$2(__spreadValues$2({}, getVariant("layout.common.tables.information")), {
|
|
941
|
+
children: /* @__PURE__ */ jsxs("table", { sx: { width: "100%" }, children: [
|
|
942
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: data.columns.map((column) => {
|
|
943
|
+
return /* @__PURE__ */ jsx("th", { children: column }, column);
|
|
944
|
+
}) }) }),
|
|
945
|
+
/* @__PURE__ */ jsx("tbody", { children: data.rows.map((row) => {
|
|
946
|
+
return /* @__PURE__ */ jsx("tr", { children: row.cells.map((cell, i) => {
|
|
947
|
+
return /* @__PURE__ */ jsx("td", { children: cell }, `${cell}_${data.columns[i]}`);
|
|
948
|
+
}) }, row.cells.join("-"));
|
|
949
|
+
}) })
|
|
950
|
+
] })
|
|
951
|
+
}),
|
|
952
|
+
elementKey
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
case "2columnSubTitle":
|
|
956
|
+
return /* @__PURE__ */ jsx(Box, { className: element.class, as: "h6", children: element.value || element.text }, elementKey);
|
|
957
|
+
case "2column":
|
|
958
|
+
return /* @__PURE__ */ jsx(
|
|
959
|
+
Box,
|
|
960
|
+
{
|
|
961
|
+
dangerouslySetInnerHTML: {
|
|
962
|
+
__html: element.value || element.text
|
|
963
|
+
},
|
|
964
|
+
className: element.class
|
|
965
|
+
},
|
|
966
|
+
elementKey
|
|
967
|
+
);
|
|
968
|
+
case "checkbox":
|
|
969
|
+
return /* @__PURE__ */ jsx(
|
|
970
|
+
ApiaApiCheckbox,
|
|
971
|
+
__spreadProps$2(__spreadValues$2({}, props), {
|
|
972
|
+
element
|
|
973
|
+
}),
|
|
974
|
+
elementKey
|
|
975
|
+
);
|
|
976
|
+
case "file":
|
|
977
|
+
return /* @__PURE__ */ jsx(
|
|
978
|
+
ApiaApiFileInput,
|
|
979
|
+
__spreadProps$2(__spreadValues$2({}, props), {
|
|
980
|
+
element
|
|
981
|
+
}),
|
|
982
|
+
elementKey
|
|
983
|
+
);
|
|
984
|
+
case "hidden":
|
|
985
|
+
case "password":
|
|
986
|
+
case "text":
|
|
987
|
+
return /* @__PURE__ */ jsx(ApiaApiInput, __spreadProps$2(__spreadValues$2({}, props), { element }), elementKey);
|
|
988
|
+
case "select":
|
|
989
|
+
return /* @__PURE__ */ jsx(
|
|
990
|
+
ApiaApiSelect,
|
|
991
|
+
__spreadProps$2(__spreadValues$2({}, props), {
|
|
992
|
+
element
|
|
993
|
+
}),
|
|
994
|
+
elementKey
|
|
995
|
+
);
|
|
996
|
+
case "radio":
|
|
997
|
+
return /* @__PURE__ */ jsx(ApiaApiRadio, __spreadProps$2(__spreadValues$2({}, props), { element }), elementKey);
|
|
998
|
+
case "empty":
|
|
999
|
+
return /* @__PURE__ */ jsx(Box, { className: "spacer" }, elementKey);
|
|
1000
|
+
default:
|
|
1001
|
+
console.warn(
|
|
1002
|
+
`Unhandled element type: ${element.type}`,
|
|
1003
|
+
element
|
|
1004
|
+
);
|
|
1005
|
+
return null;
|
|
1006
|
+
}
|
|
1007
|
+
})
|
|
1008
|
+
},
|
|
1009
|
+
uniqueId()
|
|
1010
|
+
);
|
|
1011
|
+
},
|
|
1012
|
+
[props]
|
|
1013
|
+
);
|
|
1014
|
+
return /* @__PURE__ */ jsx(Box, { className: "handler__form__elements", children: sections.map((section) => {
|
|
1015
|
+
if (section.sectionHeader) {
|
|
1016
|
+
return renderSectionContent(section.sectionElements);
|
|
1017
|
+
}
|
|
1018
|
+
return renderSectionContent(section.sectionElements);
|
|
1019
|
+
}) });
|
|
1020
|
+
};
|
|
1021
|
+
ApiaApiFieldsContainer.displayName = "ApiaApiFieldsContainer";
|
|
1022
|
+
|
|
1023
|
+
var __defProp$1 = Object.defineProperty;
|
|
1024
|
+
var __defProps$1 = Object.defineProperties;
|
|
1025
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1026
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1027
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1028
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1029
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1030
|
+
var __spreadValues$1 = (a, b) => {
|
|
1031
|
+
for (var prop in b || (b = {}))
|
|
1032
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
1033
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1034
|
+
if (__getOwnPropSymbols$1)
|
|
1035
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1036
|
+
if (__propIsEnum$1.call(b, prop))
|
|
1037
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1038
|
+
}
|
|
1039
|
+
return a;
|
|
1040
|
+
};
|
|
1041
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1042
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
1043
|
+
return new Promise((resolve, reject) => {
|
|
1044
|
+
var fulfilled = (value) => {
|
|
1045
|
+
try {
|
|
1046
|
+
step(generator.next(value));
|
|
1047
|
+
} catch (e) {
|
|
1048
|
+
reject(e);
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
var rejected = (value) => {
|
|
1052
|
+
try {
|
|
1053
|
+
step(generator.throw(value));
|
|
1054
|
+
} catch (e) {
|
|
1055
|
+
reject(e);
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1059
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1060
|
+
});
|
|
1061
|
+
};
|
|
1062
|
+
var __forAwait = (obj, it, method) => {
|
|
1063
|
+
it = obj[Symbol.asyncIterator];
|
|
1064
|
+
method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((resolve, reject, done) => {
|
|
1065
|
+
arg = fn.call(obj, arg);
|
|
1066
|
+
done = arg.done;
|
|
1067
|
+
return Promise.resolve(arg.value).then((value) => resolve({ value, done }), reject);
|
|
1068
|
+
}));
|
|
1069
|
+
return it ? it.call(obj) : (obj = obj[Symbol.iterator](), it = {}, method("next"), method("return"), it);
|
|
1070
|
+
};
|
|
1071
|
+
const NonMemoizedApiaApiButtonsContainer = (props) => {
|
|
1072
|
+
var _a, _b, _c, _d, _e;
|
|
1073
|
+
const buttons = arrayOrArray((_c = (_b = (_a = props.definition) == null ? void 0 : _a.form.buttons) == null ? void 0 : _b.button) != null ? _c : []);
|
|
1074
|
+
const modalConfiguration = (_d = props.configuration) == null ? void 0 : _d.modalConfiguration;
|
|
1075
|
+
const methodsPath = (_e = props.configuration) == null ? void 0 : _e.methodsPath;
|
|
1076
|
+
const { name: apiaApiForm } = useFormContext();
|
|
1077
|
+
const renderButton = React__default.useCallback(
|
|
1078
|
+
(button) => {
|
|
1079
|
+
const key = uniqueId();
|
|
1080
|
+
const buttonType = ["submitAjax", "submit"].includes(button.type) && !button.onclick ? "submit" : "button";
|
|
1081
|
+
const className = `handler__${buttonType}`;
|
|
1082
|
+
const onClick = () => {
|
|
1083
|
+
void function submitForm() {
|
|
1084
|
+
return __async$1(this, null, function* () {
|
|
1085
|
+
const validationResult = yield validationsStore.validateForm(
|
|
1086
|
+
apiaApiForm
|
|
1087
|
+
);
|
|
1088
|
+
if (!hasSucceedFormValidation(validationResult)) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
const { submitValues } = validationResult;
|
|
1092
|
+
if ((props == null ? void 0 : props.definition) && ["submitAjax", "submit"].includes(button.type)) {
|
|
1093
|
+
const formData = new FormData();
|
|
1094
|
+
Object.entries(submitValues).forEach(([name, value]) => {
|
|
1095
|
+
formData.append(name, value != null ? value : "");
|
|
1096
|
+
});
|
|
1097
|
+
const hasContext = props == null ? void 0 : props.definition.form.action.match(
|
|
1098
|
+
new RegExp(`^${window.CONTEXT}/`)
|
|
1099
|
+
);
|
|
1100
|
+
const url = `${hasContext ? "" : window.CONTEXT}${!(props == null ? void 0 : props.definition.form.action.startsWith("/")) ? "/" : ""}${props == null ? void 0 : props.definition.form.action}`;
|
|
1101
|
+
props.setState((current) => __spreadProps$1(__spreadValues$1({}, current), {
|
|
1102
|
+
isLoading: true
|
|
1103
|
+
}));
|
|
1104
|
+
void ApiaApi.post(url, {
|
|
1105
|
+
postData: props.state.isMultipart ? formData : QueryString.stringify(
|
|
1106
|
+
[...formData.entries(), ["isAjax", true]].reduce((accumulated, [name, value]) => {
|
|
1107
|
+
const retValue = __spreadValues$1({}, accumulated);
|
|
1108
|
+
retValue[name.toString()] = value.toString();
|
|
1109
|
+
return retValue;
|
|
1110
|
+
}, {})
|
|
1111
|
+
),
|
|
1112
|
+
handleLoad: true,
|
|
1113
|
+
notificationsCategory: "apiaApiHandler",
|
|
1114
|
+
modalConfiguration,
|
|
1115
|
+
methodsPath
|
|
1116
|
+
}).finally(() => {
|
|
1117
|
+
void (() => __async$1(this, null, function* () {
|
|
1118
|
+
var _a2, _b2, _c2, _d2;
|
|
1119
|
+
if (button.onclick) {
|
|
1120
|
+
const actions = button.onclick.split(";");
|
|
1121
|
+
try {
|
|
1122
|
+
for (var iter = __forAwait(actions), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
|
|
1123
|
+
const action = temp.value;
|
|
1124
|
+
const method = yield getFunction(action, __spreadValues$1({}, props));
|
|
1125
|
+
if (method)
|
|
1126
|
+
method({
|
|
1127
|
+
currentUrl: (_b2 = (_a2 = props.definition) == null ? void 0 : _a2.form.action) != null ? _b2 : "noUrl"
|
|
1128
|
+
});
|
|
1129
|
+
else {
|
|
1130
|
+
throw new Error(
|
|
1131
|
+
`The requested action is not defined: "${(_d2 = (_c2 = props.definition) == null ? void 0 : _c2.form.action) != null ? _d2 : ""}"`
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
} catch (temp) {
|
|
1136
|
+
error = [temp];
|
|
1137
|
+
} finally {
|
|
1138
|
+
try {
|
|
1139
|
+
more && (temp = iter.return) && (yield temp.call(iter));
|
|
1140
|
+
} finally {
|
|
1141
|
+
if (error)
|
|
1142
|
+
throw error[0];
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}))();
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
}();
|
|
1151
|
+
};
|
|
1152
|
+
return /* @__PURE__ */ jsx(
|
|
1153
|
+
SimpleButton,
|
|
1154
|
+
{
|
|
1155
|
+
className,
|
|
1156
|
+
disabled: props.state.disabled,
|
|
1157
|
+
id: button.id || button.text,
|
|
1158
|
+
isLoading: props.state.isLoading,
|
|
1159
|
+
title: button.text,
|
|
1160
|
+
type: buttonType,
|
|
1161
|
+
onClick,
|
|
1162
|
+
children: button.text
|
|
1163
|
+
},
|
|
1164
|
+
key
|
|
1165
|
+
);
|
|
1166
|
+
},
|
|
1167
|
+
[apiaApiForm, methodsPath, modalConfiguration, props]
|
|
1168
|
+
);
|
|
1169
|
+
return /* @__PURE__ */ jsx(Box, { className: "handler__form__buttons", children: buttons.map((currentButton) => renderButton(currentButton)) });
|
|
1170
|
+
};
|
|
1171
|
+
const ApiaApiButtonsContainer = React__default.memo(
|
|
1172
|
+
NonMemoizedApiaApiButtonsContainer
|
|
1173
|
+
);
|
|
1174
|
+
|
|
1175
|
+
var __defProp = Object.defineProperty;
|
|
1176
|
+
var __defProps = Object.defineProperties;
|
|
1177
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1178
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1179
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1180
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1181
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1182
|
+
var __spreadValues = (a, b) => {
|
|
1183
|
+
for (var prop in b || (b = {}))
|
|
1184
|
+
if (__hasOwnProp.call(b, prop))
|
|
1185
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1186
|
+
if (__getOwnPropSymbols)
|
|
1187
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
1188
|
+
if (__propIsEnum.call(b, prop))
|
|
1189
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1190
|
+
}
|
|
1191
|
+
return a;
|
|
1192
|
+
};
|
|
1193
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1194
|
+
var __objRest = (source, exclude) => {
|
|
1195
|
+
var target = {};
|
|
1196
|
+
for (var prop in source)
|
|
1197
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1198
|
+
target[prop] = source[prop];
|
|
1199
|
+
if (source != null && __getOwnPropSymbols)
|
|
1200
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
1201
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
1202
|
+
target[prop] = source[prop];
|
|
1203
|
+
}
|
|
1204
|
+
return target;
|
|
1205
|
+
};
|
|
1206
|
+
var __async = (__this, __arguments, generator) => {
|
|
1207
|
+
return new Promise((resolve, reject) => {
|
|
1208
|
+
var fulfilled = (value) => {
|
|
1209
|
+
try {
|
|
1210
|
+
step(generator.next(value));
|
|
1211
|
+
} catch (e) {
|
|
1212
|
+
reject(e);
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
var rejected = (value) => {
|
|
1216
|
+
try {
|
|
1217
|
+
step(generator.throw(value));
|
|
1218
|
+
} catch (e) {
|
|
1219
|
+
reject(e);
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1223
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1224
|
+
});
|
|
1225
|
+
};
|
|
1226
|
+
const ApiaApiMessenger = new class extends EventEmitter {
|
|
1227
|
+
}();
|
|
1228
|
+
const FunctionsDispatcher = new class extends EventEmitter {
|
|
1229
|
+
}();
|
|
1230
|
+
const apiaApiForm = "ApiaApiForm";
|
|
1231
|
+
const methods = {};
|
|
1232
|
+
function getFunction(name, handler) {
|
|
1233
|
+
return __async(this, null, function* () {
|
|
1234
|
+
return new Promise((resolve) => {
|
|
1235
|
+
var _a, _b, _c;
|
|
1236
|
+
try {
|
|
1237
|
+
const separateNameFromParametersRegex = /^\/?([\w\d_-]+)\/?(?:\(([^)]*)\))?$/;
|
|
1238
|
+
const match = name.match(separateNameFromParametersRegex);
|
|
1239
|
+
if (match) {
|
|
1240
|
+
const functionName = match[1];
|
|
1241
|
+
const parameters = match[2];
|
|
1242
|
+
const path = [
|
|
1243
|
+
...(_c = (_b = (_a = handler.configuration) == null ? void 0 : _a.methodsPath) == null ? void 0 : _b.split("/").filter((current) => {
|
|
1244
|
+
return !!current;
|
|
1245
|
+
})) != null ? _c : [],
|
|
1246
|
+
functionName
|
|
1247
|
+
].join("/");
|
|
1248
|
+
const storeMethodAndResolve = (result) => {
|
|
1249
|
+
if (typeof result.default !== "function")
|
|
1250
|
+
notFound();
|
|
1251
|
+
const method = result.default;
|
|
1252
|
+
methods[functionName] = (props) => {
|
|
1253
|
+
var _a2;
|
|
1254
|
+
return method(handler, __spreadProps(__spreadValues({}, props), {
|
|
1255
|
+
inlineArguments: (_a2 = parameters == null ? void 0 : parameters.split(",").map((argument) => {
|
|
1256
|
+
if (argument.startsWith("'") || argument.startsWith('"'))
|
|
1257
|
+
return argument.slice(1, argument.length - 1);
|
|
1258
|
+
return argument;
|
|
1259
|
+
})) != null ? _a2 : []
|
|
1260
|
+
}));
|
|
1261
|
+
};
|
|
1262
|
+
resolve(methods[functionName]);
|
|
1263
|
+
};
|
|
1264
|
+
const notFound = () => {
|
|
1265
|
+
throw new Error(
|
|
1266
|
+
`${functionName}.ts not found at ${path}.ts nor ./${functionName}.ts`
|
|
1267
|
+
);
|
|
1268
|
+
};
|
|
1269
|
+
import(
|
|
1270
|
+
/* webpackChunkName: "api-methods-[request]" */
|
|
1271
|
+
`/api/methods/${path}.ts`
|
|
1272
|
+
).then(storeMethodAndResolve).catch(() => {
|
|
1273
|
+
var _a2;
|
|
1274
|
+
if (((_a2 = handler.configuration) == null ? void 0 : _a2.methodsPath) !== void 0)
|
|
1275
|
+
import(
|
|
1276
|
+
/* webpackChunkName: "api-methods-[request]" */
|
|
1277
|
+
`/api/methods/${functionName}.ts`
|
|
1278
|
+
).then(storeMethodAndResolve).catch(notFound);
|
|
1279
|
+
else
|
|
1280
|
+
notFound();
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
} catch (e) {
|
|
1284
|
+
console.error(e);
|
|
1285
|
+
handler.reset();
|
|
1286
|
+
handler.setError({
|
|
1287
|
+
type: "danger",
|
|
1288
|
+
message: "Error while loading current method."
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
function isForm(responseObject) {
|
|
1295
|
+
return typeof responseObject.canClose === "boolean" && typeof responseObject.type === "string" && !!responseObject.form;
|
|
1296
|
+
}
|
|
1297
|
+
function isFunction(responseObject) {
|
|
1298
|
+
return typeof responseObject.canClose === "boolean" && typeof responseObject.type === "string" && !!responseObject.function;
|
|
1299
|
+
}
|
|
1300
|
+
function isMessage(responseObject) {
|
|
1301
|
+
if (typeof responseObject.canClose === "boolean" && typeof responseObject.type === "string" && typeof responseObject.text === "object" && responseObject.text && typeof responseObject.text.label === "string") {
|
|
1302
|
+
return true;
|
|
1303
|
+
}
|
|
1304
|
+
return false;
|
|
1305
|
+
}
|
|
1306
|
+
const modalConfigurationHandler = new WithEventsValue();
|
|
1307
|
+
function useModalConfiguration() {
|
|
1308
|
+
const [, setValue, value] = useStateRef(
|
|
1309
|
+
void 0
|
|
1310
|
+
);
|
|
1311
|
+
const handleChange = React.useCallback(
|
|
1312
|
+
(newEventsHandler) => {
|
|
1313
|
+
setValue(newEventsHandler);
|
|
1314
|
+
},
|
|
1315
|
+
[setValue]
|
|
1316
|
+
);
|
|
1317
|
+
useMount(() => {
|
|
1318
|
+
modalConfigurationHandler.on("update", handleChange);
|
|
1319
|
+
});
|
|
1320
|
+
useUnmount(() => {
|
|
1321
|
+
return modalConfigurationHandler.off("update", handleChange);
|
|
1322
|
+
});
|
|
1323
|
+
return value;
|
|
1324
|
+
}
|
|
1325
|
+
const currentFormDispatcher = new class currentFormDispatcher2 extends EventEmitter {
|
|
1326
|
+
emit(eventName, params) {
|
|
1327
|
+
super.emit(eventName, params);
|
|
1328
|
+
}
|
|
1329
|
+
}();
|
|
1330
|
+
function handle(responseObject, currentUrl, configuration) {
|
|
1331
|
+
modalConfigurationHandler.value = configuration;
|
|
1332
|
+
if (isForm(responseObject)) {
|
|
1333
|
+
currentFormDispatcher.emit("form", responseObject);
|
|
1334
|
+
return true;
|
|
1335
|
+
}
|
|
1336
|
+
if (isFunction(responseObject)) {
|
|
1337
|
+
FunctionsDispatcher.emit("method", {
|
|
1338
|
+
name: responseObject.function.name,
|
|
1339
|
+
props: {
|
|
1340
|
+
messages: responseObject.function.messages,
|
|
1341
|
+
attributes: responseObject.function,
|
|
1342
|
+
currentUrl
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
return true;
|
|
1346
|
+
}
|
|
1347
|
+
if (isMessage(responseObject)) {
|
|
1348
|
+
ApiaApiMessenger.emit("message", {
|
|
1349
|
+
predicate: responseObject.text.content,
|
|
1350
|
+
title: responseObject.text.title
|
|
1351
|
+
});
|
|
1352
|
+
return true;
|
|
1353
|
+
}
|
|
1354
|
+
return false;
|
|
1355
|
+
}
|
|
1356
|
+
const initialState = {
|
|
1357
|
+
disabled: false,
|
|
1358
|
+
isLoading: false,
|
|
1359
|
+
isMultipart: false,
|
|
1360
|
+
progress: 0,
|
|
1361
|
+
errors: {}
|
|
1362
|
+
};
|
|
1363
|
+
const ApiaApiHandlerNonMemoized = () => {
|
|
1364
|
+
var _b, _c, _d;
|
|
1365
|
+
const configuration = useModalConfiguration();
|
|
1366
|
+
const [state, setState] = React.useState(__spreadProps(__spreadValues({}, initialState), {
|
|
1367
|
+
windowIndex: -1
|
|
1368
|
+
}));
|
|
1369
|
+
const [currentForm2, setCurrentForm] = React.useState(
|
|
1370
|
+
void 0
|
|
1371
|
+
);
|
|
1372
|
+
React.useEffect(() => {
|
|
1373
|
+
return currentFormDispatcher.on("form", setCurrentForm);
|
|
1374
|
+
}, []);
|
|
1375
|
+
const setValue = React.useCallback((name, value) => {
|
|
1376
|
+
return validationsStore.setFieldValue(apiaApiForm, name, value);
|
|
1377
|
+
}, []);
|
|
1378
|
+
React.useEffect(() => {
|
|
1379
|
+
var _a2, _b2, _c2;
|
|
1380
|
+
if (!currentForm2)
|
|
1381
|
+
return;
|
|
1382
|
+
const elements = arrayOrArray((_c2 = (_b2 = (_a2 = currentForm2 == null ? void 0 : currentForm2.form) == null ? void 0 : _a2.elements) == null ? void 0 : _b2.element) != null ? _c2 : []);
|
|
1383
|
+
let isMultipart = false;
|
|
1384
|
+
const elementsValues = Object.values(elements);
|
|
1385
|
+
let i = 0;
|
|
1386
|
+
while (i < elementsValues.length && !isMultipart) {
|
|
1387
|
+
if (elementsValues[i++].type === "file") {
|
|
1388
|
+
isMultipart = true;
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
setState((currentState) => {
|
|
1392
|
+
return __spreadProps(__spreadValues(__spreadValues({}, currentState), initialState), {
|
|
1393
|
+
isMultipart
|
|
1394
|
+
});
|
|
1395
|
+
});
|
|
1396
|
+
}, [currentForm2]);
|
|
1397
|
+
const _a = useModal(), { show, onClose } = _a, modalProps = __objRest(_a, ["show", "onClose"]);
|
|
1398
|
+
const close = React.useCallback(() => {
|
|
1399
|
+
var _a2, _b2;
|
|
1400
|
+
onClose();
|
|
1401
|
+
currentFormDispatcher.emit("form", void 0);
|
|
1402
|
+
setState((currentState) => {
|
|
1403
|
+
return __spreadValues(__spreadValues({}, currentState), initialState);
|
|
1404
|
+
});
|
|
1405
|
+
if ((_b2 = (_a2 = configuration.current) == null ? void 0 : _a2.modalConfiguration) == null ? void 0 : _b2.onClose)
|
|
1406
|
+
configuration.current.modalConfiguration.onClose();
|
|
1407
|
+
validationsStore.unregisterForm(apiaApiForm);
|
|
1408
|
+
}, [onClose, configuration]);
|
|
1409
|
+
const modalRef = React.useRef(null);
|
|
1410
|
+
React.useEffect(() => {
|
|
1411
|
+
var _a2;
|
|
1412
|
+
const elements = (_a2 = modalRef.current) == null ? void 0 : _a2.querySelectorAll(
|
|
1413
|
+
"a,input,textarea,button"
|
|
1414
|
+
);
|
|
1415
|
+
if ((elements == null ? void 0 : elements.length) === 1)
|
|
1416
|
+
void focus.on([...elements][0]);
|
|
1417
|
+
});
|
|
1418
|
+
const setError = React.useCallback(
|
|
1419
|
+
(notification) => {
|
|
1420
|
+
notify(__spreadValues({}, notification));
|
|
1421
|
+
},
|
|
1422
|
+
[]
|
|
1423
|
+
);
|
|
1424
|
+
const getHandler = React.useCallback(() => {
|
|
1425
|
+
const newHandler = {
|
|
1426
|
+
alert,
|
|
1427
|
+
close,
|
|
1428
|
+
configuration: configuration.current,
|
|
1429
|
+
formDefinition: currentForm2,
|
|
1430
|
+
reset: () => {
|
|
1431
|
+
return setState((currentState) => {
|
|
1432
|
+
return __spreadValues(__spreadValues({}, currentState), initialState);
|
|
1433
|
+
});
|
|
1434
|
+
},
|
|
1435
|
+
setError,
|
|
1436
|
+
setMessage: (message) => {
|
|
1437
|
+
var _a2, _b2;
|
|
1438
|
+
if ((_b2 = (_a2 = configuration.current) == null ? void 0 : _a2.modalConfiguration) == null ? void 0 : _b2.onMessage)
|
|
1439
|
+
configuration.current.modalConfiguration.onMessage(message);
|
|
1440
|
+
},
|
|
1441
|
+
setState,
|
|
1442
|
+
state,
|
|
1443
|
+
setValue
|
|
1444
|
+
};
|
|
1445
|
+
return newHandler;
|
|
1446
|
+
}, [close, configuration, currentForm2, setError, state, setValue]);
|
|
1447
|
+
React.useEffect(() => {
|
|
1448
|
+
const handleFunction = (_0) => __async(void 0, [_0], function* ({
|
|
1449
|
+
name,
|
|
1450
|
+
props: { messages, attributes, currentUrl }
|
|
1451
|
+
}) {
|
|
1452
|
+
const method = yield getFunction(`${name}`, getHandler());
|
|
1453
|
+
if (method) {
|
|
1454
|
+
method({ messages, attributes, currentUrl });
|
|
1455
|
+
}
|
|
1456
|
+
});
|
|
1457
|
+
const handleMessage = (ev) => {
|
|
1458
|
+
var _a2, _b2, _c2, _d2;
|
|
1459
|
+
const handler2 = getHandler();
|
|
1460
|
+
notify({
|
|
1461
|
+
message: ev.predicate,
|
|
1462
|
+
type: "warning",
|
|
1463
|
+
onClose: (_b2 = (_a2 = handler2.configuration) == null ? void 0 : _a2.modalConfiguration) == null ? void 0 : _b2.onMessageClose
|
|
1464
|
+
});
|
|
1465
|
+
const onMessage = (_d2 = (_c2 = handler2.configuration) == null ? void 0 : _c2.modalConfiguration) == null ? void 0 : _d2.onMessage;
|
|
1466
|
+
if (onMessage)
|
|
1467
|
+
onMessage(ev);
|
|
1468
|
+
};
|
|
1469
|
+
const handleAction = (action) => __async(void 0, null, function* () {
|
|
1470
|
+
if (action.toDo === "ajaxHiddeAll") {
|
|
1471
|
+
close();
|
|
1472
|
+
}
|
|
1473
|
+
if (action.toDo === "functionTimedCall") {
|
|
1474
|
+
const method = yield getFunction(
|
|
1475
|
+
arrayOrArray(action.param)[1],
|
|
1476
|
+
getHandler()
|
|
1477
|
+
);
|
|
1478
|
+
if (method)
|
|
1479
|
+
setTimeout(() => {
|
|
1480
|
+
var _a2;
|
|
1481
|
+
return method({
|
|
1482
|
+
currentUrl: (_a2 = currentForm2 == null ? void 0 : currentForm2.form.action) != null ? _a2 : "noUrl"
|
|
1483
|
+
});
|
|
1484
|
+
}, Number(action.param[0]));
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
ApiaApiMessenger.on("message", handleMessage);
|
|
1488
|
+
FunctionsDispatcher.on("method", handleFunction);
|
|
1489
|
+
ApiaActions.on("action", handleAction);
|
|
1490
|
+
return () => {
|
|
1491
|
+
ApiaApiMessenger.off("message", handleMessage);
|
|
1492
|
+
FunctionsDispatcher.off("method", handleFunction);
|
|
1493
|
+
ApiaActions.off("action", handleAction);
|
|
1494
|
+
};
|
|
1495
|
+
}, [state.windowIndex, onClose, close]);
|
|
1496
|
+
React.useEffect(() => {
|
|
1497
|
+
if (currentForm2) {
|
|
1498
|
+
show();
|
|
1499
|
+
}
|
|
1500
|
+
}, [currentForm2]);
|
|
1501
|
+
const handler = getHandler();
|
|
1502
|
+
const formRef = React.useCallback(
|
|
1503
|
+
(el) => __async(void 0, null, function* () {
|
|
1504
|
+
if (el && (currentForm2 == null ? void 0 : currentForm2.form.onLoad)) {
|
|
1505
|
+
const method = yield getFunction(
|
|
1506
|
+
`${currentForm2 == null ? void 0 : currentForm2.form.onLoad}`,
|
|
1507
|
+
getHandler()
|
|
1508
|
+
);
|
|
1509
|
+
if (method) {
|
|
1510
|
+
method();
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
}),
|
|
1514
|
+
[currentForm2 == null ? void 0 : currentForm2.form.onLoad, getHandler]
|
|
1515
|
+
);
|
|
1516
|
+
return /* @__PURE__ */ jsx(ApiaApiContext$1, { id: apiaApiForm, children: /* @__PURE__ */ jsx(
|
|
1517
|
+
Modal,
|
|
1518
|
+
__spreadProps(__spreadValues({
|
|
1519
|
+
ref: modalRef,
|
|
1520
|
+
onClose: close,
|
|
1521
|
+
id: apiaApiForm,
|
|
1522
|
+
title: (_d = (_c = (_b = configuration.current) == null ? void 0 : _b.modalConfiguration) == null ? void 0 : _c.modalTitle) != null ? _d : currentForm2 == null ? void 0 : currentForm2.form.title,
|
|
1523
|
+
size: "md-fixed",
|
|
1524
|
+
shouldCloseOnEsc: !state.disabled,
|
|
1525
|
+
shouldCloseOnOverlayClick: !state.disabled,
|
|
1526
|
+
initialFocusGetter: React.useCallback((ref) => {
|
|
1527
|
+
return ref == null ? void 0 : ref.querySelector(focusSelector);
|
|
1528
|
+
}, [])
|
|
1529
|
+
}, modalProps), {
|
|
1530
|
+
children: currentForm2 && /* @__PURE__ */ jsx(Box, __spreadProps(__spreadValues({}, getVariant("layout.common.modals.apiaApi")), { children: /* @__PURE__ */ jsxs(
|
|
1531
|
+
Form,
|
|
1532
|
+
{
|
|
1533
|
+
name: apiaApiForm,
|
|
1534
|
+
avoidFieldsOverride: true,
|
|
1535
|
+
className: "handler__form",
|
|
1536
|
+
children: [
|
|
1537
|
+
/* @__PURE__ */ jsx(ApiaApiFieldsContainer, __spreadValues({ definition: currentForm2 }, handler)),
|
|
1538
|
+
state.isMultipart && state.progress > 0 && /* @__PURE__ */ jsx(Box, { className: "progressBox", children: /* @__PURE__ */ jsx(
|
|
1539
|
+
ProgressBar,
|
|
1540
|
+
{
|
|
1541
|
+
id: "ApiaApiHandler progress",
|
|
1542
|
+
progress: state.progress,
|
|
1543
|
+
loading: true
|
|
1544
|
+
}
|
|
1545
|
+
) }),
|
|
1546
|
+
/* @__PURE__ */ jsx(Box, { ref: formRef }),
|
|
1547
|
+
/* @__PURE__ */ jsx(ApiaApiButtonsContainer, __spreadValues({ definition: currentForm2 }, handler))
|
|
1548
|
+
]
|
|
1549
|
+
}
|
|
1550
|
+
) }))
|
|
1551
|
+
})
|
|
1552
|
+
) });
|
|
1553
|
+
};
|
|
1554
|
+
const ApiaApiHandler = React.memo(ApiaApiHandlerNonMemoized);
|
|
1555
|
+
|
|
1556
|
+
export { ApiaApi, ApiaApiHandler, makeApiaUrl };
|
|
1557
|
+
//# sourceMappingURL=index.js.map
|