lynkow 3.8.77 → 3.8.79

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.d.ts CHANGED
@@ -1515,15 +1515,16 @@ interface SearchOptions extends BaseRequestOptions {
1515
1515
  */
1516
1516
  interface SearchConfig {
1517
1517
  /**
1518
- * Public search engine host URL (e.g. `'https://search.lynkow.com'`).
1519
- * Use as the `host` when instantiating a Meilisearch-compatible
1520
- * browser client. Does not include a trailing slash.
1518
+ * Public Lynkow search host URL (e.g. `'https://search.lynkow.com'`).
1519
+ * Pass verbatim as the `host` when instantiating a search client in
1520
+ * the browser (for example the `meilisearch-js` npm package, which
1521
+ * speaks the same protocol). Does not include a trailing slash.
1521
1522
  */
1522
1523
  host: string;
1523
1524
  /** Short-lived tenant token (JWT, 1-hour expiry) scoped to your site's index */
1524
1525
  apiKey: string;
1525
1526
  /**
1526
- * Meilisearch index name for this site, of the form
1527
+ * Lynkow search index name for this site, of the form
1527
1528
  * `site-<siteId>_<locale>` or `site-<siteId>` for single-locale sites.
1528
1529
  * Pass verbatim as the `index` parameter in browser search queries.
1529
1530
  */
@@ -1625,6 +1626,106 @@ declare class SearchService extends BaseService {
1625
1626
  * ```
1626
1627
  */
1627
1628
  getConfig(options?: BaseRequestOptions): Promise<SearchConfig>;
1629
+ /**
1630
+ * List the public search profiles configured for the site.
1631
+ *
1632
+ * Site administrators can create multiple "search profiles", each scoped
1633
+ * to a slice of the content (a category, a set of tags, a path prefix,
1634
+ * etc.) with its own searchable/displayed fields and result limits. Use
1635
+ * this method to render a profile selector or to drive a tabbed search
1636
+ * experience (e.g. one tab per documentation space). Only profiles
1637
+ * marked as public are returned; private profiles remain accessible via
1638
+ * authenticated routes only.
1639
+ *
1640
+ * @param options - Base request options (custom fetch options)
1641
+ * @returns A list of `SearchProfilePublic` (slug, name, description,
1642
+ * facets, defaultLimit, maxLimit). Internal scope details are not
1643
+ * exposed.
1644
+ * @throws {LynkowError} With status `503` if search is not enabled for this site
1645
+ *
1646
+ * @example
1647
+ * ```typescript
1648
+ * const profiles = await lynkow.search.listProfiles()
1649
+ * for (const profile of profiles) {
1650
+ * console.log(profile.slug, profile.name)
1651
+ * }
1652
+ * ```
1653
+ */
1654
+ listProfiles(options?: BaseRequestOptions): Promise<SearchProfilePublic[]>;
1655
+ /**
1656
+ * Search a specific profile.
1657
+ *
1658
+ * Equivalent to `search()` but targets a named profile slug instead of
1659
+ * the site default. The profile's scope, searchable subset, displayed
1660
+ * subset, sort, facets, and limits are applied server-side. Use this
1661
+ * to power per-section search experiences (API docs, marketing, help,
1662
+ * etc.) without re-implementing scoping in the client.
1663
+ *
1664
+ * @param profileSlug - The profile's slug (e.g. `'api-docs'`).
1665
+ * Must reference a public profile.
1666
+ * @param query - The search query string. Typos are handled automatically.
1667
+ * @param options - Optional locale/category/tag overrides plus pagination.
1668
+ * These are applied as additional AND filters on top of the profile scope.
1669
+ * @returns A `SearchResponse` containing matched hits and pagination meta.
1670
+ * When the profile defines `featured` content IDs, those appear first
1671
+ * on page 1 with `_isFeatured: true`. `boosted` IDs follow with
1672
+ * `_isBoosted: true`.
1673
+ * @throws {LynkowError} With status `404` if the profile does not exist
1674
+ * @throws {LynkowError} With status `403` if the profile is not public
1675
+ * @throws {LynkowError} With status `503` if search is not enabled for this site
1676
+ *
1677
+ * @example
1678
+ * ```typescript
1679
+ * const results = await lynkow.search.searchByProfile('api-docs', 'pagination', {
1680
+ * limit: 10,
1681
+ * })
1682
+ * ```
1683
+ */
1684
+ searchByProfile(profileSlug: string, query: string, options?: SearchOptions): Promise<SearchResponse>;
1685
+ }
1686
+ /**
1687
+ * A public-facing search profile descriptor.
1688
+ *
1689
+ * Returned by `lynkow.search.listProfiles()`. Profiles let site admins
1690
+ * create scoped search experiences (e.g. "API docs", "Marketing", "Help")
1691
+ * each with its own facets and result shape, while sharing a single
1692
+ * underlying search index per site.
1693
+ */
1694
+ interface SearchProfilePublic {
1695
+ /**
1696
+ * URL-safe identifier for the profile (e.g. `'default'`, `'api-docs'`).
1697
+ * Pass this value to `lynkow.search.searchByProfile()` to query the
1698
+ * profile. Stable for the lifetime of the profile; renaming the slug
1699
+ * via the admin breaks any URL or bookmark referencing it.
1700
+ */
1701
+ slug: string;
1702
+ /**
1703
+ * Human-readable label shown in profile selectors. Localized to the
1704
+ * site's default locale at the time the profile was last edited.
1705
+ */
1706
+ name: string;
1707
+ /**
1708
+ * Optional admin-authored description explaining what the profile
1709
+ * covers. `null` when the admin did not provide one.
1710
+ */
1711
+ description: string | null;
1712
+ /**
1713
+ * Field names available for facet aggregation when querying this
1714
+ * profile. Pass these to a UI that renders facet checkboxes (e.g.
1715
+ * `categories.slug`, `tags.slug`, `type`, `locale`). Empty array when
1716
+ * the admin did not enable any facet.
1717
+ */
1718
+ facets: string[];
1719
+ /**
1720
+ * Default page size applied when the request omits `limit`. Always
1721
+ * positive; admins set it between 1 and 100.
1722
+ */
1723
+ defaultLimit: number;
1724
+ /**
1725
+ * Upper bound on `limit` accepted by the search endpoint. Requests
1726
+ * with a higher limit are clamped to this value. Always positive.
1727
+ */
1728
+ maxLimit: number;
1628
1729
  }
1629
1730
 
1630
1731
  /**
@@ -1784,12 +1885,18 @@ interface LynkowClient {
1784
1885
  }
1785
1886
 
1786
1887
  /**
1787
- * CDN image variant URLs generated by Cloudflare Image Transformations.
1888
+ * CDN image variant URLs generated by the Lynkow image transformation service.
1788
1889
  *
1789
1890
  * Each property is a pre-generated URL for a specific size/crop preset.
1790
- * All URLs point to Cloudflare's CDN and support WebP/AVIF auto-negotiation
1791
- * via the `Accept` header. Properties are `undefined` when the original image
1792
- * is smaller than the preset dimensions (no upscaling is performed).
1891
+ * All URLs are served through the Lynkow CDN and support WebP/AVIF
1892
+ * auto-negotiation via the `Accept` header. A property is `undefined` only
1893
+ * when the endpoint returning this object excludes that preset from its
1894
+ * response (e.g. category images omit `medium`/`content`). For featured
1895
+ * images on content and pages, the six variants `thumbnail`, `card`,
1896
+ * `medium`, `content`, `hero`, and `og` are always present. The CDN uses
1897
+ * a `scale-down` fit that preserves the original size when the source
1898
+ * image is smaller than the target preset, so every URL is safe to use
1899
+ * in `src` or `srcset` regardless of the source dimensions.
1793
1900
  *
1794
1901
  * Use the smallest variant that fits your layout to minimize bandwidth.
1795
1902
  *
@@ -1807,52 +1914,48 @@ interface ImageVariants {
1807
1914
  /**
1808
1915
  * 400x300px, cover crop with sharpening.
1809
1916
  * Use case: list views, grid thumbnails, small cards.
1810
- * `undefined` when the original image is smaller than 400x300.
1811
1917
  */
1812
1918
  thumbnail?: string;
1813
1919
  /**
1814
1920
  * 600x400px, cover crop.
1815
1921
  * Use case: card layouts, blog post previews, medium-sized list items.
1816
- * `undefined` when the original image is smaller than 600x400.
1817
1922
  */
1818
1923
  card?: string;
1819
1924
  /**
1820
1925
  * 1200px wide, scaled down proportionally (no crop).
1821
1926
  * Use case: inline images within article body content.
1822
- * `undefined` when the original image is narrower than 1200px.
1927
+ * Serves the source at its native size when the original is narrower than 1200px.
1823
1928
  */
1824
1929
  content?: string;
1825
1930
  /**
1826
1931
  * 960px wide, scaled down proportionally (no crop).
1827
1932
  * Use case: medium-width displays, sidebar featured images, tablet layouts.
1828
- * `undefined` when the original image is narrower than 960px.
1933
+ * Serves the source at its native size when the original is narrower than 960px.
1829
1934
  */
1830
1935
  medium?: string;
1831
1936
  /**
1832
1937
  * 1920px wide, scaled down proportionally (no crop).
1833
1938
  * Use case: full-width hero banners, page headers, background images.
1834
- * `undefined` when the original image is narrower than 1920px.
1939
+ * Serves the source at its native size when the original is narrower than 1920px.
1835
1940
  */
1836
1941
  hero?: string;
1837
1942
  /**
1838
1943
  * 1200x630px, cover crop.
1839
1944
  * Use case: Open Graph images, social media sharing (Facebook, LinkedIn, Twitter).
1840
1945
  * Dimensions follow the recommended OG image ratio (1.91:1).
1841
- * `undefined` when the original image is smaller than 1200x630.
1842
1946
  */
1843
1947
  og?: string;
1844
1948
  /**
1845
1949
  * 128x128px, cover crop with face detection gravity.
1846
1950
  * Use case: user avatars, author photos, profile pictures.
1847
1951
  * Face detection ensures faces are centered in the crop.
1848
- * `undefined` when the original image is smaller than 128x128.
1849
1952
  */
1850
1953
  avatar?: string;
1851
1954
  /**
1852
1955
  * 2560px wide, scaled down proportionally (no crop).
1853
1956
  * Use case: full-resolution display, lightbox/zoom views, retina hero images.
1854
- * This is the largest available variant. `undefined` when the original
1855
- * image is narrower than 2560px.
1957
+ * This is the largest available variant. Serves the source at its native size
1958
+ * when the original is narrower than 2560px.
1856
1959
  */
1857
1960
  full?: string;
1858
1961
  }
@@ -2536,7 +2639,7 @@ interface Author {
2536
2639
  fullName: string;
2537
2640
  /**
2538
2641
  * Absolute URL to the author's avatar image, or `null` if no avatar is set.
2539
- * When available, points to a Cloudflare R2-hosted image.
2642
+ * When available, points to an image hosted on the Lynkow CDN.
2540
2643
  * Use `ImageVariants.avatar` (128x128) for optimized display if available elsewhere.
2541
2644
  */
2542
2645
  avatarUrl: string | null;
@@ -2852,7 +2955,7 @@ interface SeoImage {
2852
2955
  id: string;
2853
2956
  /**
2854
2957
  * Absolute URL to the image file.
2855
- * Points to a Cloudflare R2-hosted image. Recommended size: 1200x630px for Open Graph.
2958
+ * Points to an image hosted on the Lynkow CDN. Recommended size: 1200x630px for Open Graph.
2856
2959
  * Use this directly in `<meta property="og:image">` or `<meta name="twitter:image">` tags.
2857
2960
  */
2858
2961
  url: string;
@@ -4056,6 +4159,16 @@ interface CookieConfig {
4056
4159
  * When `false`, only "Accept All" and "Reject All" buttons are shown.
4057
4160
  */
4058
4161
  showCustomizeButton?: boolean;
4162
+ /**
4163
+ * Banner layout orientation.
4164
+ * - `'auto'` (default): row layout on screens at least 600px wide,
4165
+ * automatically stacked into a column under 600px.
4166
+ * - `'column'`: forced column layout at every screen size.
4167
+ *
4168
+ * In every mode the banner is height-capped to the viewport with internal
4169
+ * scrolling, so it never overflows the screen.
4170
+ */
4171
+ orientation?: 'auto' | 'column';
4059
4172
  /**
4060
4173
  * Per-theme color overrides for light and dark modes.
4061
4174
  * Only relevant when {@link theme} is `'auto'`.
@@ -5522,6 +5635,7 @@ declare class ConsentService {
5522
5635
  private resolveTheme;
5523
5636
  private resolveColors;
5524
5637
  private contrastColor;
5638
+ private injectBannerStylesOnce;
5525
5639
  private createBannerHTML;
5526
5640
  private createPreferencesHTML;
5527
5641
  private attachBannerEvents;
@@ -5781,11 +5895,11 @@ interface SrcsetOptions {
5781
5895
  */
5782
5896
  widths?: number[];
5783
5897
  /**
5784
- * Cloudflare resize fit mode. `'scale-down'` (default) preserves
5785
- * aspect ratio and never upscales; `'cover'` fills the box and crops;
5786
- * `'contain'` fits inside the box with letterboxing; `'crop'` hard
5787
- * crops to the exact dimensions. Must pair with `gravity` for
5788
- * `'cover'` / `'crop'` when the subject is not centered.
5898
+ * Resize fit mode. `'scale-down'` (default) preserves aspect ratio and
5899
+ * never upscales; `'cover'` fills the box and crops; `'contain'` fits
5900
+ * inside the box with letterboxing; `'crop'` hard crops to the exact
5901
+ * dimensions. Must pair with `gravity` for `'cover'` / `'crop'` when
5902
+ * the subject is not centered.
5789
5903
  */
5790
5904
  fit?: 'cover' | 'contain' | 'scale-down' | 'crop';
5791
5905
  /**
@@ -5802,9 +5916,9 @@ interface SrcsetOptions {
5802
5916
  gravity?: string;
5803
5917
  }
5804
5918
  /**
5805
- * Options for building a single transformed URL. Matches the Cloudflare
5806
- * Image Transformations query parameters; omit any value to let the CDN
5807
- * choose a sensible default.
5919
+ * Options for building a single transformed URL. Each field maps to a
5920
+ * query parameter understood by the Lynkow image transformation service;
5921
+ * omit any value to let the CDN choose a sensible default.
5808
5922
  */
5809
5923
  interface TransformOptions {
5810
5924
  /**
@@ -5843,13 +5957,13 @@ interface TransformOptions {
5843
5957
  dpr?: number;
5844
5958
  }
5845
5959
  /**
5846
- * Service for building optimized image URLs using Cloudflare Image Transformations.
5960
+ * Service for building optimized image URLs backed by the Lynkow image
5961
+ * transformation service.
5847
5962
  *
5848
5963
  * Accessible via `lynkow.media`. This is a pure utility service (no API calls, no
5849
- * caching) that constructs Cloudflare `/cdn-cgi/image/` URLs from Lynkow media URLs.
5964
+ * caching) that constructs CDN transformation URLs from Lynkow media URLs.
5850
5965
  * Works on both server and browser. Handles both original URLs (`/sites/...`) and
5851
- * already-transformed URLs (`/cdn-cgi/image/...`), re-extracting the original path
5852
- * when needed.
5966
+ * already-transformed URLs, re-extracting the original path when needed.
5853
5967
  *
5854
5968
  * @example
5855
5969
  * ```typescript
@@ -5867,7 +5981,7 @@ declare class MediaHelperService {
5867
5981
  /**
5868
5982
  * Generates an HTML `srcset` attribute value from a Lynkow image URL, suitable
5869
5983
  * for use in an `<img srcset="...">` or `<source srcset="...">` tag. Produces
5870
- * one Cloudflare Image Transformation URL per width breakpoint.
5984
+ * one Lynkow CDN transformation URL per width breakpoint.
5871
5985
  *
5872
5986
  * @param imageUrl - Original image URL from the Lynkow API (e.g. `content.featuredImage`).
5873
5987
  * Accepts `null` or `undefined` safely (returns empty string).
@@ -5892,7 +6006,7 @@ declare class MediaHelperService {
5892
6006
  */
5893
6007
  srcset(imageUrl: string | null | undefined, options?: SrcsetOptions): string;
5894
6008
  /**
5895
- * Generates a single Cloudflare Image Transformation URL from a Lynkow image URL.
6009
+ * Generates a single Lynkow CDN transformation URL from a Lynkow image URL.
5896
6010
  * Useful for thumbnails, hero images, or any context where you need a specific
5897
6011
  * size/format.
5898
6012
  *
@@ -5905,7 +6019,7 @@ declare class MediaHelperService {
5905
6019
  * - `format` — output format: `'auto'`, `'webp'`, `'avif'`, or `'jpeg'` (default: `'auto'`)
5906
6020
  * - `gravity` — focal point for crop mode (e.g. `'0.5x0.3'`)
5907
6021
  * - `dpr` — device pixel ratio 1-4 for retina displays
5908
- * @returns The transformed Cloudflare URL, the original URL if transformation is
6022
+ * @returns The transformed Lynkow CDN URL, the original URL if transformation is
5909
6023
  * not possible (non-Lynkow URL), or an empty string if the URL is null/undefined
5910
6024
  *
5911
6025
  * @example
@@ -6394,4 +6508,4 @@ declare function onSiteThemeChange(callback: (theme: 'dark' | 'light') => void):
6394
6508
  */
6395
6509
  declare function renderJsonLdGraph(nodes: object[] | null | undefined): string;
6396
6510
 
6397
- export { type Alternate, AnalyticsService, type ApiErrorDetail, type Author, type BaseRequestOptions, BlocksService, BrandingService, type CategoriesListResponse, CategoriesService, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, ConsentService, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, ContentsService, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, CookiesService, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, FormsService, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type JsonLdGraphConfig, type JsonLdNode, type JsonLdNodeSource, type LegalDocument, LegalService, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, PagesService, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, PathsService, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, ReviewsService, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SearchConfig, type SearchHit, type SearchOptions, type SearchResponse, SearchService, SeoService, type SiteConfig, type SiteConfigResponse, SiteService, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, TagsService, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, detectSiteTheme, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer, onSiteThemeChange, renderJsonLdGraph };
6511
+ export { type Alternate, AnalyticsService, type ApiErrorDetail, type Author, type BaseRequestOptions, BlocksService, BrandingService, type CategoriesListResponse, CategoriesService, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, ConsentService, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, ContentsService, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, CookiesService, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, FormsService, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type JsonLdGraphConfig, type JsonLdNode, type JsonLdNodeSource, type LegalDocument, LegalService, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, PagesService, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, PathsService, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, ReviewsService, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SearchConfig, type SearchHit, type SearchOptions, type SearchProfilePublic, type SearchResponse, SearchService, SeoService, type SiteConfig, type SiteConfigResponse, SiteService, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, TagsService, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, detectSiteTheme, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer, onSiteThemeChange, renderJsonLdGraph };
package/dist/index.js CHANGED
@@ -1,24 +1,70 @@
1
- 'use strict';var C=class s extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,r,o){super(e),this.code=t,this.status=n,this.details=r,this.cause=o,Error.captureStackTrace&&Error.captureStackTrace(this,s);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,r;try{let i=await e.json();i.errors&&Array.isArray(i.errors)?(r=i.errors,n=i.errors[0]?.message||n):i.error?n=i.error:i.message&&(n=i.message);}catch{n=e.statusText||n;}let o=s.statusToCode(t);return new s(n,o,t,r)}static fromNetworkError(e){return e.name==="AbortError"?new s("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new s("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new s(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 Ce(s){return s instanceof C}function ve(s){switch(s){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 z(s,e){let t;try{t=await fetch(s,e);}catch(a){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:a instanceof Error?a.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let r=ve(t.status),o=n.error||n.message||`HTTP error: ${t.status}`,i=n.errors||[{message:o}];throw new C(o,r,t.status,i)}function re(s){let e=new URLSearchParams;for(let[t,n]of Object.entries(s))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;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=re(t);return `${n}?${r}`}return n}async get(e,t,n){let r=n?.locale||this.config.locale,o=r?{...t,locale:r}:t,i=this.buildEndpointUrl(e,o),a=this.mergeFetchOptions(n?.fetchOptions);return z(i,{method:"GET",...a})}async getWithCache(e,t,n,r,o=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,r),o):this.get(t,n,r)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let r=this.buildEndpointUrl(e),o=this.mergeFetchOptions(n?.fetchOptions);return z(r,{method:"POST",...o,headers:{"Content-Type":"application/json",...o.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),r=this.mergeFetchOptions(t?.fetchOptions),o=await fetch(n,{method:"GET",...r});if(!o.ok)throw new Error(`HTTP error: ${o.status}`);return o.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var W="contents_",b=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 r=`${W}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=`${W}slug_${e}_${n||"default"}`;return this.getWithCache(r,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(W);}};var U="categories_",R=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${U}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${U}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=`${U}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(r,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(U);}};var oe="tags_",E=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${oe}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(oe);}};var _="pages_",k=class extends m{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let r=`${_}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=`${_}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=`${_}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=`${_}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(_);}};var G="globals_",x=class extends m{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${G}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=`${G}${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(G);}};function K(s){return {_hp:"",_ts:s}}var se="forms_",S=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${se}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let r=K(this.sessionStartTime),o={data:t,honeypot:r._hp,...r};return n?.recaptchaToken&&(o.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,o,n)}clearCache(){this.invalidateCache(se);}};var F="reviews_",T=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 r=`${F}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${F}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${F}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=K(this.sessionStartTime),r={...e,...n};t?.recaptchaToken&&(r._recaptcha_token=t.recaptchaToken);let o=await this.post("/reviews",r,t);return this.invalidateCache(F),o}clearCache(){this.invalidateCache(F);}};var ie="site_",L=class extends m{async getConfig(){let e=`${ie}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(ie);}};var J="legal_",O=class extends m{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,r=`${J}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(J);}};var ae="cookies_",I=class extends m{async getConfig(){let e=`${ae}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(ae);}};var P=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 V="paths_",B=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${V}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=`${V}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(V);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",we=!c;function be(s,e){return c?s():e}async function Re(s,e){return c?s():e}var X="lynkow-tracker",D=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(X)){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=X,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 r=localStorage.getItem("_lkw_consent_mode");r&&n.setAttribute("data-consent-mode",r);}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(X)?.remove(),this.initialized=false,this.loadPromise=null;}};function Ee(s){let e=s.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),r=parseInt(e[2],10),o=parseInt(e[3],10);return (.299*n+.587*r+.114*o)/255}function w(){if(!c)return "light";let s=document.documentElement,e=document.body;for(let t of [s,e])for(let n of ["data-theme","data-mode","data-color-scheme"]){let r=t.getAttribute(n)?.toLowerCase();if(r){if(r.includes("dark"))return "dark";if(r.includes("light"))return "light"}}if(s.classList.contains("dark")||e.classList.contains("dark"))return "dark";try{let t=getComputedStyle(s).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=Ee(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 $(s){if(!c)return ()=>{};let e=w(),t=[],n=()=>{let i=w();i!==e&&(e=i,s(i));},r=new MutationObserver(n),o={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};r.observe(document.documentElement,o),r.observe(document.body,o),t.push(()=>r.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 j="_lkw_consent",ke=365*24*60*60*1e3,ce="lkw-script-",Y={necessary:true,analytics:false,marketing:false,preferences:false},q=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;themeCleanup=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:c?window.location.href:void 0}),...this.config.fetchOptions}).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(([o])=>o!=="necessary"),n=t.every(([,o])=>o===true),r=t.every(([,o])=>o===false);return n?"accept_all":r?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(j);if(e){let t=JSON.parse(e);return t.choices?t.timestamp&&Date.now()-t.timestamp>ke?(localStorage.removeItem(j),null):t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(j,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;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=$(r=>{this.updateConsentTheme(r);}));});}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=$(r=>{this.updateConsentTheme(r);}));}));}getCategories(){return c?this.getStoredConsent()||{...Y}:{...Y}}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(j);}catch{}this.events.emit("consent-changed",{...Y}),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 r=document.createElement("div");r.innerHTML=n.script;let o=Array.from(r.children);for(let i=0;i<o.length;i++){let a=o[i],p=`${ce}${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(`${ce}${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:r}=t;if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=r),this.preferencesElement){let o=this.preferencesElement.querySelector(":scope > div");o&&(o.style.background=n,o.style.color=r);}}resolveTheme(e){return e==="auto"?w():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),r=parseInt(e.slice(5,7),16);return (.299*t+.587*n+.114*r)/255>.5?"#000000":"#ffffff"}createBannerHTML(e){let t=e.position||"bottom-right",n=e.theme||"light",r=e.borderRadius??8,o=e.fontSize??13,i={"bottom-left":`bottom: 20px; left: 20px; max-width: 580px; border-radius: ${r}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 580px; border-radius: ${r}px;`},a=i[t]||i["bottom-right"],p=this.resolveTheme(n),g=this.resolveColors(e,p),{primaryColor:u,bgColor:l,textColor:f}=g,h=e.texts||{description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
2
- <div id="lynkow-consent-banner" style="
1
+ 'use strict';var C=class s extends Error{name="LynkowError";code;status;details;cause;constructor(e,t,n,r,o){super(e),this.code=t,this.status=n,this.details=r,this.cause=o,Error.captureStackTrace&&Error.captureStackTrace(this,s);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,r;try{let i=await e.json();i.errors&&Array.isArray(i.errors)?(r=i.errors,n=i.errors[0]?.message||n):i.error?n=i.error:i.message&&(n=i.message);}catch{n=e.statusText||n;}let o=s.statusToCode(t);return new s(n,o,t,r)}static fromNetworkError(e){return e.name==="AbortError"?new s("Request timed out","TIMEOUT",void 0,void 0,e):e.name==="TypeError"?new s("Network error - please check your connection","NETWORK_ERROR",void 0,void 0,e):new s(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 ve(s){return s instanceof C}function we(s){switch(s){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 z(s,e){let t;try{t=await fetch(s,e);}catch(a){throw new C("Network error: Unable to reach the server","NETWORK_ERROR",0,[{message:a instanceof Error?a.message:"Unknown error"}])}if(t.ok)return t.json();let n={};try{n=await t.json();}catch{}let r=we(t.status),o=n.error||n.message||`HTTP error: ${t.status}`,i=n.errors||[{message:o}];throw new C(o,r,t.status,i)}function oe(s){let e=new URLSearchParams;for(let[t,n]of Object.entries(s))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;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=oe(t);return `${n}?${r}`}return n}async get(e,t,n){let r=n?.locale||this.config.locale,o=r?{...t,locale:r}:t,i=this.buildEndpointUrl(e,o),a=this.mergeFetchOptions(n?.fetchOptions);return z(i,{method:"GET",...a})}async getWithCache(e,t,n,r,o=d.SHORT){return this.cache?this.cache.getOrSet(e,()=>this.get(t,n,r),o):this.get(t,n,r)}invalidateCache(e){this.cache?.invalidate(e);}async post(e,t,n){let r=this.buildEndpointUrl(e),o=this.mergeFetchOptions(n?.fetchOptions);return z(r,{method:"POST",...o,headers:{"Content-Type":"application/json",...o.headers},body:JSON.stringify(t)})}async getText(e,t){let n=this.buildEndpointUrl(e),r=this.mergeFetchOptions(t?.fetchOptions),o=await fetch(n,{method:"GET",...r});if(!o.ok)throw new Error(`HTTP error: ${o.status}`);return o.text()}mergeFetchOptions(e){return {...this.config.fetchOptions,...e,headers:{...this.config.fetchOptions.headers,...e?.headers}}}};var W="contents_",b=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 r=`${W}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=`${W}slug_${e}_${n||"default"}`;return this.getWithCache(r,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(W);}};var U="categories_",R=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${U}list_${t||"default"}`;return this.getWithCache(n,"/categories",void 0,e,d.SHORT)}async tree(e){let t=e?.locale||this.config.locale,n=`${U}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=`${U}slug_${e}_${JSON.stringify(t||{})}`;return this.getWithCache(r,`/categories/${encodeURIComponent(e)}`,n,t,d.SHORT)}clearCache(){this.invalidateCache(U);}};var se="tags_",k=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${se}list_${t||"default"}`;return this.getWithCache(n,"/tags",void 0,e,d.SHORT)}clearCache(){this.invalidateCache(se);}};var _="pages_",x=class extends m{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let r=`${_}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=`${_}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=`${_}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=`${_}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(_);}};var G="globals_",E=class extends m{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${G}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=`${G}${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(G);}};function j(s){return {_hp:"",_ts:s}}var ie="forms_",S=class extends m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async getBySlug(e){let t=`${ie}${e}`;return (await this.getWithCache(t,`/forms/${encodeURIComponent(e)}`,void 0,void 0,d.MEDIUM)).data}async submit(e,t,n){let r=j(this.sessionStartTime),o={data:t,honeypot:r._hp,...r};return n?.recaptchaToken&&(o.recaptchaToken=n.recaptchaToken),this.post(`/forms/${encodeURIComponent(e)}/submit`,o,n)}clearCache(){this.invalidateCache(ie);}};var F="reviews_",T=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 r=`${F}list_${JSON.stringify(e||{})}`;return this.getWithCache(r,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${F}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${F}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=j(this.sessionStartTime),r={...e,...n};t?.recaptchaToken&&(r._recaptcha_token=t.recaptchaToken);let o=await this.post("/reviews",r,t);return this.invalidateCache(F),o}clearCache(){this.invalidateCache(F);}};var ae="site_",L=class extends m{async getConfig(){let e=`${ae}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(ae);}};var J="legal_",O=class extends m{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,r=`${J}slug_${e}_${n||"default"}`;return (await this.getWithCache(r,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(J);}};var ce="cookies_",I=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/log",{preferences:e},t)}clearCache(){this.invalidateCache(ce);}};var P=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 V="paths_",B=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${V}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=`${V}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(V);}};var c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",be=!c;function Re(s,e){return c?s():e}async function ke(s,e){return c?s():e}var X="lynkow-tracker",D=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(X)){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=X,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 r=localStorage.getItem("_lkw_consent_mode");r&&n.setAttribute("data-consent-mode",r);}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(X)?.remove(),this.initialized=false,this.loadPromise=null;}};function xe(s){let e=s.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),r=parseInt(e[2],10),o=parseInt(e[3],10);return (.299*n+.587*r+.114*o)/255}function w(){if(!c)return "light";let s=document.documentElement,e=document.body;for(let t of [s,e])for(let n of ["data-theme","data-mode","data-color-scheme"]){let r=t.getAttribute(n)?.toLowerCase();if(r){if(r.includes("dark"))return "dark";if(r.includes("light"))return "light"}}if(s.classList.contains("dark")||e.classList.contains("dark"))return "dark";try{let t=getComputedStyle(s).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=xe(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 $(s){if(!c)return ()=>{};let e=w(),t=[],n=()=>{let i=w();i!==e&&(e=i,s(i));},r=new MutationObserver(n),o={attributes:true,attributeFilter:["data-theme","data-mode","data-color-scheme","class","style"]};r.observe(document.documentElement,o),r.observe(document.body,o),t.push(()=>r.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 K="_lkw_consent",Ee=365*24*60*60*1e3,le="lkw-script-",Y={necessary:true,analytics:false,marketing:false,preferences:false},q=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;themeCleanup=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:c?window.location.href:void 0}),...this.config.fetchOptions}).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(([o])=>o!=="necessary"),n=t.every(([,o])=>o===true),r=t.every(([,o])=>o===false);return n?"accept_all":r?"reject_all":"customize"}getStoredConsent(){if(!c)return null;try{let e=localStorage.getItem(K);if(e){let t=JSON.parse(e);return t.choices?t.timestamp&&Date.now()-t.timestamp>Ee?(localStorage.removeItem(K),null):t.choices:t}}catch{}return null}saveConsent(e){if(c){try{localStorage.setItem(K,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=$(r=>{this.updateConsentTheme(r);}));});}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=$(r=>{this.updateConsentTheme(r);}));}));}getCategories(){return c?this.getStoredConsent()||{...Y}:{...Y}}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(K);}catch{}this.events.emit("consent-changed",{...Y}),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 r=document.createElement("div");r.innerHTML=n.script;let o=Array.from(r.children);for(let i=0;i<o.length;i++){let a=o[i],p=`${le}${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(`${le}${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:r}=t;if(this.bannerElement&&(this.bannerElement.style.background=n,this.bannerElement.style.color=r),this.preferencesElement){let o=this.preferencesElement.querySelector(":scope > div");o&&(o.style.background=n,o.style.color=r);}}resolveTheme(e){return e==="auto"?w():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),r=parseInt(e.slice(5,7),16);return (.299*t+.587*n+.114*r)/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
+ #lynkow-consent-banner {
3
+ box-sizing: border-box;
4
+ max-height: calc(100vh - 40px);
5
+ max-height: calc(100dvh - 40px);
6
+ overflow-y: auto;
7
+ }
8
+ @media (max-width: 600px) {
9
+ #lynkow-consent-banner {
10
+ left: 10px !important;
11
+ right: 10px !important;
12
+ max-width: none !important;
13
+ max-height: calc(100vh - 20px);
14
+ max-height: calc(100dvh - 20px);
15
+ }
16
+ #lynkow-consent-banner .lynkow-consent-row {
17
+ flex-direction: column;
18
+ align-items: stretch;
19
+ }
20
+ #lynkow-consent-banner .lynkow-consent-row > * {
21
+ width: 100%;
22
+ }
23
+ #lynkow-consent-banner .lynkow-consent-actions {
24
+ flex-direction: column;
25
+ align-items: stretch;
26
+ }
27
+ #lynkow-consent-banner .lynkow-consent-actions > button {
28
+ width: 100%;
29
+ text-align: center;
30
+ }
31
+ }
32
+ #lynkow-consent-banner.orientation-column .lynkow-consent-row {
33
+ flex-direction: column;
34
+ align-items: stretch;
35
+ }
36
+ #lynkow-consent-banner.orientation-column .lynkow-consent-row > * {
37
+ width: 100%;
38
+ }
39
+ #lynkow-consent-banner.orientation-column .lynkow-consent-actions {
40
+ flex-direction: column;
41
+ align-items: stretch;
42
+ }
43
+ #lynkow-consent-banner.orientation-column .lynkow-consent-actions > button {
44
+ width: 100%;
45
+ text-align: center;
46
+ }
47
+ `,document.head.appendChild(e);}createBannerHTML(e){let t=e.position||"bottom-right",n=e.theme||"light",r=e.borderRadius??8,o=e.fontSize??13,i=e.orientation||"auto",a={"bottom-left":`bottom: 20px; left: 20px; max-width: 580px; border-radius: ${r}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 580px; border-radius: ${r}px;`},p=a[t]||a["bottom-right"],g=this.resolveTheme(n),u=this.resolveColors(e,g),{primaryColor:l,bgColor:f,textColor:y}=u,h=e.texts||{description:"Ce site utilise des cookies pour ameliorer votre experience.",acceptAll:"Accepter tout",rejectAll:"Refuser",customize:"Personnaliser"};return `
48
+ <div id="lynkow-consent-banner"${i==="column"?' class="orientation-column"':""} style="
3
49
  position: fixed;
4
- ${a}
50
+ ${p}
5
51
  z-index: 99999;
6
52
  padding: 16px 20px;
7
- background: ${l};
8
- color: ${f};
53
+ background: ${f};
54
+ color: ${y};
9
55
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
10
56
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
11
57
  font-size: ${o}px;
12
58
  ">
13
- <div style="display: flex; align-items: center; gap: 16px; flex-wrap: wrap;">
59
+ <div class="lynkow-consent-row" style="display: flex; align-items: center; gap: 16px; flex-wrap: wrap;">
14
60
  <p style="margin: 0; line-height: 1.5; flex: 1; min-width: 200px;">
15
- ${h.description}${(()=>{let y=e.cookiePolicyUrl||e.privacyPolicyUrl;if(!y)return "";let ye=h.privacyPolicy||"En savoir plus";return ` <a href="${y}" target="_blank" rel="noopener" style="text-decoration: underline; color: inherit;">${ye}</a>`})()}
61
+ ${h.description}${(()=>{let re=e.cookiePolicyUrl||e.privacyPolicyUrl;if(!re)return "";let Ce=h.privacyPolicy||"En savoir plus";return ` <a href="${re}" target="_blank" rel="noopener" style="text-decoration: underline; color: inherit;">${Ce}</a>`})()}
16
62
  </p>
17
- <div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
63
+ <div class="lynkow-consent-actions" style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
18
64
  <button id="lynkow-consent-accept" style="
19
65
  padding: 8px 16px;
20
- background: ${u};
21
- color: ${this.contrastColor(u)};
66
+ background: ${l};
67
+ color: ${this.contrastColor(l)};
22
68
  border: none;
23
69
  border-radius: ${r}px;
24
70
  cursor: pointer;
@@ -48,21 +94,21 @@
48
94
  </div>
49
95
  </div>
50
96
  </div>
51
- `}createPreferencesHTML(e,t){let n=e.theme||"light",r=e.borderRadius??8,o=e.fontSize??13,i=this.resolveTheme(n),a=this.resolveColors(e,i),{primaryColor:p,bgColor:g,textColor:u}=a,l=e.texts||{save:"Enregistrer"},h=(e.categories||[]).map(y=>`
52
- <label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${y.required?"not-allowed":"pointer"};">
97
+ `}createPreferencesHTML(e,t){let n=e.theme||"light",r=e.borderRadius??8,o=e.fontSize??13,i=this.resolveTheme(n),a=this.resolveColors(e,i),{primaryColor:p,bgColor:g,textColor:u}=a,l=e.texts||{save:"Enregistrer"},y=(e.categories||[]).map(h=>`
98
+ <label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${h.required?"not-allowed":"pointer"};">
53
99
  <input
54
100
  type="checkbox"
55
- name="${y.id}"
56
- ${t[y.id]?"checked":""}
57
- ${y.required?"disabled checked":""}
101
+ name="${h.id}"
102
+ ${t[h.id]?"checked":""}
103
+ ${h.required?"disabled checked":""}
58
104
  style="width: 18px; height: 18px; margin-top: 2px; accent-color: ${p};"
59
105
  />
60
106
  <div style="flex: 1;">
61
- <strong style="opacity: ${y.required?"0.6":"1"};">
62
- ${y.name}${y.required?" (requis)":""}
107
+ <strong style="opacity: ${h.required?"0.6":"1"};">
108
+ ${h.name}${h.required?" (requis)":""}
63
109
  </strong>
64
110
  <p style="margin: 5px 0 0 0; font-size: 13px; opacity: 0.8;">
65
- ${y.description}
111
+ ${h.description}
66
112
  </p>
67
113
  </div>
68
114
  </label>
@@ -91,7 +137,7 @@
91
137
  overflow-y: auto;
92
138
  ">
93
139
  <form id="lynkow-consent-form">
94
- ${h}
140
+ ${y}
95
141
 
96
142
  <div style="display: flex; gap: 10px; margin-top: 25px; padding-top: 20px; border-top: 1px solid rgba(128,128,128,0.3);">
97
143
  <button type="submit" style="
@@ -116,7 +162,7 @@
116
162
  </form>
117
163
  </div>
118
164
  </div>
119
- `}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"),r=document.getElementById("lynkow-consent-preferences-modal");t?.addEventListener("submit",o=>{o.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();}),r?.addEventListener("click",o=>{o.target===r&&(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 Q="lynkow-badge-container",Z="lynkow-badge-styles",N=class extends m{containerElement=null;themeCleanup=null;async inject(){if(c&&!document.getElementById(Q))try{let{data:e}=await this.getWithCache("branding:badge","/branding/badge",void 0,void 0,d.LONG);if(!document.getElementById(Z)){let n=document.createElement("style");n.id=Z,n.textContent=e.css,document.head.appendChild(n);}let t=document.createElement("div");t.id=Q,t.innerHTML=e.html,w()==="light"&&t.classList.add("lynkow-badge-light"),document.body.appendChild(t),this.containerElement=t,this.themeCleanup=$(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(Z)?.remove());}isVisible(){return c?document.getElementById(Q)!==null:false}destroy(){this.remove();}};var ee="lynkow-enhancements-styles",te="data-lynkow-clone",xe=new Set(["","module","text/plain","text/javascript","application/javascript","application/ecmascript","text/ecmascript","application/x-javascript","application/x-ecmascript"]),Se='<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>',Te='<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>',Le=`
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"),r=document.getElementById("lynkow-consent-preferences-modal");t?.addEventListener("submit",o=>{o.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();}),r?.addEventListener("click",o=>{o.target===r&&(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 Q="lynkow-badge-container",Z="lynkow-badge-styles",N=class extends m{containerElement=null;themeCleanup=null;async inject(){if(c&&!document.getElementById(Q))try{let{data:e}=await this.getWithCache("branding:badge","/branding/badge",void 0,void 0,d.LONG);if(!document.getElementById(Z)){let n=document.createElement("style");n.id=Z,n.textContent=e.css,document.head.appendChild(n);}let t=document.createElement("div");t.id=Q,t.innerHTML=e.html,w()==="light"&&t.classList.add("lynkow-badge-light"),document.body.appendChild(t),this.containerElement=t,this.themeCleanup=$(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(Z)?.remove());}isVisible(){return c?document.getElementById(Q)!==null:false}destroy(){this.remove();}};var ee="lynkow-enhancements-styles",te="data-lynkow-clone",Se=new Set(["","module","text/plain","text/javascript","application/javascript","application/ecmascript","text/ecmascript","application/x-javascript","application/x-ecmascript"]),Te='<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>',Le='<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>',Oe=`
120
166
  /*
121
167
  * Lynkow Content Enhancements
122
168
  * These styles ensure that content from the Lynkow API is displayed correctly,
@@ -232,6 +278,6 @@
232
278
  color: #1a1a1a;
233
279
  }
234
280
  }
235
- `,H=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");});};injectStyles(){if(!c||document.getElementById(ee))return;let e=document.createElement("style");e.id=ee,e.textContent=Le,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 r=n.textContent||"";try{await navigator.clipboard.writeText(r),e.classList.add("copied"),e.innerHTML=Te,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=Se;},2e3);}catch(o){console.error("Lynkow SDK: Failed to copy code",o);}}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])"),r=Array.from(n).filter(o=>!o.src&&o.isConnected&&xe.has(o.type.toLowerCase()));r.length!==0&&(document.head.querySelectorAll(`script[${te}]`).forEach(o=>o.remove()),r.forEach(o=>{o.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),a=o.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=o.textContent,i.setAttribute(te,""),document.head.appendChild(i);}));}init(){!c||this.initialized||(this.injectStyles(),this.bindCodeBlockCopy(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),this.observer||(this.observer=new MutationObserver(()=>{this.pendingFrame===null&&(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=null,this.activateScripts(),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(ee)?.remove(),document.head.querySelectorAll(`script[${te}]`).forEach(e=>e.remove()),this.initialized=false);}};var M=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:r="scale-down",quality:o=80,gravity:i}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let g=[`w=${p}`,`fit=${r}`,"format=auto",`quality=${o}`,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 r=[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/${r}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let o=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:o,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let o=e.substring(0,n),i=e.substring(n+1);return {cdnBase:o,relativePath:i}}let r=e.indexOf("/avatars/");if(r!==-1){let o=e.substring(0,r),i=e.substring(r+1);return {cdnBase:o,relativePath:i}}return null}};var A=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 this.getWithCache("search-config","/search/config",void 0,e,d.MEDIUM)}};var Oe=300*1e3,Ie="lynkow_cache_",v=new Map;function le(s={}){let e=s.defaultTtl??Oe,t=s.prefix??Ie;function n(u){return `${t}${u}`}function r(u){return Date.now()>u.expiresAt}function o(u){let l=n(u);if(c)try{let h=localStorage.getItem(l);if(!h)return null;let y=JSON.parse(h);return r(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let f=v.get(l);return f?r(f)?(v.delete(l),null):f.value:null}function i(u,l,f=e){let h=n(u),y={value:l,expiresAt:Date.now()+f};if(c){try{localStorage.setItem(h,JSON.stringify(y));}catch{}return}v.set(h,y);}function a(u){let l=n(u);if(c){try{localStorage.removeItem(l);}catch{}return}v.delete(l);}function p(u){if(c){try{let l=[];for(let f=0;f<localStorage.length;f++){let h=localStorage.key(f);h&&h.startsWith(t)&&(!u||h.includes(u))&&l.push(h);}l.forEach(f=>localStorage.removeItem(f));}catch{}return}if(u)for(let l of v.keys())l.startsWith(t)&&l.includes(u)&&v.delete(l);else for(let l of v.keys())l.startsWith(t)&&v.delete(l);}async function g(u,l,f=e){let h=o(u);if(h!==null)return h;let y=await l();return i(u,y,f),y}return {get:o,set:i,remove:a,invalidate:p,getOrSet:g}}function de(s){let e=s.prefix||"[Lynkow]";return {debug(...t){s.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 pe(){let s=new Map;function e(i,a){return s.has(i)||s.set(i,new Set),s.get(i).add(a),()=>t(i,a)}function t(i,a){let p=s.get(i);p&&p.delete(a);}function n(i,a){let p=s.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 r(i,a){let p=(g=>{t(i,p),a(g);});return e(i,p)}function o(i){i?s.delete(i):s.clear();}return {on:e,off:t,emit:n,once:r,removeAllListeners:o}}var me="lynkow_locale";function ne(s,e){let t=s.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function ue(s,e){if(!c)return e;let t=Pe();if(t&&s.includes(t))return t;let n=Be(s);if(n)return n;let r=document.documentElement.lang;if(r){let o=ne(r,s);if(o)return o;let i=r.split("-")[0]?.toLowerCase();if(i){let a=ne(i,s);if(a)return a}}return e}function Pe(){if(!c)return null;try{return localStorage.getItem(me)}catch{return null}}function ge(s){if(c)try{localStorage.setItem(me,s);}catch{}}function Be(s){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let r=ne(n,s);if(r)return r}}return null}function he(s,e){return e.includes(s)}var fe="https://api.lynkow.com";function $e(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e=s.cache===true?le():void 0,t=de({debug:s.debug??false}),n=pe(),r=(s.baseUrl||fe).replace(/\/$/,""),o={siteId:s.siteId,baseUrl:r,locale:s.locale,fetchOptions:s.fetchOptions||{},...e?{cache:e}:{}},i={locale:s.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new b(o),categories:new R(o),tags:new E(o),pages:new k(o),blocks:new x(o),forms:new S(o),reviews:new T(o),site:new L(o),legal:new O(o),cookies:new I(o),seo:new P(o),paths:new B(o),analytics:new D(o),consent:new q(o,n),branding:new N(o),enhancements:new H,media:new M,search:new A(o)};function p(l){o.locale=l;}async function g(){if(!i.initialized)try{let l=await a.site.getConfig();i.siteConfig=l;let f=l.defaultLocale||"fr";if(i.availableLocales=l.enabledLocales||[f],c&&!s.locale){let h=ue(i.availableLocales,f);i.locale=h,p(h);}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:s.siteId,baseUrl:r,debug:s.debug??false,cache:s.cache===true}),get locale(){return i.locale},get availableLocales(){return [...i.availableLocales]},setLocale(l){if(!he(l,i.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${i.availableLocales.join(", ")}`);return}l!==i.locale&&(i.locale=l,p(l),c&&ge(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,f){return n.on(l,f)}}}function Ae(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:s.siteId,baseUrl:(s.baseUrl||fe).replace(/\/$/,""),locale:s.locale,fetchOptions:s.fetchOptions||{}};return {contents:new b(e),categories:new R(e),tags:new E(e),pages:new k(e),blocks:new x(e),forms:new S(e),reviews:new T(e),site:new L(e),legal:new O(e),cookies:new I(e),seo:new P(e),paths:new B(e),search:new A(e)}}function _e(s){return s.type==="content"}function Fe(s){return s.type==="category"}function De(s){if(!s||s.length===0)return "";let e=s.map(r=>{let{["@context"]:o,...i}=r;return i});return `<script type="application/ld+json">${JSON.stringify({"@context":"https://schema.org","@graph":e}).replace(/<\/(script)/gi,"<\\/$1")}</script>`}
236
- exports.AnalyticsService=D;exports.BlocksService=x;exports.BrandingService=N;exports.CategoriesService=R;exports.ConsentService=q;exports.ContentsService=b;exports.CookiesService=I;exports.EnhancementsService=H;exports.FormsService=S;exports.LegalService=O;exports.LynkowError=C;exports.MediaHelperService=M;exports.PagesService=k;exports.PathsService=B;exports.ReviewsService=T;exports.SearchService=A;exports.SeoService=P;exports.SiteService=L;exports.TagsService=E;exports.browserOnly=be;exports.browserOnlyAsync=Re;exports.createClient=$e;exports.createLynkowClient=Ae;exports.detectSiteTheme=w;exports.isBrowser=c;exports.isCategoryResolve=Fe;exports.isContentResolve=_e;exports.isLynkowError=Ce;exports.isServer=we;exports.onSiteThemeChange=$;exports.renderJsonLdGraph=De;//# sourceMappingURL=index.js.map
281
+ `,H=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");});};injectStyles(){if(!c||document.getElementById(ee))return;let e=document.createElement("style");e.id=ee,e.textContent=Oe,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 r=n.textContent||"";try{await navigator.clipboard.writeText(r),e.classList.add("copied"),e.innerHTML=Le,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=Te;},2e3);}catch(o){console.error("Lynkow SDK: Failed to copy code",o);}}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])"),r=Array.from(n).filter(o=>!o.src&&o.isConnected&&Se.has(o.type.toLowerCase()));r.length!==0&&(document.head.querySelectorAll(`script[${te}]`).forEach(o=>o.remove()),r.forEach(o=>{o.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),a=o.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=o.textContent,i.setAttribute(te,""),document.head.appendChild(i);}));}init(){!c||this.initialized||(this.injectStyles(),this.bindCodeBlockCopy(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),this.observer||(this.observer=new MutationObserver(()=>{this.pendingFrame===null&&(this.pendingFrame=requestAnimationFrame(()=>{this.pendingFrame=null,this.activateScripts(),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(ee)?.remove(),document.head.querySelectorAll(`script[${te}]`).forEach(e=>e.remove()),this.initialized=false);}};var M=class{srcset(e,t={}){if(!e)return "";let{widths:n=[400,800,1200,1920],fit:r="scale-down",quality:o=80,gravity:i}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let g=[`w=${p}`,`fit=${r}`,"format=auto",`quality=${o}`,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 r=[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/${r}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let o=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:o,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let o=e.substring(0,n),i=e.substring(n+1);return {cdnBase:o,relativePath:i}}let r=e.indexOf("/avatars/");if(r!==-1){let o=e.substring(0,r),i=e.substring(r+1);return {cdnBase:o,relativePath:i}}return null}};var A=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 this.getWithCache("search-config","/search/config",void 0,e,d.MEDIUM)}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 Ie=300*1e3,Pe="lynkow_cache_",v=new Map;function de(s={}){let e=s.defaultTtl??Ie,t=s.prefix??Pe;function n(u){return `${t}${u}`}function r(u){return Date.now()>u.expiresAt}function o(u){let l=n(u);if(c)try{let y=localStorage.getItem(l);if(!y)return null;let h=JSON.parse(y);return r(h)?(localStorage.removeItem(l),null):h.value}catch{return null}let f=v.get(l);return f?r(f)?(v.delete(l),null):f.value:null}function i(u,l,f=e){let y=n(u),h={value:l,expiresAt:Date.now()+f};if(c){try{localStorage.setItem(y,JSON.stringify(h));}catch{}return}v.set(y,h);}function a(u){let l=n(u);if(c){try{localStorage.removeItem(l);}catch{}return}v.delete(l);}function p(u){if(c){try{let l=[];for(let f=0;f<localStorage.length;f++){let y=localStorage.key(f);y&&y.startsWith(t)&&(!u||y.includes(u))&&l.push(y);}l.forEach(f=>localStorage.removeItem(f));}catch{}return}if(u)for(let l of v.keys())l.startsWith(t)&&l.includes(u)&&v.delete(l);else for(let l of v.keys())l.startsWith(t)&&v.delete(l);}async function g(u,l,f=e){let y=o(u);if(y!==null)return y;let h=await l();return i(u,h,f),h}return {get:o,set:i,remove:a,invalidate:p,getOrSet:g}}function pe(s){let e=s.prefix||"[Lynkow]";return {debug(...t){s.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 me(){let s=new Map;function e(i,a){return s.has(i)||s.set(i,new Set),s.get(i).add(a),()=>t(i,a)}function t(i,a){let p=s.get(i);p&&p.delete(a);}function n(i,a){let p=s.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 r(i,a){let p=(g=>{t(i,p),a(g);});return e(i,p)}function o(i){i?s.delete(i):s.clear();}return {on:e,off:t,emit:n,once:r,removeAllListeners:o}}var ue="lynkow_locale";function ne(s,e){let t=s.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function ge(s,e){if(!c)return e;let t=Be();if(t&&s.includes(t))return t;let n=$e(s);if(n)return n;let r=document.documentElement.lang;if(r){let o=ne(r,s);if(o)return o;let i=r.split("-")[0]?.toLowerCase();if(i){let a=ne(i,s);if(a)return a}}return e}function Be(){if(!c)return null;try{return localStorage.getItem(ue)}catch{return null}}function he(s){if(c)try{localStorage.setItem(ue,s);}catch{}}function $e(s){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let r=ne(n,s);if(r)return r}}return null}function fe(s,e){return e.includes(s)}var ye="https://api.lynkow.com";function Ae(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e=s.cache===true?de():void 0,t=pe({debug:s.debug??false}),n=me(),r=(s.baseUrl||ye).replace(/\/$/,""),o={siteId:s.siteId,baseUrl:r,locale:s.locale,fetchOptions:s.fetchOptions||{},...e?{cache:e}:{}},i={locale:s.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new b(o),categories:new R(o),tags:new k(o),pages:new x(o),blocks:new E(o),forms:new S(o),reviews:new T(o),site:new L(o),legal:new O(o),cookies:new I(o),seo:new P(o),paths:new B(o),analytics:new D(o),consent:new q(o,n),branding:new N(o),enhancements:new H,media:new M,search:new A(o)};function p(l){o.locale=l;}async function g(){if(!i.initialized)try{let l=await a.site.getConfig();i.siteConfig=l;let f=l.defaultLocale||"fr";if(i.availableLocales=l.enabledLocales||[f],c&&!s.locale){let y=ge(i.availableLocales,f);i.locale=y,p(y);}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:s.siteId,baseUrl:r,debug:s.debug??false,cache:s.cache===true}),get locale(){return i.locale},get availableLocales(){return [...i.availableLocales]},setLocale(l){if(!fe(l,i.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${i.availableLocales.join(", ")}`);return}l!==i.locale&&(i.locale=l,p(l),c&&he(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,f){return n.on(l,f)}}}function _e(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:s.siteId,baseUrl:(s.baseUrl||ye).replace(/\/$/,""),locale:s.locale,fetchOptions:s.fetchOptions||{}};return {contents:new b(e),categories:new R(e),tags:new k(e),pages:new x(e),blocks:new E(e),forms:new S(e),reviews:new T(e),site:new L(e),legal:new O(e),cookies:new I(e),seo:new P(e),paths:new B(e),search:new A(e)}}function Fe(s){return s.type==="content"}function De(s){return s.type==="category"}function qe(s){if(!s||s.length===0)return "";let e=s.map(r=>{let{["@context"]:o,...i}=r;return i});return `<script type="application/ld+json">${JSON.stringify({"@context":"https://schema.org","@graph":e}).replace(/<\/(script)/gi,"<\\/$1")}</script>`}
282
+ exports.AnalyticsService=D;exports.BlocksService=E;exports.BrandingService=N;exports.CategoriesService=R;exports.ConsentService=q;exports.ContentsService=b;exports.CookiesService=I;exports.EnhancementsService=H;exports.FormsService=S;exports.LegalService=O;exports.LynkowError=C;exports.MediaHelperService=M;exports.PagesService=x;exports.PathsService=B;exports.ReviewsService=T;exports.SearchService=A;exports.SeoService=P;exports.SiteService=L;exports.TagsService=k;exports.browserOnly=Re;exports.browserOnlyAsync=ke;exports.createClient=Ae;exports.createLynkowClient=_e;exports.detectSiteTheme=w;exports.isBrowser=c;exports.isCategoryResolve=De;exports.isContentResolve=Fe;exports.isLynkowError=ve;exports.isServer=be;exports.onSiteThemeChange=$;exports.renderJsonLdGraph=qe;//# sourceMappingURL=index.js.map
237
283
  //# sourceMappingURL=index.js.map