lynkow 1.40.2 → 1.41.0

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var v=class r extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,o,s){super(e),this.code=t,this.status=n,this.details=o,this.cause=s,Error.captureStackTrace&&Error.captureStackTrace(this,r);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,o;try{let i=await e.json();i.errors&&Array.isArray(i.errors)?(o=i.errors,n=i.errors[0]?.message||n):i.error?n=i.error:i.message&&(n=i.message);}catch{n=e.statusText||n;}let s=r.statusToCode(t);return new r(n,s,t,o)}static fromNetworkError(e){return e.name==="AbortError"?new r("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new r("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new r(e.message||"Unknown error","UNKNOWN",void 0,void 0,e)}static statusToCode(e){switch(e){case 400:return "VALIDATION_ERROR";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 429:return "RATE_LIMITED";default:return "UNKNOWN"}}toJSON(){return {name:this.name,message:this.message,code:this.code,status:this.status,details:this.details}}};function Oe(r){return r instanceof v}function Ie(r){switch(r){case 400:return "BAD_REQUEST";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 422:return "VALIDATION_ERROR";case 429:return "TOO_MANY_REQUESTS";case 503:return "SERVICE_UNAVAILABLE";default:return "INTERNAL_ERROR"}}var D={retries:3,backoffMs:500,maxDelayMs:2e4},Pe=new Set([429,503]);function Be(r,e){return r==null||!Number.isFinite(r)?e:Math.max(0,Math.trunc(r))}function pe(r,e){return r==null||!Number.isFinite(r)||r<0?e:r}function W(r){return r===false?{...D,retries:0}:r===true||r===void 0?{...D}:{retries:Be(r.retries,D.retries),backoffMs:pe(r.backoffMs,D.backoffMs),maxDelayMs:pe(r.maxDelayMs,D.maxDelayMs)}}function $e(r,e){return e.signal?.aborted?true:typeof r=="object"&&r!==null&&r.name==="AbortError"}function me(r){return new Promise(e=>setTimeout(e,r))}function Ae(r){let e=r.headers?.get?.("retry-after");if(!e)return null;let t=Number(e);if(Number.isFinite(t))return Math.max(0,t*1e3);let n=Date.parse(e);return Number.isFinite(n)?Math.max(0,n-Date.now()):null}function ue(r,e,t){if(r!=null)return Math.min(r,t.maxDelayMs);let n=t.backoffMs*2**e,o=n*.25*Math.random();return Math.min(n+o,t.maxDelayMs)}async function M(r,e,t={}){let n=t.retry,i=(t.idempotent??false)&&!!n&&n.retries>0?n.retries+1:1,a;for(let p=0;p<i;p++){let g=p===i-1,m;try{m=await fetch(r,e);}catch(l){if(!$e(l,e)&&!g){a=l,await me(ue(null,p,n));continue}throw new v("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:l instanceof Error?l.message:"Unknown error"}])}if(!g&&Pe.has(m.status)){let l=ue(Ae(m),p,n);try{await m.body?.cancel();}catch{}await me(l);continue}return m}throw new v("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:a instanceof Error?a.message:"Unknown error"}])}async function X(r,e,t){let n=await M(r,e,t);if(n.ok)return n.json();let o={};try{o=await n.json();}catch{}let s=Ie(n.status),i=o.error||o.message||`HTTP error: ${n.status}`,a=o.errors||[{message:i}];throw new v(i,s,n.status,a)}function b(...r){let e={},t=new Map,n=(o,s)=>{let i=o.toLowerCase(),a=t.get(i);a!==void 0&&a!==o&&delete e[a],e[o]=s,t.set(i,o);};for(let o of r)if(o)if(o instanceof Headers)o.forEach((s,i)=>n(i,s));else if(Array.isArray(o))for(let[s,i]of o)n(s,i);else for(let[s,i]of Object.entries(o))n(s,i);return e}function ge(r){let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!=null&&n!==""&&e.append(t,String(n));return e.toString()}var d={SHORT:300*1e3,MEDIUM:600*1e3,LONG:1800*1e3},u=class{config;cache;retry;constructor(e){this.config=e,this.cache=e.cache,this.retry=W(e.retry);}buildEndpointUrl(e,t){let n=`${this.config.baseUrl}/storefront/${encodeURIComponent(this.config.siteId)}${e}`;if(t&&Object.keys(t).length>0){let o=ge(t);return `${n}?${o}`}return n}async get(e,t,n){let o=n?.locale||this.config.locale,s=o?{...t,locale:o}:t,i=this.buildEndpointUrl(e,s),a=this.mergeFetchOptions(n?.fetchOptions);return X(i,{method:"GET",...a},{retry:this.retry,idempotent:true})}async getWithCache(e,t,n,o,s=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,o),s):this.get(t,n,o)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let o=this.buildEndpointUrl(e),s=this.mergeFetchOptions(n?.fetchOptions);return X(o,{method:"POST",...s,headers:b({"Content-Type":"application/json"},s.headers),body:JSON.stringify(t)},{retry:this.retry,idempotent:false})}async getText(e,t){let n=this.buildEndpointUrl(e),o=this.mergeFetchOptions(t?.fetchOptions),s=await M(n,{method:"GET",...o},{retry:this.retry,idempotent:true});if(!s.ok)throw new Error(`HTTP error: ${s.status}`);return s.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:b(this.config.publishableKey?{"X-Lynkow-Pk":this.config.publishableKey}:void 0,this.config.fetchOptions.headers,e?.headers)}}};var Y="contents_",k=class extends u{async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.category&&(n.category=e.category),e?.tag&&(n.tag=e.tag),e?.search&&(n.search=e.search),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order),e?.locale&&(n.locale=e.locale);let o=`${Y}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/contents",n,t,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${Y}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(Y);}};var G="categories_";function Q(r){if(Array.isArray(r))return r.map(Q);if(r!==null&&typeof r=="object"){let e=r,t={};for(let n of Object.keys(e).sort())t[n]=Q(e[n]);return t}return r}var R=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${G}list_${t||"default"}`;return (await this.getWithCache(n,"/categories",void 0,e,d.SHORT)).data}async tree(e){let t=e?.locale||this.config.locale,n=`${G}tree_${t||"default"}`;return (await this.getWithCache(n,"/categories/tree",void 0,e,d.SHORT)).data}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),(t?.limit??t?.perPage)&&(n.limit=t?.limit??t?.perPage);let o=`${G}slug_${e}_${JSON.stringify(Q(t||{}))}`;return (await this.getWithCache(o,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)).data}clearCache(){this.invalidateCache(G);}};var he="tags_",x=class extends u{async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.locale&&(n.locale=e.locale);let o=t?.locale||e?.locale||this.config.locale,s=`${he}list_${o||"default"}_${JSON.stringify(e||{})}`;return this.getWithCache(s,"/tags",n,t,d.SHORT)}clearCache(){this.invalidateCache(he);}};var N="pages_",E=class extends u{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let o=`${N}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(o,"/pages",n,e,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${N}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,o=`${N}path_${e}_${n||"default"}`;return (await this.getWithCache(o,"/page-by-path",{path:e},t,d.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,o=`${N}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(N);}};var Z="globals_",S=class extends u{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${Z}siteconfig_${t||"default"}`;return this.getWithCache(n,"/site-config",void 0,e,d.MEDIUM)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${Z}${e}_${n||"default"}`;return this.getWithCache(o,`/global/${encodeURIComponent(e)}`,void 0,t,d.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(Z);}};function J(r){return {_hp:"",_ts:r}}var fe="forms_",T=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${fe}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let o=J(this.sessionStartTime),s={data:t,honeypot:o._hp,...o};return n?.recaptchaToken&&(s.recaptchaToken=n.recaptchaToken),(await this.post(`/forms/${encodeURIComponent(e)}/submissions`,s,n)).data}clearCache(){this.invalidateCache(fe);}};var q="reviews_",L=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.minRating&&(n.minRating=e.minRating),e?.maxRating&&(n.maxRating=e.maxRating),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order);let o=`${q}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${q}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${q}settings`;return (await this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)).data}async submit(e,t){let n=J(this.sessionStartTime),o={...e,...n};t?.recaptchaToken&&(o._recaptcha_token=t.recaptchaToken);let s=await this.post("/reviews",o,t);return this.invalidateCache(q),s.data}clearCache(){this.invalidateCache(q);}};var ye="site_",O=class extends u{async getConfig(){let e=`${ye}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(ye);}};var ee="legal_",I=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${ee}list_${t||"default"}`;return (await this.getWithCache(n,"/pages",{tag:"legal"},e,d.SHORT)).data}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${ee}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(ee);}};var ve="cookies_",P=class extends u{async getConfig(){let e=`${ve}config`;return (await this.getWithCache(e,"/cookie-consent/config",void 0,void 0,d.MEDIUM)).data}async logConsent(e,t){return this.post("/cookie-consent/logs",{preferences:e},t)}clearCache(){this.invalidateCache(ve);}};var B=class extends u{async sitemap(e){return this.getText("/sitemap.xml",e)}async sitemapPart(e,t){return this.getText(`/sitemap-${e}.xml`,t)}async robots(e){return this.getText("/robots.txt",e)}async llmsTxt(e){let t=e?.locale,n=t?`/${t}/llms.txt`:"/llms.txt";return this.getText(n,e)}async llmsFullTxt(e){let t=e?.locale,n=t?`/${t}/llms-full.txt`:"/llms-full.txt";return this.getText(n,e)}async getMarkdown(e,t){let n=e.startsWith("/")?e:`/${e}`;return this.getText(`${n}.md`,t)}};var te="paths_",$=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${te}list_${t||"all"}`;return (await this.getWithCache(n,"/paths",void 0,e,d.SHORT)).data}async resolve(e,t){let n=t?.locale||this.config.locale,o=`${te}resolve_${e}_${n||"default"}`;return (await this.getWithCache(o,"/resolve",{path:e},t,d.SHORT)).data}async matchRedirect(e,t){try{return (await this.get("/redirects/match",{path:e},t)).data}catch(n){if(n instanceof v&&n.status===404)return null;throw n}}clearCache(){this.invalidateCache(te);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_e=!c;function Fe(r,e){return c?r():e}async function De(r,e){return c?r():e}var ne="lynkow-tracker",H=class{config;enabled=true;initialized=false;loading=false;loadPromise=null;constructor(e){this.config=e;}getTrackerUrl(){return `${this.config.baseUrl}/analytics/tracker.js`}loadTracker(){return !c||window.LynkowAnalytics?Promise.resolve():this.loadPromise?this.loadPromise:(this.loading=true,this.loadPromise=new Promise((e,t)=>{if(document.getElementById(ne)){let o=setInterval(()=>{window.LynkowAnalytics&&(clearInterval(o),this.loading=false,e());},50);setTimeout(()=>{clearInterval(o),this.loading=false,t(new Error("Tracker script load timeout"));},1e4);return}let n=document.createElement("script");n.id=ne,n.src=this.getTrackerUrl(),n.async=true,n.setAttribute("data-site-id",this.config.siteId),this.config.baseUrl&&n.setAttribute("data-api-url",this.config.baseUrl);try{let o=localStorage.getItem("_lkw_consent_mode");o&&n.setAttribute("data-consent-mode",o);}catch{}n.onload=()=>{this.loading=false,setTimeout(()=>{window.LynkowAnalytics?e():t(new Error("Tracker script loaded but LynkowAnalytics not found"));},0);},n.onerror=()=>{this.loading=false,t(new Error("Failed to load tracker script"));},document.head.appendChild(n);}),this.loadPromise)}async init(){if(!(!c||this.initialized))try{await this.loadTracker(),window.LynkowAnalytics&&!this.initialized&&(this.initialized=!0);}catch(e){console.error("[Lynkow] Failed to initialize analytics:",e);}}async trackEvent(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track(e));}async trackPageview(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track({type:"pageview",path:e?.path||window.location.pathname,title:e?.title||document.title,referrer:e?.referrer||document.referrer}));}enable(){this.enabled=true;}disable(){this.enabled=false;}isEnabled(){return this.enabled}isInitialized(){return this.initialized&&!!window.LynkowAnalytics}getTracker(){if(c)return window.LynkowAnalytics}destroy(){if(!c)return;document.getElementById(ne)?.remove(),this.initialized=false,this.loadPromise=null;}};function Me(r){let e=r.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(!e||(e[4]!==void 0?parseFloat(e[4]):1)===0)return null;let n=parseInt(e[1],10),o=parseInt(e[2],10),s=parseInt(e[3],10);return (.299*n+.587*o+.114*s)/255}function C(){if(!c)return "light";let r=document.documentElement,e=document.body;for(let t of [r,e])for(let n of ["data-theme","data-mode","data-color-scheme"]){let o=t.getAttribute(n)?.toLowerCase();if(o){if(o.includes("dark"))return "dark";if(o.includes("light"))return "light"}}if(r.classList.contains("dark")||e.classList.contains("dark"))return "dark";try{let t=getComputedStyle(r).colorScheme;if(t){let n=t.toLowerCase().trim();if(n.startsWith("dark"))return "dark";if(n.startsWith("light"))return "light"}}catch{}try{let t=getComputedStyle(e).backgroundColor,n=Me(t);if(n!==null)return n<.5?"dark":"light"}catch{}try{if(window.matchMedia("(prefers-color-scheme: dark)").matches)return "dark"}catch{}return "light"}function A(r){if(!c)return ()=>{};let e=C(),t=[],n=()=>{let i=C();i!==e&&(e=i,r(i));},o=new MutationObserver(n),s={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};o.observe(document.documentElement,s),o.observe(document.body,s),t.push(()=>o.disconnect());try{let i=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n();i.addEventListener("change",a),t.push(()=>i.removeEventListener("change",a));}catch{}return ()=>t.forEach(i=>i())}var V="_lkw_consent",Ne=365*24*60*60*1e3,we="lkw-script-",re={necessary:true,analytics:false,marketing:false,preferences:false},U=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;themeCleanup=null;retry;constructor(e,t){this.config=e,this.retry=W(e.retry),this.events=t;}async getConfig(){if(this.configCache)return this.configCache;let e=`${this.config.baseUrl}/storefront/${encodeURIComponent(this.config.siteId)}/cookie-consent/config`,t=await M(e,{method:"GET",...this.config.fetchOptions,headers:b({"Content-Type":"application/json"},this.config.publishableKey?{"X-Lynkow-Pk":this.config.publishableKey}:void 0,this.config.fetchOptions.headers)},{retry:this.retry,idempotent:true});if(!t.ok)throw new Error(`Failed to fetch consent config: ${t.status}`);let n=await t.json();return this.configCache=n.data,this.configCache}async logConsent(e,t){let n=`${this.config.baseUrl}/storefront/${encodeURIComponent(this.config.siteId)}/cookie-consent/logs`;await fetch(n,{method:"POST",body:JSON.stringify({visitorId:this.getOrCreateVisitorId(),action:t||this.inferAction(e),consentGiven:e,pageUrl:c?window.location.href:void 0}),...this.config.fetchOptions,headers:b({"Content-Type":"application/json"},this.config.publishableKey?{"X-Lynkow-Pk":this.config.publishableKey}:void 0,this.config.fetchOptions.headers)}).catch(()=>{});}getOrCreateVisitorId(){if(!c)return "server";let e="_lkw_vid";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return crypto.randomUUID()}}inferAction(e){let t=Object.entries(e).filter(([s])=>s!=="necessary"),n=t.every(([,s])=>s===true),o=t.every(([,s])=>s===false);return n?"accept_all":o?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(V);if(e){let t=JSON.parse(e);return t.choices?t.timestamp&&Date.now()-t.timestamp>Ne?(localStorage.removeItem(V),null):t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(V,JSON.stringify({choices:e,timestamp:Date.now()}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){c&&this.getConfig().then(e=>{if(!e.enabled)return;try{e.consentMode&&localStorage.setItem("_lkw_consent_mode",e.consentMode);}catch{}let t=this.getStoredConsent();if(t){this.activateScripts(t);return}if(this.bannerElement)return;this.injectBannerStylesOnce();let n=document.createElement("div");n.innerHTML=this.createBannerHTML(e),this.bannerElement=n.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents(),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=A(o=>{this.updateConsentTheme(o);}));});}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null,this.cleanupThemeObserverIfIdle());}showPreferences(){c&&(this.preferencesElement||this.getConfig().then(e=>{let t=this.getCategories(),n=document.createElement("div");n.innerHTML=this.createPreferencesHTML(e,t),this.preferencesElement=n.firstElementChild,document.body.appendChild(this.preferencesElement),this.attachPreferencesEvents(e),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=A(o=>{this.updateConsentTheme(o);}));}));}getCategories(){return c?this.getStoredConsent()||{...re}:{...re}}hasConsented(){return c?this.getStoredConsent()!==null:false}acceptAll(){if(!c)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e,"accept_all"),this.activateScripts(e),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e,"reject_all"),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n,"customize"),this.activateScripts(n);}reset(){if(c){this.removeInjectedScripts();try{localStorage.removeItem(V);}catch{}this.events.emit("consent-changed",{...re}),this.show();}}activateScripts(e){if(this.configCache?.thirdPartyScripts?.length)for(let[t,n]of Object.entries(e))n&&this.injectScriptsForCategory(t,this.configCache.thirdPartyScripts);}injectScriptsForCategory(e,t){for(let n of t){if(n.category!==e||this.injectedScriptIds.has(n.id))continue;this.injectedScriptIds.add(n.id);let o=document.createElement("div");o.innerHTML=n.script;let s=Array.from(o.children);for(let i=0;i<s.length;i++){let a=s[i],p=`${we}${n.id}-${i}`;if(a.tagName==="SCRIPT"){let g=document.createElement("script");for(let m of Array.from(a.attributes))g.setAttribute(m.name,m.value);a.textContent&&(g.textContent=a.textContent),g.id=p,document.head.appendChild(g);}else a.id=p,document.body.appendChild(a);}}}removeInjectedScripts(){for(let e of this.injectedScriptIds){let t=0,n;for(;n=document.getElementById(`${we}${e}-${t}`);)n.remove(),t++;}this.injectedScriptIds.clear();}cleanupThemeObserverIfIdle(){!this.bannerElement&&!this.preferencesElement&&(this.themeCleanup?.(),this.themeCleanup=null);}updateConsentTheme(e){let t=this.configCache?this.resolveColors(this.configCache,e):{bgColor:e==="dark"?"#18181b":"#ffffff",textColor:e==="dark"?"#f4f4f5":"#1a1a1a"},{bgColor:n,textColor:o}=t;if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=o),this.preferencesElement){let s=this.preferencesElement.querySelector(":scope > div");s&&(s.style.background=n,s.style.color=o);}}resolveTheme(e){return e==="auto"?C():e==="dark"?"dark":"light"}resolveColors(e,t){if(e.themeStyles?.[t])return e.themeStyles[t];let n=t==="dark";return {primaryColor:e.primaryColor||"#0066cc",bgColor:n?"#18181b":"#ffffff",textColor:n?"#f4f4f5":"#1a1a1a"}}contrastColor(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return (.299*t+.587*n+.114*o)/255>.5?"#000000":"#ffffff"}injectBannerStylesOnce(){if(document.getElementById("lynkow-consent-styles"))return;let e=document.createElement("style");e.id="lynkow-consent-styles",e.textContent=`
1
+ 'use strict';var v=class r extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,o,s){super(e),this.code=t,this.status=n,this.details=o,this.cause=s,Error.captureStackTrace&&Error.captureStackTrace(this,r);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,o;try{let i=await e.json();i.errors&&Array.isArray(i.errors)?(o=i.errors,n=i.errors[0]?.message||n):i.error?n=i.error:i.message&&(n=i.message);}catch{n=e.statusText||n;}let s=r.statusToCode(t);return new r(n,s,t,o)}static fromNetworkError(e){return e.name==="AbortError"?new r("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new r("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new r(e.message||"Unknown error","UNKNOWN",void 0,void 0,e)}static statusToCode(e){switch(e){case 400:return "VALIDATION_ERROR";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 429:return "RATE_LIMITED";default:return "UNKNOWN"}}toJSON(){return {name:this.name,message:this.message,code:this.code,status:this.status,details:this.details}}};function Be(r){return r instanceof v}function $e(r){switch(r){case 400:return "BAD_REQUEST";case 401:return "UNAUTHORIZED";case 403:return "FORBIDDEN";case 404:return "NOT_FOUND";case 422:return "VALIDATION_ERROR";case 429:return "TOO_MANY_REQUESTS";case 503:return "SERVICE_UNAVAILABLE";default:return "INTERNAL_ERROR"}}var M={retries:3,backoffMs:500,maxDelayMs:2e4},Ae=new Set([429,503]);function Fe(r,e){return r==null||!Number.isFinite(r)?e:Math.max(0,Math.trunc(r))}function ue(r,e){return r==null||!Number.isFinite(r)||r<0?e:r}function G(r){return r===false?{...M,retries:0}:r===true||r===void 0?{...M}:{retries:Fe(r.retries,M.retries),backoffMs:ue(r.backoffMs,M.backoffMs),maxDelayMs:ue(r.maxDelayMs,M.maxDelayMs)}}function _e(r,e){return e.signal?.aborted?true:typeof r=="object"&&r!==null&&r.name==="AbortError"}function ge(r){return new Promise(e=>setTimeout(e,r))}function De(r){let e=r.headers?.get?.("retry-after");if(!e)return null;let t=Number(e);if(Number.isFinite(t))return Math.max(0,t*1e3);let n=Date.parse(e);return Number.isFinite(n)?Math.max(0,n-Date.now()):null}function he(r,e,t){if(r!=null)return Math.min(r,t.maxDelayMs);let n=t.backoffMs*2**e,o=n*.25*Math.random();return Math.min(n+o,t.maxDelayMs)}async function q(r,e,t={}){let n=t.retry,i=(t.idempotent??false)&&!!n&&n.retries>0?n.retries+1:1,a;for(let p=0;p<i;p++){let g=p===i-1,u;try{u=await fetch(r,e);}catch(l){if(!_e(l,e)&&!g){a=l,await ge(he(null,p,n));continue}throw new v("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:l instanceof Error?l.message:"Unknown error"}])}if(!g&&Ae.has(u.status)){let l=he(De(u),p,n);try{await u.body?.cancel();}catch{}await ge(l);continue}return u}throw new v("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:a instanceof Error?a.message:"Unknown error"}])}async function Q(r,e,t){let n=await q(r,e,t);if(n.ok)return n.json();let o={};try{o=await n.json();}catch{}let s=$e(n.status),i=o.error||o.message||`HTTP error: ${n.status}`,a=o.errors||[{message:i}];throw new v(i,s,n.status,a)}function b(...r){let e={},t=new Map,n=(o,s)=>{let i=o.toLowerCase(),a=t.get(i);a!==void 0&&a!==o&&delete e[a],e[o]=s,t.set(i,o);};for(let o of r)if(o)if(o instanceof Headers)o.forEach((s,i)=>n(i,s));else if(Array.isArray(o))for(let[s,i]of o)n(s,i);else for(let[s,i]of Object.entries(o))n(s,i);return e}function fe(r){let e=new URLSearchParams;for(let[t,n]of Object.entries(r))n!=null&&n!==""&&e.append(t,String(n));return e.toString()}var d={SHORT:300*1e3,MEDIUM:600*1e3,LONG:1800*1e3},m=class{config;cache;retry;constructor(e){this.config=e,this.cache=e.cache,this.retry=G(e.retry);}buildEndpointUrl(e,t){let n=`${this.config.baseUrl}/storefront/${encodeURIComponent(this.config.siteId)}${e}`;if(t&&Object.keys(t).length>0){let o=fe(t);return `${n}?${o}`}return n}async get(e,t,n){let o=n?.locale||this.config.locale,s=o?{...t,locale:o}:t,i=this.buildEndpointUrl(e,s),a=this.mergeFetchOptions(n?.fetchOptions);return Q(i,{method:"GET",...a},{retry:this.retry,idempotent:true})}async getWithCache(e,t,n,o,s=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,o),s):this.get(t,n,o)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let o=this.buildEndpointUrl(e),s=this.mergeFetchOptions(n?.fetchOptions);return Q(o,{method:"POST",...s,headers:b({"Content-Type":"application/json"},s.headers),body:JSON.stringify(t)},{retry:this.retry,idempotent:false})}async getText(e,t){let n=this.buildEndpointUrl(e),o=this.mergeFetchOptions(t?.fetchOptions),s=await q(n,{method:"GET",...o},{retry:this.retry,idempotent:true});if(!s.ok)throw new Error(`HTTP error: ${s.status}`);return s.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:b(this.config.publishableKey?{"X-Lynkow-Pk":this.config.publishableKey}:void 0,this.config.fetchOptions.headers,e?.headers)}}};var Z="contents_",k=class extends m{async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.category&&(n.category=e.category),e?.tag&&(n.tag=e.tag),e?.search&&(n.search=e.search),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order),e?.locale&&(n.locale=e.locale);let o=`${Z}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/contents",n,t,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${Z}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(Z);}};var J="categories_";function ee(r){if(Array.isArray(r))return r.map(ee);if(r!==null&&typeof r=="object"){let e=r,t={};for(let n of Object.keys(e).sort())t[n]=ee(e[n]);return t}return r}var R=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${J}list_${t||"default"}`;return (await this.getWithCache(n,"/categories",void 0,e,d.SHORT)).data}async tree(e){let t=e?.locale||this.config.locale,n=`${J}tree_${t||"default"}`;return (await this.getWithCache(n,"/categories/tree",void 0,e,d.SHORT)).data}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),(t?.limit??t?.perPage)&&(n.limit=t?.limit??t?.perPage);let o=`${J}slug_${e}_${JSON.stringify(ee(t||{}))}`;return (await this.getWithCache(o,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)).data}clearCache(){this.invalidateCache(J);}};var ye="tags_",x=class extends m{async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.locale&&(n.locale=e.locale);let o=t?.locale||e?.locale||this.config.locale,s=`${ye}list_${o||"default"}_${JSON.stringify(e||{})}`;return this.getWithCache(s,"/tags",n,t,d.SHORT)}clearCache(){this.invalidateCache(ye);}};var N="pages_",E=class extends m{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let o=`${N}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(o,"/pages",n,e,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${N}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,o=`${N}path_${e}_${n||"default"}`;return (await this.getWithCache(o,"/page-by-path",{path:e},t,d.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,o=`${N}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(N);}};var te="globals_",S=class extends m{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${te}siteconfig_${t||"default"}`;return this.getWithCache(n,"/site-config",void 0,e,d.MEDIUM)}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${te}${e}_${n||"default"}`;return this.getWithCache(o,`/global/${encodeURIComponent(e)}`,void 0,t,d.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(te);}};function T(r){return {_hp:"",_ts:r}}var ve="forms_",L=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${ve}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let o=T(this.sessionStartTime),s={data:t,honeypot:o._hp,...o};return n?.recaptchaToken&&(s.recaptchaToken=n.recaptchaToken),(await this.post(`/forms/${encodeURIComponent(e)}/submissions`,s,n)).data}clearCache(){this.invalidateCache(ve);}};var H="reviews_",O=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.minRating&&(n.minRating=e.minRating),e?.maxRating&&(n.maxRating=e.maxRating),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order);let o=`${H}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${H}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${H}settings`;return (await this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)).data}async submit(e,t){let n=T(this.sessionStartTime),o={...e,...n};t?.recaptchaToken&&(o._recaptcha_token=t.recaptchaToken);let s=await this.post("/reviews",o,t);return this.invalidateCache(H),s.data}clearCache(){this.invalidateCache(H);}};var we="site_",P=class extends m{async getConfig(){let e=`${we}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(we);}};var ne="legal_",I=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${ne}list_${t||"default"}`;return (await this.getWithCache(n,"/pages",{tag:"legal"},e,d.SHORT)).data}async getBySlug(e,t){let n=t?.locale||this.config.locale,o=`${ne}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(ne);}};var Ce="cookies_",B=class extends m{async getConfig(){let e=`${Ce}config`;return (await this.getWithCache(e,"/cookie-consent/config",void 0,void 0,d.MEDIUM)).data}async logConsent(e,t){return this.post("/cookie-consent/logs",{preferences:e},t)}clearCache(){this.invalidateCache(Ce);}};var $=class extends m{async sitemap(e){return this.getText("/sitemap.xml",e)}async sitemapPart(e,t){return this.getText(`/sitemap-${e}.xml`,t)}async robots(e){return this.getText("/robots.txt",e)}async llmsTxt(e){let t=e?.locale,n=t?`/${t}/llms.txt`:"/llms.txt";return this.getText(n,e)}async llmsFullTxt(e){let t=e?.locale,n=t?`/${t}/llms-full.txt`:"/llms-full.txt";return this.getText(n,e)}async getMarkdown(e,t){let n=e.startsWith("/")?e:`/${e}`;return this.getText(`${n}.md`,t)}};var oe="paths_",A=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${oe}list_${t||"all"}`;return (await this.getWithCache(n,"/paths",void 0,e,d.SHORT)).data}async resolve(e,t){let n=t?.locale||this.config.locale,o=`${oe}resolve_${e}_${n||"default"}`;return (await this.getWithCache(o,"/resolve",{path:e},t,d.SHORT)).data}async matchRedirect(e,t){try{return (await this.get("/redirects/match",{path:e},t)).data}catch(n){if(n instanceof v&&n.status===404)return null;throw n}}clearCache(){this.invalidateCache(oe);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Me=!c;function qe(r,e){return c?r():e}async function Ne(r,e){return c?r():e}var re="lynkow-tracker",U=class{config;enabled=true;initialized=false;loading=false;loadPromise=null;constructor(e){this.config=e;}getTrackerUrl(){return `${this.config.baseUrl}/analytics/tracker.js`}loadTracker(){return !c||window.LynkowAnalytics?Promise.resolve():this.loadPromise?this.loadPromise:(this.loading=true,this.loadPromise=new Promise((e,t)=>{if(document.getElementById(re)){let o=setInterval(()=>{window.LynkowAnalytics&&(clearInterval(o),this.loading=false,e());},50);setTimeout(()=>{clearInterval(o),this.loading=false,t(new Error("Tracker script load timeout"));},1e4);return}let n=document.createElement("script");n.id=re,n.src=this.getTrackerUrl(),n.async=true,n.setAttribute("data-site-id",this.config.siteId),this.config.baseUrl&&n.setAttribute("data-api-url",this.config.baseUrl);try{let o=localStorage.getItem("_lkw_consent_mode");o&&n.setAttribute("data-consent-mode",o);}catch{}n.onload=()=>{this.loading=false,setTimeout(()=>{window.LynkowAnalytics?e():t(new Error("Tracker script loaded but LynkowAnalytics not found"));},0);},n.onerror=()=>{this.loading=false,t(new Error("Failed to load tracker script"));},document.head.appendChild(n);}),this.loadPromise)}async init(){if(!(!c||this.initialized))try{await this.loadTracker(),window.LynkowAnalytics&&!this.initialized&&(this.initialized=!0);}catch(e){console.error("[Lynkow] Failed to initialize analytics:",e);}}async trackEvent(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track(e));}async trackPageview(e){!c||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track({type:"pageview",path:e?.path||window.location.pathname,title:e?.title||document.title,referrer:e?.referrer||document.referrer}));}enable(){this.enabled=true;}disable(){this.enabled=false;}isEnabled(){return this.enabled}isInitialized(){return this.initialized&&!!window.LynkowAnalytics}getTracker(){if(c)return window.LynkowAnalytics}destroy(){if(!c)return;document.getElementById(re)?.remove(),this.initialized=false,this.loadPromise=null;}};function He(r){let e=r.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(!e||(e[4]!==void 0?parseFloat(e[4]):1)===0)return null;let n=parseInt(e[1],10),o=parseInt(e[2],10),s=parseInt(e[3],10);return (.299*n+.587*o+.114*s)/255}function C(){if(!c)return "light";let r=document.documentElement,e=document.body;for(let t of [r,e])for(let n of ["data-theme","data-mode","data-color-scheme"]){let o=t.getAttribute(n)?.toLowerCase();if(o){if(o.includes("dark"))return "dark";if(o.includes("light"))return "light"}}if(r.classList.contains("dark")||e.classList.contains("dark"))return "dark";try{let t=getComputedStyle(r).colorScheme;if(t){let n=t.toLowerCase().trim();if(n.startsWith("dark"))return "dark";if(n.startsWith("light"))return "light"}}catch{}try{let t=getComputedStyle(e).backgroundColor,n=He(t);if(n!==null)return n<.5?"dark":"light"}catch{}try{if(window.matchMedia("(prefers-color-scheme: dark)").matches)return "dark"}catch{}return "light"}function F(r){if(!c)return ()=>{};let e=C(),t=[],n=()=>{let i=C();i!==e&&(e=i,r(i));},o=new MutationObserver(n),s={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};o.observe(document.documentElement,s),o.observe(document.body,s),t.push(()=>o.disconnect());try{let i=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n();i.addEventListener("change",a),t.push(()=>i.removeEventListener("change",a));}catch{}return ()=>t.forEach(i=>i())}var V="_lkw_consent",Ue=365*24*60*60*1e3,be="lkw-script-",se={necessary:true,analytics:false,marketing:false,preferences:false},K=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;themeCleanup=null;retry;constructor(e,t){this.config=e,this.retry=G(e.retry),this.events=t;}async getConfig(){if(this.configCache)return this.configCache;let e=`${this.config.baseUrl}/storefront/${encodeURIComponent(this.config.siteId)}/cookie-consent/config`,t=await q(e,{method:"GET",...this.config.fetchOptions,headers:b({"Content-Type":"application/json"},this.config.publishableKey?{"X-Lynkow-Pk":this.config.publishableKey}:void 0,this.config.fetchOptions.headers)},{retry:this.retry,idempotent:true});if(!t.ok)throw new Error(`Failed to fetch consent config: ${t.status}`);let n=await t.json();return this.configCache=n.data,this.configCache}async logConsent(e,t){let n=`${this.config.baseUrl}/storefront/${encodeURIComponent(this.config.siteId)}/cookie-consent/logs`;await fetch(n,{method:"POST",body:JSON.stringify({visitorId:this.getOrCreateVisitorId(),action:t||this.inferAction(e),consentGiven:e,pageUrl:c?window.location.href:void 0}),...this.config.fetchOptions,headers:b({"Content-Type":"application/json"},this.config.publishableKey?{"X-Lynkow-Pk":this.config.publishableKey}:void 0,this.config.fetchOptions.headers)}).catch(()=>{});}getOrCreateVisitorId(){if(!c)return "server";let e="_lkw_vid";try{let t=localStorage.getItem(e);return t||(t=crypto.randomUUID(),localStorage.setItem(e,t)),t}catch{return crypto.randomUUID()}}inferAction(e){let t=Object.entries(e).filter(([s])=>s!=="necessary"),n=t.every(([,s])=>s===true),o=t.every(([,s])=>s===false);return n?"accept_all":o?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(V);if(e){let t=JSON.parse(e);return t.choices?t.timestamp&&Date.now()-t.timestamp>Ue?(localStorage.removeItem(V),null):t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(V,JSON.stringify({choices:e,timestamp:Date.now()}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){c&&this.getConfig().then(e=>{if(!e.enabled)return;try{e.consentMode&&localStorage.setItem("_lkw_consent_mode",e.consentMode);}catch{}let t=this.getStoredConsent();if(t){this.activateScripts(t);return}if(this.bannerElement)return;this.injectBannerStylesOnce();let n=document.createElement("div");n.innerHTML=this.createBannerHTML(e),this.bannerElement=n.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents(),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=F(o=>{this.updateConsentTheme(o);}));});}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null,this.cleanupThemeObserverIfIdle());}showPreferences(){c&&(this.preferencesElement||this.getConfig().then(e=>{let t=this.getCategories(),n=document.createElement("div");n.innerHTML=this.createPreferencesHTML(e,t),this.preferencesElement=n.firstElementChild,document.body.appendChild(this.preferencesElement),this.attachPreferencesEvents(e),e.theme==="auto"&&!this.themeCleanup&&(this.themeCleanup=F(o=>{this.updateConsentTheme(o);}));}));}getCategories(){return c?this.getStoredConsent()||{...se}:{...se}}hasConsented(){return c?this.getStoredConsent()!==null:false}acceptAll(){if(!c)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e,"accept_all"),this.activateScripts(e),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e,"reject_all"),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n,"customize"),this.activateScripts(n);}reset(){if(c){this.removeInjectedScripts();try{localStorage.removeItem(V);}catch{}this.events.emit("consent-changed",{...se}),this.show();}}activateScripts(e){if(this.configCache?.thirdPartyScripts?.length)for(let[t,n]of Object.entries(e))n&&this.injectScriptsForCategory(t,this.configCache.thirdPartyScripts);}injectScriptsForCategory(e,t){for(let n of t){if(n.category!==e||this.injectedScriptIds.has(n.id))continue;this.injectedScriptIds.add(n.id);let o=document.createElement("div");o.innerHTML=n.script;let s=Array.from(o.children);for(let i=0;i<s.length;i++){let a=s[i],p=`${be}${n.id}-${i}`;if(a.tagName==="SCRIPT"){let g=document.createElement("script");for(let u of Array.from(a.attributes))g.setAttribute(u.name,u.value);a.textContent&&(g.textContent=a.textContent),g.id=p,document.head.appendChild(g);}else a.id=p,document.body.appendChild(a);}}}removeInjectedScripts(){for(let e of this.injectedScriptIds){let t=0,n;for(;n=document.getElementById(`${be}${e}-${t}`);)n.remove(),t++;}this.injectedScriptIds.clear();}cleanupThemeObserverIfIdle(){!this.bannerElement&&!this.preferencesElement&&(this.themeCleanup?.(),this.themeCleanup=null);}updateConsentTheme(e){let t=this.configCache?this.resolveColors(this.configCache,e):{bgColor:e==="dark"?"#18181b":"#ffffff",textColor:e==="dark"?"#f4f4f5":"#1a1a1a"},{bgColor:n,textColor:o}=t;if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=o),this.preferencesElement){let s=this.preferencesElement.querySelector(":scope > div");s&&(s.style.background=n,s.style.color=o);}}resolveTheme(e){return e==="auto"?C():e==="dark"?"dark":"light"}resolveColors(e,t){if(e.themeStyles?.[t])return e.themeStyles[t];let n=t==="dark";return {primaryColor:e.primaryColor||"#0066cc",bgColor:n?"#18181b":"#ffffff",textColor:n?"#f4f4f5":"#1a1a1a"}}contrastColor(e){let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return (.299*t+.587*n+.114*o)/255>.5?"#000000":"#ffffff"}injectBannerStylesOnce(){if(document.getElementById("lynkow-consent-styles"))return;let e=document.createElement("style");e.id="lynkow-consent-styles",e.textContent=`
2
2
  #lynkow-consent-banner {
3
3
  box-sizing: border-box;
4
4
  max-height: calc(100vh - 40px);
@@ -44,7 +44,7 @@
44
44
  width: 100%;
45
45
  text-align: center;
46
46
  }
47
- `,document.head.appendChild(e);}createBannerHTML(e){let t=e.position||"bottom-right",n=e.theme||"light",o=e.borderRadius??8,s=e.fontSize??13,i=e.orientation||"auto",a=e.maxWidth??580,p={"bottom-left":`bottom: 20px; left: 20px; max-width: ${a}px; border-radius: ${o}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: ${a}px; border-radius: ${o}px;`},g=p[t]||p["bottom-right"],m=this.resolveTheme(n),l=this.resolveColors(e,m),{primaryColor:h,bgColor:f,textColor:y}=l,F=e.texts||{description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
47
+ `,document.head.appendChild(e);}createBannerHTML(e){let t=e.position||"bottom-right",n=e.theme||"light",o=e.borderRadius??8,s=e.fontSize??13,i=e.orientation||"auto",a=e.maxWidth??580,p={"bottom-left":`bottom: 20px; left: 20px; max-width: ${a}px; border-radius: ${o}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: ${a}px; border-radius: ${o}px;`},g=p[t]||p["bottom-right"],u=this.resolveTheme(n),l=this.resolveColors(e,u),{primaryColor:h,bgColor:f,textColor:y}=l,D=e.texts||{description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
48
48
  <div id="lynkow-consent-banner"${i==="column"?' class="orientation-column"':""} style="
49
49
  position: fixed;
50
50
  ${g}
@@ -58,7 +58,7 @@
58
58
  ">
59
59
  <div class="lynkow-consent-row" style="display: flex; align-items: center; gap: 16px; flex-wrap: wrap;">
60
60
  <p style="margin: 0; line-height: 1.5; flex: 1; min-width: 200px;">
61
- ${F.description}${(()=>{let de=e.cookiePolicyUrl||e.privacyPolicyUrl;if(!de)return "";let Le=F.privacyPolicy||"En savoir plus";return ` <a href="${de}" target="_blank" rel="noopener" style="text-decoration: underline; color: inherit;">${Le}</a>`})()}
61
+ ${D.description}${(()=>{let me=e.cookiePolicyUrl||e.privacyPolicyUrl;if(!me)return "";let Ie=D.privacyPolicy||"En savoir plus";return ` <a href="${me}" target="_blank" rel="noopener" style="text-decoration: underline; color: inherit;">${Ie}</a>`})()}
62
62
  </p>
63
63
  <div class="lynkow-consent-actions" style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
64
64
  <button id="lynkow-consent-accept" style="
@@ -70,7 +70,7 @@
70
70
  cursor: pointer;
71
71
  font-size: ${s}px;
72
72
  white-space: nowrap;
73
- ">${F.acceptAll}</button>
73
+ ">${D.acceptAll}</button>
74
74
  <button id="lynkow-consent-reject" style="
75
75
  padding: 8px 16px;
76
76
  background: transparent;
@@ -80,7 +80,7 @@
80
80
  cursor: pointer;
81
81
  font-size: ${s}px;
82
82
  white-space: nowrap;
83
- ">${F.rejectAll}</button>
83
+ ">${D.rejectAll}</button>
84
84
  ${e.showCustomizeButton!==false?`<button id="lynkow-consent-preferences" style="
85
85
  padding: 8px 4px;
86
86
  background: transparent;
@@ -90,11 +90,11 @@
90
90
  font-size: ${s}px;
91
91
  text-decoration: underline;
92
92
  white-space: nowrap;
93
- ">${F.customize}</button>`:""}
93
+ ">${D.customize}</button>`:""}
94
94
  </div>
95
95
  </div>
96
96
  </div>
97
- `}createPreferencesHTML(e,t){let n=e.theme||"light",o=e.borderRadius??8,s=e.fontSize??13,i=this.resolveTheme(n),a=this.resolveColors(e,i),{primaryColor:p,bgColor:g,textColor:m}=a,l=e.texts||{save:"Enregistrer"},f=(e.categories||[]).map(y=>`
97
+ `}createPreferencesHTML(e,t){let n=e.theme||"light",o=e.borderRadius??8,s=e.fontSize??13,i=this.resolveTheme(n),a=this.resolveColors(e,i),{primaryColor:p,bgColor:g,textColor:u}=a,l=e.texts||{save:"Enregistrer"},f=(e.categories||[]).map(y=>`
98
98
  <label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${y.required?"not-allowed":"pointer"};">
99
99
  <input
100
100
  type="checkbox"
@@ -128,7 +128,7 @@
128
128
  ">
129
129
  <div style="
130
130
  background: ${g};
131
- color: ${m};
131
+ color: ${u};
132
132
  padding: 30px;
133
133
  border-radius: ${o}px;
134
134
  max-width: 500px;
@@ -162,7 +162,7 @@
162
162
  </form>
163
163
  </div>
164
164
  </div>
165
- `}attachBannerEvents(){let e=document.getElementById("lynkow-consent-accept"),t=document.getElementById("lynkow-consent-reject"),n=document.getElementById("lynkow-consent-preferences");e?.addEventListener("click",()=>{this.acceptAll();}),t?.addEventListener("click",()=>{this.rejectAll();}),n?.addEventListener("click",()=>{this.showPreferences();});}attachPreferencesEvents(e){let t=document.getElementById("lynkow-consent-form"),n=document.getElementById("lynkow-consent-close"),o=document.getElementById("lynkow-consent-preferences-modal");t?.addEventListener("submit",s=>{s.preventDefault();let i=new FormData(t),a={necessary:true,analytics:i.has("analytics"),marketing:i.has("marketing"),preferences:i.has("preferences")};this.setCategories(a),this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),n?.addEventListener("click",()=>{this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),o?.addEventListener("click",s=>{s.target===o&&(this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle());});}destroy(){this.themeCleanup?.(),this.themeCleanup=null,this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.removeInjectedScripts();}};var oe="lynkow-badge-container",se="lynkow-badge-styles",K=class extends u{containerElement=null;themeCleanup=null;async inject(){if(c&&!document.getElementById(oe))try{let{data:e}=await this.getWithCache("branding:badge","/branding/badge",void 0,void 0,d.LONG);if(!document.getElementById(se)){let n=document.createElement("style");n.id=se,n.textContent=e.css,document.head.appendChild(n);}let t=document.createElement("div");t.id=oe,t.innerHTML=e.html,C()==="light"&&t.classList.add("lynkow-badge-light"),document.body.appendChild(t),this.containerElement=t,this.themeCleanup=A(n=>{this.containerElement&&this.containerElement.classList.toggle("lynkow-badge-light",n==="light");});}catch{}}remove(){c&&(this.themeCleanup?.(),this.themeCleanup=null,this.containerElement?.remove(),this.containerElement=null,document.getElementById(se)?.remove());}isVisible(){return c?document.getElementById(oe)!==null:false}destroy(){this.remove();}};var ie="lynkow-enhancements-styles",ae="lynkow-enhancements-code-block-styles",ce="data-lynkow-clone",qe=new Set(["","module","text/plain","text/javascript","application/javascript","application/ecmascript","text/ecmascript","application/x-javascript","application/x-ecmascript"]),He='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',Ue='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',Ke=`
165
+ `}attachBannerEvents(){let e=document.getElementById("lynkow-consent-accept"),t=document.getElementById("lynkow-consent-reject"),n=document.getElementById("lynkow-consent-preferences");e?.addEventListener("click",()=>{this.acceptAll();}),t?.addEventListener("click",()=>{this.rejectAll();}),n?.addEventListener("click",()=>{this.showPreferences();});}attachPreferencesEvents(e){let t=document.getElementById("lynkow-consent-form"),n=document.getElementById("lynkow-consent-close"),o=document.getElementById("lynkow-consent-preferences-modal");t?.addEventListener("submit",s=>{s.preventDefault();let i=new FormData(t),a={necessary:true,analytics:i.has("analytics"),marketing:i.has("marketing"),preferences:i.has("preferences")};this.setCategories(a),this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),n?.addEventListener("click",()=>{this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle();}),o?.addEventListener("click",s=>{s.target===o&&(this.preferencesElement?.remove(),this.preferencesElement=null,this.cleanupThemeObserverIfIdle());});}destroy(){this.themeCleanup?.(),this.themeCleanup=null,this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null,this.removeInjectedScripts();}};var ie="lynkow-badge-container",ae="lynkow-badge-styles",j=class extends m{containerElement=null;themeCleanup=null;async inject(){if(c&&!document.getElementById(ie))try{let{data:e}=await this.getWithCache("branding:badge","/branding/badge",void 0,void 0,d.LONG);if(!document.getElementById(ae)){let n=document.createElement("style");n.id=ae,n.textContent=e.css,document.head.appendChild(n);}let t=document.createElement("div");t.id=ie,t.innerHTML=e.html,C()==="light"&&t.classList.add("lynkow-badge-light"),document.body.appendChild(t),this.containerElement=t,this.themeCleanup=F(n=>{this.containerElement&&this.containerElement.classList.toggle("lynkow-badge-light",n==="light");});}catch{}}remove(){c&&(this.themeCleanup?.(),this.themeCleanup=null,this.containerElement?.remove(),this.containerElement=null,document.getElementById(ae)?.remove());}isVisible(){return c?document.getElementById(ie)!==null:false}destroy(){this.remove();}};var ce="lynkow-enhancements-styles",le="lynkow-enhancements-code-block-styles",de="data-lynkow-clone",Ke=new Set(["","module","text/plain","text/javascript","application/javascript","application/ecmascript","text/ecmascript","application/x-javascript","application/x-ecmascript"]),je='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>',ze='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',We=`
166
166
  /*
167
167
  * Lynkow Content Enhancements, generic CSS reset & inline-style preservation.
168
168
  * Always injected. Independent of code-block styling.
@@ -179,7 +179,7 @@
179
179
  h1, h2, h3, h4, h5, h6, p, blockquote {
180
180
  text-align: inherit;
181
181
  }
182
- `,je=`
182
+ `,Ge=`
183
183
  /*
184
184
  * Lynkow Content Enhancements, code-block styling + copy button.
185
185
  * Variable-based: consumers can override any --lynkow-code-* var without !important.
@@ -289,6 +289,6 @@
289
289
  line-height: 1.5;
290
290
  color: var(--lynkow-code-fg);
291
291
  }
292
- `,j=class{initialized=false;observer=null;pendingFrame=null;handleWidgetResize=e=>{if(!e.data||e.data.type!=="lynkow-widget-resize")return;document.querySelectorAll('iframe[src*="/widgets/calendar/"]').forEach(n=>{n.contentWindow===e.source&&(n.style.height=e.data.height+"px");});};injectGenericStyles(){if(!c||document.getElementById(ie))return;let e=document.createElement("style");e.id=ie,e.textContent=Ke,document.head.appendChild(e);}injectCodeBlockStyles(){if(!c||document.getElementById(ae))return;let e=document.createElement("style");e.id=ae,e.textContent=je,document.head.appendChild(e);}async handleCopyClick(e){let t=e.closest(".code-block");if(!t)return;let n=t.querySelector("code");if(!n)return;let o=n.textContent||"";try{await navigator.clipboard.writeText(o),e.classList.add("copied"),e.innerHTML=Ue,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=He;},2e3);}catch(s){console.error("Lynkow SDK: Failed to copy code",s);}}bindCodeBlockCopy(){if(!c)return;document.querySelectorAll("[data-copy-code]").forEach(t=>{t.dataset.lynkowBound||(t.dataset.lynkowBound="true",t.addEventListener("click",n=>{n.preventDefault(),this.handleCopyClick(t);}));});}activateScripts(e){if(!c)return;let n=(e instanceof HTMLElement?e:document.body).querySelectorAll("script:not([data-lynkow-activated])"),o=Array.from(n).filter(s=>!s.src&&s.isConnected&&qe.has(s.type.toLowerCase()));o.length!==0&&(document.head.querySelectorAll(`script[${ce}]`).forEach(s=>s.remove()),o.forEach(s=>{s.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),a=s.attributes;for(let p=0;p<a.length;p++){let g=a[p];g&&(g.name==="type"&&g.value==="text/plain"||g.name!=="data-lynkow-activated"&&i.setAttribute(g.name,g.value));}i.textContent=s.textContent,i.setAttribute(ce,""),document.head.appendChild(i);}));}init(e={}){if(!c||this.initialized)return;let{codeBlocks:t=true}=e;this.injectGenericStyles(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),t&&(this.injectCodeBlockStyles(),this.bindCodeBlockCopy()),this.observer||(this.observer=new MutationObserver(()=>{this.pendingFrame===null&&(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=null,this.activateScripts(),t&&this.bindCodeBlockCopy();}));}),this.observer.observe(document.body,{childList:true,subtree:true})),this.initialized=true;}isInitialized(){return this.initialized}destroy(){c&&(window.removeEventListener("message",this.handleWidgetResize),this.pendingFrame!==null&&(cancelAnimationFrame(this.pendingFrame),this.pendingFrame=null),this.observer&&(this.observer.disconnect(),this.observer=null),document.getElementById(ie)?.remove(),document.getElementById(ae)?.remove(),document.head.querySelectorAll(`script[${ce}]`).forEach(e=>e.remove()),this.initialized=false);}};var z=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:o="scale-down",quality:s=80,gravity:i}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let g=[`w=${p}`,`fit=${o}`,"format=auto",`quality=${s}`,i&&`gravity=${i}`].filter(Boolean).join(",");return `${a.cdnBase}/cdn-cgi/image/${g}/${a.relativePath} ${p}w`}).join(", "):""}transform(e,t={}){if(!e)return "";let n=this.parseImageUrl(e);if(!n)return e||"";let o=[t.w&&`w=${t.w}`,t.h&&`h=${t.h}`,`fit=${t.fit||"scale-down"}`,`format=${t.format||"auto"}`,`quality=${t.quality||80}`,t.gravity&&`gravity=${t.gravity}`,t.dpr&&`dpr=${t.dpr}`].filter(Boolean).join(",");return `${n.cdnBase}/cdn-cgi/image/${o}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let s=e.substring(0,t),i=e.substring(t+15),a=i.indexOf("/");if(a===-1)return null;let p=i.substring(a+1);return {cdnBase:s,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let s=e.substring(0,n),i=e.substring(n+1);return {cdnBase:s,relativePath:i}}let o=e.indexOf("/avatars/");if(o!==-1){let s=e.substring(0,o),i=e.substring(o+1);return {cdnBase:s,relativePath:i}}return null}};var _=class extends u{async search(e,t){return this.get("/search",{q:e,locale:t?.locale,category:t?.category,tag:t?.tag,page:t?.page,limit:t?.limit},t)}async getConfig(e){return (await this.getWithCache("search-config","/search/config",void 0,e,d.MEDIUM)).data}async listProfiles(e){return (await this.getWithCache("search-profiles","/search/profiles",void 0,e,d.MEDIUM)).data}async searchByProfile(e,t,n){return this.get(`/search/${encodeURIComponent(e)}`,{q:t,locale:n?.locale,category:n?.category,tag:n?.tag,page:n?.page,limit:n?.limit},n)}};var ze=300*1e3,We="lynkow_cache_",w=new Map;function Ce(r={}){let e=r.defaultTtl??ze,t=r.prefix??We;function n(m){return `${t}${m}`}function o(m){return Date.now()>m.expiresAt}function s(m){let l=n(m);if(c)try{let f=localStorage.getItem(l);if(!f)return null;let y=JSON.parse(f);return o(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let h=w.get(l);return h?o(h)?(w.delete(l),null):h.value:null}function i(m,l,h=e){let f=n(m),y={value:l,expiresAt:Date.now()+h};if(c){try{localStorage.setItem(f,JSON.stringify(y));}catch{}return}w.set(f,y);}function a(m){let l=n(m);if(c){try{localStorage.removeItem(l);}catch{}return}w.delete(l);}function p(m){if(c){try{let l=[];for(let h=0;h<localStorage.length;h++){let f=localStorage.key(h);f&&f.startsWith(t)&&(!m||f.includes(m))&&l.push(f);}l.forEach(h=>localStorage.removeItem(h));}catch{}return}if(m)for(let l of w.keys())l.startsWith(t)&&l.includes(m)&&w.delete(l);else for(let l of w.keys())l.startsWith(t)&&w.delete(l);}async function g(m,l,h=e){let f=s(m);if(f!==null)return f;let y=await l();return i(m,y,h),y}return {get:s,set:i,remove:a,invalidate:p,getOrSet:g}}function be(r){let e=r.prefix||"[Lynkow]";return {debug(...t){r.debug&&console.debug(e,...t);},info(...t){console.info(e,...t);},warn(...t){console.warn(e,...t);},error(...t){console.error(e,...t);},log(t,...n){switch(t){case "debug":this.debug(...n);break;case "info":this.info(...n);break;case "warn":this.warn(...n);break;case "error":this.error(...n);break}}}}function ke(){let r=new Map;function e(i,a){return r.has(i)||r.set(i,new Set),r.get(i).add(a),()=>t(i,a)}function t(i,a){let p=r.get(i);p&&p.delete(a);}function n(i,a){let p=r.get(i);if(p)for(let g of p)try{g(a);}catch(m){console.error(`[Lynkow] Error in event listener for "${i}":`,m);}}function o(i,a){let p=(g=>{t(i,p),a(g);});return e(i,p)}function s(i){i?r.delete(i):r.clear();}return {on:e,off:t,emit:n,once:o,removeAllListeners:s}}var Re="lynkow_locale";function le(r,e){let t=r.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function xe(r,e){if(!c)return e;let t=Ge();if(t&&r.includes(t))return t;let n=Je(r);if(n)return n;let o=document.documentElement.lang;if(o){let s=le(o,r);if(s)return s;let i=o.split("-")[0]?.toLowerCase();if(i){let a=le(i,r);if(a)return a}}return e}function Ge(){if(!c)return null;try{return localStorage.getItem(Re)}catch{return null}}function Ee(r){if(c)try{localStorage.setItem(Re,r);}catch{}}function Je(r){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let o=le(n,r);if(o)return o}}return null}function Se(r,e){return e.includes(r)}var Te="https://api.lynkow.com";function Ve(r){if(!r.siteId)throw new Error("Lynkow SDK: siteId is required");let e=r.cache===true?Ce():void 0,t=be({debug:r.debug??false}),n=ke(),o=(r.baseUrl||Te).replace(/\/+$/,""),s={siteId:r.siteId,baseUrl:o,publishableKey:r.publishableKey,locale:r.locale,fetchOptions:r.fetchOptions||{},retry:r.retry,...e?{cache:e}:{}},i={locale:r.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new k(s),categories:new R(s),tags:new x(s),pages:new E(s),blocks:new S(s),forms:new T(s),reviews:new L(s),site:new O(s),legal:new I(s),cookies:new P(s),seo:new B(s),paths:new $(s),analytics:new H(s),consent:new U(s,n),branding:new K(s),enhancements:new j,media:new z,search:new _(s)};function p(l){s.locale=l;}async function g(){if(!i.initialized)try{let l=await a.site.getConfig();i.siteConfig=l;let h=l.defaultLocale||"fr";if(i.availableLocales=l.enabledLocales||[h],c&&!r.locale){let f=xe(i.availableLocales,h);i.locale=f,p(f);}i.initialized=!0,t.debug("Client initialized",{locale:i.locale,availableLocales:i.availableLocales}),c&&(a.analytics.init(),a.consent.hasConsented()||a.consent.show(),l.showBranding&&await a.branding.inject(),a.enhancements.init()),n.emit("ready",void 0);}catch(l){t.error("Failed to initialize client",l),n.emit("error",l);}}return c&&setTimeout(()=>{a.enhancements.init(),g();},0),{...a,globals:a.blocks,config:Object.freeze({siteId:r.siteId,baseUrl:o,debug:r.debug??false,cache:r.cache===true}),get locale(){return i.locale},get availableLocales(){return [...i.availableLocales]},setLocale(l){if(!Se(l,i.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${i.availableLocales.join(", ")}`);return}l!==i.locale&&(i.locale=l,p(l),c&&Ee(l),e?.invalidate(),n.emit("locale-changed",l),t.debug("Locale changed to",l));},clearCache(){e?.invalidate(),t.debug("Cache cleared");},destroy(){a.analytics.destroy(),a.consent.destroy(),a.branding.destroy(),a.enhancements.destroy(),e?.invalidate(),n.removeAllListeners(),t.debug("Client destroyed");},on(l,h){return n.on(l,h)}}}function Xe(r){if(!r.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:r.siteId,baseUrl:(r.baseUrl||Te).replace(/\/+$/,""),publishableKey:r.publishableKey,locale:r.locale,fetchOptions:r.fetchOptions||{},retry:r.retry};return {contents:new k(e),categories:new R(e),tags:new x(e),pages:new E(e),blocks:new S(e),forms:new T(e),reviews:new L(e),site:new O(e),legal:new I(e),cookies:new P(e),seo:new B(e),paths:new $(e),search:new _(e)}}function Ye(r){return r.type==="content"}function Qe(r){return r.type==="category"}function Ze(r){if(!r||r.length===0)return "";let e=r.map(o=>{let{["@context"]:s,...i}=o;return i});return `<script type="application/ld+json">${JSON.stringify({"@context":"https://schema.org","@graph":e}).replace(/<\/(script)/gi,"<\\/$1")}</script>`}function et(r,e){let t=r??[],n=e??[];if(n.length===0)return [...t];let o=new Set;for(let s of t){let i=s?.["@id"];typeof i=="string"&&o.add(i);}for(let s of n){let i=s?.["@id"];typeof i=="string"&&o.has(i)&&console.warn(`[lynkow] @id collision in mergeIntoGraph: "${i}" appears in both the server graph and your custom nodes. Google may merge them, which can duplicate properties on the rendered entity. Prefix custom @ids with the page URL to make them unique.`);}return [...t,...n]}
293
- exports.AnalyticsService=H;exports.BlocksService=S;exports.BrandingService=K;exports.CategoriesService=R;exports.ConsentService=U;exports.ContentsService=k;exports.CookiesService=P;exports.EnhancementsService=j;exports.FormsService=T;exports.LegalService=I;exports.LynkowError=v;exports.MediaHelperService=z;exports.PagesService=E;exports.PathsService=$;exports.ReviewsService=L;exports.SearchService=_;exports.SeoService=B;exports.SiteService=O;exports.TagsService=x;exports.browserOnly=Fe;exports.browserOnlyAsync=De;exports.createClient=Ve;exports.createLynkowClient=Xe;exports.detectSiteTheme=C;exports.isBrowser=c;exports.isCategoryResolve=Qe;exports.isContentResolve=Ye;exports.isLynkowError=Oe;exports.isServer=_e;exports.mergeIntoGraph=et;exports.onSiteThemeChange=A;exports.renderJsonLdGraph=Ze;//# sourceMappingURL=index.js.map
292
+ `,z=class{initialized=false;observer=null;pendingFrame=null;handleWidgetResize=e=>{if(!e.data||e.data.type!=="lynkow-widget-resize")return;document.querySelectorAll('iframe[src*="/widgets/calendar/"]').forEach(n=>{n.contentWindow===e.source&&(n.style.height=e.data.height+"px");});};injectGenericStyles(){if(!c||document.getElementById(ce))return;let e=document.createElement("style");e.id=ce,e.textContent=We,document.head.appendChild(e);}injectCodeBlockStyles(){if(!c||document.getElementById(le))return;let e=document.createElement("style");e.id=le,e.textContent=Ge,document.head.appendChild(e);}async handleCopyClick(e){let t=e.closest(".code-block");if(!t)return;let n=t.querySelector("code");if(!n)return;let o=n.textContent||"";try{await navigator.clipboard.writeText(o),e.classList.add("copied"),e.innerHTML=ze,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=je;},2e3);}catch(s){console.error("Lynkow SDK: Failed to copy code",s);}}bindCodeBlockCopy(){if(!c)return;document.querySelectorAll("[data-copy-code]").forEach(t=>{t.dataset.lynkowBound||(t.dataset.lynkowBound="true",t.addEventListener("click",n=>{n.preventDefault(),this.handleCopyClick(t);}));});}activateScripts(e){if(!c)return;let n=(e instanceof HTMLElement?e:document.body).querySelectorAll("script:not([data-lynkow-activated])"),o=Array.from(n).filter(s=>!s.src&&s.isConnected&&Ke.has(s.type.toLowerCase()));o.length!==0&&(document.head.querySelectorAll(`script[${de}]`).forEach(s=>s.remove()),o.forEach(s=>{s.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),a=s.attributes;for(let p=0;p<a.length;p++){let g=a[p];g&&(g.name==="type"&&g.value==="text/plain"||g.name!=="data-lynkow-activated"&&i.setAttribute(g.name,g.value));}i.textContent=s.textContent,i.setAttribute(de,""),document.head.appendChild(i);}));}init(e={}){if(!c||this.initialized)return;let{codeBlocks:t=true}=e;this.injectGenericStyles(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),t&&(this.injectCodeBlockStyles(),this.bindCodeBlockCopy()),this.observer||(this.observer=new MutationObserver(()=>{this.pendingFrame===null&&(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=null,this.activateScripts(),t&&this.bindCodeBlockCopy();}));}),this.observer.observe(document.body,{childList:true,subtree:true})),this.initialized=true;}isInitialized(){return this.initialized}destroy(){c&&(window.removeEventListener("message",this.handleWidgetResize),this.pendingFrame!==null&&(cancelAnimationFrame(this.pendingFrame),this.pendingFrame=null),this.observer&&(this.observer.disconnect(),this.observer=null),document.getElementById(ce)?.remove(),document.getElementById(le)?.remove(),document.head.querySelectorAll(`script[${de}]`).forEach(e=>e.remove()),this.initialized=false);}};var W=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:o="scale-down",quality:s=80,gravity:i}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let g=[`w=${p}`,`fit=${o}`,"format=auto",`quality=${s}`,i&&`gravity=${i}`].filter(Boolean).join(",");return `${a.cdnBase}/cdn-cgi/image/${g}/${a.relativePath} ${p}w`}).join(", "):""}transform(e,t={}){if(!e)return "";let n=this.parseImageUrl(e);if(!n)return e||"";let o=[t.w&&`w=${t.w}`,t.h&&`h=${t.h}`,`fit=${t.fit||"scale-down"}`,`format=${t.format||"auto"}`,`quality=${t.quality||80}`,t.gravity&&`gravity=${t.gravity}`,t.dpr&&`dpr=${t.dpr}`].filter(Boolean).join(",");return `${n.cdnBase}/cdn-cgi/image/${o}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let s=e.substring(0,t),i=e.substring(t+15),a=i.indexOf("/");if(a===-1)return null;let p=i.substring(a+1);return {cdnBase:s,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let s=e.substring(0,n),i=e.substring(n+1);return {cdnBase:s,relativePath:i}}let o=e.indexOf("/avatars/");if(o!==-1){let s=e.substring(0,o),i=e.substring(o+1);return {cdnBase:s,relativePath:i}}return null}};var _=class extends m{async search(e,t){return this.get("/search",{q:e,locale:t?.locale,category:t?.category,tag:t?.tag,page:t?.page,limit:t?.limit},t)}async getConfig(e){return (await this.getWithCache("search-config","/search/config",void 0,e,d.MEDIUM)).data}async listProfiles(e){return (await this.getWithCache("search-profiles","/search/profiles",void 0,e,d.MEDIUM)).data}async searchByProfile(e,t,n){return this.get(`/search/${encodeURIComponent(e)}`,{q:t,locale:n?.locale,category:n?.category,tag:n?.tag,page:n?.page,limit:n?.limit},n)}};var ke="products_",X=class extends m{async list(e,t){let n={};e?.page&&(n.page=e.page),e?.limit&&(n.limit=e.limit),e?.search&&(n.search=e.search),e?.kind&&(n.kind=e.kind),e?.sortBy&&(n.sortBy=e.sortBy),e?.sortOrder&&(n.sortOrder=e.sortOrder);let o=`${ke}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/products",n,t,d.SHORT)}async getBySlug(e,t){return (await this.getWithCache(`${ke}get_${e}`,`/products/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}};var Y=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now(),this.bookings={create:this.createBooking.bind(this)};}bookings;async availability(e,t){return (await this.get(`/products/${encodeURIComponent(e)}/availability`,{from:t.from,to:t.to,partySize:t.partySize})).data}async createBooking(e,t,n){let o=T(this.sessionStartTime),s={...t,...o};return n?.recaptchaToken&&(s._recaptcha_token=n.recaptchaToken),(await this.post(`/products/${encodeURIComponent(e)}/bookings`,s,n)).data}};var Je=300*1e3,Ve="lynkow_cache_",w=new Map;function Re(r={}){let e=r.defaultTtl??Je,t=r.prefix??Ve;function n(u){return `${t}${u}`}function o(u){return Date.now()>u.expiresAt}function s(u){let l=n(u);if(c)try{let f=localStorage.getItem(l);if(!f)return null;let y=JSON.parse(f);return o(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let h=w.get(l);return h?o(h)?(w.delete(l),null):h.value:null}function i(u,l,h=e){let f=n(u),y={value:l,expiresAt:Date.now()+h};if(c){try{localStorage.setItem(f,JSON.stringify(y));}catch{}return}w.set(f,y);}function a(u){let l=n(u);if(c){try{localStorage.removeItem(l);}catch{}return}w.delete(l);}function p(u){if(c){try{let l=[];for(let h=0;h<localStorage.length;h++){let f=localStorage.key(h);f&&f.startsWith(t)&&(!u||f.includes(u))&&l.push(f);}l.forEach(h=>localStorage.removeItem(h));}catch{}return}if(u)for(let l of w.keys())l.startsWith(t)&&l.includes(u)&&w.delete(l);else for(let l of w.keys())l.startsWith(t)&&w.delete(l);}async function g(u,l,h=e){let f=s(u);if(f!==null)return f;let y=await l();return i(u,y,h),y}return {get:s,set:i,remove:a,invalidate:p,getOrSet:g}}function xe(r){let e=r.prefix||"[Lynkow]";return {debug(...t){r.debug&&console.debug(e,...t);},info(...t){console.info(e,...t);},warn(...t){console.warn(e,...t);},error(...t){console.error(e,...t);},log(t,...n){switch(t){case "debug":this.debug(...n);break;case "info":this.info(...n);break;case "warn":this.warn(...n);break;case "error":this.error(...n);break}}}}function Ee(){let r=new Map;function e(i,a){return r.has(i)||r.set(i,new Set),r.get(i).add(a),()=>t(i,a)}function t(i,a){let p=r.get(i);p&&p.delete(a);}function n(i,a){let p=r.get(i);if(p)for(let g of p)try{g(a);}catch(u){console.error(`[Lynkow] Error in event listener for "${i}":`,u);}}function o(i,a){let p=(g=>{t(i,p),a(g);});return e(i,p)}function s(i){i?r.delete(i):r.clear();}return {on:e,off:t,emit:n,once:o,removeAllListeners:s}}var Se="lynkow_locale";function pe(r,e){let t=r.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function Te(r,e){if(!c)return e;let t=Xe();if(t&&r.includes(t))return t;let n=Ye(r);if(n)return n;let o=document.documentElement.lang;if(o){let s=pe(o,r);if(s)return s;let i=o.split("-")[0]?.toLowerCase();if(i){let a=pe(i,r);if(a)return a}}return e}function Xe(){if(!c)return null;try{return localStorage.getItem(Se)}catch{return null}}function Le(r){if(c)try{localStorage.setItem(Se,r);}catch{}}function Ye(r){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let o=pe(n,r);if(o)return o}}return null}function Oe(r,e){return e.includes(r)}var Pe="https://api.lynkow.com";function Qe(r){if(!r.siteId)throw new Error("Lynkow SDK: siteId is required");let e=r.cache===true?Re():void 0,t=xe({debug:r.debug??false}),n=Ee(),o=(r.baseUrl||Pe).replace(/\/+$/,""),s={siteId:r.siteId,baseUrl:o,publishableKey:r.publishableKey,locale:r.locale,fetchOptions:r.fetchOptions||{},retry:r.retry,...e?{cache:e}:{}},i={locale:r.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new k(s),categories:new R(s),tags:new x(s),pages:new E(s),blocks:new S(s),forms:new L(s),reviews:new O(s),site:new P(s),legal:new I(s),cookies:new B(s),seo:new $(s),paths:new A(s),analytics:new U(s),consent:new K(s,n),branding:new j(s),enhancements:new z,media:new W,search:new _(s),products:new X(s),reservations:new Y(s)};function p(l){s.locale=l;}async function g(){if(!i.initialized)try{let l=await a.site.getConfig();i.siteConfig=l;let h=l.defaultLocale||"fr";if(i.availableLocales=l.enabledLocales||[h],c&&!r.locale){let f=Te(i.availableLocales,h);i.locale=f,p(f);}i.initialized=!0,t.debug("Client initialized",{locale:i.locale,availableLocales:i.availableLocales}),c&&(a.analytics.init(),a.consent.hasConsented()||a.consent.show(),l.showBranding&&await a.branding.inject(),a.enhancements.init()),n.emit("ready",void 0);}catch(l){t.error("Failed to initialize client",l),n.emit("error",l);}}return c&&setTimeout(()=>{a.enhancements.init(),g();},0),{...a,globals:a.blocks,config:Object.freeze({siteId:r.siteId,baseUrl:o,debug:r.debug??false,cache:r.cache===true}),get locale(){return i.locale},get availableLocales(){return [...i.availableLocales]},setLocale(l){if(!Oe(l,i.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${i.availableLocales.join(", ")}`);return}l!==i.locale&&(i.locale=l,p(l),c&&Le(l),e?.invalidate(),n.emit("locale-changed",l),t.debug("Locale changed to",l));},clearCache(){e?.invalidate(),t.debug("Cache cleared");},destroy(){a.analytics.destroy(),a.consent.destroy(),a.branding.destroy(),a.enhancements.destroy(),e?.invalidate(),n.removeAllListeners(),t.debug("Client destroyed");},on(l,h){return n.on(l,h)}}}function Ze(r){if(!r.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:r.siteId,baseUrl:(r.baseUrl||Pe).replace(/\/+$/,""),publishableKey:r.publishableKey,locale:r.locale,fetchOptions:r.fetchOptions||{},retry:r.retry};return {contents:new k(e),categories:new R(e),tags:new x(e),pages:new E(e),blocks:new S(e),forms:new L(e),reviews:new O(e),site:new P(e),legal:new I(e),cookies:new B(e),seo:new $(e),paths:new A(e),search:new _(e)}}function et(r){return r.type==="content"}function tt(r){return r.type==="category"}function nt(r){if(!r||r.length===0)return "";let e=r.map(o=>{let{["@context"]:s,...i}=o;return i});return `<script type="application/ld+json">${JSON.stringify({"@context":"https://schema.org","@graph":e}).replace(/<\/(script)/gi,"<\\/$1")}</script>`}function ot(r,e){let t=r??[],n=e??[];if(n.length===0)return [...t];let o=new Set;for(let s of t){let i=s?.["@id"];typeof i=="string"&&o.add(i);}for(let s of n){let i=s?.["@id"];typeof i=="string"&&o.has(i)&&console.warn(`[lynkow] @id collision in mergeIntoGraph: "${i}" appears in both the server graph and your custom nodes. Google may merge them, which can duplicate properties on the rendered entity. Prefix custom @ids with the page URL to make them unique.`);}return [...t,...n]}
293
+ exports.AnalyticsService=U;exports.BlocksService=S;exports.BrandingService=j;exports.CategoriesService=R;exports.ConsentService=K;exports.ContentsService=k;exports.CookiesService=B;exports.EnhancementsService=z;exports.FormsService=L;exports.LegalService=I;exports.LynkowError=v;exports.MediaHelperService=W;exports.PagesService=E;exports.PathsService=A;exports.ReviewsService=O;exports.SearchService=_;exports.SeoService=$;exports.SiteService=P;exports.TagsService=x;exports.browserOnly=qe;exports.browserOnlyAsync=Ne;exports.createClient=Qe;exports.createLynkowClient=Ze;exports.detectSiteTheme=C;exports.isBrowser=c;exports.isCategoryResolve=tt;exports.isContentResolve=et;exports.isLynkowError=Be;exports.isServer=Me;exports.mergeIntoGraph=ot;exports.onSiteThemeChange=F;exports.renderJsonLdGraph=nt;//# sourceMappingURL=index.js.map
294
294
  //# sourceMappingURL=index.js.map