lynkow 3.8.52 → 3.8.53
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/core-CqpK2E3_.d.mts +14 -0
- package/dist/core-CqpK2E3_.d.ts +14 -0
- package/dist/index.d.mts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/dist/middleware/next.d.mts +10 -0
- package/dist/middleware/next.d.ts +10 -0
- package/dist/middleware/next.js +3 -0
- package/dist/middleware/next.js.map +1 -0
- package/dist/middleware/next.mjs +3 -0
- package/dist/middleware/next.mjs.map +1 -0
- package/dist/visual-editor/index.d.mts +109 -0
- package/dist/visual-editor/index.d.ts +109 -0
- package/dist/visual-editor/index.js +64 -0
- package/dist/visual-editor/index.js.map +1 -0
- package/dist/visual-editor/index.mjs +64 -0
- package/dist/visual-editor/index.mjs.map +1 -0
- package/dist/visual-editor/react/index.d.mts +21 -0
- package/dist/visual-editor/react/index.d.ts +21 -0
- package/dist/visual-editor/react/index.js +64 -0
- package/dist/visual-editor/react/index.js.map +1 -0
- package/dist/visual-editor/react/index.mjs +64 -0
- package/dist/visual-editor/react/index.mjs.map +1 -0
- package/package.json +53 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type DataChangeCallback = (blockSlug: string, fieldKey: string, fieldPath: string, value: unknown, allData: Record<string, any>) => void;
|
|
2
|
+
|
|
3
|
+
interface VisualEditorConfig {
|
|
4
|
+
cmsOrigin: string;
|
|
5
|
+
}
|
|
6
|
+
interface VisualEditorInstance {
|
|
7
|
+
destroy: () => void;
|
|
8
|
+
isPreviewMode: () => boolean;
|
|
9
|
+
getBlockData: (blockSlug: string) => Record<string, any> | null;
|
|
10
|
+
onDataChange: (callback: DataChangeCallback) => () => void;
|
|
11
|
+
}
|
|
12
|
+
declare function initVisualEditor(config: VisualEditorConfig): VisualEditorInstance;
|
|
13
|
+
|
|
14
|
+
export { type DataChangeCallback as D, type VisualEditorConfig as V, type VisualEditorInstance as a, initVisualEditor as i };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type DataChangeCallback = (blockSlug: string, fieldKey: string, fieldPath: string, value: unknown, allData: Record<string, any>) => void;
|
|
2
|
+
|
|
3
|
+
interface VisualEditorConfig {
|
|
4
|
+
cmsOrigin: string;
|
|
5
|
+
}
|
|
6
|
+
interface VisualEditorInstance {
|
|
7
|
+
destroy: () => void;
|
|
8
|
+
isPreviewMode: () => boolean;
|
|
9
|
+
getBlockData: (blockSlug: string) => Record<string, any> | null;
|
|
10
|
+
onDataChange: (callback: DataChangeCallback) => () => void;
|
|
11
|
+
}
|
|
12
|
+
declare function initVisualEditor(config: VisualEditorConfig): VisualEditorInstance;
|
|
13
|
+
|
|
14
|
+
export { type DataChangeCallback as D, type VisualEditorConfig as V, type VisualEditorInstance as a, initVisualEditor as i };
|
package/dist/index.d.mts
CHANGED
|
@@ -808,6 +808,72 @@ interface ImageVariants {
|
|
|
808
808
|
full?: string;
|
|
809
809
|
}
|
|
810
810
|
|
|
811
|
+
/**
|
|
812
|
+
* Schema types for structured content.
|
|
813
|
+
*
|
|
814
|
+
* Categories in 'structured' mode define a field schema that determines
|
|
815
|
+
* the custom fields available for content in that category. These types
|
|
816
|
+
* describe the schema structure returned by the API.
|
|
817
|
+
*/
|
|
818
|
+
/**
|
|
819
|
+
* Supported field types in a content schema
|
|
820
|
+
*/
|
|
821
|
+
type SchemaFieldType = 'string' | 'text' | 'richtext' | 'number' | 'boolean' | 'select' | 'multiselect' | 'image' | 'file' | 'url' | 'email' | 'date' | 'datetime' | 'color' | 'object' | 'array' | 'dataSource';
|
|
822
|
+
/**
|
|
823
|
+
* Option for select/multiselect fields
|
|
824
|
+
*/
|
|
825
|
+
interface SchemaFieldOption {
|
|
826
|
+
value: string;
|
|
827
|
+
label: string;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Validation rules for a schema field
|
|
831
|
+
*/
|
|
832
|
+
interface SchemaFieldValidation {
|
|
833
|
+
minLength?: number;
|
|
834
|
+
maxLength?: number;
|
|
835
|
+
min?: number;
|
|
836
|
+
max?: number;
|
|
837
|
+
pattern?: string;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* A single field definition in a content schema
|
|
841
|
+
*/
|
|
842
|
+
interface SchemaField {
|
|
843
|
+
/** Unique key (used as the property name in customData) */
|
|
844
|
+
key: string;
|
|
845
|
+
/** Field type */
|
|
846
|
+
type: SchemaFieldType;
|
|
847
|
+
/** Display label */
|
|
848
|
+
label: string;
|
|
849
|
+
/** Whether the field is required */
|
|
850
|
+
required?: boolean;
|
|
851
|
+
/** Placeholder text */
|
|
852
|
+
placeholder?: string;
|
|
853
|
+
/** Help text shown below the field */
|
|
854
|
+
helpText?: string;
|
|
855
|
+
/** Default value */
|
|
856
|
+
defaultValue?: unknown;
|
|
857
|
+
/** Validation rules */
|
|
858
|
+
validation?: SchemaFieldValidation;
|
|
859
|
+
/** Sub-fields for object/array types */
|
|
860
|
+
fields?: SchemaField[];
|
|
861
|
+
/** Label for array items */
|
|
862
|
+
itemLabel?: string;
|
|
863
|
+
/** Minimum number of array items */
|
|
864
|
+
minItems?: number;
|
|
865
|
+
/** Maximum number of array items */
|
|
866
|
+
maxItems?: number;
|
|
867
|
+
/** Options for select/multiselect types */
|
|
868
|
+
options?: SchemaFieldOption[];
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Complete content schema (list of field definitions)
|
|
872
|
+
*/
|
|
873
|
+
interface ContentSchema {
|
|
874
|
+
fields: SchemaField[];
|
|
875
|
+
}
|
|
876
|
+
|
|
811
877
|
/**
|
|
812
878
|
* Content category
|
|
813
879
|
*/
|
|
@@ -820,6 +886,14 @@ interface Category {
|
|
|
820
886
|
slug: string;
|
|
821
887
|
/** Locale */
|
|
822
888
|
locale: string;
|
|
889
|
+
/**
|
|
890
|
+
* Content mode.
|
|
891
|
+
* - `'standard'`: articles use the TipTap rich text editor (body field)
|
|
892
|
+
* - `'structured'`: articles use custom fields defined by the category schema (customData field)
|
|
893
|
+
*
|
|
894
|
+
* Only present in detail responses, not in list select projections.
|
|
895
|
+
*/
|
|
896
|
+
contentMode?: 'standard' | 'structured';
|
|
823
897
|
}
|
|
824
898
|
/**
|
|
825
899
|
* Category with path and counter
|
|
@@ -835,6 +909,18 @@ interface CategoryWithCount extends Category {
|
|
|
835
909
|
contentCount: number;
|
|
836
910
|
/** CDN image variants */
|
|
837
911
|
imageVariants?: ImageVariants;
|
|
912
|
+
/**
|
|
913
|
+
* Field schema for structured categories.
|
|
914
|
+
* Defines the custom fields available for content in this category.
|
|
915
|
+
* Only present when `contentMode` is `'structured'`.
|
|
916
|
+
*/
|
|
917
|
+
schema?: ContentSchema | null;
|
|
918
|
+
/**
|
|
919
|
+
* Schema source.
|
|
920
|
+
* - `'own'`: this category defines its own schema
|
|
921
|
+
* - `'inherit'`: schema is inherited from the parent category
|
|
922
|
+
*/
|
|
923
|
+
schemaSource?: 'own' | 'inherit' | null;
|
|
838
924
|
}
|
|
839
925
|
/**
|
|
840
926
|
* Detailed category (with all info)
|
|
@@ -1039,6 +1125,22 @@ interface Content extends ContentSummary {
|
|
|
1039
1125
|
categories: Category[];
|
|
1040
1126
|
/** Associated tags */
|
|
1041
1127
|
tags: Tag[];
|
|
1128
|
+
/**
|
|
1129
|
+
* Custom field data for structured content.
|
|
1130
|
+
* Populated when the content belongs to a category with `contentMode: 'structured'`.
|
|
1131
|
+
* Richtext fields are automatically converted to HTML by the API.
|
|
1132
|
+
* `null` for standard content (which uses `body` instead).
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
* ```typescript
|
|
1136
|
+
* if (content.customData) {
|
|
1137
|
+
* console.log(content.customData.price) // number
|
|
1138
|
+
* console.log(content.customData.description) // HTML string (richtext)
|
|
1139
|
+
* console.log(content.customData.gallery) // array of objects
|
|
1140
|
+
* }
|
|
1141
|
+
* ```
|
|
1142
|
+
*/
|
|
1143
|
+
customData?: Record<string, any> | null;
|
|
1042
1144
|
}
|
|
1043
1145
|
|
|
1044
1146
|
/**
|
|
@@ -2405,4 +2507,4 @@ declare function browserOnly<T>(fn: () => T, fallback: T): T;
|
|
|
2405
2507
|
*/
|
|
2406
2508
|
declare function browserOnlyAsync<T>(fn: () => Promise<T>, fallback: T): Promise<T>;
|
|
2407
2509
|
|
|
2408
|
-
export { type Alternate, type ApiErrorDetail, type Author, type BaseRequestOptions, type CategoriesListResponse, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, type Content, type ContentBody, type ContentResolveResponse, type ContentSummary, type ContentsFilters, type ContentsListResponse, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type LegalDocument, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, type SiteConfig, type SiteConfigResponse, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer };
|
|
2510
|
+
export { type Alternate, type ApiErrorDetail, type Author, type BaseRequestOptions, type CategoriesListResponse, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type LegalDocument, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SiteConfig, type SiteConfigResponse, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer };
|
package/dist/index.d.ts
CHANGED
|
@@ -808,6 +808,72 @@ interface ImageVariants {
|
|
|
808
808
|
full?: string;
|
|
809
809
|
}
|
|
810
810
|
|
|
811
|
+
/**
|
|
812
|
+
* Schema types for structured content.
|
|
813
|
+
*
|
|
814
|
+
* Categories in 'structured' mode define a field schema that determines
|
|
815
|
+
* the custom fields available for content in that category. These types
|
|
816
|
+
* describe the schema structure returned by the API.
|
|
817
|
+
*/
|
|
818
|
+
/**
|
|
819
|
+
* Supported field types in a content schema
|
|
820
|
+
*/
|
|
821
|
+
type SchemaFieldType = 'string' | 'text' | 'richtext' | 'number' | 'boolean' | 'select' | 'multiselect' | 'image' | 'file' | 'url' | 'email' | 'date' | 'datetime' | 'color' | 'object' | 'array' | 'dataSource';
|
|
822
|
+
/**
|
|
823
|
+
* Option for select/multiselect fields
|
|
824
|
+
*/
|
|
825
|
+
interface SchemaFieldOption {
|
|
826
|
+
value: string;
|
|
827
|
+
label: string;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Validation rules for a schema field
|
|
831
|
+
*/
|
|
832
|
+
interface SchemaFieldValidation {
|
|
833
|
+
minLength?: number;
|
|
834
|
+
maxLength?: number;
|
|
835
|
+
min?: number;
|
|
836
|
+
max?: number;
|
|
837
|
+
pattern?: string;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* A single field definition in a content schema
|
|
841
|
+
*/
|
|
842
|
+
interface SchemaField {
|
|
843
|
+
/** Unique key (used as the property name in customData) */
|
|
844
|
+
key: string;
|
|
845
|
+
/** Field type */
|
|
846
|
+
type: SchemaFieldType;
|
|
847
|
+
/** Display label */
|
|
848
|
+
label: string;
|
|
849
|
+
/** Whether the field is required */
|
|
850
|
+
required?: boolean;
|
|
851
|
+
/** Placeholder text */
|
|
852
|
+
placeholder?: string;
|
|
853
|
+
/** Help text shown below the field */
|
|
854
|
+
helpText?: string;
|
|
855
|
+
/** Default value */
|
|
856
|
+
defaultValue?: unknown;
|
|
857
|
+
/** Validation rules */
|
|
858
|
+
validation?: SchemaFieldValidation;
|
|
859
|
+
/** Sub-fields for object/array types */
|
|
860
|
+
fields?: SchemaField[];
|
|
861
|
+
/** Label for array items */
|
|
862
|
+
itemLabel?: string;
|
|
863
|
+
/** Minimum number of array items */
|
|
864
|
+
minItems?: number;
|
|
865
|
+
/** Maximum number of array items */
|
|
866
|
+
maxItems?: number;
|
|
867
|
+
/** Options for select/multiselect types */
|
|
868
|
+
options?: SchemaFieldOption[];
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Complete content schema (list of field definitions)
|
|
872
|
+
*/
|
|
873
|
+
interface ContentSchema {
|
|
874
|
+
fields: SchemaField[];
|
|
875
|
+
}
|
|
876
|
+
|
|
811
877
|
/**
|
|
812
878
|
* Content category
|
|
813
879
|
*/
|
|
@@ -820,6 +886,14 @@ interface Category {
|
|
|
820
886
|
slug: string;
|
|
821
887
|
/** Locale */
|
|
822
888
|
locale: string;
|
|
889
|
+
/**
|
|
890
|
+
* Content mode.
|
|
891
|
+
* - `'standard'`: articles use the TipTap rich text editor (body field)
|
|
892
|
+
* - `'structured'`: articles use custom fields defined by the category schema (customData field)
|
|
893
|
+
*
|
|
894
|
+
* Only present in detail responses, not in list select projections.
|
|
895
|
+
*/
|
|
896
|
+
contentMode?: 'standard' | 'structured';
|
|
823
897
|
}
|
|
824
898
|
/**
|
|
825
899
|
* Category with path and counter
|
|
@@ -835,6 +909,18 @@ interface CategoryWithCount extends Category {
|
|
|
835
909
|
contentCount: number;
|
|
836
910
|
/** CDN image variants */
|
|
837
911
|
imageVariants?: ImageVariants;
|
|
912
|
+
/**
|
|
913
|
+
* Field schema for structured categories.
|
|
914
|
+
* Defines the custom fields available for content in this category.
|
|
915
|
+
* Only present when `contentMode` is `'structured'`.
|
|
916
|
+
*/
|
|
917
|
+
schema?: ContentSchema | null;
|
|
918
|
+
/**
|
|
919
|
+
* Schema source.
|
|
920
|
+
* - `'own'`: this category defines its own schema
|
|
921
|
+
* - `'inherit'`: schema is inherited from the parent category
|
|
922
|
+
*/
|
|
923
|
+
schemaSource?: 'own' | 'inherit' | null;
|
|
838
924
|
}
|
|
839
925
|
/**
|
|
840
926
|
* Detailed category (with all info)
|
|
@@ -1039,6 +1125,22 @@ interface Content extends ContentSummary {
|
|
|
1039
1125
|
categories: Category[];
|
|
1040
1126
|
/** Associated tags */
|
|
1041
1127
|
tags: Tag[];
|
|
1128
|
+
/**
|
|
1129
|
+
* Custom field data for structured content.
|
|
1130
|
+
* Populated when the content belongs to a category with `contentMode: 'structured'`.
|
|
1131
|
+
* Richtext fields are automatically converted to HTML by the API.
|
|
1132
|
+
* `null` for standard content (which uses `body` instead).
|
|
1133
|
+
*
|
|
1134
|
+
* @example
|
|
1135
|
+
* ```typescript
|
|
1136
|
+
* if (content.customData) {
|
|
1137
|
+
* console.log(content.customData.price) // number
|
|
1138
|
+
* console.log(content.customData.description) // HTML string (richtext)
|
|
1139
|
+
* console.log(content.customData.gallery) // array of objects
|
|
1140
|
+
* }
|
|
1141
|
+
* ```
|
|
1142
|
+
*/
|
|
1143
|
+
customData?: Record<string, any> | null;
|
|
1042
1144
|
}
|
|
1043
1145
|
|
|
1044
1146
|
/**
|
|
@@ -2405,4 +2507,4 @@ declare function browserOnly<T>(fn: () => T, fallback: T): T;
|
|
|
2405
2507
|
*/
|
|
2406
2508
|
declare function browserOnlyAsync<T>(fn: () => Promise<T>, fallback: T): Promise<T>;
|
|
2407
2509
|
|
|
2408
|
-
export { type Alternate, type ApiErrorDetail, type Author, type BaseRequestOptions, type CategoriesListResponse, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, type Content, type ContentBody, type ContentResolveResponse, type ContentSummary, type ContentsFilters, type ContentsListResponse, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type LegalDocument, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, type SiteConfig, type SiteConfigResponse, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer };
|
|
2510
|
+
export { type Alternate, type ApiErrorDetail, type Author, type BaseRequestOptions, type CategoriesListResponse, type Category, type CategoryDetail, type CategoryDetailResponse, type CategoryOptions, type CategoryResolveResponse, type CategoryTreeNode, type CategoryTreeResponse, type CategoryWithCount, type Client, type ClientConfig, type ConsentCategories, type ConsentLogResponse, type Content, type ContentBody, type ContentResolveResponse, type ContentSchema, type ContentSummary, type ContentsFilters, type ContentsListResponse, type CookieCategory, type CookieConfig, type CookiePreferences, type CookieTexts, EnhancementsService, type ErrorCode, type EventData, type EventName, type Form, type FormField, type FormFieldOption, type FormFieldType, type FormFieldValidation, type FormSettings, type FormSubmitData, type FormSubmitResponse, type GlobalBlock, type GlobalBlockResponse, type ImageVariants, type LegalDocument, type LynkowClient, type LynkowConfig, LynkowError, type LynkowEvents, MediaHelperService, type Page, type PageSeo, type PageSummary, type PagesListResponse, type PageviewData, type PaginatedResponse, type PaginationMeta, type PaginationOptions, type Path, type PathsListResponse, type Redirect, type ResolveResponse, type Review, type ReviewResponse, type ReviewSettings, type ReviewSubmitData, type ReviewSubmitResponse, type ReviewsFilters, type ReviewsListResponse, type SchemaField, type SchemaFieldOption, type SchemaFieldType, type SchemaFieldValidation, type SiteConfig, type SiteConfigResponse, type SortOptions, type SrcsetOptions, type SubmitOptions, type Tag, type TagsListResponse, type TipTapMark, type TipTapNode, type TransformOptions, browserOnly, browserOnlyAsync, createClient, createLynkowClient, isBrowser, isCategoryResolve, isContentResolve, isLynkowError, isServer };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var C=class s 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,s);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,o;try{let r=await e.json();r.errors&&Array.isArray(r.errors)?(o=r.errors,n=r.errors[0]?.message||n):r.error?n=r.error:r.message&&(n=r.message);}catch{n=e.statusText||n;}let i=s.statusToCode(t);return new s(n,i,t,o)}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 me(s){return s instanceof C}function fe(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 U(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 o=fe(t.status),i=n.error||n.message||`HTTP error: ${t.status}`,r=n.errors||[{message:i}];throw new C(i,o,t.status,r)}function ee(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 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,r=this.buildEndpointUrl(e,i),a=this.mergeFetchOptions(n?.fetchOptions);return U(r,{method:"GET",...a})}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 U(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 K="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 o=`${K}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=`${K}slug_${e}_${n||"default"}`;return this.getWithCache(o,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(K);}};var D="categories_",R=class extends m{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 m{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 E="pages_",k=class extends m{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let o=`${E}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=`${E}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=`${E}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=`${E}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(E);}};var j="globals_",T=class extends m{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${j}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=`${j}${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(j);}};function H(s){return {_hp:"",_ts:s}}var ne="forms_",L=class extends m{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=H(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 m{sessionStartTime;constructor(e){super(e),this.sessionStartTime=Date.now();}async list(e,t){let n={};e?.page&&(n.page=e.page),(e?.limit??e?.perPage)&&(n.limit=e?.limit??e?.perPage),e?.minRating&&(n.minRating=e.minRating),e?.maxRating&&(n.maxRating=e.maxRating),e?.sort&&(n.sort=e.sort),e?.order&&(n.order=e.order);let o=`${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=H(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_",I=class extends m{async getConfig(){let e=`${oe}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(oe);}};var z="legal_",P=class extends m{async list(e){let t=e?.locale||this.config.locale,n=`${z}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=`${z}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(z);}};var re="cookies_",B=class extends m{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 m{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,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 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 m{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 c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",he=!c;function ye(s,e){return c?s():e}async function Ce(s,e){return c?s():e}var G="lynkow-tracker",N=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(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(!(!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(G)?.remove(),this.initialized=false,this.loadPromise=null;}};var V="_lkw_consent",se="lkw-script-",X={necessary:true,analytics:false,marketing:false,preferences:false},q=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;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(([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(!c)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(c){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(){c&&this.getConfig().then(e=>{if(!e.enabled)return;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();});}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null);}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);}));}getCategories(){return c?this.getStoredConsent()||{...X}:{...X}}hasConsented(){return c?this.getStoredConsent()!==null:false}acceptAll(){if(!c)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e,"accept_all"),this.activateScripts(e),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e,"reject_all"),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n,"customize"),this.activateScripts(n);}reset(){if(c){this.removeInjectedScripts();try{localStorage.removeItem(V);}catch{}this.events.emit("consent-changed",{...X}),this.show();}}activateScripts(e){if(this.configCache?.thirdPartyScripts?.length)for(let[t,n]of Object.entries(e))n&&this.injectScriptsForCategory(t,this.configCache.thirdPartyScripts);}injectScriptsForCategory(e,t){for(let n of t){if(n.category!==e||this.injectedScriptIds.has(n.id))continue;this.injectedScriptIds.add(n.id);let o=document.createElement("div");o.innerHTML=n.script;let i=Array.from(o.children);for(let r=0;r<i.length;r++){let a=i[r],p=`${se}${n.id}-${r}`;if(a.tagName==="SCRIPT"){let f=document.createElement("script");for(let u of Array.from(a.attributes))f.setAttribute(u.name,u.value);a.textContent&&(f.textContent=a.textContent),f.id=p,document.head.appendChild(f);}else a.id=p,document.body.appendChild(a);}}}removeInjectedScripts(){for(let e of this.injectedScriptIds){let t=0,n;for(;n=document.getElementById(`${se}${e}-${t}`);)n.remove(),t++;}this.injectedScriptIds.clear();}createBannerHTML(e){let t=e.position||"bottom",n=e.theme||"light",o=e.layout||"banner",i=e.primaryColor||"#0066cc",r=e.borderRadius??8,a={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);"},p={bottom:`bottom: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,top:`top: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,"bottom-left":`bottom: 20px; left: 20px; max-width: 400px; border-radius: ${r}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 400px; border-radius: ${r}px;`,center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`},f={center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,bottom:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,top:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,"bottom-left":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,"bottom-right":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`},u;o==="floating"?u=p:o==="modal"?u=f:u=a;let l=u[t]||u.bottom||"",g=n==="dark",h=g?"#1a1a1a":"#ffffff",y=g?"#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 `
|
|
1
|
+
'use strict';var C=class s 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,s);}static async fromResponse(e){let t=e.status,n=`HTTP ${t}`,o;try{let r=await e.json();r.errors&&Array.isArray(r.errors)?(o=r.errors,n=r.errors[0]?.message||n):r.error?n=r.error:r.message&&(n=r.message);}catch{n=e.statusText||n;}let i=s.statusToCode(t);return new s(n,i,t,o)}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 ge(s){return s instanceof C}function fe(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 U(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 o=fe(t.status),i=n.error||n.message||`HTTP error: ${t.status}`,r=n.errors||[{message:i}];throw new C(i,o,t.status,r)}function ee(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},g=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,r=this.buildEndpointUrl(e,i),a=this.mergeFetchOptions(n?.fetchOptions);return U(r,{method:"GET",...a})}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 U(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 K="contents_",b=class extends g{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=`${K}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=`${K}slug_${e}_${n||"default"}`;return this.getWithCache(o,`/contents/slug/${encodeURIComponent(e)}`,void 0,t,d.SHORT)}clearCache(){this.invalidateCache(K);}};var D="categories_",R=class extends g{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 g{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 E="pages_",k=class extends g{async list(e){let t=e?.locale||this.config.locale,n={};e?.tag&&(n.tag=e.tag);let o=`${E}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=`${E}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=`${E}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=`${E}jsonld_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}/json-ld`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(E);}};var j="globals_",T=class extends g{async siteConfig(e){let t=e?.locale||this.config.locale,n=`${j}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=`${j}${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(j);}};function H(s){return {_hp:"",_ts:s}}var ne="forms_",S=class extends g{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=H(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 L="reviews_",O=class extends g{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=`${L}list_${JSON.stringify(e||{})}`;return this.getWithCache(o,"/reviews",n,t,d.SHORT)}async getBySlug(e){let t=`${L}slug_${e}`;return (await this.getWithCache(t,`/reviews/${encodeURIComponent(e)}`,void 0,void 0,d.SHORT)).data}async settings(){let e=`${L}settings`;return this.getWithCache(e,"/reviews/settings",void 0,void 0,d.MEDIUM)}async submit(e,t){let n=H(this.sessionStartTime),o={...e,...n};t?.recaptchaToken&&(o._recaptcha_token=t.recaptchaToken);let i=await this.post("/reviews",o,t);return this.invalidateCache(L),i}clearCache(){this.invalidateCache(L);}};var oe="site_",I=class extends g{async getConfig(){let e=`${oe}config`;return (await this.getWithCache(e,"/site",void 0,void 0,d.MEDIUM)).data}clearCache(){this.invalidateCache(oe);}};var z="legal_",P=class extends g{async list(e){let t=e?.locale||this.config.locale,n=`${z}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=`${z}slug_${e}_${n||"default"}`;return (await this.getWithCache(o,`/pages/${encodeURIComponent(e)}`,void 0,t,d.SHORT)).data}clearCache(){this.invalidateCache(z);}};var re="cookies_",B=class extends g{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 g{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,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 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 g{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 c=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",he=!c;function ye(s,e){return c?s():e}async function Ce(s,e){return c?s():e}var G="lynkow-tracker",N=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(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(!(!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(G)?.remove(),this.initialized=false,this.loadPromise=null;}};var V="_lkw_consent",se="lkw-script-",X={necessary:true,analytics:false,marketing:false,preferences:false},q=class{config;events;bannerElement=null;preferencesElement=null;configCache=null;injectedScriptIds=new Set;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(([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(!c)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(c){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(){c&&this.getConfig().then(e=>{if(!e.enabled)return;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();});}hide(){c&&(this.bannerElement?.remove(),this.bannerElement=null);}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);}));}getCategories(){return c?this.getStoredConsent()||{...X}:{...X}}hasConsented(){return c?this.getStoredConsent()!==null:false}acceptAll(){if(!c)return;let e={necessary:true,analytics:true,marketing:true,preferences:true};this.saveConsent(e),this.logConsent(e,"accept_all"),this.activateScripts(e),this.hide();}rejectAll(){if(!c)return;let e={necessary:true,analytics:false,marketing:false,preferences:false};this.saveConsent(e),this.logConsent(e,"reject_all"),this.hide();}setCategories(e){if(!c)return;let n={...this.getCategories(),...e,necessary:true};this.saveConsent(n),this.logConsent(n,"customize"),this.activateScripts(n);}reset(){if(c){this.removeInjectedScripts();try{localStorage.removeItem(V);}catch{}this.events.emit("consent-changed",{...X}),this.show();}}activateScripts(e){if(this.configCache?.thirdPartyScripts?.length)for(let[t,n]of Object.entries(e))n&&this.injectScriptsForCategory(t,this.configCache.thirdPartyScripts);}injectScriptsForCategory(e,t){for(let n of t){if(n.category!==e||this.injectedScriptIds.has(n.id))continue;this.injectedScriptIds.add(n.id);let o=document.createElement("div");o.innerHTML=n.script;let i=Array.from(o.children);for(let r=0;r<i.length;r++){let a=i[r],p=`${se}${n.id}-${r}`;if(a.tagName==="SCRIPT"){let f=document.createElement("script");for(let m of Array.from(a.attributes))f.setAttribute(m.name,m.value);a.textContent&&(f.textContent=a.textContent),f.id=p,document.head.appendChild(f);}else a.id=p,document.body.appendChild(a);}}}removeInjectedScripts(){for(let e of this.injectedScriptIds){let t=0,n;for(;n=document.getElementById(`${se}${e}-${t}`);)n.remove(),t++;}this.injectedScriptIds.clear();}createBannerHTML(e){let t=e.position||"bottom",n=e.theme||"light",o=e.layout||"banner",i=e.primaryColor||"#0066cc",r=e.borderRadius??8,a={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);"},p={bottom:`bottom: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,top:`top: 20px; left: 50%; transform: translateX(-50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,"bottom-left":`bottom: 20px; left: 20px; max-width: 400px; border-radius: ${r}px;`,"bottom-right":`bottom: 20px; right: 20px; max-width: 400px; border-radius: ${r}px;`,center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`},f={center:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,bottom:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,top:`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,"bottom-left":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`,"bottom-right":`top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 500px; width: calc(100% - 40px); border-radius: ${r}px;`},m;o==="floating"?m=p:o==="modal"?m=f:m=a;let l=m[t]||m.bottom||"",u=n==="dark",h=u?"#1a1a1a":"#ffffff",y=u?"#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
2
|
${o==="modal"?`
|
|
3
3
|
<div id="lynkow-consent-backdrop" style="
|
|
4
4
|
position: fixed;
|
|
@@ -57,21 +57,21 @@
|
|
|
57
57
|
</div>
|
|
58
58
|
</div>
|
|
59
59
|
</div>
|
|
60
|
-
`}createPreferencesHTML(e,t){let n=e.theme||"light",o=e.primaryColor||"#0066cc",i=e.borderRadius??8,r=n==="dark",a=r?"#1a1a1a":"#ffffff",p=r?"#ffffff":"#1a1a1a",f=e.texts||{title:"Preferences de cookies",save:"Enregistrer"},l=(e.categories||[]).map(
|
|
61
|
-
<label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${
|
|
60
|
+
`}createPreferencesHTML(e,t){let n=e.theme||"light",o=e.primaryColor||"#0066cc",i=e.borderRadius??8,r=n==="dark",a=r?"#1a1a1a":"#ffffff",p=r?"#ffffff":"#1a1a1a",f=e.texts||{title:"Preferences de cookies",save:"Enregistrer"},l=(e.categories||[]).map(u=>`
|
|
61
|
+
<label style="display: flex; align-items: flex-start; gap: 10px; margin: 15px 0; cursor: ${u.required?"not-allowed":"pointer"};">
|
|
62
62
|
<input
|
|
63
63
|
type="checkbox"
|
|
64
|
-
name="${
|
|
65
|
-
${t[
|
|
66
|
-
${
|
|
64
|
+
name="${u.id}"
|
|
65
|
+
${t[u.id]?"checked":""}
|
|
66
|
+
${u.required?"disabled checked":""}
|
|
67
67
|
style="width: 18px; height: 18px; margin-top: 2px; accent-color: ${o};"
|
|
68
68
|
/>
|
|
69
69
|
<div style="flex: 1;">
|
|
70
|
-
<strong style="opacity: ${
|
|
71
|
-
${
|
|
70
|
+
<strong style="opacity: ${u.required?"0.6":"1"};">
|
|
71
|
+
${u.name}${u.required?" (requis)":""}
|
|
72
72
|
</strong>
|
|
73
73
|
<p style="margin: 5px 0 0 0; font-size: 13px; opacity: 0.8;">
|
|
74
|
-
${
|
|
74
|
+
${u.description}
|
|
75
75
|
</p>
|
|
76
76
|
</div>
|
|
77
77
|
</label>
|
|
@@ -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"),o=document.getElementById("lynkow-consent-preferences-modal");t?.addEventListener("submit",i=>{i.preventDefault();let r=new FormData(t),a={necessary:true,analytics:r.has("analytics"),marketing:r.has("marketing"),preferences:r.has("preferences")};this.setCategories(a),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,this.removeInjectedScripts();}};var J="lynkow-badge-container",Y="lynkow-badge-styles",M=class extends
|
|
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 r=new FormData(t),a={necessary:true,analytics:r.has("analytics"),marketing:r.has("marketing"),preferences:r.has("preferences")};this.setCategories(a),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,this.removeInjectedScripts();}};var J="lynkow-badge-container",Y="lynkow-badge-styles",M=class extends g{containerElement=null;async inject(){if(c&&!document.getElementById(J))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=J,t.innerHTML=e.html,document.body.appendChild(t),this.containerElement=t;}catch{}}remove(){c&&(this.containerElement?.remove(),this.containerElement=null,document.getElementById(Y)?.remove());}isVisible(){return c?document.getElementById(J)!==null:false}destroy(){this.remove();}};var Q="lynkow-enhancements-styles",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"><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>',we='<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>',be=`
|
|
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;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(Q))return;let e=document.createElement("style");e.id=Q,e.textContent=be,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=we,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=ve;},2e3);}catch(i){console.error("Lynkow SDK: Failed to copy code",i);}}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;(e instanceof HTMLElement?e:document.body).querySelectorAll("script:not([data-lynkow-activated])").forEach(o=>{if(o.src)return;o.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),r=o.attributes;for(let a=0;a<r.length;a++){let p=r[a];p&&(p.name==="type"&&p.value==="text/plain"||i.setAttribute(p.name,p.value));}i.textContent=o.textContent,o.parentNode?.replaceChild(i,o);});}init(){c&&(this.injectStyles(),this.bindCodeBlockCopy(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),this.observer||(this.observer=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&this.activateScripts(n);});}),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.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:r}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let f=[`w=${p}`,`fit=${o}`,"format=auto",`quality=${i}`,r&&`gravity=${r}`].filter(Boolean).join(",");return `${a.cdnBase}/cdn-cgi/image/${f}/${a.relativePath} ${p}w`}).join(", "):""}transform(e,t={}){if(!e)return "";let n=this.parseImageUrl(e);if(!n)return e||"";let o=[t.w&&`w=${t.w}`,t.h&&`h=${t.h}`,`fit=${t.fit||"scale-down"}`,`format=${t.format||"auto"}`,`quality=${t.quality||80}`,t.gravity&&`gravity=${t.gravity}`,t.dpr&&`dpr=${t.dpr}`].filter(Boolean).join(",");return `${n.cdnBase}/cdn-cgi/image/${o}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let i=e.substring(0,t),r=e.substring(t+15),a=r.indexOf("/");if(a===-1)return null;let p=r.substring(a+1);return {cdnBase:i,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let i=e.substring(0,n),r=e.substring(n+1);return {cdnBase:i,relativePath:r}}let o=e.indexOf("/avatars/");if(o!==-1){let i=e.substring(0,o),r=e.substring(o+1);return {cdnBase:i,relativePath:r}}return null}};var Re=300*1e3,xe="lynkow_cache_",v=new Map;function ie(s={}){let e=s.defaultTtl??Re,t=s.prefix??xe;function n(
|
|
247
|
-
exports.EnhancementsService=_;exports.LynkowError=C;exports.MediaHelperService=F;exports.browserOnly=ye;exports.browserOnlyAsync=Ce;exports.createClient=Te;exports.createLynkowClient=
|
|
246
|
+
`,_=class{initialized=false;observer=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(Q))return;let e=document.createElement("style");e.id=Q,e.textContent=be,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=we,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=ve;},2e3);}catch(i){console.error("Lynkow SDK: Failed to copy code",i);}}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;(e instanceof HTMLElement?e:document.body).querySelectorAll("script:not([data-lynkow-activated])").forEach(o=>{if(o.src)return;o.setAttribute("data-lynkow-activated","true");let i=document.createElement("script"),r=o.attributes;for(let a=0;a<r.length;a++){let p=r[a];p&&(p.name==="type"&&p.value==="text/plain"||i.setAttribute(p.name,p.value));}i.textContent=o.textContent,o.parentNode?.replaceChild(i,o);});}init(){c&&(this.injectStyles(),this.bindCodeBlockCopy(),this.activateScripts(),window.addEventListener("message",this.handleWidgetResize),this.observer||(this.observer=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&this.activateScripts(n);});}),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.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:r}=t,a=this.parseImageUrl(e);return a?n.map(p=>{let f=[`w=${p}`,`fit=${o}`,"format=auto",`quality=${i}`,r&&`gravity=${r}`].filter(Boolean).join(",");return `${a.cdnBase}/cdn-cgi/image/${f}/${a.relativePath} ${p}w`}).join(", "):""}transform(e,t={}){if(!e)return "";let n=this.parseImageUrl(e);if(!n)return e||"";let o=[t.w&&`w=${t.w}`,t.h&&`h=${t.h}`,`fit=${t.fit||"scale-down"}`,`format=${t.format||"auto"}`,`quality=${t.quality||80}`,t.gravity&&`gravity=${t.gravity}`,t.dpr&&`dpr=${t.dpr}`].filter(Boolean).join(",");return `${n.cdnBase}/cdn-cgi/image/${o}/${n.relativePath}`}parseImageUrl(e){let t=e.indexOf("/cdn-cgi/image/");if(t!==-1){let i=e.substring(0,t),r=e.substring(t+15),a=r.indexOf("/");if(a===-1)return null;let p=r.substring(a+1);return {cdnBase:i,relativePath:p}}let n=e.indexOf("/sites/");if(n!==-1){let i=e.substring(0,n),r=e.substring(n+1);return {cdnBase:i,relativePath:r}}let o=e.indexOf("/avatars/");if(o!==-1){let i=e.substring(0,o),r=e.substring(o+1);return {cdnBase:i,relativePath:r}}return null}};var Re=300*1e3,xe="lynkow_cache_",v=new Map;function ie(s={}){let e=s.defaultTtl??Re,t=s.prefix??xe;function n(m){return `${t}${m}`}function o(m){return Date.now()>m.expiresAt}function i(m){let l=n(m);if(c)try{let h=localStorage.getItem(l);if(!h)return null;let y=JSON.parse(h);return o(y)?(localStorage.removeItem(l),null):y.value}catch{return null}let u=v.get(l);return u?o(u)?(v.delete(l),null):u.value:null}function r(m,l,u=e){let h=n(m),y={value:l,expiresAt:Date.now()+u};if(c){try{localStorage.setItem(h,JSON.stringify(y));}catch{}return}v.set(h,y);}function a(m){let l=n(m);if(c){try{localStorage.removeItem(l);}catch{}return}v.delete(l);}function p(m){if(c){try{let l=[];for(let u=0;u<localStorage.length;u++){let h=localStorage.key(u);h&&h.startsWith(t)&&(!m||h.includes(m))&&l.push(h);}l.forEach(u=>localStorage.removeItem(u));}catch{}return}if(m)for(let l of v.keys())l.startsWith(t)&&l.includes(m)&&v.delete(l);else for(let l of v.keys())l.startsWith(t)&&v.delete(l);}async function f(m,l,u=e){let h=i(m);if(h!==null)return h;let y=await l();return r(m,y,u),y}return {get:i,set:r,remove:a,invalidate:p,getOrSet:f}}function ae(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 ce(){let s=new Map;function e(r,a){return s.has(r)||s.set(r,new Set),s.get(r).add(a),()=>t(r,a)}function t(r,a){let p=s.get(r);p&&p.delete(a);}function n(r,a){let p=s.get(r);if(p)for(let f of p)try{f(a);}catch(m){console.error(`[Lynkow] Error in event listener for "${r}":`,m);}}function o(r,a){let p=(f=>{t(r,p),a(f);});return e(r,p)}function i(r){r?s.delete(r):s.clear();}return {on:e,off:t,emit:n,once:o,removeAllListeners:i}}var le="lynkow_locale";function Z(s,e){let t=s.toLowerCase();return e.find(n=>n.toLowerCase()===t)??null}function de(s,e){if(!c)return e;let t=Ee();if(t&&s.includes(t))return t;let n=ke(s);if(n)return n;let o=document.documentElement.lang;if(o){let i=Z(o,s);if(i)return i;let r=o.split("-")[0]?.toLowerCase();if(r){let a=Z(r,s);if(a)return a}}return e}function Ee(){if(!c)return null;try{return localStorage.getItem(le)}catch{return null}}function pe(s){if(c)try{localStorage.setItem(le,s);}catch{}}function ke(s){if(!c)return null;let t=window.location.pathname.split("/").filter(Boolean);if(t.length>0){let n=t[0];if(n){let o=Z(n,s);if(o)return o}}return null}function me(s,e){return e.includes(s)}var ue="https://api.lynkow.com";function Te(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e=ie(),t=ae({debug:s.debug??false}),n=ce(),o=(s.baseUrl||ue).replace(/\/$/,""),i={siteId:s.siteId,baseUrl:o,locale:s.locale,fetchOptions:s.fetchOptions||{},cache:e},r={locale:s.locale||"fr",availableLocales:["fr"],siteConfig:null,initialized:false},a={contents:new b(i),categories:new R(i),tags:new x(i),pages:new k(i),blocks:new T(i),forms:new S(i),reviews:new O(i),site:new I(i),legal:new P(i),cookies:new B(i),seo:new $(i),paths:new A(i),analytics:new N(i),consent:new q(i,n),branding:new M(i),enhancements:new _,media:new F};function p(l){i.locale=l;}async function f(){if(!r.initialized)try{let l=await a.site.getConfig();r.siteConfig=l;let u=l.defaultLocale||"fr";if(r.availableLocales=l.enabledLocales||[u],c&&!s.locale){let h=de(r.availableLocales,u);r.locale=h,p(h);}r.initialized=!0,t.debug("Client initialized",{locale:r.locale,availableLocales:r.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&&(a.enhancements.init(),setTimeout(()=>f(),0)),{...a,globals:a.blocks,config:Object.freeze({siteId:s.siteId,baseUrl:o,debug:s.debug??false}),get locale(){return r.locale},get availableLocales(){return [...r.availableLocales]},setLocale(l){if(!me(l,r.availableLocales)){t.warn(`Locale "${l}" is not available. Available: ${r.availableLocales.join(", ")}`);return}l!==r.locale&&(r.locale=l,p(l),c&&pe(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,u){return n.on(l,u)}}}function Se(s){if(!s.siteId)throw new Error("Lynkow SDK: siteId is required");let e={siteId:s.siteId,baseUrl:(s.baseUrl||ue).replace(/\/$/,""),locale:s.locale,fetchOptions:s.fetchOptions||{}};return {contents:new b(e),categories:new R(e),tags:new x(e),pages:new k(e),blocks:new T(e),forms:new S(e),reviews:new O(e),site:new I(e),legal:new P(e),cookies:new B(e),seo:new $(e),paths:new A(e)}}function Le(s){return s.type==="content"}function Oe(s){return s.type==="category"}
|
|
247
|
+
exports.EnhancementsService=_;exports.LynkowError=C;exports.MediaHelperService=F;exports.browserOnly=ye;exports.browserOnlyAsync=Ce;exports.createClient=Te;exports.createLynkowClient=Se;exports.isBrowser=c;exports.isCategoryResolve=Oe;exports.isContentResolve=Le;exports.isLynkowError=ge;exports.isServer=he;//# sourceMappingURL=index.js.map
|
|
248
248
|
//# sourceMappingURL=index.js.map
|