@1interface/chat-shell 0.10.0 → 0.11.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/dist/Adapter-BXquRkJb.cjs +1 -0
- package/dist/Adapter-Btgjo8Dw.js +1 -0
- package/dist/Adapter-NYa2rsBP.js +1 -0
- package/dist/Adapter-cx5XZUQA.cjs +1 -0
- package/dist/PaymentProviderHost-DctZpdV2.js +1 -0
- package/dist/PaymentProviderHost-DsqmNubh.cjs +1 -0
- package/dist/PaymentResultChannel-BeNC8yyV.cjs +1 -0
- package/dist/PaymentResultChannel-Cxl4EZJx.js +1 -0
- package/dist/chat-shell.css +1 -1
- package/dist/index-CBfElPm_.js +1 -0
- package/dist/index-hPiV7e_i.cjs +1 -0
- package/dist/index.d.ts +27 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/native/index.js +1 -1
- package/native/index.native.js +1 -1
- package/native/payment/PaymentProvider.js +1 -1
- package/native/payment/PaymentProviderHost.js +1 -1
- package/native/payment/PaymentResultChannel.js +1 -1
- package/native/payment/adapters/atb/Adapter.js +1 -0
- package/native/payment/adapters/atb/AtbCheckoutFrame.js +1 -1
- package/native/payment/adapters/atb/agentText.js +1 -0
- package/native/payment/adapters/atb/codes.js +1 -0
- package/native/payment/adapters/atb/result.js +1 -1
- package/native/payment/adapters/atb/spec.js +1 -0
- package/native/payment/adapters/atb/types.js +0 -0
- package/native/payment/adapters/registry.js +1 -0
- package/native/payment/adapters/registry.native.js +1 -0
- package/native/payment/adapters/specHelpers.js +1 -0
- package/native/payment/adapters/specs.js +1 -0
- package/native/payment/adapters/stripe/Adapter.js +1 -0
- package/native/payment/adapters/stripe/outcome.js +1 -0
- package/native/payment/adapters/stripe/spec.js +1 -0
- package/native/payment/adapters/stripe/types.js +0 -0
- package/native/payment/preload.js +1 -0
- package/native/providers/ChatClientProvider.js +1 -1
- package/package.json +6 -8
- package/dist/PaymentProviderHost-BqhQHmsL.js +0 -1
- package/dist/PaymentProviderHost-Cv6mnzTj.cjs +0 -1
- package/native/payment/adapters/AtbPaymentAdapter.js +0 -1
- package/native/payment/adapters/ChargebeePaymentAdapter.js +0 -83
- package/native/payment/adapters/MoyasarPaymentAdapter.js +0 -1
- package/native/payment/adapters/StripePaymentAdapter.js +0 -1
- package/native/payment/adapters/chargebeeModalSize.js +0 -1
- package/native/payment/adapters/index.js +0 -1
- package/native/payment/adapters/moyasar/ApplePayButton.js +0 -12
- package/native/payment/adapters/moyasar/CardBrandIcon.js +0 -1
- package/native/payment/adapters/moyasar/CustomCardForm.js +0 -1
- package/native/payment/adapters/moyasar/Moyasar3DSIframe.js +0 -1
- package/native/payment/adapters/moyasar/api.js +0 -1
- package/native/payment/adapters/moyasar/applePayApi.js +0 -1
- package/native/payment/adapters/moyasar/cardValidation.js +0 -1
- package/native/payment/adapters/moyasar/constants.js +0 -1
- package/native/payment/adapters/moyasar/index.js +0 -1
- package/native/payment/adapters/moyasar/metadata.js +0 -1
- package/native/payment/adapters/moyasar/useApplePaySupported.js +0 -1
- package/native/payment/adapters/stripe/index.js +0 -1
- package/native/payment/adapters/stripe/providerWrapper.js +0 -1
- package/native/payment/createPaymentAdapter.js +0 -1
- package/native/payment/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),n=require("./PaymentResultChannel-BeNC8yyV.cjs"),r=require("@1interface/shared-core"),o=require("@1interface/chat-core"),s=require("./index-hPiV7e_i.cjs"),a="session_invalid",c="load_failed",i={READY:"ready",COMPLETED:"completed",ERROR:"error",REDIRECT:"redirect"},u=new Set(Object.values(i)),l=/^[\w.:/-]{1,200}$/;function d(e,t=200){if("string"!=typeof e)return;const n=e.trim();return n&&n.length<=t?n:void 0}function m({status:e,amount:t,currency:n,code:r}){if(e===o.PAYMENT_OUTCOME_STATUSES.SUCCESS){const e=o.formatAmount(t,n);return{agentText:`The payment${e?` of ${e}`:""} is completed.`,modelText:s.ATB_VERIFY_NOTE}}return r===a?{agentText:"The payment session has expired or is no longer valid."}:r===c?{agentText:"The payment page could not be loaded."}:{agentText:"The payment failed.",modelText:s.ATB_VERIFY_NOTE}}const f="succeeded",p="failed",y="atb-payment";function g(){const e=document.createElement("div");e.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:scroll;",document.body.appendChild(e);const t=e.offsetWidth-e.clientWidth;return e.remove(),Math.max(0,t)}const h=({payment:n,onResult:s,skin:h})=>{const T=t.useRef(null),E=t.useRef(!1),x=t.useRef(!1),[v,b]=t.useState(!1),[R]=t.useState(g),w=t.useMemo(()=>function(e){try{return new URL(e).origin}catch{return null}}(n.config.url),[n.config.url]),S=n.paymentId,_=t.useCallback((e,t={})=>{E.current||(E.current=!0,r.logger.info({message:"[atb] outcome",api_name:y,reference_id:S,outcome:e}),s(function({outcome:e,payment:t,message:n,code:r}){if(e===f){const e=o.PAYMENT_OUTCOME_STATUSES.SUCCESS;return{status:e,...m({status:e,amount:t?.amount,currency:t?.currency})}}const s=o.PAYMENT_OUTCOME_STATUSES.FAILURE;return{status:s,...m({status:s,code:r}),userMessage:n??"The payment was not completed."}}({outcome:e,payment:n,...t})))},[n,S,s]),C=t.useCallback(()=>{x.current=!0,b(!0)},[]);return t.useEffect(()=>{if(!w)return;const e=e=>{if(e.source!==T.current?.contentWindow)return;if(e.origin!==w)return;if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e;return"atb-pga"===t.source&&"number"==typeof t.v&&"string"==typeof t.type&&u.has(t.type)&&(void 0===t.data||"object"==typeof t.data&&null!==t.data)}(e.data))return;const{type:t,data:n}=e.data,s=t===i.COMPLETED?function(e){const t=e&&"object"==typeof e?e:{};let n=null;const r=d(t.returnUrl,2048);if(r)try{n=new URL(r).searchParams}catch{n=null}const o=d(t.checkoutId)??d(n?.get("checkoutId"));return{status:d(t.status)??d(n?.get("status")),...o&&l.test(o)?{checkoutId:o}:{}}}(n):{};switch(r.logger.info({message:"[atb] gateway event",api_name:y,reference_id:S,type:t,status:s.status??null,checkout_id:s.checkoutId??null}),t){case i.READY:return void C();case i.COMPLETED:return void _((c=s.status,"payment_deposited"===c?.trim().toLowerCase()?f:p));case i.ERROR:return void _(p,{message:"This payment session has expired or is no longer valid. Please start a new payment.",code:a});case i.REDIRECT:{const e=function(e){const t=e&&"object"==typeof e?e.url:void 0;return o.isHttpsUrl(t)?t:null}(n);if(!e)return void r.logger.warn({message:"ATB wallet redirect carried no https url",api_name:y});r.logger.info({message:"[atb] wallet redirect in frame",api_name:y,reference_id:S}),T.current&&(T.current.src=e)}}var c};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[w,S,C,_]),t.useEffect(()=>{const e=setTimeout(()=>{x.current||_(p,{message:"The payment page failed to load.",code:c})},6e4);return()=>clearTimeout(e)},[_]),e.jsx("div",{className:"absolute inset-0 z-[105] flex flex-col overflow-hidden",style:{background:h.cardBg},role:"region","aria-label":"Payment",children:e.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:h.muted,fontFamily:h.fontFamily},children:"Loading…"}),e.jsx("iframe",{ref:T,src:n.config.url,title:"Payment",className:"min-h-0 flex-1 "+(v?"":"invisible"),style:{border:0,background:"white",width:`calc(100% + ${R}px)`},allow:"payment",referrerPolicy:"no-referrer"})]})})};exports.default={label:"ATB",hideShellSubmit:!0,hideShellFooter:!0,FormComponent:({skin:r,onReady:o})=>{const{payment:s}=n.usePaymentAdapter(),a=n.useResultEmitter();return t.useEffect(()=>{o?.()},[o]),e.jsx(h,{payment:s,onResult:a,skin:r},s.paymentId)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import r,{useMemo as o,useState as a,useRef as i,useEffect as c,useCallback as u}from"react";import{PAYMENT_OUTCOME_STATUSES as s,defaultAgentText as f,buildBrandSkin as l}from"@1interface/chat-core";import{useBranding as p,logger as y}from"@1interface/shared-core";import{u as d,d as m,e as v,f as b}from"./PaymentResultChannel-Cxl4EZJx.js";function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var g,S="https://js.stripe.com/v3",w=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,E="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",O=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(S).concat(t);var r=document.head||document.body;if(!r)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(n),n},j=null,x=null,C=null,k=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==h(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},P=!1,_=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];P=!0;var r,o=Date.now();return(r=g,null!==j?j:(j=new Promise(function(e,t){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&r&&console.warn(E),window.Stripe)e(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(S,'"]')),t=0;t<e.length;t++){var n=e[t];if(w.test(n.src))return n}return null}();if(n&&r)console.warn(E);else if(n){if(n&&null!==C&&null!==x){var o;n.removeEventListener("load",C),n.removeEventListener("error",x),null===(o=n.parentNode)||void 0===o||o.removeChild(n),n=O(r)}}else n=O(r);C=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}}(e,t),x=function(e){return function(){e(new Error("Failed to load Stripe.js"))}}(t),n.addEventListener("load",C),n.addEventListener("error",x)}catch(e){return void t(e)}else e(null)})).catch(function(e){return j=null,Promise.reject(e)})).then(function(e){return function(e,t,n){if(null===e)return null;var r=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"4.6.0",startTime:t})}(r,n),r}(e,t,o)})};function T(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}_.setLoadParameters=function(e){if(P&&g){var t=k(e);if(Object.keys(t).reduce(function(t,n){var r;return t&&e[n]===(null===(r=g)||void 0===r?void 0:r[n])},!0))return}if(P)throw new Error("You cannot change load parameters after calling loadStripe");g=k(e)};var $,N,A,I,R,M,D,F,L,V,W,q,B,U,Y,z,J={exports:{}},H={exports:{}},G={},K={};function Q(){return A||(A=1,H.exports="production"===process.env.NODE_ENV?function(){if($)return G;$=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,s=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,l=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,d=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,v=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function g(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case u:case s:case r:case a:case o:case l:return e;default:switch(e=e&&e.$$typeof){case c:case f:case d:case y:case i:return e;default:return p}}case n:return p}}}function S(e){return g(e)===s}return G.AsyncMode=u,G.ConcurrentMode=s,G.ContextConsumer=c,G.ContextProvider=i,G.Element=t,G.ForwardRef=f,G.Fragment=r,G.Lazy=d,G.Memo=y,G.Portal=n,G.Profiler=a,G.StrictMode=o,G.Suspense=l,G.isAsyncMode=function(e){return S(e)||g(e)===u},G.isConcurrentMode=S,G.isContextConsumer=function(e){return g(e)===c},G.isContextProvider=function(e){return g(e)===i},G.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},G.isForwardRef=function(e){return g(e)===f},G.isFragment=function(e){return g(e)===r},G.isLazy=function(e){return g(e)===d},G.isMemo=function(e){return g(e)===y},G.isPortal=function(e){return g(e)===n},G.isProfiler=function(e){return g(e)===a},G.isStrictMode=function(e){return g(e)===o},G.isSuspense=function(e){return g(e)===l},G.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===s||e===a||e===o||e===l||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===d||e.$$typeof===y||e.$$typeof===i||e.$$typeof===c||e.$$typeof===f||e.$$typeof===v||e.$$typeof===b||e.$$typeof===h||e.$$typeof===m)},G.typeOf=g,G}():(N||(N=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,s=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,l=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,d=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,v=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function g(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var m=e.type;switch(m){case u:case s:case r:case a:case o:case l:return m;default:var v=m&&m.$$typeof;switch(v){case c:case f:case d:case y:case i:return v;default:return p}}case n:return p}}}var S=s,w=c,E=i,O=t,j=f,x=r,C=d,k=y,P=n,_=a,T=o,$=l,N=!1;function A(e){return g(e)===s}K.AsyncMode=u,K.ConcurrentMode=S,K.ContextConsumer=w,K.ContextProvider=E,K.Element=O,K.ForwardRef=j,K.Fragment=x,K.Lazy=C,K.Memo=k,K.Portal=P,K.Profiler=_,K.StrictMode=T,K.Suspense=$,K.isAsyncMode=function(e){return N||(N=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),A(e)||g(e)===u},K.isConcurrentMode=A,K.isContextConsumer=function(e){return g(e)===c},K.isContextProvider=function(e){return g(e)===i},K.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},K.isForwardRef=function(e){return g(e)===f},K.isFragment=function(e){return g(e)===r},K.isLazy=function(e){return g(e)===d},K.isMemo=function(e){return g(e)===y},K.isPortal=function(e){return g(e)===n},K.isProfiler=function(e){return g(e)===a},K.isStrictMode=function(e){return g(e)===o},K.isSuspense=function(e){return g(e)===l},K.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===s||e===a||e===o||e===l||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===d||e.$$typeof===y||e.$$typeof===i||e.$$typeof===c||e.$$typeof===f||e.$$typeof===v||e.$$typeof===b||e.$$typeof===h||e.$$typeof===m)},K.typeOf=g}()),K)),H.exports}function X(){return D?M:(D=1,M="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}function Z(){return L?F:(L=1,F=Function.call.bind(Object.prototype.hasOwnProperty))}function ee(){if(W)return V;W=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=X(),n={},r=Z();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,a,i,c,u){if("production"!==process.env.NODE_ENV)for(var s in o)if(r(o,s)){var f;try{if("function"!=typeof o[s]){var l=Error((c||"React class")+": "+i+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}f=o[s](a,s,c,i,null,t)}catch(e){f=e}if(!f||f instanceof Error||e((c||"React class")+": type specification of "+i+" `"+s+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in n)){n[f.message]=!0;var p=u?u():"";e("Failed "+i+" type: "+f.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},V=o}function te(){if(B)return q;B=1;var e=Q(),t=function(){if(R)return I;R=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return I=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,o){for(var a,i,c=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),u=1;u<arguments.length;u++){for(var s in a=Object(arguments[u]))t.call(a,s)&&(c[s]=a[s]);if(e){i=e(a);for(var f=0;f<i.length;f++)n.call(a,i[f])&&(c[i[f]]=a[i[f]])}}return c},I}(),n=X(),r=Z(),o=ee(),a=function(){};function i(){return null}return"production"!==process.env.NODE_ENV&&(a=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),q=function(c,u){var s="function"==typeof Symbol&&Symbol.iterator,f="<<anonymous>>",l={array:m("array"),bigint:m("bigint"),bool:m("boolean"),func:m("function"),number:m("number"),object:m("object"),string:m("string"),symbol:m("symbol"),any:d(i),arrayOf:function(e){return d(function(t,r,o,a,i){if("function"!=typeof e)return new y("Property `"+i+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var c=t[r];if(!Array.isArray(c))return new y("Invalid "+a+" `"+i+"` of type `"+h(c)+"` supplied to `"+o+"`, expected an array.");for(var u=0;u<c.length;u++){var s=e(c,u,o,a,i+"["+u+"]",n);if(s instanceof Error)return s}return null})},element:d(function(e,t,n,r,o){var a=e[t];return c(a)?null:new y("Invalid "+r+" `"+o+"` of type `"+h(a)+"` supplied to `"+n+"`, expected a single ReactElement.")}),elementType:d(function(t,n,r,o,a){var i=t[n];return e.isValidElementType(i)?null:new y("Invalid "+o+" `"+a+"` of type `"+h(i)+"` supplied to `"+r+"`, expected a single ReactElement type.")}),instanceOf:function(e){return d(function(t,n,r,o,a){return t[n]instanceof e?null:new y("Invalid "+o+" `"+a+"` of type `"+((i=t[n]).constructor&&i.constructor.name?i.constructor.name:f)+"` supplied to `"+r+"`, expected instance of `"+(e.name||f)+"`.");var i})},node:d(function(e,t,n,r,o){return b(e[t])?null:new y("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(e){return d(function(t,o,a,i,c){if("function"!=typeof e)return new y("Property `"+c+"` of component `"+a+"` has invalid PropType notation inside objectOf.");var u=t[o],s=h(u);if("object"!==s)return new y("Invalid "+i+" `"+c+"` of type `"+s+"` supplied to `"+a+"`, expected an object.");for(var f in u)if(r(u,f)){var l=e(u,f,a,i,c+"."+f,n);if(l instanceof Error)return l}return null})},oneOf:function(e){return Array.isArray(e)?d(function(t,n,r,o,a){for(var i=t[n],c=0;c<e.length;c++)if(p(i,e[c]))return null;var u=JSON.stringify(e,function(e,t){return"symbol"===g(t)?String(t):t});return new y("Invalid "+o+" `"+a+"` of value `"+String(i)+"` supplied to `"+r+"`, expected one of "+u+".")}):("production"!==process.env.NODE_ENV&&a(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),i)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&a("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+S(o)+" at index "+t+"."),i}return d(function(t,o,a,i,c){for(var u=[],s=0;s<e.length;s++){var f=(0,e[s])(t,o,a,i,c,n);if(null==f)return null;f.data&&r(f.data,"expectedType")&&u.push(f.data.expectedType)}return new y("Invalid "+i+" `"+c+"` supplied to `"+a+"`"+(u.length>0?", expected one of type ["+u.join(", ")+"]":"")+".")})},shape:function(e){return d(function(t,r,o,a,i){var c=t[r],u=h(c);if("object"!==u)return new y("Invalid "+a+" `"+i+"` of type `"+u+"` supplied to `"+o+"`, expected `object`.");for(var s in e){var f=e[s];if("function"!=typeof f)return v(o,a,i,s,g(f));var l=f(c,s,o,a,i+"."+s,n);if(l)return l}return null})},exact:function(e){return d(function(o,a,i,c,u){var s=o[a],f=h(s);if("object"!==f)return new y("Invalid "+c+" `"+u+"` of type `"+f+"` supplied to `"+i+"`, expected `object`.");var l=t({},o[a],e);for(var p in l){var d=e[p];if(r(e,p)&&"function"!=typeof d)return v(i,c,u,p,g(d));if(!d)return new y("Invalid "+c+" `"+u+"` key `"+p+"` supplied to `"+i+"`.\nBad object: "+JSON.stringify(o[a],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var m=d(s,p,i,c,u+"."+p,n);if(m)return m}return null})}};function p(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function y(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function d(e){if("production"!==process.env.NODE_ENV)var t={},r=0;function o(o,i,c,s,l,p,d){if(s=s||f,p=p||c,d!==n){if(u){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var v=s+":"+c;!t[v]&&r<3&&(a("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+s+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[v]=!0,r++)}}return null==i[c]?o?new y(null===i[c]?"The "+l+" `"+p+"` is marked as required in `"+s+"`, but its value is `null`.":"The "+l+" `"+p+"` is marked as required in `"+s+"`, but its value is `undefined`."):null:e(i,c,s,l,p)}var i=o.bind(null,!1);return i.isRequired=o.bind(null,!0),i}function m(e){return d(function(t,n,r,o,a,i){var c=t[n];return h(c)!==e?new y("Invalid "+o+" `"+a+"` of type `"+g(c)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null})}function v(e,t,n,r,o){return new y((e||"React class")+": "+t+" type `"+n+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function b(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(b);if(null===e||c(e))return!0;var t=function(e){var t=e&&(s&&e[s]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,r=t.call(e);if(t!==e.entries){for(;!(n=r.next()).done;)if(!b(n.value))return!1}else for(;!(n=r.next()).done;){var o=n.value;if(o&&!b(o[1]))return!1}return!0;default:return!1}}function h(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function g(e){if(null==e)return""+e;var t=h(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function S(e){var t=g(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return y.prototype=Error.prototype,l.checkPropTypes=o,l.resetWarningCache=o.resetWarningCache,l.PropTypes=l,l},q}function ne(){if(Y)return U;Y=1;var e=X();function t(){}function n(){}return n.resetWarningCache=t,U=function(){function r(t,n,r,o,a,i){if(i!==e){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function o(){return r}r.isRequired=r;var a={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a}}function re(){if(z)return J.exports;if(z=1,"production"!==process.env.NODE_ENV){var e=Q();J.exports=te()(e.isElement,!0)}else J.exports=ne()();return J.exports}const oe=T(re());function ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ie(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ae(Object(n),!0).forEach(function(t){ue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ae(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ce(e){return(ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ue(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function se(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return fe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fe(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var le=function(e,t,n){var o=!!n,a=r.useRef(n);r.useEffect(function(){a.current=n},[n]),r.useEffect(function(){if(!o||!e)return function(){};var n=function(){a.current&&a.current.apply(a,arguments)};return e.on(t,n),function(){e.off(t,n)}},[o,t,e,a])},pe=function(e){var t=r.useRef(e);return r.useEffect(function(){t.current=e},[e]),t.current},ye=function(e){return null!==e&&"object"===ce(e)},de="[object Object]",me=function e(t,n){if(!ye(t)||!ye(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===de;if(o!==(Object.prototype.toString.call(n)===de))return!1;if(!o&&!r)return t===n;var a=Object.keys(t),i=Object.keys(n);if(a.length!==i.length)return!1;for(var c={},u=0;u<a.length;u+=1)c[a[u]]=!0;for(var s=0;s<i.length;s+=1)c[i[s]]=!0;var f=Object.keys(c);if(f.length!==a.length)return!1;var l=t,p=n;return f.every(function(t){return e(l[t],p[t])})},ve=function(e,t,n){return ye(e)?Object.keys(e).reduce(function(r,o){var a=!ye(t)||!me(e[o],t[o]);return n.includes(o)?(a&&console.warn("Unsupported prop change: options.".concat(o," is not a mutable property.")),r):a?ie(ie({},r||{}),{},ue({},o,e[o])):r},null):null},be="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",he=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be;if(null===e||ye(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},ge=r.createContext(null);ge.displayName="ElementsContext";var Se=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},we=function(e){var t=e.stripe,n=e.options,o=e.children,a=r.useMemo(function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:be;if(function(e){return ye(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(e){return he(e,t)})};var n=he(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}}(t)},[t]),i=se(r.useState(function(){return{stripe:"sync"===a.tag?a.stripe:null,elements:"sync"===a.tag?a.stripe.elements(n):null}}),2),c=i[0],u=i[1];r.useEffect(function(){var e=!0,t=function(e){u(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return"async"!==a.tag||c.stripe?"sync"!==a.tag||c.stripe||t(a.stripe):a.stripePromise.then(function(n){n&&e&&t(n)}),function(){e=!1}},[a,c,n]);var s=pe(t);r.useEffect(function(){null!==s&&s!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[s,t]);var f=pe(n);return r.useEffect(function(){if(c.elements){var e=ve(n,f,["clientSecret","fonts"]);e&&c.elements.update(e)}},[n,f,c.elements]),r.useEffect(function(){var e;(e=c.stripe)&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.10.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.10.0",url:"https://stripe.com/docs/stripe-js/react"}))},[c.stripe]),r.createElement(ge.Provider,{value:c},o)};we.propTypes={stripe:oe.any,options:oe.object};var Ee=r.createContext(null);Ee.displayName="CheckoutSdkContext",r.createContext(null).displayName="CheckoutContext",oe.shape({fetchClientSecret:oe.func.isRequired,elementsOptions:oe.object});var Oe=function(e){var t=r.useContext(Ee),n=r.useContext(ge);if(t&&n)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return t?function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e}(t,e):Se(n,e)},je=["mode"],xe=function(e,t){var n,o="".concat((n=e).charAt(0).toUpperCase()+n.slice(1),"Element"),a=t?function(e){return Oe("mounts <".concat(o,">")),r.createElement("div",{id:e.id,className:e.className})}:function(t){var n,a=t.id,i=t.className,c=t.options,u=void 0===c?{}:c,s=t.onBlur,f=t.onFocus,l=t.onReady,p=t.onChange,y=t.onEscape,d=t.onClick,m=t.onLoadError,v=t.onLoaderStart,b=t.onNetworksChange,h=t.onConfirm,g=t.onCancel,S=t.onShippingAddressChange,w=t.onShippingRateChange,E=t.onSavedPaymentMethodRemove,O=t.onSavedPaymentMethodUpdate,j=Oe("mounts <".concat(o,">")),x="elements"in j?j.elements:null,C="checkoutSdk"in j?j.checkoutSdk:null,k=se(r.useState(null),2),P=k[0],_=k[1],T=r.useRef(null),$=r.useRef(null);le(P,"blur",s),le(P,"focus",f),le(P,"escape",y),le(P,"click",d),le(P,"loaderror",m),le(P,"loaderstart",v),le(P,"networkschange",b),le(P,"confirm",h),le(P,"cancel",g),le(P,"shippingaddresschange",S),le(P,"shippingratechange",w),le(P,"savedpaymentmethodremove",E),le(P,"savedpaymentmethodupdate",O),le(P,"change",p),l&&(n="expressCheckout"===e?l:function(){l(P)}),le(P,"ready",n),r.useLayoutEffect(function(){if(null===T.current&&null!==$.current&&(x||C)){var t=null;if(C)switch(e){case"payment":t=C.createPaymentElement(u);break;case"address":if(!("mode"in u))throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");var n=u.mode,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(u,je);if("shipping"===n)t=C.createShippingAddressElement(r);else{if("billing"!==n)throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.");t=C.createBillingAddressElement(r)}break;case"expressCheckout":t=C.createExpressCheckoutElement(u);break;case"currencySelector":t=C.createCurrencySelectorElement();break;case"taxId":t=C.createTaxIdElement(u);break;default:throw new Error("Invalid Element type ".concat(o,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else x&&(t=x.create(e,u));T.current=t,_(t),t&&t.mount($.current)}},[x,C,u]);var N=pe(u);return r.useEffect(function(){if(T.current){var e=ve(u,N,["paymentRequest"]);e&&"update"in T.current&&T.current.update(e)}},[u,N]),r.useLayoutEffect(function(){return function(){if(T.current&&"function"==typeof T.current.destroy)try{T.current.destroy(),T.current=null}catch(e){}}},[]),r.createElement("div",{id:a,className:i,ref:$})};return a.propTypes={id:oe.string,className:oe.string,onChange:oe.func,onBlur:oe.func,onFocus:oe.func,onReady:oe.func,onEscape:oe.func,onClick:oe.func,onLoadError:oe.func,onLoaderStart:oe.func,onNetworksChange:oe.func,onConfirm:oe.func,onCancel:oe.func,onShippingAddressChange:oe.func,onShippingRateChange:oe.func,onSavedPaymentMethodRemove:oe.func,onSavedPaymentMethodUpdate:oe.func,options:oe.object},a.displayName=o,a.__elementType=e,a},Ce="undefined"==typeof window;r.createContext(null).displayName="EmbeddedCheckoutProviderContext",xe("auBankAccount",Ce),xe("card",Ce),xe("cardNumber",Ce),xe("cardExpiry",Ce),xe("cardCvc",Ce),xe("fpxBank",Ce),xe("iban",Ce),xe("idealBank",Ce),xe("p24Bank",Ce),xe("epsBank",Ce);var ke=xe("payment",Ce);xe("expressCheckout",Ce),xe("currencySelector",Ce),xe("paymentRequestButton",Ce),xe("linkAuthentication",Ce),xe("address",Ce),xe("shippingAddress",Ce),xe("paymentMethodMessaging",Ce),xe("affirmMessage",Ce),xe("afterpayClearpayMessage",Ce),xe("taxId",Ce);const Pe="The payment didn't go through. Try again or use another payment method.",_e=new Set(["card_error","validation_error"]),Te=({skin:o,onReady:l})=>{const p=Oe("calls useStripe()").stripe,h=(_=r.useContext(ge),Se(_,"calls useElements()")).elements,{payment:g}=d(),S=m(),w=v(),E=b(),[O,j]=a(!1),x=i(!1),[C,k]=a(null),P=g.config.client_secret;var _;c(()=>{if(!p)return;let e=!1;return p.retrievePaymentIntent(P).then(t=>{if(e)return;const n=t.paymentIntent;n&&"number"==typeof n.amount&&n.currency&&E({amount:n.amount,currency:n.currency})}),()=>{e=!0}},[p,P,E]);const T=u(async()=>{if(p&&h&&!x.current){x.current=!0,j(!0),k(null);try{const{error:e}=await h.submit();if(e)return;const{error:t,paymentIntent:n}=await p.confirmPayment({elements:h,clientSecret:P,confirmParams:{return_url:window.location.href},redirect:"if_required"}),r=n??t?.payment_intent;if(r&&("succeeded"===r.status||"requires_capture"===r.status))return void S(function({amount:e,currency:t}){return{status:s.SUCCESS,agentText:f({status:s.SUCCESS,amount:e,currency:t})}}(r));t&&!_e.has(t.type)&&k(function(e){return"payment_intent_authentication_failure"===e.code?"We couldn't verify this payment with your bank. Try again or use another payment method.":Pe}(t))}catch(e){y.warn({message:"Stripe confirm threw",api_name:"stripe-payment",error_message:e instanceof Error?e.message:String(e)}),k(Pe)}finally{x.current=!1,j(!1)}}},[p,h,P,S]);return c(()=>(w({confirm:T,isConfirming:O}),()=>w(null)),[T,O,w]),t(n,{children:[e(ke,{options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}},onReady:l}),C&&e("p",{role:"alert",className:"text-sm mt-3",style:{color:o.danger},children:C})]})},$e={label:"Stripe",FormComponent:({skin:t,onReady:n})=>{const{themeStyles:r,theme:a}=p(),{payment:i}=d(),{publishable_key:c,client_secret:u}=i.config,s=o(()=>c.startsWith("pk_")?_(c):null,[c]),f=o(()=>l(r,a),[r,a]),y=o(()=>function(e,t,n){return{theme:"dark"===t?"night":"stripe",variables:{colorPrimary:e.statusDiscovery.solid,colorBackground:n.cardBg,colorText:n.text,colorDanger:"#df1b41",fontFamily:n.fontFamily,borderRadius:`${n.radius}px`,spacingUnit:"3px",fontSizeBase:"16px"}}}(r,a,f),[r,a,f]),m=o(()=>({clientSecret:u,appearance:y}),[u,y]);return s?e(we,{stripe:s,options:m,children:e(Te,{skin:t,onReady:n})},u):null}};export{$e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useRef as n,useState as r,useMemo as o,useCallback as a,useEffect as s}from"react";import{u as i,d as c}from"./PaymentResultChannel-Cxl4EZJx.js";import{logger as u}from"@1interface/shared-core";import{isHttpsUrl as l,PAYMENT_OUTCOME_STATUSES as d,formatAmount as m}from"@1interface/chat-core";import{A as f}from"./index-CBfElPm_.js";const p="session_invalid",y="load_failed",h={READY:"ready",COMPLETED:"completed",ERROR:"error",REDIRECT:"redirect"},g=new Set(Object.values(h)),v=/^[\w.:/-]{1,200}$/;function w(e,t=200){if("string"!=typeof e)return;const n=e.trim();return n&&n.length<=t?n:void 0}function x({status:e,amount:t,currency:n,code:r}){if(e===d.SUCCESS){const e=m(t,n);return{agentText:`The payment${e?` of ${e}`:""} is completed.`,modelText:f}}return r===p?{agentText:"The payment session has expired or is no longer valid."}:r===y?{agentText:"The payment page could not be loaded."}:{agentText:"The payment failed.",modelText:f}}const b="succeeded",T="failed",E="atb-payment";function R(){const e=document.createElement("div");e.style.cssText="position:absolute;top:-9999px;width:100px;height:100px;overflow:scroll;",document.body.appendChild(e);const t=e.offsetWidth-e.clientWidth;return e.remove(),Math.max(0,t)}const C=({payment:i,onResult:c,skin:m})=>{const f=n(null),C=n(!1),_=n(!1),[k,L]=r(!1),[S]=r(R),j=o(()=>function(e){try{return new URL(e).origin}catch{return null}}(i.config.url),[i.config.url]),I=i.paymentId,P=a((e,t={})=>{C.current||(C.current=!0,u.info({message:"[atb] outcome",api_name:E,reference_id:I,outcome:e}),c(function({outcome:e,payment:t,message:n,code:r}){if(e===b){const e=d.SUCCESS;return{status:e,...x({status:e,amount:t?.amount,currency:t?.currency})}}const o=d.FAILURE;return{status:o,...x({status:o,code:r}),userMessage:n??"The payment was not completed."}}({outcome:e,payment:i,...t})))},[i,I,c]),D=a(()=>{_.current=!0,L(!0)},[]);return s(()=>{if(!j)return;const e=e=>{if(e.source!==f.current?.contentWindow)return;if(e.origin!==j)return;if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e;return"atb-pga"===t.source&&"number"==typeof t.v&&"string"==typeof t.type&&g.has(t.type)&&(void 0===t.data||"object"==typeof t.data&&null!==t.data)}(e.data))return;const{type:t,data:n}=e.data,r=t===h.COMPLETED?function(e){const t=e&&"object"==typeof e?e:{};let n=null;const r=w(t.returnUrl,2048);if(r)try{n=new URL(r).searchParams}catch{n=null}const o=w(t.checkoutId)??w(n?.get("checkoutId"));return{status:w(t.status)??w(n?.get("status")),...o&&v.test(o)?{checkoutId:o}:{}}}(n):{};switch(u.info({message:"[atb] gateway event",api_name:E,reference_id:I,type:t,status:r.status??null,checkout_id:r.checkoutId??null}),t){case h.READY:return void D();case h.COMPLETED:return void P((o=r.status,"payment_deposited"===o?.trim().toLowerCase()?b:T));case h.ERROR:return void P(T,{message:"This payment session has expired or is no longer valid. Please start a new payment.",code:p});case h.REDIRECT:{const e=function(e){const t=e&&"object"==typeof e?e.url:void 0;return l(t)?t:null}(n);if(!e)return void u.warn({message:"ATB wallet redirect carried no https url",api_name:E});u.info({message:"[atb] wallet redirect in frame",api_name:E,reference_id:I}),f.current&&(f.current.src=e)}}var o};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[j,I,D,P]),s(()=>{const e=setTimeout(()=>{_.current||P(T,{message:"The payment page failed to load.",code:y})},6e4);return()=>clearTimeout(e)},[P]),e("div",{className:"absolute inset-0 z-[105] flex flex-col overflow-hidden",style:{background:m.cardBg},role:"region","aria-label":"Payment",children:t("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[!k&&e("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:m.muted,fontFamily:m.fontFamily},children:"Loading…"}),e("iframe",{ref:f,src:i.config.url,title:"Payment",className:"min-h-0 flex-1 "+(k?"":"invisible"),style:{border:0,background:"white",width:`calc(100% + ${S}px)`},allow:"payment",referrerPolicy:"no-referrer"})]})})},_={label:"ATB",hideShellSubmit:!0,hideShellFooter:!0,FormComponent:({skin:t,onReady:n})=>{const{payment:r}=i(),o=c();return s(()=>{n?.()},[n]),e(C,{payment:r,onResult:o,skin:t},r.paymentId)}};export{_ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),r=require("@1interface/chat-core"),n=require("@1interface/shared-core"),o=require("./PaymentResultChannel-BeNC8yyV.cjs");function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i,c="https://js.stripe.com/v3",u=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",f=function(e){var t=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",r=document.createElement("script");r.src="".concat(c).concat(t);var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(r),r},l=null,p=null,y=null,d=function(e){var t="invalid load parameters; expected object of shape\n\n {advancedFraudSignals: boolean}\n\nbut received\n\n ".concat(JSON.stringify(e),"\n");if(null===e||"object"!==a(e))throw new Error(t);if(1===Object.keys(e).length&&"boolean"==typeof e.advancedFraudSignals)return e;throw new Error(t)},m=!1,v=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];m=!0;var n,o=Date.now();return(n=i,null!==l?l:(l=new Promise(function(e,t){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&n&&console.warn(s),window.Stripe)e(window.Stripe);else try{var r=function(){for(var e=document.querySelectorAll('script[src^="'.concat(c,'"]')),t=0;t<e.length;t++){var r=e[t];if(u.test(r.src))return r}return null}();if(r&&n)console.warn(s);else if(r){if(r&&null!==y&&null!==p){var o;r.removeEventListener("load",y),r.removeEventListener("error",p),null===(o=r.parentNode)||void 0===o||o.removeChild(r),r=f(n)}}else r=f(n);y=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}}(e,t),p=function(e){return function(){e(new Error("Failed to load Stripe.js"))}}(t),r.addEventListener("load",y),r.addEventListener("error",p)}catch(e){return void t(e)}else e(null)})).catch(function(e){return l=null,Promise.reject(e)})).then(function(e){return function(e,t,r){if(null===e)return null;var n=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"4.6.0",startTime:t})}(n,r),n}(e,t,o)})};function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}v.setLoadParameters=function(e){if(m&&i){var t=d(e);if(Object.keys(t).reduce(function(t,r){var n;return t&&e[r]===(null===(n=i)||void 0===n?void 0:n[r])},!0))return}if(m)throw new Error("You cannot change load parameters after calling loadStripe");i=d(e)};var h,g,S,w,E,O,j,x,C,P,k,T,_,$,A,N,R={exports:{}},I={exports:{}},M={},F={};function D(){return S||(S=1,I.exports="production"===process.env.NODE_ENV?function(){if(h)return M;h=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,n=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,s=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,l=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,d=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,v=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,g=e?Symbol.for("react.scope"):60119;function S(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case u:case s:case n:case a:case o:case l:return e;default:switch(e=e&&e.$$typeof){case c:case f:case d:case y:case i:return e;default:return p}}case r:return p}}}function w(e){return S(e)===s}return M.AsyncMode=u,M.ConcurrentMode=s,M.ContextConsumer=c,M.ContextProvider=i,M.Element=t,M.ForwardRef=f,M.Fragment=n,M.Lazy=d,M.Memo=y,M.Portal=r,M.Profiler=a,M.StrictMode=o,M.Suspense=l,M.isAsyncMode=function(e){return w(e)||S(e)===u},M.isConcurrentMode=w,M.isContextConsumer=function(e){return S(e)===c},M.isContextProvider=function(e){return S(e)===i},M.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},M.isForwardRef=function(e){return S(e)===f},M.isFragment=function(e){return S(e)===n},M.isLazy=function(e){return S(e)===d},M.isMemo=function(e){return S(e)===y},M.isPortal=function(e){return S(e)===r},M.isProfiler=function(e){return S(e)===a},M.isStrictMode=function(e){return S(e)===o},M.isSuspense=function(e){return S(e)===l},M.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===n||e===s||e===a||e===o||e===l||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===d||e.$$typeof===y||e.$$typeof===i||e.$$typeof===c||e.$$typeof===f||e.$$typeof===v||e.$$typeof===b||e.$$typeof===g||e.$$typeof===m)},M.typeOf=S,M}():(g||(g=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,n=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,s=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,l=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,d=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,v=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,h=e?Symbol.for("react.scope"):60119;function g(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var m=e.type;switch(m){case u:case s:case n:case a:case o:case l:return m;default:var v=m&&m.$$typeof;switch(v){case c:case f:case d:case y:case i:return v;default:return p}}case r:return p}}}var S=s,w=c,E=i,O=t,j=f,x=n,C=d,P=y,k=r,T=a,_=o,$=l,A=!1;function N(e){return g(e)===s}F.AsyncMode=u,F.ConcurrentMode=S,F.ContextConsumer=w,F.ContextProvider=E,F.Element=O,F.ForwardRef=j,F.Fragment=x,F.Lazy=C,F.Memo=P,F.Portal=k,F.Profiler=T,F.StrictMode=_,F.Suspense=$,F.isAsyncMode=function(e){return A||(A=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),N(e)||g(e)===u},F.isConcurrentMode=N,F.isContextConsumer=function(e){return g(e)===c},F.isContextProvider=function(e){return g(e)===i},F.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},F.isForwardRef=function(e){return g(e)===f},F.isFragment=function(e){return g(e)===n},F.isLazy=function(e){return g(e)===d},F.isMemo=function(e){return g(e)===y},F.isPortal=function(e){return g(e)===r},F.isProfiler=function(e){return g(e)===a},F.isStrictMode=function(e){return g(e)===o},F.isSuspense=function(e){return g(e)===l},F.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===n||e===s||e===a||e===o||e===l||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===d||e.$$typeof===y||e.$$typeof===i||e.$$typeof===c||e.$$typeof===f||e.$$typeof===v||e.$$typeof===b||e.$$typeof===h||e.$$typeof===m)},F.typeOf=g}()),F)),I.exports}function q(){return j?O:(j=1,O="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}function L(){return C?x:(C=1,x=Function.call.bind(Object.prototype.hasOwnProperty))}function V(){if(k)return P;k=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=q(),r={},n=L();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,a,i,c,u){if("production"!==process.env.NODE_ENV)for(var s in o)if(n(o,s)){var f;try{if("function"!=typeof o[s]){var l=Error((c||"React class")+": "+i+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}f=o[s](a,s,c,i,null,t)}catch(e){f=e}if(!f||f instanceof Error||e((c||"React class")+": type specification of "+i+" `"+s+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in r)){r[f.message]=!0;var p=u?u():"";e("Failed "+i+" type: "+f.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(r={})},P=o}function U(){if(_)return T;_=1;var e=D(),t=function(){if(E)return w;E=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;return w=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(n,o){for(var a,i,c=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(n),u=1;u<arguments.length;u++){for(var s in a=Object(arguments[u]))t.call(a,s)&&(c[s]=a[s]);if(e){i=e(a);for(var f=0;f<i.length;f++)r.call(a,i[f])&&(c[i[f]]=a[i[f]])}}return c},w}(),r=q(),n=L(),o=V(),a=function(){};function i(){return null}return"production"!==process.env.NODE_ENV&&(a=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),T=function(c,u){var s="function"==typeof Symbol&&Symbol.iterator,f="<<anonymous>>",l={array:m("array"),bigint:m("bigint"),bool:m("boolean"),func:m("function"),number:m("number"),object:m("object"),string:m("string"),symbol:m("symbol"),any:d(i),arrayOf:function(e){return d(function(t,n,o,a,i){if("function"!=typeof e)return new y("Property `"+i+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var c=t[n];if(!Array.isArray(c))return new y("Invalid "+a+" `"+i+"` of type `"+h(c)+"` supplied to `"+o+"`, expected an array.");for(var u=0;u<c.length;u++){var s=e(c,u,o,a,i+"["+u+"]",r);if(s instanceof Error)return s}return null})},element:d(function(e,t,r,n,o){var a=e[t];return c(a)?null:new y("Invalid "+n+" `"+o+"` of type `"+h(a)+"` supplied to `"+r+"`, expected a single ReactElement.")}),elementType:d(function(t,r,n,o,a){var i=t[r];return e.isValidElementType(i)?null:new y("Invalid "+o+" `"+a+"` of type `"+h(i)+"` supplied to `"+n+"`, expected a single ReactElement type.")}),instanceOf:function(e){return d(function(t,r,n,o,a){return t[r]instanceof e?null:new y("Invalid "+o+" `"+a+"` of type `"+((i=t[r]).constructor&&i.constructor.name?i.constructor.name:f)+"` supplied to `"+n+"`, expected instance of `"+(e.name||f)+"`.");var i})},node:d(function(e,t,r,n,o){return b(e[t])?null:new y("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.")}),objectOf:function(e){return d(function(t,o,a,i,c){if("function"!=typeof e)return new y("Property `"+c+"` of component `"+a+"` has invalid PropType notation inside objectOf.");var u=t[o],s=h(u);if("object"!==s)return new y("Invalid "+i+" `"+c+"` of type `"+s+"` supplied to `"+a+"`, expected an object.");for(var f in u)if(n(u,f)){var l=e(u,f,a,i,c+"."+f,r);if(l instanceof Error)return l}return null})},oneOf:function(e){return Array.isArray(e)?d(function(t,r,n,o,a){for(var i=t[r],c=0;c<e.length;c++)if(p(i,e[c]))return null;var u=JSON.stringify(e,function(e,t){return"symbol"===g(t)?String(t):t});return new y("Invalid "+o+" `"+a+"` of value `"+String(i)+"` supplied to `"+n+"`, expected one of "+u+".")}):("production"!==process.env.NODE_ENV&&a(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),i)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&a("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+S(o)+" at index "+t+"."),i}return d(function(t,o,a,i,c){for(var u=[],s=0;s<e.length;s++){var f=(0,e[s])(t,o,a,i,c,r);if(null==f)return null;f.data&&n(f.data,"expectedType")&&u.push(f.data.expectedType)}return new y("Invalid "+i+" `"+c+"` supplied to `"+a+"`"+(u.length>0?", expected one of type ["+u.join(", ")+"]":"")+".")})},shape:function(e){return d(function(t,n,o,a,i){var c=t[n],u=h(c);if("object"!==u)return new y("Invalid "+a+" `"+i+"` of type `"+u+"` supplied to `"+o+"`, expected `object`.");for(var s in e){var f=e[s];if("function"!=typeof f)return v(o,a,i,s,g(f));var l=f(c,s,o,a,i+"."+s,r);if(l)return l}return null})},exact:function(e){return d(function(o,a,i,c,u){var s=o[a],f=h(s);if("object"!==f)return new y("Invalid "+c+" `"+u+"` of type `"+f+"` supplied to `"+i+"`, expected `object`.");var l=t({},o[a],e);for(var p in l){var d=e[p];if(n(e,p)&&"function"!=typeof d)return v(i,c,u,p,g(d));if(!d)return new y("Invalid "+c+" `"+u+"` key `"+p+"` supplied to `"+i+"`.\nBad object: "+JSON.stringify(o[a],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var m=d(s,p,i,c,u+"."+p,r);if(m)return m}return null})}};function p(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function y(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function d(e){if("production"!==process.env.NODE_ENV)var t={},n=0;function o(o,i,c,s,l,p,d){if(s=s||f,p=p||c,d!==r){if(u){var m=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name="Invariant Violation",m}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var v=s+":"+c;!t[v]&&n<3&&(a("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+s+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[v]=!0,n++)}}return null==i[c]?o?new y(null===i[c]?"The "+l+" `"+p+"` is marked as required in `"+s+"`, but its value is `null`.":"The "+l+" `"+p+"` is marked as required in `"+s+"`, but its value is `undefined`."):null:e(i,c,s,l,p)}var i=o.bind(null,!1);return i.isRequired=o.bind(null,!0),i}function m(e){return d(function(t,r,n,o,a,i){var c=t[r];return h(c)!==e?new y("Invalid "+o+" `"+a+"` of type `"+g(c)+"` supplied to `"+n+"`, expected `"+e+"`.",{expectedType:e}):null})}function v(e,t,r,n,o){return new y((e||"React class")+": "+t+" type `"+r+"."+n+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function b(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(b);if(null===e||c(e))return!0;var t=function(e){var t=e&&(s&&e[s]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var r,n=t.call(e);if(t!==e.entries){for(;!(r=n.next()).done;)if(!b(r.value))return!1}else for(;!(r=n.next()).done;){var o=r.value;if(o&&!b(o[1]))return!1}return!0;default:return!1}}function h(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function g(e){if(null==e)return""+e;var t=h(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function S(e){var t=g(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return y.prototype=Error.prototype,l.checkPropTypes=o,l.resetWarningCache=o.resetWarningCache,l.PropTypes=l,l},T}function B(){if(A)return $;A=1;var e=q();function t(){}function r(){}return r.resetWarningCache=t,$=function(){function n(t,r,n,o,a,i){if(i!==e){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function o(){return n}n.isRequired=n;var a={array:n,bigint:n,bool:n,func:n,number:n,object:n,string:n,symbol:n,any:n,arrayOf:o,element:n,elementType:n,instanceOf:o,node:n,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:r,resetWarningCache:t};return a.PropTypes=a,a}}function W(){if(N)return R.exports;if(N=1,"production"!==process.env.NODE_ENV){var e=D();R.exports=U()(e.isElement,!0)}else R.exports=B()();return R.exports}const Y=b(W());function z(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?z(Object(r),!0).forEach(function(t){G(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):z(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function G(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function K(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=r){var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Q(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var X=function(e,r,n){var o=!!n,a=t.useRef(n);t.useEffect(function(){a.current=n},[n]),t.useEffect(function(){if(!o||!e)return function(){};var t=function(){a.current&&a.current.apply(a,arguments)};return e.on(r,t),function(){e.off(r,t)}},[o,r,e,a])},Z=function(e){var r=t.useRef(e);return t.useEffect(function(){r.current=e},[e]),r.current},ee=function(e){return null!==e&&"object"===H(e)},te="[object Object]",re=function e(t,r){if(!ee(t)||!ee(r))return t===r;var n=Array.isArray(t);if(n!==Array.isArray(r))return!1;var o=Object.prototype.toString.call(t)===te;if(o!==(Object.prototype.toString.call(r)===te))return!1;if(!o&&!n)return t===r;var a=Object.keys(t),i=Object.keys(r);if(a.length!==i.length)return!1;for(var c={},u=0;u<a.length;u+=1)c[a[u]]=!0;for(var s=0;s<i.length;s+=1)c[i[s]]=!0;var f=Object.keys(c);if(f.length!==a.length)return!1;var l=t,p=r;return f.every(function(t){return e(l[t],p[t])})},ne=function(e,t,r){return ee(e)?Object.keys(e).reduce(function(n,o){var a=!ee(t)||!re(e[o],t[o]);return r.includes(o)?(a&&console.warn("Unsupported prop change: options.".concat(o," is not a mutable property.")),n):a?J(J({},n||{}),{},G({},o,e[o])):n},null):null},oe="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",ae=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oe;if(null===e||ee(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(r)},ie=t.createContext(null);ie.displayName="ElementsContext";var ce=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},ue=function(e){var r=e.stripe,n=e.options,o=e.children,a=t.useMemo(function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oe;if(function(e){return ee(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(e){return ae(e,t)})};var r=ae(e,t);return null===r?{tag:"empty"}:{tag:"sync",stripe:r}}(r)},[r]),i=K(t.useState(function(){return{stripe:"sync"===a.tag?a.stripe:null,elements:"sync"===a.tag?a.stripe.elements(n):null}}),2),c=i[0],u=i[1];t.useEffect(function(){var e=!0,t=function(e){u(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return"async"!==a.tag||c.stripe?"sync"!==a.tag||c.stripe||t(a.stripe):a.stripePromise.then(function(r){r&&e&&t(r)}),function(){e=!1}},[a,c,n]);var s=Z(r);t.useEffect(function(){null!==s&&s!==r&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[s,r]);var f=Z(n);return t.useEffect(function(){if(c.elements){var e=ne(n,f,["clientSecret","fonts"]);e&&c.elements.update(e)}},[n,f,c.elements]),t.useEffect(function(){var e;(e=c.stripe)&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.10.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.10.0",url:"https://stripe.com/docs/stripe-js/react"}))},[c.stripe]),t.createElement(ie.Provider,{value:c},o)};ue.propTypes={stripe:Y.any,options:Y.object};var se=t.createContext(null);se.displayName="CheckoutSdkContext",t.createContext(null).displayName="CheckoutContext",Y.shape({fetchClientSecret:Y.func.isRequired,elementsOptions:Y.object});var fe=function(e){var r=t.useContext(se),n=t.useContext(ie);if(r&&n)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return r?function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e}(r,e):ce(n,e)},le=["mode"],pe=function(e,r){var n,o="".concat((n=e).charAt(0).toUpperCase()+n.slice(1),"Element"),a=r?function(e){return fe("mounts <".concat(o,">")),t.createElement("div",{id:e.id,className:e.className})}:function(r){var n,a=r.id,i=r.className,c=r.options,u=void 0===c?{}:c,s=r.onBlur,f=r.onFocus,l=r.onReady,p=r.onChange,y=r.onEscape,d=r.onClick,m=r.onLoadError,v=r.onLoaderStart,b=r.onNetworksChange,h=r.onConfirm,g=r.onCancel,S=r.onShippingAddressChange,w=r.onShippingRateChange,E=r.onSavedPaymentMethodRemove,O=r.onSavedPaymentMethodUpdate,j=fe("mounts <".concat(o,">")),x="elements"in j?j.elements:null,C="checkoutSdk"in j?j.checkoutSdk:null,P=K(t.useState(null),2),k=P[0],T=P[1],_=t.useRef(null),$=t.useRef(null);X(k,"blur",s),X(k,"focus",f),X(k,"escape",y),X(k,"click",d),X(k,"loaderror",m),X(k,"loaderstart",v),X(k,"networkschange",b),X(k,"confirm",h),X(k,"cancel",g),X(k,"shippingaddresschange",S),X(k,"shippingratechange",w),X(k,"savedpaymentmethodremove",E),X(k,"savedpaymentmethodupdate",O),X(k,"change",p),l&&(n="expressCheckout"===e?l:function(){l(k)}),X(k,"ready",n),t.useLayoutEffect(function(){if(null===_.current&&null!==$.current&&(x||C)){var t=null;if(C)switch(e){case"payment":t=C.createPaymentElement(u);break;case"address":if(!("mode"in u))throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");var r=u.mode,n=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(u,le);if("shipping"===r)t=C.createShippingAddressElement(n);else{if("billing"!==r)throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.");t=C.createBillingAddressElement(n)}break;case"expressCheckout":t=C.createExpressCheckoutElement(u);break;case"currencySelector":t=C.createCurrencySelectorElement();break;case"taxId":t=C.createTaxIdElement(u);break;default:throw new Error("Invalid Element type ".concat(o,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else x&&(t=x.create(e,u));_.current=t,T(t),t&&t.mount($.current)}},[x,C,u]);var A=Z(u);return t.useEffect(function(){if(_.current){var e=ne(u,A,["paymentRequest"]);e&&"update"in _.current&&_.current.update(e)}},[u,A]),t.useLayoutEffect(function(){return function(){if(_.current&&"function"==typeof _.current.destroy)try{_.current.destroy(),_.current=null}catch(e){}}},[]),t.createElement("div",{id:a,className:i,ref:$})};return a.propTypes={id:Y.string,className:Y.string,onChange:Y.func,onBlur:Y.func,onFocus:Y.func,onReady:Y.func,onEscape:Y.func,onClick:Y.func,onLoadError:Y.func,onLoaderStart:Y.func,onNetworksChange:Y.func,onConfirm:Y.func,onCancel:Y.func,onShippingAddressChange:Y.func,onShippingRateChange:Y.func,onSavedPaymentMethodRemove:Y.func,onSavedPaymentMethodUpdate:Y.func,options:Y.object},a.displayName=o,a.__elementType=e,a},ye="undefined"==typeof window;t.createContext(null).displayName="EmbeddedCheckoutProviderContext",pe("auBankAccount",ye),pe("card",ye),pe("cardNumber",ye),pe("cardExpiry",ye),pe("cardCvc",ye),pe("fpxBank",ye),pe("iban",ye),pe("idealBank",ye),pe("p24Bank",ye),pe("epsBank",ye);var de=pe("payment",ye);pe("expressCheckout",ye),pe("currencySelector",ye),pe("paymentRequestButton",ye),pe("linkAuthentication",ye),pe("address",ye),pe("shippingAddress",ye),pe("paymentMethodMessaging",ye),pe("affirmMessage",ye),pe("afterpayClearpayMessage",ye),pe("taxId",ye);const me="The payment didn't go through. Try again or use another payment method.",ve=new Set(["card_error","validation_error"]),be=({skin:a,onReady:i})=>{const c=fe("calls useStripe()").stripe,u=(g=t.useContext(ie),ce(g,"calls useElements()")).elements,{payment:s}=o.usePaymentAdapter(),f=o.useResultEmitter(),l=o.useConfirmRegistration(),p=o.useSummaryReporter(),[y,d]=t.useState(!1),m=t.useRef(!1),[v,b]=t.useState(null),h=s.config.client_secret;var g;t.useEffect(()=>{if(!c)return;let e=!1;return c.retrievePaymentIntent(h).then(t=>{if(e)return;const r=t.paymentIntent;r&&"number"==typeof r.amount&&r.currency&&p({amount:r.amount,currency:r.currency})}),()=>{e=!0}},[c,h,p]);const S=t.useCallback(async()=>{if(c&&u&&!m.current){m.current=!0,d(!0),b(null);try{const{error:e}=await u.submit();if(e)return;const{error:t,paymentIntent:n}=await c.confirmPayment({elements:u,clientSecret:h,confirmParams:{return_url:window.location.href},redirect:"if_required"}),o=n??t?.payment_intent;if(o&&("succeeded"===o.status||"requires_capture"===o.status))return void f(function({amount:e,currency:t}){return{status:r.PAYMENT_OUTCOME_STATUSES.SUCCESS,agentText:r.defaultAgentText({status:r.PAYMENT_OUTCOME_STATUSES.SUCCESS,amount:e,currency:t})}}(o));t&&!ve.has(t.type)&&b(function(e){return"payment_intent_authentication_failure"===e.code?"We couldn't verify this payment with your bank. Try again or use another payment method.":me}(t))}catch(e){n.logger.warn({message:"Stripe confirm threw",api_name:"stripe-payment",error_message:e instanceof Error?e.message:String(e)}),b(me)}finally{m.current=!1,d(!1)}}},[c,u,h,f]);return t.useEffect(()=>(l({confirm:S,isConfirming:y}),()=>l(null)),[S,y,l]),e.jsxs(e.Fragment,{children:[e.jsx(de,{options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}},onReady:i}),v&&e.jsx("p",{role:"alert",className:"text-sm mt-3",style:{color:a.danger},children:v})]})};exports.default={label:"Stripe",FormComponent:({skin:a,onReady:i})=>{const{themeStyles:c,theme:u}=n.useBranding(),{payment:s}=o.usePaymentAdapter(),{publishable_key:f,client_secret:l}=s.config,p=t.useMemo(()=>f.startsWith("pk_")?v(f):null,[f]),y=t.useMemo(()=>r.buildBrandSkin(c,u),[c,u]),d=t.useMemo(()=>function(e,t,r){return{theme:"dark"===t?"night":"stripe",variables:{colorPrimary:e.statusDiscovery.solid,colorBackground:r.cardBg,colorText:r.text,colorDanger:"#df1b41",fontFamily:r.fontFamily,borderRadius:`${r.radius}px`,spacingUnit:"3px",fontSizeBase:"16px"}}}(c,u,y),[c,u,y]),m=t.useMemo(()=>({clientSecret:l,appearance:d}),[l,d]);return p?e.jsx(ue,{stripe:p,options:m,children:e.jsx(be,{skin:a,onReady:i})},l):null}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{forwardRef as r,createElement as a,useMemo as o,useRef as n,useEffect as l,useState as s,useCallback as i}from"react";import{resolvePaymentProvider as c,buildBrandSkin as d,PAYMENT_OUTCOME_STATUSES as m,formatAmount as u}from"@1interface/chat-core";import{logger as h,useBranding as p}from"@1interface/shared-core";import{P as y,a as b,u as f,b as g,c as w}from"./PaymentResultChannel-Cxl4EZJx.js";const k=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},v=(...e)=>e.filter((e,t,r)=>Boolean(e)&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim(),x=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var N={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const C=r(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:n="",children:l,iconNode:s,...i},c)=>a("svg",{ref:c,...N,width:t,height:t,stroke:e,strokeWidth:o?24*Number(r)/Number(t):r,className:v("lucide",n),...!l&&!x(i)&&{"aria-hidden":"true"},...i},[...s.map(([e,t])=>a(e,t)),...Array.isArray(l)?l:[l]])),S=((e,t)=>{const o=r(({className:r,...o},n)=>{return a(C,{ref:n,iconNode:t,className:v(`lucide-${l=k(e),l.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,r),...o});var l});return o.displayName=k(e),o})("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),R=({paymentInit:t=null,onResult:r})=>{const a=o(()=>c(t?.provider),[t]),n=o(()=>a&&t?a.normalize(t):null,[a,t]);return t?a&&n?e(y,{entry:a,payment:n,fallback:e(j,{}),children:e(b,{onResult:e=>r?.(e),children:e(A,{})})},a.type):e(P,{paymentInit:t,reason:a?"invalid payload":"unknown provider",onResult:r},t.payment_id??""):null},P=({paymentInit:e,reason:t,onResult:r})=>{const a=n(!1);return l(()=>{a.current||(a.current=!0,h.warn({message:"Payment surface refused payload",api_name:"payment-host",provider:e.provider??null,reference_id:e.payment_id,reason:t}),r?.({status:m.FAILURE,agentText:"The payment could not be opened.",userMessage:"This payment could not be opened. Please try again."}))},[e,t,r]),null},A=()=>{const{themeStyles:r,theme:a}=p(),{adapter:n,payment:l}=f(),c=g(),[m,h]=s(!1),y=i(()=>h(!0),[]),b=o(()=>d(r,a),[r,a]),w=c?.amount??l.amount??0,k=c?.currency??l.currency??"usd",v=null!=c?.amount||null!=l.amount,x=((e,t)=>u(e,t)??"")(w,k),N=n.FormComponent;return t("div",{className:"w-full flex-1 min-h-0 overflow-y-auto [&::-webkit-scrollbar]:hidden [scrollbar-width:none] relative",style:{background:b.pageBg,color:b.text,fontFamily:b.fontFamily,colorScheme:b.colorScheme},children:[!m&&e(B,{skin:b}),e("div",{className:"min-h-full flex items-center justify-center p-4",style:{visibility:m?"visible":"hidden"},children:t("div",{className:"w-full max-w-lg p-6",style:{background:b.cardBg,borderRadius:b.radius,boxShadow:b.cardShadow,color:b.text},children:[e("h1",{className:"text-base font-semibold text-center mb-3.5",style:{color:b.heading},children:"Payment Options"}),e("div",{className:"mb-3.5",children:e(N,{skin:b,onReady:y})}),!n.hideShellSubmit&&v&&e(L,{label:`Pay ${x}`,background:r.statusDiscovery.solid,color:r.statusDiscovery.text,radius:b.radius}),!n.hideShellFooter&&t("p",{className:"text-xs text-center mt-2.5",style:{color:b.muted},children:["Powered by ",n.label]})]})})]})},j=()=>{const{themeStyles:t,theme:r}=p(),a=o(()=>d(t,r),[t,r]);return e("div",{className:"w-full flex-1 min-h-0 relative",style:{background:a.pageBg},children:e(B,{skin:a})})},B=({skin:r})=>t("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3",style:{background:r.pageBg,color:r.text},"aria-live":"polite","aria-busy":"true",children:[e(S,{className:"h-8 w-8 animate-spin",style:{color:r.accent}}),e("p",{className:"text-sm",style:{color:r.muted},children:"Loading payment…"})]}),L=({label:t,background:r,color:a,radius:o})=>{const n=w();return e("button",{type:"button",onClick:()=>n?.confirm(),disabled:!n||n.isConfirming,className:"w-full p-3 text-sm font-semibold border-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-70",style:{background:r,color:a,borderRadius:o},children:n?.isConfirming?"Processing…":t})};export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),t=require("@1interface/chat-core"),s=require("@1interface/shared-core"),a=require("./PaymentResultChannel-BeNC8yyV.cjs"),n=e=>{const r=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,r,t)=>t?t.toUpperCase():r.toLowerCase()))(e);return r.charAt(0).toUpperCase()+r.slice(1)},o=(...e)=>e.filter((e,r,t)=>Boolean(e)&&""!==e.trim()&&t.indexOf(e)===r).join(" ").trim(),l=e=>{for(const r in e)if(r.startsWith("aria-")||"role"===r||"title"===r)return!0};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const c=r.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:a,className:n="",children:c,iconNode:d,...u},m)=>r.createElement("svg",{ref:m,...i,width:t,height:t,stroke:e,strokeWidth:a?24*Number(s)/Number(t):s,className:o("lucide",n),...!c&&!l(u)&&{"aria-hidden":"true"},...u},[...d.map(([e,t])=>r.createElement(e,t)),...Array.isArray(c)?c:[c]])),d=((e,t)=>{const s=r.forwardRef(({className:s,...a},l)=>{return r.createElement(c,{ref:l,iconNode:t,className:o(`lucide-${i=n(e),i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,s),...a});var i});return s.displayName=n(e),s})("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),u=({paymentInit:e,reason:a,onResult:n})=>{const o=r.useRef(!1);return r.useEffect(()=>{o.current||(o.current=!0,s.logger.warn({message:"Payment surface refused payload",api_name:"payment-host",provider:e.provider??null,reference_id:e.payment_id,reason:a}),n?.({status:t.PAYMENT_OUTCOME_STATUSES.FAILURE,agentText:"The payment could not be opened.",userMessage:"This payment could not be opened. Please try again."}))},[e,a,n]),null},m=()=>{const{themeStyles:n,theme:o}=s.useBranding(),{adapter:l,payment:i}=a.usePaymentAdapter(),c=a.useReportedSummary(),[d,u]=r.useState(!1),m=r.useCallback(()=>u(!0),[]),y=r.useMemo(()=>t.buildBrandSkin(n,o),[n,o]),x=c?.amount??i.amount??0,b=c?.currency??i.currency??"usd",f=null!=c?.amount||null!=i.amount,g=((e,r)=>t.formatAmount(e,r)??"")(x,b),v=l.FormComponent;return e.jsxs("div",{className:"w-full flex-1 min-h-0 overflow-y-auto [&::-webkit-scrollbar]:hidden [scrollbar-width:none] relative",style:{background:y.pageBg,color:y.text,fontFamily:y.fontFamily,colorScheme:y.colorScheme},children:[!d&&e.jsx(h,{skin:y}),e.jsx("div",{className:"min-h-full flex items-center justify-center p-4",style:{visibility:d?"visible":"hidden"},children:e.jsxs("div",{className:"w-full max-w-lg p-6",style:{background:y.cardBg,borderRadius:y.radius,boxShadow:y.cardShadow,color:y.text},children:[e.jsx("h1",{className:"text-base font-semibold text-center mb-3.5",style:{color:y.heading},children:"Payment Options"}),e.jsx("div",{className:"mb-3.5",children:e.jsx(v,{skin:y,onReady:m})}),!l.hideShellSubmit&&f&&e.jsx(p,{label:`Pay ${g}`,background:n.statusDiscovery.solid,color:n.statusDiscovery.text,radius:y.radius}),!l.hideShellFooter&&e.jsxs("p",{className:"text-xs text-center mt-2.5",style:{color:y.muted},children:["Powered by ",l.label]})]})})]})},y=()=>{const{themeStyles:a,theme:n}=s.useBranding(),o=r.useMemo(()=>t.buildBrandSkin(a,n),[a,n]);return e.jsx("div",{className:"w-full flex-1 min-h-0 relative",style:{background:o.pageBg},children:e.jsx(h,{skin:o})})},h=({skin:r})=>e.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3",style:{background:r.pageBg,color:r.text},"aria-live":"polite","aria-busy":"true",children:[e.jsx(d,{className:"h-8 w-8 animate-spin",style:{color:r.accent}}),e.jsx("p",{className:"text-sm",style:{color:r.muted},children:"Loading payment…"})]}),p=({label:r,background:t,color:s,radius:n})=>{const o=a.useConfirmHandle();return e.jsx("button",{type:"button",onClick:()=>o?.confirm(),disabled:!o||o.isConfirming,className:"w-full p-3 text-sm font-semibold border-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-70",style:{background:t,color:s,borderRadius:n},children:o?.isConfirming?"Processing…":r})};exports.default=({paymentInit:s=null,onResult:n})=>{const o=r.useMemo(()=>t.resolvePaymentProvider(s?.provider),[s]),l=r.useMemo(()=>o&&s?o.normalize(s):null,[o,s]);return s?o&&l?e.jsx(a.PaymentProvider,{entry:o,payment:l,fallback:e.jsx(y,{}),children:e.jsx(a.PaymentResultChannelProvider,{onResult:e=>n?.(e),children:e.jsx(m,{})})},o.type):e.jsx(u,{paymentInit:s,reason:o?"invalid payload":"unknown provider",onResult:n},s.payment_id??""):null};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),r=require("react"),t=r.createContext(void 0),n=new WeakMap,s=r.createContext(null),u=()=>{const e=r.useContext(s);if(!e)throw new Error("Payment result channel hooks must be used inside PaymentResultChannelProvider");return e};exports.PaymentProvider=({children:s,entry:u,payment:a,fallback:o=null})=>{const l=function(s){let u=n.get(s);return u||(u=r.lazy(()=>s.loadAdapter().catch(e=>{throw n.delete(s),e}).then(({default:n})=>({default:function({children:s,payment:u}){const a=r.useMemo(()=>({adapter:n,payment:u}),[u]);return e.jsx(t.Provider,{value:a,children:s})}}))),n.set(s,u)),u}(u);return e.jsx(r.Suspense,{fallback:o,children:e.jsx(l,{payment:a,children:s})})},exports.PaymentResultChannelProvider=({onResult:t,children:n})=>{const[u,a]=r.useState(null),[o,l]=r.useState(null),i=r.useRef(t);i.current=t;const m=r.useCallback(e=>{i.current(e)},[]),c=r.useCallback(e=>{a(e)},[]),d=r.useCallback(e=>{l(e)},[]),p=r.useMemo(()=>({emitResult:m,registerConfirm:c,confirmHandle:u,reportSummary:d,summary:o}),[m,c,u,d,o]);return e.jsx(s.Provider,{value:p,children:n})},exports.useConfirmHandle=()=>u().confirmHandle,exports.useConfirmRegistration=()=>u().registerConfirm,exports.usePaymentAdapter=()=>{const e=r.useContext(t);if(!e)throw new Error("usePaymentAdapter must be used within a PaymentProvider");return e},exports.useReportedSummary=()=>u().summary,exports.useResultEmitter=()=>u().emitResult,exports.useSummaryReporter=()=>u().reportSummary;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{Suspense as r,lazy as t,useMemo as n,useContext as a,createContext as l,useState as o,useRef as u,useCallback as s}from"react";const i=l(void 0),m=new WeakMap,c=({children:a,entry:l,payment:o,fallback:u=null})=>{const s=function(r){let a=m.get(r);return a||(a=t(()=>r.loadAdapter().catch(e=>{throw m.delete(r),e}).then(({default:r})=>({default:function({children:t,payment:a}){const l=n(()=>({adapter:r,payment:a}),[a]);return e(i.Provider,{value:l,children:t})}}))),m.set(r,a)),a}(l);return e(r,{fallback:u,children:e(s,{payment:o,children:a})})},d=()=>{const e=a(i);if(!e)throw new Error("usePaymentAdapter must be used within a PaymentProvider");return e},h=l(null),f=({onResult:r,children:t})=>{const[a,l]=o(null),[i,m]=o(null),c=u(r);c.current=r;const d=s(e=>{c.current(e)},[]),f=s(e=>{l(e)},[]),p=s(e=>{m(e)},[]),y=n(()=>({emitResult:d,registerConfirm:f,confirmHandle:a,reportSummary:p,summary:i}),[d,f,a,p,i]);return e(h.Provider,{value:y,children:t})},p=()=>{const e=a(h);if(!e)throw new Error("Payment result channel hooks must be used inside PaymentResultChannelProvider");return e},y=()=>p().emitResult,P=()=>p().registerConfirm,v=()=>p().confirmHandle,w=()=>p().reportSummary,b=()=>p().summary;export{c as P,f as a,b,v as c,y as d,P as e,w as f,d as u};
|
package/dist/chat-shell.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root{--background: 222.34 49% 11%;--foreground: 0 0% 100%;--card: 215.2915 27.9312% 26.8494%;--card-foreground: 0 0% 100%;--popover: 215.2915 27.9312% 26.8494%;--popover-foreground: 0 0% 100%;--primary: 216.8916 105.653% 59.6083%;--primary-foreground: 0 0% 100%;--secondary: 149.9516 168.4095% 24.2653%;--secondary-foreground: 0 0% 100%;--muted: 250 11.7647% 20%;--muted-foreground: 250 10.1124% 65.098%;--accent: 217.2414 32.5843% 17.451%;--accent-foreground: 210 40% 98.0392%;--destructive: 0 62.3529% 50%;--destructive-foreground: 252 20% 95.098%;--border: 217.2414 32.5843% 17.451%;--input: 217.2414 32.5843% 17.451%;--ring: 212.7273 26.8293% 83.9216%;--chart-1: 312.9412 100% 50%;--chart-2: 273.8824 100% 50%;--chart-3: 186.1176 100% 50%;--chart-4: 168 100% 50%;--chart-5: 54.1176 100% 50%;--radius: .5rem}.dark{--background: 222.34 49% 11%;--foreground: 0 0% 100%;--card: 215.2915 27.9312% 26.8494%;--card-foreground: 0 0% 100%;--popover: 215.2915 27.9312% 26.8494%;--popover-foreground: 0 0% 100%;--primary: 216.8916 105.653% 59.6083%;--primary-foreground: 0 0% 100%;--secondary: 149.9516 168.4095% 24.2653%;--secondary-foreground: 0 0% 100%;--muted: 250 11.7647% 20%;--muted-foreground: 250 10.1124% 65.098%;--accent: 217.2414 32.5843% 17.451%;--accent-foreground: 210 40% 98.0392%;--destructive: 0 62.8205% 30.5882%;--destructive-foreground: 210 40% 98.0392%;--border: 217.2414 32.5843% 17.451%;--input: 217.2414 32.5843% 17.451%;--ring: 212.7273 26.8293% 83.9216%;--chart-1: 312.9412 100% 50%;--chart-2: 273.8824 100% 50%;--chart-3: 186.1176 100% 50%;--chart-4: 168 100% 50%;--chart-5: 54.1176 100% 50%;--radius: .5rem}*{border-color:hsl(var(--border))}body{background-color:hsl(var(--background));color:hsl(var(--foreground))}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media(min-width:1400px){.container{max-width:1400px}}.
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root{--background: 222.34 49% 11%;--foreground: 0 0% 100%;--card: 215.2915 27.9312% 26.8494%;--card-foreground: 0 0% 100%;--popover: 215.2915 27.9312% 26.8494%;--popover-foreground: 0 0% 100%;--primary: 216.8916 105.653% 59.6083%;--primary-foreground: 0 0% 100%;--secondary: 149.9516 168.4095% 24.2653%;--secondary-foreground: 0 0% 100%;--muted: 250 11.7647% 20%;--muted-foreground: 250 10.1124% 65.098%;--accent: 217.2414 32.5843% 17.451%;--accent-foreground: 210 40% 98.0392%;--destructive: 0 62.3529% 50%;--destructive-foreground: 252 20% 95.098%;--border: 217.2414 32.5843% 17.451%;--input: 217.2414 32.5843% 17.451%;--ring: 212.7273 26.8293% 83.9216%;--chart-1: 312.9412 100% 50%;--chart-2: 273.8824 100% 50%;--chart-3: 186.1176 100% 50%;--chart-4: 168 100% 50%;--chart-5: 54.1176 100% 50%;--radius: .5rem}.dark{--background: 222.34 49% 11%;--foreground: 0 0% 100%;--card: 215.2915 27.9312% 26.8494%;--card-foreground: 0 0% 100%;--popover: 215.2915 27.9312% 26.8494%;--popover-foreground: 0 0% 100%;--primary: 216.8916 105.653% 59.6083%;--primary-foreground: 0 0% 100%;--secondary: 149.9516 168.4095% 24.2653%;--secondary-foreground: 0 0% 100%;--muted: 250 11.7647% 20%;--muted-foreground: 250 10.1124% 65.098%;--accent: 217.2414 32.5843% 17.451%;--accent-foreground: 210 40% 98.0392%;--destructive: 0 62.8205% 30.5882%;--destructive-foreground: 210 40% 98.0392%;--border: 217.2414 32.5843% 17.451%;--input: 217.2414 32.5843% 17.451%;--ring: 212.7273 26.8293% 83.9216%;--chart-1: 312.9412 100% 50%;--chart-2: 273.8824 100% 50%;--chart-3: 186.1176 100% 50%;--chart-4: 168 100% 50%;--chart-5: 54.1176 100% 50%;--radius: .5rem}*{border-color:hsl(var(--border))}body{background-color:hsl(var(--background));color:hsl(var(--foreground))}.container{width:100%;margin-right:auto;margin-left:auto;padding-right:2rem;padding-left:2rem}@media(min-width:1400px){.container{max-width:1400px}}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.z-10{z-index:10}.z-\[105\]{z-index:105}.mb-3\.5{margin-bottom:.875rem}.mt-2\.5{margin-top:.625rem}.mt-3{margin-top:.75rem}.flex{display:flex}.hidden{display:none}.h-8{height:2rem}.min-h-0{min-height:0px}.min-h-full{min-height:100%}.w-8{width:2rem}.w-full{width:100%}.max-w-lg{max-width:32rem}.flex-1{flex:1 1 0%}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-3{gap:.75rem}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.border{border-width:1px}.border-0{border-width:0px}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.text-center{text-align:center}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-semibold{font-weight:600}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.\[scrollbar-width\:none\]{scrollbar-width:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-70:disabled{opacity:.7}.\[\&\:\:-webkit-scrollbar\]\:hidden::-webkit-scrollbar{display:none}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getPaymentProvider as e,conversationsReducer as t,chatReducer as n,apiReducers as r,serializableCheck as o,apiMiddleware as i,resetAllApiState as s,bindChatLogger as a,useChatSettings as c,useAuth as l,ChatSettingsContext as u,useUploadDocumentMutation as d,useDeleteDocumentMutation as p,getApiErrorMessage as f,useGetBrandingQuery as h,createAdapter as m,DEFAULT_PROTOCOL as y,createDefaultAdapterConfig as _,ProtocolContext as g,ConfigurationContext as v,useConfigurationValue as b,ChatCallbacksContext as w,defaultCancelOutcome as S,isHttpsUrl as E,registerPaymentProvider as P,setDefaultPaymentProvider as I}from"@1interface/chat-core";import{getPaymentProviderHint as k,indicatorReducer as T,sessionReducer as M,sessionListenerMiddleware as A,clearSession as C,sessionExpired as O,setAccessTokenReader as D,setTokenExpiresAtReader as z,useStorage as N,STT_IMPLEMENTATIONS as R,STORAGE_KEYS as x,setNetworkLoggingEnabled as j,APPEARANCE_MODES as F,getAppearanceModeStorageKey as L,brandingToThemeStyles as $,ORB_POSITIONS as U,BrandingContext as H,setModuleStorage as K,hydrateSession as G,logger as W,StorageContext as V,setSession as Y,initializeChatConfig as q,setTokenRefreshHandler as B,NetworkContext as X}from"@1interface/shared-core";import{createAction as J,nanoid as Q,formatProdErrorMessage as Z,createSelector as ee,createAsyncThunk as te,createSlice as ne,prepareAutoBatched as re,isAnyOf as oe,isFulfilled as ie,isRejectedWithValue as se,combineReducers as ae,isPlainObject as ce,SHOULD_AUTOBATCH as le,isAllOf as ue,isRejected as de,isPending as pe,isAction as fe,createNextState as he,isAsyncThunkAction as me,configureStore as ye,createListenerMiddleware as _e}from"@reduxjs/toolkit";import{voiceReducer as ge,voiceListenerMiddleware as ve}from"@1interface/voice-core";import{jsx as be,Fragment as we}from"react/jsx-runtime";import{useState as Se,useEffect as Ee,useCallback as Pe,useContext as Ie,createContext as ke,useMemo as Te,useRef as Me,Suspense as Ae,lazy as Ce}from"react";import{useDispatch as Oe,Provider as De}from"react-redux";import{AudioPlatformProvider as ze}from"@1interface/voice-shell";function Ne(){const t=e(k());return t?t.loadAdapter().catch(()=>{}):Promise.resolve()}var Re=Symbol.for("immer-nothing"),xe=Symbol.for("immer-draftable"),je=Symbol.for("immer-state"),Fe="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Le(e,...t){if("production"!==process.env.NODE_ENV){const n=Fe[e],r=ct(n)?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var $e=Object,Ue=$e.getPrototypeOf,He="constructor",Ke="prototype",Ge="configurable",We="enumerable",Ve="writable",Ye="value",qe=e=>!!e&&!!e[je];function Be(e){return!!e&&(Qe(e)||ot(e)||!!e[xe]||!!e[He]?.[xe]||it(e)||st(e))}var Xe=$e[Ke][He].toString(),Je=new WeakMap;function Qe(e){if(!e||!at(e))return!1;const t=Ue(e);if(null===t||t===$e[Ke])return!0;const n=$e.hasOwnProperty.call(t,He)&&t[He];if(n===Object)return!0;if(!ct(n))return!1;let r=Je.get(n);return void 0===r&&(r=Function.toString.call(n),Je.set(n,r)),r===Xe}function Ze(e,t,n=!0){0===et(e)?(n?Reflect.ownKeys(e):$e.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function et(e){const t=e[je];return t?t.type_:ot(e)?1:it(e)?2:st(e)?3:0}var tt=(e,t,n=et(e))=>2===n?e.has(t):$e[Ke].hasOwnProperty.call(e,t),nt=(e,t,n=et(e))=>2===n?e.get(t):e[t],rt=(e,t,n,r=et(e))=>{2===r?e.set(t,n):3===r?e.add(n):e[t]=n},ot=Array.isArray,it=e=>e instanceof Map,st=e=>e instanceof Set,at=e=>"object"==typeof e,ct=e=>"function"==typeof e,lt=e=>"boolean"==typeof e,ut=e=>e.copy_||e.base_,dt=e=>e.modified_?e.copy_:e.base_;function pt(e,t){if(it(e))return new Map(e);if(st(e))return new Set(e);if(ot(e))return Array[Ke].slice.call(e);const n=Qe(e);if(!0===t||"class_only"===t&&!n){const t=$e.getOwnPropertyDescriptors(e);delete t[je];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){const o=n[r],i=t[o];!1===i[Ve]&&(i[Ve]=!0,i[Ge]=!0),(i.get||i.set)&&(t[o]={[Ge]:!0,[Ve]:!0,[We]:i[We],[Ye]:e[o]})}return $e.create(Ue(e),t)}{const t=Ue(e);if(null!==t&&n)return{...e};const r=$e.create(t);return $e.assign(r,e)}}function ft(e,t=!1){return mt(e)||qe(e)||!Be(e)||(et(e)>1&&$e.defineProperties(e,{set:ht,add:ht,clear:ht,delete:ht}),$e.freeze(e),t&&Ze(e,(e,t)=>{ft(t,!0)},!1)),e}var ht={[Ye]:function(){Le(2)}};function mt(e){return null===e||!at(e)||$e.isFrozen(e)}var yt="MapSet",_t="Patches",gt="ArrayMethods",vt={};function bt(e){const t=vt[e];return t||Le(0,e),t}var wt,St=e=>!!vt[e],Et=()=>wt;function Pt(e,t){t&&(e.patchPlugin_=bt(_t),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function It(e){kt(e),e.drafts_.forEach(Mt),e.drafts_=null}function kt(e){e===wt&&(wt=e.parent_)}var Tt=e=>wt={drafts_:[],parent_:wt,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:St(yt)?bt(yt):void 0,arrayMethodsPlugin_:St(gt)?bt(gt):void 0};function Mt(e){const t=e[je];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function At(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(void 0!==e&&e!==n){n[je].modified_&&(It(t),Le(4)),Be(e)&&(e=Ct(t,e));const{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[je].base_,e,t)}else e=Ct(t,n);return function(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ft(t,n)}(t,e,!0),It(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Re?e:void 0}function Ct(e,t){if(mt(t))return t;const n=t[je];if(!n)return xt(t,e.handledSet_,e);if(!Dt(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);Rt(n,e)}return n.copy_}function Ot(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Dt=(e,t)=>e.scope_===t,zt=[];function Nt(e,t,n,r){const o=ut(e),i=e.type_;if(void 0!==r&&nt(o,r,i)===t)return void rt(o,r,n,i);if(!e.draftLocations_){const t=e.draftLocations_=new Map;Ze(o,(e,n)=>{if(qe(n)){const r=t.get(n)||[];r.push(e),t.set(n,r)}})}const s=e.draftLocations_.get(t)??zt;for(const e of s)rt(o,e,n,i)}function Rt(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:n}=t;if(n){const r=n.getPath(e);r&&n.generatePatches_(e,r,t)}Ot(e)}}function xt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||qe(e)||t.has(e)||!Be(e)||mt(e)||(t.add(e),Ze(e,(r,o)=>{if(qe(o)){const t=o[je];if(Dt(t,n)){const n=dt(t);rt(e,r,n,e.type_),Ot(t)}}else Be(o)&&xt(o,t,n)})),e}var jt={get(e,t){if(t===je)return e;let n=e.scope_.arrayMethodsPlugin_;const r=1===e.type_&&"string"==typeof t;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const o=ut(e);if(!tt(o,t,e.type_))return function(e,t,n){const r=$t(t,n);return r?Ye in r?r[Ye]:r.get?.call(e.draft_):void 0}(e,o,t);const i=o[t];if(e.finalized_||!Be(i))return i;if(r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&function(e){const t=+e;return Number.isInteger(t)&&String(t)===e}(t))return i;if(i===Lt(e.base_,t)){Ht(e);const n=1===e.type_?+t:t,r=Kt(0,i,e,n);return e.copy_[n]=r}return i},has:(e,t)=>t in ut(e),ownKeys:e=>Reflect.ownKeys(ut(e)),set(e,t,n){const r=$t(ut(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=Lt(ut(e),t),s=r?.[je];if(s&&s.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(((o=n)===(i=r)?0!==o||1/o==1/i:o!=o&&i!=i)&&(void 0!==n||tt(e.base_,t,e.type_)))return!0;Ht(e),Ut(e)}var o,i;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),function(e,t,n){const{scope_:r}=e;if(qe(n)){const o=n[je];Dt(o,r)&&o.callbacks_.push(function(){Ht(e);const r=dt(o);Nt(e,n,r,t)})}else Be(n)&&e.callbacks_.push(function(){const o=ut(e);3===e.type_?o.has(n)&&xt(n,r.handledSet_,r):nt(o,t,e.type_)===n&&r.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&xt(nt(e.copy_,t,e.type_),r.handledSet_,r)})}(e,t,n)),!0},deleteProperty:(e,t)=>(Ht(e),void 0!==Lt(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),Ut(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=ut(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{[Ve]:!0,[Ge]:1!==e.type_||"length"!==t,[We]:r[We],[Ye]:n[t]}:r},defineProperty(){Le(11)},getPrototypeOf:e=>Ue(e.base_),setPrototypeOf(){Le(12)}},Ft={};for(let e in jt){let t=jt[e];Ft[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function Lt(e,t){const n=e[je];return(n?ut(n):e)[t]}function $t(e,t){if(!(t in e))return;let n=Ue(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ue(n)}}function Ut(e){e.modified_||(e.modified_=!0,e.parent_&&Ut(e.parent_))}function Ht(e){e.copy_||(e.assigned_=new Map,e.copy_=pt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function Kt(e,t,n,r){const[o,i]=it(t)?bt(yt).proxyMap_(t,n):st(t)?bt(yt).proxySet_(t,n):function(e,t){const n=ot(e),r={type_:n?1:0,scope_:t?t.scope_:Et(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=r,i=jt;n&&(o=[r],i=Ft);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,[a,r]}(t,n);return(n?.scope_??Et()).drafts_.push(o),i.callbacks_=n?.callbacks_??[],i.key_=r,n&&void 0!==r?function(e,t,n){e.callbacks_.push(function(r){const o=t;if(!o||!Dt(o,r))return;r.mapSetPlugin_?.fixSetContents(o);const i=dt(o);Nt(e,o.draft_??o,i,n),Rt(o,r)})}(n,i,r):i.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(i);const{patchPlugin_:t}=e;i.modified_&&t&&t.generatePatches_(i,[],e)}),o}function Gt(e){return qe(e)||Le(10,e),Wt(e)}function Wt(e){if(!Be(e)||mt(e))return e;const t=e[je];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=pt(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=pt(e,!0);return Ze(n,(e,t)=>{rt(n,e,Wt(t))},r),t&&(t.finalized_=!1),n}Ft.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&Le(13),Ft.set.call(this,e,t,void 0)},Ft.set=function(e,t,n){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Le(14),jt.set.call(this,e[0],t,n,e[0])},new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(ct(e)&&!ct(t)){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,e=>t.call(this,e,...o))}}let r;if(ct(t)||Le(6),void 0===n||ct(n)||Le(7),Be(e)){const o=Tt(this),i=Kt(0,e,void 0);let s=!0;try{r=t(i),s=!1}finally{s?It(o):kt(o)}return Pt(o,n),At(r,o)}if(!e||!at(e)){if(r=t(e),void 0===r&&(r=e),r===Re&&(r=void 0),this.autoFreeze_&&ft(r,!0),n){const t=[],o=[];bt(_t).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:o}),n(t,o)}return r}Le(1,e)},this.produceWithPatches=(e,t)=>{if(ct(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},lt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),lt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),lt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Be(e)||Le(8),qe(e)&&(e=Gt(e));const t=Tt(this),n=Kt(0,e,void 0);return n[je].isManual_=!0,kt(t),n}finishDraft(e,t){const n=e&&e[je];n&&n.isManual_||Le(9);const{scope_:r}=n;return Pt(r,t),At(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=bt(_t).applyPatches_;return qe(e)?r(e,t):this.produce(e,e=>r(e,t))}},Error;var Vt=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Yt=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:i,inputSelectorResultsCopy:s}=e,a=r(()=>({}),...o);if(a.apply(null,i)!==a.apply(null,s)){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:i,secondInputs:s,stack:e})}},qt={inputStabilityCheck:"once",identityFunctionCheck:"once"},Bt=e=>Array.isArray(e)?e:[e];function Xt(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var Jt="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}};function Qt(){return{s:0,v:void 0,o:null,p:null}}function Zt(e,t={}){let n={s:0,v:void 0,o:null,p:null};const{resultEqualityCheck:r}=t;let o,i=0;function s(){let t=n;const{length:s}=arguments;for(let e=0,n=s;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=Qt(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=Qt(),e.set(n,t)):t=r}}const a=t;let c;if(1===t.s)c=t.v;else if(c=e.apply(null,arguments),i++,r){const e=o?.deref?.()??o;null!=e&&r(e,c)&&(c=e,0!==i&&i--),o="object"==typeof c&&null!==c||"function"==typeof c?new Jt(c):c}return a.s=1,a.v=c,c}return s.clearCache=()=>{n={s:0,v:void 0,o:null,p:null},s.resetResultsCount()},s.resultsCount=()=>i,s.resetResultsCount=()=>{i=0},s}function en(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,o=0,i={},s=e.pop();"object"==typeof s&&(i=s,s=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(s,`createSelector expects an output function after the inputs, but received: [${typeof s}]`);const a={...n,...i},{memoize:c,memoizeOptions:l=[],argsMemoize:u=Zt,argsMemoizeOptions:d=[],devModeChecks:p={}}=a,f=Bt(l),h=Bt(d),m=function(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(e=>"function"==typeof e)){const n=e.map(e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}(e),y=c(function(){return r++,s.apply(null,arguments)},...f);let _=!0;const g=u(function(){o++;const e=Xt(m,arguments);if(t=y.apply(null,e),"production"!==process.env.NODE_ENV){const{identityFunctionCheck:n,inputStabilityCheck:r}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...qt,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Vt},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:Yt}}})(_,p);if(n.shouldRun&&n.run(s,e,t),r.shouldRun){const t=Xt(m,arguments);r.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:f},arguments)}_&&(_=!1)}return t},...h);return Object.assign(g,{resultFunc:s,memoizedResultFunc:y,dependencies:m,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:u})};return Object.assign(r,{withTypes:()=>r}),r}var tn=en(Zt),nn=Object.assign((e,t=tn)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>nn}),rn="__rtkq/",on="online",sn="offline",an="focus",cn="focused",ln="visibilitychange",un=J(`${rn}${cn}`),dn=J(`${rn}un${cn}`),pn=J(`${rn}${on}`),fn=J(`${rn}${sn}`),hn=!1;WeakMap,new Error("Promise never resolved before cacheEntryRemoved.");const mn=ae({...r,auth:M,chat:n,conversations:t,voice:ge,indicator:T}),yn=_e();yn.startListening({matcher:oe(C,O),effect:(e,{dispatch:t})=>{t(s())}});const _n=ye({reducer:mn,middleware:e=>e({serializableCheck:o}).prepend(yn.middleware,A.middleware,ve.middleware).concat(i)});var gn;gn=_n.dispatch,function(){const[e,t,n,r]=[un,dn,pn,fn].map(e=>()=>gn(e())),o=()=>{"visible"===window.document.visibilityState?e():t()};if(!hn&&"undefined"!=typeof window&&window.addEventListener){let t=function(e){Object.entries(i).forEach(([t,n])=>{e?window.addEventListener(t,n,!1):window.removeEventListener(t,n)})};const i={[an]:e,[ln]:o,[on]:n,[sn]:r};t(!0),hn=!0}}(),D(()=>_n.getState().auth.accessToken),z(()=>_n.getState().auth.tokenExpiresAt),a(()=>_n.getState());const vn=!1,bn=!0,wn=!0,Sn=R.ONLINE,En=!0,Pn=(e,t)=>null===e?t:"true"===e,In=({children:e,defaultSttImplementation:t=Sn})=>{const{user:n}=l(),r=n?.id,o=N(),[i,s]=Se(!1),[a,c]=Se(vn),[d,p]=Se(bn),[f,h]=Se(wn),[m,y]=Se(t),[_,g]=Se(En);return Ee(()=>{let e=!1;return Promise.all([o.getItem(x.DEBUG_MODE),o.getItem(x.LOCATION_ENABLED),o.getItem(x.STT_AUTO_SEND),o.getItem(x.STT_IMPLEMENTATION),o.getItem(x.SEND_DIAGNOSTICS)]).then(([n,r,o,i,s])=>{if(e)return;var a;c(Pn(n,vn)),p(Pn(r,bn)),h(Pn(o,wn)),y((a=i)===R.ONLINE||a===R.DEVICE?a:t);const l=Pn(s,En);g(l),j(l)}),()=>{e=!0}},[t,r,o]),be(u.Provider,{value:{enableTts:i,setEnableTts:s,debugMode:a,setDebugMode:e=>{c(e),o.setItem(x.DEBUG_MODE,String(e))},locationEnabled:d,setLocationEnabled:e=>{p(e),o.setItem(x.LOCATION_ENABLED,String(e))},autoSendVoice:f,setAutoSendVoice:e=>{h(e),o.setItem(x.STT_AUTO_SEND,String(e))},sttImplementation:m,setSttImplementation:e=>{y(e),o.setItem(x.STT_IMPLEMENTATION,e)},sendDiagnostics:_,setSendDiagnostics:e=>{g(e),j(e),o.setItem(x.SEND_DIAGNOSTICS,String(e))}},children:e})},kn=c;async function Tn(e){if(e instanceof File)return e;const t=e;if(t?.file instanceof File)return t.file;if(t?.uri){const e=await(await fetch(t.uri)).blob();return new File([e],t.name??"upload",{type:t.mimeType??e.type})}throw new Error("Could not read the selected file.")}function Mn(e){const[t]=d(),[n]=p();return{onUploadFile:Pe(async(n,r)=>{try{return{documentId:(await t({file:await Tn(n),filename:r.fileRequestId,documentType:r.documentType,conversationId:e,onUploadProgress:r.onProgress,onUploadComplete:()=>r.onPhase?.("processing")}).unwrap()).data.document_id}}catch(e){if(e instanceof Error)throw e;throw new Error(f(e,"Upload failed. Please try again."))}},[t,e]),onRemoveFile:Pe(e=>{n(e)},[n])}}const An=ke(void 0),Cn=ke({}),On=({children:e,messageId:t,isDisabled:n=!1})=>{const[r,o]=Se({});return be(An.Provider,{value:{messageContext:r,setMessageContext:o,updateMessageContext:(e,t)=>{o(n=>({...n,[e]:t}))},messageId:t},children:be(Cn.Provider,{value:{messageId:t,isDisabled:n},children:e})})},Dn=()=>{const e=Ie(An);if(!e)throw new Error("useMessageContext must be used within MessageContextProvider");return e},zn=()=>{const e=Ie(Cn);return e?.messageId},Nn=()=>{const e=Ie(Cn);return e?.isDisabled??!1};function Rn(){return"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches?F.DARK:F.LIGHT:F.DARK}const xn=({children:e,orgId:t,fallbackThemeStyles:n,initialAppearanceMode:r=F.SYSTEM})=>{const{user:o}=l(),i=o?.id,s=N(),[a,c]=Se(r),[u,d]=Se(()=>r===F.SYSTEM?Rn():r);Ee(()=>{let e=!1;const t=L(i),n=x.APPEARANCE_MODE_KEY;return(async()=>{const o=await s.getItem(t);if(i&&await s.removeItem(n),e)return;const a=((e,t)=>e===F.LIGHT||e===F.DARK||e===F.SYSTEM?e:t)(o,r);c(a),d(a===F.SYSTEM?Rn():a)})(),()=>{e=!0}},[i,s,r]),Ee(()=>{if(a!==F.SYSTEM)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{d(e.matches?F.DARK:F.LIGHT)};return d(e.matches?F.DARK:F.LIGHT),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[a]);const p=t||void 0,{data:f,isLoading:m,error:y}=h(p),_=f?.success?f.data??null:null,g=_?.themes?(u===F.LIGHT?_.themes.light:_.themes.dark)??null:null,v=Te(()=>!_&&n?n:$(_,g,u),[_,g,u,n]),b=_?.orbPosition??U.FOREGROUND,w=_?.showAmbientWave??!0,S=Pe(e=>{c(e);const t=L(i);s.setItem(t,e),i&&s.removeItem(x.APPEARANCE_MODE_KEY),d(e===F.SYSTEM?Rn():e)},[s,i]),E={theme:u,setTheme:S,appearanceMode:a,isLoading:m,error:y?new Error("Failed to fetch branding"):null,currentThemeColors:g,themeStyles:v,orbPosition:b,showAmbientWave:w};return be(H.Provider,{value:E,children:e})},jn=({children:e,protocolType:t})=>{const n=t||y,r=Te(()=>m(n,_({onAuthExpired:()=>_n.dispatch(C())})),[n]),o=Te(()=>({adapter:r,protocolType:n}),[r,n]);return be(g.Provider,{value:o,children:e})},Fn=({value:e,children:t,fallback:n,extraHydrations:r})=>{K(e);const o=Oe(),i=void 0!==n,[s,a]=Se(!i);return Ee(()=>{let t=!1;const n=[o(G(e))];if(r)for(const t of r)n.push(Promise.resolve(t(e,o)).catch(e=>{W.error({message:"StorageProvider hydration step failed",component:"StorageProvider",error_message:e instanceof Error?e.message:String(e)})}));return Promise.all(n).finally(()=>{t||i&&a(!0)}),()=>{t=!0}},[]),be(V.Provider,{value:e,children:i&&!s?be(we,{children:n}):t})},Ln=({token:e,user:t,children:n})=>{const r=Me(null);return e&&e!==r.current&&(r.current=e,_n.dispatch(Y({accessToken:e,expiresIn:Math.floor(Date.now()/1e3)+3600,...t&&{user:{id:"",email:t.email||"",name:t.name}}}))),be(we,{children:n})},$n=({children:e})=>be(v.Provider,{value:b(),children:e}),Un=({children:e,callbacks:t})=>be(w.Provider,{value:t,children:e});function Hn(e){return"object"==typeof e.config&&null!==e.config?e.config:null}function Kn(e){return"string"==typeof e&&e?e:void 0}const Gn={type:"stripe",normalize(e){const t=Hn(e),n=Kn(e.payment_id);return t&&n&&Kn(t.client_secret)&&Kn(t.publishable_key)?.startsWith("pk_")?{provider:Gn.type,paymentId:n,config:t}:null}},Wn="Verify the payment.",Vn={type:"atb",normalize(e){const t=Hn(e),n=Kn(e.payment_id);return t&&n&&E(t.url)?{provider:Vn.type,paymentId:n,amount:(r=t.amount,Number.isInteger(r)?r:void 0),currency:Kn(t.currency),config:t}:null;var r},cancelOutcome:()=>S({modelText:Wn})},Yn=[Gn,Vn],qn=Gn.type,Bn=Object.assign({"./atb/Adapter.tsx":()=>import("./Adapter-NYa2rsBP.js"),"./stripe/Adapter.tsx":()=>import("./Adapter-Btgjo8Dw.js")}),Xn=Yn.map(e=>{const t=Bn[`./${e.type}/Adapter.tsx`];if(!t)throw new Error(`Payment provider "${e.type}" has no adapters/${e.type}/Adapter.tsx; the folder name must equal the spec's type.`);return{...e,loadAdapter:t}});!function(){for(const e of Xn)P(e);I(qn)}();const Jn=({baseUrl:e,customHeaders:t,token:n,user:r,protocol:o=y,paymentProvider:i,onConversationChange:s,onConversationTitleChange:a,onMessagesChange:c,onLogoutRequested:l,onSessionExpired:u,storage:d,storageFallback:p,extraHydrations:f,orgId:h,initialThemeStyles:m,initialAppearanceMode:_,reuseHostBranding:g=!1,manageTokenRefresh:v=!0,audioPlatform:b,networkMonitor:w,children:S})=>{q({baseUrl:e,customHeaders:t,paymentProvider:i}),v&&B(u??null);const E=be(ze,{value:b,children:S});let P=be(Ln,{token:n,user:r,children:be(jn,{protocolType:o,children:be($n,{children:be(Un,{callbacks:{onConversationChange:s,onConversationTitleChange:a,onMessagesChange:c,onLogoutRequested:l},children:g?E:be(xn,{orgId:h,fallbackThemeStyles:m,initialAppearanceMode:_,children:E})})})})});return w&&(P=be(X.Provider,{value:w,children:P})),be(De,{store:_n,children:d?be(Fn,{value:d,fallback:p,extraHydrations:f,children:P}):P})},Qn=Ce(()=>import("./PaymentProviderHost-DctZpdV2.js")),Zn=e=>be(Ae,{fallback:null,children:be(Qn,{...e})}),er=()=>Promise.all([import("./PaymentProviderHost-DctZpdV2.js").catch(()=>{}),Ne()]);export{Wn as A,xn as B,Jn as C,On as M,Zn as P,In as S,Fn as a,Dn as b,Nn as c,zn as d,kn as e,er as p,mn as r,_n as s,Mn as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("@1interface/chat-core"),t=require("@1interface/shared-core"),n=require("@reduxjs/toolkit"),r=require("@1interface/voice-core"),o=require("react/jsx-runtime"),s=require("react"),i=require("react-redux"),a=require("@1interface/voice-shell");function c(){const n=e.getPaymentProvider(t.getPaymentProviderHint());return n?n.loadAdapter().catch(()=>{}):Promise.resolve()}var u=Symbol.for("immer-nothing"),l=Symbol.for("immer-draftable"),d=Symbol.for("immer-state"),p="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function f(e,...t){if("production"!==process.env.NODE_ENV){const n=p[e],r=j(n)?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var h=Object,m=h.getPrototypeOf,_="constructor",y="prototype",g="configurable",S="enumerable",E="writable",v="value",P=e=>!!e&&!!e[d];function A(e){return!!e&&(C(e)||R(e)||!!e[l]||!!e[_]?.[l]||k(e)||D(e))}var b=h[y][_].toString(),w=new WeakMap;function C(e){if(!e||!N(e))return!1;const t=m(e);if(null===t||t===h[y])return!0;const n=h.hasOwnProperty.call(t,_)&&t[_];if(n===Object)return!0;if(!j(n))return!1;let r=w.get(n);return void 0===r&&(r=Function.toString.call(n),w.set(n,r)),r===b}function M(e,t,n=!0){0===T(e)?(n?Reflect.ownKeys(e):h.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function T(e){const t=e[d];return t?t.type_:R(e)?1:k(e)?2:D(e)?3:0}var O=(e,t,n=T(e))=>2===n?e.has(t):h[y].hasOwnProperty.call(e,t),x=(e,t,n=T(e))=>2===n?e.get(t):e[t],I=(e,t,n,r=T(e))=>{2===r?e.set(t,n):3===r?e.add(n):e[t]=n},R=Array.isArray,k=e=>e instanceof Map,D=e=>e instanceof Set,N=e=>"object"==typeof e,j=e=>"function"==typeof e,z=e=>"boolean"==typeof e,L=e=>e.copy_||e.base_,F=e=>e.modified_?e.copy_:e.base_;function K(e,t){if(k(e))return new Map(e);if(D(e))return new Set(e);if(R(e))return Array[y].slice.call(e);const n=C(e);if(!0===t||"class_only"===t&&!n){const t=h.getOwnPropertyDescriptors(e);delete t[d];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){const o=n[r],s=t[o];!1===s[E]&&(s[E]=!0,s[g]=!0),(s.get||s.set)&&(t[o]={[g]:!0,[E]:!0,[S]:s[S],[v]:e[o]})}return h.create(m(e),t)}{const t=m(e);if(null!==t&&n)return{...e};const r=h.create(t);return h.assign(r,e)}}function G(e,t=!1){return $(e)||P(e)||!A(e)||(T(e)>1&&h.defineProperties(e,{set:U,add:U,clear:U,delete:U}),h.freeze(e),t&&M(e,(e,t)=>{G(t,!0)},!1)),e}var U={[v]:function(){f(2)}};function $(e){return null===e||!N(e)||h.isFrozen(e)}var Y="MapSet",q="Patches",H="ArrayMethods",V={};function W(e){const t=V[e];return t||f(0,e),t}var B,Q=e=>!!V[e],X=()=>B;function J(e,t){t&&(e.patchPlugin_=W(q),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Z(e){ee(e),e.drafts_.forEach(ne),e.drafts_=null}function ee(e){e===B&&(B=e.parent_)}var te=e=>B={drafts_:[],parent_:B,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Q(Y)?W(Y):void 0,arrayMethodsPlugin_:Q(H)?W(H):void 0};function ne(e){const t=e[d];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function re(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(void 0!==e&&e!==n){n[d].modified_&&(Z(t),f(4)),A(e)&&(e=oe(t,e));const{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[d].base_,e,t)}else e=oe(t,n);return function(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&G(t,n)}(t,e,!0),Z(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==u?e:void 0}function oe(e,t){if($(t))return t;const n=t[d];if(!n)return le(t,e.handledSet_,e);if(!ie(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);ue(n,e)}return n.copy_}function se(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var ie=(e,t)=>e.scope_===t,ae=[];function ce(e,t,n,r){const o=L(e),s=e.type_;if(void 0!==r&&x(o,r,s)===t)return void I(o,r,n,s);if(!e.draftLocations_){const t=e.draftLocations_=new Map;M(o,(e,n)=>{if(P(n)){const r=t.get(n)||[];r.push(e),t.set(n,r)}})}const i=e.draftLocations_.get(t)??ae;for(const e of i)I(o,e,n,s)}function ue(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:n}=t;if(n){const r=n.getPath(e);r&&n.generatePatches_(e,r,t)}se(e)}}function le(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||P(e)||t.has(e)||!A(e)||$(e)||(t.add(e),M(e,(r,o)=>{if(P(o)){const t=o[d];if(ie(t,n)){const n=F(t);I(e,r,n,e.type_),se(t)}}else A(o)&&le(o,t,n)})),e}var de={get(e,t){if(t===d)return e;let n=e.scope_.arrayMethodsPlugin_;const r=1===e.type_&&"string"==typeof t;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const o=L(e);if(!O(o,t,e.type_))return function(e,t,n){const r=he(t,n);return r?v in r?r[v]:r.get?.call(e.draft_):void 0}(e,o,t);const s=o[t];if(e.finalized_||!A(s))return s;if(r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&function(e){const t=+e;return Number.isInteger(t)&&String(t)===e}(t))return s;if(s===fe(e.base_,t)){_e(e);const n=1===e.type_?+t:t,r=ye(0,s,e,n);return e.copy_[n]=r}return s},has:(e,t)=>t in L(e),ownKeys:e=>Reflect.ownKeys(L(e)),set(e,t,n){const r=he(L(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=fe(L(e),t),i=r?.[d];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(((o=n)===(s=r)?0!==o||1/o==1/s:o!=o&&s!=s)&&(void 0!==n||O(e.base_,t,e.type_)))return!0;_e(e),me(e)}var o,s;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),function(e,t,n){const{scope_:r}=e;if(P(n)){const o=n[d];ie(o,r)&&o.callbacks_.push(function(){_e(e);const r=F(o);ce(e,n,r,t)})}else A(n)&&e.callbacks_.push(function(){const o=L(e);3===e.type_?o.has(n)&&le(n,r.handledSet_,r):x(o,t,e.type_)===n&&r.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&le(x(e.copy_,t,e.type_),r.handledSet_,r)})}(e,t,n)),!0},deleteProperty:(e,t)=>(_e(e),void 0!==fe(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),me(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=L(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{[E]:!0,[g]:1!==e.type_||"length"!==t,[S]:r[S],[v]:n[t]}:r},defineProperty(){f(11)},getPrototypeOf:e=>m(e.base_),setPrototypeOf(){f(12)}},pe={};for(let e in de){let t=de[e];pe[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function fe(e,t){const n=e[d];return(n?L(n):e)[t]}function he(e,t){if(!(t in e))return;let n=m(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=m(n)}}function me(e){e.modified_||(e.modified_=!0,e.parent_&&me(e.parent_))}function _e(e){e.copy_||(e.assigned_=new Map,e.copy_=K(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function ye(e,t,n,r){const[o,s]=k(t)?W(Y).proxyMap_(t,n):D(t)?W(Y).proxySet_(t,n):function(e,t){const n=R(e),r={type_:n?1:0,scope_:t?t.scope_:X(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=r,s=de;n&&(o=[r],s=pe);const{revoke:i,proxy:a}=Proxy.revocable(o,s);return r.draft_=a,r.revoke_=i,[a,r]}(t,n);return(n?.scope_??X()).drafts_.push(o),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&void 0!==r?function(e,t,n){e.callbacks_.push(function(r){const o=t;if(!o||!ie(o,r))return;r.mapSetPlugin_?.fixSetContents(o);const s=F(o);ce(e,o.draft_??o,s,n),ue(o,r)})}(n,s,r):s.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:t}=e;s.modified_&&t&&t.generatePatches_(s,[],e)}),o}function ge(e){return P(e)||f(10,e),Se(e)}function Se(e){if(!A(e)||$(e))return e;const t=e[d];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=K(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=K(e,!0);return M(n,(e,t)=>{I(n,e,Se(t))},r),t&&(t.finalized_=!1),n}pe.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&f(13),pe.set.call(this,e,t,void 0)},pe.set=function(e,t,n){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&f(14),de.set.call(this,e[0],t,n,e[0])},new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(j(e)&&!j(t)){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,e=>t.call(this,e,...o))}}let r;if(j(t)||f(6),void 0===n||j(n)||f(7),A(e)){const o=te(this),s=ye(0,e,void 0);let i=!0;try{r=t(s),i=!1}finally{i?Z(o):ee(o)}return J(o,n),re(r,o)}if(!e||!N(e)){if(r=t(e),void 0===r&&(r=e),r===u&&(r=void 0),this.autoFreeze_&&G(r,!0),n){const t=[],o=[];W(q).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:o}),n(t,o)}return r}f(1,e)},this.produceWithPatches=(e,t)=>{if(j(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},z(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),z(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),z(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){A(e)||f(8),P(e)&&(e=ge(e));const t=te(this),n=ye(0,e,void 0);return n[d].isManual_=!0,ee(t),n}finishDraft(e,t){const n=e&&e[d];n&&n.isManual_||f(9);const{scope_:r}=n;return J(r,t),re(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=W(q).applyPatches_;return P(e)?r(e,t):this.produce(e,e=>r(e,t))}},Error;var Ee=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},ve=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:s,inputSelectorResultsCopy:i}=e,a=r(()=>({}),...o);if(a.apply(null,s)!==a.apply(null,i)){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:s,secondInputs:i,stack:e})}},Pe={inputStabilityCheck:"once",identityFunctionCheck:"once"},Ae=e=>Array.isArray(e)?e:[e];function be(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var we="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}};function Ce(){return{s:0,v:void 0,o:null,p:null}}function Me(e,t={}){let n={s:0,v:void 0,o:null,p:null};const{resultEqualityCheck:r}=t;let o,s=0;function i(){let t=n;const{length:i}=arguments;for(let e=0,n=i;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=Ce(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=Ce(),e.set(n,t)):t=r}}const a=t;let c;if(1===t.s)c=t.v;else if(c=e.apply(null,arguments),s++,r){const e=o?.deref?.()??o;null!=e&&r(e,c)&&(c=e,0!==s&&s--),o="object"==typeof c&&null!==c||"function"==typeof c?new we(c):c}return a.s=1,a.v=c,c}return i.clearCache=()=>{n={s:0,v:void 0,o:null,p:null},i.resetResultsCount()},i.resultsCount=()=>s,i.resetResultsCount=()=>{s=0},i}function Te(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,o=0,s={},i=e.pop();"object"==typeof i&&(s=i,i=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(i,`createSelector expects an output function after the inputs, but received: [${typeof i}]`);const a={...n,...s},{memoize:c,memoizeOptions:u=[],argsMemoize:l=Me,argsMemoizeOptions:d=[],devModeChecks:p={}}=a,f=Ae(u),h=Ae(d),m=function(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(e=>"function"==typeof e)){const n=e.map(e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}(e),_=c(function(){return r++,i.apply(null,arguments)},...f);let y=!0;const g=l(function(){o++;const e=be(m,arguments);if(t=_.apply(null,e),"production"!==process.env.NODE_ENV){const{identityFunctionCheck:n,inputStabilityCheck:r}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...Pe,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Ee},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:ve}}})(y,p);if(n.shouldRun&&n.run(i,e,t),r.shouldRun){const t=be(m,arguments);r.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:f},arguments)}y&&(y=!1)}return t},...h);return Object.assign(g,{resultFunc:i,memoizedResultFunc:_,dependencies:m,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var Oe=Te(Me),xe=Object.assign((e,t=Oe)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>xe}),Ie="__rtkq/",Re="online",ke="offline",De="focus",Ne="focused",je="visibilitychange",ze=n.createAction(`${Ie}${Ne}`),Le=n.createAction(`${Ie}un${Ne}`),Fe=n.createAction(`${Ie}${Re}`),Ke=n.createAction(`${Ie}${ke}`),Ge=!1;WeakMap,new Error("Promise never resolved before cacheEntryRemoved.");const Ue=n.combineReducers({...e.apiReducers,auth:t.sessionReducer,chat:e.chatReducer,conversations:e.conversationsReducer,voice:r.voiceReducer,indicator:t.indicatorReducer}),$e=n.createListenerMiddleware();$e.startListening({matcher:n.isAnyOf(t.clearSession,t.sessionExpired),effect:(t,{dispatch:n})=>{n(e.resetAllApiState())}});const Ye=n.configureStore({reducer:Ue,middleware:n=>n({serializableCheck:e.serializableCheck}).prepend($e.middleware,t.sessionListenerMiddleware.middleware,r.voiceListenerMiddleware.middleware).concat(e.apiMiddleware)});var qe;qe=Ye.dispatch,function(){const[e,t,n,r]=[ze,Le,Fe,Ke].map(e=>()=>qe(e())),o=()=>{"visible"===window.document.visibilityState?e():t()};if(!Ge&&"undefined"!=typeof window&&window.addEventListener){let t=function(e){Object.entries(s).forEach(([t,n])=>{e?window.addEventListener(t,n,!1):window.removeEventListener(t,n)})};const s={[De]:e,[je]:o,[Re]:n,[ke]:r};t(!0),Ge=!0}}(),t.setAccessTokenReader(()=>Ye.getState().auth.accessToken),t.setTokenExpiresAtReader(()=>Ye.getState().auth.tokenExpiresAt),e.bindChatLogger(()=>Ye.getState());const He=!1,Ve=!0,We=!0,Be=t.STT_IMPLEMENTATIONS.ONLINE,Qe=!0,Xe=(e,t)=>null===e?t:"true"===e,Je=e.useChatSettings;async function Ze(e){if(e instanceof File)return e;const t=e;if(t?.file instanceof File)return t.file;if(t?.uri){const e=await(await fetch(t.uri)).blob();return new File([e],t.name??"upload",{type:t.mimeType??e.type})}throw new Error("Could not read the selected file.")}const et=s.createContext(void 0),tt=s.createContext({});function nt(){return"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches?t.APPEARANCE_MODES.DARK:t.APPEARANCE_MODES.LIGHT:t.APPEARANCE_MODES.DARK}const rt=({children:n,orgId:r,fallbackThemeStyles:i,initialAppearanceMode:a=t.APPEARANCE_MODES.SYSTEM})=>{const{user:c}=e.useAuth(),u=c?.id,l=t.useStorage(),[d,p]=s.useState(a),[f,h]=s.useState(()=>a===t.APPEARANCE_MODES.SYSTEM?nt():a);s.useEffect(()=>{let e=!1;const n=t.getAppearanceModeStorageKey(u),r=t.STORAGE_KEYS.APPEARANCE_MODE_KEY;return(async()=>{const o=await l.getItem(n);if(u&&await l.removeItem(r),e)return;const s=((e,n)=>e===t.APPEARANCE_MODES.LIGHT||e===t.APPEARANCE_MODES.DARK||e===t.APPEARANCE_MODES.SYSTEM?e:n)(o,a);p(s),h(s===t.APPEARANCE_MODES.SYSTEM?nt():s)})(),()=>{e=!0}},[u,l,a]),s.useEffect(()=>{if(d!==t.APPEARANCE_MODES.SYSTEM)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),n=e=>{h(e.matches?t.APPEARANCE_MODES.DARK:t.APPEARANCE_MODES.LIGHT)};return h(e.matches?t.APPEARANCE_MODES.DARK:t.APPEARANCE_MODES.LIGHT),e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[d]);const m=r||void 0,{data:_,isLoading:y,error:g}=e.useGetBrandingQuery(m),S=_?.success?_.data??null:null,E=S?.themes?(f===t.APPEARANCE_MODES.LIGHT?S.themes.light:S.themes.dark)??null:null,v=s.useMemo(()=>!S&&i?i:t.brandingToThemeStyles(S,E,f),[S,E,f,i]),P=S?.orbPosition??t.ORB_POSITIONS.FOREGROUND,A=S?.showAmbientWave??!0,b=s.useCallback(e=>{p(e);const n=t.getAppearanceModeStorageKey(u);l.setItem(n,e),u&&l.removeItem(t.STORAGE_KEYS.APPEARANCE_MODE_KEY),h(e===t.APPEARANCE_MODES.SYSTEM?nt():e)},[l,u]),w={theme:f,setTheme:b,appearanceMode:d,isLoading:y,error:g?new Error("Failed to fetch branding"):null,currentThemeColors:E,themeStyles:v,orbPosition:P,showAmbientWave:A};return o.jsx(t.BrandingContext.Provider,{value:w,children:n})},ot=({children:n,protocolType:r})=>{const i=r||e.DEFAULT_PROTOCOL,a=s.useMemo(()=>e.createAdapter(i,e.createDefaultAdapterConfig({onAuthExpired:()=>Ye.dispatch(t.clearSession())})),[i]),c=s.useMemo(()=>({adapter:a,protocolType:i}),[a,i]);return o.jsx(e.ProtocolContext.Provider,{value:c,children:n})},st=({value:e,children:n,fallback:r,extraHydrations:a})=>{t.setModuleStorage(e);const c=i.useDispatch(),u=void 0!==r,[l,d]=s.useState(!u);return s.useEffect(()=>{let n=!1;const r=[c(t.hydrateSession(e))];if(a)for(const n of a)r.push(Promise.resolve(n(e,c)).catch(e=>{t.logger.error({message:"StorageProvider hydration step failed",component:"StorageProvider",error_message:e instanceof Error?e.message:String(e)})}));return Promise.all(r).finally(()=>{n||u&&d(!0)}),()=>{n=!0}},[]),o.jsx(t.StorageContext.Provider,{value:e,children:u&&!l?o.jsx(o.Fragment,{children:r}):n})},it=({token:e,user:n,children:r})=>{const i=s.useRef(null);return e&&e!==i.current&&(i.current=e,Ye.dispatch(t.setSession({accessToken:e,expiresIn:Math.floor(Date.now()/1e3)+3600,...n&&{user:{id:"",email:n.email||"",name:n.name}}}))),o.jsx(o.Fragment,{children:r})},at=({children:t})=>o.jsx(e.ConfigurationContext.Provider,{value:e.useConfigurationValue(),children:t}),ct=({children:t,callbacks:n})=>o.jsx(e.ChatCallbacksContext.Provider,{value:n,children:t});function ut(e){return"object"==typeof e.config&&null!==e.config?e.config:null}function lt(e){return"string"==typeof e&&e?e:void 0}const dt={type:"stripe",normalize(e){const t=ut(e),n=lt(e.payment_id);return t&&n&<(t.client_secret)&<(t.publishable_key)?.startsWith("pk_")?{provider:dt.type,paymentId:n,config:t}:null}},pt="Verify the payment.",ft={type:"atb",normalize(t){const n=ut(t),r=lt(t.payment_id);return n&&r&&e.isHttpsUrl(n.url)?{provider:ft.type,paymentId:r,amount:(o=n.amount,Number.isInteger(o)?o:void 0),currency:lt(n.currency),config:n}:null;var o},cancelOutcome:()=>e.defaultCancelOutcome({modelText:pt})},ht=[dt,ft],mt=dt.type,_t=Object.assign({"./atb/Adapter.tsx":()=>Promise.resolve().then(()=>require("./Adapter-BXquRkJb.cjs")),"./stripe/Adapter.tsx":()=>Promise.resolve().then(()=>require("./Adapter-cx5XZUQA.cjs"))}),yt=ht.map(e=>{const t=_t[`./${e.type}/Adapter.tsx`];if(!t)throw new Error(`Payment provider "${e.type}" has no adapters/${e.type}/Adapter.tsx; the folder name must equal the spec's type.`);return{...e,loadAdapter:t}});!function(){for(const t of yt)e.registerPaymentProvider(t);e.setDefaultPaymentProvider(mt)}();const gt=s.lazy(()=>Promise.resolve().then(()=>require("./PaymentProviderHost-DsqmNubh.cjs")));exports.ATB_VERIFY_NOTE=pt,exports.BrandingProvider=rt,exports.ChatClientProvider=({baseUrl:n,customHeaders:r,token:s,user:c,protocol:u=e.DEFAULT_PROTOCOL,paymentProvider:l,onConversationChange:d,onConversationTitleChange:p,onMessagesChange:f,onLogoutRequested:h,onSessionExpired:m,storage:_,storageFallback:y,extraHydrations:g,orgId:S,initialThemeStyles:E,initialAppearanceMode:v,reuseHostBranding:P=!1,manageTokenRefresh:A=!0,audioPlatform:b,networkMonitor:w,children:C})=>{t.initializeChatConfig({baseUrl:n,customHeaders:r,paymentProvider:l}),A&&t.setTokenRefreshHandler(m??null);const M=o.jsx(a.AudioPlatformProvider,{value:b,children:C});let T=o.jsx(it,{token:s,user:c,children:o.jsx(ot,{protocolType:u,children:o.jsx(at,{children:o.jsx(ct,{callbacks:{onConversationChange:d,onConversationTitleChange:p,onMessagesChange:f,onLogoutRequested:h},children:P?M:o.jsx(rt,{orgId:S,fallbackThemeStyles:E,initialAppearanceMode:v,children:M})})})})});return w&&(T=o.jsx(t.NetworkContext.Provider,{value:w,children:T})),o.jsx(i.Provider,{store:Ye,children:_?o.jsx(st,{value:_,fallback:y,extraHydrations:g,children:T}):T})},exports.MessageContextProvider=({children:e,messageId:t,isDisabled:n=!1})=>{const[r,i]=s.useState({});return o.jsx(et.Provider,{value:{messageContext:r,setMessageContext:i,updateMessageContext:(e,t)=>{i(n=>({...n,[e]:t}))},messageId:t},children:o.jsx(tt.Provider,{value:{messageId:t,isDisabled:n},children:e})})},exports.PaymentProviderHost=e=>o.jsx(s.Suspense,{fallback:null,children:o.jsx(gt,{...e})}),exports.SettingsProvider=({children:n,defaultSttImplementation:r=Be})=>{const{user:i}=e.useAuth(),a=i?.id,c=t.useStorage(),[u,l]=s.useState(!1),[d,p]=s.useState(He),[f,h]=s.useState(Ve),[m,_]=s.useState(We),[y,g]=s.useState(r),[S,E]=s.useState(Qe);return s.useEffect(()=>{let e=!1;return Promise.all([c.getItem(t.STORAGE_KEYS.DEBUG_MODE),c.getItem(t.STORAGE_KEYS.LOCATION_ENABLED),c.getItem(t.STORAGE_KEYS.STT_AUTO_SEND),c.getItem(t.STORAGE_KEYS.STT_IMPLEMENTATION),c.getItem(t.STORAGE_KEYS.SEND_DIAGNOSTICS)]).then(([n,o,s,i,a])=>{if(e)return;var c;p(Xe(n,He)),h(Xe(o,Ve)),_(Xe(s,We)),g((c=i)===t.STT_IMPLEMENTATIONS.ONLINE||c===t.STT_IMPLEMENTATIONS.DEVICE?c:r);const u=Xe(a,Qe);E(u),t.setNetworkLoggingEnabled(u)}),()=>{e=!0}},[r,a,c]),o.jsx(e.ChatSettingsContext.Provider,{value:{enableTts:u,setEnableTts:l,debugMode:d,setDebugMode:e=>{p(e),c.setItem(t.STORAGE_KEYS.DEBUG_MODE,String(e))},locationEnabled:f,setLocationEnabled:e=>{h(e),c.setItem(t.STORAGE_KEYS.LOCATION_ENABLED,String(e))},autoSendVoice:m,setAutoSendVoice:e=>{_(e),c.setItem(t.STORAGE_KEYS.STT_AUTO_SEND,String(e))},sttImplementation:y,setSttImplementation:e=>{g(e),c.setItem(t.STORAGE_KEYS.STT_IMPLEMENTATION,e)},sendDiagnostics:S,setSendDiagnostics:e=>{E(e),t.setNetworkLoggingEnabled(e),c.setItem(t.STORAGE_KEYS.SEND_DIAGNOSTICS,String(e))}},children:n})},exports.StorageProvider=st,exports.preloadPaymentModal=()=>Promise.all([Promise.resolve().then(()=>require("./PaymentProviderHost-DsqmNubh.cjs")).catch(()=>{}),c()]),exports.rootReducer=Ue,exports.store=Ye,exports.useDocumentUploadHandlers=function(t){const[n]=e.useUploadDocumentMutation(),[r]=e.useDeleteDocumentMutation();return{onUploadFile:s.useCallback(async(r,o)=>{try{return{documentId:(await n({file:await Ze(r),filename:o.fileRequestId,documentType:o.documentType,conversationId:t,onUploadProgress:o.onProgress,onUploadComplete:()=>o.onPhase?.("processing")}).unwrap()).data.document_id}}catch(t){if(t instanceof Error)throw t;throw new Error(e.getApiErrorMessage(t,"Upload failed. Please try again."))}},[n,t]),onRemoveFile:s.useCallback(e=>{r(e)},[r])}},exports.useMessageContext=()=>{const e=s.useContext(et);if(!e)throw new Error("useMessageContext must be used within MessageContextProvider");return e},exports.useMessageDisabled=()=>{const e=s.useContext(tt);return e?.isDisabled??!1},exports.useMessageId=()=>{const e=s.useContext(tt);return e?.messageId},exports.useSettings=Je;
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|
|
18
18
|
import { MutationDefinition } from '@reduxjs/toolkit/query';
|
|
19
19
|
import { NetworkMonitor } from '@1interface/shared-core';
|
|
20
20
|
import { PaymentInitPayload } from '@1interface/shared-core';
|
|
21
|
-
import {
|
|
21
|
+
import { PaymentOutcome } from '@1interface/chat-core';
|
|
22
22
|
import { Profile } from '@1interface/chat-core';
|
|
23
23
|
import { ProtocolType } from '@1interface/chat-core';
|
|
24
24
|
import { QueryDefinition } from '@reduxjs/toolkit/query';
|
|
@@ -40,6 +40,17 @@ import { VoiceState } from '@1interface/voice-core';
|
|
|
40
40
|
|
|
41
41
|
export declare type AppDispatch = typeof store.dispatch;
|
|
42
42
|
|
|
43
|
+
export declare interface AtbPaymentInit {
|
|
44
|
+
provider: "atb";
|
|
45
|
+
payment_id: string;
|
|
46
|
+
status: string;
|
|
47
|
+
config: {
|
|
48
|
+
url: string;
|
|
49
|
+
amount?: number;
|
|
50
|
+
currency?: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
export declare const BrandingProvider: default_2.FC<BrandingProviderProps>;
|
|
44
55
|
|
|
45
56
|
declare interface BrandingProviderProps {
|
|
@@ -83,10 +94,8 @@ declare interface MessageContextType {
|
|
|
83
94
|
export declare const PaymentProviderHost: default_2.FC<PaymentProviderHostProps>;
|
|
84
95
|
|
|
85
96
|
export declare interface PaymentProviderHostProps {
|
|
86
|
-
provider?: string;
|
|
87
97
|
paymentInit?: PaymentInitPayload | null;
|
|
88
|
-
onResult?: (result:
|
|
89
|
-
conversationId?: string | null;
|
|
98
|
+
onResult?: (result: PaymentOutcome) => void;
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
export declare const preloadPaymentModal: () => Promise<unknown>;
|
|
@@ -195,6 +204,7 @@ getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, Fetch
|
|
|
195
204
|
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
196
205
|
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
197
206
|
updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
207
|
+
resolveIdentity: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
198
208
|
}, "profile", "profileApi">;
|
|
199
209
|
}, UnknownAction, Partial<{
|
|
200
210
|
auth: AuthState;
|
|
@@ -300,6 +310,7 @@ getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, Fetch
|
|
|
300
310
|
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
301
311
|
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
302
312
|
updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
313
|
+
resolveIdentity: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
303
314
|
}, "profile", "profileApi">;
|
|
304
315
|
}>>;
|
|
305
316
|
|
|
@@ -423,6 +434,7 @@ getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, Fetch
|
|
|
423
434
|
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
424
435
|
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
425
436
|
updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
437
|
+
resolveIdentity: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
426
438
|
}, "profile", "profileApi">;
|
|
427
439
|
}, UnknownAction, Tuple<[StoreEnhancer< {
|
|
428
440
|
dispatch: ((action: Action<"listenerMiddleware/add">) => UnsubscribeListener) & ThunkDispatch< {
|
|
@@ -529,10 +541,21 @@ getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, Fetch
|
|
|
529
541
|
updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
530
542
|
deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
|
|
531
543
|
updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
544
|
+
resolveIdentity: MutationDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
|
|
532
545
|
}, "profile", "profileApi">;
|
|
533
546
|
}, undefined, UnknownAction>;
|
|
534
547
|
}>, StoreEnhancer]>>;
|
|
535
548
|
|
|
549
|
+
export declare interface StripePaymentInit {
|
|
550
|
+
provider: "stripe";
|
|
551
|
+
payment_id: string;
|
|
552
|
+
status: string;
|
|
553
|
+
config: {
|
|
554
|
+
client_secret: string;
|
|
555
|
+
publishable_key: string;
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
536
559
|
export declare function useDocumentUploadHandlers(conversationId?: string): {
|
|
537
560
|
onUploadFile: UploadFileHandler;
|
|
538
561
|
onRemoveFile: RemoveFileHandler;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@reduxjs/toolkit"),t=require("@1interface/chat-core"),n=require("@1interface/shared-core"),r=require("@1interface/voice-core"),o=require("react/jsx-runtime"),s=require("react"),i=require("react-redux"),a=require("@1interface/voice-shell");var c=Symbol.for("immer-nothing"),u=Symbol.for("immer-draftable"),l=Symbol.for("immer-state"),d="production"!==process.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function p(e,...t){if("production"!==process.env.NODE_ENV){const n=d[e],r=N(n)?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var f=Object,h=f.getPrototypeOf,_="constructor",m="prototype",y="configurable",g="enumerable",S="writable",E="value",v=e=>!!e&&!!e[l];function b(e){return!!e&&(w(e)||R(e)||!!e[u]||!!e[_]?.[u]||I(e)||D(e))}var A=f[m][_].toString(),P=new WeakMap;function w(e){if(!e||!k(e))return!1;const t=h(e);if(null===t||t===f[m])return!0;const n=f.hasOwnProperty.call(t,_)&&t[_];if(n===Object)return!0;if(!N(n))return!1;let r=P.get(n);return void 0===r&&(r=Function.toString.call(n),P.set(n,r)),r===A}function C(e,t,n=!0){0===M(e)?(n?Reflect.ownKeys(e):f.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function M(e){const t=e[l];return t?t.type_:R(e)?1:I(e)?2:D(e)?3:0}var T=(e,t,n=M(e))=>2===n?e.has(t):f[m].hasOwnProperty.call(e,t),O=(e,t,n=M(e))=>2===n?e.get(t):e[t],x=(e,t,n,r=M(e))=>{2===r?e.set(t,n):3===r?e.add(n):e[t]=n},R=Array.isArray,I=e=>e instanceof Map,D=e=>e instanceof Set,k=e=>"object"==typeof e,N=e=>"function"==typeof e,j=e=>"boolean"==typeof e,z=e=>e.copy_||e.base_,L=e=>e.modified_?e.copy_:e.base_;function F(e,t){if(I(e))return new Map(e);if(D(e))return new Set(e);if(R(e))return Array[m].slice.call(e);const n=w(e);if(!0===t||"class_only"===t&&!n){const t=f.getOwnPropertyDescriptors(e);delete t[l];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){const o=n[r],s=t[o];!1===s[S]&&(s[S]=!0,s[y]=!0),(s.get||s.set)&&(t[o]={[y]:!0,[S]:!0,[g]:s[g],[E]:e[o]})}return f.create(h(e),t)}{const t=h(e);if(null!==t&&n)return{...e};const r=f.create(t);return f.assign(r,e)}}function K(e,t=!1){return U(e)||v(e)||!b(e)||(M(e)>1&&f.defineProperties(e,{set:G,add:G,clear:G,delete:G}),f.freeze(e),t&&C(e,(e,t)=>{K(t,!0)},!1)),e}var G={[E]:function(){p(2)}};function U(e){return null===e||!k(e)||f.isFrozen(e)}var Y="MapSet",$="Patches",q="ArrayMethods",H={};function W(e){const t=H[e];return t||p(0,e),t}var B,V=e=>!!H[e],Q=()=>B;function X(e,t){t&&(e.patchPlugin_=W($),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function J(e){Z(e),e.drafts_.forEach(te),e.drafts_=null}function Z(e){e===B&&(B=e.parent_)}var ee=e=>B={drafts_:[],parent_:B,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:V(Y)?W(Y):void 0,arrayMethodsPlugin_:V(q)?W(q):void 0};function te(e){const t=e[l];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function ne(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(void 0!==e&&e!==n){n[l].modified_&&(J(t),p(4)),b(e)&&(e=re(t,e));const{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[l].base_,e,t)}else e=re(t,n);return function(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&K(t,n)}(t,e,!0),J(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==c?e:void 0}function re(e,t){if(U(t))return t;const n=t[l];if(!n)return ue(t,e.handledSet_,e);if(!se(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);ce(n,e)}return n.copy_}function oe(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var se=(e,t)=>e.scope_===t,ie=[];function ae(e,t,n,r){const o=z(e),s=e.type_;if(void 0!==r&&O(o,r,s)===t)return void x(o,r,n,s);if(!e.draftLocations_){const t=e.draftLocations_=new Map;C(o,(e,n)=>{if(v(n)){const r=t.get(n)||[];r.push(e),t.set(n,r)}})}const i=e.draftLocations_.get(t)??ie;for(const e of i)x(o,e,n,s)}function ce(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:n}=t;if(n){const r=n.getPath(e);r&&n.generatePatches_(e,r,t)}oe(e)}}function ue(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||v(e)||t.has(e)||!b(e)||U(e)||(t.add(e),C(e,(r,o)=>{if(v(o)){const t=o[l];if(se(t,n)){const n=L(t);x(e,r,n,e.type_),oe(t)}}else b(o)&&ue(o,t,n)})),e}var le={get(e,t){if(t===l)return e;let n=e.scope_.arrayMethodsPlugin_;const r=1===e.type_&&"string"==typeof t;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const o=z(e);if(!T(o,t,e.type_))return function(e,t,n){const r=fe(t,n);return r?E in r?r[E]:r.get?.call(e.draft_):void 0}(e,o,t);const s=o[t];if(e.finalized_||!b(s))return s;if(r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&function(e){const t=+e;return Number.isInteger(t)&&String(t)===e}(t))return s;if(s===pe(e.base_,t)){_e(e);const n=1===e.type_?+t:t,r=me(0,s,e,n);return e.copy_[n]=r}return s},has:(e,t)=>t in z(e),ownKeys:e=>Reflect.ownKeys(z(e)),set(e,t,n){const r=fe(z(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=pe(z(e),t),i=r?.[l];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(((o=n)===(s=r)?0!==o||1/o==1/s:o!=o&&s!=s)&&(void 0!==n||T(e.base_,t,e.type_)))return!0;_e(e),he(e)}var o,s;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),function(e,t,n){const{scope_:r}=e;if(v(n)){const o=n[l];se(o,r)&&o.callbacks_.push(function(){_e(e);const r=L(o);ae(e,n,r,t)})}else b(n)&&e.callbacks_.push(function(){const o=z(e);3===e.type_?o.has(n)&&ue(n,r.handledSet_,r):O(o,t,e.type_)===n&&r.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&ue(O(e.copy_,t,e.type_),r.handledSet_,r)})}(e,t,n)),!0},deleteProperty:(e,t)=>(_e(e),void 0!==pe(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),he(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=z(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{[S]:!0,[y]:1!==e.type_||"length"!==t,[g]:r[g],[E]:n[t]}:r},defineProperty(){p(11)},getPrototypeOf:e=>h(e.base_),setPrototypeOf(){p(12)}},de={};for(let e in le){let t=le[e];de[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function pe(e,t){const n=e[l];return(n?z(n):e)[t]}function fe(e,t){if(!(t in e))return;let n=h(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=h(n)}}function he(e){e.modified_||(e.modified_=!0,e.parent_&&he(e.parent_))}function _e(e){e.copy_||(e.assigned_=new Map,e.copy_=F(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function me(e,t,n,r){const[o,s]=I(t)?W(Y).proxyMap_(t,n):D(t)?W(Y).proxySet_(t,n):function(e,t){const n=R(e),r={type_:n?1:0,scope_:t?t.scope_:Q(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=r,s=le;n&&(o=[r],s=de);const{revoke:i,proxy:a}=Proxy.revocable(o,s);return r.draft_=a,r.revoke_=i,[a,r]}(t,n);return(n?.scope_??Q()).drafts_.push(o),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&void 0!==r?function(e,t,n){e.callbacks_.push(function(r){const o=t;if(!o||!se(o,r))return;r.mapSetPlugin_?.fixSetContents(o);const s=L(o);ae(e,o.draft_??o,s,n),ce(o,r)})}(n,s,r):s.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(s);const{patchPlugin_:t}=e;s.modified_&&t&&t.generatePatches_(s,[],e)}),o}function ye(e){return v(e)||p(10,e),ge(e)}function ge(e){if(!b(e)||U(e))return e;const t=e[l];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=F(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=F(e,!0);return C(n,(e,t)=>{x(n,e,ge(t))},r),t&&(t.finalized_=!1),n}de.deleteProperty=function(e,t){return"production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&p(13),de.set.call(this,e,t,void 0)},de.set=function(e,t,n){return"production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&p(14),le.set.call(this,e[0],t,n,e[0])},new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(N(e)&&!N(t)){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,e=>t.call(this,e,...o))}}let r;if(N(t)||p(6),void 0===n||N(n)||p(7),b(e)){const o=ee(this),s=me(0,e,void 0);let i=!0;try{r=t(s),i=!1}finally{i?J(o):Z(o)}return X(o,n),ne(r,o)}if(!e||!k(e)){if(r=t(e),void 0===r&&(r=e),r===c&&(r=void 0),this.autoFreeze_&&K(r,!0),n){const t=[],o=[];W($).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:o}),n(t,o)}return r}p(1,e)},this.produceWithPatches=(e,t)=>{if(N(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},j(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),j(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),j(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){b(e)||p(8),v(e)&&(e=ye(e));const t=ee(this),n=me(0,e,void 0);return n[l].isManual_=!0,Z(t),n}finishDraft(e,t){const n=e&&e[l];n&&n.isManual_||p(9);const{scope_:r}=n;return X(r,t),ne(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=W($).applyPatches_;return v(e)?r(e,t):this.produce(e,e=>r(e,t))}},Error;var Se=(e,t,n)=>{if(1===t.length&&t[0]===n){let t=!1;try{const n={};e(n)===n&&(t=!0)}catch{}if(t){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",{stack:e})}}},Ee=(e,t,n)=>{const{memoize:r,memoizeOptions:o}=t,{inputSelectorResults:s,inputSelectorResultsCopy:i}=e,a=r(()=>({}),...o);if(a.apply(null,s)!==a.apply(null,i)){let e;try{throw new Error}catch(t){({stack:e}=t)}console.warn("An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",{arguments:n,firstInputs:s,secondInputs:i,stack:e})}},ve={inputStabilityCheck:"once",identityFunctionCheck:"once"},be=e=>Array.isArray(e)?e:[e];function Ae(e,t){const n=[],{length:r}=e;for(let o=0;o<r;o++)n.push(e[o].apply(null,t));return n}var Pe="undefined"!=typeof WeakRef?WeakRef:class{constructor(e){this.value=e}deref(){return this.value}};function we(){return{s:0,v:void 0,o:null,p:null}}function Ce(e,t={}){let n={s:0,v:void 0,o:null,p:null};const{resultEqualityCheck:r}=t;let o,s=0;function i(){let t=n;const{length:i}=arguments;for(let e=0,n=i;e<n;e++){const n=arguments[e];if("function"==typeof n||"object"==typeof n&&null!==n){let e=t.o;null===e&&(t.o=e=new WeakMap);const r=e.get(n);void 0===r?(t=we(),e.set(n,t)):t=r}else{let e=t.p;null===e&&(t.p=e=new Map);const r=e.get(n);void 0===r?(t=we(),e.set(n,t)):t=r}}const a=t;let c;if(1===t.s)c=t.v;else if(c=e.apply(null,arguments),s++,r){const e=o?.deref?.()??o;null!=e&&r(e,c)&&(c=e,0!==s&&s--),o="object"==typeof c&&null!==c||"function"==typeof c?new Pe(c):c}return a.s=1,a.v=c,c}return i.clearCache=()=>{n={s:0,v:void 0,o:null,p:null},i.resetResultsCount()},i.resultsCount=()=>s,i.resetResultsCount=()=>{s=0},i}function Me(e,...t){const n="function"==typeof e?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t,r=0,o=0,s={},i=e.pop();"object"==typeof i&&(s=i,i=e.pop()),function(e,t="expected a function, instead received "+typeof e){if("function"!=typeof e)throw new TypeError(t)}(i,`createSelector expects an output function after the inputs, but received: [${typeof i}]`);const a={...n,...s},{memoize:c,memoizeOptions:u=[],argsMemoize:l=Ce,argsMemoizeOptions:d=[],devModeChecks:p={}}=a,f=be(u),h=be(d),_=function(e){const t=Array.isArray(e[0])?e[0]:e;return function(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(e=>"function"==typeof e)){const n=e.map(e=>"function"==typeof e?`function ${e.name||"unnamed"}()`:typeof e).join(", ");throw new TypeError(`${t}[${n}]`)}}(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}(e),m=c(function(){return r++,i.apply(null,arguments)},...f);let y=!0;const g=l(function(){o++;const e=Ae(_,arguments);if(t=m.apply(null,e),"production"!==process.env.NODE_ENV){const{identityFunctionCheck:n,inputStabilityCheck:r}=((e,t)=>{const{identityFunctionCheck:n,inputStabilityCheck:r}={...ve,...t};return{identityFunctionCheck:{shouldRun:"always"===n||"once"===n&&e,run:Se},inputStabilityCheck:{shouldRun:"always"===r||"once"===r&&e,run:Ee}}})(y,p);if(n.shouldRun&&n.run(i,e,t),r.shouldRun){const t=Ae(_,arguments);r.run({inputSelectorResults:e,inputSelectorResultsCopy:t},{memoize:c,memoizeOptions:f},arguments)}y&&(y=!1)}return t},...h);return Object.assign(g,{resultFunc:i,memoizedResultFunc:m,dependencies:_,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>t,recomputations:()=>r,resetRecomputations:()=>{r=0},memoize:c,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var Te=Me(Ce),Oe=Object.assign((e,t=Te)=>{!function(e,t="expected an object, instead received "+typeof e){if("object"!=typeof e)throw new TypeError(t)}(e,"createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);const n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>Oe}),xe="__rtkq/",Re="online",Ie="offline",De="focus",ke="focused",Ne="visibilitychange",je=e.createAction(`${xe}${ke}`),ze=e.createAction(`${xe}un${ke}`),Le=e.createAction(`${xe}${Re}`),Fe=e.createAction(`${xe}${Ie}`),Ke=!1;WeakMap,new Error("Promise never resolved before cacheEntryRemoved.");const Ge=e.combineReducers({...t.apiReducers,auth:n.sessionReducer,chat:t.chatReducer,conversations:t.conversationsReducer,voice:r.voiceReducer,indicator:n.indicatorReducer}),Ue=e.createListenerMiddleware();Ue.startListening({matcher:e.isAnyOf(n.clearSession,n.sessionExpired),effect:(e,{dispatch:n})=>{n(t.resetAllApiState())}});const Ye=e.configureStore({reducer:Ge,middleware:e=>e({serializableCheck:t.serializableCheck}).prepend(Ue.middleware,n.sessionListenerMiddleware.middleware,r.voiceListenerMiddleware.middleware).concat(t.apiMiddleware)});var $e;$e=Ye.dispatch,function(){const[e,t,n,r]=[je,ze,Le,Fe].map(e=>()=>$e(e())),o=()=>{"visible"===window.document.visibilityState?e():t()};if(!Ke&&"undefined"!=typeof window&&window.addEventListener){let t=function(e){Object.entries(s).forEach(([t,n])=>{e?window.addEventListener(t,n,!1):window.removeEventListener(t,n)})};const s={[De]:e,[Ne]:o,[Re]:n,[Ie]:r};t(!0),Ke=!0}}(),n.setAccessTokenReader(()=>Ye.getState().auth.accessToken),n.setTokenExpiresAtReader(()=>Ye.getState().auth.tokenExpiresAt),t.bindChatLogger(()=>Ye.getState());const qe=!1,He=!0,We=!0,Be=n.STT_IMPLEMENTATIONS.ONLINE,Ve=!0,Qe=(e,t)=>null===e?t:"true"===e,Xe=t.useChatSettings;async function Je(e){if(e instanceof File)return e;const t=e;if(t?.file instanceof File)return t.file;if(t?.uri){const e=await(await fetch(t.uri)).blob();return new File([e],t.name??"upload",{type:t.mimeType??e.type})}throw new Error("Could not read the selected file.")}const Ze=s.createContext(void 0),et=s.createContext({});function tt(){return"undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches?n.APPEARANCE_MODES.DARK:n.APPEARANCE_MODES.LIGHT:n.APPEARANCE_MODES.DARK}const nt=({children:e,orgId:r,fallbackThemeStyles:i,initialAppearanceMode:a=n.APPEARANCE_MODES.SYSTEM})=>{const{user:c}=t.useAuth(),u=c?.id,l=n.useStorage(),[d,p]=s.useState(a),[f,h]=s.useState(()=>a===n.APPEARANCE_MODES.SYSTEM?tt():a);s.useEffect(()=>{let e=!1;const t=n.getAppearanceModeStorageKey(u),r=n.STORAGE_KEYS.APPEARANCE_MODE_KEY;return(async()=>{const o=await l.getItem(t);if(u&&await l.removeItem(r),e)return;const s=((e,t)=>e===n.APPEARANCE_MODES.LIGHT||e===n.APPEARANCE_MODES.DARK||e===n.APPEARANCE_MODES.SYSTEM?e:t)(o,a);p(s),h(s===n.APPEARANCE_MODES.SYSTEM?tt():s)})(),()=>{e=!0}},[u,l,a]),s.useEffect(()=>{if(d!==n.APPEARANCE_MODES.SYSTEM)return;const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{h(e.matches?n.APPEARANCE_MODES.DARK:n.APPEARANCE_MODES.LIGHT)};return h(e.matches?n.APPEARANCE_MODES.DARK:n.APPEARANCE_MODES.LIGHT),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[d]);const _=r||void 0,{data:m,isLoading:y,error:g}=t.useGetBrandingQuery(_),S=m?.success?m.data??null:null,E=S?.themes?(f===n.APPEARANCE_MODES.LIGHT?S.themes.light:S.themes.dark)??null:null,v=s.useMemo(()=>!S&&i?i:n.brandingToThemeStyles(S,E,f),[S,E,f,i]),b=S?.orbPosition??n.ORB_POSITIONS.FOREGROUND,A=S?.showAmbientWave??!0,P=s.useCallback(e=>{p(e);const t=n.getAppearanceModeStorageKey(u);l.setItem(t,e),u&&l.removeItem(n.STORAGE_KEYS.APPEARANCE_MODE_KEY),h(e===n.APPEARANCE_MODES.SYSTEM?tt():e)},[l,u]),w={theme:f,setTheme:P,appearanceMode:d,isLoading:y,error:g?new Error("Failed to fetch branding"):null,currentThemeColors:E,themeStyles:v,orbPosition:b,showAmbientWave:A};return o.jsx(n.BrandingContext.Provider,{value:w,children:e})},rt=({children:e,protocolType:r})=>{const i=r||t.DEFAULT_PROTOCOL,a=s.useMemo(()=>t.createAdapter(i,t.createDefaultAdapterConfig({onAuthExpired:()=>Ye.dispatch(n.clearSession())})),[i]),c=s.useMemo(()=>({adapter:a,protocolType:i}),[a,i]);return o.jsx(t.ProtocolContext.Provider,{value:c,children:e})},ot=({value:e,children:t,fallback:r,extraHydrations:a})=>{n.setModuleStorage(e);const c=i.useDispatch(),u=void 0!==r,[l,d]=s.useState(!u);return s.useEffect(()=>{let t=!1;const r=[c(n.hydrateSession(e))];if(a)for(const t of a)r.push(Promise.resolve(t(e,c)).catch(e=>{n.logger.error({message:"StorageProvider hydration step failed",component:"StorageProvider",error_message:e instanceof Error?e.message:String(e)})}));return Promise.all(r).finally(()=>{t||u&&d(!0)}),()=>{t=!0}},[]),o.jsx(n.StorageContext.Provider,{value:e,children:u&&!l?o.jsx(o.Fragment,{children:r}):t})},st=({token:e,user:t,children:r})=>{const i=s.useRef(null);return e&&e!==i.current&&(i.current=e,Ye.dispatch(n.setSession({accessToken:e,expiresIn:Math.floor(Date.now()/1e3)+3600,...t&&{user:{id:"",email:t.email||"",name:t.name}}}))),o.jsx(o.Fragment,{children:r})},it=({children:e})=>o.jsx(t.ConfigurationContext.Provider,{value:t.useConfigurationValue(),children:e}),at=({children:e,callbacks:n})=>o.jsx(t.ChatCallbacksContext.Provider,{value:n,children:e}),ct=s.lazy(()=>Promise.resolve().then(()=>require("./PaymentProviderHost-Cv6mnzTj.cjs")));exports.BrandingProvider=nt,exports.ChatClientProvider=({baseUrl:e,customHeaders:r,token:s,user:c,protocol:u=t.DEFAULT_PROTOCOL,paymentProvider:l,onConversationChange:d,onConversationTitleChange:p,onMessagesChange:f,onLogoutRequested:h,onSessionExpired:_,storage:m,storageFallback:y,extraHydrations:g,orgId:S,initialThemeStyles:E,initialAppearanceMode:v,reuseHostBranding:b=!1,manageTokenRefresh:A=!0,audioPlatform:P,networkMonitor:w,children:C})=>{n.initializeChatConfig({baseUrl:e,customHeaders:r,paymentProvider:l}),A&&n.setTokenRefreshHandler(_??null);const M=o.jsx(a.AudioPlatformProvider,{value:P,children:C});let T=o.jsx(st,{token:s,user:c,children:o.jsx(rt,{protocolType:u,children:o.jsx(it,{children:o.jsx(at,{callbacks:{onConversationChange:d,onConversationTitleChange:p,onMessagesChange:f,onLogoutRequested:h},children:b?M:o.jsx(nt,{orgId:S,fallbackThemeStyles:E,initialAppearanceMode:v,children:M})})})})});return w&&(T=o.jsx(n.NetworkContext.Provider,{value:w,children:T})),o.jsx(i.Provider,{store:Ye,children:m?o.jsx(ot,{value:m,fallback:y,extraHydrations:g,children:T}):T})},exports.MessageContextProvider=({children:e,messageId:t,isDisabled:n=!1})=>{const[r,i]=s.useState({});return o.jsx(Ze.Provider,{value:{messageContext:r,setMessageContext:i,updateMessageContext:(e,t)=>{i(n=>({...n,[e]:t}))},messageId:t},children:o.jsx(et.Provider,{value:{messageId:t,isDisabled:n},children:e})})},exports.PaymentProviderHost=e=>o.jsx(s.Suspense,{fallback:null,children:o.jsx(ct,{...e})}),exports.SettingsProvider=({children:e,defaultSttImplementation:r=Be})=>{const{user:i}=t.useAuth(),a=i?.id,c=n.useStorage(),[u,l]=s.useState(!1),[d,p]=s.useState(qe),[f,h]=s.useState(He),[_,m]=s.useState(We),[y,g]=s.useState(r),[S,E]=s.useState(Ve);return s.useEffect(()=>{let e=!1;return Promise.all([c.getItem(n.STORAGE_KEYS.DEBUG_MODE),c.getItem(n.STORAGE_KEYS.LOCATION_ENABLED),c.getItem(n.STORAGE_KEYS.STT_AUTO_SEND),c.getItem(n.STORAGE_KEYS.STT_IMPLEMENTATION),c.getItem(n.STORAGE_KEYS.SEND_DIAGNOSTICS)]).then(([t,o,s,i,a])=>{if(e)return;var c;p(Qe(t,qe)),h(Qe(o,He)),m(Qe(s,We)),g((c=i)===n.STT_IMPLEMENTATIONS.ONLINE||c===n.STT_IMPLEMENTATIONS.DEVICE?c:r);const u=Qe(a,Ve);E(u),n.setNetworkLoggingEnabled(u)}),()=>{e=!0}},[r,a,c]),o.jsx(t.ChatSettingsContext.Provider,{value:{enableTts:u,setEnableTts:l,debugMode:d,setDebugMode:e=>{p(e),c.setItem(n.STORAGE_KEYS.DEBUG_MODE,String(e))},locationEnabled:f,setLocationEnabled:e=>{h(e),c.setItem(n.STORAGE_KEYS.LOCATION_ENABLED,String(e))},autoSendVoice:_,setAutoSendVoice:e=>{m(e),c.setItem(n.STORAGE_KEYS.STT_AUTO_SEND,String(e))},sttImplementation:y,setSttImplementation:e=>{g(e),c.setItem(n.STORAGE_KEYS.STT_IMPLEMENTATION,e)},sendDiagnostics:S,setSendDiagnostics:e=>{E(e),n.setNetworkLoggingEnabled(e),c.setItem(n.STORAGE_KEYS.SEND_DIAGNOSTICS,String(e))}},children:e})},exports.StorageProvider=ot,exports.preloadPaymentModal=()=>Promise.resolve().then(()=>require("./PaymentProviderHost-Cv6mnzTj.cjs")).catch(()=>{}),exports.rootReducer=Ge,exports.store=Ye,exports.useDocumentUploadHandlers=function(e){const[n]=t.useUploadDocumentMutation(),[r]=t.useDeleteDocumentMutation();return{onUploadFile:s.useCallback(async(r,o)=>{try{return{documentId:(await n({file:await Je(r),filename:o.fileRequestId,documentType:o.documentType,conversationId:e,onUploadProgress:o.onProgress,onUploadComplete:()=>o.onPhase?.("processing")}).unwrap()).data.document_id}}catch(e){if(e instanceof Error)throw e;throw new Error(t.getApiErrorMessage(e,"Upload failed. Please try again."))}},[n,e]),onRemoveFile:s.useCallback(e=>{r(e)},[r])}},exports.useMessageContext=()=>{const e=s.useContext(Ze);if(!e)throw new Error("useMessageContext must be used within MessageContextProvider");return e},exports.useMessageDisabled=()=>{const e=s.useContext(et);return e?.isDisabled??!1},exports.useMessageId=()=>{const e=s.useContext(et);return e?.messageId},exports.useSettings=Xe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-hPiV7e_i.cjs");exports.BrandingProvider=e.BrandingProvider,exports.ChatClientProvider=e.ChatClientProvider,exports.MessageContextProvider=e.MessageContextProvider,exports.PaymentProviderHost=e.PaymentProviderHost,exports.SettingsProvider=e.SettingsProvider,exports.StorageProvider=e.StorageProvider,exports.preloadPaymentModal=e.preloadPaymentModal,exports.rootReducer=e.rootReducer,exports.store=e.store,exports.useDocumentUploadHandlers=e.useDocumentUploadHandlers,exports.useMessageContext=e.useMessageContext,exports.useMessageDisabled=e.useMessageDisabled,exports.useMessageId=e.useMessageId,exports.useSettings=e.useSettings;
|