@bikdotai/bik-component-library 0.0.595-beta.1 → 0.0.595-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/template-preview/WhatsApp/ChatUI.js +2 -2
- package/dist/cjs/components/template-preview/WhatsApp/ChatUiV2.js +5 -5
- package/dist/cjs/components/template-preview/utils/TemplateHelperUtils.d.ts +1 -0
- package/dist/cjs/components/template-preview/utils/TemplateHelperUtils.js +1 -1
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/template-preview/WhatsApp/ChatUI.js +2 -2
- package/dist/esm/components/template-preview/WhatsApp/ChatUiV2.js +5 -5
- package/dist/esm/components/template-preview/utils/TemplateHelperUtils.d.ts +1 -0
- package/dist/esm/components/template-preview/utils/TemplateHelperUtils.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/halfRectangle.svg.js"),r=require("../../../assets/icons/phone.svg.js"),s=require("../../../assets/icons/RedirectToNew.svg.js"),i=require("react"),a=require("styled-components"),o=require("../../tooltips/Tooltip.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/halfRectangle.svg.js"),r=require("../../../assets/icons/phone.svg.js"),s=require("../../../assets/icons/RedirectToNew.svg.js"),i=require("react"),a=require("styled-components"),o=require("../utils/TemplateHelperUtils.js"),n=require("../../tooltips/Tooltip.js"),l=require("../../TypographyStyle.js"),d=require("../../../constants/Theme.js"),p=require("../helpers/WhatsAppFormatToHTML.js"),c=require("../models/TemplateMeta.js"),h=require("./ChatBtn.js"),x=require("./ChatUI.style.js"),T=require("./MediaCard.js"),u=require("./RenderTemplateWithVariable.js");function j(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const m=j(a).default.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
width: 8px;
|
|
4
4
|
height: 8px;
|
|
5
5
|
left: -7.7px;
|
|
6
6
|
top: -8px;
|
|
7
|
-
`;exports.default=a=>{const{bodyText:
|
|
7
|
+
`;exports.default=a=>{const{bodyText:j,footerText:y,headerMediaType:g,headerText:S,headerAssetLink:f,headerAssetName:q,quickReplybtn:v,ctaBtn:E,actionTypes:b,textType:w,extras:C,showHeader:A,imagePreviewStyles:N,size:F,children:O,isPreview:M}=a,P=new p.WhatsAppFormatToHTML,_=i.useMemo((()=>({color:d.COLORS.content.primary,margin:12,fontSize:A?d.FONTS.caption.fontSize:d.FONTS.bodySecondary.fontSize,fontWeight:d.FONTS.bodySecondary.fontWeight,maxWidth:"100%",whiteSpace:"pre-wrap",marginBottom:0,marginTop:8,wordBreak:"break-word"})),[]);return e.jsxs(x.Container,Object.assign({isPreview:M},{children:[e.jsx(m,{children:e.jsx(t.default,{color:"white",height:8,width:8})}),g===c.HEADER_TYPES.TEXT?e.jsx(u.default,{bold:!0,text:o.replaceText(S)}):g!==c.HEADER_TYPES.NONE?e.jsx(T.MediaCard,{headerAssetLink:f,headerAssetName:q,mediaType:g,imagePreviewStyles:g===c.HEADER_TYPES.IMAGE?N:{}}):e.jsx(e.Fragment,{}),!!j&&e.jsx(e.Fragment,{children:O?e.jsx(e.Fragment,{children:O}):e.jsx(e.Fragment,{children:"html"===w?e.jsx("div",{className:"richTextEditor",style:_,dangerouslySetInnerHTML:{__html:P.convertToHTML(j)}}):e.jsx(l.BodySecondary,{children:o.replaceText(j)})})}),e.jsxs(x.FooterWrapper,{children:[e.jsx(n.Tooltip,Object.assign({body:null!=y?y:"",placement:"top"},{children:e.jsx(x.FooterText,Object.assign({style:{flex:1}},{children:y}))})),e.jsx(x.TimeStamp,{children:"16:48"})]}),b===c.ACTIONS_TYPES.QUICK_REPLY?e.jsx("div",{children:null==v?void 0:v.map(((t,r)=>e.jsx(h.ChatBtn,{text:t.text},r)))}):b===c.ACTIONS_TYPES.CTA_BTN?e.jsx("div",{children:null==E?void 0:E.map(((t,i)=>e.jsx(h.ChatBtn,{textTypography:A?l.Caption:l.BodySecondary,extraContent:C?t.extra:void 0,placeholder:t.placeholder,text:t.text,Icon:"phoneNumber"===t.type?r.default:s.default,size:F},i)))}):e.jsx(e.Fragment,{})]}))};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/copy-code-icon.svg.js"),r=require("../../../assets/icons/halfRectangle.svg.js"),s=require("../../../assets/icons/phone.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/copy-code-icon.svg.js"),r=require("../../../assets/icons/halfRectangle.svg.js"),s=require("../../../assets/icons/phone.svg.js"),i=require("../../../assets/icons/qrb.svg.js"),a=require("../../../assets/icons/RedirectToNew.svg.js"),o=require("styled-components"),l=require("../../template-context-mapper/context/templateModalContext.js"),n=require("../utils/TemplateHelperUtils.js"),d=require("../../tooltips/Tooltip.js"),p=require("../../TypographyStyle.js"),u=require("../../../constants/Theme.js"),x=require("../helpers/VariableEditorHelper.js"),c=require("../models/TemplateMeta.js"),h=require("./ChatBtn.js"),m=require("./ChatUI.style.js"),j=require("./LimitedTimeOffer/LimitedTimeOffer.index.js"),T=require("./MediaCard.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=f(o);const C=y.default.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
width: 8px;
|
|
4
4
|
height: 8px;
|
|
5
5
|
left: -7.7px;
|
|
6
6
|
top: -8px;
|
|
7
|
-
`,y
|
|
7
|
+
`,g=y.default.div`
|
|
8
8
|
font-family: 'Inter';
|
|
9
9
|
font-style: normal;
|
|
10
10
|
font-weight: 400;
|
|
11
11
|
font-size: 14px;
|
|
12
12
|
line-height: 20px;
|
|
13
13
|
padding: 8px 12px 0px;
|
|
14
|
-
color: ${
|
|
14
|
+
color: ${u.COLORS.content.primary};
|
|
15
15
|
word-wrap: break-word;
|
|
16
|
-
`,
|
|
16
|
+
`,E=y.default(g)`
|
|
17
17
|
font-weight: 600;
|
|
18
18
|
margin-bottom: 8px;
|
|
19
|
-
`,v=new
|
|
19
|
+
`,v=new x.VariableEditorHelper;exports.ChatUIV2=o=>{const{bodyText:u,footerText:x,headerMediaType:f,headerText:y,headerAssetLink:q,headerAssetName:b,quickReplybtn:O,ctaBtn:w,actionTypes:_,extras:P,showHeader:I,imagePreviewStyles:S,size:L,bodyVariableList:A,headerVariableList:H,buttons:M,limitedTimeOfferComponent:N,carouselCardIndex:R,isWhatsappCarousel:B,isPreview:Y}=o,U=v.format(n.replaceText(u),A),D=v.format(n.replaceText(y),H),{selectedCarouselIndex:F,isProductCarouselType:V,errorIndexes:k,isCarouselHovered:z}=l.useTemplateModalContext(),W={COPY_CODE:t.default,PHONE_NUMBER:s.default,URL:a.default,QUICK_REPLY:i.default};return e.jsxs(m.Container,Object.assign({isCarouselCard:null!=R&&R>-1,showBorder:null!=R&&R===F||V&&null!=R&&R>-1&&null!=F&&F>-1,hasError:null==k?void 0:k.includes(null!=R?R:-2),isWhatsappCarousel:B,isPreview:Y,showDashedBorder:V&&z&&(null!=F?F:-1)<0&&(null!=R?R:-1)>-1},{children:[!B&&e.jsx(C,{children:e.jsx(r.default,{color:"white",height:8,width:8})}),f===c.HEADER_TYPES.TEXT?e.jsx(E,{dangerouslySetInnerHTML:{__html:D}}):f!==c.HEADER_TYPES.NONE?e.jsx(T.MediaCard,{headerAssetLink:q,headerAssetName:b,mediaType:f,imagePreviewStyles:f===c.HEADER_TYPES.IMAGE?S:{}}):e.jsx(e.Fragment,{}),(null==N?void 0:N.dateTime)?e.jsx(j.LimitedTimeOffer,{text:N.text,dateTime:N.dateTime,code:N.code}):e.jsx(e.Fragment,{}),!!u&&e.jsx(e.Fragment,{children:e.jsx(g,{dangerouslySetInnerHTML:{__html:U},style:{flex:1}})}),e.jsxs(m.FooterWrapper,{children:[e.jsx(d.Tooltip,Object.assign({body:null!=x?x:"",placement:"top"},{children:e.jsx(m.FooterText,Object.assign({style:{flex:1}},{children:x}))})),e.jsx(m.TimeStamp,{children:"16:48"})]}),M&&M.length>0?M.map(((t,r)=>e.jsx(h.ChatBtn,{text:"COPY_CODE"===t.type?"Copy code":t.text,Icon:W[t.type],size:L},r))):_===c.ACTIONS_TYPES.QUICK_REPLY?e.jsx("div",{children:null==O?void 0:O.map(((t,r)=>e.jsx(h.ChatBtn,{text:t.text},r)))}):_===c.ACTIONS_TYPES.CTA_BTN?e.jsx("div",{children:null==w?void 0:w.map(((t,r)=>e.jsx(h.ChatBtn,{textTypography:I?p.Caption:p.BodySecondary,extraContent:P?t.extra:void 0,placeholder:t.placeholder,text:t.text,Icon:"phoneNumber"===t.type?s.default:a.default,size:L},r)))}):e.jsx(e.Fragment,{})]}))};
|
|
@@ -6,3 +6,4 @@ export declare class TemplateHelperUtils {
|
|
|
6
6
|
whatsappOnlyFillVariablesValueInBodyText(text: string, variableStore: templateVariable[], usePlaceholderName?: boolean): string;
|
|
7
7
|
parseJsonString(templateComps: string | WebPushTemplateComponent): WebPushTemplateComponent;
|
|
8
8
|
}
|
|
9
|
+
export declare const replaceText: (text?: string) => string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../constants/regexPatterns.js");exports.TemplateHelperUtils=class{fillVariablesValInBodyText(l,a){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const t=l.match(e.templateVariablePattern),i=l.split(e.templateVariablePattern);if(l&&(null==t?void 0:t.length)){return i.map(((e,l)=>{var n,o,v,s
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../constants/regexPatterns.js");exports.TemplateHelperUtils=class{fillVariablesValInBodyText(l,a){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const t=l.match(e.templateVariablePattern),i=l.split(e.templateVariablePattern);if(l&&(null==t?void 0:t.length)){return i.map(((e,l)=>{var n,o,v,p,s;const d=null===(n=null==t?void 0:t[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");return i.length-1===l?e:(null===(v=null===(o=null==a?void 0:a[l])||void 0===o?void 0:o.variableName)||void 0===v?void 0:v.trim())===d.trim()||(null===(s=null===(p=null==a?void 0:a[l])||void 0===p?void 0:p.variableVal)||void 0===s?void 0:s.trim())===d.trim()?a[l].editable?`${e}${r?"{{":""}${a[l].variableVal}${r?"}}":""}`:`${e}${r?"{{":""}${a[l].variableName}${r?"}}":""}`:e})).join("")}return l}getTemplateVariablesFromState(l){var a;return null===(a=l.match(e.globalVariablePattern))||void 0===a?void 0:a.map((e=>e.replace("{{","").replace("}}","")))}whatsappOnlyFillVariablesValueInBodyText(l,a){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const t=l.match(e.templateVariablePattern),i=l.split(e.templateVariablePattern);if(l&&(null==t?void 0:t.length)){return i.map(((e,l)=>{var n;const o=null===(n=null==t?void 0:t[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");if(i.length-1===l)return e;const v=a.findIndex((e=>e.variableName===o));if(v>-1){let l=a[v].variableVal;return r||(l=!a[v].variableVal&&a[v].variableName.startsWith("editableVariable")?a[v].variableName:null==l?void 0:l.replace("[[","").replace("]]","")),a[v].editable?`${e}${r?"{{":""}${l}${r?"}}":""}`:`${e}${r?"{{":""}${o}${r?"}}":""}`}return e})).join("")}return l}parseJsonString(e){let l;if("string"==typeof e)try{l=JSON.parse(e)}catch(e){console.error("Error parsing webpush component JSON:",e),l={}}else l=e;return l}},exports.replaceText=e=>null==e?void 0:e.replace(/</g,"<").replace(/>/g,">");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import o from"../../../assets/icons/halfRectangle.svg.js";import i from"../../../assets/icons/phone.svg.js";import s from"../../../assets/icons/RedirectToNew.svg.js";import{useMemo as a}from"react";import n from"styled-components";import{Tooltip as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import o from"../../../assets/icons/halfRectangle.svg.js";import i from"../../../assets/icons/phone.svg.js";import s from"../../../assets/icons/RedirectToNew.svg.js";import{useMemo as a}from"react";import n from"styled-components";import{replaceText as m}from"../utils/TemplateHelperUtils.js";import{Tooltip as p}from"../../tooltips/Tooltip.js";import{BodySecondary as l,Caption as d}from"../../TypographyStyle.js";import{COLORS as h,FONTS as c}from"../../../constants/Theme.js";import{WhatsAppFormatToHTML as f}from"../helpers/WhatsAppFormatToHTML.js";import{HEADER_TYPES as T,ACTIONS_TYPES as y}from"../models/TemplateMeta.js";import{ChatBtn as x}from"./ChatBtn.js";import{Container as g,FooterWrapper as j,FooterText as v,TimeStamp as w}from"./ChatUI.style.js";import{MediaCard as b}from"./MediaCard.js";import u from"./RenderTemplateWithVariable.js";const S=n.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
width: 8px;
|
|
4
4
|
height: 8px;
|
|
5
5
|
left: -7.7px;
|
|
6
6
|
top: -8px;
|
|
7
|
-
`,
|
|
7
|
+
`,N=n=>{const{bodyText:N,footerText:A,headerMediaType:M,headerText:C,headerAssetLink:L,headerAssetName:k,quickReplybtn:z,ctaBtn:B,actionTypes:E,textType:H,extras:I,showHeader:P,imagePreviewStyles:R,size:W,children:O,isPreview:_}=n,U=new f,q=a((()=>({color:h.content.primary,margin:12,fontSize:P?c.caption.fontSize:c.bodySecondary.fontSize,fontWeight:c.bodySecondary.fontWeight,maxWidth:"100%",whiteSpace:"pre-wrap",marginBottom:0,marginTop:8,wordBreak:"break-word"})),[]);return e(g,Object.assign({isPreview:_},{children:[t(S,{children:t(o,{color:"white",height:8,width:8})}),M===T.TEXT?t(u,{bold:!0,text:m(C)}):M!==T.NONE?t(b,{headerAssetLink:L,headerAssetName:k,mediaType:M,imagePreviewStyles:M===T.IMAGE?R:{}}):t(r,{}),!!N&&t(r,{children:t(r,O?{children:O}:{children:"html"===H?t("div",{className:"richTextEditor",style:q,dangerouslySetInnerHTML:{__html:U.convertToHTML(N)}}):t(l,{children:m(N)})})}),e(j,{children:[t(p,Object.assign({body:null!=A?A:"",placement:"top"},{children:t(v,Object.assign({style:{flex:1}},{children:A}))})),t(w,{children:"16:48"})]}),E===y.QUICK_REPLY?t("div",{children:null==z?void 0:z.map(((e,r)=>t(x,{text:e.text},r)))}):E===y.CTA_BTN?t("div",{children:null==B?void 0:B.map(((e,r)=>t(x,{textTypography:P?d:l,extraContent:I?e.extra:void 0,placeholder:e.placeholder,text:e.text,Icon:"phoneNumber"===e.type?i:s,size:W},r)))}):t(r,{})]}))};export{N as default};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../../assets/icons/copy-code-icon.svg.js";import i from"../../../assets/icons/halfRectangle.svg.js";import s from"../../../assets/icons/phone.svg.js";import l from"../../../assets/icons/qrb.svg.js";import a from"../../../assets/icons/RedirectToNew.svg.js";import n from"styled-components";import{useTemplateModalContext as
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../../assets/icons/copy-code-icon.svg.js";import i from"../../../assets/icons/halfRectangle.svg.js";import s from"../../../assets/icons/phone.svg.js";import l from"../../../assets/icons/qrb.svg.js";import a from"../../../assets/icons/RedirectToNew.svg.js";import n from"styled-components";import{useTemplateModalContext as m}from"../../template-context-mapper/context/templateModalContext.js";import{replaceText as p}from"../utils/TemplateHelperUtils.js";import{Tooltip as d}from"../../tooltips/Tooltip.js";import{Caption as h,BodySecondary as c}from"../../TypographyStyle.js";import{COLORS as f}from"../../../constants/Theme.js";import{VariableEditorHelper as x}from"../helpers/VariableEditorHelper.js";import{HEADER_TYPES as u,ACTIONS_TYPES as y}from"../models/TemplateMeta.js";import{ChatBtn as T}from"./ChatBtn.js";import{Container as g,FooterWrapper as C,FooterText as j,TimeStamp as v}from"./ChatUI.style.js";import{LimitedTimeOffer as w}from"./LimitedTimeOffer/LimitedTimeOffer.index.js";import{MediaCard as b}from"./MediaCard.js";const I=n.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
width: 8px;
|
|
4
4
|
height: 8px;
|
|
5
5
|
left: -7.7px;
|
|
6
6
|
top: -8px;
|
|
7
|
-
`,
|
|
7
|
+
`,O=n.div`
|
|
8
8
|
font-family: 'Inter';
|
|
9
9
|
font-style: normal;
|
|
10
10
|
font-weight: 400;
|
|
11
11
|
font-size: 14px;
|
|
12
12
|
line-height: 20px;
|
|
13
13
|
padding: 8px 12px 0px;
|
|
14
|
-
color: ${
|
|
14
|
+
color: ${f.content.primary};
|
|
15
15
|
word-wrap: break-word;
|
|
16
|
-
`,
|
|
16
|
+
`,E=n(O)`
|
|
17
17
|
font-weight: 600;
|
|
18
18
|
margin-bottom: 8px;
|
|
19
|
-
`,
|
|
19
|
+
`,L=new x,P=n=>{const{bodyText:f,footerText:x,headerMediaType:P,headerText:_,headerAssetLink:N,headerAssetName:M,quickReplybtn:H,ctaBtn:R,actionTypes:A,extras:B,showHeader:U,imagePreviewStyles:S,size:k,bodyVariableList:z,headerVariableList:Y,buttons:D,limitedTimeOfferComponent:V,carouselCardIndex:q,isWhatsappCarousel:K,isPreview:Q}=n,W=L.format(p(f),z),G=L.format(p(_),Y),{selectedCarouselIndex:X,isProductCarouselType:$,errorIndexes:F,isCarouselHovered:J}=m(),Z={COPY_CODE:r,PHONE_NUMBER:s,URL:a,QUICK_REPLY:l};return e(g,Object.assign({isCarouselCard:null!=q&&q>-1,showBorder:null!=q&&q===X||$&&null!=q&&q>-1&&null!=X&&X>-1,hasError:null==F?void 0:F.includes(null!=q?q:-2),isWhatsappCarousel:K,isPreview:Q,showDashedBorder:$&&J&&(null!=X?X:-1)<0&&(null!=q?q:-1)>-1},{children:[!K&&t(I,{children:t(i,{color:"white",height:8,width:8})}),P===u.TEXT?t(E,{dangerouslySetInnerHTML:{__html:G}}):P!==u.NONE?t(b,{headerAssetLink:N,headerAssetName:M,mediaType:P,imagePreviewStyles:P===u.IMAGE?S:{}}):t(o,{}),(null==V?void 0:V.dateTime)?t(w,{text:V.text,dateTime:V.dateTime,code:V.code}):t(o,{}),!!f&&t(o,{children:t(O,{dangerouslySetInnerHTML:{__html:W},style:{flex:1}})}),e(C,{children:[t(d,Object.assign({body:null!=x?x:"",placement:"top"},{children:t(j,Object.assign({style:{flex:1}},{children:x}))})),t(v,{children:"16:48"})]}),D&&D.length>0?D.map(((e,o)=>t(T,{text:"COPY_CODE"===e.type?"Copy code":e.text,Icon:Z[e.type],size:k},o))):A===y.QUICK_REPLY?t("div",{children:null==H?void 0:H.map(((e,o)=>t(T,{text:e.text},o)))}):A===y.CTA_BTN?t("div",{children:null==R?void 0:R.map(((e,o)=>t(T,{textTypography:U?h:c,extraContent:B?e.extra:void 0,placeholder:e.placeholder,text:e.text,Icon:"phoneNumber"===e.type?s:a,size:k},o)))}):t(o,{})]}))};export{P as ChatUIV2};
|
|
@@ -6,3 +6,4 @@ export declare class TemplateHelperUtils {
|
|
|
6
6
|
whatsappOnlyFillVariablesValueInBodyText(text: string, variableStore: templateVariable[], usePlaceholderName?: boolean): string;
|
|
7
7
|
parseJsonString(templateComps: string | WebPushTemplateComponent): WebPushTemplateComponent;
|
|
8
8
|
}
|
|
9
|
+
export declare const replaceText: (text?: string) => string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{templateVariablePattern as e,globalVariablePattern as l}from"../constants/regexPatterns.js";class a{fillVariablesValInBodyText(l,a){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const
|
|
1
|
+
import{templateVariablePattern as e,globalVariablePattern as l}from"../constants/regexPatterns.js";class a{fillVariablesValInBodyText(l,a){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const t=l.match(e),i=l.split(e);if(l&&(null==t?void 0:t.length)){return i.map(((e,l)=>{var n,o,v,d,s;const u=null===(n=null==t?void 0:t[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");return i.length-1===l?e:(null===(v=null===(o=null==a?void 0:a[l])||void 0===o?void 0:o.variableName)||void 0===v?void 0:v.trim())===u.trim()||(null===(s=null===(d=null==a?void 0:a[l])||void 0===d?void 0:d.variableVal)||void 0===s?void 0:s.trim())===u.trim()?a[l].editable?`${e}${r?"{{":""}${a[l].variableVal}${r?"}}":""}`:`${e}${r?"{{":""}${a[l].variableName}${r?"}}":""}`:e})).join("")}return l}getTemplateVariablesFromState(e){var a;return null===(a=e.match(l))||void 0===a?void 0:a.map((e=>e.replace("{{","").replace("}}","")))}whatsappOnlyFillVariablesValueInBodyText(l,a){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const t=l.match(e),i=l.split(e);if(l&&(null==t?void 0:t.length)){return i.map(((e,l)=>{var n;const o=null===(n=null==t?void 0:t[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");if(i.length-1===l)return e;const v=a.findIndex((e=>e.variableName===o));if(v>-1){let l=a[v].variableVal;return r||(l=!a[v].variableVal&&a[v].variableName.startsWith("editableVariable")?a[v].variableName:null==l?void 0:l.replace("[[","").replace("]]","")),a[v].editable?`${e}${r?"{{":""}${l}${r?"}}":""}`:`${e}${r?"{{":""}${o}${r?"}}":""}`}return e})).join("")}return l}parseJsonString(e){let l;if("string"==typeof e)try{l=JSON.parse(e)}catch(e){console.error("Error parsing webpush component JSON:",e),l={}}else l=e;return l}}const r=e=>null==e?void 0:e.replace(/</g,"<").replace(/>/g,">");export{a as TemplateHelperUtils,r as replaceText};
|