lynkow 3.8.0 → 3.8.2
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 +14 -1
- package/dist/index.d.mts +84 -3
- package/dist/index.d.ts +84 -3
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -298,7 +298,7 @@ await lynkow.cookies.logConsent({
|
|
|
298
298
|
})
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
-
### SEO (Sitemap, Robots)
|
|
301
|
+
### SEO (Sitemap, Robots, LLMs)
|
|
302
302
|
|
|
303
303
|
```typescript
|
|
304
304
|
// Get sitemap XML
|
|
@@ -306,6 +306,19 @@ const xml = await lynkow.seo.sitemap()
|
|
|
306
306
|
|
|
307
307
|
// Get robots.txt
|
|
308
308
|
const txt = await lynkow.seo.robots()
|
|
309
|
+
|
|
310
|
+
// Get llms.txt (LLM-optimized site index)
|
|
311
|
+
const llmsIndex = await lynkow.seo.llmsTxt()
|
|
312
|
+
const llmsIndexEn = await lynkow.seo.llmsTxt({ locale: 'en' })
|
|
313
|
+
|
|
314
|
+
// Get llms-full.txt (all content concatenated as Markdown)
|
|
315
|
+
const fullContent = await lynkow.seo.llmsFullTxt()
|
|
316
|
+
|
|
317
|
+
// Get a single blog article as Markdown
|
|
318
|
+
const articleMd = await lynkow.seo.getContentMarkdown('my-article')
|
|
319
|
+
|
|
320
|
+
// Get a single page as Markdown
|
|
321
|
+
const pageMd = await lynkow.seo.getPageMarkdown('about')
|
|
309
322
|
```
|
|
310
323
|
|
|
311
324
|
### Paths (SSG)
|
package/dist/index.d.mts
CHANGED
|
@@ -560,7 +560,7 @@ declare class SeoService extends BaseService {
|
|
|
560
560
|
*
|
|
561
561
|
* @example
|
|
562
562
|
* ```typescript
|
|
563
|
-
* // In a Next.js
|
|
563
|
+
* // In a Next.js route handler
|
|
564
564
|
* export async function GET() {
|
|
565
565
|
* const xml = await lynkow.seo.sitemap()
|
|
566
566
|
* return new Response(xml, {
|
|
@@ -577,7 +577,7 @@ declare class SeoService extends BaseService {
|
|
|
577
577
|
*
|
|
578
578
|
* @example
|
|
579
579
|
* ```typescript
|
|
580
|
-
* // In a Next.js
|
|
580
|
+
* // In a Next.js route handler
|
|
581
581
|
* export async function GET() {
|
|
582
582
|
* const txt = await lynkow.seo.robots()
|
|
583
583
|
* return new Response(txt, {
|
|
@@ -587,6 +587,83 @@ declare class SeoService extends BaseService {
|
|
|
587
587
|
* ```
|
|
588
588
|
*/
|
|
589
589
|
robots(options?: BaseRequestOptions): Promise<string>;
|
|
590
|
+
/**
|
|
591
|
+
* Retrieves the llms.txt file (LLM-optimized site index in Markdown)
|
|
592
|
+
*
|
|
593
|
+
* @param options - Request options. Use `locale` to get a locale-specific version.
|
|
594
|
+
* @returns llms.txt Markdown content
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```typescript
|
|
598
|
+
* // In a Next.js route handler (app/llms.txt/route.ts)
|
|
599
|
+
* export async function GET() {
|
|
600
|
+
* const md = await lynkow.seo.llmsTxt()
|
|
601
|
+
* return new Response(md, {
|
|
602
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
603
|
+
* })
|
|
604
|
+
* }
|
|
605
|
+
*
|
|
606
|
+
* // With locale
|
|
607
|
+
* const md = await lynkow.seo.llmsTxt({ locale: 'en' })
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
llmsTxt(options?: BaseRequestOptions): Promise<string>;
|
|
611
|
+
/**
|
|
612
|
+
* Retrieves the llms-full.txt file (all content concatenated as Markdown)
|
|
613
|
+
*
|
|
614
|
+
* @param options - Request options. Use `locale` to get a locale-specific version.
|
|
615
|
+
* @returns Full Markdown content of all published articles and pages
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* // In a Next.js route handler (app/llms-full.txt/route.ts)
|
|
620
|
+
* export async function GET() {
|
|
621
|
+
* const md = await lynkow.seo.llmsFullTxt()
|
|
622
|
+
* return new Response(md, {
|
|
623
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
624
|
+
* })
|
|
625
|
+
* }
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
llmsFullTxt(options?: BaseRequestOptions): Promise<string>;
|
|
629
|
+
/**
|
|
630
|
+
* Retrieves a single blog article as Markdown
|
|
631
|
+
*
|
|
632
|
+
* @param slug - The article slug
|
|
633
|
+
* @returns Article content as Markdown
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```typescript
|
|
637
|
+
* // In a Next.js route handler (app/llm/blog/[slug]/route.ts)
|
|
638
|
+
* export async function GET(_req: Request, { params }: { params: Promise<{ slug: string }> }) {
|
|
639
|
+
* const { slug } = await params
|
|
640
|
+
* const md = await lynkow.seo.getContentMarkdown(slug)
|
|
641
|
+
* return new Response(md, {
|
|
642
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
643
|
+
* })
|
|
644
|
+
* }
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
getContentMarkdown(slug: string, options?: BaseRequestOptions): Promise<string>;
|
|
648
|
+
/**
|
|
649
|
+
* Retrieves a single page as Markdown
|
|
650
|
+
*
|
|
651
|
+
* @param slug - The page slug
|
|
652
|
+
* @returns Page content as Markdown
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* // In a Next.js route handler (app/llm/pages/[slug]/route.ts)
|
|
657
|
+
* export async function GET(_req: Request, { params }: { params: Promise<{ slug: string }> }) {
|
|
658
|
+
* const { slug } = await params
|
|
659
|
+
* const md = await lynkow.seo.getPageMarkdown(slug)
|
|
660
|
+
* return new Response(md, {
|
|
661
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
662
|
+
* })
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
getPageMarkdown(slug: string, options?: BaseRequestOptions): Promise<string>;
|
|
590
667
|
}
|
|
591
668
|
|
|
592
669
|
/**
|
|
@@ -1252,6 +1329,8 @@ interface LocaleInfo {
|
|
|
1252
1329
|
name: string;
|
|
1253
1330
|
/** Flag emoji (e.g., '🇫🇷', '🇬🇧') */
|
|
1254
1331
|
flag: string;
|
|
1332
|
+
/** Text direction */
|
|
1333
|
+
direction?: 'ltr' | 'rtl';
|
|
1255
1334
|
}
|
|
1256
1335
|
/**
|
|
1257
1336
|
* i18n configuration for language switching
|
|
@@ -1882,7 +1961,9 @@ declare class ConsentService {
|
|
|
1882
1961
|
/**
|
|
1883
1962
|
* Log consent to server
|
|
1884
1963
|
*/
|
|
1885
|
-
logConsent(preferences: CookiePreferences): Promise<void>;
|
|
1964
|
+
logConsent(preferences: CookiePreferences, action?: 'accept_all' | 'reject_all' | 'customize' | 'withdraw'): Promise<void>;
|
|
1965
|
+
private getOrCreateVisitorId;
|
|
1966
|
+
private inferAction;
|
|
1886
1967
|
private getStoredConsent;
|
|
1887
1968
|
private saveConsent;
|
|
1888
1969
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -560,7 +560,7 @@ declare class SeoService extends BaseService {
|
|
|
560
560
|
*
|
|
561
561
|
* @example
|
|
562
562
|
* ```typescript
|
|
563
|
-
* // In a Next.js
|
|
563
|
+
* // In a Next.js route handler
|
|
564
564
|
* export async function GET() {
|
|
565
565
|
* const xml = await lynkow.seo.sitemap()
|
|
566
566
|
* return new Response(xml, {
|
|
@@ -577,7 +577,7 @@ declare class SeoService extends BaseService {
|
|
|
577
577
|
*
|
|
578
578
|
* @example
|
|
579
579
|
* ```typescript
|
|
580
|
-
* // In a Next.js
|
|
580
|
+
* // In a Next.js route handler
|
|
581
581
|
* export async function GET() {
|
|
582
582
|
* const txt = await lynkow.seo.robots()
|
|
583
583
|
* return new Response(txt, {
|
|
@@ -587,6 +587,83 @@ declare class SeoService extends BaseService {
|
|
|
587
587
|
* ```
|
|
588
588
|
*/
|
|
589
589
|
robots(options?: BaseRequestOptions): Promise<string>;
|
|
590
|
+
/**
|
|
591
|
+
* Retrieves the llms.txt file (LLM-optimized site index in Markdown)
|
|
592
|
+
*
|
|
593
|
+
* @param options - Request options. Use `locale` to get a locale-specific version.
|
|
594
|
+
* @returns llms.txt Markdown content
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```typescript
|
|
598
|
+
* // In a Next.js route handler (app/llms.txt/route.ts)
|
|
599
|
+
* export async function GET() {
|
|
600
|
+
* const md = await lynkow.seo.llmsTxt()
|
|
601
|
+
* return new Response(md, {
|
|
602
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
603
|
+
* })
|
|
604
|
+
* }
|
|
605
|
+
*
|
|
606
|
+
* // With locale
|
|
607
|
+
* const md = await lynkow.seo.llmsTxt({ locale: 'en' })
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
llmsTxt(options?: BaseRequestOptions): Promise<string>;
|
|
611
|
+
/**
|
|
612
|
+
* Retrieves the llms-full.txt file (all content concatenated as Markdown)
|
|
613
|
+
*
|
|
614
|
+
* @param options - Request options. Use `locale` to get a locale-specific version.
|
|
615
|
+
* @returns Full Markdown content of all published articles and pages
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* // In a Next.js route handler (app/llms-full.txt/route.ts)
|
|
620
|
+
* export async function GET() {
|
|
621
|
+
* const md = await lynkow.seo.llmsFullTxt()
|
|
622
|
+
* return new Response(md, {
|
|
623
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
624
|
+
* })
|
|
625
|
+
* }
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
llmsFullTxt(options?: BaseRequestOptions): Promise<string>;
|
|
629
|
+
/**
|
|
630
|
+
* Retrieves a single blog article as Markdown
|
|
631
|
+
*
|
|
632
|
+
* @param slug - The article slug
|
|
633
|
+
* @returns Article content as Markdown
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```typescript
|
|
637
|
+
* // In a Next.js route handler (app/llm/blog/[slug]/route.ts)
|
|
638
|
+
* export async function GET(_req: Request, { params }: { params: Promise<{ slug: string }> }) {
|
|
639
|
+
* const { slug } = await params
|
|
640
|
+
* const md = await lynkow.seo.getContentMarkdown(slug)
|
|
641
|
+
* return new Response(md, {
|
|
642
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
643
|
+
* })
|
|
644
|
+
* }
|
|
645
|
+
* ```
|
|
646
|
+
*/
|
|
647
|
+
getContentMarkdown(slug: string, options?: BaseRequestOptions): Promise<string>;
|
|
648
|
+
/**
|
|
649
|
+
* Retrieves a single page as Markdown
|
|
650
|
+
*
|
|
651
|
+
* @param slug - The page slug
|
|
652
|
+
* @returns Page content as Markdown
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```typescript
|
|
656
|
+
* // In a Next.js route handler (app/llm/pages/[slug]/route.ts)
|
|
657
|
+
* export async function GET(_req: Request, { params }: { params: Promise<{ slug: string }> }) {
|
|
658
|
+
* const { slug } = await params
|
|
659
|
+
* const md = await lynkow.seo.getPageMarkdown(slug)
|
|
660
|
+
* return new Response(md, {
|
|
661
|
+
* headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
662
|
+
* })
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
getPageMarkdown(slug: string, options?: BaseRequestOptions): Promise<string>;
|
|
590
667
|
}
|
|
591
668
|
|
|
592
669
|
/**
|
|
@@ -1252,6 +1329,8 @@ interface LocaleInfo {
|
|
|
1252
1329
|
name: string;
|
|
1253
1330
|
/** Flag emoji (e.g., '🇫🇷', '🇬🇧') */
|
|
1254
1331
|
flag: string;
|
|
1332
|
+
/** Text direction */
|
|
1333
|
+
direction?: 'ltr' | 'rtl';
|
|
1255
1334
|
}
|
|
1256
1335
|
/**
|
|
1257
1336
|
* i18n configuration for language switching
|
|
@@ -1882,7 +1961,9 @@ declare class ConsentService {
|
|
|
1882
1961
|
/**
|
|
1883
1962
|
* Log consent to server
|
|
1884
1963
|
*/
|
|
1885
|
-
logConsent(preferences: CookiePreferences): Promise<void>;
|
|
1964
|
+
logConsent(preferences: CookiePreferences, action?: 'accept_all' | 'reject_all' | 'customize' | 'withdraw'): Promise<void>;
|
|
1965
|
+
private getOrCreateVisitorId;
|
|
1966
|
+
private inferAction;
|
|
1886
1967
|
private getStoredConsent;
|
|
1887
1968
|
private saveConsent;
|
|
1888
1969
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var C=class o extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,r,i){super(e),this.code=t,this.status=n,this.details=r,this.cause=i,Error.captureStackTrace&&Error.captureStackTrace(this,o);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,r;try{let s=await e.json();s.errors&&Array.isArray(s.errors)?(r=s.errors,n=s.errors[0]?.message||n):s.error?n=s.error:s.message&&(n=s.message);}catch{n=e.statusText||n;}let i=o.statusToCode(t);return new o(n,i,t,r)}static fromNetworkError(e){return e.name==="AbortError"?new o("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new o("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new o(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 ue(o){return o instanceof C}function ge(o){switch(o){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"}}async function U(o,e){let t;try{t=await fetch(o,e);}catch(l){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:l instanceof Error?l.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let r=ge(t.status),i=n.error||n.message||`HTTP error: ${t.status}`,s=n.errors||[{message:i}];throw new C(i,r,t.status,s)}function Z(o){let e=new URLSearchParams;for(let[t,n]of Object.entries(o))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;constructor(e){this.config=e,this.cache=e.cache;}buildEndpointUrl(e,t){let n=`${this.config.baseUrl}/public/${this.config.siteId}${e}`;if(t&&Object.keys(t).length>0){let r=Z(t);return `${n}?${r}`}return n}async get(e,t,n){let r=n?.locale||this.config.locale,i=r?{...t,locale:r}:t,s=this.buildEndpointUrl(e,i),l=this.mergeFetchOptions(n?.fetchOptions);return U(s,{method:"GET",...l})}async getWithCache(e,t,n,r,i=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,r),i):this.get(t,n,r)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let r=this.buildEndpointUrl(e),i=this.mergeFetchOptions(n?.fetchOptions);return U(r,{method:"POST",...i,headers:{"Content-Type":"application/json",...i.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),r=this.mergeFetchOptions(t?.fetchOptions),i=await fetch(n,{method:"GET",...r});if(!i.ok)throw new Error(`HTTP error: ${i.status}`);return i.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var M="contents_",b=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 r=`${M}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/contents",n,t,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${M}slug_${e}_${n||"default"}`;return this.getWithCache(r,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(M);}};var D="categories_",R=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${D}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${D}tree_${t||"default"}`;return this.getWithCache(n,"/categories/tree",void 0,e,d.SHORT)}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),(t?.limit??t?.perPage)&&(n.limit=t?.limit??t?.perPage);let r=`${D}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(r,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(D);}};var ee="tags_",x=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${ee}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(ee);}};var k="pages_",E=class extends u{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let r=`${k}list_${t||"default"}_${e?.tag||"all"}`;return this.getWithCache(r,"/pages",n,e,d.SHORT)}async getBySlug(e,t){let n=t?.locale||this.config.locale,r=`${k}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}async getByPath(e,t){let n=t?.locale||this.config.locale,r=`${k}path_${e}_${n||"default"}`;return (await this.getWithCache(r,"/page-by-path",{path:e},t,d.SHORT)).data}async getJsonLd(e,t){let n=t?.locale||this.config.locale,r=`${k}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(k);}};var z="globals_",L=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,r=`${z}${e}_${n||"default"}`;return this.getWithCache(r,`/global/${encodeURIComponent(e)}`,void 0,t,d.MEDIUM)}async global(e,t){return this.getBySlug(e,t)}clearCache(){this.invalidateCache(z);}};function N(o){return {_hp:"",_ts:o}}var te="forms_",T=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${te}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let r=N(this.sessionStartTime),i={data:t,honeypot:r._hp,...r};return n?.recaptchaToken&&(i.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,i,n)}clearCache(){this.invalidateCache(te);}};var S="reviews_",O=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 r=`${S}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${S}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${S}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=N(this.sessionStartTime),r={...e,...n};t?.recaptchaToken&&(r._recaptcha_token=t.recaptchaToken);let i=await this.post("/reviews",r,t);return this.invalidateCache(S),i}clearCache(){this.invalidateCache(S);}};var ne="site_",P=class extends u{async getConfig(){let e=`${ne}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(ne);}};var W="legal_",B=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${W}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,r=`${W}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(W);}};var oe="cookies_",I=class extends u{async getConfig(){let e=`${oe}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/log",{preferences:e},t)}clearCache(){this.invalidateCache(oe);}};var $=class extends u{async sitemap(e){return this.getText("/sitemap.xml",e)}async robots(e){return this.getText("/robots.txt",e)}};var j="paths_",A=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${j}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,d.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,r=`${j}resolve_${e}_${n||"default"}`;return this.getWithCache(r,"/resolve",{path:e},t,d.SHORT)}async matchRedirect(e,t){try{return (await this.get("/redirects/match",{path:e},t)).data}catch(n){if(n instanceof C&&n.status===404)return null;throw n}}clearCache(){this.invalidateCache(j);}};var a=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",me=!a;function fe(o,e){return a?o():e}async function he(o,e){return a?o():e}var G="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 !a||window.LynkowAnalytics?Promise.resolve():this.loadPromise?this.loadPromise:(this.loading=true,this.loadPromise=new Promise((e,t)=>{if(document.getElementById(G)){let r=setInterval(()=>{window.LynkowAnalytics&&(clearInterval(r),this.loading=false,e());},50);setTimeout(()=>{clearInterval(r),this.loading=false,t(new Error("Tracker script load timeout"));},1e4);return}let n=document.createElement("script");n.id=G,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),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(!(!a||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){!a||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track(e));}async trackFunnelStep(e){!a||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.trackFunnel(e.funnelId,e.stepNumber,e.stepName,e.funnelName));}async trackPageview(e){!a||!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(a)return window.LynkowAnalytics}destroy(){if(!a)return;document.getElementById(G)?.remove(),this.initialized=false,this.loadPromise=null;}};var V="_lkw_consent",J={necessary:true,analytics:false,marketing:false,preferences:false},q=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;constructor(e,t){this.config=e,this.events=t;}async getConfig(){if(this.configCache)return this.configCache;let e=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/config`,t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"},...this.config.fetchOptions});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){let t=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/log`;await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({preferences:e}),...this.config.fetchOptions}).catch(()=>{});}getStoredConsent(){if(!a)return null;try{let e=localStorage.getItem(V);if(e){let t=JSON.parse(e);return t.choices?t.choices:t}}catch{}return null}saveConsent(e){if(a){try{localStorage.setItem(V,JSON.stringify({choices:e}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){a&&(this.bannerElement||this.getConfig().then(e=>{if(!e.enabled)return;let t=document.createElement("div");t.innerHTML=this.createBannerHTML(e),this.bannerElement=t.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents();}));}hide(){a&&(this.bannerElement?.remove(),this.bannerElement=null);}showPreferences(){a&&(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);}));}getCategories(){return a?this.getStoredConsent()||{...J}:{...J}}hasConsented(){return a?this.getStoredConsent()!==null:false}acceptAll(){if(!a)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e),this.hide();}rejectAll(){if(!a)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e),this.hide();}setCategories(e){if(!a)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n);}reset(){if(a){try{localStorage.removeItem(V);}catch{}this.events.emit("consent-changed",{...J}),this.show();}}createBannerHTML(e){let t=e.position||"bottom",n=e.theme||"light",r=e.layout||"banner",i=e.primaryColor||"#0066cc",s=e.borderRadius??8,l={bottom:"bottom: 0; left: 0; right: 0;",top:"top: 0; left: 0; right: 0;","bottom-left":"bottom: 0; left: 0; right: 0;","bottom-right":"bottom: 0; left: 0; right: 0;",center:"top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px);"},m={bottom:`bottom: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,top:`top: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-left":`bottom: 20px; left: 20px; max-width: 400px; border-radius: ${s}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 400px; border-radius: ${s}px;`,center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`},h={center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,bottom:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,top:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-left":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-right":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`},g;r==="floating"?g=m:r==="modal"?g=h:g=l;let c=g[t]||g.bottom||"",p=n==="dark",f=p?"#1a1a1a":"#ffffff",y=p?"#ffffff":"#1a1a1a",w=e.texts||{title:"Nous utilisons des cookies",description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
|
|
2
|
-
${
|
|
1
|
+
'use strict';var C=class r extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,o,i){super(e),this.code=t,this.status=n,this.details=o,this.cause=i,Error.captureStackTrace&&Error.captureStackTrace(this,r);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,o;try{let s=await e.json();s.errors&&Array.isArray(s.errors)?(o=s.errors,n=s.errors[0]?.message||n):s.error?n=s.error:s.message&&(n=s.message);}catch{n=e.statusText||n;}let i=r.statusToCode(t);return new r(n,i,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 ge(r){return r instanceof C}function me(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"}}async function K(r,e){let t;try{t=await fetch(r,e);}catch(l){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:l instanceof Error?l.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let o=me(t.status),i=n.error||n.message||`HTTP error: ${t.status}`,s=n.errors||[{message:i}];throw new C(i,o,t.status,s)}function ee(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;constructor(e){this.config=e,this.cache=e.cache;}buildEndpointUrl(e,t){let n=`${this.config.baseUrl}/public/${this.config.siteId}${e}`;if(t&&Object.keys(t).length>0){let o=ee(t);return `${n}?${o}`}return n}async get(e,t,n){let o=n?.locale||this.config.locale,i=o?{...t,locale:o}:t,s=this.buildEndpointUrl(e,i),l=this.mergeFetchOptions(n?.fetchOptions);return K(s,{method:"GET",...l})}async getWithCache(e,t,n,o,i=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,o),i):this.get(t,n,o)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let o=this.buildEndpointUrl(e),i=this.mergeFetchOptions(n?.fetchOptions);return K(o,{method:"POST",...i,headers:{"Content-Type":"application/json",...i.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),o=this.mergeFetchOptions(t?.fetchOptions),i=await fetch(n,{method:"GET",...o});if(!i.ok)throw new Error(`HTTP error: ${i.status}`);return i.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var M="contents_",b=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=`${M}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=`${M}slug_${e}_${n||"default"}`;return this.getWithCache(o,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(M);}};var D="categories_",R=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${D}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${D}tree_${t||"default"}`;return this.getWithCache(n,"/categories/tree",void 0,e,d.SHORT)}async getBySlug(e,t){let n={};t?.page&&(n.page=t.page),(t?.limit??t?.perPage)&&(n.limit=t?.limit??t?.perPage);let o=`${D}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(o,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(D);}};var te="tags_",x=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${te}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(te);}};var k="pages_",E=class extends u{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let o=`${k}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=`${k}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=`${k}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=`${k}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(k);}};var z="globals_",T=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 N(r){return {_hp:"",_ts:r}}var ne="forms_",L=class extends u{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${ne}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let o=N(this.sessionStartTime),i={data:t,honeypot:o._hp,...o};return n?.recaptchaToken&&(i.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,i,n)}clearCache(){this.invalidateCache(ne);}};var S="reviews_",O=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=`${S}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${S}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${S}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=N(this.sessionStartTime),o={...e,...n};t?.recaptchaToken&&(o._recaptcha_token=t.recaptchaToken);let i=await this.post("/reviews",o,t);return this.invalidateCache(S),i}clearCache(){this.invalidateCache(S);}};var oe="site_",P=class extends u{async getConfig(){let e=`${oe}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(oe);}};var j="legal_",I=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${j}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=`${j}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(j);}};var re="cookies_",B=class extends u{async getConfig(){let e=`${re}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/log",{preferences:e},t)}clearCache(){this.invalidateCache(re);}};var $=class extends u{async sitemap(e){return this.getText("/sitemap.xml",e)}async robots(e){return this.getText("/robots.txt",e)}async llmsTxt(e){let t=e?.locale||this.config.locale,n=t?`/${t}/llms.txt`:"/llms.txt";return this.getText(n,e)}async llmsFullTxt(e){let t=e?.locale||this.config.locale,n=t?`/${t}/llms-full.txt`:"/llms-full.txt";return this.getText(n,e)}async getContentMarkdown(e,t){return this.getText(`/llm/blog/${encodeURIComponent(e)}.md`,t)}async getPageMarkdown(e,t){return this.getText(`/llm/pages/${encodeURIComponent(e)}.md`,t)}};var W="paths_",A=class extends u{async list(e){let t=e?.locale||this.config.locale,n=`${W}list_${t||"all"}`;return this.getWithCache(n,"/paths",void 0,e,d.SHORT)}async resolve(e,t){let n=t?.locale||this.config.locale,o=`${W}resolve_${e}_${n||"default"}`;return this.getWithCache(o,"/resolve",{path:e},t,d.SHORT)}async matchRedirect(e,t){try{return (await this.get("/redirects/match",{path:e},t)).data}catch(n){if(n instanceof C&&n.status===404)return null;throw n}}clearCache(){this.invalidateCache(W);}};var a=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",fe=!a;function he(r,e){return a?r():e}async function ye(r,e){return a?r():e}var G="lynkow-tracker",q=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 !a||window.LynkowAnalytics?Promise.resolve():this.loadPromise?this.loadPromise:(this.loading=true,this.loadPromise=new Promise((e,t)=>{if(document.getElementById(G)){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=G,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),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(!(!a||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){!a||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.track(e));}async trackFunnelStep(e){!a||!this.enabled||(await this.init(),window.LynkowAnalytics&&window.LynkowAnalytics.trackFunnel(e.funnelId,e.stepNumber,e.stepName,e.funnelName));}async trackPageview(e){!a||!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(a)return window.LynkowAnalytics}destroy(){if(!a)return;document.getElementById(G)?.remove(),this.initialized=false,this.loadPromise=null;}};var V="_lkw_consent",J={necessary:true,analytics:false,marketing:false,preferences:false},H=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;constructor(e,t){this.config=e,this.events=t;}async getConfig(){if(this.configCache)return this.configCache;let e=`${this.config.baseUrl}/public/${this.config.siteId}/cookie-consent/config`,t=await fetch(e,{method:"GET",headers:{"Content-Type":"application/json"},...this.config.fetchOptions});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}/public/${this.config.siteId}/cookie-consent/log`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({visitorId:this.getOrCreateVisitorId(),action:t||this.inferAction(e),consentGiven:e,pageUrl:a?window.location.href:void 0}),...this.config.fetchOptions}).catch(()=>{});}getOrCreateVisitorId(){if(!a)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(([i])=>i!=="necessary"),n=t.every(([,i])=>i===true),o=t.every(([,i])=>i===false);return n?"accept_all":o?"reject_all":"customize"}getStoredConsent(){if(!a)return null;try{let e=localStorage.getItem(V);if(e){let t=JSON.parse(e);return t.choices?t.choices:t}}catch{}return null}saveConsent(e){if(a){try{localStorage.setItem(V,JSON.stringify({choices:e}));}catch{}this.events.emit("consent-changed",e),document.dispatchEvent(new CustomEvent("lynkow:consent:update",{detail:e}));}}show(){a&&(this.bannerElement||this.getConfig().then(e=>{if(!e.enabled)return;let t=document.createElement("div");t.innerHTML=this.createBannerHTML(e),this.bannerElement=t.firstElementChild,document.body.appendChild(this.bannerElement),this.attachBannerEvents();}));}hide(){a&&(this.bannerElement?.remove(),this.bannerElement=null);}showPreferences(){a&&(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);}));}getCategories(){return a?this.getStoredConsent()||{...J}:{...J}}hasConsented(){return a?this.getStoredConsent()!==null:false}acceptAll(){if(!a)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e,"accept_all"),this.hide();}rejectAll(){if(!a)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e,"reject_all"),this.hide();}setCategories(e){if(!a)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n,"customize");}reset(){if(a){try{localStorage.removeItem(V);}catch{}this.events.emit("consent-changed",{...J}),this.show();}}createBannerHTML(e){let t=e.position||"bottom",n=e.theme||"light",o=e.layout||"banner",i=e.primaryColor||"#0066cc",s=e.borderRadius??8,l={bottom:"bottom: 0; left: 0; right: 0;",top:"top: 0; left: 0; right: 0;","bottom-left":"bottom: 0; left: 0; right: 0;","bottom-right":"bottom: 0; left: 0; right: 0;",center:"top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px);"},m={bottom:`bottom: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,top:`top: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-left":`bottom: 20px; left: 20px; max-width: 400px; border-radius: ${s}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 400px; border-radius: ${s}px;`,center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`},h={center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,bottom:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,top:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-left":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`,"bottom-right":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${s}px;`},g;o==="floating"?g=m:o==="modal"?g=h:g=l;let c=g[t]||g.bottom||"",p=n==="dark",f=p?"#1a1a1a":"#ffffff",y=p?"#ffffff":"#1a1a1a",w=e.texts||{title:"Nous utilisons des cookies",description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
|
|
2
|
+
${o==="modal"?`
|
|
3
3
|
<div id="lynkow-consent-backdrop" style="
|
|
4
4
|
position: fixed;
|
|
5
5
|
top: 0;
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
</div>
|
|
58
58
|
</div>
|
|
59
59
|
</div>
|
|
60
|
-
`}createPreferencesHTML(e,t){let n=e.theme||"light",
|
|
60
|
+
`}createPreferencesHTML(e,t){let n=e.theme||"light",o=e.primaryColor||"#0066cc",i=e.borderRadius??8,s=n==="dark",l=s?"#1a1a1a":"#ffffff",m=s?"#ffffff":"#1a1a1a",h=e.texts||{title:"Preferences de cookies",save:"Enregistrer"},c=(e.categories||[]).map(p=>`
|
|
61
61
|
<label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${p.required?"not-allowed":"pointer"};">
|
|
62
62
|
<input
|
|
63
63
|
type="checkbox"
|
|
64
64
|
name="${p.id}"
|
|
65
65
|
${t[p.id]?"checked":""}
|
|
66
66
|
${p.required?"disabled checked":""}
|
|
67
|
-
style="width: 18px; height: 18px; margin-top: 2px; accent-color: ${
|
|
67
|
+
style="width: 18px; height: 18px; margin-top: 2px; accent-color: ${o};"
|
|
68
68
|
/>
|
|
69
69
|
<div style="flex: 1;">
|
|
70
70
|
<strong style="opacity: ${p.required?"0.6":"1"};">
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
<div style="display: flex; gap: 10px; margin-top: 25px; padding-top: 20px; border-top: 1px solid rgba(128,128,128,0.3);">
|
|
108
108
|
<button type="submit" style="
|
|
109
109
|
padding: 10px 20px;
|
|
110
|
-
background: ${
|
|
110
|
+
background: ${o};
|
|
111
111
|
color: white;
|
|
112
112
|
border: none;
|
|
113
113
|
border-radius: ${i}px;
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
</form>
|
|
128
128
|
</div>
|
|
129
129
|
</div>
|
|
130
|
-
`}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"),
|
|
130
|
+
`}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",i=>{i.preventDefault();let s=new FormData(t),l={necessary:true,analytics:s.has("analytics"),marketing:s.has("marketing"),preferences:s.has("preferences")};this.setCategories(l),this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null;}),n?.addEventListener("click",()=>{this.preferencesElement?.remove(),this.preferencesElement=null;}),o?.addEventListener("click",i=>{i.target===o&&(this.preferencesElement?.remove(),this.preferencesElement=null);});}destroy(){this.hide(),this.preferencesElement?.remove(),this.preferencesElement=null;}};var X="lynkow-badge-container",Y="lynkow-badge-styles",U=class extends u{containerElement=null;async inject(){if(a&&!document.getElementById(X))try{let{data:e}=await this.getWithCache("branding:badge","/branding/badge",void 0,void 0,d.LONG);if(!document.getElementById(Y)){let n=document.createElement("style");n.id=Y,n.textContent=e.css,document.head.appendChild(n);}let t=document.createElement("div");t.id=X,t.innerHTML=e.html,document.body.appendChild(t),this.containerElement=t;}catch{}}remove(){a&&(this.containerElement?.remove(),this.containerElement=null,document.getElementById(Y)?.remove());}isVisible(){return a?document.getElementById(X)!==null:false}destroy(){this.remove();}};var Q="lynkow-enhancements-styles",Ce='<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>',ve='<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=`
|
|
131
131
|
/*
|
|
132
132
|
* Lynkow Content Enhancements
|
|
133
133
|
* These styles ensure that content from the Lynkow API is displayed correctly,
|
|
@@ -243,6 +243,6 @@
|
|
|
243
243
|
color: #1a1a1a;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
`,_=class{initialized=false;observer=null;injectStyles(){if(!a||document.getElementById(Q))return;let e=document.createElement("style");e.id=Q,e.textContent=
|
|
247
|
-
exports.EnhancementsService=_;exports.LynkowError=C;exports.MediaHelperService=F;exports.browserOnly=
|
|
246
|
+
`,_=class{initialized=false;observer=null;injectStyles(){if(!a||document.getElementById(Q))return;let e=document.createElement("style");e.id=Q,e.textContent=we,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=ve,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=Ce;},2e3);}catch(i){console.error("Lynkow SDK: Failed to copy code",i);}}bindCodeBlockCopy(){if(!a)return;document.querySelectorAll("[data-copy-code]").forEach(t=>{t.dataset.lynkowBound||(t.dataset.lynkowBound="true",t.addEventListener("click",n=>{n.preventDefault(),this.handleCopyClick(t);}));});}init(){a&&(this.injectStyles(),this.bindCodeBlockCopy(),this.observer||(this.observer=new MutationObserver(e=>{let t=false;for(let n of e)if(n.addedNodes.length>0){t=true;break}t&&this.bindCodeBlockCopy();}),this.observer.observe(document.body,{childList:true,subtree:true})),this.initialized=true);}isInitialized(){return this.initialized}destroy(){a&&(this.observer&&(this.observer.disconnect(),this.observer=null),document.getElementById(Q)?.remove(),this.initialized=false);}};var F=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:o="scale-down",quality:i=80,gravity:s}=t,l=this.parseImageUrl(e);return l?n.map(m=>{let h=[`w=${m}`,`fit=${o}`,"format=auto",`quality=${i}`,s&&`gravity=${s}`].filter(Boolean).join(",");return `${l.cdnBase}/cdn-cgi/image/${h}/${l.relativePath} ${m}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 i=e.substring(0,t),s=e.substring(t+15),l=s.indexOf("/");if(l===-1)return null;let m=s.substring(l+1);return {cdnBase:i,relativePath:m}}let n=e.indexOf("/sites/");if(n!==-1){let i=e.substring(0,n),s=e.substring(n+1);return {cdnBase:i,relativePath:s}}let o=e.indexOf("/avatars/");if(o!==-1){let i=e.substring(0,o),s=e.substring(o+1);return {cdnBase:i,relativePath:s}}return null}};var be=300*1e3,Re="lynkow_cache_",v=new Map;function se(r={}){let e=r.defaultTtl??be,t=r.prefix??Re;function n(g){return `${t}${g}`}function o(g){return Date.now()>g.expiresAt}function i(g){let c=n(g);if(a)try{let f=localStorage.getItem(c);if(!f)return null;let y=JSON.parse(f);return o(y)?(localStorage.removeItem(c),null):y.value}catch{return null}let p=v.get(c);return p?o(p)?(v.delete(c),null):p.value:null}function s(g,c,p=e){let f=n(g),y={value:c,expiresAt:Date.now()+p};if(a){try{localStorage.setItem(f,JSON.stringify(y));}catch{}return}v.set(f,y);}function l(g){let c=n(g);if(a){try{localStorage.removeItem(c);}catch{}return}v.delete(c);}function m(g){if(a){try{let c=[];for(let p=0;p<localStorage.length;p++){let f=localStorage.key(p);f&&f.startsWith(t)&&(!g||f.includes(g))&&c.push(f);}c.forEach(p=>localStorage.removeItem(p));}catch{}return}if(g)for(let c of v.keys())c.startsWith(t)&&c.includes(g)&&v.delete(c);else for(let c of v.keys())c.startsWith(t)&&v.delete(c);}async function h(g,c,p=e){let f=i(g);if(f!==null)return f;let y=await c();return s(g,y,p),y}return {get:i,set:s,remove:l,invalidate:m,getOrSet:h}}function ie(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 ae(){let r=new Map;function e(s,l){return r.has(s)||r.set(s,new Set),r.get(s).add(l),()=>t(s,l)}function t(s,l){let m=r.get(s);m&&m.delete(l);}function n(s,l){let m=r.get(s);if(m)for(let h of m)try{h(l);}catch(g){console.error(`[Lynkow] Error in event listener for "${s}":`,g);}}function o(s,l){let m=(h=>{t(s,m),l(h);});return e(s,m)}function i(s){s?r.delete(s):r.clear();}return {on:e,off:t,emit:n,once:o,removeAllListeners:i}}var ce="lynkow_locale";function Z(r,e){let t=r.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function le(r,e){if(!a)return e;let t=xe();if(t&&r.includes(t))return t;let n=ke(r);if(n)return n;let o=document.documentElement.lang;if(o){let i=Z(o,r);if(i)return i;let s=o.split("-")[0]?.toLowerCase();if(s){let l=Z(s,r);if(l)return l}}return e}function xe(){if(!a)return null;try{return localStorage.getItem(ce)}catch{return null}}function de(r){if(a)try{localStorage.setItem(ce,r);}catch{}}function ke(r){if(!a)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let o=Z(n,r);if(o)return o}}return null}function pe(r,e){return e.includes(r)}var ue="https://api.lynkow.com";function Ee(r){if(!r.siteId)throw new Error("Lynkow SDK: siteId is required");let e=se(),t=ie({debug:r.debug??false}),n=ae(),o=(r.baseUrl||ue).replace(/\/$/,""),i={siteId:r.siteId,baseUrl:o,locale:r.locale,fetchOptions:r.fetchOptions||{},cache:e},s={locale:r.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},l={contents:new b(i),categories:new R(i),tags:new x(i),pages:new E(i),blocks:new T(i),forms:new L(i),reviews:new O(i),site:new P(i),legal:new I(i),cookies:new B(i),seo:new $(i),paths:new A(i),analytics:new q(i),consent:new H(i,n),branding:new U(i),enhancements:new _,media:new F};function m(c){i.locale=c;}async function h(){if(!s.initialized)try{let c=await l.site.getConfig();s.siteConfig=c;let p=c.defaultLocale||"fr";if(s.availableLocales=c.enabledLocales||[p],a&&!r.locale){let f=le(s.availableLocales,p);s.locale=f,m(f);}s.initialized=!0,t.debug("Client initialized",{locale:s.locale,availableLocales:s.availableLocales}),a&&(l.analytics.init(),l.consent.hasConsented()||l.consent.show(),c.showBranding&&await l.branding.inject(),l.enhancements.init()),n.emit("ready",void 0);}catch(c){t.error("Failed to initialize client",c),n.emit("error",c);}}return a&&setTimeout(()=>h(),0),{...l,globals:l.blocks,config:Object.freeze({siteId:r.siteId,baseUrl:o,debug:r.debug??false}),get locale(){return s.locale},get availableLocales(){return [...s.availableLocales]},setLocale(c){if(!pe(c,s.availableLocales)){t.warn(`Locale "${c}" is not available. Available: ${s.availableLocales.join(", ")}`);return}c!==s.locale&&(s.locale=c,m(c),a&&de(c),e.invalidate(),n.emit("locale-changed",c),t.debug("Locale changed to",c));},clearCache(){e.invalidate(),t.debug("Cache cleared");},destroy(){l.analytics.destroy(),l.consent.destroy(),l.branding.destroy(),l.enhancements.destroy(),e.invalidate(),n.removeAllListeners(),t.debug("Client destroyed");},on(c,p){return n.on(c,p)}}}function Te(r){if(!r.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:r.siteId,baseUrl:(r.baseUrl||ue).replace(/\/$/,""),locale:r.locale,fetchOptions:r.fetchOptions||{}};return {contents:new b(e),categories:new R(e),tags:new x(e),pages:new E(e),blocks:new T(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)}}function Le(r){return r.type==="content"}function Se(r){return r.type==="category"}
|
|
247
|
+
exports.EnhancementsService=_;exports.LynkowError=C;exports.MediaHelperService=F;exports.browserOnly=he;exports.browserOnlyAsync=ye;exports.createClient=Ee;exports.createLynkowClient=Te;exports.isBrowser=a;exports.isCategoryResolve=Se;exports.isContentResolve=Le;exports.isLynkowError=ge;exports.isServer=fe;//# sourceMappingURL=index.js.map
|
|
248
248
|
//# sourceMappingURL=index.js.map
|