commerce-kit 0.42.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/api-types.d.ts +179 -16
- package/dist/browser.d.ts +0 -1
- package/dist/browser.js +1 -4
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +10 -16
- package/dist/feedback-toolbar.d.ts +0 -18
- package/dist/feedback-toolbar.js +0 -5
- package/dist/feedback-toolbar.js.map +0 -1
package/README.md
CHANGED
|
@@ -100,6 +100,27 @@ await commerce.eventUpdate({ idOrSlug: 'summer-fest' }, { capacity: 600, status:
|
|
|
100
100
|
const { attendees, totalTickets } = await commerce.eventAttendeesBrowse({ idOrSlug: 'summer-fest' });
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
## Collections & Categories
|
|
104
|
+
|
|
105
|
+
Full CRUD for product collections, product categories, and blog categories. Mutations are
|
|
106
|
+
partial (send only the fields you want to change; pass `null` to clear an optional field).
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// Collections — create, partially update, delete
|
|
110
|
+
const collection = await commerce.collectionCreate({ name: 'Summer', filter: { type: 'manual' }, active: true });
|
|
111
|
+
await commerce.collectionUpdate({ idOrSlug: 'summer' }, { name: 'Summer 2026', active: false });
|
|
112
|
+
await commerce.collectionDelete({ idOrSlug: 'summer' }); // { ok: true, deleted: 1 }
|
|
113
|
+
|
|
114
|
+
// Categories — delete (create/update already supported)
|
|
115
|
+
await commerce.categoryUpdate({ idOrSlug: 'shoes' }, { name: 'Footwear' });
|
|
116
|
+
await commerce.categoryDelete({ idOrSlug: 'footwear' }); // 409 if still referenced by products
|
|
117
|
+
|
|
118
|
+
// Blog categories — full CRUD
|
|
119
|
+
const blogCategory = await commerce.blogCategoryCreate({ name: 'Guides' });
|
|
120
|
+
await commerce.blogCategoryUpdate({ idOrSlug: 'guides' }, { description: null });
|
|
121
|
+
await commerce.blogCategoryDelete({ idOrSlug: 'guides' });
|
|
122
|
+
```
|
|
123
|
+
|
|
103
124
|
## Raw API Requests
|
|
104
125
|
|
|
105
126
|
For endpoints not yet implemented in the SDK, use the `request()` method:
|
package/dist/api-types.d.ts
CHANGED
|
@@ -3042,7 +3042,9 @@ type APIProductGetByIdResult = ({
|
|
|
3042
3042
|
}) & {
|
|
3043
3043
|
lang?: string;
|
|
3044
3044
|
});
|
|
3045
|
-
type APIProductGetByIdParams =
|
|
3045
|
+
type APIProductGetByIdParams = {
|
|
3046
|
+
idOrSlug: string;
|
|
3047
|
+
};
|
|
3046
3048
|
type APIProductGetByIdQueryParams = {
|
|
3047
3049
|
lang?: string;
|
|
3048
3050
|
currency?: string;
|
|
@@ -3463,6 +3465,7 @@ type APICartAddResult = unknown;
|
|
|
3463
3465
|
type APICartCreateBody = {
|
|
3464
3466
|
variantId: string;
|
|
3465
3467
|
quantity: number;
|
|
3468
|
+
mode?: "set" | "add" | undefined;
|
|
3466
3469
|
cartId?: string | undefined;
|
|
3467
3470
|
subscriptionPlanId?: string | null | undefined;
|
|
3468
3471
|
currency?: string | undefined;
|
|
@@ -4303,6 +4306,7 @@ type APIOrdersBrowseResult = {
|
|
|
4303
4306
|
customerId: string | null;
|
|
4304
4307
|
lookup: number;
|
|
4305
4308
|
cartId: string | null;
|
|
4309
|
+
externalId: string | null;
|
|
4306
4310
|
orderData: {
|
|
4307
4311
|
id: string;
|
|
4308
4312
|
storeId: string;
|
|
@@ -4728,6 +4732,7 @@ type APIOrdersBrowseResult = {
|
|
|
4728
4732
|
}[] | null;
|
|
4729
4733
|
};
|
|
4730
4734
|
externalShipmentId: string | null;
|
|
4735
|
+
source: string | null;
|
|
4731
4736
|
stripeDeduplicationId: string | null;
|
|
4732
4737
|
activeSubscriptionId: string | null;
|
|
4733
4738
|
} & {
|
|
@@ -5174,6 +5179,7 @@ type APIOrderGetByIdResult = {
|
|
|
5174
5179
|
customerId: string | null;
|
|
5175
5180
|
lookup: number;
|
|
5176
5181
|
cartId: string | null;
|
|
5182
|
+
externalId: string | null;
|
|
5177
5183
|
orderData: {
|
|
5178
5184
|
id: string;
|
|
5179
5185
|
storeId: string;
|
|
@@ -5599,6 +5605,7 @@ type APIOrderGetByIdResult = {
|
|
|
5599
5605
|
}[] | null;
|
|
5600
5606
|
};
|
|
5601
5607
|
externalShipmentId: string | null;
|
|
5608
|
+
source: string | null;
|
|
5602
5609
|
stripeDeduplicationId: string | null;
|
|
5603
5610
|
activeSubscriptionId: string | null;
|
|
5604
5611
|
activeSubscription: {
|
|
@@ -5606,7 +5613,7 @@ type APIOrderGetByIdResult = {
|
|
|
5606
5613
|
createdAt: string;
|
|
5607
5614
|
updatedAt: string;
|
|
5608
5615
|
interval: number;
|
|
5609
|
-
status: "active" | "incomplete" | "canceled" | "
|
|
5616
|
+
status: "active" | "incomplete" | "canceled" | "trialing" | "past_due" | "paused" | "unpaid" | "incomplete_expired";
|
|
5610
5617
|
stripeCustomerId: string | null;
|
|
5611
5618
|
environment: "live" | "test";
|
|
5612
5619
|
stripeSubscriptionId: string;
|
|
@@ -5616,10 +5623,10 @@ type APIOrderGetByIdResult = {
|
|
|
5616
5623
|
productVariantId: string;
|
|
5617
5624
|
cadence: "month" | "week";
|
|
5618
5625
|
stripeDeduplicationId: string | null;
|
|
5626
|
+
cancelAtPeriodEnd: boolean | null;
|
|
5619
5627
|
originalOrderId: string;
|
|
5620
5628
|
canceledAt: Date | null;
|
|
5621
5629
|
cancelAt: Date | null;
|
|
5622
|
-
cancelAtPeriodEnd: boolean | null;
|
|
5623
5630
|
cancellationDetails: {
|
|
5624
5631
|
comment?: string | null;
|
|
5625
5632
|
feedback?: string | null;
|
|
@@ -6060,7 +6067,9 @@ type APIOrderGetByIdResult = {
|
|
|
6060
6067
|
}[] | null;
|
|
6061
6068
|
};
|
|
6062
6069
|
};
|
|
6063
|
-
type APIOrderGetByIdParams =
|
|
6070
|
+
type APIOrderGetByIdParams = {
|
|
6071
|
+
id: string;
|
|
6072
|
+
};
|
|
6064
6073
|
type APICategoriesBrowseResult = Omit<{
|
|
6065
6074
|
data: {
|
|
6066
6075
|
id: string;
|
|
@@ -6340,7 +6349,9 @@ type APICategoryGetByIdResult = ({
|
|
|
6340
6349
|
}) & {
|
|
6341
6350
|
lang?: string;
|
|
6342
6351
|
};
|
|
6343
|
-
type APICategoryGetByIdParams =
|
|
6352
|
+
type APICategoryGetByIdParams = {
|
|
6353
|
+
idOrSlug: string;
|
|
6354
|
+
};
|
|
6344
6355
|
type APICategoryGetByIdQueryParams = {
|
|
6345
6356
|
lang?: string;
|
|
6346
6357
|
};
|
|
@@ -6503,7 +6514,9 @@ type APICollectionGetByIdResult = ({
|
|
|
6503
6514
|
}) & {
|
|
6504
6515
|
lang?: string;
|
|
6505
6516
|
};
|
|
6506
|
-
type APICollectionGetByIdParams =
|
|
6517
|
+
type APICollectionGetByIdParams = {
|
|
6518
|
+
idOrSlug: string;
|
|
6519
|
+
};
|
|
6507
6520
|
type APICollectionGetByIdQueryParams = {
|
|
6508
6521
|
lang?: string;
|
|
6509
6522
|
};
|
|
@@ -6686,6 +6699,10 @@ type APIMeGetResult = {
|
|
|
6686
6699
|
cartRecommendations?: {
|
|
6687
6700
|
layout: "inline" | "sidebar";
|
|
6688
6701
|
} | null | undefined;
|
|
6702
|
+
stockHold?: {
|
|
6703
|
+
enabled: boolean;
|
|
6704
|
+
holdMinutes: number;
|
|
6705
|
+
} | null | undefined;
|
|
6689
6706
|
aiInstructions?: string | null | undefined;
|
|
6690
6707
|
blogSettings?: {
|
|
6691
6708
|
modelTier: "extra" | "max" | "regular";
|
|
@@ -6913,7 +6930,9 @@ type APIPostGetByIdResult = {
|
|
|
6913
6930
|
filters: unknown;
|
|
6914
6931
|
publishedAt: string | null;
|
|
6915
6932
|
} | null | undefined;
|
|
6916
|
-
type APIPostGetByIdParams =
|
|
6933
|
+
type APIPostGetByIdParams = {
|
|
6934
|
+
idOrSlug: string;
|
|
6935
|
+
};
|
|
6917
6936
|
type APIPostCreateBody = {
|
|
6918
6937
|
title: string;
|
|
6919
6938
|
slug: string;
|
|
@@ -7033,7 +7052,60 @@ type APIBlogCategoryGetByIdResult = {
|
|
|
7033
7052
|
canonical?: string | null | undefined;
|
|
7034
7053
|
} | null;
|
|
7035
7054
|
};
|
|
7036
|
-
type APIBlogCategoryGetByIdParams =
|
|
7055
|
+
type APIBlogCategoryGetByIdParams = {
|
|
7056
|
+
idOrSlug: string;
|
|
7057
|
+
};
|
|
7058
|
+
type APIBlogCategoryCreateBody = {
|
|
7059
|
+
name: string;
|
|
7060
|
+
slug?: string | undefined;
|
|
7061
|
+
description?: string | null | undefined;
|
|
7062
|
+
image?: string | null | undefined;
|
|
7063
|
+
};
|
|
7064
|
+
type APIBlogCategoryCreateResult = {
|
|
7065
|
+
id: string;
|
|
7066
|
+
name: string;
|
|
7067
|
+
image: string | null;
|
|
7068
|
+
createdAt: string;
|
|
7069
|
+
updatedAt: string;
|
|
7070
|
+
slug: string;
|
|
7071
|
+
active: boolean;
|
|
7072
|
+
storeId: string;
|
|
7073
|
+
description: string | null;
|
|
7074
|
+
position: string;
|
|
7075
|
+
seo: {
|
|
7076
|
+
title?: string | null | undefined;
|
|
7077
|
+
description?: string | null | undefined;
|
|
7078
|
+
canonical?: string | null | undefined;
|
|
7079
|
+
} | null;
|
|
7080
|
+
};
|
|
7081
|
+
type APIBlogCategoryUpdateBody = {
|
|
7082
|
+
name?: string | undefined;
|
|
7083
|
+
slug?: string | undefined;
|
|
7084
|
+
description?: string | null | undefined;
|
|
7085
|
+
image?: string | null | undefined;
|
|
7086
|
+
active?: boolean | undefined;
|
|
7087
|
+
};
|
|
7088
|
+
type APIBlogCategoryUpdateResult = {
|
|
7089
|
+
id: string;
|
|
7090
|
+
name: string;
|
|
7091
|
+
image: string | null;
|
|
7092
|
+
createdAt: string;
|
|
7093
|
+
updatedAt: string;
|
|
7094
|
+
slug: string;
|
|
7095
|
+
active: boolean;
|
|
7096
|
+
storeId: string;
|
|
7097
|
+
description: string | null;
|
|
7098
|
+
position: string;
|
|
7099
|
+
seo: {
|
|
7100
|
+
title?: string | null | undefined;
|
|
7101
|
+
description?: string | null | undefined;
|
|
7102
|
+
canonical?: string | null | undefined;
|
|
7103
|
+
} | null;
|
|
7104
|
+
};
|
|
7105
|
+
type APIBlogCategoryDeleteResult = {
|
|
7106
|
+
ok: boolean;
|
|
7107
|
+
deleted: number;
|
|
7108
|
+
};
|
|
7037
7109
|
type APIPostCommentsBrowseResult = {
|
|
7038
7110
|
data: Array<{
|
|
7039
7111
|
id: string;
|
|
@@ -7100,7 +7172,9 @@ type APICustomerGetByIdResult = {
|
|
|
7100
7172
|
}>;
|
|
7101
7173
|
createdAt: string;
|
|
7102
7174
|
};
|
|
7103
|
-
type APICustomerGetByIdParams =
|
|
7175
|
+
type APICustomerGetByIdParams = {
|
|
7176
|
+
id: string;
|
|
7177
|
+
};
|
|
7104
7178
|
type APICustomerUpdateBody = {
|
|
7105
7179
|
name?: string;
|
|
7106
7180
|
phone?: string;
|
|
@@ -7196,7 +7270,9 @@ type APIVariantGetByIdResult = {
|
|
|
7196
7270
|
images: string[];
|
|
7197
7271
|
};
|
|
7198
7272
|
};
|
|
7199
|
-
type APIVariantGetByIdParams =
|
|
7273
|
+
type APIVariantGetByIdParams = {
|
|
7274
|
+
idOrSku: string;
|
|
7275
|
+
};
|
|
7200
7276
|
type APIVariantGetByIdQueryParams = {
|
|
7201
7277
|
currency?: string;
|
|
7202
7278
|
};
|
|
@@ -7374,6 +7450,10 @@ type APICategoryUpdateResult = {
|
|
|
7374
7450
|
longDescription: JSONContent | null;
|
|
7375
7451
|
parentId: string | null;
|
|
7376
7452
|
};
|
|
7453
|
+
type APICategoryDeleteResult = {
|
|
7454
|
+
ok: boolean;
|
|
7455
|
+
deleted: number;
|
|
7456
|
+
};
|
|
7377
7457
|
type APIOrderUpdateBody = {
|
|
7378
7458
|
status?: "processing" | "shipped" | "delivered" | "canceled";
|
|
7379
7459
|
trackingNumber?: string;
|
|
@@ -7435,6 +7515,78 @@ type APICollectionCreateResult = {
|
|
|
7435
7515
|
count: number;
|
|
7436
7516
|
};
|
|
7437
7517
|
};
|
|
7518
|
+
type APICollectionUpdateBody = {
|
|
7519
|
+
name?: string | undefined;
|
|
7520
|
+
slug?: string | undefined;
|
|
7521
|
+
description?: string | null | undefined;
|
|
7522
|
+
image?: string | null | undefined;
|
|
7523
|
+
filter?: {
|
|
7524
|
+
type: "manual";
|
|
7525
|
+
} | {
|
|
7526
|
+
type: "dynamicPrice";
|
|
7527
|
+
min?: number | null | undefined;
|
|
7528
|
+
max?: number | null | undefined;
|
|
7529
|
+
} | undefined;
|
|
7530
|
+
active?: boolean | undefined;
|
|
7531
|
+
};
|
|
7532
|
+
type APICollectionUpdateResult = {
|
|
7533
|
+
id: string;
|
|
7534
|
+
name: string;
|
|
7535
|
+
image: string | null;
|
|
7536
|
+
createdAt: string;
|
|
7537
|
+
updatedAt: string;
|
|
7538
|
+
slug: string;
|
|
7539
|
+
active: boolean;
|
|
7540
|
+
filter: {
|
|
7541
|
+
type: "manual";
|
|
7542
|
+
} | {
|
|
7543
|
+
type: "dynamicPrice";
|
|
7544
|
+
min?: number | null | undefined;
|
|
7545
|
+
max?: number | null | undefined;
|
|
7546
|
+
};
|
|
7547
|
+
storeId: string;
|
|
7548
|
+
description: JSONContent | null;
|
|
7549
|
+
seo: {
|
|
7550
|
+
title?: string | null | undefined;
|
|
7551
|
+
description?: string | null | undefined;
|
|
7552
|
+
canonical?: string | null | undefined;
|
|
7553
|
+
} | null;
|
|
7554
|
+
longDescription: JSONContent | null;
|
|
7555
|
+
kind: "product" | "event";
|
|
7556
|
+
productCollections: {
|
|
7557
|
+
position: string | null;
|
|
7558
|
+
productId: string;
|
|
7559
|
+
collectionId: string;
|
|
7560
|
+
product: {
|
|
7561
|
+
id: string;
|
|
7562
|
+
name: string;
|
|
7563
|
+
createdAt: string;
|
|
7564
|
+
updatedAt: string;
|
|
7565
|
+
type: "set" | "product" | "bundle";
|
|
7566
|
+
slug: string;
|
|
7567
|
+
status: "published" | "draft" | "hidden" | null;
|
|
7568
|
+
flags: unknown;
|
|
7569
|
+
storeId: string;
|
|
7570
|
+
summary: string | null;
|
|
7571
|
+
content: JSONContent | null;
|
|
7572
|
+
images: string[];
|
|
7573
|
+
badge: unknown;
|
|
7574
|
+
bundleDiscountPercentage: string | null;
|
|
7575
|
+
seo: {
|
|
7576
|
+
title?: string | null | undefined;
|
|
7577
|
+
description?: string | null | undefined;
|
|
7578
|
+
canonical?: string | null | undefined;
|
|
7579
|
+
} | null;
|
|
7580
|
+
stripeTaxCode: string | null;
|
|
7581
|
+
categoryId: string | null;
|
|
7582
|
+
brandId: string | null;
|
|
7583
|
+
};
|
|
7584
|
+
}[];
|
|
7585
|
+
};
|
|
7586
|
+
type APICollectionDeleteResult = {
|
|
7587
|
+
ok: boolean;
|
|
7588
|
+
deleted: number;
|
|
7589
|
+
};
|
|
7438
7590
|
type APIProductReviewsBrowseResult = {
|
|
7439
7591
|
data: Array<{
|
|
7440
7592
|
id: string;
|
|
@@ -7504,7 +7656,9 @@ type APIInstaviewImagesBrowseResult = {
|
|
|
7504
7656
|
}>;
|
|
7505
7657
|
nextCursor: string | null;
|
|
7506
7658
|
};
|
|
7507
|
-
type APIInstaviewImagesBrowseParams =
|
|
7659
|
+
type APIInstaviewImagesBrowseParams = {
|
|
7660
|
+
handle: string;
|
|
7661
|
+
};
|
|
7508
7662
|
type APIInstaviewImagesBrowseQueryParams = {
|
|
7509
7663
|
limit?: number;
|
|
7510
7664
|
cursor?: string;
|
|
@@ -7534,7 +7688,9 @@ type APIEventsBrowseResult = {
|
|
|
7534
7688
|
}[];
|
|
7535
7689
|
total: number;
|
|
7536
7690
|
};
|
|
7537
|
-
type APIEventGetByIdParams =
|
|
7691
|
+
type APIEventGetByIdParams = {
|
|
7692
|
+
idOrSlug: string;
|
|
7693
|
+
};
|
|
7538
7694
|
type APIEventGetByIdResult = {
|
|
7539
7695
|
event: {
|
|
7540
7696
|
id: string;
|
|
@@ -7670,7 +7826,9 @@ type APIBrandsBrowseQueryParams = {
|
|
|
7670
7826
|
active?: boolean | undefined;
|
|
7671
7827
|
lang?: string | undefined;
|
|
7672
7828
|
};
|
|
7673
|
-
type APIBrandGetByIdParams =
|
|
7829
|
+
type APIBrandGetByIdParams = {
|
|
7830
|
+
idOrSlug: string;
|
|
7831
|
+
};
|
|
7674
7832
|
type APIBrandGetByIdResult = {
|
|
7675
7833
|
id: string;
|
|
7676
7834
|
name: string;
|
|
@@ -7828,7 +7986,9 @@ type APIBrandAssignProductsResult = {
|
|
|
7828
7986
|
assigned: number;
|
|
7829
7987
|
notFound: string[];
|
|
7830
7988
|
};
|
|
7831
|
-
type APIOrderRefundsParams =
|
|
7989
|
+
type APIOrderRefundsParams = {
|
|
7990
|
+
id: string;
|
|
7991
|
+
};
|
|
7832
7992
|
type APIOrderRefundsBrowseResult = {
|
|
7833
7993
|
data: {
|
|
7834
7994
|
createdAt: string;
|
|
@@ -7864,7 +8024,10 @@ type APIOrderRefundsBrowseQueryParams = {
|
|
|
7864
8024
|
offset?: number | undefined;
|
|
7865
8025
|
limit?: number | undefined;
|
|
7866
8026
|
};
|
|
7867
|
-
type APIOrderRefundGetParams =
|
|
8027
|
+
type APIOrderRefundGetParams = {
|
|
8028
|
+
id: string;
|
|
8029
|
+
refundId: string;
|
|
8030
|
+
};
|
|
7868
8031
|
type APIOrderRefundGetResult = {
|
|
7869
8032
|
id: string;
|
|
7870
8033
|
createdAt: string;
|
|
@@ -7915,4 +8078,4 @@ type APICartDeleteResult = {
|
|
|
7915
8078
|
success: boolean;
|
|
7916
8079
|
};
|
|
7917
8080
|
|
|
7918
|
-
export type { APIBlogCategoriesBrowseQueryParams, APIBlogCategoriesBrowseResult, APIBlogCategoryGetByIdParams, APIBlogCategoryGetByIdResult, APIBrandAssignProductsBody, APIBrandAssignProductsResult, APIBrandCreateBody, APIBrandCreateResult, APIBrandDeleteResult, APIBrandGetByIdParams, APIBrandGetByIdResult, APIBrandUpdateBody, APIBrandUpdateResult, APIBrandsBrowseQueryParams, APIBrandsBrowseResult, APICartAddBody, APICartAddResult, APICartCreateBody, APICartCreateResult, APICartDeleteResult, APICartGetResult, APICartRemoveItemQueryParams, APICartRemoveItemResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APICategoryCreateBody, APICategoryCreateResult, APICategoryGetByIdParams, APICategoryGetByIdQueryParams, APICategoryGetByIdResult, APICategoryUpdateBody, APICategoryUpdateQueryParams, APICategoryUpdateResult, APICollectionCreateBody, APICollectionCreateResult, APICollectionGetByIdParams, APICollectionGetByIdQueryParams, APICollectionGetByIdResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APIContactMessageCreateBody, APIContactMessageCreateResult, APICustomerAddressCreateBody, APICustomerAddressCreateResult, APICustomerGetByIdParams, APICustomerGetByIdResult, APICustomerOrdersBrowseQueryParams, APICustomerOrdersBrowseResult, APICustomerUpdateBody, APICustomerUpdateResult, APICustomersBrowseQueryParams, APICustomersBrowseResult, APIEventAttendeesBrowseResult, APIEventCreateBody, APIEventCreateResult, APIEventGetByIdParams, APIEventGetByIdResult, APIEventUpdateBody, APIEventUpdateResult, APIEventsBrowseQueryParams, APIEventsBrowseResult, APIInstaviewImagesBrowseParams, APIInstaviewImagesBrowseQueryParams, APIInstaviewImagesBrowseResult, APIInventoryAdjustBody, APIInventoryAdjustResult, APIInventoryBrowseQueryParams, APIInventoryBrowseResult, APILegalPageGetByPathResult, APILegalPagesBrowseResult, APIMeGetResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APIOrderRefundGetParams, APIOrderRefundGetResult, APIOrderRefundsBrowseQueryParams, APIOrderRefundsBrowseResult, APIOrderRefundsParams, APIOrderUpdateBody, APIOrderUpdateResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIPostCommentCreateBody, APIPostCommentCreateResult, APIPostCommentsBrowseQueryParams, APIPostCommentsBrowseResult, APIPostCreateBody, APIPostCreateResult, APIPostDeleteResult, APIPostGetByIdParams, APIPostGetByIdResult, APIPostUpdateBody, APIPostUpdateResult, APIPostsBrowseQueryParams, APIPostsBrowseResult, APIProductBatchBody, APIProductBatchResult, APIProductCreateBody, APIProductCreateResult, APIProductDeleteQueryParams, APIProductDeleteResult, APIProductFiltersResult, APIProductGetByIdParams, APIProductGetByIdQueryParams, APIProductGetByIdResult, APIProductReviewCreateBody, APIProductReviewCreateResult, APIProductReviewsBrowseQueryParams, APIProductReviewsBrowseResult, APIProductUpdateBody, APIProductUpdateQueryParams, APIProductUpdateResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APISearchQueryParams, APISearchResult, APISocialsGetResult, APISubscriberCreateBody, APISubscriberCreateResult, APISubscriberDeleteResult, APIVariantCreateBody, APIVariantCreateResult, APIVariantGetByIdParams, APIVariantGetByIdQueryParams, APIVariantGetByIdResult, APIVariantUpdateBody, APIVariantUpdateResult, JSONContent };
|
|
8081
|
+
export type { APIBlogCategoriesBrowseQueryParams, APIBlogCategoriesBrowseResult, APIBlogCategoryCreateBody, APIBlogCategoryCreateResult, APIBlogCategoryDeleteResult, APIBlogCategoryGetByIdParams, APIBlogCategoryGetByIdResult, APIBlogCategoryUpdateBody, APIBlogCategoryUpdateResult, APIBrandAssignProductsBody, APIBrandAssignProductsResult, APIBrandCreateBody, APIBrandCreateResult, APIBrandDeleteResult, APIBrandGetByIdParams, APIBrandGetByIdResult, APIBrandUpdateBody, APIBrandUpdateResult, APIBrandsBrowseQueryParams, APIBrandsBrowseResult, APICartAddBody, APICartAddResult, APICartCreateBody, APICartCreateResult, APICartDeleteResult, APICartGetResult, APICartRemoveItemQueryParams, APICartRemoveItemResult, APICategoriesBrowseQueryParams, APICategoriesBrowseResult, APICategoryCreateBody, APICategoryCreateResult, APICategoryDeleteResult, APICategoryGetByIdParams, APICategoryGetByIdQueryParams, APICategoryGetByIdResult, APICategoryUpdateBody, APICategoryUpdateQueryParams, APICategoryUpdateResult, APICollectionCreateBody, APICollectionCreateResult, APICollectionDeleteResult, APICollectionGetByIdParams, APICollectionGetByIdQueryParams, APICollectionGetByIdResult, APICollectionUpdateBody, APICollectionUpdateResult, APICollectionsBrowseQueryParams, APICollectionsBrowseResult, APIContactMessageCreateBody, APIContactMessageCreateResult, APICustomerAddressCreateBody, APICustomerAddressCreateResult, APICustomerGetByIdParams, APICustomerGetByIdResult, APICustomerOrdersBrowseQueryParams, APICustomerOrdersBrowseResult, APICustomerUpdateBody, APICustomerUpdateResult, APICustomersBrowseQueryParams, APICustomersBrowseResult, APIEventAttendeesBrowseResult, APIEventCreateBody, APIEventCreateResult, APIEventGetByIdParams, APIEventGetByIdResult, APIEventUpdateBody, APIEventUpdateResult, APIEventsBrowseQueryParams, APIEventsBrowseResult, APIInstaviewImagesBrowseParams, APIInstaviewImagesBrowseQueryParams, APIInstaviewImagesBrowseResult, APIInventoryAdjustBody, APIInventoryAdjustResult, APIInventoryBrowseQueryParams, APIInventoryBrowseResult, APILegalPageGetByPathResult, APILegalPagesBrowseResult, APIMeGetResult, APIOrderGetByIdParams, APIOrderGetByIdResult, APIOrderRefundGetParams, APIOrderRefundGetResult, APIOrderRefundsBrowseQueryParams, APIOrderRefundsBrowseResult, APIOrderRefundsParams, APIOrderUpdateBody, APIOrderUpdateResult, APIOrdersBrowseQueryParams, APIOrdersBrowseResult, APIPostCommentCreateBody, APIPostCommentCreateResult, APIPostCommentsBrowseQueryParams, APIPostCommentsBrowseResult, APIPostCreateBody, APIPostCreateResult, APIPostDeleteResult, APIPostGetByIdParams, APIPostGetByIdResult, APIPostUpdateBody, APIPostUpdateResult, APIPostsBrowseQueryParams, APIPostsBrowseResult, APIProductBatchBody, APIProductBatchResult, APIProductCreateBody, APIProductCreateResult, APIProductDeleteQueryParams, APIProductDeleteResult, APIProductFiltersResult, APIProductGetByIdParams, APIProductGetByIdQueryParams, APIProductGetByIdResult, APIProductReviewCreateBody, APIProductReviewCreateResult, APIProductReviewsBrowseQueryParams, APIProductReviewsBrowseResult, APIProductUpdateBody, APIProductUpdateQueryParams, APIProductUpdateResult, APIProductsBrowseQueryParams, APIProductsBrowseResult, APISearchQueryParams, APISearchResult, APISocialsGetResult, APISubscriberCreateBody, APISubscriberCreateResult, APISubscriberDeleteResult, APIVariantCreateBody, APIVariantCreateResult, APIVariantGetByIdParams, APIVariantGetByIdQueryParams, APIVariantGetByIdResult, APIVariantUpdateBody, APIVariantUpdateResult, JSONContent };
|
package/dist/browser.d.ts
CHANGED
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`)},ie=e=>{let n=e;for(;n;){if(n instanceof HTMLElement&&n.dataset.ynsFeedbackUi==="true")return!0;n=n.parentElement}return!1},Pe=new Set(["HTML","HEAD","SCRIPT","STYLE","NOSCRIPT"]),Re=1e4,Ae=3e4,Le=e=>typeof e=="object"&&e!==null&&"viewer"in e&&(e.viewer==="anonymous"||e.viewer==="non-member"||e.viewer==="member"),Ie=e=>{let n=new Date(e),t=n.getTime()-Date.now(),o=n.toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});if(t<=0)return`Any moment now (estimated by ${o})`;let s=Math.ceil(t/6e4);if(s<60)return`~${s} minutes (by ${o})`;let a=Math.round(t/36e5);if(a<24)return`~${a} ${a===1?"hour":"hours"} (by ${o})`;let d=Math.round(t/864e5);return`~${d} ${d===1?"day":"days"} (by ${o})`};async function se(e,n){try{let t=await fetch(`${e}/api/auth/sign-out`,{method:"POST",credentials:"include"});t.ok||console.warn("[YNS Feedback Toolbar] sign-out responded non-OK",t.status)}catch(t){console.warn("[YNS Feedback Toolbar] sign-out fetch failed",t)}n()}function $e(){let[e,n]=C(null),[t,o]=C(!0),[s,a]=C(!1),[d,l]=C(null),[c,m]=C(null),[v,k]=C(!1),[E,w]=C(!1),u=B(null),g=B(()=>{});$(()=>{if(u.current=xe(),!u.current){o(!1);return}let r=!1,f=null,y=0,S=null,A=null,P=()=>{S!==null&&(window.clearTimeout(S),S=null)},I=(N,F)=>{r||F<y||(A=N?.viewer??null,n(N),o(!1))},T=()=>{if(r)return;let N=A==="member"?Re:Ae;S=window.setTimeout(()=>{H()},N)},H=async()=>{if(r)return;f?.abort();let N=new AbortController;f=N;let F=++y;try{let _=await fetch(`${u.current}/api/feedback-comments?host=${encodeURIComponent(window.location.host)}`,{credentials:"include",signal:N.signal});if(r||F<y)return;if(_.status===404||!_.ok){I(null,F),T();return}let te=await _.json();if(r||F<y)return;if(!Le(te)){I(null,F),T();return}I(te,F),T()}catch(_){if(_?.name==="AbortError"||r)return;I(null,F),T()}},Z=()=>{r||(P(),H())};g.current=Z;let ee=()=>{document.hidden?(f?.abort(),P()):Z()};return document.addEventListener("visibilitychange",ee),H(),()=>{r=!0,document.removeEventListener("visibilitychange",ee),f?.abort(),P(),g.current=()=>{}}},[]);let p=e?.viewer==="member"?e:null;$(()=>{!p||p.canComment||(a(!1),l(null),k(!1),m(null))},[p]),$(()=>{if(s)return document.body.style.cursor="crosshair",()=>{document.body.style.cursor=""}},[s]),$(()=>{if(!s)return;let r=document.createElement("div");r.dataset.ynsFeedbackUi="true",r.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483644","border: 2px dashed #10b981","background: rgba(16, 185, 129, 0.08)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let f=document.createElement("div");f.dataset.ynsFeedbackUi="true",f.textContent="Click to comment",f.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483645","background: #059669","color: #fff","font-size: 11px","font-family: ui-sans-serif, system-ui, sans-serif","padding: 3px 8px","border-radius: 4px","white-space: nowrap","display: none","box-shadow: 0 2px 6px rgba(0,0,0,0.15)"].join(";"),document.documentElement.appendChild(r),document.documentElement.appendChild(f);let y=null,S=P=>{let I=document.elementFromPoint(P.clientX,P.clientY);if(!I||Pe.has(I.tagName)||ie(I)){r.style.display="none",f.style.display="none",y=null;return}y=I,requestAnimationFrame(()=>{if(y!==I)return;let T=I.getBoundingClientRect();r.style.top=`${T.top}px`,r.style.left=`${T.left}px`,r.style.width=`${T.width}px`,r.style.height=`${T.height}px`,r.style.display="block",f.style.left=`${P.clientX+14}px`,f.style.top=`${P.clientY+14}px`,f.style.display="block"})},A=()=>{r.style.display="none",f.style.display="none",y=null};return document.addEventListener("mousemove",S,!0),document.addEventListener("mouseleave",A),()=>{document.removeEventListener("mousemove",S,!0),document.removeEventListener("mouseleave",A),r.remove(),f.remove()}},[s]),$(()=>{if(!s)return;let r=f=>{let y=f.target;if(!(y instanceof Element)||ie(y))return;f.preventDefault(),f.stopPropagation();let S=y.getBoundingClientRect(),A=S.width>0?(f.clientX-S.left)/S.width:.5,P=S.height>0?(f.clientY-S.top)/S.height:.5;l({cssSelector:Ce(y),pagePath:window.location.pathname,surroundingHtml:Ee(y),rect:{top:S.top+window.scrollY,left:S.left+window.scrollX,width:S.width,height:S.height},clickX:f.clientX+window.scrollX,clickY:f.clientY+window.scrollY,offsetXRatio:Math.min(1,Math.max(0,A)),offsetYRatio:Math.min(1,Math.max(0,P))}),a(!1)};return document.addEventListener("click",r,{capture:!0}),()=>document.removeEventListener("click",r,{capture:!0})},[s]);let h=()=>{g.current()},R=async(r,f)=>{!u.current||!p||!d||!(await fetch(`${u.current}/api/feedback-comments`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedbackSessionId:p.feedbackSessionId,content:r,pagePath:d.pagePath,cssSelector:d.cssSelector,surroundingHtml:d.surroundingHtml,offsetXRatio:d.offsetXRatio,offsetYRatio:d.offsetYRatio,...f.length>0?{attachments:f}:{}})})).ok||(l(null),a(!0),h())},z=async(r,f,y)=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:f,attachments:y})})).ok||(m(null),h())},W=async r=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}`,{method:"DELETE",credentials:"include"})).ok||h()},Y=async(r,f)=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:f})})).ok||h()},X=async(r,f)=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}/replies`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:f})})).ok||h()},x=async()=>{if(!(!u.current||!p)&&window.confirm(rt(p))){w(!0);try{let r=await fetch(`${u.current}/api/feedback-sessions/${p.feedbackSessionId}/finalize`,{method:"POST",credentials:"include"});if(!r.ok)return;let y=(await r.json().catch(()=>null))?.status??"processing";n(S=>S?.viewer==="member"?{...S,canComment:!1,sessionStatus:y}:S)}finally{w(!1)}}},L=r=>{if(r.pagePath!==window.location.pathname){window.location.assign(r.pagePath);return}let f=null;try{f=document.querySelector(r.cssSelector)}catch{f=null}f&&(f.scrollIntoView({behavior:"smooth",block:"center"}),m(r.id))};if(t||!e)return null;if(e.viewer==="anonymous")return i(lt,{loginUrl:e.loginUrl});if(e.viewer==="non-member")return i(dt,{user:e.user,onSignOut:()=>{u.current&&se(u.current,()=>g.current())}});if(!p)return null;if(!p.canComment)return p.sessionStatus!=="processing"&&p.sessionStatus!=="in_review"?null:i("div",{"data-yns-feedback-ui":"true",children:i(Te,{progress:p.progress,eta:p.eta,status:p.sessionStatus})});let M=p.comments.filter(r=>r.pagePath===window.location.pathname&&r.status!=="done"&&r.status!=="wont_fix");return b("div",{"data-yns-feedback-ui":"true",children:[M.map((r,f)=>i(Ne,{pin:r,number:f+1,editing:c===r.id,feedbackSessionId:p.feedbackSessionId,apiBase:u.current,onStartEdit:()=>m(r.id),onCancelEdit:()=>m(null),onSave:(y,S)=>z(r.id,y,S),onRemove:()=>W(r.id),onReply:y=>X(r.id,y),onStatusChange:y=>Y(r.id,y)},r.id)),d&&i(_e,{pending:d,feedbackSessionId:p.feedbackSessionId,apiBase:u.current,onCancel:()=>{l(null),a(!0)},onSave:(r,f)=>R(r,f)}),v&&i(Be,{comments:p.comments,currentPath:window.location.pathname,onClose:()=>k(!1),onSelect:L}),b("div",{style:G,children:[i("button",{type:"button",onClick:()=>a(r=>!r),style:s?De:j,children:s?"Cancel":"Add comment"}),i("button",{type:"button",onClick:()=>k(r=>!r),style:We,children:v?"Hide list":`List (${p.comments.length})`}),i("button",{type:"button",onClick:x,disabled:E,style:Ye,children:E?"Finalizing\u2026":"Finalize"}),i("span",{style:J,children:s?"Click any element to comment":`${M.length} on this page`}),i(at,{authors:p.authors,viewerId:p.user.id}),i(ct,{user:p.user,onSignOut:()=>{u.current&&se(u.current,()=>g.current())}})]})]})}function Te({progress:e,eta:n,status:t}){let[,o]=C(0);$(()=>{let l=window.setInterval(()=>o(c=>c+1),6e4);return()=>window.clearInterval(l)},[]);let s=Ie(n);return b("div",{style:Rt,children:[i("style",{children:Me}),b("div",{style:At,children:[i(Fe,{}),i("span",{style:Lt,children:"Submitted"}),i("strong",{style:{fontSize:13},children:t==="in_review"?"Feedback under review":"Applying feedback"})]}),b("div",{style:It,children:[i("span",{children:"Review progress"}),i("span",{style:{opacity:.7},children:e.label})]}),i("div",{style:$t,children:i("div",{style:{...Tt,width:`${e.fillPct}%`}})}),b("p",{style:Mt,children:["Estimated delivery: ",i("span",{style:{fontWeight:600},children:s})]})]})}var Me="@keyframes yns-feedback-spin { to { transform: rotate(360deg); } }";function Fe({size:e=14}){return i("span",{"aria-hidden":!0,style:{display:"inline-block",width:e,height:e,border:"2px solid rgba(16, 185, 129, 0.25)",borderTopColor:"#10b981",borderRadius:999,animation:"yns-feedback-spin 0.9s linear infinite"}})}function re({comment:e,onReply:n,onStatusChange:t}){let[o,s]=C(""),[a,d]=C(!1),l=e.replies??[],c=async()=>{let m=o.trim();if(!(!m||a)){d(!0);try{await n(m),s("")}finally{d(!1)}}};return b("div",{style:Ft,children:[t&&b("div",{style:Nt,children:[i("span",{style:zt,children:"Status"}),i("select",{value:e.status,onChange:m=>void t(m.target.value),style:_t,children:Object.keys(ne).map(m=>i("option",{value:m,children:ne[m]},m))})]}),l.length>0&&i("div",{style:Bt,children:l.map(m=>b("div",{style:Ot,children:[i("span",{style:jt,children:m.authorKind==="system"?"System":m.author?.name||m.author?.email||"Reviewer"}),i("span",{style:Ut,children:m.content})]},m.id))}),b("div",{style:Dt,children:[i("textarea",{value:o,onChange:m=>s(m.target.value),placeholder:"Reply\u2026",rows:2,style:ue,onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),c())}}),i("button",{type:"button",onClick:()=>void c(),style:me,disabled:a||!o.trim(),children:a?"\u2026":"Reply"})]})]})}function Ne({pin:e,number:n,editing:t,feedbackSessionId:o,apiBase:s,onStartEdit:a,onCancelEdit:d,onSave:l,onRemove:c,onReply:m,onStatusChange:v}){let k=Ue(e.cssSelector,e.offsetXRatio,e.offsetYRatio);if(!k)return null;let E=e.canMutate!==!1;return b("div",{style:{position:"absolute",top:k.top,left:k.left,zIndex:2147483600,pointerEvents:"auto"},children:[i("button",{type:"button",onClick:a,style:de,title:e.content,children:n}),e.author&&i("span",{style:Ke,title:e.author.name||e.author.email,children:i(O,{user:e.author,size:16})}),t&&(E?i(le,{initial:e.content,initialAttachments:e.attachments,feedbackSessionId:o,apiBase:s,onCancel:d,onSave:l,onRemove:c,thread:i(re,{comment:e,onReply:m,onStatusChange:v})}):i(ze,{comment:e,onClose:d,thread:i(re,{comment:e,onReply:m})}))]})}function ze({comment:e,onClose:n,thread:t}){return b("div",{style:ce,children:[e.author&&b("div",{style:qe,children:[i(O,{user:e.author,size:20}),i("span",{style:Ge,children:e.author.name||e.author.email})]}),i("div",{style:Je,children:e.content}),e.attachments.length>0&&i("div",{style:fe,children:e.attachments.map(o=>i("a",{href:o.url,target:"_blank",rel:"noreferrer",style:ge,children:i("img",{src:o.url,alt:"",style:ye})},o.url))}),t,b("div",{style:pe,children:[i("span",{style:{flex:1,fontSize:12,color:"#6b7280"},children:"Only the author can edit"}),i("button",{type:"button",onClick:n,style:Q,children:"Close"})]})]})}function _e({pending:e,feedbackSessionId:n,apiBase:t,onCancel:o,onSave:s}){return b(he,{children:[i("div",{style:{position:"absolute",top:e.rect.top+e.rect.height*e.offsetYRatio-12,left:e.rect.left+e.rect.width*e.offsetXRatio-12,zIndex:2147483600,pointerEvents:"none"},children:i("div",{style:de,children:"\u2022"})}),i("div",{style:{position:"absolute",top:e.clickY+10,left:e.clickX+10,zIndex:2147483647},children:i(le,{initial:"",initialAttachments:[],feedbackSessionId:n,apiBase:t,onCancel:o,onSave:s})})]})}function Be({comments:e,currentPath:n,onClose:t,onSelect:o}){let s=new Map;for(let d of e){let l=s.get(d.pagePath)??[];l.push(d),s.set(d.pagePath,l)}let a=Array.from(s.keys()).sort((d,l)=>d===n?-1:l===n?1:d.localeCompare(l));return b("div",{style:bt,children:[b("div",{style:ht,children:[b("strong",{style:{fontSize:14},children:["Comments (",e.length,")"]}),i("button",{type:"button",onClick:t,style:Q,children:"Close"})]}),i("div",{style:St,children:e.length===0?i("div",{style:vt,children:"No comments yet. Click \u201CAdd comment\u201D to leave one."}):a.map(d=>b("div",{style:{marginBottom:12},children:[i("div",{style:wt,children:d===n?`${d} \xB7 current`:d}),(s.get(d)??[]).map((l,c)=>b("button",{type:"button",onClick:()=>o(l),style:xt,disabled:l.status==="done"&&!1,children:[i("span",{style:Ct,children:c+1}),b("span",{style:kt,children:[l.author&&i("span",{style:Et,children:l.author.name||l.author.email}),l.content.length>140?`${l.content.slice(0,140)}\u2026`:l.content]}),l.status==="done"&&i("span",{style:Pt,children:"done"})]},l.id))]},d))})]})}var q=5,Oe=5*1024*1024,je=e=>new Promise(n=>{let t=URL.createObjectURL(e),o=new window.Image;o.onload=()=>{URL.revokeObjectURL(t),n({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=()=>{URL.revokeObjectURL(t),n(null)},o.src=t});function le({initial:e,initialAttachments:n,feedbackSessionId:t,apiBase:o,onCancel:s,onSave:a,onRemove:d,thread:l}){let[c,m]=C(e),[v,k]=C(n),[E,w]=C(!1),[u,g]=C(!1),[p,h]=C(null),R=B(null),z=B(null);$(()=>{let x=R.current;if(!x)return;x.focus();let L=x.value.length;x.setSelectionRange(L,L)},[]);let W=async x=>{x.preventDefault();let L=c.trim();if(L){w(!0);try{await a(L,v)}finally{w(!1)}}},Y=async x=>{if(!x||x.length===0||!o)return;h(null);let L=q-v.length;if(L<=0){h(`Max ${q} images per comment`);return}let M=Array.from(x).slice(0,L);for(let r of M){if(!r.type.startsWith("image/")){h(`"${r.name}" is not an image`);return}if(r.size>Oe){h(`"${r.name}" exceeds 5 MB`);return}}g(!0);try{let r=await Promise.all(M.map(je)),f=new FormData;M.forEach((A,P)=>{f.append("file",A),f.append("width",r[P]?.width?String(r[P]?.width):""),f.append("height",r[P]?.height?String(r[P]?.height):"")});let y=await fetch(`${o}/api/feedback-comments/uploads?feedbackSessionId=${encodeURIComponent(t)}`,{method:"POST",credentials:"include",body:f});if(!y.ok){let A=await y.json().catch(()=>null);h(A?.error??"Upload failed");return}let S=await y.json();k(A=>[...A,...S.uploads])}catch{h("Upload failed")}finally{g(!1),z.current&&(z.current.value="")}},X=x=>{k(L=>L.filter(M=>M.url!==x))};return b("form",{onSubmit:W,style:ce,children:[i("textarea",{ref:R,value:c,onChange:x=>m(x.target.value),placeholder:"Leave a comment\u2026",style:ue,rows:3}),v.length>0&&i("div",{style:fe,children:v.map(x=>b("div",{style:ge,children:[i("img",{src:x.url,alt:"",style:ye}),i("button",{type:"button",onClick:()=>X(x.url),style:Ze,disabled:E||u,"aria-label":"Remove attachment",children:"\xD7"})]},x.url))}),p&&i("div",{style:et,children:p}),i("input",{ref:z,type:"file",accept:"image/*",multiple:!0,onChange:x=>void Y(x.target.files),style:{display:"none"}}),b("div",{style:pe,children:[d&&i("button",{type:"button",onClick:()=>d(),style:Qe,disabled:E,children:"Delete"}),i("button",{type:"button",onClick:()=>z.current?.click(),style:tt,disabled:E||u||v.length>=q,"aria-label":u?"Uploading\u2026":"Attach image",title:u?"Uploading\u2026":"Attach image",children:u?i(ot,{}):i(nt,{})}),i("div",{style:{flex:1}}),i("button",{type:"button",onClick:s,style:Q,disabled:E,children:"Cancel"}),i("button",{type:"submit",style:me,disabled:E||u||!c.trim(),children:E?"Saving\u2026":"Save"})]}),l]})}function Ue(e,n,t){let[o,s]=C(null);return $(()=>{let a=()=>{let l=null;try{l=document.querySelector(e)}catch{l=null}if(!l){s(null);return}let c=l.getBoundingClientRect();s({top:c.top+window.scrollY+c.height*t-12,left:c.left+window.scrollX+c.width*n-12})};a();let d=new ResizeObserver(a);try{let l=document.querySelector(e);l&&d.observe(l)}catch{}return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{d.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[e,n,t]),o}var G={position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:2147483646,display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"rgba(17, 17, 17, 0.92)",color:"white",borderRadius:999,boxShadow:"0 8px 24px rgba(0,0,0,0.25)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,pointerEvents:"auto"},j={border:"none",background:"white",color:"#111",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:600,fontSize:13},De={...j,background:"#ef4444",color:"white"},We={border:"1px solid rgba(255,255,255,0.4)",background:"transparent",color:"white",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:500,fontSize:13},Ye={border:"none",background:"#10b981",color:"white",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:600,fontSize:13},J={opacity:.8,fontSize:12},Xe={display:"inline-flex",alignItems:"center",paddingLeft:4},He={marginLeft:-6,display:"inline-flex",borderRadius:999,boxShadow:"0 0 0 2px rgba(17, 17, 17, 0.92)"},Ve={marginLeft:-2,padding:"0 6px",height:18,minWidth:18,borderRadius:999,background:"rgba(255,255,255,0.18)",color:"white",fontSize:10,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center"},de={width:24,height:24,borderRadius:999,background:"#10b981",color:"white",border:"2px solid white",cursor:"pointer",fontSize:12,fontWeight:700,boxShadow:"0 2px 6px rgba(0,0,0,0.3)",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0},Ke={position:"absolute",bottom:-6,right:-6,width:20,height:20,borderRadius:999,border:"2px solid white",background:"#111",display:"inline-flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.3)",pointerEvents:"none"},qe={display:"flex",alignItems:"center",gap:8},Ge={fontSize:13,fontWeight:600,color:"#111"},Je={fontSize:14,color:"#111",whiteSpace:"pre-wrap",wordBreak:"break-word"},ce={background:"white",border:"1px solid #e5e7eb",borderRadius:8,padding:12,width:280,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',display:"flex",flexDirection:"column",gap:8,color:"#111"},ue={width:"100%",border:"1px solid #d1d5db",borderRadius:6,padding:8,fontSize:14,resize:"vertical",fontFamily:"inherit",color:"#111",background:"white",boxSizing:"border-box"},pe={display:"flex",alignItems:"center",gap:6},U={border:"1px solid transparent",borderRadius:6,padding:"6px 10px",fontSize:13,cursor:"pointer",fontWeight:500},me={...U,background:"#111",color:"white"},Q={...U,background:"transparent",color:"#374151",borderColor:"#d1d5db"},Qe={...U,background:"transparent",color:"#b91c1c",borderColor:"#fecaca"},fe={display:"flex",flexWrap:"wrap",gap:6},ge={position:"relative",width:56,height:56,borderRadius:6,overflow:"hidden",border:"1px solid #e5e7eb",background:"#f9fafb"},ye={width:"100%",height:"100%",objectFit:"cover",display:"block"},Ze={position:"absolute",top:2,right:2,width:18,height:18,borderRadius:999,border:"none",background:"rgba(17, 17, 17, 0.85)",color:"white",fontSize:13,lineHeight:"16px",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center"},et={color:"#b91c1c",fontSize:12,margin:0},tt={...U,background:"transparent",color:"#374151",borderColor:"#d1d5db",width:30,height:30,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0};function nt(){return b("svg",{role:"img","aria-label":"Attach image",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("title",{children:"Attach image"}),i("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 17.93 8.83l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})]})}function ot(){return b(he,{children:[i("style",{children:"@keyframes yns-attach-spin { to { transform: rotate(360deg); } }"}),i("span",{"aria-hidden":!0,style:{display:"inline-block",width:12,height:12,border:"2px solid rgba(55, 65, 81, 0.25)",borderTopColor:"#374151",borderRadius:999,animation:"yns-attach-spin 0.9s linear infinite"}})]})}var it=480;function be(){let[e,n]=C(!1);return $(()=>{let t=window.matchMedia(`(max-width: ${it}px)`),o=()=>n(t.matches);return o(),t.addEventListener("change",o),()=>t.removeEventListener("change",o)},[]),e}var st=e=>{let n=e.name?.trim();return n?n.split(/\s+/).filter(Boolean).slice(0,2).map(o=>o[0]?.toUpperCase()??"").join(""):e.email[0]?.toUpperCase()??"?"};function O({user:e,size:n=22}){return e.image?i("img",{src:e.image,alt:"",width:n,height:n,style:{width:n,height:n,borderRadius:999,objectFit:"cover",display:"block",flexShrink:0}}):i("span",{"aria-hidden":!0,style:{width:n,height:n,borderRadius:999,background:"rgba(255,255,255,0.18)",color:"white",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(10,Math.round(n*.45)),fontWeight:600,flexShrink:0},children:st(e)})}function rt(e){let n=e.authors??[],t=e.anonymousCount??0,o=e.commentTotal;if(o===0)return"Finalize this feedback session with zero comments? It will be canceled instead of submitted.";if(n.length===0&&t===0)return`Finalize this feedback session with ${o} comment${o===1?"":"s"}? You won't be able to add more.`;let s=n.length+(t>0?1:0),a=n.map(l=>l.name||l.email);t>0&&a.push(`${t} anonymous`);let d=a.length===1?a[0]:`${a.slice(0,-1).join(", ")} and ${a.at(-1)}`;return`Submit ${o} comment${o===1?"":"s"} from ${s} reviewer${s===1?"":"s"} (${d})?
|
|
3
|
-
|
|
4
|
-
This sends ALL comments \u2014 including those from other reviewers \u2014 for AI processing. You won't be able to add more comments after finalizing.`}function at({authors:e,viewerId:n}){if(!e||e.length===0)return null;let t=e.filter(a=>a.id!==n);if(t.length===0)return null;let o=t.slice(0,3),s=t.length-o.length;return b("div",{style:Xe,title:`Also commenting: ${t.map(a=>`${a.name||a.email} (${a.commentCount})`).join(", ")}`,children:[o.map(a=>i("span",{style:He,children:i(O,{user:a,size:18})},a.id)),s>0&&b("span",{style:Ve,children:["+",s]})]})}function lt({loginUrl:e}){return i("div",{"data-yns-feedback-ui":"true",children:b("div",{style:G,children:[i("span",{style:J,children:"Log in to provide feedback"}),i("button",{type:"button",onClick:()=>window.location.assign(e),style:j,children:"Log in"})]})})}function dt({user:e,onSignOut:n}){let t=be();return i("div",{"data-yns-feedback-ui":"true",children:b("div",{style:G,children:[i(O,{user:e}),!t&&i("span",{style:ut,children:e.email}),i("span",{style:J,children:"You don't have access to this store"}),i("button",{type:"button",onClick:n,style:j,children:"Sign out"})]})})}function ct({user:e,onSignOut:n}){let[t,o]=C(!1),s=B(null),a=be();$(()=>{if(!t)return;let c=m=>{s.current&&(m.target instanceof Node&&s.current.contains(m.target)||o(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[t]);let d=e.name?.trim()||e.email,l=d.length>16?`${d.slice(0,16)}\u2026`:d;return b("div",{ref:s,style:{position:"relative"},children:[b("button",{type:"button",onClick:()=>o(c=>!c),style:pt,"aria-haspopup":"menu","aria-expanded":t,title:d,children:[i(O,{user:e,size:20}),!a&&i("span",{style:mt,children:l}),i("span",{"aria-hidden":!0,style:ft,children:"\u25BE"})]}),t&&i("div",{role:"menu",style:gt,children:i("button",{type:"button",role:"menuitem",onClick:()=>{o(!1),n()},style:yt,children:"Sign out"})})]})}var ut={fontSize:13,color:"white",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:200},pt={display:"inline-flex",alignItems:"center",gap:6,background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.16)",color:"white",padding:"4px 8px 4px 4px",borderRadius:999,cursor:"pointer",fontSize:12,fontWeight:500,fontFamily:"inherit"},mt={maxWidth:"16ch",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},ft={opacity:.7,fontSize:10},gt={position:"absolute",right:0,bottom:"calc(100% + 8px)",background:"white",color:"#111",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",minWidth:140,padding:4,zIndex:2147483647},yt={display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",padding:"6px 10px",fontSize:13,color:"#111",cursor:"pointer",borderRadius:6},bt={position:"fixed",top:0,right:0,bottom:0,width:360,maxWidth:"92vw",background:"white",borderLeft:"1px solid #e5e7eb",boxShadow:"-12px 0 32px rgba(0,0,0,0.12)",zIndex:2147483646,display:"flex",flexDirection:"column",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',color:"#111"},ht={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e5e7eb"},St={flex:1,overflow:"auto",padding:"12px 12px 24px"},vt={color:"#6b7280",fontSize:13,padding:"24px 8px",textAlign:"center"},wt={fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"#6b7280",padding:"4px 4px 6px",wordBreak:"break-all"},xt={display:"flex",alignItems:"flex-start",gap:8,width:"100%",textAlign:"left",background:"white",border:"1px solid #e5e7eb",borderRadius:6,padding:"8px 10px",cursor:"pointer",fontSize:13,marginBottom:6,color:"#111"},Ct={flexShrink:0,width:22,height:22,borderRadius:999,background:"#10b981",color:"white",fontWeight:700,fontSize:11,display:"inline-flex",alignItems:"center",justifyContent:"center"},kt={flex:1,whiteSpace:"pre-wrap",wordBreak:"break-word"},Et={display:"block",fontSize:11,fontWeight:600,color:"#6b7280",marginBottom:2},Pt={flexShrink:0,background:"#d1fae5",color:"#065f46",fontSize:11,fontWeight:600,padding:"2px 6px",borderRadius:4,alignSelf:"center"},Rt={position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:2147483646,display:"flex",flexDirection:"column",gap:8,padding:"12px 16px",width:"min(420px, calc(100vw - 32px))",background:"white",border:"1px solid #e5e7eb",borderRadius:12,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',color:"#111",pointerEvents:"auto"},At={display:"flex",alignItems:"center",gap:8},Lt={background:"#d1fae5",color:"#065f46",fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:.5},It={display:"flex",justifyContent:"space-between",fontSize:12},$t={width:"100%",height:6,background:"#f3f4f6",borderRadius:999,overflow:"hidden"},Tt={height:"100%",background:"#10b981",borderRadius:999,transition:"width 500ms"},Mt={margin:0,fontSize:12,color:"#6b7280"},Ft={display:"flex",flexDirection:"column",gap:8,borderTop:"1px solid #e5e7eb",paddingTop:8,marginTop:2},Nt={display:"flex",alignItems:"center",gap:8},zt={fontSize:12,fontWeight:600,color:"#6b7280"},_t={flex:1,border:"1px solid #d1d5db",borderRadius:6,padding:"4px 8px",fontSize:13,color:"#111",background:"white",fontFamily:"inherit"},Bt={display:"flex",flexDirection:"column",gap:6,maxHeight:160,overflowY:"auto"},Ot={display:"flex",flexDirection:"column",gap:1,borderLeft:"2px solid #e5e7eb",paddingLeft:8},jt={fontSize:11,fontWeight:600,color:"#6b7280"},Ut={fontSize:13,color:"#111",whiteSpace:"pre-wrap",wordBreak:"break-word"},Dt={display:"flex",alignItems:"flex-end",gap:6};function ae(){if(console.log("[YNS Feedback Toolbar] mountFeedbackToolbar() called",{isWindow:typeof window<"u",vercelEnv:process.env.NEXT_PUBLIC_VERCEL_ENV,alreadyMounted:typeof document<"u"&&!!document.getElementById(V)}),typeof window>"u")return null;if(process.env.NEXT_PUBLIC_VERCEL_ENV!=="preview")return console.log("[YNS Feedback Toolbar] gate failed \u2014 NEXT_PUBLIC_VERCEL_ENV is",process.env.NEXT_PUBLIC_VERCEL_ENV),null;if(document.getElementById(V))return null;let e=document.createElement("div");e.id=V,e.dataset.ynsFeedbackUi="true",document.body.appendChild(e);let n=we(e);return n.render(i($e,{})),{unmount:()=>{n.unmount(),e.remove()}}}typeof window<"u"&&console.log("[YNS Feedback Toolbar] module evaluated",{vercelEnv:process.env.NEXT_PUBLIC_VERCEL_ENV,readyState:document.readyState,willAutoMount:process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"});typeof window<"u"&&process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{ae()}):ae());function Se(){typeof window>"u"||(console.log("[YNS Sandbox Inspectors] module evaluated"),Xt(),Ht())}Se();var Wt=new Set(["HEAD","SCRIPT","STYLE","NOSCRIPT","HTML"]);function Yt(e){if(e.id)return`${e.tagName.toLowerCase()}#${CSS.escape(e.id)}`;let n=[],t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let o=t.tagName.toLowerCase();if(t.id){n.unshift(`${o}#${CSS.escape(t.id)}`);break}let s=Array.from(t.classList).filter(l=>!l.startsWith("data-yns-"));s.length>0&&(o+=`.${s.map(l=>CSS.escape(l)).join(".")}`);let a=t.parentElement,d=t.tagName;if(a&&Array.from(a.children).filter(c=>c.tagName===d&&(s.length===0||s.every(m=>c.classList.contains(m)))).length>1){let c=Array.from(a.children).indexOf(t)+1;o+=`:nth-child(${c})`}n.unshift(o),t=t.parentElement}return n.join(" > ")}function ve(e,n){let t=e.getBoundingClientRect(),o=window.getComputedStyle(e),s=(e.textContent??"").trim();return{tag:e.tagName.toLowerCase(),id:e.id||void 0,classes:Array.from(e.classList).filter(a=>!a.startsWith("data-yns-")),textContent:s.length>n?`${s.slice(0,n)}\u2026`:s,cssSelector:Yt(e),boundingRect:{top:t.top,left:t.left,width:t.width,height:t.height},computedStyles:{color:o.color,backgroundColor:o.backgroundColor,fontSize:o.fontSize,fontFamily:o.fontFamily,padding:o.padding,margin:o.margin}}}function D(e,n){if(!e?.tagName||Wt.has(e.tagName))return!0;for(let t of n)if(e.hasAttribute?.(t))return!0;return!1}function Xt(){let e=!1,n=null,t=null,o=document.createElement("div");o.setAttribute("data-yns-design-overlay","hover"),o.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483646","border: 2px solid #3b82f6","background: rgba(59, 130, 246, 0.08)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let s=document.createElement("div");s.setAttribute("data-yns-design-overlay","label"),s.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483647","background: #3b82f6","color: #fff","font-size: 11px","font-family: ui-monospace, monospace","padding: 2px 6px","border-radius: 3px","white-space: nowrap","display: none"].join(";"),document.documentElement.appendChild(o),document.documentElement.appendChild(s);let a=document.createElement("style");a.setAttribute("data-yns-design-overlay","style"),a.textContent="[data-yns-selected] { outline: 2px solid #3b82f6 !important; outline-offset: 1px; }",document.head.appendChild(a);function d(w){let u=w.getBoundingClientRect();o.style.top=`${u.top}px`,o.style.left=`${u.left}px`,o.style.width=`${u.width}px`,o.style.height=`${u.height}px`,o.style.display="block";let g=Array.from(w.classList).filter(h=>!h.startsWith("data-yns-")),p=w.tagName.toLowerCase()+(g.length?`.${g[0]}`:"");s.textContent=p,s.style.left=`${u.left}px`,s.style.top=`${Math.max(0,u.top-22)}px`,s.style.display="block"}let l=w=>{let u=document.elementFromPoint(w.clientX,w.clientY);if(D(u,["data-yns-design-overlay"])){o.style.display="none",s.style.display="none",n=null;return}n=u,requestAnimationFrame(()=>{n===u&&e&&u&&d(u)})},c=()=>{o.style.display="none",s.style.display="none",n=null},m=w=>{if(!e||!n)return;w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation();let u=n;if(D(u,["data-yns-design-overlay"]))return;let g=ve(u,120),p=g.cssSelector;t&&t.el.removeAttribute("data-yns-selected"),t&&t.cssSelector===p?(t=null,window.parent.postMessage({type:"element-deselected",data:g},"*")):(t={el:u,cssSelector:p},u.setAttribute("data-yns-selected",""),window.parent.postMessage({type:"element-selected",data:g},"*"))},v=w=>{w.key==="Escape"&&e&&(E(),window.parent.postMessage({type:"design-mode-cleared"},"*"))};function k(){e=!0,document.addEventListener("mousemove",l,!0),document.addEventListener("mouseleave",c),document.addEventListener("click",m,!0),document.addEventListener("keydown",v,!0)}function E(){e=!1,document.removeEventListener("mousemove",l,!0),document.removeEventListener("mouseleave",c),document.removeEventListener("click",m,!0),document.removeEventListener("keydown",v,!0),o.style.display="none",s.style.display="none",n=null,t&&(t.el.removeAttribute("data-yns-selected"),t=null)}window.addEventListener("message",w=>{let u=w.data;!u||typeof u!="object"||(u.type==="design-mode-toggle"&&(u.enabled?k():(E(),window.parent.postMessage({type:"design-mode-cleared"},"*"))),u.type==="design-mode-deselect"&&t&&(t.el.removeAttribute("data-yns-selected"),t=null))})}function Ht(){let e=!1,n=null,t=[],o=document.createElement("div");o.setAttribute("data-yns-comment-overlay","hover"),o.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483644","border: 2px dashed #10b981","background: rgba(16, 185, 129, 0.06)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let s=document.createElement("div");s.setAttribute("data-yns-comment-overlay","cursor-label"),s.textContent="Click to comment",s.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483645","background: #059669","color: #fff","font-size: 11px","font-family: ui-sans-serif, system-ui, sans-serif","padding: 3px 8px","border-radius: 4px","white-space: nowrap","display: none","box-shadow: 0 2px 6px rgba(0,0,0,0.15)"].join(";");let a=document.createElement("div");a.setAttribute("data-yns-comment-overlay","pins"),a.style.cssText="position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2147483643;",document.documentElement.appendChild(o),document.documentElement.appendChild(s),document.documentElement.appendChild(a);function d(){a.innerHTML="";for(let g of t){let p=null;try{p=document.querySelector(g.selector)}catch{p=null}if(!p)continue;let h=p.getBoundingClientRect(),R=document.createElement("div");R.style.cssText=["position: fixed",`top: ${h.top-12}px`,`left: ${h.left+h.width/2-12}px`,"width: 24px","height: 24px","border-radius: 50%","background: #059669","color: #fff","display: flex","align-items: center","justify-content: center","font-size: 12px","font-weight: 600","font-family: ui-sans-serif, system-ui, sans-serif","box-shadow: 0 2px 8px rgba(0,0,0,0.2)","pointer-events: none"].join(";"),R.textContent=String(g.number),a.appendChild(R)}}let l=g=>{let p=document.elementFromPoint(g.clientX,g.clientY);if(D(p,["data-yns-comment-overlay","data-yns-design-overlay"])){o.style.display="none",s.style.display="none",n=null;return}n=p,requestAnimationFrame(()=>{if(n===p&&e&&p){let h=p.getBoundingClientRect();o.style.top=`${h.top}px`,o.style.left=`${h.left}px`,o.style.width=`${h.width}px`,o.style.height=`${h.height}px`,o.style.display="block",s.style.left=`${g.clientX+14}px`,s.style.top=`${g.clientY+14}px`,s.style.display="block"}})},c=()=>{o.style.display="none",s.style.display="none",n=null},m=g=>{if(!e||!n)return;g.preventDefault(),g.stopPropagation(),g.stopImmediatePropagation();let p=n;if(D(p,["data-yns-comment-overlay","data-yns-design-overlay"]))return;let h=ve(p,200),R=p.getBoundingClientRect();window.parent.postMessage({type:"comment-click",data:{element:h,clickPosition:{x:g.clientX,y:g.clientY},elementRect:{top:R.top,left:R.left,width:R.width,height:R.height},pagePath:window.location.pathname}},"*")},v=g=>{g.key==="Escape"&&e&&(E(),window.parent.postMessage({type:"comment-mode-cleared"},"*"))};function k(){e=!0,document.body.style.cursor="crosshair",document.addEventListener("mousemove",l,!0),document.addEventListener("mouseleave",c),document.addEventListener("click",m,!0),document.addEventListener("keydown",v,!0)}function E(){e=!1,document.body.style.cursor="",document.removeEventListener("mousemove",l,!0),document.removeEventListener("mouseleave",c),document.removeEventListener("click",m,!0),document.removeEventListener("keydown",v,!0),o.style.display="none",s.style.display="none",n=null}let w=!1,u=()=>{w||(w=!0,requestAnimationFrame(()=>{w=!1,d()}))};window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0}),window.addEventListener("message",g=>{let p=g.data;!p||typeof p!="object"||(p.type==="comment-mode-toggle"&&(p.enabled?k():E()),p.type==="comment-pins-update"&&(t=p.pins??[],d()),p.type==="comment-pin-remove"&&(t=t.filter(h=>h.id!==p.pinId),d()))})}export{ae as mountFeedbackToolbar,Se as startSandboxInspectors};
|
|
1
|
+
function x(){typeof window>"u"||(console.log("[YNS Sandbox Inspectors] module evaluated"),L(),S())}x();var w=new Set(["HEAD","SCRIPT","STYLE","NOSCRIPT","HTML"]);function C(o){if(o.id)return`${o.tagName.toLowerCase()}#${CSS.escape(o.id)}`;let l=[],e=o;for(;e&&e!==document.body&&e!==document.documentElement;){let t=e.tagName.toLowerCase();if(e.id){l.unshift(`${t}#${CSS.escape(e.id)}`);break}let n=Array.from(e.classList).filter(u=>!u.startsWith("data-yns-"));n.length>0&&(t+=`.${n.map(u=>CSS.escape(u)).join(".")}`);let a=e.parentElement,f=e.tagName;if(a&&Array.from(a.children).filter(m=>m.tagName===f&&(n.length===0||n.every(y=>m.classList.contains(y)))).length>1){let m=Array.from(a.children).indexOf(e)+1;t+=`:nth-child(${m})`}l.unshift(t),e=e.parentElement}return l.join(" > ")}function E(o,l){let e=o.getBoundingClientRect(),t=window.getComputedStyle(o),n=(o.textContent??"").trim();return{tag:o.tagName.toLowerCase(),id:o.id||void 0,classes:Array.from(o.classList).filter(a=>!a.startsWith("data-yns-")),textContent:n.length>l?`${n.slice(0,l)}\u2026`:n,cssSelector:C(o),boundingRect:{top:e.top,left:e.left,width:e.width,height:e.height},computedStyles:{color:t.color,backgroundColor:t.backgroundColor,fontSize:t.fontSize,fontFamily:t.fontFamily,padding:t.padding,margin:t.margin}}}function v(o,l){if(!o?.tagName||w.has(o.tagName))return!0;for(let e of l)if(o.hasAttribute?.(e))return!0;return!1}function L(){let o=!1,l=null,e=null,t=document.createElement("div");t.setAttribute("data-yns-design-overlay","hover"),t.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483646","border: 2px solid #3b82f6","background: rgba(59, 130, 246, 0.08)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let n=document.createElement("div");n.setAttribute("data-yns-design-overlay","label"),n.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483647","background: #3b82f6","color: #fff","font-size: 11px","font-family: ui-monospace, monospace","padding: 2px 6px","border-radius: 3px","white-space: nowrap","display: none"].join(";"),document.documentElement.appendChild(t),document.documentElement.appendChild(n);let a=document.createElement("style");a.setAttribute("data-yns-design-overlay","style"),a.textContent="[data-yns-selected] { outline: 2px solid #3b82f6 !important; outline-offset: 1px; }",document.head.appendChild(a);function f(d){let i=d.getBoundingClientRect();t.style.top=`${i.top}px`,t.style.left=`${i.left}px`,t.style.width=`${i.width}px`,t.style.height=`${i.height}px`,t.style.display="block";let r=Array.from(d.classList).filter(c=>!c.startsWith("data-yns-")),s=d.tagName.toLowerCase()+(r.length?`.${r[0]}`:"");n.textContent=s,n.style.left=`${i.left}px`,n.style.top=`${Math.max(0,i.top-22)}px`,n.style.display="block"}let u=d=>{let i=document.elementFromPoint(d.clientX,d.clientY);if(v(i,["data-yns-design-overlay"])){t.style.display="none",n.style.display="none",l=null;return}l=i,requestAnimationFrame(()=>{l===i&&o&&i&&f(i)})},m=()=>{t.style.display="none",n.style.display="none",l=null},y=d=>{if(!o||!l)return;d.preventDefault(),d.stopPropagation(),d.stopImmediatePropagation();let i=l;if(v(i,["data-yns-design-overlay"]))return;let r=E(i,120),s=r.cssSelector;e&&e.el.removeAttribute("data-yns-selected"),e&&e.cssSelector===s?(e=null,window.parent.postMessage({type:"element-deselected",data:r},"*")):(e={el:i,cssSelector:s},i.setAttribute("data-yns-selected",""),window.parent.postMessage({type:"element-selected",data:r},"*"))},g=d=>{d.key==="Escape"&&o&&(h(),window.parent.postMessage({type:"design-mode-cleared"},"*"))};function b(){o=!0,document.addEventListener("mousemove",u,!0),document.addEventListener("mouseleave",m),document.addEventListener("click",y,!0),document.addEventListener("keydown",g,!0)}function h(){o=!1,document.removeEventListener("mousemove",u,!0),document.removeEventListener("mouseleave",m),document.removeEventListener("click",y,!0),document.removeEventListener("keydown",g,!0),t.style.display="none",n.style.display="none",l=null,e&&(e.el.removeAttribute("data-yns-selected"),e=null)}window.addEventListener("message",d=>{let i=d.data;!i||typeof i!="object"||(i.type==="design-mode-toggle"&&(i.enabled?b():(h(),window.parent.postMessage({type:"design-mode-cleared"},"*"))),i.type==="design-mode-deselect"&&e&&(e.el.removeAttribute("data-yns-selected"),e=null))})}function S(){let o=!1,l=null,e=[],t=document.createElement("div");t.setAttribute("data-yns-comment-overlay","hover"),t.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483644","border: 2px dashed #10b981","background: rgba(16, 185, 129, 0.06)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let n=document.createElement("div");n.setAttribute("data-yns-comment-overlay","cursor-label"),n.textContent="Click to comment",n.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483645","background: #059669","color: #fff","font-size: 11px","font-family: ui-sans-serif, system-ui, sans-serif","padding: 3px 8px","border-radius: 4px","white-space: nowrap","display: none","box-shadow: 0 2px 6px rgba(0,0,0,0.15)"].join(";");let a=document.createElement("div");a.setAttribute("data-yns-comment-overlay","pins"),a.style.cssText="position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2147483643;",document.documentElement.appendChild(t),document.documentElement.appendChild(n),document.documentElement.appendChild(a);function f(){a.innerHTML="";for(let r of e){let s=null;try{s=document.querySelector(r.selector)}catch{s=null}if(!s)continue;let c=s.getBoundingClientRect(),p=document.createElement("div");p.style.cssText=["position: fixed",`top: ${c.top-12}px`,`left: ${c.left+c.width/2-12}px`,"width: 24px","height: 24px","border-radius: 50%","background: #059669","color: #fff","display: flex","align-items: center","justify-content: center","font-size: 12px","font-weight: 600","font-family: ui-sans-serif, system-ui, sans-serif","box-shadow: 0 2px 8px rgba(0,0,0,0.2)","pointer-events: none"].join(";"),p.textContent=String(r.number),a.appendChild(p)}}let u=r=>{let s=document.elementFromPoint(r.clientX,r.clientY);if(v(s,["data-yns-comment-overlay","data-yns-design-overlay"])){t.style.display="none",n.style.display="none",l=null;return}l=s,requestAnimationFrame(()=>{if(l===s&&o&&s){let c=s.getBoundingClientRect();t.style.top=`${c.top}px`,t.style.left=`${c.left}px`,t.style.width=`${c.width}px`,t.style.height=`${c.height}px`,t.style.display="block",n.style.left=`${r.clientX+14}px`,n.style.top=`${r.clientY+14}px`,n.style.display="block"}})},m=()=>{t.style.display="none",n.style.display="none",l=null},y=r=>{if(!o||!l)return;r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation();let s=l;if(v(s,["data-yns-comment-overlay","data-yns-design-overlay"]))return;let c=E(s,200),p=s.getBoundingClientRect();window.parent.postMessage({type:"comment-click",data:{element:c,clickPosition:{x:r.clientX,y:r.clientY},elementRect:{top:p.top,left:p.left,width:p.width,height:p.height},pagePath:window.location.pathname}},"*")},g=r=>{r.key==="Escape"&&o&&(h(),window.parent.postMessage({type:"comment-mode-cleared"},"*"))};function b(){o=!0,document.body.style.cursor="crosshair",document.addEventListener("mousemove",u,!0),document.addEventListener("mouseleave",m),document.addEventListener("click",y,!0),document.addEventListener("keydown",g,!0)}function h(){o=!1,document.body.style.cursor="",document.removeEventListener("mousemove",u,!0),document.removeEventListener("mouseleave",m),document.removeEventListener("click",y,!0),document.removeEventListener("keydown",g,!0),t.style.display="none",n.style.display="none",l=null}let d=!1,i=()=>{d||(d=!0,requestAnimationFrame(()=>{d=!1,f()}))};window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0}),window.addEventListener("message",r=>{let s=r.data;!s||typeof s!="object"||(s.type==="comment-mode-toggle"&&(s.enabled?b():h()),s.type==="comment-pins-update"&&(e=s.pins??[],f()),s.type==="comment-pin-remove"&&(e=e.filter(c=>c.id!==s.pinId),f()))})}export{x as startSandboxInspectors};
|
|
5
2
|
//# sourceMappingURL=browser.js.map
|