@subiz/widget-v4 4.1.206 → 4.1.207
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/assets/less/chatbox.less +1 -0
- package/assets/less/widget.less +2 -2
- package/compiled_src/chatbox/main.js +11 -6
- package/compiled_src/util/common.js +2 -0
- package/compiled_src/util/common.test.js +8 -0
- package/dist/app.js +1406 -0
- package/dist/chat.html +10 -0
- package/dist/chat.js +1395 -0
- package/dist/form.html +10 -0
- package/dist/form.js +609 -0
- package/dist/index.html +90 -0
- package/dist/inject.html +20 -0
- package/dist/inject.js +1395 -0
- package/dist/library.html +90 -0
- package/dist/library.js +1385 -0
- package/dist/order.html +32 -0
- package/dist/order.js +810 -0
- package/dist/preview.html +784 -0
- package/dist/preview.js +1455 -0
- package/dist/screenshoot.html +10 -2
- package/dist/screenshoot.js +742 -12837
- package/dist/src_chatbox_OrderAttachments_js.js +22 -0
- package/dist/src_chatbox_Order_js.js +206 -0
- package/dist/src_chatbox_css_js.js +306 -0
- package/dist/src_contact_contact_js.js +22 -0
- package/dist/src_contact_css_js.js +32 -0
- package/dist/src_form_css_js.js +32 -0
- package/dist/src_notif_css_js.js +32 -0
- package/dist/src_notif_notif_js.js +22 -0
- package/dist/src_popup_css_js.js +32 -0
- package/dist/src_popup_popup_js.js +84 -0
- package/dist/webview.js +1406 -0
- package/package.json +7 -7
- package/src/chatbox/main.js +16 -8
- package/src/util/common.js +2 -0
- package/src/util/common.test.js +7 -0
package/dist/order.js
ADDED
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
3
|
+
* This devtool is neither made for production nor for readable output files.
|
|
4
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
5
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
6
|
+
* or disable the default devtool with "devtool: false".
|
|
7
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
|
+
*/
|
|
9
|
+
/******/ (() => { // webpackBootstrap
|
|
10
|
+
/******/ var __webpack_modules__ = ({
|
|
11
|
+
|
|
12
|
+
/***/ "./node_modules/@subiz/ajax/src/ajax.js"
|
|
13
|
+
/*!**********************************************!*\
|
|
14
|
+
!*** ./node_modules/@subiz/ajax/src/ajax.js ***!
|
|
15
|
+
\**********************************************/
|
|
16
|
+
(module) {
|
|
17
|
+
|
|
18
|
+
eval("{var METHODS = ['put', 'head', 'patch', 'delete', 'post', 'get']\nvar CONTENT_TYPE = 'Content-Type'\nvar CONTENT_TYPE_FORM = 'application/x-www-form-urlencoded'\nvar CONTENT_TYPE_JSON = 'application/json; charset=utf-8'\n\nfunction combineUrl(base, newurl) {\n\tbase = norm(base)\n\tnewurl = norm(newurl)\n\n\tif (!newurl || !base) return base + newurl\n\n\tif (newurl.startsWith('http://') || newurl.startsWith('https://') || newurl.startsWith('//')) {\n\t\treturn newurl\n\t}\n\n\tif (!base.endsWith('/')) base += '/'\n\tif (newurl.startsWith('/')) newurl = newurl.substring(1)\n\treturn base + newurl\n}\n\nfunction merge(req, obj) {\n\treturn Object.assign(req.clone(), obj)\n}\n\nfunction newRequest() {\n\tvar r = {\n\t\tparser: '',\n\t\tbeforehooks: [],\n\t\tafterhooks: [],\n\t\tbaseurl: '',\n\t\tquery: {},\n\t}\n\n\tr.clone = function () {\n\t\treturn Object.assign({}, this, {query: Object.assign({}, this.query)})\n\t}\n\n\tr.addQuery = function (key, val) {\n\t\tvar req = this.clone()\n\t\treq.query[key] = val\n\t\treturn req\n\t}\n\n\tr.removeQuery = function (key) {\n\t\tvar req = this.clone()\n\t\tif (req.query[key] !== undefined) req.query[key] = undefined\n\t\treturn req\n\t}\n\n\tr.withCredentials = function (credential) {\n\t\treturn merge(this, {_withCredentials: credential})\n\t}\n\n\tr.setQuery = function (query) {\n\t\treturn merge(this, {query: query})\n\t}\n\n\tr.clearHooks = function () {\n\t\treturn merge(this, {beforehooks: [], afterhooks: []})\n\t}\n\n\tr.beforeHook = function (cb) {\n\t\tvar beforehooks = this.beforehooks.slice()\n\t\tbeforehooks.push(cb)\n\t\treturn merge(this, {beforehooks: beforehooks})\n\t}\n\n\tr.afterHook = function (cb) {\n\t\tvar afterhooks = this.afterhooks.slice()\n\t\tafterhooks.push(cb)\n\t\treturn merge(this, {afterhooks: afterhooks})\n\t}\n\n\tr.setHeader = function (headers) {\n\t\theaders = Object.assign({}, this.headers, headers)\n\t\theaders[CONTENT_TYPE] = undefined\n\t\treturn merge(this, {headers: headers})\n\t}\n\n\tMETHODS.map(function (method) {\n\t\tr[method] = function (url, data, cb) {\n\t\t\treturn send(merge(this, {method: method, baseurl: combineUrl(this.baseurl, url)}), data, cb)\n\t\t}\n\t})\n\n\t// pass // to clean\n\tr.setBaseUrl = function (url) {\n\t\treturn merge(this, {baseurl: url})\n\t}\n\n\tr.contentTypeJson = function () {\n\t\treturn merge(this, {content_type: CONTENT_TYPE_JSON})\n\t}\n\n\tr.contentTypeForm = function () {\n\t\treturn merge(this, {content_type: CONTENT_TYPE_FORM})\n\t}\n\n\tr.setContentType = function (ty) {\n\t\treturn merge(this, {content_type: norm(ty)})\n\t}\n\n\tr.setParser = function (parser) {\n\t\treturn merge(this, {parser: norm(parser)})\n\t}\n\n\tr.setBody = function (body) {\n\t\treturn merge(this, {body: body})\n\t}\n\treturn r\n}\n\nvar networkerr = {\n\tcode: 'network_error,retry',\n\tnumber: 'SBZ-EQNETWORK',\n\tmessage: {\n\t\tEn_US: 'Can not connect to the server. Please check your internet connection.',\n\t\tVi_VN: 'Không thể kết nối tới máy chủ. Vui lòng kiểm tra lại kết nối mạng.',\n\t},\n}\n\nvar invalidbodyerr = {\n\tcode: 'invalid_response,retry',\n\tnumber: 'SBZ-EQRESPONSE',\n\tmessage: {En_US: 'Server error, please try again later', Vi_VN: 'Lỗi máy chủ, vui lòng thử lại sau'},\n}\n\nvar not200err = {\n\tcode: 'not_200,retry',\n\tnumber: 'SBZ-EQCN200',\n\tmessage: {\n\t\tEn_US: 'Error while connecting to the server, please try again later',\n\t\tVi_VN: 'Lỗi kết nối với máy chủ, vui lòng thử lại sau',\n\t},\n}\n\nfunction send(req, data, cb) {\n\tcb = cb || function () {}\n\tif (isFunc(data)) {\n\t\tcb = data\n\t\tdata = undefined\n\t}\n\n\tvar rs\n\tvar promise = new Promise(function (resolve) {\n\t\trs = function (res) {\n\t\t\ttry {\n\t\t\t\tcb(res.error, res.body, res.code)\n\t\t\t} catch (_) {}\n\t\t\tresolve(res)\n\t\t}\n\t})\n\n\tif (data) {\n\t\treq = req.clone()\n\t\treq.body = data\n\t\tif (req.content_type === CONTENT_TYPE_JSON) req.body = env.Jsonify(data)\n\t\tif (req.content_type === CONTENT_TYPE_FORM) {\n\t\t\treq.body = querify(data)\n\t\t}\n\t}\n\n\twaterfall(req.beforehooks.slice(), {request: req}, function (bp) {\n\t\tif (bp.error) return rs({body: {error: bq.error}, code: 0, error: bp.error})\n\t\tdosend(bp.request, function (err, body, code) {\n\t\t\twaterfall(req.afterhooks.slice(), {request: req, code: code, body: body, err: err}, function (param) {\n\t\t\t\tvar body = param.body\n\t\t\t\tif (err == 'network_error') return rs({body: {error: networkerr}, code: param.code, error: networkerr})\n\t\t\t\tif (req.parser == 'json' && param.body) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tbody = env.ParseJson(param.body)\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\treturn rs({\n\t\t\t\t\t\t\tbody: {error: invalidbodyerr, origin_body: param.body},\n\t\t\t\t\t\t\tcode: param.code,\n\t\t\t\t\t\t\terror: invalidbodyerr,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvar err = param.err\n\t\t\t\tif (err == 'network_error') return rs({body: {error: networkerr}, code: param.code, error: networkerr})\n\t\t\t\tif (!err && (code < 200 || code > 299)) err = body && body.error ? body.error : not200err\n\t\t\t\trs({body: err ? body || {error: err} : body, code: param.code, error: err})\n\t\t\t})\n\t\t})\n\t})\n\treturn promise\n}\n\nvar dofetch = function (req, cb, q) {\n\tvar headers = Object.assign({}, req.headers)\n\tif (req.content_type) headers[CONTENT_TYPE] = req.content_type\n\n\tvar status = 0\n\tfetch(req.baseurl + q, {\n\t\tmethod: req.method,\n\t\theaders: headers,\n\t\tcredentials: req._withCredentials,\n\t\tbody: req.body,\n\t})\n\t\t.then(function (res) {\n\t\t\tstatus = res.status\n\t\t\treturn res.text()\n\t\t})\n\t\t.then(function (text) {\n\t\t\tcb(undefined, text, status)\n\t\t})\n\t\t.catch(function (err) {\n\t\t\tcb('network_error', err, -1)\n\t\t})\n}\n\nvar dosend = function (req, cb) {\n\tlet q = querify(req.query)\n\tif (q) q = '?' + q\n\tif (!env.XMLHttpRequest) return dofetch(req, cb, q)\n\tvar request = new env.XMLHttpRequest()\n\treq.xhr = request // expose through xhr, the caller can use this to get header\n\trequest.onreadystatechange = function (e) {\n\t\tif (request.readyState !== 4) return\n\t\tif (request.status === 0) {\n\t\t\tcb('network_error', request.responseText, request.status) // network error\n\t\t} else {\n\t\t\tcb(undefined, request.responseText, request.status)\n\t\t}\n\t}\n\n\trequest.open(req.method, req.baseurl + q)\n\trequest.withCredentials = req._withCredentials // for cloudflare to work correctly\n\tfor (var i in req.headers) request.setRequestHeader(i, req.headers[i])\n\tif (req.content_type) {\n\t\trequest.setRequestHeader(CONTENT_TYPE, req.content_type)\n\t}\n\trequest.send(req.body)\n}\n\nfunction norm(str) {\n\treturn (str || '').trim()\n}\n\nfunction isFunc(f) {\n\treturn f && {}.toString.call(f) === '[object Function]'\n}\n\nfunction waterfall(ps, param, cb) {\n\tif (!ps || ps.length === 0) return cb(param)\n\n\tvar fp = ps.shift()\n\tif (!isFunc(fp)) return waterfall(ps, param, cb)\n\tfp(param, function (out) {\n\t\treturn out === false ? cb(param) : waterfall(ps, param, cb)\n\t})\n}\n\n// more stringent in adhering to RFC 3986 (which reserves !, ', (, ), and *), even\n// though these characters have no formalized URI delimiting uses, see\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent\n// for more details\nfunction encodeURICom(str) {\n\treturn encodeURIComponent(str).replace(/[!'()*]/g, function (c) {\n\t\treturn '%' + c.charCodeAt(0).toString(16)\n\t})\n}\n\nfunction querify(obj) {\n\tif (!obj) return ''\n\tvar keys = Object.keys(obj)\n\t// keys.sort(options.sort)\n\tvar out = []\n\tfor (var k = 0; k < keys.length; k++) {\n\t\tvar key = keys[k]\n\t\tvar param = ''\n\t\tvar value = obj[key]\n\t\tif (value === undefined) continue\n\t\tif (value === null) {\n\t\t\tparam = encodeURICom(key)\n\t\t} else if (!Array.isArray(value)) {\n\t\t\tparam = encodeURICom(key) + '=' + encodeURICom(value)\n\t\t} else {\n\t\t\t// array\n\t\t\tvar arr = []\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tif (value[i] === undefined) continue\n\t\t\t\tarr.push(encoderForArrayFormat(key, value[i], arr.length))\n\n\t\t\t\tarr.push(out)\n\t\t\t}\n\t\t\tparam = arr.join('&')\n\t\t}\n\t\tif (param.length > 0) out.push(param)\n\t}\n\treturn out.join('&')\n}\n\nfunction encoderForArrayFormat(key, value) {\n\tif (value === null) return encodeURICom(key)\n\treturn [encodeURICom(key), '=', encodeURICom(value)].join('')\n}\n\nvar ajax = newRequest()\nvar env = {\n\tJsonify: JSON.stringify,\n\tParseJson: JSON.parse,\n}\najax.env = env\najax.waterfall = waterfall\nmodule.exports = ajax\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/ajax/src/ajax.js?\n}");
|
|
19
|
+
|
|
20
|
+
/***/ },
|
|
21
|
+
|
|
22
|
+
/***/ "./node_modules/@subiz/flow/batch.js"
|
|
23
|
+
/*!*******************************************!*\
|
|
24
|
+
!*** ./node_modules/@subiz/flow/batch.js ***!
|
|
25
|
+
\*******************************************/
|
|
26
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
27
|
+
|
|
28
|
+
eval("{var loop = __webpack_require__(/*! ./loop.js */ \"./node_modules/@subiz/flow/loop.js\")\n// item: {payload, priority}\n\n// idle => executing\n\nmodule.exports = function (maxBatch, maxDelay, handler) {\n\tvar myBuffers = [] // job buffers\n\tvar myState = 'idle'\n\n\tvar myExecute = function (buffers) {\n\t\tvar payloads = buffers.map(function (i) {\n\t\t\treturn i.payload\n\t\t})\n\t\tvar pro = handler(payloads)\n\t\t// func return result instead of a promise\n\t\t// we treat the out put as a promise\n\t\tif (!pro || !pro.then) pro = Promise.resolve(pro)\n\n\t\tvar resolves = buffers.map(function (i) {\n\t\t\treturn i.rs\n\t\t})\n\t\treturn new Promise(function (resolve) {\n\t\t\tpro.then(function (outs) {\n\t\t\t\tresolves.map(function (rs, i) {\n\t\t\t\t\trs(outs && outs[i])\n\t\t\t\t})\n\t\t\t\tresolve()\n\t\t\t})\n\t\t})\n\t}\n\n\tvar myFlush = function () {\n\t\tif (myState === 'executing') return\n\t\tmyState = 'executing'\n\n\t\tloop(function () {\n\t\t\tif (myBuffers.length <= maxBatch) return Promise.resolve(false)\n\t\t\tvar buffers = myBuffers.splice(0, maxBatch) // myBuffers would also be trimmed\n\t\t\treturn myExecute(buffers).then(function () {\n\t\t\t\treturn true // continue loop\n\t\t\t})\n\t\t}).then(function () {\n\t\t\tif (myBuffers.length === 0) {\n\t\t\t\tmyState = 'idle'\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// last batch\n\t\t\tvar nextms = maxDelay - (Date.now() - myBuffers[0].created)\n\t\t\tif (nextms >= 1) {\n\t\t\t\t// set timeout for the first item in queue\n\t\t\t\t// the settedTimeout property will make sure that we won't\n\t\t\t\t// set multiple timeouts for this one\n\t\t\t\tmyState = 'idle'\n\n\t\t\t\tif (myBuffers[0].settedTimeout) return\n\t\t\t\tmyBuffers[0].settedTimeout = true\n\t\t\t\tsetTimeout(myFlush, nextms)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\t// have to execute remaining items\n\t\t\tvar buffers = myBuffers\n\t\t\tmyBuffers = []\n\t\t\tmyExecute(buffers).then(function () {\n\t\t\t\t// myBuffers may have been added new item, must check after executed the last batch\n\t\t\t\tmyState = 'idle'\n\t\t\t\tmyFlush()\n\t\t\t})\n\t\t})\n\t}\n\n\tthis.push = function (payload, priority) {\n\t\treturn new Promise(function (resolve) {\n\t\t\tmyBuffers.push({payload: payload, priority: priority, created: Date.now(), rs: resolve})\n\t\t\tmyFlush()\n\t\t})\n\t}\n\n\treturn this\n}\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/flow/batch.js?\n}");
|
|
29
|
+
|
|
30
|
+
/***/ },
|
|
31
|
+
|
|
32
|
+
/***/ "./node_modules/@subiz/flow/common.js"
|
|
33
|
+
/*!********************************************!*\
|
|
34
|
+
!*** ./node_modules/@subiz/flow/common.js ***!
|
|
35
|
+
\********************************************/
|
|
36
|
+
(module) {
|
|
37
|
+
|
|
38
|
+
eval("{function map(collection, predicate) {\n\tif (!collection) return []\n\tif (!predicate) {\n\t\tpredicate = function (a) {\n\t\t\treturn a\n\t\t}\n\t}\n\n\tvar out = []\n\tif (Array.isArray(collection)) {\n\t\tfor (var i = 0; i < collection.length; i++) {\n\t\t\tout.push(predicate(collection[i], i))\n\t\t}\n\t\treturn out\n\t}\n\n\tif (typeof collection === 'object') {\n\t\tvar keys = Object.keys(collection)\n\t\tfor (var i = 0; i < keys.length; i++) {\n\t\t\tvar k = keys[i]\n\t\t\tout.push(predicate(collection[k], k))\n\t\t}\n\t\treturn out\n\t}\n\n\treturn out\n}\n\nmodule.exports = {map: map}\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/flow/common.js?\n}");
|
|
39
|
+
|
|
40
|
+
/***/ },
|
|
41
|
+
|
|
42
|
+
/***/ "./node_modules/@subiz/flow/index.js"
|
|
43
|
+
/*!*******************************************!*\
|
|
44
|
+
!*** ./node_modules/@subiz/flow/index.js ***!
|
|
45
|
+
\*******************************************/
|
|
46
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
47
|
+
|
|
48
|
+
eval("{var sleep = __webpack_require__(/*! ./sleep.js */ \"./node_modules/@subiz/flow/sleep.js\")\nvar loop = __webpack_require__(/*! ./loop.js */ \"./node_modules/@subiz/flow/loop.js\")\nvar map = __webpack_require__(/*! ./map.js */ \"./node_modules/@subiz/flow/map.js\")\nvar batch = __webpack_require__(/*! ./batch.js */ \"./node_modules/@subiz/flow/batch.js\")\n\nmodule.exports = {\n\tsleep: sleep,\n\tloop: loop,\n\tmap: map,\n\tbatch: batch,\n}\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/flow/index.js?\n}");
|
|
49
|
+
|
|
50
|
+
/***/ },
|
|
51
|
+
|
|
52
|
+
/***/ "./node_modules/@subiz/flow/loop.js"
|
|
53
|
+
/*!******************************************!*\
|
|
54
|
+
!*** ./node_modules/@subiz/flow/loop.js ***!
|
|
55
|
+
\******************************************/
|
|
56
|
+
(module) {
|
|
57
|
+
|
|
58
|
+
eval("{// loop keep calling promise sequenctially until the promise resolve a false value\nmodule.exports = function loop(promise) {\n\tvar out = promise()\n\tif (!out || !out.then) {\n\t\tvar saveout = out\n\t\tout = {\n\t\t\tthen: function (f) {\n\t\t\t\tf(saveout)\n\t\t\t},\n\t\t}\n\t}\n\treturn out.then(function (cont) {\n\t\tif (!cont) return Promise.resolve()\n\t\treturn loop(promise)\n\t})\n}\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/flow/loop.js?\n}");
|
|
59
|
+
|
|
60
|
+
/***/ },
|
|
61
|
+
|
|
62
|
+
/***/ "./node_modules/@subiz/flow/map.js"
|
|
63
|
+
/*!*****************************************!*\
|
|
64
|
+
!*** ./node_modules/@subiz/flow/map.js ***!
|
|
65
|
+
\*****************************************/
|
|
66
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
67
|
+
|
|
68
|
+
eval("{var co = __webpack_require__(/*! ./common.js */ \"./node_modules/@subiz/flow/common.js\")\n\nmodule.exports = function (collections, func, limit) {\n\tif (typeof func === 'number') {\n\t\t// backword compatible\n\t\tlet tmp = limit\n\t\tlimit = func\n\t\tfunc = tmp\n\t}\n\n\tif (!func) func = function () {}\n\tif (typeof limit !== 'number' || limit <= 0) limit = 1\n\n\t// prepare input map\n\tvar ins = {} // inputs\n\tco.map(collections, function (i, k) {\n\t\tins[k] = i\n\t})\n\n\tif (limit <= 0) limit = 1 // normalize limit\n\tif (Object.keys(ins).length === 0) return Promise.resolve([])\n\tif (Object.keys(ins).length < limit) limit = Object.keys(ins).length\n\n\tvar outs = {} // outputs\n\treturn new Promise(function (resolve) {\n\t\tlet total = Object.keys(ins).length\n\n\t\tvar doJob = function () {\n\t\t\tvar keys = Object.keys(ins)\n\t\t\tif (keys.length === 0) return\n\n\t\t\tvar key = keys.shift()\n\t\t\tvar value = ins[key]\n\t\t\tdelete ins[key]\n\n\t\t\tvar pro = func(value, key)\n\t\t\t// func return result instead of a promise\n\t\t\t// we treat the out put as a promise\n\t\t\tif (!pro || !pro.then) pro = Promise.resolve(pro)\n\n\t\t\tpro.then(function (ret) {\n\t\t\t\touts[key] = ret\n\t\t\t\tif (Object.keys(outs).length === total) return resolve(co.map(outs))\n\t\t\t\tdoJob()\n\t\t\t})\n\t\t}\n\n\t\tfor (var i = 0; i < limit; i++) setTimeout(doJob, 1)\n\t})\n}\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/flow/map.js?\n}");
|
|
69
|
+
|
|
70
|
+
/***/ },
|
|
71
|
+
|
|
72
|
+
/***/ "./node_modules/@subiz/flow/sleep.js"
|
|
73
|
+
/*!*******************************************!*\
|
|
74
|
+
!*** ./node_modules/@subiz/flow/sleep.js ***!
|
|
75
|
+
\*******************************************/
|
|
76
|
+
(module) {
|
|
77
|
+
|
|
78
|
+
eval("{// sleep won't resolve after a given milliseconds\n// e.g: await sleep(100)\nmodule.exports = function sleep(ms) {\n\treturn new Promise(function (res) {\n\t\tsetTimeout(res, ms)\n\t})\n}\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/flow/sleep.js?\n}");
|
|
79
|
+
|
|
80
|
+
/***/ },
|
|
81
|
+
|
|
82
|
+
/***/ "./node_modules/@subiz/wsclient/common.js"
|
|
83
|
+
/*!************************************************!*\
|
|
84
|
+
!*** ./node_modules/@subiz/wsclient/common.js ***!
|
|
85
|
+
\************************************************/
|
|
86
|
+
(module) {
|
|
87
|
+
|
|
88
|
+
eval("{function logError(accid, userid, message, line) {\n\t// 24-01-11 04:07:05 app ERROR api-8948967b6-qtpfx subiz /app/vendor/github.com/subiz/log/error.go:271 {\"id\":141534190473829746,\"class\":500,\"code\":\"locked_account,internal\",\"number\":\"8f2b97e9\",\"fields\":{\"ip\":\"\\\"171.224.84.93\\\"\",\"no_report\":\"true\",\"user_agent\":\"\\\"Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36\\\"\"}}\n\tlet ts = displayUTCLogTime(new Date())\n\tlet msg = JSON.stringify({\n\t\tid: Date.now(),\n\t\tclass: 400,\n\t\tcode: 'frontend_error',\n\t\tnumber: line\n\t\t\t.split('')\n\t\t\t.map((c) => c.charCodeAt(0).toString(16).padStart(2, '0'))\n\t\t\t.join(''),\n\t\tfields: {\n\t\t\tmessage: JSON.stringify(message),\n\t\t\tuser_id: userid,\n\t\t\turl: JSON.stringify(location.href),\n\t\t},\n\t})\n\n\txhrsend('POST', 'https://track.subiz.net/collect', `${ts} app ERROR dashboard ${accid} ${line} ${msg}`)\n}\n\nfunction displayUTCLogTime(date) {\n\tlet yyyy = date.getUTCFullYear().toString()\n\tlet yy = yyyy.substr(2, 2)\n\tlet mm = date.getUTCMonth() + 1\n\tlet dd = date.getUTCDate()\n\tlet hh = date.getUTCHours()\n\tlet MM = date.getUTCMinutes()\n\tlet ss = date.getUTCSeconds()\n\n\treturn `${yy}-${pad(mm)}-${pad(dd)} ${pad(hh)}:${pad(MM)}:${pad(ss)}`\n}\n\nfunction pad(v) {\n\tif (v < 10) return `0${v}`\n\treturn `${v}`\n}\n\nfunction dofetch(method, url, body, cb) {\n\tlet headers = {}\n\tif (body) headers['content-type'] = 'text/plain'\n\tfetch(url, {method: method, headers: headers, body: body})\n\t\t.then((res) => res.text().then((text) => cb && cb(text, res.status)))\n\t\t.catch((err) => cb && cb(err, -1))\n}\n\n// xhrsend sends an HTTP request\nvar xhrsend = function (method, url, body, cb) {\n\tif (typeof XMLHttpRequest === 'undefined') return dofetch(method, url, body, cb)\n\tvar request = new XMLHttpRequest()\n\trequest.onreadystatechange = function (e) {\n\t\tif (request.readyState !== 4) return\n\t\tcb && cb(request.responseText, request.status)\n\t\tcb = undefined // dont call cb anymore\n\t}\n\n\trequest.onerror = function () {\n\t\tcb && cb(request.responseText, -1) // network error\n\t\tcb = undefined // dont call cb anymore\n\t}\n\n\trequest.open(method, url)\n\tif (body) request.setRequestHeader('content-type', 'text/plain')\n\trequest.send(body)\n}\n\n// JSON.parse without exception\n// return undefined when input is an invalid JSON\nfunction parseJSON(str) {\n\ttry {\n\t\treturn JSON.parse(str)\n\t} catch (e) {}\n}\n\nfunction Pubsub() {\n\t// holds all subscriptions for all topics\n\t// example {\n\t// topic1: [cb1, cb2],\n\t// topic2: [cb3, cb4],\n\t// }\n\tvar listeners = {}\n\n\t// emit notifies any callback functions that previously\n\t// subscribed to the topic (by the on function)\n\tthis.emit = function (topic) {\n\t\t// skip the first item in arguments, which is the topic\n\t\tvar args = []\n\t\tfor (var i = 1; i < arguments.length; i++) args.push(arguments[i])\n\n\t\tvar cbs = listeners[topic]\n\t\tif (!cbs) return\n\t\tfor (var i = 0; i < cbs.length; i++) cbs[i].apply(undefined, args)\n\t}\n\n\t// register a callback function for a topic\n\t// when something is sent to the topic (by the emit function),\n\t// the callback function will be called\n\tthis.on = function (topic, cb) {\n\t\tif (!listeners[topic]) listeners[topic] = []\n\t\tlisteners[topic].push(cb)\n\t}\n}\n\nfunction randomString(len, base) {\n\tvar str = ''\n\tif (!len || len < 1) len = 10\n\tvar asciiKey\n\tfor (var i = 0; i < len; i++) {\n\t\tif (base) {\n\t\t\tstr += base[Math.floor(Math.random() * base.length)]\n\t\t} else {\n\t\t\tasciiKey = Math.floor(Math.random() * 25 + 97)\n\t\t\tstr += String.fromCharCode(asciiKey)\n\t\t}\n\t}\n\treturn str\n}\n\nmodule.exports = {xhrsend, parseJSON, Pubsub, randomString, logError}\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/wsclient/common.js?\n}");
|
|
89
|
+
|
|
90
|
+
/***/ },
|
|
91
|
+
|
|
92
|
+
/***/ "./node_modules/@subiz/wsclient/realtime.js"
|
|
93
|
+
/*!**************************************************!*\
|
|
94
|
+
!*** ./node_modules/@subiz/wsclient/realtime.js ***!
|
|
95
|
+
\**************************************************/
|
|
96
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
97
|
+
|
|
98
|
+
eval("{var flow = __webpack_require__(/*! @subiz/flow */ \"./node_modules/@subiz/flow/index.js\")\nvar {xhrsend, parseJSON, Pubsub} = __webpack_require__(/*! ./common.js */ \"./node_modules/@subiz/wsclient/common.js\")\n\n// Conn represents a realtime connection between an user and the realtime\n// server (https://rt-0.subiz.com)\n//\n// You can subscribe for realtime events and it will sent you new events\n// as fast as possible through onEvents callback.\n//\n// It will try it best to keep the communication with the realtime\n// server. But if the user is offline for too long or the network can't\n// keep up with incomming events (rarely happend with today internet speed).\n// The connection will be killed. Dead.\n//\n// Once dead, onDead will be called. After that, the connection is\n// useless, all resources will be released.\nfunction Conn(apiUrl, credential, onDead, onEvents, callAPI, accid) {\n\tcallAPI = callAPI || xhrsend // allow hook\n\tcredential = credential || {}\n\tvar lastToken = ''\n\tif (!accid) accid = ''\n\tvar is_dead = false // tell if the connection is dead\n\tvar is_polling_stuck = false // tell if we've having trouble doing /poll\n\tvar is_sub_stuck = true // tell if we've having trouble doing /subscribe\n\n\t// The long polling loop runs sequentially, with each poll starting immediately\n\t// after the previous one completes. If an error occurs, the loop will pause\n\t// using an exponential backoff strategy. It will terminate if an unretryable\n\t// error is encountered.\n\t// The first loop begins after the first subscription call completes successfully\n\tvar MIN_POLL_INTERVAL = 250 // max 4 req/s, in case the server returns instantly instead of holding the long poll\n\tvar last_poll_at = 0\n\tvar polling_started = false // make sure only one polling loop is running\n\tvar startPolling = function () {\n\t\tif (polling_started) return\n\t\tpolling_started = true\n\t\tpolling(0)\n\t}\n\tvar polling = function (backoff) {\n\t\tif (is_dead) return\n\t\tlast_poll_at = Date.now()\n\t\tcallAPI('get', apiUrl + 'poll?token=' + lastToken + '&v=5&account-id=' + accid, undefined, function (body, code) {\n\t\t\tif (is_dead) return\n\t\t\tvar wait = MIN_POLL_INTERVAL - (Date.now() - last_poll_at)\n\t\t\tif (wait < 0) wait = 0\n\t\t\tif (retryable(code)) {\n\t\t\t\tis_polling_stuck = true\n\t\t\t\treturn setTimeout(polling, Math.max(calcNextBackoff(backoff), wait), backoff + 1)\n\t\t\t}\n\n\t\t\tif (code !== 200) {\n\t\t\t\t// unretryable error, should kill\n\t\t\t\tis_polling_stuck = true\n\t\t\t\treturn kill('poll')\n\t\t\t}\n\n\t\t\t// 200, success\n\t\t\tis_polling_stuck = false\n\t\t\tbody = parseJSON(body) || {}\n\t\t\tif (body.host) apiUrl = absUrl(body.host)\n\n\t\t\tvar seqToken = body.sequential_token\n\t\t\t// the server returns a malform payload. We should end\n\t\t\tif (!seqToken) return kill('poll')\n\t\t\tlastToken = seqToken\n\t\t\tonEvents(body.events || [])\n\t\t\tif (wait > 0) return setTimeout(polling, wait, 0)\n\t\t\treturn polling(0)\n\t\t})\n\t}\n\n\tvar subQueue = flow.batch(50, 100, function (topics) {\n\t\tif (is_dead) return Promise.resolve(repeat('dead', topics.length))\n\t\tif (topics.length <= 0) return Promise.resolve([])\n\n\t\tvar resolve\n\t\tvar promise = new Promise((rs) => {\n\t\t\tresolve = rs\n\t\t})\n\n\t\tvar done = false\n\t\tsetTimeout(function () {\n\t\t\tif (!done && !is_dead) is_sub_stuck = true\n\t\t}, 4000)\n\n\t\tsetTimeout(() => {\n\t\t\t// too long, kill\n\t\t\tif (done) return\n\t\t\tdone = true\n\t\t\tis_sub_stuck = true\n\t\t\tresolve(repeat('dead', topics.length))\n\t\t\tif (is_dead) return\n\t\t\tkill('subs')\n\t\t}, 60000)\n\n\t\tflow.loop(function () {\n\t\t\treturn new Promise(function (rs) {\n\t\t\t\tif (is_dead) {\n\t\t\t\t\tresolve(repeat('dead', topics.length))\n\t\t\t\t\treturn rs(false) // break loop\n\t\t\t\t}\n\n\t\t\t\tvar query = '?token=' + lastToken\n\t\t\t\tPromise.resolve()\n\t\t\t\t\t.then(function () {\n\t\t\t\t\t\treturn credential.getAccessToken()\n\t\t\t\t\t})\n\t\t\t\t\t.then(function (access_token) {\n\t\t\t\t\t\tif (is_dead) {\n\t\t\t\t\t\t\tresolve(repeat('dead', topics.length))\n\t\t\t\t\t\t\treturn rs(false) // break loop\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (credential.user_ref) query += '&user_ref=' + encodeURIComponent(credential.user_ref)\n\t\t\t\t\t\telse if (credential.user_mask) query += '&user-mask=' + encodeURIComponent(credential.user_mask)\n\t\t\t\t\t\telse if (access_token) query += '&access-token=' + access_token\n\n\t\t\t\t\t\tvar fullurl =\n\t\t\t\t\t\t\tapiUrl + 'subs' + query + '&v=5&account-id=' + encodeURIComponent(accid || credential.account_id)\n\t\t\t\t\t\tcallAPI('post', fullurl, JSON.stringify({events: topics}), function (body, code) {\n\t\t\t\t\t\t\tif (done) return\n\t\t\t\t\t\t\tif (is_dead) {\n\t\t\t\t\t\t\t\tresolve(repeat('dead', topics.length))\n\t\t\t\t\t\t\t\treturn rs(false) // break loop\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (retryable(code)) {\n\t\t\t\t\t\t\t\tis_sub_stuck = true\n\t\t\t\t\t\t\t\treturn setTimeout(rs, 3000, true)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// unretryable error\n\t\t\t\t\t\t\tif (code !== 200) {\n\t\t\t\t\t\t\t\t// we are unable to start the communication with the realtime server.\n\t\t\t\t\t\t\t\t// Must notify the user by killing the connection\n\t\t\t\t\t\t\t\tkill('subs')\n\t\t\t\t\t\t\t\tresolve(repeat('dead', topics.length))\n\t\t\t\t\t\t\t\treturn rs(false)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tis_sub_stuck = false\n\t\t\t\t\t\t\tdone = true\n\t\t\t\t\t\t\tif (lastToken) {\n\t\t\t\t\t\t\t\tresolve(topics)\n\t\t\t\t\t\t\t\treturn rs(false)\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// first time sub, should grab the initial token\n\t\t\t\t\t\t\tbody = parseJSON(body) || {}\n\t\t\t\t\t\t\tvar initialToken = body.initial_token\n\t\t\t\t\t\t\t// the server returns a malform payload. We should end\n\t\t\t\t\t\t\tif (!initialToken) {\n\t\t\t\t\t\t\t\tkill('subs')\n\t\t\t\t\t\t\t\tresolve(repeat('dead', topics.length))\n\t\t\t\t\t\t\t\treturn rs(false) // break loop\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// learn new host\n\t\t\t\t\t\t\tif (body.host) apiUrl = absUrl(body.host)\n\n\t\t\t\t\t\t\tlastToken = initialToken\n\t\t\t\t\t\t\tstartPolling()\n\t\t\t\t\t\t\tresolve(topics)\n\t\t\t\t\t\t\treturn rs(false) // to break the loop\n\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function () {\n\t\t\t\t\t\t// getAccessToken failed, retry instead of hanging the loop\n\t\t\t\t\t\tis_sub_stuck = true\n\t\t\t\t\t\tsetTimeout(rs, 3000, true)\n\t\t\t\t\t})\n\t\t\t})\n\t\t})\n\n\t\treturn promise\n\t})\n\n\t// subscribe call /subs API to tell server that we are listening for those events\n\t// this function may start polling loop if it hasn't been started yet\n\t// its safe to call this function multiple times\n\tthis.subscribe = subQueue.push.bind(subQueue)\n\n\tthis.getStatus = function () {\n\t\tif (is_dead) return 'dead'\n\t\tif (is_sub_stuck || is_polling_stuck) return 'connecting'\n\t\treturn 'active'\n\t}\n\n\t// kill force the connection to dead state\n\tvar kill = function (reason) {\n\t\tis_dead = true\n\t\tonDead(reason)\n\t}\n\tthis.kill = kill\n}\n\n// Realtime helps you subscribe and listen realtime event from th\n// realtime server\n// Realtime is just a stronger Conn.\nfunction Realtime(apiUrls, credential, callAPI, accid, skipautoreconnect) {\n\tif (typeof apiUrls === 'string' || apiUrls instanceof String) apiUrls = [apiUrls]\n\tcredential = credential || {}\n\tif (!credential.getAccessToken) {\n\t\tcredential.getAccessToken = function () {\n\t\t\treturn Promise.resolve('')\n\t\t}\n\t}\n\tif (!accid) accid = credential.account_id || ''\n\tvar pubsub = new Pubsub()\n\n\t// holds all topics that realtime must subscribed\n\tvar topics = {}\n\n\t// stop the connection\n\tthis.stop = function () {\n\t\tif (!conn) return\n\t\t// detach before killing so onDead knows this is intentional and\n\t\t// doesn't schedule a reconnect\n\t\tvar oldconn = conn\n\t\tconn = undefined\n\t\toldconn.kill()\n\t\tpubsub.emit('interrupted')\n\t}\n\n\tthis.onEvent = function (cb) {\n\t\treturn pubsub.on('event', cb)\n\t}\n\n\tthis.onInterrupted = function (cb) {\n\t\treturn pubsub.on('interrupted', cb)\n\t}\n\n\tthis.getStatus = function () {\n\t\tif (!conn) return 'dead'\n\t\treturn conn.getStatus()\n\t}\n\n\tvar subscribe = function (events) {\n\t\tif (!conn) return Promise.resolve({error: 'dead'})\n\t\tif (typeof events === 'string') events = [events]\n\t\tif (!Array.isArray(events)) return Promise.resolve({error: 'param should be an array or string'})\n\n\t\t// ignore already subscribed events\n\t\tvar all = []\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tvar topic = events[i]\n\t\t\tif (!topic) continue\n\t\t\tif (topics[topic]) continue\n\t\t\ttopics[topic] = true // mark so next time we wont subscribe this event (topic) again\n\t\t\tall.push(conn.subscribe(topic))\n\t\t}\n\t\tif (all.length === 0) return Promise.resolve({})\n\t\treturn Promise.all(all).then(function () {\n\t\t\tif (!conn || conn.getStatus() == 'dead') return {error: 'dead'}\n\t\t\treturn {}\n\t\t})\n\t}\n\tthis.subscribe = subscribe\n\n\t// reconnect make sure there is alway a Conn running in the background\n\t// if the Conn is dead, it recreate a new one\n\tvar conn\n\tvar reconnect = function () {\n\t\tvar randomUrl = apiUrls[Math.floor(Math.random() * apiUrls.length)]\n\t\tif (conn) {\n\t\t\t// detach before killing so the old conn's onDead doesn't\n\t\t\t// schedule another reconnect (which would kill this new conn,\n\t\t\t// schedule another one, and churn forever)\n\t\t\tvar oldconn = conn\n\t\t\tconn = undefined\n\t\t\toldconn.kill()\n\t\t}\n\t\tvar myconn = new Conn(\n\t\t\trandomUrl,\n\t\t\tcredential,\n\t\t\tfunction (code, body, status) {\n\t\t\t\tif (conn === undefined || myconn != conn) return // outdated\n\t\t\t\tconn = undefined // prevent dupplicate dead fire\n\t\t\t\tpubsub.emit('interrupted', code, body, status)\n\t\t\t\tif (!skipautoreconnect) setTimeout(reconnect, 2000) // reconnect and resubscribe after 2 sec\n\t\t\t},\n\t\t\tfunction (events) {\n\t\t\t\tif (myconn != conn) return\n\t\t\t\tfor (var i = 0; i < events.length; i++) pubsub.emit('event', events[i])\n\t\t\t},\n\t\t\tcallAPI,\n\t\t\taccid,\n\t\t)\n\t\tconn = myconn\n\t\tvar copyTopics = Object.keys(topics)\n\t\ttopics = {}\n\t\t// resubscribe all subscribed events\n\t\treturn subscribe(copyTopics)\n\t}\n\tthis.reconnect = reconnect\n\treconnect()\n}\n\n// calcNextBackoff returns number of seconds we must wait\n// before sending a next request\n// the results is determind based on exponential backoff algorithm\n// see https://en.wikipedia.org/wiki/Exponential_backoff\nfunction calcNextBackoff(attempts) {\n\tvar RECONNECT_INTERVAL = 1000\n\tvar MAX_RECONNECT_INTERVAL = 10000\n\tvar RECONNECT_DECAY = 1.5\n\n\tif (!attempts || attempts === -1) return 0 // first time connect\n\tvar delaytime = RECONNECT_INTERVAL * Math.pow(RECONNECT_DECAY, attempts)\n\treturn Math.min(MAX_RECONNECT_INTERVAL, delaytime)\n}\n\n// retryable decides whether we should resent the HTTP request\n// based on last response or network state\nfunction retryable(code) {\n\t// code = 0 means server return response without CORS header, so we are unable to read it\n\t// code = -1 means the network connection is dead\n\treturn (code >= 500 && code < 600) || code === 0 || code === -1 || code === 429\n}\n\nfunction repeat(ele, n) {\n\tvar arr = []\n\tfor (var i = 0; i < n; i++) arr.push(ele)\n\treturn arr\n}\n\nfunction absUrl(url) {\n\turl = url || ''\n\tif (url.startsWith('//')) return 'https:' + url\n\treturn url\n}\n\nmodule.exports = Realtime\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/@subiz/wsclient/realtime.js?\n}");
|
|
99
|
+
|
|
100
|
+
/***/ },
|
|
101
|
+
|
|
102
|
+
/***/ "./config.js"
|
|
103
|
+
/*!*******************!*\
|
|
104
|
+
!*** ./config.js ***!
|
|
105
|
+
\*******************/
|
|
106
|
+
(module) {
|
|
107
|
+
|
|
108
|
+
eval("{module.exports = {\n ApiURL: 'https://api.sbz.vn/4.0',\n RealtimeURL: 'https://api.sbz.vn/rts/0/',\n FileURL: 'https://vcdn.subiz-cdn.com/file/',\n BaseURL: 'https://widget.sbz.vn'\n};\n\n//# sourceURL=webpack://@subiz/widget-v4/./config.js?\n}");
|
|
109
|
+
|
|
110
|
+
/***/ },
|
|
111
|
+
|
|
112
|
+
/***/ "./src/chatbox/DropdownSelect.js"
|
|
113
|
+
/*!***************************************!*\
|
|
114
|
+
!*** ./src/chatbox/DropdownSelect.js ***!
|
|
115
|
+
\***************************************/
|
|
116
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
117
|
+
|
|
118
|
+
"use strict";
|
|
119
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ DropdownSelect)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common.js */ \"./src/common.js\");\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\n/* harmony import */ var _spinner_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./spinner.js */ \"./src/chatbox/spinner.js\");\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n;\n\n\n\nclass DropdownSelect extends _common_js__WEBPACK_IMPORTED_MODULE_1__.Com {\n constructor(props) {\n super(props);\n _defineProperty(this, \"state\", {\n show: false,\n searchValue: ''\n });\n _defineProperty(this, \"filterRef\", (0,preact__WEBPACK_IMPORTED_MODULE_2__.createRef)());\n _defineProperty(this, \"overlayRef\", (0,preact__WEBPACK_IMPORTED_MODULE_2__.createRef)());\n _defineProperty(this, \"onTouchMove\", e => {\n if (e.target === this.overlayRef.current) {\n e.preventDefault();\n e.stopPropagation();\n }\n });\n _defineProperty(this, \"hideDropdown\", () => {\n this.setState({\n show: false,\n searchValue: ''\n });\n });\n _defineProperty(this, \"onKeydown\", e => {\n if (e.key === 'Escape') {\n if (!this.state.show) return;\n if (this.state.searchValue) this.setState({\n searchValue: ''\n });else this.hideDropdown();\n e.preventDefault();\n e.stopPropagation();\n }\n });\n _defineProperty(this, \"hasSearch\", () => {\n if (this.props.has_search) return true;\n return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(this.props.items) >= 10;\n });\n _defineProperty(this, \"getFilteredOptions\", () => {\n let items = this.props.items;\n if (this.state.searchValue && this.hasSearch()) {\n items = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].filter(items, item => {\n let optionName = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');\n let optionDesc = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');\n let searchValue = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');\n return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;\n });\n }\n return items;\n });\n _defineProperty(this, \"onChangeSearchValue\", e => {\n this.setState({\n searchValue: e.target.value\n });\n });\n _defineProperty(this, \"toogleDropdown\", async () => {\n await this.setState({\n show: true,\n searchValue: ''\n });\n this.focusFilter();\n });\n _defineProperty(this, \"onSelect\", item => {\n this.props.onSelect(item);\n this.hideDropdown();\n });\n _defineProperty(this, \"onBackgroundScroll\", e => {\n console.log('EEEEEEE', e);\n alert('y');\n });\n document.addEventListener('touchmove', function (e) {});\n }\n componentDidMount() {\n window.addEventListener('keydown', this.onKeydown);\n }\n componentWillUnmount() {\n window.removeEventListener('keydown', this.onKeydown);\n }\n renderEmpty() {\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select_filter__empty\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"img\", {\n class: \"dropdown_select_filter__empty_img\",\n src: __webpack_require__(/*! ../../assets/img/not_found_search.png */ \"./assets/img/not_found_search.png\")\n }), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"muted\",\n style: \"text-align: center !important;\"\n }, \"Kh\\xF4ng c\\xF3 k\\u1EBFt qu\\u1EA3\"));\n }\n renderLoading() {\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select_filter__empty pt-3\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(_spinner_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n size: \"40\",\n static: true\n }), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"muted mt-2\",\n style: \"text-align: center !important;\"\n }, \"\\u0110ang t\\u1EA3i d\\u1EEF li\\u1EC7u\"));\n }\n focusFilter() {\n if (!this.filterRef.current) return;\n this.filterRef.current.focus();\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(() => {\n if (!this.filterRef.current) return;\n this.filterRef.current.focus();\n }, 100);\n }\n renderDropdown() {\n if (!this.state.show) return null;\n let items = this.getFilteredOptions();\n let $items = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(items, item => {\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__item\",\n onClick: _ => this.onSelect(item)\n }, item.name);\n });\n let $filter = null;\n if (this.hasSearch()) {\n let $img = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"img\", {\n class: \"dropdown_select_filter__icon\",\n src: __webpack_require__(/*! ../../assets/img/search.svg */ \"./assets/img/search.svg\")\n });\n if (this.props.loading) {\n $img = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"img\", {\n class: \"dropdown_select_filter__icon\",\n src: __webpack_require__(/*! ../../assets/img/loader.svg */ \"./assets/img/loader.svg\")\n });\n }\n $filter = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select_filter\"\n }, $img, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"input\", {\n ref: this.filterRef,\n value: this.state.searchValue,\n onInput: this.onChangeSearchValue,\n type: \"text\",\n class: \"dropdown_select_filter_input \"\n }));\n }\n if ($items.length == 0) $items = this.renderEmpty();\n if (this.props.loading) $items = this.renderLoading();\n let style = `width: ${this.props.width || '150px'} !important;`;\n if (this.props.full) {\n style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__overlay\",\n ref: this.overlayRef,\n onClick: this.hideDropdown,\n onTouchMove: this.onTouchMove\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select\",\n style: style,\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n }\n }, $filter, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__items\"\n }, $items)));\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select\",\n style: style\n }, $filter, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__items\"\n }, $items));\n }\n render() {\n let $name = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"muted text-truncate\",\n style: \"flex: 1 !important;\"\n }, \"Ch\\u1ECDn m\\u1ED9t ph\\u1EA7n t\\u1EED\");\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.props, 'selected.name')) $name = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"text-truncate\",\n style: \"flex: 1 !important;\"\n }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.props, 'selected.name'));\n let style = 'position: relative !important;';\n if (this.props.full) {\n style = '';\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n style: style\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(_common_js__WEBPACK_IMPORTED_MODULE_1__.Clickaway, {\n onClickaway: this.hideDropdown\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n type: \"text\",\n class: 'dropdown_select_input ' + this.props.extra_cls,\n onClick: this.toogleDropdown\n }, $name, \"\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"img\", {\n class: \"dropdown_select__caret\",\n src: __webpack_require__(/*! ../../assets/img/caret.svg */ \"./assets/img/caret.svg\")\n })), this.renderDropdown()));\n }\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/chatbox/DropdownSelect.js?\n}");
|
|
120
|
+
|
|
121
|
+
/***/ },
|
|
122
|
+
|
|
123
|
+
/***/ "./src/chatbox/spinner.js"
|
|
124
|
+
/*!********************************!*\
|
|
125
|
+
!*** ./src/chatbox/spinner.js ***!
|
|
126
|
+
\********************************/
|
|
127
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
128
|
+
|
|
129
|
+
"use strict";
|
|
130
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Spinner)\n/* harmony export */ });\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../common.js */ \"./src/common.js\");\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\nconst loadingimg = __webpack_require__(/*! ../../assets/img/loading_static.svg */ \"./assets/img/loading_static.svg\");\n\n\nclass Spinner extends _common_js__WEBPACK_IMPORTED_MODULE_0__.Com {\n render() {\n let mode = (this.props.mode + '').toLowerCase();\n let mainColor = mode === 'dark' ? '#000000dd' : mode === 'blue' ? 'rgba(52, 152, 220, .8)' : mode;\n let size = this.props.size || 14;\n let borderWidth = Math.ceil(size / 14);\n let style = `width: ${size}px !important;height: ${size}px !important;`;\n if (this.props.center) {\n return (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)(\"div\", {\n class: \"loading\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)(\"img\", {\n alt: \"loading\",\n style: style,\n src: loadingimg\n }));\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_1__.h)(\"img\", {\n alt: \"loading\",\n style: style,\n src: loadingimg\n });\n }\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/chatbox/spinner.js?\n}");
|
|
131
|
+
|
|
132
|
+
/***/ },
|
|
133
|
+
|
|
134
|
+
/***/ "./src/chatbox/time.js"
|
|
135
|
+
/*!*****************************!*\
|
|
136
|
+
!*** ./src/chatbox/time.js ***!
|
|
137
|
+
\*****************************/
|
|
138
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
139
|
+
|
|
140
|
+
"use strict";
|
|
141
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Time)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common.js */ \"./src/common.js\");\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\n\nvar g_pub = new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Pubsub();\n_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setInterval(() => g_pub.publish('time'), 20 * 1000);\n\n\nclass Time extends _common_js__WEBPACK_IMPORTED_MODULE_1__.Com {\n constructor(props) {\n super(props);\n this.setState({\n t: '',\n langCode: 'en_US'\n });\n }\n updateTime() {\n var t = '';\n let forceLocale = '';\n if (this.props.t) {\n if (this.props.t.locale && typeof this.props.t.locale === 'function') {\n forceLocale = this.props.t.locale();\n }\n }\n if (this.props.ago) {\n if (this.props.short) {}\n if (!t && this.props.time > 0) t = ago(this.props.time, new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date().getTime(), this.props.t);\n } else t = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].shortTime(this.props.time, this.props.tzoffset, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now(), forceLocale);\n if (this.props.uppercase) t = t.toUpperCase();\n if (t === this.state.t) return;\n this.setState({\n t\n });\n }\n componentDidMount() {\n g_pub.on2(this, 'time', () => this.updateTime());\n this.updateTime();\n }\n render() {\n let locale = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(navigator, 'languages.0', 'en-US');\n if (this.props.t) {\n if (this.props.t.locale && typeof this.props.t.locale === 'function') {\n locale = this.props.t.locale();\n }\n }\n let title = new Date(this.props.time).toLocaleString(locale);\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"span\", {\n class: this.props.class,\n style: this.props.style,\n title: title\n }, this.state.t);\n }\n}\nfunction ago(timeA, timeB, t) {\n let relObj = {\n s: '%d sec',\n m: '1 min',\n mm: '%d mins',\n h: '1 hour',\n hh: '%d hours',\n d: '1 day',\n dd: '%d days',\n M: '1 month',\n MM: '%d months',\n y: '1 year',\n yy: '%d years'\n };\n if (t) {\n relObj = {\n s: `%d ${t('second_short')}`,\n m: `1 ${t('minute_short')}`,\n mm: `%d ${t('minutes_short')}`,\n h: `1 ${t('hour_short')}`,\n hh: `%d ${t('hours_short')}`,\n d: `1 ${t('day_short')}`,\n dd: `%d ${t('days_short')}`,\n M: `1 ${t('month_short')}`,\n MM: `%d ${t('months_short')}`,\n y: `1 ${t('year_short')}`,\n yy: `%d ${t('years_short')}`\n };\n }\n const loc = relObj;\n const T = [{\n l: 's',\n r: 44,\n d: 1000\n }, {\n l: 'm',\n r: 89\n }, {\n l: 'mm',\n r: 44,\n d: 60000\n }, {\n l: 'h',\n r: 89\n }, {\n l: 'hh',\n r: 21,\n d: 3600000\n }, {\n l: 'd',\n r: 35\n }, {\n l: 'dd',\n r: 25,\n d: 86400000\n }, {\n l: 'M',\n r: 45\n }, {\n l: 'MM',\n r: 10,\n d: 30 * 86400000\n }, {\n l: 'y',\n r: 17\n }, {\n l: 'yy',\n d: 365 * 86400000\n }];\n const Tl = T.length;\n let result;\n let out;\n for (let i = 0; i < Tl; i += 1) {\n let t = T[i];\n if (t.d) {\n result = (timeA - timeB) / t.d;\n }\n let abs = Math.round(Math.abs(result));\n if (abs <= t.r || !t.r) {\n if (abs <= 1 && i > 0) t = T[i - 1];\n out = loc[t.l].replace('%d', abs);\n break;\n }\n }\n return out;\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/chatbox/time.js?\n}");
|
|
142
|
+
|
|
143
|
+
/***/ },
|
|
144
|
+
|
|
145
|
+
/***/ "./src/common.js"
|
|
146
|
+
/*!***********************!*\
|
|
147
|
+
!*** ./src/common.js ***!
|
|
148
|
+
\***********************/
|
|
149
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
150
|
+
|
|
151
|
+
"use strict";
|
|
152
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Clickaway: () => (/* binding */ Clickaway),\n/* harmony export */ Com: () => (/* binding */ Com),\n/* harmony export */ downloadLanguage: () => (/* binding */ downloadLanguage),\n/* harmony export */ getLocale: () => (/* binding */ getLocale),\n/* harmony export */ langMessages: () => (/* binding */ langMessages)\n/* harmony export */ });\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util/index.js */ \"./src/util/index.js\");\n\n\nclass Com extends preact__WEBPACK_IMPORTED_MODULE_0__.Component {\n constructor(props) {\n super(props);\n this._isMounted = true;\n _util_index_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].setTimeout(() => {\n if (this.componentWillUnmount) {\n let old = this.componentWillUnmount.bind(this);\n this.componentWillUnmount = () => {\n old();\n this._isMounted = false;\n };\n }\n }, 10);\n }\n}\nclass Clickaway extends Com {\n constructor(props) {\n super(props);\n this.setWrapperRef = this.setWrapperRef.bind(this);\n this.onClick = this.onClick.bind(this);\n }\n componentDidMount() {\n document.addEventListener('mousedown', this.onClick);\n }\n componentWillUnmount() {\n document.removeEventListener('mousedown', this.onClick);\n }\n setWrapperRef(node) {\n this.wrapperRef = node;\n }\n onClick(event) {\n if (this.wrapperRef && !this.wrapperRef.contains(event.target)) {\n this.props.onClickaway && this.props.onClickaway();\n }\n }\n render() {\n return (0,preact__WEBPACK_IMPORTED_MODULE_0__.h)(\"div\", {\n ref: this.setWrapperRef\n }, this.props.children);\n }\n}\nconst getLocale = (plugin, loc) => {\n if (!loc) loc = '';\n let found = _util_index_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].find(plugin.locales, l => l.toLowerCase().trim() === loc.toLowerCase().trim());\n if (found) return found;\n found = _util_index_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].find(plugin.locales, l => {\n l = l.replace('-', '_').split('_')[0].trim().toLowerCase();\n let compareloc = loc.replace('-', '_').split('_')[0].trim().toLowerCase();\n return l == compareloc;\n });\n if (found) return found;\n return plugin.locale || 'en-US';\n};\nlet langMessages = {};\nlet downloadLock = false;\nfunction downloadLanguage(store, locale, force) {\n if (downloadLock) return new Promise(resolve => _util_index_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].setTimeout(() => downloadLanguage(store, locale, force).then(resolve), 100));\n downloadLock = true;\n let messages;\n if (locale === 'debug' || langMessages[locale] && !force) {\n downloadLock = false;\n return Promise.resolve();\n }\n return store.getLocaleContent(locale).then(res => {\n downloadLock = false;\n messages = _util_index_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"].get(res, 'body.messages', []);\n langMessages[locale] = messages;\n });\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/common.js?\n}");
|
|
153
|
+
|
|
154
|
+
/***/ },
|
|
155
|
+
|
|
156
|
+
/***/ "./src/order/address_picker.js"
|
|
157
|
+
/*!*************************************!*\
|
|
158
|
+
!*** ./src/order/address_picker.js ***!
|
|
159
|
+
\*************************************/
|
|
160
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
161
|
+
|
|
162
|
+
"use strict";
|
|
163
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ AddressPicker)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common.js */ \"./src/common.js\");\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\n/* harmony import */ var _chatbox_spinner_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../chatbox/spinner.js */ \"./src/chatbox/spinner.js\");\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n;\n\n\n\nclass AddressPicker extends _common_js__WEBPACK_IMPORTED_MODULE_1__.Com {\n constructor(props) {\n super(props);\n _defineProperty(this, \"state\", {\n show: false,\n searchValue: '',\n addresses: []\n });\n _defineProperty(this, \"filterRef\", (0,preact__WEBPACK_IMPORTED_MODULE_2__.createRef)());\n _defineProperty(this, \"overlayRef\", (0,preact__WEBPACK_IMPORTED_MODULE_2__.createRef)());\n _defineProperty(this, \"onTouchMove\", e => {\n if (e.target === this.overlayRef.current) {\n e.preventDefault();\n e.stopPropagation();\n }\n });\n _defineProperty(this, \"hideDropdown\", () => {\n this.setState({\n show: false,\n searchValue: ''\n });\n });\n _defineProperty(this, \"onKeydown\", e => {\n if (e.key === 'Escape') {\n if (!this.state.show) return;\n if (this.state.searchValue) this.setState({\n searchValue: ''\n });else this.hideDropdown();\n e.preventDefault();\n e.stopPropagation();\n }\n if (e.key == 'Enter') {}\n });\n _defineProperty(this, \"doSearch\", _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].throttle(async () => {\n let requestId = Date.now();\n this.requestId = requestId;\n let res = await this.props.store.suggest_addresses(this.state.searchValue);\n if (this.requestId !== requestId) return;\n this.setState({\n addresses: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(res, 'body.addresses', [])\n });\n }, 100));\n _defineProperty(this, \"onChangeSearchValue\", e => {\n this.setState({\n searchValue: e.target.value\n });\n this.props.onChangeAddress(e.target.value);\n this.doSearch();\n });\n _defineProperty(this, \"toogleDropdown\", async () => {\n await this.setState({\n show: true,\n searchValue: this.props.initAddress || ''\n });\n this.focusFilter();\n });\n _defineProperty(this, \"onSelect\", item => {\n this.props.onSelect(item);\n this.hideDropdown();\n });\n _defineProperty(this, \"onBackgroundScroll\", e => {\n console.log('EEEEEEE', e);\n });\n document.addEventListener('touchmove', function (e) {});\n }\n componentDidMount() {\n window.addEventListener('keydown', this.onKeydown);\n }\n componentWillUnmount() {\n window.removeEventListener('keydown', this.onKeydown);\n }\n renderEmpty() {\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select_filter__empty\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"img\", {\n class: \"dropdown_select_filter__empty_img\",\n src: __webpack_require__(/*! ../../assets/img/not_found_search.png */ \"./assets/img/not_found_search.png\")\n }), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"muted\",\n style: \"text-align: center !important;\"\n }, \"Kh\\xF4ng c\\xF3 k\\u1EBFt qu\\u1EA3\"));\n }\n renderLoading() {\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select_filter__empty pt-3\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(_chatbox_spinner_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n size: \"40\",\n static: true\n }), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"muted mt-2\",\n style: \"text-align: center !important;\"\n }, \"\\u0110ang t\\u1EA3i d\\u1EEF li\\u1EC7u\"));\n }\n focusFilter() {\n if (!this.filterRef.current) return;\n this.filterRef.current.focus();\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(() => {\n if (!this.filterRef.current) return;\n this.filterRef.current.focus();\n }, 100);\n }\n renderDropdown() {\n if (!this.state.show) return null;\n let $items = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.state.addresses, (addr, i) => {\n let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');\n let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__item\",\n onClick: _ => this.onSelect(addr),\n key: i\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", null, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"b\", null, label)), (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n style: \"opacity: 0.7 !important;\"\n }, desc));\n });\n let $filter = null;\n let $img = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"img\", {\n class: \"dropdown_select_filter__icon\",\n src: __webpack_require__(/*! ../../assets/img/search.svg */ \"./assets/img/search.svg\")\n });\n if (this.props.loading) {\n $img = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"img\", {\n class: \"dropdown_select_filter__icon\",\n src: __webpack_require__(/*! ../../assets/img/loader.svg */ \"./assets/img/loader.svg\")\n });\n }\n $filter = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select_filter\"\n }, $img, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"input\", {\n ref: this.filterRef,\n value: this.state.searchValue,\n onInput: this.onChangeSearchValue,\n type: \"text\",\n class: \"dropdown_select_filter_input \"\n }));\n if ($items.length == 0) $items = this.renderEmpty();\n if (this.props.loading) $items = this.renderLoading();\n let style = `width: ${this.props.width || '150px'} !important;`;\n if (this.props.full) {\n style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__overlay\",\n ref: this.overlayRef,\n onClick: this.hideDropdown,\n onTouchMove: this.onTouchMove\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select\",\n style: style,\n onClick: e => {\n e.preventDefault();\n e.stopPropagation();\n }\n }, $filter, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__items\"\n }, $items)));\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select\",\n style: style\n }, $filter, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"dropdown_select__items\"\n }, $items));\n }\n render() {\n let $name = (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n class: \"text-truncate\",\n style: \"flex: 1 !important;\"\n }, this.props.initAddress);\n let style = 'position: relative !important;';\n if (this.props.full) {\n style = '';\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n style: style\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(_common_js__WEBPACK_IMPORTED_MODULE_1__.Clickaway, {\n onClickaway: this.hideDropdown\n }, (0,preact__WEBPACK_IMPORTED_MODULE_2__.h)(\"div\", {\n type: \"text\",\n class: 'dropdown_select_input ' + this.props.extra_cls,\n onClick: this.toogleDropdown\n }, $name), this.renderDropdown()));\n }\n}\nfunction normalize(s) {\n let ls = (s + '').toLowerCase();\n if (ls.startsWith('tp ')) return s.substr(3);\n if (ls.startsWith('thanh pho ')) return s.substr('thanh pho '.length);\n if (ls.startsWith('thành phố ')) return s.substr('thành phố '.length);\n if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);\n if (ls.startsWith('huyện ')) return s.substr('huyện '.length);\n if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);\n if (ls.startsWith('xã ')) return s.substr('xã '.length);\n if (ls.startsWith('thị trấn ')) return s.substr('thị trấn '.length);\n if (ls.startsWith('thị xã ')) return s.substr('thị xã '.length);\n if (ls.startsWith('đường ') && (s[7] < '0' || s[7] > '9')) return s.substr('đường '.length);\n if (ls.startsWith('phường ') && (s[7] < '0' || s[7] > '9')) return s.substr('phường '.length);\n if (ls.startsWith('quận ') && (s[7] < '0' || s[7] > '9')) return s.substr('quận '.length);\n return s;\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/order/address_picker.js?\n}");
|
|
164
|
+
|
|
165
|
+
/***/ },
|
|
166
|
+
|
|
167
|
+
/***/ "./src/order/icon.js"
|
|
168
|
+
/*!***************************!*\
|
|
169
|
+
!*** ./src/order/icon.js ***!
|
|
170
|
+
\***************************/
|
|
171
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
172
|
+
|
|
173
|
+
"use strict";
|
|
174
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Icon)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\n/* harmony import */ var _chatbox_time_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../chatbox/time.js */ \"./src/chatbox/time.js\");\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common.js */ \"./src/common.js\");\n/* harmony import */ var _chatbox_DropdownSelect_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../chatbox/DropdownSelect.js */ \"./src/chatbox/DropdownSelect.js\");\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\n\nlet promiseMainCSS = (() => __webpack_require__.e(/*! import() */ \"src_chatbox_css_js\").then(() => (__webpack_require__(/*! ../chatbox/css.js */ \"./src/chatbox/css.js\"))))();\nvar $link = document.createElement('link');\n$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';\n$link.rel = 'stylesheet';\ndocument.head.append($link);\n_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].preloadWebfonts(['Inter'], [400, 500]);\n\nlet defaultAvatar = __webpack_require__(/*! ../../assets/img/default_avatar.png */ \"./assets/img/default_avatar.png\");\n\n\n\nclass Icon extends _common_js__WEBPACK_IMPORTED_MODULE_2__.Com {\n render() {\n if (this.props.name == 'package') {\n if (this.props.active) return (0,preact__WEBPACK_IMPORTED_MODULE_4__.h)(\"img\", {\n style: \"width: 18px !important;\",\n src: __webpack_require__(/*! ../../assets/img/package.svg */ \"./assets/img/package.svg\")\n });\n return (0,preact__WEBPACK_IMPORTED_MODULE_4__.h)(\"img\", {\n style: \"width: 18px !important;\",\n src: __webpack_require__(/*! ../../assets/img/package_fade.svg */ \"./assets/img/package_fade.svg\")\n });\n }\n if (this.props.name === 'shop') {\n if (this.props.active) return (0,preact__WEBPACK_IMPORTED_MODULE_4__.h)(\"img\", {\n style: \"width: 18px !important;\",\n src: __webpack_require__(/*! ../../assets/img/shop.svg */ \"./assets/img/shop.svg\")\n });\n return (0,preact__WEBPACK_IMPORTED_MODULE_4__.h)(\"img\", {\n style: \"width: 18px !important;\",\n src: __webpack_require__(/*! ../../assets/img/shop_faded.svg */ \"./assets/img/shop_faded.svg\")\n });\n }\n }\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/order/icon.js?\n}");
|
|
175
|
+
|
|
176
|
+
/***/ },
|
|
177
|
+
|
|
178
|
+
/***/ "./src/order/index.js"
|
|
179
|
+
/*!****************************!*\
|
|
180
|
+
!*** ./src/order/index.js ***!
|
|
181
|
+
\****************************/
|
|
182
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
183
|
+
|
|
184
|
+
"use strict";
|
|
185
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _store_store_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../store/store.js */ \"./src/store/store.js\");\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common.js */ \"./src/common.js\");\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\n/* harmony import */ var _order_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./order.js */ \"./src/order/order.js\");\n\n\n\n\n\nlet promiseMainCSS = (() => __webpack_require__.e(/*! import() */ \"src_chatbox_css_js\").then(() => (__webpack_require__(/*! ../chatbox/css.js */ \"./src/chatbox/css.js\"))))();\nvar config = __webpack_require__(/*! ../../config.js */ \"./config.js\");\nfunction findChatbox(store) {\n var pluginM = store.matchPlugin();\n let chatboxs = _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].filter(pluginM, plugin => plugin.type === 'chatbox');\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].size(chatboxs) === 0) {\n console.error('no chatbox found.');\n return;\n }\n return chatboxs[0];\n}\nfunction getUrlParameter(name) {\n name = name.replace(/[\\[]/, '\\\\[').replace(/[\\]]/, '\\\\]');\n var regex = new RegExp('[\\\\?&]' + name + '=([^&#]*)');\n var results = regex.exec(location.search);\n return results === null ? '' : decodeURIComponent(results[1].replace(/\\+/g, ' '));\n}\nvar $link = document.createElement('link');\n$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';\n$link.rel = 'stylesheet';\ndocument.head.append($link);\n_util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].preloadWebfonts(['Inter'], [400, 500]);\nasync function load() {\n let store = new _store_store_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"](config.ApiURL, config.FileURL, config.RealtimeURL, true);\n let signkey = getUrlParameter('x-signed-key');\n let {\n body,\n error\n } = await store.lookupOrder(signkey);\n let order = body;\n let accid = _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get(order, 'ctx.credential.account_id');\n let user_id = _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get(order, 'ctx.credential.issuer');\n let mask = accid + '@' + user_id;\n await store.init(accid, mask);\n window.store = store;\n let t = key => {\n if (_locale === 'debug') return `{{${key}}}`;\n let messages = _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get(_common_js__WEBPACK_IMPORTED_MODULE_1__.langMessages, _locale, []);\n let message = _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].find(messages, message => message.key === key);\n return _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].get(message, 'message', key);\n };\n let acc = store.matchAccount();\n let plugin = findChatbox(store);\n let css = (await promiseMainCSS).default.default.toString();\n var outcss = _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].replaceCssVariable(css, plugin.chatbox);\n let $cssStyleDiv = document.createElement('style');\n document.head.appendChild($cssStyleDiv);\n $cssStyleDiv.type = 'text/css';\n $cssStyleDiv.id = 'subiz-style-for-order';\n _util_index_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].setCss('order', $cssStyleDiv, outcss);\n let _locale = plugin.locale || acc.locale || 'vi-VN';\n t.i18n = i18nText => {\n if (!i18nText) return '';\n let fallbackLocale = plugin.locale || acc.locale || 'vi-VN';\n fallbackLocale = fallbackLocale.replace('-', '_');\n let locale = _locale.replace('-', '_');\n return i18nText[locale] || i18nText[fallbackLocale];\n };\n t.locale = () => _locale;\n _common_js__WEBPACK_IMPORTED_MODULE_1__.downloadLanguage(store, _locale).then(() => {\n (0,preact__WEBPACK_IMPORTED_MODULE_3__.render)((0,preact__WEBPACK_IMPORTED_MODULE_3__.h)(_order_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n store: store,\n t: t,\n order_id: order.id\n }), document.getElementById('order'));\n });\n}\nload();\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/order/index.js?\n}");
|
|
186
|
+
|
|
187
|
+
/***/ },
|
|
188
|
+
|
|
189
|
+
/***/ "./src/order/order.js"
|
|
190
|
+
/*!****************************!*\
|
|
191
|
+
!*** ./src/order/order.js ***!
|
|
192
|
+
\****************************/
|
|
193
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
194
|
+
|
|
195
|
+
"use strict";
|
|
196
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Order)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\n/* harmony import */ var _chatbox_time_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../chatbox/time.js */ \"./src/chatbox/time.js\");\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common.js */ \"./src/common.js\");\n/* harmony import */ var _chatbox_DropdownSelect_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../chatbox/DropdownSelect.js */ \"./src/chatbox/DropdownSelect.js\");\n/* harmony import */ var _address_picker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./address_picker.js */ \"./src/order/address_picker.js\");\n/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! preact */ \"./node_modules/preact/dist/preact.module.js\");\n/* harmony import */ var _icon_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./icon.js */ \"./src/order/icon.js\");\n/* harmony import */ var _chatbox_spinner_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../chatbox/spinner.js */ \"./src/chatbox/spinner.js\");\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n;\n\n\n\n\n\n\n\nvar checkedimg = __webpack_require__(/*! ../../assets/img/done_green.svg */ \"./assets/img/done_green.svg\");\nvar ximg = __webpack_require__(/*! ../../assets/img/x.svg */ \"./assets/img/x.svg\");\nclass Order extends _common_js__WEBPACK_IMPORTED_MODULE_2__.Com {\n constructor(props) {\n super(props);\n _defineProperty(this, \"state\", {\n loadProvince: true,\n g_err: '',\n fullname: '',\n email: '',\n phone: '',\n loading: true,\n order: {},\n err: {},\n shipping_address: 'new',\n selectedProvince: null,\n selectedDistrict: null,\n selectedWard: null,\n street: '',\n address: '',\n sending: false,\n step: ''\n });\n _defineProperty(this, \"renderMobileSuccess\", order => {\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order\",\n style: \"height: 100% !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n style: \"width: 60px !important; height: 60px !important;\",\n width: \"60\",\n height: \"60\",\n src: checkedimg\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"margin-top: 20px !important; margin-bottom: 10px !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", {\n style: \"font-size: 18px !important;\"\n }, \"\\u0110\\u01A1n h\\xE0ng c\\u1EE7a b\\u1EA1n \\u0111\\xE3 \\u0111\\u01B0\\u1EE3c ghi nh\\u1EADn\")), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"muted\"\n }, \"T\\xF4i s\\u1EBD li\\xEAn h\\u1EC7 l\\u1EA1i v\\u1EDBi b\\u1EA1n khi \\u0111\\u01A1n h\\xE0ng \\u0111\\u01B0\\u1EE3c x\\u1EED l\\xFD\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"flex:1 !important\"\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_btn order__btn__light\",\n onClick: this.close\n }, this.props.t('close')))));\n });\n _defineProperty(this, \"onSelectProvince\", async item => {\n this.setState({\n selectedProvince: item,\n err: {},\n g_err: ''\n });\n this.setState({\n loadDistrict: true\n });\n let out = await this.props.store.list_districts({\n id: item.id\n });\n this.setState({\n loadDistrict: false\n });\n if (!out.error) this.setState({\n districts: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(out, 'body.addresses')\n });\n });\n _defineProperty(this, \"onSelectDistrict\", async item => {\n this.setState({\n selectedDistrict: item,\n err: {},\n g_err: ''\n });\n this.setState({\n loadWard: true\n });\n let out = await this.props.store.list_wards({\n id: item.id\n });\n this.setState({\n loadWard: false\n });\n if (!out.error) this.setState({\n wards: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(out, 'body.addresses')\n });\n });\n _defineProperty(this, \"onSelectWard\", item => this.setState({\n selectedWard: item,\n err: {},\n g_err: ''\n }));\n _defineProperty(this, \"onChangeFullname\", e => this.setState({\n fullname: e.target.value,\n err: {},\n g_err: ''\n }));\n _defineProperty(this, \"onChangeAddress\", e => this.setState({\n address: e,\n err: {},\n g_err: ''\n }));\n _defineProperty(this, \"onSelectAddress\", addr => {\n if (!addr) return;\n this.setState({\n address: [_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trim(addr.address), _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trim(addr.street)].join(' ').trim(),\n street: addr.street,\n err: {},\n g_err: ''\n });\n this.onSelectWard({\n id: addr.ward_id,\n name: addr.ward\n });\n this.onSelectDistrict({\n id: addr.district_id,\n name: addr.district\n });\n this.onSelectProvince({\n id: addr.province_id,\n name: addr.province\n });\n });\n _defineProperty(this, \"onChangeEmail\", e => this.setState({\n email: e.target.value,\n err: {},\n g_err: ''\n }));\n _defineProperty(this, \"onChangePhone\", e => this.setState({\n phone: e.target.value,\n err: {},\n g_err: ''\n }));\n _defineProperty(this, \"onChangePaymentMethod\", id => this.setState({\n pm: id\n }));\n _defineProperty(this, \"onChangeQuantity\", (item, text) => {\n let qty = parseInt(text) || 1;\n item.quantity = qty;\n this.forceUpdate();\n });\n _defineProperty(this, \"confirm\", async () => {\n this.setState({\n g_err: ''\n });\n let err = {};\n if (!this.state.shipping) {\n this.setState({\n g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'\n });\n }\n if (this.state.shipping === 'shop') {\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isPhone(this.state.phone)) {\n err.phone = true;\n }\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trim(this.state.fullname)) {\n err.name = true;\n }\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trim(this.state.email)) {\n err.email = true;\n }\n } else if (this.state.shipping_address == 'new') {\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isPhone(this.state.phone)) {\n err.phone = true;\n }\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trim(this.state.fullname)) {\n err.name = true;\n }\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trim(this.state.address)) {\n err.address = true;\n }\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(this.state.selectedWard) == 0) {\n err.ward = true;\n }\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(this.state.selectedDistrict) == 0) {\n err.district = true;\n }\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(this.state.selectedProvince) == 0) {\n err.province = true;\n }\n }\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(err) > 0) {\n this.setState({\n err,\n g_err: this.props.t('input_shipping_info_err')\n });\n return;\n }\n let user = this.props.store.matchUser();\n let ufullname = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getUserAttr(user, 'fullname', 'text');\n let uemail = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getUserAttr(user, 'emails', 'text');\n let uphone = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getUserAttr(user, 'phones', 'text');\n let order = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(this.state.order);\n if (this.state.shipping === 'shop') {\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(order, 'shipping.pickup_at_shop', true);\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(order, 'shipping.address.phone', this.state.phone);\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(order, 'shipping.address.fullname', this.state.fullname);\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(order, 'shipping.address.email', this.state.email);\n } else {\n if (this.state.shipping_address == 'new') {\n let out = await this.props.store.createShippingAddress({\n address: this.state.address,\n country: 'Việt Nam',\n fullname: this.state.fullname,\n email: this.state.email,\n phone: this.state.phone,\n district: this.state.selectedDistrict.name,\n district_id: this.state.selectedDistrict.id,\n province: this.state.selectedProvince.name,\n province_id: this.state.selectedProvince.id,\n ward: this.state.selectedWard.name,\n street: this.state.street,\n ward_id: this.state.selectedWard.id\n });\n if (out.error) return this.setState({\n g_err: this.props.t('update_failed')\n });\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(order, 'shipping.address', out.body);\n } else {\n let addresses = this.props.store.matchShippingAddresses();\n let sa = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(addresses, addr => addr.id === this.state.shipping_address);\n if (!sa) {\n return this.setState({\n err,\n g_err: this.props.t('input_shipping_info_err')\n });\n }\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(order, 'shipping.address', sa);\n }\n }\n let changeduser = false;\n if (!ufullname && this.state.fullname) {\n changeduser = true;\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setUserAttr(user, {\n key: 'fullname',\n text: this.state.fullname\n });\n }\n if (!uemail && this.state.email) {\n changeduser = true;\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setUserAttr(user, {\n key: 'emails',\n text: this.state.email\n });\n }\n if (!uphone && this.state.phone) {\n changeduser = true;\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setUserAttr(user, {\n key: 'phones',\n text: this.state.phone\n });\n }\n if (changeduser) this.props.store.setUser(user);\n this.setState({\n sending: true\n });\n order.user_confirmation = 'confirmed';\n let out = await this.props.store.updateOrder(order);\n this.setState({\n sending: false\n });\n if (out.error) {\n return this.setState({\n g_err: this.props.t('update_failed')\n });\n }\n this.setState({\n step: 'success'\n });\n if (this.props.onResponse) this.props.onResponse('confirmed');\n });\n _defineProperty(this, \"onCancel\", () => {\n if (this.props.onResponse) this.props.onResponse('rejected');\n if (this.props.cid && !this.state.order.user_confirmation) {\n let order = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(this.state.order);\n order.user_confirmation = 'rejected';\n this.props.store.updateOrder(order);\n }\n this.close();\n });\n _defineProperty(this, \"close\", () => {\n if (this.props.onClose) this.props.onClose();\n });\n this.load();\n }\n async load() {\n if (!this.props.order_id) return;\n let orderout = await this.props.store.fetchOrder(this.props.order_id);\n this.setState({\n loading: false\n });\n if (!orderout.error) {\n this.setState({\n order: orderout.body\n });\n } else {\n this.setState({\n error: orderout.error\n });\n }\n let user = this.props.store.matchUser();\n let attributes = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.props.store.matchUser(), 'attributes', []);\n let fullname = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(attributes, att => att.key === 'fullname'), 'text');\n let email = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(attributes, att => att.key === 'emails'), 'text');\n let phone = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(attributes, att => att.key === 'phones'), 'text');\n this.setState({\n fullname,\n email,\n phone\n });\n await this.props.store.fetchShippingAddresses();\n let out = await this.props.store.list_provinces();\n this.setState({\n loadProvince: false\n });\n if (!out.error) this.setState({\n provinces: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(out, 'body.addresses')\n });\n }\n isMobile() {\n if (this.props.cid) return true;\n if (this.props.isMobile) return true;\n return this.props.store.isMobile();\n }\n onChangeShippingAddress(id) {\n this.setState({\n shipping_address: id,\n err: {},\n g_err: ''\n });\n }\n onChangeShipping(id) {\n this.setState({\n shipping: id,\n err: {},\n g_err: ''\n });\n }\n renderDesktopPaymentMethod(order) {\n return null;\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n }\n renderDesktopShipping(order) {\n let editmode = false;\n if (!order.status || order.status == 'open') {\n editmode = !order.user_confirmation;\n }\n let user = this.props.store.matchUser();\n if (editmode) {\n let addresses = this.props.store.matchShippingAddresses();\n let provinces = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.state.provinces, province => ({\n id: province.id,\n name: province.province\n }));\n let districts = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.state.districts, district => ({\n id: district.id,\n name: district.district\n }));\n let wards = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.state.wards, ward => ({\n id: ward.id,\n name: ward.ward\n }));\n let cls = 'ship_card';\n let $body = null;\n let ship_icon_active = false;\n if (this.state.shipping === 'ship') {\n ship_icon_active = true;\n let $preaddrs = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(addresses, addr => {\n let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');\n let $phone = null;\n if (addr.phone) {\n $phone = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(preact__WEBPACK_IMPORTED_MODULE_5__.Fragment, null, \"\\xA0\\xB7\\xA0\", this.props.t('phn'), \" \", addr.phone);\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"margin-bottom: 15px !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"radio d-flex \"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n type: \"radio\",\n id: 'shipping_addr.' + addr.id,\n onInput: e => this.onChangeShippingAddress(addr.id),\n name: \"shipping_address\",\n checked: this.state.shipping_address === addr.id\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"label\", {\n class: \"radio--label\",\n for: 'shipping_addr.' + addr.id,\n style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`\n }, addr.fullname, $phone, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mt-1 muted\"\n }, \"DC \", fulladdr)), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"radio--check\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"inside\"\n }))));\n });\n $preaddrs.push((0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"radio d-flex \"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n type: \"radio\",\n id: 'shipping_addr.new',\n onInput: e => this.onChangeShippingAddress('new'),\n name: \"shipping_address\",\n checked: this.state.shipping_address === 'new'\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"label\", {\n class: \"radio--label\",\n for: 'shipping_addr.new'\n }, this.state.shipping_address === 'new' ? (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", null, \"T\\u1EDBi \\u0111\\u1ECBa ch\\u1EC9 kh\\xE1c\") : 'Tới địa chỉ khác'), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"radio--check\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"inside\"\n })))));\n let $new = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"padding-left: 22px !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mr-2\",\n style: \"flex: 1 !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('fullname')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n type: \"text\",\n class: 'form-control ' + (this.state.err.name && 'err'),\n onInput: this.onChangeFullname,\n value: this.state.fullname\n })), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"ml-2\",\n style: \"flex: 1 !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('phones')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n type: \"text\",\n class: 'form-control ' + (this.state.err.phone && 'err'),\n onInput: this.onChangePhone,\n value: this.state.phone\n }))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"\",\n style: \"width: 100% !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('address')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_address_picker_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n initAddress: this.state.address,\n store: this.props.store,\n width: \"100%\",\n onChangeAddress: this.onChangeAddress,\n full: this.isMobile(),\n onSelect: this.onSelectAddress,\n extra_cls: this.state.err.address && 'err'\n })), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex\",\n style: \"justify-content: space-between !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('province')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_chatbox_DropdownSelect_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n width: \"194\",\n full: this.isMobile(),\n has_search: true,\n loading: this.state.loadProvince,\n items: provinces,\n selected: this.state.selectedProvince,\n onSelect: this.onSelectProvince,\n extra_cls: this.state.err.province && 'err'\n })), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('district')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_chatbox_DropdownSelect_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n width: \"194\",\n full: this.isMobile(),\n selected: this.state.selectedDistrict,\n has_search: true,\n onSelect: this.onSelectDistrict,\n loading: this.state.loadDistrict,\n extra_cls: this.state.err.district && 'err',\n items: districts\n }))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex\",\n style: \"justify-content: space-between !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('ward')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_chatbox_DropdownSelect_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n width: \"194\",\n selected: this.state.selectedWard,\n full: this.isMobile(),\n has_search: true,\n onSelect: this.onSelectWard,\n extra_cls: this.state.err.ward && 'err',\n loading: this.state.loadWard,\n items: wards\n })), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"flex: 1 !important; margin-left: 7px !important;\"\n })));\n cls += ' ship_card__active';\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(addresses) == 0) {\n $body = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: 'mt-3 mb-2 '\n }, this.props.t('input_shipping_info')), $new);\n } else {\n if (this.state.shipping_address !== 'new') $new = null;\n $body = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mt-3 mb-2\",\n style: \"margin-bottom: 10px !important;\"\n }, \"Vui l\\xF2ng ch\\u1ECDn \\u0111\\u1ECBa ch\\u1EC9 giao h\\xE0ng\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"form\"\n }, $preaddrs), $new);\n }\n }\n let shopcls = 'ship_card';\n let shop_icon_active = false;\n if (this.state.shipping === 'shop') {\n shop_icon_active = true;\n shopcls += ' ship_card__active';\n $body = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mr-2\",\n style: \"flex: 3 !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('fullname')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n type: \"text\",\n class: 'form-control ' + (this.state.err.name && 'err'),\n onInput: this.onChangeFullname,\n value: this.state.fullname\n })), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"ml-2\",\n style: \"flex: 2 !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('phones')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n type: \"text\",\n class: 'form-control ' + (this.state.err.phone && 'err'),\n onInput: this.onChangePhone,\n value: this.state.phone\n }))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_form_label\"\n }, this.props.t('email')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n type: \"text\",\n class: 'form-control ' + (this.state.err.email && 'err'),\n onInput: this.onChangeEmail,\n value: this.state.email\n })));\n }\n let seccls = 'card_section';\n if (this.isMobile()) seccls = 'order_section';\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(preact__WEBPACK_IMPORTED_MODULE_5__.Fragment, null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_section__line\"\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: seccls\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_label\"\n }, this.props.t('ship_to')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: shopcls + ' mr-3',\n onClick: e => this.onChangeShipping('shop')\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_icon_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n name: \"shop\",\n active: shop_icon_active\n }), \" \", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", {\n class: \"ml-2\"\n }, \"Nh\\u1EADn h\\xE0ng t\\u1EA1i shop\")), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: cls,\n onClick: e => this.onChangeShipping('ship')\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_icon_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n name: \"package\",\n active: ship_icon_active\n }), \" \", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", {\n class: \"ml-2\"\n }, \"Giao h\\xE0ng cho t\\xF4i\"))), $body));\n }\n let addr = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(order, 'shipping.address') || {};\n let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');\n let $phone = null;\n if (addr.phone) $phone = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mt-1 muted\"\n }, this.props.t('phn'), \":\\xA0\", addr.phone);\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(order, 'shipping.pickup_at_shop')) {\n fulladdr = 'Nhận hàng tại cửa hàng';\n }\n let $addr = fulladdr ? (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, fulladdr) : (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"i\", {\n class: \"i muted\"\n }, \"Ch\\u01B0a c\\xF3 \\u0111\\u1ECBa ch\\u1EC9 giao h\\xE0ng\");\n let seccls = 'card_section';\n if (this.isMobile()) seccls = 'order_section';\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: seccls\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_label \"\n }, this.props.t('ship_to')), $addr, $phone);\n }\n renderDesktopSummary(order) {\n let $deposit = null;\n if (order.deposit > 0) {\n $deposit = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"span\", {\n class: \"muted\"\n }, \"(c\\u1ECDc \", _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(order.deposit), \")\");\n }\n let $discount = null;\n if (order.total_discount > 0) {\n $discount = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_summary_line\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"Gi\\u1EA3m gi\\xE1\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(order.total_discount)));\n }\n let $pay = null;\n if ($deposit || order.payment_made) {\n $pay = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(preact__WEBPACK_IMPORTED_MODULE_5__.Fragment, null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_summary_line\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"B\\u1EA1n \\u0111\\xE3 tr\\u1EA3\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, $deposit, \" \", _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(order.payment_made))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_summary_line\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"B\\u1EA1n ch\\u01B0a tr\\u1EA3\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency((order.total || 0) - (order.payment_made || 0)))));\n }\n let $tax = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_summary_line\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"Ti\\u1EC1n thu\\u1EBF\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(order.total_tax)));\n let $ship = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_summary_line\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"Ph\\xED v\\u1EADn chuy\\u1EC3n\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(order, 'shipping.fee', 0), \" d\"));\n let editmode = false;\n if (!order.status || order.status == 'open') {\n editmode = !order.user_confirmation;\n }\n let $note = null;\n if (editmode) {\n $ship = null;\n $tax = null;\n $note = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"muted\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_ship_icon\",\n src: __webpack_require__(/*! ../../assets/img/info.svg */ \"./assets/img/info.svg\")\n }), \"\\xA0 Ch\\u01B0a bao g\\u1ED3m thu\\u1EBF v\\xE0 ph\\xED v\\u1EADn chuy\\u1EC3n\");\n }\n let seccls = '';\n if (this.isMobile()) seccls = 'order_section';\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(preact__WEBPACK_IMPORTED_MODULE_5__.Fragment, null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_section__line\"\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: seccls\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_label\"\n }, \"T\\xF3m t\\u1EAFt\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_summary_line\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"T\\u1ED5ng ti\\u1EC1n h\\xE0ng\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_summary_line\",\n style: \"margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"B\\u1EA1n ph\\u1EA3i tr\\u1EA3\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order__total\"\n }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(order.total))), $pay));\n }\n renderStatusBadge(order) {\n let status = order.status || 'open';\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"float: right !important;\",\n class: 'order_status order_status__' + status\n }, status);\n }\n renderShippingInfo(order) {\n if (order.status != 'open' || order.user_confirmation) {}\n let shipping_provider = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(order, 'shipping.shipping_provider');\n if (!shipping_provider) return null;\n let shipping_code = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(order, 'shipping.shipping_code');\n let $tracking_code = null;\n if (shipping_code) $tracking_code = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"muted\",\n style: \"margin-top: 3px !important\"\n }, \"V\\u1EADn \\u0111\\u01A1n\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"a\", {\n class: \"order_tracking_link\",\n target: \"_blank\",\n href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code\n }, shipping_code, \"\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_tracking_link_icon\",\n src: __webpack_require__(/*! ../../assets/img/external-link.svg */ \"./assets/img/external-link.svg\")\n })));\n if (shipping_provider == 'ghtk') {\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_section\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_section_label\"\n }, \"\\u0110\\u01A1n v\\u1ECB v\\u1EADn chuy\\u1EC3n\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex align-items-center\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_shipping_provider_logo\",\n src: ShippingProvider.ghtk.logo\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, ShippingProvider.ghtk.name, $tracking_code)));\n }\n return null;\n }\n renderDesktopShippingInfo(order) {\n let shipping_provider = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(order, 'shipping.shipping_provider');\n if (!shipping_provider) return null;\n let shipping_code = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(order, 'shipping.shipping_code');\n let $tracking_code = null;\n if (shipping_code) $tracking_code = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"muted\",\n style: \"margin-top: 3px !important\"\n }, \"V\\u1EADn \\u0111\\u01A1n\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"a\", {\n class: \"order_tracking_link\",\n target: \"_blank\",\n href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code\n }, shipping_code, \"\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_tracking_link_icon\",\n src: __webpack_require__(/*! ../../assets/img/external-link.svg */ \"./assets/img/external-link.svg\")\n })));\n if (shipping_provider == 'ghtk') {\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(preact__WEBPACK_IMPORTED_MODULE_5__.Fragment, null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_label\"\n }, \"\\u0110\\u01A1n v\\u1ECB v\\u1EADn chuy\\u1EC3n\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex align-items-center\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_shipping_provider_logo\",\n src: ShippingProvider.ghtk.logo\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, ShippingProvider.ghtk.name, $tracking_code)));\n }\n return null;\n }\n renderProducts(order) {\n let $products = null;\n $products = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(order.items, item => {\n if (!item || !item.product) return null;\n let product = item.product;\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_attachment__product_img\",\n alt: '' + product.id,\n src: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(product, 'images.0') || __webpack_require__(/*! ../../assets/img/default.jpg */ \"./assets/img/default.jpg\")\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"overflow: hidden !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_name\"\n }, product.name), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_desc\"\n }, product.description || product.long_description), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_desc\"\n }, this.props.t('qty'), \" \", item.quantity, \"\\xA0\\xB7\\xA0\", _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(product.price))));\n });\n if (!this.isMobile()) return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_label\"\n }, this.props.t('product')), $products);\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_section\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_section_label\"\n }, this.props.t('product')), $products);\n }\n renderDesktopProducts(order) {\n let $products = null;\n let editmode = false;\n if (!order.status || order.status == 'open') {\n editmode = !order.user_confirmation;\n }\n if (editmode) {\n $products = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(order.items, item => {\n if (!item || !item.product) return null;\n let product = item.product;\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_attachment__product_img\",\n alt: '' + product.id,\n src: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(product, 'images.0') || __webpack_require__(/*! ../../assets/img/default.jpg */ \"./assets/img/default.jpg\")\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"overflow: hidden !important; flex: 1 !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_name\"\n }, product.name), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_desc\"\n }, product.description || product.long_description), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_desc\"\n }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(product.price))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"input\", {\n class: \"form-control\",\n style: \"text-align: center !important; font-weight: 400 !important; width: 50px !important\",\n value: item.quantity,\n onInput: e => this.onChangeQuantity(item, e.target.value),\n type: \"text\"\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"width: 80px !important; text-align: right !important; \"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(item.quantity * product.price))));\n });\n } else {\n $products = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(order.items, item => {\n if (!item || !item.product) return null;\n let product = item.product;\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_attachment__product_img\",\n alt: '' + product.id,\n src: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(product, 'images.0') || __webpack_require__(/*! ../../assets/img/default.jpg */ \"./assets/img/default.jpg\")\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"overflow: hidden !important; flex: 1 !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_name\"\n }, product.name), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_desc\"\n }, product.description || product.long_description), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_attachment__product_desc\"\n }, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(product.price))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"text-align: center !important; font-weight: 400 !important; width: 50px !important\"\n }, item.quantity), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"width: 80px !important; text-align: right !important; \"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", null, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].formatCurrency(item.total))));\n });\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"card_section\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"desktop_order__heading\"\n }, this.renderStatusBadge(order), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", {\n style: \"font-size: 18px !important;\"\n }, this.props.t('order'), \" #\", order.order_number || order.id), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"muted\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_chatbox_time_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n style: \"font-size: 13px !important;\",\n time: order.issue_date || order.created\n }))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_label d-flex\",\n style: \"margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"flex: 1 !important;\"\n }, this.props.t('product')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"font-weight: 400 !important; text-align:center !important; width: 50px !important\"\n }, this.props.t('qty')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"font-weight: 400 !important; text-align: right !important; width: 80px !important;\"\n }, this.props.t('total'))), $products);\n }\n renderMobile(order) {\n if (this.state.step === 'success') return this.renderMobileSuccess(order);\n let $error = null;\n if (this.state.g_err) {\n $error = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mb-2 text__danger\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n style: \"margin-top: -4px !important; height: 15px !important;\",\n src: ximg\n }), \"\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", null, this.state.g_err));\n }\n let $status = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, $error, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"btn-confirm-order\",\n style: \"margin-top: 0 !important;\",\n onClick: this.confirm\n }, this.props.t('confirm_order')));\n let $close = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_btn order__btn__light mt-3\",\n onClick: this.onCancel\n }, this.props.t('cancel_order'));\n if (order.user_confirmation || order.status != 'open') {\n $status = null;\n if (this.props.cid) $close = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_btn order__btn__light mt-3\",\n onClick: this.close\n }, this.props.t('close'));\n }\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order\",\n style: \"height: 100% !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order--content\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order--heading\"\n }, this.renderStatusBadge(order), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", {\n style: \"font-size: 16px !important;\"\n }, this.props.t('order'), \" #\", order.order_number || order.id), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"muted\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_chatbox_time_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n style: \"font-size: 13px !important;\",\n time: order.issue_date || order.created\n }))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_section pb-3\",\n style: \"padding-top: 0 !important;\"\n }, $status, $close)));\n }\n renderActions(order) {\n let $actions = null;\n let editmode = false;\n if (!order.status || order.status == 'open') {\n editmode = !order.user_confirmation;\n }\n if (this.state.step === 'success') return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"d-flex\",\n style: \"align-items: center !important; justify-content: flex-end !important\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, \"Ghi nh\\u1EADn th\\xE0nh c\\xF4ng\"), \"\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n style: \"width: 16px !important; height: 16px !important;\",\n width: \"16\",\n height: \"16\",\n src: checkedimg\n }));\n if (editmode) {\n let $error = null;\n if (this.state.g_err) {\n $error = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mb-2 text__danger\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n style: \"margin-top: -4px !important; height: 15px !important;\",\n src: ximg\n }), \"\\xA0\", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", null, this.state.g_err));\n }\n $actions = (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, $error, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"btn-confirm-order\",\n onClick: this.confirm\n }, this.props.t('confirm_order')), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"btn-cancel-order\",\n onClick: this.onCancel\n }, this.props.t('cancel_order')));\n }\n return $actions;\n }\n renderDesktop(order) {\n let acc = this.props.store.matchAccount();\n var uri = acc.logo_url || __webpack_require__(/*! ../../assets/img/image_default.png */ \"./assets/img/image_default.png\");\n return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"desktop order\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_acc_header\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"order_acc_logo\",\n src: uri\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_acc_name\"\n }, acc.name)), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"desktop_order__content\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n style: \"flex: 1 !important; padding-right: 20px !important;\"\n }, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order__footer\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"a\", {\n target: \"_blank\",\n href: \"https://subiz.com.vn\",\n class: \"order__footer_link\"\n }, \"Cung c\\u1EA5p b\\u1EDFi \", (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"b\", null, \"Subiz\")), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order__footer_delimiter\"\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"a\", {\n target: \"_blank\",\n href: \"https://subiz.com.vn/vi/terms-of-service.html\",\n class: \"order__footer_link\"\n }, \"\\u0110i\\u1EC1u kho\\u1EA3n\"), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"a\", {\n target: \"_blank\",\n href: \"https://subiz.com.vn/vi/privacy-policy.html\",\n class: \"order__footer_link\"\n }, \"Quy\\u1EC1n ri\\xEAng t\\u01B0\"))), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", null, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_recap\"\n }, this.renderDesktopSummary(order), this.renderActions(order)))));\n }\n render() {\n if (this.state.loading) return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_error\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(_chatbox_spinner_js__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n class: \"mt-4\",\n size: \"60\",\n static: true\n }));\n if (this.state.error) return (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"order_error\"\n }, (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"img\", {\n class: \"mt-3\",\n src: __webpack_require__(/*! ../../assets/img/empty_1.svg */ \"./assets/img/empty_1.svg\")\n }), (0,preact__WEBPACK_IMPORTED_MODULE_5__.h)(\"div\", {\n class: \"mt-3\"\n }, this.props.t('order_load_error')));\n let order = this.state.order;\n if (this.isMobile()) return this.renderMobile(order);\n return this.renderDesktop(order);\n }\n}\nlet ShippingProvider = {\n ghtk: {\n name: 'Giao hàng tiết kiệm',\n logo: __webpack_require__(/*! ../../assets/img/ghtk.svg */ \"./assets/img/ghtk.svg\")\n },\n ghn: {\n name: 'Giao hàng nhanh',\n logo: __webpack_require__(/*! ../../assets/img/ghn.svg */ \"./assets/img/ghn.svg\")\n }\n};\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/order/order.js?\n}");
|
|
197
|
+
|
|
198
|
+
/***/ },
|
|
199
|
+
|
|
200
|
+
/***/ "./src/store/api.js"
|
|
201
|
+
/*!**************************!*\
|
|
202
|
+
!*** ./src/store/api.js ***!
|
|
203
|
+
\**************************/
|
|
204
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
205
|
+
|
|
206
|
+
"use strict";
|
|
207
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n;\nconst ajax = __webpack_require__(/*! @subiz/ajax/src/ajax.js */ \"./node_modules/@subiz/ajax/src/ajax.js\");\nfunction jsonifyTextPlain(param, done) {\n let req = param.request;\n if (req.content_type === 'text/plain' && req.body !== undefined) req.body = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].stringify(req.body);\n done(true);\n}\nlet reqi = 0;\nlet trackRequestFn = (param, done) => {\n if (typeof sbz_info == 'undefined') return done(true);\n let req = param.request;\n reqi++;\n req._id = reqi;\n sbz_info['ajax.' + reqi] = {\n created: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now(),\n method: req.method,\n baseurl: req.baseurl,\n query: req.query\n };\n done(true);\n};\nlet trackResponseFn = (param, done) => {\n if (typeof sbz_info == 'undefined') return done(true);\n let req = param.request;\n let reqi = req._id;\n if (!sbz_info['ajax.' + reqi]) sbz_info['ajax.' + reqi] = {\n created: 0\n };\n sbz_info['ajax.' + reqi].out = {\n duration: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now() - sbz_info['ajax.' + reqi].created,\n code: param.code,\n err: param.err\n };\n done(true);\n};\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (class {\n constructor(ApiURL, FileURL) {\n _defineProperty(this, \"sendBugReport\", str => this.bugReq.post('/bugs', str));\n _defineProperty(this, \"listConversations\", _ => this.apireq.addQuery('user_id', this.uid).addQuery('integration_id', `${this.accid}.subizv4.subikon`).get(`/accounts/${this.accid}/conversations`));\n _defineProperty(this, \"listMessages\", (cid, limit, start_id) => this.apireq.addQuery('limit', limit).addQuery('start_id', start_id).get(`/accounts/${this.accid}/conversations/${cid}/messages`));\n _defineProperty(this, \"ajax\", ajax);\n _defineProperty(this, \"start\", (extraData, tpchannel, tpsource, tpid) => {\n let data = Object.assign({}, extraData);\n if (!data.touchpoint) data.touchpoint = {};\n if (!data.touchpoint.channel) data.touchpoint.channel = 'subiz';\n if (!data.touchpoint.source) data.touchpoint.source = 'web';\n data.source = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(document, 'location.href');\n return this.apireq.post(`/accounts/${this.accid}/conversations`, data);\n });\n _defineProperty(this, \"sendConvoEvent\", (cid, ev) => this.apireq.addQuery('x-referer', _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(location, 'origin', '')).post(`/accounts/${this.accid}/conversations/${cid}/events`, ev));\n _defineProperty(this, \"createPostback\", (cid, p) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/postbacks`, p));\n _defineProperty(this, \"markAsReceived\", (cid, messageId) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/messages/${messageId}/receive`));\n _defineProperty(this, \"markAsSeen\", (cid, messageId) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/messages/${messageId}/seen`));\n _defineProperty(this, \"getConversation\", cid => this.apireq.get(`/accounts/${this.accid}/conversations/${cid}`));\n _defineProperty(this, \"getLocaleContent\", locale => this.apireq.get(`/accounts/${this.accid}/languages/${locale}`));\n _defineProperty(this, \"sendEvent\", data => this.apireq.addQuery('shorten', true).addQuery('x-referer', _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(location, 'origin', '')).post(`/accounts/${this.accid}/users/${this.uid}/events`, data));\n _defineProperty(this, \"submitForm\", (form_id, page_url, device, data, user) => this.apireq.addQuery('x-referer', _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(location, 'origin', '')).post(`/accounts/${this.accid}/users/${this.uid}/events`, {\n by: {\n id: this.uid,\n device: device\n },\n type: 'form_submitted',\n data: {\n user: user,\n form_submission: {\n user_id: this.uid,\n form_id: form_id,\n page_url: page_url,\n submitted_at: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now(),\n values: data\n }\n }\n }));\n _defineProperty(this, \"sendTyping\", cid => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`));\n _defineProperty(this, \"sendLostFocus\", () => this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`));\n _defineProperty(this, \"uploadToS3\", async file => {\n let name = file.name.replace(/\\s+/g, '_');\n var {\n body,\n error\n } = await this.apireq.setBaseUrl('https://api5.subiz.com.vn/4.1').setQuery({\n 'account-id': this.accid,\n description: 'upload\\n user-client: web-widget',\n name: name,\n presign: true,\n size: file.size,\n 'content-type': file.type\n }).post('/files');\n if (error) return {\n body,\n error\n };\n let signedurl = body.signed_url;\n let fileid = body.id;\n let err = await new Promise(resolve => {\n const xhr = new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].XMLHttpRequest();\n xhr.open('PUT', signedurl, true);\n xhr.setRequestHeader('Content-Type', file.type || '');\n xhr.onload = function () {\n if (xhr.status === 200) {\n resolve();\n } else {\n resolve(new Error(`Upload failed: ${xhr.statusText}`));\n }\n };\n xhr.onerror = function () {\n resolve(new Error('Network error during upload.'));\n };\n xhr.send(file);\n });\n if (err) return {\n error: err\n };\n var {\n body,\n error\n } = await this.apireq.setBaseUrl('https://api5.subiz.com.vn/4.1').setQuery({\n 'account-id': this.accid\n }).post(`/files/${fileid}/uploaded`);\n if (error) return {\n error\n };\n return {\n url: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(body, 'file.url', '')\n };\n });\n _defineProperty(this, \"uploadToS32\", async file => {\n var {\n body,\n error\n } = await ajax.setBaseUrl('https://api5.subiz.com.vn/4.1').withCredentials(true).setQuery({\n 'account-id': this.accid,\n description: 'upload\\n user-client: web-widget',\n name: file.name.replace(/\\s+/g, '_'),\n size: file.size,\n type: file.type\n }).setParser('json').beforeHook((param, done) => {\n if (this.token_generator) {\n let user_id = this.profile_id;\n this.token_generator().then(token => {\n if (user_id != this.profile_id) return done(true);\n if (!token) return done(false);\n if (token == 'error') return done(false);\n param.request = param.request.addQuery('x-access-token', token);\n return done(true);\n });\n return;\n }\n if (this.ref) param.request = param.request.addQuery('x-user-ref', this.ref);else if (this.mask) param.request = param.request.addQuery('x-user-mask', this.mask);\n return done(true);\n }).post('/files', file);\n if (error) return {\n body,\n error\n };\n return {\n url: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(body, 'file.url')\n };\n });\n _defineProperty(this, \"time\", _ => ajax.setBaseUrl(this.ApiURL).withCredentials(true).setParser('json').get('/time'));\n _defineProperty(this, \"updateUser\", data => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}`, data));\n _defineProperty(this, \"getUser\", _ => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}`));\n _defineProperty(this, \"getAccountSetting\", async p => {\n let href = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(document, 'location.href');\n let res = {};\n if (p && p.bot_id) {\n res = await this.apireq.addQuery('url', href).addQuery('bot_id', p.bot_id).get(`/accounts/${this.accid}/settings`);\n } else {\n res = await this.apireq.addQuery('url', href).get(`/accounts/${this.accid}/settings`);\n }\n if (res.error) return res;\n let plugins = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(res, 'body.plugins') || [];\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(plugins, plugin => {\n if (plugin.type === 'popup') {\n let pages = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(plugin, 'popup.pages') || [];\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(pages, page => {\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(page.components, com => {\n if (com.type === 'image') {\n let url = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(com, 'image.url');\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(com, 'image.url', fallbackGCSUrl(url));\n }\n });\n });\n }\n });\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].set(res, 'body.plugins', plugins);\n return res;\n });\n _defineProperty(this, \"sendImpression\", impression => this.apireq.post(`/accounts/${this.accid}/campaigns/${impression.campaign_id}/impressions`, impression));\n _defineProperty(this, \"sendConversion\", conversion => this.apireq.post(`/accounts/${this.accid}/campaigns/${conversion.campaign_id}/conversions`, conversion));\n _defineProperty(this, \"lookupOrder\", key => ajax.setBaseUrl(this.ApiURL).setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json').addQuery('x-signed-key', key).get(`/orders/123`));\n _defineProperty(this, \"getOrder\", id => this.apireq.get(`/accounts/${this.accid}/orders/` + id));\n _defineProperty(this, \"updateOrder\", order => this.apireq.post(`/accounts/${this.accid}/orders/` + order.id, order));\n _defineProperty(this, \"fetchShippingAddresses\", () => this.apireq.get(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`));\n _defineProperty(this, \"createShippingAddress\", addr => this.apireq.post(`/accounts/${this.accid}/users/${this.uid}/shipping-addresses`, addr));\n _defineProperty(this, \"list_provinces\", () => this.apireq.get(`/accounts/${this.accid}/provinces`));\n _defineProperty(this, \"list_districts\", p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/districts`));\n _defineProperty(this, \"list_wards\", p => this.apireq.setQuery(p).get(`/accounts/${this.accid}/wards`));\n _defineProperty(this, \"checkFormToken\", (accid, token) => this.api41.addQuery('account-id', accid).get(`/submissions/${token}`));\n _defineProperty(this, \"submitForm2\", (accid, token, data) => this.api41.addQuery('account-id', accid).post(`/submissions/${token}`, data));\n _defineProperty(this, \"suggest_address\", keyword => this.apireq.setQuery({\n keyword: keyword\n }).get(`/accounts/${this.accid}/addresses`));\n _defineProperty(this, \"create_ticket\", ticket => this.apireq.post(`/accounts/${this.accid}/tickets`, ticket));\n this.refreshLock = new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Mutex();\n this.FileURL = FileURL;\n this.ApiURL = ApiURL;\n this.bugReq = ajax.setBaseUrl('https://api5.subiz.com.vn/4.1').setContentType('text/plain');\n this.api41 = ajax.setBaseUrl('https://api.sbz.vn/4.1').withCredentials(true).setContentType('text/plain').beforeHook(jsonifyTextPlain).afterHook(trackResponseFn).beforeHook(trackRequestFn).setParser('json');\n this.apireq = ajax.setBaseUrl(ApiURL).withCredentials(true).addQuery('v', '6').setContentType('text/plain').beforeHook(jsonifyTextPlain).afterHook(trackResponseFn).setParser('json').beforeHook(trackRequestFn).beforeHook((param, done) => {\n if (this.token_generator) {\n let user_id = this.profile_id;\n this.token_generator().then(token => {\n if (user_id != this.profile_id) return done(true);\n if (!token) return done(false);\n if (token == 'error') return done(false);\n param.request = param.request.addQuery('x-access-token', token);\n return done(true);\n });\n return;\n }\n if (this.ref) param.request = param.request.addQuery('x-user-ref', this.ref);else if (this.mask) param.request = param.request.addQuery('x-user-mask', this.mask);\n return done(true);\n });\n }\n setAgentId(agid) {\n this.agentid = agid;\n }\n async setAuth(obj) {\n if (obj.accid) this.accid = obj.accid;\n if (obj.ref) this.ref = obj.ref;\n this.mask = obj.mask;\n this.profile_id = obj.profile_id;\n if (obj.ref) {\n let outuser;\n for (let i = 0; true; i++) {\n outuser = await ajax.setBaseUrl(this.ApiURL).withCredentials(true).afterHook(trackResponseFn).beforeHook(trackRequestFn).addQuery('v', '6').addQuery('x-user-ref', this.ref).setParser('json').get(`/accounts/${this.accid}/users/${this.ref}`);\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(outuser, 'body.error.code', '').indexOf('locked_account') != -1) break;\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(outuser, 'body.error.code', '').indexOf('user_is_banned') != -1) {\n await _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].sleep(120000);\n continue;\n }\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(outuser, 'body.id')) {\n let sleeptime = Math.min(2000 + i * 400, 60000);\n await _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].sleep(sleeptime);\n continue;\n }\n break;\n }\n if (outuser.error) {\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(outuser.body.code)) return {\n error: outuser.body.code\n };\n return outuser;\n }\n this.uid = outuser.body.id;\n return outuser.body;\n }\n if (obj.tokenGenerator) {\n let tokenGenerator = obj.tokenGenerator;\n this.tokensession = this.tokensession || 0;\n this.tokensession++;\n let tokensession = this.tokensession;\n if (!this.accid || !_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(this.accid, 'ac')) return {\n error: 'invalid_account_id'\n };\n if (!this.profile_id) return {\n error: 'invalid_profile_id'\n };\n if (typeof tokenGenerator !== 'function') return {\n error: 'invalid_token_generator'\n };\n let profile_id = this.profile_id;\n this.token_generator = async force => {\n await this.refreshLock.lock();\n if (tokensession != this.tokensession) {\n this.refreshLock.unlock();\n return;\n }\n let age = (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now() - (this.last_token_at || 0)) / 1000;\n if (!force && this.last_token && age < 1800) {\n this.refreshLock.unlock();\n return this.last_token;\n }\n if (!force && this.last_token && age < 3000) {\n if (this.token_generator) _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(async () => {\n let token, err;\n try {\n token = await tokenGenerator(profile_id);\n } catch (e) {\n err = e;\n }\n if (tokensession != this.tokensession) {\n this.refreshLock.unlock();\n return;\n }\n if (err) this.last_token = 'error';else this.last_token = token;\n this.last_token_at = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now();\n this.refreshLock.unlock();\n });\n return this.last_token;\n }\n let token;\n let err;\n try {\n token = await tokenGenerator(profile_id);\n } catch (e) {\n err = e;\n }\n if (tokensession != this.tokensession) {\n this.refreshLock.unlock();\n return;\n }\n if (err) this.last_token = 'error';else this.last_token = token;\n this.last_token_at = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now();\n this.refreshLock.unlock();\n return this.last_token;\n };\n let outuser;\n for (let i = 0; true; i++) {\n await this.token_generator(true);\n if (tokensession != this.tokensession) break;\n outuser = await ajax.setBaseUrl(this.ApiURL).withCredentials(true).addQuery('v', '6').afterHook(trackResponseFn).beforeHook(trackRequestFn).addQuery('x-access-token', this.last_token).setParser('json').get(`/accounts/${this.accid}/users/${profile_id}`);\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(outuser, 'body.id')) {\n let sleeptime = Math.min(2000 + i * 100, 120000);\n await _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].sleep(sleeptime);\n continue;\n }\n break;\n }\n if (outuser.error) {\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(outuser.body.code)) return {\n error: outuser.body.code\n };\n return outuser;\n }\n this.uid = outuser.body.id;\n return outuser.body;\n }\n if (this.mask) {\n let parts = this.mask.split('@');\n this.uid = parts[1];\n return {\n id: this.uid\n };\n }\n return {\n error: 'invalid_auth'\n };\n }\n sendContentView(device, pageUrl, pageTitle, id, source_id, sku) {\n if (!id) id = undefined;\n if (!source_id) source_id = undefined;\n return this.sendEvent({\n by: {\n id: this.uid,\n device: device\n },\n type: 'content_viewed',\n data: {\n product: {\n id: id,\n source_id: source_id,\n url: pageUrl,\n name: pageTitle,\n title: pageTitle,\n sku: sku\n }\n }\n });\n }\n});\n__webpack_require__.dn(__WEBPACK_DEFAULT_EXPORT__);\nfunction fallbackGCSUrl(url) {\n try {\n const u = new URL(url);\n const isGCS = u.hostname === 'storage.googleapis.com';\n const isSubizBucket = u.pathname.startsWith('/public-gcs.subiz-cdn.com/');\n if (isGCS && isSubizBucket) {\n return `https://${u.pathname.slice(1)}`;\n }\n return url;\n } catch (e) {\n return url;\n }\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/api.js?\n}");
|
|
208
|
+
|
|
209
|
+
/***/ },
|
|
210
|
+
|
|
211
|
+
/***/ "./src/store/api_fake.js"
|
|
212
|
+
/*!*******************************!*\
|
|
213
|
+
!*** ./src/store/api_fake.js ***!
|
|
214
|
+
\*******************************/
|
|
215
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
216
|
+
|
|
217
|
+
"use strict";
|
|
218
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n;\nconst ajax = __webpack_require__(/*! @subiz/ajax/src/ajax.js */ \"./node_modules/@subiz/ajax/src/ajax.js\");\nfunction jsonifyTextPlain(param, done) {\n let req = param.request;\n if (req.content_type === 'text/plain' && req.body !== undefined) req.body = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].stringify(req.body);\n done(true);\n}\nconst OK200 = Promise.resolve({\n code: 200\n});\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (class {\n constructor(ApiURL, FileURL) {\n _defineProperty(this, \"listConversations\", _ => {\n let convo = makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);\n return Promise.resolve({\n body: {\n anchor: '',\n conversations: [convo]\n },\n code: 200\n });\n });\n _defineProperty(this, \"listMessages\", (cid, limit, start_id) => {\n let messages = makeFakeMessages(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid);\n return Promise.resolve({\n body: messages,\n code: 200\n });\n });\n _defineProperty(this, \"ajax\", ajax);\n _defineProperty(this, \"start\", extraData => OK200);\n _defineProperty(this, \"sendConvoEvent\", (cid, ev) => OK200);\n _defineProperty(this, \"createPostback\", (cid, p) => OK200);\n _defineProperty(this, \"markAsReceived\", (cid, messageId) => OK200);\n _defineProperty(this, \"markAsSeen\", (cid, messageId) => OK200);\n _defineProperty(this, \"getConversation\", cid => Promise.resolve({\n body: makeFakeConvo(this.accid, 'csqwudlkftltnbebvq', this.uid, this.agentid),\n code: 200\n }));\n _defineProperty(this, \"getLocaleContent\", locale => this.apireq.get(`/accounts/${this.accid}/locales/${locale}`));\n _defineProperty(this, \"sendEvent\", data => OK200);\n _defineProperty(this, \"submitForm\", (form_id, page_url, device, data, user) => OK200);\n _defineProperty(this, \"sendTyping\", cid => OK200);\n _defineProperty(this, \"sendPresence\", data => OK200);\n _defineProperty(this, \"sendContent\", data => OK200);\n _defineProperty(this, \"sendLostFocus\", data => OK200);\n _defineProperty(this, \"sendContentView\", data => OK200);\n _defineProperty(this, \"uploadToS3\", async file => OK200);\n _defineProperty(this, \"time\", _ => Promise.resolve({\n code: 200,\n body: new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date().toISOString()\n }));\n _defineProperty(this, \"updateUser\", data => OK200);\n _defineProperty(this, \"getUser\", _ => Promise.resolve({\n code: 200,\n body: {\n id: 'usqzgtgfake',\n attributes: [{\n key: 'fullname',\n text: 'Kiều Thanh'\n }]\n }\n }));\n _defineProperty(this, \"getAccountSetting\", () => this.apireq.get(`/accounts/${this.accid}/settings`));\n _defineProperty(this, \"sendImpression\", impression => OK200);\n _defineProperty(this, \"sendConversion\", conversion => OK200);\n this.FileURL = FileURL;\n this.apireq = ajax.setBaseUrl(ApiURL).setContentType('text/plain').beforeHook(jsonifyTextPlain).setParser('json');\n }\n setAgentId(agid) {\n this.agentid = agid;\n }\n setAuth(obj) {\n this.accid = obj.accid;\n this.mask = obj.mask;\n this.uid = obj.uid;\n return {\n account_id: this.accid,\n id: 'usqzgtgfake',\n attributes: [{\n key: 'fullname',\n text: 'Kiều Thanh'\n }]\n };\n }\n});\n__webpack_require__.dn(__WEBPACK_DEFAULT_EXPORT__);\nfunction makeFakeConvo(accid, convoid, userid, agentid) {\n let inteid = accid + '.subizv4.subikon';\n return {\n id: convoid,\n account_id: accid,\n created: 1610452894916,\n members: [{\n type: 'user',\n id: userid,\n membership: 'active',\n invited_by: {\n id: userid,\n type: 'user'\n }\n }, {\n type: 'agent',\n id: agentid,\n conversation_id: convoid,\n membership: 'active',\n invited_by: {\n id: userid,\n type: 'user'\n }\n }],\n ended: 1610454875505,\n state: 'ended',\n actived: 1610453070259,\n last_message_sent: {\n id: 'evqyiykaoizbwnkaecwphttwk',\n account_id: accid,\n created: 1616213311830,\n type: 'message_sent',\n by: {\n id: userid,\n client_id: 'clsubizapi',\n type: 'user'\n },\n data: {\n message: {\n conversation_id: convoid,\n text: 'ok cám ơn!',\n format: 'plaintext',\n integration_id: inteid,\n pongs: [{\n member_id: userid,\n type: 'seen',\n created: 1616213312110\n }]\n }\n }\n },\n assigned_to: {},\n first_message: 'Xin chào',\n subject: 'Chúc một ngày tốt lành',\n source: 'https://subiz.com.vn/'\n };\n}\nfunction makeFakeMessages(accid, convoid, userid, agentid) {\n let inteid = accid + '.subizv4.subikon';\n let usermember = {\n type: 'user',\n id: userid,\n last_page_view_url: 'https://subiz.com.vn/',\n conversation_id: convoid,\n membership: 'active',\n invited_by: {\n id: userid,\n type: 'user'\n }\n };\n let agentmember = {\n type: 'agent',\n conversation_id: convoid,\n id: agentid,\n membership: 'active',\n invited_by: {\n id: userid,\n type: 'user'\n }\n };\n return [{\n id: 'evqyiyjmxrjsylftvnrghrfmq',\n account_id: accid,\n created: 1616213202264,\n type: 'conversation_invited',\n by: {\n id: userid,\n type: 'user'\n },\n data: {\n conversation: {\n id: convoid,\n account_id: accid,\n members: [usermember],\n state: 'pending'\n }\n }\n }, {\n id: 'evqyiyjmyqdgrouswczzawuzp',\n account_id: accid,\n created: 1616213202559,\n type: 'conversation_invited',\n by: {\n id: userid,\n type: 'user'\n },\n data: {\n conversation: {\n id: convoid,\n account_id: accid,\n members: [agentmember],\n state: 'pending',\n source: 'https://subiz.com.vn/vi/'\n }\n }\n }, {\n id: 'evqyiyjmyzjpyehnngvmcyauf',\n account_id: accid,\n created: 1616213202668,\n type: 'conversation_state_updated',\n by: {\n id: userid,\n type: 'user'\n },\n data: {\n conversation: {\n id: convoid,\n account_id: accid,\n state: 'active'\n }\n }\n }, {\n id: 'evqyiyjmzaozvqgbkljbwywdl',\n account_id: accid,\n created: 1616213202683,\n type: 'conversation_joined',\n by: {\n id: userid,\n type: 'user'\n },\n data: {\n conversation: {\n id: convoid,\n members: [usermember]\n }\n }\n }, {\n id: 'evqyiyjmzatvtgpdmmpzwnwgn',\n account_id: accid,\n created: 1616213202685,\n type: 'message_sent',\n by: {\n id: userid,\n client_id: 'clsubizapi',\n type: 'user'\n },\n data: {\n message: {\n conversation_id: convoid,\n text: 'Xin chào',\n format: 'plaintext',\n idempotency_key: 'wrueysyjbhqrkiwhsejpqrwqrdkkyaibajdw',\n integration_id: inteid,\n pongs: [{\n member_id: userid,\n type: 'seen',\n created: 1616213203068\n }]\n }\n }\n }, {\n id: 'evqyiyjrhsfyuxtetszmvkkke',\n account_id: accid,\n created: 1616213237491,\n type: 'conversation_joined',\n by: {\n id: userid,\n type: 'user'\n },\n data: {\n conversation: {\n id: convoid,\n members: [agentmember]\n }\n }\n }, {\n id: 'evqyiyjrhtroknjyakrlrwhgr',\n account_id: accid,\n created: 1616213237508,\n type: 'message_sent',\n by: {\n id: agentid,\n client_id: 'dashboard',\n type: 'agent'\n },\n data: {\n message: {\n conversation_id: convoid,\n text: 'chào bạn, mình có thể giúp gì được cho bạn :grinning:',\n format: 'plaintext',\n integration_id: inteid,\n pongs: [{\n member_id: userid,\n type: 'receive',\n created: 1616213237742\n }, {\n member_id: userid,\n type: 'seen',\n created: 1616213240057\n }]\n }\n }\n }, {\n id: 'evqyiyjuvjinmclneroerxmrl',\n account_id: accid,\n created: 1616213265805,\n type: 'message_sent',\n by: {\n id: userid,\n client_id: 'clsubizapi',\n type: 'user'\n },\n data: {\n message: {\n conversation_id: convoid,\n text: 'mình muốn hỏi giá sản phẩm IPhone X',\n format: 'plaintext',\n integration_id: inteid,\n pongs: [{\n member_id: userid,\n type: 'seen',\n created: 1616213267090\n }]\n }\n }\n }, {\n id: 'evqyiyjzjxzfcsexshcjbbnnf',\n account_id: accid,\n created: 1616213302432,\n type: 'message_sent',\n by: {\n id: agentid,\n client_id: 'dashboard',\n type: 'agent'\n },\n data: {\n message: {\n conversation_id: convoid,\n text: 'IPhone X hiện đang được bán tại cửa hàng với giá 12tr đồng nha bạn',\n format: 'plaintext',\n integration_id: inteid,\n pongs: [{\n member_id: userid,\n type: 'receive',\n created: 1616213302698\n }, {\n member_id: userid,\n type: 'seen',\n created: 1616213305071\n }]\n }\n }\n }, {\n id: 'evqyiykaoizbwnkaecwphttwk',\n account_id: accid,\n created: 1616213311830,\n type: 'message_sent',\n by: {\n id: userid,\n client_id: 'clsubizapi',\n type: 'user'\n },\n data: {\n message: {\n conversation_id: convoid,\n text: 'ok cám ơn!',\n format: 'plaintext',\n integration_id: inteid,\n pongs: [{\n member_id: userid,\n type: 'seen',\n created: 1616213312110\n }]\n }\n }\n }];\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/api_fake.js?\n}");
|
|
219
|
+
|
|
220
|
+
/***/ },
|
|
221
|
+
|
|
222
|
+
/***/ "./src/store/chain.js"
|
|
223
|
+
/*!****************************!*\
|
|
224
|
+
!*** ./src/store/chain.js ***!
|
|
225
|
+
\****************************/
|
|
226
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
227
|
+
|
|
228
|
+
"use strict";
|
|
229
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Chain)\n/* harmony export */ });\nconst ChainMaxSize = 50;\nclass Chain {\n constructor(db, schema, inmem) {\n this.schema = schema + '_chain';\n this.dead = false;\n this.db = db;\n this.anchorCache = {};\n this.cache = {};\n this.init();\n }\n init() {\n let inmemItemM = {};\n let allitems = this.db.all('items');\n allitems.map(item => {\n inmemItemM[item.chain] = inmemItemM[item.chain] || {};\n inmemItemM[item.chain][item.id] = {\n id: item.id,\n chain: item.chain,\n full_id: item.full_id,\n index: item.index,\n value: item.value\n };\n });\n map(inmemItemM, (itemM, chain) => {\n if (size(itemM) < ChainMaxSize) return;\n let items = orderBy(map(itemM), ['index'], 'desc');\n let removekeys = [];\n for (var i = ChainMaxSize; i < items.length; i++) {\n removekeys.push(items[i].full_id);\n delete itemM[items[i].id];\n }\n this.db.removes('items', removekeys);\n inmemItemM[chain] = itemM;\n });\n this.cache = inmemItemM;\n }\n destroy() {\n this.db.clear('items');\n this.dead = true;\n this.cache = {};\n this.anchorCache = {};\n this.db = undefined;\n }\n put(chain, id, node_index, value) {\n if (this.dead) return;\n let inmemItemM = this.cache[chain] || {};\n let bottom = minIndex(inmemItemM) || {};\n let bottomIndex = bottom.index || 'z';\n if (size(inmemItemM) == 0) bottomIndex = '';\n let item = {\n id,\n index: node_index,\n value,\n chain,\n full_id: chain + ':' + id\n };\n delete inmemItemM[item.id];\n if (bottomIndex > item.index + '') return;\n inmemItemM[item.id] = item;\n this.cache[chain] = inmemItemM;\n this.db.put('items', item.full_id, item);\n }\n listM(chain) {\n if (this.dead) return {};\n let inmemItemM = this.cache[chain] || {};\n let out = {};\n map(inmemItemM, (item, id) => {\n out[id] = item.value;\n });\n return out;\n }\n async fetchMore(chain, limit = 20, api) {\n if (this.dead) return {\n error: 'dead'\n };\n if (!api) return {\n error: 'no api'\n };\n let anchor = this.anchorCache[chain] || '';\n var [apiItems, newanchor, error] = await api(chain, anchor, limit);\n if (error) return {\n error\n };\n if (this.dead) return {\n error: 'dead'\n };\n let inmemItemM = this.cache[chain] || {};\n if (apiItems.length === 0) return {\n end: true\n };\n apiItems.forEach(item => {\n item.chain = chain;\n item.full_id = chain + ':' + item.id;\n inmemItemM[item.id] = item;\n this.db.put('items', item.full_id, item);\n });\n this.anchorCache[chain] = newanchor;\n this.cache[chain] = inmemItemM;\n return {};\n }\n del(chain, id) {\n if (this.dead) return;\n let inmemItemM = this.cache[chain] || {};\n let full_id = chain + ':' + id;\n delete inmemItemM[id];\n this.db.removes('items', [full_id]);\n }\n match(chain, id) {\n return this.listM(chain)[id];\n }\n async reload(chain, api) {\n if (this.dead) return;\n let top = maxIndex(this.listM(chain)) || {};\n let topindex = top.index;\n if (!topindex) topindex = Date.now();\n var lastanchor = '';\n var fetchedItems = {};\n for (;;) {\n if (this.dead) return;\n let [newItems, newanchor, error] = await api(chain, lastanchor, 50);\n if (error) return;\n if (this.dead) return;\n newItems.map(item => {\n fetchedItems[item.id] = Object.assign({}, item, {\n chain,\n full_id: chain + ':' + item.id\n });\n });\n if (newItems.length === 0 || newanchor === lastanchor) break;\n if (fetchedItems.length >= 200) {\n let inmemItemM = this.cache[chain] || {};\n let removeids = [];\n map(inmemItemM, item => {\n if (item.chain !== chain) return;\n removeids.push(item.full_id);\n });\n this.db.removes('items', removeids);\n this.cache[chain] = {};\n break;\n }\n let minindexitem = minIndex(fetchedItems) || {};\n if (minindexitem.index <= topindex) {\n lastanchor = this.anchorCache[chain] || newanchor;\n break;\n }\n lastanchor = newanchor;\n }\n for (var i = 0; i < Object.keys(fetchedItems).length; i++) {\n let item = fetchedItems[Object.keys(fetchedItems)[i]];\n this.db.put('items', item.full_id, item);\n this.cache[item.chain] = this.cache[item.chain] || {};\n this.cache[item.chain][item.id] = item;\n }\n this.anchorCache[chain] = lastanchor;\n }\n}\nfunction minIndex(obj) {\n if (!obj) return;\n let keys = Object.keys(obj);\n if (!keys.length) return;\n let min = Infinity;\n let minKey = Object.keys(obj)[0];\n for (var i = 0; i < keys.length; i++) {\n let index = obj[keys[i]] && obj[keys[i]].index || Infinity;\n if (index < min) {\n min = index;\n minKey = keys[i];\n }\n }\n return obj[minKey];\n}\nfunction maxIndex(obj) {\n if (!obj) return;\n let keys = Object.keys(obj);\n if (!keys.length) return;\n let max = -Infinity;\n let maxKey = Object.keys(obj)[0];\n for (var i = 0; i < keys.length; i++) {\n let index = obj[keys[i]] && obj[keys[i]].index || -Infinity;\n if (index > max) {\n max = index;\n maxKey = keys[i];\n }\n }\n return obj[keys[maxKey]];\n}\nfunction map(collection, predicate) {\n if (!collection) return [];\n if (!predicate) return collection;\n var out = [];\n if (Array.isArray(collection)) {\n for (let i = 0; i < collection.length; i++) {\n out.push(predicate(collection[i], i));\n }\n return out;\n }\n if (typeof collection === 'object') {\n var keys = Object.keys(collection);\n for (let i = 0; i < keys.length; i++) {\n var k = keys[i];\n out.push(predicate(collection[k], k));\n }\n return out;\n }\n return out;\n}\nfunction size(o) {\n if (!o) return 0;\n if (o.length !== undefined) return o.length;\n return Object.keys(o).length;\n}\nfunction orderBy(a, k, d) {\n var clone = [];\n map(a, v => clone.push(v));\n clone.sort((i, j) => {\n if (i[k] === j[k]) return 0;\n var r = i[k] < j[k] ? -1 : 1;\n return d === 'desc' ? -r : r;\n });\n return clone;\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/chain.js?\n}");
|
|
230
|
+
|
|
231
|
+
/***/ },
|
|
232
|
+
|
|
233
|
+
/***/ "./src/store/inmem_localstorage.js"
|
|
234
|
+
/*!*****************************************!*\
|
|
235
|
+
!*** ./src/store/inmem_localstorage.js ***!
|
|
236
|
+
\*****************************************/
|
|
237
|
+
(module) {
|
|
238
|
+
|
|
239
|
+
eval("{var localStorageMemory = {};\nvar cache = {};\nlocalStorageMemory.length = 0;\nlocalStorageMemory.cache = cache;\nlocalStorageMemory.getItem = function (key) {\n if (key in cache) return cache[key];\n return null;\n};\nlocalStorageMemory.setItem = function (key, value) {\n if (typeof value === 'undefined') {\n localStorageMemory.removeItem(key);\n } else {\n if (!Object.prototype.hasOwnProperty.call(cache, key)) {\n localStorageMemory.length++;\n }\n cache[key] = value;\n }\n};\nlocalStorageMemory.removeItem = function (key) {\n if (Object.prototype.hasOwnProperty.call(cache, key)) {\n delete cache[key];\n localStorageMemory.length--;\n }\n};\nlocalStorageMemory.key = function (index) {\n return Object.keys(cache)[index] || null;\n};\nlocalStorageMemory.clear = function () {\n cache = {};\n localStorageMemory.length = 0;\n};\nmodule.exports = localStorageMemory;\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/inmem_localstorage.js?\n}");
|
|
240
|
+
|
|
241
|
+
/***/ },
|
|
242
|
+
|
|
243
|
+
/***/ "./src/store/kv.js"
|
|
244
|
+
/*!*************************!*\
|
|
245
|
+
!*** ./src/store/kv.js ***!
|
|
246
|
+
\*************************/
|
|
247
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
248
|
+
|
|
249
|
+
"use strict";
|
|
250
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nlet KvMaxSize = 500;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (class {\n constructor(db, schema) {\n this.name = schema;\n schema += '_kv';\n this.dead = false;\n this.db = db;\n this.cache = {};\n this.initialized = false;\n this.init();\n }\n refreshCache() {\n if (this.dead) return;\n let inmemItemM = {};\n let allitems = this.db.all('items');\n allitems.forEach(function (item) {\n inmemItemM[item.key] = item.value;\n });\n this.cache = inmemItemM;\n }\n init() {\n if (this.initialized) return;\n let inmemItemM = {};\n let allitems = this.db.all('items');\n allitems.forEach(function (item) {\n inmemItemM[item.key] = item.value;\n });\n this.cache = inmemItemM;\n let allkeys = Object.keys(this.cache);\n if (allkeys.length > KvMaxSize) {\n let liveChance = KvMaxSize / 2 / allkeys.lenth;\n let removekeys = [];\n for (var i = 0; i < KvMaxSize; i++) {\n let live = Math.random() <= liveChance;\n if (live) continue;\n let key = allkeys[i];\n delete this.cache[key];\n removekeys.push(key);\n }\n this.db.removes('items', [removekeys]);\n }\n this.initialized = true;\n }\n all() {\n if (this.dead) return [];\n if (!this.initialized) return [];\n return this.cache;\n }\n match(key) {\n if (this.dead || !this.initialized) return;\n if (!key) return;\n return this.cache[key];\n }\n put(key, value) {\n if (!key) return;\n if (this.dead) return [];\n if (!this.initialized) throw new Error('uninitialized');\n this.cache[key] = value;\n this.db.put('items', key, {\n key,\n value\n });\n }\n del(key) {\n if (this.dead) return;\n if (!this.initialized) throw new Error('uninitialized');\n delete this.cache[key];\n this.db.removes('items', [key]);\n }\n destroy() {\n this.db.clear('items');\n this.dead = true;\n this.db = undefined;\n this.cache = undefined;\n this.initialized = false;\n }\n});\n__webpack_require__.dn(__WEBPACK_DEFAULT_EXPORT__);\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/kv.js?\n}");
|
|
251
|
+
|
|
252
|
+
/***/ },
|
|
253
|
+
|
|
254
|
+
/***/ "./src/store/lsdb.js"
|
|
255
|
+
/*!***************************!*\
|
|
256
|
+
!*** ./src/store/lsdb.js ***!
|
|
257
|
+
\***************************/
|
|
258
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
259
|
+
|
|
260
|
+
"use strict";
|
|
261
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\nlet memlocalStorage = __webpack_require__(/*! ./inmem_localstorage.js */ \"./src/store/inmem_localstorage.js\");\n\nlet requestIdleCallback = typeof window !== 'undefined' ? window.requestIdleCallback : null;\nif (!requestIdleCallback) requestIdleCallback = cb => cb();\nconst LIMIT = 80;\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (class {\n constructor(schema, inmem) {\n this.localStorage = memlocalStorage;\n this.inmem = inmem;\n this.allkeys = {};\n if (!inmem) {\n try {\n window.localStorage.setItem('sbzstore1029', '?');\n window.localStorage.removeItem('sbzstore1029');\n this.localStorage = window.localStorage;\n } catch (e) {}\n }\n this.schema = schema;\n }\n all(table) {\n let items = [];\n for (var i = 0; i < this.localStorage.length; i++) {\n let key = this.localStorage.key(i);\n if (!key.startsWith(this.schema + '#' + table + '#')) continue;\n this.allkeys[key] = true;\n if (this.inmem) items.push(this.localStorage.getItem(key));else items.push(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].parseJSON(this.localStorage.getItem(key)));\n }\n return items;\n }\n removes(table, keys) {\n for (var i = 0; i < keys.length; i++) {\n delete this.allkeys[this.schema + '#' + table + '#' + keys[i]];\n this.localStorage.removeItem(this.schema + '#' + table + '#' + keys[i]);\n }\n }\n clear(table) {\n var keys = [];\n for (var i = 0; i < this.localStorage.length; i++) {\n let key = this.localStorage.key(i);\n if (!key.startsWith(this.schema + '#' + table + '#')) continue;\n keys.push(key);\n }\n for (var i = 0; i < keys.length; i++) {\n this.localStorage.removeItem(keys[i]);\n }\n this.allkeys = {};\n }\n put(table, key, value) {\n this.allkeys[this.schema + '#' + table + '#' + key] = true;\n if (this.inmem) return this.localStorage.setItem(this.schema + '#' + table + '#' + key, value);\n if (Object.keys(this.allkeys).length > LIMIT) this.clear(table);\n requestIdleCallback(() => {\n try {\n this.localStorage.setItem(this.schema + '#' + table + '#' + key, toString(value));\n } catch (e) {\n this.clear(table);\n }\n });\n }\n});\n__webpack_require__.dn(__WEBPACK_DEFAULT_EXPORT__);\nfunction toString(obj) {\n if (obj === undefined) return 'null';\n return JSON.stringify(obj);\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/lsdb.js?\n}");
|
|
262
|
+
|
|
263
|
+
/***/ },
|
|
264
|
+
|
|
265
|
+
/***/ "./src/store/realtime_fake.js"
|
|
266
|
+
/*!************************************!*\
|
|
267
|
+
!*** ./src/store/realtime_fake.js ***!
|
|
268
|
+
\************************************/
|
|
269
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
270
|
+
|
|
271
|
+
"use strict";
|
|
272
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (class {\n onEvent() {}\n onInterrupted() {}\n subscribe() {}\n stop() {}\n getStatus() {\n return 'active';\n }\n reconnect() {}\n});\n__webpack_require__.dn(__WEBPACK_DEFAULT_EXPORT__);\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/realtime_fake.js?\n}");
|
|
273
|
+
|
|
274
|
+
/***/ },
|
|
275
|
+
|
|
276
|
+
/***/ "./src/store/store.js"
|
|
277
|
+
/*!****************************!*\
|
|
278
|
+
!*** ./src/store/store.js ***!
|
|
279
|
+
\****************************/
|
|
280
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
281
|
+
|
|
282
|
+
"use strict";
|
|
283
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Store)\n/* harmony export */ });\n/* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ \"./src/util/index.js\");\n/* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./api.js */ \"./src/store/api.js\");\n/* harmony import */ var _lsdb_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lsdb.js */ \"./src/store/lsdb.js\");\n/* harmony import */ var _chain_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./chain.js */ \"./src/store/chain.js\");\n/* harmony import */ var _kv_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./kv.js */ \"./src/store/kv.js\");\n/* harmony import */ var _api_fake_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./api_fake.js */ \"./src/store/api_fake.js\");\n/* harmony import */ var _realtime_fake_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./realtime_fake.js */ \"./src/store/realtime_fake.js\");\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n;\nvar flow = __webpack_require__(/*! @subiz/flow */ \"./node_modules/@subiz/flow/index.js\");\n\n\n\n\n\n\nvar Realtime = __webpack_require__(/*! @subiz/wsclient */ \"./node_modules/@subiz/wsclient/realtime.js\");\nvar cookie = __webpack_require__(/*! cookie_js */ \"./node_modules/cookie_js/dist/cookie.umd.js\");\ncookie.defaults.path = '/';\ncookie.expiresMultiplier = 60 * 60 * 24;\ncookie.defaults.expires = 3650;\nlet memlocalStorage = __webpack_require__(/*! ./inmem_localstorage.js */ \"./src/store/inmem_localstorage.js\");\nconst MAX_CONVO = 20;\nconst page_loaded = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now();\nconst DEBUG_ACCOUNT_IDS = ['acqsulrowbxiugvginhw', 'acryguzgwxmamhzmqlyx'];\nclass Store {\n constructor(ApiURL, FileURL, RealtimeURL, inmem, fakeapi) {\n _defineProperty(this, \"inmem\", false);\n _defineProperty(this, \"cookie\", cookie);\n _defineProperty(this, \"getConnectionStatus\", () => this.connectionStatus);\n _defineProperty(this, \"_currentViewingProduct\", {});\n _defineProperty(this, \"new_visitor\", true);\n _defineProperty(this, \"matchUser\", () => {\n if (!this.cache) return undefined;\n this._touchAcc();\n return this.cache.match('user');\n });\n _defineProperty(this, \"suggest_addresses\", keyword => this.api.suggest_address(keyword));\n _defineProperty(this, \"matchAccount\", () => this.cache.match('account'));\n _defineProperty(this, \"matchPaymentMethods\", () => this.cache.match('payment_methods'));\n _defineProperty(this, \"matchUnread\", () => {\n let user = this.matchUser();\n if (!user || !user.id) return;\n let allconvos = this.matchConvo('*');\n let unreadcount = 0;\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(allconvos, convo => {\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isConvoSeen(convo, user.id)) unreadcount++;\n });\n return unreadcount;\n });\n _defineProperty(this, \"matchPlugin\", () => {\n if (this.is_embed_chat_mode) {\n let pluginM = this.cache.match('plugin');\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(this.forcePlugins) > 0) pluginM = this.forcePlugins;\n let chatboxs = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].filter(pluginM, (plugin, id) => plugin && plugin.type === 'chatbox');\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(chatboxs) === 0) {\n console.error('no chatbox found.');\n return;\n }\n let chatbox = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(chatboxs, chatbox => !!chatbox);\n if (!chatbox) {\n chatbox = chatboxs[0];\n }\n chatbox = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(chatbox);\n chatbox.triggers = undefined;\n return {\n [chatbox.id]: chatbox\n };\n }\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(this.forcePlugins) > 0) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(this.forcePlugins);\n return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(this.cache.match('plugin')) || {};\n });\n _defineProperty(this, \"device\", {});\n _defineProperty(this, \"browserVisibility\", 'visible');\n _defineProperty(this, \"matchAgent\", id => {\n let agentM = this.cache.match('agent') || {};\n if (id === '*') return agentM;\n return agentM[id];\n });\n _defineProperty(this, \"matchConvo\", id => {\n if (!id) return;\n if (id === '*') {\n this._touchAcc();\n return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].filter(this.cache.all(), (value, k) => k.startsWith('convo_')).concat(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.lightConvos));\n }\n if (id.startsWith('cslight')) return this.lightConvos[id];\n if (!this.isInsync(id)) this.fetchConvo(id);\n return this.cache.match('convo_' + id);\n });\n _defineProperty(this, \"fetchConvo\", async cid => {\n if (!cid) return;\n if (cid.startsWith('cslight')) return;\n if (this._die) return dieErr;\n await this.readyGate.entry();\n await this.reconnectGate.entry(undefined, true);\n if (this.isInsync(cid)) return this.reconnectGate.open();\n this.markSync(cid);\n let {\n body: convo,\n error\n } = await this.api.getConversation(cid);\n if (convo && !error) this._setConvo(convo);\n return this.reconnectGate.open();\n });\n _defineProperty(this, \"list_provinces\", () => this.api.list_provinces());\n _defineProperty(this, \"list_districts\", p => this.api.list_districts(p));\n _defineProperty(this, \"list_wards\", p => this.api.list_wards(p));\n _defineProperty(this, \"outofmsgM\", {});\n _defineProperty(this, \"listEvents\", id => {\n if (!id || id === '*' || typeof id !== 'string') return;\n if (id.startsWith('cslight')) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.lightConvos, [id, 'events'], []);\n return this.chain.listM(id);\n });\n _defineProperty(this, \"fetchMoreEvents\", async convoid => {\n if (!convoid) return;\n if (convoid.startsWith('cslight')) return [[], ''];\n if (!this.isInsync('events' + convoid)) {\n await this.readyGate.entry();\n await this.reconnectGate.entry(undefined, true);\n if (this.isInsync('events' + convoid)) {\n this.reconnectGate.open();\n return {};\n }\n this.markSync('events' + convoid);\n await this.chain.reload(convoid, () => {\n return [[], ''];\n });\n let out = await this._doFetchMsg(convoid);\n this.reconnectGate.open();\n return out;\n }\n return this._doFetchMsg(convoid);\n });\n _defineProperty(this, \"reloadConvoEvents\", async convoid => {\n await this.chain.reload(convoid, () => {\n return [[], ''];\n });\n let {\n error\n } = await this.chain.fetchMore(convoid, 150, async (type, anchor, limit) => {\n let [events, newanchor, error, outofmsg] = await this.listmessageapi(type, anchor, limit);\n if (outofmsg) this.outofmsgM[convoid] = true;\n return [events, newanchor, error];\n });\n return {\n error\n };\n });\n _defineProperty(this, \"_doFetchMsg\", async convoid => {\n let {\n error\n } = await this.chain.fetchMore(convoid, 150, async (type, anchor, limit) => {\n if (this.outofmsgM[convoid]) return [[], ''];\n let [events, newanchor, error, outofmsg] = await this.listmessageapi(type, anchor, limit);\n if (outofmsg) this.outofmsgM[convoid] = true;\n return [events, newanchor, error];\n });\n this.pubsub.publish('account');\n return {\n error\n };\n });\n _defineProperty(this, \"matchLocation\", () => this.cache.match('location') || {});\n _defineProperty(this, \"matchBot\", () => this.cache.match('bot') || {});\n _defineProperty(this, \"readyGate\", new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Gate());\n _defineProperty(this, \"convoGate\", new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Gate(true));\n _defineProperty(this, \"reconnectGate\", new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Gate(true));\n _defineProperty(this, \"wsGate\", new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Gate(true));\n _defineProperty(this, \"matchLastview\", () => {\n return this.kv.match('lastview') || {};\n });\n _defineProperty(this, \"matchIsOpen\", () => !!this.kv.match('isopen'));\n _defineProperty(this, \"matchClosePreviewAt\", () => this.kv.match('close_preview_at') || 0);\n _defineProperty(this, \"checkFormToken\", (accid, token) => this.api.checkFormToken(accid, token));\n _defineProperty(this, \"submitForm2\", (accid, token, data) => this.api.submitForm2(accid, token, data));\n _defineProperty(this, \"sendPresence\", _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].throttle(async () => {\n if (!this._track_page_view) return;\n if (this._die) return dieErr;\n await this.readyGate.entry();\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.cache.match('user'), 'id')) return;\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isUserBanned(this.cache.match('user'))) return;\n let hasfocus = this.browserVisibility === 'visible' && document.hasFocus();\n if (!hasfocus) return this.api.sendLostFocus();\n this.sendPageview();\n }, 1000, {\n leading: false\n }));\n _defineProperty(this, \"now\", () => _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now() + this.timeDiff);\n _defineProperty(this, \"seenQueue\", []);\n _defineProperty(this, \"matchTrafficSource\", () => this.kv.match('traffic_source'));\n _defineProperty(this, \"sendBugReport\", str => this.api.sendBugReport(str));\n _defineProperty(this, \"matchDebugAccountIds\", () => DEBUG_ACCOUNT_IDS);\n _defineProperty(this, \"sbzListConversations\", () => {\n return this.api.listConversations();\n });\n _defineProperty(this, \"sbzListMessages\", cid => {\n return this.api.listMessages(cid, 100, '');\n });\n _defineProperty(this, \"listAgentRealtimeMessageSent\", () => {\n return this.agent_rt_message_sent_dict;\n });\n _defineProperty(this, \"_alreadyReceived\", {});\n _defineProperty(this, \"_typing\", _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].throttle(convoid => this.api.sendTyping(convoid), 3000, {\n trailing: false\n }));\n _defineProperty(this, \"onConvoEvent\", (o, cb) => this.pubsub.on2(o, 'events', cb));\n _defineProperty(this, \"onWidgetClose\", (o, cb) => this.pubsub.on2(o, 'sbz_close_widget', cb));\n _defineProperty(this, \"onMessageUpdated\", (o, cb) => this.pubsub.on2(o, 'message_updated', cb));\n _defineProperty(this, \"seenConvo\", id => {\n if (!id || id === 'create') return;\n this.seenQueue.push(id);\n });\n _defineProperty(this, \"onUpdate\", (o, cb) => this.pubsub.on2(o, 'account', cb));\n _defineProperty(this, \"onDestroyed\", (o, cb) => this.pubsub.on2(o, 'destroy', cb));\n _defineProperty(this, \"onConnection\", (o, cb) => this.pubsub.on2(o, 'connection', cb));\n _defineProperty(this, \"onResetCSS\", (o, cb) => this.pubsub.on2(o, 'resetCSS', cb));\n _defineProperty(this, \"onHighlight\", (o, cb) => this.pubsub.on2(o, 'highlight', cb));\n _defineProperty(this, \"closePreview\", () => this.kv.put('close_preview_at', new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date().getTime()));\n _defineProperty(this, \"updateLastview\", obj => {\n let user = this.cache.match('user') || {};\n if (!user.id) return;\n let lastview = this.matchLastview() || {};\n let newview = {\n ...lastview,\n ...obj,\n user_id: user.id\n };\n this.kv.put('lastview', newview);\n this.pubsub.publish('lastview', newview, lastview);\n });\n _defineProperty(this, \"onLastview\", (o, cb) => this.pubsub.on2(o, 'lastview', cb));\n _defineProperty(this, \"timeDiff\", 0);\n this.connectionStatus = 'active';\n this.CONNECTION_CHECK_INTERVAL = 3000;\n this.reconnectTimestamp = 0;\n this.g_sync = {};\n this.agent_rt_message_sent_dict = {};\n this._die = false;\n this.forceDevice = null;\n this.forcePlugins = {};\n this.forceAcc = {};\n this.forceChatbox = {};\n this.RealtimeURL = RealtimeURL;\n this.fake = fakeapi;\n this.FileURL = FileURL;\n this._track_page_view = true;\n this.device_type = 'desktop';\n if (this.fake) this.api = new _api_fake_js__WEBPACK_IMPORTED_MODULE_5__[\"default\"](ApiURL, FileURL);else this.api = new _api_js__WEBPACK_IMPORTED_MODULE_1__[\"default\"](ApiURL, FileURL);\n if (!inmem) {\n try {\n document.cookie;\n localStorage;\n } catch (e) {\n inmem = true;\n }\n }\n if (inmem) {\n this.inmem = inmem;\n this.cookie = inmemCookie;\n }\n cleanLocalStorage();\n this.pubsub = new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Pubsub();\n this.kv = new _kv_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"](new _lsdb_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]('sbz2023', this.inmem), 'kv');\n this.cache = new _kv_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"](new _lsdb_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]('sbz2023', true), 'kv');\n this.chain = new _chain_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](new _lsdb_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]('cbz2023', true), 'ch');\n this.getLocaleContent = this.api.getLocaleContent;\n this.g_haveSentSeenM = {};\n this.last_focused = this.now();\n window.addEventListener('blur', () => {\n this.last_focused = this.now();\n this.sendPresence();\n });\n window.addEventListener('focus', () => {\n this.last_focused = 0;\n this.sendPresence();\n });\n window.addEventListener('beforeunload', () => this.api.sendLostFocus());\n this._lastPresenceURL = window.location.href;\n this._urlCheckInterval = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setInterval(() => {\n if (this._die) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(this._urlCheckInterval);\n if (this._lastPresenceURL === window.location.href) return;\n this._lastPresenceURL = window.location.href;\n this.sendPresence();\n }, 2_000);\n this.doNotStartBot = () => {\n this._donotstartbot = true;\n };\n this.autoStartBot = () => {\n this._donotstartbot = false;\n };\n this.matchAutoStartBot = () => !this._donotstartbot;\n this._presenceInterval1 = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setInterval(() => {\n if (this._die) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(this._presenceInterval1);\n if (this.browserVisibility === 'visible' && document.hasFocus()) this.sendPresence();\n }, 20000);\n this._presenceInterval2 = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setInterval(() => {\n if (this._die) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(this._presenceInterval2);\n if (this.browserVisibility === 'visible' && document.hasFocus()) return;\n if (this.last_focused && this.now() - this.last_focused > 30 * 60000) {\n return;\n }\n this.sendPresence();\n }, 60000);\n onVisibilityChange(val => {\n if (this._die) return;\n this.browserVisibility = val;\n this.sendPresence();\n });\n this.loopTime();\n this.device = this.getDeviceInfo();\n const _gaInterval = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setInterval(() => {\n let user = this.cache.match('user') || {};\n if (!user.id) return;\n var dev = this.getDeviceInfo();\n if (!dev.ga_tracking_ids || !dev.ga_client_id) return;\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(_gaInterval);\n this.device = dev;\n let ga_client_id = dev.ga_client_id;\n if (ga_client_id !== _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getUserAttr(user, 'ga_client_id', 'text')) {\n this.setUser({\n attributes: [{\n type: 'text',\n text: ga_client_id,\n key: 'ga_client_id'\n }]\n });\n }\n }, 2000);\n this.loopCheckConnectionStatus();\n }\n async loopCheckConnectionStatus() {\n while (true) {\n if (this._die) break;\n await _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].sleep(this.CONNECTION_CHECK_INTERVAL);\n if (!this.realtime) continue;\n if (!this.realtime.getStatus || !this.realtime.reconnect) continue;\n if (this.connectionStatus === 'dead') {}\n let currentStatus = this.connectionStatus;\n this.connectionStatus = this.realtime.getStatus();\n if (currentStatus !== this.connectionStatus) {\n console.log('publish connectionStatus', this.connectionStatus);\n this.pubsub.publish('connection');\n }\n }\n }\n linkProduct(p) {\n if (!p) {\n this._currentViewingProduct = {};\n return;\n }\n if (p.id) this._currentViewingProduct.id = (p.id + '').trim();\n if (p.source_id) this._currentViewingProduct.source_id = (p.source_id + '').trim();\n if (p.sku) this._currentViewingProduct.sku = (p.sku + '').trim();\n }\n getTrackPageview() {\n return this._track_page_view;\n }\n setTrackPageview(val) {\n this._track_page_view = !!val;\n }\n getLinkedProduct() {\n return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(this._currentViewingProduct);\n }\n isInsync(key) {\n return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now() - (this.g_sync[key] || 0) < 600000;\n }\n async fetchShippingAddresses() {\n let out = await this.api.fetchShippingAddresses();\n if (out.error) return null;\n this.cache.put('shipping_address', out.body.shipping_addresses);\n }\n matchShippingAddresses() {\n return this.cache.match('shipping_address');\n }\n updateOrder(order) {\n return this.api.updateOrder(order);\n }\n createShippingAddress(addr) {\n return this.api.createShippingAddress(addr);\n }\n createTicket(ticket) {\n return this.api.create_ticket(ticket);\n }\n overrideWelcomeMessage(msg) {\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.lightConvos, (convo, convoid) => {\n if (convo.last_message_sent) {\n convo.last_message_sent.data.message = msg;\n convo.last_message_sent.data.message.conversation_id = convoid;\n }\n let ev = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(convo.events, '0');\n ev.data.message = msg;\n ev.data.message.conversation_id = convoid;\n this.pubsub.publish('events', ev);\n });\n }\n async overrideAcc(acc) {\n this.forceAcc = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(acc);\n await this.readyGate.entry();\n this.reconnect();\n }\n async overrideBotId(botid) {\n this.forceBotId = botid;\n await this.readyGate.entry();\n }\n async overrideChatbox(chatbox) {\n this.forceChatbox = chatbox;\n await this.readyGate.entry();\n await this.reconnect();\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(this.pubsub.publish('resetCSS'), 10);\n }\n onShowMessageInfo(evid) {\n this.pubsub.publish('events', {\n type: 'show_event_info',\n id: evid\n });\n }\n getDeviceInfo() {\n let device = {\n screen_resolution: window.screen.width + 'x' + window.screen.height,\n source_referrer: document.referrer,\n platform: window.navigator.platform,\n language: navigator.language,\n page_url: document.URL,\n page_title: document.title\n };\n let ga_client_id = getGaClientId();\n if (ga_client_id) device.ga_client_id = ga_client_id;\n let ga_tracking_ids = getGaTrackingIds();\n if (ga_tracking_ids.length > 0) device.ga_tracking_ids = ga_tracking_ids;\n return device;\n }\n highlight(pluginid, ref) {\n this.pubsub.publish('highlight', pluginid, ref);\n }\n emitConvoEvent(ev) {\n this.pubsub.publish('events', ev);\n }\n setAIDevMode(mode) {\n this.ai_dev_mode = mode;\n }\n setEmbebedChatMode() {\n this.is_embed_chat_mode = true;\n }\n isAIDevMode() {\n return this.ai_dev_mode;\n }\n isEmbededChatMode() {\n return this.is_embed_chat_mode;\n }\n overrideDeviceType(type) {\n this.forceDevice = type;\n this.pubsub.publish('account');\n }\n isMobile() {\n if (this.forceDevice) return this.forceDevice === 'mobile';\n return this.device_type == 'mobile' || _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(window, 'screen.width', 1000) < 576;\n }\n isTablet() {\n if (this.forceDevice) return this.forceDevice === 'tablet';\n return this.device_type == 'tablet';\n }\n isDesktop() {\n if (this.forceDevice) return this.forceDevice === 'desktop';\n return !this.isMobile() && !this.isTable();\n }\n disconnect(key) {\n this.g_sync[key] = 0;\n }\n pageLoaded() {\n return page_loaded;\n }\n overridePlugin(plugins) {\n if (this._die) return dieErr;\n if (!Array.isArray(plugins)) throw 'plugins must be be an array';\n let pluginM = {};\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(plugins, function (plugin) {\n pluginM[plugin.id] = plugin;\n });\n this.forcePlugins = pluginM;\n this.pubsub.publish('account');\n this.pubsub.publish('resetCSS');\n }\n markSync(key) {\n this.g_sync[key] = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now();\n }\n async _touchAcc() {\n if (this.isInsync('account')) return;\n await this.readyGate.entry();\n if (!this.isInsync('account')) this.reconnect();\n }\n async init(accid, mask, userRef, options) {\n this.g_sync = {};\n if (typeof sbz_info != 'undefined') sbz_info.store_0 = true;\n if (!options || !options.use_subdomain_cookie) {\n if (window && window.location && window.location.hostname) {\n cookie.defaults.domain = '.' + window.location.hostname;\n }\n }\n if (typeof sbz_info != 'undefined') sbz_info.store_1 = true;\n if (!userRef) {\n try {\n userRef = this.cookie.get('__sbref', '');\n } catch (e) {}\n if (typeof sbz_info != 'undefined') sbz_info.store_2 = true;\n if (!userRef) {\n if (!mask) {\n try {\n mask = this.cookie.get('__sbmask', '');\n } catch (e) {}\n }\n if (mask) {\n let parts = mask.split('@');\n if (parts[0] != accid) {\n userRef = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].randomString(40);\n this.new_visitor = true;\n }\n this.new_visitor = false;\n this.cookie.set('__sbmask', mask);\n } else {\n userRef = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].randomString(40);\n this.new_visitor = true;\n }\n }\n }\n if (typeof sbz_info != 'undefined') sbz_info.store_3 = true;\n if (this.cookie.get('__sbref', userRef) != userRef) {\n cleanMyLocalStorage();\n this.clearBrowserData();\n }\n if (typeof sbz_info != 'undefined') sbz_info.store_4 = true;\n this.api.setAuth({\n accid: accid\n });\n if (typeof sbz_info != 'undefined') sbz_info.store_5 = true;\n if (userRef) this.cookie.set('__sbref', userRef);\n if (typeof sbz_info != 'undefined') sbz_info.store_6 = true;\n return this._initResource(accid, {\n accid: accid,\n mask: mask,\n ref: userRef\n }, {\n account_id: accid,\n user_ref: userRef,\n user_mask: mask\n });\n }\n standardlizeLastview() {\n let lastView = this.kv.match('lastview') || {};\n let user = this.cache.match('user') || {};\n if (!user.id) lastView = {};\n if (lastView.user_id != user.id) lastView = {};\n if (!lastView.screen) {\n lastView.screen = 'preview';\n if (lastView.view === 'list' || lastView.view === 'chat') {\n lastView.screen = 'widget';\n }\n }\n if (this.isMobile()) {\n lastView.screen = 'preview';\n let plugins = this.matchPlugin() || {};\n let chatbox = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(plugins, plugin => plugin.type === 'chatbox') || {};\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(chatbox, 'chatbox.greeting.mobile_disabled')) {\n lastView.screen = 'button';\n }\n }\n this.kv.put('lastview', lastView);\n }\n async _initResource(accid, auth, realtimep) {\n this.g_sync = {};\n this._current_acc_id = accid;\n let user = await this.api.setAuth(auth);\n if (typeof sbz_info != 'undefined') sbz_info.store_7 = true;\n if (user.error) {\n console.error(user);\n return user;\n }\n this.readyGate.close();\n accid = (accid || '').trim();\n let lightConvos = this.kv.match('light_convos') || {};\n this.lightConvos = {};\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(lightConvos, convo => {\n let in7Day = convo.created > _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date.now() - 7 * 24 * 3_600_000;\n let events = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].filter(convo.events, ev => ev.type === 'message_sent');\n let messages = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(events, ev => _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'data.message') || {});\n messages = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].filter(messages, msg => !_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].isEmptyMessage(msg));\n if (in7Day && _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(messages)) {\n this.lightConvos[convo.id] = convo;\n }\n });\n this.cache = new _kv_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"](new _lsdb_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]('sbz2023', true), 'kv');\n if (this.realtime) this.realtime.stop();\n if (this.fake) this.realtime = new _realtime_fake_js__WEBPACK_IMPORTED_MODULE_6__[\"default\"]();else this.realtime = new Realtime(this.RealtimeURL, realtimep, xhrsend, accid);\n this.realtime.onEvent(this.onWs.bind(this));\n this.realtime.onInterrupted(async () => {\n await this.reconnectWs(accid, user.id);\n this.reconnect();\n });\n if (typeof sbz_info != 'undefined') sbz_info.store_8 = true;\n this.seenLoop();\n if (typeof sbz_info != 'undefined') sbz_info.store_9 = true;\n await this.reconnect({\n user: user\n });\n this.standardlizeLastview();\n if (typeof sbz_info != 'undefined') sbz_info.store_10 = true;\n this.readyGate.open();\n this.reconnectWs(accid, user.id);\n return user;\n }\n async login(accid, user_id, tokenGenerator) {\n if (this._die) return dieErr;\n cleanMyLocalStorage();\n this.clearBrowserData();\n this.new_visitor = false;\n return this._initResource(accid, {\n accid: accid,\n profile_id: user_id,\n tokenGenerator: tokenGenerator\n }, {\n getAccessToken: () => this.api.token_generator()\n });\n }\n logout(userRef) {\n return this.api.setAuth({\n ref: userRef\n });\n }\n seenLoop() {\n this.seenQueue = [];\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(this._seenInterval);\n this._seenInterval = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setInterval(() => {\n if (this._die) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(this._seenInterval);\n if (!this.cache) return;\n this.seenQueue = [...new Set(this.seenQueue)];\n let user = this.cache.match('user') || {};\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.seenQueue, id => {\n var events = this.listEvents(id);\n if (!events) return;\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(events) === 0) return;\n events = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].filter(events, ev => ev.type === 'message_sent');\n var lastmsgsent = events[_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(events) - 1];\n if (!lastmsgsent) return;\n if (this.g_haveSentSeenM[lastmsgsent.id]) return;\n if (lastmsgsent.id === lastmsgsent.data.message.idempotency_key) return;\n this.pubsub.publish('events', {\n created: this.now(),\n type: 'message_pong',\n by: {\n type: 'user'\n },\n data: {\n message: {\n conversation_id: id,\n id: '*',\n pongs: [{\n type: 'seen',\n created: this.now()\n }]\n }\n }\n });\n if (id.startsWith('cslight')) {\n let old = this.lightConvos[id];\n let user = this.matchUser();\n if (!old) return;\n let mem = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(old.members, mem => mem.type == 'user' && mem.id == user.id);\n if (mem) mem.seen_at = this.now();\n this.kv.put('light_convos', this.lightConvos);\n this.g_haveSentSeenM[lastmsgsent.id] = true;\n return;\n }\n this.api.markAsSeen(id, lastmsgsent.id);\n let convo = this.cache.match('convo_' + id) || {};\n let mem = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(convo.members, m => m.id === user.id);\n if (mem) mem.seen_at = this.now();\n this._setConvo(convo);\n this.g_haveSentSeenM[lastmsgsent.id] = true;\n });\n this.seenQueue = [];\n }, 1000);\n }\n async reconnectWs(accid, userid) {\n await this.realtime.subscribe([`conversation_state_updated.account.${accid}.user.${userid}`, `conversation_joined.account.${accid}.user.${userid}`, `conversation_typing.account.${accid}.user.${userid}`, `message_sent.account.${accid}.user.${userid}`, `message_pong.account.${accid}.user.${userid}`, `conversation_rating_requested.account.${accid}.user.${userid}`, `conversation_rated.account.${accid}.user.${userid}`, `conversation_events.account.${accid}.user.${userid}`]);\n await this.readyGate.entry();\n }\n async reconnect(p) {\n if (this._die) return;\n await this.reconnectGate.entry(undefined, true);\n this.markSync('account');\n let fetchuser = p && p.user ? Promise.resolve({\n body: p.user\n }) : this.api.getUser();\n let outs = await Promise.all([fetchuser, this.api.getAccountSetting({\n bot_id: this.forceBotId\n })]);\n let error = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(outs, out => out.error);\n if (error) return console.error(error);\n let set = outs[1].body;\n set.user = outs[0].body;\n await this._setSetting(set);\n let convob = await this.api.listConversations();\n error = convob.error;\n let body = convob.body;\n if (!error) {\n let convos = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(body, 'conversations', []);\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.cache.all(), (value, k) => {\n if (k.startsWith('convo_')) {\n if (this.now() - _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getMs(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(value, 'actived')) > 1209600000) this.cache.del(k);\n }\n });\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(convos, convo => this._setConvo(convo));\n }\n return this.reconnectGate.open();\n }\n async submitForm(formid, data, user) {\n await this.readyGate.entry();\n if (user) await this.setUser(user);\n return this.api.submitForm(formid, document.URL, this.device, data, user);\n }\n async setUser(user) {\n if (!user) return;\n await this.readyGate.entry();\n this._setUser(user);\n return this.api.updateUser(user);\n }\n async setUserDiff(user) {\n if (!user) return;\n await this.readyGate.entry();\n let out = await this.api.updateUser(user);\n if (out && out.code == 200 && out.body.id) {\n this._setUser(out.body);\n }\n }\n _setUser(user) {\n user = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(user);\n let olduser = this.cache.match('user') || {};\n var accid = olduser.account_id || user.account_id;\n var id = olduser.id || user.id;\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].each(user.attributes, newattr => {\n if (!newattr) return;\n olduser.attributes = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].filter(olduser.attributes, oldattr => {\n if (!oldattr) return false;\n return oldattr.key !== newattr.key;\n });\n });\n olduser.attributes = olduser.attributes || [];\n olduser.attributes = olduser.attributes.concat(user.attributes);\n olduser.account_id = accid;\n olduser.id = id;\n this.cache.put('user', olduser);\n this.pubsub.publish('account');\n }\n async setSetting(setting) {\n if (!setting) return;\n await this.readyGate.entry();\n return this._setSetting(setting);\n }\n async _setSetting(setting) {\n setting = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].cloneDeep(setting) || {};\n setting.account = Object.assign({}, setting.account, this.forceAcc);\n if (!setting.account.logo_url) {\n setting.account.logo_url = 'https://vcdn.subiz-cdn.com/widget-v4/public/assets/img/default_logo.dd13a2b.svg';\n }\n if (setting.user) {\n setting.user.account_id = setting.account.id;\n delete setting.user.session;\n this._setUser(setting.user);\n }\n if (setting.account) {\n setting.account.is_online = setting.is_online;\n setting.account.is_in_business_hour = setting.is_in_business_hour;\n this.cache.put('account', setting.account);\n delete setting.account;\n }\n let location = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(setting, 'location', []);\n this.cache.put('location', location);\n let bots = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(setting, 'bots', []);\n let botM = {};\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(bots, bot => {\n botM[bot.id] = bot;\n });\n this.cache.put('bot', botM);\n this.device_type = setting.device_type || 'desktop';\n let plugins = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(setting, 'plugins', []);\n let pluginM = {};\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(plugins, plugin => {\n if (plugin.type === 'chatbox') {\n plugin = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].merge(plugin, this.forceChatbox);\n }\n pluginM[plugin.id] = plugin;\n });\n this.cache.put('plugin', pluginM);\n var agents = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(setting, 'agents', []);\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(agents) > 0) {\n let agentM = {};\n this.api.setAgentId(agents[0].id);\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(agents, agent => {\n agentM[agent.id] = agent;\n });\n this.cache.put('agent', agentM);\n }\n let pms = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(setting, 'payment_methods', []);\n this.cache.put('payment_methods', pms);\n this.pubsub.publish('account');\n }\n async sendPageview(p) {\n if (!p) p = {};\n let device = Object.assign({}, this.device);\n if (p.referrer) device.source_referrer = p.referrer;\n device.page_url = p.url || location.href;\n device.page_title = p.title || document.title;\n return this.api.sendContentView(device, p.url || location.href, p.title || document.title, this._currentViewingProduct.id, this._currentViewingProduct.source_id, this._currentViewingProduct.sku);\n }\n async track(e) {\n if (!e) {\n let out = await this.sendPageview();\n let traffic_source = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(out, 'body.by.device.source', '');\n if (traffic_source) this.kv.put('traffic_source', traffic_source);\n return out;\n }\n if (typeof e === 'object') {\n if (!e.data) e.data = {};\n }\n return this.api.sendEvent(e);\n }\n async onWs(ev) {\n await this.wsGate.entry();\n this.wsGate.close();\n await this._onWs(ev);\n this.wsGate.open();\n }\n handleLogCompare(ev) {\n if (!DEBUG_ACCOUNT_IDS.includes(this._current_acc_id)) return;\n if (ev.type !== 'message_sent') return;\n let byType = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'by.type');\n if (byType === 'user') return;\n this.agent_rt_message_sent_dict[ev.id] = ev;\n }\n async _onWs(ev) {\n this.handleLogCompare(ev);\n if (this._die) return;\n if (!ev || !ev.type) return;\n ev.created = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getMs(ev.created);\n if (ev.type === 'user_info_updated') {\n return;\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n // removed by dead control flow\n\n }\n if (ev.type === 'message_deleted') {\n this.pubsub.publish('message_updated', ev);\n return;\n }\n let user = this.cache.match('user') || {};\n let cid = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convoOfEv(ev);\n let convo;\n let alreadyFetched = false;\n if (cid && !cid.startsWith('cslight')) {\n convo = this.cache.match('convo_' + cid);\n if (!convo || !convo.id) {\n let {\n body: apiconvo,\n error\n } = await this.api.getConversation(cid);\n if (!apiconvo) return;\n convo = apiconvo;\n alreadyFetched = true;\n this._setConvo(convo);\n }\n }\n if (cid && cid.startsWith('cslight')) {\n convo = this.lightConvos[cid];\n if (!convo) return;\n convo.events.push(ev);\n convo.last_message_sent = ev;\n this.kv.put('light_convos', this.lightConvos);\n this.pubsub.publish('events', ev);\n return;\n }\n if (!convo) return;\n this.pubsub.publish('events', ev);\n if (ev.type === 'conversation_joined') {\n let members = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'data.conversation.members', []);\n let me = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(members, m => m.id === this.cache.match('user').id);\n if (me) {\n if (!alreadyFetched) {\n let {\n body: apiconvo\n } = await this.api.getConversation(cid);\n if (apiconvo) {\n convo = apiconvo;\n this._setConvo(convo);\n }\n this.pubsub.publish('account');\n }\n }\n }\n if (ev.type === 'message_sent') {\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'by.id') !== user.id) {\n if (!this._alreadyReceived[ev.id]) {\n this._alreadyReceived[ev.id] = true;\n this.api.markAsReceived(cid, ev.id);\n }\n }\n }\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(ev.type, 'message_') || _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(ev.type, 'conversation_')) {\n this.restConvoEvent(ev);\n if (ev.type === 'message_sent' && _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'by.id') !== user.id) {\n sendEventToThirdParty('SUBIZ Chat', 'Received', 'User');\n }\n return;\n }\n }\n async restConvoEvent(ev) {\n let user = this.cache.match('user');\n let cid = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convoOfEv(ev);\n let convo = this.cache.match('convo_' + cid) || {};\n if (ev.type === 'conversation_state_updated') {\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(convo, 'id')) {\n let {\n body: convo,\n error\n } = await this.api.getConversation(cid);\n if (error) return;\n }\n convo = Object.assign(convo, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'data.conversation'));\n }\n if (ev.type === 'message_pong') {\n var msgid = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'data.message.id');\n var oldev = this.chain.match(cid, msgid);\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(oldev, 'data.message')) return;\n var pongs = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(oldev, 'data.message.pongs', []);\n let newpongs = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'data.message.pongs', []) || [];\n pongs = pongs.concat(newpongs);\n if (newpongs.length === 1) {\n let pongtype = newpongs[0].type;\n if (pongtype === 'like' || pongtype === 'remove_dislike') {\n pongs = pongs.filter(pong => pong.type !== 'dislike');\n }\n if (pongtype === 'dislike' || pongtype === 'remove_like') {\n pongs = pongs.filter(pong => pong.type !== 'like');\n }\n }\n oldev.data.message.pongs = pongs;\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(pongs, pong => {\n if (pong.member_id == user.id && pong.type === 'seen') {\n let mem = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(convo.members, mem => mem.id === user.id);\n if (mem) mem.seen_at = pong.created;\n }\n });\n this.chain.put(cid, oldev.id, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getMs(oldev.created), oldev);\n this.pubsub.publish('events', oldev);\n }\n if (ev.type !== 'message_pong' && ev.type !== 'conversation_typing') {\n if (ev.type === 'message_sent') {\n let idemkey = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'data.message.idempotency_key');\n let found = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(this.listEvents(cid), oldev => oldev.id === idemkey);\n if (found) {\n this.chain.del(cid, found.id);\n ev.created = found.created;\n }\n convo.last_message_sent = ev;\n }\n this.chain.put(cid, ev.id, _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getMs(ev.created), ev);\n }\n this._setConvo(convo);\n this.pubsub.publish('account');\n }\n emitCloseWidgetEvent() {\n this.pubsub.publish('sbz_close_widget', {\n type: 'chatbox_closed'\n });\n }\n typing(cid) {\n if (!cid) return;\n if (cid.startsWith('cslight')) return;\n this._typing(cid);\n }\n deleteLightConvo(id) {\n delete this.lightConvos[id];\n this.kv.put('light_convos', this.lightConvos);\n }\n startLightConvo(botid, messages, locale, is_testing, botversion) {\n let convoid = 'cslight' + botid + '_' + this.now();\n let user = this.cache.match('user') || {};\n let old = this.lightConvos[convoid];\n if (old) return {\n convo: old\n };\n let now = this.now();\n let lastev = {};\n let newevs = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(messages, (message, idx) => {\n let ev = {};\n ev.created = now;\n ev.event_time = now;\n ev.id = 'evfake' + now + idx;\n ev.type = 'message_sent';\n ev.by = {\n id: botid,\n type: 'bot'\n };\n ev.data = {\n message: message\n };\n ev.data.message.conversation_id = convoid;\n lastev = ev;\n return ev;\n });\n let newconvo = {\n id: convoid,\n locale: locale,\n initial_by: botid,\n created: now,\n actived: now,\n last_message_sent: lastev,\n members: [{\n type: 'user',\n id: user.id\n }, {\n type: 'bot',\n id: botid,\n membership: 'active'\n }],\n state: 'active',\n touchpoint: {\n id: convoid,\n channel: 'subiz',\n source: 'web'\n },\n traffic_source: 'direct',\n events: newevs,\n is_testing: is_testing,\n bot_versio: botversion\n };\n this.lightConvos[convoid] = newconvo;\n this.kv.put('light_convos', this.lightConvos);\n this.pubsub.publish('events', lastev);\n return {\n convo: newconvo\n };\n }\n async startConvo(req) {\n if (!req) req = {};\n await this.readyGate.entry();\n this.convoGate.close();\n if (!req.source) req.source = document.location.href;\n let {\n body: convo,\n error\n } = await this.api.start(req);\n this.convoGate.open();\n if (error) return {\n error\n };\n this._setConvo(convo);\n return {\n convo\n };\n }\n fetchOrder(id) {\n return this.api.getOrder(id);\n }\n lookupOrder(key) {\n return this.api.lookupOrder(key);\n }\n createPostback(cid, postback) {\n if (cid && cid.startsWith('cslight')) return;\n return this.api.createPostback(cid, postback);\n }\n sendReaction(cid, ev) {\n if (cid && cid.startsWith('cslight')) return;\n return this.api.sendConvoEvent(cid, ev);\n }\n async sendConvoEvent(cid, type, data) {\n await this.readyGate.entry();\n var idempotency = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].randomString(36);\n let user = this.cache.match('user') || {};\n var event = {\n id: idempotency,\n by: {\n id: user.id,\n type: 'user',\n device: this.device\n },\n data,\n type,\n created: this.now()\n };\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].convoToEv(cid, event);\n let files = [];\n if (type === 'message_sent') {\n event.data.message.idempotency_key = idempotency;\n event.data.message.conversation_id = cid;\n await flow.map(event.data.message.attachments, 2, async (att, i) => {\n if (att.type !== 'file') return;\n if (!att._file) return;\n files.push(att);\n if (ImageTypes.includes(att._file.type)) {\n let {\n width,\n height,\n url\n } = await loadImage(att._file);\n att.url = url;\n att.width = width;\n att.height = height;\n }\n });\n }\n this.onWs(event);\n await this.convoGate.entry();\n await flow.map(files, 1, async att => {\n const {\n body,\n url,\n error\n } = await this.api.uploadToS3(att._file);\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(body, 'code') == 'invalid_field_size') {\n event._error_message = 'cannot_send_too_big_file';\n }\n event._error = error;\n att.url = url;\n });\n if (event._error) return this.onWs(event);\n if (cid && cid.startsWith('cslight')) return;\n let {\n body: ret,\n error\n } = await this.api.sendConvoEvent(cid, event);\n if (error) {\n event._error = error;\n this.onWs(event);\n return;\n }\n this.onWs(ret);\n sendEventToThirdParty('SUBIZ Chat', 'Sent', 'User');\n let lastMsgSent = this.kv.match('last_msg_sent');\n if (!lastMsgSent) {\n let dataLayer = window.dataLayer || [];\n dataLayer.push({\n event: 'SUBIZ Chat',\n event_action: 'Sent',\n event_label: 'User',\n first_interaction: 1\n });\n }\n this.kv.put('last_msg_sent', this.now());\n return ret;\n }\n _setConvo(convo) {\n let count = 0;\n let user = this.cache.match('user');\n let channel = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(convo, 'touchpoint.channel', '');\n if (channel && channel != 'subiz') return;\n let allconvo = {};\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(this.cache.all(), (value, key) => {\n if (key.startsWith('convo_')) {\n allconvo[key] = value;\n }\n });\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(allconvo) > MAX_CONVO - 2) {\n allconvo = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].orderBy(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(allconvo), 'created', 'desc');\n for (var i = MAX_CONVO - 2; i < _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(allconvo); i++) {\n let convo = allconvo[i];\n this.cache.del('convo_' + convo.id);\n }\n }\n this.markSync(convo.id);\n this.pubsub.publish('account');\n this.cache.put('convo_' + convo.id, convo);\n }\n matchLastPluginRun(pluginid) {\n let log = this.kv.match('plugin_run_logs') || {};\n return log[pluginid];\n }\n matchLastBotRun(botid) {\n let log = this.kv.match('bot_run_logs') || {};\n return log[botid];\n }\n logBotRun(botid) {\n let log = this.kv.match('bot_run_logs') || {};\n log[botid] = {\n bot_id: botid,\n created: this.now()\n };\n this.kv.put('bot_run_logs', log);\n }\n sendImpression(id) {\n let user = this.cache.match('user') || {};\n let log = this.kv.match('plugin_run_logs') || {};\n log[id] = {\n web_plugin_id: id,\n created: this.now()\n };\n this.kv.put('plugin_run_logs', log);\n return this.api.sendImpression({\n account_id: user.account_id,\n campaign_id: id,\n web_plugin_id: id,\n user_id: user.id,\n url: window.location.href,\n device: this.device\n });\n }\n sendConversion(id, fields, impressionToken) {\n let user = this.cache.match('user') || {};\n let submission = {\n account_id: user.account_id,\n user_id: user.id,\n fields: fields\n };\n let conv = this.kv.match('conversions') || {};\n conv[id] = true;\n this.kv.put('conversions', conv);\n return this.api.sendConversion({\n account_id: user.account_id,\n web_plugin_id: id,\n campaign_id: id,\n user_id: _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(user, 'id'),\n url: window.location.href,\n device: this.device,\n submission,\n impression_token: impressionToken\n });\n }\n isConverted(id) {\n let conv = this.kv.match('conversions') || {};\n return conv[id];\n }\n async listmessageapi(type, anchor, limit) {\n let convoid = type;\n if (convoid && convoid.startsWith('cslight')) return [fakeevents, '', undefined, true];\n let {\n body: events,\n code,\n error\n } = await this.api.listMessages(convoid, -limit, anchor);\n if (error || code !== 200) return [[], anchor, error];\n anchor = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].last(events), 'id');\n events = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].map(events, event => {\n event.created = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].getMs(event.created);\n return {\n id: event.id,\n index: event.created,\n value: event\n };\n });\n let user = this.cache.match('user') || {};\n for (let i = 0; i < events.length; i++) {\n let ev = events[i].value;\n if (ev.type !== 'message_sent') continue;\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'by.id') === user.id) continue;\n let pongbyme = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].find(_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(ev, 'data.message.pongs'), p => p.member_id === user.id);\n if (pongbyme) break;\n if (!this._alreadyReceived[ev.id]) {\n this._alreadyReceived[ev.id] = true;\n this.api.markAsReceived(convoid, ev.id);\n }\n break;\n }\n let outofmsg = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].size(events) < limit;\n return [events, anchor, undefined, outofmsg];\n }\n async loopTime() {\n if (this._die) return;\n let startms = this.now();\n if (!this.cache || !_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.cache.match('user'), 'id')) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(() => this.loopTime(), 240000);\n let {\n body: t,\n error\n } = await this.api.time();\n if (error) return _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(() => this.loopTime(), 30000);\n var latences = Math.abs(this.now() - startms) / 2;\n var serverMs = new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].Date(t).getTime() + latences;\n var localMs = this.now();\n this.timeDiff = Math.floor(serverMs - localMs);\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(() => this.loopTime(), 240000);\n }\n replaceFileUrl(src) {\n if (!src) return '';\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(src, '/')) return src;\n if (_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(src, 'data:')) return src;\n if (!_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(src, 'http://') && !_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(src, 'https://') && !_util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].startsWith(src, '//')) {\n src = _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trim(this.FileURL, '/') + '/' + _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].trimStart(src, '/');\n }\n src = src.replace('https://file-subiz.com/', this.FileURL);\n src = src.replace('http://file-subiz.com/', this.FileURL);\n src = src.replace('https://file-v4.subiz.com/', this.FileURL);\n src = src.replace('http://file-v4.subiz.com/', this.FileURL);\n src = src.replace('https://filev4.subiz.com/', this.FileURL);\n src = src.replace('http://filev4.subiz.com/', this.FileURL);\n src = src.replace('https://filev4-1.subiz.com/', this.FileURL);\n src = src.replace('http://filev4-1.subiz.com/', this.FileURL);\n src = src.replace('https://file.subiz.com/', this.FileURL);\n src = src.replace('http://file.subiz.com/', this.FileURL);\n src = src.replace('https://file.mysubiz.com/', this.FileURL);\n src = src.replace('http://file.mysubiz.com/', this.FileURL);\n return src;\n // removed by dead control flow\n\n }\n clearBrowserData() {\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].each(this.cookie.all(), (v, k) => {\n if ((k || '').startsWith('__sb')) this.cookie.remove(k);\n });\n if (this.kv) this.kv.destroy();\n this.kv = new _kv_js__WEBPACK_IMPORTED_MODULE_4__[\"default\"](new _lsdb_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]('sbz2023', this.inmem), 'kv');\n if (this.chain) this.chain.destroy();\n this.chain = new _chain_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"](new _lsdb_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"]('cbz2023', true), 'ch');\n if (this.realtime) this.realtime.stop();\n if (this.cache) this.cache.destroy();\n this.pubsub.publish('destroy');\n }\n isDead() {\n return this._die;\n }\n destroy() {\n this._die = true;\n this.clearBrowserData();\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(this._seenInterval);\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].clearInterval(this._urlCheckInterval);\n if (this.realtime) this.realtime.stop();\n this.readyGate.close();\n window.removeEventListener('blur', this.sendPresence);\n window.removeEventListener('focus', this.sendPresence);\n }\n}\nfunction loadImage(file) {\n return new Promise(rs => {\n var reader = new window.FileReader();\n reader.onload = e => {\n let src = e.target.result;\n let img = new Image();\n img.onload = () => {\n rs({\n url: src,\n width: img.width,\n height: img.height\n });\n };\n img.src = src;\n };\n reader.readAsDataURL(file);\n });\n}\nconst ImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml'];\nfunction onVisibilityChange(cb) {\n var hidden = 'hidden';\n if (hidden in document) document.addEventListener('visibilitychange', onchange);else if ((hidden = 'mozHidden') in document) document.addEventListener('mozvisibilitychange', onchange);else if ((hidden = 'webkitHidden') in document) document.addEventListener('webkitvisibilitychange', onchange);else if ((hidden = 'msHidden') in document) document.addEventListener('msvisibilitychange', onchange);else if ('onfocusin' in document) document.onfocusin = document.onfocusout = onchange;else window.onpageshow = window.onpagehide = window.onfocus = window.onblur = onchange;\n function onchange(evt) {\n var v = 'visible';\n var h = 'hidden';\n var evtMap = {\n focus: v,\n focusin: v,\n pageshow: v,\n blur: h,\n focusout: h,\n pagehide: h\n };\n evt = evt || window.event;\n if (evt.type in evtMap) cb(evtMap[evt.type]);else cb(this[hidden] ? 'hidden' : 'visible');\n }\n if (document[hidden] !== undefined) onchange({\n type: document[hidden] ? 'blur' : 'focus'\n });\n}\nconst inmemCookie = {\n data: {},\n get(k, def) {\n return this.data[k] || def;\n },\n set(k, v) {\n return this.data[k] = k;\n },\n all() {\n return this.data;\n },\n remove(k) {\n delete this.data[k];\n }\n};\nfunction getGaClientId() {\n if (!window.ga) return;\n if (!window.ga.getAll) return;\n var allTrackers = window.ga.getAll() || [];\n let ga_client_id = '';\n allTrackers.forEach(function (tracker) {\n ga_client_id = tracker.get('clientId');\n });\n return ga_client_id;\n}\nfunction getGaTrackingIds() {\n var trackingIds = [];\n if (!(window.ga && window.ga.getAll)) return trackingIds;\n if (!window.ga) return [];\n if (!window.ga.getAll) return [];\n const allTrackers = window.ga.getAll() || [];\n allTrackers.forEach(function (tracker) {\n var trackingId = tracker.get('trackingId');\n if (trackingId) trackingIds.push(trackingId);\n });\n return trackingIds;\n}\nfunction sendToFBPixel(category, action, label) {\n if (!window.fbq) return;\n window.fbq('trackCustom', category, {\n action: action,\n label: label\n });\n}\nfunction sendToGA(category, action, label) {\n if (window.sbz_no_gtag) {\n console.log('SKIPSENT.', category, action, label);\n return;\n }\n let dataLayer = window.dataLayer || [];\n dataLayer.push({\n event: category,\n event_action: action,\n event_label: label\n });\n if (window.gtag) window.gtag('event', category, {\n Action: action,\n Label: label\n });\n if (window.ga && window.ga.getAll) {\n const allTrackers = window.ga.getAll() || [];\n allTrackers.forEach(function (tracker) {\n const name = tracker.get('name');\n window.ga(name + '.send', 'event', category, action, label);\n });\n }\n}\nfunction sendEventToThirdParty(category, action, label) {\n document.dispatchEvent(new CustomEvent('subiz', {\n detail: {\n category,\n action,\n label\n }\n }));\n sendToGA(category, action, label);\n sendToFBPixel(category, action, label);\n}\nlet cleanLocalStorage = () => {\n try {\n localStorage;\n } catch (e) {\n return;\n }\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(() => {\n for (var key in localStorage) {\n if (key && (key.startsWith('cbz2020') || key.startsWith('sbz2020'))) {\n localStorage.removeItem(key);\n memlocalStorage.removeItem(key);\n }\n }\n });\n};\nlet cleanMyLocalStorage = () => {\n try {\n localStorage;\n } catch (e) {\n return;\n }\n _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].setTimeout(() => {\n for (var key in localStorage) {\n if (key && (key.startsWith('cbz2020') || key.startsWith('sbz2020') || key.startsWith('sbz2022') || key.startsWith('sbz2023'))) {\n localStorage.removeItem(key);\n memlocalStorage.removeItem(key);\n }\n }\n });\n};\nfunction dofetch(method, url, body, cb) {\n let headers = {};\n if (body) headers['content-type'] = 'text/plain';\n fetch(url, {\n method: method,\n headers: headers,\n body: body\n }).then(res => res.text().then(text => cb && cb(text, res.status))).catch(err => cb && cb(err, -1));\n}\nvar xhrsend = function (method, url, body, cb) {\n if (typeof _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].XMLHttpRequest === 'undefined') return dofetch(method, url, body, cb);\n var request = new _util_index_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].XMLHttpRequest();\n request.onreadystatechange = function (e) {\n if (request.readyState !== 4) return;\n cb && cb(request.responseText, request.status);\n cb = undefined;\n };\n request.onerror = function () {\n cb && cb(request.responseText, -1);\n cb = undefined;\n };\n request.open(method, url);\n if (body) request.setRequestHeader('content-type', 'text/plain');\n request.send(body);\n};\nconst dieErr = new Error('sdk unloaded');\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/store/store.js?\n}");
|
|
284
|
+
|
|
285
|
+
/***/ },
|
|
286
|
+
|
|
287
|
+
/***/ "./src/util/campaign.js"
|
|
288
|
+
/*!******************************!*\
|
|
289
|
+
!*** ./src/util/campaign.js ***!
|
|
290
|
+
\******************************/
|
|
291
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
292
|
+
|
|
293
|
+
"use strict";
|
|
294
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ trackAreaClicked: () => (/* binding */ trackAreaClicked),\n/* harmony export */ trackExitIntent: () => (/* binding */ trackExitIntent),\n/* harmony export */ trackInactivity: () => (/* binding */ trackInactivity),\n/* harmony export */ trackScrollingPercentage: () => (/* binding */ trackScrollingPercentage),\n/* harmony export */ trackTimeOnPage: () => (/* binding */ trackTimeOnPage)\n/* harmony export */ });\nvar common = __webpack_require__(/*! ./common.js */ \"./src/util/common.js\");\nfunction trackExitIntent(cb) {\n let handler = e => {\n if (e.clientY > 10) return;\n if (cb) cb();\n document.removeEventListener('mouseout', handler);\n };\n document.addEventListener('mouseout', handler);\n}\nfunction trackScrollingPercentage(percent, cb) {\n let handleScroll = e => {\n let scrollTop = e.srcElement.scrollingElement ? e.srcElement.scrollingElement.scrollTop : e.srcElement.scrollTop;\n let scrollHeight = e.srcElement.scrollingElement ? e.srcElement.scrollingElement.scrollHeight : e.srcElement.scrollHeight;\n if (scrollTop > 0 && scrollHeight > 0 && (scrollTop + window.innerHeight) / scrollHeight >= percent) {\n if (cb) cb();\n window.removeEventListener('scroll', handleScroll, false);\n }\n };\n window.addEventListener('scroll', handleScroll, false);\n}\nfunction trackAreaClicked(selector, cb) {\n if (!selector) return;\n selector = selector || '';\n common.map(selector.split('\\n'), selector => {\n selector = common.trim(selector);\n if (!selector) return;\n on('click', selector, cb);\n });\n}\nfunction trackInactivity(seconds = 0, cb) {\n let events = ['scroll', 'keyup', 'keydown', 'mousemove', 'mousewheel', 'mouseenter', 'mouseover', 'mousedown', 'touchstart', 'touchmove', 'touchenter'];\n let inactiveSeconds = 0;\n let resetTime = () => {\n inactiveSeconds = 0;\n };\n let timer = common.setInterval(() => {\n inactiveSeconds++;\n if (inactiveSeconds < seconds) return;\n if (cb) cb();\n for (let ev of events) {\n document.removeEventListener(ev, resetTime, false);\n }\n common.clearInterval(timer);\n }, 1000);\n for (let ev of events) {\n document.addEventListener(ev, resetTime, false);\n }\n}\nlet _pageLoaded = common.Date.now();\nfunction trackTimeOnPage(seconds = 0, cb) {\n if (seconds < 1) {\n return common.setTimeout(function () {\n cb(seconds);\n }, 100);\n }\n let timer = common.setInterval(() => {\n let timeOnPage = (common.Date.now() - _pageLoaded) / 1000;\n if (timeOnPage < seconds) return;\n if (cb) cb(timeOnPage);\n common.clearInterval(timer);\n }, 200);\n}\nfunction on(eventName, selector, fn) {\n document.addEventListener(eventName, function (event) {\n let possibleTargets = document.querySelectorAll(selector);\n let target = event.target;\n for (let i = 0, l = possibleTargets.length; i < l; i++) {\n let el = target;\n let p = possibleTargets[i];\n while (el && el !== document) {\n if (el === p) {\n return fn.call(p, event);\n }\n el = el.parentNode;\n }\n }\n });\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/util/campaign.js?\n}");
|
|
295
|
+
|
|
296
|
+
/***/ },
|
|
297
|
+
|
|
298
|
+
/***/ "./src/util/common.js"
|
|
299
|
+
/*!****************************!*\
|
|
300
|
+
!*** ./src/util/common.js ***!
|
|
301
|
+
\****************************/
|
|
302
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
303
|
+
|
|
304
|
+
"use strict";
|
|
305
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DEFVAL: () => (/* binding */ DEFVAL),\n/* harmony export */ DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL: () => (/* binding */ DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL),\n/* harmony export */ Date: () => (/* binding */ Date),\n/* harmony export */ XMLHttpRequest: () => (/* binding */ XMLHttpRequest),\n/* harmony export */ agentsOfConvo: () => (/* binding */ agentsOfConvo),\n/* harmony export */ blockToText: () => (/* binding */ blockToText),\n/* harmony export */ checkRunConditions: () => (/* binding */ checkRunConditions),\n/* harmony export */ checkUrlCondition: () => (/* binding */ checkUrlCondition),\n/* harmony export */ clearInterval: () => (/* binding */ clearInterval),\n/* harmony export */ clearTimeout: () => (/* binding */ clearTimeout),\n/* harmony export */ cloneDeep: () => (/* binding */ cloneDeep),\n/* harmony export */ convoOfEv: () => (/* binding */ convoOfEv),\n/* harmony export */ convoToEv: () => (/* binding */ convoToEv),\n/* harmony export */ detectLang: () => (/* binding */ detectLang),\n/* harmony export */ diffDay: () => (/* binding */ diffDay),\n/* harmony export */ diffYear: () => (/* binding */ diffYear),\n/* harmony export */ each: () => (/* binding */ each),\n/* harmony export */ extract: () => (/* binding */ extract),\n/* harmony export */ extractEmails: () => (/* binding */ extractEmails),\n/* harmony export */ extractEmojis: () => (/* binding */ extractEmojis),\n/* harmony export */ extractLinks: () => (/* binding */ extractLinks),\n/* harmony export */ extractPhones: () => (/* binding */ extractPhones),\n/* harmony export */ extractText: () => (/* binding */ extractText),\n/* harmony export */ filter: () => (/* binding */ filter),\n/* harmony export */ find: () => (/* binding */ find),\n/* harmony export */ formatCurrency: () => (/* binding */ formatCurrency),\n/* harmony export */ getAgentDisplayName: () => (/* binding */ getAgentDisplayName),\n/* harmony export */ getDayName: () => (/* binding */ getDayName),\n/* harmony export */ getMs: () => (/* binding */ getMs),\n/* harmony export */ getUrlParameter: () => (/* binding */ getUrlParameter),\n/* harmony export */ getUserAttr: () => (/* binding */ getUserAttr),\n/* harmony export */ hslToRgb: () => (/* binding */ hslToRgb),\n/* harmony export */ includes: () => (/* binding */ includes),\n/* harmony export */ isBlockEmpty: () => (/* binding */ isBlockEmpty),\n/* harmony export */ isConvoSeen: () => (/* binding */ isConvoSeen),\n/* harmony export */ isEmail: () => (/* binding */ isEmail),\n/* harmony export */ isEmptyBlock: () => (/* binding */ isEmptyBlock),\n/* harmony export */ isEmptyMessage: () => (/* binding */ isEmptyMessage),\n/* harmony export */ isNumber: () => (/* binding */ isNumber),\n/* harmony export */ isPhone: () => (/* binding */ isPhone),\n/* harmony export */ isURL: () => (/* binding */ isURL),\n/* harmony export */ isUserBanned: () => (/* binding */ isUserBanned),\n/* harmony export */ js2css: () => (/* binding */ js2css),\n/* harmony export */ last: () => (/* binding */ last),\n/* harmony export */ map: () => (/* binding */ map),\n/* harmony export */ merge: () => (/* binding */ merge),\n/* harmony export */ noop: () => (/* binding */ noop),\n/* harmony export */ norm: () => (/* binding */ norm),\n/* harmony export */ offsetToMin: () => (/* binding */ offsetToMin),\n/* harmony export */ orderBy: () => (/* binding */ orderBy),\n/* harmony export */ orderByF: () => (/* binding */ orderByF),\n/* harmony export */ parseJSON: () => (/* binding */ parseJSON),\n/* harmony export */ pipeExtracts: () => (/* binding */ pipeExtracts),\n/* harmony export */ preloadImg: () => (/* binding */ preloadImg),\n/* harmony export */ preloadWebfonts: () => (/* binding */ preloadWebfonts),\n/* harmony export */ randomString: () => (/* binding */ randomString),\n/* harmony export */ replaceAll: () => (/* binding */ replaceAll),\n/* harmony export */ replaceCssVariable: () => (/* binding */ replaceCssVariable),\n/* harmony export */ replaceCssVariablePlugin: () => (/* binding */ replaceCssVariablePlugin),\n/* harmony export */ requestAnimationFrame: () => (/* binding */ requestAnimationFrame),\n/* harmony export */ rgbToHsl: () => (/* binding */ rgbToHsl),\n/* harmony export */ sameDay: () => (/* binding */ sameDay),\n/* harmony export */ scrollIntoViewIfNeeded: () => (/* binding */ scrollIntoViewIfNeeded),\n/* harmony export */ setCss: () => (/* binding */ setCss),\n/* harmony export */ setInterval: () => (/* binding */ setInterval),\n/* harmony export */ setTimeout: () => (/* binding */ setTimeout),\n/* harmony export */ setUserAttr: () => (/* binding */ setUserAttr),\n/* harmony export */ shortTime: () => (/* binding */ shortTime),\n/* harmony export */ size: () => (/* binding */ size),\n/* harmony export */ sleep: () => (/* binding */ sleep),\n/* harmony export */ startsWith: () => (/* binding */ startsWith),\n/* harmony export */ stringify: () => (/* binding */ stringify),\n/* harmony export */ throttle: () => (/* binding */ throttle),\n/* harmony export */ tokenize: () => (/* binding */ tokenize),\n/* harmony export */ trim: () => (/* binding */ trim),\n/* harmony export */ trimStart: () => (/* binding */ trimStart),\n/* harmony export */ unicodeToAscii: () => (/* binding */ unicodeToAscii),\n/* harmony export */ unixSec: () => (/* binding */ unixSec),\n/* harmony export */ usersOfConvo: () => (/* binding */ usersOfConvo)\n/* harmony export */ });\nvar op = __webpack_require__(/*! ./op.js */ \"./src/util/op.js\");\nconst ajax = __webpack_require__(/*! @subiz/ajax/src/ajax.js */ \"./node_modules/@subiz/ajax/src/ajax.js\");\nfunction rgbToHsl(r, g, b) {\n ;\n r /= 255, g /= 255, b /= 255;\n var max = Math.max(r, g, b),\n min = Math.min(r, g, b);\n var h,\n s,\n l = (max + min) / 2;\n if (max == min) {\n h = s = 0;\n } else {\n var d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n return [h, s, l];\n}\nfunction hslToRgb(h, s, l) {\n var r, g, b;\n if (s == 0) {\n r = g = b = l;\n } else {\n function hue2rgb(p, q, t) {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n }\n var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n var p = 2 * l - q;\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n return [r * 255, g * 255, b * 255];\n}\nfunction extractEmojis(text) {\n var out = [];\n for (var i = 0; i < text.length; i++) {\n for (var e = 0; e < emojis.length; e++) {\n if (text.indexOf(emojis[e], i) !== i) continue;\n out.push({\n index: i,\n length: emojis[e].length\n });\n i += emojis[e].length - 1;\n break;\n }\n }\n return out;\n}\nfunction extractLinks(text) {\n text = text || '';\n var reg = /(https?:\\/\\/)?(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z()]{2,6}\\b([-a-zA-Z0-9@:%_\\+.,~#?&//=]*)/gim;\n var out = [];\n var match;\n while (match = reg.exec(text)) {\n const MINIMUM_URL_CHARS = 5;\n if (reg.lastIndex - match.index > MINIMUM_URL_CHARS + 1) {\n out.push({\n index: match.index,\n length: reg.lastIndex - match.index\n });\n }\n }\n return out;\n}\nfunction extractEmails(text) {\n text = text || '';\n var reg = /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/gim;\n var out = [];\n var match;\n while (match = reg.exec(text)) {\n out.push({\n index: match.index,\n length: reg.lastIndex - match.index\n });\n }\n return out;\n}\nfunction extractPhones(msg) {\n msg = msg || '';\n var fgmsg = '';\n var realchmap = {};\n for (var i = 0; i < msg.length; i++) {\n var ch = msg.charAt(i);\n if (ch !== '.' && ch !== '-' && ch !== ' ') {\n fgmsg += ch;\n realchmap[fgmsg.length - 1] = i;\n continue;\n }\n var prevCh = i > 0 ? msg.charAt(i - 1) : '-';\n var nextCh = i < msg.length - 1 ? msg.charAt(i + 1) : '-';\n if ('0123456789'.indexOf(prevCh) !== -1 && '0123456789'.indexOf(nextCh) !== -1) continue;\n fgmsg += ch;\n realchmap[fgmsg.length - 1] = i;\n }\n var reg = /([0-9]{8,13})/gim;\n var out = [];\n var match;\n while (match = reg.exec(fgmsg)) {\n out.push({\n index: realchmap[match.index],\n length: realchmap[reg.lastIndex - 1] - realchmap[match.index] + 1\n });\n }\n return out;\n}\nfunction extract(text, extractor, type) {\n if (!text) return [];\n var out = [];\n var lastindex = 0;\n var tags = extractor(text);\n if (size(tags) === 0) return [{\n type: 'text',\n text\n }];\n each(tags, tag => {\n out.push({\n type: 'text',\n text: text.substr(lastindex, tag.index - lastindex)\n });\n out.push({\n type,\n text: text.substr(tag.index, tag.length)\n });\n lastindex = tag.index + tag.length;\n });\n var lastTag = last(tags);\n out.push({\n type: 'text',\n text: text.substr(lastTag.index + lastTag.length, text.length - lastTag.index + lastTag.length)\n });\n return filter(out, o => o.text !== '');\n}\nfunction pipeExtracts(text, extractors) {\n var out = [];\n if (size(extractors) === 0) return [{\n type: 'text',\n text\n }];\n var ext = extractors.shift();\n var tags = extract(text, ext, ext.type);\n each(tags, t => {\n if (t.type !== 'text') return out.push(t);\n out = out.concat(pipeExtracts(t.text, extractors.slice()));\n });\n return out;\n}\nfunction extractText(text) {\n var link = extractLinks;\n link.type = 'link';\n var email = extractEmails;\n email.type = 'email';\n var phone = extractPhones;\n phone.type = 'phone';\n var emoji = extractEmojis;\n emoji.type = 'emoji';\n return pipeExtracts(text, [link, email, phone, emoji]);\n}\nfunction parseJSON(str) {\n try {\n return parse(str);\n } catch (e) {}\n}\nvar f = document.createElement('iframe');\nf.style.display = 'none';\ndocument.documentElement.appendChild(f);\nconst tempElement = f.contentDocument.createElement('div');\nf.contentDocument.body.appendChild(tempElement);\nvar stringify = f.contentWindow.JSON.stringify;\nvar parse = f.contentWindow.JSON.parse;\nvar Date = f.contentWindow.Date;\nvar requestAnimationFrame = f.contentWindow.requestAnimationFrame;\nvar setTimeout = f.contentWindow.setTimeout.bind(f.contentWindow);\nvar setInterval = f.contentWindow.setInterval.bind(f.contentWindow);\nvar clearInterval = f.contentWindow.clearInterval.bind(f.contentWindow);\nvar clearTimeout = f.contentWindow.clearTimeout.bind(f.contentWindow);\nvar XMLHttpRequest = f.contentWindow.XMLHttpRequest;\nconst _originalOpen = XMLHttpRequest.prototype.open;\nconst _originalSend = XMLHttpRequest.prototype.send;\nXMLHttpRequest.prototype.open = function (method, url, async, user, password) {\n this._url = url;\n return _originalOpen.apply(this, arguments);\n};\nXMLHttpRequest.prototype.send = function (body) {\n let old = this.onreadystatechange;\n this.onreadystatechange = function (a, b, c) {\n if (this.readyState != 4) return;\n if (this.status >= 400 || this.status == 0) {\n if (typeof sbz_logs == 'object') sbz_logs.push({\n type: 'xhrfailed',\n url: this._url,\n status: this.status,\n response: this.responseText\n });\n }\n if (typeof old == 'function') old(a, b, c);\n };\n return _originalSend.apply(this, arguments);\n};\najax.env.XMLHttpRequest = XMLHttpRequest;\nfunction convoOfEv(ev) {\n if (!ev) return '';\n return op.get(ev, 'data.conversation.id', op.get(ev, 'data.message.conversation_id'));\n}\nfunction convoToEv(convoid, ev) {\n if (!ev) return '';\n switch (ev.type) {\n case 'message_sent':\n case 'message_updated':\n case 'message_deleted':\n case 'message_pong':\n return op.set(ev, 'data.message.conversation_id', convoid);\n case 'ticket_updated':\n return op.set(ev, 'data.ticket.conversation_id', convoid);\n default:\n return op.set(ev, 'data.conversation.id', convoid);\n }\n}\nfunction isObject(item) {\n return item && typeof item === 'object' && !Array.isArray(item);\n}\nfunction merge(target, ...sources) {\n if (!sources.length) return target;\n const source = sources.shift();\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, {\n [key]: {}\n });\n merge(target[key], source[key]);\n } else {\n Object.assign(target, {\n [key]: source[key]\n });\n }\n }\n }\n return merge(target, ...sources);\n}\nfunction cloneDeep(p) {\n if (p !== Object(p)) return p;\n var s = stringify(p);\n if (s === undefined) return;\n return parse(s);\n}\nfunction randomString(len) {\n var str = '';\n if (!len || len < 1) len = 10;\n var asciiKey;\n for (var i = 0; i < len; i++) {\n asciiKey = Math.floor(Math.random() * 25 + 97);\n str += String.fromCharCode(asciiKey);\n }\n return str;\n}\nfunction filter(collection, predicate) {\n if (!collection) return [];\n if (!predicate) return collection;\n var out = [];\n if (typeof collection === 'object') {\n var keys = Object.keys(collection);\n for (let i = 0; i < keys.length; i++) {\n var k = keys[i];\n if (predicate(collection[k], k)) out.push(collection[k]);\n }\n return out;\n }\n if (Array.isArray(collection)) {\n for (let i = 0; i < collection.length; i++) {\n if (predicate(collection[i], i)) out.push(collection[i]);\n }\n return out;\n }\n return out;\n}\nfunction includes(collection, value) {\n if (!collection) return false;\n var isString = typeof collection === 'string' || collection instanceof String;\n if (Array.isArray(collection) || isString) return collection.includes(value);\n return false;\n}\nfunction map(collection, predicate) {\n if (!collection) return [];\n if (!predicate) predicate = i => i;\n var out = [];\n if (typeof collection === 'object') {\n var keys = Object.keys(collection);\n for (let i = 0; i < keys.length; i++) {\n var k = keys[i];\n out.push(predicate(collection[k], k));\n }\n return out;\n }\n if (Array.isArray(collection)) {\n for (let i = 0; i < collection.length; i++) {\n out.push(predicate(collection[i], i));\n }\n return out;\n }\n return out;\n}\nfunction each(collection, predicate) {\n return map(collection, predicate);\n}\nfunction usersOfConvo(convo) {\n if (!convo) return [];\n return map(filter(convo.members, m => m.type === 'user'), m => m.id);\n}\nfunction isConvoSeen(convo, memberid) {\n if (convo.state === 'ended') return true;\n let lastmsgsent = convo.last_message_sent;\n if (!lastmsgsent) return true;\n if (op.get(lastmsgsent, 'by.id') === memberid) return true;\n let mem = find(convo.members, m => m.id === memberid);\n if (!mem) return true;\n return getMs(lastmsgsent.created) < getMs(mem.seen_at);\n}\nfunction agentsOfConvo(convo, botIncluded) {\n if (!convo) return [];\n return map(filter(convo.members, m => {\n if (botIncluded) return m.type === 'agent' || m.type === 'bot';\n return m.type === 'agent';\n }), m => m.id);\n}\nfunction startsWith(s, i) {\n return ((s || '') + '').startsWith(i);\n}\nfunction size(o) {\n if (!o) return 0;\n if (o.length !== undefined) return o.length;\n return Object.keys(o).length;\n}\nfunction replaceAll(str, a, b) {\n return (str || '').split(a).join(b);\n}\nfunction trim(s, suffix) {\n return ((s || '') + '').replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, '');\n}\nfunction trimStart(s, prefix) {\n s = (s || '') + '';\n while (s.charAt(0) === prefix) s = s.substr(1);\n return s;\n}\nfunction throttle(func, wait, options) {\n var context, args, result;\n var timeout = null;\n var previous = 0;\n if (!options) options = {};\n var later = function () {\n previous = options.leading === false ? 0 : new Date().getTime();\n timeout = null;\n result = func.apply(context, args);\n if (!timeout) context = args = null;\n };\n return function () {\n var now = new Date().getTime();\n if (!previous && options.leading === false) previous = now;\n var remaining = wait - (now - previous);\n context = this;\n args = arguments;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n result = func.apply(context, args);\n if (!timeout) context = args = null;\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining);\n }\n return result;\n };\n}\nfunction find(collection, f) {\n if (!collection) return undefined;\n return collection[findIndex(collection, f)];\n}\nfunction findIndex(collection, f) {\n if (!collection) return -1;\n if (!f) return -1;\n if (typeof collection === 'object') {\n var keys = Object.keys(collection);\n for (let i = 0; i < keys.length; i++) {\n var k = keys[i];\n if (f(collection[k], k)) return k;\n }\n }\n if (Array.isArray(collection)) {\n for (let i = 0; i < collection.length; i++) {\n if (f(collection[i], i)) return i;\n }\n return -1;\n }\n return -1;\n}\nfunction orderBy(a, k, d) {\n var clone = [];\n each(a, v => clone.push(v));\n clone.sort((i, j) => {\n if (i[k] === j[k]) return 0;\n var r = i[k] < j[k] ? -1 : 1;\n return d === 'desc' ? -r : r;\n });\n return clone;\n}\nfunction orderByF(a, f, d) {\n var clone = [];\n each(a, v => clone.push(v));\n clone.sort((i, j) => {\n let ik = f(i);\n let jk = f(j);\n if (ik === jk) return 0;\n var r = ik < jk ? -1 : 1;\n return d === 'desc' ? -r : r;\n });\n return clone;\n}\nfunction isPhone(phone) {\n var re = /^[\\+]?[(]?[0-9]{2,3}[)]?[-\\s\\.]?[0-9]{3,4}[-\\s\\.]?[0-9]{4,6}$/im;\n return re.test(String(phone));\n}\nfunction isURL(url) {\n var re = /[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)/gi;\n return re.test(String(url).toLowerCase());\n}\nfunction isNumber(num) {\n var re = /^\\d+$/;\n return re.test(String(num));\n}\nfunction isEmail(email) {\n const re = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n return re.test(String(email).toLowerCase());\n}\nfunction last(array) {\n var length = array == null ? 0 : array.length;\n return length ? array[length - 1] : undefined;\n}\nfunction getAgentDisplayName(account, agent) {\n return op.get(agent, 'fullname') || op.get(agent, 'email') || op.get(account, 'name') || 'Agent';\n}\nfunction isUserBanned(user) {\n return getUserAttr(user, 'is_ban', 'boolean');\n}\nfunction setUserAttr(user, attr) {\n if (!user) return;\n if (!op.get(attr, 'key')) return;\n user.attributes = user.attributes || [];\n var index = findIndex(user.attributes, a => a && a.key === attr.key);\n if (index === -1) {\n user.attributes.push(attr);\n return;\n }\n user.attributes[index] = attr;\n}\nfunction getUserAttr(user, key, type) {\n if (!user || !user.attributes) return;\n let value;\n each(user.attributes, attr => {\n if (!attr || attr.key !== key) return;\n if (type === 'datetime') value = attr.datetime;\n if (type === 'boolean') value = attr.boolean;\n if (type === 'number') value = attr.number;\n if (type === 'text') value = attr.text;\n if (type === 'list') {\n value = [attr.text].concat(attr.other_values);\n }\n });\n return value;\n}\nfunction norm(s) {\n s = s || '';\n return s.trim().toLowerCase();\n}\nfunction noop() {}\nfunction norm2(val) {\n if (typeof val === 'string' || val instanceof String) val = val.trim().replace(/;+$/, '');\n return val;\n}\nfunction replaceCssVariablePlugin(css, setting) {\n var tokens = [css];\n let spacer = setting.spacer || 10;\n setting = Object.assign({}, setting, {\n spacer: spacer + 'px',\n spacer0: spacer / 2 + 'px',\n spacer2: 2 * spacer + 'px',\n spacer3: 3 * spacer + 'px'\n });\n tokens = tokenize(tokens, \"'@font_family'\");\n tokens = tokenize(tokens, \"'@font_size'\");\n tokens = tokenize(tokens, \"'@text_color'\");\n tokens = tokenize(tokens, \"'@faded_text_color'\");\n tokens = tokenize(tokens, \"'@primary_color'\");\n tokens = tokenize(tokens, \"'@background'\");\n tokens = tokenize(tokens, \"'@spacer'\");\n tokens = tokenize(tokens, \"'@spacer0'\");\n tokens = tokenize(tokens, \"'@spacer2'\");\n tokens = tokenize(tokens, \"'@spacer3'\");\n var primary_color = op.get(setting, 'primary_color') || op.get(DEFVAL, 'primary_color');\n let parseColor = parseCssColor(primary_color);\n if (!parseColor) parseColor = {\n red: 238,\n blue: 238,\n green: 238\n };\n let hue = rgbToHsl(parseColor.red, parseColor.green, parseColor.blue)[0];\n let [r, g, b] = hslToRgb(hue, 0.25, 0.95);\n DEFVAL.primary_color_faded = `rgb(${r},${g},${b})`;\n var ret = [];\n for (var i = 0; i < tokens.length; i++) {\n var item = tokens[i];\n if (typeof item === 'string') {\n ret.push(item);\n continue;\n }\n var path = item.type.substr(2, item.type.length - 3);\n var val = op.get(setting, path) || op.get(DEFVAL, path) || '';\n ret.push(val);\n }\n return ret.join('');\n}\nfunction replaceCssVariable(css, setting) {\n var tokens = [css];\n tokens = tokenize(tokens, \"'@primary_color'\");\n tokens = tokenize(tokens, \"'@primary_color_faded'\");\n tokens = tokenize(tokens, '@esc-primary-color-esc');\n tokens = tokenize(tokens, \"'@secondary_color'\");\n tokens = tokenize(tokens, \"'@background'\");\n tokens = tokenize(tokens, \"'@text_color'\");\n tokens = tokenize(tokens, \"'@width'\");\n tokens = tokenize(tokens, \"'@height'\");\n tokens = tokenize(tokens, \"'@desktop_button.width'\");\n tokens = tokenize(tokens, \"'@desktop_button.height'\");\n tokens = tokenize(tokens, \"'@desktop_button.background'\");\n tokens = tokenize(tokens, \"'@desktop_button.border_radius'\");\n tokens = tokenize(tokens, \"'@desktop_button.margin_x'\");\n tokens = tokenize(tokens, \"'@desktop_button.margin_y'\");\n tokens = tokenize(tokens, \"'@desktop_widget_max_height'\");\n tokens = tokenize(tokens, \"'@preview_max_width'\");\n tokens = tokenize(tokens, \"'@mobile_button.width'\");\n tokens = tokenize(tokens, \"'@mobile_button.height'\");\n tokens = tokenize(tokens, \"'@mobile_button.background'\");\n tokens = tokenize(tokens, \"'@mobile_button.border_radius'\");\n tokens = tokenize(tokens, \"'@mobile_button.margin_x'\");\n tokens = tokenize(tokens, \"'@mobile_button.margin_y'\");\n tokens = tokenize(tokens, \"'@widget_position'\");\n tokens = tokenize(tokens, \"'@z_index'\");\n tokens = tokenize(tokens, \"'@z_index_2'\");\n tokens = tokenize(tokens, \"'@z_index_3'\");\n tokens = tokenize(tokens, \"'@z_index_4'\");\n tokens = tokenize(tokens, \"'@z_index_5'\");\n tokens = tokenize(tokens, \"'@form_background_color'\");\n tokens = tokenize(tokens, \"'@form_header_font_size'\");\n tokens = tokenize(tokens, \"'@form_header_font_family'\");\n tokens = tokenize(tokens, \"'@form_desc_font_size'\");\n tokens = tokenize(tokens, \"'@form_desc_font_family'\");\n tokens = tokenize(tokens, \"'@form_input_label_font_size'\");\n tokens = tokenize(tokens, \"'@form_input_label_font_family'\");\n var primary_color = op.get(setting, 'primary_color') || op.get(DEFVAL, 'primary_color');\n let parseColor = parseCssColor(primary_color);\n if (!parseColor) parseColor = {\n red: 238,\n blue: 238,\n green: 238\n };\n let hue = rgbToHsl(parseColor.red, parseColor.green, parseColor.blue)[0];\n let [r, g, b] = hslToRgb(hue, 0.25, 0.95);\n DEFVAL.primary_color_faded = `rgb(${r},${g},${b})`;\n var ret = [];\n for (var i = 0; i < tokens.length; i++) {\n var item = tokens[i];\n if (typeof item === 'string') {\n ret.push(item);\n continue;\n }\n if (item.type === '@esc-primary-color-esc') {\n var val = op.get(setting, 'primary_color') || op.get(DEFVAL, 'primary_color');\n ret.push(encodeURIComponent(norm2(val)));\n continue;\n }\n if (item.type === \"'@z_index_2'\") {\n var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');\n ret.push(val + 2);\n continue;\n }\n if (item.type === \"'@z_index_3'\") {\n var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');\n ret.push(val + 3);\n continue;\n }\n if (item.type === \"'@z_index_4'\") {\n var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');\n ret.push(val + 4);\n continue;\n }\n if (item.type === \"'@z_index_5'\") {\n var val = op.get(setting, 'z_index') || op.get(DEFVAL, 'z_index');\n ret.push(val + 5);\n continue;\n }\n var path = item.type.substr(2, item.type.length - 3);\n var val = op.get(setting, path) || op.get(DEFVAL, path) || '';\n val = norm2(val);\n if (['mobile_button.width', 'mobile_button.height', 'mobile_button.margin_x', 'mobile_button.margin_y', 'desktop_button.width', 'desktop_button.height', 'desktop_button.margin_x', 'desktop_button.margin_y', 'form_header_font_size', 'form_desc_font_size', 'form_input_label_font_size', 'width', 'height'].includes(path)) {\n val += 'px';\n }\n if (path === 'height' && op.get(setting, 'window_mode') === 'full') {\n ret.push('100%');\n continue;\n }\n ret.push(val);\n }\n return ret.join('');\n}\nfunction tokenize(arr, token) {\n if (!arr || !arr.length) return [];\n var out = [];\n for (let i = 0; i < arr.length; i++) {\n var item = arr[i];\n if (typeof item !== 'string') {\n out.push(item);\n continue;\n }\n var ts = item.split(token);\n for (let i = 0; i < ts.length; i++) {\n out.push(ts[i]);\n out.push({\n type: token\n });\n }\n out.pop();\n }\n return out;\n}\nfunction setCss(id, $css, css) {\n css = replaceAll(css, '#sbz92', '#' + id);\n if ($css.styleSheet) {\n $css.styleSheet.cssText = css;\n } else {\n $css.innerHTML = '';\n $css.appendChild(document.createTextNode(css));\n }\n}\nconst DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL = 'https://vcdn.subiz-cdn.com/file/bubble_11.svg?v=5';\nconst DEFVAL = {\n primary_color: '#0265FF',\n secondary_color: '#555555',\n background: 'linear-gradient(280.16deg, #0053d3 22.03%, #0265ff 78.2%)',\n text_color: 'white',\n width: 375,\n height: 705,\n window_mode: 'mini',\n desktop_button: {\n width: 0.3,\n height: 0.3,\n border_radius: '100%',\n background_mask_url: DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL,\n margin_x: 0.3,\n margin_y: 0.3\n },\n mobile_button: {\n width: 0.3,\n height: 0.3,\n border_radius: '100%',\n background_mask_url: DEF_CHAT_BUTTON_BACKGROUND_IMAGE_URL,\n margin_x: 0.3,\n margin_y: 0.3\n },\n widget_position: 'fixed',\n z_index: 2000000000\n};\nfunction js2css(js, onlyprops, variables) {\n var newjs = {};\n for (var prop in js) {\n if (!js.hasOwnProperty(prop)) continue;\n if (onlyprops && onlyprops.length > 0 && onlyprops.indexOf(prop) === -1) continue;\n if (typeof js[prop] === 'string') newjs[prop] = trim(js[prop]);else newjs[prop] = js[prop];\n }\n js = newjs;\n let style = '';\n for (var prop in js) {\n if (!js.hasOwnProperty(prop)) continue;\n var filter = '';\n if (js.blur) filter += 'blur(' + js.blur + ') ';\n if (js.grayscale) filter += 'grayscale(' + js + ') ';\n if (filter) style += 'filter: ' + filter + '!important;';\n if (js.rotate !== undefined) style += 'transform:rotate(' + js.rotate + ') !important;';\n if (js[prop] !== undefined) {\n let propval = js[prop] + '';\n map(variables, (value, name) => {\n if (propval.indexOf(name) !== -1) propval = replaceAll(propval, name, value);\n });\n style += replaceAll(prop, '_', '-') + ':' + propval + ' !important;';\n if (prop === 'color') style += '-webkit-text-fill-color: ' + propval + ' !important;';\n }\n }\n return style;\n}\nfunction browserName() {\n var isOpera = !!window.opr && !!opr.addons || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;\n var isFirefox = typeof InstallTrigger !== 'undefined';\n var isSafari = /constructor/i.test(window.HTMLElement) || function (p) {\n return p.toString() === '[object SafariRemoteNotification]';\n }(!window['safari'] || typeof safari !== 'undefined' && window['safari'].pushNotification);\n var isIE = false || !!document.documentMode;\n var isEdge = !isIE && !!window.StyleMedia;\n var isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime);\n if (!isChrome) isChrome = navigator.userAgent.indexOf('Chrome');\n var isEdgeChromium = isChrome && navigator.userAgent.indexOf('Edg') != -1;\n var isBlink = (isChrome || isOpera) && !!window.CSS;\n if (isOpera) return 'opera';\n if (isFirefox) return 'firefox';\n if (isIE) return 'ie';\n if (isEdge || isEdgeChromium) return 'edge';\n if (isChrome) return 'chrome';\n if (isBlink) return 'blink';\n return 'unknown';\n}\nfunction check_frequently(freq, lastrun, store) {\n if (!lastrun) return true;\n if (op.get(freq, 'once_per_user')) return false;\n if (op.get(freq, 'once_per_session')) {\n if (sameDay(lastrun.created, Date.now())) return false;\n }\n if (op.get(freq, 'interval_sec')) {\n var sec = op.get(freq, 'interval_sec');\n if (sec > (Date.now() - lastrun.created) / 1000) return false;\n }\n return true;\n}\nfunction checkRunConditions(freq, conds, lastrun, store) {\n var acc = store.matchAccount() || {};\n var location = store.matchLocation() || {};\n if (!check_frequently(freq, lastrun, store)) return false;\n for (let i = 0; i < size(conds); i++) {\n var cond = conds[i];\n switch (cond.key) {\n case 'url':\n if (!checkUrlCondition(cond, window.location.href)) return false;\n break;\n case 'url_path':\n let excludePaths = filter(cond.exclude_url_paths, url => norm(url));\n if (size(excludePaths) > 0) {\n let urlObj = new URL(window.location.href);\n let pathname = urlObj.pathname || '';\n if (typeof pathname === 'string' && pathname.endsWith('/')) {\n pathname = pathname.substring(0, pathname.length - 1);\n }\n let found = find(excludePaths, url => {\n if (typeof url === 'string' && url.endsWith('/')) {\n url = url.substring(0, url.length - 1);\n }\n return pathname === url;\n });\n if (found) return false;\n }\n let paths = filter(cond.url_paths, url => norm(url));\n if (size(paths) > 0) {\n let urlObj = new URL(window.location.href);\n let pathname = urlObj.pathname || '';\n if (typeof pathname === 'string' && pathname.endsWith('/')) {\n pathname = pathname.substring(0, pathname.length - 1);\n }\n let found = find(paths, url => {\n if (typeof url === 'string' && url.endsWith('/')) {\n url = url.substring(0, url.length - 1);\n }\n return pathname === url;\n });\n if (!found) return false;\n }\n break;\n case 'browser':\n if (size(cond.browsers) > 0) {\n var browsername = browserName();\n if (!find(cond.browsers, b => norm(b) === norm(browsername))) return false;\n }\n break;\n case 'location':\n if (size(cond.exclude_locations) > 0) {\n let found = find(cond.exclude_locations, loc => {\n if (loc.city_name && loc.country_code) {\n if (loc.city_name === location.city_name && loc.country_code === location.country_code) return true;\n }\n if (loc.city_name && !loc.country_code) {\n if (loc.city_name === location.city_name) return true;\n }\n if (!loc.city_name && loc.country_code) {\n if (loc.country_code === location.country_code) return true;\n }\n });\n if (found) return false;\n }\n if (size(cond.locations) > 0) {\n let found = find(cond.locations, loc => {\n if (loc.city_name && loc.country_code) {\n if (loc.city_name === location.city_name && loc.country_code === location.country_code) return true;\n }\n if (loc.city_name && !loc.country_code) {\n if (loc.city_name === location.city_name) return true;\n }\n if (!loc.city_name && loc.country_code) {\n if (loc.country_code === location.country_code) return true;\n }\n });\n if (!found) return false;\n }\n break;\n case 'returning_visitor':\n if (cond.returning_visitor) {\n if (store.new_visitor) return false;\n }\n if (!cond.returning_visitor) {\n if (!store.new_visitor) return false;\n }\n break;\n case 'user_is_a_contact':\n let attributes = op.get(store.matchUser(), 'attributes', []);\n let emailAttr = find(attributes, att => att.key === 'emails' && attr.text && att.key === 'related_email' && attr.text);\n let phoneAttr = find(attributes, att => att.key === 'phones' && attr.text && att.key === 'related_phone' && attr.text);\n let hasContact = emailAttr || phoneAttr;\n if (cond.user_is_a_contact) {\n if (!hasContact) return false;\n }\n if (!cond.user_is_a_contact) {\n if (hasContact) return false;\n }\n break;\n case 'device_type':\n if (size(cond.device_types) > 0) {\n let type = 'desktop';\n if (store.isMobile()) type = 'mobile';\n if (store.isTablet()) type = 'tablet';\n if (!find(cond.device_types, t => norm(t) === norm(type))) return false;\n }\n break;\n case 'referer':\n if (size(cond.exclude_referers) > 0) {\n let found = find(cond.exclude_referers, ref => {\n return norm(document.referrer).indexOf(norm(ref)) > -1;\n });\n if (found) return false;\n }\n if (size(cond.urls) > 0) {\n let found = find(cond.referers, ref => {\n return norm(document.referrer).indexOf(norm(ref)) > -1;\n });\n if (!found) return false;\n }\n break;\n case 'source':\n if (size(cond.sources) > 0) {\n let source = store.matchTrafficSource() || 'direct';\n if (!find(cond.sources, src => norm(src) === norm(source))) return false;\n }\n break;\n case 'user_attribute':\n case 'user':\n let userprop;\n let attrs = op.get(store.matchUser(), 'attributes', []);\n let operator = op.get(cond, 'user.operator');\n each(attrs, attr => {\n if (!attr || attr.key !== op.get(cond, 'user.key')) return;\n userprop = attr.datetime || attr.boolean || attr.number || attr.text || attr.list;\n });\n let valid = true;\n switch (operator) {\n case 'cons':\n let vals = parseJSON(cond.value) || [];\n if (size(vals) === 0) return false;\n let found = find(vals, val => {\n return norm(userprop).indexOf(norm(val)) > -1;\n });\n valid = !!found;\n break;\n case 'notEmpty':\n valid = !!userprop;\n break;\n case 'empty':\n valid = !userprop;\n break;\n case 'true':\n valid = userprop === true || userprop === 'true';\n break;\n case 'false':\n valid = !userprop || userprop === false || userprop === 'false';\n break;\n }\n if (!valid) return false;\n break;\n case 'timming':\n if (cond.business_hour === 'in' && !acc.is_in_business_hour) return false;\n if (cond.business_hour === 'notIn' && acc.is_in_business_hour) return false;\n if (size(cond.days_of_week) > 0) {\n let found = find(cond.days_of_week, day => {\n return norm(getDayName(new Date().getDay())) === norm(day);\n });\n if (!found) return false;\n }\n if (size(cond.minutes_of_day) > 0 && size(cond.minutes_of_day) % 2 === 0) {\n var now = new Date();\n var minuteofday = now.getMinutes() + now.getHours() * 60;\n let found = false;\n for (let i = 0; i < cond.minutes_of_day.length; i += 2) {\n if (cond.minutes_of_day[i] <= minuteofday && minuteofday <= cond.minutes_of_day[i + 1]) {\n found = true;\n break;\n }\n if (cond.minutes_of_day[i] > cond.minutes_of_day[i + 1]) {\n if (minuteofday >= cond.minutes_of_day[i] || minuteofday <= cond.minutes_of_day[i + 1]) {\n found = true;\n break;\n }\n }\n }\n if (!found) return false;\n }\n break;\n case 'offline':\n if (!acc.is_online !== !!cond.offline) return false;\n }\n }\n return true;\n}\nfunction getDayName(dayOfWeek) {\n let days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\n return days[dayOfWeek];\n}\nlet loadedFonts = {};\nfunction preloadWebfonts(fonts, done) {\n for (var i = 0; i < fonts.length; i++) {\n let font = fonts[i];\n if (!font) continue;\n if (loadedFonts[font]) continue;\n loadedFonts[font] = true;\n for (var w = 0; w < 2; w++) {\n let weight = [400, 500][w];\n let node = document.createElement('div');\n node.innerHTML = '@!-/#Chào mỪng1';\n node.style.position = 'absolute';\n node.style.display = 'block';\n node.style.opacity = '0.1';\n node.style.color = 'transparent';\n node.style.fontSize = '20px';\n node.style.height = '0px';\n node.style.top = '0px';\n node.style.width = '0px';\n node.style.fontWeight = weight;\n node.setAttribute('subiz-preload', font + ':' + weight);\n document.body.appendChild(node);\n node.style.fontFamily = font;\n setTimeout(() => node.remove(), 3000);\n }\n }\n}\nfunction preloadImg(src, cb) {\n if (!cb) cb = () => {};\n if (!src) {\n cb();\n return Promise.resolve(true);\n }\n let image = new Image();\n src = replaceFileUrl(src);\n image.src = src;\n return new Promise(rs => {\n image.onload = () => {\n cb();\n rs();\n };\n });\n}\nfunction offsetToMin(offset) {\n if (!offset) return 0;\n if (offset.length <= 2) offset += ':00';\n let sp = offset.split(':');\n if (sp.length !== 2) return 0;\n let hour = parseInt(sp[0]);\n if (hour < 0 || hour > 23) return 0;\n let min = parseInt(sp[1]);\n if (min < 0 || min > 59) return 0;\n return hour * 60 + min;\n}\nfunction diffDay(a, b, tzoffset) {\n var offsetmin = -new Date().getTimezoneOffset();\n if (tzoffset) offsetmin = offsetToMin(tzoffset);\n var ams = new Date(a).getTime();\n var bms = new Date(b).getTime();\n var aunixDay = Math.ceil((ams / 60 / 1000 + offsetmin) / 60 / 24);\n var bunixDay = Math.ceil((bms / 60 / 1000 + offsetmin) / 60 / 24);\n return Math.abs(aunixDay - bunixDay);\n}\nfunction diffYear(a, b, tzoffset) {\n var machineoffsetmin = -new Date().getTimezoneOffset();\n var offsetmin = -new Date().getTimezoneOffset();\n if (tzoffset) offsetmin = offsetToMin(tzoffset);\n var ams = new Date(a).getTime();\n var bms = new Date(b).getTime();\n var amsInZone = ams + (offsetmin - machineoffsetmin) * 60 * 1000;\n var bmsInZone = bms + (offsetmin - machineoffsetmin) * 60 * 1000;\n return Math.abs(new Date(amsInZone).getYear() - new Date(bmsInZone).getYear());\n}\nfunction sameDay(a, b, tzoffset) {\n return diffDay(a, b, tzoffset) === 0;\n}\nfunction shortTime(utcms, tzoffset, now, forcelocale) {\n var machineoffsetmin = -new Date().getTimezoneOffset();\n var offsetmin = machineoffsetmin;\n if (tzoffset) offsetmin = offsetToMin(tzoffset);\n var time = new Date(getMs(utcms));\n let tztime = new Date(time);\n tztime.setMinutes(time.getMinutes() + offsetmin - machineoffsetmin);\n if (!now) now = new Date();\n let tzhour = tztime.getHours();\n let tzmin = tztime.getMinutes();\n let locale = op.get(navigator, 'languages.0', 'en-US');\n if (forcelocale) locale = forcelocale;\n let tzdddd = tztime.toLocaleDateString(locale, {\n weekday: 'long'\n });\n let tzyear = tztime.getFullYear();\n let tzmonth = tztime.getMonth() + 1;\n let tzmonthname = tztime.toLocaleDateString(locale, {\n month: 'long'\n });\n let tzdate = tztime.getDate();\n if (tzhour < 10) tzhour = '0' + tzhour;\n if (tzmin < 10) tzmin = '0' + tzmin;\n if (sameDay(time, now, tzoffset)) return tzhour + ':' + tzmin;\n if (diffDay(time, now, tzoffset) <= 5) return tzdddd + ', ' + tzhour + ':' + tzmin;\n if (diffYear(time, now, tzoffset) === 0) {\n if (locale === 'vi-VN') {\n return tzdate + ' ' + tzmonthname + ', ' + tzhour + ':' + tzmin;\n }\n return tzmonthname + ' ' + tzdate + ', ' + tzhour + ':' + tzmin;\n }\n if (locale === 'vi-VN') {\n return tzdate + '/' + tzmonth + '/' + tzyear + ', ' + tzhour + ':' + tzmin;\n }\n return tzyear + '/' + tzmonth + '/' + tzdate + ', ' + tzhour + ':' + tzmin;\n}\nfunction unixSec(t) {\n return Math.floor(getMs(t) / 1000);\n}\nfunction getMs(t) {\n if (!t) t = 0;else if (typeof t !== 'number') t = new Date(t).getTime();\n if (t > 1e18) {\n return Math.floor(t / 1e6);\n }\n if (t > 1e15) {\n return Math.floor(t / 1e3);\n }\n if (t > 1e12) {\n return t;\n }\n return t * 1e3;\n}\nfunction detectLang() {\n let urllang = getUrlParameter('sbz_locale');\n let doclang = document.getElementsByTagName('html')[0].getAttribute('xml:lang') || document.getElementsByTagName('html')[0].getAttribute('lang');\n let browserlang = navigator.language;\n return urllang || doclang || browserlang;\n}\nfunction getUrlParameter(name) {\n name = name.replace(/[\\[]/, '\\\\[').replace(/[\\]]/, '\\\\]');\n var regex = new RegExp('[\\\\?&]' + name + '=([^&#]*)');\n var results = regex.exec(location.search);\n return results === null ? '' : decodeURIComponent(results[1].replace(/\\+/g, ' '));\n}\nvar sleep = ms => new Promise(res => setTimeout(res, ms));\nfunction formatCurrency(val, currency = 'VND') {\n let currencyObj = ALL_CURRENCIES.find(cur => cur.code === currency) || {\n name: 'Dong',\n code: 'VND',\n symbol: '₫'\n };\n let prefix = '';\n let suffix = '';\n if (currency === 'VND') {\n prefix = '';\n suffix = ' ' + currencyObj.symbol;\n } else {\n prefix = currencyObj.symbol + ' ';\n suffix = '';\n }\n if (!val) return `${prefix}0${suffix}`;\n val = Math.round(val);\n return prefix + val.toString().replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1,') + suffix;\n}\nfunction replaceFileUrl(src) {\n let fileurl = 'https://vcdn.subiz-cdn.com/file/';\n if (!src) return '';\n if (startsWith(src, '/')) return src;\n if (startsWith(src, 'data:')) return src;\n if (!startsWith(src, 'http://') && !startsWith(src, 'https://') && !startsWith(src, '//')) {\n src = trim(fileurl, '/') + '/' + trimStart(src, '/');\n }\n src = src.replace('https://file-subiz.com/', fileurl);\n src = src.replace('http://file-subiz.com/', fileurl);\n src = src.replace('https://file-v4.subiz.com/', fileurl);\n src = src.replace('http://file-v4.subiz.com/', fileurl);\n src = src.replace('https://filev4.subiz.com/', fileurl);\n src = src.replace('http://filev4.subiz.com/', fileurl);\n src = src.replace('https://filev4-1.subiz.com/', fileurl);\n src = src.replace('http://filev4-1.subiz.com/', fileurl);\n src = src.replace('https://file.subiz.com/', fileurl);\n src = src.replace('http://file.subiz.com/', fileurl);\n src = src.replace('https://file.mysubiz.com/', fileurl);\n src = src.replace('http://file.mysubiz.com/', fileurl);\n return src;\n}\nfunction unicodeToAscii(str) {\n str = str + '';\n str = str.replaceAll('đ', 'd').replaceAll('Đ', 'D');\n return str.normalize('NFD').replace(/[\\u0300-\\u036f]/g, '');\n}\nfunction scrollIntoViewIfNeeded($ele) {\n centerIfNeeded = arguments.length === 0 ? true : !!centerIfNeeded;\n var parent = $ele.parentNode;\n var parentComputedStyle = window.getComputedStyle(parent, null);\n var parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'));\n var parentBorderLeftWidth = parseInt(parentComputedStyle.getPropertyValue('border-left-width'));\n var overTop = $ele.offsetTop - parent.offsetTop < parent.scrollTop;\n var overBottom = $ele.offsetTop - parent.offsetTop + $ele.clientHeight - parentBorderTopWidth > parent.scrollTop + parent.clientHeight;\n var overLeft = $ele.offsetLeft - parent.offsetLeft < parent.scrollLeft;\n var overRight = $ele.offsetLeft - parent.offsetLeft + $ele.clientWidth - parentBorderLeftWidth > parent.scrollLeft + parent.clientWidth;\n var alignWithTop = overTop && !overBottom;\n if ((overTop || overBottom) && centerIfNeeded) {\n parent.scrollTop = $ele.offsetTop - parent.offsetTop - parent.clientHeight / 2 - parentBorderTopWidth + $ele.clientHeight / 2;\n }\n if ((overLeft || overRight) && centerIfNeeded) {\n parent.scrollLeft = $ele.offsetLeft - parent.offsetLeft - parent.clientWidth / 2 - parentBorderLeftWidth + $ele.clientWidth / 2;\n }\n if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {\n $ele.scrollIntoView(alignWithTop);\n }\n}\nconst ALL_CURRENCIES = [{\n code: 'USD',\n symbol: '$'\n}, {\n code: 'VND',\n symbol: '₫'\n}];\nfunction blockToText(block) {\n return _blockToText(block).trim();\n}\nfunction isBlockEmpty(block) {\n return _isBlockEmpty(block);\n}\nfunction _isBlockEmpty(block = {}) {\n if (!size(block.content)) {\n if ((block.text || '').trim()) return false;\n return true;\n }\n let result = true;\n map(block.content, content => {\n result = result && _isBlockEmpty(content);\n });\n return result;\n}\nfunction _blockToText(block) {\n if (!block || !block.type) return '';\n let out = '';\n if (block.type == 'bullet_list' || block.type == 'ordered_list') {\n map(block.content, item => {\n preifx = '\\n* ';\n if (block.type == 'ordered_list') {\n prefix = i + '\\n. ';\n }\n out += prefix + blockToText(item).trim();\n });\n return out;\n }\n if (block.type == 'heading' || block.type == 'paragraph') {\n out += '\\n';\n }\n if (block.type == '' || block.type == 'text' || block.type == 'link' || block.type == 'mention-agent' || block.type == 'dynamic-field') {\n return out + block.text;\n }\n if (block.type == 'horizontal_rule') return out + '\\n---\\n';\n if (block.type == 'emoji') {\n let code;\n if (size(block.attrs) > 0) code = block.attrs['code'];\n if (code == '') code = block.text;\n if (code != '') {\n let emoji = find(LEXICAL_EMOJI_LIST, emoji => emoji.code === code);\n out + op.get(emoji, 'text', code);\n }\n return out;\n }\n map(block.content, block => {\n out += blockToText(block);\n });\n return out;\n}\nfunction parseCssColor(color) {\n if (!color || !color.split) return '';\n tempElement.style.color = color;\n const computedColor = f.contentWindow.getComputedStyle(tempElement).color;\n const match = computedColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/);\n if (match) {\n return {\n red: parseInt(match[1]),\n green: parseInt(match[2]),\n blue: parseInt(match[3])\n };\n } else {\n return null;\n }\n}\nlet emojis = ['like', 'unlike', 'wink', 'tongue-out', 'tired', 'surprised', 'smiling', 'sleepy', 'sad', 'neutral', 'heart-eyes', 'grinning', 'crying', 'confused', 'angry', 'cry', 'heart_eyes', 'neutral_face', 'emoji--disappointed', 'smile', 'open_mouth', 'tired_face', 'stuck_out_tongue', 'moyai', 'thumbsdown', 'dislike', 'thumbsup', 'ok_hand', 'octopus', 'pig2', 'wave', 'mouse', 'mouse2', 'rat'];\nemojis = map(emojis, e => ':' + e + ':');\nfunction absLink(url) {\n if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('//')) return 'http://' + url;\n return url;\n}\nfunction isEmptyBlock(block) {\n if (!block || !block.type) return true;\n let hasContent = size(filter(map(block.content, block => isEmptyBlock(block)), isEmpty => !isEmpty)) > 0;\n return !trim(block.text) && !hasContent;\n}\nfunction isEmptyMessage(msg) {\n if (!msg) return true;\n if (!msg.text && isEmptyBlock(msg.block) && isEmptyAttachment(msg)) return true;\n return false;\n}\nfunction isEmptyAttachment(msg) {\n if (!msg) return true;\n if (!size(msg.attachments)) return true;\n return size(filter(msg.attachments, att => {\n if (att.type == 'quick_replies') {\n return size(filter(att.quick_replies, r => size(trim(r)) > 0)) > 0;\n }\n return true;\n })) == 0;\n}\nfunction checkUrlCondition(cond, href) {\n let exclude_urls = filter(cond.exclude_urls, url => norm(url));\n let foundExclude = false;\n let excludeLen = 0;\n map(exclude_urls, url => {\n if (norm(href).indexOf(url) > -1) {\n if (excludeLen < size(url)) excludeLen = size(url);\n foundExclude = true;\n }\n });\n let includeLen = 0;\n let urls = filter(cond.urls, url => norm(url));\n let foundInclude = size(urls) == 0;\n map(urls, url => {\n if (norm(href).indexOf(url) > -1) {\n if (includeLen < size(url)) includeLen = size(url);\n foundInclude = true;\n }\n });\n if (foundExclude) {\n if (excludeLen >= includeLen) return false;\n }\n if (!foundInclude) return false;\n return true;\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/util/common.js?\n}");
|
|
306
|
+
|
|
307
|
+
/***/ },
|
|
308
|
+
|
|
309
|
+
/***/ "./src/util/gate.js"
|
|
310
|
+
/*!**************************!*\
|
|
311
|
+
!*** ./src/util/gate.js ***!
|
|
312
|
+
\**************************/
|
|
313
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
314
|
+
|
|
315
|
+
"use strict";
|
|
316
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Gate)\n/* harmony export */ });\nclass Gate {\n constructor(isOpen) {\n this.isOpen = isOpen === true;\n this.cbs = [];\n }\n open() {\n this.isOpen = true;\n let newcbs = [];\n this.cbs.forEach(cb => {\n if (this.isOpen) cb();else newcbs.push(cb);\n });\n this.cbs = newcbs;\n }\n close() {\n this.isOpen = false;\n }\n entry(cb, lock) {\n if (this.isOpen) {\n if (lock) this.isOpen = false;\n cb && cb();\n return Promise.resolve();\n }\n return new Promise(resolve => {\n this.cbs.push(() => {\n if (lock) this.isOpen = false;\n cb && cb();\n resolve();\n });\n });\n }\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/util/gate.js?\n}");
|
|
317
|
+
|
|
318
|
+
/***/ },
|
|
319
|
+
|
|
320
|
+
/***/ "./src/util/index.js"
|
|
321
|
+
/*!***************************!*\
|
|
322
|
+
!*** ./src/util/index.js ***!
|
|
323
|
+
\***************************/
|
|
324
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
325
|
+
|
|
326
|
+
"use strict";
|
|
327
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _common_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./common.js */ \"./src/util/common.js\");\n/* harmony import */ var _campaign_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./campaign.js */ \"./src/util/campaign.js\");\nvar sb = {};\n\nsb = Object.assign(sb, _common_js__WEBPACK_IMPORTED_MODULE_0__);\nsb.Gate = (__webpack_require__(/*! ./gate.js */ \"./src/util/gate.js\")[\"default\"]);\nsb.Mutex = (__webpack_require__(/*! ./mutex.js */ \"./src/util/mutex.js\")[\"default\"]);\nvar op = __webpack_require__(/*! ./op.js */ \"./src/util/op.js\");\nsb.get = op.get;\nsb.set = op.set;\nsb.take = op.take;\nsb.Pubsub = (__webpack_require__(/*! ./pubsub.js */ \"./src/util/pubsub.js\")[\"default\"]);\n\nsb = Object.assign(sb, _campaign_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (sb);\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/util/index.js?\n}");
|
|
328
|
+
|
|
329
|
+
/***/ },
|
|
330
|
+
|
|
331
|
+
/***/ "./src/util/mutex.js"
|
|
332
|
+
/*!***************************!*\
|
|
333
|
+
!*** ./src/util/mutex.js ***!
|
|
334
|
+
\***************************/
|
|
335
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
336
|
+
|
|
337
|
+
"use strict";
|
|
338
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Mutex)\n/* harmony export */ });\nclass Mutex {\n constructor() {\n this.isOpen = true;\n this.cbs = [];\n }\n _check() {\n if (!this.isOpen) return;\n let cb = this.cbs.pop();\n if (!cb) return;\n this.isOpen = false;\n cb();\n }\n lock() {\n return new Promise(resolve => {\n this.cbs.push(resolve);\n this._check();\n });\n }\n unlock() {\n if (this.isOpen) return;\n this.isOpen = true;\n this._check();\n }\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/util/mutex.js?\n}");
|
|
339
|
+
|
|
340
|
+
/***/ },
|
|
341
|
+
|
|
342
|
+
/***/ "./src/util/op.js"
|
|
343
|
+
/*!************************!*\
|
|
344
|
+
!*** ./src/util/op.js ***!
|
|
345
|
+
\************************/
|
|
346
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
347
|
+
|
|
348
|
+
"use strict";
|
|
349
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ get: () => (/* binding */ get),\n/* harmony export */ set: () => (/* binding */ set),\n/* harmony export */ take: () => (/* binding */ take)\n/* harmony export */ });\nvar toStr = Object.prototype.toString;\nvar isArray = Array.isArray || function (obj) {\n return toStr.call(obj) === '[object Array]';\n};\nfunction hasOwnProperty(obj, prop) {\n if (obj == null) return false;\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\nfunction getKey(key) {\n var intKey = parseInt(key);\n return intKey.toString() === key ? intKey : key;\n}\nfunction hasShallowProperty(obj, prop) {\n return typeof prop === 'number' && isArray(obj) || hasOwnProperty(obj, prop);\n}\nfunction getShallowProperty(obj, prop) {\n if (hasShallowProperty(obj, prop)) return obj[prop];\n}\nfunction get(obj, path, defaultValue) {\n if (typeof path === 'number') path = [path];\n if (!path || path.length === 0) return obj;\n if (obj == null) return defaultValue;\n if (typeof path === 'string') {\n return get(obj, path.split('.'), defaultValue);\n }\n var currentPath = getKey(path[0]);\n var nextObj = getShallowProperty(obj, currentPath);\n if (nextObj === void 0) return defaultValue;\n if (path.length === 1) return nextObj;\n return get(obj[currentPath], path.slice(1), defaultValue);\n}\nfunction set(obj, path, value) {\n if (typeof path === 'number') path = [path];\n if (!path || path.length === 0) return obj;\n if (typeof path === 'string') {\n return set(obj, path.split('.').map(getKey), value);\n }\n var currentPath = path[0];\n var currentValue = getShallowProperty(obj, currentPath);\n if (path.length === 1) {\n obj[currentPath] = value;\n return currentValue;\n }\n if (currentValue === void 0) {\n obj[currentPath] = typeof path[1] === 'number' ? [] : {};\n }\n return set(obj[currentPath], path.slice(1), value);\n}\nfunction take(arr, n = 1) {\n if (!Array.isArray(arr)) return [];\n let len = arr.length;\n if (typeof len !== 'number' || len <= 0) return [];\n if (n <= 0) return [];\n let end = Math.min(n, len);\n return arr.slice(0, end);\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/util/op.js?\n}");
|
|
350
|
+
|
|
351
|
+
/***/ },
|
|
352
|
+
|
|
353
|
+
/***/ "./src/util/pubsub.js"
|
|
354
|
+
/*!****************************!*\
|
|
355
|
+
!*** ./src/util/pubsub.js ***!
|
|
356
|
+
\****************************/
|
|
357
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
358
|
+
|
|
359
|
+
"use strict";
|
|
360
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ Pubsub)\n/* harmony export */ });\nvar {\n filter,\n map\n} = __webpack_require__(/*! ./common.js */ \"./src/util/common.js\");\nclass Pubsub {\n constructor() {\n this.listeners = {};\n }\n publish(topic, payload, payload2, payload3) {\n this.listeners[topic] = filter(this.listeners[topic], sub => sub.obj._isMounted);\n map(this.listeners[topic], ({\n cb\n }) => cb(payload, payload2, payload3));\n }\n on2(obj, topic, cb) {\n if (!this.listeners[topic]) this.listeners[topic] = [];\n this.listeners[topic].push({\n obj,\n cb\n });\n }\n}\n\n//# sourceURL=webpack://@subiz/widget-v4/./src/util/pubsub.js?\n}");
|
|
361
|
+
|
|
362
|
+
/***/ },
|
|
363
|
+
|
|
364
|
+
/***/ "./node_modules/cookie_js/dist/cookie.umd.js"
|
|
365
|
+
/*!***************************************************!*\
|
|
366
|
+
!*** ./node_modules/cookie_js/dist/cookie.umd.js ***!
|
|
367
|
+
\***************************************************/
|
|
368
|
+
(module) {
|
|
369
|
+
|
|
370
|
+
eval("{(function (global, factory) {\n true ? module.exports = factory() :\n 0;\n}(this, function () { 'use strict';\n\n // Copyright (c) Florian Hartmann, https://github.com/florian https://github.com/florian/cookie.js\n\n var cookie = function() {\n return cookie.get.apply(cookie, arguments);\n };\n\n var utils = cookie.utils = {\n\n // Is the given value an array? Use ES5 Array.isArray if it's available.\n isArray: Array.isArray || function (value) {\n return Object.prototype.toString.call(value) === '[object Array]';\n },\n\n // Is the given value a plain object / an object whose constructor is `Object`?\n isPlainObject: function (value) {\n return !!value && Object.prototype.toString.call(value) === '[object Object]';\n },\n\n // Convert an array-like object to an array – for example `arguments`.\n toArray: function (value) {\n return Array.prototype.slice.call(value);\n },\n\n // Get the keys of an object. Use ES5 Object.keys if it's available.\n getKeys: Object.keys || function (obj) {\n var keys = [],\n key = '';\n for (key in obj) {\n if (obj.hasOwnProperty(key)) keys.push(key);\n }\n return keys;\n },\n\n // Unlike JavaScript's built-in escape functions, this method\n // only escapes characters that are not allowed in cookies.\n encode: function (value) {\n return String(value).replace(/[,;\"\\\\=\\s%]/g, function (character) {\n return encodeURIComponent(character);\n });\n },\n\n decode: function (value) {\n return decodeURIComponent(value);\n },\n\n // Return fallback if the value is not defined, otherwise return value.\n retrieve: function (value, fallback) {\n return value == null ? fallback : value;\n }\n\n };\n\n cookie.defaults = {};\n\n cookie.expiresMultiplier = 60 * 60 * 24;\n\n cookie.set = function (key, value, options) {\n if (utils.isPlainObject(key)) {\n // `key` contains an object with keys and values for cookies, `value` contains the options object.\n\n for (var k in key) {\n if (key.hasOwnProperty(k)) this.set(k, key[k], value);\n }\n } else {\n options = utils.isPlainObject(options) ? options : { expires: options };\n\n // Empty string for session cookies.\n var expires = options.expires !== undefined ? options.expires : (this.defaults.expires || ''),\n expiresType = typeof(expires);\n\n if (expiresType === 'string' && expires !== '') expires = new Date(expires);\n else if (expiresType === 'number') expires = new Date(+new Date + 1000 * this.expiresMultiplier * expires); // This is needed because IE does not support the `max-age` cookie attribute.\n\n if (expires !== '' && 'toUTCString' in expires) expires = ';expires=' + expires.toUTCString();\n\n var path = options.path || this.defaults.path;\n path = path ? ';path=' + path : '';\n\n var domain = options.domain || this.defaults.domain;\n domain = domain ? ';domain=' + domain : '';\n\n var secure = options.secure || this.defaults.secure ? ';secure' : '';\n if (options.secure === false) secure = '';\n\n var sameSite = options.sameSite || this.defaults.sameSite;\n sameSite = sameSite ? ';SameSite=' + sameSite : '';\n if (options.sameSite === null) sameSite = '';\n\n document.cookie = utils.encode(key) + '=' + utils.encode(value) + expires + path + domain + secure + sameSite;\n }\n\n return this; // Return the `cookie` object to make chaining possible.\n };\n\n cookie.setDefault = function (key, value, options) {\n if (utils.isPlainObject(key)) {\n for (var k in key) {\n if (this.get(k) === undefined) this.set(k, key[k], value);\n }\n return cookie;\n } else {\n if (this.get(key) === undefined) return this.set.apply(this, arguments);\n }\n },\n\n cookie.remove = function (keys) {\n keys = utils.isArray(keys) ? keys : utils.toArray(arguments);\n\n for (var i = 0, l = keys.length; i < l; i++) {\n this.set(keys[i], '', -1);\n }\n\n return this; // Return the `cookie` object to make chaining possible.\n };\n\n cookie.removeSpecific = function (keys, options) {\n if (!options) return this.remove(keys);\n\n keys = utils.isArray(keys) ? keys : [keys];\n options.expires = -1;\n\n for (var i = 0, l = keys.length; i < l; i++) {\n this.set(keys[i], '', options);\n }\n\n return this; // Return the `cookie` object to make chaining possible.\n };\n\n cookie.empty = function () {\n return this.remove(utils.getKeys(this.all()));\n };\n\n cookie.get = function (keys, fallback) {\n var cookies = this.all();\n\n if (utils.isArray(keys)) {\n var result = {};\n\n for (var i = 0, l = keys.length; i < l; i++) {\n var value = keys[i];\n result[value] = utils.retrieve(cookies[value], fallback);\n }\n\n return result;\n\n } else return utils.retrieve(cookies[keys], fallback);\n };\n\n cookie.all = function () {\n if (document.cookie === '') return {};\n\n var cookies = document.cookie.split('; '),\n result = {};\n\n for (var i = 0, l = cookies.length; i < l; i++) {\n var item = cookies[i].split('=');\n var key = utils.decode(item.shift());\n var value = utils.decode(item.join('='));\n result[key] = value;\n }\n\n return result;\n };\n\n cookie.enabled = function () {\n if (navigator.cookieEnabled) return true;\n\n var ret = cookie.set('_', '_').get('_') === '_';\n cookie.remove('_');\n return ret;\n };\n\n return cookie;\n\n}));\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/cookie_js/dist/cookie.umd.js?\n}");
|
|
371
|
+
|
|
372
|
+
/***/ },
|
|
373
|
+
|
|
374
|
+
/***/ "./assets/img/caret.svg"
|
|
375
|
+
/*!******************************!*\
|
|
376
|
+
!*** ./assets/img/caret.svg ***!
|
|
377
|
+
\******************************/
|
|
378
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
379
|
+
|
|
380
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/caret.998eb8f.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/caret.svg?\n}");
|
|
381
|
+
|
|
382
|
+
/***/ },
|
|
383
|
+
|
|
384
|
+
/***/ "./assets/img/default.jpg"
|
|
385
|
+
/*!********************************!*\
|
|
386
|
+
!*** ./assets/img/default.jpg ***!
|
|
387
|
+
\********************************/
|
|
388
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
389
|
+
|
|
390
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/default.06e6ee0.jpg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/default.jpg?\n}");
|
|
391
|
+
|
|
392
|
+
/***/ },
|
|
393
|
+
|
|
394
|
+
/***/ "./assets/img/default_avatar.png"
|
|
395
|
+
/*!***************************************!*\
|
|
396
|
+
!*** ./assets/img/default_avatar.png ***!
|
|
397
|
+
\***************************************/
|
|
398
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
399
|
+
|
|
400
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/default_avatar.e449b04.png\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/default_avatar.png?\n}");
|
|
401
|
+
|
|
402
|
+
/***/ },
|
|
403
|
+
|
|
404
|
+
/***/ "./assets/img/done_green.svg"
|
|
405
|
+
/*!***********************************!*\
|
|
406
|
+
!*** ./assets/img/done_green.svg ***!
|
|
407
|
+
\***********************************/
|
|
408
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
409
|
+
|
|
410
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/done_green.b817fd4.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/done_green.svg?\n}");
|
|
411
|
+
|
|
412
|
+
/***/ },
|
|
413
|
+
|
|
414
|
+
/***/ "./assets/img/empty_1.svg"
|
|
415
|
+
/*!********************************!*\
|
|
416
|
+
!*** ./assets/img/empty_1.svg ***!
|
|
417
|
+
\********************************/
|
|
418
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
419
|
+
|
|
420
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/empty_1.0b98af0.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/empty_1.svg?\n}");
|
|
421
|
+
|
|
422
|
+
/***/ },
|
|
423
|
+
|
|
424
|
+
/***/ "./assets/img/external-link.svg"
|
|
425
|
+
/*!**************************************!*\
|
|
426
|
+
!*** ./assets/img/external-link.svg ***!
|
|
427
|
+
\**************************************/
|
|
428
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
429
|
+
|
|
430
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/external-link.90577cc.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/external-link.svg?\n}");
|
|
431
|
+
|
|
432
|
+
/***/ },
|
|
433
|
+
|
|
434
|
+
/***/ "./assets/img/ghn.svg"
|
|
435
|
+
/*!****************************!*\
|
|
436
|
+
!*** ./assets/img/ghn.svg ***!
|
|
437
|
+
\****************************/
|
|
438
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
439
|
+
|
|
440
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/ghn.070f8e3.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/ghn.svg?\n}");
|
|
441
|
+
|
|
442
|
+
/***/ },
|
|
443
|
+
|
|
444
|
+
/***/ "./assets/img/ghtk.svg"
|
|
445
|
+
/*!*****************************!*\
|
|
446
|
+
!*** ./assets/img/ghtk.svg ***!
|
|
447
|
+
\*****************************/
|
|
448
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
449
|
+
|
|
450
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/ghtk.326eac1.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/ghtk.svg?\n}");
|
|
451
|
+
|
|
452
|
+
/***/ },
|
|
453
|
+
|
|
454
|
+
/***/ "./assets/img/image_default.png"
|
|
455
|
+
/*!**************************************!*\
|
|
456
|
+
!*** ./assets/img/image_default.png ***!
|
|
457
|
+
\**************************************/
|
|
458
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
459
|
+
|
|
460
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/image_default.be0698b.png\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/image_default.png?\n}");
|
|
461
|
+
|
|
462
|
+
/***/ },
|
|
463
|
+
|
|
464
|
+
/***/ "./assets/img/info.svg"
|
|
465
|
+
/*!*****************************!*\
|
|
466
|
+
!*** ./assets/img/info.svg ***!
|
|
467
|
+
\*****************************/
|
|
468
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
469
|
+
|
|
470
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/info.ebce7ea.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/info.svg?\n}");
|
|
471
|
+
|
|
472
|
+
/***/ },
|
|
473
|
+
|
|
474
|
+
/***/ "./assets/img/loader.svg"
|
|
475
|
+
/*!*******************************!*\
|
|
476
|
+
!*** ./assets/img/loader.svg ***!
|
|
477
|
+
\*******************************/
|
|
478
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
479
|
+
|
|
480
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/loader.37000a7.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/loader.svg?\n}");
|
|
481
|
+
|
|
482
|
+
/***/ },
|
|
483
|
+
|
|
484
|
+
/***/ "./assets/img/loading_static.svg"
|
|
485
|
+
/*!***************************************!*\
|
|
486
|
+
!*** ./assets/img/loading_static.svg ***!
|
|
487
|
+
\***************************************/
|
|
488
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
489
|
+
|
|
490
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/loading_static.a27f0ac.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/loading_static.svg?\n}");
|
|
491
|
+
|
|
492
|
+
/***/ },
|
|
493
|
+
|
|
494
|
+
/***/ "./assets/img/not_found_search.png"
|
|
495
|
+
/*!*****************************************!*\
|
|
496
|
+
!*** ./assets/img/not_found_search.png ***!
|
|
497
|
+
\*****************************************/
|
|
498
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
499
|
+
|
|
500
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/not_found_search.2ddb8d1.png\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/not_found_search.png?\n}");
|
|
501
|
+
|
|
502
|
+
/***/ },
|
|
503
|
+
|
|
504
|
+
/***/ "./assets/img/package.svg"
|
|
505
|
+
/*!********************************!*\
|
|
506
|
+
!*** ./assets/img/package.svg ***!
|
|
507
|
+
\********************************/
|
|
508
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
509
|
+
|
|
510
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/package.8d37d0f.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/package.svg?\n}");
|
|
511
|
+
|
|
512
|
+
/***/ },
|
|
513
|
+
|
|
514
|
+
/***/ "./assets/img/package_fade.svg"
|
|
515
|
+
/*!*************************************!*\
|
|
516
|
+
!*** ./assets/img/package_fade.svg ***!
|
|
517
|
+
\*************************************/
|
|
518
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
519
|
+
|
|
520
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/package_fade.763c001.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/package_fade.svg?\n}");
|
|
521
|
+
|
|
522
|
+
/***/ },
|
|
523
|
+
|
|
524
|
+
/***/ "./assets/img/search.svg"
|
|
525
|
+
/*!*******************************!*\
|
|
526
|
+
!*** ./assets/img/search.svg ***!
|
|
527
|
+
\*******************************/
|
|
528
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
529
|
+
|
|
530
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/search.f9705ff.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/search.svg?\n}");
|
|
531
|
+
|
|
532
|
+
/***/ },
|
|
533
|
+
|
|
534
|
+
/***/ "./assets/img/shop.svg"
|
|
535
|
+
/*!*****************************!*\
|
|
536
|
+
!*** ./assets/img/shop.svg ***!
|
|
537
|
+
\*****************************/
|
|
538
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
539
|
+
|
|
540
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/shop.f7dc7d8.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/shop.svg?\n}");
|
|
541
|
+
|
|
542
|
+
/***/ },
|
|
543
|
+
|
|
544
|
+
/***/ "./assets/img/shop_faded.svg"
|
|
545
|
+
/*!***********************************!*\
|
|
546
|
+
!*** ./assets/img/shop_faded.svg ***!
|
|
547
|
+
\***********************************/
|
|
548
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
549
|
+
|
|
550
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/shop_faded.df7845a.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/shop_faded.svg?\n}");
|
|
551
|
+
|
|
552
|
+
/***/ },
|
|
553
|
+
|
|
554
|
+
/***/ "./assets/img/x.svg"
|
|
555
|
+
/*!**************************!*\
|
|
556
|
+
!*** ./assets/img/x.svg ***!
|
|
557
|
+
\**************************/
|
|
558
|
+
(module, __unused_webpack_exports, __webpack_require__) {
|
|
559
|
+
|
|
560
|
+
eval("{module.exports = __webpack_require__.p + \"assets/img/x.26fdfa3.svg\";\n\n//# sourceURL=webpack://@subiz/widget-v4/./assets/img/x.svg?\n}");
|
|
561
|
+
|
|
562
|
+
/***/ },
|
|
563
|
+
|
|
564
|
+
/***/ "./node_modules/preact/dist/preact.module.js"
|
|
565
|
+
/*!***************************************************!*\
|
|
566
|
+
!*** ./node_modules/preact/dist/preact.module.js ***!
|
|
567
|
+
\***************************************************/
|
|
568
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
569
|
+
|
|
570
|
+
"use strict";
|
|
571
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Component: () => (/* binding */ b),\n/* harmony export */ Fragment: () => (/* binding */ g),\n/* harmony export */ cloneElement: () => (/* binding */ E),\n/* harmony export */ createContext: () => (/* binding */ F),\n/* harmony export */ createElement: () => (/* binding */ y),\n/* harmony export */ createRef: () => (/* binding */ _),\n/* harmony export */ h: () => (/* binding */ y),\n/* harmony export */ hydrate: () => (/* binding */ B),\n/* harmony export */ isValidElement: () => (/* binding */ t),\n/* harmony export */ options: () => (/* binding */ l),\n/* harmony export */ render: () => (/* binding */ q),\n/* harmony export */ toChildArray: () => (/* binding */ $)\n/* harmony export */ });\nvar n,l,u,t,i,o,r,f,e,c={},s=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,h=Array.isArray;function v(n,l){for(var u in l)n[u]=l[u];return n}function p(n){var l=n.parentNode;l&&l.removeChild(n)}function y(l,u,t){var i,o,r,f={};for(r in u)\"key\"==r?i=u[r]:\"ref\"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),\"function\"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return d(l,f,i,o,null)}function d(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u:r,__i:-1,__u:0};return null==r&&null!=l.vnode&&l.vnode(f),f}function _(){return{current:null}}function g(n){return n.children}function b(n,l){this.props=n,this.context=l}function m(n,l){if(null==l)return n.__?m(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return\"function\"==typeof n.type?m(n):null}function k(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k(n)}}function w(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!x.__r++||o!==l.debounceRendering)&&((o=l.debounceRendering)||r)(x)}function x(){var n,u,t,o,r,e,c,s,a;for(i.sort(f);n=i.shift();)n.__d&&(u=i.length,o=void 0,e=(r=(t=n).__v).__e,s=[],a=[],(c=t.__P)&&((o=v({},r)).__v=r.__v+1,l.vnode&&l.vnode(o),L(c,o,r,t.__n,void 0!==c.ownerSVGElement,32&r.__u?[e]:null,s,null==e?m(r):e,!!(32&r.__u),a),o.__.__k[o.__i]=o,M(s,o,a),o.__e!=e&&k(o)),i.length>u&&i.sort(f));x.__r=0}function C(n,l,u,t,i,o,r,f,e,a,h){var v,p,y,d,_,g=t&&t.__k||s,b=l.length;for(u.__d=e,P(u,l,g),e=u.__d,v=0;v<b;v++)null!=(y=u.__k[v])&&\"boolean\"!=typeof y&&\"function\"!=typeof y&&(p=-1===y.__i?c:g[y.__i]||c,y.__i=v,L(n,y,p,i,o,r,f,e,a,h),d=y.__e,y.ref&&p.ref!=y.ref&&(p.ref&&z(p.ref,null,y),h.push(y.ref,y.__c||d,y)),null==_&&null!=d&&(_=d),65536&y.__u||p.__k===y.__k?e=S(y,e,n):\"function\"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=_}function P(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)null!=(i=n.__k[t]=null==(i=l[t])||\"boolean\"==typeof i||\"function\"==typeof i?null:\"string\"==typeof i||\"number\"==typeof i||\"bigint\"==typeof i||i.constructor==String?d(null,i,null,null,i):h(i)?d(g,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?d(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=H(i,u,r=t+a,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,\"function\"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f===r+1?a++:f>r?s>e-r?a+=f-r:a--:a=f<r&&f==r-1?f-r:0,f!==t+a&&(i.__u|=65536))):(o=u[t])&&null==o.key&&o.__e&&(o.__e==n.__d&&(n.__d=m(o)),N(o,o,!1),u[t]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=m(o)),N(o,o))}function S(n,l,u){var t,i;if(\"function\"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=S(t[i],l,u));return l}return n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e),l&&l.nextSibling}function $(n,l){return l=l||[],null==n||\"boolean\"==typeof n||(h(n)?n.some(function(n){$(n,l)}):l.push(n)),l}function H(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type)return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++}}return-1}function I(n,l,u){\"-\"===l[0]?n.setProperty(l,null==u?\"\":u):n[l]=null==u?\"\":\"number\"!=typeof u||a.test(l)?u:u+\"px\"}function T(n,l,u,t,i){var o;n:if(\"style\"===l)if(\"string\"==typeof u)n.style.cssText=u;else{if(\"string\"==typeof t&&(n.style.cssText=t=\"\"),t)for(l in t)u&&l in u||I(n.style,l,\"\");if(u)for(l in u)t&&u[l]===t[l]||I(n.style,l,u[l])}else if(\"o\"===l[0]&&\"n\"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/,\"$1\")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=Date.now(),n.addEventListener(l,o?D:A,o)):n.removeEventListener(l,o?D:A,o);else{if(i)l=l.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(\"width\"!==l&&\"height\"!==l&&\"href\"!==l&&\"list\"!==l&&\"form\"!==l&&\"tabIndex\"!==l&&\"download\"!==l&&\"rowSpan\"!==l&&\"colSpan\"!==l&&\"role\"!==l&&l in n)try{n[l]=null==u?\"\":u;break n}catch(n){}\"function\"==typeof u||(null==u||!1===u&&\"-\"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u))}}function A(n){var u=this.l[n.type+!1];if(n.t){if(n.t<=u.u)return}else n.t=Date.now();return u(l.event?l.event(n):n)}function D(n){return this.l[n.type+!0](l.event?l.event(n):n)}function L(n,u,t,i,o,r,f,e,c,s){var a,p,y,d,_,m,k,w,x,P,S,$,H,I,T,A=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l.__b)&&a(u);n:if(\"function\"==typeof A)try{if(w=u.props,x=(a=A.contextType)&&i[a.__c],P=a?x?x.props.value:a.__:i,t.__c?k=(p=u.__c=t.__c).__=p.__E:(\"prototype\"in A&&A.prototype.render?u.__c=p=new A(w,P):(u.__c=p=new b(w,P),p.constructor=A,p.render=O),x&&x.sub(p),p.props=w,p.state||(p.state={}),p.context=P,p.__n=i,y=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=A.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=v({},p.__s)),v(p.__s,A.getDerivedStateFromProps(w,p.__s))),d=p.props,_=p.state,p.__v=u,y)null==A.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==A.getDerivedStateFromProps&&w!==d&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,P),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,P)||u.__v===t.__v)){for(u.__v!==t.__v&&(p.props=w,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.forEach(function(n){n&&(n.__=u)}),S=0;S<p._sb.length;S++)p.__h.push(p._sb[S]);p._sb=[],p.__h.length&&f.push(p);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,P),null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(d,_,m)})}if(p.context=P,p.props=w,p.__P=n,p.__e=!1,$=l.__r,H=0,\"prototype\"in A&&A.prototype.render){for(p.state=p.__s,p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),I=0;I<p._sb.length;I++)p.__h.push(p._sb[I]);p._sb=[]}else do{p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=v(v({},i),p.getChildContext())),y||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(d,_)),C(n,h(T=null!=a&&a.type===g&&null==a.key?a.props.children:a)?T:[T],u,t,i,o,r,f,e,c,s),p.base=u.__e,u.__u&=-161,p.__h.length&&f.push(p),k&&(p.__E=p.__=null)}catch(n){u.__v=null,c||null!=r?(u.__e=e,u.__u|=c?160:32,r[r.indexOf(e)]=null):(u.__e=t.__e,u.__k=t.__k),l.__e(n,u,t)}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=j(t.__e,u,t,i,o,r,f,c,s);(a=l.diffed)&&a(u)}function M(n,u,t){u.__d=void 0;for(var i=0;i<t.length;i++)z(t[i],t[++i],t[++i]);l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function j(l,u,t,i,o,r,f,e,s){var a,v,y,d,_,g,b,k=t.props,w=u.props,x=u.type;if(\"svg\"===x&&(o=!0),null!=r)for(a=0;a<r.length;a++)if((_=r[a])&&\"setAttribute\"in _==!!x&&(x?_.localName===x:3===_.nodeType)){l=_,r[a]=null;break}if(null==l){if(null===x)return document.createTextNode(w);l=o?document.createElementNS(\"http://www.w3.org/2000/svg\",x):document.createElement(x,w.is&&w),r=null,e=!1}if(null===x)k===w||e&&l.data===w||(l.data=w);else{if(r=r&&n.call(l.childNodes),k=t.props||c,!e&&null!=r)for(k={},a=0;a<l.attributes.length;a++)k[(_=l.attributes[a]).name]=_.value;for(a in k)_=k[a],\"children\"==a||(\"dangerouslySetInnerHTML\"==a?y=_:\"key\"===a||a in w||T(l,a,null,_,o));for(a in w)_=w[a],\"children\"==a?d=_:\"dangerouslySetInnerHTML\"==a?v=_:\"value\"==a?g=_:\"checked\"==a?b=_:\"key\"===a||e&&\"function\"!=typeof _||k[a]===_||T(l,a,_,k[a],o);if(v)e||y&&(v.__html===y.__html||v.__html===l.innerHTML)||(l.innerHTML=v.__html),u.__k=[];else if(y&&(l.innerHTML=\"\"),C(l,h(d)?d:[d],u,t,i,o&&\"foreignObject\"!==x,r,f,r?r[0]:t.__k&&m(t,0),e,s),null!=r)for(a=r.length;a--;)null!=r[a]&&p(r[a]);e||(a=\"value\",void 0!==g&&(g!==l[a]||\"progress\"===x&&!g||\"option\"===x&&g!==k[a])&&T(l,a,g,k[a],!1),a=\"checked\",void 0!==b&&b!==l[a]&&T(l,a,b,k[a],!1))}return l}function z(n,u,t){try{\"function\"==typeof n?n(u):n.current=u}catch(n){l.__e(n,t)}}function N(n,u,t){var i,o;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||z(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,u)}i.base=i.__P=null,n.__c=void 0}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&N(i[o],u,t||\"function\"!=typeof n.type);t||null==n.__e||p(n.__e),n.__=n.__e=n.__d=void 0}function O(n,l,u){return this.constructor(n,u)}function q(u,t,i){var o,r,f,e;l.__&&l.__(u,t),r=(o=\"function\"==typeof i)?null:i&&i.__k||t.__k,f=[],e=[],L(t,u=(!o&&i||t).__k=y(g,null,[u]),r||c,c,void 0!==t.ownerSVGElement,!o&&i?[i]:r?null:t.firstChild?n.call(t.childNodes):null,f,!o&&i?i:r?r.__e:t.firstChild,o,e),M(f,u,e)}function B(n,l){q(n,l,B)}function E(l,u,t){var i,o,r,f,e=v({},l.props);for(r in l.type&&l.type.defaultProps&&(f=l.type.defaultProps),u)\"key\"==r?i=u[r]:\"ref\"==r?o=u[r]:e[r]=void 0===u[r]&&void 0!==f?f[r]:u[r];return arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),d(l.type,e,i||l.key,o||l.ref,null)}function F(n,l){var u={__c:l=\"__cC\"+e++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=[],(t={})[l]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,w(n)})},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=s.slice,l={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&null==n.constructor},b.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=v({},this.state),\"function\"==typeof n&&(n=n(v({},u),this.props)),n&&v(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),w(this))},b.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),w(this))},b.prototype.render=g,i=[],r=\"function\"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(n,l){return n.__v.__b-l.__v.__b},x.__r=0,e=0;\n//# sourceMappingURL=preact.module.js.map\n\n\n//# sourceURL=webpack://@subiz/widget-v4/./node_modules/preact/dist/preact.module.js?\n}");
|
|
572
|
+
|
|
573
|
+
/***/ }
|
|
574
|
+
|
|
575
|
+
/******/ });
|
|
576
|
+
/************************************************************************/
|
|
577
|
+
/******/ // The module cache
|
|
578
|
+
/******/ const __webpack_module_cache__ = {};
|
|
579
|
+
/******/
|
|
580
|
+
/******/ // The require function
|
|
581
|
+
/******/ function __webpack_require__(moduleId) {
|
|
582
|
+
/******/ // Check if module is in cache
|
|
583
|
+
/******/ const cachedModule = __webpack_module_cache__[moduleId];
|
|
584
|
+
/******/ if (cachedModule !== undefined) {
|
|
585
|
+
/******/ return cachedModule.exports;
|
|
586
|
+
/******/ }
|
|
587
|
+
/******/ // Create a new module (and put it into the cache)
|
|
588
|
+
/******/ const module = __webpack_module_cache__[moduleId] = {
|
|
589
|
+
/******/ id: moduleId,
|
|
590
|
+
/******/ // no module.loaded needed
|
|
591
|
+
/******/ exports: {}
|
|
592
|
+
/******/ };
|
|
593
|
+
/******/
|
|
594
|
+
/******/ // Execute the module function
|
|
595
|
+
/******/ if (!(moduleId in __webpack_modules__)) {
|
|
596
|
+
/******/ delete __webpack_module_cache__[moduleId];
|
|
597
|
+
/******/ const e = new Error("Cannot find module '" + moduleId + "'");
|
|
598
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
599
|
+
/******/ throw e;
|
|
600
|
+
/******/ }
|
|
601
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
602
|
+
/******/
|
|
603
|
+
/******/ // Return the exports of the module
|
|
604
|
+
/******/ return module.exports;
|
|
605
|
+
/******/ }
|
|
606
|
+
/******/
|
|
607
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
608
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
609
|
+
/******/
|
|
610
|
+
/************************************************************************/
|
|
611
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
612
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
613
|
+
/******/ __webpack_require__.n = (module) => {
|
|
614
|
+
/******/ const getter = module && module.__esModule ?
|
|
615
|
+
/******/ () => (module['default']) :
|
|
616
|
+
/******/ () => (module);
|
|
617
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
618
|
+
/******/ return getter;
|
|
619
|
+
/******/ };
|
|
620
|
+
/******/
|
|
621
|
+
/******/ /* webpack/runtime/define property getters */
|
|
622
|
+
/******/ // define getter/value functions for harmony exports
|
|
623
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
624
|
+
/******/ for(var key in definition) {
|
|
625
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
626
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
627
|
+
/******/ }
|
|
628
|
+
/******/ }
|
|
629
|
+
/******/ };
|
|
630
|
+
/******/
|
|
631
|
+
/******/ /* webpack/runtime/ensure chunk */
|
|
632
|
+
/******/ __webpack_require__.f = {};
|
|
633
|
+
/******/ // This file contains only the entry chunk.
|
|
634
|
+
/******/ // The chunk loading function for additional chunks
|
|
635
|
+
/******/ __webpack_require__.e = (chunkId) => {
|
|
636
|
+
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
|
|
637
|
+
/******/ __webpack_require__.f[key](chunkId, promises);
|
|
638
|
+
/******/ return promises;
|
|
639
|
+
/******/ }, []));
|
|
640
|
+
/******/ };
|
|
641
|
+
/******/
|
|
642
|
+
/******/ /* webpack/runtime/get javascript chunk filename */
|
|
643
|
+
/******/ // This function allow to reference async chunks
|
|
644
|
+
/******/ __webpack_require__.u = (chunkId) => (chunkId + ".js");
|
|
645
|
+
/******/
|
|
646
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
647
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));
|
|
648
|
+
/******/
|
|
649
|
+
/******/ /* webpack/runtime/load script */
|
|
650
|
+
/******/ (() => {
|
|
651
|
+
/******/ const inProgress = {};
|
|
652
|
+
/******/ const dataWebpackPrefix = "@subiz/widget-v4:";
|
|
653
|
+
/******/ // loadScript function to load a script via script tag
|
|
654
|
+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
|
|
655
|
+
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
|
|
656
|
+
/******/ let script, needAttach;
|
|
657
|
+
/******/ if(key !== undefined) {
|
|
658
|
+
/******/ const scripts = document.getElementsByTagName("script");
|
|
659
|
+
/******/ for(var i = 0; i < scripts.length; i++) {
|
|
660
|
+
/******/ const s = scripts[i];
|
|
661
|
+
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
|
|
662
|
+
/******/ }
|
|
663
|
+
/******/ }
|
|
664
|
+
/******/ if(!script) {
|
|
665
|
+
/******/ needAttach = true;
|
|
666
|
+
/******/ script = document.createElement('script');
|
|
667
|
+
/******/
|
|
668
|
+
/******/ script.charset = 'utf-8';
|
|
669
|
+
/******/ if (__webpack_require__.nc) {
|
|
670
|
+
/******/ script.setAttribute("nonce", __webpack_require__.nc);
|
|
671
|
+
/******/ }
|
|
672
|
+
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
|
|
673
|
+
/******/
|
|
674
|
+
/******/ script.src = url;
|
|
675
|
+
/******/ }
|
|
676
|
+
/******/ inProgress[url] = [done];
|
|
677
|
+
/******/ const onScriptComplete = (prev, event) => {
|
|
678
|
+
/******/ // avoid mem leaks in IE.
|
|
679
|
+
/******/ script.onerror = script.onload = null;
|
|
680
|
+
/******/ clearTimeout(timeout);
|
|
681
|
+
/******/ const doneFns = inProgress[url];
|
|
682
|
+
/******/ delete inProgress[url];
|
|
683
|
+
/******/ script.parentNode?.removeChild(script);
|
|
684
|
+
/******/ doneFns?.forEach((fn) => (fn(event)));
|
|
685
|
+
/******/ if(prev) return prev(event);
|
|
686
|
+
/******/ }
|
|
687
|
+
/******/ const timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
|
688
|
+
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
689
|
+
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
|
690
|
+
/******/ needAttach && document.head.appendChild(script);
|
|
691
|
+
/******/ };
|
|
692
|
+
/******/ })();
|
|
693
|
+
/******/
|
|
694
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
695
|
+
/******/ // define __esModule on exports
|
|
696
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
697
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
698
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
699
|
+
/******/ };
|
|
700
|
+
/******/
|
|
701
|
+
/******/ /* webpack/runtime/set anonymous default export name */
|
|
702
|
+
/******/ // set .name for anonymous default exports per ES spec
|
|
703
|
+
/******/ // skipped when the property is non-configurable (pre-ES2015 engines),
|
|
704
|
+
/******/ // where Object.defineProperty would throw
|
|
705
|
+
/******/ __webpack_require__.dn = (x) => {
|
|
706
|
+
/******/ var descriptor = Object.getOwnPropertyDescriptor(x, "name");
|
|
707
|
+
/******/ if (!descriptor || (!descriptor.writable && descriptor.configurable)) Object.defineProperty(x, "name", { value: "default", configurable: true });
|
|
708
|
+
/******/ };
|
|
709
|
+
/******/
|
|
710
|
+
/******/ /* webpack/runtime/publicPath */
|
|
711
|
+
/******/ __webpack_require__.p = "/";
|
|
712
|
+
/******/
|
|
713
|
+
/******/ /* webpack/runtime/jsonp chunk loading */
|
|
714
|
+
/******/ (() => {
|
|
715
|
+
/******/ // no baseURI
|
|
716
|
+
/******/
|
|
717
|
+
/******/ // object to store loaded and loading chunks
|
|
718
|
+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
719
|
+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
720
|
+
/******/ const installedChunks = {
|
|
721
|
+
/******/ "order": 0
|
|
722
|
+
/******/ };
|
|
723
|
+
/******/
|
|
724
|
+
/******/ __webpack_require__.f.j = (chunkId, promises) => {
|
|
725
|
+
/******/ // JSONP chunk loading for javascript
|
|
726
|
+
/******/ let installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
|
|
727
|
+
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
|
|
728
|
+
/******/
|
|
729
|
+
/******/ // a Promise means "currently loading".
|
|
730
|
+
/******/ if(installedChunkData) {
|
|
731
|
+
/******/ promises.push(installedChunkData[2]);
|
|
732
|
+
/******/ } else {
|
|
733
|
+
/******/ if(true) { // all chunks have JS
|
|
734
|
+
/******/ // setup Promise in chunk cache
|
|
735
|
+
/******/ const promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
|
736
|
+
/******/ promises.push(installedChunkData[2] = promise);
|
|
737
|
+
/******/
|
|
738
|
+
/******/ // create error before stack unwound to get useful stacktrace later
|
|
739
|
+
/******/ const error = new Error();
|
|
740
|
+
/******/ const loadingEnded = (event) => {
|
|
741
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
|
742
|
+
/******/ installedChunkData = installedChunks[chunkId];
|
|
743
|
+
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
|
744
|
+
/******/ if(installedChunkData) {
|
|
745
|
+
/******/ const errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
746
|
+
/******/ const realSrc = event && event.target && event.target.src;
|
|
747
|
+
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
|
748
|
+
/******/ error.name = 'ChunkLoadError';
|
|
749
|
+
/******/ error.type = errorType;
|
|
750
|
+
/******/ error.request = realSrc;
|
|
751
|
+
/******/ error.event = event;
|
|
752
|
+
/******/ installedChunkData[1](error);
|
|
753
|
+
/******/ }
|
|
754
|
+
/******/ }
|
|
755
|
+
/******/ };
|
|
756
|
+
/******/ __webpack_require__.l(__webpack_require__.p + __webpack_require__.u(chunkId), loadingEnded, "chunk-" + chunkId, chunkId);
|
|
757
|
+
/******/ }
|
|
758
|
+
/******/ }
|
|
759
|
+
/******/ }
|
|
760
|
+
/******/ };
|
|
761
|
+
/******/
|
|
762
|
+
/******/ // no prefetching
|
|
763
|
+
/******/
|
|
764
|
+
/******/ // no preloaded
|
|
765
|
+
/******/
|
|
766
|
+
/******/ // no HMR
|
|
767
|
+
/******/
|
|
768
|
+
/******/ // no HMR manifest
|
|
769
|
+
/******/
|
|
770
|
+
/******/ // no on chunks loaded
|
|
771
|
+
/******/
|
|
772
|
+
/******/ // install a JSONP callback for chunk loading
|
|
773
|
+
/******/ const webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
|
774
|
+
/******/ let [chunkIds, moreModules, runtime] = data;
|
|
775
|
+
/******/ // add "moreModules" to the modules object,
|
|
776
|
+
/******/ // then flag all "chunkIds" as loaded and fire callback
|
|
777
|
+
/******/ var moduleId, chunkId, i = 0;
|
|
778
|
+
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
|
779
|
+
/******/ for(moduleId in moreModules) {
|
|
780
|
+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
|
781
|
+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
782
|
+
/******/ }
|
|
783
|
+
/******/ }
|
|
784
|
+
/******/ if(runtime) var result = runtime(__webpack_require__);
|
|
785
|
+
/******/ }
|
|
786
|
+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
|
787
|
+
/******/ for(;i < chunkIds.length; i++) {
|
|
788
|
+
/******/ chunkId = chunkIds[i];
|
|
789
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
790
|
+
/******/ installedChunks[chunkId][0]();
|
|
791
|
+
/******/ }
|
|
792
|
+
/******/ installedChunks[chunkId] = 0;
|
|
793
|
+
/******/ }
|
|
794
|
+
/******/
|
|
795
|
+
/******/ }
|
|
796
|
+
/******/
|
|
797
|
+
/******/ const chunkLoadingGlobal = self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || [];
|
|
798
|
+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
799
|
+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
800
|
+
/******/ })();
|
|
801
|
+
/******/
|
|
802
|
+
/************************************************************************/
|
|
803
|
+
/******/
|
|
804
|
+
/******/ // startup
|
|
805
|
+
/******/ // Load entry module and return exports
|
|
806
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
807
|
+
/******/ let __webpack_exports__ = __webpack_require__("./src/order/index.js");
|
|
808
|
+
/******/
|
|
809
|
+
/******/ })()
|
|
810
|
+
;
|