ordering-ui-external 1.5.3 → 1.5.5
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/_bundles/0.ordering-ui.cb87b9b647114f245c57.js +1 -0
- package/_bundles/{1.ordering-ui.5de718771fdf8a9bc402.js → 1.ordering-ui.cb87b9b647114f245c57.js} +0 -0
- package/_bundles/{2.ordering-ui.5de718771fdf8a9bc402.js → 2.ordering-ui.cb87b9b647114f245c57.js} +0 -0
- package/_bundles/{4.ordering-ui.5de718771fdf8a9bc402.js → 4.ordering-ui.cb87b9b647114f245c57.js} +0 -0
- package/_bundles/{5.ordering-ui.5de718771fdf8a9bc402.js → 5.ordering-ui.cb87b9b647114f245c57.js} +1 -1
- package/_bundles/{6.ordering-ui.5de718771fdf8a9bc402.js → 6.ordering-ui.cb87b9b647114f245c57.js} +0 -0
- package/_bundles/{7.ordering-ui.5de718771fdf8a9bc402.js → 7.ordering-ui.cb87b9b647114f245c57.js} +2 -2
- package/_bundles/{7.ordering-ui.5de718771fdf8a9bc402.js.LICENSE.txt → 7.ordering-ui.cb87b9b647114f245c57.js.LICENSE.txt} +0 -0
- package/_bundles/{8.ordering-ui.5de718771fdf8a9bc402.js → 8.ordering-ui.cb87b9b647114f245c57.js} +0 -0
- package/_bundles/{9.ordering-ui.5de718771fdf8a9bc402.js → 9.ordering-ui.cb87b9b647114f245c57.js} +0 -0
- package/_bundles/ordering-ui.cb87b9b647114f245c57.js +2 -0
- package/_bundles/{ordering-ui.5de718771fdf8a9bc402.js.LICENSE.txt → ordering-ui.cb87b9b647114f245c57.js.LICENSE.txt} +0 -0
- package/_modules/styles/Switch/index.js +46 -0
- package/_modules/styles/Switch/styles.js +23 -0
- package/_modules/themes/five/src/components/Cart/index.js +13 -2
- package/_modules/themes/five/src/components/ServiceForm/index.js +33 -7
- package/_modules/themes/five/src/components/ServiceForm/styles.js +8 -3
- package/package.json +2 -2
- package/src/styles/Switch/index.js +39 -0
- package/src/styles/Switch/styles.js +58 -0
- package/src/themes/five/src/components/Cart/index.js +24 -9
- package/src/themes/five/src/components/ServiceForm/index.js +162 -139
- package/src/themes/five/src/components/ServiceForm/styles.js +10 -0
- package/_bundles/0.ordering-ui.5de718771fdf8a9bc402.js +0 -1
- package/_bundles/ordering-ui.5de718771fdf8a9bc402.js +0 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { Swiper, SwiperSlide } from 'swiper/react'
|
|
3
3
|
import { useUtils, useLanguage, useSession, ProductForm as ProductFormController } from 'ordering-components-external'
|
|
4
|
+
import Skeleton from 'react-loading-skeleton'
|
|
4
5
|
import { Alert } from '../Confirm'
|
|
5
6
|
import { Modal } from '../Modal'
|
|
6
7
|
import { LoginForm } from '../LoginForm'
|
|
@@ -34,22 +35,25 @@ import {
|
|
|
34
35
|
StatusInfo,
|
|
35
36
|
DropDownWrapper,
|
|
36
37
|
DropDownTitle,
|
|
37
|
-
EmptyProfessional
|
|
38
|
+
EmptyProfessional,
|
|
39
|
+
SkeletonBlock
|
|
38
40
|
} from './styles'
|
|
39
41
|
import moment from 'moment'
|
|
40
42
|
SwiperCore.use([Navigation])
|
|
41
43
|
|
|
42
44
|
const ServiceFormUI = (props) => {
|
|
43
45
|
const {
|
|
44
|
-
|
|
46
|
+
productObject,
|
|
45
47
|
professionalSelected,
|
|
46
48
|
handleSave,
|
|
47
49
|
isSoldOut,
|
|
48
50
|
maxProductQuantity,
|
|
49
51
|
productCart,
|
|
50
|
-
|
|
52
|
+
isCartProduct,
|
|
53
|
+
professionalListState
|
|
51
54
|
} = props
|
|
52
55
|
|
|
56
|
+
const { product, loading, error } = productObject
|
|
53
57
|
const theme = useTheme()
|
|
54
58
|
const [, t] = useLanguage()
|
|
55
59
|
const [{ parsePrice, parseDate }] = useUtils()
|
|
@@ -151,102 +155,84 @@ const ServiceFormUI = (props) => {
|
|
|
151
155
|
}, [isDropDown])
|
|
152
156
|
|
|
153
157
|
useEffect(() => {
|
|
154
|
-
if (!professionalSelected) return
|
|
158
|
+
if (!professionalSelected?.schedule) return
|
|
155
159
|
setCurrentProfessional(professionalSelected)
|
|
156
160
|
}, [professionalSelected])
|
|
157
161
|
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (isCartProduct && professionalListState?.professionals?.length > 0) {
|
|
164
|
+
const professional = professionalListState?.professionals?.find(item => item.id === professionalSelected?.id)
|
|
165
|
+
setCurrentProfessional(professional)
|
|
166
|
+
}
|
|
167
|
+
}, [isCartProduct, professionalListState?.professionals])
|
|
168
|
+
|
|
158
169
|
return (
|
|
159
170
|
<>
|
|
160
171
|
<Container>
|
|
161
|
-
|
|
162
|
-
<
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
{isBusyTime(currentProfessional) ? (
|
|
216
|
-
<>
|
|
217
|
-
<span className='status'>{t('BUSY_ON_SELECTED_TIME', 'Busy on selected time')}</span>
|
|
218
|
-
</>
|
|
219
|
-
) : (
|
|
220
|
-
<span className='status'>{t('AVAILABLE', 'Available')}</span>
|
|
221
|
-
)}
|
|
222
|
-
</StatusInfo>
|
|
223
|
-
</NameWrapper>
|
|
224
|
-
</InfoWrapper>
|
|
225
|
-
) : (
|
|
226
|
-
<p>{t('SELECT_PROFESSIONAL', 'Select professional')}</p>
|
|
227
|
-
)}
|
|
228
|
-
<ChevronDown />
|
|
229
|
-
</SelectedItem>
|
|
230
|
-
{isDropDown && (
|
|
231
|
-
<DropDownWrapper>
|
|
232
|
-
<DropDownTitle>{t('ANY_PROFESSIONAL_MEMBER', 'Any professional member')}</DropDownTitle>
|
|
233
|
-
{professionalList?.map((professional) => (
|
|
234
|
-
<SelectedItem
|
|
235
|
-
key={professional?.id}
|
|
236
|
-
isDropDown
|
|
237
|
-
active={professional?.id === currentProfessional?.id}
|
|
238
|
-
onClick={() => handleChangeProfessional(professional)}
|
|
239
|
-
>
|
|
172
|
+
{loading && !error && (
|
|
173
|
+
<SkeletonBlock width={90}>
|
|
174
|
+
<Skeleton variant='rect' height={50} />
|
|
175
|
+
<Skeleton variant='rect' height={50} />
|
|
176
|
+
<Skeleton variant='rect' height={200} />
|
|
177
|
+
</SkeletonBlock>
|
|
178
|
+
)}
|
|
179
|
+
{product && !loading && (
|
|
180
|
+
<>
|
|
181
|
+
<ImageWrapper>
|
|
182
|
+
<SwiperWrapper>
|
|
183
|
+
<ArrowButtonWrapper className='button-prev'>
|
|
184
|
+
<ChevronLeft />
|
|
185
|
+
</ArrowButtonWrapper>
|
|
186
|
+
<Swiper
|
|
187
|
+
spaceBetween={0}
|
|
188
|
+
slidesPerView={1}
|
|
189
|
+
watchSlidesProgress
|
|
190
|
+
className='mySwiper2'
|
|
191
|
+
preventClicksPropagation={false}
|
|
192
|
+
navigation={{
|
|
193
|
+
nextEl: '.button-next',
|
|
194
|
+
prevEl: '.button-prev'
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
{gallery?.map((photo, i) => (
|
|
198
|
+
<SwiperSlide key={i}>
|
|
199
|
+
<img src={photo} alt='' />
|
|
200
|
+
</SwiperSlide>
|
|
201
|
+
))}
|
|
202
|
+
</Swiper>
|
|
203
|
+
<ArrowButtonWrapper className='button-next'>
|
|
204
|
+
<ChevronRight />
|
|
205
|
+
</ArrowButtonWrapper>
|
|
206
|
+
</SwiperWrapper>
|
|
207
|
+
</ImageWrapper>
|
|
208
|
+
<HeaderInfoWrapper>
|
|
209
|
+
<h2>{product?.name}</h2>
|
|
210
|
+
<PriceAndDuration>
|
|
211
|
+
<span>{parsePrice(product?.price)}</span>
|
|
212
|
+
<span className='dot'>•</span>
|
|
213
|
+
<span>{product?.duration}min</span>
|
|
214
|
+
</PriceAndDuration>
|
|
215
|
+
<p>{product?.description}</p>
|
|
216
|
+
</HeaderInfoWrapper>
|
|
217
|
+
<Divider />
|
|
218
|
+
<ProfessionalInfoWrapper>
|
|
219
|
+
<SectionHeader>
|
|
220
|
+
<h2>{t('PROFESSIONALS', 'Professionals')}</h2>
|
|
221
|
+
<span>{t('REQUIRED', 'Required')}</span>
|
|
222
|
+
</SectionHeader>
|
|
223
|
+
<ProfessionalSelectWrapper ref={dropDownRef}>
|
|
224
|
+
<SelectedItem onClick={() => setIsDropDown(prev => !prev)}>
|
|
225
|
+
{currentProfessional ? (
|
|
240
226
|
<InfoWrapper>
|
|
241
|
-
{
|
|
227
|
+
{currentProfessional?.photo ? (
|
|
242
228
|
<ProfessionalPhoto
|
|
243
|
-
bgimage={
|
|
229
|
+
bgimage={currentProfessional?.photo}
|
|
244
230
|
/>
|
|
245
231
|
) : <FaUserAlt />}
|
|
246
232
|
<NameWrapper>
|
|
247
|
-
<p>{
|
|
248
|
-
<StatusInfo available={!isBusyTime(
|
|
249
|
-
{isBusyTime(
|
|
233
|
+
<p>{currentProfessional?.name} {currentProfessional?.lastname}</p>
|
|
234
|
+
<StatusInfo available={!isBusyTime()}>
|
|
235
|
+
{isBusyTime(currentProfessional) ? (
|
|
250
236
|
<>
|
|
251
237
|
<span className='status'>{t('BUSY_ON_SELECTED_TIME', 'Busy on selected time')}</span>
|
|
252
238
|
</>
|
|
@@ -256,58 +242,95 @@ const ServiceFormUI = (props) => {
|
|
|
256
242
|
</StatusInfo>
|
|
257
243
|
</NameWrapper>
|
|
258
244
|
</InfoWrapper>
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
245
|
+
) : (
|
|
246
|
+
<p>{t('SELECT_PROFESSIONAL', 'Select professional')}</p>
|
|
247
|
+
)}
|
|
248
|
+
<ChevronDown />
|
|
249
|
+
</SelectedItem>
|
|
250
|
+
{isDropDown && (
|
|
251
|
+
<DropDownWrapper>
|
|
252
|
+
<DropDownTitle>{t('ANY_PROFESSIONAL_MEMBER', 'Any professional member')}</DropDownTitle>
|
|
253
|
+
{professionalListState?.professionals?.map((professional) => (
|
|
254
|
+
<SelectedItem
|
|
255
|
+
key={professional?.id}
|
|
256
|
+
isDropDown
|
|
257
|
+
active={professional?.id === currentProfessional?.id}
|
|
258
|
+
onClick={() => handleChangeProfessional(professional)}
|
|
259
|
+
>
|
|
260
|
+
<InfoWrapper>
|
|
261
|
+
{professional?.photo ? (
|
|
262
|
+
<ProfessionalPhoto
|
|
263
|
+
bgimage={professional?.photo}
|
|
264
|
+
/>
|
|
265
|
+
) : <FaUserAlt />}
|
|
266
|
+
<NameWrapper>
|
|
267
|
+
<p>{professional?.name} {professional?.lastname}</p>
|
|
268
|
+
<StatusInfo available={!isBusyTime(professional)}>
|
|
269
|
+
{isBusyTime(professional) ? (
|
|
270
|
+
<>
|
|
271
|
+
<span className='status'>{t('BUSY_ON_SELECTED_TIME', 'Busy on selected time')}</span>
|
|
272
|
+
</>
|
|
273
|
+
) : (
|
|
274
|
+
<span className='status'>{t('AVAILABLE', 'Available')}</span>
|
|
275
|
+
)}
|
|
276
|
+
</StatusInfo>
|
|
277
|
+
</NameWrapper>
|
|
278
|
+
</InfoWrapper>
|
|
279
|
+
</SelectedItem>
|
|
280
|
+
))}
|
|
281
|
+
</DropDownWrapper>
|
|
282
|
+
)}
|
|
283
|
+
|
|
284
|
+
</ProfessionalSelectWrapper>
|
|
285
|
+
</ProfessionalInfoWrapper>
|
|
286
|
+
<ScheduleWrapper>
|
|
287
|
+
<SectionHeader>
|
|
288
|
+
<h2>{t('SCHEDULE', 'Schedule')}</h2>
|
|
289
|
+
<span>{t('REQUIRED', 'Required')}</span>
|
|
290
|
+
</SectionHeader>
|
|
291
|
+
{currentProfessional ? (
|
|
292
|
+
<BusinessPreorder
|
|
293
|
+
business={currentProfessional}
|
|
294
|
+
isProfessional
|
|
295
|
+
maxDays={50}
|
|
296
|
+
onChangeMoment={setDateSelected}
|
|
297
|
+
useOrderContext={false}
|
|
298
|
+
/>
|
|
299
|
+
) : (
|
|
300
|
+
<EmptyProfessional>
|
|
301
|
+
{t('NO_SCHEDULE', 'No schedule')}
|
|
302
|
+
</EmptyProfessional>
|
|
303
|
+
)}
|
|
304
|
+
</ScheduleWrapper>
|
|
305
|
+
<ButtonWrapper>
|
|
306
|
+
<span>{dateSelected
|
|
307
|
+
? parseDate(dateSelected, { outputFormat: 'hh:mm a' })
|
|
308
|
+
: t('ASAP_ABBREVIATION', 'ASAP')}
|
|
309
|
+
</span>
|
|
310
|
+
{!isSoldOut && maxProductQuantity > 0 && auth && (
|
|
311
|
+
<Button
|
|
312
|
+
onClick={() => handleAddProduct()}
|
|
313
|
+
color='primary'
|
|
314
|
+
disabled={isBusyTime(currentProfessional)}
|
|
315
|
+
>
|
|
316
|
+
{t('BOOK', 'Book')}
|
|
317
|
+
</Button>
|
|
318
|
+
)}
|
|
319
|
+
{(!auth || isSoldOut || maxProductQuantity <= 0) && (
|
|
320
|
+
<Button
|
|
321
|
+
className={`add ${!(productCart && !isSoldOut && maxProductQuantity > 0) ? 'soldout' : ''}`}
|
|
322
|
+
color='primary'
|
|
323
|
+
outline
|
|
324
|
+
disabled={isSoldOut || maxProductQuantity <= 0}
|
|
325
|
+
onClick={() => setModalIsOpen(true)}
|
|
326
|
+
>
|
|
327
|
+
{isSoldOut || maxProductQuantity <= 0 ? t('SOLD_OUT', theme?.defaultLanguages?.SOLD_OUT || 'Sold out') : t('LOGIN_SIGNUP', theme?.defaultLanguages?.LOGIN_SIGNUP || 'Login / Sign Up')}
|
|
328
|
+
</Button>
|
|
329
|
+
)}
|
|
330
|
+
</ButtonWrapper>
|
|
331
|
+
</>
|
|
332
|
+
)}
|
|
263
333
|
|
|
264
|
-
</ProfessionalSelectWrapper>
|
|
265
|
-
</ProfessionalInfoWrapper>
|
|
266
|
-
<ScheduleWrapper>
|
|
267
|
-
<SectionHeader>
|
|
268
|
-
<h2>{t('SCHEDULE', 'Schedule')}</h2>
|
|
269
|
-
<span>{t('REQUIRED', 'Required')}</span>
|
|
270
|
-
</SectionHeader>
|
|
271
|
-
{currentProfessional ? (
|
|
272
|
-
<BusinessPreorder
|
|
273
|
-
business={currentProfessional}
|
|
274
|
-
isProfessional
|
|
275
|
-
maxDays={50}
|
|
276
|
-
onChangeMoment={setDateSelected}
|
|
277
|
-
useOrderContext={false}
|
|
278
|
-
/>
|
|
279
|
-
) : (
|
|
280
|
-
<EmptyProfessional>
|
|
281
|
-
{t('NO_SCHEDULE', 'No schedule')}
|
|
282
|
-
</EmptyProfessional>
|
|
283
|
-
)}
|
|
284
|
-
</ScheduleWrapper>
|
|
285
|
-
<ButtonWrapper>
|
|
286
|
-
<span>{dateSelected
|
|
287
|
-
? parseDate(dateSelected, { outputFormat: 'hh:mm a' })
|
|
288
|
-
: t('ASAP_ABBREVIATION', 'ASAP')}
|
|
289
|
-
</span>
|
|
290
|
-
{!isSoldOut && maxProductQuantity > 0 && auth && (
|
|
291
|
-
<Button
|
|
292
|
-
onClick={() => handleAddProduct()}
|
|
293
|
-
color='primary'
|
|
294
|
-
disabled={isBusyTime(currentProfessional)}
|
|
295
|
-
>
|
|
296
|
-
{t('BOOK', 'Book')}
|
|
297
|
-
</Button>
|
|
298
|
-
)}
|
|
299
|
-
{(!auth || isSoldOut || maxProductQuantity <= 0) && (
|
|
300
|
-
<Button
|
|
301
|
-
className={`add ${!(productCart && !isSoldOut && maxProductQuantity > 0) ? 'soldout' : ''}`}
|
|
302
|
-
color='primary'
|
|
303
|
-
outline
|
|
304
|
-
disabled={isSoldOut || maxProductQuantity <= 0}
|
|
305
|
-
onClick={() => setModalIsOpen(true)}
|
|
306
|
-
>
|
|
307
|
-
{isSoldOut || maxProductQuantity <= 0 ? t('SOLD_OUT', theme?.defaultLanguages?.SOLD_OUT || 'Sold out') : t('LOGIN_SIGNUP', theme?.defaultLanguages?.LOGIN_SIGNUP || 'Login / Sign Up')}
|
|
308
|
-
</Button>
|
|
309
|
-
)}
|
|
310
|
-
</ButtonWrapper>
|
|
311
334
|
{modalIsOpen && !auth && (
|
|
312
335
|
<Modal
|
|
313
336
|
open={modalIsOpen}
|
|
@@ -311,3 +311,13 @@ export const EmptyProfessional = styled.div`
|
|
|
311
311
|
align-items: center;
|
|
312
312
|
justify-content: center;
|
|
313
313
|
`
|
|
314
|
+
|
|
315
|
+
export const SkeletonBlock = styled.div`
|
|
316
|
+
width: ${({ width }) => width && `${width}%`};
|
|
317
|
+
border-radius: 16px;
|
|
318
|
+
margin: 50px auto 20px auto;
|
|
319
|
+
|
|
320
|
+
span {
|
|
321
|
+
margin-bottom: 10px;
|
|
322
|
+
}
|
|
323
|
+
`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(window.webpackJsonpOrderingUI=window.webpackJsonpOrderingUI||[]).push([[0],{596:function(t,n,e){"use strict";function i(t,n){var e,i;return"boolean"==typeof(null==n?void 0:n.enabled)?n.enabled:null===(i=null===(e=null==t?void 0:t.__default)||void 0===e?void 0:e.enabled)||void 0===i||i}e.d(n,"a",(function(){return i}))},698:function(t,n,e){"use strict";e.r(n),e.d(n,"LegacyDestination",(function(){return O})),e.d(n,"ajsDestinations",(function(){return _}));var i=e(3),r=e(55),o=e(46),a=e(18),s=e(101),c=e(64),u=e(63),d=e(596),l=e(189),h=e(193),v=e(47),f=e(69),b=e(335),p=e(85),g=e(106);function y(t){return t.toLowerCase().replace(".","").replace(/\s+/g,"-")}function j(t,n){return void 0===n&&(n=!1),n?btoa(t).replace(/=/g,""):void 0}function m(t,n,e,r,o,a){return Object(i.b)(this,void 0,void 0,(function(){var s,c,u,d,l,h,v,f;return Object(i.d)(this,(function(b){switch(b.label){case 0:s=y(e),c=j(s,a),u=Object(p.b)(),d="".concat(u,"/integrations/").concat(null!=c?c:s,"/").concat(r,"/").concat(null!=c?c:s,".dynamic.js.gz"),b.label=1;case 1:return b.trys.push([1,3,,4]),[4,Object(g.a)(d)];case 2:return b.sent(),function(t,n,e){var r,o;try{var a=(null!==(o=null===(r=null===window||void 0===window?void 0:window.performance)||void 0===r?void 0:r.getEntriesByName(t,"resource"))&&void 0!==o?o:[])[0];a&&n.stats.gauge("legacy_destination_time",Math.round(a.duration),Object(i.f)([e],a.duration<100?["cached"]:[],!0))}catch(t){}}(d,t,e),[3,4];case 3:throw l=b.sent(),t.stats.gauge("legacy_destination_time",-1,["plugin:".concat(e),"failed"]),l;case 4:return h=window["".concat(s,"Deps")],[4,Promise.all(h.map((function(t){return Object(g.a)(u+t+".gz")})))];case 5:return b.sent(),window["".concat(s,"Loader")](),(v=window["".concat(s,"Integration")]).Integration&&(v({user:function(){return n.user()},addIntegration:function(){}}),v=v.Integration),(f=new v(o)).analytics=n,[2,f]}}))}))}function w(t,n){return Object(i.b)(this,void 0,void 0,(function(){var e,r=this;return Object(i.d)(this,(function(s){switch(s.label){case 0:return e=[],Object(o.a)()?[2,n]:[4,Object(h.a)((function(){return n.length>0&&Object(o.b)()}),(function(){return Object(i.b)(r,void 0,void 0,(function(){var r,o;return Object(i.d)(this,(function(i){switch(i.label){case 0:return(r=n.pop())?[4,Object(c.a)(r,t)]:[2];case 1:return o=i.sent(),o instanceof a.a||e.push(r),[2]}}))}))}))];case 1:return s.sent(),e.map((function(t){return n.pushWithBackoff(t)})),[2,n]}}))}))}var O=function(){function t(t,n,e,r){void 0===e&&(e={}),this.options={},this.type="destination",this.middleware=[],this._ready=!1,this._initialized=!1,this.flushing=!1,this.name=t,this.version=n,this.settings=Object(i.a)({},e),this.settings.type&&"browser"===this.settings.type&&delete this.settings.type,this.options=r,this.buffer=r.disableClientPersistence?new v.b(4,[]):new f.a(4,"dest-".concat(t)),this.scheduleFlush()}return t.prototype.isLoaded=function(){return this._ready},t.prototype.ready=function(){var t;return null!==(t=this.onReady)&&void 0!==t?t:Promise.resolve()},t.prototype.load=function(t,n){return Object(i.b)(this,void 0,void 0,(function(){var e,r=this;return Object(i.d)(this,(function(i){switch(i.label){case 0:return this._ready||void 0!==this.onReady?[2]:(e=this,[4,m(t,n,this.name,this.version,this.settings,this.options.obfuscate)]);case 1:e.integration=i.sent(),this.onReady=new Promise((function(t){r.integration.once("ready",(function(){r._ready=!0,t(!0)}))})),this.onInitialize=new Promise((function(t){r.integration.on("initialize",(function(){r._initialized=!0,t(!0)}))}));try{t.stats.increment("analytics_js.integration.invoke",1,["method:initialize","integration_name:".concat(this.name)]),this.integration.initialize()}catch(n){throw t.stats.increment("analytics_js.integration.invoke.error",1,["method:initialize","integration_name:".concat(this.name)]),n}return[2]}}))}))},t.prototype.unload=function(t,n){return function(t,n,e){return Object(i.b)(this,void 0,void 0,(function(){var r,o,a,s;return Object(i.d)(this,(function(i){return r=Object(p.b)(),o=y(t),a=j(t,e),s="".concat(r,"/integrations/").concat(null!=a?a:o,"/").concat(n,"/").concat(null!=a?a:o,".dynamic.js.gz"),[2,Object(g.b)(s)]}))}))}(this.name,this.version,this.options.obfuscate)},t.prototype.addMiddleware=function(){for(var t,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];this.middleware=(t=this.middleware).concat.apply(t,n)},t.prototype.shouldBuffer=function(t){return"page"!==t.event.type&&(Object(o.a)()||!1===this._ready||!1===this._initialized)},t.prototype.send=function(t,n,e){var r,o;return Object(i.b)(this,void 0,void 0,(function(){var s,c,l,h,v,f;return Object(i.d)(this,(function(p){switch(p.label){case 0:if(this.shouldBuffer(t))return this.buffer.push(t),this.scheduleFlush(),[2,t];if(s=null===(o=null===(r=this.options)||void 0===r?void 0:r.plan)||void 0===o?void 0:o.track,c=t.event.event,s&&c&&"Segment.io"!==this.name){if(l=s[c],!Object(d.a)(s,l))return t.updateEvent("integrations",Object(i.a)(Object(i.a)({},t.event.integrations),{All:!1,"Segment.io":!0})),t.cancel(new a.b({retry:!1,reason:"Event ".concat(c," disabled for integration ").concat(this.name," in tracking plan"),type:"Dropped by plan"})),[2,t];if(t.updateEvent("integrations",Object(i.a)(Object(i.a)({},t.event.integrations),null==l?void 0:l.integrations)),(null==l?void 0:l.enabled)&&!1===(null==l?void 0:l.integrations[this.name]))return t.cancel(new a.b({retry:!1,reason:"Event ".concat(c," disabled for integration ").concat(this.name," in tracking plan"),type:"Dropped by plan"})),[2,t]}return[4,Object(b.applyDestinationMiddleware)(this.name,t.event,this.middleware)];case 1:if(null===(h=p.sent()))return[2,t];v=new n(h,{}),t.stats.increment("analytics_js.integration.invoke",1,["method:".concat(e),"integration_name:".concat(this.name)]),p.label=2;case 2:return p.trys.push([2,5,,6]),this.integration?[4,Object(u.a)(this.integration.invoke.call(this.integration,e,v))]:[3,4];case 3:p.sent(),p.label=4;case 4:return[3,6];case 5:throw f=p.sent(),t.stats.increment("analytics_js.integration.invoke.error",1,["method:".concat(e),"integration_name:".concat(this.name)]),f;case 6:return[2,t]}}))}))},t.prototype.track=function(t){return Object(i.b)(this,void 0,void 0,(function(){return Object(i.d)(this,(function(n){return[2,this.send(t,r.Track,"track")]}))}))},t.prototype.page=function(t){var n;return Object(i.b)(this,void 0,void 0,(function(){var e=this;return Object(i.d)(this,(function(i){return(null===(n=this.integration)||void 0===n?void 0:n._assumesPageview)&&!this._initialized&&this.integration.initialize(),[2,this.onInitialize.then((function(){return e.send(t,r.Page,"page")}))]}))}))},t.prototype.identify=function(t){return Object(i.b)(this,void 0,void 0,(function(){return Object(i.d)(this,(function(n){return[2,this.send(t,r.Identify,"identify")]}))}))},t.prototype.alias=function(t){return Object(i.b)(this,void 0,void 0,(function(){return Object(i.d)(this,(function(n){return[2,this.send(t,r.Alias,"alias")]}))}))},t.prototype.group=function(t){return Object(i.b)(this,void 0,void 0,(function(){return Object(i.d)(this,(function(n){return[2,this.send(t,r.Group,"group")]}))}))},t.prototype.scheduleFlush=function(){var t=this;this.flushing||setTimeout((function(){return Object(i.b)(t,void 0,void 0,(function(){var t;return Object(i.d)(this,(function(n){switch(n.label){case 0:return this.flushing=!0,t=this,[4,w(this,this.buffer)];case 1:return t.buffer=n.sent(),this.flushing=!1,this.buffer.todo>0&&this.scheduleFlush(),[2]}}))}))}),5e3*Math.random())},t}();function _(t,n,e,i){var r,o;if(void 0===n&&(n={}),void 0===e&&(e={}),Object(s.b)())return[];t.plan&&((e=null!=e?e:{}).plan=t.plan);var a=null!==(o=null===(r=t.middlewareSettings)||void 0===r?void 0:r.routingRules)&&void 0!==o?o:[],c=Object(l.a)(t,null!=e?e:{});return Object.entries(t.integrations).map((function(t){var r,o=t[0],s=t[1];if(!o.startsWith("Segment")){var u=!1===n.All&&void 0===n[o];if(!1!==n[o]&&!u){var d=s.type,l=s.bundlingStatus,h=s.versionSettings;if(("unbundled"!==l&&("browser"===d||(null===(r=null==h?void 0:h.componentTypes)||void 0===r?void 0:r.includes("browser")))||"Segment.io"===o)&&"Iterable"!==o){var v=function(t){var n,e,i,r;return null!==(r=null!==(e=null===(n=t.versionSettings)||void 0===n?void 0:n.override)&&void 0!==e?e:null===(i=t.versionSettings)||void 0===i?void 0:i.version)&&void 0!==r?r:"latest"}(s),f=new O(o,v,c[o],e);return a.filter((function(t){return t.destinationName===o})).length>0&&i&&f.addMiddleware(i),f}}}})).filter((function(t){return void 0!==t}))}}}]);
|