@orderingstack/front-hooks 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +499 -7
- package/dist/index.es.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/useCms.d.ts +23 -0
- package/dist/src/useCms.d.ts.map +1 -1
- package/dist/src/useMediaUrl.d.ts +14 -0
- package/dist/src/useMediaUrl.d.ts.map +1 -0
- package/dist/src/utils/cms.d.ts +11 -0
- package/dist/src/utils/cms.d.ts.map +1 -0
- package/package.json +3 -2
package/dist/index.es.js
CHANGED
|
@@ -2981,13 +2981,13 @@ function CancelToken(executor) {
|
|
|
2981
2981
|
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
2982
2982
|
resolvePromise = resolve;
|
|
2983
2983
|
});
|
|
2984
|
-
var
|
|
2984
|
+
var token2 = this;
|
|
2985
2985
|
executor(function cancel(message) {
|
|
2986
|
-
if (
|
|
2986
|
+
if (token2.reason) {
|
|
2987
2987
|
return;
|
|
2988
2988
|
}
|
|
2989
|
-
|
|
2990
|
-
resolvePromise(
|
|
2989
|
+
token2.reason = new Cancel(message);
|
|
2990
|
+
resolvePromise(token2.reason);
|
|
2991
2991
|
});
|
|
2992
2992
|
}
|
|
2993
2993
|
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
@@ -2997,11 +2997,11 @@ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
|
2997
2997
|
};
|
|
2998
2998
|
CancelToken.source = function source() {
|
|
2999
2999
|
var cancel;
|
|
3000
|
-
var
|
|
3000
|
+
var token2 = new CancelToken(function executor(c) {
|
|
3001
3001
|
cancel = c;
|
|
3002
3002
|
});
|
|
3003
3003
|
return {
|
|
3004
|
-
token,
|
|
3004
|
+
token: token2,
|
|
3005
3005
|
cancel
|
|
3006
3006
|
};
|
|
3007
3007
|
};
|
|
@@ -3042,6 +3042,17 @@ axios$1.isAxiosError = isAxiosError;
|
|
|
3042
3042
|
axios$2.exports = axios$1;
|
|
3043
3043
|
axios$2.exports.default = axios$1;
|
|
3044
3044
|
var axios = axios$2.exports;
|
|
3045
|
+
const getUrlFromLocalizedVenueMedia = (localizedVenueMedia, locale) => {
|
|
3046
|
+
var _a, _b, _c;
|
|
3047
|
+
if (localizedVenueMedia && ((_a = localizedVenueMedia == null ? void 0 : localizedVenueMedia.url) == null ? void 0 : _a.length) > 0) {
|
|
3048
|
+
return ((_b = localizedVenueMedia.url.find((item) => item.locale === locale)) == null ? void 0 : _b.value) || ((_c = localizedVenueMedia.url.find((item) => item.locale === "*")) == null ? void 0 : _c.value) || null;
|
|
3049
|
+
}
|
|
3050
|
+
return null;
|
|
3051
|
+
};
|
|
3052
|
+
const getLocalizedVenueMediaFromArray = (localizedVenueMedia, venue) => {
|
|
3053
|
+
var _a, _b;
|
|
3054
|
+
return ((_a = localizedVenueMedia == null ? void 0 : localizedVenueMedia.find) == null ? void 0 : _a.call(localizedVenueMedia, (item) => item.venue === venue)) || ((_b = localizedVenueMedia == null ? void 0 : localizedVenueMedia.find) == null ? void 0 : _b.call(localizedVenueMedia, (item) => item.venue === "*"));
|
|
3055
|
+
};
|
|
3045
3056
|
function useCms(id, intervalSeconds = 600, withLocalStorage = true, baseUrl, tenant) {
|
|
3046
3057
|
var _a, _b;
|
|
3047
3058
|
if (!baseUrl || !tenant) {
|
|
@@ -3129,6 +3140,30 @@ function useLocalizedVenueMedia(id, venue, locale, intervalSeconds = 300, withLo
|
|
|
3129
3140
|
}
|
|
3130
3141
|
return { url: localizedValue, fallbackUrl, isError };
|
|
3131
3142
|
}
|
|
3143
|
+
function useKioskMediaCms({
|
|
3144
|
+
kioskMediaId,
|
|
3145
|
+
kioskMediaType,
|
|
3146
|
+
intervalSeconds = 600,
|
|
3147
|
+
withLocalStorage = true,
|
|
3148
|
+
baseUrl,
|
|
3149
|
+
tenant,
|
|
3150
|
+
venue,
|
|
3151
|
+
locale
|
|
3152
|
+
}) {
|
|
3153
|
+
var _a;
|
|
3154
|
+
const { value, isError, isLoading } = useCms(kioskMediaId, intervalSeconds, withLocalStorage, baseUrl, tenant);
|
|
3155
|
+
const kioskMediaFoundType = (value == null ? void 0 : value[kioskMediaType]) || [];
|
|
3156
|
+
const kioskMediaFoundTypeVenue = getLocalizedVenueMediaFromArray(kioskMediaFoundType, venue);
|
|
3157
|
+
const localizedValue = getUrlFromLocalizedVenueMedia(kioskMediaFoundTypeVenue, locale);
|
|
3158
|
+
const fallbackUrl = !localizedValue && kioskMediaFoundTypeVenue && ((_a = kioskMediaFoundTypeVenue == null ? void 0 : kioskMediaFoundTypeVenue.url) == null ? void 0 : _a.length) > 0 ? kioskMediaFoundTypeVenue.url[0].value : null;
|
|
3159
|
+
return {
|
|
3160
|
+
url: localizedValue,
|
|
3161
|
+
fallbackUrl,
|
|
3162
|
+
mediaType: kioskMediaFoundTypeVenue == null ? void 0 : kioskMediaFoundTypeVenue.mediaType,
|
|
3163
|
+
isError,
|
|
3164
|
+
isLoading
|
|
3165
|
+
};
|
|
3166
|
+
}
|
|
3132
3167
|
function useOnClickOutside(ref, handler) {
|
|
3133
3168
|
useEffect(() => {
|
|
3134
3169
|
const listener = (event) => {
|
|
@@ -3166,5 +3201,462 @@ function useKioskChannelsAvailability(channelConstrainst) {
|
|
|
3166
3201
|
useInterval(checkOpen, 6e4);
|
|
3167
3202
|
return { dineInOpen, takeAwayOpen };
|
|
3168
3203
|
}
|
|
3169
|
-
|
|
3204
|
+
var queryString = {};
|
|
3205
|
+
var strictUriEncode = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x) => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
3206
|
+
var token = "%[a-f0-9]{2}";
|
|
3207
|
+
var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi");
|
|
3208
|
+
var multiMatcher = new RegExp("(" + token + ")+", "gi");
|
|
3209
|
+
function decodeComponents(components, split) {
|
|
3210
|
+
try {
|
|
3211
|
+
return [decodeURIComponent(components.join(""))];
|
|
3212
|
+
} catch (err) {
|
|
3213
|
+
}
|
|
3214
|
+
if (components.length === 1) {
|
|
3215
|
+
return components;
|
|
3216
|
+
}
|
|
3217
|
+
split = split || 1;
|
|
3218
|
+
var left = components.slice(0, split);
|
|
3219
|
+
var right = components.slice(split);
|
|
3220
|
+
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
3221
|
+
}
|
|
3222
|
+
function decode(input) {
|
|
3223
|
+
try {
|
|
3224
|
+
return decodeURIComponent(input);
|
|
3225
|
+
} catch (err) {
|
|
3226
|
+
var tokens = input.match(singleMatcher) || [];
|
|
3227
|
+
for (var i = 1; i < tokens.length; i++) {
|
|
3228
|
+
input = decodeComponents(tokens, i).join("");
|
|
3229
|
+
tokens = input.match(singleMatcher) || [];
|
|
3230
|
+
}
|
|
3231
|
+
return input;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
function customDecodeURIComponent(input) {
|
|
3235
|
+
var replaceMap = {
|
|
3236
|
+
"%FE%FF": "\uFFFD\uFFFD",
|
|
3237
|
+
"%FF%FE": "\uFFFD\uFFFD"
|
|
3238
|
+
};
|
|
3239
|
+
var match = multiMatcher.exec(input);
|
|
3240
|
+
while (match) {
|
|
3241
|
+
try {
|
|
3242
|
+
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
3243
|
+
} catch (err) {
|
|
3244
|
+
var result = decode(match[0]);
|
|
3245
|
+
if (result !== match[0]) {
|
|
3246
|
+
replaceMap[match[0]] = result;
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
match = multiMatcher.exec(input);
|
|
3250
|
+
}
|
|
3251
|
+
replaceMap["%C2"] = "\uFFFD";
|
|
3252
|
+
var entries = Object.keys(replaceMap);
|
|
3253
|
+
for (var i = 0; i < entries.length; i++) {
|
|
3254
|
+
var key = entries[i];
|
|
3255
|
+
input = input.replace(new RegExp(key, "g"), replaceMap[key]);
|
|
3256
|
+
}
|
|
3257
|
+
return input;
|
|
3258
|
+
}
|
|
3259
|
+
var decodeUriComponent = function(encodedURI) {
|
|
3260
|
+
if (typeof encodedURI !== "string") {
|
|
3261
|
+
throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`");
|
|
3262
|
+
}
|
|
3263
|
+
try {
|
|
3264
|
+
encodedURI = encodedURI.replace(/\+/g, " ");
|
|
3265
|
+
return decodeURIComponent(encodedURI);
|
|
3266
|
+
} catch (err) {
|
|
3267
|
+
return customDecodeURIComponent(encodedURI);
|
|
3268
|
+
}
|
|
3269
|
+
};
|
|
3270
|
+
var splitOnFirst = (string, separator) => {
|
|
3271
|
+
if (!(typeof string === "string" && typeof separator === "string")) {
|
|
3272
|
+
throw new TypeError("Expected the arguments to be of type `string`");
|
|
3273
|
+
}
|
|
3274
|
+
if (separator === "") {
|
|
3275
|
+
return [string];
|
|
3276
|
+
}
|
|
3277
|
+
const separatorIndex = string.indexOf(separator);
|
|
3278
|
+
if (separatorIndex === -1) {
|
|
3279
|
+
return [string];
|
|
3280
|
+
}
|
|
3281
|
+
return [
|
|
3282
|
+
string.slice(0, separatorIndex),
|
|
3283
|
+
string.slice(separatorIndex + separator.length)
|
|
3284
|
+
];
|
|
3285
|
+
};
|
|
3286
|
+
var filterObj = function(obj, predicate) {
|
|
3287
|
+
var ret = {};
|
|
3288
|
+
var keys2 = Object.keys(obj);
|
|
3289
|
+
var isArr = Array.isArray(predicate);
|
|
3290
|
+
for (var i = 0; i < keys2.length; i++) {
|
|
3291
|
+
var key = keys2[i];
|
|
3292
|
+
var val = obj[key];
|
|
3293
|
+
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
|
|
3294
|
+
ret[key] = val;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
return ret;
|
|
3298
|
+
};
|
|
3299
|
+
(function(exports) {
|
|
3300
|
+
const strictUriEncode$1 = strictUriEncode;
|
|
3301
|
+
const decodeComponent = decodeUriComponent;
|
|
3302
|
+
const splitOnFirst$1 = splitOnFirst;
|
|
3303
|
+
const filterObject = filterObj;
|
|
3304
|
+
const isNullOrUndefined = (value) => value === null || value === void 0;
|
|
3305
|
+
const encodeFragmentIdentifier = Symbol("encodeFragmentIdentifier");
|
|
3306
|
+
function encoderForArrayFormat(options) {
|
|
3307
|
+
switch (options.arrayFormat) {
|
|
3308
|
+
case "index":
|
|
3309
|
+
return (key) => (result, value) => {
|
|
3310
|
+
const index = result.length;
|
|
3311
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
3312
|
+
return result;
|
|
3313
|
+
}
|
|
3314
|
+
if (value === null) {
|
|
3315
|
+
return [...result, [encode2(key, options), "[", index, "]"].join("")];
|
|
3316
|
+
}
|
|
3317
|
+
return [
|
|
3318
|
+
...result,
|
|
3319
|
+
[encode2(key, options), "[", encode2(index, options), "]=", encode2(value, options)].join("")
|
|
3320
|
+
];
|
|
3321
|
+
};
|
|
3322
|
+
case "bracket":
|
|
3323
|
+
return (key) => (result, value) => {
|
|
3324
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
3325
|
+
return result;
|
|
3326
|
+
}
|
|
3327
|
+
if (value === null) {
|
|
3328
|
+
return [...result, [encode2(key, options), "[]"].join("")];
|
|
3329
|
+
}
|
|
3330
|
+
return [...result, [encode2(key, options), "[]=", encode2(value, options)].join("")];
|
|
3331
|
+
};
|
|
3332
|
+
case "colon-list-separator":
|
|
3333
|
+
return (key) => (result, value) => {
|
|
3334
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
3335
|
+
return result;
|
|
3336
|
+
}
|
|
3337
|
+
if (value === null) {
|
|
3338
|
+
return [...result, [encode2(key, options), ":list="].join("")];
|
|
3339
|
+
}
|
|
3340
|
+
return [...result, [encode2(key, options), ":list=", encode2(value, options)].join("")];
|
|
3341
|
+
};
|
|
3342
|
+
case "comma":
|
|
3343
|
+
case "separator":
|
|
3344
|
+
case "bracket-separator": {
|
|
3345
|
+
const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
|
|
3346
|
+
return (key) => (result, value) => {
|
|
3347
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
3348
|
+
return result;
|
|
3349
|
+
}
|
|
3350
|
+
value = value === null ? "" : value;
|
|
3351
|
+
if (result.length === 0) {
|
|
3352
|
+
return [[encode2(key, options), keyValueSep, encode2(value, options)].join("")];
|
|
3353
|
+
}
|
|
3354
|
+
return [[result, encode2(value, options)].join(options.arrayFormatSeparator)];
|
|
3355
|
+
};
|
|
3356
|
+
}
|
|
3357
|
+
default:
|
|
3358
|
+
return (key) => (result, value) => {
|
|
3359
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
3360
|
+
return result;
|
|
3361
|
+
}
|
|
3362
|
+
if (value === null) {
|
|
3363
|
+
return [...result, encode2(key, options)];
|
|
3364
|
+
}
|
|
3365
|
+
return [...result, [encode2(key, options), "=", encode2(value, options)].join("")];
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
function parserForArrayFormat(options) {
|
|
3370
|
+
let result;
|
|
3371
|
+
switch (options.arrayFormat) {
|
|
3372
|
+
case "index":
|
|
3373
|
+
return (key, value, accumulator) => {
|
|
3374
|
+
result = /\[(\d*)\]$/.exec(key);
|
|
3375
|
+
key = key.replace(/\[\d*\]$/, "");
|
|
3376
|
+
if (!result) {
|
|
3377
|
+
accumulator[key] = value;
|
|
3378
|
+
return;
|
|
3379
|
+
}
|
|
3380
|
+
if (accumulator[key] === void 0) {
|
|
3381
|
+
accumulator[key] = {};
|
|
3382
|
+
}
|
|
3383
|
+
accumulator[key][result[1]] = value;
|
|
3384
|
+
};
|
|
3385
|
+
case "bracket":
|
|
3386
|
+
return (key, value, accumulator) => {
|
|
3387
|
+
result = /(\[\])$/.exec(key);
|
|
3388
|
+
key = key.replace(/\[\]$/, "");
|
|
3389
|
+
if (!result) {
|
|
3390
|
+
accumulator[key] = value;
|
|
3391
|
+
return;
|
|
3392
|
+
}
|
|
3393
|
+
if (accumulator[key] === void 0) {
|
|
3394
|
+
accumulator[key] = [value];
|
|
3395
|
+
return;
|
|
3396
|
+
}
|
|
3397
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
3398
|
+
};
|
|
3399
|
+
case "colon-list-separator":
|
|
3400
|
+
return (key, value, accumulator) => {
|
|
3401
|
+
result = /(:list)$/.exec(key);
|
|
3402
|
+
key = key.replace(/:list$/, "");
|
|
3403
|
+
if (!result) {
|
|
3404
|
+
accumulator[key] = value;
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3407
|
+
if (accumulator[key] === void 0) {
|
|
3408
|
+
accumulator[key] = [value];
|
|
3409
|
+
return;
|
|
3410
|
+
}
|
|
3411
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
3412
|
+
};
|
|
3413
|
+
case "comma":
|
|
3414
|
+
case "separator":
|
|
3415
|
+
return (key, value, accumulator) => {
|
|
3416
|
+
const isArray2 = typeof value === "string" && value.includes(options.arrayFormatSeparator);
|
|
3417
|
+
const isEncodedArray = typeof value === "string" && !isArray2 && decode2(value, options).includes(options.arrayFormatSeparator);
|
|
3418
|
+
value = isEncodedArray ? decode2(value, options) : value;
|
|
3419
|
+
const newValue = isArray2 || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode2(item, options)) : value === null ? value : decode2(value, options);
|
|
3420
|
+
accumulator[key] = newValue;
|
|
3421
|
+
};
|
|
3422
|
+
case "bracket-separator":
|
|
3423
|
+
return (key, value, accumulator) => {
|
|
3424
|
+
const isArray2 = /(\[\])$/.test(key);
|
|
3425
|
+
key = key.replace(/\[\]$/, "");
|
|
3426
|
+
if (!isArray2) {
|
|
3427
|
+
accumulator[key] = value ? decode2(value, options) : value;
|
|
3428
|
+
return;
|
|
3429
|
+
}
|
|
3430
|
+
const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode2(item, options));
|
|
3431
|
+
if (accumulator[key] === void 0) {
|
|
3432
|
+
accumulator[key] = arrayValue;
|
|
3433
|
+
return;
|
|
3434
|
+
}
|
|
3435
|
+
accumulator[key] = [].concat(accumulator[key], arrayValue);
|
|
3436
|
+
};
|
|
3437
|
+
default:
|
|
3438
|
+
return (key, value, accumulator) => {
|
|
3439
|
+
if (accumulator[key] === void 0) {
|
|
3440
|
+
accumulator[key] = value;
|
|
3441
|
+
return;
|
|
3442
|
+
}
|
|
3443
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
function validateArrayFormatSeparator(value) {
|
|
3448
|
+
if (typeof value !== "string" || value.length !== 1) {
|
|
3449
|
+
throw new TypeError("arrayFormatSeparator must be single character string");
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
function encode2(value, options) {
|
|
3453
|
+
if (options.encode) {
|
|
3454
|
+
return options.strict ? strictUriEncode$1(value) : encodeURIComponent(value);
|
|
3455
|
+
}
|
|
3456
|
+
return value;
|
|
3457
|
+
}
|
|
3458
|
+
function decode2(value, options) {
|
|
3459
|
+
if (options.decode) {
|
|
3460
|
+
return decodeComponent(value);
|
|
3461
|
+
}
|
|
3462
|
+
return value;
|
|
3463
|
+
}
|
|
3464
|
+
function keysSorter(input) {
|
|
3465
|
+
if (Array.isArray(input)) {
|
|
3466
|
+
return input.sort();
|
|
3467
|
+
}
|
|
3468
|
+
if (typeof input === "object") {
|
|
3469
|
+
return keysSorter(Object.keys(input)).sort((a, b) => Number(a) - Number(b)).map((key) => input[key]);
|
|
3470
|
+
}
|
|
3471
|
+
return input;
|
|
3472
|
+
}
|
|
3473
|
+
function removeHash(input) {
|
|
3474
|
+
const hashStart = input.indexOf("#");
|
|
3475
|
+
if (hashStart !== -1) {
|
|
3476
|
+
input = input.slice(0, hashStart);
|
|
3477
|
+
}
|
|
3478
|
+
return input;
|
|
3479
|
+
}
|
|
3480
|
+
function getHash(url) {
|
|
3481
|
+
let hash = "";
|
|
3482
|
+
const hashStart = url.indexOf("#");
|
|
3483
|
+
if (hashStart !== -1) {
|
|
3484
|
+
hash = url.slice(hashStart);
|
|
3485
|
+
}
|
|
3486
|
+
return hash;
|
|
3487
|
+
}
|
|
3488
|
+
function extract(input) {
|
|
3489
|
+
input = removeHash(input);
|
|
3490
|
+
const queryStart = input.indexOf("?");
|
|
3491
|
+
if (queryStart === -1) {
|
|
3492
|
+
return "";
|
|
3493
|
+
}
|
|
3494
|
+
return input.slice(queryStart + 1);
|
|
3495
|
+
}
|
|
3496
|
+
function parseValue(value, options) {
|
|
3497
|
+
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) {
|
|
3498
|
+
value = Number(value);
|
|
3499
|
+
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
|
|
3500
|
+
value = value.toLowerCase() === "true";
|
|
3501
|
+
}
|
|
3502
|
+
return value;
|
|
3503
|
+
}
|
|
3504
|
+
function parse(query, options) {
|
|
3505
|
+
options = Object.assign({
|
|
3506
|
+
decode: true,
|
|
3507
|
+
sort: true,
|
|
3508
|
+
arrayFormat: "none",
|
|
3509
|
+
arrayFormatSeparator: ",",
|
|
3510
|
+
parseNumbers: false,
|
|
3511
|
+
parseBooleans: false
|
|
3512
|
+
}, options);
|
|
3513
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
3514
|
+
const formatter = parserForArrayFormat(options);
|
|
3515
|
+
const ret = /* @__PURE__ */ Object.create(null);
|
|
3516
|
+
if (typeof query !== "string") {
|
|
3517
|
+
return ret;
|
|
3518
|
+
}
|
|
3519
|
+
query = query.trim().replace(/^[?#&]/, "");
|
|
3520
|
+
if (!query) {
|
|
3521
|
+
return ret;
|
|
3522
|
+
}
|
|
3523
|
+
for (const param of query.split("&")) {
|
|
3524
|
+
if (param === "") {
|
|
3525
|
+
continue;
|
|
3526
|
+
}
|
|
3527
|
+
let [key, value] = splitOnFirst$1(options.decode ? param.replace(/\+/g, " ") : param, "=");
|
|
3528
|
+
value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode2(value, options);
|
|
3529
|
+
formatter(decode2(key, options), value, ret);
|
|
3530
|
+
}
|
|
3531
|
+
for (const key of Object.keys(ret)) {
|
|
3532
|
+
const value = ret[key];
|
|
3533
|
+
if (typeof value === "object" && value !== null) {
|
|
3534
|
+
for (const k of Object.keys(value)) {
|
|
3535
|
+
value[k] = parseValue(value[k], options);
|
|
3536
|
+
}
|
|
3537
|
+
} else {
|
|
3538
|
+
ret[key] = parseValue(value, options);
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
if (options.sort === false) {
|
|
3542
|
+
return ret;
|
|
3543
|
+
}
|
|
3544
|
+
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
|
|
3545
|
+
const value = ret[key];
|
|
3546
|
+
if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) {
|
|
3547
|
+
result[key] = keysSorter(value);
|
|
3548
|
+
} else {
|
|
3549
|
+
result[key] = value;
|
|
3550
|
+
}
|
|
3551
|
+
return result;
|
|
3552
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
3553
|
+
}
|
|
3554
|
+
exports.extract = extract;
|
|
3555
|
+
exports.parse = parse;
|
|
3556
|
+
exports.stringify = (object, options) => {
|
|
3557
|
+
if (!object) {
|
|
3558
|
+
return "";
|
|
3559
|
+
}
|
|
3560
|
+
options = Object.assign({
|
|
3561
|
+
encode: true,
|
|
3562
|
+
strict: true,
|
|
3563
|
+
arrayFormat: "none",
|
|
3564
|
+
arrayFormatSeparator: ","
|
|
3565
|
+
}, options);
|
|
3566
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
3567
|
+
const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === "";
|
|
3568
|
+
const formatter = encoderForArrayFormat(options);
|
|
3569
|
+
const objectCopy = {};
|
|
3570
|
+
for (const key of Object.keys(object)) {
|
|
3571
|
+
if (!shouldFilter(key)) {
|
|
3572
|
+
objectCopy[key] = object[key];
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
const keys2 = Object.keys(objectCopy);
|
|
3576
|
+
if (options.sort !== false) {
|
|
3577
|
+
keys2.sort(options.sort);
|
|
3578
|
+
}
|
|
3579
|
+
return keys2.map((key) => {
|
|
3580
|
+
const value = object[key];
|
|
3581
|
+
if (value === void 0) {
|
|
3582
|
+
return "";
|
|
3583
|
+
}
|
|
3584
|
+
if (value === null) {
|
|
3585
|
+
return encode2(key, options);
|
|
3586
|
+
}
|
|
3587
|
+
if (Array.isArray(value)) {
|
|
3588
|
+
if (value.length === 0 && options.arrayFormat === "bracket-separator") {
|
|
3589
|
+
return encode2(key, options) + "[]";
|
|
3590
|
+
}
|
|
3591
|
+
return value.reduce(formatter(key), []).join("&");
|
|
3592
|
+
}
|
|
3593
|
+
return encode2(key, options) + "=" + encode2(value, options);
|
|
3594
|
+
}).filter((x) => x.length > 0).join("&");
|
|
3595
|
+
};
|
|
3596
|
+
exports.parseUrl = (url, options) => {
|
|
3597
|
+
options = Object.assign({
|
|
3598
|
+
decode: true
|
|
3599
|
+
}, options);
|
|
3600
|
+
const [url_, hash] = splitOnFirst$1(url, "#");
|
|
3601
|
+
return Object.assign({
|
|
3602
|
+
url: url_.split("?")[0] || "",
|
|
3603
|
+
query: parse(extract(url), options)
|
|
3604
|
+
}, options && options.parseFragmentIdentifier && hash ? { fragmentIdentifier: decode2(hash, options) } : {});
|
|
3605
|
+
};
|
|
3606
|
+
exports.stringifyUrl = (object, options) => {
|
|
3607
|
+
options = Object.assign({
|
|
3608
|
+
encode: true,
|
|
3609
|
+
strict: true,
|
|
3610
|
+
[encodeFragmentIdentifier]: true
|
|
3611
|
+
}, options);
|
|
3612
|
+
const url = removeHash(object.url).split("?")[0] || "";
|
|
3613
|
+
const queryFromUrl = exports.extract(object.url);
|
|
3614
|
+
const parsedQueryFromUrl = exports.parse(queryFromUrl, { sort: false });
|
|
3615
|
+
const query = Object.assign(parsedQueryFromUrl, object.query);
|
|
3616
|
+
let queryString2 = exports.stringify(query, options);
|
|
3617
|
+
if (queryString2) {
|
|
3618
|
+
queryString2 = `?${queryString2}`;
|
|
3619
|
+
}
|
|
3620
|
+
let hash = getHash(object.url);
|
|
3621
|
+
if (object.fragmentIdentifier) {
|
|
3622
|
+
hash = `#${options[encodeFragmentIdentifier] ? encode2(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
|
|
3623
|
+
}
|
|
3624
|
+
return `${url}${queryString2}${hash}`;
|
|
3625
|
+
};
|
|
3626
|
+
exports.pick = (input, filter, options) => {
|
|
3627
|
+
options = Object.assign({
|
|
3628
|
+
parseFragmentIdentifier: true,
|
|
3629
|
+
[encodeFragmentIdentifier]: false
|
|
3630
|
+
}, options);
|
|
3631
|
+
const { url, query, fragmentIdentifier } = exports.parseUrl(input, options);
|
|
3632
|
+
return exports.stringifyUrl({
|
|
3633
|
+
url,
|
|
3634
|
+
query: filterObject(query, filter),
|
|
3635
|
+
fragmentIdentifier
|
|
3636
|
+
}, options);
|
|
3637
|
+
};
|
|
3638
|
+
exports.exclude = (input, filter, options) => {
|
|
3639
|
+
const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value);
|
|
3640
|
+
return exports.pick(input, exclusionFilter, options);
|
|
3641
|
+
};
|
|
3642
|
+
})(queryString);
|
|
3643
|
+
const supported = [".png", ".jpg", ".jpeg", ".webp", ".bmp", ".tiff"];
|
|
3644
|
+
function getMediaUrl(url, size = 500) {
|
|
3645
|
+
const link = queryString.parseUrl(url);
|
|
3646
|
+
if (!(url.startsWith("https://orderingstackmedia.blob.core.windows.net/pictures") || url.startsWith("https://orderingstack-mmedia-tools.azurewebsites.net/api/img/"))) {
|
|
3647
|
+
return url;
|
|
3648
|
+
}
|
|
3649
|
+
const extension = link.url.substring(link.url.lastIndexOf("."));
|
|
3650
|
+
if (!supported.includes(extension)) {
|
|
3651
|
+
return url;
|
|
3652
|
+
}
|
|
3653
|
+
return queryString.stringifyUrl({
|
|
3654
|
+
url: link.url.replace("https://orderingstackmedia.blob.core.windows.net/pictures/", "https://orderingstack-mmedia-tools.azurewebsites.net/api/img/"),
|
|
3655
|
+
query: { ...link.query, w: size }
|
|
3656
|
+
});
|
|
3657
|
+
}
|
|
3658
|
+
function useMediaUrl(url, size = 500) {
|
|
3659
|
+
return getMediaUrl(url, size);
|
|
3660
|
+
}
|
|
3661
|
+
export { getGroupedBucketLines, getMediaUrl, groupOrderLines, useAvailability, useCms, useDisplayPrice, useGroupOrderLines, useInterval, useKioskChannelsAvailability, useKioskMediaCms, useLocalizedVenueMedia, useMediaUrl, useOnClickOutside, useVenueCms };
|
|
3170
3662
|
//# sourceMappingURL=index.es.js.map
|