"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2720],{5327:(t,e,n)=>{n.d(e,{E1:()=>i,EQ:()=>s,TW:()=>l,fX:()=>u,lp:()=>c,vS:()=>d,wR:()=>o});var r=n(25177);let a="https://api.komero.ge/Brand";async function i(){return(0,r.nr)(`${a}/get-all-brands`)}async function o(t){return(0,r.nr)(`${a}/get-brand-by-${t}`)}async function u(t){return(0,r.nr)(`${a}/update-brand`,{method:"PUT",body:JSON.stringify(t),requireAuth:!0,failIfUnauthenticated:!0,adminAuth:!0})}async function s(t,e,n,i,o,u,s){let c={name:t,origin:e,description:n,images:i,parentId:o||null,...u,translations:s};return(0,r.nr)(`${a}/add-brand`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c),requireAuth:!0,failIfUnauthenticated:!0,adminAuth:!0})}async function c(t){return(0,r.nr)(`${a}/delete-brand-by-${t}`,{method:"PUT",requireAuth:!0,failIfUnauthenticated:!0,adminAuth:!0})}async function d(t,e){return(0,r.nr)(`${a}/delete-image-${e}-by-brand-${t}`,{method:"DELETE",requireAuth:!0,failIfUnauthenticated:!0,adminAuth:!0})}async function l(t,e,n){if(!t)throw Error("brand is required");if(!e||0===e.length)throw Error("at least one file is required");let i=new FormData;return i.append("id",t),e.forEach(t=>{i.append("files",t,t.name)}),void 0!==n&&n>=0&&i.append("coverIndex",n.toString()),(0,r.nr)(`${a}/images`,{method:"POST",body:i,requireAuth:!0,failIfUnauthenticated:!0,adminAuth:!0})}},10383:(t,e,n)=>{n.d(e,{EY:()=>u,L9:()=>o,g3:()=>i});var r=n(25177);let a="https://api.komero.ge/api/FinaSync";async function i(){let t=await (0,r.nr)("https://api.komero.ge/api/FinaAuthentication/authenticate",{method:"POST",body:"",adminAuth:!0});if(!t||!t.token)throw console.error("❌ Fina Authentication failed: Token is null or undefined",t),Error("Authentication failed: No valid token received from Fina");return t}async function o(){let t=await (0,r.nr)(`${a}/sync-all`,{method:"POST",body:"",adminAuth:!0});return{success:t.message?.includes("success")||t.successCount>0,successCount:t.successCount||0,failureCount:t.failureCount||0,processedItems:t.processedItems||0,errors:t.errors||[],addedCount:t.addedCount||0,updatedCount:t.updatedCount||0,unchangedCount:t.unchangedCount||0,productChanges:t.productChanges||[]}}async function u(){return(0,r.nr)(`${a}/status`,{method:"GET",adminAuth:!0})}},22660:(t,e,n)=>{n.d(e,{Ku:()=>s,WE:()=>d});var r=n(95155),a=n(12115),i=n(25734),o=n(42950);let u=(0,a.createContext)({config:null,isLoading:!0,refresh:async()=>!1}),s=()=>(0,a.useContext)(u),c="tenantConfig",d=({children:t,initialConfig:e=null})=>{let[n,s]=(0,a.useState)(e),[d,l]=(0,a.useState)(!e),f=(0,a.useRef)(!0);(0,a.useEffect)(()=>{if(n?.theme){(0,i.s)(n.theme);try{localStorage.setItem(c,JSON.stringify({v:1,data:n}))}catch{}}},[n]),(0,a.useEffect)(()=>{if(window.self===window.top)return;let t=t=>{t.data?.type==="UPDATE_TENANT_CONFIG"&&t.data.config&&s(e=>e?{...e,...t.data.config,ui:{...e.ui??{},...t.data.config.ui??{}},theme:{...e.theme??{},...t.data.config.theme??{}}}:t.data.config)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[]),(0,a.useEffect)(()=>(f.current=!0,(async()=>{if((0,o.Hc)().catch(()=>{}),e)return l(!1);try{let t=localStorage.getItem(c);if(t){let e=JSON.parse(t);e?.v===1&&e?.data?s(e.data):localStorage.removeItem(c)}}catch{}l(!1);try{let t=window.location.host,e=await fetch(`/api/tenant-config?host=${encodeURIComponent(t)}`,{cache:"no-store"});if(e.ok){let t=await e.json();f.current&&s(t)}else console.error("❌ Failed to fetch tenant config:",e.status)}catch(t){console.error("❌ Error fetching tenant config:",t)}finally{f.current&&l(!1)}})(),()=>{f.current=!1}),[e]);let h=async()=>{try{let t=window.location.host,e=await fetch(`/api/tenant-config?host=${encodeURIComponent(t)}`,{cache:"no-store"});if(!e.ok)return!1;let n=await e.json();return f.current&&s(n),!0}catch{return!1}},g=(0,a.useMemo)(()=>({config:n,isLoading:d,refresh:h}),[n,d]);return(0,r.jsx)(u.Provider,{value:g,children:t})}},25016:(t,e,n)=>{n.d(e,{$g:()=>o,Yt:()=>c,ZC:()=>s,cn:()=>i,hU:()=>u});var r=n(2821),a=n(75889);function i(...t){return(0,a.QP)((0,r.$)(t))}function o(t,e="₾"){let n=t.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,",");return"GEL"===e||"₾"===e?`${n} ₾`:`${({GEL:"₾",USD:"$",EUR:"€"})[e]||e}${n}`}function u(t,e="GEL"){let n=t.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,",");return"GEL"===e||"₾"===e?`${n} ₾`:`${({GEL:"₾",USD:"$",EUR:"€"})[e]||e} ${n}`}function s(t){if(!t)return"/placeholder.png";if(t.startsWith("http://")||t.startsWith("https://"))return t;if(t.startsWith("/assets/")){let e="https://api.komero.ge/".replace(/\/$/,"")||0;return`${e}${t}`}return t}function c(t){return t?t.replace(/\bcolor\s*:\s*[^;}"']+;?/gi,"").replace(/\bbackground-color\s*:\s*[^;}"']+;?/gi,"").replace(/style\s*=\s*["']\s*["']/gi,"").replace(/style\s*=\s*["']\s*;?\s*["']/gi,""):""}},25177:(t,e,n)=>{n.d(e,{Hd:()=>s,ZU:()=>u,nr:()=>c});class r extends Error{constructor(t="Authentication required"){super(t),this.status=401,this.code="AUTH_REQUIRED",this.name="AuthRequiredError"}}let a=null,i=null,o=null;async function u(){return o||(o=fetch("/api/auth/refresh",{method:"POST",credentials:"same-origin"}).then(async t=>{if(t.ok){let e=(await t.json().catch(()=>({}))).token;return e&&(a=e),{refreshed:!0,token:e}}return{refreshed:!1}}).catch(()=>({refreshed:!1})).finally(()=>{o=null}))}function s(t,e=!1){e?i=t:a=t}async function c(t,e={}){let o=(e.method??"GET").toUpperCase(),s=!0===e.requireAuth||!1!==e.requireAuth&&["POST","PUT","PATCH","DELETE"].includes(o),d=new Headers(e.headers),l=null!=e.body&&"GET"!==o&&"HEAD"!==o,f="undefined"!=typeof FormData&&e.body instanceof FormData;!l||f||d.has("Content-Type")||d.set("Content-Type","application/json");let h=e.token??null;if(s&&!h){let t=!!e.adminAuth,o=t?"/api/auth/token?admin=1":"/api/auth/token";if(!(h=t?i:a))if(1){try{let e=await fetch(o,{credentials:"same-origin",cache:"no-store"});h=e.ok?(await e.json())?.token??null:null,t?i=h??null:a=h??null}catch{h=null}if(!h&&!t)try{if(await u()){let e=await fetch(o,{credentials:"same-origin",cache:"no-store"});h=e.ok?(await e.json())?.token??null:null,t?i=h??null:a=h??null}}catch{}}else{let{cookies:e}=await n.e(684).then(n.bind(n,20684));h=(await e()).get(t?"adminAccessToken":"accessToken")?.value??null}if(!h&&e.failIfUnauthenticated)throw new r;h&&d.set("Authorization",h.startsWith("Bearer ")?h:`Bearer ${h}`)}if(!d.has("X-Client-Domain"))if(0){let t="".replace(/^https?:\/\//i,"").replace(/\/+$/,"");d.set("X-Client-Domain",t||"localhost")}else if(1)d.set("X-Client-Domain",window.location.hostname);else try{let{headers:t}=await n.e(684).then(n.bind(n,20684)),e=await t(),r=e.get("x-forwarded-host")??e.get("host");d.set("X-Client-Domain",r??"localhost")}catch{d.set("X-Client-Domain","localhost")}let g={...e,headers:d,credentials:"same-origin"};"no-store"!==e.cache&&(g.next={revalidate:60,...e.next});let m=await fetch(t,g);if(401===m.status&&s&&!e.token&&!e.adminAuth){a=null;try{let{refreshed:e,token:n}=await u();e&&n&&(d.set("Authorization",n.startsWith("Bearer ")?n:`Bearer ${n}`),m=await fetch(t,{...g,headers:d}))}catch{}}let p=m.headers.get("content-type")||"";if(!m.ok){let e=p.includes("application/json")?JSON.stringify(await m.json()):await m.text();throw console.error(`❌ API Error [${o} ${t}]:`,m.status,e),Error(`Error ${m.status}: ${e}`)}let y=p.includes("application/json")?await m.json():await m.text();return t.includes("/Tenant/tenant-configuration"),y}},25734:(t,e,n)=>{n.d(e,{s:()=>r});function r(t){let e=document.documentElement;for(let[n,r]of Object.entries(function(t){let e={},n=(t,n,r=!1)=>{n&&(e[t]=r&&function(t){if(!t||"string"!=typeof t||!t.startsWith("#"))return t;let e=0,n=0,r=0;return 4===t.length?(e=parseInt(t[1]+t[1],16),n=parseInt(t[2]+t[2],16),r=parseInt(t[3]+t[3],16)):(7===t.length||9===t.length)&&(e=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16)),`${e} ${n} ${r}`}(n)||n)};n("--brand-primary",t.brand?.primary,!0),n("--brand-primary-dark",t.brand?.primaryDark,!0),n("--brand-surface",t.brand?.surface,!0),n("--brand-surface-dark",t.brand?.surfaceDark,!0),n("--brand-muted",t.brand?.muted,!0),n("--brand-muted-dark",t.brand?.mutedDark,!0),n("--brand-accent",t.brand?.accent,!0),n("--text-light",t.text?.light,!0),n("--text-subtle",t.text?.subtle,!0),n("--text-light-dark",t.text?.lightDark,!0),n("--text-subtle-dark",t.text?.subtleDark,!0);let r=(t,n)=>{null!=n&&""!==n&&(e[t]=n)};if(t.fonts){let e=((t,e="system-ui, -apple-system, sans-serif")=>{if(!t||"string"!=typeof t||t.includes("://")||t.startsWith("//")||t.includes(".css"))return;let n=t.replace(/['"]/g,"");return n.includes(",")?n:`'${n}', ${e}`})(t.fonts.family);e&&(r("--font-primary",e),r("--font-heading",e),r("--font-secondary",e))}return e}(t)))n.startsWith("--")&&e.style.setProperty(n,"number"==typeof r?String(r):r)}},36300:(t,e,n)=>{function r(t){if(!t)return[];try{let e=JSON.parse(t);if(Array.isArray(e))return e;return[]}catch{return[]}}function a(t){return JSON.stringify(t)}function i(t){if(!t||0===t.length)return!1;let e=t[0];return"object"==typeof e&&null!==e&&"imagePath"in e}function o(t){return t&&0!==t.length?i(t)?[...t].sort((t,e)=>t.displayOrder!==e.displayOrder?t.displayOrder-e.displayOrder:t.isCover&&!e.isCover?-1:!t.isCover&&e.isCover?1:0).map(t=>t.imagePath):t.filter(t=>"string"==typeof t&&t.trim()):[]}function u(t){if(!t||0===t.length)return;if(!i(t))return t.find(t=>"string"==typeof t&&t.trim());let e=t.find(t=>t.isCover);if(e)return e.imagePath;let n=[...t].sort((t,e)=>t.displayOrder-e.displayOrder);return n[0]?.imagePath}n.d(e,{my:()=>u,nV:()=>o,pv:()=>r,vh:()=>a}),n(99274),n(5327)},42950:(t,e,n)=>{n.d(e,{Hc:()=>h,OA:()=>o,_y:()=>f,gC:()=>l,jW:()=>d,pO:()=>m,pq:()=>i,sY:()=>g,v9:()=>c}),n(10383);var r=n(25177),a=n(77321);let i={Fina:1,BOG:11,RequestProduct:12,Flitt:13,BOGInstallment:21,BOGGooglePay:22,GeorgianPost:30,Glovo:31,Wolt:32,Delivo:33,BasicAuth:50,GoogleOAuth:51,FacebookOAuth:52,Invoice:70