@nylas/react 1.0.2-prealpha1 → 1.1.0-canary.3
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/add-circle-icon_22.entry-8d0ac489.cjs +1 -0
- package/dist/add-circle-icon_22.entry-da31fa71.js +1733 -0
- package/dist/{archive-icon_7.entry-84d70dbf.cjs → archive-icon_7.entry-7aad8104.cjs} +1 -1
- package/dist/{archive-icon_7.entry-91aaa1aa.js → archive-icon_7.entry-bc2418f7.js} +20 -20
- package/dist/{arrow-icon.entry-400a08fa.cjs → arrow-icon.entry-6eba68a9.cjs} +1 -1
- package/dist/arrow-icon.entry-9a932082.js +15 -0
- package/dist/{bold-icon_3.entry-4b2798a8.js → bold-icon_3.entry-5f7e3755.js} +4 -4
- package/dist/{bold-icon_3.entry-9ad35153.cjs → bold-icon_3.entry-db17d481.cjs} +1 -1
- package/dist/{calendar-cancel-icon.entry-83ba884a.js → calendar-cancel-icon.entry-1ff7845a.js} +4 -4
- package/dist/{calendar-cancel-icon.entry-fcb66929.cjs → calendar-cancel-icon.entry-a5141f82.cjs} +1 -1
- package/dist/calendar-check-icon_2.entry-c3add652.cjs +1 -0
- package/dist/calendar-check-icon_2.entry-d7421059.js +25 -0
- package/dist/{calendar-icon.entry-8f38af4a.js → calendar-icon.entry-4458997f.js} +2 -2
- package/dist/{calendar-icon.entry-7bae38d7.cjs → calendar-icon.entry-445d624a.cjs} +1 -1
- package/dist/chevron-icon_3.entry-8961e6bb.cjs +1 -0
- package/dist/chevron-icon_3.entry-f7f3d487.js +117 -0
- package/dist/close-icon.entry-6dd5ff0a.js +15 -0
- package/dist/close-icon.entry-ebc527c5.cjs +1 -0
- package/dist/{nylas-booked-event-card_10.entry-7e66a648.js → constants-6ee60d6d-4cd16450.js} +1656 -2374
- package/dist/{nylas-booked-event-card_10.entry-ed515326.cjs → constants-6ee60d6d-6c0540db.cjs} +6 -6
- package/dist/document-refresh-icon.entry-298b2133.cjs +1 -0
- package/dist/document-refresh-icon.entry-bdc323b5.js +15 -0
- package/dist/elements/index.d.ts +31 -2
- package/dist/{forward-icon_6.entry-3345af84.cjs → forward-icon_6.entry-15208ea9.cjs} +3 -3
- package/dist/{forward-icon_6.entry-b60fcb35.js → forward-icon_6.entry-62759373.js} +127 -127
- package/dist/{globe-icon.entry-e3fd373f.js → globe-icon.entry-9e082178.js} +4 -4
- package/dist/{globe-icon.entry-8325e73e.cjs → globe-icon.entry-c8302bf5.cjs} +1 -1
- package/dist/google-logo-icon_3.entry-0c095209.js +258 -0
- package/dist/google-logo-icon_3.entry-f8433ff9.cjs +1 -0
- package/dist/index-0f3bd8df.js +1824 -0
- package/dist/index-7a55dc33.cjs +30 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.es-2578c6a5-098d48d0.cjs +7 -0
- package/dist/{index-b30d446a-a90f84b2.js → index.es-2578c6a5-71441142.js} +833 -933
- package/dist/info-icon_2.entry-73106882.js +34 -0
- package/dist/info-icon_2.entry-ca224a3b.cjs +1 -0
- package/dist/{loading-icon.entry-27410cf8.js → loading-icon.entry-012644b7.js} +4 -4
- package/dist/{loading-icon.entry-b2096d2b.cjs → loading-icon.entry-f9f5e66f.cjs} +1 -1
- package/dist/mailbox-store-bb21512c-045c3ea0.cjs +1 -0
- package/dist/{mailbox-store-19f0c6c9-e3e8b4e5.js → mailbox-store-bb21512c-615660ef.js} +17 -16
- package/dist/nylas-additional-participants.entry-a50ef8e2.cjs +1 -0
- package/dist/nylas-additional-participants.entry-db85836a.js +83 -0
- package/dist/nylas-booked-event-card_10.entry-b49b2369.js +784 -0
- package/dist/nylas-booked-event-card_10.entry-fccb783c.cjs +1 -0
- package/dist/nylas-form-card.entry-090a4d3b.js +56 -0
- package/dist/nylas-form-card.entry-f5230005.cjs +1 -0
- package/dist/nylas-if-state.entry-7924dde0.js +96 -0
- package/dist/nylas-if-state.entry-ff9c9a85.cjs +1 -0
- package/dist/{nylas-list-folders.entry-a5437201.js → nylas-list-folders.entry-9dd96530.js} +9 -8
- package/dist/nylas-list-folders.entry-dbfc2cf8.cjs +1 -0
- package/dist/nylas-list-threads.entry-6bcc0328.cjs +1 -0
- package/dist/{nylas-list-threads.entry-fd6cda61.js → nylas-list-threads.entry-b435eaae.js} +5 -4
- package/dist/nylas-login.entry-1623d309.cjs +1 -0
- package/dist/nylas-login.entry-97350c76.js +75 -0
- package/dist/nylas-mailbox-pagination.entry-1776eb16.cjs +1 -0
- package/dist/{nylas-mailbox-pagination.entry-988214bc.js → nylas-mailbox-pagination.entry-ceef8be2.js} +4 -3
- package/dist/nylas-mailbox-toolbar-button.entry-7d3f79b9.cjs +1 -0
- package/dist/{nylas-mailbox-toolbar-button.entry-c720e22a.js → nylas-mailbox-toolbar-button.entry-e6b3d3a4.js} +11 -10
- package/dist/nylas-mailbox.entry-06d8014a.js +136 -0
- package/dist/nylas-mailbox.entry-ae8da6ff.cjs +1 -0
- package/dist/{nylas-provider.entry-70721009.js → nylas-provider.entry-8b9c2b69.js} +46 -33
- package/dist/nylas-provider.entry-97c9e272.cjs +1 -0
- package/dist/nylas-scheduler-editor.entry-c3791787.js +2181 -0
- package/dist/nylas-scheduler-editor.entry-f6cf1cd9.cjs +7 -0
- package/dist/nylas-scheduling.entry-08ae840a.cjs +1 -0
- package/dist/nylas-scheduling.entry-6380509a.js +237 -0
- package/dist/nylas-threads-refresh.entry-246e6d77.cjs +1 -0
- package/dist/{nylas-threads-refresh.entry-b7f9e93f.js → nylas-threads-refresh.entry-eaee86fb.js} +6 -5
- package/dist/nylas-threads-search.entry-42a2acb1.cjs +1 -0
- package/dist/{nylas-threads-search.entry-95afea9c.js → nylas-threads-search.entry-7e12758e.js} +15 -14
- package/dist/nylas-view-thread.entry-78e6927a.cjs +1 -0
- package/dist/{nylas-view-thread.entry-165173b1.js → nylas-view-thread.entry-b936e76a.js} +5 -4
- package/dist/people-icon.entry-5c8ee696.js +15 -0
- package/dist/people-icon.entry-bcf848c0.cjs +1 -0
- package/dist/play-icon_2.entry-356e63cc.js +25 -0
- package/dist/play-icon_2.entry-92e78f1b.cjs +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.js +92 -61
- package/dist/{refresh-icon.entry-e48a338f.js → refresh-icon.entry-77f0c377.js} +2 -2
- package/dist/{refresh-icon.entry-601cac89.cjs → refresh-icon.entry-bec053b6.cjs} +1 -1
- package/dist/{register-component-152c6ad2-a06f58c2.js → register-component-dc659dc3-0fdb18dc.js} +2 -2
- package/dist/{register-component-152c6ad2-0df7215b.cjs → register-component-dc659dc3-f58bf25b.cjs} +1 -1
- package/dist/scheduler-config-store-51ee4f42-ce3a9b0e.cjs +1 -0
- package/dist/scheduler-config-store-51ee4f42-e02895da.js +14 -0
- package/dist/{scheduler-store-7d48e682-0c0c3991.js → scheduler-store-72116723-3ba2480c.js} +100 -95
- package/dist/scheduler-store-72116723-db9d91f6.cjs +1 -0
- package/dist/time-period-selector.entry-decd251b.js +78 -0
- package/dist/time-period-selector.entry-f25fad77.cjs +1 -0
- package/dist/translate-icon.entry-cac02c46.js +15 -0
- package/dist/translate-icon.entry-dd5b707c.cjs +1 -0
- package/dist/utils-c00bdc3c-89ab163d.js +2111 -0
- package/dist/utils-c00bdc3c-94b9c3b6.cjs +8 -0
- package/dist/warning-icon.entry-370b9cf0.js +15 -0
- package/dist/warning-icon.entry-8af8a742.cjs +1 -0
- package/package.json +7 -4
- package/dist/add-circle-icon.entry-2ccb238b.cjs +0 -1
- package/dist/add-circle-icon.entry-35d6aa07.js +0 -15
- package/dist/arrow-icon.entry-8b2e96a6.js +0 -15
- package/dist/calendar-check-icon_3.entry-903e2d82.js +0 -35
- package/dist/calendar-check-icon_3.entry-a16ce05e.cjs +0 -1
- package/dist/chevron-icon.entry-58366662.cjs +0 -1
- package/dist/chevron-icon.entry-5e11cef5.js +0 -15
- package/dist/close-icon_2.entry-011d9cf4.js +0 -25
- package/dist/close-icon_2.entry-83088b9a.cjs +0 -1
- package/dist/document-refresh-icon.entry-071ffd66.cjs +0 -1
- package/dist/document-refresh-icon.entry-9083a2e9.js +0 -15
- package/dist/duration-bddc4a13-05d3e3e2.cjs +0 -1
- package/dist/duration-bddc4a13-179ce826.js +0 -41
- package/dist/index-3b6f5cd5.cjs +0 -30
- package/dist/index-630f4e87.js +0 -1498
- package/dist/index-b30d446a-cbbef925.cjs +0 -7
- package/dist/mailbox-store-19f0c6c9-a0cbfa97.cjs +0 -1
- package/dist/nylas-if-state_3.entry-504be976.cjs +0 -1
- package/dist/nylas-if-state_3.entry-e96d01f1.js +0 -291
- package/dist/nylas-list-folders.entry-866361cc.cjs +0 -1
- package/dist/nylas-list-threads.entry-04989295.cjs +0 -1
- package/dist/nylas-mailbox-pagination.entry-e0bd4aef.cjs +0 -1
- package/dist/nylas-mailbox-toolbar-button.entry-3d772b26.cjs +0 -1
- package/dist/nylas-open-hours-picker.entry-6bdc7c73.js +0 -186
- package/dist/nylas-open-hours-picker.entry-881b6db7.cjs +0 -1
- package/dist/nylas-provider.entry-8d9a844b.cjs +0 -1
- package/dist/nylas-scheduler.entry-7321e18f.js +0 -230
- package/dist/nylas-scheduler.entry-e82977fb.cjs +0 -1
- package/dist/nylas-threads-refresh.entry-477e68e4.cjs +0 -1
- package/dist/nylas-threads-search.entry-c5854641.cjs +0 -1
- package/dist/nylas-view-thread.entry-8b72cbdb.cjs +0 -1
- package/dist/play-icon_2.entry-ed5877e3.js +0 -25
- package/dist/play-icon_2.entry-f23ed6c1.cjs +0 -1
- package/dist/scheduler-store-7d48e682-674705ef.cjs +0 -1
- package/dist/search-icon_3.entry-292138c3.js +0 -101
- package/dist/search-icon_3.entry-8e555357.cjs +0 -1
- package/dist/utils-5074a070-ce33ee6b.js +0 -119
- package/dist/utils-5074a070-d5ba6add.cjs +0 -2
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";const T=require("./utils-5074a070-d5ba6add.cjs"),Ye=require("./index-3b6f5cd5.cjs");class ir{constructor(e,n,r=!0,s){this.automaticComponentRegistration=!0,this.registeredComponents={},this.propStateRegistrations=new Map,this.eventListenerRegistrations=new Map,this.host=e,this.stores=n,this.automaticComponentRegistration=r,this.eventOverrides=s,T.debug(`[${this.hostTagName}] Initializing (abstract) provider.`,{eventOverrides:s}),this.registerComponent=this.registerComponent.bind(this),this.getStore=this.getStore.bind(this),Object.keys(this.stores).forEach(i=>{this.propStateRegistrations.set(i,new Map)})}async componentWillLoad(e){T.debug(`[${this.hostTagName}] Will load`),this.setupStoreListeners(),this.nylasConnector=e;const n=Array.from(this.host.querySelectorAll("*")).filter(r=>r.tagName.toLowerCase().startsWith("nylas-"));T.debug(`[${this.hostTagName}] Found ${n.length} child component(s).`,{childComponents:n}),n.forEach(r=>{const s=r;if(!s){T.debug(`[~${this.hostTagName}] Component ${s.tagName} does not have a name. Skipping.`);return}if(!s.registerNylasComponent){T.debug(`[~${this.hostTagName}] Component ${s.tagName} is not a component that can be registered. Skipping.`,{component:s});return}const i={element:s,name:s.tagName.toLowerCase(),getStoresToProp:s.getStoresToProp,storeToProps:s.storeToProps,stateToProps:s.stateToProps,authToProp:s.authToProp,eventToProps:s.eventToProps,connectorToProp:s.connectorToProp};this.registerComponent(i)})}async componentDidLoad(){T.debug(`[${this.hostTagName}] Did load`)}async componentDisconnected(){Object.values(this.stores).forEach(e=>{e.dispose()})}async registerComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){T.debug(`[${this.hostTagName}] Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);return}this.registerComponent(e.detail)}async unregisterComponentHandler(e){if(e.stopPropagation(),!this.automaticComponentRegistration){T.debug(`[${this.hostTagName}] Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);return}this.unregisterComponent(e.detail)}registerComponent(e){T.debug(`[${this.hostTagName}] Registering component ${e.name}.`);const n=e.element.dataset.nylasId;if(n&&this.registeredComponents[n]){T.debug(`[${this.hostTagName}] Component ${e.name} already registered. Skipping.`);return}const{stateToProps:r,getStoresToProp:s,eventToProps:i,storeToProps:o,connectorToProp:u,element:a}=e;a.dataset.nylasId=T.uniqueID(),this.registeredComponents[a.dataset.nylasId]=e;const l=this.eventOverrides;i==null||i.forEach((h,c)=>{var y;const d=this.nylasConnector,g=async m=>{T.debug(`[${this.hostTagName}] Handling "${e.name}" prop "${String(c)}" event.`,{event:m}),c in l&&(T.debug(`[${this.hostTagName}] Found event override for "${String(c)}" event. Calling override.`),await l[c](m,d)),m.defaultPrevented||await h(m,d)},p=e.element.dataset.nylasId;p&&!this.eventListenerRegistrations.has(p)&&this.eventListenerRegistrations.set(p,[]),p&&((y=this.eventListenerRegistrations.get(p))==null||y.push([a,c,g])),T.debug(`[${this.hostTagName}] Setting "${e.name}" event "${String(c)}" to automcially call NylasConnector method.`);const f=T.formatEventName(c.toString());T.debug(`[${this.hostTagName}] Adding event listener for "${f}" on "${a.tagName}"`),a.addEventListener(f,g)}),r==null||r.forEach((h,c)=>{var y,m,v,b;const[d,g]=c.split("."),f=this.getStore(d).state[g];if(!a.dataset.nylasId){T.debug(`[${this.hostTagName}] Component "${e.name}" not registered. Skipping.`,{component:e});return}this.propStateRegistrations.has(d)||this.propStateRegistrations.set(d,new Map),(y=this.propStateRegistrations.get(d))!=null&&y.has(g)?(b=(v=this.propStateRegistrations.get(d))==null?void 0:v.get(g))==null||b.push({elementId:a.dataset.nylasId,propKey:h}):(m=this.propStateRegistrations.get(d))==null||m.set(g,[{elementId:a.dataset.nylasId,propKey:h}]),a[h.toString()]=f,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${h.toString()}" to "${c}" value.`,{stateValue:f})}),s&&(a[s==null?void 0:s.toString()]=this.getStore,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${s.toString()}" to "getStore" method.`)),o==null||o.forEach((h,c)=>{const d=this.getStore(c);a[h.toString()]=d,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${h.toString()}" to "${c}" store.`,{store:d})}),u&&(a[u==null?void 0:u.toString()]=this.nylasConnector,T.debug(`[${this.hostTagName}] Setting "${e.name}" prop "${u.toString()}" to "nylasConnector" value.`,{connectorToProp:u})),T.debug(`[${this.hostTagName}] Component ${e.name} registered.`)}unregisterComponent(e){T.debug(`[${this.hostTagName}] Unregistering component ${e.name}.`);const n=e.element.dataset.nylasId;if(!n){T.debug(`[${this.hostTagName}] Component ${e.name} not registered. Skipping.`);return}if(this.registeredComponents[n]){T.debug(`[${this.hostTagName}] Component ${e.name} not registered. Skipping.`);return}this.propStateRegistrations.forEach((s,i)=>{s.forEach((o,u)=>{var h,c;const a=(h=this.propStateRegistrations.get(i))==null?void 0:h.get(u),l=a==null?void 0:a.filter(d=>d.elementId!==n);l&&((c=this.propStateRegistrations.get(i))==null||c.set(u,l))})});const r=this.eventListenerRegistrations.get(n);r==null||r.forEach(([s,i,o])=>{const u=T.formatEventName(i.toString());T.debug(`[${this.hostTagName}] Removing event listener for "${u}" on "${s.tagName}"`),s.removeEventListener(u,o)}),delete this.registeredComponents[n]}getStore(e){const n=this.stores[e];if(!n)throw new Error(`[${this.hostTagName}] Store "${e.toString()}" not found.`);return n}async setupStoreListeners(){const e=this;Object.entries(this.stores).forEach(([n,r])=>{T.debug(`[${e.hostTagName}] Listening for changes in "${n}" store.`),r.use({set(s,i,o){var l;if(T.debug(`[${e.hostTagName}] Store "${n}" state "${s.toString()}" changed`,{newValue:i,oldValue:o}),i===o){T.debug(`[${e.hostTagName}] Store "${n}" state "${s.toString()}" unchanged. Skipping.`);return}const u=e.registeredComponents;if(!u){T.debug(`[${e.hostTagName}] No registered components found. Skipping.`);return}const a=((l=e.propStateRegistrations.get(n))==null?void 0:l.get(s.toString()))||[];T.debug(`[${e.hostTagName}] Found ${a.length} prop(s) registered for "${s.toString()}" store.`,{props:a,propStateRegistrations:e.propStateRegistrations}),a.forEach(({elementId:h,propKey:c})=>{const d=u[h];if(!d){T.debug(`[${e.hostTagName}] Component "${h}" not found. Skipping.`,{component:d});return}const p=e.getStore(n).state[s];d.element[c.toString()]=p,T.debug(`[${e.hostTagName}] Setting "${d.name}" prop "${c.toString()}" to "${s.toString()}" value.`,{stateValue:p})})}})})}get hostTagName(){var e,n;return((n=(e=this.host)==null?void 0:e.tagName)==null?void 0:n.toLowerCase())??"nylas-provider"}}class or extends ir{}var ar=Object.defineProperty,ur=(t,e,n)=>e in t?ar(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ct=(t,e,n)=>(ur(t,typeof e!="symbol"?e+"":e,n),n),Cn=(t=>(t.Error="error",t.Warning="warning",t.Info="info",t.Success="success",t))(Cn||{});const cr=t=>"error"in t;class lr extends Error{constructor(e){super(e==null?void 0:e.message),ct(this,"apiError"),this.name="NylasAPIError",this.stack=new Error().stack,this.apiError=e}}async function fn(t){const e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),r=Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("");return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const R=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,$=Object.keys,F=Array.isArray;function U(t,e){return typeof e!="object"||$(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||R.Promise||(R.Promise=Promise);const Be=Object.getPrototypeOf,hr={}.hasOwnProperty;function z(t,e){return hr.call(t,e)}function Ee(t,e){typeof e=="function"&&(e=e(Be(t))),(typeof Reflect>"u"?$:Reflect.ownKeys)(e).forEach(n=>{ee(t,n,e[n])})}const Tn=Object.defineProperty;function ee(t,e,n,r){Tn(t,e,U(n&&z(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function ke(t){return{from:function(e){return t.prototype=Object.create(e.prototype),ee(t.prototype,"constructor",t),{extend:Ee.bind(null,t.prototype)}}}}const dr=Object.getOwnPropertyDescriptor;function en(t,e){let n;return dr(t,e)||(n=Be(t))&&en(n,e)}const fr=[].slice;function lt(t,e,n){return fr.call(t,e,n)}function An(t,e){return e(t)}function Ie(t){if(!t)throw new Error("Assertion Failed")}function On(t){R.setImmediate?setImmediate(t):setTimeout(t,0)}function In(t,e){return t.reduce((n,r,s)=>{var i=e(r,s);return i&&(n[i[0]]=i[1]),n},{})}function te(t,e){if(z(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,s=e.length;r<s;++r){var i=te(t,e[r]);n.push(i)}return n}var o=e.indexOf(".");if(o!==-1){var u=t[e.substr(0,o)];return u===void 0?void 0:te(u,e.substr(o+1))}}function H(t,e,n){if(t&&e!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(t)))if(typeof e!="string"&&"length"in e){Ie(typeof n!="string"&&"length"in n);for(var r=0,s=e.length;r<s;++r)H(t,e[r],n[r])}else{var i=e.indexOf(".");if(i!==-1){var o=e.substr(0,i),u=e.substr(i+1);if(u==="")n===void 0?F(t)&&!isNaN(parseInt(o))?t.splice(o,1):delete t[o]:t[o]=n;else{var a=t[o];a&&z(t,o)||(a=t[o]={}),H(a,u,n)}}else n===void 0?F(t)&&!isNaN(parseInt(e))?t.splice(e,1):delete t[e]:t[e]=n}}function Rn(t){var e={};for(var n in t)z(t,n)&&(e[n]=t[n]);return e}const pr=[].concat;function Kn(t){return pr.apply([],t)}const jn="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Kn([8,16,32,64].map(t=>["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>R[t]),gr=jn.map(t=>R[t]);In(jn,t=>[t,!0]);let se=null;function We(t){se=typeof WeakMap<"u"&&new WeakMap;const e=At(t);return se=null,e}function At(t){if(!t||typeof t!="object")return t;let e=se&&se.get(t);if(e)return e;if(F(t)){e=[],se&&se.set(t,e);for(var n=0,r=t.length;n<r;++n)e.push(At(t[n]))}else if(gr.indexOf(t.constructor)>=0)e=t;else{const i=Be(t);for(var s in e=i===Object.prototype?{}:Object.create(i),se&&se.set(t,e),t)z(t,s)&&(e[s]=At(t[s]))}return e}const{toString:mr}={};function Ot(t){return mr.call(t).slice(8,-1)}const It=typeof Symbol<"u"?Symbol.iterator:"@@iterator",yr=typeof It=="symbol"?function(t){var e;return t!=null&&(e=t[It])&&e.apply(t)}:function(){return null},_e={};function J(t){var e,n,r,s;if(arguments.length===1){if(F(t))return t.slice();if(this===_e&&typeof t=="string")return[t];if(s=yr(t)){for(n=[];!(r=s.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const tn=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var G=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Dn(t,e){G=t,$n=e}var $n=()=>!0;const vr=!new Error("").stack;function Pe(){if(vr)try{throw new Error}catch(t){return t}return new Error}function Rt(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(`
|
|
2
|
-
`).length),n.split(`
|
|
3
|
-
`).slice(e).filter($n).map(r=>`
|
|
4
|
-
`+r).join("")):""}var Nn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],nn=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Nn),br={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function xe(t,e){this._e=Pe(),this.name=t,this.message=e}function Bn(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,s)=>s.indexOf(n)===r).join(`
|
|
5
|
-
`)}function ht(t,e,n,r){this._e=Pe(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Bn(t,e)}function Ke(t,e){this._e=Pe(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Bn(t,e)}ke(xe).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Rt(this._e,2))}},toString:function(){return this.name+": "+this.message}}),ke(ht).from(xe),ke(Ke).from(xe);var rn=nn.reduce((t,e)=>(t[e]=e+"Error",t),{});const wr=xe;var C=nn.reduce((t,e)=>{var n=e+"Error";function r(s,i){this._e=Pe(),this.name=n,s?typeof s=="string"?(this.message=`${s}${i?`
|
|
6
|
-
`+i:""}`,this.inner=i||null):typeof s=="object"&&(this.message=`${s.name} ${s.message}`,this.inner=s):(this.message=br[e]||n,this.inner=null)}return ke(r).from(wr),t[e]=r,t},{});C.Syntax=SyntaxError,C.Type=TypeError,C.Range=RangeError;var pn=Nn.reduce((t,e)=>(t[e+"Error"]=C[e],t),{}),nt=nn.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=C[e]),t),{});function I(){}function Me(t){return t}function _r(t,e){return t==null||t===Me?e:function(n){return e(t(n))}}function ge(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function kr(t,e){return t===I?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?ge(r,this.onsuccess):r),s&&(this.onerror=this.onerror?ge(s,this.onerror):s),i!==void 0?i:n}}function xr(t,e){return t===I?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?ge(n,this.onsuccess):n),r&&(this.onerror=this.onerror?ge(r,this.onerror):r)}}function Sr(t,e){return t===I?e:function(n){var r=t.apply(this,arguments);U(n,r);var s=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return s&&(this.onsuccess=this.onsuccess?ge(s,this.onsuccess):s),i&&(this.onerror=this.onerror?ge(i,this.onerror):i),r===void 0?o===void 0?void 0:o:U(r,o)}}function Er(t,e){return t===I?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function sn(t,e){return t===I?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then(function(){return e.apply(r,i)})}return e.apply(this,arguments)}}nt.ModifyError=ht,nt.DexieError=xe,nt.BulkError=Ke;var Fe={};const Mn=100,[Kt,dt,jt]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Be(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Be(e),t]})(),Fn=dt&&dt.then,rt=Kt&&Kt.constructor,on=!!jt;var Dt=!1,Pr=jt?()=>{jt.then(Ge)}:R.setImmediate?setImmediate.bind(null,Ge):R.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Ge(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Ge,0)},je=function(t,e){Re.push([t,e]),ft&&(Pr(),ft=!1)},$t=!0,ft=!0,de=[],st=[],Nt=null,Bt=Me,Se={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:yn,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{yn(t[0],t[1])}catch{}})}},P=Se,Re=[],fe=0,it=[];function S(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=I,this._lib=!1;var e=this._PSD=P;if(G&&(this._stackHolder=Pe(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Fe)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Ft(this,this._value))}this._state=null,this._value=null,++e.ref,Ln(this,t)}const Mt={get:function(){var t=P,e=pt;function n(r,s){var i=!t.global&&(t!==P||e!==pt);const o=i&&!ne();var u=new S((a,l)=>{an(this,new qn(gt(r,t,i,o),gt(s,t,i,o),a,l,t))});return G&&Wn(u,this),u}return n.prototype=Fe,n},set:function(t){ee(this,"then",t&&t.prototype===Fe?Mt:{get:function(){return t},set:Mt.set})}};function qn(t,e,n,r,s){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=s}function Ln(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&ze();n&&typeof n.then=="function"?Ln(t,(s,i)=>{n instanceof S?n._then(s,i):n.then(s,i)}):(t._state=!0,t._value=n,Un(t)),r&&He()}},Ft.bind(null,t))}catch(n){Ft(t,n)}}function Ft(t,e){if(st.push(e),t._state===null){var n=t._lib&&ze();e=Bt(e),t._state=!1,t._value=e,G&&e!==null&&typeof e=="object"&&!e._promise&&function(r,s,i){try{r.apply(null,i)}catch(o){s&&s(o)}}(()=>{var r=en(e,"stack");e._promise=t,ee(e,"stack",{get:()=>Dt?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){de.some(s=>s._value===r._value)||de.push(r)}(t),Un(t),n&&He()}}function Un(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n<r;++n)an(t,e[n]);var s=t._PSD;--s.ref||s.finalize(),fe===0&&(++fe,je(()=>{--fe==0&&un()},[]))}function an(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++fe,je(Cr,[n,t,e])}else t._listeners.push(e)}function Cr(t,e,n){try{Nt=e;var r,s=e._value;e._state?r=t(s):(st.length&&(st=[]),r=t(s),st.indexOf(s)===-1&&function(i){for(var o=de.length;o;)if(de[--o]._value===i._value)return void de.splice(o,1)}(e)),n.resolve(r)}catch(i){n.reject(i)}finally{Nt=null,--fe==0&&un(),--n.psd.ref||n.psd.finalize()}}function Vn(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var s,i,o=t._value;o!=null?(s=o.name||"Error",i=o.message||o,r=Rt(o,0)):(s=o,i=""),e.push(s+(i?": "+i:"")+r)}return G&&((r=Rt(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Vn(t._prev,e,n)),e}function Wn(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function Ge(){ze()&&He()}function ze(){var t=$t;return $t=!1,ft=!1,t}function He(){var t,e,n;do for(;Re.length>0;)for(t=Re,Re=[],n=t.length,e=0;e<n;++e){var r=t[e];r[0].apply(null,r[1])}while(Re.length>0);$t=!0,ft=!0}function un(){var t=de;de=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=it.slice(0),n=e.length;n;)e[--n]()}function Xe(t){return new S(Fe,!1,t)}function K(t,e){var n=P;return function(){var r=ze(),s=P;try{return ae(n,!0),t.apply(this,arguments)}catch(i){e&&e(i)}finally{ae(s,!1),r&&He()}}}Ee(S.prototype,{then:Mt,_then:function(t,e){an(this,new qn(null,null,t,e,P))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):Xe(r)):this.then(null,r=>r&&r.name===e?n(r):Xe(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),Xe(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Dt=!0;var t=Vn(this,[],20).join(`
|
|
7
|
-
From previous: `);return this._state!==null&&(this._stack=t),t}finally{Dt=!1}}},timeout:function(t,e){return t<1/0?new S((n,r)=>{var s=setTimeout(()=>r(new C.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,s))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&ee(S.prototype,Symbol.toStringTag,"Dexie.Promise"),Se.env=zn(),Ee(S,{all:function(){var t=J.apply(null,arguments).map(Qe);return new S(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((s,i)=>S.resolve(s).then(o=>{t[i]=o,--r||e(t)},n))})},resolve:t=>{if(t instanceof S)return t;if(t&&typeof t.then=="function")return new S((n,r)=>{t.then(n,r)});var e=new S(Fe,!0,t);return Wn(e,Nt),e},reject:Xe,race:function(){var t=J.apply(null,arguments).map(Qe);return new S((e,n)=>{t.map(r=>S.resolve(r).then(e,n))})},PSD:{get:()=>P,set:t=>P=t},totalEchoes:{get:()=>pt},newPSD:oe,usePSD:Te,scheduler:{get:()=>je,set:t=>{je=t}},rejectionMapper:{get:()=>Bt,set:t=>{Bt=t}},follow:(t,e)=>new S((n,r)=>oe((s,i)=>{var o=P;o.unhandleds=[],o.onunhandled=i,o.finalize=ge(function(){(function(u){function a(){u(),it.splice(it.indexOf(a),1)}it.push(a),++fe,je(()=>{--fe==0&&un()},[])})(()=>{this.unhandleds.length===0?s():i(this.unhandleds[0])})},o.finalize),t()},e,n,r))}),rt&&(rt.allSettled&&ee(S,"allSettled",function(){const t=J.apply(null,arguments).map(Qe);return new S(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((s,i)=>S.resolve(s).then(o=>r[i]={status:"fulfilled",value:o},o=>r[i]={status:"rejected",reason:o}).then(()=>--n||e(r)))})}),rt.any&&typeof AggregateError<"u"&&ee(S,"any",function(){const t=J.apply(null,arguments).map(Qe);return new S((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const s=new Array(r);t.forEach((i,o)=>S.resolve(i).then(u=>e(u),u=>{s[o]=u,--r||n(new AggregateError(s))}))})}));const M={awaits:0,echoes:0,id:0};var Tr=0,ot=[],_t=0,pt=0,Ar=0;function oe(t,e,n,r){var s=P,i=Object.create(s);i.parent=s,i.ref=0,i.global=!1,i.id=++Ar;var o=Se.env;i.env=on?{Promise:S,PromiseProp:{value:S,configurable:!0,writable:!0},all:S.all,race:S.race,allSettled:S.allSettled,any:S.any,resolve:S.resolve,reject:S.reject,nthen:gn(o.nthen,i),gthen:gn(o.gthen,i)}:{},e&&U(i,e),++s.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=Te(i,t,n,r);return i.ref===0&&i.finalize(),u}function Ce(){return M.id||(M.id=++Tr),++M.awaits,M.echoes+=Mn,M.id}function ne(){return!!M.awaits&&(--M.awaits==0&&(M.id=0),M.echoes=M.awaits*Mn,!0)}function Qe(t){return M.echoes&&t&&t.constructor===rt?(Ce(),t.then(e=>(ne(),e),e=>(ne(),N(e)))):t}function Or(t){++pt,M.echoes&&--M.echoes!=0||(M.echoes=M.id=0),ot.push(P),ae(t,!0)}function Ir(){var t=ot[ot.length-1];ot.pop(),ae(t,!1)}function ae(t,e){var n=P;if((e?!M.echoes||_t++&&t===P:!_t||--_t&&t===P)||Hn(e?Or.bind(null,t):Ir),t!==P&&(P=t,n===Se&&(Se.env=zn()),on)){var r=Se.env.Promise,s=t.env;dt.then=s.nthen,r.prototype.then=s.gthen,(n.global||t.global)&&(Object.defineProperty(R,"Promise",s.PromiseProp),r.all=s.all,r.race=s.race,r.resolve=s.resolve,r.reject=s.reject,s.allSettled&&(r.allSettled=s.allSettled),s.any&&(r.any=s.any))}}function zn(){var t=R.Promise;return on?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(R,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:dt.then,gthen:t.prototype.then}:{}}function Te(t,e,n,r,s){var i=P;try{return ae(t,!0),e(n,r,s)}finally{ae(i,!1)}}function Hn(t){Fn.call(Kt,t)}function gt(t,e,n,r){return typeof t!="function"?t:function(){var s=P;n&&Ce(),ae(e,!0);try{return t.apply(this,arguments)}finally{ae(s,!1),r&&Hn(ne)}}}function gn(t,e){return function(n,r){return t.call(this,gt(n,e),gt(r,e))}}(""+Fn).indexOf("[native code]")===-1&&(Ce=ne=I);const mn="unhandledrejection";function yn(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,s={promise:e,reason:t};if(R.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(mn,!0,!0),U(r,s)):R.CustomEvent&&U(r=new CustomEvent(mn,{detail:s}),s),r&&R.dispatchEvent&&(dispatchEvent(r),!R.PromiseRejectionEvent&&R.onunhandledrejection))try{R.onunhandledrejection(r)}catch{}G&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var N=S.reject;function qt(t,e,n,r){if(t.idbdb&&(t._state.openComplete||P.letThrough||t._vip)){var s=t._createTransaction(e,n,t._dbSchema);try{s.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===rn.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>qt(t,e,n,r))):N(i)}return s._promise(e,(i,o)=>oe(()=>(P.trans=s,r(i,o,s)))).then(i=>s._completion.then(()=>i))}if(t._state.openComplete)return N(new C.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return N(new C.DatabaseClosed);t.open().catch(I)}return t._state.dbReadyPromise.then(()=>qt(t,e,n,r))}const vn="3.2.4",he=String.fromCharCode(65535),Lt=-1/0,X="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Yn="String expected.",De=[],vt=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Rr=vt,Kr=vt,Gn=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),bt="__dbnames",kt="readonly",xt="readwrite";function me(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Xn={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Je(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=We(e))[t],e)}class jr{_trans(e,n,r){const s=this._tx||P.trans,i=this.name;function o(a,l,h){if(!h.schema[i])throw new C.NotFound("Table "+i+" not part of transaction");return n(h.idbtrans,h)}const u=ze();try{return s&&s.db===this.db?s===P.trans?s._promise(e,o,r):oe(()=>s._promise(e,o,r),{trans:s,transless:P.transless||P}):qt(this.db,e,[this.name],o)}finally{u&&He()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(s=>this.hook.reading.fire(s))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(F(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=$(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(l=>l.compound&&n.every(h=>l.keyPath.indexOf(h)>=0)&&l.keyPath.every(h=>n.indexOf(h)>=0))[0];if(r&&this.db._maxKey!==he)return this.where(r.name).equals(r.keyPath.map(l=>e[l]));!r&&G&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:s}=this.schema,i=this.db._deps.indexedDB;function o(l,h){try{return i.cmp(l,h)===0}catch{return!1}}const[u,a]=n.reduce(([l,h],c)=>{const d=s[c],g=e[c];return[l||d,l||!d?me(h,d&&d.multi?p=>{const f=te(p,c);return F(f)&&f.some(y=>o(g,y))}:p=>o(g,te(p,c))):h]},[null,null]);return u?this.where(u.name).equals(e[u.keyPath]).filter(a):r?this.filter(a):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,F(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const s=Object.create(e.prototype);for(var i in r)if(z(r,i))try{s[i]=r[i]}catch{}return s};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){U(this,e)})}add(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=Je(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"add",keys:n!=null?[n]:null,values:[i]})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{H(e,s,o)}catch{}return o})}update(e,n){if(typeof e!="object"||F(e))return this.where(":id").equals(e).modify(n);{const r=te(e,this.schema.primKey.keyPath);if(r===void 0)return N(new C.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?$(n).forEach(s=>{H(e,s,n[s])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=Je(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"put",values:[i],keys:n!=null?[n]:null})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{H(e,s,o)}catch{}return o})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?S.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Xn})).then(e=>e.numFailures?S.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(s=>this.hook.reading.fire(s))))}bulkAdd(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:u,keyPath:a}=this.schema.primKey;if(a&&s)throw new C.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new C.InvalidArgument("Arguments objects and keys must have the same length");const l=e.length;let h=a&&u?e.map(Je(a)):e;return this.core.mutate({trans:o,type:"add",keys:s,values:h,wantResults:i}).then(({numFailures:c,results:d,lastResult:g,failures:p})=>{if(c===0)return i?d:g;throw new Ke(`${this.name}.bulkAdd(): ${c} of ${l} operations failed`,p)})})}bulkPut(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:u,keyPath:a}=this.schema.primKey;if(a&&s)throw new C.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new C.InvalidArgument("Arguments objects and keys must have the same length");const l=e.length;let h=a&&u?e.map(Je(a)):e;return this.core.mutate({trans:o,type:"put",keys:s,values:h,wantResults:i}).then(({numFailures:c,results:d,lastResult:g,failures:p})=>{if(c===0)return i?d:g;throw new Ke(`${this.name}.bulkPut(): ${c} of ${l} operations failed`,p)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:s,failures:i})=>{if(r===0)return s;throw new Ke(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,i)})}}function $e(t){var e={},n=function(o,u){if(u){for(var a=arguments.length,l=new Array(a-1);--a;)l[a-1]=arguments[a];return e[o].subscribe.apply(null,l),t}if(typeof o=="string")return e[o]};n.addEventType=i;for(var r=1,s=arguments.length;r<s;++r)i(arguments[r]);return n;function i(o,u,a){if(typeof o!="object"){var l;u||(u=Er),a||(a=I);var h={subscribers:[],fire:a,subscribe:function(c){h.subscribers.indexOf(c)===-1&&(h.subscribers.push(c),h.fire=u(h.fire,c))},unsubscribe:function(c){h.subscribers=h.subscribers.filter(function(d){return d!==c}),h.fire=h.subscribers.reduce(u,a)}};return e[o]=n[o]=h,h}$(l=o).forEach(function(c){var d=l[c];if(F(d))i(c,l[c][0],l[c][1]);else{if(d!=="asap")throw new C.InvalidArgument("Invalid event config");var g=i(c,Me,function(){for(var p=arguments.length,f=new Array(p);p--;)f[p]=arguments[p];g.subscribers.forEach(function(y){On(function(){y.apply(null,f)})})})}})}}function Oe(t,e){return ke(e).from({prototype:t}),e}function be(t,e){return!(t.filter||t.algorithm||t.or)&&(e?t.justLimit:!t.replayFilter)}function St(t,e){t.filter=me(t.filter,e)}function Et(t,e,n){var r=t.replayFilter;t.replayFilter=r?()=>me(r(),e()):e,t.justLimit=n&&!r}function at(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new C.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function bn(t,e,n){const r=at(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function Ze(t,e,n,r){const s=t.replayFilter?me(t.filter,t.replayFilter()):t.filter;if(t.or){const i={},o=(u,a,l)=>{if(!s||s(a,l,d=>a.stop(d),d=>a.fail(d))){var h=a.primaryKey,c=""+h;c==="[object ArrayBuffer]"&&(c=""+new Uint8Array(h)),z(i,c)||(i[c]=!0,e(u,a,l))}};return Promise.all([t.or._iterate(o,n),wn(bn(t,r,n),t.algorithm,o,!t.keysOnly&&t.valueMapper)])}return wn(bn(t,r,n),me(t.algorithm,s),e,!t.keysOnly&&t.valueMapper)}function wn(t,e,n,r){var s=K(r?(i,o,u)=>n(r(i),o,u):n);return t.then(i=>{if(i)return i.start(()=>{var o=()=>i.continue();e&&!e(i,u=>o=u,u=>{i.stop(u),o=I},u=>{i.fail(u),o=I})||s(i.value,i,u=>o=u),o()})})}function L(t,e){try{const n=_n(t),r=_n(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:t<e?-1:0;case"binary":return function(s,i){const o=s.length,u=i.length,a=o<u?o:u;for(let l=0;l<a;++l)if(s[l]!==i[l])return s[l]<i[l]?-1:1;return o===u?0:o<u?-1:1}(kn(t),kn(e));case"Array":return function(s,i){const o=s.length,u=i.length,a=o<u?o:u;for(let l=0;l<a;++l){const h=L(s[l],i[l]);if(h!==0)return h}return o===u?0:o<u?-1:1}(t,e)}}catch{}return NaN}function _n(t){const e=typeof t;if(e!=="object")return e;if(ArrayBuffer.isView(t))return"binary";const n=Ot(t);return n==="ArrayBuffer"?"binary":n}function kn(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}class Dr{_read(e,n){var r=this._ctx;return r.error?r.table._trans(null,N.bind(null,r.error)):r.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,N.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=me(n.algorithm,e)}_iterate(e,n){return Ze(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&U(r,e),n._ctx=r,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(r=>Ze(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,s=r.table.core;if(be(r,!0))return s.count({trans:n,query:{index:at(r,s.schema),range:r.range}}).then(o=>Math.min(o,r.limit));var i=0;return Ze(r,()=>(++i,!1),n,s).then(()=>i)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),s=r[0],i=r.length-1;function o(l,h){return h?o(l[r[h]],h-1):l[s]}var u=this._ctx.dir==="next"?1:-1;function a(l,h){var c=o(l,i),d=o(h,i);return c<d?-u:c>d?u:0}return this.toArray(function(l){return l.sort(a)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&be(r,!0)&&r.limit>0){const{valueMapper:s}=r,i=at(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:i,range:r.range}}).then(({result:o})=>s?o.map(s):o)}{const s=[];return Ze(r,i=>s.push(i),n,r.table.core).then(()=>s)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,be(n)?Et(n,()=>{var r=e;return(s,i)=>r===0||(r===1?(--r,!1):(i(()=>{s.advance(r),r=0}),!1))}):Et(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Et(this._ctx,()=>{var n=e;return function(r,s,i){return--n<=0&&s(i),n>=0}},!0),this}until(e,n){return St(this._ctx,function(r,s,i){return!e(r.value)||(s(i),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return St(this._ctx,function(s){return e(s.value)}),n=this._ctx,r=e,n.isMatch=me(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.key,s)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.primaryKey,s)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&be(n,!0)&&n.limit>0)return this._read(s=>{var i=at(n,n.table.core.schema);return n.table.core.query({trans:s,values:!1,limit:n.limit,query:{index:i,range:n.range}})}).then(({result:s})=>s).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return St(this._ctx,function(s){var i=s.primaryKey.toString(),o=z(r,i);return r[i]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(r=>{var s;if(typeof e=="function")s=e;else{var i=$(e),o=i.length;s=function(f){for(var y=!1,m=0;m<o;++m){var v=i[m],b=e[v];te(f,v)!==b&&(H(f,v,b),y=!0)}return y}}const u=n.table.core,{outbound:a,extractKey:l}=u.schema.primaryKey,h=this.db._options.modifyChunkSize||200,c=[];let d=0;const g=[],p=(f,y)=>{const{failures:m,numFailures:v}=y;d+=f-v;for(let b of $(m))c.push(m[b])};return this.clone().primaryKeys().then(f=>{const y=m=>{const v=Math.min(h,f.length-m);return u.getMany({trans:r,keys:f.slice(m,m+v),cache:"immutable"}).then(b=>{const x=[],E=[],k=a?[]:null,w=[];for(let _=0;_<v;++_){const j=b[_],O={value:We(j),primKey:f[m+_]};s.call(O,O.value,O)!==!1&&(O.value==null?w.push(f[m+_]):a||L(l(j),l(O.value))===0?(E.push(O.value),a&&k.push(f[m+_])):(w.push(f[m+_]),x.push(O.value)))}const A=be(n)&&n.limit===1/0&&(typeof e!="function"||e===Pt)&&{index:n.index,range:n.range};return Promise.resolve(x.length>0&&u.mutate({trans:r,type:"add",values:x}).then(_=>{for(let j in _.failures)w.splice(parseInt(j),1);p(x.length,_)})).then(()=>(E.length>0||A&&typeof e=="object")&&u.mutate({trans:r,type:"put",keys:k,values:E,criteria:A,changeSpec:typeof e!="function"&&e}).then(_=>p(E.length,_))).then(()=>(w.length>0||A&&e===Pt)&&u.mutate({trans:r,type:"delete",keys:w,criteria:A}).then(_=>p(w.length,_))).then(()=>f.length>m+v&&y(m+h))})};return y(0).then(()=>{if(c.length>0)throw new ht("Error modifying one or more objects",c,d,g);return f.length})})})}delete(){var e=this._ctx,n=e.range;return be(e)&&(e.isPrimKey&&!Kr||n.type===3)?this._write(r=>{const{primaryKey:s}=e.table.core.schema,i=n;return e.table.core.count({trans:r,query:{index:s,range:i}}).then(o=>e.table.core.mutate({trans:r,type:"deleteRange",range:i}).then(({failures:u,lastResult:a,results:l,numFailures:h})=>{if(h)throw new ht("Could not delete some values",Object.keys(u).map(c=>u[c]),o-h);return o-h}))}):this.modify(Pt)}}const Pt=(t,e)=>e.value=null;function $r(t,e){return t<e?-1:t===e?0:1}function Nr(t,e){return t>e?-1:t===e?0:1}function W(t,e,n){var r=t instanceof Jn?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function we(t){return new t.Collection(t,()=>Qn("")).limit(0)}function Br(t,e,n,r,s,i){for(var o=Math.min(t.length,r.length),u=-1,a=0;a<o;++a){var l=e[a];if(l!==r[a])return s(t[a],n[a])<0?t.substr(0,a)+n[a]+n.substr(a+1):s(t[a],r[a])<0?t.substr(0,a)+r[a]+n.substr(a+1):u>=0?t.substr(0,u)+e[u]+n.substr(u+1):null;s(t[a],l)<0&&(u=a)}return o<r.length&&i==="next"?t+n.substr(t.length):o<t.length&&i==="prev"?t.substr(0,n.length):u<0?null:t.substr(0,u)+r[u]+n.substr(u+1)}function et(t,e,n,r){var s,i,o,u,a,l,h,c=n.length;if(!n.every(f=>typeof f=="string"))return W(t,Yn);function d(f){s=function(m){return m==="next"?v=>v.toUpperCase():v=>v.toLowerCase()}(f),i=function(m){return m==="next"?v=>v.toLowerCase():v=>v.toUpperCase()}(f),o=f==="next"?$r:Nr;var y=n.map(function(m){return{lower:i(m),upper:s(m)}}).sort(function(m,v){return o(m.lower,v.lower)});u=y.map(function(m){return m.upper}),a=y.map(function(m){return m.lower}),l=f,h=f==="next"?"":r}d("next");var g=new t.Collection(t,()=>re(u[0],a[c-1]+r));g._ondirectionchange=function(f){d(f)};var p=0;return g._addAlgorithm(function(f,y,m){var v=f.key;if(typeof v!="string")return!1;var b=i(v);if(e(b,a,p))return!0;for(var x=null,E=p;E<c;++E){var k=Br(v,b,u[E],a[E],o,l);k===null&&x===null?p=E+1:(x===null||o(x,k)>0)&&(x=k)}return y(x!==null?function(){f.continue(x+h)}:m),!1}),g}function re(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Qn(t){return{type:1,lower:t,upper:t}}class Jn{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,s){r=r!==!1,s=s===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||s)&&(!r||!s)?we(this):new this.Collection(this,()=>re(e,n,!r,!s))}catch{return W(this,X)}}equals(e){return e==null?W(this,X):new this.Collection(this,()=>Qn(e))}above(e){return e==null?W(this,X):new this.Collection(this,()=>re(e,void 0,!0))}aboveOrEqual(e){return e==null?W(this,X):new this.Collection(this,()=>re(e,void 0,!1))}below(e){return e==null?W(this,X):new this.Collection(this,()=>re(void 0,e,!1,!0))}belowOrEqual(e){return e==null?W(this,X):new this.Collection(this,()=>re(void 0,e))}startsWith(e){return typeof e!="string"?W(this,Yn):this.between(e,e+he,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):et(this,(n,r)=>n.indexOf(r[0])===0,[e],he)}equalsIgnoreCase(e){return et(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=J.apply(_e,arguments);return e.length===0?we(this):et(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=J.apply(_e,arguments);return e.length===0?we(this):et(this,(n,r)=>r.some(s=>n.indexOf(s)===0),e,he)}anyOf(){const e=J.apply(_e,arguments);let n=this._cmp;try{e.sort(n)}catch{return W(this,X)}if(e.length===0)return we(this);const r=new this.Collection(this,()=>re(e[0],e[e.length-1]));r._ondirectionchange=i=>{n=i==="next"?this._ascending:this._descending,e.sort(n)};let s=0;return r._addAlgorithm((i,o,u)=>{const a=i.key;for(;n(a,e[s])>0;)if(++s,s===e.length)return o(u),!1;return n(a,e[s])===0||(o(()=>{i.continue(e[s])}),!1)}),r}notEqual(e){return this.inAnyRange([[Lt,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=J.apply(_e,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return W(this,X)}const n=e.reduce((r,s)=>r?r.concat([[r[r.length-1][1],s]]):[[Lt,s]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,s=this._ascending,i=this._descending,o=this._min,u=this._max;if(e.length===0)return we(this);if(!e.every(v=>v[0]!==void 0&&v[1]!==void 0&&s(v[0],v[1])<=0))return W(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",C.InvalidArgument);const a=!n||n.includeLowers!==!1,l=n&&n.includeUppers===!0;let h,c=s;function d(v,b){return c(v[0],b[0])}try{h=e.reduce(function(v,b){let x=0,E=v.length;for(;x<E;++x){const k=v[x];if(r(b[0],k[1])<0&&r(b[1],k[0])>0){k[0]=o(k[0],b[0]),k[1]=u(k[1],b[1]);break}}return x===E&&v.push(b),v},[]),h.sort(d)}catch{return W(this,X)}let g=0;const p=l?v=>s(v,h[g][1])>0:v=>s(v,h[g][1])>=0,f=a?v=>i(v,h[g][0])>0:v=>i(v,h[g][0])>=0;let y=p;const m=new this.Collection(this,()=>re(h[0][0],h[h.length-1][1],!a,!l));return m._ondirectionchange=v=>{v==="next"?(y=p,c=s):(y=f,c=i),h.sort(d)},m._addAlgorithm((v,b,x)=>{for(var E=v.key;y(E);)if(++g,g===h.length)return b(x),!1;return!!function(k){return!p(k)&&!f(k)}(E)||(this._cmp(E,h[g][1])===0||this._cmp(E,h[g][0])===0||b(()=>{c===s?v.continue(h[g][0]):v.continue(h[g][1])}),!1)}),m}startsWithAnyOf(){const e=J.apply(_e,arguments);return e.every(n=>typeof n=="string")?e.length===0?we(this):this.inAnyRange(e.map(n=>[n,n+he])):W(this,"startsWithAnyOf() only works with strings")}}function Y(t){return K(function(e){return qe(e),t(e.target.error),!1})}function qe(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const Le="storagemutated",ie="x-storagemutated-1",ue=$e(null,Le);class Mr{_lock(){return Ie(!P.global),++this._reculock,this._reculock!==1||P.global||(P.lockOwnerFor=this),this}_unlock(){if(Ie(!P.global),--this._reculock==0)for(P.global||(P.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Te(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&P.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(Ie(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new C.DatabaseClosed(r);case"MissingAPIError":throw new C.MissingAPI(r.message,r);default:throw new C.OpenFailed(r)}if(!this.active)throw new C.TransactionInactive;return Ie(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=K(s=>{qe(s),this._reject(e.error)}),e.onabort=K(s=>{qe(s),this.active&&this._reject(new C.Abort(e.error)),this.active=!1,this.on("abort").fire(s)}),e.oncomplete=K(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&ue.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return N(new C.ReadOnly("Transaction is readonly"));if(!this.active)return N(new C.TransactionInactive);if(this._locked())return new S((i,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(i,o)},P])});if(r)return oe(()=>{var i=new S((o,u)=>{this._lock();const a=n(o,u,this);a&&a.then&&a.then(o,u)});return i.finally(()=>this._unlock()),i._lib=!0,i});var s=new S((i,o)=>{var u=n(i,o,this);u&&u.then&&u.then(i,o)});return s._lib=!0,s}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=S.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var s=n.idbtrans.objectStore(n.storeNames[0]);(function o(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(s.get(-1/0).onsuccess=o)})()}var i=n._waitingFor;return new S((o,u)=>{r.then(a=>n._waitingQueue.push(K(o.bind(null,a))),a=>n._waitingQueue.push(K(u.bind(null,a)))).finally(()=>{n._waitingFor===i&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new C.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(z(n,e))return n[e];const r=this.schema[e];if(!r)throw new C.NotFound("Table "+e+" not part of transaction");const s=new this.db.Table(e,r,this);return s.core=this.db.core.table(e),n[e]=s,s}}function Ut(t,e,n,r,s,i,o){return{name:t,keyPath:e,unique:n,multi:r,auto:s,compound:i,src:(n&&!o?"&":"")+(r?"*":"")+(s?"++":"")+Zn(e)}}function Zn(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function er(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:In(n,r=>[r.name,r])}}let Ue=t=>{try{return t.only([[]]),Ue=()=>[[]],[[]]}catch{return Ue=()=>he,he}};function Vt(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?n=>n[e]:n=>te(n,e)}(t):e=>te(e,t)}function xn(t){return[].slice.call(t)}let Fr=0;function Ne(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function qr(t,e,n){function r(a){if(a.type===3)return null;if(a.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:l,upper:h,lowerOpen:c,upperOpen:d}=a;return l===void 0?h===void 0?null:e.upperBound(h,!!d):h===void 0?e.lowerBound(l,!!c):e.bound(l,h,!!c,!!d)}const{schema:s,hasGetAll:i}=function(a,l){const h=xn(a.objectStoreNames);return{schema:{name:a.name,tables:h.map(c=>l.objectStore(c)).map(c=>{const{keyPath:d,autoIncrement:g}=c,p=F(d),f=d==null,y={},m={name:c.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f,compound:p,keyPath:d,autoIncrement:g,unique:!0,extractKey:Vt(d)},indexes:xn(c.indexNames).map(v=>c.index(v)).map(v=>{const{name:b,unique:x,multiEntry:E,keyPath:k}=v,w={name:b,compound:F(k),keyPath:k,unique:x,multiEntry:E,extractKey:Vt(k)};return y[Ne(k)]=w,w}),getIndexByKeyPath:v=>y[Ne(v)]};return y[":id"]=m.primaryKey,d!=null&&(y[Ne(d)]=m.primaryKey),m})},hasGetAll:h.length>0&&"getAll"in l.objectStore(h[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),o=s.tables.map(a=>function(l){const h=l.name;return{name:h,schema:l,mutate:function({trans:c,type:d,keys:g,values:p,range:f}){return new Promise((y,m)=>{y=K(y);const v=c.objectStore(h),b=v.keyPath==null,x=d==="put"||d==="add";if(!x&&d!=="delete"&&d!=="deleteRange")throw new Error("Invalid operation type: "+d);const{length:E}=g||p||{length:1};if(g&&p&&g.length!==p.length)throw new Error("Given keys array must have same length as given values array.");if(E===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let k;const w=[],A=[];let _=0;const j=q=>{++_,qe(q)};if(d==="deleteRange"){if(f.type===4)return y({numFailures:_,failures:A,results:[],lastResult:void 0});f.type===3?w.push(k=v.clear()):w.push(k=v.delete(r(f)))}else{const[q,B]=x?b?[p,g]:[p,null]:[g,null];if(x)for(let D=0;D<E;++D)w.push(k=B&&B[D]!==void 0?v[d](q[D],B[D]):v[d](q[D])),k.onerror=j;else for(let D=0;D<E;++D)w.push(k=v[d](q[D])),k.onerror=j}const O=q=>{const B=q.target.result;w.forEach((D,ye)=>D.error!=null&&(A[ye]=D.error)),y({numFailures:_,failures:A,results:d==="delete"?g:w.map(D=>D.result),lastResult:B})};k.onerror=q=>{j(q),O(q)},k.onsuccess=O})},getMany:({trans:c,keys:d})=>new Promise((g,p)=>{g=K(g);const f=c.objectStore(h),y=d.length,m=new Array(y);let v,b=0,x=0;const E=w=>{const A=w.target;m[A._pos]=A.result,++x===b&&g(m)},k=Y(p);for(let w=0;w<y;++w)d[w]!=null&&(v=f.get(d[w]),v._pos=w,v.onsuccess=E,v.onerror=k,++b);b===0&&g(m)}),get:({trans:c,key:d})=>new Promise((g,p)=>{g=K(g);const f=c.objectStore(h).get(d);f.onsuccess=y=>g(y.target.result),f.onerror=Y(p)}),query:function(c){return d=>new Promise((g,p)=>{g=K(g);const{trans:f,values:y,limit:m,query:v}=d,b=m===1/0?void 0:m,{index:x,range:E}=v,k=f.objectStore(h),w=x.isPrimaryKey?k:k.index(x.name),A=r(E);if(m===0)return g({result:[]});if(c){const _=y?w.getAll(A,b):w.getAllKeys(A,b);_.onsuccess=j=>g({result:j.target.result}),_.onerror=Y(p)}else{let _=0;const j=y||!("openKeyCursor"in w)?w.openCursor(A):w.openKeyCursor(A),O=[];j.onsuccess=q=>{const B=j.result;return B?(O.push(y?B.value:B.primaryKey),++_===m?g({result:O}):void B.continue()):g({result:O})},j.onerror=Y(p)}})}(i),openCursor:function({trans:c,values:d,query:g,reverse:p,unique:f}){return new Promise((y,m)=>{y=K(y);const{index:v,range:b}=g,x=c.objectStore(h),E=v.isPrimaryKey?x:x.index(v.name),k=p?f?"prevunique":"prev":f?"nextunique":"next",w=d||!("openKeyCursor"in E)?E.openCursor(r(b),k):E.openKeyCursor(r(b),k);w.onerror=Y(m),w.onsuccess=K(A=>{const _=w.result;if(!_)return void y(null);_.___id=++Fr,_.done=!1;const j=_.continue.bind(_);let O=_.continuePrimaryKey;O&&(O=O.bind(_));const q=_.advance.bind(_),B=()=>{throw new Error("Cursor not stopped")};_.trans=c,_.stop=_.continue=_.continuePrimaryKey=_.advance=()=>{throw new Error("Cursor not started")},_.fail=K(m),_.next=function(){let D=1;return this.start(()=>D--?this.continue():this.stop()).then(()=>this)},_.start=D=>{const ye=new Promise((V,ce)=>{V=K(V),w.onerror=Y(ce),_.fail=ce,_.stop=Ae=>{_.stop=_.continue=_.continuePrimaryKey=_.advance=B,V(Ae)}}),ve=()=>{if(w.result)try{D()}catch(V){_.fail(V)}else _.done=!0,_.start=()=>{throw new Error("Cursor behind last entry")},_.stop()};return w.onsuccess=K(V=>{w.onsuccess=ve,ve()}),_.continue=j,_.continuePrimaryKey=O,_.advance=q,ve(),ye},y(_)},m)})},count({query:c,trans:d}){const{index:g,range:p}=c;return new Promise((f,y)=>{const m=d.objectStore(h),v=g.isPrimaryKey?m:m.index(g.name),b=r(p),x=b?v.count(b):v.count();x.onsuccess=K(E=>f(E.target.result)),x.onerror=Y(y)})}}}(a)),u={};return o.forEach(a=>u[a.name]=a),{stack:"dbcore",transaction:t.transaction.bind(t),table(a){if(!u[a])throw new Error(`Table '${a}' not found`);return u[a]},MIN_KEY:-1/0,MAX_KEY:Ue(e),schema:s}}function Wt({_novip:t},e){const n=e.db,r=function(s,i,{IDBKeyRange:o,indexedDB:u},a){return{dbcore:function(l,h){return h.reduce((c,{create:d})=>({...c,...d(c)}),l)}(qr(i,o,a),s.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(s=>{const i=s.name;t.core.schema.tables.some(o=>o.name===i)&&(s.core=t.core.table(i),t[i]instanceof t.Table&&(t[i].core=s.core))})}function mt({_novip:t},e,n,r){n.forEach(s=>{const i=r[s];e.forEach(o=>{const u=en(o,s);(!u||"value"in u&&u.value===void 0)&&(o===t.Transaction.prototype||o instanceof t.Transaction?ee(o,s,{get(){return this.table(s)},set(a){Tn(this,s,{value:a,writable:!0,configurable:!0,enumerable:!0})}}):o[s]=new t.Table(s,i))})})}function zt({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Lr(t,e){return t._cfg.version-e._cfg.version}function Ur(t,e,n,r){const s=t._dbSchema,i=t._createTransaction("readwrite",t._storeNames,s);i.create(n),i._completion.catch(r);const o=i._reject.bind(i),u=P.transless||P;oe(()=>{P.trans=i,P.transless=u,e===0?($(s).forEach(a=>{Ct(n,a,s[a].primKey,s[a].indexes)}),Wt(t,n),S.follow(()=>t.on.populate.fire(i)).catch(o)):function({_novip:a},l,h,c){const d=[],g=a._versions;let p=a._dbSchema=Yt(a,a.idbdb,c),f=!1;const y=g.filter(v=>v._cfg.version>=l);function m(){return d.length?S.resolve(d.shift()(h.idbtrans)).then(m):S.resolve()}return y.forEach(v=>{d.push(()=>{const b=p,x=v._cfg.dbschema;Gt(a,b,c),Gt(a,x,c),p=a._dbSchema=x;const E=tr(b,x);E.add.forEach(w=>{Ct(c,w[0],w[1].primKey,w[1].indexes)}),E.change.forEach(w=>{if(w.recreate)throw new C.Upgrade("Not yet support for changing primary key");{const A=c.objectStore(w.name);w.add.forEach(_=>Ht(A,_)),w.change.forEach(_=>{A.deleteIndex(_.name),Ht(A,_)}),w.del.forEach(_=>A.deleteIndex(_))}});const k=v._cfg.contentUpgrade;if(k&&v._cfg.version>l){Wt(a,c),h._memoizedTables={},f=!0;let w=Rn(x);E.del.forEach(O=>{w[O]=b[O]}),zt(a,[a.Transaction.prototype]),mt(a,[a.Transaction.prototype],$(w),w),h.schema=w;const A=tn(k);let _;A&&Ce();const j=S.follow(()=>{if(_=k(h),_&&A){var O=ne.bind(null,null);_.then(O,O)}});return _&&typeof _.then=="function"?S.resolve(_):j.then(()=>_)}}),d.push(b=>{(!f||!Rr)&&function(x,E){[].slice.call(E.db.objectStoreNames).forEach(k=>x[k]==null&&E.db.deleteObjectStore(k))}(v._cfg.dbschema,b),zt(a,[a.Transaction.prototype]),mt(a,[a.Transaction.prototype],a._storeNames,a._dbSchema),h.schema=a._dbSchema})}),m().then(()=>{var v,b;b=c,$(v=p).forEach(x=>{b.db.objectStoreNames.contains(x)||Ct(b,x,v[x].primKey,v[x].indexes)})})}(t,e,i,n).catch(o)})}function tr(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const s=t[r],i=e[r];if(s){const o={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!vt)o.recreate=!0,n.change.push(o);else{const u=s.idxByName,a=i.idxByName;let l;for(l in u)a[l]||o.del.push(l);for(l in a){const h=u[l],c=a[l];h?h.src!==c.src&&o.change.push(c):o.add.push(c)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}else n.add.push([r,i])}return n}function Ct(t,e,n,r){const s=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(i=>Ht(s,i)),s}function Ht(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Yt(t,e,n){const r={};return lt(e.objectStoreNames,0).forEach(s=>{const i=n.objectStore(s);let o=i.keyPath;const u=Ut(Zn(o),o||"",!1,!1,!!i.autoIncrement,o&&typeof o!="string",!0),a=[];for(let h=0;h<i.indexNames.length;++h){const c=i.index(i.indexNames[h]);o=c.keyPath;var l=Ut(c.name,o,!!c.unique,!!c.multiEntry,!1,o&&typeof o!="string",!1);a.push(l)}r[s]=er(s,u,a)}),r}function Gt({_novip:t},e,n){const r=n.db.objectStoreNames;for(let s=0;s<r.length;++s){const i=r[s],o=n.objectStore(i);t._hasGetAll="getAll"in o;for(let u=0;u<o.indexNames.length;++u){const a=o.indexNames[u],l=o.index(a).keyPath,h=typeof l=="string"?l:"["+lt(l).join("+")+"]";if(e[i]){const c=e[i].idxByName[h];c&&(c.name=a,delete e[i].idxByName[h],e[i].idxByName[a]=c)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&R.WorkerGlobalScope&&R instanceof R.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}class Vr{_parseStoresSpec(e,n){$(e).forEach(r=>{if(e[r]!==null){var s=e[r].split(",").map((o,u)=>{const a=(o=o.trim()).replace(/([&*]|\+\+)/g,""),l=/^\[/.test(a)?a.match(/^\[(.*)\]$/)[1].split("+"):a;return Ut(a,l||null,/\&/.test(o),/\*/.test(o),/\+\+/.test(o),F(l),u===0)}),i=s.shift();if(i.multi)throw new C.Schema("Primary key cannot be multi-valued");s.forEach(o=>{if(o.auto)throw new C.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new C.Schema("Index must have a name and cannot be an empty string")}),n[r]=er(r,i,s)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?U(this._cfg.storesSource,e):e;const r=n._versions,s={};let i={};return r.forEach(o=>{U(s,o._cfg.storesSource),i=o._cfg.dbschema={},o._parseStoresSpec(s,i)}),n._dbSchema=i,zt(n,[n._allTables,n,n.Transaction.prototype]),mt(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],$(i),i),n._storeNames=$(i),this}upgrade(e){return this._cfg.contentUpgrade=sn(this._cfg.contentUpgrade||I,e),this}}function cn(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new pe(bt,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function ln(t){return t&&typeof t.databases=="function"}function Xt(t){return oe(function(){return P.letThrough=!0,t()})}function Wr(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function zr(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?N(e.dbOpenError):t);G&&(e.openCanceller._stackHolder=Pe()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function s(){if(e.openCanceller!==r)throw new C.DatabaseClosed("db.open() was cancelled")}let i=e.dbReadyResolve,o=null,u=!1;return S.race([r,(typeof navigator>"u"?S.resolve():Wr()).then(()=>new S((a,l)=>{if(s(),!n)throw new C.MissingAPI;const h=t.name,c=e.autoSchema?n.open(h):n.open(h,Math.round(10*t.verno));if(!c)throw new C.MissingAPI;c.onerror=Y(l),c.onblocked=K(t._fireOnBlocked),c.onupgradeneeded=K(d=>{if(o=c.transaction,e.autoSchema&&!t._options.allowEmptyDB){c.onerror=qe,o.abort(),c.result.close();const p=n.deleteDatabase(h);p.onsuccess=p.onerror=K(()=>{l(new C.NoSuchDatabase(`Database ${h} doesnt exist`))})}else{o.onerror=Y(l);var g=d.oldVersion>Math.pow(2,62)?0:d.oldVersion;u=g<1,t._novip.idbdb=c.result,Ur(t,g/10,o,l)}},l),c.onsuccess=K(()=>{o=null;const d=t._novip.idbdb=c.result,g=lt(d.objectStoreNames);if(g.length>0)try{const f=d.transaction((p=g).length===1?p[0]:p,"readonly");e.autoSchema?function({_novip:y},m,v){y.verno=m.version/10;const b=y._dbSchema=Yt(0,m,v);y._storeNames=lt(m.objectStoreNames,0),mt(y,[y._allTables],$(b),b)}(t,d,f):(Gt(t,t._dbSchema,f),function(y,m){const v=tr(Yt(0,y.idbdb,m),y._dbSchema);return!(v.add.length||v.change.some(b=>b.add.length||b.change.length))}(t,f)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Wt(t,f)}catch{}var p;De.push(t),d.onversionchange=K(f=>{e.vcFired=!0,t.on("versionchange").fire(f)}),d.onclose=K(f=>{t.on("close").fire(f)}),u&&function({indexedDB:f,IDBKeyRange:y},m){!ln(f)&&m!==bt&&cn(f,y).put({name:m}).catch(I)}(t._deps,h),a()},l)}))]).then(()=>(s(),e.onReadyBeingFired=[],S.resolve(Xt(()=>t.on.ready.fire(t.vip))).then(function a(){if(e.onReadyBeingFired.length>0){let l=e.onReadyBeingFired.reduce(sn,I);return e.onReadyBeingFired=[],S.resolve(Xt(()=>l(t.vip))).then(a)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(a=>{e.dbOpenError=a;try{o&&o.abort()}catch{}return r===e.openCanceller&&t._close(),N(a)}).finally(()=>{e.openComplete=!0,i()})}function Qt(t){var e=i=>t.next(i),n=s(e),r=s(i=>t.throw(i));function s(i){return o=>{var u=i(o),a=u.value;return u.done?a:a&&typeof a.then=="function"?a.then(n,r):F(a)?Promise.all(a).then(n,r):n(a)}}return s(e)()}function Hr(t,e,n){var r=arguments.length;if(r<2)throw new C.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];return n=s.pop(),[t,Kn(s),n]}function nr(t,e,n,r,s){return S.resolve().then(()=>{const i=P.transless||P,o=t._createTransaction(e,n,t._dbSchema,r),u={trans:o,transless:i};if(r)o.idbtrans=r.idbtrans;else try{o.create(),t._state.PR1398_maxLoop=3}catch(c){return c.name===rn.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>nr(t,e,n,null,s))):N(c)}const a=tn(s);let l;a&&Ce();const h=S.follow(()=>{if(l=s.call(o,o),l)if(a){var c=ne.bind(null,null);l.then(c,c)}else typeof l.next=="function"&&typeof l.throw=="function"&&(l=Qt(l))},u);return(l&&typeof l.then=="function"?S.resolve(l).then(c=>o.active?c:N(new C.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):h.then(()=>l)).then(c=>(r&&o._resolve(),o._completion.then(()=>c))).catch(c=>(o._reject(c),N(c)))})}function tt(t,e,n){const r=F(t)?t.slice():[t];for(let s=0;s<n;++s)r.push(e);return r}const Yr={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(t){return{...t,table(e){const n=t.table(e),{schema:r}=n,s={},i=[];function o(l,h,c){const d=Ne(l),g=s[d]=s[d]||[],p=l==null?0:typeof l=="string"?1:l.length,f=h>0,y={...c,isVirtual:f,keyTail:h,keyLength:p,extractKey:Vt(l),unique:!f&&c.unique};return g.push(y),y.isPrimaryKey||i.push(y),p>1&&o(p===2?l[0]:l.slice(0,p-1),h+1,c),g.sort((m,v)=>m.keyTail-v.keyTail),y}const u=o(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[u];for(const l of r.indexes)o(l.keyPath,0,l);function a(l){const h=l.query.index;return h.isVirtual?{...l,query:{index:h,range:(c=l.query.range,d=h.keyTail,{type:c.type===1?2:c.type,lower:tt(c.lower,c.lowerOpen?t.MAX_KEY:t.MIN_KEY,d),lowerOpen:!0,upper:tt(c.upper,c.upperOpen?t.MIN_KEY:t.MAX_KEY,d),upperOpen:!0})}}:l;var c,d}return{...n,schema:{...r,primaryKey:u,indexes:i,getIndexByKeyPath:function(l){const h=s[Ne(l)];return h&&h[0]}},count:l=>n.count(a(l)),query:l=>n.query(a(l)),openCursor(l){const{keyTail:h,isVirtual:c,keyLength:d}=l.query.index;return c?n.openCursor(a(l)).then(g=>g&&function(p){return Object.create(p,{continue:{value:function(f){f!=null?p.continue(tt(f,l.reverse?t.MAX_KEY:t.MIN_KEY,h)):l.unique?p.continue(p.key.slice(0,d).concat(l.reverse?t.MIN_KEY:t.MAX_KEY,h)):p.continue()}},continuePrimaryKey:{value(f,y){p.continuePrimaryKey(tt(f,t.MAX_KEY,h),y)}},primaryKey:{get:()=>p.primaryKey},key:{get(){const f=p.key;return d===1?f[0]:f.slice(0,d)}},value:{get:()=>p.value}})}(g)):n.openCursor(l)}}}}}};function hn(t,e,n,r){return n=n||{},r=r||"",$(t).forEach(s=>{if(z(e,s)){var i=t[s],o=e[s];if(typeof i=="object"&&typeof o=="object"&&i&&o){const u=Ot(i);u!==Ot(o)?n[r+s]=e[s]:u==="Object"?hn(i,o,n,r+s+"."):i!==o&&(n[r+s]=e[s])}else i!==o&&(n[r+s]=e[s])}else n[r+s]=void 0}),$(e).forEach(s=>{z(t,s)||(n[r+s]=e[s])}),n}const Gr={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(s){const i=P.trans,{deleting:o,creating:u,updating:a}=i.table(e).hook;switch(s.type){case"add":if(u.fire===I)break;return i._promise("readwrite",()=>l(s),!0);case"put":if(u.fire===I&&a.fire===I)break;return i._promise("readwrite",()=>l(s),!0);case"delete":if(o.fire===I)break;return i._promise("readwrite",()=>l(s),!0);case"deleteRange":if(o.fire===I)break;return i._promise("readwrite",()=>function(c){return h(c.trans,c.range,1e4)}(s),!0)}return n.mutate(s);function l(c){const d=P.trans,g=c.keys||function(p,f){return f.type==="delete"?f.keys:f.keys||f.values.map(p.extractKey)}(r,c);if(!g)throw new Error("Keys missing");return(c=c.type==="add"||c.type==="put"?{...c,keys:g}:{...c}).type!=="delete"&&(c.values=[...c.values]),c.keys&&(c.keys=[...c.keys]),function(p,f,y){return f.type==="add"?Promise.resolve([]):p.getMany({trans:f.trans,keys:y,cache:"immutable"})}(n,c,g).then(p=>{const f=g.map((y,m)=>{const v=p[m],b={onerror:null,onsuccess:null};if(c.type==="delete")o.fire.call(b,y,v,d);else if(c.type==="add"||v===void 0){const x=u.fire.call(b,y,c.values[m],d);y==null&&x!=null&&(y=x,c.keys[m]=y,r.outbound||H(c.values[m],r.keyPath,y))}else{const x=hn(v,c.values[m]),E=a.fire.call(b,x,y,v,d);if(E){const k=c.values[m];Object.keys(E).forEach(w=>{z(k,w)?k[w]=E[w]:H(k,w,E[w])})}}return b});return n.mutate(c).then(({failures:y,results:m,numFailures:v,lastResult:b})=>{for(let x=0;x<g.length;++x){const E=m?m[x]:g[x],k=f[x];E==null?k.onerror&&k.onerror(y[x]):k.onsuccess&&k.onsuccess(c.type==="put"&&p[x]?c.values[x]:E)}return{failures:y,results:m,numFailures:v,lastResult:b}}).catch(y=>(f.forEach(m=>m.onerror&&m.onerror(y)),Promise.reject(y)))})}function h(c,d,g){return n.query({trans:c,values:!1,query:{index:r,range:d},limit:g}).then(({result:p})=>l({type:"delete",keys:p,trans:c}).then(f=>f.numFailures>0?Promise.reject(f.failures[0]):p.length<g?{failures:[],numFailures:0,lastResult:void 0}:h(c,{...d,lower:p[p.length-1],lowerOpen:!0},g)))}}}}})};function rr(t,e,n){try{if(!e||e.keys.length<t.length)return null;const r=[];for(let s=0,i=0;s<e.keys.length&&i<t.length;++s)L(e.keys[s],t[i])===0&&(r.push(n?We(e.values[s]):e.values[s]),++i);return r.length===t.length?r:null}catch{return null}}const Xr={stack:"dbcore",level:-1,create:t=>({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const s=rr(r.keys,r.trans._cache,r.cache==="clone");return s?S.resolve(s):n.getMany(r).then(i=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?We(i):i},i))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function dn(t){return!("from"in t)}const Q=function(t,e){if(!this){const n=new Q;return t&&"d"in t&&U(n,t),n}U(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Ve(t,e,n){const r=L(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(dn(t))return U(t,{from:e,to:n,d:1});const s=t.l,i=t.r;if(L(n,t.from)<0)return s?Ve(s,e,n):t.l={from:e,to:n,d:1,l:null,r:null},Sn(t);if(L(e,t.to)>0)return i?Ve(i,e,n):t.r={from:e,to:n,d:1,l:null,r:null},Sn(t);L(e,t.from)<0&&(t.from=e,t.l=null,t.d=i?i.d+1:1),L(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const o=!t.r;s&&!t.l&&yt(t,s),i&&o&&yt(t,i)}function yt(t,e){dn(e)||function n(r,{from:s,to:i,l:o,r:u}){Ve(r,s,i),o&&n(r,o),u&&n(r,u)}(t,e)}function Qr(t,e){const n=Jt(e);let r=n.next();if(r.done)return!1;let s=r.value;const i=Jt(t);let o=i.next(s.from),u=o.value;for(;!r.done&&!o.done;){if(L(u.from,s.to)<=0&&L(u.to,s.from)>=0)return!0;L(s.from,u.from)<0?s=(r=n.next(u.from)).value:u=(o=i.next(s.from)).value}return!1}function Jt(t){let e=dn(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&L(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||L(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function Sn(t){var e,n;const r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const i=s==="r"?"l":"r",o={...t},u=t[s];t.from=u.from,t.to=u.to,t[s]=u[s],o[s]=u[i],t[i]=o,o.d=En(o)}t.d=En(t)}function En({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}Ee(Q.prototype,{add(t){return yt(this,t),this},addKey(t){return Ve(this,t,t),this},addKeys(t){return t.forEach(e=>Ve(this,e,e)),this},[It](){return Jt(this)}});const Jr={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new Q(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const s=t.table(r),{schema:i}=s,{primaryKey:o}=i,{extractKey:u,outbound:a}=o,l={...s,mutate:d=>{const g=d.trans,p=g.mutatedParts||(g.mutatedParts={}),f=k=>{const w=`idb://${e}/${r}/${k}`;return p[w]||(p[w]=new Q)},y=f(""),m=f(":dels"),{type:v}=d;let[b,x]=d.type==="deleteRange"?[d.range]:d.type==="delete"?[d.keys]:d.values.length<50?[[],d.values]:[];const E=d.trans._cache;return s.mutate(d).then(k=>{if(F(b)){v!=="delete"&&(b=k.results),y.addKeys(b);const w=rr(b,E);w||v==="add"||m.addKeys(b),(w||x)&&function(A,_,j,O){function q(B){const D=A(B.name||"");function ye(V){return V!=null?B.extractKey(V):null}const ve=V=>B.multiEntry&&F(V)?V.forEach(ce=>D.addKey(ce)):D.addKey(V);(j||O).forEach((V,ce)=>{const Ae=j&&ye(j[ce]),wt=O&&ye(O[ce]);L(Ae,wt)!==0&&(Ae!=null&&ve(Ae),wt!=null&&ve(wt))})}_.indexes.forEach(q)}(f,i,w,x)}else if(b){const w={from:b.lower,to:b.upper};m.add(w),y.add(w)}else y.add(n),m.add(n),i.indexes.forEach(w=>f(w.name).add(n));return k})}},h=({query:{index:d,range:g}})=>{var p,f;return[d,new Q((p=g.lower)!==null&&p!==void 0?p:t.MIN_KEY,(f=g.upper)!==null&&f!==void 0?f:t.MAX_KEY)]},c={get:d=>[o,new Q(d.key)],getMany:d=>[o,new Q().addKeys(d.keys)],count:h,query:h,openCursor:h};return $(c).forEach(d=>{l[d]=function(g){const{subscr:p}=P;if(p){const f=x=>{const E=`idb://${e}/${r}/${x}`;return p[E]||(p[E]=new Q)},y=f(""),m=f(":dels"),[v,b]=c[d](g);if(f(v.name||"").add(b),!v.isPrimaryKey){if(d!=="count"){const x=d==="query"&&a&&g.values&&s.query({...g,values:!1});return s[d].apply(this,arguments).then(E=>{if(d==="query"){if(a&&g.values)return x.then(({result:w})=>(y.addKeys(w),E));const k=g.values?E.result.map(u):E.result;g.values?y.addKeys(k):m.addKeys(k)}else if(d==="openCursor"){const k=E,w=g.values;return k&&Object.create(k,{key:{get:()=>(m.addKey(k.primaryKey),k.key)},primaryKey:{get(){const A=k.primaryKey;return m.addKey(A),A}},value:{get:()=>(w&&y.addKey(k.primaryKey),k.value)}})}return E})}m.add(n)}}return s[d].apply(this,arguments)}}),l}}}};class pe{constructor(e,n){this._middlewares={},this.verno=0;const r=pe.dependencies;this._options=n={addons:pe.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:s}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:I,dbReadyPromise:null,cancelOpen:I,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var o;i.dbReadyPromise=new S(u=>{i.dbReadyResolve=u}),i.openCanceller=new S((u,a)=>{i.cancelOpen=a}),this._state=i,this.name=e,this.on=$e(this,"populate","blocked","versionchange","close",{ready:[sn,I]}),this.on.ready.subscribe=An(this.on.ready.subscribe,u=>(a,l)=>{pe.vip(()=>{const h=this._state;if(h.openComplete)h.dbOpenError||S.resolve().then(a),l&&u(a);else if(h.onReadyBeingFired)h.onReadyBeingFired.push(a),l&&u(a);else{u(a);const c=this;l||u(function d(){c.on.ready.unsubscribe(a),c.on.ready.unsubscribe(d)})}})}),this.Collection=(o=this,Oe(Dr.prototype,function(u,a){this.db=o;let l=Xn,h=null;if(a)try{l=a()}catch(p){h=p}const c=u._ctx,d=c.table,g=d.hook.reading.fire;this._ctx={table:d,index:c.index,isPrimKey:!c.index||d.schema.primKey.keyPath&&c.index===d.schema.primKey.name,range:l,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:h,or:c.or,valueMapper:g!==Me?g:null}})),this.Table=function(u){return Oe(jr.prototype,function(a,l,h){this.db=u,this._tx=h,this.name=a,this.schema=l,this.hook=u._allTables[a]?u._allTables[a].hook:$e(null,{creating:[kr,I],reading:[_r,Me],updating:[Sr,I],deleting:[xr,I]})})}(this),this.Transaction=function(u){return Oe(Mr.prototype,function(a,l,h,c,d){this.db=u,this.mode=a,this.storeNames=l,this.schema=h,this.chromeTransactionDurability=c,this.idbtrans=null,this.on=$e(this,"complete","error","abort"),this.parent=d||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new S((g,p)=>{this._resolve=g,this._reject=p}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},g=>{var p=this.active;return this.active=!1,this.on.error.fire(g),this.parent?this.parent._reject(g):p&&this.idbtrans&&this.idbtrans.abort(),N(g)})})}(this),this.Version=function(u){return Oe(Vr.prototype,function(a){this.db=u,this._cfg={version:a,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(u){return Oe(Jn.prototype,function(a,l,h){this.db=u,this._ctx={table:a,index:l===":id"?null:l,or:h};const c=u._deps.indexedDB;if(!c)throw new C.MissingAPI;this._cmp=this._ascending=c.cmp.bind(c),this._descending=(d,g)=>c.cmp(g,d),this._max=(d,g)=>c.cmp(d,g)>0?d:g,this._min=(d,g)=>c.cmp(d,g)<0?d:g,this._IDBKeyRange=u._deps.IDBKeyRange})}(this),this.on("versionchange",u=>{u.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",u=>{!u.newVersion||u.newVersion<u.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${u.oldVersion/10}`)}),this._maxKey=Ue(n.IDBKeyRange),this._createTransaction=(u,a,l,h)=>new this.Transaction(u,a,l,this._options.chromeTransactionDurability,h),this._fireOnBlocked=u=>{this.on("blocked").fire(u),De.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(u))},this.use(Yr),this.use(Gr),this.use(Jr),this.use(Xr),this.vip=Object.create(this,{_vip:{value:!0}}),s.forEach(u=>u(this))}version(e){if(isNaN(e)||e<.1)throw new C.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new C.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(s=>s._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(Lr),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||P.letThrough||this._vip)?e():new S((n,r)=>{if(this._state.openComplete)return r(new C.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new C.DatabaseClosed);this.open().catch(I)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:s}){s&&this.unuse({stack:e,name:s});const i=this._middlewares[e]||(this._middlewares[e]=[]);return i.push({stack:e,create:n,level:r??10,name:s}),i.sort((o,u)=>o.level-u.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(s=>r?s.create!==r:!!n&&s.name!==n)),this}open(){return zr(this)}_close(){const e=this._state,n=De.indexOf(this);if(n>=0&&De.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new S(r=>{e.dbReadyResolve=r}),e.openCanceller=new S((r,s)=>{e.cancelOpen=s})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new C.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new S((r,s)=>{const i=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=K(()=>{(function({indexedDB:u,IDBKeyRange:a},l){!ln(u)&&l!==bt&&cn(u,a).delete(l).catch(I)})(this._deps,this.name),r()}),o.onerror=Y(s),o.onblocked=this._fireOnBlocked};if(e)throw new C.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(i):i()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return $(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Hr.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let s=P.trans;s&&s.db===this&&e.indexOf("!")===-1||(s=null);const i=e.indexOf("?")!==-1;let o,u;e=e.replace("!","").replace("?","");try{if(u=n.map(l=>{var h=l instanceof this.Table?l.name:l;if(typeof h!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return h}),e=="r"||e===kt)o=kt;else{if(e!="rw"&&e!=xt)throw new C.InvalidArgument("Invalid transaction mode: "+e);o=xt}if(s){if(s.mode===kt&&o===xt){if(!i)throw new C.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");s=null}s&&u.forEach(l=>{if(s&&s.storeNames.indexOf(l)===-1){if(!i)throw new C.SubTransaction("Table "+l+" not included in parent transaction.");s=null}}),i&&s&&!s.active&&(s=null)}}catch(l){return s?s._promise(null,(h,c)=>{c(l)}):N(l)}const a=nr.bind(null,this,o,u,s,r);return s?s._promise(o,a,"lock"):P.trans?Te(P.transless,()=>this._whenReady(a)):this._whenReady(a)}table(e){if(!z(this._allTables,e))throw new C.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Zr=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class es{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[Zr](){return this}}function sr(t,e){return $(e).forEach(n=>{yt(t[n]||(t[n]=new Q),e[n])}),t}function ts(t){let e,n=!1;const r=new es(s=>{const i=tn(t);let o=!1,u={},a={};const l={get closed(){return o},unsubscribe:()=>{o=!0,ue.storagemutated.unsubscribe(g)}};s.start&&s.start(l);let h=!1,c=!1;function d(){return $(a).some(f=>u[f]&&Qr(u[f],a[f]))}const g=f=>{sr(u,f),d()&&p()},p=()=>{if(h||o)return;u={};const f={},y=function(m){i&&Ce();const v=()=>oe(t,{subscr:m,trans:null}),b=P.trans?Te(P.transless,v):v();return i&&b.then(ne,ne),b}(f);c||(ue(Le,g),c=!0),h=!0,Promise.resolve(y).then(m=>{n=!0,e=m,h=!1,o||(d()?p():(u={},a=f,s.next&&s.next(m)))},m=>{h=!1,n=!1,s.error&&s.error(m),l.unsubscribe()})};return p(),l});return r.hasValue=()=>n,r.getValue=()=>e,r}let Zt;try{Zt={indexedDB:R.indexedDB||R.mozIndexedDB||R.webkitIndexedDB||R.msIndexedDB,IDBKeyRange:R.IDBKeyRange||R.webkitIDBKeyRange}}catch{Zt={indexedDB:null,IDBKeyRange:null}}const le=pe;function ut(t){let e=Z;try{Z=!0,ue.storagemutated.fire(t)}finally{Z=e}}Ee(le,{...nt,delete:t=>new le(t,{addons:[]}).delete(),exists:t=>new le(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return ln(e)?Promise.resolve(e.databases()).then(r=>r.map(s=>s.name).filter(s=>s!==bt)):cn(e,n).toCollection().primaryKeys()}(le.dependencies).then(t)}catch{return N(new C.MissingAPI)}},defineClass:()=>function(t){U(this,t)},ignoreTransaction:t=>P.trans?Te(P.transless,t):t(),vip:Xt,async:function(t){return function(){try{var e=Qt(t.apply(this,arguments));return e&&typeof e.then=="function"?e:S.resolve(e)}catch(n){return N(n)}}},spawn:function(t,e,n){try{var r=Qt(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:S.resolve(r)}catch(s){return N(s)}},currentTransaction:{get:()=>P.trans||null},waitFor:function(t,e){const n=S.resolve(typeof t=="function"?le.ignoreTransaction(t):t).timeout(e||6e4);return P.trans?P.trans.waitFor(n):n},Promise:S,debug:{get:()=>G,set:t=>{Dn(t,t==="dexie"?()=>!0:Gn)}},derive:ke,extend:U,props:Ee,override:An,Events:$e,on:ue,liveQuery:ts,extendObservabilitySet:sr,getByKeyPath:te,setByKeyPath:H,delByKeyPath:function(t,e){typeof e=="string"?H(t,e,void 0):"length"in e&&[].map.call(e,function(n){H(t,n,void 0)})},shallowClone:Rn,deepClone:We,getObjectDiff:hn,cmp:L,asap:On,minKey:Lt,addons:[],connections:De,errnames:rn,dependencies:Zt,semVer:vn,version:vn.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),le.maxKey=Ue(le.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(ue(Le,t=>{if(!Z){let e;vt?(e=document.createEvent("CustomEvent"),e.initCustomEvent(ie,!0,!0,t)):e=new CustomEvent(ie,{detail:t}),Z=!0,dispatchEvent(e),Z=!1}}),addEventListener(ie,({detail:t})=>{Z||ut(t)}));let Z=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(ie);typeof t.unref=="function"&&t.unref(),ue(Le,e=>{Z||t.postMessage(e)}),t.onmessage=e=>{e.data&&ut(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){ue(Le,e=>{try{Z||(typeof localStorage<"u"&&localStorage.setItem(ie,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:ie,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===ie){const n=JSON.parse(e.newValue);n&&ut(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===ie&&ut(e.changedParts)})}S.rejectionMapper=function(t,e){if(!t||t instanceof xe||t instanceof TypeError||t instanceof SyntaxError||!t.name||!pn[t.name])return t;var n=new pn[t.name](e||t.message,t);return"stack"in t&&ee(n,"stack",{get:function(){return this.inner.stack}}),n},Dn(G,Gn);class ns extends pe{constructor(){super("NylasAuthDatabase"),ct(this,"grant"),ct(this,"pkce"),this.version(1).stores({grant:"++id,token",pkce:"++id,codeVerifier"}),this.grant=this.table("grant"),this.pkce=this.table("pkce")}}class rs{constructor(){ct(this,"theDB"),this.theDB=new ns}async setCodeVerifier(e){await this.theDB.pkce.put({id:1,codeVerifier:e},1)}async getCodeVerifier(){const[e]=await this.theDB.pkce.toArray();return e?e.codeVerifier:null}async getTokenInfo(){const e=await this.theDB.grant.get(1);return e?e.token:null}async setTokenInfo(e){await this.theDB.grant.put({id:1,token:e},1)}async reset(){await this.theDB.grant.clear()}}function ss(t){const e="NylasAuth";if(!t)throw new Error("NylasAuth requires a config object");let n=null;if(t.storageType==="indexeddb"&&(n=new rs),!n)throw new Error("NylasAuth requires a storage object");const r=[{type:"read-only",value:"https://www.googleapis.com/auth/gmail.readonly"},{type:"modify",value:"https://www.googleapis.com/auth/gmail.modify"},{type:"compose",value:"https://www.googleapis.com/auth/gmail.compose"},{type:"insert",value:"https://www.googleapis.com/auth/gmail.insert"},{type:"labels",value:"https://www.googleapis.com/auth/gmail.labels"},{type:"metadata",value:"https://www.googleapis.com/auth/gmail.metadata"},{type:"settings.basic",value:"https://www.googleapis.com/auth/gmail.settings.basic"},{type:"settings.sharing",value:"https://www.googleapis.com/auth/gmail.settings.sharing"}],s=[{type:"read-only",value:"https://outlook.office.com/mail.read"},{type:"modify",value:"https://outlook.office.com/mail.readwrite"},{type:"send",value:"https://outlook.office.com/mail.send"},{type:"offline",value:"offline_access"}];async function i(o,u,a,l=!0,h,c){const d=await(n==null?void 0:n.getTokenInfo()),g=new URL(o,h??t.apiUri),p=new Headers;p.append("Accept","application/json"),p.append("Content-Type","application/json"),p.append("User-Agent",e),d&&p.append("Authorization",`Bearer ${d.access_token}`);const f=await fetch(g.toString(),{method:u||"GET",headers:p,mode:"cors",referrer:location.origin,body:a?JSON.stringify(a):void 0,...c||{}});return l?await f.json():f.body}return{config:t,async getHostedAuthRedirectURL(o=t.defaultScopes,u,a){const l=await fn(Math.random().toString()),h=await fn(l);await(n==null?void 0:n.setCodeVerifier(l));const c=new URL(`${t.apiUri}/v3/connect/auth`);return c.searchParams.set("client_id",t.clientId),c.searchParams.set("response_type","code"),c.searchParams.set("scope",o.join(" ")),c.searchParams.set("redirect_uri",t.redirectURI),c.searchParams.set("access_type","offline"),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method","S256"),c.searchParams.set("options","rotate_refresh_token"),a&&c.searchParams.set("provider",a),u&&c.searchParams.set("login_hint",u),c.toString()},nylasAPIRequest:i,async exchangeAuthCodeForTokenInfo(o){if(!o)return null;const u=await(n==null?void 0:n.getCodeVerifier()),a=await this.nylasAPIRequest("/v3/connect/token","POST",{code:o,client_id:t.clientId,grant_type:"authorization_code",redirect_uri:t.redirectURI,code_verifier:u});return"error"in a||await(n==null?void 0:n.setTokenInfo(a)),a},async nylasDownloadFileRequest(o,u="GET",a){const l=await(n==null?void 0:n.getTokenInfo()),h=new URL(o,t.apiUri),c=new Headers;return c.append("Accept","application/json"),c.append("Content-Type","application/octet-stream"),c.append("User-Agent",e),l&&c.append("Authorization",`Bearer ${l.access_token}`),(await fetch(h.toString(),{method:u,headers:c,mode:"cors",referrer:location.origin,body:a?JSON.stringify(a):void 0})).blob()},async logout(){const o=await(n==null?void 0:n.getTokenInfo());o&&await this.nylasAPIRequest(`/v3/connect/revoke?token=${o.access_token}`,"POST"),await(n==null?void 0:n.reset())},async isAuthenticated(){return!!await(n==null?void 0:n.getTokenInfo())},async getTokenInfo(){const o=await(n==null?void 0:n.getTokenInfo());if(!o)return null;const{access_token:u,...a}=o;return a},async isAccessTokenValid(){const o=await(n==null?void 0:n.getTokenInfo());return o?"data"in await this.nylasAPIRequest(`/v3/connect/tokeninfo?id_token=${o.id_token}`,"GET"):!1},async refreshAccessToken(){const o=await(n==null?void 0:n.getTokenInfo());if(!o)return null;const u=await this.nylasAPIRequest("/v3/connect/token","POST",{client_id:t.clientId,grant_type:"refresh_token",refresh_token:o.refresh_token});return"error"in u||await(n==null?void 0:n.setTokenInfo(u)),u},async hasScopeByType(o="email",u){const a=await(n==null?void 0:n.getTokenInfo());if(!a)return!1;const l=a.scope.toLowerCase().split(" ");let h=[];const c=Array.isArray(u)?u:[u];return o==="email"&&(h=[...s,...r].filter(d=>c.includes(d.type))),h.every(d=>l.includes(d.value))},async hasScope(o){const u=await(n==null?void 0:n.getTokenInfo());if(!u)return!1;const a=u.scope.toLowerCase().split(" ");return(Array.isArray(o)?o:[o]).some(l=>a.includes(l.toLowerCase()))}}}const is=(t,e,n)=>{const r=t.get(e);r?r.includes(n)||r.push(n):t.set(e,[n])},os=(t,e)=>{let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>{n=0,t(...r)},e)}},as=t=>!("isConnected"in t)||t.isConnected,Pn=os(t=>{for(let e of t.keys())t.set(e,t.get(e).filter(as))},2e3),us=()=>{if(typeof Ye.getRenderingRef!="function")return{};const t=new Map;return{dispose:()=>t.clear(),get:e=>{const n=Ye.getRenderingRef();n&&is(t,e,n)},set:e=>{const n=t.get(e);n&&t.set(e,n.filter(Ye.forceUpdate)),Pn(t)},reset:()=>{t.forEach(e=>e.forEach(Ye.forceUpdate)),Pn(t)}}},Tt=t=>typeof t=="function"?t():t,cs=(t,e=(n,r)=>n!==r)=>{const n=Tt(t);let r=new Map(Object.entries(n??{}));const s={dispose:[],get:[],set:[],reset:[]},i=()=>{var p;r=new Map(Object.entries((p=Tt(t))!==null&&p!==void 0?p:{})),s.reset.forEach(f=>f())},o=()=>{s.dispose.forEach(p=>p()),i()},u=p=>(s.get.forEach(f=>f(p)),r.get(p)),a=(p,f)=>{const y=r.get(p);e(f,y,p)&&(r.set(p,f),s.set.forEach(m=>m(p,f,y)))},l=typeof Proxy>"u"?{}:new Proxy(n,{get(p,f){return u(f)},ownKeys(p){return Array.from(r.keys())},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}},has(p,f){return r.has(f)},set(p,f,y){return a(f,y),!0}}),h=(p,f)=>(s[p].push(f),()=>{ls(s[p],f)});return{state:l,get:u,set:a,on:h,onChange:(p,f)=>{const y=h("set",(v,b)=>{v===p&&f(b)}),m=h("reset",()=>f(Tt(t)[p]));return()=>{y(),m()}},use:(...p)=>{const f=p.reduce((y,m)=>(m.set&&y.push(h("set",m.set)),m.get&&y.push(h("get",m.get)),m.reset&&y.push(h("reset",m.reset)),m.dispose&&y.push(h("dispose",m.dispose)),y),[]);return()=>f.forEach(y=>y())},dispose:o,reset:i,forceUpdate:p=>{const f=r.get(p);s.set.forEach(y=>y(p,f,f))}}},ls=(t,e)=>{const n=t.indexOf(e);n>=0&&(t[n]=t[t.length-1],t.length--)},hs=(t,e)=>{const n=cs(t,e);return n.use(us()),n};exports.NylasBaseProvider=or;exports.Xr=cr;exports.Zr=lr;exports.createStore=hs;exports.es=ss;exports.nr=Cn;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const o=require("./utils-5074a070-d5ba6add.cjs"),i=require("./index-b30d446a-cbbef925.cjs");class g{constructor(t,e){this.nylasAuth=t,this.nylasAuthStore=e}async validateSession(){const t=await this.isAccessTokenValid();if(!t)this.logout();else{let e=await this.nylasAuth.getTokenInfo();if(e){const a=Math.floor(Date.now()/1e3);if(e.expires_in&&e.expires_in-a<3e5&&(o.debug("[NylasAuthConnectorMixin] Refreshing access token"),e=await this.nylasAuth.refreshAccessToken(),!e)){o.debug("[NylasAuthConnectorMixin] Token is expired and could not be refreshed. Logging out."),this.logout();return}this.nylasAuthStore.state.tokenInfo=e}}this.nylasAuthStore.state.isAuthenticated=t}async isAuthenticated(){return this.nylasAuth.isAuthenticated()}async getTokenInfo(){return this.nylasAuth.getTokenInfo()}async isAccessTokenValid(){return this.nylasAuth.isAccessTokenValid()}async logout(){await this.nylasAuth.logout()}async getHostedAuthRedirectURL(t,e,s){return this.nylasAuth.getHostedAuthRedirectURL(t,e,s)}async manageHostedAuthCodeExchange(t){const s=new URL(t).searchParams.get("code");if(s){const a=await this.nylasAuth.exchangeAuthCodeForTokenInfo(s);if(a)return this.nylasAuthStore.state.tokenInfo=a,this.nylasAuthStore.state.isAuthenticated=!0,a}return null}}class f{constructor(t,e,s){this.nylasAuth=t,this.nylasAuthStore=e,this.nylasMailboxStore=s}async getMessages(){var n;if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing message:read-only scope");this.nylasMailboxStore.state.state="loading";const t=this.nylasMailboxStore.state.messgeQueryParams,e=new URLSearchParams;for(const h in t){const u=(n=t[h])==null?void 0:n.toString();u&&e.append(h,u)}const s=`/v3/grants/me/messages?${e.toString()}`,a=await this.nylasAuth.nylasAPIRequest(s);if(i.Xr(a))throw new i.Zr(a.error);const r=a.data;return this.nylasMailboxStore.state.messages=r,this.nylasMailboxStore.state.state="ready",r}async getThreadMessages(t){if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing message:read-only scope");const e=await this.nylasAuth.nylasAPIRequest(`/v3/grants/me/messages?thread_id=${t}&fields=include_headers`);if(i.Xr(e))throw new i.Zr(e.error);const s=e.data;return this.nylasMailboxStore.state.messages=s,s}downloadMessageAttachments(t){if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing message:read-only scope");const e=[],s=t.attachments||[];for(const a of s){const r=this.nylasAuth.nylasDownloadFileRequest(`/v3/grants/me/attachments/${a.id}?message_id=${t.id}`);e.push(r)}return e}async summarizeText(t){if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing message:read-only scope");const e=await this.nylasAuth.nylasAPIRequest("/v3/grants/me/mailbox/summarize","POST",{message:{body:t}},!0,this.nylasAuth.config.elementsApiUri);if(i.Xr(e))throw new i.Zr(e.error);return e.data.summary}async textToSpeech(t,e){if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing message:read-only scope");return this.nylasAuth.nylasAPIRequest("/v3/grants/me/mailbox/tts","POST",{text:t},!1,this.nylasAuth.config.elementsApiUri,{...e?{signal:e==null?void 0:e.signal}:{}})}}class w{constructor(t,e,s,a){this.nylasAuth=t,this.nylasAuthStore=e,this.nylasMailboxStore=s,this.router=a}async getThreads(t,e="overwrite",s=!0){var c;if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing thread:read-only scope");s&&(this.nylasMailboxStore.state.state="loading");const a=t||this.nylasMailboxStore.state.threadsQueryParams,r=new URLSearchParams;for(const y in a){const d=(c=a[y])==null?void 0:c.toString();typeof d<"u"&&d!==null&&r.append(y,d)}a.search_query_native?this.router.navigate(`/?query=${a.search_query_native}`,!0):this.nylasMailboxStore.state.threadsQueryParams.search_query_native&&!a.search_query_native&&this.router.navigate("/",!0),a.page_token||(this.nylasMailboxStore.state.previousThreadPageTokens=[]),this.nylasMailboxStore.state.threadsQueryParams=a;const n=`/v3/grants/me/threads?${r.toString()}`,h=await this.nylasAuth.nylasAPIRequest(n);if(i.Xr(h))throw new i.Zr(h.error);const u=h.data;switch(e){case"prepend":this.nylasMailboxStore.state.threads=[...u,...this.nylasMailboxStore.state.threads];break;case"append":this.nylasMailboxStore.state.threads=[...this.nylasMailboxStore.state.threads,...u];break;case"overwrite":default:this.nylasMailboxStore.state.threads=u;break}return h.next_cursor?this.nylasMailboxStore.state.nextThreadPageToken=h.next_cursor:this.nylasMailboxStore.state.nextThreadPageToken=null,s&&(this.nylasMailboxStore.state.state="ready"),u}async getThread(t){if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing thread:read-only scope");const e=this.nylasMailboxStore.state.threads.find(n=>n.id===t);if(e)return e;this.nylasMailboxStore.state.state="loading";const s=`/v3/grants/me/threads/${t}`,a=await this.nylasAuth.nylasAPIRequest(s);if(i.Xr(a))throw new i.Zr(a.error);const r=a.data;return this.nylasMailboxStore.state.threads=this.nylasMailboxStore.state.threads.map(n=>n.id===r.id?r:n),this.nylasMailboxStore.state.state="ready",r}async nextThreadPage(t="overwrite",e=!0){if(!this.nylasMailboxStore.state.nextThreadPageToken)throw new Error("No next page token");this.nylasMailboxStore.state.previousThreadPageTokens=Array.from(new Set([...this.nylasMailboxStore.state.previousThreadPageTokens,this.nylasMailboxStore.state.threadsQueryParams.page_token??null]));const s=this.nylasMailboxStore.state.nextThreadPageToken;return this.getThreads({...this.nylasMailboxStore.state.threadsQueryParams,page_token:s},t,e)}async previousThreadPage(t="overwrite",e=!0){if(!this.nylasMailboxStore.state.previousThreadPageTokens.length)throw new Error("No previous page token");const s=[...this.nylasMailboxStore.state.previousThreadPageTokens],a=s.pop();return this.nylasMailboxStore.state.previousThreadPageTokens=s,this.getThreads({...this.nylasMailboxStore.state.threadsQueryParams,page_token:a??void 0},t,e)}updateThreadQueryParams(t){this.nylasMailboxStore.state.threadsQueryParams={...this.nylasMailboxStore.state.threadsQueryParams,...t}}back(){this.router.navigate("/",!0),this.nylasMailboxStore.state.selectedThread=null}unSelectThread(){this.nylasMailboxStore.state.selectedThread=null}async selectThread(t){this.router.navigate(`/thread/${t.id}`,!0),this.nylasMailboxStore.state.selectedThread=t,t.unread&&this.markThreadAsRead(t).catch(e=>{o.debug("Error marking thread as read",e)})}async markThreadAsRead(t){return this.updateThread(t,{unread:!1})}async updateThread(t,e){if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email","modify"))throw new Error("Missing thread:modify scope");const s=`/v3/grants/me/threads/${t.id}`,a=await this.nylasAuth.nylasAPIRequest(s,"PUT",e);if(i.Xr(a))throw new i.Zr(a.error);const r=a.data;return this.nylasMailboxStore.state.threads=this.nylasMailboxStore.state.threads.map(n=>n.id===r.id?r:n),this.nylasMailboxStore.state.selectedThread=r,r}}class m{constructor(t,e,s){this.nylasAuth=t,this.nylasAuthStore=e,this.nylasMailboxStore=s}async getFolders(){if(!this.nylasAuthStore.state.isAuthenticated)throw new Error("Not authenticated");if(!this.nylasAuth.hasScopeByType("email",["read-only","modify"]))throw new Error("Missing thread:read-only scope");this.nylasMailboxStore.state.state="loading";const t="/v3/grants/me/folders",e=await this.nylasAuth.nylasAPIRequest(t);if(i.Xr(e))throw new i.Zr(e.error);const s=e.data;return this.nylasMailboxStore.state.folders=s,this.nylasMailboxStore.state.state="ready",s}async selectFolder(t){this.nylasMailboxStore.state.threadsQueryParams={in:t.id,...this.nylasMailboxStore.state.threadsQueryParams||{}}}}class p extends Event{constructor(t,e){super(t,e),this.oldURL=e.oldURL,this.newURL=e.newURL}}class S{constructor(){this.routeChangeListeners=[],o.debug("HashRouter constructor")}destroy(){o.debug("HashRouter destroy"),window.removeEventListener("hashchange",this.onRouteChange.bind(this))}init(){if(o.debug("HashRouter init"),window.addEventListener("hashchange",this.onRouteChange.bind(this)),typeof HashChangeEvent<"u"){const t=new HashChangeEvent("hashchange",{oldURL:"",newURL:window.location.href});this.onRouteChange(t)}else{const t=new p("hashchange",{oldURL:"",newURL:window.location.href});this.onRouteChange(t)}}addRouteChangeListener(t,e){o.debug("HashRouter addRouteChangeListener"),this.routeChangeListeners.push([t,e])}navigate(t,e){if(o.debug("HashRouter navigate"),e)return window.history.pushState(null,"",`#${t}`);window.location.hash=t}setRoute(t){o.debug("HashRouter setRoute"),window.location.hash=t}matchRoute(t,e){const s=t.split("/"),a=e.split("/");if(o.debug(`HashRouter matchRoute route=${t} path=${e}`,{routeParts:s,pathParts:a}),s[1]===""&&a[0]==="")return!0;if(s.length!==a.length)return!1;for(let r=0;r<s.length;r++){const n=s[r],h=a[r];if(!n.startsWith(":")&&n!==h)return!1}return!0}getRouteParams(t){o.debug("HashRouter getRouteParams");const e={},s=t.split("/"),a=window.location.hash.split("/");return s.forEach((r,n)=>{if(r.startsWith(":")){const h=r.substring(1);e[h]=a[n]}}),e}getRouteWithParams(t,e){o.debug("HashRouter getRouteWithParams");let s=t;return Object.keys(e).forEach(a=>{s=s.replace(`:${a}`,e[a])}),s}getRoute(){return o.debug("HashRouter getRoute"),window.location.hash}onRouteChange(t){this.routeChangeListeners.forEach(async([e,s])=>{const a=t.newURL.indexOf("#")===-1?"":t.newURL.substring(t.newURL.indexOf("#")+1);if(o.debug(`HashRouter onRouteChange route=${e} path=${a}`,{event:t}),!this.matchRoute(e,a)){o.debug(`HashRouter onRouteChange route=${e} path=${a} does not match`);return}const r=this.getRouteParams(e);await s(e,a,r)})}getBasePath(){return o.debug("HashRouter getBasePath"),""}}function A(l={}){const t={isAuthenticated:!1,tokenInfo:null,state:"ready",...l},e=i.createStore(t);return e.reset=()=>{for(const s in t){const a=t[s];e.set(s,a)}},e}function T(l={}){const t={state:"ready",messages:[],threads:[],folders:[],selectedThread:null,nextThreadPageToken:null,previousThreadPageTokens:[],searchQuery:"",hasNextThreadPage:!1,hasPreviousThreadPage:!1,selectedFolder:"inbox",threadsQueryParams:{in:"inbox"},messgeQueryParams:{fields:"include_headers"},...l},e=i.createStore({...t});return e.onChange("nextThreadPageToken",s=>{e.set("hasNextThreadPage",s!==null)}),e.onChange("previousThreadPageTokens",s=>{e.set("hasPreviousThreadPage",s.length>0)}),e.onChange("threadsQueryParams",s=>{e.set("selectedFolder",s.in||"inbox"),e.set("searchQuery",s.search_query_native||"")}),e.reset=()=>{for(const s in t){const a=t[s];e.set(s,a)}},e}exports.CreateNylasAuthStore=A;exports.CreateNylasMailboxStore=T;exports.HashRouter=S;exports.NylasAuthConnector=g;exports.NylasFoldersConnector=m;exports.NylasMessagesConnector=f;exports.NylasThreadsConnector=w;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-3b6f5cd5.cjs"),M=require("./register-component-152c6ad2-0df7215b.cjs"),h=require("./utils-5074a070-d5ba6add.cjs"),A=require("./index-b30d446a-cbbef925.cjs"),c=require("./mailbox-store-19f0c6c9-a0cbfa97.cjs");require("react");require("react-dom");const P=":host{display:block}div{height:inherit}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.fade-in{animation:fadeIn 1.5s}.fade-out{animation:fadeOut 1.5s}@keyframes slideIn{0%{transform:translateY(100%)}100%{transform:translateY(0)}}@keyframes slideOut{0%{transform:translateY(0)}100%{transform:translateY(100%)}}.slide-in{animation:slideIn 1.5s}.slide-out{animation:slideOut 1.5s}@keyframes swipeIn{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes swipeOut{0%{transform:translateX(0)}100%{transform:translateX(100%)}}.swipe-in{animation:swipeIn 1.5s}.swipe-out{animation:swipeOut 1.5s}",N=P;var L=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},y=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const p=class{constructor(e){o.registerInstance(this,e),this.state=void 0,this.isStateSet=void 0,this.isBoolean=void 0,this.getStore=void 0,this.transition="none",this.show=!1,this.classes={},this.initTransition=this.initTransition.bind(this)}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){h.debug("[nylas-if-state] Component will load"),this.watchStore(!0)}async componentDidLoad(){h.debug("[nylas-if-state] Component did load")}shouldRender(){const[e,t]=this.state?this.state.split("."):["",""],n=this.getStore;if(typeof n>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{getStore:n}),!1;const s=n(e);if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{store:s}),!1;const i=s.state[t];return typeof this.isStateSet=="boolean"?this.isStateSet===!1&&(typeof i>"u"||i===null||i.length===0)||this.isStateSet===!0&&typeof i<"u"&&i!==null:typeof this.isBoolean=="boolean"?this.isBoolean===!0&&typeof i<"u"&&i===!0||this.isBoolean===!1&&typeof i<"u"&&i===!1:!1}onGetStoreChange(){this.watchStore(!0)}watchStore(e=!1){const[t,n]=this.state?this.state.split("."):["",""],s=this.getStore;if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{getStore:s}),null;const i=s(t);if(typeof i>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{store:i}),null;e===!0&&this.initTransition(),i.onChange(n,this.initTransition)}initTransition(){const e=this.shouldRender();switch(this.transition){case"fade":case"slide":case"swipe":this.classes={[`${this.transition}-in`]:e,[`${this.transition}-out`]:!e},setTimeout(()=>{this.show=e},150);break;default:this.show=this.shouldRender();break}}render(){return o.h(o.Host,{key:"91d17bc89a09742106ef3bd9365c5ce48cf14e86"},o.h("div",{key:"9d0070be4bf5d9a5f405fc4a0733e6d832fa669a",class:this.classes},this.show&&o.h("slot",null)))}static get watchers(){return{getStore:["onGetStoreChange"]}}};L([M.RegisterComponent({name:"nylas-if-state",getStoresToProp:"getStore",fireRegisterEvent:!0}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],p.prototype,"render",null);p.style=N;const T=":host{font-family:'Arial', sans-serif;background:var(--nylas-color-primary-50);color:var(--nylas-color-primary-800);margin:0;display:contents}input{box-sizing:border-box}.login-container{display:flex;justify-content:center;align-items:center;height:100%}.login-box{width:300px;padding:20px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border-radius:var(--nylas-border-radius-2x);background:var(--nylas-color-primary-50);text-align:center}.login-box h1{margin-top:0;margin-bottom:0.5em}.login-box p{margin-bottom:1em}.login-methods button{display:block;width:100%;padding:10px 10px 10px 50px;margin-bottom:10px;border:none;border-radius:var(--nylas-border-radius);border:1px solid var(--nylas-color-primary-300);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-600);cursor:pointer;transition:background 0.3s ease;position:relative;text-align:left}.login-methods button svg{position:absolute;left:16px;top:50%;transform:translateY(-50%)}.login-methods button:hover{background:var(--nylas-color-primary-200);}.login-form label{display:block;margin-bottom:5px;text-align:left}.login-form input{width:100%;padding:10px;margin-bottom:10px;border:1px solid var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-800);}.login-form button{width:100%;padding:10px;border:none;border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-500);color:var(--nylas-color-primary-50);cursor:pointer;transition:background 0.3s ease}.login-form button:hover{background:var(--nylas-color-primary-600);}",I=T;var O=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},m=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const b=class{constructor(e){o.registerInstance(this,e),this.buttonClick=o.createEvent(this,"buttonClick",7),this._handleLoginRedirect=async()=>{var s;const t=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes));this.buttonClick.emit({url:t}).defaultPrevented||t&&(window.location.href=t)},this._onGoogleButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"google"));n&&(window.location.href=n)},this._onMicrosoftButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"microsoft"));n&&(window.location.href=n)},this._onFormSubmit=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,this.email));n&&(window.location.href=n)},this.isAuthenticated=!1,this.nylasConnector=void 0,this.scopes=void 0,this.loginMethod="redirect",this.companyName="Nylas",this.logoUrl="https://www.nylas.com/wp-content/uploads/main-logo.svg",this.logoWidth="min-content",this.providers="google,microsoft",this.buttonText="Login",this.email=""}connectedCallback(){}disconnectedCallback(){}componentWillLoad(){}async componentDidLoad(){var t;await((t=this.nylasConnector)==null?void 0:t.auth.manageHostedAuthCodeExchange(window.location.href))&&window.history.replaceState({},document.title,window.location.pathname)}render(){var t;const e=((t=this.providers)==null?void 0:t.split(","))||[];return o.h(o.Host,{key:"a0b36443906ea5244070e6d0eece3794b1d1d3d5"},this.loginMethod==="redirect"&&o.h("div",{class:"redirect-container"},!this.isAuthenticated&&o.h("sp-button",{part:"button",onClick:this._handleLoginRedirect},this.buttonText)),this.loginMethod==="emebded"&&o.h("main",{class:"login-container"},o.h("section",{class:"login-box"},o.h("header",null,o.h("img",{src:this.logoUrl,alt:`${this.companyName} logo`,width:"100%",style:{minWidth:this.logoWidth}}),o.h("h1",null,"Welcome")),o.h("p",null,"Log in to your account to continue to ",this.companyName),o.h("div",{class:"login-methods"},e.includes("google")&&o.h("button",{class:"login-google",onClick:this._onGoogleButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 256 262"},o.h("path",{fill:"#4285F4",d:"M255.6 131.6c0-8.2-.8-16.2-2.2-23.9H130v45.3h70.3c-3 16.1-12.4 29.7-26.3 38.9v32.4h42.6c25-23 39.4-56.7 39.4-97.7z"}),o.h("path",{fill:"#34A853",d:"M130 262c35.3 0 64.9-11.7 86.5-31.7l-42.6-32.4c-11.7 7.9-26.7 12.6-43.9 12.6-33.7 0-62.3-22.7-72.5-53.4H14.5v33.3A130.3 130.3 0 00130 262z"}),o.h("path",{fill:"#FBBC05",d:"M57.5 158.1a72.7 72.7 0 010-54.2V70.6H14.5a130.4 130.4 0 000 120.8l43-33.3z"}),o.h("path",{fill:"#EA4335",d:"M130 51.6c19 0 36 6.5 49.4 19.2l37-36C195 13.1 165.2 0 130 0A130.3 130.3 0 0014.5 70.6l43 33.3c10.2-30.7 38.8-53.3 72.5-53.3z"})),"Continue with Google"),e.includes("microsoft")&&o.h("button",{class:"login-microsoft",onClick:this._onMicrosoftButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 448 512"},o.h("path",{fill:"#F3F3F3",d:"M0 32v192h192V32H0zm256 0v192h192V32H256zm192 256v192h-192V288h192zM0 224v192h192V224H0z"})),"Continue with Microsoft")),o.h("form",{class:"login-form",method:"POST",onSubmit:this._onFormSubmit},o.h("label",{htmlFor:"email"},"Email"),o.h("input",{type:"email",id:"email",name:"email",required:!0,value:this.email}),o.h("button",{type:"submit"},"Next")))))}};O([M.RegisterComponent({name:"nylas-login",connectorToProp:"nylasConnector",stateToProps:new Map([["auth.isAuthenticated","isAuthenticated"]]),fireRegisterEvent:!0}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",void 0)],b.prototype,"render",null);b.style=I;class E{constructor(t,n,s,i){this.router=t,this.nylasAuth=n,this.nylasAuthStore=s,this.nylasMailboxStore=i}init(){h.debug("NylasMailboxConnector init")}get mailboxStore(){return this.nylasMailboxStore}get authStore(){return this.nylasAuthStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new c.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new c.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new c.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new c.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasMailboxStore.reset(),this.nylasAuthStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const H=":host{display:contents}",B=H,_=class{constructor(e){o.registerInstance(this,e),this.init=o.createEvent(this,"init",7),this.loggedIn=o.createEvent(this,"loggedIn",7),this.loggedOut=o.createEvent(this,"loggedOut",7),this.handleAuthChange=async t=>{var n;t?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host).defaultPrevented||await((n=this.nylasMailboxConnector)==null?void 0:n.logout())},this.automaticComponentRegistration=!0,this.eventOverrides={},this.authConfig=void 0,this.defaultAuthStoreState=void 0,this.defaultMailboxStoreState=void 0}connectedCallback(){h.debug("[nylas-mailbox] connectedCallback")}async componentWillLoad(){var s,i,a,r,l,v,C;this.stores={auth:c.CreateNylasAuthStore(this.defaultAuthStoreState),mailbox:c.CreateNylasMailboxStore(this.defaultMailboxStoreState)},this.baseProvider=new A.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.router=new c.HashRouter,this.nylasAuth=A.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const e=(s=this.baseProvider)==null?void 0:s.getStore("auth");if(!e)throw new Error("Auth store is not defined");const t=(i=this.baseProvider)==null?void 0:i.getStore("mailbox");if(!t)throw new Error("Mailbox store is not defined");this.nylasMailboxConnector=new E(this.router,this.nylasAuth,e,t),this.init.emit(this.host).defaultPrevented||await((a=this.nylasMailboxConnector)==null?void 0:a.auth.validateSession()),(r=this.router)==null||r.addRouteChangeListener("/thread/:threadId",async(R,k,w)=>{var u,f;const g=w.threadId,d=await((u=this.nylasMailboxConnector)==null?void 0:u.threads.getThread(g));d&&((f=this.nylasMailboxConnector)==null||f.mailboxStore.set("selectedThread",d))}),(l=this.router)==null||l.addRouteChangeListener("/",async(R,k,w)=>{var d,u,f,S;if(!e.state.isAuthenticated)return;(d=this.nylasMailboxConnector)==null||d.threads.unSelectThread(),(u=this.nylasMailboxConnector)==null||u.folders.getFolders();const g=window.location.hash.split("?")[1];if(g){const x=new URLSearchParams(g).get("query");x&&await((f=this.nylasMailboxConnector)==null?void 0:f.threads.getThreads({search_query_native:x,page_token:void 0}))}else(S=this.nylasMailboxConnector)==null||S.threads.getThreads()}),(v=this.router)==null||v.init(),this.handleAuthChange(e.state.isAuthenticated),(C=this.baseProvider)==null||C.componentWillLoad(this.nylasMailboxConnector)}async componentDidLoad(){var t,n;const e=(t=this.baseProvider)==null?void 0:t.getStore("auth");if(!e)throw new Error("Auth store is not defined");e.onChange("isAuthenticated",this.handleAuthChange),(n=this.baseProvider)==null||n.componentDidLoad()}componentDisconnected(){var e;(e=this.baseProvider)==null||e.componentDisconnected()}async registerComponentHandler(e){var t;(t=this.baseProvider)==null||t.registerComponent(e.detail)}async unregisterComponentHandler(e){var t;(t=this.baseProvider)==null||t.unregisterComponent(e.detail)}async getMailboxStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("mailbox")}async getAuthStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("auth")}async getNylasAuth(){return this.nylasAuth}async getNylasMailboxConnector(){return this.nylasMailboxConnector}render(){return o.h(o.Host,{key:"a3c855c441914ccb60f6ad72cf166fe888508a6c"},o.h("slot",{key:"09bb1cbaf72e4beb90dcb723b1dc398b63072dd7"}))}get host(){return o.getElement(this)}};_.style=B;exports.nylas_if_state=p;exports.nylas_login=b;exports.nylas_mailbox=_;
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { r as p, h as i, H as b, c as m, g as N } from "./index-630f4e87.js";
|
|
2
|
-
import { R as A } from "./register-component-152c6ad2-a06f58c2.js";
|
|
3
|
-
import { d as h } from "./utils-5074a070-ce33ee6b.js";
|
|
4
|
-
import { N as P, e as L } from "./index-b30d446a-a90f84b2.js";
|
|
5
|
-
import { C as T, a as O, H as I, N as H, b as E, c as B, d as $ } from "./mailbox-store-19f0c6c9-e3e8b4e5.js";
|
|
6
|
-
import "react";
|
|
7
|
-
import "react-dom";
|
|
8
|
-
const D = ":host{display:block}div{height:inherit}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.fade-in{animation:fadeIn 1.5s}.fade-out{animation:fadeOut 1.5s}@keyframes slideIn{0%{transform:translateY(100%)}100%{transform:translateY(0)}}@keyframes slideOut{0%{transform:translateY(0)}100%{transform:translateY(100%)}}.slide-in{animation:slideIn 1.5s}.slide-out{animation:slideOut 1.5s}@keyframes swipeIn{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes swipeOut{0%{transform:translateX(0)}100%{transform:translateX(100%)}}.swipe-in{animation:swipeIn 1.5s}.swipe-out{animation:swipeOut 1.5s}", F = D;
|
|
9
|
-
var U = function(e, t, o, n) {
|
|
10
|
-
var s = arguments.length, a = s < 3 ? t : n === null ? n = Object.getOwnPropertyDescriptor(t, o) : n, r;
|
|
11
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
|
|
12
|
-
a = Reflect.decorate(e, t, o, n);
|
|
13
|
-
else
|
|
14
|
-
for (var l = e.length - 1; l >= 0; l--)
|
|
15
|
-
(r = e[l]) && (a = (s < 3 ? r(a) : s > 3 ? r(t, o, a) : r(t, o)) || a);
|
|
16
|
-
return s > 3 && a && Object.defineProperty(t, o, a), a;
|
|
17
|
-
}, y = function(e, t) {
|
|
18
|
-
if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
|
|
19
|
-
return Reflect.metadata(e, t);
|
|
20
|
-
};
|
|
21
|
-
const M = class {
|
|
22
|
-
constructor(e) {
|
|
23
|
-
p(this, e), this.state = void 0, this.isStateSet = void 0, this.isBoolean = void 0, this.getStore = void 0, this.transition = "none", this.show = !1, this.classes = {}, this.initTransition = this.initTransition.bind(this);
|
|
24
|
-
}
|
|
25
|
-
connectedCallback() {
|
|
26
|
-
}
|
|
27
|
-
disconnectedCallback() {
|
|
28
|
-
}
|
|
29
|
-
async componentWillLoad() {
|
|
30
|
-
h("[nylas-if-state] Component will load"), this.watchStore(!0);
|
|
31
|
-
}
|
|
32
|
-
async componentDidLoad() {
|
|
33
|
-
h("[nylas-if-state] Component did load");
|
|
34
|
-
}
|
|
35
|
-
shouldRender() {
|
|
36
|
-
const [e, t] = this.state ? this.state.split(".") : ["", ""], o = this.getStore;
|
|
37
|
-
if (typeof o > "u")
|
|
38
|
-
return h(`[nylas-if-state] Store name: ${e} | State name: ${t}`, { getStore: o }), !1;
|
|
39
|
-
const n = o(e);
|
|
40
|
-
if (typeof n > "u")
|
|
41
|
-
return h(`[nylas-if-state] Store name: ${e} | State name: ${t}`, { store: n }), !1;
|
|
42
|
-
const s = n.state[t];
|
|
43
|
-
return typeof this.isStateSet == "boolean" ? this.isStateSet === !1 && (typeof s > "u" || s === null || s.length === 0) || this.isStateSet === !0 && typeof s < "u" && s !== null : typeof this.isBoolean == "boolean" ? this.isBoolean === !0 && typeof s < "u" && s === !0 || this.isBoolean === !1 && typeof s < "u" && s === !1 : !1;
|
|
44
|
-
}
|
|
45
|
-
onGetStoreChange() {
|
|
46
|
-
this.watchStore(!0);
|
|
47
|
-
}
|
|
48
|
-
watchStore(e = !1) {
|
|
49
|
-
const [t, o] = this.state ? this.state.split(".") : ["", ""], n = this.getStore;
|
|
50
|
-
if (typeof n > "u")
|
|
51
|
-
return h(`[nylas-if-state] Store name: ${t} | State name: ${o}`, { getStore: n }), null;
|
|
52
|
-
const s = n(t);
|
|
53
|
-
if (typeof s > "u")
|
|
54
|
-
return h(`[nylas-if-state] Store name: ${t} | State name: ${o}`, { store: s }), null;
|
|
55
|
-
e === !0 && this.initTransition(), s.onChange(o, this.initTransition);
|
|
56
|
-
}
|
|
57
|
-
initTransition() {
|
|
58
|
-
const e = this.shouldRender();
|
|
59
|
-
switch (this.transition) {
|
|
60
|
-
case "fade":
|
|
61
|
-
case "slide":
|
|
62
|
-
case "swipe":
|
|
63
|
-
this.classes = {
|
|
64
|
-
[`${this.transition}-in`]: e,
|
|
65
|
-
[`${this.transition}-out`]: !e
|
|
66
|
-
}, setTimeout(() => {
|
|
67
|
-
this.show = e;
|
|
68
|
-
}, 150);
|
|
69
|
-
break;
|
|
70
|
-
default:
|
|
71
|
-
this.show = this.shouldRender();
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
render() {
|
|
76
|
-
return i(b, { key: "91d17bc89a09742106ef3bd9365c5ce48cf14e86" }, i("div", { key: "9d0070be4bf5d9a5f405fc4a0733e6d832fa669a", class: this.classes }, this.show && i("slot", null)));
|
|
77
|
-
}
|
|
78
|
-
static get watchers() {
|
|
79
|
-
return {
|
|
80
|
-
getStore: ["onGetStoreChange"]
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
U([
|
|
85
|
-
A({
|
|
86
|
-
name: "nylas-if-state",
|
|
87
|
-
getStoresToProp: "getStore",
|
|
88
|
-
fireRegisterEvent: !0
|
|
89
|
-
}),
|
|
90
|
-
y("design:type", Function),
|
|
91
|
-
y("design:paramtypes", []),
|
|
92
|
-
y("design:returntype", void 0)
|
|
93
|
-
], M.prototype, "render", null);
|
|
94
|
-
M.style = F;
|
|
95
|
-
const j = ":host{font-family:'Arial', sans-serif;background:var(--nylas-color-primary-50);color:var(--nylas-color-primary-800);margin:0;display:contents}input{box-sizing:border-box}.login-container{display:flex;justify-content:center;align-items:center;height:100%}.login-box{width:300px;padding:20px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border-radius:var(--nylas-border-radius-2x);background:var(--nylas-color-primary-50);text-align:center}.login-box h1{margin-top:0;margin-bottom:0.5em}.login-box p{margin-bottom:1em}.login-methods button{display:block;width:100%;padding:10px 10px 10px 50px;margin-bottom:10px;border:none;border-radius:var(--nylas-border-radius);border:1px solid var(--nylas-color-primary-300);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-600);cursor:pointer;transition:background 0.3s ease;position:relative;text-align:left}.login-methods button svg{position:absolute;left:16px;top:50%;transform:translateY(-50%)}.login-methods button:hover{background:var(--nylas-color-primary-200);}.login-form label{display:block;margin-bottom:5px;text-align:left}.login-form input{width:100%;padding:10px;margin-bottom:10px;border:1px solid var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-800);}.login-form button{width:100%;padding:10px;border:none;border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-500);color:var(--nylas-color-primary-50);cursor:pointer;transition:background 0.3s ease}.login-form button:hover{background:var(--nylas-color-primary-600);}", z = j;
|
|
96
|
-
var W = function(e, t, o, n) {
|
|
97
|
-
var s = arguments.length, a = s < 3 ? t : n === null ? n = Object.getOwnPropertyDescriptor(t, o) : n, r;
|
|
98
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
|
|
99
|
-
a = Reflect.decorate(e, t, o, n);
|
|
100
|
-
else
|
|
101
|
-
for (var l = e.length - 1; l >= 0; l--)
|
|
102
|
-
(r = e[l]) && (a = (s < 3 ? r(a) : s > 3 ? r(t, o, a) : r(t, o)) || a);
|
|
103
|
-
return s > 3 && a && Object.defineProperty(t, o, a), a;
|
|
104
|
-
}, g = function(e, t) {
|
|
105
|
-
if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
|
|
106
|
-
return Reflect.metadata(e, t);
|
|
107
|
-
};
|
|
108
|
-
const _ = class {
|
|
109
|
-
constructor(e) {
|
|
110
|
-
p(this, e), this.buttonClick = m(this, "buttonClick", 7), this._handleLoginRedirect = async () => {
|
|
111
|
-
var n;
|
|
112
|
-
const t = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes));
|
|
113
|
-
this.buttonClick.emit({ url: t }).defaultPrevented || t && (window.location.href = t);
|
|
114
|
-
}, this._onGoogleButtonClick = async (t) => {
|
|
115
|
-
var n;
|
|
116
|
-
t.preventDefault();
|
|
117
|
-
const o = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes, void 0, "google"));
|
|
118
|
-
o && (window.location.href = o);
|
|
119
|
-
}, this._onMicrosoftButtonClick = async (t) => {
|
|
120
|
-
var n;
|
|
121
|
-
t.preventDefault();
|
|
122
|
-
const o = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes, void 0, "microsoft"));
|
|
123
|
-
o && (window.location.href = o);
|
|
124
|
-
}, this._onFormSubmit = async (t) => {
|
|
125
|
-
var n;
|
|
126
|
-
t.preventDefault();
|
|
127
|
-
const o = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes, this.email));
|
|
128
|
-
o && (window.location.href = o);
|
|
129
|
-
}, this.isAuthenticated = !1, this.nylasConnector = void 0, this.scopes = void 0, this.loginMethod = "redirect", this.companyName = "Nylas", this.logoUrl = "https://www.nylas.com/wp-content/uploads/main-logo.svg", this.logoWidth = "min-content", this.providers = "google,microsoft", this.buttonText = "Login", this.email = "";
|
|
130
|
-
}
|
|
131
|
-
connectedCallback() {
|
|
132
|
-
}
|
|
133
|
-
disconnectedCallback() {
|
|
134
|
-
}
|
|
135
|
-
componentWillLoad() {
|
|
136
|
-
}
|
|
137
|
-
async componentDidLoad() {
|
|
138
|
-
var t;
|
|
139
|
-
await ((t = this.nylasConnector) == null ? void 0 : t.auth.manageHostedAuthCodeExchange(window.location.href)) && window.history.replaceState({}, document.title, window.location.pathname);
|
|
140
|
-
}
|
|
141
|
-
render() {
|
|
142
|
-
var t;
|
|
143
|
-
const e = ((t = this.providers) == null ? void 0 : t.split(",")) || [];
|
|
144
|
-
return i(b, { key: "a0b36443906ea5244070e6d0eece3794b1d1d3d5" }, this.loginMethod === "redirect" && i("div", { class: "redirect-container" }, !this.isAuthenticated && i("sp-button", { part: "button", onClick: this._handleLoginRedirect }, this.buttonText)), this.loginMethod === "emebded" && i("main", { class: "login-container" }, i("section", { class: "login-box" }, i("header", null, i("img", { src: this.logoUrl, alt: `${this.companyName} logo`, width: "100%", style: {
|
|
145
|
-
minWidth: this.logoWidth
|
|
146
|
-
} }), i("h1", null, "Welcome")), i("p", null, "Log in to your account to continue to ", this.companyName), i("div", { class: "login-methods" }, e.includes("google") && i("button", { class: "login-google", onClick: this._onGoogleButtonClick }, i("svg", { xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", role: "img", width: "18", height: "18", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 256 262" }, i("path", { fill: "#4285F4", d: "M255.6 131.6c0-8.2-.8-16.2-2.2-23.9H130v45.3h70.3c-3 16.1-12.4 29.7-26.3 38.9v32.4h42.6c25-23 39.4-56.7 39.4-97.7z" }), i("path", { fill: "#34A853", d: "M130 262c35.3 0 64.9-11.7 86.5-31.7l-42.6-32.4c-11.7 7.9-26.7 12.6-43.9 12.6-33.7 0-62.3-22.7-72.5-53.4H14.5v33.3A130.3 130.3 0 00130 262z" }), i("path", { fill: "#FBBC05", d: "M57.5 158.1a72.7 72.7 0 010-54.2V70.6H14.5a130.4 130.4 0 000 120.8l43-33.3z" }), i("path", { fill: "#EA4335", d: "M130 51.6c19 0 36 6.5 49.4 19.2l37-36C195 13.1 165.2 0 130 0A130.3 130.3 0 0014.5 70.6l43 33.3c10.2-30.7 38.8-53.3 72.5-53.3z" })), "Continue with Google"), e.includes("microsoft") && i("button", { class: "login-microsoft", onClick: this._onMicrosoftButtonClick }, i("svg", { xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", role: "img", width: "18", height: "18", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 448 512" }, i("path", { fill: "#F3F3F3", d: "M0 32v192h192V32H0zm256 0v192h192V32H256zm192 256v192h-192V288h192zM0 224v192h192V224H0z" })), "Continue with Microsoft")), i("form", { class: "login-form", method: "POST", onSubmit: this._onFormSubmit }, i("label", { htmlFor: "email" }, "Email"), i("input", { type: "email", id: "email", name: "email", required: !0, value: this.email }), i("button", { type: "submit" }, "Next")))));
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
W([
|
|
150
|
-
A({
|
|
151
|
-
name: "nylas-login",
|
|
152
|
-
connectorToProp: "nylasConnector",
|
|
153
|
-
stateToProps: /* @__PURE__ */ new Map([["auth.isAuthenticated", "isAuthenticated"]]),
|
|
154
|
-
fireRegisterEvent: !0
|
|
155
|
-
}),
|
|
156
|
-
g("design:type", Function),
|
|
157
|
-
g("design:paramtypes", []),
|
|
158
|
-
g("design:returntype", void 0)
|
|
159
|
-
], _.prototype, "render", null);
|
|
160
|
-
_.style = z;
|
|
161
|
-
class Y {
|
|
162
|
-
constructor(t, o, n, s) {
|
|
163
|
-
this.router = t, this.nylasAuth = o, this.nylasAuthStore = n, this.nylasMailboxStore = s;
|
|
164
|
-
}
|
|
165
|
-
init() {
|
|
166
|
-
h("NylasMailboxConnector init");
|
|
167
|
-
}
|
|
168
|
-
get mailboxStore() {
|
|
169
|
-
return this.nylasMailboxStore;
|
|
170
|
-
}
|
|
171
|
-
get authStore() {
|
|
172
|
-
return this.nylasAuthStore;
|
|
173
|
-
}
|
|
174
|
-
get auth() {
|
|
175
|
-
return this._authConnector ? this._authConnector : (this._authConnector = new H(this.nylasAuth, this.nylasAuthStore), this._authConnector);
|
|
176
|
-
}
|
|
177
|
-
get threads() {
|
|
178
|
-
return this._threadConnector ? this._threadConnector : (this._threadConnector = new E(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore, this.router), this._threadConnector);
|
|
179
|
-
}
|
|
180
|
-
get messages() {
|
|
181
|
-
return this._messageConnector ? this._messageConnector : (this._messageConnector = new B(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._messageConnector);
|
|
182
|
-
}
|
|
183
|
-
get folders() {
|
|
184
|
-
return this._foldersConnector ? this._foldersConnector : (this._foldersConnector = new $(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._foldersConnector);
|
|
185
|
-
}
|
|
186
|
-
getAuth() {
|
|
187
|
-
return this.nylasAuth;
|
|
188
|
-
}
|
|
189
|
-
resetStores() {
|
|
190
|
-
this.nylasMailboxStore.reset(), this.nylasAuthStore.reset();
|
|
191
|
-
}
|
|
192
|
-
async logout() {
|
|
193
|
-
await this.nylasAuth.logout(), this.resetStores();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const G = ":host{display:contents}", V = G, q = class {
|
|
197
|
-
constructor(e) {
|
|
198
|
-
p(this, e), this.init = m(this, "init", 7), this.loggedIn = m(this, "loggedIn", 7), this.loggedOut = m(this, "loggedOut", 7), this.handleAuthChange = async (t) => {
|
|
199
|
-
var o;
|
|
200
|
-
t ? this.loggedIn.emit(this.host) : this.loggedOut.emit(this.host).defaultPrevented || await ((o = this.nylasMailboxConnector) == null ? void 0 : o.logout());
|
|
201
|
-
}, this.automaticComponentRegistration = !0, this.eventOverrides = {}, this.authConfig = void 0, this.defaultAuthStoreState = void 0, this.defaultMailboxStoreState = void 0;
|
|
202
|
-
}
|
|
203
|
-
connectedCallback() {
|
|
204
|
-
h("[nylas-mailbox] connectedCallback");
|
|
205
|
-
}
|
|
206
|
-
async componentWillLoad() {
|
|
207
|
-
var n, s, a, r, l, C, v;
|
|
208
|
-
this.stores = {
|
|
209
|
-
auth: T(this.defaultAuthStoreState),
|
|
210
|
-
mailbox: O(this.defaultMailboxStoreState)
|
|
211
|
-
}, this.baseProvider = new P(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides), this.router = new I(), this.nylasAuth = L({
|
|
212
|
-
apiUri: "https://api.us.nylas.com",
|
|
213
|
-
elementsApiUri: "https://elements.us.nylas.com",
|
|
214
|
-
storageType: "indexeddb",
|
|
215
|
-
clientId: "YOUR_CLIENT_ID",
|
|
216
|
-
defaultScopes: [],
|
|
217
|
-
redirectURI: "/",
|
|
218
|
-
...this.authConfig
|
|
219
|
-
});
|
|
220
|
-
const e = (n = this.baseProvider) == null ? void 0 : n.getStore("auth");
|
|
221
|
-
if (!e)
|
|
222
|
-
throw new Error("Auth store is not defined");
|
|
223
|
-
const t = (s = this.baseProvider) == null ? void 0 : s.getStore("mailbox");
|
|
224
|
-
if (!t)
|
|
225
|
-
throw new Error("Mailbox store is not defined");
|
|
226
|
-
this.nylasMailboxConnector = new Y(this.router, this.nylasAuth, e, t), this.init.emit(this.host).defaultPrevented || await ((a = this.nylasMailboxConnector) == null ? void 0 : a.auth.validateSession()), (r = this.router) == null || r.addRouteChangeListener("/thread/:threadId", async (R, k, w) => {
|
|
227
|
-
var c, u;
|
|
228
|
-
const f = w.threadId, d = await ((c = this.nylasMailboxConnector) == null ? void 0 : c.threads.getThread(f));
|
|
229
|
-
d && ((u = this.nylasMailboxConnector) == null || u.mailboxStore.set("selectedThread", d));
|
|
230
|
-
}), (l = this.router) == null || l.addRouteChangeListener("/", async (R, k, w) => {
|
|
231
|
-
var d, c, u, S;
|
|
232
|
-
if (!e.state.isAuthenticated)
|
|
233
|
-
return;
|
|
234
|
-
(d = this.nylasMailboxConnector) == null || d.threads.unSelectThread(), (c = this.nylasMailboxConnector) == null || c.folders.getFolders();
|
|
235
|
-
const f = window.location.hash.split("?")[1];
|
|
236
|
-
if (f) {
|
|
237
|
-
const x = new URLSearchParams(f).get("query");
|
|
238
|
-
x && await ((u = this.nylasMailboxConnector) == null ? void 0 : u.threads.getThreads({
|
|
239
|
-
search_query_native: x,
|
|
240
|
-
page_token: void 0
|
|
241
|
-
}));
|
|
242
|
-
} else
|
|
243
|
-
(S = this.nylasMailboxConnector) == null || S.threads.getThreads();
|
|
244
|
-
}), (C = this.router) == null || C.init(), this.handleAuthChange(e.state.isAuthenticated), (v = this.baseProvider) == null || v.componentWillLoad(this.nylasMailboxConnector);
|
|
245
|
-
}
|
|
246
|
-
async componentDidLoad() {
|
|
247
|
-
var t, o;
|
|
248
|
-
const e = (t = this.baseProvider) == null ? void 0 : t.getStore("auth");
|
|
249
|
-
if (!e)
|
|
250
|
-
throw new Error("Auth store is not defined");
|
|
251
|
-
e.onChange("isAuthenticated", this.handleAuthChange), (o = this.baseProvider) == null || o.componentDidLoad();
|
|
252
|
-
}
|
|
253
|
-
componentDisconnected() {
|
|
254
|
-
var e;
|
|
255
|
-
(e = this.baseProvider) == null || e.componentDisconnected();
|
|
256
|
-
}
|
|
257
|
-
async registerComponentHandler(e) {
|
|
258
|
-
var t;
|
|
259
|
-
(t = this.baseProvider) == null || t.registerComponent(e.detail);
|
|
260
|
-
}
|
|
261
|
-
async unregisterComponentHandler(e) {
|
|
262
|
-
var t;
|
|
263
|
-
(t = this.baseProvider) == null || t.unregisterComponent(e.detail);
|
|
264
|
-
}
|
|
265
|
-
async getMailboxStore() {
|
|
266
|
-
var e;
|
|
267
|
-
return (e = this.baseProvider) == null ? void 0 : e.getStore("mailbox");
|
|
268
|
-
}
|
|
269
|
-
async getAuthStore() {
|
|
270
|
-
var e;
|
|
271
|
-
return (e = this.baseProvider) == null ? void 0 : e.getStore("auth");
|
|
272
|
-
}
|
|
273
|
-
async getNylasAuth() {
|
|
274
|
-
return this.nylasAuth;
|
|
275
|
-
}
|
|
276
|
-
async getNylasMailboxConnector() {
|
|
277
|
-
return this.nylasMailboxConnector;
|
|
278
|
-
}
|
|
279
|
-
render() {
|
|
280
|
-
return i(b, { key: "a3c855c441914ccb60f6ad72cf166fe888508a6c" }, i("slot", { key: "09bb1cbaf72e4beb90dcb723b1dc398b63072dd7" }));
|
|
281
|
-
}
|
|
282
|
-
get host() {
|
|
283
|
-
return N(this);
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
q.style = V;
|
|
287
|
-
export {
|
|
288
|
-
M as nylas_if_state,
|
|
289
|
-
_ as nylas_login,
|
|
290
|
-
q as nylas_mailbox
|
|
291
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-3b6f5cd5.cjs"),u=require("./register-component-152c6ad2-0df7215b.cjs"),a=require("./utils-5074a070-d5ba6add.cjs");require("react");require("react-dom");const h=":host{display:block}.folders{display:flex;flex-direction:column;align-items:self-start}.folders .folder{border:1px solid var(--nylas-color-primary-100);padding:0.5rem 0.75rem;margin-bottom:0.5rem;justify-content:left;width:100%;min-width:200px;border-radius:var(--nylas-border-radius);background-color:var(--nylas-color-primary-50)}.folders .folder:last-child{margin-bottom:0}.folders .folder.selected{background-color:var(--nylas-color-primary-100)}.folders .folder .icon{margin-right:0.5rem;stroke:var(--nylas-color-primary-900);fill:none}hr{width:100%;margin:1rem 0;border:0;border-top:1px solid var(--nylas-color-primary-100)}",m=h;var p=function(t,r,e,o){var s=arguments.length,n=s<3?r:o===null?o=Object.getOwnPropertyDescriptor(r,e):o,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,r,e,o);else for(var i=t.length-1;i>=0;i--)(d=t[i])&&(n=(s<3?d(n):s>3?d(r,e,n):d(r,e))||n);return s>3&&n&&Object.defineProperty(r,e,n),n},c=function(t,r){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,r)};const f=class{constructor(t){l.registerInstance(this,t),this.folderSelected=l.createEvent(this,"folderSelected",7),this.folderSelectedHandler=r=>{var e;(e=this.folderSelected)==null||e.emit(r)},this.folders=void 0,this.selectedFolder=void 0,this.defaultFolders=void 0,this.otherFolders=void 0}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){a.debug("[nylas-list-folders] Component will load")}async componentDidLoad(){a.debug("[nylas-list-folders] Component did load")}watchFolders(t){a.debug("[nylas-list-folders] watchFolders",{newFolders:t});const r=["inbox","drafts","sent","starred","spam","archive","trash"];this.defaultFolders=r.filter(e=>t.find(o=>{var s;return((s=o.name)==null?void 0:s.toLowerCase())===e.toLowerCase()})).map(e=>t.find(o=>{var s;return((s=o.name)==null?void 0:s.toLowerCase())===e.toLowerCase()})).filter(e=>typeof e<"u").sort((e,o)=>r.indexOf((e==null?void 0:e.name)??"")-r.indexOf((o==null?void 0:o.name)??"")),this.otherFolders=t.filter(e=>!r.find(o=>{var s;return((s=e.name)==null?void 0:s.toLowerCase())===o.toLowerCase()})).sort((e,o)=>(e.name??"").localeCompare(o.name??""))}formatFolderName(t){var r;return a.toTitleCase(((r=t.name)==null?void 0:r.replace("CATEGORY_",""))??"Unknown")}getFolderIcon(t){var r;switch((r=t.name)==null?void 0:r.toLowerCase()){case"inbox":return l.h("inbox-icon",null);case"drafts":return l.h("drafts-icon",null);case"sent":return l.h("sent-icon",null);case"starred":return l.h("star-icon",null);case"spam":return l.h("spam-icon",null);case"archive":return l.h("archive-icon",null);case"trash":return l.h("trash-icon",null);default:return l.h("folder-icon",null)}}render(){var t,r;return l.h(l.Host,{key:"7cccf397860653266b6f2635762fa76a2910c6b3"},l.h("div",{key:"390e0d26d5c5568487a937ff49f2931da00f26b1",class:"folders"},(t=this.defaultFolders)==null?void 0:t.map(e=>{var o;return l.h("sp-button",{onClick:()=>this.folderSelectedHandler(e),class:{folder:!0,selected:a.formatFolderName(e.name??"inbox").toLowerCase()===((o=this.selectedFolder)==null?void 0:o.toLowerCase())}},l.h("div",{slot:"icon",class:"icon"},this.getFolderIcon(e)),this.formatFolderName(e))})),this.otherFolders&&l.h(l.Fragment,null,l.h("hr",null),l.h("div",{class:"folders"},(r=this.otherFolders)==null?void 0:r.map(e=>{var o;return l.h("sp-button",{onClick:()=>this.folderSelectedHandler(e),class:{folder:!0,selected:a.formatFolderName(e.name??"inbox").toLowerCase()===((o=this.selectedFolder)==null?void 0:o.toLowerCase())}},l.h("div",{slot:"icon",class:"icon"},this.getFolderIcon(e)),this.formatFolderName(e))}))))}static get watchers(){return{folders:["watchFolders"]}}};p([u.RegisterComponent({name:"nylas-pagination",stateToProps:new Map([["mailbox.folders","folders"],["mailbox.selectedFolder","selectedFolder"]]),eventToProps:{folderSelected:async(t,r)=>{a.debug("[nylas-list-folders] folderSelected event",{_event:t}),await r.threads.getThreads({page_token:void 0,in:a.formatFolderName(t.detail.id??"inbox")})}},fireRegisterEvent:!0}),c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],f.prototype,"render",null);f.style=m;exports.nylas_list_folders=f;
|