@cnv-vn/track 0.3.0-beta.16 → 0.3.0-beta.17

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @cnv-vn/track v0.3.0-beta.16
2
+ * @cnv-vn/track v0.3.0-beta.17
3
3
  * (c) 2026 CNV
4
4
  * Released under the UNLICENSED license.
5
5
  */
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:_(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 p(n){return"regex"===n.mode?{mode:"regex",needle:n.value,re:_(n.value,!0)}:{mode:n.mode,needle:n.value.toLowerCase(),re:null}}function f(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:_(t,!1)}}function h(n,t){return"startsWith"===n.mode?0===t.indexOf(n.needle):!n.re||w(n.re,t)}const v=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,m=/\+?\d[\d\s().-]{7,}\d/g;function g(n){if(!n)return n;try{return n.replace(v,"[email]").replace(m,"[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 _(n,t){try{return!n||n.length>1e3?null:new RegExp(n,t?"i":"")}catch(n){return null}}function w(n,t){try{return n.test(t)}catch(n){return!1}}function x(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?p(i.destinationUrl):null,urlScope:r.urlScope?f(r.urlScope):null,dedupeWindowMs:S(c.dedupeWindowMs,S(t.dedupeWindowMs,500)),maxPerPageview:S(c.maxPerPageview,S(t.maxPerPageview,1/0)),samplingRate:O(S(c.samplingRate,S(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=M();function d(e){try{if(0!==e.button)return;const r=M();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&&!h(s.urlScope,u))continue;let d=null;for(let n=0;n<i.length;n++)if(A(s,i[n])){d=i[n];break}if(!d)continue;const p=s.rule.id;if((a.get(p)||0)>=s.maxPerPageview)return;const f=p+"#"+c(d),v=Date.now(),m=l.get(f);if(void 0!==m&&v-m<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;l.set(f,v),a.set(p,(a.get(p)||0)+1);const g=C(s.rule,d,e);return void n(()=>t.track("clicked",g))}}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 A(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&&w(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&&w(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 C(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=g(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]=g(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=g(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 M(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}function S(n,t){return"number"!=typeof n||isNaN(n)?t:n}function O(n){return n<0?0:n>1?1:n}const E="__cnvPatched";function I(n){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=N();function e(){try{const e=N();if(e===t)return;t=e,n(e)}catch(n){}}const o=history.pushState,r=history.replaceState,i=!0===o[E],c=!0===r[E];if(!i){function u(...n){o.apply(this,n),e()}u[E]=!0,history.pushState=u}if(!c){function s(...n){r.apply(this,n),e()}s[E]=!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[E]&&(history.pushState=o),!c&&history.replaceState[E]&&(history.replaceState=r)}catch(n){}}}function N(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}const z=["q","s","query","search","keyword"],T={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};const j=2147483e3,F="#6C5CE7",R="#FFFFFF";function B(){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 L(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 P(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 $(n){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(Math.trunc(n),0),2147483647):null}function U(n,t=20){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(n,0),2e3):t}function V(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 H(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:U(null==e?void 0:e.sideSpacing),bottomSpacingPx:U(null==e?void 0:e.bottomSpacing)}}function q(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 K(n){var t;(null!==(t=document.body)&&void 0!==t?t:document.documentElement).appendChild(n)}function G(t,e){if("function"!=typeof MutationObserver)return()=>{};let o=0,r=!1;function i(){l.disconnect(),l.observe(document,{childList:!0}),document.documentElement&&l.observe(document.documentElement,{childList:!0}),document.body&&l.observe(document.body,{childList:!0})}function c(){r=!0,l.disconnect()}const l=new MutationObserver(()=>{r||(i(),!t.isConnected&&document.body&&(++o>5?c():(K(t),i(),e&&n(e))))});return i(),c}const Z="cnv:panel:opened",W="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&&P(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}=q("data-cnv-launcher",':host{all:initial;}.cnv-launcher-fab{display:inline-flex;align-items:center;gap:8px;height:48px;padding:0 18px;border:none;cursor:pointer;box-shadow:0 6px 18px rgba(0,0,0,.18);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:14px;font-weight:600;line-height:1;white-space:nowrap;transition:transform .18s cubic-bezier(.16,1,.3,1),box-shadow .18s ease;animation:cnv-fab-in .32s cubic-bezier(.16,1,.3,1);}.cnv-launcher-fab:hover{transform:translateY(-2px);box-shadow:0 10px 26px rgba(0,0,0,.24);}.cnv-launcher-fab:active{transform:translateY(0) scale(.96);}.cnv-launcher-fab__icon{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex-shrink:0;}.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{width:20px;height:20px;object-fit:contain;animation:cnv-fab-icon-in .28s cubic-bezier(.16,1,.3,1);}@keyframes cnv-fab-in{from{opacity:0;transform:translateY(10px) scale(.9);}to{opacity:1;transform:none;}}@keyframes cnv-fab-icon-in{from{opacity:0;transform:rotate(-90deg) scale(.4);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-launcher-fab,.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{animation:none !important;transition:none !important;}}'),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=L(e.backgroundColor,F),n.style.color=L(e.textColor,R),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=B();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}=H(r,c),s=r.useCustomZIndex?$(r.zIndex):null,d=r.addImportantRule?"important":"",p=(t,e)=>n.style.setProperty(t,e,d);p("position","fixed"),p("bottom",u+"px"),p("left","left"===l?a+"px":"auto"),p("right","right"===l?a+"px":"auto"),p("z-index",String(null!=s?s:j));const f=c?r.contentLayoutMobile:r.contentLayoutDesktop,h=!i&&"ICON_ONLY"!==f;e.style.display=i||"TEXT_ONLY"!==f?"inline-flex":"none",o.style.display=h?"inline":"none",h&&(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),p=()=>s(!1);window.addEventListener(Z,d),window.addEventListener(W,p);const f=()=>{n(()=>window.dispatchEvent(new CustomEvent("cnv:launcher:click",{detail:{config:o}})))};i.addEventListener("click",f);let h=null;const v=()=>{n(()=>{K(e),h=G(e,u),u()})};document.body?v():document.addEventListener("DOMContentLoaded",v,{once:!0});const m=t(()=>window.matchMedia("(max-width: 768px)"),null),g=()=>u(),b=m;m&&"function"==typeof m.addEventListener?m.addEventListener("change",g):m&&"function"==typeof b.addListener?b.addListener(g):window.addEventListener("resize",g);const y=I(u);return()=>{n(()=>{document.removeEventListener("DOMContentLoaded",v),i.removeEventListener("click",f),window.removeEventListener(Z,d),window.removeEventListener(W,p),m&&"function"==typeof m.removeEventListener?m.removeEventListener("change",g):m&&"function"==typeof b.removeListener?b.removeListener(g):window.removeEventListener("resize",g),h&&h(),e.remove()}),n(y)}}catch(n){return()=>{}}}function Q(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 X=(n,t)=>{let e=n;const o=nn[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),p(),d(),h(n,t),e>=7&&f(n),null==c&&(c=m(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)},p=()=>{const n=tn.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}},f=n=>{const t=tn.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}},h=(n,t)=>{const e=tn.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=tn.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}}},m=(n,t,e)=>{const o=rn.getRSBlocks(n,t),r=cn();for(let t=0;t<e.length;t+=1){const o=e[t];r.put(o.getMode(),4),r.put(o.getLength(),tn.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=tn.getErrorCorrectPolynomial(u),d=on(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=ln(n);break;case"Alphanumeric":e=an(n);break;case"Byte":e=un(n);break;case"Kanji":e=sn(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=rn.getRSBlocks(n,o),e=cn();for(let t=0;t<l.length;t++){const o=l[t];e.put(o.getMode(),4),e.put(o.getLength(),tn.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=tn.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,p="";for(d="l"+n+",0 0,"+n+" -"+n+",0 0,-"+n+"z ",p+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',p+=r.scalable?"":' width="'+i+'px" height="'+i+'px"',p+=' viewBox="0 0 '+i+" "+i+'" ',p+=' preserveAspectRatio="xMinYMin meet"',p+=o.text||e.text?' role="img" aria-labelledby="'+g([o.id,e.id].join(" ").trim())+'"':"",p+=">",p+=o.text?'<title id="'+g(o.id)+'">'+g(o.text)+"</title>":"",p+=e.text?'<description id="'+g(e.id)+'">'+g(e.text)+"</description>":"",p+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',p+='<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,p+="M"+l+","+s+d);return p+='" stroke="transparent" fill="black"/>',p+="</svg>",p},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 fn(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+=g(e),r+='"'),r+="/>",r};const g=n=>{let t="";for(let e=0;e<n.length;e+=1){const o=n.charAt(e);switch(o){case"<":t+="&lt;";break;case">":t+="&gt;";break;case"&":t+="&amp;";break;case'"':t+="&quot;";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 p="";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+="█",p+=n<1&&r+1>=o?d[u]:s[u];p+="\n"}return t%2&&n>0?p.substring(0,p.length-t-1)+Array(t+1).join("▀"):p.substring(0,p.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 p="",f="";for(i=0;i<e;i+=1){for(l=Math.floor((i-o)/n),f="",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),f+=u?s:d;for(l=0;l<n;l+=1)p+=f+"\n"}return p.substring(0,p.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};X.stringToBytes=n=>{const t=[];for(let e=0;e<n.length;e+=1){const o=n.charCodeAt(e);t.push(255&o)}return t},X.createStringToBytes=(n,t)=>{const e=(()=>{const e=pn(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 nn={L:1,M:0,Q:3,H:2},tn=(()=>{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=on([1],0);for(let e=0;e<n;e+=1)t=t.multiply(on([1,en.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})(),en=(()=>{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]}}})(),on=(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]^=en.gexp(en.glog(o.getAt(e))+en.glog(n.getAt(r)));return on(t,0)},mod(n){if(o.getLength()-n.getLength()<0)return o;const t=en.glog(o.getAt(0))-en.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]^=en.gexp(en.glog(n.getAt(o))+t);return on(e,0).mod(n)}};return o},rn=(()=>{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 nn.L:return n[4*(t-1)+0];case nn.M:return n[4*(t-1)+1];case nn.Q:return n[4*(t-1)+2];case nn.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}}})(),cn=()=>{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},ln=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},an=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},un=n=>{const t=X.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)}}},sn=n=>{const t=X.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},dn=()=>{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},pn=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},fn=(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=dn(),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=dn();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 vn(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 mn(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,vn(n)===t}catch(n){return!1}}function gn(){if(!hn)return!1;try{const n="__cnv_probe__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch(n){return!1}}function bn(n){if(!gn())return null;try{return localStorage.getItem(n)}catch(n){return null}}function yn(n,t){if(!gn())return!1;try{return localStorage.setItem(n,t),!0}catch(n){return!1}}function _n(n){if(!gn())return!1;try{return localStorage.removeItem(n),!0}catch(n){return!1}}function wn(){if(!hn)return!1;try{const n="__cnv_probe__";return sessionStorage.setItem(n,"1"),sessionStorage.removeItem(n),!0}catch(n){return!1}}const xn="0123456789abcdef";function kn(n){return xn[n>>>4&15]+xn[15&n]}function An(){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,kn(n[0])+kn(n[1])+kn(n[2])+kn(n[3])+"-"+kn(n[4])+kn(n[5])+"-"+kn(n[6])+kn(n[7])+"-"+kn(n[8])+kn(n[9])+"-"+kn(n[10])+kn(n[11])+kn(n[12])+kn(n[13])+kn(n[14])+kn(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 Cn=/^[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 Mn(n){return"string"==typeof n&&Cn.test(n)}const Sn=8e3,On=3e4,En=/^(https:|zalo:)/i;class In 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 Nn(n,t,e,o){return`${n}${t}?${new URLSearchParams(Object.assign({projectId:e},o)).toString()}`}function zn(n,t){if(!n||!t)return()=>{};if(t.aborted)return n.abort(),()=>{};const e=()=>n.abort();return t.addEventListener("abort",e),()=>t.removeEventListener("abort",e)}function Tn(n){return{title:"string"==typeof n.title?n.title:void 0,description:"string"==typeof n.description?n.description:void 0,points:Fn(n.points),expPoints:Fn(n.expPoints),balanceAfter:Fn(n.balanceAfter),expBalanceAfter:Fn(n.expBalanceAfter),rankAfter:"string"==typeof n.rankAfter?n.rankAfter:void 0,createdAt:"string"==typeof n.createdAt?n.createdAt:void 0}}function Dn(n){return{campaignId:Fn(n.campaignId),rewardId:Fn(n.rewardId),title:"string"==typeof n.title?n.title:void 0,imageUrl:"string"==typeof n.imageUrl?n.imageUrl:void 0,discountValue:"string"==typeof n.discountValue?n.discountValue:void 0,channelLabel:"string"==typeof n.channelLabel?n.channelLabel:void 0,channelIcon:"string"==typeof n.channelIcon?n.channelIcon:void 0,redeemPoints:Fn(n.redeemPoints),redeemRemain:Fn(n.redeemRemain),expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,stock:"boolean"==typeof n.stock?n.stock:void 0,burnOnUse:!0===n.burnOnUse}}function jn(n,t){return n?"string"==typeof n.error&&n.error?n.error:t&&"string"==typeof n.code&&n.code?n.code:null:null}function Fn(n){return"number"==typeof n&&Number.isFinite(n)?n:void 0}function Rn(n){return{id:Fn(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:Fn(n.threshold),level:Fn(n.level),benefits:Array.isArray(n.benefits)?n.benefits.filter(n=>"string"==typeof n&&""!==n.trim()):[]}}function Bn(n){return{id:Fn(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:Fn(n.level),progressCurrent:Fn(n.progressCurrent),progressTarget:Fn(n.progressTarget),remaining:Fn(n.remaining),nextLevelName:"string"==typeof n.nextLevelName?n.nextLevelName:void 0,isHighestLevel:!0===n.isHighestLevel}}function Ln(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,channelLabel:"string"==typeof n.channelLabel?n.channelLabel:void 0,channelIcon:"string"==typeof n.channelIcon?n.channelIcon:void 0,expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,useRemain:"number"==typeof n.useRemain&&Number.isFinite(n.useRemain)?n.useRemain:void 0,redeemId:"number"==typeof n.redeemId&&Number.isFinite(n.redeemId)?n.redeemId:void 0,usedAt:"string"==typeof n.usedAt?n.usedAt:void 0,canUse:!0===n.canUse,burnOnUse:!0===n.burnOnUse}}function Pn(n,t){return Q(this,void 0,void 0,function*(){var e,o;if(!n.projectId||!n.endpoint)throw new In("not-initialized");if(!n.zaloQrLoginEnabled)throw new In("disabled");if(!n.consentGranted)throw new In("consent-required");const r={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},i=n.projectId,c=n.endpoint,l=(()=>{const n="undefined"!=typeof crypto?crypto:void 0;if(n&&"function"==typeof n.getRandomValues)try{const t=new Uint8Array(24);n.getRandomValues(t);let e="";for(let n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(n){return}})(),a=yield function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;let i;try{i=yield fetch(Nn(n,"/zalo-qr/session",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:o?o.signal:void 0})}catch(n){throw new In("network")}finally{r&&clearTimeout(r)}if(!i.ok)throw new In(401===(c=i.status)?"invalid-project-key":403===c?"project-suspended":"network");var c;return(n=>{const t=n;if(!t||"string"!=typeof t.sessionToken||!t.sessionToken||"string"!=typeof t.miniAppDeepLink||!En.test(t.miniAppDeepLink)||"number"!=typeof t.expiresInSeconds||!Number.isFinite(t.expiresInSeconds)||t.expiresInSeconds<=0)throw new In("network");return{sessionToken:t.sessionToken,miniAppDeepLink:t.miniAppDeepLink,expiresInSeconds:t.expiresInSeconds}})(yield i.json())})}(c,i,Object.assign(Object.assign({},(n=>{var t,e,o;const r={};try{const i=null===(t=n.getAnonymousId)||void 0===t?void 0:t.call(n);i&&(r.anonymousId=i);const c=null===(e=n.getSessionId)||void 0===e?void 0:e.call(n);c&&(r.sessionId=c);const l=null===(o=n.getAttribution)||void 0===o?void 0:o.call(n);l&&(r.attribution=l)}catch(n){}return r})(n)),l?{pollSecret:l}:{})),u=((n,t,e,o,r,i)=>{let c=!1,l=null,a=null,u=null,s=null,d=null;const p=()=>{l&&(l.close(),l=null),null!==a&&(clearInterval(a),a=null),null!==u&&(clearTimeout(u),u=null),null!==s&&(clearTimeout(s),s=null)};return{promise:new Promise((f,h)=>{d=h;const v=n=>{c||(c=!0,p(),n())},m=n=>{"success"===n.status?v(()=>f((n=>({contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,panelSessionToken:n.panelSessionToken,panelSessionExp:n.panelSessionExp,panelSessionExpiresInMs:"number"==typeof n.panelSessionExpiresInMs?n.panelSessionExpiresInMs:void 0}))(n))):"denied"===n.status?v(()=>h(new In("denied"))):"expired"===n.status?v(()=>h(new In("expired"))):"blocked"===n.status&&v(()=>h(new In("agent_registration_required"===n.reason?"agent-registration-required":"login-blocked")))},g=()=>{null!==a||c||(a=setInterval(()=>{fetch(Nn(n,"/zalo-qr/status",t,{sessionToken:e}),{method:"GET",credentials:"omit",mode:"cors",headers:i?{"X-Poll-Secret":i}:void 0}).then(n=>404===n.status?m({status:"expired"}):n.ok?n.json().then(n=>m(n)):void 0).catch(()=>{})},r.pollIntervalMs))};if(r.preferSse&&"undefined"!=typeof EventSource)try{l=new EventSource(Nn(n,"/zalo-qr/stream",t,i?{sessionToken:e,pollSecret:i}:{sessionToken:e})),l.addEventListener("success",n=>{try{m(JSON.parse(n.data))}catch(n){}}),l.addEventListener("denied",()=>m({status:"denied"})),l.addEventListener("blocked",n=>{try{m(JSON.parse(n.data))}catch(n){m({status:"blocked"})}}),l.onerror=()=>{null!==s||c||(s=setTimeout(()=>{s=null,c||(l&&(l.close(),l=null),g())},3e3))}}catch(n){g()}else g();u=setTimeout(()=>{v(()=>h(new In("expired")))},1e3*o)}),cancel(){c||(c=!0,p(),null==d||d(new In("cancelled")))}}})(c,i,a.sessionToken,a.expiresInSeconds,r,l);return{sessionToken:a.sessionToken,qrPayload:a.miniAppDeepLink,expiresInSeconds:a.expiresInSeconds,result:u.promise,cancel:u.cancel,retry(){return u.cancel(),Pn(n,t)}}})}const $n="cnv:launcher:click",Un="cnv:panel:identify",Vn="cnv-panel-card--leaving";function Hn(n){return"cnv_panel_session_"+(null!=n?n:"default")}function qn(n){const e=bn(Hn(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 Kn(n,t){yn(Hn(n),JSON.stringify(t))}function Gn(n){_n(Hn(n))}function Zn(n){return"SQUARE"===n?"0px":"12px"}function Wn(n){const t=n.colors;return L(null==t?void 0:t.iconColor,L(null==t?void 0:t.buttonBg,L(null==t?void 0:t.bannerBg,F)))}function Yn(n,t){n.style.background=V(t,.12),n.style.color=t}const Jn='<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"/>',Qn='<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',Xn='<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"/>',nt='<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"/>',tt='<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"/>',et='<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.8"/><path d="M12 10.6v6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="7.6" r="1.1" fill="currentColor"/>',ot='<path d="M5 13l4.5 4.5L19 8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',rt='<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"/>',it='<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"/>',ct='<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"/>',lt="#1E9E5B",at="rgba(30, 158, 91, 0.12)",ut="#D64545",st="rgba(214, 69, 69, 0.10)",dt="#6B7280",pt="rgba(107, 114, 128, 0.12)";function ft(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 ht(n,t){const e=document.createElement("div");return e.className="cnv-panel-chip",Yn(e,t),e.appendChild(ft(n,14)),e}function vt(n,t){const e=document.createElement("span");return e.className="cnv-panel-badge",Yn(e,t),e.textContent=n,e}const mt={POINTS:{label:"Điểm thưởng",icon:Xn},REFERRAL:{label:"Giới thiệu bạn bè",icon:nt},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"/>'}},gt={rewards:it,earn:rt,redeem:Jn,history:tt},bt={ORDER:ct,STAR:Xn,GIFT:Jn,USERS:nt,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:rt,CHECK:ot},yt={store:'<path d="M2.8 9.4 5 4.9h14l2.2 4.5ZM4.4 9.4v10.2h15.2V9.4M9.8 19.6v-5.7h4.4v5.7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',web:'<circle cx="12" cy="12" r="8.4" stroke="currentColor" stroke-width="1.8"/><ellipse cx="12" cy="12" rx="3.5" ry="8.4" stroke="currentColor" stroke-width="1.8"/><path d="M3.6 12h16.8" stroke="currentColor" stroke-width="1.8"/>',zalo:'<path d="M5.5 4h13A2.5 2.5 0 0 1 21 6.5v8a2.5 2.5 0 0 1-2.5 2.5H11l-4.5 3.5V17h-1A2.5 2.5 0 0 1 3 14.5v-8A2.5 2.5 0 0 1 5.5 4Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M9 8h6l-6 5.5h6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>',app:'<rect x="6.5" y="2.6" width="11" height="18.8" rx="2.2" stroke="currentColor" stroke-width="1.8"/><path d="M10.6 17.8h2.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',bag:ct},_t={earn:{label:"Cách kiếm thêm điểm",icon:rt},redeem:{label:"Cách đổi điểm",icon:Jn}},wt="cnv-panel-reward__title--full",xt="Tham gia ngay",kt=[[_t.earn.label,"earn"],[_t.redeem.label,"redeem"]],At=/\{\{\s*TenKhachHang\s*\}\}/gi,Ct=/[\u0000-\u001F\u007F\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2066-\u2069\uFEFF]/g;function Mt(n){return"number"==typeof n.campaignId&&n.campaignId>0?Object.assign({campaignId:n.campaignId},"number"==typeof n.redeemPoints&&n.redeemPoints>0?{redeemPoints:n.redeemPoints}:{}):"number"==typeof n.rewardId&&n.rewardId>0?{rewardId:n.rewardId}:null}function St(n,e){const o=(n=>{if("string"!=typeof n)return"bạn";const e=t(()=>n.normalize("NFC"),n).replace(Ct," ").replace(/\s+/g," ").trim();if(!e)return"bạn";const o=Array.from(e);return o.length<=24?e:o.slice(0,24).join("").trimEnd()+"…"})(e);return(n||"").replace(At,()=>o)}const Ot=[{key:"redeem",label:"Đổi ưu đãi"},{key:"owned",label:"Ưu đãi của bạn"}],Et={message:'Lượt đổi đã được ghi nhận nhưng mã chưa phát kịp. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},It={message:'Điểm đã được trừ và ưu đãi đã là của bạn, chỉ chưa có mã. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},Nt={INSUFFICIENT_POINTS:{message:"Bạn không đủ điểm để đổi ưu đãi này.",action:"other"},REDEMPTION_LIMIT_EXCEEDED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},REWARD_OUT_OF_STOCK:{message:"Ưu đãi này vừa hết. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},PRICE_CHANGED:{message:"Giá đổi của ưu đãi vừa thay đổi. Bạn tải lại danh sách rồi đổi lại nhé.",action:"other"},POINT_HOLD_FAILED:{message:"Chưa trừ được điểm của bạn. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_REFUNDED:{message:"Đổi ưu đãi không thành công, điểm của bạn đã được hoàn lại. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_STUCK:{message:"Đổi ưu đãi không thành công. Điểm của bạn đang được kiểm tra, bạn liên hệ shop nhé.",action:"none"},CAMPAIGN_NOT_STARTED:{message:"Ưu đãi chưa tới thời gian áp dụng. Bạn quay lại sau nhé.",action:"other"},REWARD_NOT_PUBLISHED:{message:"Ưu đãi chưa được mở. Bạn quay lại sau nhé.",action:"other"},NOT_POINT_CAMPAIGN:{message:"Ưu đãi này không đổi bằng điểm. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_IN_PROGRESS:{message:'Lượt đổi của bạn đang được xử lý. Bạn đợi một chút rồi kiểm tra ở tab "Ưu đãi của bạn" nhé.',action:"owned"},IDEMPOTENCY_UNAVAILABLE:{message:"Hệ thống đang bận, chưa đổi được. Bạn thử lại sau ít phút nhé.",action:"other"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này. Bạn tải lại danh sách nhé.",action:"other"},CAMPAIGN_INACTIVE:{message:"Ưu đãi này vừa được shop tạm dừng.",action:"other"},CAMPAIGN_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng. Bạn chọn ưu đãi khác nhé.",action:"other"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn chọn ưu đãi khác nhé.",action:"other"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_UNAVAILABLE:{message:"Ưu đãi này hiện không khả dụng.",action:"other"},NOT_SELF_REDEEMABLE:{message:"Ưu đãi này không tự đổi được. Bạn liên hệ shop nhé.",action:"other"},NOT_FREE:{message:"Ưu đãi này không phải ưu đãi tặng. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_LIMIT_REACHED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},ALREADY_REDEEMED:{message:'Bạn đã nhận ưu đãi này rồi. Mã nằm ở tab "Ưu đãi của bạn".',action:"owned"},CODE_NOT_ISSUED:{message:"Đã ghi nhận lượt đổi nhưng mã chưa phát kịp. Bạn thử lại nhé.",action:"retry"},NOT_REDEEMED:{message:"Bạn chưa đổi ưu đãi này.",action:"other"},LOYALTY_SERVICE_UNAVAILABLE:{message:"Hệ thống điểm đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},VENDOR_ERROR:{message:"Nhà cung cấp ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},MISSING_VOUCHER:Et,MISSING_SERIAL:Et,INVALID_REQUEST:{message:"Ưu đãi này đang lỗi dữ liệu nên không đổi được. Bạn chọn ưu đãi khác nhé.",action:"other"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"none"},REDEEM_FAILED:{message:"Đổi ưu đãi không thành công. Bạn thử lại sau ít phút nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry",retryWithNewKey:!0},SESSION_CHECK_UNAVAILABLE:{message:"Chưa kiểm tra được phiên đăng nhập của bạn. Bạn thử lại sau ít phút nhé.",action:"retry"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"none"},UNCONFIRMED:{message:'Chưa xác nhận được kết quả. Điểm có thể đã được trừ — bạn kiểm tra ở tab "Ưu đãi của bạn" trước khi đổi lại nhé.',action:"owned",heading:"Chưa xác nhận được",tone:"neutral"}},zt={CODE_NOT_ISSUED:It,MISSING_VOUCHER:It,MISSING_SERIAL:It,OUT_OF_CODES:{message:"Ưu đãi đã hết mã, điểm của bạn đã bị trừ. Bạn liên hệ shop để được hỗ trợ nhé.",action:"none"}},Tt={message:"Không đổi được ưu đãi lúc này. Bạn thử lại sau nhé.",action:"retry"},Dt={USE_LIMIT_REACHED:{message:"Ưu đãi này đã hết lượt sử dụng.",action:"back"},NOT_REDEEMED:{message:"Ưu đãi này không còn trong danh sách của bạn.",action:"back"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này nữa.",action:"back"},CODE_NOT_ISSUED:{message:"Chưa lấy được mã cho ưu đãi này. Bạn thử lại nhé.",action:"retry"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn liên hệ shop nhé.",action:"back"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn liên hệ shop nhé.",action:"back"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng để lấy mã. Bạn liên hệ shop nhé.",action:"back"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn liên hệ shop nhé.",action:"back"},UNCONFIRMED:{message:"Chưa xác nhận được. Bạn thử lại nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},SESSION_CHECK_UNAVAILABLE:{message:"Hệ thống đang bận, chưa lấy được mã. Bạn thử lại sau ít phút nhé.",action:"retry"},USE_FAILED:{message:"Chưa dùng được ưu đãi này. Bạn thử lại sau ít phút nhé.",action:"retry"},INVALID_REQUEST:{message:"Yêu cầu không hợp lệ. Bạn quay lại danh sách rồi thử lại nhé.",action:"back"},INVALID_REWARD:{message:"Không xác định được ưu đãi cần dùng. Bạn quay lại danh sách nhé.",action:"back"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"back"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"back"}},jt={message:"Chưa lấy được mã lúc này. Bạn thử lại sau nhé.",action:"retry"},Ft={other:"Chọn ưu đãi khác",retry:"Thử lại",owned:"Kiểm tra ưu đãi của bạn",none:""};function Rt(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=Zn(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 Bt(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 Lt(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 Pt(n){const t=document.createElement("div");t.className="cnv-panel-vstack";const e=document.createElement("div");e.className="cnv-panel-zalo__qr",e.appendChild(Bt(180,180)),Lt(e,n),t.appendChild(e);const o=document.createElement("div");return o.className="cnv-panel-vstack",o.style.gap="6px",o.append(Bt(240,14),Bt(160,14)),t.appendChild(o),t.appendChild(Bt(120,14)),t}function $t(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(ft(n,20));const c=document.createElement("div");return c.className="cnv-panel-zalo__title",c.textContent=o,r.append(i,c),r}function Ut(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 Vt(n){return"number"==typeof n.useRemain&&n.useRemain>0}function Ht(n){if(!n.usedAt)return null;if(Vt(n))return null;const t=Kt(n.usedAt);return t?`Đã dùng ${t}`:"Đã dùng"}function qt(n){const t=n.useRemain;return"number"!=typeof t||t<=0||t<=1&&!n.usedAt?null:`Còn ${t} lượt`}function Kt(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()}`}function Gt(n){return n instanceof In?n.reason:null}function Zt(n){switch(Gt(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"agent-registration-required":return"Bạn mở Mini App của shop để đăng ký đại lý, được duyệt rồi thì quét lại mã này nhé.";case"login-blocked":return"Shop chưa cho phép tài khoản này đăng nhập.";case"cancelled":return"Đã huỷ đăng nhập.";default:return"Vui lòng thử lại giúp mình nhé."}}function Wt(o,r){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{let i,c,l,a=null,u=null,s=null,d=null,p=null,f=null,h=null,v=null,m=null,g=null,b=null,y=null,_=!1,w=null,x=null,k=!1,A=!1,C=!1,M=[],S=0,O=!1,E=null,I=null,N=null,z=!1,T=0,D=[],U=0,Z=null,W=!1,Y=!1,J=Ot[0].key,nn=[],tn=0,en=0,on=!1,rn=null,cn=null,ln=!1,an=0,un=null,sn=null;function dn(t){const e="owned"===t?un:sn;e&&("owned"===t?un=null:sn=null,n(()=>e.abort()))}function pn(){return"undefined"!=typeof AbortController?new AbortController:null}let fn=null,hn=!1,vn=null,mn=0,gn=0,bn=0,yn=null,_n=null,wn=null;const xn=n=>{"Escape"===n.key&&po()};function kn(n){return!k||n!==gn}function Cn(n,e){return t(()=>{const t=new CustomEvent(n,{detail:{action:e},cancelable:!0});return window.dispatchEvent(t),t.defaultPrevented},!1)}function Mn(n){Cn("cnv:panel:cta-click",n)}function Sn(n){return()=>{_&&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=gt[t];if(i){const n=ft(i,20);n.style.color=Wn(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(ft(Qn,12,"cnv-panel-icon--chevron")),o.addEventListener("click",Sn(()=>{Cn("cnv:panel:menu-click",t)||("rewards"===t?(A=!0,J=Ot[0].key,fn=null,Ye(),_e(),Pn()):"history"===t?(C=!0,Ye(),Ce(),M.length||(S=0,Ae())):_t[t]&&(E=t,Ye(),Ne()))})),o}function En(){var n,t,e,o;const i=Rt(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=Zn(null===(n=r.shapes)||void 0===n?void 0:n.button),u.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,F),u.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,R),u.appendChild(ft(Jn,15)),u.appendChild(document.createTextNode(((null==c?void 0:c.createAccountButtonText)||"").trim()||xt)),u.addEventListener("click",Sn(()=>{Mn("create-account"),lo()})),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=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,F),n.appendChild(document.createTextNode(s)),n.appendChild(ft(Qn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Sn(()=>{Mn("sign-in"),lo()})),i.appendChild(n)}return i}function In(){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=Zn(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 Nn(){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=Zn(null===(n=r.shapes)||void 0===n?void 0:n.button),a.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,F),a.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,R),a.appendChild(ft(Jn,15)),a.appendChild(document.createTextNode(((null==i?void 0:i.createAccountButtonText)||"").trim()||xt)),a.addEventListener("click",Sn(()=>{Mn("create-account"),lo()})),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=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,F),n.appendChild(document.createTextNode(u)),n.appendChild(ft(Qn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Sn(()=>{Mn("sign-in"),lo()})),l.appendChild(n)}return l}function zn(){var n;return null!==(n=null==N?void 0:N.points)&&void 0!==n?n:null==w?void 0:w.points}function Tn(){return"redeem"===J?null!==fn:null!==cn||null!==rn}function Dn(){A&&!Tn()&&_e()}function jn(n=!1){if(!(null==w?void 0:w.isMember)||z)return;if(!n&&N&&Date.now()-T<3e4)return;const t=qn(o.projectId);if(!t)return;z=!0,dn("owned");const e=pn();un=e,_&&Ge(),Dn(),o.fetchRewardsSummary(t.token,1,e?e.signal:void 0).then(n=>{if(z=!1,!e||!e.signal.aborted){if(!n)return _&&Ge(),void Dn();N=n,T=Date.now(),D=n.rewards.slice(),U=1,_&&Ge(),Dn()}}).catch(()=>{z=!1,_&&Ge(),Dn()})}function Fn(){return(Array.isArray(r.sections)?r.sections:[]).some(n=>"VIP"===n.type&&n.enabled)}function Rn(){const n=null==N?void 0:N.rewardsAvailableCount;return"number"==typeof n&&U?Math.max(0,n-D.length):0}function Bn(){if(Y||z||!Rn())return;const n=qn(o.projectId);if(!n)return;const t=U+1;Y=!0,A&&_e(),o.fetchRewardsSummary(n.token,t).then(n=>{Y=!1,U=t,n&&(n.rewards.length&&(D=D.concat(n.rewards)),"number"==typeof n.rewardsAvailableCount&&N&&(N=Object.assign(Object.assign({},N),{rewardsAvailableCount:n.rewardsAvailableCount}))),A&&_e()}).catch(()=>{Y=!1,A&&_e()})}function Ln(n){if(J===n)return;const t=J;J=n,fn=null,rn=null,Wt(),dn(t),Ye(),_e(),Pn(!0)}function Pn(n=!1){if("redeem"===J){if(!n&&nn.length&&Date.now()-en<3e4)return;return tn=0,nn=[],void Hn()}jn(n)}function Hn(){if(on)return;const n=qn(o.projectId);if(!n)return;const t=tn+1;on=!0,dn("redeem");const e=pn();sn=e,A&&_e(),o.fetchRedeemableRewards(n.token,t,e?e.signal:void 0).then(n=>{on=!1,tn=t,n&&(1===t&&(en=Date.now()),"number"==typeof n.total&&(c=n.total),"number"==typeof n.points&&(l=n.points),n.rewards.length&&(nn=nn.concat(n.rewards))),A&&_e()}).catch(()=>{on=!1,A&&_e()})}function Xn(){return null!=l?l:zn()}function nt(){return null!==qn(o.projectId)}function rt(n,t,e){const o=document.createElement("div");o.className="cnv-panel-reward__meta",o.textContent=e,n.appendChild(o);const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn cnv-panel-reward__more",r.textContent="Đăng nhập bằng Zalo",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",Sn(lo)),n.appendChild(r)}function ct(n,t=!1){const e=Mt(n);if(hn||null===e)return;const r=qn(o.projectId);if(!r)return;if(Cn("cnv:panel:redeem-click","redeem-confirm"))return;const i=t&&vn?vn:An();vn=i;const c=++mn;hn=!0,fn={kind:"confirm",item:n},_e(),o.redeemReward(r.token,e,i).then(t=>{var e;At(c)&&(hn=!1),t.ok&&(vn=null,e=t.result,Yt(),l="number"==typeof e.pointsRemaining?e.pointsRemaining:void 0,jn()),A&&At(c)&&(fn=t.ok?{kind:"success",item:n,result:t.result}:{kind:"error",code:t.code,item:n},_e())}).catch(()=>{At(c)&&(hn=!1),A&&At(c)&&(Yt(),fn={kind:"error",code:"UNCONFIRMED",item:n},_e())})}function At(n){return n===mn}function Ct(n){const t=n.redeemId;if(ln||"number"!=typeof t||t<=0)return;const e=qn(o.projectId);if(!e)return;const r=++an;ln=!0,cn={kind:"confirm",item:n},_e(),o.useReward(e.token,t).then(e=>{const o=e.ok?Et(t,n,e.result):null;r===an&&(ln=!1),A&&r===an&&(o?(cn=null,rn=o):e.ok||(cn={kind:"error",code:e.code,item:n}),Ye(),_e())}).catch(()=>{r===an&&(ln=!1),A&&r===an&&(cn={kind:"error",code:"UNCONFIRMED",item:n},_e())})}function Et(n,t,e){const o=D.findIndex(t=>t.redeemId===n),r=o>=0?D[o]:t,i="number"==typeof e.useRemain?e.useRemain:0,c=Object.assign(Object.assign({},r),{code:e.code,usedAt:e.usedAt||r.usedAt,expiredAt:e.expiredAt||r.expiredAt,useRemain:i,canUse:!0===r.burnOnUse&&"number"==typeof i&&i>0});return o>=0&&(D[o]=c),c}function It(){fn=null,rn=null,hn=!1,mn++,Wt()}function Wt(){cn=null,ln=!1,an++}function Yt(){N=null,T=0,D=[],U=0,M=[],i=void 0,S=0,nn=[],c=void 0,tn=0,en=0}function Jt(n,t,e=!1){if(!n.channelLabel)return null;const o=document.createElement("div");o.className=e?"cnv-panel-reward__channel cnv-panel-reward__channel--center":"cnv-panel-reward__channel",o.style.color="DARK"===r.theme?"rgba(255,255,255,.72)":"rgba(24,28,50,.66)";const i="string"==typeof n.channelIcon?yt[n.channelIcon]:void 0;if("string"==typeof i){const n=ft(i,14);n.style.color=t,o.appendChild(n)}const c=document.createElement("span");return c.textContent=n.channelLabel,o.appendChild(c),o}function Qt(n,t){const e="DARK"===r.theme,o=document.createElement("div");o.className="cnv-panel-reward",o.style.setProperty("--cnv-tk-bg",e?"rgba(255,255,255,.04)":"#FFFFFF"),o.style.setProperty("--cnv-tk-line",e?"rgba(255,255,255,.14)":"#E4E6EF"),o.style.setProperty("--cnv-tk-dash",e?"rgba(255,255,255,.24)":"#D1D3E0"),o.style.setProperty("--cnv-tk-hole",e?"#3F4254":"#FFFFFF"),o.appendChild(Xt(n,t));const i=document.createElement("div");i.className="cnv-panel-ticket__cut";const c=document.createElement("span");c.className="cnv-panel-ticket__hole cnv-panel-ticket__hole--top";const l=document.createElement("span");l.className="cnv-panel-ticket__hole cnv-panel-ticket__hole--bottom",i.append(c,l),o.appendChild(i);const a=document.createElement("div");return a.className="cnv-panel-reward__main",o.appendChild(a),{row:o,main:a}}function Xt(n,t){var e,o;const i=t?"DARK"===r.theme?"rgba(255,255,255,.16)":"#C4C6D0":L(null===(e=r.colors)||void 0===e?void 0:e.buttonBg,F),c=document.createElement("div");c.className="cnv-panel-ticket__stub",c.style.backgroundColor=i,c.style.color=t?"#FFFFFF":L(null===(o=r.colors)||void 0===o?void 0:o.buttonFont,R);const l=document.createElement("div");l.className="cnv-panel-ticket__badge",l.style.color=t?"#A1A5B7":i;const a="string"==typeof n.channelIcon?n.channelIcon:"",u="zalo"===a?'<text x="12" y="16" text-anchor="middle" font-size="11" font-weight="800" textLength="23" lengthAdjust="spacingAndGlyphs" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Arial,sans-serif" fill="currentColor">Zalo</text>':yt[a],s="string"==typeof u?u:it,d=()=>{l.textContent="",l.appendChild(ft(s,26))};if(P(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",d),l.appendChild(t)}else d();if(c.appendChild(l),n.channelLabel){const t=document.createElement("div");t.className="cnv-panel-ticket__label",t.textContent=n.channelLabel,c.appendChild(t)}return c}function ne(n,t){const e=Ht(n),{row:o,main:r}=Qt(n,null!==e),i=qt(n);if(n.discountValue||i||e){const o=document.createElement("div");if(o.className="cnv-panel-reward__tags",e){const n=document.createElement("span");n.className="cnv-panel-reward__uses",n.textContent=e,o.appendChild(n)}if(n.discountValue){const e=document.createElement("span");e.className="cnv-panel-reward__value",Yn(e,t),e.textContent=n.discountValue,o.appendChild(e)}if(i){const n=document.createElement("span");n.className="cnv-panel-reward__uses",n.textContent=i,o.appendChild(n)}r.appendChild(o)}r.appendChild(pe(n.title||"Ưu đãi"));const c=Kt(n.expiredAt);if(c){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${c}`,r.appendChild(n)}if(n.code||n.canUse){const e=document.createElement("div");e.className="cnv-panel-reward__foot";const o=document.createElement("button");o.type="button",o.className="cnv-panel-zalo__btn cnv-panel-reward__cta cnv-panel-reward__show",o.textContent=n.canUse?"Sử dụng":"Xem mã",o.style.borderColor=t,o.style.color=t,o.addEventListener("click",Sn(()=>{if(!n.canUse)return rn=n,Ye(),void _e();te(n)})),e.appendChild(o),r.appendChild(e)}return o}function te(n){if(n.burnOnUse)return cn={kind:"confirm",item:n},Ye(),void _e();Ct(n)}function ee(n,t,e){const o=$t(ln?tt:Jn,ln?dt:t,ln?pt:V(t,.12),e.title||"Ưu đãi"),r=document.createElement("div");r.className="cnv-panel-zalo__status";const i=null!=e.usedAt&&Vt(e);r.textContent=ln?"Đang lấy mã…":i?`Bạn còn ${e.useRemain} lượt dùng. Mã mới sẽ được cấp và đánh dấu đã dùng ngay. Tiếp tục?`:"Mã sẽ không còn hiệu lực sau khi ấn dùng ngay. Bạn có chắc muốn dùng ngay không?",o.appendChild(r),n.appendChild(o);const c=document.createElement("div");c.className="cnv-panel-redeem__actions";const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent="Hủy",l.disabled=ln,ln||l.addEventListener("click",Sn(()=>{cn=null,Ye(),_e()}));const a=document.createElement("button");a.type="button",a.className="cnv-panel-zalo__btn",a.textContent=ln?"Đang xử lý…":"Dùng ngay",a.disabled=ln,ln||(a.style.borderColor=t,a.style.color=t,a.addEventListener("click",Sn(()=>Ct(e)))),c.append(l,a),n.appendChild(c)}function oe(n,t,e,o){const r=o&&Dt[o]||jt,i="UNCONFIRMED"===o,c=$t(i?tt:Jn,i?dt:ut,i?pt:st,i?"Chưa xác nhận được":"Chưa dùng được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,c.appendChild(n)}const l=document.createElement("div");l.className="cnv-panel-zalo__status",l.textContent=r.message,l.setAttribute("role","alert"),c.appendChild(l),n.appendChild(c);const a=document.createElement("div");a.className="cnv-panel-redeem__actions";const u=document.createElement("button");if(u.type="button",u.className="cnv-panel-zalo__btn",u.textContent="Về danh sách",u.addEventListener("click",Sn(()=>{cn=null,Ye(),_e()})),a.appendChild(u),"retry"===r.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Thử lại",n.style.borderColor=t,n.style.color=t,n.addEventListener("click",Sn(()=>Ct(e))),a.appendChild(n)}n.appendChild(a)}function re(n,t){const e=document.createElement("button");return e.type="button",e.className="cnv-panel-zalo__btn",e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.addEventListener("click",Sn(()=>{e.disabled||(e.disabled=!0,function(n){return Q(this,void 0,void 0,function*(){if(!n)return!1;try{if(navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return yield navigator.clipboard.writeText(n),!0}catch(n){}let t=null;try{return t=document.createElement("textarea"),t.value=n,t.setAttribute("readonly",""),t.style.cssText="position:fixed;top:-1000px;left:-1000px;opacity:0;pointer-events:none;",document.body.appendChild(t),t.select(),t.setSelectionRange(0,n.length),document.execCommand("copy")}catch(n){return!1}finally{t&&t.parentNode&&t.parentNode.removeChild(t)}})}(n).then(n=>{e.isConnected&&(e.textContent=n?"Đã chép":"Không chép được",e.style.borderColor=n?lt:t,e.style.color=n?lt:t,window.setTimeout(()=>{e.isConnected&&(e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.disabled=!1)},1600))}))})),e}function ie(n,t,e){const o=$t(Jn,t,V(t,.12),e.title||"Ưu đãi");if(e.discountValue){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.discountValue,o.appendChild(n)}if(e.code){const n=document.createElement("div");n.className="cnv-panel-reward__code cnv-panel-reward__code--big",n.textContent=e.code,o.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Bấm "Dùng ngay" để hiện mã.',o.appendChild(n)}const r=Ht(e);if(r){const n=document.createElement("span");n.className="cnv-panel-reward__uses",n.textContent=r,o.appendChild(n)}const i=Jt(e,t,!0);i&&o.appendChild(i);const c=[],l=Kt(e.expiredAt);l&&c.push(`HSD ${l}`);const a=qt(e);if(a&&c.push(a),c.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=c.join(" · "),o.appendChild(n)}if(n.appendChild(o),e.canUse){const o=document.createElement("div");o.className="cnv-panel-redeem__actions";const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn",r.textContent=e.usedAt?"Dùng lượt tiếp":"Dùng ngay",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",Sn(()=>{rn=null,te(e)})),o.appendChild(r),n.appendChild(o)}const u=document.createElement("div");u.className="cnv-panel-redeem__actions",e.code&&u.appendChild(re(e.code,t));const s=document.createElement("button");s.type="button",s.className="cnv-panel-zalo__btn",s.textContent="Quay lại",s.addEventListener("click",Sn(()=>{rn=null,Ye(),_e()})),u.appendChild(s),n.appendChild(u)}function ce(n){if("owned"!==n.key)return n.label;const t=null!==(e=null==N?void 0:N.rewardsAvailableCount)&&void 0!==e?e:null==w?void 0:w.rewardsAvailableCount;var e;return"number"==typeof t&&Number.isFinite(t)&&t>0?`${n.label} (${t.toLocaleString("vi-VN")})`:n.label}function le(n){const t=document.createElement("div");return t.className="cnv-panel-rtabs",t.setAttribute("role","tablist"),Ot.forEach(e=>{const o=e.key===J,r=document.createElement("button");r.type="button",r.className="cnv-panel-rtab"+(o?" cnv-panel-rtab--on":""),r.setAttribute("role","tab"),r.setAttribute("aria-selected",o?"true":"false"),r.textContent=ce(e),o&&(r.style.borderBottomColor=n,r.style.color=n),r.addEventListener("click",Sn(()=>Ln(e.key))),t.appendChild(r)}),t}function ae(n){return n.toLocaleString("vi-VN")+" điểm"}function ue(n){return n>0?ae(n):"Miễn phí"}function se(n,t,e){t.length>15?n.style.fontSize=Math.round(.62*e)+"px":t.length>11&&(n.style.fontSize=Math.round(.77*e)+"px")}function de(n,t){const e=document.createElement("div");e.className="cnv-panel-balance";const o=document.createElement("div");o.className="cnv-panel-balance__label",o.textContent="Điểm của bạn";const r=document.createElement("div");r.className="cnv-panel-balance__row";const i=document.createElement("div");i.className="cnv-panel-balance__num",i.style.color=t;const c=n.toLocaleString("vi-VN");i.textContent=c,se(i,c,26);const l=document.createElement("div");return l.className="cnv-panel-balance__unit",l.textContent="điểm",r.append(i,l),e.append(o,r),e}function pe(n){const t=document.createElement("div");t.className="cnv-panel-reward__name";const e=document.createElement("div");e.className="cnv-panel-reward__title",e.textContent=n,e.title=n;const o=document.createElement("button");return o.type="button",o.className="cnv-panel-reward__info",o.setAttribute("aria-label","Xem đầy đủ tên ưu đãi"),o.appendChild(ft(et,14)),o.addEventListener("click",()=>{e.classList.toggle(wt)}),t.append(e,o),t}function fe(n){if(null===Mt(n)||"number"!=typeof n.redeemPoints)return"Chưa thể đổi ưu đãi này";if(!1===n.stock)return"Đã hết hàng";if("number"==typeof n.redeemRemain&&n.redeemRemain<=0)return"Bạn đã đạt giới hạn đổi";const t=Xn();return"number"==typeof t&&t<n.redeemPoints?`Cần thêm ${ae(n.redeemPoints-t)}`:null}function he(n,t){const e=fe(n),{row:o,main:r}=Qt(n,null!==e);if(n.discountValue){const e=document.createElement("div");e.className="cnv-panel-reward__tags";const o=document.createElement("span");o.className="cnv-panel-reward__value",Yn(o,t),o.textContent=n.discountValue,e.appendChild(o),r.appendChild(e)}r.appendChild(pe(n.title||"Ưu đãi"));const i=Kt(n.expiredAt);if(i){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${i}`,r.appendChild(n)}if(e){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=e,r.appendChild(n)}const c=document.createElement("div");if(c.className="cnv-panel-reward__foot","number"==typeof n.redeemPoints){const e=document.createElement("div");e.className="cnv-panel-reward__price",e.style.color=t,e.textContent=ue(n.redeemPoints),c.appendChild(e)}const l=document.createElement("button");return l.type="button",l.className="cnv-panel-zalo__btn cnv-panel-reward__cta",l.textContent="Đổi",l.disabled=null!==e||hn,l.disabled||(l.style.borderColor=t,l.style.color=t,l.addEventListener("click",Sn(()=>{fn={kind:"confirm",item:n},Ye(),_e()}))),c.appendChild(l),r.appendChild(c),o}function ve(n,t){const e=Xn();if("number"==typeof e&&n.appendChild(de(e,t)),!nt())return void rt(n,t,"Bạn cần đăng nhập để xem ưu đãi có thể đổi.");if(on&&!nn.length)return n.appendChild(Bt(200,12)),void n.appendChild(Bt(150,12));if(!nn.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Hiện chưa có ưu đãi nào để đổi.",void n.appendChild(t)}const o=document.createElement("div");o.className="cnv-panel-reward__list",nn.forEach(n=>o.appendChild(he(n,t))),n.appendChild(o);const r="number"==typeof c&&tn?Math.max(0,c-nn.length):0;if(r>0||on){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=on,t.textContent=on?"Đang tải…":`Xem thêm ${r} ưu đãi`,t.addEventListener("click",Sn(Hn)),n.appendChild(t)}}function me(n,t,e){const o=Jt(t,e,!0);o&&n.appendChild(o);const r=Kt(t.expiredAt);if(r){const t=document.createElement("div");t.className="cnv-panel-redeem__sub",t.textContent=`HSD ${r}`,n.appendChild(t)}}function ge(n,t,e){const o=$t(Jn,t,V(t,.12),e.title||"Ưu đãi");if("number"==typeof e.redeemPoints){const n=document.createElement("div");n.className="cnv-panel-redeem__cost",n.style.color=t;const r=ue(e.redeemPoints);n.textContent=r,se(n,r,20),o.appendChild(n);const i=Xn();if(e.redeemPoints>0&&"number"==typeof i){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Còn lại ${ae(i-e.redeemPoints)}`,o.appendChild(n)}}me(o,e,t),n.appendChild(o);const r=document.createElement("div");r.className="cnv-panel-redeem__actions";const i=document.createElement("button");i.type="button",i.className="cnv-panel-zalo__btn",i.textContent="Hủy",i.disabled=hn,hn||i.addEventListener("click",Sn(()=>{fn=null,_e()}));const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent=hn?"Đang đổi…":"Đổi",c.disabled=hn,hn||(c.style.borderColor=t,c.style.color=t,c.addEventListener("click",Sn(()=>ct(e)))),r.append(i,c),n.appendChild(r)}function be(n,t,e,o){var r;const i=$t(ot,lt,at,"Đổi thành công"),c=document.createElement("div");if(c.className="cnv-panel-redeem__sub",c.textContent=e.title||"Ưu đãi",i.appendChild(c),o.burnOnUse||e.burnOnUse){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Mã đã sẵn sàng trong "Ưu đãi của bạn" — bấm Sử dụng khi bạn dùng nhé.',i.appendChild(n)}else if(o.code){const n=document.createElement("div");n.className="cnv-panel-reward__code",n.textContent=o.code,i.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Chưa có mã ngay — bạn kiểm tra ở tab "Ưu đãi của bạn" nhé.',i.appendChild(n)}me(i,e,t);const l=null!==(r=o.pointsSpent)&&void 0!==r?r:e.redeemPoints,a=[];if("number"==typeof l&&l>0&&a.push(`Đã dùng ${ae(l)}`),"number"==typeof o.pointsRemaining&&a.push(`còn lại ${ae(o.pointsRemaining)}`),a.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=a.join(" · "),i.appendChild(n)}if(o.transactionId){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Mã giao dịch ${o.transactionId}`,i.appendChild(n)}if(n.appendChild(i),!o.burnOnUse&&!e.burnOnUse&&o.code){const e=document.createElement("div");e.className="cnv-panel-redeem__actions",e.appendChild(re(o.code,t)),n.appendChild(e)}const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=document.createElement("button");s.type="button",s.className="cnv-panel-zalo__btn",s.textContent="Ưu đãi của bạn",s.addEventListener("click",Sn(()=>Ln("owned")));const d=document.createElement("button");d.type="button",d.className="cnv-panel-zalo__btn",d.textContent="Đổi tiếp",d.addEventListener("click",Sn(()=>{fn=null,Ye(),_e(),"redeem"!==J||nn.length||(tn=0,Hn())})),u.append(d,s),n.appendChild(u)}function ye(n,t,e,o){var r;const i=((n,t)=>{var e;if(t){if(void 0!==(null===(e=Mt(n))||void 0===e?void 0:e.redeemPoints)&&zt[t])return zt[t];if(Nt[t])return Nt[t]}return Tt})(e,o),c="neutral"===i.tone,l=$t(c?tt:Jn,c?dt:ut,c?pt:st,null!==(r=i.heading)&&void 0!==r?r:"Không đổi được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,l.appendChild(n)}const a=document.createElement("div");a.className="cnv-panel-zalo__status",a.textContent=i.message,a.setAttribute("role","alert"),l.appendChild(a),n.appendChild(l);const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=()=>{fn=null,Ye(),_e()},d=Ft[i.action];if("other"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",Sn(s)),u.appendChild(n)}else if("owned"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",Sn(()=>Ln("owned"))),u.appendChild(n)}else{const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Về danh sách",n.addEventListener("click",Sn(s)),u.appendChild(n),"retry"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.style.borderColor=t,n.style.color=t,n.addEventListener("click",Sn(()=>ct(e,!i.retryWithNewKey))),u.appendChild(n)}}n.appendChild(u)}function _e(){var n,t;if(!v)return;Qe(),Xe(),Je(!0);const e=null!==(t=null===(n=v.querySelector(".cnv-panel-rlist"))||void 0===n?void 0:n.scrollTop)&&void 0!==t?t:0;v.textContent="";const o=Wn(r),i=Tn(),c=Rt(r,i?"cnv-panel-phase":"cnv-panel-rcard");let l=c;if(!i){const n=document.createElement("div");n.className="cnv-panel-section__head",n.appendChild(ht(Jn,o));const t=document.createElement("div");t.className="cnv-panel-section__title",t.textContent="Ưu đãi",n.appendChild(t);const e=document.createElement("div");e.className="cnv-panel-rhead",e.append(n,le(o)),c.appendChild(e),l=document.createElement("div"),l.className="cnv-panel-rlist",c.appendChild(l)}"redeem"===J?"confirm"===(null==fn?void 0:fn.kind)?ge(c,o,fn.item):"success"===(null==fn?void 0:fn.kind)?be(c,o,fn.item,fn.result):"error"===(null==fn?void 0:fn.kind)?ye(c,o,fn.item,fn.code):ve(l,o):"confirm"===(null==cn?void 0:cn.kind)?ee(c,o,cn.item):"error"===(null==cn?void 0:cn.kind)?oe(c,o,cn.item,cn.code):rn?ie(c,o,rn):we(l,o),v.appendChild(c),e>0&&l!==c&&(l.scrollTop=e),v&&v.querySelectorAll(".cnv-panel-reward__name").forEach(n=>{const t=n.querySelector(".cnv-panel-reward__title");if(!t)return;if(t.clientWidth<=0)return;const e=t.offsetHeight;t.classList.add(wt);const o=t.offsetHeight;t.classList.remove(wt),n.classList.toggle("cnv-panel-reward__name--clamped",o>e+1)})}function we(n,t){if(!nt())return void rt(n,t,"Bạn cần đăng nhập để xem ưu đãi của bạn.");if(z&&!D.length)return n.appendChild(Bt(200,12)),void n.appendChild(Bt(150,12));if(!D.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Bạn chưa có ưu đãi nào.",void n.appendChild(t)}const e=document.createElement("div");e.className="cnv-panel-reward__list",D.forEach(n=>e.appendChild(ne(n,t))),n.appendChild(e);const o=Rn();if(o>0||Y){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more";const e=Y||z;t.disabled=e,t.textContent=e?"Đang tải…":`Xem thêm ${o} ưu đãi`,t.addEventListener("click",Bn),n.appendChild(t)}}function xe(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 ke(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=bt[n.icon];i.appendChild(ht("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 Ae(){if(O)return;const n=qn(o.projectId);if(!n)return;const t=S+1;O=!0,C&&Ce(),o.fetchPointHistory(n.token,t).then(n=>{O=!1,S=t,n&&("number"==typeof n.totalCount&&(i=n.totalCount),n.items.length&&(M=M.concat(n.items))),C&&Ce()}).catch(()=>{O=!1,C&&Ce()})}function Ce(){if(!v)return;Qe(),Xe(),Je(!0),v.textContent="";const n=Wn(r),t=Rt(r);if(t.appendChild(ze({label:"Lịch sử hoạt động",icon:tt},n)),!M.length&&O)t.appendChild(Bt(180,12)),t.appendChild(Bt(120,12));else if(M.length){const n=document.createElement("div");n.className="cnv-panel-history__list",M.forEach((t,e)=>n.appendChild(Me(t,e>0))),t.appendChild(n);const e="number"==typeof i&&S?Math.max(0,i-M.length):0;if(e>0||O){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=O,n.textContent=O?"Đang tải…":`Xem thêm ${e} hoạt động`,n.addEventListener("click",Sn(Ae)),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)}v.appendChild(t)}function Me(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(Se(c));const l=[];"number"==typeof n.balanceAfter&&l.push("Điểm tích lũy: "+Ee(n.balanceAfter));const a=(n.rankAfter||"").trim();"number"==typeof n.expBalanceAfter?l.push("Điểm xét hạng: "+Ee(n.expBalanceAfter)+(a?" (Hạng "+a+")":"")):a&&l.push("Hạng "+a),l.length&&o.appendChild(Se(l.join(" / ")));const u=Ie(n.createdAt);u&&o.appendChild(Se(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=Oe(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=Oe(n.expPoints)+" xét hạng",s.appendChild(t)}return s.childElementCount&&e.appendChild(s),e}function Se(n){const t=document.createElement("div");return t.className="cnv-panel-history__meta",t.textContent=n,t}function Oe(n){const t=Math.round(n);return(t>0?"+":"")+t.toLocaleString("vi-VN")}function Ee(n){return Math.round(n).toLocaleString("vi-VN")}function Ie(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 Ne(){if(!v||!E)return;const n=_t[E];if(!n)return E=null,void He();const t=xe(E);Qe(),Xe(),Je(!0),v.textContent="";const e=Wn(r),o=Rt(r);if(o.appendChild(ze(n,e)),t.length){const r=document.createElement("div");r.className="cnv-panel-block__list",t.forEach((t,o)=>r.appendChild(ke(t,o>0,e,n.icon))),o.appendChild(r)}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="redeem"===E?"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(v.appendChild(o),!We()){const n=In();n&&v.appendChild(n)}I=We()}function ze(n,t){const e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(ht(n.icon,t));const o=document.createElement("div");return o.className="cnv-panel-section__title",o.textContent=n.label,e.appendChild(o),e}function Te(n){if(!(Array.isArray(r.sections)?r.sections:[]).some(n=>"POINTS"===n.type&&n.enabled))return null;const t=Rt(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 kt.forEach((n,t)=>o.appendChild(On(n[0],n[1],t>0))),t.append(ze(mt.POINTS,n),e,o),t}function De(n){const t=Math.max(0,Math.round(n)).toLocaleString("vi-VN");return"SPENDING"===(null==Z?void 0:Z.applyFor)?t+"đ":t+" điểm"}function je(n){const t=document.createElement("span");if(t.className="cnv-panel-tier__badge",P(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=L(n.colorCode,Wn(r)),t}function Fe(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(je(n));const i=document.createElement("span");return 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:"",r.appendChild(i),r}function Re(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 Be(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 Le(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 "+De(s)+" nữa để lên "+n.nextLevelName:"Còn "+De(s)+" nữa để lên hạng kế tiếp",c.append(l,u),c}function Pe(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 $e(n,t){var e,o;const i=null!==(e=null==Z?void 0:Z.tiers)&&void 0!==e?e:[];if(!i.length)return null;const c=Rt(r),l=document.createElement("div"),a=t?null==N?void 0:N.tier:void 0;if(null==a?void 0:a.name){const t=document.createElement("div");t.className="cnv-panel-tier__current",t.appendChild(je(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=Le(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}=Pe(i,u),p=document.createElement("div");p.className="cnv-panel-tier__list",s>0&&p.appendChild(Be(s,!1));for(let n=s;n<d;n++){const t=n===u;if(p.appendChild(Fe(i[n],t)),t||u<0){const t=Re(i[n].benefits);t&&p.appendChild(t)}}const f=Math.max(null!==(o=null==Z?void 0:Z.totalTiers)&&void 0!==o?o:i.length,i.length)-d;return f>0&&p.appendChild(Be(f,!0)),l.appendChild(p),c.append(ze(mt.VIP,n),l),c}function Ue(n,t){const e=mt[n];if(!e||"string"!=typeof e.label)return null;if("VIP"===n)return $e(t,!0);const o=Rt(r),i=ze(e,t),c=document.createElement("div");if("POINTS"!==n)return c.appendChild(vt("Sắp ra mắt",t)),o.append(i,c),o;const l=zn();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(vt("Đang cập nhật",t));return[["Ưu đãi","rewards"],...kt,["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 Ve(){if(!f||!h)return;const n=r.colors;s&&(s.style.backgroundColor="DARK"===r.theme?"#181C32":"#FFFFFF",s.style.color="DARK"===r.theme?"#FFFFFF":"#181C32");const t=f.parentElement;if(t&&(t.style.backgroundColor=L(null==n?void 0:n.bannerBg,F),t.style.color=L(null==n?void 0:n.bannerFont,R)),d&&(P(r.bannerImageUrl)?(d.src=r.bannerImageUrl,d.style.display="block"):(d.style.display="none",d.removeAttribute("src"))),p){const t=p.parentElement;P(r.brandIconUrl)?(p.src=r.brandIconUrl,t&&(t.style.display="flex",t.style.background=V(L(null==n?void 0:n.bannerFont,R),.18))):(t&&(t.style.display="none"),p.removeAttribute("src"))}const e=(null==w?void 0:w.isMember)?r.headerMember:r.headerVisitor,i=(null==w?void 0:w.isMember)?null===(c=qn(o.projectId))||void 0===c?void 0:c.fullName:null;var c;f.textContent=St((null==e?void 0:e.caption)||"",i),h.textContent=St((null==e?void 0:e.title)||"",i)}function He(){if(!v||k||A||C||E)return;Qe(),Xe(),Je(!0),v.textContent="";const n=Wn(r);if(!(null==w?void 0:w.isMember)){let t=0;Ke(En(),t++);const e=Te(n);e&&Ke(e,t++);const o=Fn()?$e(n,!1):null;return void(o&&Ke(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=Ue(t.type,n);o&&Ke(o,e++)}),nt()&&Ke(qe(),e++)}function qe(){const n=document.createElement("div");n.className="cnv-panel-logout";const t=document.createElement("button");return t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-logout__btn",t.textContent="Đăng xuất",t.addEventListener("click",Sn(Oo)),n.appendChild(t),n}function Ke(n,t){n.style.animationDelay=40+55*t+"ms",v.appendChild(n)}function Ge(){Ve(),E?I!==We()&&Ne():He()}function Ze(){dn("owned"),dn("redeem"),N=null,T=0,en=0,D=[],U=0,A=!1,nn=[],c=void 0,tn=0,l=void 0,vn=null,It(),M=[],i=void 0,S=0,C=!1}function We(){return!!(null==w?void 0:w.isMember)}function Ye(){if(!v)return;v.scrollTop=0;const n=v.querySelector(".cnv-panel-rlist");n&&(n.scrollTop=0)}function Je(n){s&&(s.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 Qe(){const n=k||A||C||null!==E;g&&(g.style.display=n?"inline-flex":"none"),m&&m.classList.toggle("cnv-panel-banner--sub",n)}function Xe(){if(!s)return;const n=!We()&&null!==E;if(n&&!y)return y=Nn(),void s.insertBefore(y,b);!n&&y&&(y.remove(),y=null)}function no(){k&&(eo(),k=!1),A=!1,It(),C=!1,E=null,Ye(),He()}function to(){yn=e(yn)}function eo(){_n=e(_n)}function oo(n,t){to();const e=Date.now()+1e3*t.expiresInSeconds;yn=Ut(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 ro(){if(k=!1,to(),eo(),x){const t=x;x=null,n(()=>t.cancel())}}function io(){const n=document.createElement("button");return n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Huỷ",n.addEventListener("click",()=>{ro(),Ge()}),n}function co(n){var t;if(!v)return;Qe(),Xe(),Je(!1),v.textContent="";const e=Wn(r),o=Rt(r,"cnv-panel-zalo");if("loading"===n.phase)o.appendChild(Pt(e)),o.appendChild(io());else if("qr"===n.phase){const t=(n=>{try{const t=X(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),Lt(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(ft(tt,12));const l=document.createElement("span");c.appendChild(l),o.appendChild(c),oo(l,n.session),o.appendChild(io())}else{o.style.position="relative",o.appendChild(Pt(e));const l=document.createElement("div");let a;if(l.className="cnv-panel-zalo__overlay",l.style.borderRadius=Zn(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=$t(ot,lt,at,n.result.fullName?`Xin chào ${n.result.fullName}!`:"Đăng nhập thành công!");else{const t="expired"===n.reason,o="agent-registration-required"===n.reason;a=$t(o?et:t?tt:'<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"/>',o||t?dt:ut,o||t?pt:st,o?"Cần đăng ký đại lý":t?"Mã QR đã hết hạn":"Có lỗi xảy ra");const r=document.createElement("div");if(r.className="cnv-panel-zalo__status",r.textContent=t?'Bấm "Thử lại" để lấy mã mới.':n.message,a.appendChild(r),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",Sn(()=>lo())),bn>=3){const t=Math.min(5+5*(bn-3),20);i=n,c=t,eo(),i.disabled=!0,_n=Ut(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;v.appendChild(o)}function lo(){if(!v)return;ro(),E=null,k=!0,Ye();const t=++gn;co({phase:"loading"}),o.loginWithZalo().then(e=>{kn(t)?n(()=>e.cancel()):(x=e,bn=0,co({phase:"qr",session:e}),e.result.then(n=>{if(!kn(t)){if(to(),x=null,co({phase:"success",result:n}),null!=n.contactId&&"string"==typeof n.panelSessionToken&&n.panelSessionToken&&"number"==typeof n.panelSessionExp){const t="number"==typeof n.panelSessionExpiresInMs&&n.panelSessionExpiresInMs>0?Date.now()+n.panelSessionExpiresInMs:n.panelSessionExp;Kn(o.projectId,{token:n.panelSessionToken,contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,exp:t}),Mo(t)}w={isMember:!0},jn(),setTimeout(()=>{kn(t)||(k=!1,Ge())},1500)}}).catch(n=>{if(kn(t))return;to(),x=null;const e=Gt(n);co({phase:"error",message:Zt(n),canRetry:"agent-registration-required"!==e,reason:e})}))}).catch(n=>{kn(t)||(bn+=1,co({phase:"error",message:Zt(n),canRetry:!0,reason:Gt(n)}))})}function ao(n){var t,e,o;if(a)return;const i=q("data-cnv-panel",":host{all:initial;}.cnv-panel-card{position:fixed;display:flex;flex-direction:column;background-repeat:repeat;width:min(360px,calc(100vw - 32px));height:600px;max-height:calc(100vh - 32px);overflow:hidden;box-shadow:0 20px 44px rgba(24,28,50,.22),0 4px 10px rgba(24,28,50,.12);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.4;animation:cnv-panel-in .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-card--leaving{animation:cnv-panel-out .18s cubic-bezier(.4,0,1,1) both;pointer-events:none;}@keyframes cnv-panel-in{from{opacity:0;transform:translateY(14px) scale(.92);}to{opacity:1;transform:none;}}@keyframes cnv-panel-out{from{opacity:1;transform:none;}to{opacity:0;transform:translateY(10px) scale(.96);}}@keyframes cnv-panel-bubble-in{from{opacity:0;transform:translateY(4px) scale(.97);}to{opacity:1;transform:none;}}@keyframes cnv-panel-rise{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-panel-card,.cnv-panel-card--leaving,.cnv-panel-card__section,.cnv-panel-zalo__overlay-bubble{animation:none !important;}}.cnv-panel-close{position:absolute;z-index:2;top:10px;right:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;font-size:16px;display:inline-flex;align-items:center;justify-content:center;line-height:1;padding:0;transition:background .15s;}.cnv-panel-close:hover{background:rgba(0,0,0,.3);}.cnv-panel-back{position:absolute;z-index:2;top:10px;left:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;padding:0;display:none;align-items:center;justify-content:center;transition:background .15s;}.cnv-panel-back:hover{background:rgba(0,0,0,.3);}.cnv-panel-banner{position:relative;flex:0 0 auto;padding:20px 20px 54px;min-height:160px;margin-bottom:-54px;box-sizing:border-box;overflow:hidden;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:.35;display:none;}.cnv-panel-banner__brandchip{position:relative;width:34px;height:34px;border-radius:10px;margin:0 0 10px;display:none;align-items:center;justify-content:center;overflow:hidden;}.cnv-panel-banner__brandicon{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-banner__caption{position:relative;font-size:11.5px;opacity:.85;}.cnv-panel-banner__title{position:relative;font-size:26px;font-weight:800;line-height:1.24;margin-top:3px;}.cnv-panel-body{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;padding:16px;display:flex;flex-direction:column;gap:12px;position:relative;z-index:1;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-body::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-footer{flex:0 0 auto;padding:11px 16px;display:flex;align-items:center;justify-content:center;gap:4px;font-size:11.5px;font-weight:500;}.cnv-panel-footer__brand{font-weight:800;}.cnv-panel-card__section{padding:16px;box-sizing:border-box;animation:cnv-panel-rise .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-phase{flex:1 0 auto;display:flex;flex-direction:column;justify-content:center;}.cnv-panel-phase .cnv-panel-zalo__status{max-width:none;}.cnv-panel-chip{width:26px;height:26px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}.cnv-panel-section__head{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-cta{text-align:center;}.cnv-panel-cta__title{font-size:15px;font-weight:800;margin-bottom:5px;}.cnv-panel-cta__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:14px;}.cnv-panel-history__row{display:flex;align-items:flex-start;gap:10px;padding:10px 0;}.cnv-panel-history__main{flex:1;min-width:0;}.cnv-panel-history__title{font-size:13px;font-weight:700;line-height:1.35;}.cnv-panel-history__meta{font-size:11.5px;line-height:1.45;opacity:.66;margin-top:2px;}.cnv-panel-history__amounts{flex:0 0 auto;text-align:right;}.cnv-panel-history__points{font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap;}.cnv-panel-history__exp{font-size:11px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;opacity:.66;margin-top:2px;}.cnv-panel-join-hint{padding:13px 16px;text-align:center;font-size:12.5px;line-height:1.5;font-weight:600;}.cnv-panel-joinbar{flex:0 0 auto;padding:12px 16px;}.cnv-panel-cta__btn{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;height:40px;border:none;font-weight:700;cursor:pointer;margin-bottom:10px;font-size:13.5px;transition:filter .15s,transform .15s cubic-bezier(.16,1,.3,1);}.cnv-panel-cta__btn:hover{filter:brightness(1.06);transform:translateY(-1px);}.cnv-panel-cta__btn:active{transform:translateY(0) scale(.985);}.cnv-panel-cta__signin{display:flex;align-items:center;justify-content:center;gap:4px;font-size:12.5px;text-align:center;cursor:pointer;font-weight:700;}@media (max-height:560px){.cnv-panel-banner{min-height:96px;margin-bottom:-38px;padding:14px 16px 38px;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__title{font-size:20px;}.cnv-panel-body{padding:12px;gap:8px;}.cnv-panel-joinbar{padding:8px 12px;}.cnv-panel-cta__btn{height:34px;margin-bottom:6px;}.cnv-panel-footer{padding:6px 12px;}}.cnv-panel-icon{display:inline-flex;flex-shrink:0;}.cnv-panel-icon--chevron{transition:transform .15s;}.cnv-panel-cta__signin:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-section__title{font-size:11.5px;font-weight:800;text-transform:uppercase;letter-spacing:.04em;opacity:.68;}.cnv-panel-section__points{font-size:28px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;margin-bottom:6px;}.cnv-panel-section__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:4px;}.cnv-panel-section__row{font-size:12.5px;display:flex;align-items:center;gap:10px;padding:10px 0;cursor:pointer;}.cnv-panel-section__row-label{flex:1;min-width:0;}.cnv-panel-section__row:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-badge{display:inline-flex;align-items:center;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.03em;padding:3px 8px;border-radius:999px;}.cnv-panel-tier__current{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-tier__current-name{font-size:19px;font-weight:800;line-height:1.2;}.cnv-panel-tier__badge{flex:0 0 auto;width:18px;height:18px;border-radius:999px;overflow:hidden;display:inline-flex;align-items:center;justify-content:center;}.cnv-panel-tier__badge-img{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-tier__progress{margin-bottom:8px;}.cnv-panel-tier__bar{height:6px;border-radius:999px;overflow:hidden;}.cnv-panel-tier__fill{height:100%;border-radius:999px;transition:width .35s ease;}.cnv-panel-tier__hint{font-size:12px;line-height:1.5;opacity:.72;}.cnv-panel-tier__list{}.cnv-panel-tier__row{display:flex;align-items:center;gap:8px;font-size:12.5px;padding:7px 0;}.cnv-panel-tier__row--current{font-weight:800;}.cnv-panel-tier__name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cnv-panel-tier__benefits{margin:0 0 6px 26px;padding:0 0 0 14px;font-size:12px;line-height:1.55;opacity:.72;}.cnv-panel-tier__more{font-size:11.5px;padding:5px 0 5px 26px;opacity:.58;}.cnv-panel-zalo{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;text-align:center;min-height:346px;}.cnv-panel-vstack{display:flex;flex-direction:column;align-items:center;gap:8px;}.cnv-panel-zalo__qr{position:relative;padding:10px;border-radius:12px;}.cnv-panel-zalo__qr--white{background:#fff;}.cnv-panel-zalo__qr svg{display:block;}.cnv-panel-zalo__corner{position:absolute;width:16px;height:16px;border:3px solid;border-radius:5px 0 0 0;}.cnv-panel-zalo__corner.tl{top:-3px;left:-3px;border-right:none;border-bottom:none;}.cnv-panel-zalo__corner.br{bottom:-3px;right:-3px;border-left:none;border-top:none;border-radius:0 0 5px 0;}.cnv-panel-zalo__title{font-size:14px;font-weight:800;}.cnv-panel-zalo__status{font-size:12.5px;font-weight:500;line-height:1.45;max-width:250px;}.cnv-panel-zalo__timer{font-size:11.5px;font-weight:700;opacity:.7;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center;gap:5px;}.cnv-panel-reward__list{}.cnv-panel-reward{position:relative;display:flex;align-items:stretch;padding:8px;margin-top:10px;border-radius:10px;border:1px solid var(--cnv-tk-line);background:var(--cnv-tk-bg);}.cnv-panel-reward:first-child{margin-top:2px;}.cnv-panel-ticket__stub{flex:0 0 76px;min-height:84px;box-sizing:border-box;border-radius:8px;border-top:4px solid transparent;border-bottom:4px solid rgba(0,0,0,.15);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;padding:4px 3px;text-align:center;}.cnv-panel-ticket__badge{width:40px;height:40px;flex:none;border-radius:50%;background:#FFFFFF;overflow:hidden;display:flex;align-items:center;justify-content:center;}.cnv-panel-ticket__label{font-size:10px;font-weight:700;line-height:1.3;word-break:break-word;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;}.cnv-panel-ticket__cut{position:relative;flex:0 0 14px;}.cnv-panel-ticket__cut::before{content:'';position:absolute;left:50%;top:4px;bottom:4px;border-left:1px dashed var(--cnv-tk-dash);}.cnv-panel-ticket__hole{position:absolute;left:50%;width:14px;height:8px;margin-left:-7px;box-sizing:border-box;background:var(--cnv-tk-hole);border:1px solid var(--cnv-tk-line);}.cnv-panel-ticket__hole--top{top:-9px;border-top:none;border-radius:0 0 8px 8px;}.cnv-panel-ticket__hole--bottom{bottom:-9px;border-bottom:none;border-radius:8px 8px 0 0;}.cnv-panel-reward__main{min-width:0;flex:1;display:flex;flex-direction:column;align-items:flex-start;padding-top:2px;}.cnv-panel-reward__thumb{width:34px;height:34px;border-radius:50%;object-fit:cover;}.cnv-panel-reward__foot{margin-top:auto;padding-top:8px;align-self:stretch;display:flex;align-items:center;justify-content:flex-end;gap:8px;}.cnv-panel-reward__title{font-size:13px;font-weight:700;line-height:1.4;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}.cnv-panel-reward__title--full{display:block;-webkit-line-clamp:none;overflow:visible;}.cnv-panel-reward__name{display:flex;align-items:flex-start;gap:4px;}.cnv-panel-reward__name>.cnv-panel-reward__title{flex:1 1 auto;min-width:0;}.cnv-panel-reward__info{display:none;flex:none;padding:0;margin-top:1px;border:none;background:transparent;color:inherit;opacity:.45;cursor:pointer;line-height:0;}.cnv-panel-reward__info:hover{opacity:.85;}.cnv-panel-reward__name--clamped .cnv-panel-reward__info{display:inline-flex;}.cnv-panel-reward__tags{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:6px;}.cnv-panel-reward__value{font-size:12px;font-weight:800;padding:3px 8px;border-radius:999px;white-space:nowrap;}.cnv-panel-reward__uses{font-size:11.5px;font-weight:600;padding:3px 8px;border-radius:999px;background:rgba(127,127,127,.14);white-space:nowrap;}.cnv-panel-reward__code{font-size:13px;font-weight:800;letter-spacing:.06em;margin-top:6px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;user-select:all;}.cnv-panel-reward__meta{font-size:11.5px;opacity:.7;margin-top:4px;line-height:1.45;}.cnv-panel-reward__code--big{font-size:20px;margin-top:10px;}.cnv-panel-reward__channel{display:flex;align-items:flex-start;gap:5px;margin-top:4px;font-size:11.5px;line-height:1.45;}.cnv-panel-reward__channel .cnv-panel-icon{margin-top:1px;}.cnv-panel-reward__channel--center{justify-content:center;margin-top:6px;font-size:12px;}.cnv-panel-reward__show{width:auto;white-space:nowrap;}.cnv-panel-reward__more{width:100%;margin-top:10px;}.cnv-panel-balance{padding:2px 0 8px;}.cnv-panel-balance__label{font-size:11.5px;opacity:.66;margin-bottom:2px;}.cnv-panel-balance__row{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;}.cnv-panel-balance__num{font-size:26px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;}.cnv-panel-balance__unit{font-size:12.5px;font-weight:700;opacity:.7;}.cnv-panel-rtabs{display:flex;gap:2px;margin:2px 0 2px;border-bottom:1px solid rgba(127,127,127,.22);}.cnv-panel-rcard{flex:0 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.cnv-panel-rhead{flex:0 0 auto;}.cnv-panel-rlist{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-rlist::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-rtab{flex:1;padding:9px 6px;margin-bottom:-1px;background:transparent;border:none;border-bottom:2px solid transparent;color:inherit;cursor:pointer;font-size:12.5px;font-weight:700;opacity:.6;transition:opacity .15s;font-family:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.cnv-panel-rtab:hover{opacity:.85;}.cnv-panel-rtab--on{opacity:1;font-weight:800;}.cnv-panel-reward__price{flex:1 1 auto;min-width:0;font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;}.cnv-panel-reward__cta{height:30px;padding:0 12px;font-size:12px;}.cnv-panel-redeem__cost{font-size:20px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1;}.cnv-panel-redeem__sub{font-size:11.5px;opacity:.66;line-height:1.45;}.cnv-panel-redeem__actions{display:flex;gap:8px;margin-top:12px;justify-content:center;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn{flex:1;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn:only-child{flex:0 0 auto;}.cnv-panel-block__list{}.cnv-panel-block{padding:11px 0;display:flex;gap:10px;align-items:flex-start;}.cnv-panel-block .cnv-panel-chip{margin-top:1px;}.cnv-panel-block__main{min-width:0;flex:1;}.cnv-panel-block__title{font-size:13px;font-weight:700;line-height:1.4;}.cnv-panel-block__desc{font-size:12px;line-height:1.5;opacity:.72;margin-top:3px;white-space:pre-line;}.cnv-panel-zalo__btn{height:36px;padding:0 16px;border:1px solid rgba(127,127,127,.3);border-radius:10px;background:transparent;color:inherit;font-size:12.5px;font-weight:700;cursor:pointer;transition:filter .15s;}.cnv-panel-zalo__btn:hover:not(:disabled){filter:brightness(1.1);}.cnv-panel-zalo__btn:disabled{opacity:.5;cursor:not-allowed;}.cnv-panel-logout{display:flex;justify-content:center;padding:2px 0 10px;}.cnv-panel-logout__btn{height:32px;font-size:12px;font-weight:600;opacity:.72;}.cnv-panel-logout__btn:hover{opacity:1;}.cnv-panel-zalo__overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:16px;}.cnv-panel-zalo__overlay-bubble{display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;padding:0 8px;max-width:100%;animation:cnv-panel-bubble-in .2s ease;}.cnv-panel-bubble-icon{width:40px;height:40px;border-radius:999px;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 0 0 1px rgba(127,127,127,.22);}.cnv-panel-zalo__skeleton{border-radius:6px;background:rgba(127,127,127,.15);background-image:linear-gradient( 90deg,rgba(127,127,127,.15) 25%,rgba(127,127,127,.32) 37%,rgba(127,127,127,.15) 63% );background-size:400% 100%;animation:cnv-panel-shimmer 1.4s ease infinite;}@keyframes cnv-panel-shimmer{0%{background-position:100% 50%;}100%{background-position:0% 50%;}}@media (prefers-reduced-motion:reduce){.cnv-panel-zalo__skeleton{animation:none;}}");a=i.hostEl;const c=i.shadow;a.style.setProperty("display","none");const l=null!==(t=(null==n?void 0:n.useCustomZIndex)?$(n.zIndex):null)&&void 0!==t?t:j,y=null!==(e=$(l+600))&&void 0!==e?e:j;s=document.createElement("div"),s.className="cnv-panel-card",s.style.zIndex=String(y),s.addEventListener("animationend",n=>{"cnv-panel-out"===n.animationName&&fo()}),s.style.borderRadius=Zn(null===(o=r.shapes)||void 0===o?void 0:o.container);const _=document.createElement("button");_.type="button",_.className="cnv-panel-close",_.setAttribute("aria-label","Đóng"),_.textContent="×",_.addEventListener("click",po),g=document.createElement("button"),g.type="button",g.className="cnv-panel-back",g.setAttribute("aria-label","Quay lại"),g.appendChild(ft('<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',15)),g.addEventListener("click",Sn(no));const w=document.createElement("div");m=w,w.className="cnv-panel-banner",d=document.createElement("img"),d.className="cnv-panel-banner__img",d.alt="",p=document.createElement("img"),p.className="cnv-panel-banner__brandicon",p.alt="";const x=document.createElement("div");x.className="cnv-panel-banner__brandchip",x.appendChild(p),f=document.createElement("div"),f.className="cnv-panel-banner__caption",h=document.createElement("div"),h.className="cnv-panel-banner__title",w.append(d,x,f,h),v=document.createElement("div"),v.className="cnv-panel-body",s.append(_,g,w,v),b=uo(),b&&s.appendChild(b),c.appendChild(s),K(a),u=G(a)}function uo(){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 CDP",t.appendChild(e),t}function so(n){if(!s)return;const{side:t,sideSpacingPx:e,bottomSpacingPx:o}=H(n,B());s.style.left="left"===t?e+"px":"auto",s.style.right="right"===t?e+"px":"auto";const r=o+48+24;s.style.bottom=r+"px",s.style.maxHeight=`calc(100vh - ${r+16}px)`,s.style.transformOrigin="left"===t?"left bottom":"right bottom"}function po(){a&&_&&(_=!1,ro(),A=!1,It(),C=!1,E=null,document.removeEventListener("keydown",xn),vo("cnv:panel:closed"),s&&!t(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,!1)?(s.classList.add(Vn),wn=setTimeout(fo,320)):fo())}function fo(){null!==wn&&(clearTimeout(wn),wn=null),null==s||s.classList.remove(Vn),null==a||a.style.setProperty("display","none")}function ho(){null!==wn&&(clearTimeout(wn),wn=null),null==s||s.classList.remove(Vn)}function vo(t){n(()=>window.dispatchEvent(new CustomEvent(t)))}const mo=t=>{n(()=>{var n;const e=t.detail;var r;_?po():(ao(r=null!==(n=null==e?void 0:e.config)&&void 0!==n?n:null),a&&(ho(),so(r),a.style.setProperty("display","block"),_=!0,Ge(),jn(),!Fn()||Z||W||(W=!0,o.fetchPanelTiers().then(n=>{W=!1,n&&n.tiers.length&&(Z=n,_&&Ge())}).catch(()=>{W=!1})),document.addEventListener("keydown",xn),vo("cnv:panel:opened")))})},go=t=>{n(()=>{const n=t.detail;w=(null==n?void 0:n.isMember)?{isMember:!0,points:n.points,rewardsAvailableCount:n.rewardsAvailableCount}:{isMember:!1},w.isMember||Ze(),_&&Ge(),_&&jn()})},bo=3e5,yo=15e3,_o=6e4;let wo=null,xo=!1,ko=!1;function Ao(){null!==wo&&(clearTimeout(wo),wo=null)}function Co(n){Ao(),ko||(wo=t(()=>setTimeout(Eo,Math.max(0,n)),null))}function Mo(n){Co(Math.max(yo,n-Date.now()-bo))}function So(){Ao(),Gn(o.projectId),w={isMember:!1},Ze(),Ge()}function Oo(){const t=qn(o.projectId),e=o.revokePanelSession;t&&e&&n(()=>{e(t.token).catch(()=>{})}),So()}function Eo(){if(Ao(),ko||xo)return;const n=qn(o.projectId);n&&(Date.now()>n.exp?So():(xo=!0,o.refreshPanelSession(n.token).then(t=>{if(xo=!1,ko)return;const e=qn(o.projectId);if(!e)return;if(e.token!==n.token)return void Mo(e.exp);if("ok"===t.kind)return Kn(o.projectId,Object.assign(Object.assign({},e),{token:t.token,exp:t.exp})),void Mo(t.exp);if("unauthorized"===t.kind)return void So();const r=e.exp-Date.now();r<=0?So():Co(Math.min(_o,r))}).catch(()=>{if(xo=!1,ko)return;const t=n.exp-Date.now();t>0&&Co(Math.min(_o,t))})))}function Io(){if("visible"!==document.visibilityState)return;const n=qn(o.projectId);n&&(Date.now()>n.exp?So():n.exp-Date.now()<=bo?Eo():Mo(n.exp))}function No(){const n=qn(o.projectId);n&&(Date.now()>n.exp?Gn(o.projectId):(Mo(n.exp),w={isMember:!0},Ge(),o.restorePanelSession(n.token).then(t=>{if(ko)return;if("unavailable"===t.kind)return;const e=qn(o.projectId);e&&e.token===n.token&&("ok"===t.kind?(w={isMember:!0},Kn(o.projectId,Object.assign(Object.assign({},e),{fullName:t.session.fullName,level:t.session.level,xp:t.session.xp}))):(Ao(),Gn(o.projectId),w={isMember:!1},Ze()),Ge())}).catch(()=>{})))}return window.addEventListener($n,mo),window.addEventListener(Un,go),document.addEventListener("visibilitychange",Io),No(),()=>{ro(),ko=!0,n(()=>{window.removeEventListener($n,mo),window.removeEventListener(Un,go),document.removeEventListener("visibilitychange",Io),Ao(),document.removeEventListener("keydown",xn),ho(),u&&u(),null==a||a.remove()})}}catch(zo){return()=>{}}}const Yt={path:"/config",timeoutMs:4e3,ttlMs:3e5};function Jt(n,t){var e,o;const r=null!=t?t:Object.assign({enabled:!0},Yt);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 Qt(n){return"_cnv_cfg_"+n}function Xt(n){const t=bn(Qt(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 ne(n,t,e){try{const o={etag:t,envelope:e,fetchedAt:Date.now()};yn(Qt(n),JSON.stringify(o))}catch(n){}}function te(n){const t=Xt(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 ee=["gclid","fbclid","ttclid","msclkid","dclid"],oe=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function re(){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 ie(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 oe){const e=r.get(n);e&&e.length>0&&(i[t]=e,c=!0)}if(e){const n={};for(const t of ee){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}function ce(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.16"}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}}function le(n){if(n)try{const t=new URL(n);if("http:"!==t.protocol&&"https:"!==t.protocol)return;return t.origin+t.pathname}catch(n){return}}const ae=256;function ue(n,t){if("string"!=typeof n)return;const e=n.trim();return e?e.length>t?e.slice(0,t):e:void 0}function se(n){return"_cnv_ft_"+n}function de(n){const e=bn(se(n));if(!e)return null;const o=t(()=>(n=>{if(!n||"object"!=typeof n)return null;const t=n;if("number"!=typeof t.ts||!Number.isFinite(t.ts))return null;const e={ts:t.ts},o=ue(t.source,ae);o&&(e.source=o);const r=ue(t.medium,ae);r&&(e.medium=r);const i=ue(t.name,ae);i&&(e.name=i);const c=ue(t.term,ae);c&&(e.term=c);const l=ue(t.content,ae);l&&(e.content=l);const a=ue(t.id,ae);a&&(e.id=a);const u=ue(t.referrer,1024);u&&(e.referrer=u);const s=ue(t.landingPage,1024);if(s&&(e.landingPage=s),t.clickIds&&"object"==typeof t.clickIds){const n={};for(const[e,o]of Object.entries(t.clickIds)){if(Object.keys(n).length>=8)break;const t=ue(e,ae),r=ue(o,ae);t&&r&&(n[t]=r)}Object.keys(n).length>0&&(e.clickIds=n)}return 1===Object.keys(e).length?null:e})(JSON.parse(e)),null);if(!o)return _n(se(n)),null;const r=Date.now()-o.ts;return r>63072e6||r<-864e5?(_n(se(n)),null):o}function pe(n,t=!0){const e={first_seen_at:n.ts};return n.source&&(e.utm_source=n.source),n.medium&&(e.utm_medium=n.medium),n.name&&(e.utm_campaign=n.name),n.term&&(e.utm_term=n.term),n.content&&(e.utm_content=n.content),n.id&&(e.utm_id=n.id),n.clickIds&&t&&(e.click_ids=n.clickIds),n.referrer&&(e.referrer=n.referrer),n.landingPage&&(e.landing_page=n.landingPage),e}const fe="_cnv_cid";function he(n={}){const t=vn(fe),e=bn(fe);let o=null;return Mn(t)?o=t:Mn(e)&&(o=e),o||(o=An()),ve(o,n),o}function ve(n,t={}){var e;mn(fe,n,{domain:t.cookieDomain,maxAgeDays:null!==(e=t.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),yn(fe,n)}const me="1.0";function ge(){return(new Date).toISOString()}function be(n,t){var e;const o=null!==(e=t.timestamp)&&void 0!==e?e:ge(),r=Object.assign(Object.assign({},t.context),{projectId:t.projectId,schemaVersion:me}),i={type:n,messageId:An(),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 ye="_cnv_sid";function _e(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!Mn(e)||!Number.isFinite(o)||o<=0?null:{id:e,lastActivity:o}}function we(n={}){const t=Date.now(),e=(n=>{var t;return 6e4*(null!==(t=n.timeoutMinutes)&&void 0!==t?t:30)})(n),o=_e(vn(ye)),r=_e((n=>{if(!wn())return null;try{return sessionStorage.getItem(n)}catch(n){return null}})(ye));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:An(),lastActivity:t};return xe(c,n),c.id}function xe(n,t={}){var e;const o=(n=>`${n.id}.${n.lastActivity}`)(n),r=null!==(e=t.timeoutMinutes)&&void 0!==e?e:30;mn(ye,o,{domain:t.cookieDomain,maxAgeDays:r/1440,sameSite:"Lax"}),((n,t)=>{if(!wn())return!1;try{return sessionStorage.setItem(n,t),!0}catch(n){return!1}})(ye,o)}class ke{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&&Ae(t)>this.maxMessages;)t.shift();this.write(t),this.config.debug&&console.log("[cnv-track] retry queued",n.length,"buffered",Ae(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 Ae(this.read())}clear(){try{_n(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=bn(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?yn(this.storageKey,JSON.stringify(n)):_n(this.storageKey)}}function Ae(n){let t=0;for(const e of n)t+=e.length;return t}class Ce{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 ke({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=ge(),o={batch:n.map(n=>Me(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=Me(n,ge());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 Me(n,t){return Object.assign(Object.assign({},n),{sentAt:t})}const Se="_cnv_uid",Oe="_cnv_traits",Ee={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:Jt(void 0)},Ie={analytics:!0,marketing:!0};function Ne(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 ze="0.3.0-beta.16",Te="@cnv-vn/track",De=function(){let l=null,a=Object.assign({},Ee),u=Object.assign({},Ie),s=null,d=!1,p=null;function f(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 h=null;const v=()=>h,m=f(x,v),g=f(J,v),b=f(Wt,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=Jt(n.remoteConfig,a.remoteConfig)),t):t;var e}function _(){return s||(s=new Ce({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 w(){var n;if(!l)return null;const e=((n={})=>{var e;const o={page:re(),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:ce(n.library)},r=ie(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:he({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),sessionId:we({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),userId:null!==(n=vn(Se)||bn(Se))&&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 A(n,t){try{const e=w();if(!e)return k("pageview");(n=>{const t=de(n.projectId);t&&(n.context.firstTouch=pe(t,a.allowAdTracking))})(e);const o=((n,t,e)=>{const o=be("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);_().enqueue(o)}catch(n){}}function C(n,t){A(n,t)}function M(n,t){try{if("string"!=typeof n||0===n.length)return;const e=w();if(!e)return k("track");const o=((n,t,e)=>{const o=be("track",e);return o.event=n,o.properties=null!=t?t:{},o})(n,t,e);_().enqueue(o)}catch(n){}}return{get initialized(){return d},get projectId(){return l},get endpoint(){return a.endpoint},isZaloQrLoginEnabled:()=>!!l&&te(l),get consentGranted(){return u.analytics&&u.marketing},init(f,v){var w,k;try{if(!f||"string"!=typeof f)return;a=y(v),(null==v?void 0:v.consent)&&(u=Object.assign(Object.assign({},u),v.consent)),l=f,s&&s.destroy(),s=null,_(),d=!0,he({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),we({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),((n,e=!0,o)=>{const r=de(n);if(r)return r;const i=ie(0,e),c=(n=>{const e=t(()=>document.referrer,"");if(e){try{const o=new URL(e).host;if(o===t(()=>window.location.host,""))return;const r=n?n.replace(/^\./,"").toLowerCase():"";if(r){const n=o.toLowerCase();if(n===r||n.endsWith("."+r))return}}catch(n){return}return le(e)}})(o);if(!i&&!c)return null;const l=Object.assign(Object.assign({},null!=i?i:{}),{referrer:c,landingPage:le(t(()=>window.location.href,"")),ts:Date.now()});yn(se(n),JSON.stringify(l))})(f,a.allowAdTracking,a.cookieDomain),a.autoPageview&&A(),p=e(p);const S={page(n,t){return C(n,t)},track(n,t){return M(n,t)},loginWithZalo(n){return Pn({projectId:l,endpoint:a.endpoint,zaloQrLoginEnabled:!!l&&te(l),consentGranted:u.analytics&&u.marketing,getAttribution(){const n=l?de(l):null;return n?pe(n,a.allowAdTracking):null},getAnonymousId(){return he({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays})},getSessionId(){return we({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes})}},n)},projectId:l,restorePanelSession(n){return l?function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{const r=yield fetch(Nn(n,"/panel/session",t),{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const i=yield r.json();return i&&"number"==typeof i.contactId?{kind:"ok",session:{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}}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},refreshPanelSession(n){return l?function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{const r=yield fetch(Nn(n,"/panel/session/refresh",t),{method:"POST",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const l=yield r.json();return l&&"string"==typeof l.panelSessionToken&&l.panelSessionToken&&"number"==typeof l.panelSessionExp?{kind:"ok",token:l.panelSessionToken,exp:(i=l.panelSessionExpiresInMs,c=l.panelSessionExp,"number"==typeof i&&i>0?Date.now()+i:c)}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}var i,c})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},revokePanelSession(n){return l?function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{return(yield fetch(Nn(n,"/panel/session/revoke",t),{method:"POST",credentials:"omit",mode:"cors",keepalive:!0,headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0})).ok}catch(n){return!1}finally{r&&clearTimeout(r)}})}(a.endpoint,l,n):Promise.resolve(!1)},fetchRewardsSummary(n,t,e){return l?function(n,t,e){return Q(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=zn(i,r);try{const r=Nn(n,"/panel/rewards-summary",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.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(Ln):[];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?Bn(t.tier):void 0}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},fetchPanelTiers(){return l?function(n,t){return Q(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),On):null;try{const o=yield fetch(Nn(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(Rn):[];return{applyFor:"SPENDING"===t.applyFor||"POINTS"===t.applyFor?t.applyFor:void 0,thresholdKind:"RELATIVE"===t.thresholdKind||"ABSOLUTE"===t.thresholdKind?t.thresholdKind:void 0,totalTiers:Fn(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 Q(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),On):null;try{const i=Nn(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(Tn):[];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)},fetchRedeemableRewards(n,t,e){return l?function(n,t,e){return Q(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=zn(i,r);try{const r=Nn(n,"/panel/redeemable-rewards",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.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(Dn):[];return{points:Fn(t.points),total:Fn(t.total),rewards:e}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},redeemReward(n,t,e){return l?function(n,t,e,o,r){return Q(this,void 0,void 0,function*(){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),25e3):null;try{const c=yield fetch(Nn(n,"/panel/redeem",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Idempotency-Key":r},body:JSON.stringify(null!=o.campaignId?null!=o.redeemPoints&&o.redeemPoints>0?{campaignId:o.campaignId,redeemPoints:o.redeemPoints}:{campaignId:o.campaignId}:{rewardId:o.rewardId}),signal:i?i.signal:void 0}),a=yield c.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!c.ok)return{ok:!1,code:a?jn(a,!0):null};const u=jn(a,!1);return u?{ok:!1,code:u}:{ok:!0,result:(l=a,l?{code:"string"==typeof l.code?l.code:void 0,pointsSpent:Fn(l.pointsSpent),pointsRemaining:Fn(l.pointsRemaining),transactionId:"string"==typeof l.transactionId?l.transactionId:void 0,burnOnUse:!0===l.burnOnUse}:{})}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{c&&clearTimeout(c)}var l})}(a.endpoint,l,n,t,e):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})},useReward(n,t){return l?function(n,t,e,o){return Q(this,void 0,void 0,function*(){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),25e3):null;try{const i=yield fetch(Nn(n,"/panel/rewards/use",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({redeemId:o}),signal:r?r.signal:void 0}),c=yield i.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!i.ok)return{ok:!1,code:c?jn(c,!0):null};const l=jn(c,!1);if(l)return{ok:!1,code:l};const a=c&&"string"==typeof c.code&&c.code?c.code:null;return a?{ok:!0,result:{code:a,usedAt:c&&"string"==typeof c.usedAt?c.usedAt:void 0,expiredAt:c&&"string"==typeof c.expiredAt?c.expiredAt:void 0,useRemain:c&&"number"==typeof c.useRemain&&Number.isFinite(c.useRemain)?c.useRemain:void 0}}:{ok:!1,code:"CODE_NOT_ISSUED"}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})}};if(h=S,a.autotrack){let t=a.autotrack;a.remoteConfig.enabled&&"object"==typeof t&&t.buttonTracking&&(t=Object.assign(Object.assign({},t),{buttonTracking:void 0})),p=function(t,e){const l=void 0===(a=e)||!1===a?Object.assign(Object.assign({},D),{searchParams:z}):!0===a?Object.assign(Object.assign({},T),{searchParams:z}):{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===(p=a.downloads)||void 0===p||p,siteSearch:null===(f=a.siteSearch)||void 0===f||f,downloadExtensions:a.downloadExtensions,searchParams:null!==(h=a.searchParams)&&void 0!==h?h:z,buttonTracking:a.buttonTracking};var a,u,s,d,p,f,h;l.outboundClicks=!1,l.downloads=!1,l.scroll=!1,l.siteSearch=!1;const v=[];let m=null;function g(e){if(l.siteSearch)try{const o=null!=e?e:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(n){return""}})();if(o===m)return;m=o;const r=((n,t=z)=>{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 p=(n=>{try{return new URL(n,location.href)}catch(n){return null}})(d);if(!p)return;let f=!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()})(p.pathname);(t||r&&e.has(r))&&(f=!0,null===(o=n.onDownload)||void 0===o||o.call(n,{url:p.href,fileName:i(p.pathname),fileExtension:null!=r?r:"",text:c(s)}))}l&&!f&&p.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(n){return""}})()&&p.host&&(null===(u=n.onOutbound)||void 0===u||u.call(n,{url:p.href,host:p.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(x(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=I(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(),g(o)});v.push(()=>{for(let n=0;n<e.length;n++)clearTimeout(e[n]);e.length=0,o()})}return g(),()=>{for(;v.length>0;){const n=v.pop();try{null==n||n()}catch(n){}}m=null}}(S,t)}if(m.dispose(),g.dispose(),b.dispose(),a.remoteConfig.enabled&&l){const n=n=>{var t,e,o,r;m.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),g.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!==(k=null===(w=Xt(l))||void 0===w?void 0:w.envelope)&&void 0!==k?k:null),function(n){return Q(this,void 0,void 0,function*(){if(!n.projectId)return{status:"error"};const t=Xt(n.projectId);if(t&&Date.now()-t.fetchedAt<n.ttlMs)return{status:"unchanged"};const e=yield function(n){return Q(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&&ne(n.projectId,t.etag,t.envelope),{status:"unchanged"}):e.envelope?(ne(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:A,page:C,screen(n,t){},track:M,identify(n,t){try{if("string"!=typeof n||0===n.length)return;((n,t,e={})=>{var o,r;if(n&&(mn(Se,n,{domain:e.cookieDomain,maxAgeDays:null!==(o=e.cookieMaxAgeDays)&&void 0!==o?o:730,sameSite:"Lax"}),yn(Se,n),null!=t)){const n=null!==(r=(()=>{const n=bn(Oe);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{yn(Oe,JSON.stringify(e))}catch(n){}}})(n,t,{cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays});const e=w();if(!e)return k("identify");const o=((n,t,e)=>{var o;const r=be("identify",e);return n&&(r.userId=n),r.traits=null!==(o=t)&&void 0!==o?o:{},r})(n,t,e);_().enqueue(o)}catch(n){}},alias(n,t){},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===vn(n)}catch(n){return!1}})(Se,{domain:n.cookieDomain}),_n(Se),_n(Oe)})({cookieDomain:a.cookieDomain}),((n={})=>{ve(An(),n)})({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),((n={})=>{xe({id:An(),lastActivity:Date.now()},n)})({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),l&&(n=>{_n(se(n))})(l)}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(){p=e(p),m.dispose(),g.dispose(),b.dispose(),h=null,s&&s.destroy(),s=null,d=!1,l=null,a=Object.assign({},Ee),u=Object.assign({},Ie)}}}();function je(n){return Pn({projectId:De.projectId,endpoint:De.endpoint,zaloQrLoginEnabled:De.isZaloQrLoginEnabled(),consentGranted:De.consentGranted},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)Ne(n,e);return e.length},e.__loaded=!0;for(const t of o)Ne(n,t)})(De);const Fe=Object.assign(De,{version:ze,name:Te,schemaVersion:me,loginWithZalo:je});export{Te as NAME,me as SCHEMA_VERSION,ze as VERSION,In as ZaloQrLoginError,Fe as default,je 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:_(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 p(n){return"regex"===n.mode?{mode:"regex",needle:n.value,re:_(n.value,!0)}:{mode:n.mode,needle:n.value.toLowerCase(),re:null}}function f(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:_(t,!1)}}function h(n,t){return"startsWith"===n.mode?0===t.indexOf(n.needle):!n.re||w(n.re,t)}const v=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,m=/\+?\d[\d\s().-]{7,}\d/g;function g(n){if(!n)return n;try{return n.replace(v,"[email]").replace(m,"[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 _(n,t){try{return!n||n.length>1e3?null:new RegExp(n,t?"i":"")}catch(n){return null}}function w(n,t){try{return n.test(t)}catch(n){return!1}}function x(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?p(i.destinationUrl):null,urlScope:r.urlScope?f(r.urlScope):null,dedupeWindowMs:M(c.dedupeWindowMs,M(t.dedupeWindowMs,500)),maxPerPageview:M(c.maxPerPageview,M(t.maxPerPageview,1/0)),samplingRate:O(M(c.samplingRate,M(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=S();function d(e){try{if(0!==e.button)return;const r=S();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&&!h(s.urlScope,u))continue;let d=null;for(let n=0;n<i.length;n++)if(A(s,i[n])){d=i[n];break}if(!d)continue;const p=s.rule.id;if((a.get(p)||0)>=s.maxPerPageview)return;const f=p+"#"+c(d),v=Date.now(),m=l.get(f);if(void 0!==m&&v-m<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;l.set(f,v),a.set(p,(a.get(p)||0)+1);const g=C(s.rule,d,e);return void n(()=>t.track("clicked",g))}}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 A(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&&w(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&&w(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 C(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=g(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]=g(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=g(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 S(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}function M(n,t){return"number"!=typeof n||isNaN(n)?t:n}function O(n){return n<0?0:n>1?1:n}const E="__cnvPatched";function I(n){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=z();function e(){try{const e=z();if(e===t)return;t=e,n(e)}catch(n){}}const o=history.pushState,r=history.replaceState,i=!0===o[E],c=!0===r[E];if(!i){function u(...n){o.apply(this,n),e()}u[E]=!0,history.pushState=u}if(!c){function s(...n){r.apply(this,n),e()}s[E]=!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[E]&&(history.pushState=o),!c&&history.replaceState[E]&&(history.replaceState=r)}catch(n){}}}function z(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}const N=["q","s","query","search","keyword"],D={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},j={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};const T=2147483e3,R="#6C5CE7",B="#FFFFFF";function F(){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 L(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 P(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 $(n){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(Math.trunc(n),0),2147483647):null}function U(n,t=20){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(n,0),2e3):t}function V(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 H(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:U(null==e?void 0:e.sideSpacing),bottomSpacingPx:U(null==e?void 0:e.bottomSpacing)}}function q(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 K(n){var t;(null!==(t=document.body)&&void 0!==t?t:document.documentElement).appendChild(n)}function Z(t,e){if("function"!=typeof MutationObserver)return()=>{};let o=0,r=!1;function i(){l.disconnect(),l.observe(document,{childList:!0}),document.documentElement&&l.observe(document.documentElement,{childList:!0}),document.body&&l.observe(document.body,{childList:!0})}function c(){r=!0,l.disconnect()}const l=new MutationObserver(()=>{r||(i(),!t.isConnected&&document.body&&(++o>5?c():(K(t),i(),e&&n(e))))});return i(),c}const G="cnv:panel:opened",W="cnv:panel:closed";function J(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&&P(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 Y(e,o){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{const{hostEl:e,shadow:r}=q("data-cnv-launcher",':host{all:initial;}.cnv-launcher-fab{display:inline-flex;align-items:center;gap:8px;height:48px;padding:0 18px;border:none;cursor:pointer;box-shadow:0 6px 18px rgba(0,0,0,.18);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:14px;font-weight:600;line-height:1;white-space:nowrap;transition:transform .18s cubic-bezier(.16,1,.3,1),box-shadow .18s ease;animation:cnv-fab-in .32s cubic-bezier(.16,1,.3,1);}.cnv-launcher-fab:hover{transform:translateY(-2px);box-shadow:0 10px 26px rgba(0,0,0,.24);}.cnv-launcher-fab:active{transform:translateY(0) scale(.96);}.cnv-launcher-fab__icon{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex-shrink:0;}.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{width:20px;height:20px;object-fit:contain;animation:cnv-fab-icon-in .28s cubic-bezier(.16,1,.3,1);}@keyframes cnv-fab-in{from{opacity:0;transform:translateY(10px) scale(.9);}to{opacity:1;transform:none;}}@keyframes cnv-fab-icon-in{from{opacity:0;transform:rotate(-90deg) scale(.4);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-launcher-fab,.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{animation:none !important;transition:none !important;}}'),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=L(e.backgroundColor,R),n.style.color=L(e.textColor,B),n.style.borderRadius=(n=>{switch(n){case"SQUARE":return"2px";case"SHAVED":return"8px";case"ROUNDED":return"16px";default:return"999px"}})(e.buttonShape),J(t,e,!1)})(i,c,o);let a=!1;const u=()=>((n,e,o,r,i)=>{try{const c=F();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}=H(r,c),s=r.useCustomZIndex?$(r.zIndex):null,d=r.addImportantRule?"important":"",p=(t,e)=>n.style.setProperty(t,e,d);p("position","fixed"),p("bottom",u+"px"),p("left","left"===l?a+"px":"auto"),p("right","right"===l?a+"px":"auto"),p("z-index",String(null!=s?s:T));const f=c?r.contentLayoutMobile:r.contentLayoutDesktop,h=!i&&"ICON_ONLY"!==f;e.style.display=i||"TEXT_ONLY"!==f?"inline-flex":"none",o.style.display=h?"inline":"none",h&&(o.textContent=(c?r.buttonTextMobile:r.buttonTextDesktop)||"")}catch(n){}})(e,c,l,o,a),s=t=>{a!==t&&(a=t,n(()=>{J(c,o,t),i.setAttribute("aria-label",t?"Đóng":"Launcher"),u()}))},d=()=>s(!0),p=()=>s(!1);window.addEventListener(G,d),window.addEventListener(W,p);const f=()=>{n(()=>window.dispatchEvent(new CustomEvent("cnv:launcher:click",{detail:{config:o}})))};i.addEventListener("click",f);let h=null;const v=()=>{n(()=>{K(e),h=Z(e,u),u()})};document.body?v():document.addEventListener("DOMContentLoaded",v,{once:!0});const m=t(()=>window.matchMedia("(max-width: 768px)"),null),g=()=>u(),b=m;m&&"function"==typeof m.addEventListener?m.addEventListener("change",g):m&&"function"==typeof b.addListener?b.addListener(g):window.addEventListener("resize",g);const y=I(u);return()=>{n(()=>{document.removeEventListener("DOMContentLoaded",v),i.removeEventListener("click",f),window.removeEventListener(G,d),window.removeEventListener(W,p),m&&"function"==typeof m.removeEventListener?m.removeEventListener("change",g):m&&"function"==typeof b.removeListener?b.removeListener(g):window.removeEventListener("resize",g),h&&h(),e.remove()}),n(y)}}catch(n){return()=>{}}}function Q(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 X=(n,t)=>{let e=n;const o=nn[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),p(),d(),h(n,t),e>=7&&f(n),null==c&&(c=m(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)},p=()=>{const n=tn.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}},f=n=>{const t=tn.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}},h=(n,t)=>{const e=tn.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=tn.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}}},m=(n,t,e)=>{const o=rn.getRSBlocks(n,t),r=cn();for(let t=0;t<e.length;t+=1){const o=e[t];r.put(o.getMode(),4),r.put(o.getLength(),tn.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=tn.getErrorCorrectPolynomial(u),d=on(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=ln(n);break;case"Alphanumeric":e=an(n);break;case"Byte":e=un(n);break;case"Kanji":e=sn(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=rn.getRSBlocks(n,o),e=cn();for(let t=0;t<l.length;t++){const o=l[t];e.put(o.getMode(),4),e.put(o.getLength(),tn.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=tn.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,p="";for(d="l"+n+",0 0,"+n+" -"+n+",0 0,-"+n+"z ",p+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',p+=r.scalable?"":' width="'+i+'px" height="'+i+'px"',p+=' viewBox="0 0 '+i+" "+i+'" ',p+=' preserveAspectRatio="xMinYMin meet"',p+=o.text||e.text?' role="img" aria-labelledby="'+g([o.id,e.id].join(" ").trim())+'"':"",p+=">",p+=o.text?'<title id="'+g(o.id)+'">'+g(o.text)+"</title>":"",p+=e.text?'<description id="'+g(e.id)+'">'+g(e.text)+"</description>":"",p+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',p+='<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,p+="M"+l+","+s+d);return p+='" stroke="transparent" fill="black"/>',p+="</svg>",p},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 fn(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+=g(e),r+='"'),r+="/>",r};const g=n=>{let t="";for(let e=0;e<n.length;e+=1){const o=n.charAt(e);switch(o){case"<":t+="&lt;";break;case">":t+="&gt;";break;case"&":t+="&amp;";break;case'"':t+="&quot;";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 p="";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+="█",p+=n<1&&r+1>=o?d[u]:s[u];p+="\n"}return t%2&&n>0?p.substring(0,p.length-t-1)+Array(t+1).join("▀"):p.substring(0,p.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 p="",f="";for(i=0;i<e;i+=1){for(l=Math.floor((i-o)/n),f="",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),f+=u?s:d;for(l=0;l<n;l+=1)p+=f+"\n"}return p.substring(0,p.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};X.stringToBytes=n=>{const t=[];for(let e=0;e<n.length;e+=1){const o=n.charCodeAt(e);t.push(255&o)}return t},X.createStringToBytes=(n,t)=>{const e=(()=>{const e=pn(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 nn={L:1,M:0,Q:3,H:2},tn=(()=>{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=on([1],0);for(let e=0;e<n;e+=1)t=t.multiply(on([1,en.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})(),en=(()=>{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]}}})(),on=(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]^=en.gexp(en.glog(o.getAt(e))+en.glog(n.getAt(r)));return on(t,0)},mod(n){if(o.getLength()-n.getLength()<0)return o;const t=en.glog(o.getAt(0))-en.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]^=en.gexp(en.glog(n.getAt(o))+t);return on(e,0).mod(n)}};return o},rn=(()=>{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 nn.L:return n[4*(t-1)+0];case nn.M:return n[4*(t-1)+1];case nn.Q:return n[4*(t-1)+2];case nn.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}}})(),cn=()=>{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},ln=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},an=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},un=n=>{const t=X.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)}}},sn=n=>{const t=X.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},dn=()=>{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},pn=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},fn=(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=dn(),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=dn();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 vn(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 mn(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,vn(n)===t}catch(n){return!1}}function gn(){if(!hn)return!1;try{const n="__cnv_probe__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch(n){return!1}}function bn(n){if(!gn())return null;try{return localStorage.getItem(n)}catch(n){return null}}function yn(n,t){if(!gn())return!1;try{return localStorage.setItem(n,t),!0}catch(n){return!1}}function _n(n){if(!gn())return!1;try{return localStorage.removeItem(n),!0}catch(n){return!1}}function wn(){if(!hn)return!1;try{const n="__cnv_probe__";return sessionStorage.setItem(n,"1"),sessionStorage.removeItem(n),!0}catch(n){return!1}}const xn="0123456789abcdef";function kn(n){return xn[n>>>4&15]+xn[15&n]}function An(){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,kn(n[0])+kn(n[1])+kn(n[2])+kn(n[3])+"-"+kn(n[4])+kn(n[5])+"-"+kn(n[6])+kn(n[7])+"-"+kn(n[8])+kn(n[9])+"-"+kn(n[10])+kn(n[11])+kn(n[12])+kn(n[13])+kn(n[14])+kn(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 Cn=/^[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 Sn(n){return"string"==typeof n&&Cn.test(n)}const Mn=8e3,On=3e4,En=/^(https:|zalo:)/i;class In 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 zn(n,t,e,o){return`${n}${t}?${new URLSearchParams(Object.assign({projectId:e},o)).toString()}`}function Nn(n,t){if(!n||!t)return()=>{};if(t.aborted)return n.abort(),()=>{};const e=()=>n.abort();return t.addEventListener("abort",e),()=>t.removeEventListener("abort",e)}function Dn(n){return{title:"string"==typeof n.title?n.title:void 0,description:"string"==typeof n.description?n.description:void 0,points:Rn(n.points),expPoints:Rn(n.expPoints),balanceAfter:Rn(n.balanceAfter),expBalanceAfter:Rn(n.expBalanceAfter),rankAfter:"string"==typeof n.rankAfter?n.rankAfter:void 0,createdAt:"string"==typeof n.createdAt?n.createdAt:void 0}}function jn(n){return{campaignId:Rn(n.campaignId),rewardId:Rn(n.rewardId),title:"string"==typeof n.title?n.title:void 0,imageUrl:"string"==typeof n.imageUrl?n.imageUrl:void 0,discountValue:"string"==typeof n.discountValue?n.discountValue:void 0,channelLabel:"string"==typeof n.channelLabel?n.channelLabel:void 0,channelIcon:"string"==typeof n.channelIcon?n.channelIcon:void 0,redeemPoints:Rn(n.redeemPoints),redeemRemain:Rn(n.redeemRemain),expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,stock:"boolean"==typeof n.stock?n.stock:void 0,burnOnUse:!0===n.burnOnUse}}function Tn(n,t){return n?"string"==typeof n.error&&n.error?n.error:t&&"string"==typeof n.code&&n.code?n.code:null:null}function Rn(n){return"number"==typeof n&&Number.isFinite(n)?n:void 0}function Bn(n){return{id:Rn(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:Rn(n.threshold),level:Rn(n.level),benefits:Array.isArray(n.benefits)?n.benefits.filter(n=>"string"==typeof n&&""!==n.trim()):[]}}function Fn(n){return{id:Rn(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:Rn(n.level),progressCurrent:Rn(n.progressCurrent),progressTarget:Rn(n.progressTarget),remaining:Rn(n.remaining),nextLevelName:"string"==typeof n.nextLevelName?n.nextLevelName:void 0,isHighestLevel:!0===n.isHighestLevel}}function Ln(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,channelLabel:"string"==typeof n.channelLabel?n.channelLabel:void 0,channelIcon:"string"==typeof n.channelIcon?n.channelIcon:void 0,expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,useRemain:"number"==typeof n.useRemain&&Number.isFinite(n.useRemain)?n.useRemain:void 0,redeemId:"number"==typeof n.redeemId&&Number.isFinite(n.redeemId)?n.redeemId:void 0,usedAt:"string"==typeof n.usedAt?n.usedAt:void 0,canUse:!0===n.canUse,burnOnUse:!0===n.burnOnUse}}function Pn(t,e){return Q(this,void 0,void 0,function*(){var o,r;if(!t.projectId||!t.endpoint)throw new In("not-initialized");if(!t.zaloQrLoginEnabled)throw new In("disabled");if(!t.consentGranted)throw new In("consent-required");const i={preferSse:null===(o=null==e?void 0:e.preferSse)||void 0===o||o,pollIntervalMs:null!==(r=null==e?void 0:e.pollIntervalMs)&&void 0!==r?r:2e3,onProgress:null==e?void 0:e.onProgress},c=t.projectId,l=t.endpoint,a=(()=>{const n="undefined"!=typeof crypto?crypto:void 0;if(n&&"function"==typeof n.getRandomValues)try{const t=new Uint8Array(24);n.getRandomValues(t);let e="";for(let n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(n){return}})(),u=yield function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;let i;try{i=yield fetch(zn(n,"/zalo-qr/session",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:o?o.signal:void 0})}catch(n){throw new In("network")}finally{r&&clearTimeout(r)}if(!i.ok){let n=null;if(403===i.status)try{const t=yield i.json();t&&"string"==typeof t.error&&(n=t.error)}catch(n){}throw new In(((n,t)=>401===n?"invalid-project-key":403===n?"origin_required"===t?"origin-required":"project-suspended":422===n?"zalo-login-not-configured":503===n?"zalo-login-unavailable":"network")(i.status,n))}return(n=>{const t=n;if(!t||"string"!=typeof t.sessionToken||!t.sessionToken||"string"!=typeof t.miniAppDeepLink||!En.test(t.miniAppDeepLink)||"number"!=typeof t.expiresInSeconds||!Number.isFinite(t.expiresInSeconds)||t.expiresInSeconds<=0)throw new In("network");return{sessionToken:t.sessionToken,miniAppDeepLink:t.miniAppDeepLink,expiresInSeconds:t.expiresInSeconds,miniAppKind:"CNV_SHARED"===t.miniAppKind?"CNV_SHARED":"SHOP"}})(yield i.json())})}(l,c,Object.assign(Object.assign(Object.assign({},(n=>{var t,e,o;const r={};try{const i=null===(t=n.getAnonymousId)||void 0===t?void 0:t.call(n);i&&(r.anonymousId=i);const c=null===(e=n.getSessionId)||void 0===e?void 0:e.call(n);c&&(r.sessionId=c);const l=null===(o=n.getAttribution)||void 0===o?void 0:o.call(n);l&&(r.attribution=l)}catch(n){}return r})(t)),a?{pollSecret:a}:{}),{supportsScanned:!0})),s=((t,e,o,r,i,c)=>{let l=!1,a=null,u=null,s=null,d=0,p=!1,f=null,h=null,v=null;const m=()=>{v&&(document.removeEventListener("visibilitychange",v),v=null),a&&(a.close(),a=null),null!==u&&(clearInterval(u),u=null),null!==s&&(clearTimeout(s),s=null),null!==f&&(clearTimeout(f),f=null)};return{promise:new Promise((g,b)=>{h=b;const y=n=>{l||(l=!0,m(),n())},_=n=>{d=n,null!==s&&clearTimeout(s),s=setTimeout(()=>{y(()=>b(new In("expired")))},n-Date.now())},w=t=>{if(l)return;const e=Rn(t),o=void 0!==e&&e>0&&e<=3600?e:void 0,r=void 0!==o?Date.now()+1e3*o:0;r>d&&_(r),p||(p=!0,n(()=>{var n;return null===(n=i.onProgress)||void 0===n?void 0:n.call(i,{stage:"scanned",expiresInSeconds:o})}))},x=n=>{"success"===n.status?y(()=>g((n=>({contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,panelSessionToken:n.panelSessionToken,panelSessionExp:n.panelSessionExp,panelSessionExpiresInMs:"number"==typeof n.panelSessionExpiresInMs?n.panelSessionExpiresInMs:void 0}))(n))):"denied"===n.status?y(()=>{return b(new In("consent_declined"===(t=n.deniedReason)?"consent-declined":"zalo_permission_denied"===t?"zalo-permission-denied":"underage_self_declared"===t?"underage-self-declared":"denied"));var t}):"expired"===n.status?y(()=>b(new In("expired"))):"blocked"===n.status?y(()=>{return b(new In("agent_registration_required"===(t=n.reason)?"agent-registration-required":"requester_not_ready"===t?"requester-not-ready":"login-blocked"));var t}):"pending"===n.status&&!0===n.scanned&&w(n.expiresInSeconds)},k=()=>{fetch(zn(t,"/zalo-qr/status",e,{sessionToken:o}),{method:"GET",credentials:"omit",mode:"cors",headers:c?{"X-Poll-Secret":c}:void 0}).then(n=>404===n.status?x({status:"expired"}):n.ok?n.json().then(n=>x(n)):void 0).catch(()=>{})},A=()=>{null!==u||l||(u=setInterval(k,i.pollIntervalMs))};if("undefined"!=typeof document&&(v=()=>{"visible"===document.visibilityState&&k()},document.addEventListener("visibilitychange",v)),i.preferSse&&"undefined"!=typeof EventSource)try{a=new EventSource(zn(t,"/zalo-qr/stream",e,c?{sessionToken:o,pollSecret:c}:{sessionToken:o})),a.addEventListener("success",n=>{try{x(JSON.parse(n.data))}catch(n){}});for(const n of["denied","blocked"])a.addEventListener(n,t=>{let e=null;try{e=JSON.parse(t.data)}catch(n){}x(Object.assign(Object.assign({},e),{status:n}))});a.addEventListener("scanned",n=>{let t=null;try{t=JSON.parse(n.data)}catch(n){}w(null==t?void 0:t.expiresInSeconds)}),a.onerror=()=>{null!==f||l||(f=setTimeout(()=>{f=null,l||(a&&(a.close(),a=null),A())},3e3))}}catch(n){A()}else A();_(Date.now()+1e3*r)}),cancel(){l||(l=!0,m(),null==h||h(new In("cancelled")))}}})(l,c,u.sessionToken,u.expiresInSeconds,i,a);return{sessionToken:u.sessionToken,qrPayload:u.miniAppDeepLink,expiresInSeconds:u.expiresInSeconds,miniAppKind:u.miniAppKind,result:s.promise,cancel:s.cancel,retry(){return s.cancel(),Pn(t,e)}}})}const $n="cnv:launcher:click",Un="cnv:panel:identify",Vn="cnv-panel-card--leaving";function Hn(n){return"cnv_panel_session_"+(null!=n?n:"default")}function qn(n){const e=bn(Hn(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 Kn(n,t){yn(Hn(n),JSON.stringify(t))}function Zn(n){_n(Hn(n))}function Gn(n){return"SQUARE"===n?"0px":"12px"}function Wn(n){const t=n.colors;return L(null==t?void 0:t.iconColor,L(null==t?void 0:t.buttonBg,L(null==t?void 0:t.bannerBg,R)))}function Jn(n,t){n.style.background=V(t,.12),n.style.color=t}const Yn='<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"/>',Qn='<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',Xn='<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"/>',nt='<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"/>',tt='<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"/>',et='<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.8"/><path d="M12 10.6v6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="7.6" r="1.1" fill="currentColor"/>',ot='<path d="M5 13l4.5 4.5L19 8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',rt='<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"/>',it='<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"/>',ct='<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"/>',lt="#1E9E5B",at="rgba(30, 158, 91, 0.12)",ut="#D64545",st="rgba(214, 69, 69, 0.10)",dt="#6B7280",pt="rgba(107, 114, 128, 0.12)";function ft(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 ht(n,t){const e=document.createElement("div");return e.className="cnv-panel-chip",Jn(e,t),e.appendChild(ft(n,14)),e}function vt(n,t){const e=document.createElement("span");return e.className="cnv-panel-badge",Jn(e,t),e.textContent=n,e}const mt={POINTS:{label:"Điểm thưởng",icon:Xn},REFERRAL:{label:"Giới thiệu bạn bè",icon:nt},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"/>'}},gt={rewards:it,earn:rt,redeem:Yn,history:tt},bt={ORDER:ct,STAR:Xn,GIFT:Yn,USERS:nt,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:rt,CHECK:ot},yt={store:'<path d="M2.8 9.4 5 4.9h14l2.2 4.5ZM4.4 9.4v10.2h15.2V9.4M9.8 19.6v-5.7h4.4v5.7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',web:'<circle cx="12" cy="12" r="8.4" stroke="currentColor" stroke-width="1.8"/><ellipse cx="12" cy="12" rx="3.5" ry="8.4" stroke="currentColor" stroke-width="1.8"/><path d="M3.6 12h16.8" stroke="currentColor" stroke-width="1.8"/>',zalo:'<path d="M5.5 4h13A2.5 2.5 0 0 1 21 6.5v8a2.5 2.5 0 0 1-2.5 2.5H11l-4.5 3.5V17h-1A2.5 2.5 0 0 1 3 14.5v-8A2.5 2.5 0 0 1 5.5 4Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M9 8h6l-6 5.5h6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>',app:'<rect x="6.5" y="2.6" width="11" height="18.8" rx="2.2" stroke="currentColor" stroke-width="1.8"/><path d="M10.6 17.8h2.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',bag:ct},_t={earn:{label:"Cách kiếm thêm điểm",icon:rt},redeem:{label:"Cách đổi điểm",icon:Yn}},wt="cnv-panel-reward__title--full",xt="Tham gia ngay",kt=[[_t.earn.label,"earn"],[_t.redeem.label,"redeem"]],At=/\{\{\s*TenKhachHang\s*\}\}/gi,Ct=/[\u0000-\u001F\u007F\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2066-\u2069\uFEFF]/g;function St(n){return"number"==typeof n.campaignId&&n.campaignId>0?Object.assign({campaignId:n.campaignId},"number"==typeof n.redeemPoints&&n.redeemPoints>0?{redeemPoints:n.redeemPoints}:{}):"number"==typeof n.rewardId&&n.rewardId>0?{rewardId:n.rewardId}:null}function Mt(n,e){const o=(n=>{if("string"!=typeof n)return"bạn";const e=t(()=>n.normalize("NFC"),n).replace(Ct," ").replace(/\s+/g," ").trim();if(!e)return"bạn";const o=Array.from(e);return o.length<=24?e:o.slice(0,24).join("").trimEnd()+"…"})(e);return(n||"").replace(At,()=>o)}const Ot=[{key:"redeem",label:"Đổi ưu đãi"},{key:"owned",label:"Ưu đãi của bạn"}],Et={message:'Lượt đổi đã được ghi nhận nhưng mã chưa phát kịp. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},It={message:'Điểm đã được trừ và ưu đãi đã là của bạn, chỉ chưa có mã. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},zt={INSUFFICIENT_POINTS:{message:"Bạn không đủ điểm để đổi ưu đãi này.",action:"other"},REDEMPTION_LIMIT_EXCEEDED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},REWARD_OUT_OF_STOCK:{message:"Ưu đãi này vừa hết. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},PRICE_CHANGED:{message:"Giá đổi của ưu đãi vừa thay đổi. Bạn tải lại danh sách rồi đổi lại nhé.",action:"other"},POINT_HOLD_FAILED:{message:"Chưa trừ được điểm của bạn. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_REFUNDED:{message:"Đổi ưu đãi không thành công, điểm của bạn đã được hoàn lại. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_STUCK:{message:"Đổi ưu đãi không thành công. Điểm của bạn đang được kiểm tra, bạn liên hệ shop nhé.",action:"none"},CAMPAIGN_NOT_STARTED:{message:"Ưu đãi chưa tới thời gian áp dụng. Bạn quay lại sau nhé.",action:"other"},REWARD_NOT_PUBLISHED:{message:"Ưu đãi chưa được mở. Bạn quay lại sau nhé.",action:"other"},NOT_POINT_CAMPAIGN:{message:"Ưu đãi này không đổi bằng điểm. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_IN_PROGRESS:{message:'Lượt đổi của bạn đang được xử lý. Bạn đợi một chút rồi kiểm tra ở tab "Ưu đãi của bạn" nhé.',action:"owned"},IDEMPOTENCY_UNAVAILABLE:{message:"Hệ thống đang bận, chưa đổi được. Bạn thử lại sau ít phút nhé.",action:"other"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này. Bạn tải lại danh sách nhé.",action:"other"},CAMPAIGN_INACTIVE:{message:"Ưu đãi này vừa được shop tạm dừng.",action:"other"},CAMPAIGN_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng. Bạn chọn ưu đãi khác nhé.",action:"other"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn chọn ưu đãi khác nhé.",action:"other"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_UNAVAILABLE:{message:"Ưu đãi này hiện không khả dụng.",action:"other"},NOT_SELF_REDEEMABLE:{message:"Ưu đãi này không tự đổi được. Bạn liên hệ shop nhé.",action:"other"},NOT_FREE:{message:"Ưu đãi này không phải ưu đãi tặng. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_LIMIT_REACHED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},ALREADY_REDEEMED:{message:'Bạn đã nhận ưu đãi này rồi. Mã nằm ở tab "Ưu đãi của bạn".',action:"owned"},CODE_NOT_ISSUED:{message:"Đã ghi nhận lượt đổi nhưng mã chưa phát kịp. Bạn thử lại nhé.",action:"retry"},NOT_REDEEMED:{message:"Bạn chưa đổi ưu đãi này.",action:"other"},LOYALTY_SERVICE_UNAVAILABLE:{message:"Hệ thống điểm đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},VENDOR_ERROR:{message:"Nhà cung cấp ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},MISSING_VOUCHER:Et,MISSING_SERIAL:Et,INVALID_REQUEST:{message:"Ưu đãi này đang lỗi dữ liệu nên không đổi được. Bạn chọn ưu đãi khác nhé.",action:"other"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"none"},REDEEM_FAILED:{message:"Đổi ưu đãi không thành công. Bạn thử lại sau ít phút nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry",retryWithNewKey:!0},SESSION_CHECK_UNAVAILABLE:{message:"Chưa kiểm tra được phiên đăng nhập của bạn. Bạn thử lại sau ít phút nhé.",action:"retry"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"none"},UNCONFIRMED:{message:'Chưa xác nhận được kết quả. Điểm có thể đã được trừ — bạn kiểm tra ở tab "Ưu đãi của bạn" trước khi đổi lại nhé.',action:"owned",heading:"Chưa xác nhận được",tone:"neutral"}},Nt={CODE_NOT_ISSUED:It,MISSING_VOUCHER:It,MISSING_SERIAL:It,OUT_OF_CODES:{message:"Ưu đãi đã hết mã, điểm của bạn đã bị trừ. Bạn liên hệ shop để được hỗ trợ nhé.",action:"none"}},Dt={message:"Không đổi được ưu đãi lúc này. Bạn thử lại sau nhé.",action:"retry"},jt={USE_LIMIT_REACHED:{message:"Ưu đãi này đã hết lượt sử dụng.",action:"back"},NOT_REDEEMED:{message:"Ưu đãi này không còn trong danh sách của bạn.",action:"back"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này nữa.",action:"back"},CODE_NOT_ISSUED:{message:"Chưa lấy được mã cho ưu đãi này. Bạn thử lại nhé.",action:"retry"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn liên hệ shop nhé.",action:"back"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn liên hệ shop nhé.",action:"back"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng để lấy mã. Bạn liên hệ shop nhé.",action:"back"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn liên hệ shop nhé.",action:"back"},UNCONFIRMED:{message:"Chưa xác nhận được. Bạn thử lại nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},SESSION_CHECK_UNAVAILABLE:{message:"Hệ thống đang bận, chưa lấy được mã. Bạn thử lại sau ít phút nhé.",action:"retry"},USE_FAILED:{message:"Chưa dùng được ưu đãi này. Bạn thử lại sau ít phút nhé.",action:"retry"},INVALID_REQUEST:{message:"Yêu cầu không hợp lệ. Bạn quay lại danh sách rồi thử lại nhé.",action:"back"},INVALID_REWARD:{message:"Không xác định được ưu đãi cần dùng. Bạn quay lại danh sách nhé.",action:"back"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"back"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"back"}},Tt={message:"Chưa lấy được mã lúc này. Bạn thử lại sau nhé.",action:"retry"},Rt={other:"Chọn ưu đãi khác",retry:"Thử lại",owned:"Kiểm tra ưu đãi của bạn",none:""};function Bt(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=Gn(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 Ft(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 Lt(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 Pt(n){const t=document.createElement("div");t.className="cnv-panel-vstack";const e=document.createElement("div");e.className="cnv-panel-zalo__qr",e.appendChild(Ft(180,180)),Lt(e,n),t.appendChild(e);const o=document.createElement("div");return o.className="cnv-panel-vstack",o.style.gap="6px",o.append(Ft(240,14),Ft(160,14)),t.appendChild(o),t.appendChild(Ft(120,14)),t}function $t(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(ft(n,20));const c=document.createElement("div");return c.className="cnv-panel-zalo__title",c.textContent=o,r.append(i,c),r}function Ut(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 Vt(n){return"number"==typeof n.useRemain&&n.useRemain>0}function Ht(n){if(!n.usedAt)return null;if(Vt(n))return null;const t=Kt(n.usedAt);return t?`Đã dùng ${t}`:"Đã dùng"}function qt(n){const t=n.useRemain;return"number"!=typeof t||t<=0||t<=1&&!n.usedAt?null:`Còn ${t} lượt`}function Kt(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()}`}function Zt(n){return n instanceof In?n.reason:null}const Gt={denied:"Đã huỷ đăng nhập","consent-declined":"Bạn đã huỷ chia sẻ thông tin","zalo-permission-denied":"Chưa cho phép chia sẻ số điện thoại","underage-self-declared":"Chưa thể đăng nhập","agent-registration-required":"Cần đăng ký đại lý","requester-not-ready":"Shop chưa sẵn sàng"};function Wt(n,t){switch(Zt(n)){case"disabled":case"zalo-login-not-configured":return"Đăng nhập bằng Zalo hiện đang tắt.";case"zalo-login-unavailable":return"Đăng nhập bằng Zalo đang tạm gián đoạn. Bạn thử lại sau ít phút nhé.";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"Bạn có thể thử lại bất cứ lúc nào.";case"consent-declined":return"Shop không nhận được thông tin nào. Bạn có thể thử lại bất cứ lúc nào.";case"zalo-permission-denied":return"Bạn cần cho phép Zalo chia sẻ số điện thoại để đăng nhập.";case"underage-self-declared":return"Người dưới 16 tuổi cần có sự đồng ý của cha mẹ hoặc người giám hộ.";case"agent-registration-required":return"CNV_SHARED"===t?"Shop yêu cầu đăng ký đại lý trước khi đăng nhập. Bạn liên hệ shop để được hướng dẫn nhé.":"Bạn mở Mini App của shop để đăng ký đại lý, được duyệt rồi thì quét lại mã này nhé.";case"requester-not-ready":return"Đăng nhập bằng Zalo chưa dùng được ở website này. Bạn quay lại sau nhé.";case"login-blocked":return"Shop chưa cho phép tài khoản này đăng nhập.";case"cancelled":return"Đã huỷ đăng nhập.";default:return"Vui lòng thử lại giúp mình nhé."}}function Jt(o,r){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{let i,c,l,a=null,u=null,s=null,d=null,p=null,f=null,h=null,v=null,m=null,g=null,b=null,y=null,_=!1,w=null,x=null,k=!1,A=!1,C=!1,S=[],M=0,O=!1,E=null,I=null,z=null,N=!1,D=0,j=[],U=0,G=null,W=!1,J=!1,Y=Ot[0].key,nn=[],tn=0,en=0,on=!1,rn=null,cn=null,ln=!1,an=0,un=null,sn=null;function dn(t){const e="owned"===t?un:sn;e&&("owned"===t?un=null:sn=null,n(()=>e.abort()))}function pn(){return"undefined"!=typeof AbortController?new AbortController:null}let fn=null,hn=!1,vn=null,mn=0,gn=0,bn=0,yn=null,_n=null,wn=0,xn=null;const kn=n=>{"Escape"===n.key&&ho()};function Cn(n){return!k||n!==gn}function Sn(n,e){return t(()=>{const t=new CustomEvent(n,{detail:{action:e},cancelable:!0});return window.dispatchEvent(t),t.defaultPrevented},!1)}function Mn(n){Sn("cnv:panel:cta-click",n)}function On(n){return()=>{_&&n()}}function En(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=gt[t];if(i){const n=ft(i,20);n.style.color=Wn(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(ft(Qn,12,"cnv-panel-icon--chevron")),o.addEventListener("click",On(()=>{Sn("cnv:panel:menu-click",t)||("rewards"===t?(A=!0,Y=Ot[0].key,fn=null,Qe(),xe(),Hn()):"history"===t?(C=!0,Qe(),Me(),S.length||(M=0,Se())):_t[t]&&(E=t,Qe(),De()))})),o}function In(){var n,t,e,o;const i=Bt(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=Gn(null===(n=r.shapes)||void 0===n?void 0:n.button),u.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,R),u.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,B),u.appendChild(ft(Yn,15)),u.appendChild(document.createTextNode(((null==c?void 0:c.createAccountButtonText)||"").trim()||xt)),u.addEventListener("click",On(()=>{Mn("create-account"),uo()})),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=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,R),n.appendChild(document.createTextNode(s)),n.appendChild(ft(Qn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",On(()=>{Mn("sign-in"),uo()})),i.appendChild(n)}return i}function zn(){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=Gn(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 Nn(){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=Gn(null===(n=r.shapes)||void 0===n?void 0:n.button),a.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,R),a.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,B),a.appendChild(ft(Yn,15)),a.appendChild(document.createTextNode(((null==i?void 0:i.createAccountButtonText)||"").trim()||xt)),a.addEventListener("click",On(()=>{Mn("create-account"),uo()})),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=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,R),n.appendChild(document.createTextNode(u)),n.appendChild(ft(Qn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",On(()=>{Mn("sign-in"),uo()})),l.appendChild(n)}return l}function Dn(){var n;return null!==(n=null==z?void 0:z.points)&&void 0!==n?n:null==w?void 0:w.points}function jn(){return"redeem"===Y?null!==fn:null!==cn||null!==rn}function Tn(){A&&!jn()&&xe()}function Rn(n=!1){if(!(null==w?void 0:w.isMember)||N)return;if(!n&&z&&Date.now()-D<3e4)return;const t=qn(o.projectId);if(!t)return;N=!0,dn("owned");const e=pn();un=e,_&&We(),Tn(),o.fetchRewardsSummary(t.token,1,e?e.signal:void 0).then(n=>{if(N=!1,!e||!e.signal.aborted){if(!n)return _&&We(),void Tn();z=n,D=Date.now(),j=n.rewards.slice(),U=1,_&&We(),Tn()}}).catch(()=>{N=!1,_&&We(),Tn()})}function Bn(){return(Array.isArray(r.sections)?r.sections:[]).some(n=>"VIP"===n.type&&n.enabled)}function Fn(){const n=null==z?void 0:z.rewardsAvailableCount;return"number"==typeof n&&U?Math.max(0,n-j.length):0}function Ln(){if(J||N||!Fn())return;const n=qn(o.projectId);if(!n)return;const t=U+1;J=!0,A&&xe(),o.fetchRewardsSummary(n.token,t).then(n=>{J=!1,U=t,n&&(n.rewards.length&&(j=j.concat(n.rewards)),"number"==typeof n.rewardsAvailableCount&&z&&(z=Object.assign(Object.assign({},z),{rewardsAvailableCount:n.rewardsAvailableCount}))),A&&xe()}).catch(()=>{J=!1,A&&xe()})}function Pn(n){if(Y===n)return;const t=Y;Y=n,fn=null,rn=null,Yt(),dn(t),Qe(),xe(),Hn(!0)}function Hn(n=!1){if("redeem"===Y){if(!n&&nn.length&&Date.now()-en<3e4)return;return tn=0,nn=[],void Xn()}Rn(n)}function Xn(){if(on)return;const n=qn(o.projectId);if(!n)return;const t=tn+1;on=!0,dn("redeem");const e=pn();sn=e,A&&xe(),o.fetchRedeemableRewards(n.token,t,e?e.signal:void 0).then(n=>{on=!1,tn=t,n&&(1===t&&(en=Date.now()),"number"==typeof n.total&&(c=n.total),"number"==typeof n.points&&(l=n.points),n.rewards.length&&(nn=nn.concat(n.rewards))),A&&xe()}).catch(()=>{on=!1,A&&xe()})}function nt(){return null!=l?l:Dn()}function rt(){return null!==qn(o.projectId)}function ct(n,t,e){const o=document.createElement("div");o.className="cnv-panel-reward__meta",o.textContent=e,n.appendChild(o);const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn cnv-panel-reward__more",r.textContent="Đăng nhập bằng Zalo",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",On(uo)),n.appendChild(r)}function At(n,t=!1){const e=St(n);if(hn||null===e)return;const r=qn(o.projectId);if(!r)return;if(Sn("cnv:panel:redeem-click","redeem-confirm"))return;const i=t&&vn?vn:An();vn=i;const c=++mn;hn=!0,fn={kind:"confirm",item:n},xe(),o.redeemReward(r.token,e,i).then(t=>{var e;Ct(c)&&(hn=!1),t.ok&&(vn=null,e=t.result,Qt(),l="number"==typeof e.pointsRemaining?e.pointsRemaining:void 0,Rn()),A&&Ct(c)&&(fn=t.ok?{kind:"success",item:n,result:t.result}:{kind:"error",code:t.code,item:n},xe())}).catch(()=>{Ct(c)&&(hn=!1),A&&Ct(c)&&(Qt(),fn={kind:"error",code:"UNCONFIRMED",item:n},xe())})}function Ct(n){return n===mn}function Et(n){const t=n.redeemId;if(ln||"number"!=typeof t||t<=0)return;const e=qn(o.projectId);if(!e)return;const r=++an;ln=!0,cn={kind:"confirm",item:n},xe(),o.useReward(e.token,t).then(e=>{const o=e.ok?It(t,n,e.result):null;r===an&&(ln=!1),A&&r===an&&(o?(cn=null,rn=o):e.ok||(cn={kind:"error",code:e.code,item:n}),Qe(),xe())}).catch(()=>{r===an&&(ln=!1),A&&r===an&&(cn={kind:"error",code:"UNCONFIRMED",item:n},xe())})}function It(n,t,e){const o=j.findIndex(t=>t.redeemId===n),r=o>=0?j[o]:t,i="number"==typeof e.useRemain?e.useRemain:0,c=Object.assign(Object.assign({},r),{code:e.code,usedAt:e.usedAt||r.usedAt,expiredAt:e.expiredAt||r.expiredAt,useRemain:i,canUse:!0===r.burnOnUse&&"number"==typeof i&&i>0});return o>=0&&(j[o]=c),c}function Jt(){fn=null,rn=null,hn=!1,mn++,Yt()}function Yt(){cn=null,ln=!1,an++}function Qt(){z=null,D=0,j=[],U=0,S=[],i=void 0,M=0,nn=[],c=void 0,tn=0,en=0}function Xt(n,t,e=!1){if(!n.channelLabel)return null;const o=document.createElement("div");o.className=e?"cnv-panel-reward__channel cnv-panel-reward__channel--center":"cnv-panel-reward__channel",o.style.color="DARK"===r.theme?"rgba(255,255,255,.72)":"rgba(24,28,50,.66)";const i="string"==typeof n.channelIcon?yt[n.channelIcon]:void 0;if("string"==typeof i){const n=ft(i,14);n.style.color=t,o.appendChild(n)}const c=document.createElement("span");return c.textContent=n.channelLabel,o.appendChild(c),o}function ne(n,t){const e="DARK"===r.theme,o=document.createElement("div");o.className="cnv-panel-reward",o.style.setProperty("--cnv-tk-bg",e?"rgba(255,255,255,.04)":"#FFFFFF"),o.style.setProperty("--cnv-tk-line",e?"rgba(255,255,255,.14)":"#E4E6EF"),o.style.setProperty("--cnv-tk-dash",e?"rgba(255,255,255,.24)":"#D1D3E0"),o.style.setProperty("--cnv-tk-hole",e?"#3F4254":"#FFFFFF"),o.appendChild(te(n,t));const i=document.createElement("div");i.className="cnv-panel-ticket__cut";const c=document.createElement("span");c.className="cnv-panel-ticket__hole cnv-panel-ticket__hole--top";const l=document.createElement("span");l.className="cnv-panel-ticket__hole cnv-panel-ticket__hole--bottom",i.append(c,l),o.appendChild(i);const a=document.createElement("div");return a.className="cnv-panel-reward__main",o.appendChild(a),{row:o,main:a}}function te(n,t){var e,o;const i=t?"DARK"===r.theme?"rgba(255,255,255,.16)":"#C4C6D0":L(null===(e=r.colors)||void 0===e?void 0:e.buttonBg,R),c=document.createElement("div");c.className="cnv-panel-ticket__stub",c.style.backgroundColor=i,c.style.color=t?"#FFFFFF":L(null===(o=r.colors)||void 0===o?void 0:o.buttonFont,B);const l=document.createElement("div");l.className="cnv-panel-ticket__badge",l.style.color=t?"#A1A5B7":i;const a="string"==typeof n.channelIcon?n.channelIcon:"",u="zalo"===a?'<text x="12" y="16" text-anchor="middle" font-size="11" font-weight="800" textLength="23" lengthAdjust="spacingAndGlyphs" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Arial,sans-serif" fill="currentColor">Zalo</text>':yt[a],s="string"==typeof u?u:it,d=()=>{l.textContent="",l.appendChild(ft(s,26))};if(P(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",d),l.appendChild(t)}else d();if(c.appendChild(l),n.channelLabel){const t=document.createElement("div");t.className="cnv-panel-ticket__label",t.textContent=n.channelLabel,c.appendChild(t)}return c}function ee(n,t){const e=Ht(n),{row:o,main:r}=ne(n,null!==e),i=qt(n);if(n.discountValue||i||e){const o=document.createElement("div");if(o.className="cnv-panel-reward__tags",e){const n=document.createElement("span");n.className="cnv-panel-reward__uses",n.textContent=e,o.appendChild(n)}if(n.discountValue){const e=document.createElement("span");e.className="cnv-panel-reward__value",Jn(e,t),e.textContent=n.discountValue,o.appendChild(e)}if(i){const n=document.createElement("span");n.className="cnv-panel-reward__uses",n.textContent=i,o.appendChild(n)}r.appendChild(o)}r.appendChild(he(n.title||"Ưu đãi"));const c=Kt(n.expiredAt);if(c){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${c}`,r.appendChild(n)}if(n.code||n.canUse){const e=document.createElement("div");e.className="cnv-panel-reward__foot";const o=document.createElement("button");o.type="button",o.className="cnv-panel-zalo__btn cnv-panel-reward__cta cnv-panel-reward__show",o.textContent=n.canUse?"Sử dụng":"Xem mã",o.style.borderColor=t,o.style.color=t,o.addEventListener("click",On(()=>{if(!n.canUse)return rn=n,Qe(),void xe();oe(n)})),e.appendChild(o),r.appendChild(e)}return o}function oe(n){if(n.burnOnUse)return cn={kind:"confirm",item:n},Qe(),void xe();Et(n)}function re(n,t,e){const o=$t(ln?tt:Yn,ln?dt:t,ln?pt:V(t,.12),e.title||"Ưu đãi"),r=document.createElement("div");r.className="cnv-panel-zalo__status";const i=null!=e.usedAt&&Vt(e);r.textContent=ln?"Đang lấy mã…":i?`Bạn còn ${e.useRemain} lượt dùng. Mã mới sẽ được cấp và đánh dấu đã dùng ngay. Tiếp tục?`:"Mã sẽ không còn hiệu lực sau khi ấn dùng ngay. Bạn có chắc muốn dùng ngay không?",o.appendChild(r),n.appendChild(o);const c=document.createElement("div");c.className="cnv-panel-redeem__actions";const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent="Hủy",l.disabled=ln,ln||l.addEventListener("click",On(()=>{cn=null,Qe(),xe()}));const a=document.createElement("button");a.type="button",a.className="cnv-panel-zalo__btn",a.textContent=ln?"Đang xử lý…":"Dùng ngay",a.disabled=ln,ln||(a.style.borderColor=t,a.style.color=t,a.addEventListener("click",On(()=>Et(e)))),c.append(l,a),n.appendChild(c)}function ie(n,t,e,o){const r=o&&jt[o]||Tt,i="UNCONFIRMED"===o,c=$t(i?tt:Yn,i?dt:ut,i?pt:st,i?"Chưa xác nhận được":"Chưa dùng được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,c.appendChild(n)}const l=document.createElement("div");l.className="cnv-panel-zalo__status",l.textContent=r.message,l.setAttribute("role","alert"),c.appendChild(l),n.appendChild(c);const a=document.createElement("div");a.className="cnv-panel-redeem__actions";const u=document.createElement("button");if(u.type="button",u.className="cnv-panel-zalo__btn",u.textContent="Về danh sách",u.addEventListener("click",On(()=>{cn=null,Qe(),xe()})),a.appendChild(u),"retry"===r.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Thử lại",n.style.borderColor=t,n.style.color=t,n.addEventListener("click",On(()=>Et(e))),a.appendChild(n)}n.appendChild(a)}function ce(n,t){const e=document.createElement("button");return e.type="button",e.className="cnv-panel-zalo__btn",e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.addEventListener("click",On(()=>{e.disabled||(e.disabled=!0,function(n){return Q(this,void 0,void 0,function*(){if(!n)return!1;try{if(navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return yield navigator.clipboard.writeText(n),!0}catch(n){}let t=null;try{return t=document.createElement("textarea"),t.value=n,t.setAttribute("readonly",""),t.style.cssText="position:fixed;top:-1000px;left:-1000px;opacity:0;pointer-events:none;",document.body.appendChild(t),t.select(),t.setSelectionRange(0,n.length),document.execCommand("copy")}catch(n){return!1}finally{t&&t.parentNode&&t.parentNode.removeChild(t)}})}(n).then(n=>{e.isConnected&&(e.textContent=n?"Đã chép":"Không chép được",e.style.borderColor=n?lt:t,e.style.color=n?lt:t,window.setTimeout(()=>{e.isConnected&&(e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.disabled=!1)},1600))}))})),e}function le(n,t,e){const o=$t(Yn,t,V(t,.12),e.title||"Ưu đãi");if(e.discountValue){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.discountValue,o.appendChild(n)}if(e.code){const n=document.createElement("div");n.className="cnv-panel-reward__code cnv-panel-reward__code--big",n.textContent=e.code,o.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Bấm "Dùng ngay" để hiện mã.',o.appendChild(n)}const r=Ht(e);if(r){const n=document.createElement("span");n.className="cnv-panel-reward__uses",n.textContent=r,o.appendChild(n)}const i=Xt(e,t,!0);i&&o.appendChild(i);const c=[],l=Kt(e.expiredAt);l&&c.push(`HSD ${l}`);const a=qt(e);if(a&&c.push(a),c.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=c.join(" · "),o.appendChild(n)}if(n.appendChild(o),e.canUse){const o=document.createElement("div");o.className="cnv-panel-redeem__actions";const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn",r.textContent=e.usedAt?"Dùng lượt tiếp":"Dùng ngay",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",On(()=>{rn=null,oe(e)})),o.appendChild(r),n.appendChild(o)}const u=document.createElement("div");u.className="cnv-panel-redeem__actions",e.code&&u.appendChild(ce(e.code,t));const s=document.createElement("button");s.type="button",s.className="cnv-panel-zalo__btn",s.textContent="Quay lại",s.addEventListener("click",On(()=>{rn=null,Qe(),xe()})),u.appendChild(s),n.appendChild(u)}function ae(n){if("owned"!==n.key)return n.label;const t=null!==(e=null==z?void 0:z.rewardsAvailableCount)&&void 0!==e?e:null==w?void 0:w.rewardsAvailableCount;var e;return"number"==typeof t&&Number.isFinite(t)&&t>0?`${n.label} (${t.toLocaleString("vi-VN")})`:n.label}function ue(n){const t=document.createElement("div");return t.className="cnv-panel-rtabs",t.setAttribute("role","tablist"),Ot.forEach(e=>{const o=e.key===Y,r=document.createElement("button");r.type="button",r.className="cnv-panel-rtab"+(o?" cnv-panel-rtab--on":""),r.setAttribute("role","tab"),r.setAttribute("aria-selected",o?"true":"false"),r.textContent=ae(e),o&&(r.style.borderBottomColor=n,r.style.color=n),r.addEventListener("click",On(()=>Pn(e.key))),t.appendChild(r)}),t}function se(n){return n.toLocaleString("vi-VN")+" điểm"}function de(n){return n>0?se(n):"Miễn phí"}function pe(n,t,e){t.length>15?n.style.fontSize=Math.round(.62*e)+"px":t.length>11&&(n.style.fontSize=Math.round(.77*e)+"px")}function fe(n,t){const e=document.createElement("div");e.className="cnv-panel-balance";const o=document.createElement("div");o.className="cnv-panel-balance__label",o.textContent="Điểm của bạn";const r=document.createElement("div");r.className="cnv-panel-balance__row";const i=document.createElement("div");i.className="cnv-panel-balance__num",i.style.color=t;const c=n.toLocaleString("vi-VN");i.textContent=c,pe(i,c,26);const l=document.createElement("div");return l.className="cnv-panel-balance__unit",l.textContent="điểm",r.append(i,l),e.append(o,r),e}function he(n){const t=document.createElement("div");t.className="cnv-panel-reward__name";const e=document.createElement("div");e.className="cnv-panel-reward__title",e.textContent=n,e.title=n;const o=document.createElement("button");return o.type="button",o.className="cnv-panel-reward__info",o.setAttribute("aria-label","Xem đầy đủ tên ưu đãi"),o.appendChild(ft(et,14)),o.addEventListener("click",()=>{e.classList.toggle(wt)}),t.append(e,o),t}function ve(n){if(null===St(n)||"number"!=typeof n.redeemPoints)return"Chưa thể đổi ưu đãi này";if(!1===n.stock)return"Đã hết hàng";if("number"==typeof n.redeemRemain&&n.redeemRemain<=0)return"Bạn đã đạt giới hạn đổi";const t=nt();return"number"==typeof t&&t<n.redeemPoints?`Cần thêm ${se(n.redeemPoints-t)}`:null}function me(n,t){const e=ve(n),{row:o,main:r}=ne(n,null!==e);if(n.discountValue){const e=document.createElement("div");e.className="cnv-panel-reward__tags";const o=document.createElement("span");o.className="cnv-panel-reward__value",Jn(o,t),o.textContent=n.discountValue,e.appendChild(o),r.appendChild(e)}r.appendChild(he(n.title||"Ưu đãi"));const i=Kt(n.expiredAt);if(i){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${i}`,r.appendChild(n)}if(e){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=e,r.appendChild(n)}const c=document.createElement("div");if(c.className="cnv-panel-reward__foot","number"==typeof n.redeemPoints){const e=document.createElement("div");e.className="cnv-panel-reward__price",e.style.color=t,e.textContent=de(n.redeemPoints),c.appendChild(e)}const l=document.createElement("button");return l.type="button",l.className="cnv-panel-zalo__btn cnv-panel-reward__cta",l.textContent="Đổi",l.disabled=null!==e||hn,l.disabled||(l.style.borderColor=t,l.style.color=t,l.addEventListener("click",On(()=>{fn={kind:"confirm",item:n},Qe(),xe()}))),c.appendChild(l),r.appendChild(c),o}function ge(n,t){const e=nt();if("number"==typeof e&&n.appendChild(fe(e,t)),!rt())return void ct(n,t,"Bạn cần đăng nhập để xem ưu đãi có thể đổi.");if(on&&!nn.length)return n.appendChild(Ft(200,12)),void n.appendChild(Ft(150,12));if(!nn.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Hiện chưa có ưu đãi nào để đổi.",void n.appendChild(t)}const o=document.createElement("div");o.className="cnv-panel-reward__list",nn.forEach(n=>o.appendChild(me(n,t))),n.appendChild(o);const r="number"==typeof c&&tn?Math.max(0,c-nn.length):0;if(r>0||on){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=on,t.textContent=on?"Đang tải…":`Xem thêm ${r} ưu đãi`,t.addEventListener("click",On(Xn)),n.appendChild(t)}}function be(n,t,e){const o=Xt(t,e,!0);o&&n.appendChild(o);const r=Kt(t.expiredAt);if(r){const t=document.createElement("div");t.className="cnv-panel-redeem__sub",t.textContent=`HSD ${r}`,n.appendChild(t)}}function ye(n,t,e){const o=$t(Yn,t,V(t,.12),e.title||"Ưu đãi");if("number"==typeof e.redeemPoints){const n=document.createElement("div");n.className="cnv-panel-redeem__cost",n.style.color=t;const r=de(e.redeemPoints);n.textContent=r,pe(n,r,20),o.appendChild(n);const i=nt();if(e.redeemPoints>0&&"number"==typeof i){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Còn lại ${se(i-e.redeemPoints)}`,o.appendChild(n)}}be(o,e,t),n.appendChild(o);const r=document.createElement("div");r.className="cnv-panel-redeem__actions";const i=document.createElement("button");i.type="button",i.className="cnv-panel-zalo__btn",i.textContent="Hủy",i.disabled=hn,hn||i.addEventListener("click",On(()=>{fn=null,xe()}));const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent=hn?"Đang đổi…":"Đổi",c.disabled=hn,hn||(c.style.borderColor=t,c.style.color=t,c.addEventListener("click",On(()=>At(e)))),r.append(i,c),n.appendChild(r)}function _e(n,t,e,o){var r;const i=$t(ot,lt,at,"Đổi thành công"),c=document.createElement("div");if(c.className="cnv-panel-redeem__sub",c.textContent=e.title||"Ưu đãi",i.appendChild(c),o.burnOnUse||e.burnOnUse){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Mã đã sẵn sàng trong "Ưu đãi của bạn" — bấm Sử dụng khi bạn dùng nhé.',i.appendChild(n)}else if(o.code){const n=document.createElement("div");n.className="cnv-panel-reward__code",n.textContent=o.code,i.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Chưa có mã ngay — bạn kiểm tra ở tab "Ưu đãi của bạn" nhé.',i.appendChild(n)}be(i,e,t);const l=null!==(r=o.pointsSpent)&&void 0!==r?r:e.redeemPoints,a=[];if("number"==typeof l&&l>0&&a.push(`Đã dùng ${se(l)}`),"number"==typeof o.pointsRemaining&&a.push(`còn lại ${se(o.pointsRemaining)}`),a.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=a.join(" · "),i.appendChild(n)}if(o.transactionId){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Mã giao dịch ${o.transactionId}`,i.appendChild(n)}if(n.appendChild(i),!o.burnOnUse&&!e.burnOnUse&&o.code){const e=document.createElement("div");e.className="cnv-panel-redeem__actions",e.appendChild(ce(o.code,t)),n.appendChild(e)}const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=document.createElement("button");s.type="button",s.className="cnv-panel-zalo__btn",s.textContent="Ưu đãi của bạn",s.addEventListener("click",On(()=>Pn("owned")));const d=document.createElement("button");d.type="button",d.className="cnv-panel-zalo__btn",d.textContent="Đổi tiếp",d.addEventListener("click",On(()=>{fn=null,Qe(),xe(),"redeem"!==Y||nn.length||(tn=0,Xn())})),u.append(d,s),n.appendChild(u)}function we(n,t,e,o){var r;const i=((n,t)=>{var e;if(t){if(void 0!==(null===(e=St(n))||void 0===e?void 0:e.redeemPoints)&&Nt[t])return Nt[t];if(zt[t])return zt[t]}return Dt})(e,o),c="neutral"===i.tone,l=$t(c?tt:Yn,c?dt:ut,c?pt:st,null!==(r=i.heading)&&void 0!==r?r:"Không đổi được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,l.appendChild(n)}const a=document.createElement("div");a.className="cnv-panel-zalo__status",a.textContent=i.message,a.setAttribute("role","alert"),l.appendChild(a),n.appendChild(l);const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=()=>{fn=null,Qe(),xe()},d=Rt[i.action];if("other"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",On(s)),u.appendChild(n)}else if("owned"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",On(()=>Pn("owned"))),u.appendChild(n)}else{const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Về danh sách",n.addEventListener("click",On(s)),u.appendChild(n),"retry"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.style.borderColor=t,n.style.color=t,n.addEventListener("click",On(()=>At(e,!i.retryWithNewKey))),u.appendChild(n)}}n.appendChild(u)}function xe(){var n,t;if(!v)return;no(),to(),Xe(!0);const e=null!==(t=null===(n=v.querySelector(".cnv-panel-rlist"))||void 0===n?void 0:n.scrollTop)&&void 0!==t?t:0;v.textContent="";const o=Wn(r),i=jn(),c=Bt(r,i?"cnv-panel-phase":"cnv-panel-rcard");let l=c;if(!i){const n=document.createElement("div");n.className="cnv-panel-section__head",n.appendChild(ht(Yn,o));const t=document.createElement("div");t.className="cnv-panel-section__title",t.textContent="Ưu đãi",n.appendChild(t);const e=document.createElement("div");e.className="cnv-panel-rhead",e.append(n,ue(o)),c.appendChild(e),l=document.createElement("div"),l.className="cnv-panel-rlist",c.appendChild(l)}"redeem"===Y?"confirm"===(null==fn?void 0:fn.kind)?ye(c,o,fn.item):"success"===(null==fn?void 0:fn.kind)?_e(c,o,fn.item,fn.result):"error"===(null==fn?void 0:fn.kind)?we(c,o,fn.item,fn.code):ge(l,o):"confirm"===(null==cn?void 0:cn.kind)?re(c,o,cn.item):"error"===(null==cn?void 0:cn.kind)?ie(c,o,cn.item,cn.code):rn?le(c,o,rn):ke(l,o),v.appendChild(c),e>0&&l!==c&&(l.scrollTop=e),v&&v.querySelectorAll(".cnv-panel-reward__name").forEach(n=>{const t=n.querySelector(".cnv-panel-reward__title");if(!t)return;if(t.clientWidth<=0)return;const e=t.offsetHeight;t.classList.add(wt);const o=t.offsetHeight;t.classList.remove(wt),n.classList.toggle("cnv-panel-reward__name--clamped",o>e+1)})}function ke(n,t){if(!rt())return void ct(n,t,"Bạn cần đăng nhập để xem ưu đãi của bạn.");if(N&&!j.length)return n.appendChild(Ft(200,12)),void n.appendChild(Ft(150,12));if(!j.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Bạn chưa có ưu đãi nào.",void n.appendChild(t)}const e=document.createElement("div");e.className="cnv-panel-reward__list",j.forEach(n=>e.appendChild(ee(n,t))),n.appendChild(e);const o=Fn();if(o>0||J){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more";const e=J||N;t.disabled=e,t.textContent=e?"Đang tải…":`Xem thêm ${o} ưu đãi`,t.addEventListener("click",Ln),n.appendChild(t)}}function Ae(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 Ce(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=bt[n.icon];i.appendChild(ht("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 Se(){if(O)return;const n=qn(o.projectId);if(!n)return;const t=M+1;O=!0,C&&Me(),o.fetchPointHistory(n.token,t).then(n=>{O=!1,M=t,n&&("number"==typeof n.totalCount&&(i=n.totalCount),n.items.length&&(S=S.concat(n.items))),C&&Me()}).catch(()=>{O=!1,C&&Me()})}function Me(){if(!v)return;no(),to(),Xe(!0),v.textContent="";const n=Wn(r),t=Bt(r);if(t.appendChild(je({label:"Lịch sử hoạt động",icon:tt},n)),!S.length&&O)t.appendChild(Ft(180,12)),t.appendChild(Ft(120,12));else if(S.length){const n=document.createElement("div");n.className="cnv-panel-history__list",S.forEach((t,e)=>n.appendChild(Oe(t,e>0))),t.appendChild(n);const e="number"==typeof i&&M?Math.max(0,i-S.length):0;if(e>0||O){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=O,n.textContent=O?"Đang tải…":`Xem thêm ${e} hoạt động`,n.addEventListener("click",On(Se)),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)}v.appendChild(t)}function Oe(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(Ee(c));const l=[];"number"==typeof n.balanceAfter&&l.push("Điểm tích lũy: "+ze(n.balanceAfter));const a=(n.rankAfter||"").trim();"number"==typeof n.expBalanceAfter?l.push("Điểm xét hạng: "+ze(n.expBalanceAfter)+(a?" (Hạng "+a+")":"")):a&&l.push("Hạng "+a),l.length&&o.appendChild(Ee(l.join(" / ")));const u=Ne(n.createdAt);u&&o.appendChild(Ee(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=Ie(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=Ie(n.expPoints)+" xét hạng",s.appendChild(t)}return s.childElementCount&&e.appendChild(s),e}function Ee(n){const t=document.createElement("div");return t.className="cnv-panel-history__meta",t.textContent=n,t}function Ie(n){const t=Math.round(n);return(t>0?"+":"")+t.toLocaleString("vi-VN")}function ze(n){return Math.round(n).toLocaleString("vi-VN")}function Ne(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 De(){if(!v||!E)return;const n=_t[E];if(!n)return E=null,void Ke();const t=Ae(E);no(),to(),Xe(!0),v.textContent="";const e=Wn(r),o=Bt(r);if(o.appendChild(je(n,e)),t.length){const r=document.createElement("div");r.className="cnv-panel-block__list",t.forEach((t,o)=>r.appendChild(Ce(t,o>0,e,n.icon))),o.appendChild(r)}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="redeem"===E?"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(v.appendChild(o),!Ye()){const n=zn();n&&v.appendChild(n)}I=Ye()}function je(n,t){const e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(ht(n.icon,t));const o=document.createElement("div");return o.className="cnv-panel-section__title",o.textContent=n.label,e.appendChild(o),e}function Te(n){if(!(Array.isArray(r.sections)?r.sections:[]).some(n=>"POINTS"===n.type&&n.enabled))return null;const t=Bt(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 kt.forEach((n,t)=>o.appendChild(En(n[0],n[1],t>0))),t.append(je(mt.POINTS,n),e,o),t}function Re(n){const t=Math.max(0,Math.round(n)).toLocaleString("vi-VN");return"SPENDING"===(null==G?void 0:G.applyFor)?t+"đ":t+" điểm"}function Be(n){const t=document.createElement("span");if(t.className="cnv-panel-tier__badge",P(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=L(n.colorCode,Wn(r)),t}function Fe(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(Be(n));const i=document.createElement("span");return 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:"",r.appendChild(i),r}function Le(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 Pe(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 $e(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 "+Re(s)+" nữa để lên "+n.nextLevelName:"Còn "+Re(s)+" nữa để lên hạng kế tiếp",c.append(l,u),c}function Ue(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 Ve(n,t){var e,o;const i=null!==(e=null==G?void 0:G.tiers)&&void 0!==e?e:[];if(!i.length)return null;const c=Bt(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(Be(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=$e(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}=Ue(i,u),p=document.createElement("div");p.className="cnv-panel-tier__list",s>0&&p.appendChild(Pe(s,!1));for(let n=s;n<d;n++){const t=n===u;if(p.appendChild(Fe(i[n],t)),t||u<0){const t=Le(i[n].benefits);t&&p.appendChild(t)}}const f=Math.max(null!==(o=null==G?void 0:G.totalTiers)&&void 0!==o?o:i.length,i.length)-d;return f>0&&p.appendChild(Pe(f,!0)),l.appendChild(p),c.append(je(mt.VIP,n),l),c}function He(n,t){const e=mt[n];if(!e||"string"!=typeof e.label)return null;if("VIP"===n)return Ve(t,!0);const o=Bt(r),i=je(e,t),c=document.createElement("div");if("POINTS"!==n)return c.appendChild(vt("Sắp ra mắt",t)),o.append(i,c),o;const l=Dn();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(vt("Đang cập nhật",t));return[["Ưu đãi","rewards"],...kt,["Lịch sử hoạt động","history"]].forEach((n,t)=>c.appendChild(En(n[0],n[1],t>0))),o.append(i,c),o}function qe(){if(!f||!h)return;const n=r.colors;s&&(s.style.backgroundColor="DARK"===r.theme?"#181C32":"#FFFFFF",s.style.color="DARK"===r.theme?"#FFFFFF":"#181C32");const t=f.parentElement;if(t&&(t.style.backgroundColor=L(null==n?void 0:n.bannerBg,R),t.style.color=L(null==n?void 0:n.bannerFont,B)),d&&(P(r.bannerImageUrl)?(d.src=r.bannerImageUrl,d.style.display="block"):(d.style.display="none",d.removeAttribute("src"))),p){const t=p.parentElement;P(r.brandIconUrl)?(p.src=r.brandIconUrl,t&&(t.style.display="flex",t.style.background=V(L(null==n?void 0:n.bannerFont,B),.18))):(t&&(t.style.display="none"),p.removeAttribute("src"))}const e=(null==w?void 0:w.isMember)?r.headerMember:r.headerVisitor,i=(null==w?void 0:w.isMember)?null===(c=qn(o.projectId))||void 0===c?void 0:c.fullName:null;var c;f.textContent=Mt((null==e?void 0:e.caption)||"",i),h.textContent=Mt((null==e?void 0:e.title)||"",i)}function Ke(){if(!v||k||A||C||E)return;no(),to(),Xe(!0),v.textContent="";const n=Wn(r);if(!(null==w?void 0:w.isMember)){let t=0;Ge(In(),t++);const e=Te(n);e&&Ge(e,t++);const o=Bn()?Ve(n,!1):null;return void(o&&Ge(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=He(t.type,n);o&&Ge(o,e++)}),rt()&&Ge(Ze(),e++)}function Ze(){const n=document.createElement("div");n.className="cnv-panel-logout";const t=document.createElement("button");return t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-logout__btn",t.textContent="Đăng xuất",t.addEventListener("click",On(Io)),n.appendChild(t),n}function Ge(n,t){n.style.animationDelay=40+55*t+"ms",v.appendChild(n)}function We(){qe(),E?I!==Ye()&&De():Ke()}function Je(){dn("owned"),dn("redeem"),z=null,D=0,en=0,j=[],U=0,A=!1,nn=[],c=void 0,tn=0,l=void 0,vn=null,Jt(),S=[],i=void 0,M=0,C=!1}function Ye(){return!!(null==w?void 0:w.isMember)}function Qe(){if(!v)return;v.scrollTop=0;const n=v.querySelector(".cnv-panel-rlist");n&&(n.scrollTop=0)}function Xe(n){s&&(s.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 no(){const n=k||A||C||null!==E;g&&(g.style.display=n?"inline-flex":"none"),m&&m.classList.toggle("cnv-panel-banner--sub",n)}function to(){if(!s)return;const n=!Ye()&&null!==E;if(n&&!y)return y=Nn(),void s.insertBefore(y,b);!n&&y&&(y.remove(),y=null)}function eo(){k&&(ro(),k=!1),A=!1,Jt(),C=!1,E=null,Qe(),Ke()}function oo(){yn=e(yn)}function ro(){_n=e(_n)}function io(n,t){oo(),void 0!==t&&(wn=Date.now()+1e3*t);const e=wn;yn=Ut(Math.ceil((e-Date.now())/1e3),()=>{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 co(){if(k=!1,oo(),ro(),x){const t=x;x=null,n(()=>t.cancel())}}function lo(){const n=document.createElement("button");return n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Huỷ",n.addEventListener("click",()=>{co(),We()}),n}function ao(n){var e;if(!v)return;no(),to(),Xe(!1),v.textContent="";const o=Wn(r),i=Bt(r,"cnv-panel-zalo");if("loading"===n.phase)i.appendChild(Pt(o)),i.appendChild(lo());else if("qr"===n.phase||"scanned"===n.phase){const e=(n=>{try{const t=X(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(e){const t=document.createElement("div");t.className="cnv-panel-zalo__qr cnv-panel-zalo__qr--white",t.appendChild(e),Lt(t,o),"scanned"===n.phase&&t.appendChild(((n,t)=>{const e=document.createElement("div");return e.className="cnv-panel-zalo__overlay",e.style.borderRadius="inherit",e.style.background="DARK"===n?"rgba(63, 66, 84, 0.94)":"rgba(255, 255, 255, 0.94)",e.appendChild($t(ot,t,V(t,.12),"Đã quét mã")),e})(r.theme,o)),i.appendChild(t)}const c=document.createElement("div");c.className="cnv-panel-zalo__status",c.appendChild(document.createTextNode("Mở "));const l=document.createElement("b");l.style.color=o,l.textContent="Zalo",c.appendChild(l),c.appendChild(document.createTextNode(" trên điện thoại và quét mã để đăng nhập")),i.appendChild(t(()=>window.matchMedia("(pointer: coarse)").matches,!1)?((n,t)=>{const e=document.createElement("a");return e.className="cnv-panel-zalo__btn",e.href=n,e.target="_blank",e.rel="noopener noreferrer",e.style.backgroundColor=t,e.style.borderColor=t,e.style.color="#fff",e.textContent="Mở Zalo để xác nhận",e})(n.session.qrPayload,o):"scanned"===n.phase?(()=>{const n=document.createElement("div");return n.className="cnv-panel-zalo__status cnv-panel-zalo__confirm",n.textContent="Xác nhận trên điện thoại để đăng nhập",n})():c);const a=document.createElement("div");a.className="cnv-panel-zalo__timer",a.appendChild(ft(tt,12));const u=document.createElement("span");a.appendChild(u),i.appendChild(a),io(u,"scanned"===n.phase?n.expiresInSeconds:n.session.expiresInSeconds),i.appendChild(lo())}else{i.style.position="relative",i.appendChild(Pt(o));const t=document.createElement("div");let a;if(t.className="cnv-panel-zalo__overlay",t.style.borderRadius=Gn(null===(e=r.shapes)||void 0===e?void 0:e.card),t.style.background="DARK"===r.theme?"rgba(63, 66, 84, 0.94)":"rgba(255, 255, 255, 0.94)","success"===n.phase)a=$t(ot,lt,at,n.result.fullName?`Xin chào ${n.result.fullName}!`:"Đăng nhập thành công!");else{const t="expired"===n.reason,e=n.reason?Gt[n.reason]:void 0,r=t||void 0!==e;a=$t(e?et:t?tt:'<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"/>',r?dt:ut,r?pt:st,null!=e?e:t?"Mã QR đã hết hạn":"Có lỗi xảy ra");const i=document.createElement("div");if(i.className="cnv-panel-zalo__status",i.textContent=t?'Bấm "Thử lại" để lấy mã mới.':n.message,a.appendChild(i),n.canRetry){const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.style.backgroundColor=o,n.style.borderColor=o,n.style.color="#fff",n.textContent="Thử lại",n.addEventListener("click",On(()=>uo())),bn>=3){const t=Math.min(5+5*(bn-3),20);c=n,l=t,ro(),c.disabled=!0,_n=Ut(l,n=>{n>0&&(c.textContent=`Thử lại (${n}s)`)},()=>{c.disabled=!1,c.textContent="Thử lại"})}a.appendChild(n)}}t.appendChild(a),i.appendChild(t)}var c,l;v.appendChild(i)}function uo(){if(!v)return;co(),E=null,k=!0,Qe();const t=++gn;ao({phase:"loading"}),o.loginWithZalo({onProgress(n){!Cn(t)&&x&&ao({phase:"scanned",session:x,expiresInSeconds:n.expiresInSeconds})}}).then(e=>{Cn(t)?n(()=>e.cancel()):(x=e,bn=0,ao({phase:"qr",session:e}),e.result.then(n=>{if(!Cn(t)){if(oo(),x=null,ao({phase:"success",result:n}),null!=n.contactId&&"string"==typeof n.panelSessionToken&&n.panelSessionToken&&"number"==typeof n.panelSessionExp){const t="number"==typeof n.panelSessionExpiresInMs&&n.panelSessionExpiresInMs>0?Date.now()+n.panelSessionExpiresInMs:n.panelSessionExp;Kn(o.projectId,{token:n.panelSessionToken,contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,exp:t}),Oo(t)}w={isMember:!0},Rn(),setTimeout(()=>{Cn(t)||(k=!1,We())},1500)}}).catch(n=>{if(Cn(t))return;oo(),x=null;const o=Zt(n);ao({phase:"error",message:Wt(n,e.miniAppKind),canRetry:"agent-registration-required"!==o&&"requester-not-ready"!==o&&"underage-self-declared"!==o,reason:o})}))}).catch(n=>{Cn(t)||(bn+=1,ao({phase:"error",message:Wt(n),canRetry:!0,reason:Zt(n)}))})}function so(n){var t,e,o;if(a)return;const i=q("data-cnv-panel",":host{all:initial;}.cnv-panel-card{position:fixed;display:flex;flex-direction:column;background-repeat:repeat;width:min(360px,calc(100vw - 32px));height:600px;max-height:calc(100vh - 32px);overflow:hidden;box-shadow:0 20px 44px rgba(24,28,50,.22),0 4px 10px rgba(24,28,50,.12);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.4;animation:cnv-panel-in .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-card--leaving{animation:cnv-panel-out .18s cubic-bezier(.4,0,1,1) both;pointer-events:none;}@keyframes cnv-panel-in{from{opacity:0;transform:translateY(14px) scale(.92);}to{opacity:1;transform:none;}}@keyframes cnv-panel-out{from{opacity:1;transform:none;}to{opacity:0;transform:translateY(10px) scale(.96);}}@keyframes cnv-panel-bubble-in{from{opacity:0;transform:translateY(4px) scale(.97);}to{opacity:1;transform:none;}}@keyframes cnv-panel-rise{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-panel-card,.cnv-panel-card--leaving,.cnv-panel-card__section,.cnv-panel-zalo__overlay-bubble{animation:none !important;}}.cnv-panel-close{position:absolute;z-index:2;top:10px;right:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;font-size:16px;display:inline-flex;align-items:center;justify-content:center;line-height:1;padding:0;transition:background .15s;}.cnv-panel-close:hover{background:rgba(0,0,0,.3);}.cnv-panel-back{position:absolute;z-index:2;top:10px;left:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;padding:0;display:none;align-items:center;justify-content:center;transition:background .15s;}.cnv-panel-back:hover{background:rgba(0,0,0,.3);}.cnv-panel-banner{position:relative;flex:0 0 auto;padding:20px 20px 54px;min-height:160px;margin-bottom:-54px;box-sizing:border-box;overflow:hidden;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:.35;display:none;}.cnv-panel-banner__brandchip{position:relative;width:34px;height:34px;border-radius:10px;margin:0 0 10px;display:none;align-items:center;justify-content:center;overflow:hidden;}.cnv-panel-banner__brandicon{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-banner__caption{position:relative;font-size:11.5px;opacity:.85;}.cnv-panel-banner__title{position:relative;font-size:26px;font-weight:800;line-height:1.24;margin-top:3px;}.cnv-panel-body{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;padding:16px;display:flex;flex-direction:column;gap:12px;position:relative;z-index:1;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-body::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-footer{flex:0 0 auto;padding:11px 16px;display:flex;align-items:center;justify-content:center;gap:4px;font-size:11.5px;font-weight:500;}.cnv-panel-footer__brand{font-weight:800;}.cnv-panel-card__section{padding:16px;box-sizing:border-box;animation:cnv-panel-rise .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-phase{flex:1 0 auto;display:flex;flex-direction:column;justify-content:center;}.cnv-panel-phase .cnv-panel-zalo__status{max-width:none;}.cnv-panel-chip{width:26px;height:26px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}.cnv-panel-section__head{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-cta{text-align:center;}.cnv-panel-cta__title{font-size:15px;font-weight:800;margin-bottom:5px;}.cnv-panel-cta__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:14px;}.cnv-panel-history__row{display:flex;align-items:flex-start;gap:10px;padding:10px 0;}.cnv-panel-history__main{flex:1;min-width:0;}.cnv-panel-history__title{font-size:13px;font-weight:700;line-height:1.35;}.cnv-panel-history__meta{font-size:11.5px;line-height:1.45;opacity:.66;margin-top:2px;}.cnv-panel-history__amounts{flex:0 0 auto;text-align:right;}.cnv-panel-history__points{font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap;}.cnv-panel-history__exp{font-size:11px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;opacity:.66;margin-top:2px;}.cnv-panel-join-hint{padding:13px 16px;text-align:center;font-size:12.5px;line-height:1.5;font-weight:600;}.cnv-panel-joinbar{flex:0 0 auto;padding:12px 16px;}.cnv-panel-cta__btn{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;height:40px;border:none;font-weight:700;cursor:pointer;margin-bottom:10px;font-size:13.5px;transition:filter .15s,transform .15s cubic-bezier(.16,1,.3,1);}.cnv-panel-cta__btn:hover{filter:brightness(1.06);transform:translateY(-1px);}.cnv-panel-cta__btn:active{transform:translateY(0) scale(.985);}.cnv-panel-cta__signin{display:flex;align-items:center;justify-content:center;gap:4px;font-size:12.5px;text-align:center;cursor:pointer;font-weight:700;}@media (max-height:560px){.cnv-panel-banner{min-height:96px;margin-bottom:-38px;padding:14px 16px 38px;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__title{font-size:20px;}.cnv-panel-body{padding:12px;gap:8px;}.cnv-panel-joinbar{padding:8px 12px;}.cnv-panel-cta__btn{height:34px;margin-bottom:6px;}.cnv-panel-footer{padding:6px 12px;}}.cnv-panel-icon{display:inline-flex;flex-shrink:0;}.cnv-panel-icon--chevron{transition:transform .15s;}.cnv-panel-cta__signin:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-section__title{font-size:11.5px;font-weight:800;text-transform:uppercase;letter-spacing:.04em;opacity:.68;}.cnv-panel-section__points{font-size:28px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;margin-bottom:6px;}.cnv-panel-section__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:4px;}.cnv-panel-section__row{font-size:12.5px;display:flex;align-items:center;gap:10px;padding:10px 0;cursor:pointer;}.cnv-panel-section__row-label{flex:1;min-width:0;}.cnv-panel-section__row:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-badge{display:inline-flex;align-items:center;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.03em;padding:3px 8px;border-radius:999px;}.cnv-panel-tier__current{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-tier__current-name{font-size:19px;font-weight:800;line-height:1.2;}.cnv-panel-tier__badge{flex:0 0 auto;width:18px;height:18px;border-radius:999px;overflow:hidden;display:inline-flex;align-items:center;justify-content:center;}.cnv-panel-tier__badge-img{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-tier__progress{margin-bottom:8px;}.cnv-panel-tier__bar{height:6px;border-radius:999px;overflow:hidden;}.cnv-panel-tier__fill{height:100%;border-radius:999px;transition:width .35s ease;}.cnv-panel-tier__hint{font-size:12px;line-height:1.5;opacity:.72;}.cnv-panel-tier__list{}.cnv-panel-tier__row{display:flex;align-items:center;gap:8px;font-size:12.5px;padding:7px 0;}.cnv-panel-tier__row--current{font-weight:800;}.cnv-panel-tier__name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cnv-panel-tier__benefits{margin:0 0 6px 26px;padding:0 0 0 14px;font-size:12px;line-height:1.55;opacity:.72;}.cnv-panel-tier__more{font-size:11.5px;padding:5px 0 5px 26px;opacity:.58;}.cnv-panel-zalo{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;text-align:center;min-height:346px;}.cnv-panel-vstack{display:flex;flex-direction:column;align-items:center;gap:8px;}.cnv-panel-zalo__qr{position:relative;padding:10px;border-radius:12px;}.cnv-panel-zalo__qr--white{background:#fff;}.cnv-panel-zalo__qr svg{display:block;}.cnv-panel-zalo__corner{position:absolute;width:16px;height:16px;border:3px solid;border-radius:5px 0 0 0;}.cnv-panel-zalo__corner.tl{top:-3px;left:-3px;border-right:none;border-bottom:none;}.cnv-panel-zalo__corner.br{bottom:-3px;right:-3px;border-left:none;border-top:none;border-radius:0 0 5px 0;}.cnv-panel-zalo__title{font-size:14px;font-weight:800;}.cnv-panel-zalo__status{font-size:12.5px;font-weight:500;line-height:1.45;max-width:250px;}.cnv-panel-zalo__confirm{min-height:36px;display:flex;align-items:center;justify-content:center;}.cnv-panel-zalo__timer{font-size:11.5px;font-weight:700;opacity:.7;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center;gap:5px;}.cnv-panel-reward__list{}.cnv-panel-reward{position:relative;display:flex;align-items:stretch;padding:8px;margin-top:10px;border-radius:10px;border:1px solid var(--cnv-tk-line);background:var(--cnv-tk-bg);}.cnv-panel-reward:first-child{margin-top:2px;}.cnv-panel-ticket__stub{flex:0 0 76px;min-height:84px;box-sizing:border-box;border-radius:8px;border-top:4px solid transparent;border-bottom:4px solid rgba(0,0,0,.15);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;padding:4px 3px;text-align:center;}.cnv-panel-ticket__badge{width:40px;height:40px;flex:none;border-radius:50%;background:#FFFFFF;overflow:hidden;display:flex;align-items:center;justify-content:center;}.cnv-panel-ticket__label{font-size:10px;font-weight:700;line-height:1.3;word-break:break-word;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;}.cnv-panel-ticket__cut{position:relative;flex:0 0 14px;}.cnv-panel-ticket__cut::before{content:'';position:absolute;left:50%;top:4px;bottom:4px;border-left:1px dashed var(--cnv-tk-dash);}.cnv-panel-ticket__hole{position:absolute;left:50%;width:14px;height:8px;margin-left:-7px;box-sizing:border-box;background:var(--cnv-tk-hole);border:1px solid var(--cnv-tk-line);}.cnv-panel-ticket__hole--top{top:-9px;border-top:none;border-radius:0 0 8px 8px;}.cnv-panel-ticket__hole--bottom{bottom:-9px;border-bottom:none;border-radius:8px 8px 0 0;}.cnv-panel-reward__main{min-width:0;flex:1;display:flex;flex-direction:column;align-items:flex-start;padding-top:2px;}.cnv-panel-reward__thumb{width:34px;height:34px;border-radius:50%;object-fit:cover;}.cnv-panel-reward__foot{margin-top:auto;padding-top:8px;align-self:stretch;display:flex;align-items:center;justify-content:flex-end;gap:8px;}.cnv-panel-reward__title{font-size:13px;font-weight:700;line-height:1.4;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}.cnv-panel-reward__title--full{display:block;-webkit-line-clamp:none;overflow:visible;}.cnv-panel-reward__name{display:flex;align-items:flex-start;gap:4px;}.cnv-panel-reward__name>.cnv-panel-reward__title{flex:1 1 auto;min-width:0;}.cnv-panel-reward__info{display:none;flex:none;padding:0;margin-top:1px;border:none;background:transparent;color:inherit;opacity:.45;cursor:pointer;line-height:0;}.cnv-panel-reward__info:hover{opacity:.85;}.cnv-panel-reward__name--clamped .cnv-panel-reward__info{display:inline-flex;}.cnv-panel-reward__tags{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:6px;}.cnv-panel-reward__value{font-size:12px;font-weight:800;padding:3px 8px;border-radius:999px;white-space:nowrap;}.cnv-panel-reward__uses{font-size:11.5px;font-weight:600;padding:3px 8px;border-radius:999px;background:rgba(127,127,127,.14);white-space:nowrap;}.cnv-panel-reward__code{font-size:13px;font-weight:800;letter-spacing:.06em;margin-top:6px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;user-select:all;}.cnv-panel-reward__meta{font-size:11.5px;opacity:.7;margin-top:4px;line-height:1.45;}.cnv-panel-reward__code--big{font-size:20px;margin-top:10px;}.cnv-panel-reward__channel{display:flex;align-items:flex-start;gap:5px;margin-top:4px;font-size:11.5px;line-height:1.45;}.cnv-panel-reward__channel .cnv-panel-icon{margin-top:1px;}.cnv-panel-reward__channel--center{justify-content:center;margin-top:6px;font-size:12px;}.cnv-panel-reward__show{width:auto;white-space:nowrap;}.cnv-panel-reward__more{width:100%;margin-top:10px;}.cnv-panel-balance{padding:2px 0 8px;}.cnv-panel-balance__label{font-size:11.5px;opacity:.66;margin-bottom:2px;}.cnv-panel-balance__row{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;}.cnv-panel-balance__num{font-size:26px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;}.cnv-panel-balance__unit{font-size:12.5px;font-weight:700;opacity:.7;}.cnv-panel-rtabs{display:flex;gap:2px;margin:2px 0 2px;border-bottom:1px solid rgba(127,127,127,.22);}.cnv-panel-rcard{flex:0 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.cnv-panel-rhead{flex:0 0 auto;}.cnv-panel-rlist{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-rlist::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-rtab{flex:1;padding:9px 6px;margin-bottom:-1px;background:transparent;border:none;border-bottom:2px solid transparent;color:inherit;cursor:pointer;font-size:12.5px;font-weight:700;opacity:.6;transition:opacity .15s;font-family:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.cnv-panel-rtab:hover{opacity:.85;}.cnv-panel-rtab--on{opacity:1;font-weight:800;}.cnv-panel-reward__price{flex:1 1 auto;min-width:0;font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;}.cnv-panel-reward__cta{height:30px;padding:0 12px;font-size:12px;}.cnv-panel-redeem__cost{font-size:20px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1;}.cnv-panel-redeem__sub{font-size:11.5px;opacity:.66;line-height:1.45;}.cnv-panel-redeem__actions{display:flex;gap:8px;margin-top:12px;justify-content:center;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn{flex:1;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn:only-child{flex:0 0 auto;}.cnv-panel-block__list{}.cnv-panel-block{padding:11px 0;display:flex;gap:10px;align-items:flex-start;}.cnv-panel-block .cnv-panel-chip{margin-top:1px;}.cnv-panel-block__main{min-width:0;flex:1;}.cnv-panel-block__title{font-size:13px;font-weight:700;line-height:1.4;}.cnv-panel-block__desc{font-size:12px;line-height:1.5;opacity:.72;margin-top:3px;white-space:pre-line;}.cnv-panel-zalo__btn{height:36px;padding:0 16px;border:1px solid rgba(127,127,127,.3);border-radius:10px;background:transparent;color:inherit;font-size:12.5px;font-weight:700;cursor:pointer;transition:filter .15s;}.cnv-panel-zalo__btn:hover:not(:disabled){filter:brightness(1.1);}.cnv-panel-zalo__btn:disabled{opacity:.5;cursor:not-allowed;}a.cnv-panel-zalo__btn{display:inline-flex;align-items:center;box-sizing:border-box;text-decoration:none;}.cnv-panel-logout{display:flex;justify-content:center;padding:2px 0 10px;}.cnv-panel-logout__btn{height:32px;font-size:12px;font-weight:600;opacity:.72;}.cnv-panel-logout__btn:hover{opacity:1;}.cnv-panel-zalo__overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:16px;}.cnv-panel-zalo__overlay-bubble{display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;padding:0 8px;max-width:100%;animation:cnv-panel-bubble-in .2s ease;}.cnv-panel-bubble-icon{width:40px;height:40px;border-radius:999px;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 0 0 1px rgba(127,127,127,.22);}.cnv-panel-zalo__skeleton{border-radius:6px;background:rgba(127,127,127,.15);background-image:linear-gradient( 90deg,rgba(127,127,127,.15) 25%,rgba(127,127,127,.32) 37%,rgba(127,127,127,.15) 63% );background-size:400% 100%;animation:cnv-panel-shimmer 1.4s ease infinite;}@keyframes cnv-panel-shimmer{0%{background-position:100% 50%;}100%{background-position:0% 50%;}}@media (prefers-reduced-motion:reduce){.cnv-panel-zalo__skeleton{animation:none;}}");a=i.hostEl;const c=i.shadow;a.style.setProperty("display","none");const l=null!==(t=(null==n?void 0:n.useCustomZIndex)?$(n.zIndex):null)&&void 0!==t?t:T,y=null!==(e=$(l+600))&&void 0!==e?e:T;s=document.createElement("div"),s.className="cnv-panel-card",s.style.zIndex=String(y),s.addEventListener("animationend",n=>{"cnv-panel-out"===n.animationName&&vo()}),s.style.borderRadius=Gn(null===(o=r.shapes)||void 0===o?void 0:o.container);const _=document.createElement("button");_.type="button",_.className="cnv-panel-close",_.setAttribute("aria-label","Đóng"),_.textContent="×",_.addEventListener("click",ho),g=document.createElement("button"),g.type="button",g.className="cnv-panel-back",g.setAttribute("aria-label","Quay lại"),g.appendChild(ft('<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',15)),g.addEventListener("click",On(eo));const w=document.createElement("div");m=w,w.className="cnv-panel-banner",d=document.createElement("img"),d.className="cnv-panel-banner__img",d.alt="",p=document.createElement("img"),p.className="cnv-panel-banner__brandicon",p.alt="";const x=document.createElement("div");x.className="cnv-panel-banner__brandchip",x.appendChild(p),f=document.createElement("div"),f.className="cnv-panel-banner__caption",h=document.createElement("div"),h.className="cnv-panel-banner__title",w.append(d,x,f,h),v=document.createElement("div"),v.className="cnv-panel-body",s.append(_,g,w,v),b=po(),b&&s.appendChild(b),c.appendChild(s),K(a),u=Z(a)}function po(){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 CDP",t.appendChild(e),t}function fo(n){if(!s)return;const{side:t,sideSpacingPx:e,bottomSpacingPx:o}=H(n,F());s.style.left="left"===t?e+"px":"auto",s.style.right="right"===t?e+"px":"auto";const r=o+48+24;s.style.bottom=r+"px",s.style.maxHeight=`calc(100vh - ${r+16}px)`,s.style.transformOrigin="left"===t?"left bottom":"right bottom"}function ho(){a&&_&&(_=!1,co(),A=!1,Jt(),C=!1,E=null,document.removeEventListener("keydown",kn),go("cnv:panel:closed"),s&&!t(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,!1)?(s.classList.add(Vn),xn=setTimeout(vo,320)):vo())}function vo(){null!==xn&&(clearTimeout(xn),xn=null),null==s||s.classList.remove(Vn),null==a||a.style.setProperty("display","none")}function mo(){null!==xn&&(clearTimeout(xn),xn=null),null==s||s.classList.remove(Vn)}function go(t){n(()=>window.dispatchEvent(new CustomEvent(t)))}const bo=t=>{n(()=>{var n;const e=t.detail;var r;_?ho():(so(r=null!==(n=null==e?void 0:e.config)&&void 0!==n?n:null),a&&(mo(),fo(r),a.style.setProperty("display","block"),_=!0,We(),Rn(),!Bn()||G||W||(W=!0,o.fetchPanelTiers().then(n=>{W=!1,n&&n.tiers.length&&(G=n,_&&We())}).catch(()=>{W=!1})),document.addEventListener("keydown",kn),go("cnv:panel:opened")))})},yo=t=>{n(()=>{const n=t.detail;w=(null==n?void 0:n.isMember)?{isMember:!0,points:n.points,rewardsAvailableCount:n.rewardsAvailableCount}:{isMember:!1},w.isMember||Je(),_&&We(),_&&Rn()})},_o=3e5,wo=15e3,xo=6e4;let ko=null,Ao=!1,Co=!1;function So(){null!==ko&&(clearTimeout(ko),ko=null)}function Mo(n){So(),Co||(ko=t(()=>setTimeout(zo,Math.max(0,n)),null))}function Oo(n){Mo(Math.max(wo,n-Date.now()-_o))}function Eo(){So(),Zn(o.projectId),w={isMember:!1},Je(),We()}function Io(){const t=qn(o.projectId),e=o.revokePanelSession;t&&e&&n(()=>{e(t.token).catch(()=>{})}),Eo()}function zo(){if(So(),Co||Ao)return;const n=qn(o.projectId);n&&(Date.now()>n.exp?Eo():(Ao=!0,o.refreshPanelSession(n.token).then(t=>{if(Ao=!1,Co)return;const e=qn(o.projectId);if(!e)return;if(e.token!==n.token)return void Oo(e.exp);if("ok"===t.kind)return Kn(o.projectId,Object.assign(Object.assign({},e),{token:t.token,exp:t.exp})),void Oo(t.exp);if("unauthorized"===t.kind)return void Eo();const r=e.exp-Date.now();r<=0?Eo():Mo(Math.min(xo,r))}).catch(()=>{if(Ao=!1,Co)return;const t=n.exp-Date.now();t>0&&Mo(Math.min(xo,t))})))}function No(){if("visible"!==document.visibilityState)return;const n=qn(o.projectId);n&&(Date.now()>n.exp?Eo():n.exp-Date.now()<=_o?zo():Oo(n.exp))}function Do(){const n=qn(o.projectId);n&&(Date.now()>n.exp?Zn(o.projectId):(Oo(n.exp),w={isMember:!0},We(),o.restorePanelSession(n.token).then(t=>{if(Co)return;if("unavailable"===t.kind)return;const e=qn(o.projectId);e&&e.token===n.token&&("ok"===t.kind?(w={isMember:!0},Kn(o.projectId,Object.assign(Object.assign({},e),{fullName:t.session.fullName,level:t.session.level,xp:t.session.xp}))):(So(),Zn(o.projectId),w={isMember:!1},Je()),We())}).catch(()=>{})))}return window.addEventListener($n,bo),window.addEventListener(Un,yo),document.addEventListener("visibilitychange",No),Do(),()=>{co(),Co=!0,n(()=>{window.removeEventListener($n,bo),window.removeEventListener(Un,yo),document.removeEventListener("visibilitychange",No),So(),document.removeEventListener("keydown",kn),mo(),u&&u(),null==a||a.remove()})}}catch(jo){return()=>{}}}const Yt={path:"/config",timeoutMs:4e3,ttlMs:3e5};function Qt(n,t){var e,o;const r=null!=t?t:Object.assign({enabled:!0},Yt);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 Xt(n){return"_cnv_cfg_"+n}function ne(n){const t=bn(Xt(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 te(n,t,e){try{const o={etag:t,envelope:e,fetchedAt:Date.now()};yn(Xt(n),JSON.stringify(o))}catch(n){}}function ee(n){const t=ne(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 oe=["gclid","fbclid","ttclid","msclkid","dclid"],re=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function ie(){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 ce(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 re){const e=r.get(n);e&&e.length>0&&(i[t]=e,c=!0)}if(e){const n={};for(const t of oe){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}function le(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.17"}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}}function ae(n){if(n)try{const t=new URL(n);if("http:"!==t.protocol&&"https:"!==t.protocol)return;return t.origin+t.pathname}catch(n){return}}const ue=256;function se(n,t){if("string"!=typeof n)return;const e=n.trim();return e?e.length>t?e.slice(0,t):e:void 0}function de(n){return"_cnv_ft_"+n}function pe(n){const e=bn(de(n));if(!e)return null;const o=t(()=>(n=>{if(!n||"object"!=typeof n)return null;const t=n;if("number"!=typeof t.ts||!Number.isFinite(t.ts))return null;const e={ts:t.ts},o=se(t.source,ue);o&&(e.source=o);const r=se(t.medium,ue);r&&(e.medium=r);const i=se(t.name,ue);i&&(e.name=i);const c=se(t.term,ue);c&&(e.term=c);const l=se(t.content,ue);l&&(e.content=l);const a=se(t.id,ue);a&&(e.id=a);const u=se(t.referrer,1024);u&&(e.referrer=u);const s=se(t.landingPage,1024);if(s&&(e.landingPage=s),t.clickIds&&"object"==typeof t.clickIds){const n={};for(const[e,o]of Object.entries(t.clickIds)){if(Object.keys(n).length>=8)break;const t=se(e,ue),r=se(o,ue);t&&r&&(n[t]=r)}Object.keys(n).length>0&&(e.clickIds=n)}return 1===Object.keys(e).length?null:e})(JSON.parse(e)),null);if(!o)return _n(de(n)),null;const r=Date.now()-o.ts;return r>63072e6||r<-864e5?(_n(de(n)),null):o}function fe(n,t=!0){const e={first_seen_at:n.ts};return n.source&&(e.utm_source=n.source),n.medium&&(e.utm_medium=n.medium),n.name&&(e.utm_campaign=n.name),n.term&&(e.utm_term=n.term),n.content&&(e.utm_content=n.content),n.id&&(e.utm_id=n.id),n.clickIds&&t&&(e.click_ids=n.clickIds),n.referrer&&(e.referrer=n.referrer),n.landingPage&&(e.landing_page=n.landingPage),e}const he="_cnv_cid";function ve(n={}){const t=vn(he),e=bn(he);let o=null;return Sn(t)?o=t:Sn(e)&&(o=e),o||(o=An()),me(o,n),o}function me(n,t={}){var e;mn(he,n,{domain:t.cookieDomain,maxAgeDays:null!==(e=t.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),yn(he,n)}const ge="1.0";function be(){return(new Date).toISOString()}function ye(n,t){var e;const o=null!==(e=t.timestamp)&&void 0!==e?e:be(),r=Object.assign(Object.assign({},t.context),{projectId:t.projectId,schemaVersion:ge}),i={type:n,messageId:An(),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 _e="_cnv_sid";function we(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!Sn(e)||!Number.isFinite(o)||o<=0?null:{id:e,lastActivity:o}}function xe(n={}){const t=Date.now(),e=(n=>{var t;return 6e4*(null!==(t=n.timeoutMinutes)&&void 0!==t?t:30)})(n),o=we(vn(_e)),r=we((n=>{if(!wn())return null;try{return sessionStorage.getItem(n)}catch(n){return null}})(_e));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:An(),lastActivity:t};return ke(c,n),c.id}function ke(n,t={}){var e;const o=(n=>`${n.id}.${n.lastActivity}`)(n),r=null!==(e=t.timeoutMinutes)&&void 0!==e?e:30;mn(_e,o,{domain:t.cookieDomain,maxAgeDays:r/1440,sameSite:"Lax"}),((n,t)=>{if(!wn())return!1;try{return sessionStorage.setItem(n,t),!0}catch(n){return!1}})(_e,o)}class Ae{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&&Ce(t)>this.maxMessages;)t.shift();this.write(t),this.config.debug&&console.log("[cnv-track] retry queued",n.length,"buffered",Ce(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 Ce(this.read())}clear(){try{_n(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=bn(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?yn(this.storageKey,JSON.stringify(n)):_n(this.storageKey)}}function Ce(n){let t=0;for(const e of n)t+=e.length;return t}class Se{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 Ae({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=be(),o={batch:n.map(n=>Me(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=Me(n,be());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 Me(n,t){return Object.assign(Object.assign({},n),{sentAt:t})}const Oe="_cnv_uid",Ee="_cnv_traits",Ie={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:Qt(void 0)},ze={analytics:!0,marketing:!0};function Ne(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 De="0.3.0-beta.17",je="@cnv-vn/track",Te=function(){let l=null,a=Object.assign({},Ie),u=Object.assign({},ze),s=null,d=!1,p=null;function f(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 h=null;const v=()=>h,m=f(x,v),g=f(Y,v),b=f(Jt,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=Qt(n.remoteConfig,a.remoteConfig)),t):t;var e}function _(){return s||(s=new Se({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 w(){var n;if(!l)return null;const e=((n={})=>{var e;const o={page:ie(),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:le(n.library)},r=ce(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:ve({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),sessionId:xe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),userId:null!==(n=vn(Oe)||bn(Oe))&&void 0!==n?n:void 0,context:e,projectId:l,integrations:Object.keys(a.integrations).length>0?a.integrations:void 0}}function k(){return{projectId:l,endpoint:a.endpoint,zaloQrLoginEnabled:!!l&&ee(l),consentGranted:u.analytics&&u.marketing,getAttribution(){const n=l?pe(l):null;return n?fe(n,a.allowAdTracking):null},getAnonymousId(){return ve({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays})},getSessionId(){return xe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes})}}}function A(n){a.debug&&console.warn(`[cnv-track] ${n}() called before init()`)}function C(n,t){try{const e=w();if(!e)return A("pageview");(n=>{const t=pe(n.projectId);t&&(n.context.firstTouch=fe(t,a.allowAdTracking))})(e);const o=((n,t,e)=>{const o=ye("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);_().enqueue(o)}catch(n){}}function S(n,t){C(n,t)}function M(n,t){try{if("string"!=typeof n||0===n.length)return;const e=w();if(!e)return A("track");const o=((n,t,e)=>{const o=ye("track",e);return o.event=n,o.properties=null!=t?t:{},o})(n,t,e);_().enqueue(o)}catch(n){}}return{get initialized(){return d},get projectId(){return l},get endpoint(){return a.endpoint},isZaloQrLoginEnabled:()=>!!l&&ee(l),get consentGranted(){return u.analytics&&u.marketing},zaloQrLoginHost:k,init(f,v){var w,A;try{if(!f||"string"!=typeof f)return;a=y(v),(null==v?void 0:v.consent)&&(u=Object.assign(Object.assign({},u),v.consent)),l=f,s&&s.destroy(),s=null,_(),d=!0,ve({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),xe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),((n,e=!0,o)=>{const r=pe(n);if(r)return r;const i=ce(0,e),c=(n=>{const e=t(()=>document.referrer,"");if(e){try{const o=new URL(e).host;if(o===t(()=>window.location.host,""))return;const r=n?n.replace(/^\./,"").toLowerCase():"";if(r){const n=o.toLowerCase();if(n===r||n.endsWith("."+r))return}}catch(n){return}return ae(e)}})(o);if(!i&&!c)return null;const l=Object.assign(Object.assign({},null!=i?i:{}),{referrer:c,landingPage:ae(t(()=>window.location.href,"")),ts:Date.now()});yn(de(n),JSON.stringify(l))})(f,a.allowAdTracking,a.cookieDomain),a.autoPageview&&C(),p=e(p);const O={page(n,t){return S(n,t)},track(n,t){return M(n,t)},loginWithZalo(n){return Pn(k(),n)},projectId:l,restorePanelSession(n){return l?function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;try{const r=yield fetch(zn(n,"/panel/session",t),{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const i=yield r.json();return i&&"number"==typeof i.contactId?{kind:"ok",session:{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}}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},refreshPanelSession(n){return l?function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;try{const r=yield fetch(zn(n,"/panel/session/refresh",t),{method:"POST",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const l=yield r.json();return l&&"string"==typeof l.panelSessionToken&&l.panelSessionToken&&"number"==typeof l.panelSessionExp?{kind:"ok",token:l.panelSessionToken,exp:(i=l.panelSessionExpiresInMs,c=l.panelSessionExp,"number"==typeof i&&i>0?Date.now()+i:c)}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}var i,c})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},revokePanelSession(n){return l?function(n,t,e){return Q(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;try{return(yield fetch(zn(n,"/panel/session/revoke",t),{method:"POST",credentials:"omit",mode:"cors",keepalive:!0,headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0})).ok}catch(n){return!1}finally{r&&clearTimeout(r)}})}(a.endpoint,l,n):Promise.resolve(!1)},fetchRewardsSummary(n,t,e){return l?function(n,t,e){return Q(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=Nn(i,r);try{const r=zn(n,"/panel/rewards-summary",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.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(Ln):[];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?Fn(t.tier):void 0}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},fetchPanelTiers(){return l?function(n,t){return Q(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),On):null;try{const o=yield fetch(zn(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(Bn):[];return{applyFor:"SPENDING"===t.applyFor||"POINTS"===t.applyFor?t.applyFor:void 0,thresholdKind:"RELATIVE"===t.thresholdKind||"ABSOLUTE"===t.thresholdKind?t.thresholdKind:void 0,totalTiers:Rn(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 Q(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),On):null;try{const i=zn(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(Dn):[];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)},fetchRedeemableRewards(n,t,e){return l?function(n,t,e){return Q(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=Nn(i,r);try{const r=zn(n,"/panel/redeemable-rewards",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.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(jn):[];return{points:Rn(t.points),total:Rn(t.total),rewards:e}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},redeemReward(n,t,e){return l?function(n,t,e,o,r){return Q(this,void 0,void 0,function*(){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),25e3):null;try{const c=yield fetch(zn(n,"/panel/redeem",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Idempotency-Key":r},body:JSON.stringify(null!=o.campaignId?null!=o.redeemPoints&&o.redeemPoints>0?{campaignId:o.campaignId,redeemPoints:o.redeemPoints}:{campaignId:o.campaignId}:{rewardId:o.rewardId}),signal:i?i.signal:void 0}),a=yield c.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!c.ok)return{ok:!1,code:a?Tn(a,!0):null};const u=Tn(a,!1);return u?{ok:!1,code:u}:{ok:!0,result:(l=a,l?{code:"string"==typeof l.code?l.code:void 0,pointsSpent:Rn(l.pointsSpent),pointsRemaining:Rn(l.pointsRemaining),transactionId:"string"==typeof l.transactionId?l.transactionId:void 0,burnOnUse:!0===l.burnOnUse}:{})}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{c&&clearTimeout(c)}var l})}(a.endpoint,l,n,t,e):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})},useReward(n,t){return l?function(n,t,e,o){return Q(this,void 0,void 0,function*(){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),25e3):null;try{const i=yield fetch(zn(n,"/panel/rewards/use",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({redeemId:o}),signal:r?r.signal:void 0}),c=yield i.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!i.ok)return{ok:!1,code:c?Tn(c,!0):null};const l=Tn(c,!1);if(l)return{ok:!1,code:l};const a=c&&"string"==typeof c.code&&c.code?c.code:null;return a?{ok:!0,result:{code:a,usedAt:c&&"string"==typeof c.usedAt?c.usedAt:void 0,expiredAt:c&&"string"==typeof c.expiredAt?c.expiredAt:void 0,useRemain:c&&"number"==typeof c.useRemain&&Number.isFinite(c.useRemain)?c.useRemain:void 0}}:{ok:!1,code:"CODE_NOT_ISSUED"}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})}};if(h=O,a.autotrack){let t=a.autotrack;a.remoteConfig.enabled&&"object"==typeof t&&t.buttonTracking&&(t=Object.assign(Object.assign({},t),{buttonTracking:void 0})),p=function(t,e){const l=void 0===(a=e)||!1===a?Object.assign(Object.assign({},j),{searchParams:N}):!0===a?Object.assign(Object.assign({},D),{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===(p=a.downloads)||void 0===p||p,siteSearch:null===(f=a.siteSearch)||void 0===f||f,downloadExtensions:a.downloadExtensions,searchParams:null!==(h=a.searchParams)&&void 0!==h?h:N,buttonTracking:a.buttonTracking};var a,u,s,d,p,f,h;l.outboundClicks=!1,l.downloads=!1,l.scroll=!1,l.siteSearch=!1;const v=[];let m=null;function g(e){if(l.siteSearch)try{const o=null!=e?e:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(n){return""}})();if(o===m)return;m=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 p=(n=>{try{return new URL(n,location.href)}catch(n){return null}})(d);if(!p)return;let f=!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()})(p.pathname);(t||r&&e.has(r))&&(f=!0,null===(o=n.onDownload)||void 0===o||o.call(n,{url:p.href,fileName:i(p.pathname),fileExtension:null!=r?r:"",text:c(s)}))}l&&!f&&p.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(n){return""}})()&&p.host&&(null===(u=n.onOutbound)||void 0===u||u.call(n,{url:p.href,host:p.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(x(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=I(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(),g(o)});v.push(()=>{for(let n=0;n<e.length;n++)clearTimeout(e[n]);e.length=0,o()})}return g(),()=>{for(;v.length>0;){const n=v.pop();try{null==n||n()}catch(n){}}m=null}}(O,t)}if(m.dispose(),g.dispose(),b.dispose(),a.remoteConfig.enabled&&l){const n=n=>{var t,e,o,r;m.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),g.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!==(A=null===(w=ne(l))||void 0===w?void 0:w.envelope)&&void 0!==A?A:null),function(n){return Q(this,void 0,void 0,function*(){if(!n.projectId)return{status:"error"};const t=ne(n.projectId);if(t&&Date.now()-t.fetchedAt<n.ttlMs)return{status:"unchanged"};const e=yield function(n){return Q(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&&te(n.projectId,t.etag,t.envelope),{status:"unchanged"}):e.envelope?(te(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:C,page:S,screen(n,t){},track:M,identify(n,t){try{if("string"!=typeof n||0===n.length)return;((n,t,e={})=>{var o,r;if(n&&(mn(Oe,n,{domain:e.cookieDomain,maxAgeDays:null!==(o=e.cookieMaxAgeDays)&&void 0!==o?o:730,sameSite:"Lax"}),yn(Oe,n),null!=t)){const n=null!==(r=(()=>{const n=bn(Ee);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{yn(Ee,JSON.stringify(e))}catch(n){}}})(n,t,{cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays});const e=w();if(!e)return A("identify");const o=((n,t,e)=>{var o;const r=ye("identify",e);return n&&(r.userId=n),r.traits=null!==(o=t)&&void 0!==o?o:{},r})(n,t,e);_().enqueue(o)}catch(n){}},alias(n,t){},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===vn(n)}catch(n){return!1}})(Oe,{domain:n.cookieDomain}),_n(Oe),_n(Ee)})({cookieDomain:a.cookieDomain}),((n={})=>{me(An(),n)})({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),((n={})=>{ke({id:An(),lastActivity:Date.now()},n)})({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),l&&(n=>{_n(de(n))})(l)}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(){p=e(p),m.dispose(),g.dispose(),b.dispose(),h=null,s&&s.destroy(),s=null,d=!1,l=null,a=Object.assign({},Ie),u=Object.assign({},ze)}}}();function Re(n){return Pn(Te.zaloQrLoginHost(),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)Ne(n,e);return e.length},e.__loaded=!0;for(const t of o)Ne(n,t)})(Te);const Be=Object.assign(Te,{version:De,name:je,schemaVersion:ge,loginWithZalo:Re});export{je as NAME,ge as SCHEMA_VERSION,De as VERSION,In as ZaloQrLoginError,Be as default,Re as loginWithZalo};