@cnv-vn/track 0.2.0-beta.7 → 0.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cnv-track.esm.js +2 -2
- package/dist/cnv-track.min.js +2 -2
- package/dist/cnv-track.umd.cjs +2 -2
- package/dist/types/index.d.ts +155 -8
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# cnv-track.js
|
|
2
2
|
|
|
3
|
-
> Lightweight, async-first web analytics tracker — bundle size ≤
|
|
3
|
+
> Lightweight, async-first web analytics tracker — bundle size ≤ 30 KB gzipped.
|
|
4
4
|
|
|
5
5
|
`cnv-track.js` là Web JS SDK của hệ thống tracking CNV, có vai trò tương đương
|
|
6
6
|
Google Analytics / Facebook Pixel: nhúng một dòng `<script>` vào website
|
|
@@ -101,7 +101,7 @@ Schema mirror nguyên `com.cnv.tracking.dto.SegmentMessage` Java DTO
|
|
|
101
101
|
| File | Format | Mục đích |
|
|
102
102
|
| ------------------------ | :----: | ----------------------------------------- |
|
|
103
103
|
| `dist/cnv-track.js` | IIFE | Debug build, có sourcemap |
|
|
104
|
-
| `dist/cnv-track.min.js` | IIFE | **CDN target** — minified, <
|
|
104
|
+
| `dist/cnv-track.min.js` | IIFE | **CDN target** — minified, < 30KB gzipped |
|
|
105
105
|
| `dist/cnv-track.esm.js` | ESM | Cho Webpack / Vite / Rollup consumers |
|
|
106
106
|
| `dist/cnv-track.umd.cjs` | UMD | Legacy CommonJS / AMD / RequireJS |
|
|
107
107
|
| `dist/types/index.d.ts` | .d.ts | Bundled type declarations |
|
|
@@ -121,7 +121,7 @@ npm run build:analyze # Sinh dist/stats.html (rollup-plugin-visualizer)
|
|
|
121
121
|
npm run type-check # tsc --noEmit
|
|
122
122
|
npm run lint # ESLint + typescript-eslint
|
|
123
123
|
npm run format # Prettier
|
|
124
|
-
npm run size # size-limit — fail nếu vượt
|
|
124
|
+
npm run size # size-limit — fail nếu vượt 30KB
|
|
125
125
|
npm run verify # type-check + lint + format:check + build + size
|
|
126
126
|
```
|
|
127
127
|
|
package/dist/cnv-track.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cnv-vn/track v0.
|
|
2
|
+
* @cnv-vn/track v0.3.0-beta.1
|
|
3
3
|
* (c) 2026 CNV
|
|
4
4
|
* Released under the UNLICENSED license.
|
|
5
5
|
*/
|
|
6
|
-
const t=["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","zip","rar","7z","tar","gz","mp3","mp4","mov","wav","avi","mkv","dmg","exe","pkg","apk","msi","svg"];function n(t){return!!t&&"object"==typeof t&&1===t.nodeType&&"A"===t.tagName}function e(t){const n=t.lastIndexOf("/");return-1===n?t:t.slice(n+1)}function r(t){var n,e,r;let o=(null!==(n=t.textContent)&&void 0!==n?n:"").trim();return o||(o=(null!==(e=t.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),o||(o=(null!==(r=t.getAttribute("title"))&&void 0!==r?r:"").trim()),o.length>200?o.slice(0,200):o}const o=200;function i(t){let n="";try{n=(t.textContent||"").replace(/\s+/g," ").trim(),n||(n=(t.getAttribute("aria-label")||"").trim()),n||(n=(t.getAttribute("title")||"").trim()),n=n.normalize("NFC")}catch(t){return""}return n.length>o?n.slice(0,o):n}function c(t){const n=!1!==t.caseInsensitive;if("regex"===t.mode)return{mode:"regex",needle:t.value,ci:n,re:m(t.value,n)};const e=t.value.normalize("NFC");return{mode:t.mode,needle:n?e.toLowerCase():e,ci:n,re:null}}function u(t,n){try{return t.matches(n)}catch(t){return!1}}function l(t){try{if("A"===t.tagName){const n=t.getAttribute("href");return n?p(n):null}const n=t.getAttribute("formaction");if(n)return p(n);const e=t.getAttribute("data-href");if(e)return p(e);const r=t.closest("form");if(r){const t=r.getAttribute("action");if(t)return p(t)}return null}catch(t){return null}}function s(t){return"regex"===t.mode?{mode:"regex",needle:t.value,re:m(t.value,!0)}:{mode:t.mode,needle:t.value.toLowerCase(),re:null}}function a(t){if("startsWith"===t.mode)return{mode:"startsWith",needle:t.value,re:null};const n="glob"===t.mode?"^"+t.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":t.value;return{mode:t.mode,needle:t.value,re:m(n,!1)}}function f(t,n){return"startsWith"===t.mode?0===n.indexOf(t.needle):!t.re||b(t.re,n)}const d=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,h=/\+?\d[\d\s().-]{7,}\d/g;function y(t){if(!t)return t;try{return t.replace(d,"[email]").replace(h,"[phone]")}catch(n){return t}}function v(t){return!!t&&"object"==typeof t&&1===t.nodeType}function p(t){try{return new URL(t,location.href).href}catch(n){return t}}function m(t,n){try{return!t||t.length>1e3?null:new RegExp(t,n?"i":"")}catch(t){return null}}function b(t,n){try{return t.test(n)}catch(t){return!1}}function w(t,n){if("undefined"==typeof document)return()=>{};const e=(t=>{const n=t.globalThrottle||{},e=[],r=t.rules||[];for(let t=0;t<r.length;t++){const o=r[t];if(!o||!1===o.enabled)continue;if(!o.match||!o.event)continue;const i=o.match,u=o.throttle||{};e.push({rule:o,elementSpec:g(o),selector:i.selector||null,text:i.text?c(i.text):null,dest:i.destinationUrl?s(i.destinationUrl):null,urlScope:o.urlScope?a(o.urlScope):null,dedupeWindowMs:S(u.dedupeWindowMs,S(n.dedupeWindowMs,500)),maxPerPageview:S(u.maxPerPageview,S(n.maxPerPageview,1/0)),samplingRate:A(S(u.samplingRate,S(n.samplingRate,1)))})}return e.sort((t,n)=>(t.rule.priority||0)-(n.rule.priority||0)),e})(n);if(0===e.length)return()=>{};const r=new WeakMap;let o=0;const i=t=>{let n=r.get(t);return void 0===n&&(n=++o,r.set(t,n)),String(n)},u=new Map,l=new Map;let d=O();function h(n){try{if(0!==n.button)return;const r=O();r!==d&&(d=r,l.clear(),u.clear());const o=(t=>{const n=[];try{const e="function"==typeof t.composedPath?t.composedPath():[];if(e&&e.length>0){for(const t of e)v(t)&&n.push(t);return n}let r=t.target;for(;r;)v(r)&&n.push(r),r=r.parentNode}catch(t){}return n})(n);if(0===o.length)return;const c=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(t){return""}})();for(let r=0;r<e.length;r++){const s=e[r];if(s.urlScope&&!f(s.urlScope,c))continue;let a=null;for(let t=0;t<o.length;t++)if(x(s,o[t])){a=o[t];break}if(!a)continue;const d=s.rule.id;if((l.get(d)||0)>=s.maxPerPageview)return;const h=d+"#"+i(a),y=Date.now(),v=u.get(h);if(void 0!==v&&y-v<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;u.set(h,y),l.set(d,(l.get(d)||0)+1);const p=k(s.rule,a,n);return void j(()=>t.track("button_click",p))}}catch(t){}}try{document.addEventListener("click",h,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",h,!0)}catch(t){}u.clear(),l.clear()}}function g(t){const n=t.match;return n.element?n.element:n.selector||n.id||n.dataAttr||n.classes&&n.classes.length>0||n.destinationUrl?"any":void 0}function x(t,n){if(!((t,n)=>{if(!n)return(t=>{const n=t.tagName;if("BUTTON"===n||"A"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")})(t);if("any"===n)return!0;if("button"===n){const n=t.tagName;if("BUTTON"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")}return"link"===n?"A"===t.tagName:u(t,n)})(n,t.elementSpec))return!1;const e=t.rule.match;return!(t.selector&&!u(n,t.selector)||void 0!==e.id&&!((t,n)=>t.id===n)(n,e.id)||e.classes&&e.classes.length>0&&!((t,n)=>{try{for(let e=0;e<n.length;e++)if(!t.classList.contains(n[e]))return!1;return!0}catch(t){return!1}})(n,e.classes)||e.dataAttr&&!((t,n,e)=>{try{return!!t.hasAttribute(n)&&(void 0===e||t.getAttribute(n)===e)}catch(t){return!1}})(n,e.dataAttr.name,e.dataAttr.value)||t.text&&!((t,n)=>{const e=i(t);if("regex"===n.mode)return!!n.re&&b(n.re,e);const r=n.ci?e.toLowerCase():e;return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.text)||t.dest&&!((t,n)=>{const e=l(t);if(!e)return!1;if("regex"===n.mode)return!!n.re&&b(n.re,e);if("domain"===n.mode)try{return new URL(e).host.toLowerCase()===n.needle}catch(t){return!1}const r=e.toLowerCase();return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.dest))}function k(t,n,e){const r={},c=t.event.staticProps;if(c)for(const t of Object.keys(c))r[t]=c[t];const u=t.capture;if(u)try{if(u.text){const t=y(i(n));t&&(r.text=t)}if(u.href){const t=l(n);t&&(r.href=t)}if(u.elementId&&n.id&&(r.element_id=n.id),u.classes&&(r.element_classes=Array.from(n.classList)),u.dataAttrs&&u.dataAttrs.length>0)for(let t=0;t<u.dataAttrs.length;t++){const e=u.dataAttrs[t],o=n.getAttribute(e);null!==o&&(r[e]=y(o))}if(u.valueFrom){const t=((t,n)=>{try{const e=t.querySelector(n.selector)||(t.parentElement?t.parentElement.querySelector(n.selector):null);if(!e)return null;const r=n.attr?e.getAttribute(n.attr):e.textContent||"";if(null===r)return null;const i=y(r.replace(/\s+/g," ").trim());return i.length>o?i.slice(0,o):i}catch(t){return null}})(n,u.valueFrom);null!==t&&(r[u.valueFrom.as]=t)}u.selectorPath&&(r.selector_path=((t,n=5)=>{try{const e=[];let r=t,o=0;for(;r&&1===r.nodeType&&o<n;){let t=r.tagName.toLowerCase();if(r.id){e.unshift(t+"#"+r.id);break}const n=Array.from(r.classList).slice(0,2).join(".");n&&(t+="."+n),e.unshift(t),r=r.parentElement,o++}return e.join(" > ")}catch(t){return""}})(n)),u.position&&(r.x=e.clientX,r.y=e.clientY)}catch(t){}return r.rule_id=t.id,t.name&&(r.rule_name=t.name),t.event&&t.event.name&&(r.event_name=t.event.name),r.tag=n.tagName.toLowerCase(),r}function j(t){try{t()}catch(t){}}function O(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}function S(t,n){return"number"!=typeof t||isNaN(t)?n:t}function A(t){return t<0?0:t>1?1:t}const T="__cnvPatched";function I(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}const _=["q","s","query","search","keyword"],P={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},M={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};function D(t){try{t()}catch(t){}}function U(t,n,e,r){return new(e||(e=Promise))((o,i)=>{function c(t){try{l(r.next(t))}catch(t){i(t)}}function u(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(t=>{t(n)})).then(c,u)}l((r=r.apply(t,n||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const C="undefined"!=typeof window&&"undefined"!=typeof document;function N(t){if(!C)return null;try{const n=document.cookie;if(!n)return null;const e=encodeURIComponent(t),r=n.split(";");for(let n=0;n<r.length;n++){const o=r[n].indexOf("=");if(o<0)continue;const i=r[n].slice(0,o).trim();if(i===e||i===t)try{return decodeURIComponent(r[n].slice(o+1))}catch(t){return r[n].slice(o+1)}}return null}catch(t){return null}}function $(t,n,e={}){var r,o,i;if(!C)return!1;try{let c=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(c+=`; path=${null!==(r=e.path)&&void 0!==r?r:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const t=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${t}`,c+=`; expires=${new Date(Date.now()+1e3*t).toUTCString()}`}return c+=`; SameSite=${null!==(o=e.sameSite)&&void 0!==o?o:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,N(t)===n}catch(t){return!1}}function L(){if(!C)return!1;try{const t="__cnv_probe__";return localStorage.setItem(t,"1"),localStorage.removeItem(t),!0}catch(t){return!1}}function R(t){if(!L())return null;try{return localStorage.getItem(t)}catch(t){return null}}function q(t,n){if(!L())return!1;try{return localStorage.setItem(t,n),!0}catch(t){return!1}}function z(t){if(!L())return!1;try{return localStorage.removeItem(t),!0}catch(t){return!1}}function E(){if(!C)return!1;try{const t="__cnv_probe__";return sessionStorage.setItem(t,"1"),sessionStorage.removeItem(t),!0}catch(t){return!1}}const B={path:"/config",timeoutMs:4e3,ttlMs:3e5};function J(t,n){var e,r;const o=null!=n?n:Object.assign({enabled:!0},B);return void 0===t?Object.assign({},o):!0===t?Object.assign(Object.assign({},o),{enabled:!0}):!1===t?Object.assign(Object.assign({},o),{enabled:!1}):{enabled:null===(e=t.enabled)||void 0===e||e,path:null!==(r=t.path)&&void 0!==r?r:o.path,timeoutMs:"number"==typeof t.timeoutMs?t.timeoutMs:o.timeoutMs,ttlMs:"number"==typeof t.ttlMs?t.ttlMs:o.ttlMs}}function W(t){return"_cnv_cfg_"+t}function Z(t){const n=R(W(t));if(!n)return null;try{const t=JSON.parse(n);return t&&"object"==typeof t&&t.envelope?t:null}catch(t){return null}}function G(t,n,e){try{const r={etag:n,envelope:e,fetchedAt:Date.now()};q(W(t),JSON.stringify(r))}catch(t){}}function F(t){const n=null==t?void 0:t.buttonTracking;if(!n||!1===n.enabled)return null;const e=Array.isArray(n.rules)?n.rules:[];return 0===e.length?null:{rules:e,globalThrottle:n.globalThrottle}}const Q=["gclid","fbclid","ttclid","msclkid","dclid"],V=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function H(t,n){try{return t()}catch(t){return n}}function K(){const t=H(()=>window.location.href,"");let n="",e="",r="";if(t)try{const o=new URL(t);n=o.pathname,e=o.search,r=o.hash}catch(t){}return{url:t,path:n,search:e,hash:r,title:H(()=>document.title,""),referrer:H(()=>document.referrer,"")}}function X(t){var n,e;let r="@cnv-vn/track",o="0.0.0-dev";try{r="@cnv-vn/track"}catch(t){}try{o="0.2.0-beta.7"}catch(t){}return{name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:r,version:null!==(e=null==t?void 0:t.version)&&void 0!==e?e:o}}const Y="0123456789abcdef";function tt(t){return Y[t>>>4&15]+Y[15&t]}function nt(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const t=new Uint8Array(16);return crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128,tt(t[0])+tt(t[1])+tt(t[2])+tt(t[3])+"-"+tt(t[4])+tt(t[5])+"-"+tt(t[6])+tt(t[7])+"-"+tt(t[8])+tt(t[9])+"-"+tt(t[10])+tt(t[11])+tt(t[12])+tt(t[13])+tt(t[14])+tt(t[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}const et=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function rt(t){return"string"==typeof t&&et.test(t)}const ot="_cnv_cid";function it(t={}){const n=N(ot),e=R(ot);let r=null;return rt(n)?r=n:rt(e)&&(r=e),r||(r=nt()),ct(r,t),r}function ct(t,n={}){var e;$(ot,t,{domain:n.cookieDomain,maxAgeDays:null!==(e=n.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),q(ot,t)}const ut="1.0";function lt(){return(new Date).toISOString()}function st(t,n){var e;const r=null!==(e=n.timestamp)&&void 0!==e?e:lt(),o=Object.assign(Object.assign({},n.context),{projectId:n.projectId,schemaVersion:ut}),i={type:t,messageId:nt(),anonymousId:n.anonymousId,timestamp:r,originalTimestamp:r,context:o};return n.userId&&(i.userId=n.userId),n.sessionId&&(i.sessionId=n.sessionId),n.integrations&&(i.integrations=n.integrations),i}const at="_cnv_sid";function ft(t){if(!t)return null;const n=t.lastIndexOf(".");if(n<0)return null;const e=t.slice(0,n),r=Number(t.slice(n+1));return!rt(e)||!Number.isFinite(r)||r<=0?null:{id:e,lastActivity:r}}function dt(t={}){const n=Date.now(),e=(t=>{var n;return 6e4*(null!==(n=t.timeoutMinutes)&&void 0!==n?n:30)})(t),r=ft(N(at)),o=ft((t=>{if(!E())return null;try{return sessionStorage.getItem(t)}catch(t){return null}})(at));let i=null;for(const t of[r,o])t&&(n-t.lastActivity>e||(!i||t.lastActivity>i.lastActivity)&&(i=t));const c=i?{id:i.id,lastActivity:n}:{id:nt(),lastActivity:n};return ht(c,t),c.id}function ht(t,n={}){var e;const r=(t=>`${t.id}.${t.lastActivity}`)(t),o=null!==(e=n.timeoutMinutes)&&void 0!==e?e:30;$(at,r,{domain:n.cookieDomain,maxAgeDays:o/1440,sameSite:"Lax"}),((t,n)=>{if(!E())return!1;try{return sessionStorage.setItem(t,n),!0}catch(t){return!1}})(at,r)}class yt{constructor(t){var n,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"storageKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"flushing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"onlineHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.storageKey=null!==(n=t.storageKey)&&void 0!==n?n:"_cnv_rq",this.maxMessages=null!==(e=t.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(t){if(t&&0!==t.length)try{const n=this.read();for(n.push(t);n.length>1&&vt(n)>this.maxMessages;)n.shift();this.write(n),this.config.debug&&console.log("[cnv-track] retry queued",t.length,"buffered",vt(n))}catch(t){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const t=this.read();if(0===t.length)return Promise.resolve();this.flushing=!0,this.write([]);const n=()=>{this.flushing=!1};return t.reduce((t,n)=>t.then(()=>this.config.resend(n)),Promise.resolve()).then(n,n)}size(){return vt(this.read())}clear(){try{z(this.storageKey)}catch(t){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(t){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const t=()=>{this.flush()};try{window.addEventListener("online",t),this.onlineHandler=t}catch(t){}}read(){const t=R(this.storageKey);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(t=>Array.isArray(t)&&t.length>0):[]}catch(t){return[]}}write(t){0!==t.length?q(this.storageKey,JSON.stringify(t)):z(this.storageKey)}}function vt(t){let n=0;for(const e of t)n+=e.length;return n}class pt{constructor(t){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"retryQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.retryQueue=new yt({debug:t.debug,resend:t=>this.send(t)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}enqueue(t){this.destroyed||(this.buffer.push(t),this.buffer.length>=this.config.flushAt?this.flush():this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush()},this.config.flushInterval)))}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),0===this.buffer.length)return Promise.resolve();const t=this.buffer;return this.buffer=[],this.send(t)}bufferedCount(){return this.buffer.length}destroy(){this.destroyed||(this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),this.uninstallPageLifecycleHandlers(),this.retryQueue.destroy())}send(t){try{return this.config.useBatch?this.sendBatch(t):Promise.all(t.map(t=>this.sendSingle(t))).then(()=>{})}catch(t){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",t),Promise.resolve()}}sendBatch(t){var n;const e=lt(),r={batch:t.map(t=>mt(t,e)),context:Object.assign(Object.assign({},null!==(n=this.config.batchContext)&&void 0!==n?n:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),r,t)}sendSingle(t){const n=mt(t,lt());return this.post(this.singleUrl(t.type),n,[t])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(t){const n=this.config.singlePath.replace("{type}",t);return this.config.endpoint+n+"?projectId="+encodeURIComponent(this.config.projectId)}post(t,n,e){const r=JSON.stringify(n),o=((t,n)=>{try{return new Blob([t],{type:n})}catch(t){return null}})(r,this.config.contentType),i=o?o.size:(t=>{try{return new Blob([t]).size}catch(n){return t.length}})(r),c=i>65536?null:e;return c&&"undefined"!=typeof navigator&&!1===navigator.onLine?(this.retryQueue.stash(c),this.config.debug&&console.log("[cnv-track] offline; queued for retry",t),Promise.resolve()):o&&this.sendViaBeacon(t,o)?(this.config.debug&&console.log("[cnv-track] beacon",t),Promise.resolve()):this.sendViaFetch(t,r,c)}sendViaBeacon(t,n){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(n.size>65536)return!1;try{return navigator.sendBeacon(t,n)}catch(t){return!1}}sendViaFetch(t,n,e){return"function"!=typeof fetch?(this.config.debug&&console.warn("[cnv-track] no transport available; queued for retry"),e&&this.retryQueue.stash(e),Promise.resolve()):fetch(t,{method:"POST",headers:{"Content-Type":this.config.contentType},body:n,keepalive:!0,credentials:"omit",mode:"cors"}).then(n=>{this.config.debug&&console.log("[cnv-track] fetch flushed",t,n.status)}).catch(n=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",t,n),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const t=()=>{this.flush()},n=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",t),document.addEventListener("visibilitychange",n),this.handlers={pagehide:t,visibility:n}}catch(t){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(t){}this.handlers=null}}}function mt(t,n){return Object.assign(Object.assign({},t),{sentAt:n})}const bt="_cnv_uid",wt="_cnv_traits";function gt(){return N(bt)||R(bt)}const xt={endpoint:"https://tracking.cnvcdp.com/js/v1",batchPath:"/batch",singlePath:"/{type}",useBatch:!0,contentType:"text/plain",debug:!1,allowAdTracking:!0,cookieMaxAgeDays:730,sessionTimeoutMinutes:30,flushAt:20,flushInterval:5e3,autoPageview:!0,autotrack:!1,integrations:{},remoteConfig:J(void 0)},kt={analytics:!0,marketing:!0};function jt(t,n){if(!Array.isArray(n)||0===n.length)return;const e=n;try{switch(e[0]){case"init":t.init(e[1],e[2]);break;case"pageview":t.pageview(e[1],e[2]);break;case"page":t.page(e[1],e[2]);break;case"screen":t.screen(e[1],e[2]);break;case"track":t.track(e[1],e[2]);break;case"identify":t.identify(e[1],e[2]);break;case"alias":t.alias(e[1],e[2]);break;case"group":t.group(e[1],e[2]);break;case"reset":t.reset();break;case"flush":t.flush();break;case"consent":t.consent(e[1]);break;case"set":t.set(e[1])}}catch(t){}}const Ot=/^(https:|zalo:)/i;class St extends Error{constructor(t){super(`loginWithZalo() thất bại: ${t}`),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:t}),this.name="ZaloQrLoginError"}}function At(t,n,e,r){return`${t}${n}?${new URLSearchParams(Object.assign({projectId:e},r)).toString()}`}function Tt(t,n){return U(this,void 0,void 0,function*(){var e,r,o;if(!t.projectId||!t.endpoint)throw new St("not-initialized");if(!t.zaloQrLoginEnabled)throw new St("disabled");if(!t.consentGranted)throw new St("consent-required");const i={preferSse:null===(e=null==n?void 0:n.preferSse)||void 0===e||e,pollIntervalMs:null!==(r=null==n?void 0:n.pollIntervalMs)&&void 0!==r?r:2e3,autoIdentify:null===(o=null==n?void 0:n.autoIdentify)||void 0===o||o},c=t.projectId,u=t.endpoint,l=yield function(t,n){return U(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,r=e?setTimeout(()=>e.abort(),8e3):null;let o;try{o=yield fetch(At(t,"/zalo-qr/session",n),{method:"POST",credentials:"omit",mode:"cors",signal:e?e.signal:void 0})}catch(t){throw new St("network")}finally{r&&clearTimeout(r)}if(!o.ok)throw new St(401===(i=o.status)?"invalid-project-key":403===i?"project-suspended":"network");var i;return(t=>{const n=t;if(!n||"string"!=typeof n.sessionToken||!n.sessionToken||"string"!=typeof n.miniAppDeepLink||!Ot.test(n.miniAppDeepLink)||"number"!=typeof n.expiresInSeconds||!Number.isFinite(n.expiresInSeconds)||n.expiresInSeconds<=0)throw new St("network");return{sessionToken:n.sessionToken,miniAppDeepLink:n.miniAppDeepLink,expiresInSeconds:n.expiresInSeconds}})(yield o.json())})}(u,c),s=((t,n,e,r,o)=>{let i=!1,c=null,u=null,l=null,s=null,a=null;const f=()=>{c&&(c.close(),c=null),null!==u&&(clearInterval(u),u=null),null!==l&&(clearTimeout(l),l=null),null!==s&&(clearTimeout(s),s=null)};return{promise:new Promise((d,h)=>{a=h;const y=t=>{i||(i=!0,f(),t())},v=t=>{"success"===t.status?y(()=>d((t=>({contactId:t.contactId,fullName:t.fullName,level:t.level,xp:t.xp}))(t))):"denied"===t.status?y(()=>h(new St("denied"))):"expired"===t.status&&y(()=>h(new St("expired")))},p=()=>{null!==u||i||(u=setInterval(()=>{fetch(At(t,"/zalo-qr/status",n,{sessionToken:e}),{method:"GET",credentials:"omit",mode:"cors"}).then(t=>404===t.status?v({status:"expired"}):t.ok?t.json().then(t=>v(t)):void 0).catch(()=>{})},o.pollIntervalMs))};if(o.preferSse&&"undefined"!=typeof EventSource)try{c=new EventSource(At(t,"/zalo-qr/stream",n,{sessionToken:e})),c.addEventListener("success",t=>{try{v(JSON.parse(t.data))}catch(t){}}),c.addEventListener("denied",()=>v({status:"denied"})),c.onerror=()=>{null!==s||i||(s=setTimeout(()=>{s=null,i||(c&&(c.close(),c=null),p())},3e3))}}catch(t){p()}else p();l=setTimeout(()=>{y(()=>h(new St("expired")))},1e3*r)}),cancel(){i||(i=!0,f(),null==a||a(new St("cancelled")))}}})(u,c,l.sessionToken,l.expiresInSeconds,i),a=s.promise.then(n=>{try{if(i.autoIdentify&&null!=n.contactId){const e=String(n.contactId),r=t.getUserId();null!=r&&r!==e?t.alias(e,r):t.identify(e,Object.assign(Object.assign(Object.assign({},n.fullName?{name:n.fullName}:{}),n.level?{level:n.level}:{}),null!=n.xp?{xp:n.xp}:{}))}}catch(t){}return n});return{sessionToken:l.sessionToken,qrPayload:l.miniAppDeepLink,expiresInSeconds:l.expiresInSeconds,result:a,cancel:s.cancel,retry(){return s.cancel(),Tt(t,n)}}})}const It="0.2.0-beta.7",_t="@cnv-vn/track",Pt=function(){let o=null,i=Object.assign({},xt),c=Object.assign({},kt),u=null,l=!1,s=null,a=null;function f(t){const n=Object.assign({},i);return t?(void 0!==t.endpoint&&(n.endpoint=(e=t.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==t.batchPath&&(n.batchPath=t.batchPath),void 0!==t.singlePath&&(n.singlePath=t.singlePath),void 0!==t.useBatch&&(n.useBatch=t.useBatch),void 0!==t.contentType&&(n.contentType=t.contentType),void 0!==t.debug&&(n.debug=t.debug),void 0!==t.allowAdTracking&&(n.allowAdTracking=t.allowAdTracking),void 0!==t.cookieDomain&&(n.cookieDomain=t.cookieDomain),void 0!==t.cookieMaxAgeDays&&(n.cookieMaxAgeDays=t.cookieMaxAgeDays),void 0!==t.sessionTimeoutMinutes&&(n.sessionTimeoutMinutes=t.sessionTimeoutMinutes),void 0!==t.flushAt&&(n.flushAt=t.flushAt),void 0!==t.flushInterval&&(n.flushInterval=t.flushInterval),void 0!==t.autoPageview&&(n.autoPageview=t.autoPageview),void 0!==t.autotrack&&(n.autotrack=t.autotrack),void 0!==t.integrations&&(n.integrations=t.integrations),void 0!==t.remoteConfig&&(n.remoteConfig=J(t.remoteConfig,i.remoteConfig)),n):n;var e}function d(){return u||(u=new pt({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,projectId:null!=o?o:"",debug:i.debug}),u)}function h(){var t;if(!o)return null;const n=((t={})=>{var n;const e={page:K(),screen:{width:H(()=>window.screen.width,0),height:H(()=>window.screen.height,0),density:H(()=>window.devicePixelRatio||1,1)},locale:H(()=>navigator.language||"",""),timezone:H(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:H(()=>navigator.userAgent||"",""),library:X(t.library)},r=((t,n=!0)=>{const e=H(()=>window.location.search,"");if(!e)return;let r;try{r=new URLSearchParams(e)}catch(t){return}const o={};let i=!1;for(const[t,n]of V){const e=r.get(t);e&&e.length>0&&(o[n]=e,i=!0)}if(n){const t={};for(const n of Q){const e=r.get(n);e&&e.length>0&&(t[n]=e)}Object.keys(t).length>0&&(o.clickIds=t,i=!0)}return i?o:void 0})(0,null===(n=t.allowAdTracking)||void 0===n||n);return r&&(e.campaign=r),e})({allowAdTracking:i.allowAdTracking});return c.analytics&&c.marketing||(n.consent=Object.assign({},c)),{anonymousId:it({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),sessionId:dt({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),userId:null!==(t=gt())&&void 0!==t?t:void 0,context:n,projectId:o,integrations:Object.keys(i.integrations).length>0?i.integrations:void 0}}function y(t){i.debug&&console.warn(`[cnv-track] ${t}() called before init()`)}function v(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("track");const r=((t,n,e)=>{const r=st("track",e);return r.event=t,r.properties=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}}return{get initialized(){return l},get projectId(){return o},get endpoint(){return i.endpoint},isZaloQrLoginEnabled:()=>!!o&&(t=>{const n=Z(t);return!n||!1!==(null===(r=null==(e=n.envelope)?void 0:e.zaloQrLogin)||void 0===r?void 0:r.enabled);var e,r})(o),get consentGranted(){return c.analytics&&c.marketing},init(h,y){try{if(!h||"string"!=typeof h)return;if(i=f(y),(null==y?void 0:y.consent)&&(c=Object.assign(Object.assign({},c),y.consent)),o=h,u&&u.destroy(),u=null,d(),l=!0,it({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),dt({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),s){try{s()}catch(t){}s=null}const p={page(t,n){},track(t,n){return v(t,n)}};if(i.autotrack){let o=i.autotrack;i.remoteConfig.enabled&&"object"==typeof o&&o.buttonTracking&&(o=Object.assign(Object.assign({},o),{buttonTracking:void 0})),s=function(o,i){const c=void 0===(u=i)||!1===u?Object.assign(Object.assign({},M),{searchParams:_}):!0===u?Object.assign(Object.assign({},P),{searchParams:_}):{spa:null===(l=u.spa)||void 0===l||l,outboundClicks:null===(s=u.outboundClicks)||void 0===s||s,scroll:null===(a=u.scroll)||void 0===a||a,downloads:null===(f=u.downloads)||void 0===f||f,siteSearch:null===(d=u.siteSearch)||void 0===d||d,downloadExtensions:u.downloadExtensions,searchParams:null!==(h=u.searchParams)&&void 0!==h?h:_,buttonTracking:u.buttonTracking};var u,l,s,a,f,d,h;c.outboundClicks=!1,c.downloads=!1,c.scroll=!1,c.siteSearch=!1;const y=[];let v=null;function p(t){if(c.siteSearch)try{const n=null!=t?t:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(t){return""}})();if(n===v)return;v=n;const e=((t,n=_)=>{try{if(!t){if("undefined"==typeof location)return null;t=location.href}const e=t instanceof URL?t:new URL(t,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(t){return"http://localhost/"}})());if(!e.search)return null;for(const t of n){const n=e.searchParams.get(t);if(null===n)continue;const r=n.trim();if(0!==r.length)return{query:r,param:t}}return null}catch(t){return null}})(n,c.searchParams);e&&D(()=>o.track("Site Searched",{query:e.query,param:e.param}))}catch(t){}}if(c.outboundClicks||c.downloads){const i=(o=>{var i;if("undefined"==typeof document)return()=>{};const c=new Set((null!==(i=o.downloadExtensions)&&void 0!==i?i:t).map(t=>t.toLowerCase())),u=!!o.onOutbound,l=!!o.onDownload;if(!u&&!l)return()=>{};function s(t){var i,s;try{if(0!==t.button)return;if(t.defaultPrevented)return;const a=(t=>{const e="function"==typeof t.composedPath?t.composedPath():[];if(e.length>0)for(const t of e)if(n(t))return t;let r=t.target;for(;r;){if(n(r))return r;r=r.parentNode}return null})(t);if(!a)return;const f=a.getAttribute("href");if(!f)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(f))return;if(f.startsWith("#"))return;const d=(t=>{try{return new URL(t,location.href)}catch(t){return null}})(f);if(!d)return;let h=!1;if(l){const t=a.hasAttribute("download"),n=(t=>{const n=e(t),r=n.lastIndexOf(".");return r<=0||r===n.length-1?null:n.slice(r+1).toLowerCase()})(d.pathname);(t||n&&c.has(n))&&(h=!0,null===(i=o.onDownload)||void 0===i||i.call(o,{url:d.href,fileName:e(d.pathname),fileExtension:null!=n?n:"",text:r(a)}))}u&&!h&&d.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(t){return""}})()&&d.host&&(null===(s=o.onOutbound)||void 0===s||s.call(o,{url:d.href,host:d.host,text:r(a),target:a.target||"_self"}))}catch(t){}}try{document.addEventListener("click",s,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",s,!0)}catch(t){}}})({downloadExtensions:c.downloadExtensions,onOutbound:c.outboundClicks?t=>D(()=>o.track("Clicked",t)):void 0,onDownload:c.downloads?t=>D(()=>o.track("File Downloaded",t)):void 0});y.push(i)}c.buttonTracking&&c.buttonTracking.rules&&c.buttonTracking.rules.length>0&&y.push(w(o,c.buttonTracking));let m=null;if(c.scroll&&(m=(t=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let n=!1,e=null,r=!1;function o(){if(e=null,!r&&!n)try{const e=document.documentElement,r=document.body,o=Math.max(e?e.scrollHeight:0,r?r.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(o<=i)return n=!0,c(),void t(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/o>=.9&&(n=!0,c(),t(90))}catch(t){}}function i(){if(null===e)try{e=window.requestAnimationFrame(o)}catch(t){o()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(t){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}return{destroy(){r=!0,c()},reset(){if(!r){n=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}}}}})(t=>{D(()=>o.track("Scrolled",{percent:t}))}),y.push(()=>null==m?void 0:m.destroy())),c.spa){const t=[],n=function(){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let n=I();function e(){try{const e=I();if(e===n)return;n=e,(n=>{const e=setTimeout(()=>{const n=t.indexOf(e);-1!==n&&t.splice(n,1),D(()=>o.page())},0);t.push(e),null==m||m.reset(),p(n)})(e)}catch(t){}}const r=history.pushState,i=history.replaceState,c=!0===r[T],u=!0===i[T];if(!c){function a(...t){r.apply(this,t),e()}a[T]=!0,history.pushState=a}if(!u){function f(...t){i.apply(this,t),e()}f[T]=!0,history.replaceState=f}const l=()=>e(),s=()=>e();try{window.addEventListener("popstate",l),window.addEventListener("hashchange",s)}catch(d){}return()=>{try{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",s)}catch(t){}try{!c&&history.pushState[T]&&(history.pushState=r),!u&&history.replaceState[T]&&(history.replaceState=i)}catch(t){}}}();y.push(()=>{for(let n=0;n<t.length;n++)clearTimeout(t[n]);t.length=0,n()})}return p(),()=>{for(;y.length>0;){const t=y.pop();try{null==t||t()}catch(t){}}v=null}}(p,o)}if(a){try{a()}catch(t){}a=null}if(i.remoteConfig.enabled&&o){const t=t=>{if(a){try{a()}catch(t){}a=null}t&&t.rules&&t.rules.length>0&&(a=w(p,t))},n=(t=>{const n=Z(t);return n?F(n.envelope):null})(o);n&&t(n),function(t){return U(this,void 0,void 0,function*(){if(!t.projectId)return{status:"error"};const n=Z(t.projectId);if(n&&Date.now()-n.fetchedAt<t.ttlMs)return{status:"unchanged"};const e=yield function(t){return U(this,void 0,void 0,function*(){var n;if("function"!=typeof fetch)return null;const e=t.endpoint+t.path+"?projectId="+encodeURIComponent(t.projectId),r="undefined"!=typeof AbortController?new AbortController:null,o=r?setTimeout(()=>r.abort(),t.timeoutMs):null;try{const o={};t.etag&&(o["If-None-Match"]=t.etag);const i=yield fetch(e,{method:"GET",headers:o,credentials:"omit",mode:"cors",signal:r?r.signal:void 0});if(304===i.status)return{envelope:null,etag:null!==(n=t.etag)&&void 0!==n?n:"",notModified:!0};if(!i.ok)return null;const c=i.headers&&"function"==typeof i.headers.get?i.headers.get("ETag"):null;return{envelope:yield i.json(),etag:null!=c?c:"",notModified:!1}}catch(t){return null}finally{o&&clearTimeout(o)}})}({endpoint:t.endpoint,path:t.path,projectId:t.projectId,timeoutMs:t.timeoutMs,etag:null==n?void 0:n.etag});return e?e.notModified?(n&&G(t.projectId,n.etag,n.envelope),{status:"unchanged"}):e.envelope?(G(t.projectId,e.etag,e.envelope),{status:"updated",buttonTracking:F(e.envelope)}):{status:"error"}:{status:"error"}})}({endpoint:i.endpoint,path:i.remoteConfig.path,projectId:o,timeoutMs:i.remoteConfig.timeoutMs,ttlMs:i.remoteConfig.ttlMs}).then(n=>{"updated"===n.status&&t(n.buttonTracking)}).catch(()=>{})}}catch(t){}},pageview(t,n){},page(t,n){},screen(t,n){},track:v,identify(t,n){try{if("string"!=typeof t||0===t.length)return;((t,n,e={})=>{var r,o;if(t&&($(bt,t,{domain:e.cookieDomain,maxAgeDays:null!==(r=e.cookieMaxAgeDays)&&void 0!==r?r:730,sameSite:"Lax"}),q(bt,t),null!=n)){const t=null!==(o=(()=>{const t=R(wt);if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(t){return null}})())&&void 0!==o?o:{},e=Object.assign(Object.assign({},t),n);try{q(wt,JSON.stringify(e))}catch(t){}}})(t,n,{cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays});const e=h();if(!e)return y("identify");const r=((t,n,e)=>{var r;const o=st("identify",e);return t&&(o.userId=t),o.traits=null!==(r=n)&&void 0!==r?r:{},o})(t,n,e);d().enqueue(r)}catch(t){}},alias(t,n){},group(t,n){},reset(){try{((t={})=>{((t,n={})=>{var e;if(!C)return!1;try{let r=`${encodeURIComponent(t)}=`;return r+=`; path=${null!==(e=n.path)&&void 0!==e?e:"/"}`,n.domain&&(r+=`; domain=${n.domain}`),r+="; max-age=0",r+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=r,null===N(t)}catch(t){return!1}})(bt,{domain:t.cookieDomain}),z(bt),z(wt)})({cookieDomain:i.cookieDomain}),((t={})=>{ct(nt(),t)})({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),((t={})=>{ht({id:nt(),lastActivity:Date.now()},t)})({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes})}catch(t){}},flush(){try{u&&u.flush()}catch(t){}},consent(t){try{c=Object.assign(Object.assign({},c),t)}catch(t){}},set(t){try{i=f(t),t.consent&&(c=Object.assign(Object.assign({},c),t.consent)),u&&u.setConfig({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,debug:i.debug})}catch(t){}},destroy(){if(s){try{s()}catch(t){}s=null}if(a){try{a()}catch(t){}a=null}u&&u.destroy(),u=null,l=!1,o=null,i=Object.assign({},xt),c=Object.assign({},kt)}}}();function Mt(t){return Tt({projectId:Pt.projectId,endpoint:Pt.endpoint,zaloQrLoginEnabled:Pt.isZaloQrLoginEnabled(),consentGranted:Pt.consentGranted,identify:Pt.identify,alias:Pt.alias,getUserId:gt},t)}"undefined"!=typeof window&&(t=>{if("undefined"==typeof window)return()=>{};const n=window.cnvQ;if(n&&n.__loaded)return()=>{};const e=window.cnvQ=null!=n?n:[],r=e.splice(0,e.length);e.push.bind(e),e.push=(...n)=>{for(const e of n)jt(t,e);return e.length},e.__loaded=!0;for(const n of r)jt(t,n)})(Pt);const Dt=Object.assign(Pt,{version:It,name:_t,schemaVersion:ut,loginWithZalo:Mt});export{_t as NAME,ut as SCHEMA_VERSION,It as VERSION,St as ZaloQrLoginError,Dt as default,Mt as loginWithZalo};
|
|
6
|
+
function n(n){try{n()}catch(n){}}function t(n,t){try{return n()}catch(n){return t}}function e(t){return t&&n(t),null}const o=["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","zip","rar","7z","tar","gz","mp3","mp4","mov","wav","avi","mkv","dmg","exe","pkg","apk","msi","svg"];function r(n){return!!n&&"object"==typeof n&&1===n.nodeType&&"A"===n.tagName}function i(n){const t=n.lastIndexOf("/");return-1===t?n:n.slice(t+1)}function c(n){var t,e,o;let r=(null!==(t=n.textContent)&&void 0!==t?t:"").trim();return r||(r=(null!==(e=n.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),r||(r=(null!==(o=n.getAttribute("title"))&&void 0!==o?o:"").trim()),r.length>200?r.slice(0,200):r}const l=200;function a(n){let t="";try{t=(n.textContent||"").replace(/\s+/g," ").trim(),t||(t=(n.getAttribute("aria-label")||"").trim()),t||(t=(n.getAttribute("title")||"").trim()),t=t.normalize("NFC")}catch(n){return""}return t.length>l?t.slice(0,l):t}function u(n){const t=!1!==n.caseInsensitive;if("regex"===n.mode)return{mode:"regex",needle:n.value,ci:t,re:w(n.value,t)};const e=n.value.normalize("NFC");return{mode:n.mode,needle:t?e.toLowerCase():e,ci:t,re:null}}function s(n,t){try{return n.matches(t)}catch(n){return!1}}function d(n){try{if("A"===n.tagName){const t=n.getAttribute("href");return t?y(t):null}const t=n.getAttribute("formaction");if(t)return y(t);const e=n.getAttribute("data-href");if(e)return y(e);const o=n.closest("form");if(o){const n=o.getAttribute("action");if(n)return y(n)}return null}catch(n){return null}}function h(n){return"regex"===n.mode?{mode:"regex",needle:n.value,re:w(n.value,!0)}:{mode:n.mode,needle:n.value.toLowerCase(),re:null}}function p(n){if("startsWith"===n.mode)return{mode:"startsWith",needle:n.value,re:null};const t="glob"===n.mode?"^"+n.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":n.value;return{mode:n.mode,needle:n.value,re:w(t,!1)}}function f(n,t){return"startsWith"===n.mode?0===t.indexOf(n.needle):!n.re||x(n.re,t)}const v=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,g=/\+?\d[\d\s().-]{7,}\d/g;function m(n){if(!n)return n;try{return n.replace(v,"[email]").replace(g,"[phone]")}catch(t){return n}}function b(n){return!!n&&"object"==typeof n&&1===n.nodeType}function y(n){try{return new URL(n,location.href).href}catch(t){return n}}function w(n,t){try{return!n||n.length>1e3?null:new RegExp(n,t?"i":"")}catch(n){return null}}function x(n,t){try{return n.test(t)}catch(n){return!1}}function _(t,e){if("undefined"==typeof document)return()=>{};const o=(n=>{const t=n.globalThrottle||{},e=[],o=n.rules||[];for(let n=0;n<o.length;n++){const r=o[n];if(!r||!1===r.enabled)continue;if(!r.match||!r.event)continue;const i=r.match,c=r.throttle||{};e.push({rule:r,elementSpec:k(r),selector:i.selector||null,text:i.text?u(i.text):null,dest:i.destinationUrl?h(i.destinationUrl):null,urlScope:r.urlScope?p(r.urlScope):null,dedupeWindowMs:j(c.dedupeWindowMs,j(t.dedupeWindowMs,500)),maxPerPageview:j(c.maxPerPageview,j(t.maxPerPageview,1/0)),samplingRate:z(j(c.samplingRate,j(t.samplingRate,1)))})}return e.sort((n,t)=>(n.rule.priority||0)-(t.rule.priority||0)),e})(e);if(0===o.length)return()=>{};const r=new WeakMap;let i=0;const c=n=>{let t=r.get(n);return void 0===t&&(t=++i,r.set(n,t)),String(t)},l=new Map,a=new Map;let s=C();function d(e){try{if(0!==e.button)return;const r=C();r!==s&&(s=r,a.clear(),l.clear());const i=(n=>{const t=[];try{const e="function"==typeof n.composedPath?n.composedPath():[];if(e&&e.length>0){for(const n of e)b(n)&&t.push(n);return t}let o=n.target;for(;o;)b(o)&&t.push(o),o=o.parentNode}catch(n){}return t})(e);if(0===i.length)return;const u=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(n){return""}})();for(let r=0;r<o.length;r++){const s=o[r];if(s.urlScope&&!f(s.urlScope,u))continue;let d=null;for(let n=0;n<i.length;n++)if(M(s,i[n])){d=i[n];break}if(!d)continue;const h=s.rule.id;if((a.get(h)||0)>=s.maxPerPageview)return;const p=h+"#"+c(d),v=Date.now(),g=l.get(p);if(void 0!==g&&v-g<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;l.set(p,v),a.set(h,(a.get(h)||0)+1);const m=A(s.rule,d,e);return void n(()=>t.track("clicked",m))}}catch(n){}}try{document.addEventListener("click",d,!0)}catch(n){return()=>{}}return()=>{try{document.removeEventListener("click",d,!0)}catch(n){}l.clear(),a.clear()}}function k(n){const t=n.match;return t.element?t.element:t.selector||t.id||t.dataAttr||t.classes&&t.classes.length>0||t.destinationUrl?"any":void 0}function M(n,t){if(!((n,t)=>{if(!t)return(n=>{const t=n.tagName;if("BUTTON"===t||"A"===t)return!0;if("INPUT"===t){const t=(n.getAttribute("type")||"").toLowerCase();return"submit"===t||"button"===t||"reset"===t}return"button"===n.getAttribute("role")})(n);if("any"===t)return!0;if("button"===t){const t=n.tagName;if("BUTTON"===t)return!0;if("INPUT"===t){const t=(n.getAttribute("type")||"").toLowerCase();return"submit"===t||"button"===t||"reset"===t}return"button"===n.getAttribute("role")}return"link"===t?"A"===n.tagName:s(n,t)})(t,n.elementSpec))return!1;const e=n.rule.match;return!(n.selector&&!s(t,n.selector)||void 0!==e.id&&!((n,t)=>n.id===t)(t,e.id)||e.classes&&e.classes.length>0&&!((n,t)=>{try{for(let e=0;e<t.length;e++)if(!n.classList.contains(t[e]))return!1;return!0}catch(n){return!1}})(t,e.classes)||e.dataAttr&&!((n,t,e)=>{try{return!!n.hasAttribute(t)&&(void 0===e||n.getAttribute(t)===e)}catch(n){return!1}})(t,e.dataAttr.name,e.dataAttr.value)||n.text&&!((n,t)=>{const e=a(n);if("regex"===t.mode)return!!t.re&&x(t.re,e);const o=t.ci?e.toLowerCase():e;return"exact"===t.mode?o===t.needle:"startsWith"===t.mode?0===o.indexOf(t.needle):-1!==o.indexOf(t.needle)})(t,n.text)||n.dest&&!((n,t)=>{const e=d(n);if(!e)return!1;if("regex"===t.mode)return!!t.re&&x(t.re,e);if("domain"===t.mode)try{return new URL(e).host.toLowerCase()===t.needle}catch(n){return!1}const o=e.toLowerCase();return"exact"===t.mode?o===t.needle:"startsWith"===t.mode?0===o.indexOf(t.needle):-1!==o.indexOf(t.needle)})(t,n.dest))}function A(n,t,e){const o={},r=n.event.staticProps;if(r)for(const n of Object.keys(r))o[n]=r[n];const i=n.capture;if(i)try{if(i.text){const n=m(a(t));n&&(o.text=n)}if(i.href){const n=d(t);n&&(o.href=n)}if(i.elementId&&t.id&&(o.element_id=t.id),i.classes&&(o.element_classes=Array.from(t.classList)),i.dataAttrs&&i.dataAttrs.length>0)for(let n=0;n<i.dataAttrs.length;n++){const e=i.dataAttrs[n],r=t.getAttribute(e);null!==r&&(o[e]=m(r))}if(i.valueFrom){const n=((n,t)=>{try{const e=n.querySelector(t.selector)||(n.parentElement?n.parentElement.querySelector(t.selector):null);if(!e)return null;const o=t.attr?e.getAttribute(t.attr):e.textContent||"";if(null===o)return null;const r=m(o.replace(/\s+/g," ").trim());return r.length>l?r.slice(0,l):r}catch(n){return null}})(t,i.valueFrom);null!==n&&(o[i.valueFrom.as]=n)}i.selectorPath&&(o.selector_path=((n,t=5)=>{try{const e=[];let o=n,r=0;for(;o&&1===o.nodeType&&r<t;){let n=o.tagName.toLowerCase();if(o.id){e.unshift(n+"#"+o.id);break}const t=Array.from(o.classList).slice(0,2).join(".");t&&(n+="."+t),e.unshift(n),o=o.parentElement,r++}return e.join(" > ")}catch(n){return""}})(t)),i.position&&(o.x=e.clientX,o.y=e.clientY)}catch(n){}return o.rule_id=n.id,n.name&&(o.rule_name=n.name),n.event&&n.event.name&&(o.event_name=n.event.name),o.tag=t.tagName.toLowerCase(),o}function C(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}function j(n,t){return"number"!=typeof n||isNaN(n)?t:n}function z(n){return n<0?0:n>1?1:n}const S="__cnvPatched";function T(n){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=O();function e(){try{const e=O();if(e===t)return;t=e,n(e)}catch(n){}}const o=history.pushState,r=history.replaceState,i=!0===o[S],c=!0===r[S];if(!i){function u(...n){o.apply(this,n),e()}u[S]=!0,history.pushState=u}if(!c){function s(...n){r.apply(this,n),e()}s[S]=!0,history.replaceState=s}const l=()=>e(),a=()=>e();try{window.addEventListener("popstate",l),window.addEventListener("hashchange",a)}catch(d){}return()=>{try{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",a)}catch(n){}try{!i&&history.pushState[S]&&(history.pushState=o),!c&&history.replaceState[S]&&(history.replaceState=r)}catch(n){}}}function O(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}const N=["q","s","query","search","keyword"],F={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},I={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};const P=2147483e3,$="#6C5CE7",D="#FFFFFF";function H(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia?window.matchMedia("(max-width: 768px)").matches:"undefined"!=typeof window&&"number"==typeof window.innerWidth&&window.innerWidth<=768}catch(n){return!1}}function R(n,t){return(n=>"string"==typeof n&&/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(n))(n)?n:t}function L(n){if("string"!=typeof n||0===n.trim().length)return!1;try{const t="undefined"!=typeof location?location.href:void 0,e=new URL(n,t);return"https:"===e.protocol||"http:"===e.protocol||"data:"===e.protocol&&/^data:image\//i.test(n.trim())}catch(n){return!1}}function E(n){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(Math.trunc(n),0),2147483647):null}function B(n,t=20){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(n,0),2e3):t}function U(n,t){const e=n.replace("#",""),o=3===e.length?e.replace(/(.)/g,"$1$1"):e;return`rgba(${parseInt(o.slice(0,2),16)}, ${parseInt(o.slice(2,4),16)}, ${parseInt(o.slice(4,6),16)}, ${t})`}function V(n,t){const e=t?null==n?void 0:n.placementMobile:null==n?void 0:n.placementDesktop;return{side:"LEFT"===(null==e?void 0:e.position)?"left":"right",sideSpacingPx:B(null==e?void 0:e.sideSpacing),bottomSpacingPx:B(null==e?void 0:e.bottomSpacing)}}function K(n,t){const e=document.createElement("div");e.setAttribute(n,"");const o=e.attachShadow({mode:"open"}),r=document.createElement("style");return r.textContent=t,o.appendChild(r),{hostEl:e,shadow:o}}function q(n){var t;(null!==(t=document.body)&&void 0!==t?t:document.documentElement).appendChild(n)}const G="cnv:panel:opened",Z="cnv:panel:closed";function Y(n,t,e){if(e)n.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none"><path d="M6 6l12 12M18 6 6 18" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></svg>';else if("CUSTOM"===t.iconType&&L(t.customIconUrl)){n.innerHTML="";const e=document.createElement("img");e.src=t.customIconUrl,e.alt="",n.appendChild(e)}else n.innerHTML=(n=>{switch(n){case"BAG_HEART":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 8V6a5 5 0 0 1 10 0v2" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M4.5 8h15l-1 12.5a1.5 1.5 0 0 1-1.5 1.4H7a1.5 1.5 0 0 1-1.5-1.4L4.5 8Z" fill="currentColor"/><path d="M12 12.8c1-1.4 3.6-1 3.6 1 0 1.7-2.2 2.9-3.6 3.9-1.4-1-3.6-2.2-3.6-3.9 0-2 2.6-2.4 3.6-1Z" fill="#fff"/></svg>';case"TAG":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.6 3.4 20 10.8a2 2 0 0 1 0 2.8l-6.4 6.4a2 2 0 0 1-2.8 0L3.4 12.6A2 2 0 0 1 2.8 11l.6-6.2A2 2 0 0 1 5.2 3l6.2-.6a2 2 0 0 1 1.2.4Z" fill="currentColor"/><circle cx="8" cy="8" r="1.6" fill="#fff"/></svg>';case"STAR":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2.5l2.9 6 6.6.7-4.9 4.5 1.3 6.5L12 16.9l-5.9 3.3 1.3-6.5-4.9-4.5 6.6-.7L12 2.5Z" fill="currentColor"/></svg>';case"GIFT":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="3.5" y="9.5" width="17" height="10" rx="1.2" fill="currentColor"/><rect x="2.5" y="6.5" width="19" height="3.5" rx="1" fill="currentColor"/><rect x="11" y="6.5" width="2" height="13" fill="#fff"/><path d="M12 6.5c0-2 -2-3.5-3.6-3.5S6 4.3 6 5.4c0 .9.8 1.1 1.6 1.1H12Z" fill="currentColor"/><path d="M12 6.5c0-2 2-3.5 3.6-3.5S18 4.3 18 5.4c0 .9-.8 1.1-1.6 1.1H12Z" fill="currentColor"/></svg>';default:return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 9.5 7 12l5-6 5 6 4-2.5-1.6 9.5a1.5 1.5 0 0 1-1.5 1.3H6.1a1.5 1.5 0 0 1-1.5-1.3L3 9.5Z" fill="currentColor"/></svg>'}})(t.iconPreset)}function J(e,o){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{const{hostEl:e,shadow:r}=K("data-cnv-launcher",'\n :host { all: initial; }\n .cnv-launcher-fab {\n display: inline-flex; align-items: center; gap: 8px;\n height: 48px; padding: 0 18px; border: none; cursor: pointer;\n box-shadow: 0 6px 18px rgba(0, 0, 0, .18);\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;\n font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;\n transition: transform .18s cubic-bezier(.16, 1, .3, 1), box-shadow .18s ease;\n /* KHÔNG dùng animation-fill-mode ở đây: fill giữ lại transform cuối của keyframe, mà animation\n thắng cả declaration thường → :hover/:active sẽ mất tác dụng vĩnh viễn sau khi FAB hiện ra. */\n animation: cnv-fab-in .32s cubic-bezier(.16, 1, .3, 1);\n }\n .cnv-launcher-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, .24); }\n .cnv-launcher-fab:active { transform: translateY(0) scale(.96); }\n .cnv-launcher-fab__icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 20px; height: 20px; flex-shrink: 0;\n }\n .cnv-launcher-fab__icon svg, .cnv-launcher-fab__icon img {\n width: 20px; height: 20px; object-fit: contain;\n /* Animation đặt trên CHÍNH node icon chứ không phải trên wrapper: mỗi lần đổi icon là thay\n innerHTML, tức node mới → animation tự chạy lại. Không cần toggle class rồi ép reflow để\n "restart" như cách thường làm. */\n animation: cnv-fab-icon-in .28s cubic-bezier(.16, 1, .3, 1);\n }\n @keyframes cnv-fab-in {\n from { opacity: 0; transform: translateY(10px) scale(.9); }\n to { opacity: 1; transform: none; }\n }\n /* Xoay + phóng: quà ↔ dấu × không biến hình được vào nhau, nhưng xoay nhanh thì mắt đọc thành một\n cú lật mặt chứ không phải một cú thay ảnh. */\n @keyframes cnv-fab-icon-in {\n from { opacity: 0; transform: rotate(-90deg) scale(.4); }\n to { opacity: 1; transform: none; }\n }\n @media (prefers-reduced-motion: reduce) {\n .cnv-launcher-fab, .cnv-launcher-fab__icon svg, .cnv-launcher-fab__icon img {\n animation: none !important; transition: none !important;\n }\n }\n'),i=document.createElement("button");i.type="button",i.className="cnv-launcher-fab",i.setAttribute("aria-label","Launcher");const c=document.createElement("span");c.className="cnv-launcher-fab__icon";const l=document.createElement("span");l.className="cnv-launcher-fab__text",i.appendChild(c),i.appendChild(l),r.appendChild(i),((n,t,e)=>{n.style.backgroundColor=R(e.backgroundColor,$),n.style.color=R(e.textColor,D),n.style.borderRadius=(n=>{switch(n){case"SQUARE":return"2px";case"SHAVED":return"8px";case"ROUNDED":return"16px";default:return"999px"}})(e.buttonShape),Y(t,e,!1)})(i,c,o);let a=!1;const u=()=>((n,e,o,r,i)=>{try{const c=H();if(((n,e)=>{if("DESKTOP_ONLY"===n.deviceVisibility&&e)return!0;if(n.hideOnHomepage&&t(()=>"/"===location.pathname||""===location.pathname,!1))return!0;const o=n.hideUrlConditions;if(o&&o.length>0){const n=t(()=>location.pathname+location.search,"");if(o.some(t=>"string"==typeof t&&t.length>0&&n.includes(t)))return!0}return!1})(r,c))return void n.style.setProperty("display","none");n.style.removeProperty("display");const{side:l,sideSpacingPx:a,bottomSpacingPx:u}=V(r,c),s=r.useCustomZIndex?E(r.zIndex):null,d=r.addImportantRule?"important":"",h=(t,e)=>n.style.setProperty(t,e,d);h("position","fixed"),h("bottom",u+"px"),h("left","left"===l?a+"px":"auto"),h("right","right"===l?a+"px":"auto"),h("z-index",String(null!=s?s:P));const p=c?r.contentLayoutMobile:r.contentLayoutDesktop,f=!i&&"ICON_ONLY"!==p;e.style.display=i||"TEXT_ONLY"!==p?"inline-flex":"none",o.style.display=f?"inline":"none",f&&(o.textContent=(c?r.buttonTextMobile:r.buttonTextDesktop)||"")}catch(n){}})(e,c,l,o,a),s=t=>{a!==t&&(a=t,n(()=>{Y(c,o,t),i.setAttribute("aria-label",t?"Đóng":"Launcher"),u()}))},d=()=>s(!0),h=()=>s(!1);window.addEventListener(G,d),window.addEventListener(Z,h);const p=()=>{n(()=>window.dispatchEvent(new CustomEvent("cnv:launcher:click",{detail:{config:o}})))};i.addEventListener("click",p);const f=()=>{n(()=>{q(e),u()})};document.body?f():document.addEventListener("DOMContentLoaded",f,{once:!0});const v=t(()=>window.matchMedia("(max-width: 768px)"),null),g=()=>u(),m=v;v&&"function"==typeof v.addEventListener?v.addEventListener("change",g):v&&"function"==typeof m.addListener?m.addListener(g):window.addEventListener("resize",g);const b=T(u);return()=>{n(()=>{document.removeEventListener("DOMContentLoaded",f),i.removeEventListener("click",p),window.removeEventListener(G,d),window.removeEventListener(Z,h),v&&"function"==typeof v.removeEventListener?v.removeEventListener("change",g):v&&"function"==typeof m.removeListener?m.removeListener(g):window.removeEventListener("resize",g),e.remove()}),n(b)}}catch(n){return()=>{}}}const Q=(n,t)=>{let e=n;const o=W[t];let r=null,i=0,c=null;const l=[],a={},u=(n,t)=>{i=4*e+17,r=(n=>{const t=new Array(n);for(let e=0;e<n;e+=1){t[e]=new Array(n);for(let o=0;o<n;o+=1)t[e][o]=null}return t})(i),s(0,0),s(i-7,0),s(0,i-7),h(),d(),f(n,t),e>=7&&p(n),null==c&&(c=g(e,o,l)),v(c,t)},s=(n,t)=>{for(let e=-1;e<=7;e+=1)if(!(n+e<=-1||i<=n+e))for(let o=-1;o<=7;o+=1)t+o<=-1||i<=t+o||(r[n+e][t+o]=0<=e&&e<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=o&&o<=4)},d=()=>{for(let n=8;n<i-8;n+=1)null==r[n][6]&&(r[n][6]=n%2==0);for(let n=8;n<i-8;n+=1)null==r[6][n]&&(r[6][n]=n%2==0)},h=()=>{const n=X.getPatternPosition(e);for(let t=0;t<n.length;t+=1)for(let e=0;e<n.length;e+=1){const o=n[t],i=n[e];if(null==r[o][i])for(let n=-2;n<=2;n+=1)for(let t=-2;t<=2;t+=1)r[o+n][i+t]=-2==n||2==n||-2==t||2==t||0==n&&0==t}},p=n=>{const t=X.getBCHTypeNumber(e);for(let e=0;e<18;e+=1){const o=!n&&1==(t>>e&1);r[Math.floor(e/3)][e%3+i-8-3]=o}for(let e=0;e<18;e+=1){const o=!n&&1==(t>>e&1);r[e%3+i-8-3][Math.floor(e/3)]=o}},f=(n,t)=>{const e=X.getBCHTypeInfo(o<<3|t);for(let t=0;t<15;t+=1){const o=!n&&1==(e>>t&1);t<6?r[t][8]=o:t<8?r[t+1][8]=o:r[i-15+t][8]=o}for(let t=0;t<15;t+=1){const o=!n&&1==(e>>t&1);t<8?r[8][i-t-1]=o:t<9?r[8][15-t-1+1]=o:r[8][15-t-1]=o}r[i-8][8]=!n},v=(n,t)=>{let e=-1,o=i-1,c=7,l=0;const a=X.getMaskFunction(t);for(let t=i-1;t>0;t-=2)for(6==t&&(t-=1);;){for(let e=0;e<2;e+=1)if(null==r[o][t-e]){let i=!1;l<n.length&&(i=1==(n[l]>>>c&1)),a(o,t-e)&&(i=!i),r[o][t-e]=i,c-=1,-1==c&&(l+=1,c=7)}if(o+=e,o<0||i<=o){o-=e,e=-e;break}}},g=(n,t,e)=>{const o=en.getRSBlocks(n,t),r=on();for(let t=0;t<e.length;t+=1){const o=e[t];r.put(o.getMode(),4),r.put(o.getLength(),X.getLengthInBits(o.getMode(),n)),o.write(r)}let i=0;for(let n=0;n<o.length;n+=1)i+=o[n].dataCount;if(r.getLengthInBits()>8*i)throw"code length overflow. ("+r.getLengthInBits()+">"+8*i+")";for(r.getLengthInBits()+4<=8*i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*i||(r.put(236,8),r.getLengthInBits()>=8*i));)r.put(17,8);return((n,t)=>{let e=0,o=0,r=0;const i=new Array(t.length),c=new Array(t.length);for(let l=0;l<t.length;l+=1){const a=t[l].dataCount,u=t[l].totalCount-a;o=Math.max(o,a),r=Math.max(r,u),i[l]=new Array(a);for(let t=0;t<i[l].length;t+=1)i[l][t]=255&n.getBuffer()[t+e];e+=a;const s=X.getErrorCorrectPolynomial(u),d=tn(i[l],s.getLength()-1).mod(s);c[l]=new Array(s.getLength()-1);for(let n=0;n<c[l].length;n+=1){const t=n+d.getLength()-c[l].length;c[l][n]=t>=0?d.getAt(t):0}}let l=0;for(let n=0;n<t.length;n+=1)l+=t[n].totalCount;const a=new Array(l);let u=0;for(let n=0;n<o;n+=1)for(let e=0;e<t.length;e+=1)n<i[e].length&&(a[u]=i[e][n],u+=1);for(let n=0;n<r;n+=1)for(let e=0;e<t.length;e+=1)n<c[e].length&&(a[u]=c[e][n],u+=1);return a})(r,o)};a.addData=(n,t)=>{let e=null;switch(t=t||"Byte"){case"Numeric":e=rn(n);break;case"Alphanumeric":e=cn(n);break;case"Byte":e=ln(n);break;case"Kanji":e=an(n);break;default:throw"mode:"+t}l.push(e),c=null},a.isDark=(n,t)=>{if(n<0||i<=n||t<0||i<=t)throw n+","+t;return r[n][t]},a.getModuleCount=()=>i,a.make=()=>{if(e<1){let n=1;for(;n<40;n++){const t=en.getRSBlocks(n,o),e=on();for(let t=0;t<l.length;t++){const o=l[t];e.put(o.getMode(),4),e.put(o.getLength(),X.getLengthInBits(o.getMode(),n)),o.write(e)}let r=0;for(let n=0;n<t.length;n++)r+=t[n].dataCount;if(e.getLengthInBits()<=8*r)break}e=n}u(!1,(()=>{let n=0,t=0;for(let e=0;e<8;e+=1){u(!0,e);const o=X.getLostPoint(a);(0==e||n>o)&&(n=o,t=e)}return t})())},a.createTableTag=(n,t)=>{n=n||2;let e="";e+='<table style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: "+(t=void 0===t?4*n:t)+"px;",e+='">',e+="<tbody>";for(let t=0;t<a.getModuleCount();t+=1){e+="<tr>";for(let o=0;o<a.getModuleCount();o+=1)e+='<td style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: 0px;",e+=" width: "+n+"px;",e+=" height: "+n+"px;",e+=" background-color: ",e+=a.isDark(t,o)?"#000000":"#ffffff",e+=";",e+='"/>';e+="</tr>"}return e+="</tbody>",e+="</table>",e},a.createSvgTag=function(n,t,e,o){let r={};"object"==typeof arguments[0]&&(r=arguments[0],n=r.cellSize,t=r.margin,e=r.alt,o=r.title),n=n||2,t=void 0===t?4*n:t,(e="string"==typeof e?{text:e}:e||{}).text=e.text||null,e.id=e.text?e.id||"qrcode-description":null,(o="string"==typeof o?{text:o}:o||{}).text=o.text||null,o.id=o.text?o.id||"qrcode-title":null;const i=a.getModuleCount()*n+2*t;let c,l,u,s,d,h="";for(d="l"+n+",0 0,"+n+" -"+n+",0 0,-"+n+"z ",h+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',h+=r.scalable?"":' width="'+i+'px" height="'+i+'px"',h+=' viewBox="0 0 '+i+" "+i+'" ',h+=' preserveAspectRatio="xMinYMin meet"',h+=o.text||e.text?' role="img" aria-labelledby="'+m([o.id,e.id].join(" ").trim())+'"':"",h+=">",h+=o.text?'<title id="'+m(o.id)+'">'+m(o.text)+"</title>":"",h+=e.text?'<description id="'+m(e.id)+'">'+m(e.text)+"</description>":"",h+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',h+='<path d="',u=0;u<a.getModuleCount();u+=1)for(s=u*n+t,c=0;c<a.getModuleCount();c+=1)a.isDark(u,c)&&(l=c*n+t,h+="M"+l+","+s+d);return h+='" stroke="transparent" fill="black"/>',h+="</svg>",h},a.createDataURL=(n,t)=>{n=n||2,t=void 0===t?4*n:t;const e=a.getModuleCount()*n+2*t,o=t,r=e-t;return dn(e,e,(t,e)=>{if(o<=t&&t<r&&o<=e&&e<r){const r=Math.floor((t-o)/n),i=Math.floor((e-o)/n);return a.isDark(i,r)?0:1}return 1})},a.createImgTag=(n,t,e)=>{n=n||2,t=void 0===t?4*n:t;const o=a.getModuleCount()*n+2*t;let r="";return r+="<img",r+=' src="',r+=a.createDataURL(n,t),r+='"',r+=' width="',r+=o,r+='"',r+=' height="',r+=o,r+='"',e&&(r+=' alt="',r+=m(e),r+='"'),r+="/>",r};const m=n=>{let t="";for(let e=0;e<n.length;e+=1){const o=n.charAt(e);switch(o){case"<":t+="<";break;case">":t+=">";break;case"&":t+="&";break;case'"':t+=""";break;default:t+=o}}return t};return a.createASCII=(n,t)=>{if((n=n||1)<2)return(n=>{n=void 0===n?2:n;const t=1*a.getModuleCount()+2*n,e=n,o=t-n;let r,i,c,l,u;const s={"██":"█","█ ":"▀"," █":"▄"," ":" "},d={"██":"▀","█ ":"▀"," █":" "," ":" "};let h="";for(r=0;r<t;r+=2){for(c=Math.floor((r-e)/1),l=Math.floor((r+1-e)/1),i=0;i<t;i+=1)u="█",e<=i&&i<o&&e<=r&&r<o&&a.isDark(c,Math.floor((i-e)/1))&&(u=" "),e<=i&&i<o&&e<=r+1&&r+1<o&&a.isDark(l,Math.floor((i-e)/1))?u+=" ":u+="█",h+=n<1&&r+1>=o?d[u]:s[u];h+="\n"}return t%2&&n>0?h.substring(0,h.length-t-1)+Array(t+1).join("▀"):h.substring(0,h.length-1)})(t);n-=1,t=void 0===t?2*n:t;const e=a.getModuleCount()*n+2*t,o=t,r=e-t;let i,c,l,u;const s=Array(n+1).join("██"),d=Array(n+1).join(" ");let h="",p="";for(i=0;i<e;i+=1){for(l=Math.floor((i-o)/n),p="",c=0;c<e;c+=1)u=1,o<=c&&c<r&&o<=i&&i<r&&a.isDark(l,Math.floor((c-o)/n))&&(u=0),p+=u?s:d;for(l=0;l<n;l+=1)h+=p+"\n"}return h.substring(0,h.length-1)},a.renderTo2dContext=(n,t)=>{t=t||2;const e=a.getModuleCount();for(let o=0;o<e;o++)for(let r=0;r<e;r++)n.fillStyle=a.isDark(o,r)?"black":"white",n.fillRect(r*t,o*t,t,t)},a};Q.stringToBytes=n=>{const t=[];for(let e=0;e<n.length;e+=1){const o=n.charCodeAt(e);t.push(255&o)}return t},Q.createStringToBytes=(n,t)=>{const e=(()=>{const e=sn(n),o=()=>{const n=e.read();if(-1==n)throw"eof";return n};let r=0;const i={};for(;;){const n=e.read();if(-1==n)break;const t=o(),c=o(),l=o();i[String.fromCharCode(n<<8|t)]=c<<8|l,r+=1}if(r!=t)throw r+" != "+t;return i})(),o="?".charCodeAt(0);return n=>{const t=[];for(let r=0;r<n.length;r+=1){const i=n.charCodeAt(r);if(i<128)t.push(i);else{const i=e[n.charAt(r)];"number"==typeof i?(255&i)==i?t.push(i):(t.push(i>>>8),t.push(255&i)):t.push(o)}}return t}};const W={L:1,M:0,Q:3,H:2},X=(()=>{const n=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,e=7973,o={},r=n=>{let t=0;for(;0!=n;)t+=1,n>>>=1;return t};return o.getBCHTypeInfo=n=>{let e=n<<10;for(;r(e)-r(t)>=0;)e^=t<<r(e)-r(t);return 21522^(n<<10|e)},o.getBCHTypeNumber=n=>{let t=n<<12;for(;r(t)-r(e)>=0;)t^=e<<r(t)-r(e);return n<<12|t},o.getPatternPosition=t=>n[t-1],o.getMaskFunction=n=>{switch(n){case 0:return(n,t)=>(n+t)%2==0;case 1:return(n,t)=>n%2==0;case 2:return(n,t)=>t%3==0;case 3:return(n,t)=>(n+t)%3==0;case 4:return(n,t)=>(Math.floor(n/2)+Math.floor(t/3))%2==0;case 5:return(n,t)=>n*t%2+n*t%3==0;case 6:return(n,t)=>(n*t%2+n*t%3)%2==0;case 7:return(n,t)=>(n*t%3+(n+t)%2)%2==0;default:throw"bad maskPattern:"+n}},o.getErrorCorrectPolynomial=n=>{let t=tn([1],0);for(let e=0;e<n;e+=1)t=t.multiply(tn([1,nn.gexp(e)],0));return t},o.getLengthInBits=(n,t)=>{if(1<=t&&t<10)switch(n){case 1:return 10;case 2:return 9;case 4:case 8:return 8;default:throw"mode:"+n}else if(t<27)switch(n){case 1:return 12;case 2:return 11;case 4:return 16;case 8:return 10;default:throw"mode:"+n}else{if(!(t<41))throw"type:"+t;switch(n){case 1:return 14;case 2:return 13;case 4:return 16;case 8:return 12;default:throw"mode:"+n}}},o.getLostPoint=n=>{const t=n.getModuleCount();let e=0;for(let o=0;o<t;o+=1)for(let r=0;r<t;r+=1){let i=0;const c=n.isDark(o,r);for(let e=-1;e<=1;e+=1)if(!(o+e<0||t<=o+e))for(let l=-1;l<=1;l+=1)r+l<0||t<=r+l||0==e&&0==l||c==n.isDark(o+e,r+l)&&(i+=1);i>5&&(e+=3+i-5)}for(let o=0;o<t-1;o+=1)for(let r=0;r<t-1;r+=1){let t=0;n.isDark(o,r)&&(t+=1),n.isDark(o+1,r)&&(t+=1),n.isDark(o,r+1)&&(t+=1),n.isDark(o+1,r+1)&&(t+=1),0!=t&&4!=t||(e+=3)}for(let o=0;o<t;o+=1)for(let r=0;r<t-6;r+=1)n.isDark(o,r)&&!n.isDark(o,r+1)&&n.isDark(o,r+2)&&n.isDark(o,r+3)&&n.isDark(o,r+4)&&!n.isDark(o,r+5)&&n.isDark(o,r+6)&&(e+=40);for(let o=0;o<t;o+=1)for(let r=0;r<t-6;r+=1)n.isDark(r,o)&&!n.isDark(r+1,o)&&n.isDark(r+2,o)&&n.isDark(r+3,o)&&n.isDark(r+4,o)&&!n.isDark(r+5,o)&&n.isDark(r+6,o)&&(e+=40);let o=0;for(let e=0;e<t;e+=1)for(let r=0;r<t;r+=1)n.isDark(r,e)&&(o+=1);return e+=Math.abs(100*o/t/t-50)/5*10,e},o})(),nn=(()=>{const n=new Array(256),t=new Array(256);for(let t=0;t<8;t+=1)n[t]=1<<t;for(let t=8;t<256;t+=1)n[t]=n[t-4]^n[t-5]^n[t-6]^n[t-8];for(let e=0;e<255;e+=1)t[n[e]]=e;return{glog(n){if(n<1)throw"glog("+n+")";return t[n]},gexp(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return n[t]}}})(),tn=(n,t)=>{if(void 0===n.length)throw n.length+"/"+t;const e=(()=>{let e=0;for(;e<n.length&&0==n[e];)e+=1;const o=new Array(n.length-e+t);for(let t=0;t<n.length-e;t+=1)o[t]=n[t+e];return o})(),o={getAt:n=>e[n],getLength:()=>e.length,multiply(n){const t=new Array(o.getLength()+n.getLength()-1);for(let e=0;e<o.getLength();e+=1)for(let r=0;r<n.getLength();r+=1)t[e+r]^=nn.gexp(nn.glog(o.getAt(e))+nn.glog(n.getAt(r)));return tn(t,0)},mod(n){if(o.getLength()-n.getLength()<0)return o;const t=nn.glog(o.getAt(0))-nn.glog(n.getAt(0)),e=new Array(o.getLength());for(let n=0;n<o.getLength();n+=1)e[n]=o.getAt(n);for(let o=0;o<n.getLength();o+=1)e[o]^=nn.gexp(nn.glog(n.getAt(o))+t);return tn(e,0).mod(n)}};return o},en=(()=>{const n=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=(n,t)=>{const e={};return e.totalCount=n,e.dataCount=t,e};return{getRSBlocks(e,o){const r=((t,e)=>{switch(e){case W.L:return n[4*(t-1)+0];case W.M:return n[4*(t-1)+1];case W.Q:return n[4*(t-1)+2];case W.H:return n[4*(t-1)+3];default:return}})(e,o);if(void 0===r)throw"bad rs block @ typeNumber:"+e+"/errorCorrectionLevel:"+o;const i=r.length/3,c=[];for(let n=0;n<i;n+=1){const e=r[3*n+0],o=r[3*n+1],i=r[3*n+2];for(let n=0;n<e;n+=1)c.push(t(o,i))}return c}}})(),on=()=>{const n=[];let t=0;const e={getBuffer:()=>n,getAt(t){const e=Math.floor(t/8);return 1==(n[e]>>>7-t%8&1)},put(n,t){for(let o=0;o<t;o+=1)e.putBit(1==(n>>>t-o-1&1))},getLengthInBits:()=>t,putBit(e){const o=Math.floor(t/8);n.length<=o&&n.push(0),e&&(n[o]|=128>>>t%8),t+=1}};return e},rn=n=>{const t=n,e={getMode:()=>1,getLength:n=>t.length,write(n){const e=t;let r=0;for(;r+2<e.length;)n.put(o(e.substring(r,r+3)),10),r+=3;r<e.length&&(e.length-r==1?n.put(o(e.substring(r,r+1)),4):e.length-r==2&&n.put(o(e.substring(r,r+2)),7))}},o=n=>{let t=0;for(let e=0;e<n.length;e+=1)t=10*t+r(n.charAt(e));return t},r=n=>{if("0"<=n&&n<="9")return n.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+n};return e},cn=n=>{const t=n,e={getMode:()=>2,getLength:n=>t.length,write(n){const e=t;let r=0;for(;r+1<e.length;)n.put(45*o(e.charAt(r))+o(e.charAt(r+1)),11),r+=2;r<e.length&&n.put(o(e.charAt(r)),6)}},o=n=>{if("0"<=n&&n<="9")return n.charCodeAt(0)-"0".charCodeAt(0);if("A"<=n&&n<="Z")return n.charCodeAt(0)-"A".charCodeAt(0)+10;switch(n){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+n}};return e},ln=n=>{const t=Q.stringToBytes(n);return{getMode:()=>4,getLength:n=>t.length,write(n){for(let e=0;e<t.length;e+=1)n.put(t[e],8)}}},an=n=>{const t=Q.stringToBytes;(()=>{const n=t("友");if(2!=n.length||38726!=(n[0]<<8|n[1]))throw"sjis not supported."})();const e=t(n),o={getMode:()=>8,getLength:n=>~~(e.length/2),write(n){const t=e;let o=0;for(;o+1<t.length;){let e=(255&t[o])<<8|255&t[o+1];if(33088<=e&&e<=40956)e-=33088;else{if(!(57408<=e&&e<=60351))throw"illegal char at "+(o+1)+"/"+e;e-=49472}e=192*(e>>>8&255)+(255&e),n.put(e,13),o+=2}if(o<t.length)throw"illegal char at "+(o+1)}};return o},un=()=>{const n=[],t={writeByte(t){n.push(255&t)},writeShort(n){t.writeByte(n),t.writeByte(n>>>8)},writeBytes(n,e,o){e=e||0,o=o||n.length;for(let r=0;r<o;r+=1)t.writeByte(n[r+e])},writeString(n){for(let e=0;e<n.length;e+=1)t.writeByte(n.charCodeAt(e))},toByteArray:()=>n,toString(){let t="";t+="[";for(let e=0;e<n.length;e+=1)e>0&&(t+=","),t+=n[e];return t+="]",t}};return t},sn=n=>{const t=n;let e=0,o=0,r=0;const i={read(){for(;r<8;){if(e>=t.length){if(0==r)return-1;throw"unexpected end of file./"+r}const n=t.charAt(e);if(e+=1,"="==n)return r=0,-1;n.match(/^\s$/)||(o=o<<6|c(n.charCodeAt(0)),r+=6)}const n=o>>>r-8&255;return r-=8,n}},c=n=>{if(65<=n&&n<=90)return n-65;if(97<=n&&n<=122)return n-97+26;if(48<=n&&n<=57)return n-48+52;if(43==n)return 62;if(47==n)return 63;throw"c:"+n};return i},dn=(n,t,e)=>{const o=((n,t)=>{const e=n,o=t,r=new Array(n*t),i={setPixel(n,t,o){r[t*e+n]=o},write(n){n.writeString("GIF87a"),n.writeShort(e),n.writeShort(o),n.writeByte(128),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(255),n.writeByte(255),n.writeByte(255),n.writeString(","),n.writeShort(0),n.writeShort(0),n.writeShort(e),n.writeShort(o),n.writeByte(0);const t=c(2);n.writeByte(2);let r=0;for(;t.length-r>255;)n.writeByte(255),n.writeBytes(t,r,255),r+=255;n.writeByte(t.length-r),n.writeBytes(t,r,t.length-r),n.writeByte(0),n.writeString(";")}},c=n=>{const t=1<<n,e=1+(1<<n);let o=n+1;const i=l();for(let n=0;n<t;n+=1)i.add(String.fromCharCode(n));i.add(String.fromCharCode(t)),i.add(String.fromCharCode(e));const c=un(),a=(n=>{const t=n;let e=0,o=0;return{write(n,r){if(n>>>r!=0)throw"length over";for(;e+r>=8;)t.writeByte(255&(n<<e|o)),r-=8-e,n>>>=8-e,o=0,e=0;o|=n<<e,e+=r},flush(){e>0&&t.writeByte(o)}}})(c);a.write(t,o);let u=0,s=String.fromCharCode(r[u]);for(u+=1;u<r.length;){const n=String.fromCharCode(r[u]);u+=1,i.contains(s+n)?s+=n:(a.write(i.indexOf(s),o),i.size()<4095&&(i.size()==1<<o&&(o+=1),i.add(s+n)),s=n)}return a.write(i.indexOf(s),o),a.write(e,o),a.flush(),c.toByteArray()},l=()=>{const n={};let t=0;const e={add(o){if(e.contains(o))throw"dup key:"+o;n[o]=t,t+=1},size(){return t},indexOf(t){return n[t]},contains(t){return void 0!==n[t]}};return e};return i})(n,t);for(let r=0;r<t;r+=1)for(let t=0;t<n;t+=1)o.setPixel(t,r,e(t,r));const r=un();o.write(r);const i=(()=>{let n=0,t=0,e=0,o="";const r={},i=n=>{o+=String.fromCharCode(c(63&n))},c=n=>{if(n<0)throw"n:"+n;if(n<26)return 65+n;if(n<52)return n-26+97;if(n<62)return n-52+48;if(62==n)return 43;if(63==n)return 47;throw"n:"+n};return r.writeByte=o=>{for(n=n<<8|255&o,t+=8,e+=1;t>=6;)i(n>>>t-6),t-=6},r.flush=()=>{if(t>0&&(i(n<<6-t),n=0,t=0),e%3!=0){const n=3-e%3;for(let t=0;t<n;t+=1)o+="="}},r.toString=()=>o,r})(),c=r.toByteArray();for(let n=0;n<c.length;n+=1)i.writeByte(c[n]);return i.flush(),"data:image/gif;base64,"+i},hn="undefined"!=typeof window&&"undefined"!=typeof document;function pn(n){if(!hn)return null;try{const t=document.cookie;if(!t)return null;const e=encodeURIComponent(n),o=t.split(";");for(let t=0;t<o.length;t++){const r=o[t].indexOf("=");if(r<0)continue;const i=o[t].slice(0,r).trim();if(i===e||i===n)try{return decodeURIComponent(o[t].slice(r+1))}catch(n){return o[t].slice(r+1)}}return null}catch(n){return null}}function fn(n,t,e={}){var o,r,i;if(!hn)return!1;try{let c=`${encodeURIComponent(n)}=${encodeURIComponent(t)}`;if(c+=`; path=${null!==(o=e.path)&&void 0!==o?o:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const n=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${n}`,c+=`; expires=${new Date(Date.now()+1e3*n).toUTCString()}`}return c+=`; SameSite=${null!==(r=e.sameSite)&&void 0!==r?r:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,pn(n)===t}catch(n){return!1}}function vn(){if(!hn)return!1;try{const n="__cnv_probe__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch(n){return!1}}function gn(n){if(!vn())return null;try{return localStorage.getItem(n)}catch(n){return null}}function mn(n,t){if(!vn())return!1;try{return localStorage.setItem(n,t),!0}catch(n){return!1}}function bn(n){if(!vn())return!1;try{return localStorage.removeItem(n),!0}catch(n){return!1}}function yn(){if(!hn)return!1;try{const n="__cnv_probe__";return sessionStorage.setItem(n,"1"),sessionStorage.removeItem(n),!0}catch(n){return!1}}function wn(n,t,e,o){return new(e||(e=Promise))((r,i)=>{function c(n){try{a(o.next(n))}catch(n){i(n)}}function l(n){try{a(o.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?r(n.value):(t=n.value,t instanceof e?t:new e(n=>{n(t)})).then(c,l)}a((o=o.apply(n,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const xn=2e4,_n=/^(https:|zalo:)/i;class kn extends Error{constructor(n){super(`loginWithZalo() thất bại: ${n}`),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:n}),this.name="ZaloQrLoginError"}}function Mn(n,t,e,o){return`${n}${t}?${new URLSearchParams(Object.assign({projectId:e},o)).toString()}`}function An(n){return{title:"string"==typeof n.title?n.title:void 0,description:"string"==typeof n.description?n.description:void 0,points:Cn(n.points),expPoints:Cn(n.expPoints),balanceAfter:Cn(n.balanceAfter),expBalanceAfter:Cn(n.expBalanceAfter),rankAfter:"string"==typeof n.rankAfter?n.rankAfter:void 0,createdAt:"string"==typeof n.createdAt?n.createdAt:void 0}}function Cn(n){return"number"==typeof n&&Number.isFinite(n)?n:void 0}function jn(n){return{id:Cn(n.id),name:"string"==typeof n.name?n.name:void 0,iconUrl:"string"==typeof n.iconUrl?n.iconUrl:void 0,colorCode:"string"==typeof n.colorCode?n.colorCode:void 0,threshold:Cn(n.threshold),level:Cn(n.level),benefits:Array.isArray(n.benefits)?n.benefits.filter(n=>"string"==typeof n&&""!==n.trim()):[]}}function zn(n){return{id:Cn(n.id),name:"string"==typeof n.name?n.name:void 0,iconUrl:"string"==typeof n.iconUrl?n.iconUrl:void 0,colorCode:"string"==typeof n.colorCode?n.colorCode:void 0,level:Cn(n.level),progressCurrent:Cn(n.progressCurrent),progressTarget:Cn(n.progressTarget),remaining:Cn(n.remaining),nextLevelName:"string"==typeof n.nextLevelName?n.nextLevelName:void 0,isHighestLevel:!0===n.isHighestLevel}}function Sn(n){return{title:"string"==typeof n.title?n.title:void 0,imageUrl:"string"==typeof n.imageUrl?n.imageUrl:void 0,code:"string"==typeof n.code?n.code:void 0,discountValue:"string"==typeof n.discountValue?n.discountValue:void 0,expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,useRemain:"number"==typeof n.useRemain&&Number.isFinite(n.useRemain)?n.useRemain:void 0}}function Tn(n,t){return wn(this,void 0,void 0,function*(){var e,o,r;if(!n.projectId||!n.endpoint)throw new kn("not-initialized");if(!n.zaloQrLoginEnabled)throw new kn("disabled");if(!n.consentGranted)throw new kn("consent-required");const i={preferSse:null===(e=null==t?void 0:t.preferSse)||void 0===e||e,pollIntervalMs:null!==(o=null==t?void 0:t.pollIntervalMs)&&void 0!==o?o:2e3,autoIdentify:null===(r=null==t?void 0:t.autoIdentify)||void 0===r||r},c=n.projectId,l=n.endpoint,a=yield function(n,t){return wn(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),8e3):null;let r;try{r=yield fetch(Mn(n,"/zalo-qr/session",t),{method:"POST",credentials:"omit",mode:"cors",signal:e?e.signal:void 0})}catch(n){throw new kn("network")}finally{o&&clearTimeout(o)}if(!r.ok)throw new kn(401===(i=r.status)?"invalid-project-key":403===i?"project-suspended":"network");var i;return(n=>{const t=n;if(!t||"string"!=typeof t.sessionToken||!t.sessionToken||"string"!=typeof t.miniAppDeepLink||!_n.test(t.miniAppDeepLink)||"number"!=typeof t.expiresInSeconds||!Number.isFinite(t.expiresInSeconds)||t.expiresInSeconds<=0)throw new kn("network");return{sessionToken:t.sessionToken,miniAppDeepLink:t.miniAppDeepLink,expiresInSeconds:t.expiresInSeconds}})(yield r.json())})}(l,c),u=((n,t,e,o,r)=>{let i=!1,c=null,l=null,a=null,u=null,s=null;const d=()=>{c&&(c.close(),c=null),null!==l&&(clearInterval(l),l=null),null!==a&&(clearTimeout(a),a=null),null!==u&&(clearTimeout(u),u=null)};return{promise:new Promise((h,p)=>{s=p;const f=n=>{i||(i=!0,d(),n())},v=n=>{"success"===n.status?f(()=>h((n=>({contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,panelSessionToken:n.panelSessionToken,panelSessionExp:n.panelSessionExp}))(n))):"denied"===n.status?f(()=>p(new kn("denied"))):"expired"===n.status&&f(()=>p(new kn("expired")))},g=()=>{null!==l||i||(l=setInterval(()=>{fetch(Mn(n,"/zalo-qr/status",t,{sessionToken:e}),{method:"GET",credentials:"omit",mode:"cors"}).then(n=>404===n.status?v({status:"expired"}):n.ok?n.json().then(n=>v(n)):void 0).catch(()=>{})},r.pollIntervalMs))};if(r.preferSse&&"undefined"!=typeof EventSource)try{c=new EventSource(Mn(n,"/zalo-qr/stream",t,{sessionToken:e})),c.addEventListener("success",n=>{try{v(JSON.parse(n.data))}catch(n){}}),c.addEventListener("denied",()=>v({status:"denied"})),c.onerror=()=>{null!==u||i||(u=setTimeout(()=>{u=null,i||(c&&(c.close(),c=null),g())},3e3))}}catch(n){g()}else g();a=setTimeout(()=>{f(()=>p(new kn("expired")))},1e3*o)}),cancel(){i||(i=!0,d(),null==s||s(new kn("cancelled")))}}})(l,c,a.sessionToken,a.expiresInSeconds,i),s=u.promise.then(t=>{try{if(i.autoIdentify&&null!=t.contactId){const e=String(t.contactId),o=n.getUserId();null!=o&&o!==e?n.alias(e,o):n.identify(e,Object.assign(Object.assign(Object.assign({},t.fullName?{name:t.fullName}:{}),t.level?{level:t.level}:{}),null!=t.xp?{xp:t.xp}:{}))}}catch(n){}return t});return{sessionToken:a.sessionToken,qrPayload:a.miniAppDeepLink,expiresInSeconds:a.expiresInSeconds,result:s,cancel:u.cancel,retry(){return u.cancel(),Tn(n,t)}}})}const On="cnv:launcher:click",Nn="cnv:panel:identify",Fn="cnv-panel-card--leaving";function In(n){return"cnv_panel_session_"+(null!=n?n:"default")}function Pn(n){const e=gn(In(n));return e?t(()=>{const n=JSON.parse(e);return n&&"string"==typeof n.token&&n.token&&"number"==typeof n.contactId&&"number"==typeof n.exp?n:null},null):null}function $n(n,t){mn(In(n),JSON.stringify(t))}function Dn(n){bn(In(n))}function Hn(n){return"SQUARE"===n?"0px":"12px"}function Rn(n){const t=n.colors;return R(null==t?void 0:t.iconColor,R(null==t?void 0:t.buttonBg,R(null==t?void 0:t.bannerBg,$)))}function Ln(n,t){n.style.background=U(t,.12),n.style.color=t}const En='<path d="M20 12v9H4v-9M2 7h20v5H2V7Zm10 0V4a2.5 2.5 0 0 0-5 0v3h5Zm0 0V4a2.5 2.5 0 0 1 5 0v3h-5Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>',Bn='<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',Un='<path d="M12 2.5l2.9 6.3 6.9.8-5.1 4.7 1.4 6.8L12 17.8 5.9 21.1l1.4-6.8-5.1-4.7 6.9-.8L12 2.5Z" fill="currentColor"/>',Vn='<circle cx="9" cy="8" r="3.2" stroke="currentColor" stroke-width="1.8"/><path d="M2.5 20c0-3.6 2.9-6 6.5-6s6.5 2.4 6.5 6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',Kn='<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.8"/><path d="M12 7v5l3.5 2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',qn='<path d="M5 13l4.5 4.5L19 8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',Gn='<circle cx="11" cy="4.6" r="2.3" fill="currentColor"/><rect x="2.2" y="10" width="3" height="6.4" rx="1.5" fill="currentColor"/><path d="M7.4 12.2c2 0 3.4.6 4.6 1.8h2.2a1.6 1.6 0 1 1 0 3.2h-3.4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.4 12.2v7c3.2 1.2 6.2.5 9-2l3.2-2.9a1.7 1.7 0 0 0-2.2-2.6l-3 2.3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>';function Zn(n,t,e){const o=document.createElement("span");return o.className=e?"cnv-panel-icon "+e:"cnv-panel-icon",o.innerHTML=`<svg viewBox="0 0 24 24" fill="none" width="${t}" height="${t}">${n}</svg>`,o}function Yn(n,t){const e=document.createElement("div");return e.className="cnv-panel-chip",Ln(e,t),e.appendChild(Zn(n,14)),e}function Jn(n,t){const e=document.createElement("span");return e.className="cnv-panel-badge",Ln(e,t),e.textContent=n,e}const Qn={POINTS:{label:"Điểm thưởng",icon:Un},REFERRAL:{label:"Giới thiệu bạn bè",icon:Vn},VIP:{label:"Hạng thành viên (VIP)",icon:'<path d="M3 8l3.2 3 3.6-5.4L12 3l2.2 2.6L17.8 11 21 8l-1.6 10H4.6L3 8Z" fill="currentColor"/>'}},Wn={rewards:'<path d="M3 9V6.4c0-.8.6-1.4 1.4-1.4h15.2c.8 0 1.4.6 1.4 1.4V9a3 3 0 0 0 0 6v2.6c0 .8-.6 1.4-1.4 1.4H4.4c-.8 0-1.4-.6-1.4-1.4V15a3 3 0 0 0 0-6Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M14.6 5.6v12.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-dasharray="2.2 2.6"/>',earn:Gn,redeem:En,history:Kn},Xn={ORDER:'<path d="M4.4 8h15.2l-1.1 12.3H5.5L4.4 8Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M8.7 8V6.3a3.3 3.3 0 0 1 6.6 0V8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',STAR:Un,GIFT:En,USERS:Vn,CAKE:'<path d="M3.6 20.6h16.8v-5.1c0-1-.8-1.9-1.9-1.9H5.5c-1 0-1.9.8-1.9 1.9v5.1Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M12 13.6V9.7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="7.5" r="1.8" fill="currentColor"/>',SHARE:'<circle cx="17.8" cy="5.6" r="2.6" stroke="currentColor" stroke-width="1.8"/><circle cx="6.2" cy="12" r="2.6" stroke="currentColor" stroke-width="1.8"/><circle cx="17.8" cy="18.4" r="2.6" stroke="currentColor" stroke-width="1.8"/><path d="M15.5 6.9 8.5 10.7M8.5 13.3l7 3.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',COIN:Gn,CHECK:qn},nt={earn:{label:"Cách kiếm thêm điểm",icon:Gn},redeem:{label:"Cách đổi điểm",icon:En}},tt="Tham gia ngay",et=[[nt.earn.label,"earn"],[nt.redeem.label,"redeem"]];function ot(n,t){var e;const o=document.createElement("div");var r,i;return o.className=t?"cnv-panel-card__section "+t:"cnv-panel-card__section",o.style.borderRadius=Hn(null===(e=n.shapes)||void 0===e?void 0:e.card),(r=o).style.backgroundColor="DARK"===(i=n.theme)?"#3F4254":"#FFFFFF",r.style.boxShadow="DARK"===i?"none":"0 2px 4px rgba(15, 42, 81, 0.04)",o}function rt(n,t){const e=document.createElement("div");return e.className="cnv-panel-zalo__skeleton",e.style.width=n+"px",e.style.height=t+"px",e}function it(n,t){const e=document.createElement("div");e.className="cnv-panel-zalo__corner tl",e.style.borderColor=t;const o=document.createElement("div");o.className="cnv-panel-zalo__corner br",o.style.borderColor=t,n.append(e,o)}function ct(n){const t=document.createElement("div");t.className="cnv-panel-vstack";const e=document.createElement("div");e.className="cnv-panel-zalo__qr",e.appendChild(rt(180,180)),it(e,n),t.appendChild(e);const o=document.createElement("div");return o.className="cnv-panel-vstack",o.style.gap="6px",o.append(rt(240,14),rt(160,14)),t.appendChild(o),t.appendChild(rt(120,14)),t}function lt(n,t,e,o){const r=document.createElement("div");r.className="cnv-panel-zalo__overlay-bubble";const i=document.createElement("div");i.className="cnv-panel-bubble-icon",i.style.background=e,i.style.color=t,i.appendChild(Zn(n,20));const c=document.createElement("div");return c.className="cnv-panel-zalo__title",c.textContent=o,r.append(i,c),r}function at(n,t,e){let o=n,r=null;const i=()=>{null!==r&&(clearInterval(r),r=null)};return!0===t(o)||(r=setInterval(()=>{o-=1,(!0===t(o)||o<=0)&&(i(),e&&e())},1e3)),i}function ut(n){return n instanceof kn?n.reason:null}function st(n){switch(ut(n)){case"disabled":return"Đăng nhập bằng Zalo hiện đang tắt.";case"consent-required":return"Cần đồng ý thu thập dữ liệu để đăng nhập bằng Zalo.";case"expired":return"Mã QR đã hết hạn.";case"denied":return"Đăng nhập đã bị từ chối.";case"cancelled":return"Đã huỷ đăng nhập.";default:return"Vui lòng thử lại giúp mình nhé."}}function dt(o,r){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{let i,c=null,l=null,a=null,u=null,s=null,d=null,h=null,p=null,f=null,v=null,g=null,m=!1,b=null,y=null,w=!1,x=!1,_=!1,k=[],M=0,A=!1,C=null,j=null,z=null,S=!1,T=[],O=0,N=null,F=!1,I=!1,B=0,G=0,Z=null,Y=null,J=null;const W=n=>{"Escape"===n.key&&It()};function X(n){return!w||n!==B}function nn(n,e){return t(()=>{const t=new CustomEvent(n,{detail:{action:e},cancelable:!0});return window.dispatchEvent(t),t.defaultPrevented},!1)}function tn(n){nn("cnv:panel:cta-click",n)}function en(n){return()=>{m&&n()}}function on(n,t,e){const o=document.createElement("div");o.className="cnv-panel-section__row",e&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const i=Wn[t];if(i){const n=Zn(i,20);n.style.color=Rn(r),o.appendChild(n)}const c=document.createElement("span");return c.className="cnv-panel-section__row-label",c.textContent=n,o.appendChild(c),o.appendChild(Zn(Bn,12,"cnv-panel-icon--chevron")),o.addEventListener("click",en(()=>{nn("cnv:panel:menu-click",t)||("rewards"===t?(x=!0,yt(),fn()):"history"===t?(_=!0,yt(),bn(),k.length||(M=0,mn())):nt[t]&&(C=t,yt(),Mn()))})),o}function rn(){var n,t,e,o;const i=ot(r,"cnv-panel-cta"),c=r.accountCreationCta,l=document.createElement("div");l.className="cnv-panel-cta__title",l.textContent=(null==c?void 0:c.title)||"";const a=document.createElement("div");a.className="cnv-panel-cta__desc",a.textContent=(null==c?void 0:c.description)||"";const u=document.createElement("button");u.type="button",u.className="cnv-panel-cta__btn",u.style.borderRadius=Hn(null===(n=r.shapes)||void 0===n?void 0:n.button),u.style.backgroundColor=R(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,$),u.style.color=R(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,D),u.appendChild(Zn(En,15)),u.appendChild(document.createTextNode(((null==c?void 0:c.createAccountButtonText)||"").trim()||tt)),u.addEventListener("click",en(()=>{tn("create-account"),Tt()})),i.append(l,a,u);const s=((null==c?void 0:c.signInLinkText)||"").trim();if(s){const n=document.createElement("div");n.className="cnv-panel-cta__signin",n.style.color=R(null===(o=r.colors)||void 0===o?void 0:o.linkColor,$),n.appendChild(document.createTextNode(s)),n.appendChild(Zn(Bn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",en(()=>{tn("sign-in"),Tt()})),i.appendChild(n)}return i}function cn(){var n;const t=r.accountCreationCta,e=((null==t?void 0:t.description)||"").trim()||((null==t?void 0:t.title)||"").trim();if(!e)return null;const o="DARK"===r.theme,i=document.createElement("div");return i.className="cnv-panel-card__section cnv-panel-join-hint",i.style.borderRadius=Hn(null===(n=r.shapes)||void 0===n?void 0:n.card),i.style.backgroundColor=o?"#2A2E44":"#F1F1F4",i.style.color=o?"rgba(255,255,255,.72)":"rgba(24,28,50,.66)",i.textContent=e,i}function ln(){var n,t,e,o;const i=r.accountCreationCta,c="DARK"===r.theme,l=document.createElement("div");l.className="cnv-panel-joinbar",l.style.backgroundColor=c?"#181C32":"#FFFFFF",l.style.borderTop=c?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2";const a=document.createElement("button");a.type="button",a.className="cnv-panel-cta__btn",a.style.borderRadius=Hn(null===(n=r.shapes)||void 0===n?void 0:n.button),a.style.backgroundColor=R(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,$),a.style.color=R(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,D),a.appendChild(Zn(En,15)),a.appendChild(document.createTextNode(((null==i?void 0:i.createAccountButtonText)||"").trim()||tt)),a.addEventListener("click",en(()=>{tn("create-account"),Tt()})),l.appendChild(a);const u=((null==i?void 0:i.signInLinkText)||"").trim();if(u){const n=document.createElement("div");n.className="cnv-panel-cta__signin",n.style.color=R(null===(o=r.colors)||void 0===o?void 0:o.linkColor,$),n.appendChild(document.createTextNode(u)),n.appendChild(Zn(Bn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",en(()=>{tn("sign-in"),Tt()})),l.appendChild(n)}return l}function an(){var n;return null!==(n=null==z?void 0:z.rewardsAvailableCount)&&void 0!==n?n:null==b?void 0:b.rewardsAvailableCount}function un(){if(!(null==b?void 0:b.isMember)||z||S)return;const n=Pn(o.projectId);n&&(S=!0,o.fetchRewardsSummary(n.token).then(n=>{S=!1,n&&(z=n,T=n.rewards.slice(),O=1,m&>())}).catch(()=>{S=!1}))}function sn(){return(Array.isArray(r.sections)?r.sections:[]).some(n=>"VIP"===n.type&&n.enabled)}function dn(){const n=null==z?void 0:z.rewardsAvailableCount;return"number"==typeof n&&O?Math.max(0,n-T.length):0}function hn(){if(I||!dn())return;const n=Pn(o.projectId);if(!n)return;const t=O+1;I=!0,x&&fn(),o.fetchRewardsSummary(n.token,t).then(n=>{I=!1,O=t,n&&(n.rewards.length&&(T=T.concat(n.rewards)),"number"==typeof n.rewardsAvailableCount&&z&&(z=Object.assign(Object.assign({},z),{rewardsAvailableCount:n.rewardsAvailableCount}))),x&&fn()}).catch(()=>{I=!1,x&&fn()})}function pn(n,t,e){const o=document.createElement("div");if(o.className="cnv-panel-reward",t&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2"),L(n.imageUrl)){const t=document.createElement("img");t.className="cnv-panel-reward__thumb",t.src=n.imageUrl,t.alt="",t.loading="lazy",t.decoding="async",t.addEventListener("error",()=>t.remove()),o.appendChild(t)}const i=document.createElement("div");i.className="cnv-panel-reward__main";const c=document.createElement("div");c.className="cnv-panel-reward__title",c.textContent=n.title||"Ưu đãi",i.appendChild(c);const l="number"==typeof n.useRemain&&n.useRemain>1;if(n.discountValue||l){const t=document.createElement("div");if(t.className="cnv-panel-reward__tags",n.discountValue){const o=document.createElement("span");o.className="cnv-panel-reward__value",Ln(o,e),o.textContent=n.discountValue,t.appendChild(o)}if(l){const e=document.createElement("span");e.className="cnv-panel-reward__uses",e.textContent=`Còn ${n.useRemain} lượt`,t.appendChild(e)}i.appendChild(t)}if(n.code){const t=document.createElement("div");t.className="cnv-panel-reward__code",t.textContent=n.code,i.appendChild(t)}const a=(n=>{if(!n)return null;const t=Date.parse(n);if(!Number.isFinite(t))return null;const e=new Date(t),o=n=>String(n).padStart(2,"0");return`${o(e.getDate())}/${o(e.getMonth()+1)}/${e.getFullYear()}`})(n.expiredAt);if(a){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${a}`,i.appendChild(n)}return o.appendChild(i),o}function fn(){if(!h)return;xt(),_t(),wt(!0),h.textContent="";const n=Rn(r),t=ot(r),e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(Yn(En,n));const o=document.createElement("div");if(o.className="cnv-panel-section__title",o.textContent="Ưu đãi của bạn",e.appendChild(o),t.appendChild(e),T.length){const e=document.createElement("div");e.className="cnv-panel-reward__list",T.forEach((t,o)=>e.appendChild(pn(t,o>0,n))),t.appendChild(e);const o=dn();if(o>0||I){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=I,n.textContent=I?"Đang tải…":`Xem thêm ${o} ưu đãi`,n.addEventListener("click",hn),t.appendChild(n)}}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="Bạn chưa có ưu đãi nào.",t.appendChild(n)}h.appendChild(t)}function vn(n){const t="earn"===n?r.earnBlocks:"redeem"===n?r.redeemBlocks:null;return Array.isArray(t)?t.filter(n=>n&&"string"==typeof n.title&&""!==n.title.trim()).slice(0,12):[]}function gn(n,t,e,o){const i=document.createElement("div");i.className="cnv-panel-block",t&&(i.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const c=Xn[n.icon];i.appendChild(Yn("string"==typeof c?c:o,e));const l=document.createElement("div");l.className="cnv-panel-block__main";const a=document.createElement("div");a.className="cnv-panel-block__title",a.textContent=n.title.trim(),l.appendChild(a);const u="string"==typeof n.description?n.description.trim():"";if(u){const n=document.createElement("div");n.className="cnv-panel-block__desc",n.textContent=u,l.appendChild(n)}return i.appendChild(l),i}function mn(){if(A)return;const n=Pn(o.projectId);if(!n)return;const t=M+1;A=!0,_&&bn(),o.fetchPointHistory(n.token,t).then(n=>{A=!1,M=t,n&&("number"==typeof n.totalCount&&(i=n.totalCount),n.items.length&&(k=k.concat(n.items))),_&&bn()}).catch(()=>{A=!1,_&&bn()})}function bn(){if(!h)return;xt(),_t(),wt(!0),h.textContent="";const n=Rn(r),t=ot(r);if(t.appendChild(An({label:"Lịch sử hoạt động",icon:Kn},n)),!k.length&&A)t.appendChild(rt(180,12)),t.appendChild(rt(120,12));else if(k.length){const n=document.createElement("div");n.className="cnv-panel-history__list",k.forEach((t,e)=>n.appendChild(yn(t,e>0))),t.appendChild(n);const e="number"==typeof i&&M?Math.max(0,i-k.length):0;if(e>0||A){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=A,n.textContent=A?"Đang tải…":`Xem thêm ${e} hoạt động`,n.addEventListener("click",en(mn)),t.appendChild(n)}}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="Chưa có hoạt động nào.",t.appendChild(n)}h.appendChild(t)}function yn(n,t){const e=document.createElement("div");e.className="cnv-panel-history__row",t&&(e.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const o=document.createElement("div");o.className="cnv-panel-history__main";const i=document.createElement("div");i.className="cnv-panel-history__title",i.textContent=(n.title||"").trim()||"Hoạt động",o.appendChild(i);const c=(n.description||"").trim();c&&o.appendChild(wn(c));const l=[];"number"==typeof n.balanceAfter&&l.push("Điểm tích lũy: "+_n(n.balanceAfter));const a=(n.rankAfter||"").trim();"number"==typeof n.expBalanceAfter?l.push("Điểm xét hạng: "+_n(n.expBalanceAfter)+(a?" (Hạng "+a+")":"")):a&&l.push("Hạng "+a),l.length&&o.appendChild(wn(l.join(" / ")));const u=kn(n.createdAt);u&&o.appendChild(wn(u)),e.appendChild(o);const s=document.createElement("div");if(s.className="cnv-panel-history__amounts","number"==typeof n.points){const t=document.createElement("div");t.className="cnv-panel-history__points",t.textContent=xn(n.points)+" điểm",s.appendChild(t)}if("number"==typeof n.expPoints&&0!==n.expPoints){const t=document.createElement("div");t.className="cnv-panel-history__exp",t.textContent=xn(n.expPoints)+" xét hạng",s.appendChild(t)}return s.childElementCount&&e.appendChild(s),e}function wn(n){const t=document.createElement("div");return t.className="cnv-panel-history__meta",t.textContent=n,t}function xn(n){const t=Math.round(n);return(t>0?"+":"")+t.toLocaleString("vi-VN")}function _n(n){return Math.round(n).toLocaleString("vi-VN")}function kn(n){if(!n)return null;const t=new Date(n);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("vi-VN")+" "+t.toLocaleTimeString("vi-VN",{hour:"2-digit",minute:"2-digit"})}function Mn(){if(!h||!C)return;const n=nt[C];if(!n)return C=null,void ft();const t=vn(C);xt(),_t(),wt(!0),h.textContent="";const e=Rn(r),o=ot(r);if(o.appendChild(An(n,e)),t.length){const r=document.createElement("div");r.className="cnv-panel-block__list",t.forEach((t,o)=>r.appendChild(gn(t,o>0,e,n.icon))),o.appendChild(r)}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="redeem"===C?"Shop chưa cập nhật cách đổi điểm. Bạn quay lại sau nhé.":"Shop chưa cập nhật cách kiếm thêm điểm. Bạn quay lại sau nhé.",o.appendChild(n)}if(h.appendChild(o),!bt()){const n=cn();n&&h.appendChild(n)}j=bt()}function An(n,t){const e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(Yn(n.icon,t));const o=document.createElement("div");return o.className="cnv-panel-section__title",o.textContent=n.label,e.appendChild(o),e}function Cn(n){if(!(Array.isArray(r.sections)?r.sections:[]).some(n=>"POINTS"===n.type&&n.enabled))return null;const t=ot(r),e=document.createElement("div");e.className="cnv-panel-section__desc",e.textContent="Kiếm điểm từ nhiều hoạt động, rồi đổi điểm lấy những ưu đãi hấp dẫn.";const o=document.createElement("div");return et.forEach((n,t)=>o.appendChild(on(n[0],n[1],t>0))),t.append(An(Qn.POINTS,n),e,o),t}function jn(n){const t=Math.max(0,Math.round(n)).toLocaleString("vi-VN");return"SPENDING"===(null==N?void 0:N.applyFor)?t+"đ":t+" điểm"}function zn(n){return"number"!=typeof n.threshold||n.threshold<=0?"":"RELATIVE"===(null==N?void 0:N.thresholdKind)?"cần thêm "+jn(n.threshold):"từ "+jn(n.threshold)}function Sn(n){const t=document.createElement("span");if(t.className="cnv-panel-tier__badge",L(n.iconUrl)){const e=document.createElement("img");return e.className="cnv-panel-tier__badge-img",e.alt="",e.src=n.iconUrl,t.appendChild(e),t}return t.style.backgroundColor=R(n.colorCode,Rn(r)),t}function Tn(n,t){var e,o;const r=document.createElement("div");r.className="cnv-panel-tier__row",t&&r.classList.add("cnv-panel-tier__row--current"),r.appendChild(Sn(n));const i=document.createElement("span");i.className="cnv-panel-tier__name",i.textContent=t?(null!==(e=n.name)&&void 0!==e?e:"")+" — bạn đang ở đây":null!==(o=n.name)&&void 0!==o?o:"";const c=document.createElement("span");return c.className="cnv-panel-tier__threshold",c.textContent=zn(n),r.append(i,c),r}function In(n){const t=n.filter(n=>"string"==typeof n&&""!==n.trim());if(!t.length)return null;const e=document.createElement("ul");return e.className="cnv-panel-tier__benefits",t.forEach(n=>{const t=document.createElement("li");t.textContent=n.trim(),e.appendChild(t)}),e}function Un(n,t){const e=document.createElement("div");return e.className="cnv-panel-tier__more",e.textContent="…và "+n+(t?" hạng cao hơn":" hạng thấp hơn"),e}function Vn(n,t){var e;const o=n.progressTarget,i=null!==(e=n.progressCurrent)&&void 0!==e?e:0;if("number"!=typeof o||o<=0)return null;const c=document.createElement("div");c.className="cnv-panel-tier__progress";const l=document.createElement("div");l.className="cnv-panel-tier__bar",l.style.backgroundColor="DARK"===r.theme?"rgba(255,255,255,.16)":"rgba(24,28,50,.10)";const a=document.createElement("div");a.className="cnv-panel-tier__fill",a.style.backgroundColor=t,a.style.width=Math.max(0,Math.min(100,i/o*100)).toFixed(1)+"%",l.appendChild(a);const u=document.createElement("div");u.className="cnv-panel-tier__hint";const s="number"==typeof n.remaining?n.remaining:o-i;return u.textContent=n.nextLevelName?"Còn "+jn(s)+" nữa để lên "+n.nextLevelName:"Còn "+jn(s)+" nữa để lên hạng kế tiếp",c.append(l,u),c}function Gn(n,t){if(t<0)return{from:0,to:Math.min(n.length,4)};const e=Math.max(0,t-1);return{from:e,to:Math.min(n.length,e+4)}}function dt(n,t){var e,o;const i=null!==(e=null==N?void 0:N.tiers)&&void 0!==e?e:[];if(!i.length)return null;const c=ot(r),l=document.createElement("div"),a=t?null==z?void 0:z.tier:void 0;if(null==a?void 0:a.name){const t=document.createElement("div");t.className="cnv-panel-tier__current",t.appendChild(Sn(a));const e=document.createElement("span");e.className="cnv-panel-tier__current-name",e.style.color=n,e.textContent=a.name,t.appendChild(e),l.appendChild(t);const o=Vn(a,n);if(o)l.appendChild(o);else if(a.isHighestLevel){const n=document.createElement("div");n.className="cnv-panel-tier__hint",n.textContent="Bạn đang ở hạng cao nhất.",l.appendChild(n)}}else if(!t){const n=document.createElement("div");n.className="cnv-panel-section__desc",n.textContent="Mua càng nhiều, hạng càng cao, quyền lợi càng nhiều.",l.appendChild(n)}const u=null!=(null==a?void 0:a.id)?i.findIndex(n=>n.id===a.id):-1,{from:s,to:d}=Gn(i,u),h=document.createElement("div");h.className="cnv-panel-tier__list",s>0&&h.appendChild(Un(s,!1));for(let n=s;n<d;n++){const t=n===u;if(h.appendChild(Tn(i[n],t)),t||u<0){const t=In(i[n].benefits);t&&h.appendChild(t)}}const p=Math.max(null!==(o=null==N?void 0:N.totalTiers)&&void 0!==o?o:i.length,i.length)-d;return p>0&&h.appendChild(Un(p,!0)),l.appendChild(h),c.append(An(Qn.VIP,n),l),c}function ht(n,t){const e=Qn[n];if(!e||"string"!=typeof e.label)return null;if("VIP"===n)return dt(t,!0);const o=ot(r),i=An(e,t),c=document.createElement("div");if("POINTS"!==n)return c.appendChild(Jn("Sắp ra mắt",t)),o.append(i,c),o;const l=null!==(a=null==z?void 0:z.points)&&void 0!==a?a:null==b?void 0:b.points;var a;if("number"==typeof l&&Number.isFinite(l)){const n=document.createElement("div");n.className="cnv-panel-section__points",n.style.color=t;const e=l.toLocaleString("vi-VN");n.textContent=e,e.length>15&&(n.style.fontSize="20px"),c.appendChild(n)}else c.appendChild(Jn("Đang cập nhật",t));const u=an();return[["number"==typeof u?`Ưu đãi của bạn — ${u} ưu đãi khả dụng`:"Ưu đãi của bạn","rewards"],...et,["Lịch sử hoạt động","history"]].forEach((n,t)=>c.appendChild(on(n[0],n[1],t>0))),o.append(i,c),o}function pt(){if(!s||!d)return;const n=r.colors;l&&(l.style.backgroundColor="DARK"===r.theme?"#181C32":"#FFFFFF",l.style.color="DARK"===r.theme?"#FFFFFF":"#181C32");const t=s.parentElement;if(t&&(t.style.backgroundColor=R(null==n?void 0:n.bannerBg,$),t.style.color=R(null==n?void 0:n.bannerFont,D)),a&&(L(r.bannerImageUrl)?(a.src=r.bannerImageUrl,a.style.display="block"):(a.style.display="none",a.removeAttribute("src"))),u){const t=u.parentElement;L(r.brandIconUrl)?(u.src=r.brandIconUrl,t&&(t.style.display="flex",t.style.background=U(R(null==n?void 0:n.bannerFont,D),.18))):(t&&(t.style.display="none"),u.removeAttribute("src"))}const e=(null==b?void 0:b.isMember)?r.headerMember:r.headerVisitor;s.textContent=(null==e?void 0:e.caption)||"",d.textContent=(null==e?void 0:e.title)||""}function ft(){if(!h||w||x||_||C)return;xt(),_t(),wt(!0),h.textContent="";const n=Rn(r);if(!(null==b?void 0:b.isMember)){let t=0;vt(rn(),t++);const e=Cn(n);e&&vt(e,t++);const o=sn()?dt(n,!1):null;return void(o&&vt(o,t++))}const t=Array.isArray(r.sections)?[...r.sections]:[];let e=0;t.filter(n=>n.enabled&&"string"==typeof n.type).sort((n,t)=>{var e,o;return(null!==(e=n.order)&&void 0!==e?e:0)-(null!==(o=t.order)&&void 0!==o?o:0)}).forEach(t=>{const o=ht(t.type,n);o&&vt(o,e++)})}function vt(n,t){n.style.animationDelay=40+55*t+"ms",h.appendChild(n)}function gt(){pt(),C?j!==bt()&&Mn():ft()}function mt(){z=null,T=[],O=0,x=!1,k=[],i=void 0,M=0,_=!1}function bt(){return!!(null==b?void 0:b.isMember)}function yt(){h&&(h.scrollTop=0)}function wt(n){l&&(l.style.backgroundImage=n?((n,t)=>{if(!n||"NONE"===n)return"none";const e=((n,t)=>{switch(n){case"WAVES":return`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="24" viewBox="0 0 48 24"><path d="M0 12c6 0 6 8 12 8s6-8 12-8 6 8 12 8 6-8 12-8" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"CUBES":return`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><rect x="4" y="4" width="14" height="14" fill="none" stroke="${t}" stroke-width="2"/><rect x="22" y="22" width="14" height="14" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"FUN":return`<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 44 44"><circle cx="8" cy="10" r="2.4" fill="${t}"/><path d="M30 6l1.6 3.4 3.6.4-2.6 2.6.7 3.7-3.3-1.8-3.3 1.8.7-3.7-2.6-2.6 3.6-.4z" fill="${t}"/><circle cx="34" cy="34" r="2.4" fill="${t}"/><circle cx="10" cy="34" r="1.8" fill="${t}"/></svg>`;case"GEOMETRIC":return`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M8 36 16 12l8 24Z" fill="none" stroke="${t}" stroke-width="2"/><circle cx="36" cy="14" r="6" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"CROSS_HATCHING":return`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0 24 24M0 24 24 0" stroke="${t}" stroke-width="1.4"/></svg>`;default:return""}})(n,t?"rgba(255,255,255,0.16)":"rgba(17,17,17,0.10)");return e?`url("data:image/svg+xml,${encodeURIComponent(e)}")`:"none"})(r.wallpaper,"DARK"===r.theme):"none")}function xt(){const n=w||x||_||null!==C;f&&(f.style.display=n?"inline-flex":"none"),p&&p.classList.toggle("cnv-panel-banner--sub",n)}function _t(){if(!l)return;const n=!bt()&&null!==C;if(n&&!g)return g=ln(),void l.insertBefore(g,v);!n&&g&&(g.remove(),g=null)}function kt(){w&&(At(),w=!1),x=!1,_=!1,C=null,yt(),ft()}function Mt(){Z=e(Z)}function At(){Y=e(Y)}function Ct(n,t){Mt();const e=Date.now()+1e3*t.expiresInSeconds;Z=at(t.expiresInSeconds,()=>{const t=Math.max(0,Math.round((e-Date.now())/1e3)),o=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");return n.textContent=`Hết hạn sau ${o}:${r}`,t<=0})}function jt(){if(w=!1,Mt(),At(),y){const t=y;y=null,n(()=>t.cancel())}}function zt(){const n=document.createElement("button");return n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Huỷ",n.addEventListener("click",()=>{jt(),gt()}),n}function St(n){var t;if(!h)return;xt(),_t(),wt(!1),h.textContent="";const e=Rn(r),o=ot(r,"cnv-panel-zalo");if("loading"===n.phase)o.appendChild(ct(e)),o.appendChild(zt());else if("qr"===n.phase){const t=(n=>{try{const t=Q(0,"M");t.addData(n),t.make();const e=t.getModuleCount(),o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox",`0 0 ${e} ${e}`),o.setAttribute("width",String(180)),o.setAttribute("height",String(180));const r=document.createElementNS("http://www.w3.org/2000/svg","rect");r.setAttribute("width",String(e)),r.setAttribute("height",String(e)),r.setAttribute("fill","#fff"),o.appendChild(r);let i="";for(let n=0;n<e;n++)for(let o=0;o<e;o++)t.isDark(n,o)&&(i+=`M${o} ${n}h1v1h-1z`);const c=document.createElementNS("http://www.w3.org/2000/svg","path");return c.setAttribute("d",i),c.setAttribute("fill","#000"),o.appendChild(c),o}catch(n){return null}})(n.session.qrPayload);if(t){const n=document.createElement("div");n.className="cnv-panel-zalo__qr cnv-panel-zalo__qr--white",n.appendChild(t),it(n,e),o.appendChild(n)}const r=document.createElement("div");r.className="cnv-panel-zalo__status",r.appendChild(document.createTextNode("Mở "));const i=document.createElement("b");i.style.color=e,i.textContent="Zalo",r.appendChild(i),r.appendChild(document.createTextNode(" trên điện thoại và quét mã để đăng nhập")),o.appendChild(r);const c=document.createElement("div");c.className="cnv-panel-zalo__timer",c.appendChild(Zn(Kn,12));const l=document.createElement("span");c.appendChild(l),o.appendChild(c),Ct(l,n.session),o.appendChild(zt())}else{o.style.position="relative",o.appendChild(ct(e));const l=document.createElement("div");let a;if(l.className="cnv-panel-zalo__overlay",l.style.borderRadius=Hn(null===(t=r.shapes)||void 0===t?void 0:t.card),l.style.background="DARK"===r.theme?"rgba(63, 66, 84, 0.94)":"rgba(255, 255, 255, 0.94)","success"===n.phase)a=lt(qn,"#1E9E5B","rgba(30, 158, 91, 0.12)",n.result.fullName?`Xin chào ${n.result.fullName}!`:"Đăng nhập thành công!");else{const t="expired"===n.reason;a=lt(t?Kn:'<path d="M2 8.5a17 17 0 0 1 20 0M5.5 12.3a11.6 11.6 0 0 1 13 0M9 16a6 6 0 0 1 6 0M3 3l18 18" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',t?"#6B7280":"#D64545",t?"rgba(107, 114, 128, 0.12)":"rgba(214, 69, 69, 0.10)",t?"Mã QR đã hết hạn":"Có lỗi xảy ra");const o=document.createElement("div");if(o.className="cnv-panel-zalo__status",o.textContent=t?'Bấm "Thử lại" để lấy mã mới.':n.message,a.appendChild(o),n.canRetry){const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.style.backgroundColor=e,n.style.borderColor=e,n.style.color="#fff",n.textContent="Thử lại",n.addEventListener("click",en(()=>Tt())),G>=3){const t=Math.min(5+5*(G-3),20);i=n,c=t,At(),i.disabled=!0,Y=at(c,n=>{n>0&&(i.textContent=`Thử lại (${n}s)`)},()=>{i.disabled=!1,i.textContent="Thử lại"})}a.appendChild(n)}}l.appendChild(a),o.appendChild(l)}var i,c;h.appendChild(o)}function Tt(){if(!h)return;jt(),C=null,w=!0,yt();const t=++B;St({phase:"loading"}),o.loginWithZalo().then(e=>{X(t)?n(()=>e.cancel()):(y=e,G=0,St({phase:"qr",session:e}),e.result.then(n=>{X(t)||(Mt(),y=null,St({phase:"success",result:n}),null!=n.contactId&&"string"==typeof n.panelSessionToken&&n.panelSessionToken&&"number"==typeof n.panelSessionExp&&$n(o.projectId,{token:n.panelSessionToken,contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,exp:n.panelSessionExp}),b={isMember:!0},un(),setTimeout(()=>{X(t)||(w=!1,gt())},1500))}).catch(n=>{X(t)||(Mt(),y=null,St({phase:"error",message:st(n),canRetry:!0,reason:ut(n)}))}))}).catch(n=>{X(t)||(G+=1,St({phase:"error",message:st(n),canRetry:!0,reason:ut(n)}))})}function Ot(n){var t,e,o;if(c)return;const i=K("data-cnv-panel",'\n :host { all: initial; }\n .cnv-panel-card {\n /* max-height ở đây chỉ là mức sàn cho lúc chưa đặt vị trí — placeCard() LUÔN ghi đè bằng trần\n có trừ khoảng cách đáy thật (xem ghi chú ở đó). Sửa số 32 ở đây mà quên chỗ kia là vô nghĩa. */\n /* Chiều cao CỐ ĐỊNH, không co theo nội dung — đúng cách smile.io bày: banner ghim trên, chân ghim\n dưới, chỉ thân giữa cuộn. Nội dung ít thì panel vẫn đúng khổ đó (còn khoảng trống dưới), nội dung\n nhiều thì thân cuộn. max-height vẫn cần: màn hình thấp hơn 600px thì panel co lại theo, nếu\n không thì mép trên trôi ra ngoài viewport và mất luôn nút đóng.\n display: flex là điều kiện để chia 3 phần — bỏ nó là chân panel rơi vào giữa thân. */\n position: fixed; display: flex; flex-direction: column; background-repeat: repeat;\n width: min(360px, calc(100vw - 32px)); height: 600px; max-height: calc(100vh - 32px);\n overflow: hidden; box-shadow: 0 20px 44px rgba(24, 28, 50, .22), 0 4px 10px rgba(24, 28, 50, .12);\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;\n font-size: 14px; line-height: 1.4;\n /* transform-origin do placeCard() đặt theo bên của FAB — panel BUNG RA TỪ nút vừa bấm chứ không\n nở ra từ tâm nó. Đây là thứ làm chuyển động thấy "có nguồn gốc" thay vì thấy rời rạc. */\n animation: cnv-panel-in .34s cubic-bezier(.16, 1, .3, 1) both;\n }\n /* Đóng NHANH HƠN mở (.18s vs .34s) và bằng đường cong tăng tốc: đi vào thì mắt cần theo dõi, đi ra\n thì chỉ cần biết là nó đi — kéo dài lúc ra chỉ làm thao tác thấy chậm. */\n .cnv-panel-card--leaving {\n animation: cnv-panel-out .18s cubic-bezier(.4, 0, 1, 1) both;\n /* Panel đã đóng về mặt logic nhưng còn hiện để chạy animation — phải thôi ăn click NGAY, nếu\n không khách bấm trúng thân panel đang mờ dần là kích hoạt hành động của một panel đã đóng\n (xem whileOpen). opacity: 0 KHÔNG tắt hit-test, đã đo: elementFromPoint ở khung cuối của\n cnv-panel-out vẫn trả về đúng nút bên trong. */\n pointer-events: none;\n }\n @keyframes cnv-panel-in {\n from { opacity: 0; transform: translateY(14px) scale(.92); }\n to { opacity: 1; transform: none; }\n }\n @keyframes cnv-panel-out {\n from { opacity: 1; transform: none; }\n to { opacity: 0; transform: translateY(10px) scale(.96); }\n }\n @keyframes cnv-panel-bubble-in {\n from { opacity: 0; transform: translateY(4px) scale(.97); }\n to { opacity: 1; transform: none; }\n }\n /* Card trong thân panel trồi lên so le (delay do renderBody đặt) — mắt đọc được thứ tự nội dung\n thay vì bị đập vào cả khối. Cũng chạy khi đổi view (Ưu đãi/QR) vì card lúc đó dựng lại. */\n @keyframes cnv-panel-rise {\n from { opacity: 0; transform: translateY(10px); }\n to { opacity: 1; transform: none; }\n }\n @media (prefers-reduced-motion: reduce) {\n .cnv-panel-card, .cnv-panel-card--leaving, .cnv-panel-card__section,\n .cnv-panel-zalo__overlay-bubble { animation: none !important; }\n }\n /* z-index BẮT BUỘC: nút đóng nằm TRƯỚC .cnv-panel-banner trong DOM và cả hai đều là positioned\n element không z-index, nên banner (đứng sau) vẽ ĐÈ LÊN nút — nút vẫn có trong DOM nhưng vô hình\n và elementFromPoint tại tâm nút trả về .cnv-panel-banner__caption, tức không bấm được. */\n .cnv-panel-close {\n position: absolute; z-index: 2; top: 10px; right: 10px; width: 26px; height: 26px; border: none;\n border-radius: 999px; background: rgba(0, 0, 0, .18); color: #fff; cursor: pointer; font-size: 16px;\n display: inline-flex; align-items: center; justify-content: center; line-height: 1; padding: 0;\n transition: background .15s;\n }\n .cnv-panel-close:hover { background: rgba(0, 0, 0, .3); }\n /* Nút quay lại — ĐỐI XỨNG với .cnv-panel-close (cùng z-index vì cùng lý do: banner đứng sau trong DOM\n nên nếu không nâng z-index thì nó vẽ đè lên và nút không bấm được). Chỉ hiện khi đang ở view con. */\n .cnv-panel-back {\n position: absolute; z-index: 2; top: 10px; left: 10px; width: 26px; height: 26px; border: none;\n border-radius: 999px; background: rgba(0, 0, 0, .18); color: #fff; cursor: pointer; padding: 0;\n display: none; align-items: center; justify-content: center; transition: background .15s;\n }\n .cnv-panel-back:hover { background: rgba(0, 0, 0, .3); }\n /* min-height 160px: banner chiếm ~27% chiều cao panel như smile.io (ta từng để 88px = 14,7%, banner\n đọc ra một dải header mỏng chứ không ra phông nền).\n margin-bottom ÂM kéo thân panel lên, để card đầu tiên CHỒNG lên banner — chữ ký của smile.io. Số\n 54 = 38px chồng thật + 16px padding-top của thân. KHÔNG làm bằng margin-top âm trên card đầu: thân\n là vùng cuộn, phần tràn lên trên mép nó thì scrollTop không xuống âm được nên bị cắt vĩnh viễn. */\n .cnv-panel-banner {\n position: relative; flex: 0 0 auto; padding: 20px 20px 22px; min-height: 160px;\n margin-bottom: -54px; box-sizing: border-box; overflow: hidden;\n }\n /* Đẩy nội dung banner sang phải để chừa chỗ cho nút quay lại — nếu không thì chip thương hiệu và\n dòng caption (cả hai bắt đầu ở góc trên-trái) nằm ĐÈ lên nút.\n PHẢI đứng SAU rule trên: .cnv-panel-banner dùng shorthand "padding", cùng độ ưu tiên nên rule nào\n ở sau thì thắng — đặt trước là "padding-left" này bị xoá sạch (đã đo: caption đè lên nút 16px). */\n .cnv-panel-banner--sub { padding-left: 44px; }\n .cnv-panel-banner__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .35; display: none; }\n .cnv-panel-banner__brandchip {\n position: relative; width: 34px; height: 34px; border-radius: 10px; margin: 0 0 10px;\n display: none; align-items: center; justify-content: center; overflow: hidden;\n }\n .cnv-panel-banner__brandicon { width: 100%; height: 100%; object-fit: cover; display: block; }\n .cnv-panel-banner__caption { position: relative; font-size: 11.5px; opacity: .85; }\n .cnv-panel-banner__title { position: relative; font-size: 26px; font-weight: 800; line-height: 1.24; margin-top: 3px; }\n /* Vùng cuộn DUY NHẤT của panel. flex: 1 để nó ăn hết chỗ giữa banner và chân — nhờ vậy chân luôn ở\n đáy dù nội dung ngắn. overscroll-behavior chặn cuộn hết thân rồi kéo trôi cả trang phía sau. */\n .cnv-panel-body {\n flex: 1 1 auto; min-height: 0; overflow: hidden auto; overscroll-behavior: contain;\n padding: 16px; display: flex; flex-direction: column; gap: 12px;\n /* BẮT BUỘC khi banner có margin-bottom âm: banner là positioned element (position: relative cho\n ảnh/caption tuyệt đối bên trong) nên nó vẽ ĐÈ lên thân dù thân đứng sau trong DOM — không nâng\n thân lên thì phần chồng nhau bị banner che, card đầu bị cắt mất 38px trên. */\n position: relative; z-index: 1;\n /* Ẩn thanh cuộn nhưng VẪN cuộn được — smile.io không hiện thanh nào. Dấu hiệu "còn nội dung phía\n dưới" là card bị chân panel cắt ngang, đúng cách smile.io làm. */\n scrollbar-width: none; -ms-overflow-style: none;\n }\n .cnv-panel-body::-webkit-scrollbar { width: 0; height: 0; display: none; }\n /* Phần tử flex thứ 3 của card, KHÔNG còn "position: sticky": từ khi card cao cố định và thân cuộn\n riêng thì chân tự nằm đáy: sticky trong một vùng KHÔNG cuộn sẽ để chân nổi giữa panel khi nội dung\n ngắn (đúng lỗi đó đã gặp lúc chuyển sang chiều cao cố định).\n Làm mờ bằng MÀU CHỮ, tuyệt đối không dùng opacity: opacity áp lên cả element nên nền mờ theo. */\n .cnv-panel-footer {\n flex: 0 0 auto; padding: 11px 16px;\n display: flex; align-items: center; justify-content: center; gap: 4px;\n font-size: 11.5px; font-weight: 500;\n }\n .cnv-panel-footer__brand { font-weight: 800; }\n .cnv-panel-card__section {\n padding: 16px; box-sizing: border-box;\n animation: cnv-panel-rise .34s cubic-bezier(.16, 1, .3, 1) both;\n }\n .cnv-panel-chip {\n width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center;\n flex-shrink: 0;\n }\n .cnv-panel-section__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }\n /* Card mời tham gia của MÀN CHÍNH — giữ nguyên đủ bộ (tiêu đề + mô tả + nút + link), đúng như\n smile.io bày màn chính cho khách chưa đăng nhập. Canh giữa cả cụm; nút và dòng "Đăng nhập" vốn đã\n tự canh giữa bằng flex, chỉ 2 khối chữ này còn canh trái. */\n .cnv-panel-cta { text-align: center; }\n .cnv-panel-cta__title { font-size: 15px; font-weight: 800; margin-bottom: 5px; }\n .cnv-panel-cta__desc { font-size: 12.5px; line-height: 1.5; opacity: .72; margin-bottom: 14px; }\n /* Dải mời tham gia của VIEW CON ("Cách kiếm thêm điểm"/"Cách đổi điểm"): MỘT câu trên nền mờ.\n Vì sao view con KHÁC màn chính: ở đó khách đang đọc nội dung shop soạn, nhắc lại cả card CTA đủ bộ\n là một cục cao gần gấp đôi phần nội dung đang đọc. smile.io cũng chỉ để một dải mờ trong view con,\n còn nút thì ghim đáy panel (.cnv-panel-joinbar).\n padding PHẢI đứng sau .cnv-panel-card__section trong file (cùng độ đặc hiệu, luật sau thắng) —\n đảo thứ tự là padding 16px của section ăn mất dòng này, đúng lỗi đã gặp với .cnv-panel-banner--sub.\n Nền do JS đặt và phải ĐẶC: thân panel có hoạ tiết wallpaper, nền alpha để hoạ tiết lộ xuyên qua. */\n /* Dòng lịch sử: nhãn + các dòng phụ bên trái, biến động điểm bên phải. Cùng nhịp padding với dòng\n ưu đãi/block. */\n .cnv-panel-history__row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; }\n .cnv-panel-history__main { flex: 1; min-width: 0; }\n .cnv-panel-history__title { font-size: 13px; font-weight: 700; line-height: 1.35; }\n .cnv-panel-history__meta { font-size: 11.5px; line-height: 1.45; opacity: .66; margin-top: 2px; }\n /* flex-shrink: 0 để cột điểm không bị nhãn dài bóp xuống dòng; tabular-nums cho các số thẳng cột.\n KHÔNG tô màu theo dấu +/- — xem ghi chú ở formatPointDelta(). */\n .cnv-panel-history__amounts { flex: 0 0 auto; text-align: right; }\n .cnv-panel-history__points {\n font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap;\n }\n .cnv-panel-history__exp {\n font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;\n opacity: .66; margin-top: 2px;\n }\n .cnv-panel-join-hint { padding: 13px 16px; text-align: center; font-size: 12.5px; line-height: 1.5; font-weight: 600; }\n /* Thanh ghim đáy — con TRỰC TIẾP của card như chân panel, KHÔNG nằm trong thân cuộn: cả điểm của nó\n là nút tham gia luôn trong tầm mắt dù khách đang cuộn ở đâu (smile.io ghim "Join now" y vậy).\n flex: 0 0 auto để thân (flex: 1 1 auto) không co nó lại khi nội dung dài. */\n .cnv-panel-joinbar { flex: 0 0 auto; padding: 12px 16px; }\n /* Nút + link đăng nhập: GIỮ tên lớp .cnv-panel-cta__* dù card CTA đã bỏ — chúng vẫn đúng nghĩa\n "nút CTA / link đăng nhập", và site của shop có thể đang bắt đúng selector này. */\n .cnv-panel-cta__btn {\n display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 40px;\n border: none; font-weight: 700; cursor: pointer; margin-bottom: 10px; font-size: 13.5px;\n transition: filter .15s, transform .15s cubic-bezier(.16, 1, .3, 1);\n }\n .cnv-panel-cta__btn:hover { filter: brightness(1.06); transform: translateY(-1px); }\n .cnv-panel-cta__btn:active { transform: translateY(0) scale(.985); }\n .cnv-panel-cta__signin {\n display: flex; align-items: center; justify-content: center; gap: 4px;\n font-size: 12.5px; text-align: center; cursor: pointer; font-weight: 700;\n }\n /* Viewport THẤP (điện thoại xoay ngang) — các phần CỐ ĐỊNH phải nhường chỗ.\n Vì sao bắt buộc: từ khi card cao cố định + "overflow: hidden", ".cnv-panel-body" là phần tử DUY\n NHẤT co được, nên nó gánh hết phần thiếu và co về 0 — khách không cuộn tới được nội dung nào, mà\n card không còn van an toàn nào (trước đây card tự cuộn được). Đo thật trong Chrome: chiều cao\n viewport 375px (iPhone 6/7/8 nằm ngang) ⇒ trần card = 100vh - 108 = 267px, mà phần cố định của\n màn KHÁCH = banner 106 + padding thân 32 + thanh ghim 92 + chân 38 = 268 ⇒ thân = 0px và cả\n thanh ghim lẫn chân panel bị cắt. Chính thanh ghim đẩy ngưỡng vỡ từ ~284px lên ~375px.\n Với block này: vh 375 ⇒ thân còn ~86px và cuộn được bình thường. */\n @media (max-height: 560px) {\n .cnv-panel-banner { min-height: 96px; margin-bottom: -38px; padding: 14px 16px 16px; }\n .cnv-panel-banner--sub { padding-left: 44px; }\n .cnv-panel-banner__title { font-size: 20px; }\n .cnv-panel-body { padding: 12px; gap: 8px; }\n .cnv-panel-joinbar { padding: 8px 12px; }\n .cnv-panel-cta__btn { height: 34px; margin-bottom: 6px; }\n .cnv-panel-footer { padding: 6px 12px; }\n }\n .cnv-panel-icon { display: inline-flex; flex-shrink: 0; }\n .cnv-panel-icon--chevron { transition: transform .15s; }\n .cnv-panel-cta__signin:hover .cnv-panel-icon--chevron { transform: translateX(2px); }\n .cnv-panel-section__title { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; opacity: .68; }\n .cnv-panel-section__points { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; margin-bottom: 6px; }\n .cnv-panel-section__desc { font-size: 12.5px; line-height: 1.5; opacity: .72; margin-bottom: 4px; }\n .cnv-panel-section__row {\n font-size: 12.5px; display: flex; align-items: center; gap: 10px;\n padding: 10px 0; cursor: pointer;\n }\n /* flex:1 đẩy chevron về sát mép phải (thay cho justify-content:space-between hồi dòng chưa có\n icon dẫn đầu); min-width:0 để nhãn dài tự co lại thay vì đội chevron ra ngoài card. */\n .cnv-panel-section__row-label { flex: 1; min-width: 0; }\n .cnv-panel-section__row:hover .cnv-panel-icon--chevron { transform: translateX(2px); }\n .cnv-panel-badge {\n display: inline-flex; align-items: center; font-size: 10px; font-weight: 800; text-transform: uppercase;\n letter-spacing: .03em; padding: 3px 8px; border-radius: 999px;\n }\n /* ── Hạng thành viên (VIP) ──────────────────────────────────────────────── */\n .cnv-panel-tier__current { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }\n .cnv-panel-tier__current-name { font-size: 19px; font-weight: 800; line-height: 1.2; }\n /* Huy hiệu là chấm màu khi shop không tải icon lên; kích thước cố định để hàng nào cũng thẳng cột. */\n .cnv-panel-tier__badge {\n flex: 0 0 auto; width: 18px; height: 18px; border-radius: 999px; overflow: hidden;\n display: inline-flex; align-items: center; justify-content: center;\n }\n .cnv-panel-tier__badge-img { width: 100%; height: 100%; object-fit: cover; display: block; }\n .cnv-panel-tier__progress { margin-bottom: 8px; }\n /* Nền thanh làm nhạt bằng MÀU CÓ ALPHA đặt inline theo theme, KHÔNG dùng opacity: opacity áp lên cả\n element nên nó kéo mờ luôn lớp fill bên trong (fill còn 14% đậm → thanh đọc ra ngược chiều). */\n .cnv-panel-tier__bar { height: 6px; border-radius: 999px; overflow: hidden; }\n .cnv-panel-tier__fill { height: 100%; border-radius: 999px; transition: width .35s ease; }\n .cnv-panel-tier__hint { font-size: 12px; line-height: 1.5; opacity: .72; }\n /* KHÔNG có trần/cuộn riêng: panel cuộn bằng MỘT thanh duy nhất ở .cnv-panel-card, chân panel ghim\n sticky ở đáy — đúng cách smile.io bày. Hộp cuộn lồng trong từng card tạo 2 tầng cuộn: khách cuộn\n tới giữa card là bị "kẹt" trong hộp con, và nội dung dài vẫn không đọc hết được. */\n .cnv-panel-tier__list { }\n .cnv-panel-tier__row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 7px 0; }\n .cnv-panel-tier__row--current { font-weight: 800; }\n /* Tên hạng do merchant tự đặt và loyalty KHÔNG giới hạn độ dài (chỉ bắt khác rỗng + không trùng),\n nên phải kẹp 1 dòng: tên 200 ký tự mà để tự xuống dòng là đẩy ngưỡng ra khỏi hàng. */\n .cnv-panel-tier__name {\n flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;\n }\n .cnv-panel-tier__threshold { flex: 0 0 auto; font-size: 11.5px; opacity: .66; font-variant-numeric: tabular-nums; }\n .cnv-panel-tier__benefits { margin: 0 0 6px 26px; padding: 0 0 0 14px; font-size: 12px; line-height: 1.55; opacity: .72; }\n .cnv-panel-tier__more { font-size: 11.5px; padding: 5px 0 5px 26px; opacity: .58; }\n .cnv-panel-zalo {\n display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;\n text-align: center;\n /* Khoá chiều cao theo khung phase \'loading\'/\'qr\' (cao nhất: khối QR 180 + viền 20 + hint 2 dòng\n + timer + nút Huỷ + padding card) để panel KHÔNG co/giãn đột ngột khi chuyển sang\n success/error. Trước đây đo runtime bằng scrollHeight ngay sau khi append card — ép browser\n flush style+layout đồng bộ ngay trong click handler; con số này suy được từ chính các hằng số\n ở trên nên không cần đo. */\n min-height: 346px;\n }\n .cnv-panel-vstack { display: flex; flex-direction: column; align-items: center; gap: 8px; }\n .cnv-panel-zalo__qr { position: relative; padding: 10px; border-radius: 12px; }\n .cnv-panel-zalo__qr--white { background: #fff; }\n .cnv-panel-zalo__qr svg { display: block; }\n .cnv-panel-zalo__corner { position: absolute; width: 16px; height: 16px; border: 3px solid; border-radius: 5px 0 0 0; }\n .cnv-panel-zalo__corner.tl { top: -3px; left: -3px; border-right: none; border-bottom: none; }\n .cnv-panel-zalo__corner.br { bottom: -3px; right: -3px; border-left: none; border-top: none; border-radius: 0 0 5px 0; }\n .cnv-panel-zalo__title { font-size: 14px; font-weight: 800; }\n .cnv-panel-zalo__status { font-size: 12.5px; font-weight: 500; line-height: 1.45; max-width: 250px; }\n .cnv-panel-zalo__timer {\n font-size: 11.5px; font-weight: 700; opacity: .7; font-variant-numeric: tabular-nums;\n display: inline-flex; align-items: center; gap: 5px;\n }\n /* Không cuộn riêng — xem ghi chú ở .cnv-panel-tier__list. */\n .cnv-panel-reward__list { }\n .cnv-panel-reward { padding: 10px 0; display: flex; gap: 10px; align-items: flex-start; }\n .cnv-panel-reward__main { min-width: 0; flex: 1; }\n .cnv-panel-reward__thumb {\n width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: cover;\n background: rgba(127, 127, 127, .12);\n }\n /* Tên dài (ưu đãi hay có tên rất dài) kẹp 2 dòng rồi "…" — không để 1 ưu đãi chiếm 3-4 dòng đẩy\n các ưu đãi khác ra khỏi khung. min-width:0 ở __main là điều kiện để ellipsis hoạt động\n trong flex. */\n .cnv-panel-reward__title {\n font-size: 13px; font-weight: 700; line-height: 1.4;\n display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;\n }\n .cnv-panel-reward__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }\n .cnv-panel-reward__value {\n font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px;\n white-space: nowrap;\n }\n .cnv-panel-reward__uses {\n font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px;\n background: rgba(127, 127, 127, .14); white-space: nowrap;\n }\n .cnv-panel-reward__code {\n font-size: 13px; font-weight: 800; letter-spacing: .06em; margin-top: 6px;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all;\n }\n .cnv-panel-reward__meta { font-size: 11.5px; opacity: .7; margin-top: 4px; line-height: 1.45; }\n .cnv-panel-reward__more { width: 100%; margin-top: 10px; }\n /* ── Block nội dung merchant tự soạn (Cách kiếm thêm điểm / Cách đổi điểm) ──\n Không cuộn riêng — xem ghi chú ở .cnv-panel-tier__list. */\n .cnv-panel-block__list { }\n .cnv-panel-block { padding: 11px 0; display: flex; gap: 10px; align-items: flex-start; }\n /* Chip lệch xuống 1px cho khớp đường chân chữ của dòng tiêu đề bên cạnh. */\n .cnv-panel-block .cnv-panel-chip { margin-top: 1px; }\n .cnv-panel-block__main { min-width: 0; flex: 1; }\n .cnv-panel-block__title { font-size: 13px; font-weight: 700; line-height: 1.4; }\n .cnv-panel-block__desc { font-size: 12px; line-height: 1.5; opacity: .72; margin-top: 3px; white-space: pre-line; }\n .cnv-panel-zalo__btn {\n height: 36px; padding: 0 16px; border: 1px solid rgba(127, 127, 127, .3); border-radius: 10px;\n background: transparent; color: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;\n transition: filter .15s;\n }\n .cnv-panel-zalo__btn:hover:not(:disabled) { filter: brightness(1.1); }\n .cnv-panel-zalo__btn:disabled { opacity: .5; cursor: default; }\n .cnv-panel-zalo__overlay {\n position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;\n padding: 16px;\n }\n .cnv-panel-zalo__overlay-bubble {\n display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;\n padding: 0 8px; max-width: 100%; animation: cnv-panel-bubble-in .2s ease;\n }\n .cnv-panel-bubble-icon {\n width: 40px; height: 40px; border-radius: 999px; display: flex; align-items: center; justify-content: center;\n }\n .cnv-panel-zalo__skeleton {\n border-radius: 6px; background: rgba(127, 127, 127, .15);\n background-image: linear-gradient(\n 90deg, rgba(127, 127, 127, .15) 25%, rgba(127, 127, 127, .32) 37%, rgba(127, 127, 127, .15) 63%\n );\n background-size: 400% 100%; animation: cnv-panel-shimmer 1.4s ease infinite;\n }\n @keyframes cnv-panel-shimmer {\n 0% { background-position: 100% 50%; }\n 100% { background-position: 0% 50%; }\n }\n @media (prefers-reduced-motion: reduce) { .cnv-panel-zalo__skeleton { animation: none; } }\n');c=i.hostEl;const g=i.shadow;c.style.setProperty("display","none");const m=null!==(t=(null==n?void 0:n.useCustomZIndex)?E(n.zIndex):null)&&void 0!==t?t:P,b=null!==(e=E(m+600))&&void 0!==e?e:P;l=document.createElement("div"),l.className="cnv-panel-card",l.style.zIndex=String(b),l.addEventListener("animationend",n=>{"cnv-panel-out"===n.animationName&&Pt()}),l.style.borderRadius=Hn(null===(o=r.shapes)||void 0===o?void 0:o.container);const y=document.createElement("button");y.type="button",y.className="cnv-panel-close",y.setAttribute("aria-label","Đóng"),y.textContent="×",y.addEventListener("click",It),f=document.createElement("button"),f.type="button",f.className="cnv-panel-back",f.setAttribute("aria-label","Quay lại"),f.appendChild(Zn('<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',15)),f.addEventListener("click",en(kt));const w=document.createElement("div");p=w,w.className="cnv-panel-banner",a=document.createElement("img"),a.className="cnv-panel-banner__img",a.alt="",u=document.createElement("img"),u.className="cnv-panel-banner__brandicon",u.alt="";const x=document.createElement("div");x.className="cnv-panel-banner__brandchip",x.appendChild(u),s=document.createElement("div"),s.className="cnv-panel-banner__caption",d=document.createElement("div"),d.className="cnv-panel-banner__title",w.append(a,x,s,d),h=document.createElement("div"),h.className="cnv-panel-body",l.append(y,f,w,h),v=Nt(),v&&l.appendChild(v),g.appendChild(l),q(c)}function Nt(){if(r.hideBranding)return null;const n="DARK"===r.theme,t=document.createElement("div");t.className="cnv-panel-footer",t.style.backgroundColor=n?"#181C32":"#FFFFFF",t.style.borderTop=n?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2",t.style.color=n?"rgba(255,255,255,.62)":"rgba(24,28,50,.58)",t.appendChild(document.createTextNode("Cung cấp bởi "));const e=document.createElement("span");return e.className="cnv-panel-footer__brand",e.textContent="CNV Loyalty",t.appendChild(e),t}function Ft(n){if(!l)return;const{side:t,sideSpacingPx:e,bottomSpacingPx:o}=V(n,H());l.style.left="left"===t?e+"px":"auto",l.style.right="right"===t?e+"px":"auto";const r=o+48+24;l.style.bottom=r+"px",l.style.maxHeight=`calc(100vh - ${r+16}px)`,l.style.transformOrigin="left"===t?"left bottom":"right bottom"}function It(){c&&m&&(m=!1,jt(),x=!1,_=!1,C=null,document.removeEventListener("keydown",W),Dt("cnv:panel:closed"),l&&!t(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,!1)?(l.classList.add(Fn),J=setTimeout(Pt,320)):Pt())}function Pt(){null!==J&&(clearTimeout(J),J=null),null==l||l.classList.remove(Fn),null==c||c.style.setProperty("display","none")}function $t(){null!==J&&(clearTimeout(J),J=null),null==l||l.classList.remove(Fn)}function Dt(t){n(()=>window.dispatchEvent(new CustomEvent(t)))}const Ht=t=>{n(()=>{var n;const e=t.detail;var r;m?It():(Ot(r=null!==(n=null==e?void 0:e.config)&&void 0!==n?n:null),c&&($t(),Ft(r),c.style.setProperty("display","block"),m=!0,gt(),un(),!sn()||N||F||(F=!0,o.fetchPanelTiers().then(n=>{F=!1,n&&n.tiers.length&&(N=n,m&>())}).catch(()=>{F=!1})),document.addEventListener("keydown",W),Dt("cnv:panel:opened")))})},Rt=t=>{n(()=>{const n=t.detail;b=(null==n?void 0:n.isMember)?{isMember:!0,points:n.points,rewardsAvailableCount:n.rewardsAvailableCount}:{isMember:!1},b.isMember||mt(),m&>(),m&&un()})};function Lt(){const n=Pn(o.projectId);n&&(Date.now()>n.exp?Dn(o.projectId):(b={isMember:!0},gt(),o.restorePanelSession(n.token).then(t=>{t?(b={isMember:!0},$n(o.projectId,Object.assign(Object.assign({},n),{fullName:t.fullName,level:t.level,xp:t.xp}))):(Dn(o.projectId),b={isMember:!1},mt()),gt()}).catch(()=>{})))}return window.addEventListener(On,Ht),window.addEventListener(Nn,Rt),Lt(),()=>{jt(),n(()=>{window.removeEventListener(On,Ht),window.removeEventListener(Nn,Rt),document.removeEventListener("keydown",W),$t(),null==c||c.remove()})}}catch(Et){return()=>{}}}const ht={path:"/config",timeoutMs:4e3,ttlMs:3e5};function pt(n,t){var e,o;const r=null!=t?t:Object.assign({enabled:!0},ht);return void 0===n?Object.assign({},r):!0===n?Object.assign(Object.assign({},r),{enabled:!0}):!1===n?Object.assign(Object.assign({},r),{enabled:!1}):{enabled:null===(e=n.enabled)||void 0===e||e,path:null!==(o=n.path)&&void 0!==o?o:r.path,timeoutMs:"number"==typeof n.timeoutMs?n.timeoutMs:r.timeoutMs,ttlMs:"number"==typeof n.ttlMs?n.ttlMs:r.ttlMs}}function ft(n){return"_cnv_cfg_"+n}function vt(n){const t=gn(ft(n));if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&n.envelope?n:null}catch(n){return null}}function gt(n,t,e){try{const o={etag:t,envelope:e,fetchedAt:Date.now()};mn(ft(n),JSON.stringify(o))}catch(n){}}function mt(n){const t=vt(n);return!t||!1!==(null===(o=null==(e=t.envelope)?void 0:e.zaloQrLogin)||void 0===o?void 0:o.enabled);var e,o}const bt=["gclid","fbclid","ttclid","msclkid","dclid"],yt=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function wt(){const n=t(()=>window.location.href,"");let e="",o="",r="";if(n)try{const t=new URL(n);e=t.pathname,o=t.search,r=t.hash}catch(n){}return{url:n,path:e,search:o,hash:r,title:t(()=>document.title,""),referrer:t(()=>document.referrer,"")}}function xt(n){var t,e;let o="@cnv-vn/track",r="0.0.0-dev";try{o="@cnv-vn/track"}catch(n){}try{r="0.3.0-beta.1"}catch(n){}return{name:null!==(t=null==n?void 0:n.name)&&void 0!==t?t:o,version:null!==(e=null==n?void 0:n.version)&&void 0!==e?e:r}}const _t="0123456789abcdef";function kt(n){return _t[n>>>4&15]+_t[15&n]}function Mt(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const n=new Uint8Array(16);return crypto.getRandomValues(n),n[6]=15&n[6]|64,n[8]=63&n[8]|128,kt(n[0])+kt(n[1])+kt(n[2])+kt(n[3])+"-"+kt(n[4])+kt(n[5])+"-"+kt(n[6])+kt(n[7])+"-"+kt(n[8])+kt(n[9])+"-"+kt(n[10])+kt(n[11])+kt(n[12])+kt(n[13])+kt(n[14])+kt(n[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const t=16*Math.random()|0;return("x"===n?t:3&t|8).toString(16)})}const At=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Ct(n){return"string"==typeof n&&At.test(n)}const jt="_cnv_cid";function zt(n={}){const t=pn(jt),e=gn(jt);let o=null;return Ct(t)?o=t:Ct(e)&&(o=e),o||(o=Mt()),St(o,n),o}function St(n,t={}){var e;fn(jt,n,{domain:t.cookieDomain,maxAgeDays:null!==(e=t.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),mn(jt,n)}const Tt="1.0";function Ot(){return(new Date).toISOString()}function Nt(n,t){var e;const o=null!==(e=t.timestamp)&&void 0!==e?e:Ot(),r=Object.assign(Object.assign({},t.context),{projectId:t.projectId,schemaVersion:Tt}),i={type:n,messageId:Mt(),anonymousId:t.anonymousId,timestamp:o,originalTimestamp:o,context:r};return t.userId&&(i.userId=t.userId),t.sessionId&&(i.sessionId=t.sessionId),t.integrations&&(i.integrations=t.integrations),i}const Ft="_cnv_sid";function It(n){if(!n)return null;const t=n.lastIndexOf(".");if(t<0)return null;const e=n.slice(0,t),o=Number(n.slice(t+1));return!Ct(e)||!Number.isFinite(o)||o<=0?null:{id:e,lastActivity:o}}function Pt(n={}){const t=Date.now(),e=(n=>{var t;return 6e4*(null!==(t=n.timeoutMinutes)&&void 0!==t?t:30)})(n),o=It(pn(Ft)),r=It((n=>{if(!yn())return null;try{return sessionStorage.getItem(n)}catch(n){return null}})(Ft));let i=null;for(const n of[o,r])n&&(t-n.lastActivity>e||(!i||n.lastActivity>i.lastActivity)&&(i=n));const c=i?{id:i.id,lastActivity:t}:{id:Mt(),lastActivity:t};return $t(c,n),c.id}function $t(n,t={}){var e;const o=(n=>`${n.id}.${n.lastActivity}`)(n),r=null!==(e=t.timeoutMinutes)&&void 0!==e?e:30;fn(Ft,o,{domain:t.cookieDomain,maxAgeDays:r/1440,sameSite:"Lax"}),((n,t)=>{if(!yn())return!1;try{return sessionStorage.setItem(n,t),!0}catch(n){return!1}})(Ft,o)}class Dt{constructor(n){var t,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"storageKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"flushing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"onlineHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.storageKey=null!==(t=n.storageKey)&&void 0!==t?t:"_cnv_rq",this.maxMessages=null!==(e=n.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(n){if(n&&0!==n.length)try{const t=this.read();for(t.push(n);t.length>1&&Ht(t)>this.maxMessages;)t.shift();this.write(t),this.config.debug&&console.log("[cnv-track] retry queued",n.length,"buffered",Ht(t))}catch(n){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const n=this.read();if(0===n.length)return Promise.resolve();this.flushing=!0,this.write([]);const t=()=>{this.flushing=!1};return n.reduce((n,t)=>n.then(()=>this.config.resend(t)),Promise.resolve()).then(t,t)}size(){return Ht(this.read())}clear(){try{bn(this.storageKey)}catch(n){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(n){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const n=()=>{this.flush()};try{window.addEventListener("online",n),this.onlineHandler=n}catch(n){}}read(){const n=gn(this.storageKey);if(!n)return[];try{const t=JSON.parse(n);return Array.isArray(t)?t.filter(n=>Array.isArray(n)&&n.length>0):[]}catch(n){return[]}}write(n){0!==n.length?mn(this.storageKey,JSON.stringify(n)):bn(this.storageKey)}}function Ht(n){let t=0;for(const e of n)t+=e.length;return t}class Rt{constructor(n){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"retryQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.retryQueue=new Dt({debug:n.debug,resend:n=>this.send(n)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(n){this.config=Object.assign(Object.assign({},this.config),n)}enqueue(n){this.destroyed||(this.buffer.push(n),this.buffer.length>=this.config.flushAt?this.flush():this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush()},this.config.flushInterval)))}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),0===this.buffer.length)return Promise.resolve();const n=this.buffer;return this.buffer=[],this.send(n)}bufferedCount(){return this.buffer.length}destroy(){this.destroyed||(this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),this.uninstallPageLifecycleHandlers(),this.retryQueue.destroy())}send(n){try{return this.config.useBatch?this.sendBatch(n):Promise.all(n.map(n=>this.sendSingle(n))).then(()=>{})}catch(n){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",n),Promise.resolve()}}sendBatch(n){var t;const e=Ot(),o={batch:n.map(n=>Lt(n,e)),context:Object.assign(Object.assign({},null!==(t=this.config.batchContext)&&void 0!==t?t:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),o,n)}sendSingle(n){const t=Lt(n,Ot());return this.post(this.singleUrl(n.type),t,[n])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(n){const t=this.config.singlePath.replace("{type}",n);return this.config.endpoint+t+"?projectId="+encodeURIComponent(this.config.projectId)}post(n,t,e){const o=JSON.stringify(t),r=((n,t)=>{try{return new Blob([n],{type:t})}catch(n){return null}})(o,this.config.contentType),i=r?r.size:(n=>{try{return new Blob([n]).size}catch(t){return n.length}})(o),c=i>65536?null:e;return c&&"undefined"!=typeof navigator&&!1===navigator.onLine?(this.retryQueue.stash(c),this.config.debug&&console.log("[cnv-track] offline; queued for retry",n),Promise.resolve()):r&&this.sendViaBeacon(n,r)?(this.config.debug&&console.log("[cnv-track] beacon",n),Promise.resolve()):this.sendViaFetch(n,o,c)}sendViaBeacon(n,t){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(t.size>65536)return!1;try{return navigator.sendBeacon(n,t)}catch(n){return!1}}sendViaFetch(n,t,e){return"function"!=typeof fetch?(this.config.debug&&console.warn("[cnv-track] no transport available; queued for retry"),e&&this.retryQueue.stash(e),Promise.resolve()):fetch(n,{method:"POST",headers:{"Content-Type":this.config.contentType},body:t,keepalive:!0,credentials:"omit",mode:"cors"}).then(t=>{this.config.debug&&console.log("[cnv-track] fetch flushed",n,t.status)}).catch(t=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",n,t),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const n=()=>{this.flush()},t=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",n),document.addEventListener("visibilitychange",t),this.handlers={pagehide:n,visibility:t}}catch(n){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(n){}this.handlers=null}}}function Lt(n,t){return Object.assign(Object.assign({},n),{sentAt:t})}const Et="_cnv_uid",Bt="_cnv_traits";function Ut(){return pn(Et)||gn(Et)}const Vt={endpoint:"https://tracking.cnvcdp.com/js/v1",batchPath:"/batch",singlePath:"/{type}",useBatch:!0,contentType:"text/plain",debug:!1,allowAdTracking:!0,cookieMaxAgeDays:730,sessionTimeoutMinutes:30,flushAt:20,flushInterval:5e3,autoPageview:!0,autotrack:!1,integrations:{},remoteConfig:pt(void 0)},Kt={analytics:!0,marketing:!0};function qt(n,t){if(!Array.isArray(t)||0===t.length)return;const e=t;try{switch(e[0]){case"init":n.init(e[1],e[2]);break;case"pageview":n.pageview(e[1],e[2]);break;case"page":n.page(e[1],e[2]);break;case"screen":n.screen(e[1],e[2]);break;case"track":n.track(e[1],e[2]);break;case"identify":n.identify(e[1],e[2]);break;case"alias":n.alias(e[1],e[2]);break;case"group":n.group(e[1],e[2]);break;case"reset":n.reset();break;case"flush":n.flush();break;case"consent":n.consent(e[1]);break;case"set":n.set(e[1])}}catch(n){}}const Gt="0.3.0-beta.1",Zt="@cnv-vn/track",Yt=function(){let l=null,a=Object.assign({},Vt),u=Object.assign({},Kt),s=null,d=!1,h=null;function p(n,t){let o=null,r=null;return{apply(i,c){o&&null!==c&&c===r||(o=e(o),r=c,i&&(o=n(t(),i)))},dispose(){o=e(o),r=null}}}let f=null;const v=()=>f,g=p(_,v),m=p(J,v),b=p(dt,v);function y(n){const t=Object.assign({},a);return n?(void 0!==n.endpoint&&(t.endpoint=(e=n.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==n.batchPath&&(t.batchPath=n.batchPath),void 0!==n.singlePath&&(t.singlePath=n.singlePath),void 0!==n.useBatch&&(t.useBatch=n.useBatch),void 0!==n.contentType&&(t.contentType=n.contentType),void 0!==n.debug&&(t.debug=n.debug),void 0!==n.allowAdTracking&&(t.allowAdTracking=n.allowAdTracking),void 0!==n.cookieDomain&&(t.cookieDomain=n.cookieDomain),void 0!==n.cookieMaxAgeDays&&(t.cookieMaxAgeDays=n.cookieMaxAgeDays),void 0!==n.sessionTimeoutMinutes&&(t.sessionTimeoutMinutes=n.sessionTimeoutMinutes),void 0!==n.flushAt&&(t.flushAt=n.flushAt),void 0!==n.flushInterval&&(t.flushInterval=n.flushInterval),void 0!==n.autoPageview&&(t.autoPageview=n.autoPageview),void 0!==n.autotrack&&(t.autotrack=n.autotrack),void 0!==n.integrations&&(t.integrations=n.integrations),void 0!==n.remoteConfig&&(t.remoteConfig=pt(n.remoteConfig,a.remoteConfig)),t):t;var e}function w(){return s||(s=new Rt({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,projectId:null!=l?l:"",debug:a.debug}),s)}function x(){var n;if(!l)return null;const e=((n={})=>{var e;const o={page:wt(),screen:{width:t(()=>window.screen.width,0),height:t(()=>window.screen.height,0),density:t(()=>window.devicePixelRatio||1,1)},locale:t(()=>navigator.language||"",""),timezone:t(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:t(()=>navigator.userAgent||"",""),library:xt(n.library)},r=((n,e=!0)=>{const o=t(()=>window.location.search,"");if(!o)return;let r;try{r=new URLSearchParams(o)}catch(n){return}const i={};let c=!1;for(const[n,t]of yt){const e=r.get(n);e&&e.length>0&&(i[t]=e,c=!0)}if(e){const n={};for(const t of bt){const e=r.get(t);e&&e.length>0&&(n[t]=e)}Object.keys(n).length>0&&(i.clickIds=n,c=!0)}return c?i:void 0})(0,null===(e=n.allowAdTracking)||void 0===e||e);return r&&(o.campaign=r),o})({allowAdTracking:a.allowAdTracking});return u.analytics&&u.marketing||(e.consent=Object.assign({},u)),{anonymousId:zt({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),sessionId:Pt({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),userId:null!==(n=Ut())&&void 0!==n?n:void 0,context:e,projectId:l,integrations:Object.keys(a.integrations).length>0?a.integrations:void 0}}function k(n){a.debug&&console.warn(`[cnv-track] ${n}() called before init()`)}function M(n,t){try{const e=x();if(!e)return k("pageview");const o=((n,t,e)=>{const o=Nt("page",e);return n&&(o.name=n),o.properties=null!=t?t:{},o})(n,((n,t)=>{const e={};return n&&(n.url&&(e.url=n.url),n.path&&(e.path=n.path),n.title&&(e.title=n.title),n.referrer&&(e.referrer=n.referrer),n.search&&(e.search=n.search)),Object.assign(Object.assign({},e),null!=t?t:{})})(e.context.page,t),e);w().enqueue(o)}catch(n){}}function A(n,t){M(n,t)}function C(n,t){try{if("string"!=typeof n||0===n.length)return;const e=x();if(!e)return k("track");const o=((n,t,e)=>{const o=Nt("track",e);return o.event=n,o.properties=null!=t?t:{},o})(n,t,e);w().enqueue(o)}catch(n){}}function j(n,t){try{if("string"!=typeof n||0===n.length)return;((n,t,e={})=>{var o,r;if(n&&(fn(Et,n,{domain:e.cookieDomain,maxAgeDays:null!==(o=e.cookieMaxAgeDays)&&void 0!==o?o:730,sameSite:"Lax"}),mn(Et,n),null!=t)){const n=null!==(r=(()=>{const n=gn(Bt);if(!n)return null;try{const t=JSON.parse(n);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(n){return null}})())&&void 0!==r?r:{},e=Object.assign(Object.assign({},n),t);try{mn(Bt,JSON.stringify(e))}catch(n){}}})(n,t,{cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays});const e=x();if(!e)return k("identify");const o=((n,t,e)=>{var o;const r=Nt("identify",e);return n&&(r.userId=n),r.traits=null!==(o=t)&&void 0!==o?o:{},r})(n,t,e);w().enqueue(o)}catch(n){}}function z(n,t){}return{get initialized(){return d},get projectId(){return l},get endpoint(){return a.endpoint},isZaloQrLoginEnabled:()=>!!l&&mt(l),get consentGranted(){return u.analytics&&u.marketing},init(t,p){var v,x;try{if(!t||"string"!=typeof t)return;a=y(p),(null==p?void 0:p.consent)&&(u=Object.assign(Object.assign({},u),p.consent)),l=t,s&&s.destroy(),s=null,w(),d=!0,zt({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),Pt({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),a.autoPageview&&M(),h=e(h);const k={page(n,t){return A(n,t)},track(n,t){return C(n,t)},loginWithZalo(n){return Tn({projectId:l,endpoint:a.endpoint,zaloQrLoginEnabled:!!l&&mt(l),consentGranted:u.analytics&&u.marketing,identify:j,alias:z,getUserId:Ut},n)},projectId:l,restorePanelSession(n){return l?function(n,t,e){return wn(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),8e3):null;try{const r=yield fetch(Mn(n,"/panel/session",t),{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(!r.ok)return null;const i=yield r.json();return i&&"number"==typeof i.contactId?{contactId:i.contactId,fullName:"string"==typeof i.fullName?i.fullName:void 0,level:"string"==typeof i.level?i.level:void 0,xp:"number"==typeof i.xp?i.xp:void 0}:null}catch(n){return null}finally{r&&clearTimeout(r)}})}(a.endpoint,l,n):Promise.resolve(null)},fetchRewardsSummary(n,t){return l?function(n,t,e){return wn(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),xn):null;try{const i=Mn(n,"/panel/rewards-summary",t),c=o>1?`${i}${i.includes("?")?"&":"?"}page=${o}`:i,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:r?r.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.rewards)?t.rewards.filter(n=>!!n&&"object"==typeof n).map(Sn):[];return{points:"number"==typeof t.points&&Number.isFinite(t.points)?t.points:void 0,rewardsAvailableCount:"number"==typeof t.rewardsAvailableCount&&Number.isFinite(t.rewardsAvailableCount)?t.rewardsAvailableCount:void 0,rewards:e,tier:t.tier&&"object"==typeof t.tier?zn(t.tier):void 0}})(yield l.json()):null}catch(n){return null}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve(null)},fetchPanelTiers(){return l?function(n,t){return wn(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),xn):null;try{const o=yield fetch(Mn(n,"/panel/tiers",t),{method:"GET",credentials:"omit",mode:"cors",signal:e?e.signal:void 0});return o.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.tiers)?t.tiers.filter(n=>!!n&&"object"==typeof n).map(jn):[];return{applyFor:"SPENDING"===t.applyFor||"POINTS"===t.applyFor?t.applyFor:void 0,thresholdKind:"RELATIVE"===t.thresholdKind||"ABSOLUTE"===t.thresholdKind?t.thresholdKind:void 0,totalTiers:Cn(t.totalTiers),tiers:e}})(yield o.json()):null}catch(n){return null}finally{o&&clearTimeout(o)}})}(a.endpoint,l):Promise.resolve(null)},fetchPointHistory(n,t){return l?function(n,t,e){return wn(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),xn):null;try{const i=Mn(n,"/panel/point-history",t),c=o>1?`${i}${i.includes("?")?"&":"?"}page=${o}`:i,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:r?r.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.items)?t.items.filter(n=>!!n&&"object"==typeof n).map(An):[];return{totalCount:"number"==typeof t.totalCount&&Number.isFinite(t.totalCount)?t.totalCount:void 0,items:e}})(yield l.json()):null}catch(n){return null}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve(null)}};if(f=k,a.autotrack){let t=a.autotrack;a.remoteConfig.enabled&&"object"==typeof t&&t.buttonTracking&&(t=Object.assign(Object.assign({},t),{buttonTracking:void 0})),h=function(t,e){const l=void 0===(a=e)||!1===a?Object.assign(Object.assign({},I),{searchParams:N}):!0===a?Object.assign(Object.assign({},F),{searchParams:N}):{spa:null===(u=a.spa)||void 0===u||u,outboundClicks:null===(s=a.outboundClicks)||void 0===s||s,scroll:null===(d=a.scroll)||void 0===d||d,downloads:null===(h=a.downloads)||void 0===h||h,siteSearch:null===(p=a.siteSearch)||void 0===p||p,downloadExtensions:a.downloadExtensions,searchParams:null!==(f=a.searchParams)&&void 0!==f?f:N,buttonTracking:a.buttonTracking};var a,u,s,d,h,p,f;l.outboundClicks=!1,l.downloads=!1,l.scroll=!1,l.siteSearch=!1;const v=[];let g=null;function m(e){if(l.siteSearch)try{const o=null!=e?e:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(n){return""}})();if(o===g)return;g=o;const r=((n,t=N)=>{try{if(!n){if("undefined"==typeof location)return null;n=location.href}const e=n instanceof URL?n:new URL(n,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(n){return"http://localhost/"}})());if(!e.search)return null;for(const n of t){const t=e.searchParams.get(n);if(null===t)continue;const o=t.trim();if(0!==o.length)return{query:o,param:n}}return null}catch(n){return null}})(o,l.searchParams);r&&n(()=>t.track("Site Searched",{query:r.query,param:r.param}))}catch(n){}}if(l.outboundClicks||l.downloads){const e=(n=>{var t;if("undefined"==typeof document)return()=>{};const e=new Set((null!==(t=n.downloadExtensions)&&void 0!==t?t:o).map(n=>n.toLowerCase())),l=!!n.onOutbound,a=!!n.onDownload;if(!l&&!a)return()=>{};function u(t){var o,u;try{if(0!==t.button)return;if(t.defaultPrevented)return;const s=(n=>{const t="function"==typeof n.composedPath?n.composedPath():[];if(t.length>0)for(const n of t)if(r(n))return n;let e=n.target;for(;e;){if(r(e))return e;e=e.parentNode}return null})(t);if(!s)return;const d=s.getAttribute("href");if(!d)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(d))return;if(d.startsWith("#"))return;const h=(n=>{try{return new URL(n,location.href)}catch(n){return null}})(d);if(!h)return;let p=!1;if(a){const t=s.hasAttribute("download"),r=(n=>{const t=i(n),e=t.lastIndexOf(".");return e<=0||e===t.length-1?null:t.slice(e+1).toLowerCase()})(h.pathname);(t||r&&e.has(r))&&(p=!0,null===(o=n.onDownload)||void 0===o||o.call(n,{url:h.href,fileName:i(h.pathname),fileExtension:null!=r?r:"",text:c(s)}))}l&&!p&&h.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(n){return""}})()&&h.host&&(null===(u=n.onOutbound)||void 0===u||u.call(n,{url:h.href,host:h.host,text:c(s),target:s.target||"_self"}))}catch(n){}}try{document.addEventListener("click",u,!0)}catch(n){return()=>{}}return()=>{try{document.removeEventListener("click",u,!0)}catch(n){}}})({downloadExtensions:l.downloadExtensions,onOutbound:l.outboundClicks?e=>n(()=>t.track("Clicked",e)):void 0,onDownload:l.downloads?e=>n(()=>t.track("File Downloaded",e)):void 0});v.push(e)}l.buttonTracking&&l.buttonTracking.rules&&l.buttonTracking.rules.length>0&&v.push(_(t,l.buttonTracking));let b=null;if(l.scroll&&(b=(n=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let t=!1,e=null,o=!1;function r(){if(e=null,!o&&!t)try{const e=document.documentElement,o=document.body,r=Math.max(e?e.scrollHeight:0,o?o.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(r<=i)return t=!0,c(),void n(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/r>=.9&&(t=!0,c(),n(90))}catch(n){}}function i(){if(null===e)try{e=window.requestAnimationFrame(r)}catch(n){r()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(n){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(n){try{window.addEventListener("scroll",i)}catch(n){}}try{window.requestAnimationFrame(r)}catch(n){r()}return{destroy(){o=!0,c()},reset(){if(!o){t=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(n){try{window.addEventListener("scroll",i)}catch(n){}}try{window.requestAnimationFrame(r)}catch(n){r()}}}}})(e=>{n(()=>t.track("Scrolled",{percent:e}))}),v.push(()=>null==b?void 0:b.destroy())),l.spa){const e=[],o=T(o=>{const r=setTimeout(()=>{const o=e.indexOf(r);-1!==o&&e.splice(o,1),n(()=>t.page())},0);e.push(r),null==b||b.reset(),m(o)});v.push(()=>{for(let n=0;n<e.length;n++)clearTimeout(e[n]);e.length=0,o()})}return m(),()=>{for(;v.length>0;){const n=v.pop();try{null==n||n()}catch(n){}}g=null}}(k,t)}if(g.dispose(),m.dispose(),b.dispose(),a.remoteConfig.enabled&&l){const n=n=>{var t,e,o,r;g.apply((n=>{const t=null==n?void 0:n.buttonTracking;if(!t||!1===t.enabled)return null;const e=Array.isArray(t.rules)?t.rules:[];return 0===e.length?null:{rules:e,globalThrottle:t.globalThrottle}})(n),null),m.apply((n=>{var t;const e=null===(t=null==n?void 0:n.launcher)||void 0===t?void 0:t.config;return e?"NONE"===e.deviceVisibility?null:e:null})(n),null!==(e=null===(t=null==n?void 0:n.launcher)||void 0===t?void 0:t.version)&&void 0!==e?e:null),b.apply((n=>{var t;const e=null===(t=null==n?void 0:n.panel)||void 0===t?void 0:t.config;return null!=e?e:null})(n),null!==(r=null===(o=null==n?void 0:n.panel)||void 0===o?void 0:o.version)&&void 0!==r?r:null)};n(null!==(x=null===(v=vt(l))||void 0===v?void 0:v.envelope)&&void 0!==x?x:null),function(n){return wn(this,void 0,void 0,function*(){if(!n.projectId)return{status:"error"};const t=vt(n.projectId);if(t&&Date.now()-t.fetchedAt<n.ttlMs)return{status:"unchanged"};const e=yield function(n){return wn(this,void 0,void 0,function*(){var t;if("function"!=typeof fetch)return null;const e=n.endpoint+n.path+"?projectId="+encodeURIComponent(n.projectId),o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),n.timeoutMs):null;try{const r={};n.etag&&(r["If-None-Match"]=n.etag);const i=yield fetch(e,{method:"GET",headers:r,credentials:"omit",mode:"cors",cache:"no-store",signal:o?o.signal:void 0});if(304===i.status)return{envelope:null,etag:null!==(t=n.etag)&&void 0!==t?t:"",notModified:!0};if(!i.ok)return null;const c=i.headers&&"function"==typeof i.headers.get?i.headers.get("ETag"):null;return{envelope:yield i.json(),etag:null!=c?c:"",notModified:!1}}catch(n){return null}finally{r&&clearTimeout(r)}})}({endpoint:n.endpoint,path:n.path,projectId:n.projectId,timeoutMs:n.timeoutMs,etag:null==t?void 0:t.etag});return e?e.notModified?(t&>(n.projectId,t.etag,t.envelope),{status:"unchanged"}):e.envelope?(gt(n.projectId,e.etag,e.envelope),{status:"updated",envelope:e.envelope}):{status:"error"}:{status:"error"}})}({endpoint:a.endpoint,path:a.remoteConfig.path,projectId:l,timeoutMs:a.remoteConfig.timeoutMs,ttlMs:a.remoteConfig.ttlMs}).then(t=>{"updated"===t.status&&n(t.envelope)}).catch(()=>{})}}catch(n){}},pageview:M,page:A,screen(n,t){},track:C,identify:j,alias:z,group(n,t){},reset(){try{((n={})=>{((n,t={})=>{var e;if(!hn)return!1;try{let o=`${encodeURIComponent(n)}=`;return o+=`; path=${null!==(e=t.path)&&void 0!==e?e:"/"}`,t.domain&&(o+=`; domain=${t.domain}`),o+="; max-age=0",o+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=o,null===pn(n)}catch(n){return!1}})(Et,{domain:n.cookieDomain}),bn(Et),bn(Bt)})({cookieDomain:a.cookieDomain}),((n={})=>{St(Mt(),n)})({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),((n={})=>{$t({id:Mt(),lastActivity:Date.now()},n)})({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes})}catch(n){}},flush(){try{s&&s.flush()}catch(n){}},consent(n){try{u=Object.assign(Object.assign({},u),n)}catch(n){}},set(n){try{a=y(n),n.consent&&(u=Object.assign(Object.assign({},u),n.consent)),s&&s.setConfig({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,debug:a.debug})}catch(n){}},destroy(){h=e(h),g.dispose(),m.dispose(),b.dispose(),f=null,s&&s.destroy(),s=null,d=!1,l=null,a=Object.assign({},Vt),u=Object.assign({},Kt)}}}();function Jt(n){return Tn({projectId:Yt.projectId,endpoint:Yt.endpoint,zaloQrLoginEnabled:Yt.isZaloQrLoginEnabled(),consentGranted:Yt.consentGranted,identify:Yt.identify,alias:Yt.alias,getUserId:Ut},n)}"undefined"!=typeof window&&(n=>{if("undefined"==typeof window)return()=>{};const t=window.cnvQ;if(t&&t.__loaded)return()=>{};const e=window.cnvQ=null!=t?t:[],o=e.splice(0,e.length);e.push.bind(e),e.push=(...t)=>{for(const e of t)qt(n,e);return e.length},e.__loaded=!0;for(const t of o)qt(n,t)})(Yt);const Qt=Object.assign(Yt,{version:Gt,name:Zt,schemaVersion:Tt,loginWithZalo:Jt});export{Zt as NAME,Tt as SCHEMA_VERSION,Gt as VERSION,kn as ZaloQrLoginError,Qt as default,Jt as loginWithZalo};
|