@redonvn/zalo-ads-sdk 0.2.18 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ __export(index_exports, {
40
40
  AutomatedRuleTimeRangeEnum: () => AutomatedRuleTimeRangeEnum,
41
41
  ConversionLabelEnum: () => ConversionLabelEnum,
42
42
  ConversionUrlTypeEnum: () => ConversionUrlTypeEnum,
43
+ InstantPageFactory: () => InstantPageFactory,
43
44
  MAX_REPORT_RANGE_MS: () => MAX_REPORT_RANGE_MS,
44
45
  MAX_REPORT_RANGE_SECONDS: () => MAX_REPORT_RANGE_SECONDS,
45
46
  MemoryZaloSessionStore: () => MemoryZaloSessionStore,
@@ -119,6 +120,7 @@ __export(index_exports, {
119
120
  defaultSharedMemorySessionStore: () => defaultSharedMemorySessionStore,
120
121
  deriveAccountKeyFromZpsid: () => deriveAccountKeyFromZpsid,
121
122
  parseZaloCookieInput: () => parseZaloCookieInput,
123
+ sanitizeCanvasKeys: () => sanitizeCanvasKeys,
122
124
  validateChangeCampaignStatusParams: () => validateChangeCampaignStatusParams,
123
125
  validateCloneInstantPageRequest: () => validateCloneInstantPageRequest,
124
126
  validateCreateCampaignPayload: () => validateCreateCampaignPayload,
@@ -139,6 +141,7 @@ __export(index_exports, {
139
141
  validateEstimateAudienceRequest: () => validateEstimateAudienceRequest,
140
142
  validateGetInstantPageDetailRequest: () => validateGetInstantPageDetailRequest,
141
143
  validateGetInstantPageSharedUserRequest: () => validateGetInstantPageSharedUserRequest,
144
+ validateInstantPageCanvas: () => validateInstantPageCanvas,
142
145
  validateListFlowsByOfficialAccountRequest: () => validateListFlowsByOfficialAccountRequest,
143
146
  validateListFormLeadsRequest: () => validateListFormLeadsRequest,
144
147
  validateListFormsByOfficialAccountRequest: () => validateListFormsByOfficialAccountRequest,
@@ -6517,6 +6520,127 @@ function validateSearchInstantPagesRequest(input) {
6517
6520
  data: errors.length === 0 ? data : void 0
6518
6521
  };
6519
6522
  }
6523
+ function sanitizeCanvasKeys(data) {
6524
+ const cleanData = {};
6525
+ for (const [key, value] of Object.entries(data)) {
6526
+ const cleanKey = key.replace(/^["']+|["']+$/g, "").trim();
6527
+ if (value && typeof value === "object" && !Array.isArray(value)) {
6528
+ const valObj = value;
6529
+ const sanitizedSub = { ...valObj };
6530
+ if (sanitizedSub.images && typeof sanitizedSub.images === "object" && !Array.isArray(sanitizedSub.images)) {
6531
+ sanitizedSub.images = sanitizeCanvasKeys(sanitizedSub.images);
6532
+ }
6533
+ if (sanitizedSub.videos && typeof sanitizedSub.videos === "object" && !Array.isArray(sanitizedSub.videos)) {
6534
+ sanitizedSub.videos = sanitizeCanvasKeys(sanitizedSub.videos);
6535
+ }
6536
+ cleanData[cleanKey] = sanitizedSub;
6537
+ } else {
6538
+ cleanData[cleanKey] = value;
6539
+ }
6540
+ }
6541
+ return cleanData;
6542
+ }
6543
+ function validateInstantPageCanvas(input, isPublishing = false) {
6544
+ const errors = [];
6545
+ if (!input) {
6546
+ return { isValid: false, errors: ["Canvas Instant Page kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng."] };
6547
+ }
6548
+ let canvasObj;
6549
+ if (typeof input === "string") {
6550
+ if (input.trim() === "") {
6551
+ return { isValid: false, errors: ["Chu\u1ED7i Canvas JSON kh\xF4ng \u0111\u01B0\u1EE3c r\u1ED7ng."] };
6552
+ }
6553
+ try {
6554
+ canvasObj = JSON.parse(input);
6555
+ } catch (e) {
6556
+ return { isValid: false, errors: [`Canvas JSON kh\xF4ng h\u1EE3p l\u1EC7: ${e.message}`] };
6557
+ }
6558
+ } else if (typeof input === "object" && input !== null) {
6559
+ canvasObj = input;
6560
+ } else {
6561
+ return { isValid: false, errors: ["Canvas ph\u1EA3i l\xE0 \u0111\u1ED1i t\u01B0\u1EE3ng (Object) ho\u1EB7c chu\u1ED7i JSON h\u1EE3p l\u1EC7."] };
6562
+ }
6563
+ if (!canvasObj.renderList || !Array.isArray(canvasObj.renderList)) {
6564
+ errors.push("Canvas b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 m\u1EA3ng 'renderList' \u0111\u1ECBnh ngh\u0129a th\u1EE9 t\u1EF1 hi\u1EC3n th\u1ECB c\xE1c kh\u1ED1i giao di\u1EC7n (v\xED d\u1EE5: ['0', '1', '2']). Kh\xF4ng \u0111\u01B0\u1EE3c d\xF9ng { blocks: [] }.");
6565
+ } else if (canvasObj.renderList.length === 0) {
6566
+ errors.push("M\u1EA3ng 'renderList' kh\xF4ng \u0111\u01B0\u1EE3c r\u1ED7ng, ph\u1EA3i ch\u1EE9a \xEDt nh\u1EA5t 1 ID kh\u1ED1i giao di\u1EC7n.");
6567
+ }
6568
+ if (!canvasObj.data || typeof canvasObj.data !== "object" || Array.isArray(canvasObj.data)) {
6569
+ errors.push("Canvas b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 \u0111\u1ED1i t\u01B0\u1EE3ng 'data' ch\u1EE9a c\u1EA5u h\xECnh chi ti\u1EBFt c\u1EE7a t\u1EEBng kh\u1ED1i giao di\u1EC7n.");
6570
+ }
6571
+ if (errors.length > 0) {
6572
+ return { isValid: false, errors };
6573
+ }
6574
+ const renderList = canvasObj.renderList.map(
6575
+ (id) => String(id).replace(/^["']+|["']+$/g, "").trim()
6576
+ );
6577
+ const rawData = canvasObj.data;
6578
+ const cleanData = sanitizeCanvasKeys(rawData);
6579
+ for (const blockId of renderList) {
6580
+ if (!(blockId in cleanData)) {
6581
+ errors.push(`Kh\u1ED1i ID '${blockId}' c\xF3 trong 'renderList' nh\u01B0ng kh\xF4ng t\u1ED3n t\u1EA1i trong t\u1EEB \u0111i\u1EC3n 'data'.`);
6582
+ } else {
6583
+ const block = cleanData[blockId];
6584
+ if (!block || typeof block !== "object") {
6585
+ errors.push(`Kh\u1ED1i d\u1EEF li\u1EC7u data['${blockId}'] ph\u1EA3i l\xE0 m\u1ED9t \u0111\u1ED1i t\u01B0\u1EE3ng.`);
6586
+ } else if (block.type === void 0 || typeof block.type !== "number") {
6587
+ errors.push(`Kh\u1ED1i data['${blockId}'] b\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 tr\u01B0\u1EDDng 'type' l\xE0 m\xE3 s\u1ED1 nguy\xEAn (Block Type).`);
6588
+ }
6589
+ }
6590
+ }
6591
+ if (isPublishing) {
6592
+ for (const blockId of renderList) {
6593
+ const block = cleanData[blockId];
6594
+ if (!block) continue;
6595
+ if (block.type === 28) {
6596
+ const name = typeof block.name === "string" ? block.name.trim() : "";
6597
+ if (name.length < 2 || name.length > 30) {
6598
+ errors.push(`Kh\u1ED1i Th\xF4ng tin Mini Shop (ID: '${blockId}'): T\xEAn Mini Shop ('name') ph\u1EA3i t\u1EEB 2 \u0111\u1EBFn 30 k\xFD t\u1EF1.`);
6599
+ }
6600
+ const img = block.image;
6601
+ if (!img || typeof img.url !== "string" || !img.url.startsWith("http")) {
6602
+ errors.push(`Kh\u1ED1i Th\xF4ng tin Mini Shop (ID: '${blockId}'): B\u1EAFt bu\u1ED9c ph\u1EA3i c\xF3 \u1EA3nh logo v\u1EDBi URL h\u1EE3p l\u1EC7 ('image.url').`);
6603
+ }
6604
+ }
6605
+ if (block.type === 29) {
6606
+ const len = typeof block.length === "number" ? block.length : 0;
6607
+ const html = typeof block.outputHtml === "string" ? block.outputHtml.trim() : "";
6608
+ if (len === 0 && html === "") {
6609
+ errors.push(`Kh\u1ED1i M\xF4 t\u1EA3 (ID: '${blockId}'): Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng n\u1ED9i dung m\xF4 t\u1EA3.`);
6610
+ }
6611
+ }
6612
+ if (block.type === 1) {
6613
+ const indexes = Array.isArray(block.indexes) ? block.indexes : [];
6614
+ const images = block.images && typeof block.images === "object" ? block.images : {};
6615
+ for (const idx of indexes) {
6616
+ const img = images[String(idx)];
6617
+ if (img && typeof img.url === "string" && img.url.trim() === "") {
6618
+ errors.push(`Kh\u1ED1i Carousel (ID: '${blockId}'): \u1EA2nh t\u1EA1i ch\u1EC9 m\u1EE5c '${idx}' kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 URL r\u1ED7ng.`);
6619
+ }
6620
+ }
6621
+ }
6622
+ if (block.type === 21) {
6623
+ const msg = typeof block.content === "string" ? block.content.trim() : "";
6624
+ if (msg.length === 0 || msg.length > 40) {
6625
+ errors.push(`Kh\u1ED1i Tin nh\u1EAFn m\u1EB7c \u0111\u1ECBnh (ID: '${blockId}'): N\u1ED9i dung tin nh\u1EAFn ph\u1EA3i t\u1EEB 1 \u0111\u1EBFn 40 k\xFD t\u1EF1.`);
6626
+ }
6627
+ }
6628
+ }
6629
+ }
6630
+ const resultCanvas = {
6631
+ version: typeof canvasObj.version === "number" || typeof canvasObj.version === "string" ? canvasObj.version : "1",
6632
+ renderList,
6633
+ data: cleanData,
6634
+ ...canvasObj.freezedTop !== void 0 ? { freezedTop: Number(canvasObj.freezedTop) } : {},
6635
+ ...canvasObj.freezedBottom !== void 0 ? { freezedBottom: Number(canvasObj.freezedBottom) } : {},
6636
+ ...canvasObj.pageTitle !== void 0 ? { pageTitle: String(canvasObj.pageTitle) } : {}
6637
+ };
6638
+ return {
6639
+ isValid: errors.length === 0,
6640
+ errors,
6641
+ data: errors.length === 0 ? resultCanvas : void 0
6642
+ };
6643
+ }
6520
6644
  function validateUpdateInstantPageRequest(input) {
6521
6645
  const errors = [];
6522
6646
  if (!input || typeof input !== "object") {
@@ -6555,40 +6679,42 @@ function validateUpdateInstantPageRequest(input) {
6555
6679
  data.active = obj.active;
6556
6680
  }
6557
6681
  }
6682
+ let isPublishing = false;
6558
6683
  if (obj.status !== void 0 && obj.status !== null) {
6559
6684
  const st = Number(obj.status);
6560
6685
  if (![0, 1, 2, 3].includes(st)) {
6561
6686
  errors.push("Tr\u01B0\u1EDDng 'status' ph\u1EA3i l\xE0 m\u1ED9t trong c\xE1c m\xE3: 0 (B\u1EA3n sao m\u1EDBi t\u1EA1o ch\u01B0a l\u01B0u), 1 (\u0110ang ho\u1EA1t \u0111\u1ED9ng / \u0110\xE3 xu\u1EA5t b\u1EA3n), 3 (\u0110\xE3 k\u1EBFt th\xFAc / L\u01B0u tr\u1EEF).");
6562
6687
  } else {
6563
6688
  data.status = st;
6689
+ if (st === 1) isPublishing = true;
6564
6690
  }
6565
6691
  }
6692
+ let validatedDraftCanvas;
6566
6693
  if (obj.draft !== void 0 && obj.draft !== null) {
6567
- if (typeof obj.draft !== "string") {
6568
- errors.push("Tr\u01B0\u1EDDng 'draft' ph\u1EA3i l\xE0 chu\u1ED7i JSON (JSON-encoded string).");
6569
- } else if (obj.draft.trim() !== "") {
6570
- try {
6571
- JSON.parse(obj.draft);
6572
- data.draft = obj.draft;
6573
- } catch (err) {
6574
- errors.push(`Tr\u01B0\u1EDDng 'draft' kh\xF4ng ph\u1EA3i l\xE0 chu\u1ED7i JSON h\u1EE3p l\u1EC7: ${err.message}`);
6575
- }
6694
+ const canvasRes = validateInstantPageCanvas(obj.draft, isPublishing);
6695
+ if (!canvasRes.isValid) {
6696
+ errors.push(...canvasRes.errors.map((err) => `[draft] ${err}`));
6576
6697
  } else {
6577
- data.draft = "";
6698
+ validatedDraftCanvas = canvasRes.data;
6699
+ data.draft = JSON.stringify(canvasRes.data);
6578
6700
  }
6579
6701
  }
6702
+ let validatedContentCanvas;
6580
6703
  if (obj.content !== void 0 && obj.content !== null) {
6581
- if (typeof obj.content !== "string") {
6582
- errors.push("Tr\u01B0\u1EDDng 'content' ph\u1EA3i l\xE0 chu\u1ED7i JSON (JSON-encoded string).");
6583
- } else if (obj.content.trim() !== "") {
6584
- try {
6585
- JSON.parse(obj.content);
6586
- data.content = obj.content;
6587
- } catch (err) {
6588
- errors.push(`Tr\u01B0\u1EDDng 'content' kh\xF4ng ph\u1EA3i l\xE0 chu\u1ED7i JSON h\u1EE3p l\u1EC7: ${err.message}`);
6589
- }
6704
+ const canvasRes = validateInstantPageCanvas(obj.content, isPublishing);
6705
+ if (!canvasRes.isValid) {
6706
+ errors.push(...canvasRes.errors.map((err) => `[content] ${err}`));
6590
6707
  } else {
6591
- data.content = "";
6708
+ validatedContentCanvas = canvasRes.data;
6709
+ data.content = JSON.stringify(canvasRes.data);
6710
+ }
6711
+ }
6712
+ if (isPublishing) {
6713
+ if (data.draft && !data.content) {
6714
+ data.content = data.draft;
6715
+ } else if (data.content && !data.draft) {
6716
+ data.draft = data.content;
6717
+ } else if (!data.draft && !data.content) {
6592
6718
  }
6593
6719
  }
6594
6720
  const hasUpdateField = data.name !== void 0 || data.oaId !== void 0 || data.active !== void 0 || data.status !== void 0 || data.draft !== void 0 || data.content !== void 0;
@@ -7599,6 +7725,8 @@ var ZaloInstantPageBlockType = /* @__PURE__ */ ((ZaloInstantPageBlockType2) => {
7599
7725
  ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["CALL_HOTLINE_BUTTON"] = 23] = "CALL_HOTLINE_BUTTON";
7600
7726
  ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["KEY_VALUE_TABLE"] = 25] = "KEY_VALUE_TABLE";
7601
7727
  ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["CONSENT_NOTICE"] = 27] = "CONSENT_NOTICE";
7728
+ ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["SHOP_INFO"] = 28] = "SHOP_INFO";
7729
+ ZaloInstantPageBlockType2[ZaloInstantPageBlockType2["SHOP_DESCRIPTION"] = 29] = "SHOP_DESCRIPTION";
7602
7730
  return ZaloInstantPageBlockType2;
7603
7731
  })(ZaloInstantPageBlockType || {});
7604
7732
  var ZaloInstantPageSharePermission = {
@@ -7612,6 +7740,399 @@ var ZaloInstantPageSharePermission = {
7612
7740
  READ_ONLY: 4
7613
7741
  };
7614
7742
 
7743
+ // src/helpers/instant-page-factory.ts
7744
+ var InstantPageFactory = class {
7745
+ /**
7746
+ * Khởi tạo Canvas hoàn chỉnh từ Template ID (1, 3, 4, 5) được điền sẵn dữ liệu hợp lệ.
7747
+ */
7748
+ static createFromTemplate(templateId, options = {}) {
7749
+ const brandName = options.brandName || "RedAI Official Store";
7750
+ const brandLogoUrl = options.brandLogoUrl || "https://adtima-media.zascdn.me/2023/10/58117541-e206-4f9d-b4cf-69e50f963288.svg";
7751
+ const productName = options.productName || "S\u1EA3n ph\u1EA9m / D\u1ECBch v\u1EE5 \u0110\u1ED9t ph\xE1 2026";
7752
+ const price = options.price ?? 299e3;
7753
+ const rawPrice = options.rawPrice ?? 499e3;
7754
+ const defaultMsg = options.defaultMessage || "T\xF4i mu\u1ED1n t\xECm hi\u1EC3u th\xEAm v\u1EC1 s\u1EA3n ph\u1EA9m n\xE0y";
7755
+ const defaultImages = [
7756
+ "https://adtima-media.zascdn.me/2023/06/84cba4c9-be13-425a-8daa-40e695ca9805.jpg",
7757
+ "https://adtima-media.zascdn.me/2023/06/805587cd-4699-47e6-a9bb-3cbbb4039b40.jpg",
7758
+ "https://adtima-media.zascdn.me/2023/06/aca98d2c-1739-4f03-a366-43a6d6c4ef53.jpg",
7759
+ "https://adtima-media.zascdn.me/2023/06/8cc5692b-2899-4862-9957-d3f66e8778cd.jpg"
7760
+ ];
7761
+ switch (templateId) {
7762
+ case 5: {
7763
+ const carouselImgs = options.carouselImages && options.carouselImages.length > 0 ? options.carouselImages : defaultImages.map((url, i) => ({ url, name: `image-${i + 1}.jpg` }));
7764
+ const indexes = carouselImgs.map((_, i) => String(i));
7765
+ const imagesMap = {};
7766
+ carouselImgs.forEach((img, i) => {
7767
+ imagesMap[String(i)] = {
7768
+ name: img.name || `image-${i + 1}.jpg`,
7769
+ url: img.url
7770
+ };
7771
+ });
7772
+ const descText = options.description || "H\u1EC7 sinh th\xE1i c\xF4ng ngh\u1EC7 t\u1EF1 \u0111\u1ED9ng h\xF3a RedAI. T\xEDch h\u1EE3p \u0111a k\xEAnh Zalo OA, Website & CRM; h\u1ED7 tr\u1EE3 t\u1EF1 \u0111\u1ED9ng ph\u1EA3n h\u1ED3i v\xE0 ch\u1ED1t \u0111\u01A1n 24/7.";
7773
+ return {
7774
+ version: 1,
7775
+ renderList: ["1", "2", "3", "4"],
7776
+ freezedBottom: 4,
7777
+ pageTitle: "Chi ti\u1EBFt",
7778
+ data: {
7779
+ "1": {
7780
+ id: "-1",
7781
+ type: 28,
7782
+ name: brandName,
7783
+ image: {
7784
+ name: "logo.png",
7785
+ url: brandLogoUrl
7786
+ }
7787
+ },
7788
+ "2": {
7789
+ id: "-1",
7790
+ type: 29,
7791
+ delta: {
7792
+ ops: [
7793
+ { attributes: { bold: true, size: "18px" }, insert: `${brandName}
7794
+ ` },
7795
+ { insert: `
7796
+ ${descText}
7797
+ ` }
7798
+ ]
7799
+ },
7800
+ outputHtml: `<p><strong style="font-size: 18px;">${brandName}</strong></p><p><br>${descText}</p>`,
7801
+ length: brandName.length + descText.length + 10
7802
+ },
7803
+ "3": {
7804
+ id: "-1",
7805
+ type: 1,
7806
+ indexes,
7807
+ images: imagesMap,
7808
+ videos: {
7809
+ "0": { name: "", thumbnail: "", url: "" }
7810
+ }
7811
+ },
7812
+ "4": {
7813
+ id: "-1",
7814
+ type: 21,
7815
+ content: defaultMsg,
7816
+ marginTop: 0,
7817
+ marginBottom: 0
7818
+ }
7819
+ }
7820
+ };
7821
+ }
7822
+ case 4: {
7823
+ return {
7824
+ version: 4,
7825
+ renderList: ["1", "2", "3"],
7826
+ freezedBottom: 3,
7827
+ data: {
7828
+ "1": {
7829
+ id: "-1",
7830
+ indexes: ["0", "1", "2"],
7831
+ images: {
7832
+ "1": { name: "banner-1.jpg", url: defaultImages[0] },
7833
+ "2": { name: "banner-2.jpg", url: defaultImages[1] }
7834
+ },
7835
+ textEditor: {
7836
+ delta: {
7837
+ ops: [
7838
+ { attributes: { bold: true }, insert: `Ch\xE0o m\u1EEBng b\u1EA1n \u0111\u1EBFn v\u1EDBi ${brandName}` },
7839
+ { insert: "\n\nB\u1EA1n \u0111ang quan t\xE2m gi\u1EA3i ph\xE1p n\xE0o \u0111\u1EC3 chuy\xEAn vi\xEAn h\u1ED7 tr\u1EE3 ngay?\n\n" }
7840
+ ]
7841
+ },
7842
+ outputHtml: `<p><strong>Ch\xE0o m\u1EEBng b\u1EA1n \u0111\u1EBFn v\u1EDBi ${brandName}</strong></p><p><br></p><p>B\u1EA1n \u0111ang quan t\xE2m gi\u1EA3i ph\xE1p n\xE0o \u0111\u1EC3 chuy\xEAn vi\xEAn h\u1ED7 tr\u1EE3 ngay?</p>`
7843
+ },
7844
+ type: 1,
7845
+ videos: {
7846
+ "0": { name: "", thumbnail: "", url: "" }
7847
+ }
7848
+ },
7849
+ "2": {
7850
+ rows: [{ id: 0, left: "\u01AFu \u0111\xE3i tr\u1EA3i nghi\u1EC7m", right: "D\xF9ng th\u1EED mi\u1EC5n ph\xED" }],
7851
+ type: 25
7852
+ },
7853
+ "3": {
7854
+ list: [
7855
+ "T\u01B0 v\u1EA5n gi\u1EA3i ph\xE1p t\u1EF1 \u0111\u1ED9ng h\xF3a",
7856
+ "B\xE1o gi\xE1 chi ti\u1EBFt g\xF3i doanh nghi\u1EC7p",
7857
+ "H\u1ED7 tr\u1EE3 k\u1EF9 thu\u1EADt 24/7"
7858
+ ],
7859
+ marginBottom: 16,
7860
+ marginTop: 0,
7861
+ type: 20
7862
+ }
7863
+ }
7864
+ };
7865
+ }
7866
+ case 3:
7867
+ case 1:
7868
+ default: {
7869
+ return {
7870
+ version: "1",
7871
+ renderList: [
7872
+ "0",
7873
+ "1",
7874
+ "2",
7875
+ "11",
7876
+ "16",
7877
+ "17",
7878
+ "18",
7879
+ "26",
7880
+ "3",
7881
+ "4",
7882
+ "5",
7883
+ "7",
7884
+ "8",
7885
+ "9",
7886
+ "12",
7887
+ "10",
7888
+ "27"
7889
+ ],
7890
+ freezedTop: 3,
7891
+ freezedBottom: 10,
7892
+ data: {
7893
+ "0": {
7894
+ id: "-1",
7895
+ type: 1,
7896
+ indexes: ["0", "1", "2"],
7897
+ images: {
7898
+ "0": { name: "prod-1.jpg", url: defaultImages[0] },
7899
+ "1": { name: "prod-2.jpg", url: defaultImages[1] },
7900
+ "2": { name: "prod-3.jpg", url: defaultImages[2] }
7901
+ },
7902
+ videos: { "5": { name: "", thumbnail: "", url: "" } }
7903
+ },
7904
+ "1": {
7905
+ id: "-1",
7906
+ discountValue: 35,
7907
+ visible: true,
7908
+ countdownType: 4,
7909
+ type: 2,
7910
+ startDate: Date.now(),
7911
+ loopDays: 1,
7912
+ label: "<p>Th\u1EDDi gian \u01B0u \u0111\xE3i c\xF2n l\u1EA1i:</p>",
7913
+ labelDelta: { ops: [{ insert: "Th\u1EDDi gian \u01B0u \u0111\xE3i c\xF2n l\u1EA1i:\n" }] },
7914
+ marginTop: 8,
7915
+ marginBottom: 0,
7916
+ visibility: { days: true, hours: true, minutes: true, seconds: true }
7917
+ },
7918
+ "2": {
7919
+ type: 19,
7920
+ name: productName,
7921
+ price,
7922
+ rawPrice,
7923
+ marginTop: 8,
7924
+ marginBottom: 8
7925
+ },
7926
+ "3": {
7927
+ id: "-1",
7928
+ type: 18,
7929
+ visible: true,
7930
+ formQuestion: {
7931
+ type: 2,
7932
+ title: "Phi\xEAn b\u1EA3n",
7933
+ isRequired: true,
7934
+ disable: false,
7935
+ answers: [
7936
+ { type: 1, value: "B\u1EA3n Ti\xEAu Chu\u1EA9n", priority: 0 },
7937
+ { type: 1, value: "B\u1EA3n Cao C\u1EA5p", priority: 1 }
7938
+ ],
7939
+ description: "",
7940
+ priority: 0
7941
+ },
7942
+ marginTop: 8,
7943
+ marginBottom: 8
7944
+ },
7945
+ "4": {
7946
+ id: "-1",
7947
+ type: 18,
7948
+ visible: true,
7949
+ formQuestion: {
7950
+ type: 2,
7951
+ title: "G\xF3i dung l\u01B0\u1EE3ng",
7952
+ isRequired: true,
7953
+ disable: false,
7954
+ answers: [
7955
+ { type: 1, value: "G\xF3i 1 Th\xE1ng", priority: 0 },
7956
+ { type: 1, value: "G\xF3i 1 N\u0103m", priority: 1 }
7957
+ ],
7958
+ description: "",
7959
+ priority: 0
7960
+ },
7961
+ marginTop: 8,
7962
+ marginBottom: 8
7963
+ },
7964
+ "5": {
7965
+ id: "-1",
7966
+ type: 16,
7967
+ formQuestion: {
7968
+ type: 1,
7969
+ title: "S\u1ED1 l\u01B0\u1EE3ng",
7970
+ isRequired: true,
7971
+ disable: false,
7972
+ answers: [{ type: 5, value: "", priority: 0 }],
7973
+ description: "",
7974
+ priority: 0
7975
+ },
7976
+ marginTop: 8,
7977
+ marginBottom: 8
7978
+ },
7979
+ "7": {
7980
+ id: "-1",
7981
+ type: 7,
7982
+ formQuestion: {
7983
+ type: 1,
7984
+ title: "H\u1ECD v\xE0 t\xEAn",
7985
+ isRequired: true,
7986
+ disable: false,
7987
+ answers: [{ type: 7, value: "", placeHolder: "Nh\u1EADp h\u1ECD v\xE0 t\xEAn c\u1EE7a b\u1EA1n", priority: 0 }],
7988
+ description: "",
7989
+ priority: 0
7990
+ },
7991
+ marginTop: 8,
7992
+ marginBottom: 8
7993
+ },
7994
+ "8": {
7995
+ id: "-1",
7996
+ type: 9,
7997
+ formQuestion: {
7998
+ type: 1,
7999
+ title: "S\u1ED1 \u0111i\u1EC7n tho\u1EA1i",
8000
+ isRequired: true,
8001
+ disable: false,
8002
+ answers: [{ type: 13, value: "", placeHolder: "Nh\u1EADp s\u1ED1 \u0111i\u1EC7n tho\u1EA1i li\xEAn h\u1EC7", priority: 0 }],
8003
+ description: "",
8004
+ priority: 0
8005
+ },
8006
+ marginTop: 8,
8007
+ marginBottom: 8
8008
+ },
8009
+ "9": {
8010
+ id: "-1",
8011
+ type: 10,
8012
+ formQuestion: {
8013
+ type: 1,
8014
+ title: "\u0110\u1ECBa ch\u1EC9",
8015
+ isRequired: true,
8016
+ disable: false,
8017
+ answers: [{ type: 15, value: "", placeHolder: "Nh\u1EADp \u0111\u1ECBa ch\u1EC9 giao h\xE0ng ho\u1EB7c nh\u1EADn t\u01B0 v\u1EA5n", priority: 0 }],
8018
+ description: "",
8019
+ priority: 0
8020
+ },
8021
+ marginTop: 8,
8022
+ marginBottom: 8
8023
+ },
8024
+ "10": {
8025
+ id: "-1",
8026
+ type: 8,
8027
+ background: "#008FE5",
8028
+ borderColor: "#000000",
8029
+ borderRadius: 4,
8030
+ borderSize: 1,
8031
+ showBorder: false,
8032
+ formPopup: templateId === 3,
8033
+ fixedPosition: true,
8034
+ image: {
8035
+ name: "cart.svg",
8036
+ url: "https://adtima-media.zascdn.me/2023/10/58117541-e206-4f9d-b4cf-69e50f963288.svg"
8037
+ },
8038
+ content2: "\u0110\u1EB7t h\xE0ng ngay"
8039
+ },
8040
+ "11": {
8041
+ id: "-1",
8042
+ type: 4,
8043
+ delta: {
8044
+ ops: [
8045
+ { attributes: { color: "#bf2600", bold: true }, insert: "\u01AFU \u0110\xC3I \u0110\u1EB6C BI\u1EC6T H\xD4M NAY\n" },
8046
+ { insert: `Tr\u1EA3i nghi\u1EC7m tr\u1ECDn b\u1ED9 t\xEDnh n\u0103ng v\u01B0\u1EE3t tr\u1ED9i c\u1EE7a ${productName}.
8047
+ ` }
8048
+ ]
8049
+ },
8050
+ marginTop: 16,
8051
+ marginBottom: 16,
8052
+ outputHtml: `<p><strong style="color: rgb(191, 38, 0);">\u01AFU \u0110\xC3I \u0110\u1EB6C BI\u1EC6T H\xD4M NAY</strong></p><p>Tr\u1EA3i nghi\u1EC7m tr\u1ECDn b\u1ED9 t\xEDnh n\u0103ng v\u01B0\u1EE3t tr\u1ED9i c\u1EE7a ${productName}.</p>`
8053
+ },
8054
+ "12": {
8055
+ id: "-1",
8056
+ type: 23,
8057
+ actionType: "1",
8058
+ content: "Li\xEAn h\u1EC7 Hotline",
8059
+ borderColor: "#008fe5",
8060
+ borderRadius: 4,
8061
+ borderSize: 2,
8062
+ showBorder: true,
8063
+ fixedPosition: true,
8064
+ visible: true,
8065
+ phone: options.hotline || "",
8066
+ image: {
8067
+ name: "phone.svg",
8068
+ url: "https://adtima-media.zascdn.me/2023/10/03d065a4-90b2-4deb-b684-5ff61407a47d.svg"
8069
+ },
8070
+ color: "#008fe5",
8071
+ background: "#ffffff",
8072
+ marginTop: 16,
8073
+ marginBottom: 16
8074
+ },
8075
+ "16": {
8076
+ id: "-1",
8077
+ type: 6,
8078
+ mediaType: "image",
8079
+ image: { url: defaultImages[0], name: "hero-1.png" },
8080
+ videoSetting: { autoPlay: true, loop: true }
8081
+ },
8082
+ "17": {
8083
+ id: "-1",
8084
+ type: 6,
8085
+ mediaType: "image",
8086
+ image: { url: defaultImages[1], name: "hero-2.png" },
8087
+ videoSetting: { autoPlay: true, loop: true }
8088
+ },
8089
+ "18": {
8090
+ id: "-1",
8091
+ type: 6,
8092
+ mediaType: "image",
8093
+ image: { url: defaultImages[2], name: "hero-3.png" },
8094
+ videoSetting: { autoPlay: true, loop: true }
8095
+ },
8096
+ "26": {
8097
+ id: "-1",
8098
+ type: 14,
8099
+ backgroundColor: "#f2f3f3",
8100
+ textDelta: { ops: [{ attributes: { size: "18px", bold: true }, insert: `${brandName}
8101
+ ` }] },
8102
+ textHtml: `<p><strong style="font-size: 18px;">${brandName}</strong></p>`,
8103
+ detailings: [
8104
+ {
8105
+ image: {
8106
+ url: "https://adtima-media.zascdn.me/2023/10/cba64b4d-0bd5-4504-8b6d-5f2d2562854a.png",
8107
+ name: "home.png"
8108
+ },
8109
+ textDelta: { ops: [{ insert: `\u0110\u1ECBa ch\u1EC9: ${options.address || "H\xE0 N\u1ED9i / TP.HCM"}
8110
+ ` }] },
8111
+ textHtml: `<p>\u0110\u1ECBa ch\u1EC9: ${options.address || "H\xE0 N\u1ED9i / TP.HCM"}</p>`
8112
+ },
8113
+ {
8114
+ image: {
8115
+ url: "https://adtima-media.zascdn.me/2023/10/d538811f-9232-4ef0-a130-ea2b1dda05d2.png",
8116
+ name: "phone.png"
8117
+ },
8118
+ textDelta: { ops: [{ insert: `Hotline: ${options.hotline || "1900 xxxx"}
8119
+ ` }] },
8120
+ textHtml: `<p>Hotline: ${options.hotline || "1900 xxxx"}</p>`
8121
+ }
8122
+ ]
8123
+ },
8124
+ "27": {
8125
+ id: "-1",
8126
+ type: 27,
8127
+ useCustomConsent: false
8128
+ }
8129
+ }
8130
+ };
8131
+ }
8132
+ }
8133
+ }
8134
+ };
8135
+
7615
8136
  // src/validators/automated-rules.validator.ts
7616
8137
  var AutomatedRuleScopeEnum = /* @__PURE__ */ ((AutomatedRuleScopeEnum2) => {
7617
8138
  AutomatedRuleScopeEnum2[AutomatedRuleScopeEnum2["Ads"] = 1] = "Ads";
@@ -8348,6 +8869,7 @@ var ZaloMediaValidator = {
8348
8869
  AutomatedRuleTimeRangeEnum,
8349
8870
  ConversionLabelEnum,
8350
8871
  ConversionUrlTypeEnum,
8872
+ InstantPageFactory,
8351
8873
  MAX_REPORT_RANGE_MS,
8352
8874
  MAX_REPORT_RANGE_SECONDS,
8353
8875
  MemoryZaloSessionStore,
@@ -8426,6 +8948,7 @@ var ZaloMediaValidator = {
8426
8948
  defaultSharedMemorySessionStore,
8427
8949
  deriveAccountKeyFromZpsid,
8428
8950
  parseZaloCookieInput,
8951
+ sanitizeCanvasKeys,
8429
8952
  validateChangeCampaignStatusParams,
8430
8953
  validateCloneInstantPageRequest,
8431
8954
  validateCreateCampaignPayload,
@@ -8446,6 +8969,7 @@ var ZaloMediaValidator = {
8446
8969
  validateEstimateAudienceRequest,
8447
8970
  validateGetInstantPageDetailRequest,
8448
8971
  validateGetInstantPageSharedUserRequest,
8972
+ validateInstantPageCanvas,
8449
8973
  validateListFlowsByOfficialAccountRequest,
8450
8974
  validateListFormLeadsRequest,
8451
8975
  validateListFormsByOfficialAccountRequest,