@dashx/react 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,247 @@
1
+ (function(ee,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],M):(ee=typeof globalThis<"u"?globalThis:ee||self,M(ee["ui-library"]={},ee.React))})(this,function(ee,M){"use strict";function ft(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function lt(s){if(s.__esModule)return s;var o=s.default;if(typeof o=="function"){var r=function t(){return this instanceof t?Reflect.construct(o,arguments,this.constructor):o.apply(this,arguments)};r.prototype=o.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(s).forEach(function(t){var a=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:function(){return s[t]}})}),r}var Re={exports:{}},fe={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Fe;function dt(){if(Fe)return fe;Fe=1;var s=M,o=Symbol.for("react.element"),r=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,a=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function p(c,f,n){var m,b={},E=null,O=null;n!==void 0&&(E=""+n),f.key!==void 0&&(E=""+f.key),f.ref!==void 0&&(O=f.ref);for(m in f)t.call(f,m)&&!d.hasOwnProperty(m)&&(b[m]=f[m]);if(c&&c.defaultProps)for(m in f=c.defaultProps,f)b[m]===void 0&&(b[m]=f[m]);return{$$typeof:o,type:c,key:E,ref:O,props:b,_owner:a.current}}return fe.Fragment=r,fe.jsx=p,fe.jsxs=p,fe}var le={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Me;function pt(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&function(){var s=M,o=Symbol.for("react.element"),r=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),p=Symbol.for("react.provider"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),n=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),Z=Symbol.iterator,G="@@iterator";function Q(e){if(e===null||typeof e!="object")return null;var u=Z&&e[Z]||e[G];return typeof u=="function"?u:null}var q=s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function j(e){{for(var u=arguments.length,h=new Array(u>1?u-1:0),w=1;w<u;w++)h[w-1]=arguments[w];te("error",e,h)}}function te(e,u,h){{var w=q.ReactDebugCurrentFrame,P=w.getStackAddendum();P!==""&&(u+="%s",h=h.concat([P]));var A=h.map(function(R){return String(R)});A.unshift("Warning: "+u),Function.prototype.apply.call(console[e],console,A)}}var pe=!1,K=!1,ie=!1,ne=!1,re=!1,ae;ae=Symbol.for("react.module.reference");function l(e){return!!(typeof e=="string"||typeof e=="function"||e===t||e===d||re||e===a||e===n||e===m||ne||e===O||pe||K||ie||typeof e=="object"&&e!==null&&(e.$$typeof===E||e.$$typeof===b||e.$$typeof===p||e.$$typeof===c||e.$$typeof===f||e.$$typeof===ae||e.getModuleId!==void 0))}function i(e,u,h){var w=e.displayName;if(w)return w;var P=u.displayName||u.name||"";return P!==""?h+"("+P+")":h}function y(e){return e.displayName||"Context"}function g(e){if(e==null)return null;if(typeof e.tag=="number"&&j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case t:return"Fragment";case r:return"Portal";case d:return"Profiler";case a:return"StrictMode";case n:return"Suspense";case m:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case c:var u=e;return y(u)+".Consumer";case p:var h=e;return y(h._context)+".Provider";case f:return i(e,e.render,"ForwardRef");case b:var w=e.displayName||null;return w!==null?w:g(e.type)||"Memo";case E:{var P=e,A=P._payload,R=P._init;try{return g(R(A))}catch{return null}}}return null}var v=Object.assign,I=0,L,W,J,T,F,X,he;function ve(){}ve.__reactDisabledLog=!0;function me(){{if(I===0){L=console.log,W=console.info,J=console.warn,T=console.error,F=console.group,X=console.groupCollapsed,he=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}}function oe(){{if(I--,I===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:v({},e,{value:L}),info:v({},e,{value:W}),warn:v({},e,{value:J}),error:v({},e,{value:T}),group:v({},e,{value:F}),groupCollapsed:v({},e,{value:X}),groupEnd:v({},e,{value:he})})}I<0&&j("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Oe=q.ReactCurrentDispatcher,je;function we(e,u,h){{if(je===void 0)try{throw Error()}catch(P){var w=P.stack.trim().match(/\n( *(at )?)/);je=w&&w[1]||""}return`
18
+ `+je+e}}var Ie=!1,be;{var pr=typeof WeakMap=="function"?WeakMap:Map;be=new pr}function Je(e,u){if(!e||Ie)return"";{var h=be.get(e);if(h!==void 0)return h}var w;Ie=!0;var P=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var A;A=Oe.current,Oe.current=null,me();try{if(u){var R=function(){throw Error()};if(Object.defineProperty(R.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(R,[])}catch(Y){w=Y}Reflect.construct(e,[],R)}else{try{R.call()}catch(Y){w=Y}e.call(R.prototype)}}else{try{throw Error()}catch(Y){w=Y}e()}}catch(Y){if(Y&&w&&typeof Y.stack=="string"){for(var C=Y.stack.split(`
19
+ `),H=w.stack.split(`
20
+ `),$=C.length-1,x=H.length-1;$>=1&&x>=0&&C[$]!==H[x];)x--;for(;$>=1&&x>=0;$--,x--)if(C[$]!==H[x]){if($!==1||x!==1)do if($--,x--,x<0||C[$]!==H[x]){var z=`
21
+ `+C[$].replace(" at new "," at ");return e.displayName&&z.includes("<anonymous>")&&(z=z.replace("<anonymous>",e.displayName)),typeof e=="function"&&be.set(e,z),z}while($>=1&&x>=0);break}}}finally{Ie=!1,Oe.current=A,oe(),Error.prepareStackTrace=P}var ce=e?e.displayName||e.name:"",ue=ce?we(ce):"";return typeof e=="function"&&be.set(e,ue),ue}function hr(e,u,h){return Je(e,!1)}function vr(e){var u=e.prototype;return!!(u&&u.isReactComponent)}function Ce(e,u,h){if(e==null)return"";if(typeof e=="function")return Je(e,vr(e));if(typeof e=="string")return we(e);switch(e){case n:return we("Suspense");case m:return we("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return hr(e.render);case b:return Ce(e.type,u,h);case E:{var w=e,P=w._payload,A=w._init;try{return Ce(A(P),u,h)}catch{}}}return""}var ye=Object.prototype.hasOwnProperty,ze={},Ze=q.ReactDebugCurrentFrame;function Ee(e){if(e){var u=e._owner,h=Ce(e.type,e._source,u?u.type:null);Ze.setExtraStackFrame(h)}else Ze.setExtraStackFrame(null)}function mr(e,u,h,w,P){{var A=Function.call.bind(ye);for(var R in e)if(A(e,R)){var C=void 0;try{if(typeof e[R]!="function"){var H=Error((w||"React class")+": "+h+" type `"+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[R]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw H.name="Invariant Violation",H}C=e[R](u,R,w,h,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch($){C=$}C&&!(C instanceof Error)&&(Ee(P),j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",w||"React class",h,R,typeof C),Ee(null)),C instanceof Error&&!(C.message in ze)&&(ze[C.message]=!0,Ee(P),j("Failed %s type: %s",h,C.message),Ee(null))}}}var yr=Array.isArray;function $e(e){return yr(e)}function gr(e){{var u=typeof Symbol=="function"&&Symbol.toStringTag,h=u&&e[Symbol.toStringTag]||e.constructor.name||"Object";return h}}function wr(e){try{return Qe(e),!1}catch{return!0}}function Qe(e){return""+e}function et(e){if(wr(e))return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",gr(e)),Qe(e)}var ge=q.ReactCurrentOwner,br={key:!0,ref:!0,__self:!0,__source:!0},tt,rt,xe;xe={};function Cr(e){if(ye.call(e,"ref")){var u=Object.getOwnPropertyDescriptor(e,"ref").get;if(u&&u.isReactWarning)return!1}return e.ref!==void 0}function Er(e){if(ye.call(e,"key")){var u=Object.getOwnPropertyDescriptor(e,"key").get;if(u&&u.isReactWarning)return!1}return e.key!==void 0}function Rr(e,u){if(typeof e.ref=="string"&&ge.current&&u&&ge.current.stateNode!==u){var h=g(ge.current.type);xe[h]||(j('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',g(ge.current.type),e.ref),xe[h]=!0)}}function _r(e,u){{var h=function(){tt||(tt=!0,j("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};h.isReactWarning=!0,Object.defineProperty(e,"key",{get:h,configurable:!0})}}function Tr(e,u){{var h=function(){rt||(rt=!0,j("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",u))};h.isReactWarning=!0,Object.defineProperty(e,"ref",{get:h,configurable:!0})}}var Pr=function(e,u,h,w,P,A,R){var C={$$typeof:o,type:e,key:u,ref:h,props:R,_owner:A};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:P}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function Sr(e,u,h,w,P){{var A,R={},C=null,H=null;h!==void 0&&(et(h),C=""+h),Er(u)&&(et(u.key),C=""+u.key),Cr(u)&&(H=u.ref,Rr(u,P));for(A in u)ye.call(u,A)&&!br.hasOwnProperty(A)&&(R[A]=u[A]);if(e&&e.defaultProps){var $=e.defaultProps;for(A in $)R[A]===void 0&&(R[A]=$[A])}if(C||H){var x=typeof e=="function"?e.displayName||e.name||"Unknown":e;C&&_r(R,x),H&&Tr(R,x)}return Pr(e,C,H,P,w,ge.current,R)}}var Ue=q.ReactCurrentOwner,nt=q.ReactDebugCurrentFrame;function se(e){if(e){var u=e._owner,h=Ce(e.type,e._source,u?u.type:null);nt.setExtraStackFrame(h)}else nt.setExtraStackFrame(null)}var De;De=!1;function Le(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function at(){{if(Ue.current){var e=g(Ue.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function kr(e){return""}var it={};function Ar(e){{var u=at();if(!u){var h=typeof e=="string"?e:e.displayName||e.name;h&&(u=`
24
+
25
+ Check the top-level render call using <`+h+">.")}return u}}function ot(e,u){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var h=Ar(u);if(it[h])return;it[h]=!0;var w="";e&&e._owner&&e._owner!==Ue.current&&(w=" It was passed a child from "+g(e._owner.type)+"."),se(e),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',h,w),se(null)}}function ut(e,u){{if(typeof e!="object")return;if($e(e))for(var h=0;h<e.length;h++){var w=e[h];Le(w)&&ot(w,u)}else if(Le(e))e._store&&(e._store.validated=!0);else if(e){var P=Q(e);if(typeof P=="function"&&P!==e.entries)for(var A=P.call(e),R;!(R=A.next()).done;)Le(R.value)&&ot(R.value,u)}}}function Or(e){{var u=e.type;if(u==null||typeof u=="string")return;var h;if(typeof u=="function")h=u.propTypes;else if(typeof u=="object"&&(u.$$typeof===f||u.$$typeof===b))h=u.propTypes;else return;if(h){var w=g(u);mr(h,e.props,"prop",w,e)}else if(u.PropTypes!==void 0&&!De){De=!0;var P=g(u);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",P||"Unknown")}typeof u.getDefaultProps=="function"&&!u.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function jr(e){{for(var u=Object.keys(e.props),h=0;h<u.length;h++){var w=u[h];if(w!=="children"&&w!=="key"){se(e),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",w),se(null);break}}e.ref!==null&&(se(e),j("Invalid attribute `ref` supplied to `React.Fragment`."),se(null))}}var st={};function ct(e,u,h,w,P,A){{var R=l(e);if(!R){var C="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var H=kr();H?C+=H:C+=at();var $;e===null?$="null":$e(e)?$="array":e!==void 0&&e.$$typeof===o?($="<"+(g(e.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):$=typeof e,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",$,C)}var x=Sr(e,u,h,P,A);if(x==null)return x;if(R){var z=u.children;if(z!==void 0)if(w)if($e(z)){for(var ce=0;ce<z.length;ce++)ut(z[ce],e);Object.freeze&&Object.freeze(z)}else j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ut(z,e)}if(ye.call(u,"key")){var ue=g(e),Y=Object.keys(u).filter(function(Lr){return Lr!=="key"}),qe=Y.length>0?"{key: someKey, "+Y.join(": ..., ")+": ...}":"{key: someKey}";if(!st[ue+qe]){var Dr=Y.length>0?"{"+Y.join(": ..., ")+": ...}":"{}";j(`A props object containing a "key" prop is being spread into JSX:
26
+ let props = %s;
27
+ <%s {...props} />
28
+ React keys must be passed directly to JSX without using spread:
29
+ let props = %s;
30
+ <%s key={someKey} {...props} />`,qe,ue,Dr,ue),st[ue+qe]=!0}}return e===t?jr(x):Or(x),x}}function Ir(e,u,h){return ct(e,u,h,!0)}function $r(e,u,h){return ct(e,u,h,!1)}var xr=$r,Ur=Ir;le.Fragment=t,le.jsx=xr,le.jsxs=Ur}()),le}process.env.NODE_ENV==="production"?Re.exports=dt():Re.exports=pt();var U=Re.exports;function Be(s,o){return o=o||{},new Promise(function(r,t){var a=new XMLHttpRequest,d=[],p=[],c={},f=function(){return{ok:(a.status/100|0)==2,statusText:a.statusText,status:a.status,url:a.responseURL,text:function(){return Promise.resolve(a.responseText)},json:function(){return Promise.resolve(a.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([a.response]))},clone:f,headers:{keys:function(){return d},entries:function(){return p},get:function(m){return c[m.toLowerCase()]},has:function(m){return m.toLowerCase()in c}}}};for(var n in a.open(o.method||"get",s,!0),a.onload=function(){a.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(m,b,E){d.push(b=b.toLowerCase()),p.push([b,E]),c[b]=c[b]?c[b]+","+E:E}),r(f())},a.onerror=t,a.withCredentials=o.credentials=="include",o.headers)a.setRequestHeader(n,o.headers[n]);a.send(o.body||null)})}function ht(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ne={exports:{}};const vt=lt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(s){(function(){var o,r=0,t=[],a;for(a=0;a<256;a++)t[a]=(a+256).toString(16).substr(1);f.BUFFER_SIZE=4096,f.bin=c,f.clearBuffer=function(){o=null,r=0},f.test=function(n){return typeof n=="string"?/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n):!1};var d;typeof crypto<"u"?d=crypto:typeof window<"u"&&typeof window.msCrypto<"u"&&(d=window.msCrypto),typeof ht=="function"?(d=d||vt,s.exports=f):typeof window<"u"&&(window.uuid=f),f.randomBytes=function(){if(d){if(d.randomBytes)return d.randomBytes;if(d.getRandomValues)return typeof Uint8Array.prototype.slice!="function"?function(n){var m=new Uint8Array(n);return d.getRandomValues(m),Array.from(m)}:function(n){var m=new Uint8Array(n);return d.getRandomValues(m),m}}return function(n){var m,b=[];for(m=0;m<n;m++)b.push(Math.floor(Math.random()*256));return b}}();function p(n){return(!o||r+n>f.BUFFER_SIZE)&&(r=0,o=f.randomBytes(f.BUFFER_SIZE)),o.slice(r,r+=n)}function c(){var n=p(16);return n[6]=n[6]&15|64,n[8]=n[8]&63|128,n}function f(){var n=c();return t[n[0]]+t[n[1]]+t[n[2]]+t[n[3]]+"-"+t[n[4]]+t[n[5]]+"-"+t[n[6]]+t[n[7]]+"-"+t[n[8]]+t[n[9]]+"-"+t[n[10]]+t[n[11]]+t[n[12]]+t[n[13]]+t[n[14]]+t[n[15]]}})()})(Ne);var mt=Ne.exports;const _e=ft(mt);function _(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_=function(){return s};var s={},o=Object.prototype,r=o.hasOwnProperty,t=typeof Symbol=="function"?Symbol:{},a=t.iterator||"@@iterator",d=t.asyncIterator||"@@asyncIterator",p=t.toStringTag||"@@toStringTag";function c(l,i,y){return Object.defineProperty(l,i,{value:y,enumerable:!0,configurable:!0,writable:!0}),l[i]}try{c({},"")}catch{c=function(i,y,g){return i[y]=g}}function f(l,i,y,g){var v=i&&i.prototype instanceof b?i:b,I=Object.create(v.prototype),L=new ne(g||[]);return I._invoke=function(W,J,T){var F="suspendedStart";return function(X,he){if(F==="executing")throw new Error("Generator is already running");if(F==="completed"){if(X==="throw")throw he;return ae()}for(T.method=X,T.arg=he;;){var ve=T.delegate;if(ve){var me=pe(ve,T);if(me){if(me===m)continue;return me}}if(T.method==="next")T.sent=T._sent=T.arg;else if(T.method==="throw"){if(F==="suspendedStart")throw F="completed",T.arg;T.dispatchException(T.arg)}else T.method==="return"&&T.abrupt("return",T.arg);F="executing";var oe=n(W,J,T);if(oe.type==="normal"){if(F=T.done?"completed":"suspendedYield",oe.arg===m)continue;return{value:oe.arg,done:T.done}}oe.type==="throw"&&(F="completed",T.method="throw",T.arg=oe.arg)}}}(l,y,L),I}function n(l,i,y){try{return{type:"normal",arg:l.call(i,y)}}catch(g){return{type:"throw",arg:g}}}s.wrap=f;var m={};function b(){}function E(){}function O(){}var Z={};c(Z,a,function(){return this});var G=Object.getPrototypeOf,Q=G&&G(G(re([])));Q&&Q!==o&&r.call(Q,a)&&(Z=Q);var q=O.prototype=b.prototype=Object.create(Z);function j(l){["next","throw","return"].forEach(function(i){c(l,i,function(y){return this._invoke(i,y)})})}function te(l,i){function y(v,I,L,W){var J=n(l[v],l,I);if(J.type!=="throw"){var T=J.arg,F=T.value;return F&&typeof F=="object"&&r.call(F,"__await")?i.resolve(F.__await).then(function(X){y("next",X,L,W)},function(X){y("throw",X,L,W)}):i.resolve(F).then(function(X){T.value=X,L(T)},function(X){return y("throw",X,L,W)})}W(J.arg)}var g;this._invoke=function(v,I){function L(){return new i(function(W,J){y(v,I,W,J)})}return g=g?g.then(L,L):L()}}function pe(l,i){var y=l.iterator[i.method];if(y===void 0){if(i.delegate=null,i.method==="throw"){if(l.iterator.return&&(i.method="return",i.arg=void 0,pe(l,i),i.method==="throw"))return m;i.method="throw",i.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var g=n(y,l.iterator,i.arg);if(g.type==="throw")return i.method="throw",i.arg=g.arg,i.delegate=null,m;var v=g.arg;return v?v.done?(i[l.resultName]=v.value,i.next=l.nextLoc,i.method!=="return"&&(i.method="next",i.arg=void 0),i.delegate=null,m):v:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,m)}function K(l){var i={tryLoc:l[0]};1 in l&&(i.catchLoc=l[1]),2 in l&&(i.finallyLoc=l[2],i.afterLoc=l[3]),this.tryEntries.push(i)}function ie(l){var i=l.completion||{};i.type="normal",delete i.arg,l.completion=i}function ne(l){this.tryEntries=[{tryLoc:"root"}],l.forEach(K,this),this.reset(!0)}function re(l){if(l){var i=l[a];if(i)return i.call(l);if(typeof l.next=="function")return l;if(!isNaN(l.length)){var y=-1,g=function v(){for(;++y<l.length;)if(r.call(l,y))return v.value=l[y],v.done=!1,v;return v.value=void 0,v.done=!0,v};return g.next=g}}return{next:ae}}function ae(){return{value:void 0,done:!0}}return E.prototype=O,c(q,"constructor",O),c(O,"constructor",E),E.displayName=c(O,p,"GeneratorFunction"),s.isGeneratorFunction=function(l){var i=typeof l=="function"&&l.constructor;return!!i&&(i===E||(i.displayName||i.name)==="GeneratorFunction")},s.mark=function(l){return Object.setPrototypeOf?Object.setPrototypeOf(l,O):(l.__proto__=O,c(l,p,"GeneratorFunction")),l.prototype=Object.create(q),l},s.awrap=function(l){return{__await:l}},j(te.prototype),c(te.prototype,d,function(){return this}),s.AsyncIterator=te,s.async=function(l,i,y,g,v){v===void 0&&(v=Promise);var I=new te(f(l,i,y,g),v);return s.isGeneratorFunction(i)?I:I.next().then(function(L){return L.done?L.value:I.next()})},j(q),c(q,p,"Generator"),c(q,a,function(){return this}),c(q,"toString",function(){return"[object Generator]"}),s.keys=function(l){var i=[];for(var y in l)i.push(y);return i.reverse(),function g(){for(;i.length;){var v=i.pop();if(v in l)return g.value=v,g.done=!1,g}return g.done=!0,g}},s.values=re,ne.prototype={constructor:ne,reset:function(l){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(ie),!l)for(var i in this)i.charAt(0)==="t"&&r.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=void 0)},stop:function(){this.done=!0;var l=this.tryEntries[0].completion;if(l.type==="throw")throw l.arg;return this.rval},dispatchException:function(l){if(this.done)throw l;var i=this;function y(J,T){return I.type="throw",I.arg=l,i.next=J,T&&(i.method="next",i.arg=void 0),!!T}for(var g=this.tryEntries.length-1;g>=0;--g){var v=this.tryEntries[g],I=v.completion;if(v.tryLoc==="root")return y("end");if(v.tryLoc<=this.prev){var L=r.call(v,"catchLoc"),W=r.call(v,"finallyLoc");if(L&&W){if(this.prev<v.catchLoc)return y(v.catchLoc,!0);if(this.prev<v.finallyLoc)return y(v.finallyLoc)}else if(L){if(this.prev<v.catchLoc)return y(v.catchLoc,!0)}else{if(!W)throw new Error("try statement without catch or finally");if(this.prev<v.finallyLoc)return y(v.finallyLoc)}}}},abrupt:function(l,i){for(var y=this.tryEntries.length-1;y>=0;--y){var g=this.tryEntries[y];if(g.tryLoc<=this.prev&&r.call(g,"finallyLoc")&&this.prev<g.finallyLoc){var v=g;break}}v&&(l==="break"||l==="continue")&&v.tryLoc<=i&&i<=v.finallyLoc&&(v=null);var I=v?v.completion:{};return I.type=l,I.arg=i,v?(this.method="next",this.next=v.finallyLoc,m):this.complete(I)},complete:function(l,i){if(l.type==="throw")throw l.arg;return l.type==="break"||l.type==="continue"?this.next=l.arg:l.type==="return"?(this.rval=this.arg=l.arg,this.method="return",this.next="end"):l.type==="normal"&&i&&(this.next=i),m},finish:function(l){for(var i=this.tryEntries.length-1;i>=0;--i){var y=this.tryEntries[i];if(y.finallyLoc===l)return this.complete(y.completion,y.afterLoc),ie(y),m}},catch:function(l){for(var i=this.tryEntries.length-1;i>=0;--i){var y=this.tryEntries[i];if(y.tryLoc===l){var g=y.completion;if(g.type==="throw"){var v=g.arg;ie(y)}return v}}throw new Error("illegal catch attempt")},delegateYield:function(l,i,y){return this.delegate={iterator:re(l),resultName:i,nextLoc:y},this.method==="next"&&(this.arg=void 0),m}},s}function He(s,o,r,t,a,d,p){try{var c=s[d](p),f=c.value}catch(n){r(n);return}c.done?o(f):Promise.resolve(f).then(t,a)}function B(s){return function(){var o=this,r=arguments;return new Promise(function(t,a){var d=s.apply(o,r);function p(f){He(d,t,a,p,c,"next",f)}function c(f){He(d,t,a,p,c,"throw",f)}p(void 0)})}}function yt(s,o){for(var r=0;r<o.length;r++){var t=o[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,t.key,t)}}function gt(s,o,r){return o&&yt(s.prototype,o),Object.defineProperty(s,"prototype",{writable:!1}),s}function N(){return N=Object.assign?Object.assign.bind():function(s){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(s[t]=r[t])}return s},N.apply(this,arguments)}function wt(s,o){if(s==null)return{};var r={},t=Object.keys(s),a,d;for(d=0;d<t.length;d++)a=t[d],!(o.indexOf(a)>=0)&&(r[a]=s[a]);return r}var bt=0;function Te(s){return"__private_"+bt+++"_"+s}function S(s,o){if(!Object.prototype.hasOwnProperty.call(s,o))throw new TypeError("attempted to use private field on non-instance");return s}var Ct=`
31
+ mutation TrackEvent($input: TrackEventInput!) {
32
+ trackEvent(input: $input) {
33
+ success
34
+ }
35
+ }
36
+ `,Et=`
37
+ mutation IdentifyAccount($input: IdentifyAccountInput!) {
38
+ identifyAccount(input: $input) {
39
+ id
40
+ }
41
+ }
42
+ `,Rt=`
43
+ mutation AddContent($input: AddContentInput!) {
44
+ addContent(input: $input) {
45
+ id
46
+ identifier
47
+ position
48
+ data
49
+ createdAt
50
+ updatedAt
51
+ }
52
+ }
53
+ `,_t=`
54
+ mutation EditContent($input: EditContentInput!) {
55
+ editContent(input: $input) {
56
+ id
57
+ identifier
58
+ position
59
+ data
60
+ createdAt
61
+ updatedAt
62
+ }
63
+ }
64
+ `,We=`
65
+ query SearchContent($input: SearchContentInput!) {
66
+ searchContent(input: $input)
67
+ }
68
+ `,Tt=`
69
+ query FetchContent($input: FetchContentInput!) {
70
+ fetchContent(input: $input)
71
+ }
72
+ `,Pt=`
73
+ id
74
+ name
75
+ identifier
76
+ description
77
+ createdAt
78
+ updatedAt
79
+ pricings {
80
+ id
81
+ kind
82
+ amount
83
+ originalAmount
84
+ isRecurring
85
+ recurringInterval
86
+ recurringIntervalUnit
87
+ appleProductIdentifier
88
+ googleProductIdentifier
89
+ currencyCode
90
+ createdAt
91
+ updatedAt
92
+ }
93
+ `,de=`
94
+ id
95
+ status
96
+ subtotal
97
+ discount
98
+ tax
99
+ total
100
+ gatewayMeta
101
+ currencyCode
102
+
103
+ orderItems {
104
+ id
105
+ quantity
106
+ unitPrice
107
+ subtotal
108
+ discount
109
+ tax
110
+ total
111
+ custom
112
+ currencyCode
113
+
114
+ item {
115
+ `+Pt+`
116
+ }
117
+ }
118
+
119
+ couponRedemptions {
120
+ coupon {
121
+ name
122
+ identifier
123
+ discountType
124
+ discountAmount
125
+ currencyCode
126
+ expiresAt
127
+ }
128
+ }
129
+ `,St=`
130
+ mutation AddItemToCart($input: AddItemToCartInput) {
131
+ addItemToCart(input:$input) {
132
+ `+de+`
133
+ }
134
+ }
135
+ `,kt=`
136
+ mutation ApplyCouponToCart($input: ApplyCouponToCartInput) {
137
+ applyCouponToCart(input:$input) {
138
+ `+de+`
139
+ }
140
+ }
141
+ `,At=`
142
+ mutation RemoveCouponFromCart($input: RemoveCouponFromCartInput) {
143
+ removeCouponFromCart(input:$input) {
144
+ `+de+`
145
+ }
146
+ }
147
+ `,Ot=`
148
+ query FetchCart($input: FetchCartInput!) {
149
+ fetchCart(input: $input) {
150
+ `+de+`
151
+ }
152
+ }
153
+ `,jt=`
154
+ mutation TransferCart($input: TransferCartInput!) {
155
+ transferCart(input: $input) {
156
+ `+de+`
157
+ }
158
+ }
159
+ `,It=`
160
+ query FetchStoredPreferences($input: FetchStoredPreferencesInput!) {
161
+ fetchStoredPreferences(input: $input) {
162
+ preferenceData
163
+ }
164
+ }
165
+ `,$t=`
166
+ mutation SaveStoredPreferences($input: SaveStoredPreferencesInput!) {
167
+ saveStoredPreferences(input: $input) {
168
+ success
169
+ }
170
+ }
171
+ `,xt=`
172
+ query FetchContacts($input: FetchContactsInput!) {
173
+ fetchContacts(input: $input) {
174
+ contacts {
175
+ id
176
+ accountId
177
+ name
178
+ kind
179
+ value
180
+ unverifiedValue
181
+ verifiedAt
182
+ status
183
+ tag
184
+ createdAt
185
+ updatedAt
186
+ }
187
+ }
188
+ }
189
+ `,Ut=`
190
+ mutation SaveContacts($input: SaveContactsInput!) {
191
+ saveContacts(input: $input) {
192
+ contacts {
193
+ id
194
+ accountId
195
+ name
196
+ kind
197
+ value
198
+ unverifiedValue
199
+ verifiedAt
200
+ status
201
+ tag
202
+ createdAt
203
+ updatedAt
204
+ }
205
+ }
206
+ }
207
+ `,Dt=`
208
+ mutation prepareAsset($input: PrepareAssetInput!) {
209
+ prepareAsset(input: $input) {
210
+ attributeId
211
+ createdAt
212
+ data
213
+ id
214
+ mimeType
215
+ name
216
+ processingStatus
217
+ resourceId
218
+ size
219
+ storageProviderId
220
+ updatedAt
221
+ uploadStatus
222
+ uploaderId
223
+ url
224
+ workspaceId
225
+ }
226
+ }
227
+ `,Lt=`
228
+ query Asset($id: ID!) {
229
+ asset(id: $id) {
230
+ attributeId
231
+ createdAt
232
+ data
233
+ id
234
+ mimeType
235
+ name
236
+ processingStatus
237
+ resourceId
238
+ size
239
+ storageProviderId
240
+ updatedAt
241
+ uploadStatus
242
+ uploaderId
243
+ url
244
+ workspaceId
245
+ }
246
+ }
247
+ `,qt="@dashx/browser",Ft="dashx-browser",Mt="0.1.29",Bt="DashX SDK for Browser",Nt="dist/index.js",Ht="dist/browser.esm.js",Wt=["dist"],Yt={build:"tsdx build --tsconfig tsconfig.json",start:"tsdx watch --tsconfig tsconfig.json --verbose --noClean",release:"yarn build && npm publish"},Vt={type:"git",url:"git+https://github.com/dashxhq/dashx-browser"},Gt=["dashx"],Xt="MIT",Kt={unfetch:"^4.2.0","uuid-random":"^1.3.2"},Jt={"@typescript-eslint/eslint-plugin":"^5.29.0","@typescript-eslint/parser":"^5.29.0",eslint:"^8.18.0","eslint-config-airbnb-typescript":"^17.0.0","eslint-plugin-import":"^2.26.0",tsdx:"^0.14.1",typescript:"^4.7.4"},Ye={name:qt,title:Ft,version:Mt,description:Bt,main:Nt,module:Ht,files:Wt,scripts:Yt,repository:Vt,keywords:Gt,license:Xt,dependencies:Kt,devDependencies:Jt};function zt(){return{height:window.screen.height,width:window.screen.width}}function Zt(){return{name:Ye.name,version:Ye.version}}function Qt(){return navigator.language}function er(){return{path:window.location.pathname,search:window.location.search,title:window.document.title,url:window.location.href}}function tr(){return Intl.DateTimeFormat().resolvedOptions().timeZone}function rr(){return{displayMetrics:zt(),library:Zt(),locale:Qt(),page:er(),timezone:tr()}}function Ve(s){s===void 0&&(s={});var o={};return Object.keys(s).forEach(function(r){var t;if(r.startsWith("_")){o[r.substring(1)]=s[r];return}o.data=N((t={},t[r]=s[r],t),o.data)}),o}var nr=function(){function s(r){this.options={},this.callback=r}var o=s.prototype;return o.limit=function(t){return this.options.limit=t,this},o.filter=function(t){return this.options.filter=Ve(t),this},o.order=function(t){return this.options.order=t,this},o.language=function(t){return this.options.language=t,this},o.fields=function(t){return this.options.fields=t,this},o.include=function(t){return this.options.include=t,this},o.exclude=function(t){return this.options.exclude=t,this},o.preview=function(t){return t===void 0&&(t=!0),this.options.preview=t,this},o.all=function(t){return this.options=N({},this.options,t,{returnType:"all"}),this.callback(this.options)},o.one=function(){var r=B(_().mark(function a(d){var p;return _().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return this.options=N({},this.options,d,{returnType:"one"}),f.next=3,this.callback(this.options);case 3:return p=f.sent,f.abrupt("return",Array.isArray(p)?p[0]:null);case 5:case"end":return f.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),s}(),Pe="dashx-sdk";function Se(s){var o=window.localStorage.getItem(Pe);if(!o)return null;var r=JSON.parse(o);return r[s]}function ke(s,o){var r=window.localStorage.getItem(Pe),t=r?JSON.parse(r):{};t[s]=o,window.localStorage.setItem(Pe,JSON.stringify(t))}var ar=["custom"],ir=5,or=3e3,D=Te("accountAnonymousUid"),k=Te("accountUid"),V=Te("identityToken"),ur=function(){function s(r){var t=r.publicKey,a=r.baseUri,d=a===void 0?"https://api.dashx.com/graphql":a,p=r.targetEnvironment;Object.defineProperty(this,D,{writable:!0,value:void 0}),Object.defineProperty(this,k,{writable:!0,value:void 0}),Object.defineProperty(this,V,{writable:!0,value:void 0}),S(this,k)[k]=null,S(this,V)[V]=null,this.baseUri=d,this.publicKey=t,this.targetEnvironment=p,this.context=rr(),this.loadIdentity()}var o=s.prototype;return o.makeHttpRequest=function(){var r=B(_().mark(function a(d,p){var c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Be(this.baseUri,{method:"POST",headers:N({"Content-Type":"application/json","X-Public-Key":this.publicKey},this.targetEnvironment?{"X-Target-Environment":this.targetEnvironment}:{},S(this,V)[V]?{"X-Identity-Token":S(this,V)[V]}:{}),body:JSON.stringify({query:d,variables:p})}).then(function(m){return m.json()});case 2:if(c=n.sent,!c.data){n.next=5;break}return n.abrupt("return",Promise.resolve(c.data));case 5:return n.abrupt("return",Promise.reject(c.errors));case 6:case"end":return n.stop()}},a,this)}));function t(a,d){return r.apply(this,arguments)}return t}(),o.loadIdentity=function(){this.accountAnonymousUid=Se("accountAnonymousUid")||_e(),this.accountUid=Se("accountUid")||null,this.identityToken=Se("identityToken")||null},o.identify=function(t){if(typeof t=="string"){this.accountUid=t;return}this.accountUid=t==null?void 0:t.uid;var a=N({uid:t==null?void 0:t.uid,anonymousUid:S(this,D)[D]},t);return this.makeHttpRequest(Et,{input:a}).then(function(d){return d==null?void 0:d.identifyAccount})},o.setIdentity=function(t,a){this.accountUid=t,this.identityToken=a},o.setAnonymousIdentity=function(t){this.accountAnonymousUid=t},o.reset=function(){this.accountAnonymousUid=_e(),this.accountUid=null,this.identityToken=null},o.track=function(t,a){var d={event:t,data:a,accountUid:S(this,k)[k],accountAnonymousUid:S(this,D)[D]};return this.makeHttpRequest(Ct,{input:d})},o.addContent=function(t,a){var d,p;if(t.includes("/")){var c=t.split("/");p=c[0],d=c[1]}else p=t;var f={content:d,contentType:p,data:a};return this.makeHttpRequest(Rt,{input:f})},o.editContent=function(t,a){var d,p;if(t.includes("/")){var c=t.split("/");p=c[0],d=c[1]}else p=t;var f={content:d,contentType:p,data:a};return this.makeHttpRequest(_t,{input:f})},o.searchContent=function(t,a){var d=this;if(!a)return new nr(function(f){return d.makeHttpRequest(We,{input:N({},f,{contentType:t})}).then(function(n){return n==null?void 0:n.searchContent})});var p=Ve(a.filter),c=this.makeHttpRequest(We,{input:N({},a,{contentType:t,filter:p})}).then(function(f){return f==null?void 0:f.searchContent});return a.returnType==="all"?c:c.then(function(f){return Array.isArray(f)?f[0]:null})},o.fetchContent=function(){var r=B(_().mark(function a(d,p){var c,f,n,m,b;return _().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(d.includes("/")){O.next=2;break}throw new Error("URN must be of form: {contentType}/{content}");case 2:return c=d.split("/"),f=c[0],n=c[1],m=N({content:n,contentType:f},p),O.next=6,this.makeHttpRequest(Tt,{input:m});case 6:return b=O.sent,O.abrupt("return",b==null?void 0:b.fetchContent);case 8:case"end":return O.stop()}},a,this)}));function t(a,d){return r.apply(this,arguments)}return t}(),o.addItemToCart=function(){var r=B(_().mark(function a(d){var p,c,f,n,m;return _().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return p=d.custom,c=p===void 0?{}:p,f=wt(d,ar),n=N({custom:c},f,{accountUid:S(this,k)[k],accountAnonymousUid:S(this,D)[D]}),E.next=4,this.makeHttpRequest(St,{input:n});case 4:return m=E.sent,E.abrupt("return",m==null?void 0:m.addItemToCart);case 6:case"end":return E.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.applyCouponToCart=function(){var r=B(_().mark(function a(d){var p,c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return p=N({},d,{accountUid:S(this,k)[k],accountAnonymousUid:S(this,D)[D]}),n.next=3,this.makeHttpRequest(kt,{input:p});case 3:return c=n.sent,n.abrupt("return",c==null?void 0:c.applyCouponToCart);case 5:case"end":return n.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.removeCouponFromCart=function(){var r=B(_().mark(function a(d){var p,c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return p=N({},d,{accountUid:S(this,k)[k],accountAnonymousUid:S(this,D)[D]}),n.next=3,this.makeHttpRequest(At,{input:p});case 3:return c=n.sent,n.abrupt("return",c==null?void 0:c.removeCouponFromCart);case 5:case"end":return n.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.fetchCart=function(){var r=B(_().mark(function a(d){var p,c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return p=N({},d,{accountUid:S(this,k)[k],accountAnonymousUid:S(this,D)[D]}),n.next=3,this.makeHttpRequest(Ot,{input:p});case 3:return c=n.sent,n.abrupt("return",c==null?void 0:c.fetchCart);case 5:case"end":return n.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.transferCart=function(){var r=B(_().mark(function a(d){var p,c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return p=N({},d,{accountUid:S(this,k)[k],accountAnonymousUid:S(this,D)[D]}),n.next=3,this.makeHttpRequest(jt,{input:p});case 3:return c=n.sent,n.abrupt("return",c==null?void 0:c.transferCart);case 5:case"end":return n.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.fetchStoredPreferences=function(){var r=B(_().mark(function a(){var d,p;return _().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return d={accountUid:S(this,k)[k]},f.next=3,this.makeHttpRequest(It,{input:d});case 3:return p=f.sent,f.abrupt("return",p==null?void 0:p.fetchStoredPreferences.preferenceData);case 5:case"end":return f.stop()}},a,this)}));function t(){return r.apply(this,arguments)}return t}(),o.saveStoredPreferences=function(){var r=B(_().mark(function a(d){var p,c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return p={accountUid:S(this,k)[k],preferenceData:d},n.next=3,this.makeHttpRequest($t,{input:p});case 3:return c=n.sent,n.abrupt("return",c==null?void 0:c.saveStoredPreferences);case 5:case"end":return n.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.fetchContacts=function(){var r=B(_().mark(function a(){var d,p;return _().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return d={uid:S(this,k)[k]},f.next=3,this.makeHttpRequest(xt,{input:d});case 3:return p=f.sent,f.abrupt("return",p==null?void 0:p.fetchContacts.contacts);case 5:case"end":return f.stop()}},a,this)}));function t(){return r.apply(this,arguments)}return t}(),o.saveContacts=function(){var r=B(_().mark(function a(d){var p,c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return p={uid:S(this,k)[k],contacts:d},n.next=3,this.makeHttpRequest(Ut,{input:p});case 3:return c=n.sent,n.abrupt("return",c==null?void 0:c.saveContacts);case 5:case"end":return n.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.upload=function(){var r=B(_().mark(function a(d){var p,c,f,n,m=this,b,E,O,Z,G,Q,q,j,te;return _().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return b=d.file,E=d.attribute,O=d.resource,Z={name:b.name,size:b.size,mimeType:b.type,attribute:E,resource:O,targetEnvironment:this.targetEnvironment},K.next=4,this.makeHttpRequest(Dt,{input:Z});case 4:if(G=K.sent,Q=G==null||(p=G.prepareAsset)==null?void 0:p.id,q=G==null||(c=G.prepareAsset)==null||(f=c.data)==null||(n=f.upload)==null?void 0:n.url,!(!q||!Q)){K.next=9;break}throw new Error("Something went wrong");case 9:return K.next=11,Be(q,{method:"PUT",body:b,headers:{"Content-Type":b.type,"x-goog-meta-origin-id":Q}});case 11:return j=ir,te=function(){var ie=B(_().mark(function ne(){var re,ae;return _().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,m.getAsset({id:Q});case 2:if(re=i.sent,ae=re==null?void 0:re.uploadStatus,ae!=="UPLOADED"){i.next=6;break}return i.abrupt("return",Promise.resolve(re));case 6:return i.next=8,new Promise(function(y){return setTimeout(y,or)});case 8:if(j--,j){i.next=11;break}return i.abrupt("return",Promise.reject("Something went wrong."));case 11:return i.abrupt("return",te());case 12:case"end":return i.stop()}},ne)}));return function(){return ie.apply(this,arguments)}}(),K.abrupt("return",te());case 14:case"end":return K.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),o.getAsset=function(){var r=B(_().mark(function a(d){var p,c;return _().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return p=d.id,n.next=3,this.makeHttpRequest(Lt,{id:p});case 3:return c=n.sent,n.abrupt("return",c==null?void 0:c.asset);case 5:case"end":return n.stop()}},a,this)}));function t(a){return r.apply(this,arguments)}return t}(),gt(s,[{key:"accountAnonymousUid",set:function(t){if(!_e.test(t))throw new Error("Anonymous UID must be a valid UUID");S(this,D)[D]=t,ke("accountAnonymousUid",S(this,D)[D])}},{key:"accountUid",set:function(t){t==null?S(this,k)[k]=t:S(this,k)[k]=String(t),ke("accountUid",S(this,k)[k])}},{key:"identityToken",set:function(t){t==null?S(this,V)[V]=t:S(this,V)[V]=String(t),ke("identityToken",S(this,V)[V])}}]),s}(),sr=function(s){return new ur(s)},Ae={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Ge=M.createContext(null);function cr({children:s,publicKey:o,baseUri:r,targetEnvironment:t}){const a=M.useMemo(()=>sr({publicKey:o||Ae.REACT_APP_DASHX_PUBLIC_KEY,baseUri:r||Ae.REACT_APP_DASHX_BASE_URI,targetEnvironment:t||Ae.REACT_APP_TARGET_ENVIRONMENT}),[o,r,t]);return U.jsx(Ge.Provider,{value:a,children:s})}const Xe=()=>{const s=M.useContext(Ge);if(!s)throw new Error("DashXProvider not initialized. Make sure your app is wrapped in DashXProvider.");return s},fr=({preference:s,onChange:o})=>{const r=t=>{o(t,s)};return U.jsxs("div",{children:[U.jsx("p",{children:s[0]}),U.jsxs("label",{children:["Email",U.jsx("input",{name:"email",type:"checkbox",defaultChecked:s[1].email,onChange:r})]}),U.jsxs("label",{children:["Push",U.jsx("input",{name:"push",type:"checkbox",defaultChecked:s[1].push,onChange:r})]}),U.jsxs("label",{children:["SMS",U.jsx("input",{name:"sms",type:"checkbox",defaultChecked:s[1].sms,onChange:r})]}),U.jsxs("label",{children:["Whatsapp",U.jsx("input",{name:"whatsapp",type:"checkbox",defaultChecked:s[1].whatsapp,onChange:r})]}),U.jsx("br",{})]})};function Ke({preference:s,onChange:o,renderPreference:r=fr}){return r({preference:s,onChange:o})}const lr=({preferences:s,onChange:o,loading:r})=>s?U.jsx(U.Fragment,{children:s.map(t=>U.jsx(Ke,{preference:t,onChange:o},t[0]))}):r?U.jsx(U.Fragment,{children:"Loading..."}):U.jsx(U.Fragment,{children:"An unexpected error ocurred"});function dr({renderPreferences:s=lr}){const o=Xe(),[r,t]=M.useState(null),[a,d]=M.useState(!0),[p,c]=M.useState(null),[f,n]=M.useState(!1),m=(b,E)=>{n(!0);const[O,Z]=E;t(G=>({...G||{},[O]:{...Z,[b.target.name]:b.target.checked}}))};return M.useEffect(()=>{if(!f)return;const b=setTimeout(async()=>{await o.saveStoredPreferences(r),n(!1)},100);return()=>clearTimeout(b)},[r,f,o]),M.useEffect(()=>{async function b(){d(!0);try{const E=await o.fetchStoredPreferences();t(E)}catch(E){c(E)}finally{d(!1)}}b()},[o]),s({preferences:r&&Object.entries(r).map(([b,E])=>[b,E]),onChange:m,loading:a,error:p})}ee.DashXProvider=cr,ee.Preference=Ke,ee.Preferences=dr,ee.useDashXProvider=Xe,Object.defineProperty(ee,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@dashx/react",
3
+ "title": "dashx-react",
4
+ "version": "0.0.1",
5
+ "description": "DashX SDK for the React",
6
+ "license": "MIT",
7
+ "main": "./dist/index.umd.js",
8
+ "module": "./dist/index.es.js",
9
+ "types": "./dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.es.js",
16
+ "require": "./dist/index.umd.js",
17
+ "types": "./dist/index.d.ts"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "dev": "vite",
22
+ "build": "tsc && vite build"
23
+ },
24
+ "devDependencies": {
25
+ "@rollup/plugin-commonjs": "^25.0.7",
26
+ "@rollup/plugin-node-resolve": "^15.2.3",
27
+ "@rollup/plugin-terser": "^0.4.4",
28
+ "@rollup/plugin-typescript": "^11.1.6",
29
+ "@types/node": "^20.12.7",
30
+ "@types/react": "^18.3.1",
31
+ "@vitejs/plugin-react": "^4.2.1",
32
+ "@vitejs/plugin-react-swc": "^3.6.0",
33
+ "rollup": "^4.17.2",
34
+ "rollup-plugin-dts": "^6.1.0",
35
+ "rollup-plugin-peer-deps-external": "^2.2.4",
36
+ "tslib": "^2.6.2",
37
+ "typescript": "^5.4.5",
38
+ "vite": "^5.2.11",
39
+ "vite-plugin-dts": "^3.9.0",
40
+ "vite-tsconfig-paths": "^4.3.2"
41
+ },
42
+ "peerDependencies": {
43
+ "react": "^18.2.0",
44
+ "react-dom": "^18.2.0"
45
+ },
46
+ "dependencies": {
47
+ "@dashx/browser": "^0.1.29"
48
+ }
49
+ }