@phygitallabs/phygital-consent 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,6 +38,10 @@ function AppWithBanner() {
38
38
 
39
39
  On Accept/Reject, the banner calls the consent API, then stores the selection in the browser cookie `phygital_cookie_consent` (hashed device id + `selected_preferences`), then calls `onSubmitted` so the provider refreshes and hides the banner.
40
40
 
41
+ ## Analytics (GA) consent
42
+
43
+ GA is allowed only when the user has submitted cookie preference and **analytics** is in `selected_preferences`. Use `isAnalyticsAllowed()` (helper) or `useIsAnalyticsAllowed()` (hook) or `usePhygitalConsent().isAnalyticsAllowed` (context). Before the GA script runs (or as the first thing in app), set gtag consent default to denied: `gtag('consent', 'default', { analytics_storage: 'denied', ad_storage: 'denied' })`. When `isAnalyticsAllowed` becomes true, call `gtag('consent', 'update', { analytics_storage: 'granted' })`. The consuming app owns all gtag calls; this package does not depend on `window` or gtag.
44
+
41
45
  ## Cookie consent banner
42
46
 
43
47
  One-page cookie banner with three preferences: **essential**, **analytics**, **advertising**. Reject sends only `essential`; Accept sends all three. Use inside `PhygitalConsentProvider` and pass `onSubmitted={refreshConsentPreference}` so the banner hides after submit. The consumer app must supply `deviceId` (and hash it before the API if required).
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- "use strict";var ge=Object.create;var q=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,be=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var n in t)q(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ce(t))!be.call(e,s)&&s!==n&&q(e,s,{get:()=>t[s],enumerable:!(o=he(t,s))||o.enumerable});return e};var ve=(e,t,n)=>(n=e!=null?ge(ye(e)):{},ne(t||!e||!e.__esModule?q(n,"default",{value:e,enumerable:!0}):n,e)),Pe=e=>ne(q({},"__esModule",{value:!0}),e);var qe={};xe(qe,{COOKIE_CONSENT_NAME:()=>H,CookieConsentBanner:()=>X,EntityStatus:()=>se,MediaType:()=>oe,PhygitalConsentProvider:()=>Le,PolicyPopup:()=>te,consentQueryKeys:()=>x,consentService:()=>w,getConsentPreferenceCookie:()=>M,getCookie:()=>re,policyQueryKeys:()=>Y,setConsentPreferenceCookie:()=>K,setCookie:()=>ie,sha256:()=>_,useConsentById:()=>Be,useCreateDeviceCookieConsent:()=>j,useCreateUserConsent:()=>$,useHealth:()=>Ae,useLatestConsentByUserId:()=>V,useLatestCookieConsentByDeviceId:()=>Te,useManyConsents:()=>_e,usePhygitalConsent:()=>Z,usePolicies:()=>J});module.exports=Pe(qe);var oe=(n=>(n.IMAGE="image",n.VIDEO="video",n))(oe||{}),se=(n=>(n.ACTIVE="Active",n.INACTIVE="Inactive",n))(se||{});var y=require("react");var D=require("react");var H="phygital_cookie_consent";function re(e){if(typeof document>"u")return null;let t=document.cookie.match(new RegExp("(?:^|; )"+encodeURIComponent(e)+"=([^;]*)"));return t?decodeURIComponent(t[1]):null}function ie(e,t,n={}){if(typeof document>"u")return;let{maxAge:o=31536e3,path:s="/",sameSite:a="Lax",secure:p=!1}=n,l=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=${s}; max-age=${o}; SameSite=${a}`;p&&(l+="; Secure"),document.cookie=l}function M(){let e=re(H);if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t=="object"&&"deviceId"in t&&"selected_preferences"in t&&typeof t.deviceId=="string"&&Array.isArray(t.selected_preferences))return t}catch{}return null}function K(e,t,n){ie(H,JSON.stringify({deviceId:e,selected_preferences:t}),{maxAge:31536e3,path:"/",sameSite:"Lax",...n})}var R=require("@tanstack/react-query");var A="",w=e=>({getHealth:async()=>{let{data:t}=await e.get("/health");return t},getManyConsents:async t=>{let{data:n}=await e.get(`${A}/consent`,{params:t?{type:t.type}:void 0});return n},getConsentById:async({id:t})=>{let{data:n}=await e.get(`${A}/consent/${t}`);return n},getPolicies:async t=>{let{data:n}=await e.get(`${A}/policy`,{params:t??void 0});return n},getLatestConsentByUserId:async({user_id:t})=>{let{data:n}=await e.get(`${A}/user-id`,{params:{user_id:t}});return n},createUserConsent:async t=>{let{data:n}=await e.post(`${A}/user-id`,t);return n},getLatestCookieConsentByDeviceId:async({device_id:t})=>{let{data:n}=await e.get(`${A}/cookies/device-id`,{params:{device_id:t}});return n},createDeviceCookieConsent:async t=>{let{data:n}=await e.post(`${A}/cookies/device-id`,t);return n}});function ke(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("").toLowerCase()}async function Re(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return ke(n)}function we(e){let t=Se(e),n=Ie(),o=Ue(),s=new Uint32Array(64),a=t.length>>6;for(let l=0;l<a;l++){let d=l<<6;for(let u=0;u<16;u++){let k=d+(u<<2);s[u]=t[k]<<24|t[k+1]<<16|t[k+2]<<8|t[k+3]}for(let u=16;u<64;u++){let k=I(s[u-15],7)^I(s[u-15],18)^s[u-15]>>>3,O=I(s[u-2],17)^I(s[u-2],19)^s[u-2]>>>10;s[u]=s[u-16]+k+s[u-7]+O>>>0}let c=o[0],v=o[1],C=o[2],S=o[3],g=o[4],P=o[5],f=o[6],b=o[7];for(let u=0;u<64;u++){let k=I(g,6)^I(g,11)^I(g,25),O=g&P^~g&f,N=b+k+O+n[u]+s[u]>>>0,Q=I(c,2)^I(c,13)^I(c,22),W=c&v^c&C^v&C,i=Q+W>>>0;b=f,f=P,P=g,g=S+N>>>0,S=C,C=v,v=c,c=N+i>>>0}o[0]=o[0]+c>>>0,o[1]=o[1]+v>>>0,o[2]=o[2]+C>>>0,o[3]=o[3]+S>>>0,o[4]=o[4]+g>>>0,o[5]=o[5]+P>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+b>>>0}let p="";for(let l=0;l<8;l++){let d=o[l];p+=(d>>>28).toString(16)+(d>>>24&15).toString(16)+(d>>>20&15).toString(16)+(d>>>16&15).toString(16)+(d>>>12&15).toString(16)+(d>>>8&15).toString(16)+(d>>>4&15).toString(16)+(d&15).toString(16)}return p.toLowerCase()}function I(e,t){return e>>>t|e<<32-t}function Se(e){let t=e.length,n=[];for(let d=0;d<t;d++){let c=e.charCodeAt(d);c<128?n.push(c):c<2048?n.push(192|c>>6,128|c&63):c<55296||c>=57344?n.push(224|c>>12,128|c>>6&63,128|c&63):(c=65536+((c&1023)<<10|e.charCodeAt(++d)&1023),n.push(240|c>>18,128|c>>12&63,128|c>>6&63,128|c&63))}let o=n.length,s=(64-(o+9)%64)%64,a=o+9+s,p=new Uint8Array(a);p.set(n),p[o]=128;let l=new DataView(p.buffer,p.byteOffset,p.byteLength);return l.setUint32(a-8,0,!1),l.setUint32(a-4,o*8>>>0,!1),p}function Ie(){let e=[];return"428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5 d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174 e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da 983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967 27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85 a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070 19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3 748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2".split(" ").forEach(n=>e.push(parseInt(n,16))),e}function Ue(){return[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]}function Ee(){return!(typeof crypto>"u"||!crypto.subtle)}async function _(e){return typeof e!="string"||e.length===0?e:Ee()?Re(e):Promise.resolve(we(e))}var z=require("@tanstack/react-query"),ce=ve(require("axios")),B=require("react"),F=require("react/jsx-runtime"),ae=(0,B.createContext)(void 0),De=({baseURL:e="",axiosConfig:t={},requestInterceptors:n={},responseInterceptors:o={}})=>{let s=ce.default.create({baseURL:e,...t});return s.interceptors.request.use(n.onFulfilled,n.onRejected),s.interceptors.response.use(o.onFulfilled,o.onRejected),{consentApi:s,updateHeaders:p=>{Object.entries(p).forEach(([l,d])=>{s.defaults.headers.common[l]=d})}}},de=({children:e,baseURL:t="",axiosConfig:n={},queryClient:o,queryClientConfig:s={},requestInterceptors:a={},responseInterceptors:p={}})=>{let l=(0,B.useMemo)(()=>o||new z.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,...s?.defaultOptions?.queries},mutations:{...s?.defaultOptions?.mutations}},queryCache:s?.queryCache,mutationCache:s?.mutationCache}),[o]),d=(0,B.useMemo)(()=>{let c=De({baseURL:t,axiosConfig:n,requestInterceptors:a,responseInterceptors:p});return{consentApi:c.consentApi,updateHeaders:c.updateHeaders,queryClient:l}},[t,l,n,a,p]);return(0,F.jsx)(ae.Provider,{value:d,children:(0,F.jsx)(z.QueryClientProvider,{client:l,children:e})})},U=()=>{let e=(0,B.useContext)(ae);if(!e)throw new Error("useConsentService must be used within a ConsentServiceProvider");return e};var x={all:["consent"],health:()=>[...x.all,"health"],list:e=>[...x.all,"list",e],detail:e=>[...x.all,"detail",e],latestByUserId:e=>[...x.all,"user-id",e],latestCookieByDeviceId:e=>[...x.all,"cookies","device-id",e]},Ae=e=>{let{consentApi:t}=U(),n=w(t);return(0,R.useQuery)({queryKey:x.health(),queryFn:()=>n.getHealth(),...e})},_e=(e,t)=>{let{consentApi:n}=U(),o=w(n);return(0,R.useQuery)({queryKey:x.list(e),queryFn:()=>o.getManyConsents(e),...t})},Be=(e,t)=>{let{consentApi:n}=U(),o=w(n);return(0,R.useQuery)({queryKey:x.detail(e.id),queryFn:()=>o.getConsentById(e),enabled:!!e.id,...t})},V=(e,t)=>{let{consentApi:n}=U(),o=w(n);return(0,R.useQuery)({queryKey:x.latestByUserId(e.user_id),queryFn:async()=>{let s=await _(e.user_id);return o.getLatestConsentByUserId({user_id:s})},enabled:!!e.user_id,...t})},Te=(e,t)=>{let{consentApi:n}=U(),o=w(n);return(0,R.useQuery)({queryKey:x.latestCookieByDeviceId(e.device_id),queryFn:async()=>{let s=await _(e.device_id);return o.getLatestCookieConsentByDeviceId({device_id:s})},enabled:!!e.device_id,...t})},$=e=>{let{consentApi:t}=U(),n=(0,R.useQueryClient)(),o=w(t);return(0,R.useMutation)({mutationFn:async s=>{let a={...s};return s.user_id!=null&&s.user_id!==""&&(a.user_id=await _(s.user_id)),s.device_id!=null&&s.device_id!==""&&(a.device_id=await _(s.device_id)),o.createUserConsent(a)},onSuccess:(s,a)=>{a.user_id&&n.invalidateQueries({queryKey:x.latestByUserId(a.user_id)}),n.invalidateQueries({queryKey:x.list()})},...e})},j=e=>{let{consentApi:t}=U(),n=(0,R.useQueryClient)(),o=w(t);return(0,R.useMutation)({mutationFn:async s=>{let a={...s,device_id:await _(s.device_id)};return o.createDeviceCookieConsent(a)},onSuccess:(s,a)=>{n.invalidateQueries({queryKey:x.latestCookieByDeviceId(a.device_id)}),n.invalidateQueries({queryKey:x.list()})},...e})};var le=require("@tanstack/react-query");var Y={all:["policy"],list:e=>[...Y.all,"list",e]},J=(e,t)=>{let{consentApi:n}=U(),o=w(n);return(0,le.useQuery)({queryKey:Y.list(e),queryFn:()=>o.getPolicies(e),...t})};var r=require("react/jsx-runtime");function X({onSubmitted:e,onDismiss:t,className:n=""}){let[o,s]=(0,D.useState)(!1),[a,p]=(0,D.useState)(!1),[l,d]=(0,D.useState)(null),[c,v]=(0,D.useState)({}),{data:C}=J({type:"COOKIE_PREFERENCE",status:"ACTIVE"}),g=(0,D.useMemo)(()=>C?C?.find(i=>i.type==="COOKIE_PREFERENCE"&&i.status==="ACTIVE")??C?.[0]:null,[C])?.preferences??[],P=(0,D.useMemo)(()=>({...Object.fromEntries(g.map(h=>[h.id??"",!0]).filter(([h])=>!!h)),...c}),[g,c]),{deviceId:f}=Z(),b=j({onSuccess:(i,h)=>{K(f,h.selected_preferences??[]),e?.(),t?.(),s(!0),p(!1)}}),u=()=>g.map(i=>i.id).filter(i=>!!i).filter(i=>P[i]),k=(i,h)=>({device_id:f,status:i,selected_preferences:h,page_url:typeof window<"u"?window.location.href:void 0,user_agent:typeof navigator<"u"?navigator.userAgent:void 0}),O=i=>{g.find(E=>E.id===i)?.is_mandatory||v(E=>({...E,[i]:!P[i]}))},N=()=>{b.mutate(k("REJECTED",[]))},Q=()=>{let i=g.map(h=>h.id).filter(h=>!!h);b.mutate(k("ACCEPTED",i.length>0?i:[]))},W=()=>{let i=u();b.mutate(k("ACCEPTED",i.length>0?i:["essential"]))};return o?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{role:"dialog","aria-label":"Th\xF4ng b\xE1o v\u1EC1 cookie",className:`consent:fixed consent:bottom-0 consent:left-0 consent:right-0 consent:z-50 consent:flex consent:flex-col consent:gap-4 consent:rounded-t-xl consent:border consent:border-b-0 consent:border-gray-200 consent:bg-white consent:p-4 consent:shadow-lg consent:md:left-4 consent:md:right-auto consent:md:bottom-4 consent:md:max-w-md consent:md:rounded-xl consent:md:border consent:md:border-gray-200 ${n}`,style:{position:"fixed",bottom:0,left:0,right:0,zIndex:50,display:"flex",flexDirection:"column",gap:"1rem",borderRadius:"0.75rem 0.75rem 0 0",borderWidth:"1px 1px 0 1px",borderColor:"#e5e7eb",backgroundColor:"#fff",padding:"1rem",boxShadow:"0 -4px 6px -1px rgb(0 0 0 / 0.1)"},children:[(0,r.jsx)("h2",{className:"consent:text-lg consent:font-semibold consent:text-gray-900",style:{fontSize:"1.125rem",fontWeight:600,color:"#111827"},children:"Th\xF4ng b\xE1o v\u1EC1 cookie"}),(0,r.jsxs)("div",{className:"consent:text-sm consent:text-gray-600",style:{fontSize:"0.875rem",color:"#4b5563",display:"flex",flexDirection:"column",gap:"0.5rem"},children:[(0,r.jsx)("p",{children:"TapQuest s\u1EED d\u1EE5ng tr\xECnh theo d\xF5i (nh\u01B0 Cookie ho\u1EB7c SDK) cho:"}),(0,r.jsx)("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:g.map(i=>(0,r.jsx)("li",{children:i.name??i.id??""},i.id??i.name))}),(0,r.jsx)("p",{children:"Tr\u01B0\u1EDBc khi b\u1EA1n \u0111\u1ED3ng \xFD, ch\u1EC9 nh\u1EEFng tr\xECnh theo d\xF5i ho\xE0n to\xE0n c\u1EA7n thi\u1EBFt m\u1EDBi \u0111\u01B0\u1EE3c tri\u1EC3n khai."}),(0,r.jsx)("p",{children:"N\u1EBFu b\u1EA1n ch\u1ECDn Ch\u1EA5p nh\u1EADn t\u1EA5t c\u1EA3, b\u1EA1n \u0111\u1ED3ng \xFD s\u1EED d\u1EE5ng t\u1EA5t c\u1EA3 tr\xECnh theo d\xF5i c\u1EE7a ch\xFAng t\xF4i."}),(0,r.jsx)("p",{children:"N\u1EBFu b\u1EA1n ch\u1ECDn T\u1EEB ch\u1ED1i t\u1EA5t c\u1EA3, b\u1EA1n t\u1EEB ch\u1ED1i nh\u1EEFng tr\xECnh theo d\xF5i y\xEAu c\u1EA7u s\u1EF1 \u0111\u1ED3ng \xFD c\u1EE7a b\u1EA1n v\xE0 s\u1EBD kh\xF4ng c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o c\xE1c \u0111\u1EC1 ngh\u1ECB ho\u1EB7c n\u1ED9i dung \u0111\u01B0\u1EE3c c\xE1 nh\xE2n h\xF3a."}),(0,r.jsx)("p",{children:"N\u1EBFu b\u1EA1n ch\u1ECDn T\xF9y ch\u1ECDn, b\u1EA1n c\xF3 th\u1EC3 ch\u1ECDn xem b\u1EA1n c\xF3 \u0111\u1ED3ng \xFD s\u1EED d\u1EE5ng tr\xECnh theo d\xF5i tr\xEAn \u1EE9ng d\u1EE5ng c\u1EE7a ch\xFAng t\xF4i hay kh\xF4ng v\xE0 \u1EDF m\u1EE9c \u0111\u1ED9 n\xE0o."}),(0,r.jsxs)("p",{children:["B\u1EA1n c\xF3 th\u1EC3 r\xFAt l\u1EA1i s\u1EF1 \u0111\u1ED3ng \xFD c\u1EE7a m\xECnh b\u1EA5t k\u1EF3 l\xFAc n\xE0o b\u1EB1ng c\xE1ch nh\u1EA5p v\xE0o li\xEAn k\u1EBFt trong"," ","Ch\xEDnh s\xE1ch cookie"," ","c\u1EE7a ch\xFAng t\xF4i."]})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 flex-wrap",children:[(0,r.jsx)("button",{type:"button",onClick:()=>p(!0),className:"consent:rounded-lg consent:border consent:border-gray-300 consent:bg-white consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-gray-700 consent:shadow-sm hover:consent:bg-gray-50 disabled:consent:opacity-50",style:{borderRadius:"0.5rem",border:"1px solid #111827",background:"#fff",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#111827",cursor:"pointer"},children:"T\xF9y ch\u1ECDn"}),(0,r.jsx)("button",{type:"button",onClick:N,disabled:b.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm hover:consent:bg-gray-800 disabled:consent:opacity-50",style:{borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer"},children:"T\u1EEB ch\u1ED1i t\u1EA5t c\u1EA3"}),(0,r.jsx)("button",{type:"button",onClick:Q,disabled:b.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm hover:consent:bg-gray-800 disabled:consent:opacity-50",style:{borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer"},children:"Ch\u1EA5p nh\u1EADn t\u1EA5t c\u1EA3"})]}),b.isError&&(0,r.jsx)("p",{className:"consent:text-sm consent:text-red-600",style:{fontSize:"0.875rem",color:"#dc2626"},children:"\u0110\xE3 x\u1EA3y ra l\u1ED7i. Vui l\xF2ng th\u1EED l\u1EA1i."})]}),a&&(0,r.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Trung t\xE2m tu\u1EF3 ch\u1ECDn b\u1EA3o m\u1EADt",style:{position:"fixed",inset:0,zIndex:60,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)",padding:"1rem"},onClick:i=>i.target===i.currentTarget&&p(!1),children:(0,r.jsxs)("div",{className:"consent:bg-white consent:rounded-xl consent:border consent:border-gray-200 consent:shadow-lg consent:max-h-[90vh] consent:overflow-y-auto",style:{backgroundColor:"#fff",borderRadius:"0.75rem",border:"1px solid #e5e7eb",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1)",maxWidth:"28rem",width:"100%",maxHeight:"90vh",overflowY:"auto",padding:"1.25rem",position:"relative"},onClick:i=>i.stopPropagation(),children:[(0,r.jsx)("button",{type:"button",onClick:()=>p(!1),"aria-label":"\u0110\xF3ng",style:{position:"absolute",top:"1rem",right:"1rem",width:"2rem",height:"2rem",borderRadius:"0.25rem",border:"none",background:"transparent",cursor:"pointer",fontSize:"1.25rem",lineHeight:1,color:"#6b7280"},children:"\xD7"}),(0,r.jsx)("h2",{className:"consent:text-lg consent:font-semibold consent:text-gray-900",style:{fontSize:"1.125rem",fontWeight:600,color:"#111827",marginBottom:"0.75rem",paddingRight:"2rem"},children:"Trung t\xE2m tu\u1EF3 ch\u1ECDn b\u1EA3o m\u1EADt"}),(0,r.jsxs)("div",{className:"consent:text-sm consent:text-gray-600",style:{fontSize:"0.875rem",color:"#4b5563",marginBottom:"1rem"},children:[(0,r.jsx)("p",{style:{marginBottom:"0.5rem"},children:"Khi b\u1EA1n truy c\u1EADp b\u1EA5t k\u1EF3 trang web n\xE0o, trang web \u0111\xF3 c\xF3 th\u1EC3 l\u01B0u tr\u1EEF ho\u1EB7c truy xu\u1EA5t th\xF4ng tin tr\xEAn tr\xECnh duy\u1EC7t c\u1EE7a b\u1EA1n, ch\u1EE7 y\u1EBFu d\u01B0\u1EDBi d\u1EA1ng cookie. Th\xF4ng tin n\xE0y c\xF3 th\u1EC3 li\xEAn quan \u0111\u1EBFn b\u1EA1n, t\xF9y ch\u1ECDn c\u1EE7a b\u1EA1n ho\u1EB7c thi\u1EBFt b\u1ECB c\u1EE7a b\u1EA1n, v\xE0 ch\u1EE7 y\u1EBFu \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 trang web ho\u1EA1t \u0111\u1ED9ng nh\u01B0 mong \u0111\u1EE3i."}),(0,r.jsx)("p",{style:{marginBottom:"0.5rem"},children:"Th\xF4ng tin n\xE0y th\u01B0\u1EDDng kh\xF4ng tr\u1EF1c ti\u1EBFp x\xE1c \u0111\u1ECBnh b\u1EA1n nh\u01B0ng c\xF3 th\u1EC3 mang l\u1EA1i tr\u1EA3i nghi\u1EC7m web \u0111\u01B0\u1EE3c c\xE1 nh\xE2n h\xF3a h\u01A1n. Ch\xFAng t\xF4i t\xF4n tr\u1ECDng quy\u1EC1n ri\xEAng t\u01B0 c\u1EE7a b\u1EA1n; b\u1EA1n c\xF3 th\u1EC3 ch\u1ECDn kh\xF4ng cho ph\xE9p m\u1ED9t s\u1ED1 lo\u1EA1i cookie. Nh\u1EA5p v\xE0o ti\xEAu \u0111\u1EC1 t\u1EEBng danh m\u1EE5c \u0111\u1EC3 t\xECm hi\u1EC3u th\xEAm v\xE0 thay \u0111\u1ED5i c\xE0i \u0111\u1EB7t m\u1EB7c \u0111\u1ECBnh. Vi\u1EC7c ch\u1EB7n m\u1ED9t s\u1ED1 cookie c\xF3 th\u1EC3 \u1EA3nh h\u01B0\u1EDFng \u0111\u1EBFn tr\u1EA3i nghi\u1EC7m c\u1EE7a b\u1EA1n v\u1EDBi trang web v\xE0 c\xE1c d\u1ECBch v\u1EE5 \u0111\u01B0\u1EE3c cung c\u1EA5p."}),(0,r.jsx)("p",{style:{marginBottom:"0.5rem"},children:'N\u1EBFu ch\u1ECDn "Kh\xF4ng theo d\xF5i" khi l\u1EA7n \u0111\u1EA7u s\u1EED d\u1EE5ng TapQuest, ch\u1EC9 cookie ho\xE0n to\xE0n c\u1EA7n thi\u1EBFt m\u1EDBi \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng.'}),(0,r.jsx)("span",{style:{color:"#2563eb",textDecoration:"underline"},children:"Th\xF4ng tin kh\xE1c"})]}),(0,r.jsx)("h3",{className:"consent:text-sm consent:font-semibold consent:text-gray-900",style:{fontSize:"0.875rem",fontWeight:600,color:"#111827",marginBottom:"0.75rem"},children:"Qu\u1EA3n l\xFD tu\u1EF3 ch\u1ECDn \u0111\u1ED3ng \xFD"}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",marginBottom:"1.25rem"},children:g.map(i=>{let h=i.id??i.name??"",E=P[h],G=l===h,L=i.is_mandatory===!0;return(0,r.jsxs)("div",{style:{border:"1px solid #e5e7eb",borderRadius:"0.5rem",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.75rem",cursor:"pointer",backgroundColor:G?"#f9fafb":"transparent"},onClick:()=>d(G?null:h),children:[(0,r.jsx)("span",{style:{flexShrink:0,width:"1.25rem",height:"1.25rem",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1rem",color:"#6b7280",transform:G?"rotate(45deg)":"none",transition:"transform 0.2s"},children:"+"}),(0,r.jsx)("span",{className:"consent:font-medium consent:text-gray-900",style:{flex:1,fontSize:"0.875rem",fontWeight:500,color:"#111827"},children:i.name??h}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":E,"aria-label":`${i.name??h} ${E?"b\u1EADt":"t\u1EAFt"}`,disabled:L,onClick:fe=>{fe.stopPropagation(),O(h)},style:{flexShrink:0,width:44,height:24,borderRadius:12,border:"none",padding:0,cursor:L?"default":"pointer",backgroundColor:L?"#e5e7eb":E?"#111827":"#d1d5db",opacity:L?.7:1,transition:"background-color 0.2s"},children:(0,r.jsx)("span",{style:{display:"block",width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",marginLeft:E?22:2,marginTop:2,transition:"margin-left 0.2s",boxShadow:"0 1px 2px rgb(0 0 0 / 0.2)"}})})]}),G&&(0,r.jsx)("div",{className:"consent:text-sm consent:text-gray-600",style:{fontSize:"0.875rem",color:"#4b5563",padding:"0.75rem 0.75rem 0.75rem 2.5rem",borderTop:"1px solid #e5e7eb"},children:i.description??""})]},h)})}),(0,r.jsx)("button",{type:"button",onClick:W,disabled:b.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm hover:consent:bg-gray-800 disabled:consent:opacity-50 consent:w-full",style:{borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer",width:"100%"},children:"X\xE1c nh\u1EADn l\u1EF1a ch\u1ECDn c\u1EE7a t\xF4i"})]})})]})}var ee=require("react");var m=require("react/jsx-runtime"),Oe=`
2
+ "use strict";var he=Object.create;var W=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty;var ve=(e,t)=>{for(var n in t)W(e,n,{get:t[n],enumerable:!0})},oe=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ye(t))!xe.call(e,s)&&s!==n&&W(e,s,{get:()=>t[s],enumerable:!(o=Ce(t,s))||o.enumerable});return e};var Pe=(e,t,n)=>(n=e!=null?he(be(e)):{},oe(t||!e||!e.__esModule?W(n,"default",{value:e,enumerable:!0}):n,e)),ke=e=>oe(W({},"__esModule",{value:!0}),e);var We={};ve(We,{COOKIE_CONSENT_NAME:()=>F,CookieConsentBanner:()=>ee,EntityStatus:()=>re,MediaType:()=>se,PhygitalConsentProvider:()=>ze,PolicyPopup:()=>ne,consentQueryKeys:()=>x,consentService:()=>w,getConsentPreferenceCookie:()=>N,getCookie:()=>ie,isAnalyticsAllowed:()=>L,policyQueryKeys:()=>X,setConsentPreferenceCookie:()=>V,setCookie:()=>ce,sha256:()=>_,useConsentById:()=>Te,useCreateDeviceCookieConsent:()=>J,useCreateUserConsent:()=>Y,useHealth:()=>_e,useIsAnalyticsAllowed:()=>Qe,useLatestConsentByUserId:()=>j,useLatestCookieConsentByDeviceId:()=>Oe,useManyConsents:()=>Be,usePhygitalConsent:()=>G,usePolicies:()=>Z});module.exports=ke(We);var se=(n=>(n.IMAGE="image",n.VIDEO="video",n))(se||{}),re=(n=>(n.ACTIVE="Active",n.INACTIVE="Inactive",n))(re||{});var y=require("react");var U=require("react");var F="phygital_cookie_consent";function ie(e){if(typeof document>"u")return null;let t=document.cookie.match(new RegExp("(?:^|; )"+encodeURIComponent(e)+"=([^;]*)"));return t?decodeURIComponent(t[1]):null}function ce(e,t,n={}){if(typeof document>"u")return;let{maxAge:o=31536e3,path:s="/",sameSite:a="Lax",secure:p=!1}=n,l=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=${s}; max-age=${o}; SameSite=${a}`;p&&(l+="; Secure"),document.cookie=l}function N(){let e=ie(F);if(!e)return null;try{let t=JSON.parse(e);if(t&&typeof t=="object"&&"deviceId"in t&&"selected_preferences"in t&&typeof t.deviceId=="string"&&Array.isArray(t.selected_preferences))return t}catch{}return null}function V(e,t,n){ce(F,JSON.stringify({deviceId:e,selected_preferences:t}),{maxAge:31536e3,path:"/",sameSite:"Lax",...n})}var R=require("@tanstack/react-query");var D="",w=e=>({getHealth:async()=>{let{data:t}=await e.get("/health");return t},getManyConsents:async t=>{let{data:n}=await e.get(`${D}/consent`,{params:t?{type:t.type}:void 0});return n},getConsentById:async({id:t})=>{let{data:n}=await e.get(`${D}/consent/${t}`);return n},getPolicies:async t=>{let{data:n}=await e.get(`${D}/policy`,{params:t??void 0});return n},getLatestConsentByUserId:async({user_id:t})=>{let{data:n}=await e.get(`${D}/user-id`,{params:{user_id:t}});return n},createUserConsent:async t=>{let{data:n}=await e.post(`${D}/user-id`,t);return n},getLatestCookieConsentByDeviceId:async({device_id:t})=>{let{data:n}=await e.get(`${D}/cookies/device-id`,{params:{device_id:t}});return n},createDeviceCookieConsent:async t=>{let{data:n}=await e.post(`${D}/cookies/device-id`,t);return n}});function Re(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("").toLowerCase()}async function we(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Re(n)}function Se(e){let t=Ie(e),n=Ae(),o=Ee(),s=new Uint32Array(64),a=t.length>>6;for(let l=0;l<a;l++){let d=l<<6;for(let u=0;u<16;u++){let k=d+(u<<2);s[u]=t[k]<<24|t[k+1]<<16|t[k+2]<<8|t[k+3]}for(let u=16;u<64;u++){let k=I(s[u-15],7)^I(s[u-15],18)^s[u-15]>>>3,O=I(s[u-2],17)^I(s[u-2],19)^s[u-2]>>>10;s[u]=s[u-16]+k+s[u-7]+O>>>0}let c=o[0],v=o[1],C=o[2],S=o[3],g=o[4],P=o[5],f=o[6],b=o[7];for(let u=0;u<64;u++){let k=I(g,6)^I(g,11)^I(g,25),O=g&P^~g&f,q=b+k+O+n[u]+s[u]>>>0,M=I(c,2)^I(c,13)^I(c,22),K=c&v^c&C^v&C,i=M+K>>>0;b=f,f=P,P=g,g=S+q>>>0,S=C,C=v,v=c,c=q+i>>>0}o[0]=o[0]+c>>>0,o[1]=o[1]+v>>>0,o[2]=o[2]+C>>>0,o[3]=o[3]+S>>>0,o[4]=o[4]+g>>>0,o[5]=o[5]+P>>>0,o[6]=o[6]+f>>>0,o[7]=o[7]+b>>>0}let p="";for(let l=0;l<8;l++){let d=o[l];p+=(d>>>28).toString(16)+(d>>>24&15).toString(16)+(d>>>20&15).toString(16)+(d>>>16&15).toString(16)+(d>>>12&15).toString(16)+(d>>>8&15).toString(16)+(d>>>4&15).toString(16)+(d&15).toString(16)}return p.toLowerCase()}function I(e,t){return e>>>t|e<<32-t}function Ie(e){let t=e.length,n=[];for(let d=0;d<t;d++){let c=e.charCodeAt(d);c<128?n.push(c):c<2048?n.push(192|c>>6,128|c&63):c<55296||c>=57344?n.push(224|c>>12,128|c>>6&63,128|c&63):(c=65536+((c&1023)<<10|e.charCodeAt(++d)&1023),n.push(240|c>>18,128|c>>12&63,128|c>>6&63,128|c&63))}let o=n.length,s=(64-(o+9)%64)%64,a=o+9+s,p=new Uint8Array(a);p.set(n),p[o]=128;let l=new DataView(p.buffer,p.byteOffset,p.byteLength);return l.setUint32(a-8,0,!1),l.setUint32(a-4,o*8>>>0,!1),p}function Ae(){let e=[];return"428a2f98 71374491 b5c0fbcf e9b5dba5 3956c25b 59f111f1 923f82a4 ab1c5ed5 d807aa98 12835b01 243185be 550c7dc3 72be5d74 80deb1fe 9bdc06a7 c19bf174 e49b69c1 efbe4786 0fc19dc6 240ca1cc 2de92c6f 4a7484aa 5cb0a9dc 76f988da 983e5152 a831c66d b00327c8 bf597fc7 c6e00bf3 d5a79147 06ca6351 14292967 27b70a85 2e1b2138 4d2c6dfc 53380d13 650a7354 766a0abb 81c2c92e 92722c85 a2bfe8a1 a81a664b c24b8b70 c76c51a3 d192e819 d6990624 f40e3585 106aa070 19a4c116 1e376c08 2748774c 34b0bcb5 391c0cb3 4ed8aa4a 5b9cca4f 682e6ff3 748f82ee 78a5636f 84c87814 8cc70208 90befffa a4506ceb bef9a3f7 c67178f2".split(" ").forEach(n=>e.push(parseInt(n,16))),e}function Ee(){return[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]}function Ue(){return!(typeof crypto>"u"||!crypto.subtle)}async function _(e){return typeof e!="string"||e.length===0?e:Ue()?we(e):Promise.resolve(Se(e))}var H=require("@tanstack/react-query"),ae=Pe(require("axios")),B=require("react"),$=require("react/jsx-runtime"),de=(0,B.createContext)(void 0),De=({baseURL:e="",axiosConfig:t={},requestInterceptors:n={},responseInterceptors:o={}})=>{let s=ae.default.create({baseURL:e,...t});return s.interceptors.request.use(n.onFulfilled,n.onRejected),s.interceptors.response.use(o.onFulfilled,o.onRejected),{consentApi:s,updateHeaders:p=>{Object.entries(p).forEach(([l,d])=>{s.defaults.headers.common[l]=d})}}},le=({children:e,baseURL:t="",axiosConfig:n={},queryClient:o,queryClientConfig:s={},requestInterceptors:a={},responseInterceptors:p={}})=>{let l=(0,B.useMemo)(()=>o||new H.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1,...s?.defaultOptions?.queries},mutations:{...s?.defaultOptions?.mutations}},queryCache:s?.queryCache,mutationCache:s?.mutationCache}),[o]),d=(0,B.useMemo)(()=>{let c=De({baseURL:t,axiosConfig:n,requestInterceptors:a,responseInterceptors:p});return{consentApi:c.consentApi,updateHeaders:c.updateHeaders,queryClient:l}},[t,l,n,a,p]);return(0,$.jsx)(de.Provider,{value:d,children:(0,$.jsx)(H.QueryClientProvider,{client:l,children:e})})},A=()=>{let e=(0,B.useContext)(de);if(!e)throw new Error("useConsentService must be used within a ConsentServiceProvider");return e};var x={all:["consent"],health:()=>[...x.all,"health"],list:e=>[...x.all,"list",e],detail:e=>[...x.all,"detail",e],latestByUserId:e=>[...x.all,"user-id",e],latestCookieByDeviceId:e=>[...x.all,"cookies","device-id",e]},_e=e=>{let{consentApi:t}=A(),n=w(t);return(0,R.useQuery)({queryKey:x.health(),queryFn:()=>n.getHealth(),...e})},Be=(e,t)=>{let{consentApi:n}=A(),o=w(n);return(0,R.useQuery)({queryKey:x.list(e),queryFn:()=>o.getManyConsents(e),...t})},Te=(e,t)=>{let{consentApi:n}=A(),o=w(n);return(0,R.useQuery)({queryKey:x.detail(e.id),queryFn:()=>o.getConsentById(e),enabled:!!e.id,...t})},j=(e,t)=>{let{consentApi:n}=A(),o=w(n);return(0,R.useQuery)({queryKey:x.latestByUserId(e.user_id),queryFn:async()=>{let s=await _(e.user_id);return o.getLatestConsentByUserId({user_id:s})},enabled:!!e.user_id,...t})},Oe=(e,t)=>{let{consentApi:n}=A(),o=w(n);return(0,R.useQuery)({queryKey:x.latestCookieByDeviceId(e.device_id),queryFn:async()=>{let s=await _(e.device_id);return o.getLatestCookieConsentByDeviceId({device_id:s})},enabled:!!e.device_id,...t})},Y=e=>{let{consentApi:t}=A(),n=(0,R.useQueryClient)(),o=w(t);return(0,R.useMutation)({mutationFn:async s=>{let a={...s};return s.user_id!=null&&s.user_id!==""&&(a.user_id=await _(s.user_id)),s.device_id!=null&&s.device_id!==""&&(a.device_id=await _(s.device_id)),o.createUserConsent(a)},onSuccess:(s,a)=>{a.user_id&&n.invalidateQueries({queryKey:x.latestByUserId(a.user_id)}),n.invalidateQueries({queryKey:x.list()})},...e})},J=e=>{let{consentApi:t}=A(),n=(0,R.useQueryClient)(),o=w(t);return(0,R.useMutation)({mutationFn:async s=>{let a={...s,device_id:await _(s.device_id)};return o.createDeviceCookieConsent(a)},onSuccess:(s,a)=>{n.invalidateQueries({queryKey:x.latestCookieByDeviceId(a.device_id)}),n.invalidateQueries({queryKey:x.list()})},...e})};var ue=require("@tanstack/react-query");var X={all:["policy"],list:e=>[...X.all,"list",e]},Z=(e,t)=>{let{consentApi:n}=A(),o=w(n);return(0,ue.useQuery)({queryKey:X.list(e),queryFn:()=>o.getPolicies(e),...t})};var r=require("react/jsx-runtime");function ee({onSubmitted:e,onDismiss:t,className:n=""}){let[o,s]=(0,U.useState)(!1),[a,p]=(0,U.useState)(!1),[l,d]=(0,U.useState)(null),[c,v]=(0,U.useState)({}),{data:C}=Z({type:"COOKIE_PREFERENCE",status:"ACTIVE"}),g=(0,U.useMemo)(()=>C?C?.find(i=>i.type==="COOKIE_PREFERENCE"&&i.status==="ACTIVE")??C?.[0]:null,[C])?.preferences??[],P=(0,U.useMemo)(()=>({...Object.fromEntries(g.map(h=>[h.id??"",!0]).filter(([h])=>!!h)),...c}),[g,c]),{deviceId:f}=G(),b=J({onSuccess:(i,h)=>{V(f,h.selected_preferences??[]),e?.(),t?.(),s(!0),p(!1)}}),u=()=>g.map(i=>i.id).filter(i=>!!i).filter(i=>P[i]),k=(i,h)=>({device_id:f,status:i,selected_preferences:h,page_url:typeof window<"u"?window.location.href:void 0,user_agent:typeof navigator<"u"?navigator.userAgent:void 0}),O=i=>{g.find(E=>E.id===i)?.is_mandatory||v(E=>({...E,[i]:!P[i]}))},q=()=>{b.mutate(k("REJECTED",[]))},M=()=>{let i=g.map(h=>h.id).filter(h=>!!h);b.mutate(k("ACCEPTED",i.length>0?i:[]))},K=()=>{let i=u();b.mutate(k("ACCEPTED",i.length>0?i:["essential"]))};return o?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{role:"dialog","aria-label":"Th\xF4ng b\xE1o v\u1EC1 cookie",className:`consent:fixed consent:bottom-0 consent:left-0 consent:right-0 consent:z-50 consent:flex consent:flex-col consent:gap-4 consent:rounded-t-xl consent:border consent:border-b-0 consent:border-gray-200 consent:bg-white consent:p-4 consent:shadow-lg consent:md:left-4 consent:md:right-auto consent:md:bottom-4 consent:md:max-w-md consent:md:rounded-xl consent:md:border consent:md:border-gray-200 ${n}`,style:{position:"fixed",bottom:0,left:0,right:0,zIndex:50,display:"flex",flexDirection:"column",gap:"1rem",borderRadius:"0.75rem 0.75rem 0 0",borderWidth:"1px 1px 0 1px",borderColor:"#e5e7eb",backgroundColor:"#fff",padding:"1rem",boxShadow:"0 -4px 6px -1px rgb(0 0 0 / 0.1)"},children:[(0,r.jsx)("h2",{className:"consent:text-lg consent:font-semibold consent:text-gray-900",style:{fontSize:"1.125rem",fontWeight:600,color:"#111827"},children:"Th\xF4ng b\xE1o v\u1EC1 cookie"}),(0,r.jsxs)("div",{className:"consent:text-sm consent:text-gray-600",style:{fontSize:"0.875rem",color:"#4b5563",display:"flex",flexDirection:"column",gap:"0.5rem"},children:[(0,r.jsx)("p",{children:"TapQuest s\u1EED d\u1EE5ng tr\xECnh theo d\xF5i (nh\u01B0 Cookie ho\u1EB7c SDK) cho:"}),(0,r.jsx)("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:g.map(i=>(0,r.jsx)("li",{children:i.name??i.id??""},i.id??i.name))}),(0,r.jsx)("p",{children:"Tr\u01B0\u1EDBc khi b\u1EA1n \u0111\u1ED3ng \xFD, ch\u1EC9 nh\u1EEFng tr\xECnh theo d\xF5i ho\xE0n to\xE0n c\u1EA7n thi\u1EBFt m\u1EDBi \u0111\u01B0\u1EE3c tri\u1EC3n khai."}),(0,r.jsx)("p",{children:"N\u1EBFu b\u1EA1n ch\u1ECDn Ch\u1EA5p nh\u1EADn t\u1EA5t c\u1EA3, b\u1EA1n \u0111\u1ED3ng \xFD s\u1EED d\u1EE5ng t\u1EA5t c\u1EA3 tr\xECnh theo d\xF5i c\u1EE7a ch\xFAng t\xF4i."}),(0,r.jsx)("p",{children:"N\u1EBFu b\u1EA1n ch\u1ECDn T\u1EEB ch\u1ED1i t\u1EA5t c\u1EA3, b\u1EA1n t\u1EEB ch\u1ED1i nh\u1EEFng tr\xECnh theo d\xF5i y\xEAu c\u1EA7u s\u1EF1 \u0111\u1ED3ng \xFD c\u1EE7a b\u1EA1n v\xE0 s\u1EBD kh\xF4ng c\xF3 quy\u1EC1n truy c\u1EADp v\xE0o c\xE1c \u0111\u1EC1 ngh\u1ECB ho\u1EB7c n\u1ED9i dung \u0111\u01B0\u1EE3c c\xE1 nh\xE2n h\xF3a."}),(0,r.jsx)("p",{children:"N\u1EBFu b\u1EA1n ch\u1ECDn T\xF9y ch\u1ECDn, b\u1EA1n c\xF3 th\u1EC3 ch\u1ECDn xem b\u1EA1n c\xF3 \u0111\u1ED3ng \xFD s\u1EED d\u1EE5ng tr\xECnh theo d\xF5i tr\xEAn \u1EE9ng d\u1EE5ng c\u1EE7a ch\xFAng t\xF4i hay kh\xF4ng v\xE0 \u1EDF m\u1EE9c \u0111\u1ED9 n\xE0o."}),(0,r.jsxs)("p",{children:["B\u1EA1n c\xF3 th\u1EC3 r\xFAt l\u1EA1i s\u1EF1 \u0111\u1ED3ng \xFD c\u1EE7a m\xECnh b\u1EA5t k\u1EF3 l\xFAc n\xE0o b\u1EB1ng c\xE1ch nh\u1EA5p v\xE0o li\xEAn k\u1EBFt trong"," ","Ch\xEDnh s\xE1ch cookie"," ","c\u1EE7a ch\xFAng t\xF4i."]})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 flex-wrap",children:[(0,r.jsx)("button",{type:"button",onClick:()=>p(!0),className:"consent:rounded-lg consent:border consent:border-gray-300 consent:bg-white consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-gray-700 consent:shadow-sm hover:consent:bg-gray-50 disabled:consent:opacity-50",style:{borderRadius:"0.5rem",border:"1px solid #111827",background:"#fff",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#111827",cursor:"pointer"},children:"T\xF9y ch\u1ECDn"}),(0,r.jsx)("button",{type:"button",onClick:q,disabled:b.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm hover:consent:bg-gray-800 disabled:consent:opacity-50",style:{borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer"},children:"T\u1EEB ch\u1ED1i t\u1EA5t c\u1EA3"}),(0,r.jsx)("button",{type:"button",onClick:M,disabled:b.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm hover:consent:bg-gray-800 disabled:consent:opacity-50",style:{borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer"},children:"Ch\u1EA5p nh\u1EADn t\u1EA5t c\u1EA3"})]}),b.isError&&(0,r.jsx)("p",{className:"consent:text-sm consent:text-red-600",style:{fontSize:"0.875rem",color:"#dc2626"},children:"\u0110\xE3 x\u1EA3y ra l\u1ED7i. Vui l\xF2ng th\u1EED l\u1EA1i."})]}),a&&(0,r.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Trung t\xE2m tu\u1EF3 ch\u1ECDn b\u1EA3o m\u1EADt",style:{position:"fixed",inset:0,zIndex:60,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)",padding:"1rem"},onClick:i=>i.target===i.currentTarget&&p(!1),children:(0,r.jsxs)("div",{className:"consent:bg-white consent:rounded-xl consent:border consent:border-gray-200 consent:shadow-lg consent:max-h-[90vh] consent:overflow-y-auto",style:{backgroundColor:"#fff",borderRadius:"0.75rem",border:"1px solid #e5e7eb",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1)",maxWidth:"28rem",width:"100%",maxHeight:"90vh",overflowY:"auto",padding:"1.25rem",position:"relative"},onClick:i=>i.stopPropagation(),children:[(0,r.jsx)("button",{type:"button",onClick:()=>p(!1),"aria-label":"\u0110\xF3ng",style:{position:"absolute",top:"1rem",right:"1rem",width:"2rem",height:"2rem",borderRadius:"0.25rem",border:"none",background:"transparent",cursor:"pointer",fontSize:"1.25rem",lineHeight:1,color:"#6b7280"},children:"\xD7"}),(0,r.jsx)("h2",{className:"consent:text-lg consent:font-semibold consent:text-gray-900",style:{fontSize:"1.125rem",fontWeight:600,color:"#111827",marginBottom:"0.75rem",paddingRight:"2rem"},children:"Trung t\xE2m tu\u1EF3 ch\u1ECDn b\u1EA3o m\u1EADt"}),(0,r.jsxs)("div",{className:"consent:text-sm consent:text-gray-600",style:{fontSize:"0.875rem",color:"#4b5563",marginBottom:"1rem"},children:[(0,r.jsx)("p",{style:{marginBottom:"0.5rem"},children:"Khi b\u1EA1n truy c\u1EADp b\u1EA5t k\u1EF3 trang web n\xE0o, trang web \u0111\xF3 c\xF3 th\u1EC3 l\u01B0u tr\u1EEF ho\u1EB7c truy xu\u1EA5t th\xF4ng tin tr\xEAn tr\xECnh duy\u1EC7t c\u1EE7a b\u1EA1n, ch\u1EE7 y\u1EBFu d\u01B0\u1EDBi d\u1EA1ng cookie. Th\xF4ng tin n\xE0y c\xF3 th\u1EC3 li\xEAn quan \u0111\u1EBFn b\u1EA1n, t\xF9y ch\u1ECDn c\u1EE7a b\u1EA1n ho\u1EB7c thi\u1EBFt b\u1ECB c\u1EE7a b\u1EA1n, v\xE0 ch\u1EE7 y\u1EBFu \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng \u0111\u1EC3 trang web ho\u1EA1t \u0111\u1ED9ng nh\u01B0 mong \u0111\u1EE3i."}),(0,r.jsx)("p",{style:{marginBottom:"0.5rem"},children:"Th\xF4ng tin n\xE0y th\u01B0\u1EDDng kh\xF4ng tr\u1EF1c ti\u1EBFp x\xE1c \u0111\u1ECBnh b\u1EA1n nh\u01B0ng c\xF3 th\u1EC3 mang l\u1EA1i tr\u1EA3i nghi\u1EC7m web \u0111\u01B0\u1EE3c c\xE1 nh\xE2n h\xF3a h\u01A1n. Ch\xFAng t\xF4i t\xF4n tr\u1ECDng quy\u1EC1n ri\xEAng t\u01B0 c\u1EE7a b\u1EA1n; b\u1EA1n c\xF3 th\u1EC3 ch\u1ECDn kh\xF4ng cho ph\xE9p m\u1ED9t s\u1ED1 lo\u1EA1i cookie. Nh\u1EA5p v\xE0o ti\xEAu \u0111\u1EC1 t\u1EEBng danh m\u1EE5c \u0111\u1EC3 t\xECm hi\u1EC3u th\xEAm v\xE0 thay \u0111\u1ED5i c\xE0i \u0111\u1EB7t m\u1EB7c \u0111\u1ECBnh. Vi\u1EC7c ch\u1EB7n m\u1ED9t s\u1ED1 cookie c\xF3 th\u1EC3 \u1EA3nh h\u01B0\u1EDFng \u0111\u1EBFn tr\u1EA3i nghi\u1EC7m c\u1EE7a b\u1EA1n v\u1EDBi trang web v\xE0 c\xE1c d\u1ECBch v\u1EE5 \u0111\u01B0\u1EE3c cung c\u1EA5p."}),(0,r.jsx)("p",{style:{marginBottom:"0.5rem"},children:'N\u1EBFu ch\u1ECDn "Kh\xF4ng theo d\xF5i" khi l\u1EA7n \u0111\u1EA7u s\u1EED d\u1EE5ng TapQuest, ch\u1EC9 cookie ho\xE0n to\xE0n c\u1EA7n thi\u1EBFt m\u1EDBi \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng.'}),(0,r.jsx)("span",{style:{color:"#2563eb",textDecoration:"underline"},children:"Th\xF4ng tin kh\xE1c"})]}),(0,r.jsx)("h3",{className:"consent:text-sm consent:font-semibold consent:text-gray-900",style:{fontSize:"0.875rem",fontWeight:600,color:"#111827",marginBottom:"0.75rem"},children:"Qu\u1EA3n l\xFD tu\u1EF3 ch\u1ECDn \u0111\u1ED3ng \xFD"}),(0,r.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",marginBottom:"1.25rem"},children:g.map(i=>{let h=i.id??i.name??"",E=P[h],z=l===h,Q=i.is_mandatory===!0;return(0,r.jsxs)("div",{style:{border:"1px solid #e5e7eb",borderRadius:"0.5rem",overflow:"hidden"},children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.75rem",cursor:"pointer",backgroundColor:z?"#f9fafb":"transparent"},onClick:()=>d(z?null:h),children:[(0,r.jsx)("span",{style:{flexShrink:0,width:"1.25rem",height:"1.25rem",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1rem",color:"#6b7280",transform:z?"rotate(45deg)":"none",transition:"transform 0.2s"},children:"+"}),(0,r.jsx)("span",{className:"consent:font-medium consent:text-gray-900",style:{flex:1,fontSize:"0.875rem",fontWeight:500,color:"#111827"},children:i.name??h}),(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":E,"aria-label":`${i.name??h} ${E?"b\u1EADt":"t\u1EAFt"}`,disabled:Q,onClick:ge=>{ge.stopPropagation(),O(h)},style:{flexShrink:0,width:44,height:24,borderRadius:12,border:"none",padding:0,cursor:Q?"default":"pointer",backgroundColor:Q?"#e5e7eb":E?"#111827":"#d1d5db",opacity:Q?.7:1,transition:"background-color 0.2s"},children:(0,r.jsx)("span",{style:{display:"block",width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",marginLeft:E?22:2,marginTop:2,transition:"margin-left 0.2s",boxShadow:"0 1px 2px rgb(0 0 0 / 0.2)"}})})]}),z&&(0,r.jsx)("div",{className:"consent:text-sm consent:text-gray-600",style:{fontSize:"0.875rem",color:"#4b5563",padding:"0.75rem 0.75rem 0.75rem 2.5rem",borderTop:"1px solid #e5e7eb"},children:i.description??""})]},h)})}),(0,r.jsx)("button",{type:"button",onClick:K,disabled:b.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm hover:consent:bg-gray-800 disabled:consent:opacity-50 consent:w-full",style:{borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer",width:"100%"},children:"X\xE1c nh\u1EADn l\u1EF1a ch\u1ECDn c\u1EE7a t\xF4i"})]})})]})}var te=require("react");var m=require("react/jsx-runtime"),Ne=`
3
3
  Tanta petere igitur et tam longe abesse non opus est. Quodsi haberent magnalia inter potentiam et divitias, et tamen ista philosophia et disciplina vivendi. Quam ob rem ut illi superiores, nos usque ad hanc aetatem. Sed ut iis bonis erudiamur, quae gignuntur ex tempore. Et tamen rerum necessitatibus saepe vincimur. Quam ob rem ut illi superiores, nos usque ad hanc aetatem.
4
- `.trim(),Ne="V\xEC b\u1EA1n kh\xF4ng \u0111\u1ED3ng \xFD v\u1EDBi th\u1ECFa thu\u1EADn n\xE0y. Ch\xFAng t\xF4i s\u1EBD x\xF3a t\xE0i kho\u1EA3n trong v\xF2ng x ng\xE0y";function te({open:e,onClose:t,userId:n,onAgreeSuccess:o}){let[s,a]=(0,ee.useState)(!1),[p,l]=(0,ee.useState)(!1),d=$({onSuccess:(f,b)=>{b.status==="ACCEPTED"&&o?.(),c()}}),c=()=>{a(!1),l(!1),t()},v=()=>{l(!0)},C=()=>{l(!1)},S=f=>({user_id:n,status:f,page_url:typeof window<"u"?window.location.href:void 0,user_agent:typeof navigator<"u"?navigator.userAgent:void 0}),g=()=>{d.mutate(S("REJECTED"))},P=()=>{s&&d.mutate(S("ACCEPTED"))};return e?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt",style:{position:"fixed",inset:0,zIndex:60,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)",padding:"1rem"},onClick:f=>f.target===f.currentTarget&&c(),children:(0,m.jsxs)("div",{className:"consent:bg-white consent:rounded-xl consent:border consent:border-gray-200 consent:shadow-lg consent:max-h-[90vh] consent:overflow-hidden consent:flex consent:flex-col",style:{backgroundColor:"#fff",borderRadius:"0.75rem",border:"1px solid #e5e7eb",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1)",maxWidth:"28rem",width:"100%",maxHeight:"90vh",overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},onClick:f=>f.stopPropagation(),children:[(0,m.jsx)("button",{type:"button",onClick:c,"aria-label":"\u0110\xF3ng",style:{position:"absolute",top:"1rem",right:"1rem",width:"2rem",height:"2rem",borderRadius:"0.25rem",border:"none",background:"transparent",cursor:"pointer",fontSize:"1.25rem",lineHeight:1,color:"#6b7280"},children:"\xD7"}),(0,m.jsx)("h2",{style:{fontSize:"18px",fontWeight:600,color:"#000",padding:"20px 2.5rem 12px 20px"},children:"Ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt"}),(0,m.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"1rem 1.25rem",fontSize:"0.875rem",color:"#111827",lineHeight:1.6},children:(0,m.jsx)("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:Oe})}),(0,m.jsxs)("div",{style:{padding:"1rem 1.25rem 1.25rem 1.25rem",display:"flex",flexDirection:"column",gap:"1rem"},children:[(0,m.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:"#111827",cursor:"pointer"},children:[(0,m.jsx)("input",{type:"checkbox",checked:s,onChange:f=>a(f.target.checked),style:{width:"1rem",height:"1rem",accentColor:"#111827"},"aria-label":"T\xF4i \u0111\u1ED3ng \xFD v\u1EDBi ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt tr\xEAn"}),(0,m.jsx)("span",{children:"T\xF4i \u0111\u1ED3ng \xFD v\u1EDBi ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt tr\xEAn"})]}),(0,m.jsxs)("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[(0,m.jsx)("button",{type:"button",onClick:v,disabled:d.isPending,className:"consent:rounded-lg consent:border consent:border-gray-300 consent:bg-white consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-gray-700 consent:shadow-sm hover:consent:bg-gray-50 disabled:consent:opacity-50",style:{flex:1,borderRadius:"0.5rem",border:"1px solid #111827",background:"#fff",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#111827",cursor:"pointer"},children:"T\u1EEB ch\u1ED1i"}),(0,m.jsx)("button",{type:"button",onClick:P,disabled:!s||d.isPending,className:"consent:rounded-lg consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:shadow-sm disabled:consent:opacity-50 disabled:consent:cursor-not-allowed",style:{flex:1,minWidth:0,borderRadius:"0.5rem",background:s?"#111827":"#e5e7eb",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:s?"#fff":"#9ca3af",border:"none",cursor:s?"pointer":"not-allowed"},children:"Ti\u1EBFp t\u1EE5c"})]}),d.isError&&(0,m.jsx)("p",{className:"consent:text-sm consent:text-red-600",style:{fontSize:"0.875rem",color:"#dc2626",margin:0},children:"\u0110\xE3 x\u1EA3y ra l\u1ED7i. Vui l\xF2ng th\u1EED l\u1EA1i."})]})]})}),p&&(0,m.jsx)("div",{role:"alertdialog","aria-modal":"true","aria-label":"Th\xF4ng b\xE1o t\u1EEB ch\u1ED1i",style:{position:"fixed",inset:0,zIndex:70,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)",padding:"1rem"},onClick:f=>f.target===f.currentTarget&&C(),children:(0,m.jsxs)("div",{className:"consent:bg-white consent:rounded-xl consent:border consent:border-gray-200 consent:shadow-lg",style:{backgroundColor:"#fff",borderRadius:"0.75rem",border:"1px solid #e5e7eb",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1)",maxWidth:"22rem",width:"100%",padding:"1.25rem"},onClick:f=>f.stopPropagation(),children:[(0,m.jsx)("p",{className:"consent:text-sm consent:text-gray-700",style:{fontSize:"0.875rem",color:"#374151",margin:"0 0 1rem 0",lineHeight:1.5},children:Ne}),(0,m.jsxs)("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[(0,m.jsx)("button",{type:"button",onClick:C,className:"consent:rounded-lg consent:border consent:border-gray-300 consent:bg-white consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-gray-700 consent:shadow-sm hover:consent:bg-gray-50 disabled:consent:opacity-50",style:{flex:1,borderRadius:"0.5rem",border:"1px solid #111827",background:"#fff",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#111827",cursor:"pointer"},children:"Tr\u1EDF l\u1EA1i"}),(0,m.jsx)("button",{type:"button",onClick:g,disabled:d.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm disabled:consent:opacity-50 consent:flex-1",style:{flex:1,minWidth:0,borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer"},children:"Ti\u1EBFp t\u1EE5c"})]}),d.isError&&(0,m.jsx)("p",{className:"consent:text-sm consent:text-red-600",style:{fontSize:"0.875rem",color:"#dc2626",margin:"0.5rem 0 0 0"},children:"\u0110\xE3 x\u1EA3y ra l\u1ED7i. Vui l\xF2ng th\u1EED l\u1EA1i."})]})})]}):null}var T=require("react/jsx-runtime"),me=(0,y.createContext)(void 0);function Ge({children:e,deviceId:t,showBannerWhenNoPreference:n=!0}){let[o,s]=(0,y.useState)(!1),[a,p]=(0,y.useState)(null),[l,d]=(0,y.useState)(!1),[c,v]=(0,y.useState)(null),{data:C,isFetched:S}=V({user_id:a??""});(0,y.useEffect)(()=>{if(!(!a||!S)){if(C!=null){p(null);return}v(a),d(!0),p(null)}},[a,S,C]);let g=(0,y.useCallback)(()=>{let u=M();s(!!u)},[]),P=(0,y.useCallback)(u=>{u&&p(u)},[]),f=(0,y.useCallback)(()=>{d(!1),v(null)},[]);(0,y.useEffect)(()=>{g()},[g]);let b={deviceId:t,hasConsentPreference:o,refreshConsentPreference:g,openPolicyPopup:P};return(0,T.jsxs)(me.Provider,{value:b,children:[e,n&&!o&&(0,T.jsx)(X,{onSubmitted:g}),l&&c&&(0,T.jsx)(te,{open:l,onClose:f,userId:c})]})}function Le(e){let{children:t,deviceId:n,showBannerWhenNoPreference:o=!0,...s}=e;return(0,T.jsx)(de,{...s,children:(0,T.jsx)(Ge,{deviceId:n,showBannerWhenNoPreference:o,children:t})})}function Z(){let e=(0,y.useContext)(me);if(!e)throw new Error("usePhygitalConsent must be used within a PhygitalConsentProvider");return e}0&&(module.exports={COOKIE_CONSENT_NAME,CookieConsentBanner,EntityStatus,MediaType,PhygitalConsentProvider,PolicyPopup,consentQueryKeys,consentService,getConsentPreferenceCookie,getCookie,policyQueryKeys,setConsentPreferenceCookie,setCookie,sha256,useConsentById,useCreateDeviceCookieConsent,useCreateUserConsent,useHealth,useLatestConsentByUserId,useLatestCookieConsentByDeviceId,useManyConsents,usePhygitalConsent,usePolicies});
4
+ `.trim(),Ge="V\xEC b\u1EA1n kh\xF4ng \u0111\u1ED3ng \xFD v\u1EDBi th\u1ECFa thu\u1EADn n\xE0y. Ch\xFAng t\xF4i s\u1EBD x\xF3a t\xE0i kho\u1EA3n trong v\xF2ng x ng\xE0y";function ne({open:e,onClose:t,userId:n,onAgreeSuccess:o}){let[s,a]=(0,te.useState)(!1),[p,l]=(0,te.useState)(!1),d=Y({onSuccess:(f,b)=>{b.status==="ACCEPTED"&&o?.(),c()}}),c=()=>{a(!1),l(!1),t()},v=()=>{l(!0)},C=()=>{l(!1)},S=f=>({user_id:n,status:f,page_url:typeof window<"u"?window.location.href:void 0,user_agent:typeof navigator<"u"?navigator.userAgent:void 0}),g=()=>{d.mutate(S("REJECTED"))},P=()=>{s&&d.mutate(S("ACCEPTED"))};return e?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"Ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt",style:{position:"fixed",inset:0,zIndex:60,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)",padding:"1rem"},onClick:f=>f.target===f.currentTarget&&c(),children:(0,m.jsxs)("div",{className:"consent:bg-white consent:rounded-xl consent:border consent:border-gray-200 consent:shadow-lg consent:max-h-[90vh] consent:overflow-hidden consent:flex consent:flex-col",style:{backgroundColor:"#fff",borderRadius:"0.75rem",border:"1px solid #e5e7eb",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1)",maxWidth:"28rem",width:"100%",maxHeight:"90vh",overflow:"hidden",display:"flex",flexDirection:"column",position:"relative"},onClick:f=>f.stopPropagation(),children:[(0,m.jsx)("button",{type:"button",onClick:c,"aria-label":"\u0110\xF3ng",style:{position:"absolute",top:"1rem",right:"1rem",width:"2rem",height:"2rem",borderRadius:"0.25rem",border:"none",background:"transparent",cursor:"pointer",fontSize:"1.25rem",lineHeight:1,color:"#6b7280"},children:"\xD7"}),(0,m.jsx)("h2",{style:{fontSize:"18px",fontWeight:600,color:"#000",padding:"20px 2.5rem 12px 20px"},children:"Ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt"}),(0,m.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"1rem 1.25rem",fontSize:"0.875rem",color:"#111827",lineHeight:1.6},children:(0,m.jsx)("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:Ne})}),(0,m.jsxs)("div",{style:{padding:"1rem 1.25rem 1.25rem 1.25rem",display:"flex",flexDirection:"column",gap:"1rem"},children:[(0,m.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:"#111827",cursor:"pointer"},children:[(0,m.jsx)("input",{type:"checkbox",checked:s,onChange:f=>a(f.target.checked),style:{width:"1rem",height:"1rem",accentColor:"#111827"},"aria-label":"T\xF4i \u0111\u1ED3ng \xFD v\u1EDBi ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt tr\xEAn"}),(0,m.jsx)("span",{children:"T\xF4i \u0111\u1ED3ng \xFD v\u1EDBi ch\xEDnh s\xE1ch b\u1EA3o m\u1EADt tr\xEAn"})]}),(0,m.jsxs)("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[(0,m.jsx)("button",{type:"button",onClick:v,disabled:d.isPending,className:"consent:rounded-lg consent:border consent:border-gray-300 consent:bg-white consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-gray-700 consent:shadow-sm hover:consent:bg-gray-50 disabled:consent:opacity-50",style:{flex:1,borderRadius:"0.5rem",border:"1px solid #111827",background:"#fff",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#111827",cursor:"pointer"},children:"T\u1EEB ch\u1ED1i"}),(0,m.jsx)("button",{type:"button",onClick:P,disabled:!s||d.isPending,className:"consent:rounded-lg consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:shadow-sm disabled:consent:opacity-50 disabled:consent:cursor-not-allowed",style:{flex:1,minWidth:0,borderRadius:"0.5rem",background:s?"#111827":"#e5e7eb",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:s?"#fff":"#9ca3af",border:"none",cursor:s?"pointer":"not-allowed"},children:"Ti\u1EBFp t\u1EE5c"})]}),d.isError&&(0,m.jsx)("p",{className:"consent:text-sm consent:text-red-600",style:{fontSize:"0.875rem",color:"#dc2626",margin:0},children:"\u0110\xE3 x\u1EA3y ra l\u1ED7i. Vui l\xF2ng th\u1EED l\u1EA1i."})]})]})}),p&&(0,m.jsx)("div",{role:"alertdialog","aria-modal":"true","aria-label":"Th\xF4ng b\xE1o t\u1EEB ch\u1ED1i",style:{position:"fixed",inset:0,zIndex:70,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)",padding:"1rem"},onClick:f=>f.target===f.currentTarget&&C(),children:(0,m.jsxs)("div",{className:"consent:bg-white consent:rounded-xl consent:border consent:border-gray-200 consent:shadow-lg",style:{backgroundColor:"#fff",borderRadius:"0.75rem",border:"1px solid #e5e7eb",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1)",maxWidth:"22rem",width:"100%",padding:"1.25rem"},onClick:f=>f.stopPropagation(),children:[(0,m.jsx)("p",{className:"consent:text-sm consent:text-gray-700",style:{fontSize:"0.875rem",color:"#374151",margin:"0 0 1rem 0",lineHeight:1.5},children:Ge}),(0,m.jsxs)("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[(0,m.jsx)("button",{type:"button",onClick:C,className:"consent:rounded-lg consent:border consent:border-gray-300 consent:bg-white consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-gray-700 consent:shadow-sm hover:consent:bg-gray-50 disabled:consent:opacity-50",style:{flex:1,borderRadius:"0.5rem",border:"1px solid #111827",background:"#fff",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#111827",cursor:"pointer"},children:"Tr\u1EDF l\u1EA1i"}),(0,m.jsx)("button",{type:"button",onClick:g,disabled:d.isPending,className:"consent:rounded-lg consent:bg-gray-900 consent:px-4 consent:py-2 consent:text-sm consent:font-medium consent:text-white consent:shadow-sm disabled:consent:opacity-50 consent:flex-1",style:{flex:1,minWidth:0,borderRadius:"0.5rem",background:"#111827",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:500,color:"#fff",border:"none",cursor:"pointer"},children:"Ti\u1EBFp t\u1EE5c"})]}),d.isError&&(0,m.jsx)("p",{className:"consent:text-sm consent:text-red-600",style:{fontSize:"0.875rem",color:"#dc2626",margin:"0.5rem 0 0 0"},children:"\u0110\xE3 x\u1EA3y ra l\u1ED7i. Vui l\xF2ng th\u1EED l\u1EA1i."})]})})]}):null}var Le="analytics";function L(){let e=N();return e?.selected_preferences?e.selected_preferences.includes(Le):!1}var T=require("react/jsx-runtime"),fe=(0,y.createContext)(void 0);function qe({children:e,deviceId:t,showBannerWhenNoPreference:n=!0}){let[o,s]=(0,y.useState)(!1),[a,p]=(0,y.useState)(null),[l,d]=(0,y.useState)(!1),[c,v]=(0,y.useState)(null),{data:C,isFetched:S}=j({user_id:a??""});(0,y.useEffect)(()=>{if(!(!a||!S)){if(C!=null){p(null);return}v(a),d(!0),p(null)}},[a,S,C]);let g=(0,y.useCallback)(()=>{let u=N();s(!!u)},[]),P=(0,y.useCallback)(u=>{u&&p(u)},[]),f=(0,y.useCallback)(()=>{d(!1),v(null)},[]);(0,y.useEffect)(()=>{g()},[g]);let b={deviceId:t,hasConsentPreference:o,isAnalyticsAllowed:L(),refreshConsentPreference:g,openPolicyPopup:P};return(0,T.jsxs)(fe.Provider,{value:b,children:[e,n&&!o&&(0,T.jsx)(ee,{onSubmitted:g}),l&&c&&(0,T.jsx)(ne,{open:l,onClose:f,userId:c})]})}function ze(e){let{children:t,deviceId:n,showBannerWhenNoPreference:o=!0,...s}=e;return(0,T.jsx)(le,{...s,children:(0,T.jsx)(qe,{deviceId:n,showBannerWhenNoPreference:o,children:t})})}function G(){let e=(0,y.useContext)(fe);if(!e)throw new Error("usePhygitalConsent must be used within a PhygitalConsentProvider");return e}function Qe(){return G(),L()}0&&(module.exports={COOKIE_CONSENT_NAME,CookieConsentBanner,EntityStatus,MediaType,PhygitalConsentProvider,PolicyPopup,consentQueryKeys,consentService,getConsentPreferenceCookie,getCookie,isAnalyticsAllowed,policyQueryKeys,setConsentPreferenceCookie,setCookie,sha256,useConsentById,useCreateDeviceCookieConsent,useCreateUserConsent,useHealth,useIsAnalyticsAllowed,useLatestConsentByUserId,useLatestCookieConsentByDeviceId,useManyConsents,usePhygitalConsent,usePolicies});
5
5
  //# sourceMappingURL=index.cjs.map