@haus-storefront-react/discounts 0.0.15

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/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # Changelog
package/README.md ADDED
@@ -0,0 +1,243 @@
1
+ # Discounts Components
2
+
3
+ A collection of headless, flexible discount components for e-commerce storefronts. Include coupon code management and active discounts display. Built with TypeScript, accessibility-first design, and works on both web and React Native.
4
+
5
+ ## Components
6
+
7
+ ### CouponCode Component
8
+
9
+ A headless, flexible coupon code component for e-commerce storefronts. Supports applying and removing coupon codes, error handling, and platform-agnostic architecture.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @haus-storefront-react/discounts
15
+ # or
16
+ yarn add @haus-storefront-react/discounts
17
+ ```
18
+
19
+ ## Components
20
+
21
+ ### CouponCode component
22
+
23
+ Supports applying and removing coupon codes, error handling, and platform-agnostic architecture.
24
+
25
+ #### Usage Example
26
+
27
+ ```tsx
28
+ import { CouponCode } from '@haus-storefront-react/discounts'
29
+ ;<CouponCode.Root>
30
+ {(couponCodeContext) => (
31
+ <div>
32
+ <CouponCode.Input placeholder="Enter coupon code" />
33
+ <CouponCode.ApplyButton>Apply</CouponCode.ApplyButton>
34
+ <CouponCode.Error>
35
+ <div>Invalid coupon code</div>
36
+ </CouponCode.Error>
37
+ </div>
38
+ )
39
+ </div>
40
+ )}
41
+ </CouponCode.Root>
42
+ ```
43
+
44
+ ## API Reference
45
+
46
+ ### CouponCode.Root
47
+
48
+ The main container component that provides the coupon code context.
49
+
50
+ **Props:**
51
+
52
+ - `children`: Render function that receives the coupon code context
53
+
54
+ ### CouponCode.Input
55
+
56
+ Text input for entering coupon codes.
57
+
58
+ **Props:**
59
+
60
+ - `asChild`: Use a custom component instead of the default input
61
+ - `placeholder`: Placeholder text
62
+ - `disabled`: Disable the input
63
+ - All standard HTML input attributes
64
+
65
+ **Features:**
66
+
67
+ - Enter key applies the coupon code
68
+ - Escape key closes the input
69
+ - Auto-focus when opened
70
+
71
+ ### CouponCode.ApplyButton
72
+
73
+ Button to apply the entered coupon code.
74
+
75
+ **Props:**
76
+
77
+ - `asChild`: Use a custom component instead of the default button
78
+ - `disabled`: Disable the button (auto-disabled when no code entered)
79
+ - All standard HTML button attributes
80
+
81
+ ### CouponCode.RemoveButton
82
+
83
+ Button to remove an applied coupon code.
84
+
85
+ **Props:**
86
+
87
+ - `couponCode`: The coupon code to remove
88
+ - `asChild`: Use a custom component instead of the default button
89
+ - All standard HTML button attributes
90
+
91
+ ## ActiveDiscounts Component
92
+
93
+ A headless component for displaying and managing active discounts on an order. Shows applied discounts with their descriptions and amounts, and provides functionality to remove coupon codes.
94
+
95
+ ### Usage Example
96
+
97
+ ```tsx
98
+ import { ActiveDiscounts } from '@haus-storefront-react/discounts'
99
+ import { Price } from '@haus-storefront-react/common-ui'
100
+ ;<ActiveDiscounts.Root>
101
+ {(activeDiscountsContext) => (
102
+ <ActiveDiscounts.List>
103
+ {({ discounts }) => (
104
+ <div>
105
+ {discounts?.map((discount, index) => (
106
+ <ActiveDiscounts.Item key={index} discount={discount}>
107
+ {({ discount }) => (
108
+ <div>
109
+ <div>
110
+ <span>{discount.description}</span>
111
+ {discount.promotion?.couponCode && (
112
+ <span>({discount.promotion.couponCode})</span>
113
+ )}
114
+ </div>
115
+
116
+ <ActiveDiscounts.RemoveButton discount={discount}>
117
+ Remove discount code
118
+ </ActiveDiscounts.RemoveButton>
119
+
120
+ <Price.Root
121
+ price={discount.amount}
122
+ priceWithTax={discount.amountWithTax}
123
+ currencyCode={discount.currencyCode}
124
+ asChild
125
+ >
126
+ <div>
127
+ <Price.Amount withCurrency />
128
+ </div>
129
+ </Price.Root>
130
+ </div>
131
+ )}
132
+ </ActiveDiscounts.Item>
133
+ ))}
134
+ </div>
135
+ )}
136
+ </ActiveDiscounts.List>
137
+ )}
138
+ </ActiveDiscounts.Root>
139
+ ```
140
+
141
+ ### API Reference
142
+
143
+ #### ActiveDiscounts.Root
144
+
145
+ The main container component that provides the active discounts context.
146
+
147
+ **Props:**
148
+
149
+ - `children`: Render function that receives the active discounts context
150
+
151
+ #### ActiveDiscounts.List
152
+
153
+ Container for the list of active discounts.
154
+
155
+ **Props:**
156
+
157
+ - `asChild`: Use a custom component instead of the default div
158
+ - `children`: Render function that receives the discounts array
159
+
160
+ #### ActiveDiscounts.Item
161
+
162
+ Container for individual discount items.
163
+
164
+ **Props:**
165
+
166
+ - `asChild`: Use a custom component instead of the default div
167
+ - `children`: Render function that receives the discount object
168
+
169
+ #### ActiveDiscounts.RemoveButton
170
+
171
+ Button to remove a coupon code from the order. Only renders if the discount has a promotion with a coupon code.
172
+
173
+ **Props:**
174
+
175
+ - `discount`: The discount object (required to check if it has a coupon code)
176
+ - `asChild`: Use a custom component instead of the default button
177
+ - All standard HTML button attributes
178
+
179
+ **Features:**
180
+
181
+ - Only renders if the discount has a promotion with a coupon code
182
+ - Automatically removes the coupon code associated with the discount
183
+ - Platform agnostic (works on web and React Native)
184
+
185
+ ## Context Value
186
+
187
+ The `CouponCode.Root` component provides the following context to its children:
188
+
189
+ ```typescript
190
+ interface UseCouponCodeReturn {
191
+ code: string // Current coupon code input
192
+ isLoading: boolean // Loading state for API calls
193
+ error: Error | null // Error state
194
+ isOpen: boolean // Whether input is visible
195
+ setCode: (code: string) => void
196
+ setIsOpen: (isOpen: boolean) => void
197
+ applyCouponCode: (code: string) => Promise<void>
198
+ removeCouponCode: (code: string) => Promise<void>
199
+ clearError: () => void
200
+ }
201
+ ```
202
+
203
+ ### React Native Usage
204
+
205
+ ```tsx
206
+ import { View, Text, TouchableOpacity, TextInput } from 'react-native'
207
+ ;<CouponCode.Root>
208
+ {(context) => (
209
+ <View>
210
+ {context.isOpen ? (
211
+ <View>
212
+ <CouponCode.Input asChild>
213
+ <TextInput placeholder="Enter coupon code" />
214
+ </CouponCode.Input>
215
+ <CouponCode.ApplyButton asChild>
216
+ <TouchableOpacity>
217
+ <Text>Apply</Text>
218
+ </TouchableOpacity>
219
+ </CouponCode.ApplyButton>
220
+ </View>
221
+ ) : (
222
+ <CouponCode.ToggleButton asChild>
223
+ <TouchableOpacity>
224
+ <Text>Add Coupon Code</Text>
225
+ </TouchableOpacity>
226
+ </CouponCode.ToggleButton>
227
+ )}
228
+
229
+ <CouponCode.Error asChild>
230
+ <View>
231
+ <Text>Invalid coupon code</Text>
232
+ </View>
233
+ </CouponCode.Error>
234
+ </View>
235
+ )}
236
+ </CouponCode.Root>
237
+ ```
238
+
239
+ ## Dependencies
240
+
241
+ - `@haus-storefront-react/core`: Core SDK and platform detection
242
+ - `@haus-storefront-react/common-utils`: Platform utilities and context creation
243
+ - `@haus-storefront-react/shared-types`: TypeScript type definitions
@@ -0,0 +1,2 @@
1
+ "use strict";const P=require("./index-0w2MTo8y.js");function z(w,d){for(var b=0;b<d.length;b++){const y=d[b];if(typeof y!="string"&&!Array.isArray(y)){for(const l in y)if(l!=="default"&&!(l in w)){const p=Object.getOwnPropertyDescriptor(y,l);p&&Object.defineProperty(w,l,p.get?p:{enumerable:!0,get:()=>y[l]})}}}return Object.freeze(Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}))}var A={exports:{}},U;function $(){return U||(U=1,function(w,d){var b=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof P.commonjsGlobal<"u"&&P.commonjsGlobal,y=function(){function p(){this.fetch=!1,this.DOMException=b.DOMException}return p.prototype=b,new p}();(function(p){(function(u){var a=typeof p<"u"&&p||typeof self<"u"&&self||typeof a<"u"&&a,f={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function S(e){return e&&DataView.prototype.isPrototypeOf(e)}if(f.arrayBuffer)var F=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],q=ArrayBuffer.isView||function(e){return e&&F.indexOf(Object.prototype.toString.call(e))>-1};function v(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function E(e){return typeof e!="string"&&(e=String(e)),e}function T(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return f.iterable&&(t[Symbol.iterator]=function(){return t}),t}function s(e){this.map={},e instanceof s?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}s.prototype.append=function(e,t){e=v(e),t=E(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},s.prototype.delete=function(e){delete this.map[v(e)]},s.prototype.get=function(e){return e=v(e),this.has(e)?this.map[e]:null},s.prototype.has=function(e){return this.map.hasOwnProperty(v(e))},s.prototype.set=function(e,t){this.map[v(e)]=E(t)},s.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},s.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),T(e)},s.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),T(e)},s.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),T(e)},f.iterable&&(s.prototype[Symbol.iterator]=s.prototype.entries);function B(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function D(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function I(e){var t=new FileReader,r=D(t);return t.readAsArrayBuffer(e),r}function M(e){var t=new FileReader,r=D(t);return t.readAsText(e),r}function H(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function x(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function R(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:f.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:f.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():f.arrayBuffer&&f.blob&&S(e)?(this._bodyArrayBuffer=x(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||q(e))?this._bodyArrayBuffer=x(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=B(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(I)}),this.text=function(){var e=B(this);if(e)return e;if(this._bodyBlob)return M(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(H(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function C(e){var t=e.toUpperCase();return L.indexOf(t)>-1?t:e}function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new s(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new s(t.headers)),this.method=C(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})};function k(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),i=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(o))}}),t}function N(e){var t=new s,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
2
+ `)===0?n.substr(1,n.length):n}).forEach(function(n){var i=n.split(":"),o=i.shift().trim();if(o){var _=i.join(":").trim();t.append(o,_)}}),t}R.call(m.prototype);function c(e,t){if(!(this instanceof c))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new s(t.headers),this.url=t.url||"",this._initBody(e)}R.call(c.prototype),c.prototype.clone=function(){return new c(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new s(this.headers),url:this.url})},c.error=function(){var e=new c(null,{status:0,statusText:""});return e.type="error",e};var G=[301,302,303,307,308];c.redirect=function(e,t){if(G.indexOf(t)===-1)throw new RangeError("Invalid status code");return new c(null,{status:t,headers:{location:e}})},u.DOMException=a.DOMException;try{new u.DOMException}catch{u.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function O(e,t){return new Promise(function(r,n){var i=new m(e,t);if(i.signal&&i.signal.aborted)return n(new u.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function _(){o.abort()}o.onload=function(){var h={status:o.status,statusText:o.statusText,headers:N(o.getAllResponseHeaders()||"")};h.url="responseURL"in o?o.responseURL:h.headers.get("X-Request-URL");var g="response"in o?o.response:o.responseText;setTimeout(function(){r(new c(g,h))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.onabort=function(){setTimeout(function(){n(new u.DOMException("Aborted","AbortError"))},0)};function V(h){try{return h===""&&a.location.href?a.location.href:h}catch{return h}}o.open(i.method,V(i.url),!0),i.credentials==="include"?o.withCredentials=!0:i.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(f.blob?o.responseType="blob":f.arrayBuffer&&i.headers.get("Content-Type")&&i.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof s)?Object.getOwnPropertyNames(t.headers).forEach(function(h){o.setRequestHeader(h,E(t.headers[h]))}):i.headers.forEach(function(h,g){o.setRequestHeader(g,h)}),i.signal&&(i.signal.addEventListener("abort",_),o.onreadystatechange=function(){o.readyState===4&&i.signal.removeEventListener("abort",_)}),o.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}return O.polyfill=!0,a.fetch||(a.fetch=O,a.Headers=s,a.Request=m,a.Response=c),u.Headers=s,u.Request=m,u.Response=c,u.fetch=O,u})({})})(y),y.fetch.ponyfill=!0,delete y.fetch.polyfill;var l=b.fetch?b:y;d=l.fetch,d.default=l.fetch,d.fetch=l.fetch,d.Headers=l.Headers,d.Request=l.Request,d.Response=l.Response,w.exports=d}(A,A.exports)),A.exports}var j=$();const X=P.getDefaultExportFromCjs(j),J=z({__proto__:null,default:X},[j]);exports.browserPonyfill=J;
@@ -0,0 +1,341 @@
1
+ import { c as R, g as z } from "./index-CJQ4SQIa.mjs";
2
+ function $(w, d) {
3
+ for (var b = 0; b < d.length; b++) {
4
+ const y = d[b];
5
+ if (typeof y != "string" && !Array.isArray(y)) {
6
+ for (const h in y)
7
+ if (h !== "default" && !(h in w)) {
8
+ const p = Object.getOwnPropertyDescriptor(y, h);
9
+ p && Object.defineProperty(w, h, p.get ? p : {
10
+ enumerable: !0,
11
+ get: () => y[h]
12
+ });
13
+ }
14
+ }
15
+ }
16
+ return Object.freeze(Object.defineProperty(w, Symbol.toStringTag, { value: "Module" }));
17
+ }
18
+ var A = { exports: {} }, U;
19
+ function X() {
20
+ return U || (U = 1, function(w, d) {
21
+ var b = typeof globalThis < "u" && globalThis || typeof self < "u" && self || typeof R < "u" && R, y = function() {
22
+ function p() {
23
+ this.fetch = !1, this.DOMException = b.DOMException;
24
+ }
25
+ return p.prototype = b, new p();
26
+ }();
27
+ (function(p) {
28
+ (function(u) {
29
+ var a = typeof p < "u" && p || typeof self < "u" && self || typeof a < "u" && a, f = {
30
+ searchParams: "URLSearchParams" in a,
31
+ iterable: "Symbol" in a && "iterator" in Symbol,
32
+ blob: "FileReader" in a && "Blob" in a && function() {
33
+ try {
34
+ return new Blob(), !0;
35
+ } catch {
36
+ return !1;
37
+ }
38
+ }(),
39
+ formData: "FormData" in a,
40
+ arrayBuffer: "ArrayBuffer" in a
41
+ };
42
+ function S(e) {
43
+ return e && DataView.prototype.isPrototypeOf(e);
44
+ }
45
+ if (f.arrayBuffer)
46
+ var F = [
47
+ "[object Int8Array]",
48
+ "[object Uint8Array]",
49
+ "[object Uint8ClampedArray]",
50
+ "[object Int16Array]",
51
+ "[object Uint16Array]",
52
+ "[object Int32Array]",
53
+ "[object Uint32Array]",
54
+ "[object Float32Array]",
55
+ "[object Float64Array]"
56
+ ], I = ArrayBuffer.isView || function(e) {
57
+ return e && F.indexOf(Object.prototype.toString.call(e)) > -1;
58
+ };
59
+ function v(e) {
60
+ if (typeof e != "string" && (e = String(e)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e) || e === "")
61
+ throw new TypeError('Invalid character in header field name: "' + e + '"');
62
+ return e.toLowerCase();
63
+ }
64
+ function E(e) {
65
+ return typeof e != "string" && (e = String(e)), e;
66
+ }
67
+ function T(e) {
68
+ var t = {
69
+ next: function() {
70
+ var r = e.shift();
71
+ return { done: r === void 0, value: r };
72
+ }
73
+ };
74
+ return f.iterable && (t[Symbol.iterator] = function() {
75
+ return t;
76
+ }), t;
77
+ }
78
+ function s(e) {
79
+ this.map = {}, e instanceof s ? e.forEach(function(t, r) {
80
+ this.append(r, t);
81
+ }, this) : Array.isArray(e) ? e.forEach(function(t) {
82
+ this.append(t[0], t[1]);
83
+ }, this) : e && Object.getOwnPropertyNames(e).forEach(function(t) {
84
+ this.append(t, e[t]);
85
+ }, this);
86
+ }
87
+ s.prototype.append = function(e, t) {
88
+ e = v(e), t = E(t);
89
+ var r = this.map[e];
90
+ this.map[e] = r ? r + ", " + t : t;
91
+ }, s.prototype.delete = function(e) {
92
+ delete this.map[v(e)];
93
+ }, s.prototype.get = function(e) {
94
+ return e = v(e), this.has(e) ? this.map[e] : null;
95
+ }, s.prototype.has = function(e) {
96
+ return this.map.hasOwnProperty(v(e));
97
+ }, s.prototype.set = function(e, t) {
98
+ this.map[v(e)] = E(t);
99
+ }, s.prototype.forEach = function(e, t) {
100
+ for (var r in this.map)
101
+ this.map.hasOwnProperty(r) && e.call(t, this.map[r], r, this);
102
+ }, s.prototype.keys = function() {
103
+ var e = [];
104
+ return this.forEach(function(t, r) {
105
+ e.push(r);
106
+ }), T(e);
107
+ }, s.prototype.values = function() {
108
+ var e = [];
109
+ return this.forEach(function(t) {
110
+ e.push(t);
111
+ }), T(e);
112
+ }, s.prototype.entries = function() {
113
+ var e = [];
114
+ return this.forEach(function(t, r) {
115
+ e.push([r, t]);
116
+ }), T(e);
117
+ }, f.iterable && (s.prototype[Symbol.iterator] = s.prototype.entries);
118
+ function B(e) {
119
+ if (e.bodyUsed)
120
+ return Promise.reject(new TypeError("Already read"));
121
+ e.bodyUsed = !0;
122
+ }
123
+ function P(e) {
124
+ return new Promise(function(t, r) {
125
+ e.onload = function() {
126
+ t(e.result);
127
+ }, e.onerror = function() {
128
+ r(e.error);
129
+ };
130
+ });
131
+ }
132
+ function M(e) {
133
+ var t = new FileReader(), r = P(t);
134
+ return t.readAsArrayBuffer(e), r;
135
+ }
136
+ function q(e) {
137
+ var t = new FileReader(), r = P(t);
138
+ return t.readAsText(e), r;
139
+ }
140
+ function H(e) {
141
+ for (var t = new Uint8Array(e), r = new Array(t.length), n = 0; n < t.length; n++)
142
+ r[n] = String.fromCharCode(t[n]);
143
+ return r.join("");
144
+ }
145
+ function D(e) {
146
+ if (e.slice)
147
+ return e.slice(0);
148
+ var t = new Uint8Array(e.byteLength);
149
+ return t.set(new Uint8Array(e)), t.buffer;
150
+ }
151
+ function x() {
152
+ return this.bodyUsed = !1, this._initBody = function(e) {
153
+ this.bodyUsed = this.bodyUsed, this._bodyInit = e, e ? typeof e == "string" ? this._bodyText = e : f.blob && Blob.prototype.isPrototypeOf(e) ? this._bodyBlob = e : f.formData && FormData.prototype.isPrototypeOf(e) ? this._bodyFormData = e : f.searchParams && URLSearchParams.prototype.isPrototypeOf(e) ? this._bodyText = e.toString() : f.arrayBuffer && f.blob && S(e) ? (this._bodyArrayBuffer = D(e.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : f.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(e) || I(e)) ? this._bodyArrayBuffer = D(e) : this._bodyText = e = Object.prototype.toString.call(e) : this._bodyText = "", this.headers.get("content-type") || (typeof e == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : f.searchParams && URLSearchParams.prototype.isPrototypeOf(e) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
154
+ }, f.blob && (this.blob = function() {
155
+ var e = B(this);
156
+ if (e)
157
+ return e;
158
+ if (this._bodyBlob)
159
+ return Promise.resolve(this._bodyBlob);
160
+ if (this._bodyArrayBuffer)
161
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]));
162
+ if (this._bodyFormData)
163
+ throw new Error("could not read FormData body as blob");
164
+ return Promise.resolve(new Blob([this._bodyText]));
165
+ }, this.arrayBuffer = function() {
166
+ if (this._bodyArrayBuffer) {
167
+ var e = B(this);
168
+ return e || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(
169
+ this._bodyArrayBuffer.buffer.slice(
170
+ this._bodyArrayBuffer.byteOffset,
171
+ this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
172
+ )
173
+ ) : Promise.resolve(this._bodyArrayBuffer));
174
+ } else
175
+ return this.blob().then(M);
176
+ }), this.text = function() {
177
+ var e = B(this);
178
+ if (e)
179
+ return e;
180
+ if (this._bodyBlob)
181
+ return q(this._bodyBlob);
182
+ if (this._bodyArrayBuffer)
183
+ return Promise.resolve(H(this._bodyArrayBuffer));
184
+ if (this._bodyFormData)
185
+ throw new Error("could not read FormData body as text");
186
+ return Promise.resolve(this._bodyText);
187
+ }, f.formData && (this.formData = function() {
188
+ return this.text().then(k);
189
+ }), this.json = function() {
190
+ return this.text().then(JSON.parse);
191
+ }, this;
192
+ }
193
+ var L = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
194
+ function C(e) {
195
+ var t = e.toUpperCase();
196
+ return L.indexOf(t) > -1 ? t : e;
197
+ }
198
+ function m(e, t) {
199
+ if (!(this instanceof m))
200
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
201
+ t = t || {};
202
+ var r = t.body;
203
+ if (e instanceof m) {
204
+ if (e.bodyUsed)
205
+ throw new TypeError("Already read");
206
+ this.url = e.url, this.credentials = e.credentials, t.headers || (this.headers = new s(e.headers)), this.method = e.method, this.mode = e.mode, this.signal = e.signal, !r && e._bodyInit != null && (r = e._bodyInit, e.bodyUsed = !0);
207
+ } else
208
+ this.url = String(e);
209
+ if (this.credentials = t.credentials || this.credentials || "same-origin", (t.headers || !this.headers) && (this.headers = new s(t.headers)), this.method = C(t.method || this.method || "GET"), this.mode = t.mode || this.mode || null, this.signal = t.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && r)
210
+ throw new TypeError("Body not allowed for GET or HEAD requests");
211
+ if (this._initBody(r), (this.method === "GET" || this.method === "HEAD") && (t.cache === "no-store" || t.cache === "no-cache")) {
212
+ var n = /([?&])_=[^&]*/;
213
+ if (n.test(this.url))
214
+ this.url = this.url.replace(n, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
215
+ else {
216
+ var i = /\?/;
217
+ this.url += (i.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
218
+ }
219
+ }
220
+ }
221
+ m.prototype.clone = function() {
222
+ return new m(this, { body: this._bodyInit });
223
+ };
224
+ function k(e) {
225
+ var t = new FormData();
226
+ return e.trim().split("&").forEach(function(r) {
227
+ if (r) {
228
+ var n = r.split("="), i = n.shift().replace(/\+/g, " "), o = n.join("=").replace(/\+/g, " ");
229
+ t.append(decodeURIComponent(i), decodeURIComponent(o));
230
+ }
231
+ }), t;
232
+ }
233
+ function N(e) {
234
+ var t = new s(), r = e.replace(/\r?\n[\t ]+/g, " ");
235
+ return r.split("\r").map(function(n) {
236
+ return n.indexOf(`
237
+ `) === 0 ? n.substr(1, n.length) : n;
238
+ }).forEach(function(n) {
239
+ var i = n.split(":"), o = i.shift().trim();
240
+ if (o) {
241
+ var _ = i.join(":").trim();
242
+ t.append(o, _);
243
+ }
244
+ }), t;
245
+ }
246
+ x.call(m.prototype);
247
+ function c(e, t) {
248
+ if (!(this instanceof c))
249
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
250
+ t || (t = {}), this.type = "default", this.status = t.status === void 0 ? 200 : t.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = t.statusText === void 0 ? "" : "" + t.statusText, this.headers = new s(t.headers), this.url = t.url || "", this._initBody(e);
251
+ }
252
+ x.call(c.prototype), c.prototype.clone = function() {
253
+ return new c(this._bodyInit, {
254
+ status: this.status,
255
+ statusText: this.statusText,
256
+ headers: new s(this.headers),
257
+ url: this.url
258
+ });
259
+ }, c.error = function() {
260
+ var e = new c(null, { status: 0, statusText: "" });
261
+ return e.type = "error", e;
262
+ };
263
+ var G = [301, 302, 303, 307, 308];
264
+ c.redirect = function(e, t) {
265
+ if (G.indexOf(t) === -1)
266
+ throw new RangeError("Invalid status code");
267
+ return new c(null, { status: t, headers: { location: e } });
268
+ }, u.DOMException = a.DOMException;
269
+ try {
270
+ new u.DOMException();
271
+ } catch {
272
+ u.DOMException = function(t, r) {
273
+ this.message = t, this.name = r;
274
+ var n = Error(t);
275
+ this.stack = n.stack;
276
+ }, u.DOMException.prototype = Object.create(Error.prototype), u.DOMException.prototype.constructor = u.DOMException;
277
+ }
278
+ function O(e, t) {
279
+ return new Promise(function(r, n) {
280
+ var i = new m(e, t);
281
+ if (i.signal && i.signal.aborted)
282
+ return n(new u.DOMException("Aborted", "AbortError"));
283
+ var o = new XMLHttpRequest();
284
+ function _() {
285
+ o.abort();
286
+ }
287
+ o.onload = function() {
288
+ var l = {
289
+ status: o.status,
290
+ statusText: o.statusText,
291
+ headers: N(o.getAllResponseHeaders() || "")
292
+ };
293
+ l.url = "responseURL" in o ? o.responseURL : l.headers.get("X-Request-URL");
294
+ var g = "response" in o ? o.response : o.responseText;
295
+ setTimeout(function() {
296
+ r(new c(g, l));
297
+ }, 0);
298
+ }, o.onerror = function() {
299
+ setTimeout(function() {
300
+ n(new TypeError("Network request failed"));
301
+ }, 0);
302
+ }, o.ontimeout = function() {
303
+ setTimeout(function() {
304
+ n(new TypeError("Network request failed"));
305
+ }, 0);
306
+ }, o.onabort = function() {
307
+ setTimeout(function() {
308
+ n(new u.DOMException("Aborted", "AbortError"));
309
+ }, 0);
310
+ };
311
+ function V(l) {
312
+ try {
313
+ return l === "" && a.location.href ? a.location.href : l;
314
+ } catch {
315
+ return l;
316
+ }
317
+ }
318
+ o.open(i.method, V(i.url), !0), i.credentials === "include" ? o.withCredentials = !0 : i.credentials === "omit" && (o.withCredentials = !1), "responseType" in o && (f.blob ? o.responseType = "blob" : f.arrayBuffer && i.headers.get("Content-Type") && i.headers.get("Content-Type").indexOf("application/octet-stream") !== -1 && (o.responseType = "arraybuffer")), t && typeof t.headers == "object" && !(t.headers instanceof s) ? Object.getOwnPropertyNames(t.headers).forEach(function(l) {
319
+ o.setRequestHeader(l, E(t.headers[l]));
320
+ }) : i.headers.forEach(function(l, g) {
321
+ o.setRequestHeader(g, l);
322
+ }), i.signal && (i.signal.addEventListener("abort", _), o.onreadystatechange = function() {
323
+ o.readyState === 4 && i.signal.removeEventListener("abort", _);
324
+ }), o.send(typeof i._bodyInit > "u" ? null : i._bodyInit);
325
+ });
326
+ }
327
+ return O.polyfill = !0, a.fetch || (a.fetch = O, a.Headers = s, a.Request = m, a.Response = c), u.Headers = s, u.Request = m, u.Response = c, u.fetch = O, u;
328
+ })({});
329
+ })(y), y.fetch.ponyfill = !0, delete y.fetch.polyfill;
330
+ var h = b.fetch ? b : y;
331
+ d = h.fetch, d.default = h.fetch, d.fetch = h.fetch, d.Headers = h.Headers, d.Request = h.Request, d.Response = h.Response, w.exports = d;
332
+ }(A, A.exports)), A.exports;
333
+ }
334
+ var j = X();
335
+ const J = /* @__PURE__ */ z(j), Q = /* @__PURE__ */ $({
336
+ __proto__: null,
337
+ default: J
338
+ }, [j]);
339
+ export {
340
+ Q as b
341
+ };