hapi-recaptcha-html 1.0.0 → 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 +75 -0
- package/demo/contactus-success.html +14 -0
- package/demo/enquiry-forms.js +18 -0
- package/demo/index.html +128 -0
- package/demo/loading.svg +31 -0
- package/dist/hapi.min.js +3 -3
- package/index.js +2 -4
- package/package.json +14 -11
- package/src/hapi.js +185 -189
- package/src/recaptcha.js +1 -1
- package/enquiry-form.js +0 -6
- package/index.html +0 -127
- package/readme.md +0 -68
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# HAPI Form Plugin
|
|
2
|
+
Wrapper of Alpine JS plugin for HAPI Form, works on Laravel API endpoint.
|
|
3
|
+
## CDN
|
|
4
|
+
```html
|
|
5
|
+
<script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>
|
|
6
|
+
|
|
7
|
+
<script src="enquiry-forms.js" defer></script>
|
|
8
|
+
```
|
|
9
|
+
## Usage
|
|
10
|
+
```html
|
|
11
|
+
enquiry-forms.js file:
|
|
12
|
+
|
|
13
|
+
<script>
|
|
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
|
+
|
|
34
|
+
</script>
|
|
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
|
+
...
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
- name – The name of the instance, to be matched with `x-data="name"`.
|
|
50
|
+
- endpoint – The form endpoint URL generated from the backend.
|
|
51
|
+
- redirectTo – Location to be redirected after success. Eg: "/thank-you" or "https://example.com". (Optional)
|
|
52
|
+
- fileUpload
|
|
53
|
+
- filepond – Filepond object. (Filepond plugin required)
|
|
54
|
+
- el – Select `input` element if you're using normal upload.
|
|
55
|
+
- captchaId - Id of div element to render the google recaptcha, `null` means recaptcha is disabled.
|
|
56
|
+
- recaptchaTheme - `light` or `dark`.
|
|
57
|
+
- onSuccess() – On success event.
|
|
58
|
+
- onFailed() – On failed event.
|
|
59
|
+
- errors.recaptchaError - to display captcha verification errors.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Events
|
|
63
|
+
|
|
64
|
+
### Success Event
|
|
65
|
+
When submission is success, Hapi will emit `hapi:success` event.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### 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>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Hapi.forms([
|
|
2
|
+
// form 01
|
|
3
|
+
{
|
|
4
|
+
name: 'form01',
|
|
5
|
+
endpoint: 'https://hapiform.sg/api/5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
6
|
+
redirectTo: 'contactus-success.html',
|
|
7
|
+
captchaId: 'captcha-01'
|
|
8
|
+
|
|
9
|
+
},
|
|
10
|
+
// form 02
|
|
11
|
+
{
|
|
12
|
+
name: 'form02',
|
|
13
|
+
endpoint: 'https://hapiform.sg/api/5867eae1-c53d-4734-a50c-abd350eb79d9',
|
|
14
|
+
redirectTo: 'contactus-success.html',
|
|
15
|
+
captchaId: 'captcha-02'
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
);
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport"
|
|
6
|
+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
7
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
8
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
|
|
9
|
+
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
|
10
|
+
<title>Demo Forms</title>
|
|
11
|
+
<style>
|
|
12
|
+
h1 {
|
|
13
|
+
font-size: 20px;
|
|
14
|
+
text-align: center;
|
|
15
|
+
margin: 20px auto;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
form {
|
|
19
|
+
width: 100%;
|
|
20
|
+
max-width: 550px;
|
|
21
|
+
margin: 10px auto;
|
|
22
|
+
border: 1px solid #dedede;
|
|
23
|
+
border-radius: 5px;
|
|
24
|
+
padding: 10px;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<div class="container">
|
|
30
|
+
<h1>Demo Forms</h1>
|
|
31
|
+
|
|
32
|
+
<div class="d-lg-flex">
|
|
33
|
+
|
|
34
|
+
<form x-on:submit.prevent="submit" x-data="form01">
|
|
35
|
+
|
|
36
|
+
<template x-if="errors">
|
|
37
|
+
<div x-html="JSON.stringify(errors)" class="text-danger"></div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<div x-text='JSON.stringify($store.form01.fields,null,2)' class="text-success"></div>
|
|
41
|
+
<div>
|
|
42
|
+
<div class="mb-3">
|
|
43
|
+
<div class="form-field">
|
|
44
|
+
<label for="form01-name" class="form-label">Name</label>
|
|
45
|
+
<input type="text" id="form01-name" x-model="$store.form01.fields.name" placeholder="Name" class="form-control">
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
<template x-if="errors && errors.name">
|
|
49
|
+
<div x-text="errors.name" class="text-danger"></div>
|
|
50
|
+
</template>
|
|
51
|
+
<div x-text="$store.form01.fields.name"></div>
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
<div class="mb-3">
|
|
55
|
+
<div class="form-field">
|
|
56
|
+
<label for="form01-message" class="form-label">Message</label>
|
|
57
|
+
<textarea id="form01-message" x-model="$store.form01.fields.message" rows="4" placeholder="Message"
|
|
58
|
+
class="form-control form-textarea"></textarea>
|
|
59
|
+
</div>
|
|
60
|
+
<template x-if="errors && errors.message">
|
|
61
|
+
<div x-text="errors.message" class="text-danger"></div>
|
|
62
|
+
</template>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="mb-3">
|
|
65
|
+
<div id="captcha-01"></div>
|
|
66
|
+
<template x-if="errors && errors.recaptchaError">
|
|
67
|
+
<div x-text="errors.recaptchaError" class="text-danger"></div>
|
|
68
|
+
</template>
|
|
69
|
+
</div>
|
|
70
|
+
<div class="mb-3">
|
|
71
|
+
<button type="submit" class="btn btn-primary">
|
|
72
|
+
Submit Form 1 <img x-show="busy" src="loading.svg">
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</form>
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<form x-on:submit.prevent="submit" x-data="form02">
|
|
80
|
+
|
|
81
|
+
<template x-if="errors">
|
|
82
|
+
<div x-text="JSON.stringify(errors)" class="text-danger"></div>
|
|
83
|
+
</template>
|
|
84
|
+
|
|
85
|
+
<div x-text='JSON.stringify($store.form02.fields,null,2)' class="text-success"></div>
|
|
86
|
+
<div>
|
|
87
|
+
<div class="mb-3">
|
|
88
|
+
<div class="form-field">
|
|
89
|
+
<label for="form02-name" class="form-label">Name</label>
|
|
90
|
+
<input type="text" id="form02-name" x-model="$store.form02.fields.name" placeholder="Name" class="form-control">
|
|
91
|
+
</div>
|
|
92
|
+
<template x-if="errors && errors.name">
|
|
93
|
+
<div x-text="errors.name" class="text-danger"></div>
|
|
94
|
+
</template>
|
|
95
|
+
<div x-text="$store.form02.fields.name"></div>
|
|
96
|
+
</div>
|
|
97
|
+
<div class="mb-3">
|
|
98
|
+
<div class="form-field">
|
|
99
|
+
<label for="form02-message" class="form-label">Message</label>
|
|
100
|
+
<textarea id="form02-message" x-model="$store.form02.fields.message" rows="4" placeholder="Message"
|
|
101
|
+
class="form-control form-textarea"></textarea>
|
|
102
|
+
</div>
|
|
103
|
+
<template x-if="errors && errors.message">
|
|
104
|
+
<div x-text="errors.message" class="text-danger"></div>
|
|
105
|
+
</template>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="mb-3">
|
|
108
|
+
<div id="captcha-02"></div>
|
|
109
|
+
<template x-if="errors && errors.recaptchaError">
|
|
110
|
+
<div x-text="errors.recaptchaError" class="text-danger"></div>
|
|
111
|
+
</template>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="mb-3">
|
|
114
|
+
<button type="submit" class="btn btn-success">
|
|
115
|
+
Submit Form 2 <img x-show="busy" src="loading.svg">
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</form>
|
|
120
|
+
|
|
121
|
+
</div>
|
|
122
|
+
<!-- <script src="https://unpkg.com/hapi-recaptcha-html@latest/dist/hapi.min.js" defer></script>-->
|
|
123
|
+
|
|
124
|
+
<script src="../dist/hapi.min.js" defer></script>
|
|
125
|
+
<script src="enquiry-forms.js" defer></script>
|
|
126
|
+
</div>
|
|
127
|
+
</body>
|
|
128
|
+
</html>
|
package/demo/loading.svg
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<svg viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a">
|
|
4
|
+
<stop stop-color="#fff" stop-opacity="0" offset="0%"/>
|
|
5
|
+
<stop stop-color="#fff" stop-opacity=".631" offset="63.146%"/>
|
|
6
|
+
<stop stop-color="#fff" offset="100%"/>
|
|
7
|
+
</linearGradient>
|
|
8
|
+
</defs>
|
|
9
|
+
<g fill="none" fill-rule="evenodd">
|
|
10
|
+
<g transform="translate(1 1)">
|
|
11
|
+
<path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2">
|
|
12
|
+
<animateTransform
|
|
13
|
+
attributeName="transform"
|
|
14
|
+
type="rotate"
|
|
15
|
+
from="0 18 18"
|
|
16
|
+
to="360 18 18"
|
|
17
|
+
dur="0.9s"
|
|
18
|
+
repeatCount="indefinite"/>
|
|
19
|
+
</path>
|
|
20
|
+
<circle fill="#fff" cx="36" cy="18" r="1">
|
|
21
|
+
<animateTransform
|
|
22
|
+
attributeName="transform"
|
|
23
|
+
type="rotate"
|
|
24
|
+
from="0 18 18"
|
|
25
|
+
to="360 18 18"
|
|
26
|
+
dur="0.9s"
|
|
27
|
+
repeatCount="indefinite"/>
|
|
28
|
+
</circle>
|
|
29
|
+
</g>
|
|
30
|
+
</g>
|
|
31
|
+
</svg>
|
package/dist/hapi.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(()=>{function j(e,t){return function(){return e.apply(t,arguments)}}var{toString:ut}=Object.prototype,{getPrototypeOf:fe}=Object,G=(e=>t=>{let r=ut.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),R=e=>(e=e.toLowerCase(),t=>G(t)===e),X=e=>t=>typeof t===e,{isArray:U}=Array,k=X("undefined");function ft(e){return e!==null&&!k(e)&&e.constructor!==null&&!k(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Pe=R("ArrayBuffer");function dt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Pe(e.buffer),t}var pt=X("string"),x=X("function"),Fe=X("number"),Y=e=>e!==null&&typeof e=="object",mt=e=>e===!0||e===!1,K=e=>{if(G(e)!=="object")return!1;let t=fe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},ht=R("Date"),yt=R("File"),wt=R("Blob"),Et=R("FileList"),bt=e=>Y(e)&&x(e.pipe),St=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=G(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},xt=R("URLSearchParams"),At=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function I(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),U(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=>!k(e)&&e!==_e;function ue(){let{caseless:e}=De(this)&&this||{},t={},r=(n,o)=>{let i=e&&Ue(t,o)||o;K(t[i])&&K(n)?t[i]=ue(t[i],n):K(n)?t[i]=ue({},n):U(n)?t[i]=n.slice():t[i]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&I(arguments[n],r);return t}var Rt=(e,t,r,{allOwnKeys:n}={})=>(I(t,(o,i)=>{r&&x(o)?e[i]=j(o,r):e[i]=o},{allOwnKeys:n}),e),Ot=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),gt=(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)},Tt=(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&&fe(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Ct=(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},Nt=e=>{if(!e)return null;if(U(e))return e;let t=e.length;if(!Fe(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"&&fe(Uint8Array)),Ft=(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])}},Ut=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},_t=R("HTMLFormElement"),Dt=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),Lt=R("RegExp"),Le=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};I(r,(o,i)=>{t(o,i,e)!==!1&&(n[i]=o)}),Object.defineProperties(e,n)},Bt=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+"'")})}})},jt=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return U(e)?n(e):n(String(e).split(t)),r},kt=()=>{},It=(e,t)=>(e=+e,Number.isFinite(e)?e:t),le="abcdefghijklmnopqrstuvwxyz",Ne="0123456789",Be={DIGIT:Ne,ALPHA:le,ALPHA_DIGIT:le+le.toUpperCase()+Ne},Ht=(e=16,t=Be.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function qt(e){return!!(e&&x(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var Mt=e=>{let t=new Array(10),r=(n,o)=>{if(Y(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let i=U(n)?[]:{};return I(n,(s,c)=>{let f=r(s,o+1);!k(f)&&(i[c]=f)}),t[o]=void 0,i}}return n};return r(e,0)},Jt=R("AsyncFunction"),zt=e=>e&&(Y(e)||x(e))&&x(e.then)&&x(e.catch),a={isArray:U,isArrayBuffer:Pe,isBuffer:ft,isFormData:St,isArrayBufferView:dt,isString:pt,isNumber:Fe,isBoolean:mt,isObject:Y,isPlainObject:K,isUndefined:k,isDate:ht,isFile:yt,isBlob:wt,isRegExp:Lt,isFunction:x,isStream:bt,isURLSearchParams:xt,isTypedArray:Pt,isFileList:Et,forEach:I,merge:ue,extend:Rt,trim:At,stripBOM:Ot,inherits:gt,toFlatObject:Tt,kindOf:G,kindOfTest:R,endsWith:Ct,toArray:Nt,forEachEntry:Ft,matchAll:Ut,isHTMLForm:_t,hasOwnProperty:Ce,hasOwnProp:Ce,reduceDescriptors:Le,freezeMethods:Bt,toObjectSet:jt,toCamelCase:Dt,noop:kt,toFiniteNumber:It,findKey:Ue,global:_e,isContextDefined:De,ALPHABET:Be,generateString:Ht,isSpecCompliantForm:qt,toJSONObject:Mt,isAsyncFn:Jt,isThenable:zt};function _(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(_,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=_.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(_,ke);Object.defineProperty(je,"isAxiosError",{value:!0});_.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"),_.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var m=_;var Q=null;function de(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(de)}var Vt=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function $t(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(Q||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,g){return!a.isUndefined(g[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,g){let A=d;if(d&&!g&&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(W,lt){!(a.isUndefined(W)||W===null)&&t.append(s===!0?Ie([h],lt,i):s===null?h:h+"[]",l(W))}),!1}return de(d)?!0:(t.append(Ie(g,h,i),l(d)),!1)}let p=[],E=Object.assign(Vt,{defaultVisitor:u,convertValue:l,isVisitable:de});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,E))===!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 C=$t;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&&C(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 Z=Me;function Wt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function H(e,t,r){if(!t)return e;let n=r&&r.encode||Wt,o=r&&r.serialize,i;if(o?i=o(t,r):i=a.isURLSearchParams(t)?t.toString():new Z(t,r).toString(n),i){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}var pe=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)})}},me=pe;var ee={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ze=typeof URLSearchParams<"u"?URLSearchParams:Z;var ve=typeof FormData<"u"?FormData:null;var Ve=typeof Blob<"u"?Blob:null;var Kt=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Gt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),b={isBrowser:!0,classes:{URLSearchParams:ze,FormData:ve,Blob:Ve},isStandardBrowserEnv:Kt,isStandardBrowserWebWorkerEnv:Gt,protocols:["http","https","file","blob","url","data"]};function he(e,t){return C(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 Xt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Yt(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 Qt(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]=Yt(o[s])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(Xt(n),o,r,0)}),r}return null}var te=Qt;var Zt={"Content-Type":void 0};function er(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 re={transitional:ee,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(te(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 he(t,this.formSerializer).toString();if((c=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return C(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),er(t)):t}],transformResponse:[function(t){let r=this.transitional||re.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){re.headers[t]={}});a.forEach(["post","put","patch"],function(t){re.headers[t]=a.merge(Zt)});var D=re;var tr=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=q(s);n[c]||(sr(o,s),n[c]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};L.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(L.prototype);a.freezeMethods(L);var S=L;function M(e,t){let r=this||D,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 J(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 N=Ke;function we(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 be(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function z(e,t){return e&&!Ee(t)?be(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 Se(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function ir(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,E=0;for(;p!==o;)E+=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(E*1e3/y):void 0}}var Ye=ir;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 ar=typeof XMLHttpRequest<"u",Ze=ar&&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=z(e.baseURL,e.url);l.open(e.method.toUpperCase(),H(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};we(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||ee;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 N(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 E=Se(u);if(E&&b.protocols.indexOf(E)===-1){n(new m("Unsupported protocol "+E+":",m.ERR_BAD_REQUEST,e));return}l.send(o||null)})};var oe={http:Q,xhr:Ze};a.forEach(oe,(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)?oe[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(oe,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:oe};function xe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new N(null,e)}function se(e){return xe(e),e.headers=S.from(e.headers),e.data=M.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),et.getAdapter(e.adapter||D.adapter)(e).then(function(n){return xe(e),n.data=M.call(e,e.transformResponse,n),n.headers=S.from(n.headers),n},function(n){return J(n)||(xe(e),n&&n.response&&(n.response.data=M.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 T(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,E=p(e[u],t[u],u);a.isUndefined(E)&&p!==c||(r[u]=E)}),r}var ie="1.4.0";var Ae={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ae[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var rt={};Ae.transitional=function(t,r,n){function o(i,s){return"[Axios v"+ie+"] 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 cr(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 ae={assertOptions:cr,validators:Ae};var P=ae.validators,B=class{constructor(t){this.defaults=t,this.interceptors={request:new me,response:new me}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=T(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&ae.assertOptions(n,{silentJSONParsing:P.transitional(P.boolean),forcedJSONParsing:P.transitional(P.boolean),clarifyTimeoutError:P.transitional(P.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ae.assertOptions(o,{encode:P.function,serialize:P.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,E;if(!f){let d=[se.bind(this),void 0];for(d.unshift.apply(d,c),d.push.apply(d,l),E=d.length,u=Promise.resolve(r);p<E;)u=u.then(d[p++],d[p++]);return u}E=c.length;let y=r;for(p=0;p<E;){let d=c[p++],h=c[p++];try{y=d(y)}catch(g){h.call(this,g);break}}try{u=se.call(this,y)}catch(d){return Promise.reject(d)}for(p=0,E=l.length;p<E;)u=u.then(l[p++],l[p++]);return u}getUri(t){t=T(this.defaults,t);let r=z(t.baseURL,t.url);return H(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){B.prototype[t]=function(r,n){return this.request(T(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(T(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}B.prototype[t]=r(),B.prototype[t+"Form"]=r(!0)});var v=B;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 N(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 Re(e){return function(r){return e.apply(null,r)}}function Oe(e){return a.isObject(e)&&e.isAxiosError===!0}var ge={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(ge).forEach(([e,t])=>{ge[t]=e});var ot=ge;function st(e){let t=new v(e),r=j(v.prototype.request,t);return a.extend(r,v.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return st(T(e,o))},r}var w=st(D);w.Axios=v;w.CanceledError=N;w.CancelToken=nt;w.isCancel=J;w.VERSION=ie;w.toFormData=C;w.AxiosError=m;w.Cancel=w.CanceledError;w.all=function(t){return Promise.all(t)};w.spread=Re;w.isAxiosError=Oe;w.mergeConfig=T;w.AxiosHeaders=S;w.formToJSON=e=>te(a.isHTMLForm(e)?new FormData(e):e);w.HttpStatusCode=ot;w.default=w;var ce=w;var{Axios:Wo,AxiosError:Ko,CanceledError:Go,isCancel:Xo,CancelToken:Yo,VERSION:Qo,all:Zo,Cancel:es,isAxiosError:ts,spread:rs,toFormData:ns,AxiosHeaders:os,HttpStatusCode:ss,formToJSON:is,mergeConfig:as}=ce;var $=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=()=>{console.log("api loaded")}}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 O={config:{},fields:{},name:null,endpoint:null,redirectTo:null,fileUpload:{filepond:null,el:null},onSuccess(e){},onFailed(e){},amCaptcha:Object,captchaId:null,recaptchaTheme:"light",widgetId:null};async function it(e){let t=Object.assign({},O,e);await lr(t)}async function lr(e){document.addEventListener("alpine:init",()=>{if(Alpine.data(e.name,()=>({...e,errors:{},busy:!1,async init(){if(this.$watch("busy",t=>{let r=document.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(),this.captchaId){let t=document.getElementById(this.captchaId);if(t)this.amCaptcha=new $({theme:this.recaptchaTheme,render_element_or_id:t}),this.widgetId=await this.amCaptcha.render();else throw"Can't find recaptcha rendering element."}},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:yr(e.endpoint),data:t},i=Object.assign({},o,e.config);this.captchaId&&ur(this.amCaptcha).then(()=>{ce(i).then(s=>{e.redirectTo&&(window.location.href=e.redirectTo),e.fileUpload.filepond&&e.fileUpload.filepond.removeFiles(),fr(),this.resetFields(),e.onSuccess(s),mr()}).catch(s=>{this.errors=s.response.data.errors,this.busy=!1,e.onFailed(s.response),hr(),this.captchaId&&this.amCaptcha.reset(this.widgetId)})}).catch(s=>{this.errors=s,e.onFailed(s),this.busy=!1}).finally(()=>{this.amCaptcha.reset(this.widgetId)})},resetFields(){this.errors={},this.fields=e.fields,this.busy=!1,this.captchaId&&this.amCaptcha.reset(this.widgetId)}})),O.redirectTo&&O.endpoint&&new URL(O.endpoint).host==="hapiform.sg"&&console.log("\u{1F680} "+window.location.origin+O.redirectTo),O.endpoint){let t=new URL(O.endpoint),r=O.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 ur(e){let t=e.fetchResponse(this.widgetId);if(t.length===0)throw{recaptchaError:"You can't leave Captcha Code empty"};return await e.verifyRecaptcha(t).then(r=>{if(r.success===!1)throw{recaptchaError:"captcha invalid: timeout or duplicate."}})}function fr(){dr(),pr()}function dr(){try{O.fileUpload.filepond.removeFiles()}catch{}}function pr(){try{let e=document.querySelector(O.fileUpload.el);e.value=""}catch{}}function mr(){at("hapi:success")}function hr(){at("hapi:error")}function at(e){let t=new Event(e);document.dispatchEvent(t)}function yr(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 ct={form:it},hs=ct;window.Hapi=ct;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
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "chenghuichao"
|
|
4
|
+
},
|
|
5
|
+
"bundleDependencies": false,
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"axios": "^1.4.0",
|
|
8
|
+
"esbuild": "0.17.19"
|
|
9
|
+
},
|
|
10
|
+
"deprecated": false,
|
|
4
11
|
"description": "hapiform html js library with google recaptcha",
|
|
5
|
-
"main": "index.js",
|
|
6
12
|
"keywords": [
|
|
7
|
-
"hapiform"
|
|
13
|
+
"hapi", "hapiform"
|
|
8
14
|
],
|
|
9
|
-
"author": "chenghuichao",
|
|
10
15
|
"license": "MIT",
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"esbuild": "^0.17.19"
|
|
14
|
-
},
|
|
15
|
-
"bundleDependencies": false,
|
|
16
|
+
"main": "index.js",
|
|
17
|
+
"name": "hapi-recaptcha-html",
|
|
16
18
|
"scripts": {
|
|
17
19
|
"build": "esbuild index.js --bundle --minify --outfile=./dist/hapi.min.js",
|
|
18
20
|
"watch": "esbuild index.js --watch --bundle --minify --outfile=./dist/hapi.min.js"
|
|
19
|
-
}
|
|
21
|
+
},
|
|
22
|
+
"version": "1.0.2"
|
|
20
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,
|
|
@@ -20,217 +19,214 @@ let hapiOptions = {
|
|
|
20
19
|
onFailed(res) {
|
|
21
20
|
res;
|
|
22
21
|
},
|
|
23
|
-
amCaptcha: Object,
|
|
24
22
|
captchaId: null,
|
|
25
23
|
recaptchaTheme: 'light', // light, dark
|
|
26
|
-
widgetId: null,
|
|
27
24
|
};
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
let mergedOptions = Object.assign({}, hapiOptions, options);
|
|
31
|
-
|
|
32
|
-
await alpine(mergedOptions);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function alpine(options) {
|
|
26
|
+
function forms(formsOption) {
|
|
36
27
|
document.addEventListener("alpine:init", () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let buttons = document.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');
|
|
44
|
-
|
|
45
|
-
if (value) {
|
|
46
|
-
buttons.forEach((button) => {
|
|
47
|
-
button.disabled = true;
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
buttons.forEach((button) => {
|
|
51
|
-
button.disabled = false;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
this.$init ? this.$init() : null;
|
|
57
|
-
|
|
58
|
-
if (this.captchaId) {
|
|
59
|
-
// find the rending element
|
|
60
|
-
let recaptcha_el = document.getElementById(this.captchaId);
|
|
61
|
-
if (recaptcha_el) {
|
|
62
|
-
this.amCaptcha = new AMCaptcha({
|
|
63
|
-
theme: this.recaptchaTheme,
|
|
64
|
-
render_element_or_id: recaptcha_el
|
|
65
|
-
});
|
|
66
|
-
this.widgetId = await this.amCaptcha.render();
|
|
67
|
-
|
|
68
|
-
} else {
|
|
69
|
-
throw "Can't find recaptcha rendering element.";
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
submit() {
|
|
74
|
-
// Set busy to true and reset error validations
|
|
75
|
-
this.busy = true;
|
|
76
|
-
this.errors = {};
|
|
77
|
-
|
|
78
|
-
// Get all form fields
|
|
79
|
-
let formData = new FormData();
|
|
80
|
-
|
|
81
|
-
let fieldNames = Object.keys(this.fields);
|
|
82
|
-
|
|
83
|
-
// Append all fields to formData
|
|
84
|
-
fieldNames.forEach((field, i) => {
|
|
85
|
-
if (typeof this.fields[field] === "object") {
|
|
86
|
-
this.fields[field].forEach((item, index) => {
|
|
87
|
-
formData.append(`${field}[${index}]`, item);
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
90
|
-
formData.append(field, this.fields[field]);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Check if filepond is enabled
|
|
95
|
-
if (options.fileUpload.filepond) {
|
|
96
|
-
options.fileUpload.filepond.getFiles().forEach((file, i) => {
|
|
97
|
-
formData.append(`files[${i}]`, file.file, file.name);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
// Check if normal file upload is enabled
|
|
101
|
-
else if (options.fileUpload.el) {
|
|
102
|
-
let inputElement = document.querySelector(options.fileUpload.el);
|
|
28
|
+
for (const options of formsOption) {
|
|
29
|
+
let mergedOptions = Object.assign({}, hapiOptions, options);
|
|
30
|
+
document.addEventListener("alpine:init", alpineInitData(mergedOptions));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
103
34
|
|
|
104
|
-
|
|
35
|
+
async function renderCaptcha(a) {
|
|
36
|
+
if (a.captchaId) {
|
|
37
|
+
// find the rending element
|
|
38
|
+
let recaptcha_el = document.getElementById(a.captchaId);
|
|
39
|
+
if (recaptcha_el) {
|
|
40
|
+
a.amCaptcha = new AMCaptcha({
|
|
41
|
+
theme: this.recaptchaTheme,
|
|
42
|
+
render_element_or_id: recaptcha_el
|
|
43
|
+
});
|
|
44
|
+
a.widgetId = await a.amCaptcha.render();
|
|
45
|
+
|
|
46
|
+
} else {
|
|
47
|
+
// console.error( "Can't find recaptcha rendering element. by id: " + a.captchaId);
|
|
48
|
+
throw "Can't find recaptcha rendering element. by id: " + this.captchaId;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
105
52
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
53
|
+
function displayHapiformInformation(a) {
|
|
54
|
+
console.log("📢 Form name: " + a.name);
|
|
55
|
+
// Display redirect path
|
|
56
|
+
if (typeof a.redirectTo !== "function" && a.redirectTo.length) {
|
|
57
|
+
let endpoint = new URL(a.endpoint);
|
|
110
58
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
formData.append("x_origin", currentUrl.origin + currentUrl.pathname);
|
|
115
|
-
|
|
116
|
-
const defaultConfig = {
|
|
117
|
-
method: "POST",
|
|
118
|
-
url: getEndpoint(options.endpoint),
|
|
119
|
-
data: formData,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const config = Object.assign({}, defaultConfig, options.config);
|
|
123
|
-
|
|
124
|
-
if (this.captchaId) {
|
|
125
|
-
|
|
126
|
-
verifyRecaptcha(this.amCaptcha)
|
|
127
|
-
.then(() => {
|
|
128
|
-
// do submission
|
|
129
|
-
axios(config)
|
|
130
|
-
.then((res) => {
|
|
131
|
-
if (options.redirectTo) {
|
|
132
|
-
window.location.href = options.redirectTo;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Remove files from filepond
|
|
136
|
-
if (options.fileUpload.filepond) {
|
|
137
|
-
options.fileUpload.filepond.removeFiles();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
clearFiles();
|
|
141
|
-
this.resetFields();
|
|
142
|
-
options.onSuccess(res);
|
|
143
|
-
successEvent();
|
|
144
|
-
})
|
|
145
|
-
.catch((err) => {
|
|
146
|
-
this.errors = err.response.data.errors;
|
|
147
|
-
this.busy = false;
|
|
148
|
-
options.onFailed(err.response);
|
|
149
|
-
errorEvent();
|
|
150
|
-
if (this.captchaId) this.amCaptcha.reset(this.widgetId);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
})
|
|
154
|
-
.catch((error) => {
|
|
155
|
-
this.errors = error;
|
|
156
|
-
// failed method
|
|
157
|
-
options.onFailed(error);
|
|
158
|
-
this.busy = false;
|
|
159
|
-
})
|
|
160
|
-
.finally(() => {
|
|
161
|
-
this.amCaptcha.reset(this.widgetId);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
resetFields() {
|
|
166
|
-
this.errors = {};
|
|
167
|
-
this.fields = options.fields;
|
|
168
|
-
this.busy = false;
|
|
169
|
-
if (this.captchaId) this.amCaptcha.reset(this.widgetId);
|
|
170
|
-
},
|
|
171
|
-
}));
|
|
172
|
-
|
|
173
|
-
// Display redirect path
|
|
174
|
-
if (hapiOptions.redirectTo && hapiOptions.endpoint) {
|
|
175
|
-
let endpoint = new URL(hapiOptions.endpoint);
|
|
176
|
-
|
|
177
|
-
if (endpoint.host === "hapiform.sg") {
|
|
178
|
-
console.log("🚀 " + window.location.origin + hapiOptions.redirectTo);
|
|
179
|
-
}
|
|
59
|
+
if (endpoint.host === "hapiform.sg") {
|
|
60
|
+
console.log("🚀 " + window.location.origin + a.redirectTo);
|
|
180
61
|
}
|
|
62
|
+
}
|
|
181
63
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
64
|
+
// Display the endpoint
|
|
65
|
+
if (a.endpoint) {
|
|
66
|
+
let endpoint = new URL(a.endpoint);
|
|
67
|
+
let uuid = a.endpoint.match(/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/);
|
|
186
68
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
69
|
+
if (endpoint.host === "hapiform.sg") {
|
|
70
|
+
console.log(`🚀 ${endpoint.origin}/${uuid}`);
|
|
190
71
|
}
|
|
191
|
-
}
|
|
72
|
+
}
|
|
192
73
|
}
|
|
193
74
|
|
|
194
|
-
async function
|
|
75
|
+
async function verifyCaptcha(a) {
|
|
195
76
|
// 1. get response of recaptcha
|
|
196
|
-
const token =
|
|
77
|
+
const token = a.amCaptcha.fetchResponse(a.widgetId);
|
|
197
78
|
if (token.length === 0) {
|
|
198
|
-
throw {recaptchaError:"You can't leave Captcha Code empty"};
|
|
79
|
+
throw {recaptchaError: "You can't leave Captcha Code empty"};
|
|
199
80
|
}
|
|
200
81
|
// 2. verify recaptcha
|
|
201
|
-
return await
|
|
82
|
+
return await a.amCaptcha.verifyRecaptcha(token)
|
|
202
83
|
.then((data) => {
|
|
203
84
|
if (data.success === false) {
|
|
204
|
-
throw {recaptchaError:"captcha invalid: timeout or duplicate."};
|
|
85
|
+
throw {recaptchaError: "captcha invalid: timeout or duplicate."};
|
|
205
86
|
}
|
|
206
87
|
});
|
|
207
88
|
}
|
|
208
89
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
90
|
+
function onSubmission(config, a) {
|
|
91
|
+
axios(config)
|
|
92
|
+
.then((res) => {
|
|
93
|
+
if (a.redirectTo) {
|
|
94
|
+
window.location.href = a.redirectTo;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Remove files from filepond
|
|
98
|
+
if (a.fileUpload.filepond) {
|
|
99
|
+
a.fileUpload.filepond.removeFiles();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
clearFiles();
|
|
103
|
+
a.resetFields();
|
|
104
|
+
a.onSuccess(res);
|
|
105
|
+
successEvent();
|
|
106
|
+
})
|
|
107
|
+
.catch((err) => {
|
|
108
|
+
a.errors = err.response.data.errors;
|
|
109
|
+
a.busy = false;
|
|
110
|
+
a.onFailed(err.response);
|
|
111
|
+
errorEvent();
|
|
112
|
+
if (a.captchaId) a.amCaptcha.reset(a.widgetId);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function alpineInitData(options) {
|
|
117
|
+
Alpine.data(options.name, () => ({
|
|
118
|
+
...options,
|
|
119
|
+
errors: {},
|
|
120
|
+
busy: false,
|
|
121
|
+
amCaptcha: null,
|
|
122
|
+
widgetId: null,
|
|
123
|
+
async init() {
|
|
124
|
+
|
|
125
|
+
// todo: remove special characters
|
|
126
|
+
Alpine.store(options.name, {fields: {}});
|
|
127
|
+
|
|
128
|
+
this.$watch("busy", (value) => {
|
|
129
|
+
let buttons = this.$el.querySelectorAll('form button, form input[type="submit"], form input[type="button"]');
|
|
130
|
+
|
|
131
|
+
if (value) {
|
|
132
|
+
buttons.forEach((button) => {
|
|
133
|
+
button.disabled = true;
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
buttons.forEach((button) => {
|
|
137
|
+
button.disabled = false;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
this.$init ? this.$init() : null;
|
|
143
|
+
|
|
144
|
+
renderCaptcha(this).catch((err) => console.error(err));
|
|
145
|
+
|
|
146
|
+
displayHapiformInformation(this);
|
|
147
|
+
|
|
148
|
+
},
|
|
149
|
+
async submit() {
|
|
150
|
+
// Set busy to true and reset error validations
|
|
151
|
+
this.busy = true;
|
|
152
|
+
this.errors = {};
|
|
153
|
+
|
|
154
|
+
// Get all form fields
|
|
155
|
+
let formData = new FormData();
|
|
156
|
+
|
|
157
|
+
let fieldsStore = Alpine.store(this.name).fields;
|
|
158
|
+
let fieldNames = Object.keys(fieldsStore);
|
|
159
|
+
|
|
160
|
+
// Append all fields to formData
|
|
161
|
+
fieldNames.forEach((field, i) => {
|
|
162
|
+
if (typeof fieldsStore[field] === "object") {
|
|
163
|
+
fieldsStore[field].forEach((item, index) => {
|
|
164
|
+
formData.append(`${field}[${index}]`, item);
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
formData.append(field, fieldsStore[field]);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Check if filepond is enabled
|
|
172
|
+
if (options.fileUpload.filepond) {
|
|
173
|
+
options.fileUpload.filepond.getFiles().forEach((file, i) => {
|
|
174
|
+
formData.append(`files[${i}]`, file.file, file.name);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// Check if normal file upload is enabled
|
|
178
|
+
else if (options.fileUpload.el) {
|
|
179
|
+
let inputElement = document.querySelector(options.fileUpload.el);
|
|
180
|
+
|
|
181
|
+
let fileList = inputElement.files;
|
|
182
|
+
|
|
183
|
+
for (let i = 0; i < fileList.length; i++) {
|
|
184
|
+
formData.append(`files[${i}]`, fileList[i], fileList[i].name);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Append x_origin to formData
|
|
189
|
+
let currentUrl = new URL(window.top.location.href);
|
|
190
|
+
|
|
191
|
+
formData.append("x_origin", currentUrl.origin + currentUrl.pathname);
|
|
192
|
+
|
|
193
|
+
const defaultConfig = {
|
|
194
|
+
method: "POST",
|
|
195
|
+
url: getEndpoint(options.endpoint),
|
|
196
|
+
data: formData,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const config = Object.assign({}, defaultConfig, options.config);
|
|
200
|
+
|
|
201
|
+
if (this.captchaId) { // with captcha
|
|
202
|
+
await verifyCaptcha(this)
|
|
203
|
+
.then(() => {
|
|
204
|
+
// do submission
|
|
205
|
+
onSubmission(config, this);
|
|
206
|
+
})
|
|
207
|
+
.catch((error) => {
|
|
208
|
+
this.errors = error;
|
|
209
|
+
// failed method
|
|
210
|
+
options.onFailed(error);
|
|
211
|
+
this.busy = false;
|
|
212
|
+
})
|
|
213
|
+
.finally(() => {
|
|
214
|
+
// this.amCaptcha.reset(this.widgetId);
|
|
215
|
+
});
|
|
216
|
+
} else { // without captcha
|
|
217
|
+
onSubmission(config, this);
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
resetFields() {
|
|
221
|
+
this.errors = {};
|
|
222
|
+
// this.fields = options.fields;
|
|
223
|
+
Alpine.store(this.name).fields = {};
|
|
224
|
+
this.busy = false;
|
|
225
|
+
if (this.captchaId) this.amCaptcha.reset(this.widgetId);
|
|
226
|
+
},
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
|
|
234
230
|
|
|
235
231
|
function clearFiles() {
|
|
236
232
|
clearFilepondFiles();
|
|
@@ -277,4 +273,4 @@ function getEndpoint(endpoint) {
|
|
|
277
273
|
return url.href;
|
|
278
274
|
}
|
|
279
275
|
|
|
280
|
-
export {
|
|
276
|
+
export {forms};
|
package/src/recaptcha.js
CHANGED
package/enquiry-form.js
DELETED
package/index.html
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport"
|
|
6
|
-
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
|
7
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
8
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
|
|
9
|
-
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
|
10
|
-
<title>Document</title>
|
|
11
|
-
<style>
|
|
12
|
-
form {
|
|
13
|
-
width: 500px;
|
|
14
|
-
margin: 10px auto;
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
<body>
|
|
19
|
-
<h1>Test</h1>
|
|
20
|
-
<form x-on:submit.prevent="submit" x-data="contactForm">
|
|
21
|
-
<div>
|
|
22
|
-
<div class="mb-3">
|
|
23
|
-
<div class="form-field">
|
|
24
|
-
<label for="form01-name" class="form-label">Name</label>
|
|
25
|
-
<input type="text" id="form01-name" x-model="fields.name"
|
|
26
|
-
placeholder="Name" class="form-control">
|
|
27
|
-
</div>
|
|
28
|
-
<template x-if="errors && errors.name">
|
|
29
|
-
<div x-text="errors.name" class="text-danger"></div>
|
|
30
|
-
</template>
|
|
31
|
-
</div>
|
|
32
|
-
<div class="mb-3">
|
|
33
|
-
<div class="form-field">
|
|
34
|
-
<label for="form01-contact_number" class="form-label">Contact Number</label>
|
|
35
|
-
<input type="tel" id="form01-contact_number" x-model="fields.contact_number"
|
|
36
|
-
placeholder="Contact Number" class="form-control">
|
|
37
|
-
|
|
38
|
-
</div>
|
|
39
|
-
<template x-if="errors && errors.contact_number">
|
|
40
|
-
<div x-text="errors.contact_number" class="text-danger"></div>
|
|
41
|
-
</template>
|
|
42
|
-
</div>
|
|
43
|
-
<div class="mb-3">
|
|
44
|
-
<div class="form-field">
|
|
45
|
-
<label for="form01-email" class="form-label">Email</label>
|
|
46
|
-
<input type="email" id="form01-email" x-model="fields.email"
|
|
47
|
-
placeholder="Email" class="form-control">
|
|
48
|
-
</div>
|
|
49
|
-
<template x-if="errors && errors.email">
|
|
50
|
-
<div x-text="errors.email" class="text-danger"></div>
|
|
51
|
-
</template>
|
|
52
|
-
</div>
|
|
53
|
-
<div class="mb-3">
|
|
54
|
-
<div class="form-field">
|
|
55
|
-
<select class="form-select" id="form01-specialist" x-model="fields.specialist">
|
|
56
|
-
<option value="" selected>Preferred Specialist</option>
|
|
57
|
-
<option value="Dr Dennis Koh">Dr Dennis Koh</option>
|
|
58
|
-
<option value="Dr Sharon Koh">Dr Sharon Koh</option>
|
|
59
|
-
<option value="Dr Pauleon Tan">Dr Pauleon Tan</option>
|
|
60
|
-
<option value="No Preference">No Preference</option>
|
|
61
|
-
</select>
|
|
62
|
-
</div>
|
|
63
|
-
<template x-if="errors && errors.specialist">
|
|
64
|
-
<div x-text="errors.specialist" class="text-danger"></div>
|
|
65
|
-
</template>
|
|
66
|
-
</div>
|
|
67
|
-
<div class="mb-3">
|
|
68
|
-
<div class="form-field">
|
|
69
|
-
<label for="form01-message" class="form-label">Message</label>
|
|
70
|
-
<textarea id="form01-message" x-model="fields.message" rows="4"
|
|
71
|
-
placeholder="Message" class="form-control form-textarea"></textarea>
|
|
72
|
-
|
|
73
|
-
</div>
|
|
74
|
-
<template x-if="errors && errors.message">
|
|
75
|
-
<div x-text="errors.message" class="text-danger"></div>
|
|
76
|
-
</template>
|
|
77
|
-
</div>
|
|
78
|
-
<div class="mb-3">
|
|
79
|
-
<div id="captcha-01"></div>
|
|
80
|
-
<template x-if="errors && errors.recaptchaError">
|
|
81
|
-
<div x-text="errors.recaptchaError" class="text-danger"></div>
|
|
82
|
-
</template>
|
|
83
|
-
</div>
|
|
84
|
-
<div class="mb-3">
|
|
85
|
-
<button type="submit" class="btn btn-primary">
|
|
86
|
-
Submit
|
|
87
|
-
<svg x-show="busy" class="form-loading" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
|
|
88
|
-
<defs>
|
|
89
|
-
<linearGradient x1="8.042%" y1="0%" x2="65.682%" y2="23.865%" id="a">
|
|
90
|
-
<stop stop-color="#fff" stop-opacity="0" offset="0%"/>
|
|
91
|
-
<stop stop-color="#fff" stop-opacity=".631" offset="63.146%"/>
|
|
92
|
-
<stop stop-color="#fff" offset="100%"/>
|
|
93
|
-
</linearGradient>
|
|
94
|
-
</defs>
|
|
95
|
-
<g fill="none" fill-rule="evenodd">
|
|
96
|
-
<g transform="translate(1 1)">
|
|
97
|
-
<path d="M36 18c0-9.94-8.06-18-18-18" id="Oval-2" stroke="url(#a)" stroke-width="2">
|
|
98
|
-
<animateTransform
|
|
99
|
-
attributeName="transform"
|
|
100
|
-
type="rotate"
|
|
101
|
-
from="0 18 18"
|
|
102
|
-
to="360 18 18"
|
|
103
|
-
dur="0.9s"
|
|
104
|
-
repeatCount="indefinite"/>
|
|
105
|
-
</path>
|
|
106
|
-
<circle fill="#fff" cx="36" cy="18" r="1">
|
|
107
|
-
<animateTransform
|
|
108
|
-
attributeName="transform"
|
|
109
|
-
type="rotate"
|
|
110
|
-
from="0 18 18"
|
|
111
|
-
to="360 18 18"
|
|
112
|
-
dur="0.9s"
|
|
113
|
-
repeatCount="indefinite"/>
|
|
114
|
-
</circle>
|
|
115
|
-
</g>
|
|
116
|
-
</g>
|
|
117
|
-
</svg>
|
|
118
|
-
</button>
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
</form>
|
|
122
|
-
|
|
123
|
-
<script src="dist/hapi.min.js" defer></script>
|
|
124
|
-
<script src="enquiry-form.js" defer></script>
|
|
125
|
-
|
|
126
|
-
</body>
|
|
127
|
-
</html>
|
package/readme.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# HAPI Form Plugin
|
|
2
|
-
Wrapper of Alpine JS plugin for HAPI Form, works on Laravel API endpoint.
|
|
3
|
-
## CDN
|
|
4
|
-
```html
|
|
5
|
-
<script src="https://unpkg.com/chenghuichao/hapi-recaptcha-html@latest/dist/hapi.min.js"></script>
|
|
6
|
-
```
|
|
7
|
-
|
|
8
|
-
## Usage
|
|
9
|
-
```html
|
|
10
|
-
|
|
11
|
-
<script>
|
|
12
|
-
Hapi.form({
|
|
13
|
-
name: "",
|
|
14
|
-
endpoint: "",
|
|
15
|
-
redirectTo: "",
|
|
16
|
-
fileUpload: {
|
|
17
|
-
filepond: filepondObject,
|
|
18
|
-
el: '#files'
|
|
19
|
-
},
|
|
20
|
-
captchaId: null,
|
|
21
|
-
recaptchaTheme: 'light',
|
|
22
|
-
onSuccess(res) {
|
|
23
|
-
},
|
|
24
|
-
onFailed(err) {
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
</script>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
- name – The name of the instance, to be matched with `x-data="name"`.
|
|
31
|
-
- endpoint – The form endpoint URL generated from the backend.
|
|
32
|
-
- redirectTo – Location to be redirected after success. Eg: "/thank-you" or "https://example.com". (Optional)
|
|
33
|
-
- fileUpload
|
|
34
|
-
- filepond – Filepond object. (Filepond plugin required)
|
|
35
|
-
- el – Select `input` element if you're using normal upload.
|
|
36
|
-
- captchaId - Id of div element to render the google recaptcha, `null` means recaptcha is disabled.
|
|
37
|
-
- recaptchaTheme - `light` or `dark`.
|
|
38
|
-
- onSuccess() – On success event.
|
|
39
|
-
- onFailed() – On failed event.
|
|
40
|
-
- errors.recaptchaError - to display captcha verification errors.
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
## Events
|
|
62
|
-
|
|
63
|
-
### Success Event
|
|
64
|
-
When submission is success, Hapi will emit `hapi:success` event.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
### Error Event
|
|
68
|
-
When submission has error, Hapi will emit `hapi:error` event.
|