hapi-recaptcha-html 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -36
- package/demo/contactus-success.html +14 -0
- package/demo/enquiry-forms.js +9 -14
- package/demo/index.html +14 -102
- package/dist/hapi.min.js +3 -3
- package/index.js +0 -2
- package/package.json +2 -2
- package/src/hapi.js +11 -6
package/README.md
CHANGED
|
@@ -2,31 +2,50 @@
|
|
|
2
2
|
Wrapper of Alpine JS plugin for HAPI Form, works on Laravel API endpoint.
|
|
3
3
|
## CDN
|
|
4
4
|
```html
|
|
5
|
-
<script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js"></script>
|
|
6
|
-
```
|
|
5
|
+
<script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>
|
|
7
6
|
|
|
7
|
+
<script src="enquiry-forms.js" defer></script>
|
|
8
|
+
```
|
|
8
9
|
## Usage
|
|
9
10
|
```html
|
|
11
|
+
enquiry-forms.js file:
|
|
10
12
|
|
|
11
13
|
<script>
|
|
12
|
-
Hapi.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
Hapi.forms([
|
|
15
|
+
// form 01
|
|
16
|
+
{
|
|
17
|
+
name: 'form01',
|
|
18
|
+
endpoint: 'https://hapiform.sg/api/<hapiform-id-number-1>',
|
|
19
|
+
redirectTo: '/contactus-success.html',
|
|
20
|
+
captchaId: 'captcha-01'
|
|
21
|
+
|
|
22
|
+
},
|
|
23
|
+
// form 02
|
|
24
|
+
{
|
|
25
|
+
name: 'form02',
|
|
26
|
+
endpoint: 'https://hapiform.sg/api/<hapiform-id-number-2>',
|
|
27
|
+
redirectTo: '/contactus-success.html',
|
|
28
|
+
captchaId: 'captcha-02'
|
|
29
|
+
}
|
|
30
|
+
...
|
|
31
|
+
]
|
|
32
|
+
);
|
|
33
|
+
|
|
27
34
|
</script>
|
|
28
35
|
```
|
|
36
|
+
please note that you must use `$store.<form-name>.fileds.<field-name>` to bind inputs.
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
// in form01
|
|
40
|
+
<input id="form01-name" x-model="$store.form01.fields.name">
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
// in form02
|
|
44
|
+
<input id="form02-name" x-model="$store.form02.fields.name">
|
|
45
|
+
...
|
|
29
46
|
|
|
47
|
+
|
|
48
|
+
```
|
|
30
49
|
- name – The name of the instance, to be matched with `x-data="name"`.
|
|
31
50
|
- endpoint – The form endpoint URL generated from the backend.
|
|
32
51
|
- redirectTo – Location to be redirected after success. Eg: "/thank-you" or "https://example.com". (Optional)
|
|
@@ -39,25 +58,7 @@ Wrapper of Alpine JS plugin for HAPI Form, works on Laravel API endpoint.
|
|
|
39
58
|
- onFailed() – On failed event.
|
|
40
59
|
- errors.recaptchaError - to display captcha verification errors.
|
|
41
60
|
|
|
42
|
-
## Array data
|
|
43
|
-
```js
|
|
44
|
-
Hapi.form({
|
|
45
|
-
fields: {
|
|
46
|
-
colors; [] // Example an empty array of colors
|
|
47
|
-
},
|
|
48
|
-
name: "",
|
|
49
|
-
endpoint: "",
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
61
|
|
|
53
|
-
## Alpine.js data
|
|
54
|
-
Sometimes you might need to set data for Alpine.js, I got your back.
|
|
55
|
-
```js
|
|
56
|
-
Hapi.form({
|
|
57
|
-
...
|
|
58
|
-
open: false,
|
|
59
|
-
});
|
|
60
|
-
```
|
|
61
62
|
## Events
|
|
62
63
|
|
|
63
64
|
### Success Event
|
|
@@ -65,4 +66,10 @@ When submission is success, Hapi will emit `hapi:success` event.
|
|
|
65
66
|
|
|
66
67
|
|
|
67
68
|
### Error Event
|
|
68
|
-
When submission has error, Hapi will emit `hapi:error` event.
|
|
69
|
+
When submission has error, Hapi will emit `hapi:error` event.
|
|
70
|
+
|
|
71
|
+
### Example
|
|
72
|
+
|
|
73
|
+
[index.html](https://unpkg.com/hapi-recaptcha-html@latest/demo/index.html)
|
|
74
|
+
|
|
75
|
+
[enquiry-forms.js](https://unpkg.com/hapi-recaptcha-html@latest/demo/enquiry-forms.js)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Demo Thank You Page</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
|
|
9
|
+
<div style="text-align: center; margin-top: 100px;">
|
|
10
|
+
<h1>Thank you!</h1>
|
|
11
|
+
<a href="index.html">Go Back Home</a>
|
|
12
|
+
</div>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
package/demo/enquiry-forms.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
Hapi.forms([
|
|
2
2
|
// form 01
|
|
3
3
|
{
|
|
4
|
-
name: '
|
|
5
|
-
endpoint: 'https://hapiform.sg/api/
|
|
6
|
-
redirectTo: '
|
|
7
|
-
captchaId: 'captcha-01'
|
|
8
|
-
|
|
9
|
-
console.error(err);
|
|
10
|
-
}
|
|
4
|
+
name: 'form01',
|
|
5
|
+
endpoint: 'https://hapiform.sg/api/5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
6
|
+
redirectTo: 'contactus-success.html',
|
|
7
|
+
captchaId: 'captcha-01'
|
|
8
|
+
|
|
11
9
|
},
|
|
12
10
|
// form 02
|
|
13
11
|
{
|
|
14
|
-
name: '
|
|
15
|
-
endpoint: 'https://hapiform.sg/api/
|
|
16
|
-
redirectTo: '
|
|
17
|
-
captchaId: 'captcha-02'
|
|
18
|
-
onFailed(err) {
|
|
19
|
-
console.error(err);
|
|
20
|
-
}
|
|
12
|
+
name: 'form02',
|
|
13
|
+
endpoint: 'https://hapiform.sg/api/5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
14
|
+
redirectTo: 'contactus-success.html',
|
|
15
|
+
captchaId: 'captcha-02'
|
|
21
16
|
}
|
|
22
17
|
]
|
|
23
18
|
);
|
package/demo/index.html
CHANGED
|
@@ -31,59 +31,30 @@
|
|
|
31
31
|
|
|
32
32
|
<div class="d-lg-flex">
|
|
33
33
|
|
|
34
|
-
<form x-on:submit.prevent="submit" x-data="
|
|
34
|
+
<form x-on:submit.prevent="submit" x-data="form01">
|
|
35
|
+
|
|
35
36
|
<template x-if="errors">
|
|
36
37
|
<div x-html="JSON.stringify(errors)" class="text-danger"></div>
|
|
37
38
|
</template>
|
|
39
|
+
|
|
40
|
+
<div x-text='JSON.stringify($store.form01.fields,null,2)' class="text-success"></div>
|
|
38
41
|
<div>
|
|
39
42
|
<div class="mb-3">
|
|
40
43
|
<div class="form-field">
|
|
41
44
|
<label for="form01-name" class="form-label">Name</label>
|
|
42
|
-
<input type="text" id="form01-name" x-model="fields.name" placeholder="Name" class="form-control">
|
|
45
|
+
<input type="text" id="form01-name" x-model="$store.form01.fields.name" placeholder="Name" class="form-control">
|
|
46
|
+
|
|
43
47
|
</div>
|
|
44
48
|
<template x-if="errors && errors.name">
|
|
45
49
|
<div x-text="errors.name" class="text-danger"></div>
|
|
46
50
|
</template>
|
|
47
|
-
|
|
48
|
-
<div class="mb-3">
|
|
49
|
-
<div class="form-field">
|
|
50
|
-
<label for="form01-contact_number" class="form-label">Contact Number</label>
|
|
51
|
-
<input type="tel" id="form01-contact_number" x-model="fields.contact_number"
|
|
52
|
-
placeholder="Contact Number" class="form-control">
|
|
51
|
+
<div x-text="$store.form01.fields.name"></div>
|
|
53
52
|
|
|
54
|
-
</div>
|
|
55
|
-
<template x-if="errors && errors.contact_number">
|
|
56
|
-
<div x-text="errors.contact_number" class="text-danger"></div>
|
|
57
|
-
</template>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="mb-3">
|
|
60
|
-
<div class="form-field">
|
|
61
|
-
<label for="form01-email" class="form-label">Email</label>
|
|
62
|
-
<input type="email" id="form01-email" x-model="fields.email" placeholder="Email"
|
|
63
|
-
class="form-control">
|
|
64
|
-
</div>
|
|
65
|
-
<template x-if="errors && errors.email">
|
|
66
|
-
<div x-text="errors.email" class="text-danger"></div>
|
|
67
|
-
</template>
|
|
68
|
-
</div>
|
|
69
|
-
<div class="mb-3">
|
|
70
|
-
<div class="form-field">
|
|
71
|
-
<select class="form-select" id="form01-specialist" x-model="fields.specialist">
|
|
72
|
-
<option value="" selected>Preferred Specialist</option>
|
|
73
|
-
<option value="Dr Dennis Koh">Dr Dennis Koh</option>
|
|
74
|
-
<option value="Dr Sharon Koh">Dr Sharon Koh</option>
|
|
75
|
-
<option value="Dr Pauleon Tan">Dr Pauleon Tan</option>
|
|
76
|
-
<option value="No Preference">No Preference</option>
|
|
77
|
-
</select>
|
|
78
|
-
</div>
|
|
79
|
-
<template x-if="errors && errors.specialist">
|
|
80
|
-
<div x-text="errors.specialist" class="text-danger"></div>
|
|
81
|
-
</template>
|
|
82
53
|
</div>
|
|
83
54
|
<div class="mb-3">
|
|
84
55
|
<div class="form-field">
|
|
85
56
|
<label for="form01-message" class="form-label">Message</label>
|
|
86
|
-
<textarea id="form01-message" x-model="fields.message" rows="4" placeholder="Message"
|
|
57
|
+
<textarea id="form01-message" x-model="$store.form01.fields.message" rows="4" placeholder="Message"
|
|
87
58
|
class="form-control form-textarea"></textarea>
|
|
88
59
|
</div>
|
|
89
60
|
<template x-if="errors && errors.message">
|
|
@@ -104,61 +75,29 @@
|
|
|
104
75
|
</div>
|
|
105
76
|
</form>
|
|
106
77
|
|
|
107
|
-
|
|
78
|
+
|
|
79
|
+
<form x-on:submit.prevent="submit" x-data="form02">
|
|
108
80
|
|
|
109
81
|
<template x-if="errors">
|
|
110
82
|
<div x-text="JSON.stringify(errors)" class="text-danger"></div>
|
|
111
83
|
</template>
|
|
112
84
|
|
|
85
|
+
<div x-text='JSON.stringify($store.form02.fields,null,2)' class="text-success"></div>
|
|
113
86
|
<div>
|
|
114
87
|
<div class="mb-3">
|
|
115
88
|
<div class="form-field">
|
|
116
89
|
<label for="form02-name" class="form-label">Name</label>
|
|
117
|
-
<input type="text" id="form02-name" x-model="fields.name" placeholder="Name" class="form-control">
|
|
90
|
+
<input type="text" id="form02-name" x-model="$store.form02.fields.name" placeholder="Name" class="form-control">
|
|
118
91
|
</div>
|
|
119
92
|
<template x-if="errors && errors.name">
|
|
120
93
|
<div x-text="errors.name" class="text-danger"></div>
|
|
121
94
|
</template>
|
|
122
|
-
|
|
123
|
-
<div class="mb-3">
|
|
124
|
-
<div class="form-field">
|
|
125
|
-
<label for="form02-contact_number" class="form-label">Contact Number</label>
|
|
126
|
-
<input type="tel" id="form02-contact_number" x-model="fields.contact_number"
|
|
127
|
-
placeholder="Contact Number" class="form-control">
|
|
128
|
-
|
|
129
|
-
</div>
|
|
130
|
-
<template x-if="errors && errors.contact_number">
|
|
131
|
-
<div x-text="errors.contact_number" class="text-danger"></div>
|
|
132
|
-
</template>
|
|
133
|
-
</div>
|
|
134
|
-
<div class="mb-3">
|
|
135
|
-
<div class="form-field">
|
|
136
|
-
<label for="form02-email" class="form-label">Email</label>
|
|
137
|
-
<input type="email" id="form02-email" x-model="fields.email" placeholder="Email"
|
|
138
|
-
class="form-control">
|
|
139
|
-
</div>
|
|
140
|
-
<template x-if="errors && errors.email">
|
|
141
|
-
<div x-text="errors.email" class="text-danger"></div>
|
|
142
|
-
</template>
|
|
143
|
-
</div>
|
|
144
|
-
<div class="mb-3">
|
|
145
|
-
<div class="form-field">
|
|
146
|
-
<select class="form-select" id="form02-specialist" x-model="fields.specialist">
|
|
147
|
-
<option value="" selected>Preferred Specialist</option>
|
|
148
|
-
<option value="Dr Dennis Koh">Dr Dennis Koh</option>
|
|
149
|
-
<option value="Dr Sharon Koh">Dr Sharon Koh</option>
|
|
150
|
-
<option value="Dr Pauleon Tan">Dr Pauleon Tan</option>
|
|
151
|
-
<option value="No Preference">No Preference</option>
|
|
152
|
-
</select>
|
|
153
|
-
</div>
|
|
154
|
-
<template x-if="errors && errors.specialist">
|
|
155
|
-
<div x-text="errors.specialist" class="text-danger"></div>
|
|
156
|
-
</template>
|
|
95
|
+
<div x-text="$store.form02.fields.name"></div>
|
|
157
96
|
</div>
|
|
158
97
|
<div class="mb-3">
|
|
159
98
|
<div class="form-field">
|
|
160
99
|
<label for="form02-message" class="form-label">Message</label>
|
|
161
|
-
<textarea id="form02-message" x-model="fields.message" rows="4" placeholder="Message"
|
|
100
|
+
<textarea id="form02-message" x-model="$store.form02.fields.message" rows="4" placeholder="Message"
|
|
162
101
|
class="form-control form-textarea"></textarea>
|
|
163
102
|
</div>
|
|
164
103
|
<template x-if="errors && errors.message">
|
|
@@ -180,33 +119,6 @@
|
|
|
180
119
|
</form>
|
|
181
120
|
|
|
182
121
|
</div>
|
|
183
|
-
<!-- <script>-->
|
|
184
|
-
<!-- const sharedData = {-->
|
|
185
|
-
<!-- fields: {},-->
|
|
186
|
-
<!-- counter: 0,-->
|
|
187
|
-
<!-- increment() {-->
|
|
188
|
-
<!-- this.counter++;-->
|
|
189
|
-
<!-- },-->
|
|
190
|
-
<!-- decrement() {-->
|
|
191
|
-
<!-- this.counter--;-->
|
|
192
|
-
<!-- }-->
|
|
193
|
-
<!-- };-->
|
|
194
|
-
<!-- </script>-->
|
|
195
|
-
|
|
196
|
-
<!-- <div x-data="(() => ({ ...sharedData }))()">-->
|
|
197
|
-
<!-- <input type="text" x-model="fields.name">-->
|
|
198
|
-
<!-- <p>Value in first instance: <span x-text="fields.name"></span></p>-->
|
|
199
|
-
<!-- <br>-->
|
|
200
|
-
<!-- <input type="text" x-model="fields.email">-->
|
|
201
|
-
<!-- <p>Value in first instance: <span x-text="fields.email"></span></p>-->
|
|
202
|
-
<!-- </div>-->
|
|
203
|
-
|
|
204
|
-
<!-- <div x-data="{ data: { value: 'Second instance' } }">-->
|
|
205
|
-
<!-- <input type="text" x-model="data.value">-->
|
|
206
|
-
<!-- <p>Value in second instance: <span x-text="data.value"></span></p>-->
|
|
207
|
-
<!-- </div>-->
|
|
208
|
-
|
|
209
|
-
|
|
210
122
|
<!-- <script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>-->
|
|
211
123
|
|
|
212
124
|
<script src="../dist/hapi.min.js" defer></script>
|
package/dist/hapi.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(()=>{function B(e,t){return function(){return e.apply(t,arguments)}}var{toString:ft}=Object.prototype,{getPrototypeOf:ue}=Object,K=(e=>t=>{let r=ft.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),R=e=>(e=e.toLowerCase(),t=>K(t)===e),G=e=>t=>typeof t===e,{isArray:P}=Array,j=G("undefined");function dt(e){return e!==null&&!j(e)&&e.constructor!==null&&!j(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Fe=R("ArrayBuffer");function pt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Fe(e.buffer),t}var mt=G("string"),x=G("function"),Pe=G("number"),X=e=>e!==null&&typeof e=="object",ht=e=>e===!0||e===!1,W=e=>{if(K(e)!=="object")return!1;let t=ue(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},yt=R("Date"),Et=R("File"),wt=R("Blob"),bt=R("FileList"),St=e=>X(e)&&x(e.pipe),xt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=K(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},At=R("URLSearchParams"),Rt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function k(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),P(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{let i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,c;for(n=0;n<s;n++)c=i[n],t.call(null,e[c],c,e)}}function Ue(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}var _e=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),De=e=>!j(e)&&e!==_e;function le(){let{caseless:e}=De(this)&&this||{},t={},r=(n,o)=>{let i=e&&Ue(t,o)||o;W(t[i])&&W(n)?t[i]=le(t[i],n):W(n)?t[i]=le({},n):P(n)?t[i]=n.slice():t[i]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&k(arguments[n],r);return t}var Ot=(e,t,r,{allOwnKeys:n}={})=>(k(t,(o,i)=>{r&&x(o)?e[i]=B(o,r):e[i]=o},{allOwnKeys:n}),e),gt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Tt=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Ct=(e,t,r,n)=>{let o,i,s,c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!c[s]&&(t[s]=e[s],c[s]=!0);e=r!==!1&&ue(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Nt=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},Ft=e=>{if(!e)return null;if(P(e))return e;let t=e.length;if(!Pe(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Pt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ue(Uint8Array)),Ut=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),o;for(;(o=n.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},_t=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Dt=R("HTMLFormElement"),Lt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Ce=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Bt=R("RegExp"),Le=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};k(r,(o,i)=>{t(o,i,e)!==!1&&(n[i]=o)}),Object.defineProperties(e,n)},jt=e=>{Le(e,(t,r)=>{if(x(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(x(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},kt=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return P(e)?n(e):n(String(e).split(t)),r},It=()=>{},Ht=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ce="abcdefghijklmnopqrstuvwxyz",Ne="0123456789",Be={DIGIT:Ne,ALPHA:ce,ALPHA_DIGIT:ce+ce.toUpperCase()+Ne},qt=(e=16,t=Be.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function Mt(e){return!!(e&&x(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var Jt=e=>{let t=new Array(10),r=(n,o)=>{if(X(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let i=P(n)?[]:{};return k(n,(s,c)=>{let f=r(s,o+1);!j(f)&&(i[c]=f)}),t[o]=void 0,i}}return n};return r(e,0)},zt=R("AsyncFunction"),vt=e=>e&&(X(e)||x(e))&&x(e.then)&&x(e.catch),a={isArray:P,isArrayBuffer:Fe,isBuffer:dt,isFormData:xt,isArrayBufferView:pt,isString:mt,isNumber:Pe,isBoolean:ht,isObject:X,isPlainObject:W,isUndefined:j,isDate:yt,isFile:Et,isBlob:wt,isRegExp:Bt,isFunction:x,isStream:St,isURLSearchParams:At,isTypedArray:Pt,isFileList:bt,forEach:k,merge:le,extend:Ot,trim:Rt,stripBOM:gt,inherits:Tt,toFlatObject:Ct,kindOf:K,kindOfTest:R,endsWith:Nt,toArray:Ft,forEachEntry:Ut,matchAll:_t,isHTMLForm:Dt,hasOwnProperty:Ce,hasOwnProp:Ce,reduceDescriptors:Le,freezeMethods:jt,toObjectSet:kt,toCamelCase:Lt,noop:It,toFiniteNumber:Ht,findKey:Ue,global:_e,isContextDefined:De,ALPHABET:Be,generateString:qt,isSpecCompliantForm:Mt,toJSONObject:Jt,isAsyncFn:zt,isThenable:vt};function U(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}a.inherits(U,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var je=U.prototype,ke={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ke[e]={value:e}});Object.defineProperties(U,ke);Object.defineProperty(je,"isAxiosError",{value:!0});U.from=(e,t,r,n,o,i)=>{let s=Object.create(je);return a.toFlatObject(e,s,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),U.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var m=U;var Y=null;function fe(e){return a.isPlainObject(e)||a.isArray(e)}function He(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ie(e,t,r){return e?e.concat(t).map(function(o,i){return o=He(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function Vt(e){return a.isArray(e)&&!e.some(fe)}var $t=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Wt(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(Y||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,O){return!a.isUndefined(O[h])});let n=r.metaTokens,o=r.visitor||u,i=r.dots,s=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function l(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(!f&&a.isBlob(d))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?f&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function u(d,h,O){let A=d;if(d&&!O&&typeof d=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&Vt(d)||(a.isFileList(d)||a.endsWith(h,"[]"))&&(A=a.toArray(d)))return h=He(h),A.forEach(function($,ut){!(a.isUndefined($)||$===null)&&t.append(s===!0?Ie([h],ut,i):s===null?h:h+"[]",l($))}),!1}return fe(d)?!0:(t.append(Ie(O,h,i),l(d)),!1)}let p=[],w=Object.assign($t,{defaultVisitor:u,convertValue:l,isVisitable:fe});function y(d,h){if(!a.isUndefined(d)){if(p.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(d),a.forEach(d,function(A,F){(!(a.isUndefined(A)||A===null)&&o.call(t,A,a.isString(F)?F.trim():F,h,w))===!0&&y(A,h?h.concat(F):[F])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}var T=Wt;function qe(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Me(e,t){this._pairs=[],e&&T(e,this,t)}var Je=Me.prototype;Je.append=function(t,r){this._pairs.push([t,r])};Je.toString=function(t){let r=t?function(n){return t.call(this,n,qe)}:qe;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Q=Me;function Kt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function I(e,t,r){if(!t)return e;let n=r&&r.encode||Kt,o=r&&r.serialize,i;if(o?i=o(t,r):i=a.isURLSearchParams(t)?t.toString():new Q(t,r).toString(n),i){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}var de=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(n){n!==null&&t(n)})}},pe=de;var Z={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ze=typeof URLSearchParams<"u"?URLSearchParams:Q;var ve=typeof FormData<"u"?FormData:null;var Ve=typeof Blob<"u"?Blob:null;var Gt=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Xt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),b={isBrowser:!0,classes:{URLSearchParams:ze,FormData:ve,Blob:Ve},isStandardBrowserEnv:Gt,isStandardBrowserWebWorkerEnv:Xt,protocols:["http","https","file","blob","url","data"]};function me(e,t){return T(e,new b.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,i){return b.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Yt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Qt(e){let t={},r=Object.keys(e),n,o=r.length,i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function Zt(e){function t(r,n,o,i){let s=r[i++],c=Number.isFinite(+s),f=i>=r.length;return s=!s&&a.isArray(o)?o.length:s,f?(a.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!c):((!o[s]||!a.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&a.isArray(o[s])&&(o[s]=Qt(o[s])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(Yt(n),o,r,0)}),r}return null}var ee=Zt;var er={"Content-Type":void 0};function tr(e,t,r){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var te={transitional:Z,adapter:["xhr","http"],transformRequest:[function(t,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return o&&o?JSON.stringify(ee(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return me(t,this.formSerializer).toString();if((c=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return T(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),tr(t)):t}],transformResponse:[function(t){let r=this.transitional||te.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&a.isString(t)&&(n&&!this.responseType||o)){let s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(c){if(s)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){te.headers[t]={}});a.forEach(["post","put","patch"],function(t){te.headers[t]=a.merge(er)});var _=te;var rr=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$e=e=>{let t={},r,n,o;return e&&e.split(`
|
|
2
|
-
`).forEach(function(
|
|
3
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[We]=this[We]={accessors:{}}).accessors,o=this.prototype;function i(s){let c=H(s);n[c]||(ir(o,s),n[c]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(D.prototype);a.freezeMethods(D);var S=D;function q(e,t){let r=this||_,n=t||r,o=S.from(n.headers),i=n.data;return a.forEach(e,function(c){i=c.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function M(e){return!!(e&&e.__CANCEL__)}function Ke(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(Ke,m,{__CANCEL__:!0});var C=Ke;function ye(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var Ge=b.isStandardBrowserEnv?function(){return{write:function(r,n,o,i,s,c){let f=[];f.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&f.push("expires="+new Date(o).toGMTString()),a.isString(i)&&f.push("path="+i),a.isString(s)&&f.push("domain="+s),c===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Ee(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function we(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function J(e,t){return e&&!Ee(t)?we(e,t):t}var Xe=b.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){let s=i;return t&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(s){let c=a.isString(s)?o(s):s;return c.protocol===n.protocol&&c.host===n.host}}():function(){return function(){return!0}}();function be(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function ar(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(f){let l=Date.now(),u=n[i];s||(s=l),r[o]=f,n[o]=l;let p=i,w=0;for(;p!==o;)w+=r[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),l-s<t)return;let y=u&&l-u;return y?Math.round(w*1e3/y):void 0}}var Ye=ar;function Qe(e,t){let r=0,n=Ye(50,250);return o=>{let i=o.loaded,s=o.lengthComputable?o.total:void 0,c=i-r,f=n(c),l=i<=s;r=i;let u={loaded:i,total:s,progress:s?i/s:void 0,bytes:c,rate:f||void 0,estimated:f&&s&&l?(s-i)/f:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}var cr=typeof XMLHttpRequest<"u",Ze=cr&&function(e){return new Promise(function(r,n){let o=e.data,i=S.from(e.headers).normalize(),s=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}a.isFormData(o)&&(b.isStandardBrowserEnv||b.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let l=new XMLHttpRequest;if(e.auth){let y=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(y+":"+d))}let u=J(e.baseURL,e.url);l.open(e.method.toUpperCase(),I(u,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function p(){if(!l)return;let y=S.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),h={data:!s||s==="text"||s==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:y,config:e,request:l};ye(function(A){r(A),f()},function(A){n(A),f()},h),l=null}if("onloadend"in l?l.onloadend=p:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(p)},l.onabort=function(){l&&(n(new m("Request aborted",m.ECONNABORTED,e,l)),l=null)},l.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,l)),l=null},l.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||Z;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),n(new m(d,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,l)),l=null},b.isStandardBrowserEnv){let y=(e.withCredentials||Xe(u))&&e.xsrfCookieName&&Ge.read(e.xsrfCookieName);y&&i.set(e.xsrfHeaderName,y)}o===void 0&&i.setContentType(null),"setRequestHeader"in l&&a.forEach(i.toJSON(),function(d,h){l.setRequestHeader(h,d)}),a.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),s&&s!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",Qe(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",Qe(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=y=>{l&&(n(!y||y.type?new C(null,e,l):y),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));let w=be(u);if(w&&b.protocols.indexOf(w)===-1){n(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}l.send(o||null)})};var ne={http:Y,xhr:Ze};a.forEach(ne,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var et={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ne[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ne,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ne};function Se(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new C(null,e)}function oe(e){return Se(e),e.headers=S.from(e.headers),e.data=q.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et.getAdapter(e.adapter||_.adapter)(e).then(function(n){return Se(e),n.data=q.call(e,e.transformResponse,n),n.headers=S.from(n.headers),n},function(n){return M(n)||(Se(e),n&&n.response&&(n.response.data=q.call(e,e.transformResponse,n.response),n.response.headers=S.from(n.response.headers))),Promise.reject(n)})}var tt=e=>e instanceof S?e.toJSON():e;function g(e,t){t=t||{};let r={};function n(l,u,p){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:p},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function o(l,u,p){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l,p)}else return n(l,u,p)}function i(l,u){if(!a.isUndefined(u))return n(void 0,u)}function s(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function c(l,u,p){if(p in t)return n(l,u);if(p in e)return n(void 0,l)}let f={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:c,headers:(l,u)=>o(tt(l),tt(u),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){let p=f[u]||o,w=p(e[u],t[u],u);a.isUndefined(w)&&p!==c||(r[u]=w)}),r}var se="1.4.0";var xe={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{xe[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var rt={};xe.transitional=function(t,r,n){function o(i,s){return"[Axios v"+se+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,c)=>{if(t===!1)throw new m(o(s," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!rt[s]&&(rt[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,c):!0}};function lr(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let i=n[o],s=t[i];if(s){let c=e[i],f=c===void 0||s(c,i,e);if(f!==!0)throw new m("option "+i+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}var ie={assertOptions:lr,validators:xe};var N=ie.validators,L=class{constructor(t){this.defaults=t,this.interceptors={request:new pe,response:new pe}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=g(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&ie.assertOptions(n,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ie.assertOptions(o,{encode:N.function,serialize:N.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s;s=i&&a.merge(i.common,i[r.method]),s&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),r.headers=S.concat(s,i);let c=[],f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(f=f&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});let l=[];this.interceptors.response.forEach(function(h){l.push(h.fulfilled,h.rejected)});let u,p=0,w;if(!f){let d=[oe.bind(this),void 0];for(d.unshift.apply(d,c),d.push.apply(d,l),w=d.length,u=Promise.resolve(r);p<w;)u=u.then(d[p++],d[p++]);return u}w=c.length;let y=r;for(p=0;p<w;){let d=c[p++],h=c[p++];try{y=d(y)}catch(O){h.call(this,O);break}}try{u=oe.call(this,y)}catch(d){return Promise.reject(d)}for(p=0,w=l.length;p<w;)u=u.then(l[p++],l[p++]);return u}getUri(t){t=g(this.defaults,t);let r=J(t.baseURL,t.url);return I(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){L.prototype[t]=function(r,n){return this.request(g(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,c){return this.request(g(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}L.prototype[t]=r(),L.prototype[t+"Form"]=r(!0)});var z=L;var v=class{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(c=>{n.subscribe(c),i=c}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,c){n.reason||(n.reason=new C(i,s,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new v(function(o){t=o}),cancel:t}}},nt=v;function Ae(e){return function(r){return e.apply(null,r)}}function Re(e){return a.isObject(e)&&e.isAxiosError===!0}var Oe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Oe).forEach(([e,t])=>{Oe[t]=e});var ot=Oe;function st(e){let t=new z(e),r=B(z.prototype.request,t);return a.extend(r,z.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return st(g(e,o))},r}var E=st(_);E.Axios=z;E.CanceledError=C;E.CancelToken=nt;E.isCancel=M;E.VERSION=se;E.toFormData=T;E.AxiosError=m;E.Cancel=E.CanceledError;E.all=function(t){return Promise.all(t)};E.spread=Ae;E.isAxiosError=Re;E.mergeConfig=g;E.AxiosHeaders=S;E.formToJSON=e=>ee(a.isHTMLForm(e)?new FormData(e):e);E.HttpStatusCode=ot;E.default=E;var ae=E;var{Axios:Xo,AxiosError:Yo,CanceledError:Qo,isCancel:Zo,CancelToken:es,VERSION:ts,all:rs,Cancel:ns,isAxiosError:os,spread:ss,toFormData:is,AxiosHeaders:as,HttpStatusCode:cs,formToJSON:ls,mergeConfig:us}=ae;var V=class{constructor({theme:t="light",render_element_or_id:r="recaptcha-el"}){this.gl_api_url="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit",this.captcha_sitekey="6LeRUzsjAAAAANUHNEY6VkUXmMo_wlrDK5SUoFUV",this.verify_url="https://internalapi.activamedia.com.sg/v1/recaptcha/verify",this.theme=t,this.render_element_or_id=r,this.defineOnloadCallBack(),this.loadJsFile()}defineOnloadCallBack(){window.onloadCallback=()=>{}}loadJsFile(){if(document.querySelectorAll(`script[src="${this.gl_api_url}"]`).length===0){var t=document.createElement("script");t.setAttribute("src",this.gl_api_url),t.setAttribute("type","text/javascript"),t.setAttribute("async",!0),t.setAttribute("defer",!0),document.body.appendChild(t)}}sleep(t){return new Promise(r=>setTimeout(r,t))}async render(){let t="";for(;;){if(await this.sleep(200),typeof grecaptcha<"u"&&grecaptcha!==void 0&&typeof grecaptcha.render=="function"){t=grecaptcha.render(this.render_element_or_id,{sitekey:this.captcha_sitekey,theme:this.theme});break}console.info("checking grecaptcha undefined")}return t}reset(t){grecaptcha.reset(t)}fetchResponse(t){try{return grecaptcha.getResponse(t)}catch(r){console.error(r)}}async verifyRecaptcha(t){return await fetch(this.verify_url,{method:"post",body:JSON.stringify({token:t}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(r=>r.json())}};var ge={config:{},fields:{},name:null,endpoint:null,redirectTo:null,fileUpload:{filepond:null,el:null},onSuccess(e){},onFailed(e){},captchaId:null,recaptchaTheme:"light"};function at(e){document.addEventListener("alpine:init",()=>{for(let t of e){let r=Object.assign({},ge,t);document.addEventListener("alpine:init",pr(r))}})}async function ur(e){if(e.captchaId){let t=document.getElementById(e.captchaId);if(t)e.amCaptcha=new V({theme:this.recaptchaTheme,render_element_or_id:t}),e.widgetId=await e.amCaptcha.render();else throw"Can't find recaptcha rendering element. by id: "+this.captchaId}}function fr(e){if(console.log("\u{1F4E2} Form name: "+e.name),typeof e.redirectTo!="function"&&e.redirectTo.length&&new URL(e.endpoint).host==="hapiform.sg"&&console.log("\u{1F680} "+window.location.origin+e.redirectTo),e.endpoint){let t=new URL(e.endpoint),r=e.endpoint.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);t.host==="hapiform.sg"&&console.log(`\u{1F680} ${t.origin}/${r}`)}}async function dr(e){let t=e.amCaptcha.fetchResponse(e.widgetId);if(t.length===0)throw{recaptchaError:"You can't leave Captcha Code empty"};return await e.amCaptcha.verifyRecaptcha(t).then(r=>{if(r.success===!1)throw{recaptchaError:"captcha invalid: timeout or duplicate."}})}function it(e,t){ae(e).then(r=>{t.redirectTo&&(window.location.href=t.redirectTo),t.fileUpload.filepond&&t.fileUpload.filepond.removeFiles(),mr(),t.resetFields(),t.onSuccess(r),Er()}).catch(r=>{t.errors=r.response.data.errors,t.busy=!1,t.onFailed(r.response),wr(),t.captchaId&&t.amCaptcha.reset(t.widgetId)})}async function pr(e){Alpine.data(e.name,()=>({...e,errors:{},busy:!1,amCaptcha:null,widgetId:null,async init(){this.$watch("busy",t=>{let r=this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');t?r.forEach(n=>{n.disabled=!0}):r.forEach(n=>{n.disabled=!1})}),this.$init&&this.$init(),ur(this).catch(t=>console.error(t)),fr(this)},async submit(){this.busy=!0,this.errors={};let t=new FormData;if(Object.keys(this.fields).forEach((s,c)=>{typeof this.fields[s]=="object"?this.fields[s].forEach((f,l)=>{t.append(`${s}[${l}]`,f)}):t.append(s,this.fields[s])}),e.fileUpload.filepond)e.fileUpload.filepond.getFiles().forEach((s,c)=>{t.append(`files[${c}]`,s.file,s.name)});else if(e.fileUpload.el){let c=document.querySelector(e.fileUpload.el).files;for(let f=0;f<c.length;f++)t.append(`files[${f}]`,c[f],c[f].name)}let n=new URL(window.top.location.href);t.append("x_origin",n.origin+n.pathname);let o={method:"POST",url:br(e.endpoint),data:t},i=Object.assign({},o,e.config);this.captchaId?await dr(this).then(()=>{it(i,this)}).catch(s=>{this.errors=s,e.onFailed(s),this.busy=!1}).finally(()=>{}):it(i,this)},resetFields(){this.errors={},this.fields=e.fields,this.busy=!1,this.captchaId&&this.amCaptcha.reset(this.widgetId)}}))}function mr(){hr(),yr()}function hr(){try{ge.fileUpload.filepond.removeFiles()}catch{}}function yr(){try{let e=document.querySelector(ge.fileUpload.el);e.value=""}catch{}}function Er(){ct("hapi:success")}function wr(){ct("hapi:error")}function ct(e){let t=new Event(e);document.dispatchEvent(t)}function br(e){let t=new URL(e);return(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")&&(t.searchParams.set("test","1"),console.log("testing mode!")),t.href}function Te(){if(document.querySelectorAll('script[src="//unpkg.com/alpinejs"]').length===0){var e=document.createElement("script");e.setAttribute("src","//unpkg.com/alpinejs"),e.setAttribute("type","text/javascript"),e.setAttribute("defer",!0),document.body.appendChild(e)}}var lt={forms:at},ws=lt;window.Hapi=lt;Te();})();
|
|
1
|
+
(()=>{function B(e,t){return function(){return e.apply(t,arguments)}}var{toString:ft}=Object.prototype,{getPrototypeOf:ue}=Object,K=(e=>t=>{let r=ft.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),R=e=>(e=e.toLowerCase(),t=>K(t)===e),G=e=>t=>typeof t===e,{isArray:P}=Array,j=G("undefined");function dt(e){return e!==null&&!j(e)&&e.constructor!==null&&!j(e.constructor)&&S(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Fe=R("ArrayBuffer");function pt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Fe(e.buffer),t}var mt=G("string"),S=G("function"),Pe=G("number"),X=e=>e!==null&&typeof e=="object",ht=e=>e===!0||e===!1,W=e=>{if(K(e)!=="object")return!1;let t=ue(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},yt=R("Date"),Et=R("File"),wt=R("Blob"),bt=R("FileList"),At=e=>X(e)&&S(e.pipe),St=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||S(e.append)&&((t=K(e))==="formdata"||t==="object"&&S(e.toString)&&e.toString()==="[object FormData]"))},xt=R("URLSearchParams"),Rt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function k(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),P(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{let s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length,c;for(n=0;n<i;n++)c=s[n],t.call(null,e[c],c,e)}}function Ue(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}var _e=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),De=e=>!j(e)&&e!==_e;function le(){let{caseless:e}=De(this)&&this||{},t={},r=(n,o)=>{let s=e&&Ue(t,o)||o;W(t[s])&&W(n)?t[s]=le(t[s],n):W(n)?t[s]=le({},n):P(n)?t[s]=n.slice():t[s]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&k(arguments[n],r);return t}var Ot=(e,t,r,{allOwnKeys:n}={})=>(k(t,(o,s)=>{r&&S(o)?e[s]=B(o,r):e[s]=o},{allOwnKeys:n}),e),gt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Tt=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Ct=(e,t,r,n)=>{let o,s,i,c={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),s=o.length;s-- >0;)i=o[s],(!n||n(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=r!==!1&&ue(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Nt=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},Ft=e=>{if(!e)return null;if(P(e))return e;let t=e.length;if(!Pe(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Pt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ue(Uint8Array)),Ut=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),o;for(;(o=n.next())&&!o.done;){let s=o.value;t.call(e,s[0],s[1])}},_t=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Dt=R("HTMLFormElement"),Lt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Ce=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Bt=R("RegExp"),Le=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};k(r,(o,s)=>{t(o,s,e)!==!1&&(n[s]=o)}),Object.defineProperties(e,n)},jt=e=>{Le(e,(t,r)=>{if(S(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(S(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},kt=(e,t)=>{let r={},n=o=>{o.forEach(s=>{r[s]=!0})};return P(e)?n(e):n(String(e).split(t)),r},It=()=>{},Ht=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ce="abcdefghijklmnopqrstuvwxyz",Ne="0123456789",Be={DIGIT:Ne,ALPHA:ce,ALPHA_DIGIT:ce+ce.toUpperCase()+Ne},qt=(e=16,t=Be.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function Mt(e){return!!(e&&S(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var Jt=e=>{let t=new Array(10),r=(n,o)=>{if(X(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let s=P(n)?[]:{};return k(n,(i,c)=>{let d=r(i,o+1);!j(d)&&(s[c]=d)}),t[o]=void 0,s}}return n};return r(e,0)},zt=R("AsyncFunction"),vt=e=>e&&(X(e)||S(e))&&S(e.then)&&S(e.catch),a={isArray:P,isArrayBuffer:Fe,isBuffer:dt,isFormData:St,isArrayBufferView:pt,isString:mt,isNumber:Pe,isBoolean:ht,isObject:X,isPlainObject:W,isUndefined:j,isDate:yt,isFile:Et,isBlob:wt,isRegExp:Bt,isFunction:S,isStream:At,isURLSearchParams:xt,isTypedArray:Pt,isFileList:bt,forEach:k,merge:le,extend:Ot,trim:Rt,stripBOM:gt,inherits:Tt,toFlatObject:Ct,kindOf:K,kindOfTest:R,endsWith:Nt,toArray:Ft,forEachEntry:Ut,matchAll:_t,isHTMLForm:Dt,hasOwnProperty:Ce,hasOwnProp:Ce,reduceDescriptors:Le,freezeMethods:jt,toObjectSet:kt,toCamelCase:Lt,noop:It,toFiniteNumber:Ht,findKey:Ue,global:_e,isContextDefined:De,ALPHABET:Be,generateString:qt,isSpecCompliantForm:Mt,toJSONObject:Jt,isAsyncFn:zt,isThenable:vt};function U(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}a.inherits(U,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var je=U.prototype,ke={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ke[e]={value:e}});Object.defineProperties(U,ke);Object.defineProperty(je,"isAxiosError",{value:!0});U.from=(e,t,r,n,o,s)=>{let i=Object.create(je);return a.toFlatObject(e,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),U.call(i,e.message,t,r,n,o),i.cause=e,i.name=e.name,s&&Object.assign(i,s),i};var m=U;var Y=null;function fe(e){return a.isPlainObject(e)||a.isArray(e)}function He(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ie(e,t,r){return e?e.concat(t).map(function(o,s){return o=He(o),!r&&s?"["+o+"]":o}).join(r?".":""):t}function Vt(e){return a.isArray(e)&&!e.some(fe)}var $t=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Wt(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(Y||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,O){return!a.isUndefined(O[h])});let n=r.metaTokens,o=r.visitor||u,s=r.dots,i=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function l(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(!d&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function u(f,h,O){let x=f;if(f&&!O&&typeof f=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Vt(f)||(a.isFileList(f)||a.endsWith(h,"[]"))&&(x=a.toArray(f)))return h=He(h),x.forEach(function($,ut){!(a.isUndefined($)||$===null)&&t.append(i===!0?Ie([h],ut,s):i===null?h:h+"[]",l($))}),!1}return fe(f)?!0:(t.append(Ie(O,h,s),l(f)),!1)}let p=[],w=Object.assign($t,{defaultVisitor:u,convertValue:l,isVisitable:fe});function y(f,h){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(f),a.forEach(f,function(x,F){(!(a.isUndefined(x)||x===null)&&o.call(t,x,a.isString(F)?F.trim():F,h,w))===!0&&y(x,h?h.concat(F):[F])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}var T=Wt;function qe(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Me(e,t){this._pairs=[],e&&T(e,this,t)}var Je=Me.prototype;Je.append=function(t,r){this._pairs.push([t,r])};Je.toString=function(t){let r=t?function(n){return t.call(this,n,qe)}:qe;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Q=Me;function Kt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function I(e,t,r){if(!t)return e;let n=r&&r.encode||Kt,o=r&&r.serialize,s;if(o?s=o(t,r):s=a.isURLSearchParams(t)?t.toString():new Q(t,r).toString(n),s){let i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}var de=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(n){n!==null&&t(n)})}},pe=de;var Z={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ze=typeof URLSearchParams<"u"?URLSearchParams:Q;var ve=typeof FormData<"u"?FormData:null;var Ve=typeof Blob<"u"?Blob:null;var Gt=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Xt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),b={isBrowser:!0,classes:{URLSearchParams:ze,FormData:ve,Blob:Ve},isStandardBrowserEnv:Gt,isStandardBrowserWebWorkerEnv:Xt,protocols:["http","https","file","blob","url","data"]};function me(e,t){return T(e,new b.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,s){return b.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},t))}function Yt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Qt(e){let t={},r=Object.keys(e),n,o=r.length,s;for(n=0;n<o;n++)s=r[n],t[s]=e[s];return t}function Zt(e){function t(r,n,o,s){let i=r[s++],c=Number.isFinite(+i),d=s>=r.length;return i=!i&&a.isArray(o)?o.length:i,d?(a.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!c):((!o[i]||!a.isObject(o[i]))&&(o[i]=[]),t(r,n,o[i],s)&&a.isArray(o[i])&&(o[i]=Qt(o[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(Yt(n),o,r,0)}),r}return null}var ee=Zt;var er={"Content-Type":void 0};function tr(e,t,r){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var te={transitional:Z,adapter:["xhr","http"],transformRequest:[function(t,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=a.isObject(t);if(s&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return o&&o?JSON.stringify(ee(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return me(t,this.formSerializer).toString();if((c=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return T(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),tr(t)):t}],transformResponse:[function(t){let r=this.transitional||te.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&a.isString(t)&&(n&&!this.responseType||o)){let i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){te.headers[t]={}});a.forEach(["post","put","patch"],function(t){te.headers[t]=a.merge(er)});var _=te;var rr=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$e=e=>{let t={},r,n,o;return e&&e.split(`
|
|
2
|
+
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||t[r]&&rr[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var We=Symbol("internals");function H(e){return e&&String(e).trim().toLowerCase()}function re(e){return e===!1||e==null?e:a.isArray(e)?e.map(re):String(e)}function nr(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var or=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function he(e,t,r,n,o){if(a.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!a.isString(t)){if(a.isString(n))return t.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(t)}}function sr(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function ir(e,t){let r=a.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,s,i){return this[n].call(this,t,o,s,i)},configurable:!0})})}var D=class{constructor(t){t&&this.set(t)}set(t,r,n){let o=this;function s(c,d,l){let u=H(d);if(!u)throw new Error("header name must be a non-empty string");let p=a.findKey(o,u);(!p||o[p]===void 0||l===!0||l===void 0&&o[p]!==!1)&&(o[p||d]=re(c))}let i=(c,d)=>a.forEach(c,(l,u)=>s(l,u,d));return a.isPlainObject(t)||t instanceof this.constructor?i(t,r):a.isString(t)&&(t=t.trim())&&!or(t)?i($e(t),r):t!=null&&s(r,t,n),this}get(t,r){if(t=H(t),t){let n=a.findKey(this,t);if(n){let o=this[n];if(!r)return o;if(r===!0)return nr(o);if(a.isFunction(r))return r.call(this,o,n);if(a.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=H(t),t){let n=a.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||he(this,this[n],n,r)))}return!1}delete(t,r){let n=this,o=!1;function s(i){if(i=H(i),i){let c=a.findKey(n,i);c&&(!r||he(n,n[c],c,r))&&(delete n[c],o=!0)}}return a.isArray(t)?t.forEach(s):s(t),o}clear(t){let r=Object.keys(this),n=r.length,o=!1;for(;n--;){let s=r[n];(!t||he(this,this[s],s,t,!0))&&(delete this[s],o=!0)}return o}normalize(t){let r=this,n={};return a.forEach(this,(o,s)=>{let i=a.findKey(n,s);if(i){r[i]=re(o),delete r[s];return}let c=t?sr(s):String(s).trim();c!==s&&delete r[s],r[c]=re(o),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return a.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
3
|
+
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[We]=this[We]={accessors:{}}).accessors,o=this.prototype;function s(i){let c=H(i);n[c]||(ir(o,i),n[c]=!0)}return a.isArray(t)?t.forEach(s):s(t),this}};D.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(D.prototype);a.freezeMethods(D);var A=D;function q(e,t){let r=this||_,n=t||r,o=A.from(n.headers),s=n.data;return a.forEach(e,function(c){s=c.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function M(e){return!!(e&&e.__CANCEL__)}function Ke(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(Ke,m,{__CANCEL__:!0});var C=Ke;function ye(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var Ge=b.isStandardBrowserEnv?function(){return{write:function(r,n,o,s,i,c){let d=[];d.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&d.push("expires="+new Date(o).toGMTString()),a.isString(s)&&d.push("path="+s),a.isString(i)&&d.push("domain="+i),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Ee(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function we(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function J(e,t){return e&&!Ee(t)?we(e,t):t}var Xe=b.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(s){let i=s;return t&&(r.setAttribute("href",i),i=r.href),r.setAttribute("href",i),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(i){let c=a.isString(i)?o(i):i;return c.protocol===n.protocol&&c.host===n.host}}():function(){return function(){return!0}}();function be(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function ar(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,s=0,i;return t=t!==void 0?t:1e3,function(d){let l=Date.now(),u=n[s];i||(i=l),r[o]=d,n[o]=l;let p=s,w=0;for(;p!==o;)w+=r[p++],p=p%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;let y=u&&l-u;return y?Math.round(w*1e3/y):void 0}}var Ye=ar;function Qe(e,t){let r=0,n=Ye(50,250);return o=>{let s=o.loaded,i=o.lengthComputable?o.total:void 0,c=s-r,d=n(c),l=s<=i;r=s;let u={loaded:s,total:i,progress:i?s/i:void 0,bytes:c,rate:d||void 0,estimated:d&&i&&l?(i-s)/d:void 0,event:o};u[t?"download":"upload"]=!0,e(u)}}var cr=typeof XMLHttpRequest<"u",Ze=cr&&function(e){return new Promise(function(r,n){let o=e.data,s=A.from(e.headers).normalize(),i=e.responseType,c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}a.isFormData(o)&&(b.isStandardBrowserEnv||b.isStandardBrowserWebWorkerEnv?s.setContentType(!1):s.setContentType("multipart/form-data;",!1));let l=new XMLHttpRequest;if(e.auth){let y=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.set("Authorization","Basic "+btoa(y+":"+f))}let u=J(e.baseURL,e.url);l.open(e.method.toUpperCase(),I(u,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function p(){if(!l)return;let y=A.from("getAllResponseHeaders"in l&&l.getAllResponseHeaders()),h={data:!i||i==="text"||i==="json"?l.responseText:l.response,status:l.status,statusText:l.statusText,headers:y,config:e,request:l};ye(function(x){r(x),d()},function(x){n(x),d()},h),l=null}if("onloadend"in l?l.onloadend=p:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(p)},l.onabort=function(){l&&(n(new m("Request aborted",m.ECONNABORTED,e,l)),l=null)},l.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,l)),l=null},l.ontimeout=function(){let f=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||Z;e.timeoutErrorMessage&&(f=e.timeoutErrorMessage),n(new m(f,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,l)),l=null},b.isStandardBrowserEnv){let y=(e.withCredentials||Xe(u))&&e.xsrfCookieName&&Ge.read(e.xsrfCookieName);y&&s.set(e.xsrfHeaderName,y)}o===void 0&&s.setContentType(null),"setRequestHeader"in l&&a.forEach(s.toJSON(),function(f,h){l.setRequestHeader(h,f)}),a.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),i&&i!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",Qe(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",Qe(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=y=>{l&&(n(!y||y.type?new C(null,e,l):y),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));let w=be(u);if(w&&b.protocols.indexOf(w)===-1){n(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}l.send(o||null)})};var ne={http:Y,xhr:Ze};a.forEach(ne,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var et={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ne[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ne,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ne};function Ae(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new C(null,e)}function oe(e){return Ae(e),e.headers=A.from(e.headers),e.data=q.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et.getAdapter(e.adapter||_.adapter)(e).then(function(n){return Ae(e),n.data=q.call(e,e.transformResponse,n),n.headers=A.from(n.headers),n},function(n){return M(n)||(Ae(e),n&&n.response&&(n.response.data=q.call(e,e.transformResponse,n.response),n.response.headers=A.from(n.response.headers))),Promise.reject(n)})}var tt=e=>e instanceof A?e.toJSON():e;function g(e,t){t=t||{};let r={};function n(l,u,p){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:p},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function o(l,u,p){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l,p)}else return n(l,u,p)}function s(l,u){if(!a.isUndefined(u))return n(void 0,u)}function i(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function c(l,u,p){if(p in t)return n(l,u);if(p in e)return n(void 0,l)}let d={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,u)=>o(tt(l),tt(u),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){let p=d[u]||o,w=p(e[u],t[u],u);a.isUndefined(w)&&p!==c||(r[u]=w)}),r}var se="1.4.0";var Se={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Se[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var rt={};Se.transitional=function(t,r,n){function o(s,i){return"[Axios v"+se+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,c)=>{if(t===!1)throw new m(o(i," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!rt[i]&&(rt[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,c):!0}};function lr(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let s=n[o],i=t[s];if(i){let c=e[s],d=c===void 0||i(c,s,e);if(d!==!0)throw new m("option "+s+" must be "+d,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+s,m.ERR_BAD_OPTION)}}var ie={assertOptions:lr,validators:Se};var N=ie.validators,L=class{constructor(t){this.defaults=t,this.interceptors={request:new pe,response:new pe}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=g(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&ie.assertOptions(n,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ie.assertOptions(o,{encode:N.function,serialize:N.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i;i=s&&a.merge(s.common,s[r.method]),i&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),r.headers=A.concat(i,s);let c=[],d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(d=d&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});let l=[];this.interceptors.response.forEach(function(h){l.push(h.fulfilled,h.rejected)});let u,p=0,w;if(!d){let f=[oe.bind(this),void 0];for(f.unshift.apply(f,c),f.push.apply(f,l),w=f.length,u=Promise.resolve(r);p<w;)u=u.then(f[p++],f[p++]);return u}w=c.length;let y=r;for(p=0;p<w;){let f=c[p++],h=c[p++];try{y=f(y)}catch(O){h.call(this,O);break}}try{u=oe.call(this,y)}catch(f){return Promise.reject(f)}for(p=0,w=l.length;p<w;)u=u.then(l[p++],l[p++]);return u}getUri(t){t=g(this.defaults,t);let r=J(t.baseURL,t.url);return I(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){L.prototype[t]=function(r,n){return this.request(g(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,c){return this.request(g(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}L.prototype[t]=r(),L.prototype[t+"Form"]=r(!0)});var z=L;var v=class{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});let n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s,i=new Promise(c=>{n.subscribe(c),s=c}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,c){n.reason||(n.reason=new C(s,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new v(function(o){t=o}),cancel:t}}},nt=v;function xe(e){return function(r){return e.apply(null,r)}}function Re(e){return a.isObject(e)&&e.isAxiosError===!0}var Oe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Oe).forEach(([e,t])=>{Oe[t]=e});var ot=Oe;function st(e){let t=new z(e),r=B(z.prototype.request,t);return a.extend(r,z.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return st(g(e,o))},r}var E=st(_);E.Axios=z;E.CanceledError=C;E.CancelToken=nt;E.isCancel=M;E.VERSION=se;E.toFormData=T;E.AxiosError=m;E.Cancel=E.CanceledError;E.all=function(t){return Promise.all(t)};E.spread=xe;E.isAxiosError=Re;E.mergeConfig=g;E.AxiosHeaders=A;E.formToJSON=e=>ee(a.isHTMLForm(e)?new FormData(e):e);E.HttpStatusCode=ot;E.default=E;var ae=E;var{Axios:Xo,AxiosError:Yo,CanceledError:Qo,isCancel:Zo,CancelToken:es,VERSION:ts,all:rs,Cancel:ns,isAxiosError:os,spread:ss,toFormData:is,AxiosHeaders:as,HttpStatusCode:cs,formToJSON:ls,mergeConfig:us}=ae;var V=class{constructor({theme:t="light",render_element_or_id:r="recaptcha-el"}){this.gl_api_url="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit",this.captcha_sitekey="6LeRUzsjAAAAANUHNEY6VkUXmMo_wlrDK5SUoFUV",this.verify_url="https://internalapi.activamedia.com.sg/v1/recaptcha/verify",this.theme=t,this.render_element_or_id=r,this.defineOnloadCallBack(),this.loadJsFile()}defineOnloadCallBack(){window.onloadCallback=()=>{}}loadJsFile(){if(document.querySelectorAll(`script[src="${this.gl_api_url}"]`).length===0){var t=document.createElement("script");t.setAttribute("src",this.gl_api_url),t.setAttribute("type","text/javascript"),t.setAttribute("async",!0),t.setAttribute("defer",!0),document.body.appendChild(t)}}sleep(t){return new Promise(r=>setTimeout(r,t))}async render(){let t="";for(;;){if(await this.sleep(200),typeof grecaptcha<"u"&&grecaptcha!==void 0&&typeof grecaptcha.render=="function"){t=grecaptcha.render(this.render_element_or_id,{sitekey:this.captcha_sitekey,theme:this.theme});break}console.info("checking grecaptcha undefined")}return t}reset(t){grecaptcha.reset(t)}fetchResponse(t){try{return grecaptcha.getResponse(t)}catch(r){console.error(r)}}async verifyRecaptcha(t){return await fetch(this.verify_url,{method:"post",body:JSON.stringify({token:t}),headers:{Accept:"application/json","Content-Type":"application/json"}}).then(r=>r.json())}};var ge={config:{},name:null,endpoint:null,redirectTo:null,fileUpload:{filepond:null,el:null},onSuccess(e){},onFailed(e){},captchaId:null,recaptchaTheme:"light"};function at(e){document.addEventListener("alpine:init",()=>{for(let t of e){let r=Object.assign({},ge,t);document.addEventListener("alpine:init",pr(r))}})}async function ur(e){if(e.captchaId){let t=document.getElementById(e.captchaId);if(t)e.amCaptcha=new V({theme:this.recaptchaTheme,render_element_or_id:t}),e.widgetId=await e.amCaptcha.render();else throw"Can't find recaptcha rendering element. by id: "+this.captchaId}}function fr(e){if(console.log("\u{1F4E2} Form name: "+e.name),typeof e.redirectTo!="function"&&e.redirectTo.length&&new URL(e.endpoint).host==="hapiform.sg"&&console.log("\u{1F680} "+window.location.origin+e.redirectTo),e.endpoint){let t=new URL(e.endpoint),r=e.endpoint.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);t.host==="hapiform.sg"&&console.log(`\u{1F680} ${t.origin}/${r}`)}}async function dr(e){let t=e.amCaptcha.fetchResponse(e.widgetId);if(t.length===0)throw{recaptchaError:"You can't leave Captcha Code empty"};return await e.amCaptcha.verifyRecaptcha(t).then(r=>{if(r.success===!1)throw{recaptchaError:"captcha invalid: timeout or duplicate."}})}function it(e,t){ae(e).then(r=>{t.redirectTo&&(window.location.href=t.redirectTo),t.fileUpload.filepond&&t.fileUpload.filepond.removeFiles(),mr(),t.resetFields(),t.onSuccess(r),Er()}).catch(r=>{t.errors=r.response.data.errors,t.busy=!1,t.onFailed(r.response),wr(),t.captchaId&&t.amCaptcha.reset(t.widgetId)})}async function pr(e){Alpine.data(e.name,()=>({...e,errors:{},busy:!1,amCaptcha:null,widgetId:null,async init(){Alpine.store(e.name,{fields:{}}),this.$watch("busy",t=>{let r=this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');t?r.forEach(n=>{n.disabled=!0}):r.forEach(n=>{n.disabled=!1})}),this.$init&&this.$init(),ur(this).catch(t=>console.error(t)),fr(this)},async submit(){this.busy=!0,this.errors={};let t=new FormData,r=Alpine.store(this.name).fields;if(Object.keys(r).forEach((c,d)=>{typeof r[c]=="object"?r[c].forEach((l,u)=>{t.append(`${c}[${u}]`,l)}):t.append(c,r[c])}),e.fileUpload.filepond)e.fileUpload.filepond.getFiles().forEach((c,d)=>{t.append(`files[${d}]`,c.file,c.name)});else if(e.fileUpload.el){let d=document.querySelector(e.fileUpload.el).files;for(let l=0;l<d.length;l++)t.append(`files[${l}]`,d[l],d[l].name)}let o=new URL(window.top.location.href);t.append("x_origin",o.origin+o.pathname);let s={method:"POST",url:br(e.endpoint),data:t},i=Object.assign({},s,e.config);this.captchaId?await dr(this).then(()=>{it(i,this)}).catch(c=>{this.errors=c,e.onFailed(c),this.busy=!1}).finally(()=>{}):it(i,this)},resetFields(){this.errors={},Alpine.store(this.name).fields={},this.busy=!1,this.captchaId&&this.amCaptcha.reset(this.widgetId)}}))}function mr(){hr(),yr()}function hr(){try{ge.fileUpload.filepond.removeFiles()}catch{}}function yr(){try{let e=document.querySelector(ge.fileUpload.el);e.value=""}catch{}}function Er(){ct("hapi:success")}function wr(){ct("hapi:error")}function ct(e){let t=new Event(e);document.dispatchEvent(t)}function br(e){let t=new URL(e);return(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1")&&(t.searchParams.set("test","1"),console.log("testing mode!")),t.href}function Te(){if(document.querySelectorAll('script[src="//unpkg.com/alpinejs"]').length===0){var e=document.createElement("script");e.setAttribute("src","//unpkg.com/alpinejs"),e.setAttribute("type","text/javascript"),e.setAttribute("defer",!0),document.body.appendChild(e)}}var lt={forms:at},ws=lt;window.Hapi=lt;Te();})();
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"deprecated": false,
|
|
11
11
|
"description": "hapiform html js library with google recaptcha",
|
|
12
12
|
"keywords": [
|
|
13
|
-
"hapiform"
|
|
13
|
+
"hapi", "hapiform"
|
|
14
14
|
],
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"main": "index.js",
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"build": "esbuild index.js --bundle --minify --outfile=./dist/hapi.min.js",
|
|
20
20
|
"watch": "esbuild index.js --watch --bundle --minify --outfile=./dist/hapi.min.js"
|
|
21
21
|
},
|
|
22
|
-
"version": "1.0.
|
|
22
|
+
"version": "1.0.2"
|
|
23
23
|
}
|
package/src/hapi.js
CHANGED
|
@@ -6,7 +6,6 @@ import AMCaptcha from './recaptcha';
|
|
|
6
6
|
|
|
7
7
|
let hapiOptions = {
|
|
8
8
|
config: {},
|
|
9
|
-
fields: {},
|
|
10
9
|
name: null,
|
|
11
10
|
endpoint: null,
|
|
12
11
|
redirectTo: null,
|
|
@@ -122,6 +121,10 @@ async function alpineInitData(options) {
|
|
|
122
121
|
amCaptcha: null,
|
|
123
122
|
widgetId: null,
|
|
124
123
|
async init() {
|
|
124
|
+
|
|
125
|
+
// todo: remove special characters
|
|
126
|
+
Alpine.store(options.name, {fields: {}});
|
|
127
|
+
|
|
125
128
|
this.$watch("busy", (value) => {
|
|
126
129
|
let buttons = this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');
|
|
127
130
|
|
|
@@ -151,16 +154,17 @@ async function alpineInitData(options) {
|
|
|
151
154
|
// Get all form fields
|
|
152
155
|
let formData = new FormData();
|
|
153
156
|
|
|
154
|
-
let
|
|
157
|
+
let fieldsStore = Alpine.store(this.name).fields;
|
|
158
|
+
let fieldNames = Object.keys(fieldsStore);
|
|
155
159
|
|
|
156
160
|
// Append all fields to formData
|
|
157
161
|
fieldNames.forEach((field, i) => {
|
|
158
|
-
if (typeof
|
|
159
|
-
|
|
162
|
+
if (typeof fieldsStore[field] === "object") {
|
|
163
|
+
fieldsStore[field].forEach((item, index) => {
|
|
160
164
|
formData.append(`${field}[${index}]`, item);
|
|
161
165
|
});
|
|
162
166
|
} else {
|
|
163
|
-
formData.append(field,
|
|
167
|
+
formData.append(field, fieldsStore[field]);
|
|
164
168
|
}
|
|
165
169
|
});
|
|
166
170
|
|
|
@@ -215,7 +219,8 @@ async function alpineInitData(options) {
|
|
|
215
219
|
},
|
|
216
220
|
resetFields() {
|
|
217
221
|
this.errors = {};
|
|
218
|
-
this.fields = options.fields;
|
|
222
|
+
// this.fields = options.fields;
|
|
223
|
+
Alpine.store(this.name).fields = {};
|
|
219
224
|
this.busy = false;
|
|
220
225
|
if (this.captchaId) this.amCaptcha.reset(this.widgetId);
|
|
221
226
|
},
|