@bikdotai/bik-component-library 0.0.817 → 0.0.818

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),R=require("react"),I=require("../../template-context-mapper/context/templateModalContext.js"),H=require("../helpers/templateMiscHelper.js"),L=require("../helpers/VariableEditorHelper.js"),a=require("../models/TemplateMeta.js"),O=require("../WhatsApp/ChatBtn.js"),B=require("./RCSButtons.js"),T=require("./RCSMediaCard.js"),o=require("./RCSPreview.styled.js"),E=new L.VariableEditorHelper,Y=y=>{const{bodyText:p,titleText:c,headerMediaType:t,headerText:M,headerAssetLink:s,headerAssetName:C,imagePreviewStyles:x,size:h,bodyVariableList:j,headerVariableList:P,buttons:l,carouselCardIndex:r,isWhatsappCarousel:v,isPreview:A,titleVariableList:_,templateConfiguration:i}=y,b=E.format(p?.replace(/</g,"&lt;").replace(/>/g,"&gt;"),j),w=E.format(M?.replace(/</g,"&lt;").replace(/>/g,"&gt;"),P),D=E.format(c?.replace(/</g,"&lt;").replace(/>/g,"&gt;"),_),{selectedCarouselIndex:d,isProductCarouselType:S,errorIndexes:q,isCarouselHovered:N}=I.useTemplateModalContext(),g=R.useMemo(()=>H.isRichAndCarouselCards(i?.templateType),[i?.templateType]),n=R.useMemo(()=>i?.orientation=="HORIZONTAL",[i]);return e.jsxs(o.RCSPreviewContainer,{isCarouselCard:r!=null&&r>-1,showBorder:r!=null&&r===d||S&&r!=null&&r>-1&&d!=null&&d>-1,hasError:q?.includes(r??-2),isWhatsappCarousel:v,isPreview:A,showDashedBorder:S&&N&&(d??-1)<0&&(r??-1)>-1,needBorder:g,isHorizontalOrientation:n,children:[!n&&e.jsx(e.Fragment,{children:t===a.HEADER_TYPES.TEXT?e.jsx(o.HeaderTextContainer,{dangerouslySetInnerHTML:{__html:w}}):t!==a.HEADER_TYPES.NONE&&s&&t!==a.HEADER_TYPES.DOCUMENT?e.jsx(T.RCSMediaCard,{headerAssetLink:s,headerAssetName:C,mediaType:t,imagePreviewStyles:t===a.HEADER_TYPES.IMAGE?x:{}}):null}),e.jsxs("div",{style:{width:n?"50%":""},children:[e.jsxs("div",{className:g?"":"text--template",children:[!!c&&e.jsx(e.Fragment,{children:e.jsx(o.TitleTextContainer,{dangerouslySetInnerHTML:{__html:D}})}),!!p&&e.jsx(e.Fragment,{children:e.jsx(o.RcsHtmlContainer,{dangerouslySetInnerHTML:{__html:b},style:{paddingTop:c?0:12}})}),t===a.HEADER_TYPES.DOCUMENT?e.jsx(T.PdfMediaCard,{headerAssetLink:s,headerAssetName:C}):e.jsx(e.Fragment,{})]}),l&&l.length>0?H.isRichAndCarouselCards(i?.templateType)?e.jsx(e.Fragment,{children:l.map((u,m)=>e.jsx(O.ChatBtn,{text:u.text,size:h},m))}):e.jsx(o.RCSChatBtnContainer,{children:l.map((u,m)=>e.jsx(B.RCSButtons,{text:u.text,size:h},m))}):null]}),n&&t!==a.HEADER_TYPES.NONE&&s&&t!==a.HEADER_TYPES.DOCUMENT&&e.jsx(T.RCSMediaCard,{headerAssetLink:s,headerAssetName:C,mediaType:t,imagePreviewStyles:t===a.HEADER_TYPES.IMAGE?x:{},isHorizontal:n})]})};exports.RCSChatPreview=Y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),T=require("react"),L=require("../../template-context-mapper/context/templateModalContext.js"),y=require("../helpers/templateMiscHelper.js"),O=require("../helpers/VariableEditorHelper.js"),s=require("../models/TemplateMeta.js"),f=require("../WhatsApp/ChatBtn.js"),Y=require("./RCSButtons.js"),E=require("./RCSMediaCard.js"),o=require("./RCSPreview.styled.js"),p=new O.VariableEditorHelper,V=P=>{const{bodyText:x,titleText:c,headerMediaType:t,headerText:j,headerAssetLink:n,headerAssetName:C,imagePreviewStyles:h,size:S,bodyVariableList:v,headerVariableList:A,buttons:l,carouselCardIndex:r,isWhatsappCarousel:_,isPreview:b,titleVariableList:w,templateConfiguration:i}=P,D=p.format(x?.replace(/</g,"&lt;").replace(/>/g,"&gt;"),v),q=p.format(j?.replace(/</g,"&lt;").replace(/>/g,"&gt;"),A),B=p.format(c?.replace(/</g,"&lt;").replace(/>/g,"&gt;"),w),{selectedCarouselIndex:d,isProductCarouselType:H,errorIndexes:N,isCarouselHovered:I}=L.useTemplateModalContext(),M=T.useMemo(()=>y.isRichAndCarouselCards(i?.templateType),[i?.templateType]),a=T.useMemo(()=>i?.orientation=="HORIZONTAL",[i]),R=T.useMemo(()=>!a&&!!i?.isMediaAfterBody,[a,i]),g=t===s.HEADER_TYPES.TEXT?e.jsx(o.HeaderTextContainer,{dangerouslySetInnerHTML:{__html:q}}):t!==s.HEADER_TYPES.NONE&&n&&t!==s.HEADER_TYPES.DOCUMENT?e.jsx(E.RCSMediaCard,{headerAssetLink:n,headerAssetName:C,mediaType:t,imagePreviewStyles:t===s.HEADER_TYPES.IMAGE?h:{}}):null;return e.jsxs(o.RCSPreviewContainer,{isCarouselCard:r!=null&&r>-1,showBorder:r!=null&&r===d||H&&r!=null&&r>-1&&d!=null&&d>-1,hasError:N?.includes(r??-2),isWhatsappCarousel:_,isPreview:b,showDashedBorder:H&&I&&(d??-1)<0&&(r??-1)>-1,needBorder:M,isHorizontalOrientation:a,children:[!a&&!R&&g,e.jsxs("div",{style:{width:a?"50%":""},children:[e.jsxs("div",{className:M?"":"text--template",children:[!!c&&e.jsx(e.Fragment,{children:e.jsx(o.TitleTextContainer,{dangerouslySetInnerHTML:{__html:B}})}),!!x&&e.jsx(e.Fragment,{children:e.jsx(o.RcsHtmlContainer,{dangerouslySetInnerHTML:{__html:D},style:{paddingTop:c?0:12}})}),t===s.HEADER_TYPES.DOCUMENT?e.jsx(E.PdfMediaCard,{headerAssetLink:n,headerAssetName:C}):e.jsx(e.Fragment,{})]}),!a&&R&&g,l&&l.length>0?y.isRichAndCarouselCards(i?.templateType)?e.jsx(e.Fragment,{children:l.map((u,m)=>e.jsx(f.ChatBtn,{text:u.text,size:S},m))}):e.jsx(o.RCSChatBtnContainer,{children:l.map((u,m)=>e.jsx(Y.RCSButtons,{text:u.text,size:S},m))}):null]}),a&&t!==s.HEADER_TYPES.NONE&&n&&t!==s.HEADER_TYPES.DOCUMENT&&e.jsx(E.RCSMediaCard,{headerAssetLink:n,headerAssetName:C,mediaType:t,imagePreviewStyles:t===s.HEADER_TYPES.IMAGE?h:{},isHorizontal:a})]})};exports.RCSChatPreview=V;
2
2
  //# sourceMappingURL=RCSChatPreview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RCSChatPreview.js","sources":["../../../../../src/components/template-preview/RCS/RCSChatPreview.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useTemplateModalContext } from '@src/components/template-context-mapper/context/templateModalContext';\nimport { isRichAndCarouselCards } from '../helpers/templateMiscHelper';\nimport { VariableEditorHelper } from '../helpers/VariableEditorHelper';\nimport { RCS_TEMPLATE_TYPE, RCSPreviewPropsV2 } from '../models/RCSTemplate';\nimport { HEADER_TYPES } from '../models/TemplateMeta';\nimport { ChatBtn } from '../WhatsApp/ChatBtn';\nimport { RCSButtons } from './RCSButtons';\nimport { PdfMediaCard, RCSMediaCard } from './RCSMediaCard';\nimport {\n\tHeaderTextContainer,\n\tRCSChatBtnContainer,\n\tRcsHtmlContainer,\n\tRCSPreviewContainer,\n\tTitleTextContainer,\n} from './RCSPreview.styled';\n\nconst variableEditorHelper = new VariableEditorHelper();\n\nexport const RCSChatPreview = (props: RCSPreviewPropsV2) => {\n\tconst {\n\t\tbodyText,\n\t\ttitleText,\n\t\theaderMediaType,\n\t\theaderText,\n\t\theaderAssetLink,\n\t\theaderAssetName,\n\t\timagePreviewStyles,\n\t\tsize,\n\t\tbodyVariableList,\n\t\theaderVariableList,\n\t\tbuttons,\n\t\tcarouselCardIndex,\n\t\tisWhatsappCarousel,\n\t\tisPreview,\n\t\ttitleVariableList,\n\t\ttemplateConfiguration,\n\t} = props;\n\n\tconst bodyHTML = variableEditorHelper.format(\n\t\tbodyText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\tbodyVariableList,\n\t);\n\tconst headerHtml = variableEditorHelper.format(\n\t\theaderText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\theaderVariableList,\n\t);\n\tconst titleHtml = variableEditorHelper.format(\n\t\ttitleText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\ttitleVariableList,\n\t);\n\tconst {\n\t\tselectedCarouselIndex,\n\t\tisProductCarouselType,\n\t\terrorIndexes,\n\t\tisCarouselHovered,\n\t} = useTemplateModalContext();\n\n\tconst isRichCardTypeTemplate = useMemo(() => {\n\t\treturn isRichAndCarouselCards(\n\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t);\n\t}, [templateConfiguration?.templateType]);\n\n\tconst isHorizontalOrientation = useMemo(() => {\n\t\treturn templateConfiguration?.orientation == 'HORIZONTAL';\n\t}, [templateConfiguration]);\n\n\treturn (\n\t\t<RCSPreviewContainer\n\t\t\tisCarouselCard={carouselCardIndex != undefined && carouselCardIndex > -1}\n\t\t\tshowBorder={\n\t\t\t\t(carouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex === selectedCarouselIndex) ||\n\t\t\t\t(isProductCarouselType &&\n\t\t\t\t\tcarouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex > -1 &&\n\t\t\t\t\tselectedCarouselIndex != undefined &&\n\t\t\t\t\tselectedCarouselIndex > -1)\n\t\t\t}\n\t\t\thasError={errorIndexes?.includes(carouselCardIndex ?? -2)}\n\t\t\tisWhatsappCarousel={isWhatsappCarousel}\n\t\t\tisPreview={isPreview}\n\t\t\tshowDashedBorder={\n\t\t\t\tisProductCarouselType &&\n\t\t\t\tisCarouselHovered &&\n\t\t\t\t(selectedCarouselIndex ?? -1) < 0 &&\n\t\t\t\t(carouselCardIndex ?? -1) > -1\n\t\t\t}\n\t\t\tneedBorder={isRichCardTypeTemplate}\n\t\t\tisHorizontalOrientation={isHorizontalOrientation}\n\t\t>\n\t\t\t{!isHorizontalOrientation && (\n\t\t\t\t<>\n\t\t\t\t\t{headerMediaType === HEADER_TYPES.TEXT ? (\n\t\t\t\t\t\t<HeaderTextContainer\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={{ __html: headerHtml }}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : headerMediaType !== HEADER_TYPES.NONE &&\n\t\t\t\t\t headerAssetLink &&\n\t\t\t\t\t headerMediaType !== HEADER_TYPES.DOCUMENT ? (\n\t\t\t\t\t\t<RCSMediaCard\n\t\t\t\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\t\t\t\tmediaType={headerMediaType}\n\t\t\t\t\t\t\timagePreviewStyles={\n\t\t\t\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t<div style={{ width: isHorizontalOrientation ? '50%' : '' }}>\n\t\t\t\t<div className={isRichCardTypeTemplate ? '' : 'text--template'}>\n\t\t\t\t\t{!!titleText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<TitleTextContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: titleHtml,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{!!bodyText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RcsHtmlContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: bodyHTML,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tstyle={{ paddingTop: titleText ? 0 : 12 }}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t\t{headerMediaType === HEADER_TYPES.DOCUMENT ? (\n\t\t\t\t\t\t<PdfMediaCard {...{ headerAssetLink, headerAssetName }} />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<></>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t{buttons && buttons.length > 0 ? (\n\t\t\t\t\tisRichAndCarouselCards(\n\t\t\t\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t\t\t\t) ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<ChatBtn key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<RCSChatBtnContainer>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<RCSButtons key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</RCSChatBtnContainer>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{isHorizontalOrientation &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.NONE &&\n\t\t\t\theaderAssetLink &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.DOCUMENT && (\n\t\t\t\t\t<RCSMediaCard\n\t\t\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\t\t\tmediaType={headerMediaType}\n\t\t\t\t\t\timagePreviewStyles={\n\t\t\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisHorizontal={isHorizontalOrientation}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</RCSPreviewContainer>\n\t);\n};\n"],"names":["variableEditorHelper","VariableEditorHelper","RCSChatPreview","props","bodyText","titleText","headerMediaType","headerText","headerAssetLink","headerAssetName","imagePreviewStyles","size","bodyVariableList","headerVariableList","buttons","carouselCardIndex","isWhatsappCarousel","isPreview","titleVariableList","templateConfiguration","bodyHTML","headerHtml","titleHtml","selectedCarouselIndex","isProductCarouselType","errorIndexes","isCarouselHovered","useTemplateModalContext","isRichCardTypeTemplate","useMemo","isRichAndCarouselCards","isHorizontalOrientation","jsxs","RCSPreviewContainer","jsx","Fragment","HEADER_TYPES","HeaderTextContainer","RCSMediaCard","TitleTextContainer","RcsHtmlContainer","PdfMediaCard","button","i","ChatBtn","RCSChatBtnContainer","RCSButtons"],"mappings":"4dAiBMA,EAAuB,IAAIC,EAAAA,qBAEpBC,EAAkBC,GAA6B,CAC3D,KAAM,CACL,SAAAC,EACA,UAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,mBAAAC,EACA,KAAAC,EACA,iBAAAC,EACA,mBAAAC,EACA,QAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,UAAAC,EACA,kBAAAC,EACA,sBAAAC,CAAA,EACGhB,EAEEiB,EAAWpB,EAAqB,OACrCI,GAAU,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM,EACpDQ,CAAA,EAEKS,EAAarB,EAAqB,OACvCO,GAAY,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM,EACtDM,CAAA,EAEKS,EAAYtB,EAAqB,OACtCK,GAAW,QAAQ,KAAM,MAAM,EAAE,QAAQ,KAAM,MAAM,EACrDa,CAAA,EAEK,CACL,sBAAAK,EACA,sBAAAC,EACA,aAAAC,EACA,kBAAAC,CAAA,EACGC,0BAAA,EAEEC,EAAyBC,EAAAA,QAAQ,IAC/BC,EAAAA,uBACNX,GAAuB,YAAA,EAEtB,CAACA,GAAuB,YAAY,CAAC,EAElCY,EAA0BF,EAAAA,QAAQ,IAChCV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EAEAC,IAAoB8B,EAAAA,aAAa,SACjCF,EAAAA,IAACO,EAAAA,aAAA,CAAmB,gBAAAjC,EAAiB,gBAAAC,CAAgB,CAAG,EAExDyB,EAAAA,IAAAC,EAAAA,SAAA,CAAA,CAAE,CAAA,EAEJ,EAECrB,GAAWA,EAAQ,OAAS,EAC5BgB,EAAAA,uBACCX,GAAuB,YAAA,EAEvBe,EAAAA,IAAAC,EAAAA,SAAA,CACE,SAAArB,EAAQ,IAAI,CAAC4B,EAAQC,IACrBT,EAAAA,IAACU,EAAAA,QAAA,CAAgB,KAAMF,EAAO,KAAM,KAAA/B,CAAA,EAAtBgC,CAAkC,CAChD,CAAA,CACF,EAEAT,EAAAA,IAACW,EAAAA,oBAAA,CACC,SAAA/B,EAAQ,IAAI,CAAC4B,EAAQC,IACrBT,EAAAA,IAACY,EAAAA,WAAA,CAAmB,KAAMJ,EAAO,KAAM,KAAA/B,CAAA,EAAtBgC,CAAkC,CACnD,EACF,EAEE,IAAA,EACL,EACCZ,GACAzB,IAAoB8B,EAAAA,aAAa,MACjC5B,GACAF,IAAoB8B,EAAAA,aAAa,UAChCF,EAAAA,IAACI,EAAAA,aAAA,CACA,gBAAA9B,EACA,gBAAAC,EACA,UAAWH,EACX,mBACCA,IAAoB8B,EAAAA,aAAa,MAAQ1B,EAAqB,CAAA,EAE/D,aAAcqB,CAAA,CAAA,CACf,CAAA,CAAA,CAIL"}
1
+ {"version":3,"file":"RCSChatPreview.js","sources":["../../../../../src/components/template-preview/RCS/RCSChatPreview.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useTemplateModalContext } from '@src/components/template-context-mapper/context/templateModalContext';\nimport { isRichAndCarouselCards } from '../helpers/templateMiscHelper';\nimport { VariableEditorHelper } from '../helpers/VariableEditorHelper';\nimport { RCS_TEMPLATE_TYPE, RCSPreviewPropsV2 } from '../models/RCSTemplate';\nimport { HEADER_TYPES } from '../models/TemplateMeta';\nimport { ChatBtn } from '../WhatsApp/ChatBtn';\nimport { RCSButtons } from './RCSButtons';\nimport { PdfMediaCard, RCSMediaCard } from './RCSMediaCard';\nimport {\n\tHeaderTextContainer,\n\tRCSChatBtnContainer,\n\tRcsHtmlContainer,\n\tRCSPreviewContainer,\n\tTitleTextContainer,\n} from './RCSPreview.styled';\n\nconst variableEditorHelper = new VariableEditorHelper();\n\nexport const RCSChatPreview = (props: RCSPreviewPropsV2) => {\n\tconst {\n\t\tbodyText,\n\t\ttitleText,\n\t\theaderMediaType,\n\t\theaderText,\n\t\theaderAssetLink,\n\t\theaderAssetName,\n\t\timagePreviewStyles,\n\t\tsize,\n\t\tbodyVariableList,\n\t\theaderVariableList,\n\t\tbuttons,\n\t\tcarouselCardIndex,\n\t\tisWhatsappCarousel,\n\t\tisPreview,\n\t\ttitleVariableList,\n\t\ttemplateConfiguration,\n\t} = props;\n\n\tconst bodyHTML = variableEditorHelper.format(\n\t\tbodyText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\tbodyVariableList,\n\t);\n\tconst headerHtml = variableEditorHelper.format(\n\t\theaderText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\theaderVariableList,\n\t);\n\tconst titleHtml = variableEditorHelper.format(\n\t\ttitleText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\ttitleVariableList,\n\t);\n\tconst {\n\t\tselectedCarouselIndex,\n\t\tisProductCarouselType,\n\t\terrorIndexes,\n\t\tisCarouselHovered,\n\t} = useTemplateModalContext();\n\n\tconst isRichCardTypeTemplate = useMemo(() => {\n\t\treturn isRichAndCarouselCards(\n\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t);\n\t}, [templateConfiguration?.templateType]);\n\n\tconst isHorizontalOrientation = useMemo(() => {\n\t\treturn templateConfiguration?.orientation == 'HORIZONTAL';\n\t}, [templateConfiguration]);\n\n\t// For VERTICAL templates whose original `components[]` order is\n\t// body-then-media, render the media after the body instead of the default\n\t// media-first layout. Defaults to false → unchanged behaviour.\n\tconst isMediaAfterBody = useMemo(() => {\n\t\treturn (\n\t\t\t!isHorizontalOrientation && !!templateConfiguration?.isMediaAfterBody\n\t\t);\n\t}, [isHorizontalOrientation, templateConfiguration]);\n\n\tconst verticalMediaHeader =\n\t\theaderMediaType === HEADER_TYPES.TEXT ? (\n\t\t\t<HeaderTextContainer dangerouslySetInnerHTML={{ __html: headerHtml }} />\n\t\t) : headerMediaType !== HEADER_TYPES.NONE &&\n\t\t headerAssetLink &&\n\t\t headerMediaType !== HEADER_TYPES.DOCUMENT ? (\n\t\t\t<RCSMediaCard\n\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\tmediaType={headerMediaType}\n\t\t\t\timagePreviewStyles={\n\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t}\n\t\t\t/>\n\t\t) : null;\n\n\treturn (\n\t\t<RCSPreviewContainer\n\t\t\tisCarouselCard={carouselCardIndex != undefined && carouselCardIndex > -1}\n\t\t\tshowBorder={\n\t\t\t\t(carouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex === selectedCarouselIndex) ||\n\t\t\t\t(isProductCarouselType &&\n\t\t\t\t\tcarouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex > -1 &&\n\t\t\t\t\tselectedCarouselIndex != undefined &&\n\t\t\t\t\tselectedCarouselIndex > -1)\n\t\t\t}\n\t\t\thasError={errorIndexes?.includes(carouselCardIndex ?? -2)}\n\t\t\tisWhatsappCarousel={isWhatsappCarousel}\n\t\t\tisPreview={isPreview}\n\t\t\tshowDashedBorder={\n\t\t\t\tisProductCarouselType &&\n\t\t\t\tisCarouselHovered &&\n\t\t\t\t(selectedCarouselIndex ?? -1) < 0 &&\n\t\t\t\t(carouselCardIndex ?? -1) > -1\n\t\t\t}\n\t\t\tneedBorder={isRichCardTypeTemplate}\n\t\t\tisHorizontalOrientation={isHorizontalOrientation}\n\t\t>\n\t\t\t{!isHorizontalOrientation && !isMediaAfterBody && verticalMediaHeader}\n\t\t\t<div style={{ width: isHorizontalOrientation ? '50%' : '' }}>\n\t\t\t\t<div className={isRichCardTypeTemplate ? '' : 'text--template'}>\n\t\t\t\t\t{!!titleText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<TitleTextContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: titleHtml,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{!!bodyText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RcsHtmlContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: bodyHTML,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tstyle={{ paddingTop: titleText ? 0 : 12 }}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t\t{headerMediaType === HEADER_TYPES.DOCUMENT ? (\n\t\t\t\t\t\t<PdfMediaCard {...{ headerAssetLink, headerAssetName }} />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<></>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t{!isHorizontalOrientation && isMediaAfterBody && verticalMediaHeader}\n\n\t\t\t\t{buttons && buttons.length > 0 ? (\n\t\t\t\t\tisRichAndCarouselCards(\n\t\t\t\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t\t\t\t) ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<ChatBtn key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<RCSChatBtnContainer>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<RCSButtons key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</RCSChatBtnContainer>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{isHorizontalOrientation &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.NONE &&\n\t\t\t\theaderAssetLink &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.DOCUMENT && (\n\t\t\t\t\t<RCSMediaCard\n\t\t\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\t\t\tmediaType={headerMediaType}\n\t\t\t\t\t\timagePreviewStyles={\n\t\t\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisHorizontal={isHorizontalOrientation}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</RCSPreviewContainer>\n\t);\n};\n"],"names":["variableEditorHelper","VariableEditorHelper","RCSChatPreview","props","bodyText","titleText","headerMediaType","headerText","headerAssetLink","headerAssetName","imagePreviewStyles","size","bodyVariableList","headerVariableList","buttons","carouselCardIndex","isWhatsappCarousel","isPreview","titleVariableList","templateConfiguration","bodyHTML","headerHtml","titleHtml","selectedCarouselIndex","isProductCarouselType","errorIndexes","isCarouselHovered","useTemplateModalContext","isRichCardTypeTemplate","useMemo","isRichAndCarouselCards","isHorizontalOrientation","isMediaAfterBody","verticalMediaHeader","HEADER_TYPES","jsx","HeaderTextContainer","RCSMediaCard","jsxs","RCSPreviewContainer","Fragment","TitleTextContainer","RcsHtmlContainer","PdfMediaCard","button","i","ChatBtn","RCSChatBtnContainer","RCSButtons"],"mappings":"4dAiBMA,EAAuB,IAAIC,EAAAA,qBAEpBC,EAAkBC,GAA6B,CAC3D,KAAM,CACL,SAAAC,EACA,UAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,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,IAAI,CAAC8B,EAAQC,IACrBV,EAAAA,IAACa,EAAAA,WAAA,CAAmB,KAAMJ,EAAO,KAAM,KAAAjC,CAAA,EAAtBkC,CAAkC,CACnD,EACF,EAEE,IAAA,EACL,EACCd,GACAzB,IAAoB4B,EAAAA,aAAa,MACjC1B,GACAF,IAAoB4B,EAAAA,aAAa,UAChCC,EAAAA,IAACE,EAAAA,aAAA,CACA,gBAAA7B,EACA,gBAAAC,EACA,UAAWH,EACX,mBACCA,IAAoB4B,EAAAA,aAAa,MAAQxB,EAAqB,CAAA,EAE/D,aAAcqB,CAAA,CAAA,CACf,CAAA,CAAA,CAIL"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("date-fns"),b=require("../../../constants/Theme.js"),h=require("../constants/regexPatterns.js"),r=require("../constants/TemplateConstants.js"),d=require("../models/TemplateMeta.js"),u=require("../models/WhatsAppTemplate.js"),A=require("../utils/TemplateHelperUtils.js");class P{parseDataFromHeaderComponent(t,o,n){const e={headerType:d.HEADER_TYPES.NONE,headerVariables:[]},a=t?.components?.find(l=>l.type==="HEADER");if(a){e.headerType=a.format,e.headerText=a.text,e.headerAssetLink=a.example?.header_handle?.[0];const l=a.example?.header_text?.[0],c=t.mapping?.header?.[0],i=c;if(c){const s=c?.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),p=/\(\(/.test(c),E=n===u.POD.CHATBOT&&i&&i?.startsWith("((")&&i?.endsWith("))"),m={idx:0,variableVal:o||E?l:i,editable:p,editableDefaultValues:p?void 0:l,variableName:s};e.headerVariables=[m],a.example?.header_text?.length&&(e.headerText=e.headerText?.replace("{{1}}",`{{${s}}}`))}}return e}validateState(t){const o=new RegExp("\\p{Extended_Pictographic}","u");let n="valid";const e={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},a=new A.TemplateHelperUtils;let l=!1;const c=i=>{document.getElementById(i)?.scrollIntoView({behavior:"smooth",block:"nearest"})};if(t.meta?.name?t.meta.name?.trim().length>r.NAME_LEN_LIMIT?(e.meta.name=r.NAME_LEN_ERROR,n="invalid"):h.specialCharPattern.test(t.meta.name?.trim())&&(e.meta.name=r.NO_SPECIAL_CHAR,n="invalid"):(e.meta.name=r.REQUIRED_FIELD,n="invalid"),e.meta.name&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.name),l=!0),t.headerType===d.HEADER_TYPES.TEXT){const i=t.headerText?.trim()??"";if(!i)e.header=r.REQUIRED_FIELD,n="invalid";else if(i.length>r.HEADER_TEXT_LEN_LIMIT)e.header=r.HEADER_LEN_ERROR,n="invalid";else{const s=a.getTemplateVariablesFromState(i);s&&s.length>1&&(e.header=r.ONE_VAR_ALLOWED,n="invalid")}}else t.headerType===d.HEADER_TYPES.DOCUMENT||t.headerType===d.HEADER_TYPES.IMAGE||(t.headerType,d.HEADER_TYPES.VIDEO);if((t.headerType===d.HEADER_TYPES.DOCUMENT||t.headerType===d.HEADER_TYPES.IMAGE||t.headerType===d.HEADER_TYPES.VIDEO)&&(t.headerAssetLink||(e.header=r.HEADER_ASSET_LINK_ERROR,n="invalid")),e.header&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.header),l=!0),t.bodyText?t.bodyTextRaw&&t.bodyTextRaw?.trim().length>r.BODY_TEXT_LEN_LIMIT&&(e.body=r.BODY_LEN_ERROR,n="invalid"):(e.body=r.REQUIRED_FIELD,n="invalid"),e.body&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.body),l=!0),t.footerText&&t.footerText.length>r.HEADER_TEXT_LEN_LIMIT&&(e.footer=r.HEADER_LEN_ERROR,n="invalid"),e?.footer&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.footer),l=!0),t.actionsType===d.ACTIONS_TYPES.CTA_BTN){if(t.ctaBtn?.phoneNumber?.isChecked){const i=t.ctaBtn.phoneNumber.btnText?.trim(),s=t.ctaBtn.phoneNumber.phoneNumber;e.ctaBtn&&!i?(e.ctaBtn.phoneNumber.btnText=r.REQUIRED_FIELD,n="invalid"):e.ctaBtn&&i&&i.length>r.QUICK_REPLY_BTN_TEXT_LIMIT?(e.ctaBtn.phoneNumber.btnText=r.QUICK_REPLY_LEN_ERROR,n="invalid"):e.ctaBtn&&i&&o.test(i)&&(e.ctaBtn.phoneNumber.btnText=r.BUTTON_EMOJI_ERROR,n="invalid"),e.ctaBtn&&!s?(e.ctaBtn.phoneNumber.link=r.REQUIRED_FIELD,n="invalid"):e.ctaBtn&&s&&s.length<10&&(e.ctaBtn.phoneNumber.link=r.VALID_PHONE_NUMBER,n="invalid")}if(t.ctaBtn?.websiteLinkBtn?.isChecked){const i=t.ctaBtn.websiteLinkBtn.btnText?.trim(),s=t.ctaBtn.websiteLinkBtn.linkOpens?.trim(),p=t.ctaBtn.websiteLinkBtn.placeholder?.trim();e.ctaBtn&&!i?(e.ctaBtn.websiteLink.btnText=r.REQUIRED_FIELD,n="invalid"):e.ctaBtn&&i&&i.length>r.QUICK_REPLY_BTN_TEXT_LIMIT?(e.ctaBtn.websiteLink.btnText=r.QUICK_REPLY_LEN_ERROR,n="invalid"):e.ctaBtn&&i&&o.test(i)&&(e.ctaBtn.websiteLink.btnText=r.BUTTON_EMOJI_ERROR,n="invalid"),e.ctaBtn&&!s&&!p&&(e.ctaBtn.websiteLink.link=r.REQUIRED_FIELD,n="invalid")}}else if(t.actionsType===d.ACTIONS_TYPES.QUICK_REPLY){const i=["","",""];t.quickReply.forEach((s,p)=>{const E=s.text?.trim();if(!E)i[p]=r.REQUIRED_FIELD,n="invalid";else if(E.length>r.QUICK_REPLY_NAME_LEN_LIMIT)i[p]=r.QUICK_REPLY_LEN_ERROR,n="invalid";else if(o.test(E))i[p]=r.BUTTON_EMOJI_ERROR,n="invalid";else{const m=[...t.quickReply];m.splice(p,1),m.find(_=>_.text===E)&&(i[p]=r.QUICK_REPLY_NAME_ERROR,n="invalid")}}),e.quickReply=i}if(t.actionsType===d.ACTIONS_TYPES.CTA_BTN||t.actionsType===d.ACTIONS_TYPES.QUICK_REPLY){const i=e.quickReply?.reduce((s,p)=>s||!!p,!1);(e?.ctaBtn?.websiteLink?.link||e.ctaBtn?.websiteLink?.btnText||e.ctaBtn?.phoneNumber?.link||e.ctaBtn?.phoneNumber?.btnText||i)&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.actionButtons),l=!0)}return{status:n,errors:e}}parseBodyComponent(t,o=!1,n,e){const a=[];let l="";const c=t.components?.find(i=>i.type==="BODY");return c&&(c.example?.body_text?.[0]?.forEach((i,s)=>{let p=t.mapping?.body?.[s];const E=p,m=p&&/\(\(/.test(p),T=p?.match(h.placeHolderNamePattern);T?.[2]&&(p=T?.[2]);const _=e===u.POD.CHATBOT&&E&&E?.startsWith("((")&&E?.endsWith("))");a.push({idx:s,variableVal:n||_?i:E,editable:!!m,editableDefaultValues:m?void 0:i,variableName:p??""})}),t.htmlContentUrl?l=t.htmlContentUrl:l=c.text?.split(/\{\{[0-9]+\}\}/).length?c.text?.split(/\{\{[0-9]+\}\}/).map((i,s)=>{if(a?.[s]){const p=a[s].variableName;return o?`${i}{{${p}}}`:`${i} <span> </span><span style="color: ${b.COLORS.content.brand}; text-decoration: underline;">{{${p}}}</span><span> </span>`}return i}).join(""):""),{bodyVariable:a,bodyText:l}}parseTitleComponent(t,o=!1,n){const e=[];let a="";const l=t.components?.find(c=>c.type==="TITLE");return l&&(l.example?.title_text?.[0]?.forEach((c,i)=>{let s=t.mapping?.body?.[i];const p=s,E=s&&/\(\(/.test(s),m=s?.match(h.placeHolderNamePattern);m?.[2]&&(s=m?.[2]),e.push({idx:i,variableVal:n?c:p,editable:!!E,editableDefaultValues:E?void 0:c,variableName:s??""})}),t.htmlContentUrl?a=t.htmlContentUrl:a=l.text?.split(/\{\{[0-9]+\}\}/).length?l.text?.split(/\{\{[0-9]+\}\}/).map((c,i)=>{if(e?.[i]){const s=e[i].variableName;return o?`${c}{{${s}}}`:`${c} <span> </span><span style="color: ${b.COLORS.content.brand}; text-decoration: underline;">{{${s}}}</span><span> </span>`}return c}).join(""):""),{titleText:a,titleVariables:e}}parseFooterComponent(t){return t.components?.find(n=>n.type==="FOOTER")?.text}parseButtonComponent(t){const o={actionsType:d.ACTIONS_TYPES.NONE,quickReply:[],ctaBtn:{phoneNumber:void 0,websiteLinkBtn:void 0},allButtons:[]},n=t.components?.find(e=>e.type==="BUTTONS");if(n&&n?.buttons?.length){const e=n?.buttons?.[0].type==="QUICK_REPLY"?d.ACTIONS_TYPES.QUICK_REPLY:d.ACTIONS_TYPES.CTA_BTN;if(o.actionsType=e,e===d.ACTIONS_TYPES.QUICK_REPLY){const a=n?.buttons?.map(l=>l)??[];o.quickReply=a}else e===d.ACTIONS_TYPES.CTA_BTN&&n?.buttons?.forEach(a=>{if(a.phone_number&&(o.ctaBtn.phoneNumber={isChecked:!0,btnText:a.text,phoneNumber:a.phone_number}),a.url){const l=t?.mapping?.buttons?.[0]??void 0;let c=!1;l&&h.editableVarPattern.test(l)&&(c=!0),o.ctaBtn.websiteLinkBtn={isChecked:!0,btnText:a.text,linkOpens:c?a.example?.[0]:a.url,placeholder:c?void 0:l}}});o.allButtons=n.buttons?.map(a=>a.type==="COPY_CODE"?{...a,placeholder:Array.isArray(a.example)?a.example[0]:a?.example||""}:a)}return o}parseLimitedTimeOfferComponent(t,o){const n={text:"",dateTime:"",code:""};return t.components.forEach(e=>{if(e.type==="limited_time_offer"){n.text=e.limited_time_offer?.text??"";const a=e.example?.limited_time_offer;a&&a.startsWith("{{")&&a.endsWith("}}")?n.dateTime=a:n.dateTime=D.format(a?new Date(a):new Date,"MMM dd")}o.forEach(a=>{a.type==="COPY_CODE"&&(n.code=a.placeholder??"")})}),n}parseCallPermissionComponent(t){const o=t.components?.find(n=>n.type==="CALL_PERMISSION_REQUEST");return{showCallPermissionCard:!!o,callPermissionText:o?.text}}async parseUITemplateFromDBFormat(t){const{dbFormattedTemplate:o,isDuplicate:n,isV2:e=!1,showSampleValues:a,pod:l}=t,{headerType:c,headerAssetLink:i,headerAssetName:s,headerText:p,headerVariables:E}=await this.parseDataFromHeaderComponent(o,void 0,l),{bodyText:m,bodyVariable:T}=await this.parseBodyComponent(o,e,a,l),{titleText:_,titleVariables:C}=await this.parseTitleComponent(o,e,a),{actionsType:y,quickReply:N,ctaBtn:x,allButtons:R}=await this.parseButtonComponent(o),I=this.parseLimitedTimeOfferComponent(o,R),{showCallPermissionCard:L,callPermissionText:O}=this.parseCallPermissionComponent(o),f={quickReply:N,ctaBtn:x,allButtons:R,meta:{name:n?`${o.label} Copy`:o.label,category:o.category?.toUpperCase(),subCategory:o.templateCategory,language:o.language,templateId:o.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:y,footerText:this.parseFooterComponent(o),bodyVariables:T,bodyText:m,headerType:c,headerAssetLink:i,headerAssetName:s,headerText:p,headerVariables:E,alreadyAsADraft:o.isDraft,mode:"edit",initialLoading:!1,limitedTimeOfferComponent:I,titleText:_,titleVariables:C,showCallPermissionCard:L,callPermissionText:O},{errors:B}=this.validateState(f);return f.error=B,f}parseTemplateConfiguration(t){let o;const n=t?.content||{};if(typeof n=="string")try{o=JSON.parse(n)}catch(e){console.error("Error parsing rcsTemplate component JSON:",e),o={orientation:"VERTICAL"}}else o=n;return{...o,templateType:t?.templateType}}}exports.TemplateCreatorHelper=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("date-fns"),u=require("../../../constants/Theme.js"),h=require("../constants/regexPatterns.js"),r=require("../constants/TemplateConstants.js"),d=require("../models/TemplateMeta.js"),b=require("../models/WhatsAppTemplate.js"),D=require("../utils/TemplateHelperUtils.js");class P{parseDataFromHeaderComponent(t,o,n){const e={headerType:d.HEADER_TYPES.NONE,headerVariables:[]},a=t?.components?.find(l=>l.type==="HEADER");if(a){e.headerType=a.format,e.headerText=a.text,e.headerAssetLink=a.example?.header_handle?.[0];const l=a.example?.header_text?.[0],c=t.mapping?.header?.[0],i=c;if(c){const s=c?.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),p=/\(\(/.test(c),E=n===b.POD.CHATBOT&&i&&i?.startsWith("((")&&i?.endsWith("))"),m={idx:0,variableVal:o||E?l:i,editable:p,editableDefaultValues:p?void 0:l,variableName:s};e.headerVariables=[m],a.example?.header_text?.length&&(e.headerText=e.headerText?.replace("{{1}}",`{{${s}}}`))}}return e}validateState(t){const o=new RegExp("\\p{Extended_Pictographic}","u");let n="valid";const e={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},a=new D.TemplateHelperUtils;let l=!1;const c=i=>{document.getElementById(i)?.scrollIntoView({behavior:"smooth",block:"nearest"})};if(t.meta?.name?t.meta.name?.trim().length>r.NAME_LEN_LIMIT?(e.meta.name=r.NAME_LEN_ERROR,n="invalid"):h.specialCharPattern.test(t.meta.name?.trim())&&(e.meta.name=r.NO_SPECIAL_CHAR,n="invalid"):(e.meta.name=r.REQUIRED_FIELD,n="invalid"),e.meta.name&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.name),l=!0),t.headerType===d.HEADER_TYPES.TEXT){const i=t.headerText?.trim()??"";if(!i)e.header=r.REQUIRED_FIELD,n="invalid";else if(i.length>r.HEADER_TEXT_LEN_LIMIT)e.header=r.HEADER_LEN_ERROR,n="invalid";else{const s=a.getTemplateVariablesFromState(i);s&&s.length>1&&(e.header=r.ONE_VAR_ALLOWED,n="invalid")}}else t.headerType===d.HEADER_TYPES.DOCUMENT||t.headerType===d.HEADER_TYPES.IMAGE||(t.headerType,d.HEADER_TYPES.VIDEO);if((t.headerType===d.HEADER_TYPES.DOCUMENT||t.headerType===d.HEADER_TYPES.IMAGE||t.headerType===d.HEADER_TYPES.VIDEO)&&(t.headerAssetLink||(e.header=r.HEADER_ASSET_LINK_ERROR,n="invalid")),e.header&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.header),l=!0),t.bodyText?t.bodyTextRaw&&t.bodyTextRaw?.trim().length>r.BODY_TEXT_LEN_LIMIT&&(e.body=r.BODY_LEN_ERROR,n="invalid"):(e.body=r.REQUIRED_FIELD,n="invalid"),e.body&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.body),l=!0),t.footerText&&t.footerText.length>r.HEADER_TEXT_LEN_LIMIT&&(e.footer=r.HEADER_LEN_ERROR,n="invalid"),e?.footer&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.footer),l=!0),t.actionsType===d.ACTIONS_TYPES.CTA_BTN){if(t.ctaBtn?.phoneNumber?.isChecked){const i=t.ctaBtn.phoneNumber.btnText?.trim(),s=t.ctaBtn.phoneNumber.phoneNumber;e.ctaBtn&&!i?(e.ctaBtn.phoneNumber.btnText=r.REQUIRED_FIELD,n="invalid"):e.ctaBtn&&i&&i.length>r.QUICK_REPLY_BTN_TEXT_LIMIT?(e.ctaBtn.phoneNumber.btnText=r.QUICK_REPLY_LEN_ERROR,n="invalid"):e.ctaBtn&&i&&o.test(i)&&(e.ctaBtn.phoneNumber.btnText=r.BUTTON_EMOJI_ERROR,n="invalid"),e.ctaBtn&&!s?(e.ctaBtn.phoneNumber.link=r.REQUIRED_FIELD,n="invalid"):e.ctaBtn&&s&&s.length<10&&(e.ctaBtn.phoneNumber.link=r.VALID_PHONE_NUMBER,n="invalid")}if(t.ctaBtn?.websiteLinkBtn?.isChecked){const i=t.ctaBtn.websiteLinkBtn.btnText?.trim(),s=t.ctaBtn.websiteLinkBtn.linkOpens?.trim(),p=t.ctaBtn.websiteLinkBtn.placeholder?.trim();e.ctaBtn&&!i?(e.ctaBtn.websiteLink.btnText=r.REQUIRED_FIELD,n="invalid"):e.ctaBtn&&i&&i.length>r.QUICK_REPLY_BTN_TEXT_LIMIT?(e.ctaBtn.websiteLink.btnText=r.QUICK_REPLY_LEN_ERROR,n="invalid"):e.ctaBtn&&i&&o.test(i)&&(e.ctaBtn.websiteLink.btnText=r.BUTTON_EMOJI_ERROR,n="invalid"),e.ctaBtn&&!s&&!p&&(e.ctaBtn.websiteLink.link=r.REQUIRED_FIELD,n="invalid")}}else if(t.actionsType===d.ACTIONS_TYPES.QUICK_REPLY){const i=["","",""];t.quickReply.forEach((s,p)=>{const E=s.text?.trim();if(!E)i[p]=r.REQUIRED_FIELD,n="invalid";else if(E.length>r.QUICK_REPLY_NAME_LEN_LIMIT)i[p]=r.QUICK_REPLY_LEN_ERROR,n="invalid";else if(o.test(E))i[p]=r.BUTTON_EMOJI_ERROR,n="invalid";else{const m=[...t.quickReply];m.splice(p,1),m.find(_=>_.text===E)&&(i[p]=r.QUICK_REPLY_NAME_ERROR,n="invalid")}}),e.quickReply=i}if(t.actionsType===d.ACTIONS_TYPES.CTA_BTN||t.actionsType===d.ACTIONS_TYPES.QUICK_REPLY){const i=e.quickReply?.reduce((s,p)=>s||!!p,!1);(e?.ctaBtn?.websiteLink?.link||e.ctaBtn?.websiteLink?.btnText||e.ctaBtn?.phoneNumber?.link||e.ctaBtn?.phoneNumber?.btnText||i)&&!l&&(c(r.CREATE_TEMPLATE_DOM_IDS.actionButtons),l=!0)}return{status:n,errors:e}}parseBodyComponent(t,o=!1,n,e){const a=[];let l="";const c=t.components?.find(i=>i.type==="BODY");return c&&(c.example?.body_text?.[0]?.forEach((i,s)=>{let p=t.mapping?.body?.[s];const E=p,m=p&&/\(\(/.test(p),T=p?.match(h.placeHolderNamePattern);T?.[2]&&(p=T?.[2]);const _=e===b.POD.CHATBOT&&E&&E?.startsWith("((")&&E?.endsWith("))");a.push({idx:s,variableVal:n||_?i:E,editable:!!m,editableDefaultValues:m?void 0:i,variableName:p??""})}),t.htmlContentUrl?l=t.htmlContentUrl:l=c.text?.split(/\{\{[0-9]+\}\}/).length?c.text?.split(/\{\{[0-9]+\}\}/).map((i,s)=>{if(a?.[s]){const p=a[s].variableName;return o?`${i}{{${p}}}`:`${i} <span> </span><span style="color: ${u.COLORS.content.brand}; text-decoration: underline;">{{${p}}}</span><span> </span>`}return i}).join(""):""),{bodyVariable:a,bodyText:l}}parseTitleComponent(t,o=!1,n){const e=[];let a="";const l=t.components?.find(c=>c.type==="TITLE");return l&&(l.example?.title_text?.[0]?.forEach((c,i)=>{let s=t.mapping?.body?.[i];const p=s,E=s&&/\(\(/.test(s),m=s?.match(h.placeHolderNamePattern);m?.[2]&&(s=m?.[2]),e.push({idx:i,variableVal:n?c:p,editable:!!E,editableDefaultValues:E?void 0:c,variableName:s??""})}),t.htmlContentUrl?a=t.htmlContentUrl:a=l.text?.split(/\{\{[0-9]+\}\}/).length?l.text?.split(/\{\{[0-9]+\}\}/).map((c,i)=>{if(e?.[i]){const s=e[i].variableName;return o?`${c}{{${s}}}`:`${c} <span> </span><span style="color: ${u.COLORS.content.brand}; text-decoration: underline;">{{${s}}}</span><span> </span>`}return c}).join(""):""),{titleText:a,titleVariables:e}}parseFooterComponent(t){return t.components?.find(n=>n.type==="FOOTER")?.text}parseButtonComponent(t){const o={actionsType:d.ACTIONS_TYPES.NONE,quickReply:[],ctaBtn:{phoneNumber:void 0,websiteLinkBtn:void 0},allButtons:[]},n=t.components?.find(e=>e.type==="BUTTONS");if(n&&n?.buttons?.length){const e=n?.buttons?.[0].type==="QUICK_REPLY"?d.ACTIONS_TYPES.QUICK_REPLY:d.ACTIONS_TYPES.CTA_BTN;if(o.actionsType=e,e===d.ACTIONS_TYPES.QUICK_REPLY){const a=n?.buttons?.map(l=>l)??[];o.quickReply=a}else e===d.ACTIONS_TYPES.CTA_BTN&&n?.buttons?.forEach(a=>{if(a.phone_number&&(o.ctaBtn.phoneNumber={isChecked:!0,btnText:a.text,phoneNumber:a.phone_number}),a.url){const l=t?.mapping?.buttons?.[0]??void 0;let c=!1;l&&h.editableVarPattern.test(l)&&(c=!0),o.ctaBtn.websiteLinkBtn={isChecked:!0,btnText:a.text,linkOpens:c?a.example?.[0]:a.url,placeholder:c?void 0:l}}});o.allButtons=n.buttons?.map(a=>a.type==="COPY_CODE"?{...a,placeholder:Array.isArray(a.example)?a.example[0]:a?.example||""}:a)}return o}parseLimitedTimeOfferComponent(t,o){const n={text:"",dateTime:"",code:""};return t.components.forEach(e=>{if(e.type==="limited_time_offer"){n.text=e.limited_time_offer?.text??"";const a=e.example?.limited_time_offer;a&&a.startsWith("{{")&&a.endsWith("}}")?n.dateTime=a:n.dateTime=A.format(a?new Date(a):new Date,"MMM dd")}o.forEach(a=>{a.type==="COPY_CODE"&&(n.code=a.placeholder??"")})}),n}parseCallPermissionComponent(t){const o=t.components?.find(n=>n.type==="CALL_PERMISSION_REQUEST");return{showCallPermissionCard:!!o,callPermissionText:o?.text}}async parseUITemplateFromDBFormat(t){const{dbFormattedTemplate:o,isDuplicate:n,isV2:e=!1,showSampleValues:a,pod:l}=t,{headerType:c,headerAssetLink:i,headerAssetName:s,headerText:p,headerVariables:E}=await this.parseDataFromHeaderComponent(o,void 0,l),{bodyText:m,bodyVariable:T}=await this.parseBodyComponent(o,e,a,l),{titleText:_,titleVariables:C}=await this.parseTitleComponent(o,e,a),{actionsType:y,quickReply:x,ctaBtn:I,allButtons:R}=await this.parseButtonComponent(o),N=this.parseLimitedTimeOfferComponent(o,R),{showCallPermissionCard:L,callPermissionText:B}=this.parseCallPermissionComponent(o),f={quickReply:x,ctaBtn:I,allButtons:R,meta:{name:n?`${o.label} Copy`:o.label,category:o.category?.toUpperCase(),subCategory:o.templateCategory,language:o.language,templateId:o.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:y,footerText:this.parseFooterComponent(o),bodyVariables:T,bodyText:m,headerType:c,headerAssetLink:i,headerAssetName:s,headerText:p,headerVariables:E,alreadyAsADraft:o.isDraft,mode:"edit",initialLoading:!1,limitedTimeOfferComponent:N,titleText:_,titleVariables:C,showCallPermissionCard:L,callPermissionText:B},{errors:O}=this.validateState(f);return f.error=O,f}parseTemplateConfiguration(t){let o;const n=t?.content||{};if(typeof n=="string")try{o=JSON.parse(n)}catch(e){console.error("Error parsing rcsTemplate component JSON:",e),o={orientation:"VERTICAL"}}else o=n;return{...o,templateType:t?.templateType,isMediaAfterBody:this.isRcsMediaAfterBody(t)}}isRcsMediaAfterBody(t){const o=t?.components;if(!Array.isArray(o))return!1;const n=o.findIndex(a=>a.type==="HEADER"&&!!a.format&&a.format!==d.HEADER_TYPES.TEXT),e=o.findIndex(a=>a.type==="BODY");return n>-1&&e>-1&&n>e}}exports.TemplateCreatorHelper=P;
2
2
  //# sourceMappingURL=TemplateCreatorHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateCreatorHelper.js","sources":["../../../../../src/components/template-preview/helpers/TemplateCreatorHelper.ts"],"sourcesContent":["import { format } from 'date-fns';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\teditableVarPattern,\n\tplaceHolderNamePattern,\n\tspecialCharPattern,\n} from '../constants/regexPatterns';\nimport {\n\tBODY_LEN_ERROR,\n\tBODY_TEXT_LEN_LIMIT,\n\tBUTTON_EMOJI_ERROR,\n\tCREATE_TEMPLATE_DOM_IDS,\n\tHEADER_ASSET_LINK_ERROR,\n\tHEADER_LEN_ERROR,\n\tHEADER_TEXT_LEN_LIMIT,\n\tNAME_LEN_ERROR,\n\tNAME_LEN_LIMIT,\n\tNO_SPECIAL_CHAR,\n\tONE_VAR_ALLOWED,\n\tQUICK_REPLY_BTN_TEXT_LIMIT,\n\tQUICK_REPLY_LEN_ERROR,\n\tQUICK_REPLY_NAME_ERROR,\n\tQUICK_REPLY_NAME_LEN_LIMIT,\n\tREQUIRED_FIELD,\n\tVALID_PHONE_NUMBER,\n} from '../constants/TemplateConstants';\nimport {\n\tRCS_TEMPLATE_TYPE,\n\tRCSTemplateConfig,\n\tRCSTemplateType,\n} from '../models/RCSTemplate';\nimport {\n\tACTIONS_TYPES,\n\tHEADER_TYPES,\n\tQUICK_REPLY_BUTTON,\n} from '../models/TemplateMeta';\nimport {\n\tCreateTemplateType,\n\tPOD,\n\ttemplateVariable,\n\tWhatsappPreviewButtonType,\n\tWhatsAppTemplate,\n} from '../models/WhatsAppTemplate';\nimport { TemplateHelperUtils } from '../utils/TemplateHelperUtils';\n\nexport class TemplateCreatorHelper {\n\tprivate parseDataFromHeaderComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst res: {\n\t\t\theaderType: HEADER_TYPES;\n\t\t\theaderAssetLink?: string;\n\t\t\theaderAssetName?: string;\n\t\t\theaderText?: string;\n\t\t\theaderVariables: templateVariable[];\n\t\t} = {\n\t\t\theaderType: HEADER_TYPES.NONE,\n\t\t\theaderVariables: [],\n\t\t};\n\n\t\tconst headerComponent = dbFormattedTemplate?.components?.find(\n\t\t\t(component) => component.type === 'HEADER',\n\t\t);\n\n\t\tif (headerComponent) {\n\t\t\tres.headerType = headerComponent.format as HEADER_TYPES;\n\t\t\tres.headerText = headerComponent.text;\n\n\t\t\tres.headerAssetLink = headerComponent.example?.header_handle?.[0];\n\n\t\t\tconst sampleValue = headerComponent.example?.header_text?.[0];\n\t\t\tconst headerVarPlaceholder = dbFormattedTemplate.mapping?.header?.[0];\n\t\t\tconst originalVariable = headerVarPlaceholder;\n\t\t\tif (headerVarPlaceholder) {\n\t\t\t\tconst normalizedName = headerVarPlaceholder\n\t\t\t\t\t?.replace('[[', '')\n\t\t\t\t\t.replace(']]', '')\n\t\t\t\t\t.replace('{{', '')\n\t\t\t\t\t.replace('}}', '')\n\t\t\t\t\t.replace('((', '')\n\t\t\t\t\t.replace('))', '');\n\t\t\t\tconst editable = /\\(\\(/.test(headerVarPlaceholder);\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tconst reduxHeaderVar: templateVariable = {\n\t\t\t\t\tidx: 0,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: normalizedName,\n\t\t\t\t};\n\t\t\t\tres.headerVariables = [reduxHeaderVar];\n\t\t\t\tif (headerComponent.example?.header_text?.length) {\n\t\t\t\t\tres.headerText = res.headerText?.replace(\n\t\t\t\t\t\t/** since there will be only one variable in template so hard replace */\n\t\t\t\t\t\t'{{1}}',\n\t\t\t\t\t\t`{{${normalizedName}}}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Check if current template state is ready for saving as a draft/submit-template or not\n\t * @param state\n\t */\n\tvalidateState(state: CreateTemplateType): {\n\t\tstatus: 'invalid' | 'valid';\n\t\terrors: CreateTemplateType['error'];\n\t} {\n\t\tconst emojiRegex = /\\p{Extended_Pictographic}/u;\n\t\tlet status: 'invalid' | 'valid' = 'valid';\n\t\tconst errors: CreateTemplateType['error'] = {\n\t\t\tmeta: {},\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: { btnText: '', link: '' },\n\t\t\t\twebsiteLink: { btnText: '', link: '' },\n\t\t\t},\n\t\t\tquickReply: [null, null, null],\n\t\t};\n\t\tconst templateHelperUtils = new TemplateHelperUtils();\n\t\tlet isScrolled = false;\n\n\t\tconst scrollByElementId = (elementId: string) => {\n\t\t\tdocument.getElementById(elementId)?.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t});\n\t\t};\n\n\t\tif (!state.meta?.name) {\n\t\t\terrors.meta!.name = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else if (state.meta.name?.trim().length > NAME_LEN_LIMIT) {\n\t\t\terrors.meta!.name = NAME_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t} else if (specialCharPattern.test(state.meta.name?.trim())) {\n\t\t\terrors.meta!.name = NO_SPECIAL_CHAR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors.meta!.name && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.name);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.headerType === HEADER_TYPES.TEXT) {\n\t\t\tconst text = state.headerText?.trim() ?? '';\n\t\t\tif (!text) {\n\t\t\t\terrors.header = REQUIRED_FIELD;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else if (text.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\t\terrors.header = HEADER_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else {\n\t\t\t\tconst variableList =\n\t\t\t\t\ttemplateHelperUtils.getTemplateVariablesFromState(text);\n\t\t\t\tif (variableList && variableList.length > 1) {\n\t\t\t\t\terrors.header = ONE_VAR_ALLOWED;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.headerType === HEADER_TYPES.DOCUMENT) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.IMAGE) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.VIDEO) {\n\t\t\t/** @todo add media header validations */\n\t\t}\n\n\t\tif (\n\t\t\tstate.headerType === HEADER_TYPES.DOCUMENT ||\n\t\t\tstate.headerType === HEADER_TYPES.IMAGE ||\n\t\t\tstate.headerType === HEADER_TYPES.VIDEO\n\t\t) {\n\t\t\tif (!state.headerAssetLink) {\n\t\t\t\terrors.header = HEADER_ASSET_LINK_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.header && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.header);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (!state.bodyText) {\n\t\t\terrors.body = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else {\n\t\t\tif (\n\t\t\t\tstate.bodyTextRaw &&\n\t\t\t\tstate.bodyTextRaw?.trim().length > BODY_TEXT_LEN_LIMIT\n\t\t\t) {\n\t\t\t\terrors.body = BODY_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.body && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.body);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.footerText && state.footerText.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\terrors.footer = HEADER_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors?.footer && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.footer);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\tif (state.ctaBtn?.phoneNumber?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.phoneNumber.btnText?.trim();\n\t\t\t\tconst phoneNumber = state.ctaBtn.phoneNumber.phoneNumber;\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !phoneNumber) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && phoneNumber && phoneNumber.length < 10) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = VALID_PHONE_NUMBER;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (state.ctaBtn?.websiteLinkBtn?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.websiteLinkBtn.btnText?.trim();\n\t\t\t\tconst customLink = state.ctaBtn.websiteLinkBtn.linkOpens?.trim();\n\t\t\t\tconst placeholder = state.ctaBtn.websiteLinkBtn.placeholder?.trim();\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !customLink && !placeholder) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\tconst quickReplyErrors = ['', '', ''];\n\t\t\tstate.quickReply.forEach((button, i) => {\n\t\t\t\tconst text = button.text?.trim();\n\t\t\t\tif (!text) {\n\t\t\t\t\tquickReplyErrors[i] = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (text.length > QUICK_REPLY_NAME_LEN_LIMIT) {\n\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (emojiRegex.test(text)) {\n\t\t\t\t\tquickReplyErrors[i] = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else {\n\t\t\t\t\tconst buttons = [...state.quickReply];\n\t\t\t\t\tbuttons.splice(i, 1);\n\t\t\t\t\tconst exists = buttons.find(\n\t\t\t\t\t\t(el: QUICK_REPLY_BUTTON) => el.text === text,\n\t\t\t\t\t);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_NAME_ERROR;\n\t\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\terrors.quickReply = quickReplyErrors;\n\t\t}\n\n\t\tif (\n\t\t\tstate.actionsType === ACTIONS_TYPES.CTA_BTN ||\n\t\t\tstate.actionsType === ACTIONS_TYPES.QUICK_REPLY\n\t\t) {\n\t\t\tconst quickReplyErrors = errors.quickReply?.reduce(\n\t\t\t\t(qrbErrorAcc, currentError) => qrbErrorAcc || !!currentError,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t(!!errors?.ctaBtn?.websiteLink?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.websiteLink?.btnText ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.btnText ||\n\t\t\t\t\t!!quickReplyErrors) &&\n\t\t\t\t!isScrolled\n\t\t\t) {\n\t\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.actionButtons);\n\t\t\t\tisScrolled = true;\n\t\t\t}\n\t\t}\n\n\t\treturn { status, errors };\n\t}\n\n\tprivate parseBodyComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst bodyVariable: templateVariable[] = [];\n\t\tlet bodyText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BODY',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.body_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tbodyVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\tbodyText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\tbodyText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (bodyVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = bodyVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { bodyVariable, bodyText };\n\t}\n\n\tprivate parseTitleComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t) {\n\t\tconst titleVariable: templateVariable[] = [];\n\t\tlet titleText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'TITLE',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.title_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\ttitleVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal: showSampleValues ? sampleValue : originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\ttitleText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\ttitleText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (titleVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = titleVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { titleText, titleVariables: titleVariable };\n\t}\n\n\tprivate parseFooterComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst footerComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'FOOTER',\n\t\t);\n\n\t\treturn footerComponent?.text;\n\t}\n\n\tprivate parseButtonComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst res: {\n\t\t\tactionsType: ACTIONS_TYPES;\n\t\t\tquickReply: Array<QUICK_REPLY_BUTTON>;\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tphoneNumber?: string;\n\t\t\t\t};\n\t\t\t\twebsiteLinkBtn?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tlinkOpens?: string;\n\t\t\t\t\tplaceholder?: string;\n\t\t\t\t};\n\t\t\t};\n\t\t\tallButtons: WhatsappPreviewButtonType[];\n\t\t} = {\n\t\t\tactionsType: ACTIONS_TYPES.NONE,\n\t\t\tquickReply: [],\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: undefined,\n\t\t\t\twebsiteLinkBtn: undefined,\n\t\t\t},\n\t\t\tallButtons: [],\n\t\t};\n\n\t\tconst buttonComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BUTTONS',\n\t\t);\n\n\t\tif (buttonComponent && buttonComponent?.buttons?.length) {\n\t\t\tconst actionsType =\n\t\t\t\tbuttonComponent?.buttons?.[0].type === 'QUICK_REPLY'\n\t\t\t\t\t? ACTIONS_TYPES.QUICK_REPLY\n\t\t\t\t\t: ACTIONS_TYPES.CTA_BTN;\n\n\t\t\tres.actionsType = actionsType;\n\n\t\t\tif (actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\t\tconst btnTexts = (buttonComponent?.buttons?.map((btn) => btn) ??\n\t\t\t\t\t[]) as QUICK_REPLY_BUTTON[];\n\t\t\t\tres.quickReply = btnTexts;\n\t\t\t} else if (actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\t\tbuttonComponent?.buttons?.forEach((btn) => {\n\t\t\t\t\tif (btn.phone_number) {\n\t\t\t\t\t\tres.ctaBtn.phoneNumber = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tphoneNumber: btn.phone_number,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (btn.url) {\n\t\t\t\t\t\tconst btnPlaceholder =\n\t\t\t\t\t\t\tdbFormattedTemplate?.mapping?.buttons?.[0] ?? undefined;\n\t\t\t\t\t\tlet customUrl = false;\n\n\t\t\t\t\t\tif (btnPlaceholder && editableVarPattern.test(btnPlaceholder)) {\n\t\t\t\t\t\t\tcustomUrl = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tres.ctaBtn.websiteLinkBtn = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tlinkOpens: customUrl ? btn.example?.[0] : btn.url,\n\t\t\t\t\t\t\tplaceholder: customUrl ? undefined : btnPlaceholder,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Parses buttons from template to a format preview can understand.\n\t\t\t// Since copy code does not come with a variable by default, we are adding placeholder from example.\n\t\t\tres.allButtons = buttonComponent.buttons?.map((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...button,\n\t\t\t\t\t\tplaceholder: Array.isArray(button.example)\n\t\t\t\t\t\t\t? button.example[0]\n\t\t\t\t\t\t\t: button?.example || '',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn button;\n\t\t\t}) as WhatsappPreviewButtonType[];\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Parses LTO component to a format preview can understand.\n\t * Points to Note -\n\t * 1. Takes the Copy Code from previously parsed buttons.\n\t * 2. LTO component does not have a dateTime expiry by default. Hence, while sending template to ContextMapper, send with a date or current Date and Time is picked here.\n\t */\n\tprivate parseLimitedTimeOfferComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tallButtons: WhatsappPreviewButtonType[],\n\t) {\n\t\tconst limitedTimeOfferComponent: CreateTemplateType['limitedTimeOfferComponent'] =\n\t\t\t{\n\t\t\t\ttext: '',\n\t\t\t\tdateTime: '',\n\t\t\t\tcode: '',\n\t\t\t};\n\n\t\tdbFormattedTemplate.components.forEach((component) => {\n\t\t\tif (component.type === 'limited_time_offer') {\n\t\t\t\tlimitedTimeOfferComponent.text =\n\t\t\t\t\tcomponent.limited_time_offer?.text ?? '';\n\t\t\t\tconst dateTime = component.example?.limited_time_offer;\n\t\t\t\tif (dateTime && dateTime.startsWith('{{') && dateTime.endsWith('}}')) {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = dateTime;\n\t\t\t\t} else {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = format(\n\t\t\t\t\t\tdateTime ? new Date(dateTime) : new Date(),\n\t\t\t\t\t\t'MMM dd',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tallButtons.forEach((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\tlimitedTimeOfferComponent.code = button.placeholder ?? '';\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn limitedTimeOfferComponent;\n\t}\n\n\tprivate parseCallPermissionComponent(dbFormattedTemplate: WhatsAppTemplate): {\n\t\tshowCallPermissionCard: boolean;\n\t\tcallPermissionText?: string;\n\t} {\n\t\tconst callPermissionComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => (component as any).type === 'CALL_PERMISSION_REQUEST',\n\t\t);\n\n\t\treturn {\n\t\t\tshowCallPermissionCard: Boolean(callPermissionComponent),\n\t\t\tcallPermissionText: (callPermissionComponent as any)?.text,\n\t\t};\n\t}\n\n\tasync parseUITemplateFromDBFormat(data: {\n\t\tdbFormattedTemplate: WhatsAppTemplate;\n\t\tisDuplicate?: boolean;\n\t\tshowSampleValues?: boolean;\n\t\tisV2?: boolean;\n\t\tpod?: string;\n\t}) {\n\t\tconst {\n\t\t\tdbFormattedTemplate,\n\t\t\tisDuplicate,\n\t\t\tisV2 = false,\n\t\t\tshowSampleValues,\n\t\t\tpod,\n\t\t} = data;\n\t\tconst {\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t} = await this.parseDataFromHeaderComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tundefined,\n\t\t\tpod,\n\t\t);\n\n\t\tconst { bodyText, bodyVariable: bodyVariables } =\n\t\t\tawait this.parseBodyComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t\tpod,\n\t\t\t);\n\t\tconst { titleText, titleVariables: titleVariables } =\n\t\t\tawait this.parseTitleComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t);\n\n\t\tconst { actionsType, quickReply, ctaBtn, allButtons } =\n\t\t\tawait this.parseButtonComponent(dbFormattedTemplate);\n\n\t\tconst limitedTimeOfferComponent = this.parseLimitedTimeOfferComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tallButtons,\n\t\t);\n\n\t\tconst { showCallPermissionCard, callPermissionText } =\n\t\t\tthis.parseCallPermissionComponent(dbFormattedTemplate);\n\n\t\tconst state: CreateTemplateType = {\n\t\t\tquickReply,\n\t\t\tctaBtn,\n\t\t\tallButtons,\n\t\t\tmeta: {\n\t\t\t\tname: isDuplicate\n\t\t\t\t\t? `${dbFormattedTemplate.label} Copy`\n\t\t\t\t\t: dbFormattedTemplate.label,\n\t\t\t\tcategory: dbFormattedTemplate.category?.toUpperCase(),\n\t\t\t\tsubCategory: dbFormattedTemplate.templateCategory,\n\t\t\t\tlanguage: dbFormattedTemplate.language,\n\t\t\t\ttemplateId: dbFormattedTemplate.templateId,\n\t\t\t},\n\t\t\terror: {\n\t\t\t\theader: undefined,\n\t\t\t\tbody: undefined,\n\t\t\t\tfooter: undefined,\n\t\t\t\tquickReply: undefined,\n\t\t\t\tmeta: undefined,\n\t\t\t\tctaBtn: undefined,\n\t\t\t},\n\n\t\t\tactionsType,\n\t\t\tfooterText: this.parseFooterComponent(dbFormattedTemplate),\n\t\t\t/** BODY TEXT */\n\t\t\tbodyVariables,\n\t\t\tbodyText,\n\n\t\t\t/** HEADER */\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t\talreadyAsADraft: dbFormattedTemplate.isDraft,\n\t\t\tmode: 'edit',\n\t\t\tinitialLoading: false,\n\t\t\t/* LIMITED TIME OFFER */\n\t\t\tlimitedTimeOfferComponent,\n\t\t\t/* Title for RCS */\n\t\t\ttitleText,\n\t\t\ttitleVariables,\n\t\t\t/* Call Permission */\n\t\t\tshowCallPermissionCard,\n\t\t\tcallPermissionText,\n\t\t};\n\n\t\tconst { errors } = this.validateState(state);\n\n\t\tstate.error = errors;\n\n\t\treturn state;\n\t}\n\n\tparseTemplateConfiguration(template: RCSTemplateType): RCSTemplateConfig {\n\t\tlet config: RCSTemplateConfig;\n\t\tconst templateConfig = template?.content || ({} as RCSTemplateConfig);\n\t\tif (typeof templateConfig === 'string') {\n\t\t\ttry {\n\t\t\t\tconfig = JSON.parse(templateConfig) as RCSTemplateConfig;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Error parsing rcsTemplate component JSON:', error);\n\t\t\t\tconfig = { orientation: 'VERTICAL' } as RCSTemplateConfig;\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = templateConfig;\n\t\t}\n\t\treturn {\n\t\t\t...config,\n\t\t\ttemplateType: template?.templateType as RCS_TEMPLATE_TYPE,\n\t\t};\n\t}\n}\n"],"names":["TemplateCreatorHelper","dbFormattedTemplate","showSampleValues","pod","res","HEADER_TYPES","headerComponent","component","sampleValue","headerVarPlaceholder","originalVariable","normalizedName","editable","isChatbotCustomText","POD","reduxHeaderVar","state","emojiRegex","status","errors","templateHelperUtils","TemplateHelperUtils","isScrolled","scrollByElementId","elementId","NAME_LEN_LIMIT","NAME_LEN_ERROR","specialCharPattern","NO_SPECIAL_CHAR","REQUIRED_FIELD","CREATE_TEMPLATE_DOM_IDS","text","HEADER_TEXT_LEN_LIMIT","HEADER_LEN_ERROR","variableList","ONE_VAR_ALLOWED","HEADER_ASSET_LINK_ERROR","BODY_TEXT_LEN_LIMIT","BODY_LEN_ERROR","ACTIONS_TYPES","btnText","phoneNumber","QUICK_REPLY_BTN_TEXT_LIMIT","QUICK_REPLY_LEN_ERROR","BUTTON_EMOJI_ERROR","VALID_PHONE_NUMBER","customLink","placeholder","quickReplyErrors","button","i","QUICK_REPLY_NAME_LEN_LIMIT","buttons","el","QUICK_REPLY_NAME_ERROR","qrbErrorAcc","currentError","isV2","bodyVariable","bodyText","bodyComponent","bodyVarPlaceholder","matchedPlaceholderName","placeHolderNamePattern","t","normalizeName","COLORS","titleVariable","titleText","buttonComponent","actionsType","btnTexts","btn","btnPlaceholder","customUrl","editableVarPattern","allButtons","limitedTimeOfferComponent","dateTime","format","callPermissionComponent","data","isDuplicate","headerType","headerAssetLink","headerAssetName","headerText","headerVariables","bodyVariables","titleVariables","quickReply","ctaBtn","showCallPermissionCard","callPermissionText","template","config","templateConfig","error"],"mappings":"8WA6CO,MAAMA,CAAsB,CAC1B,6BACPC,EACAC,EACAC,EACC,CACD,MAAMC,EAMF,CACH,WAAYC,EAAAA,aAAa,KACzB,gBAAiB,CAAA,CAAC,EAGbC,EAAkBL,GAAqB,YAAY,KACvDM,GAAcA,EAAU,OAAS,QAAA,EAGnC,GAAID,EAAiB,CACpBF,EAAI,WAAaE,EAAgB,OACjCF,EAAI,WAAaE,EAAgB,KAEjCF,EAAI,gBAAkBE,EAAgB,SAAS,gBAAgB,CAAC,EAEhE,MAAME,EAAcF,EAAgB,SAAS,cAAc,CAAC,EACtDG,EAAuBR,EAAoB,SAAS,SAAS,CAAC,EAC9DS,EAAmBD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GT,YAAAqE,EACA,WAAY,KAAK,qBAAqBrE,CAAmB,EAEzD,cAAAuF,EACA,SAAA7B,EAGA,WAAAwB,EACA,gBAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,gBAAAC,EACA,gBAAiBtF,EAAoB,QACrC,KAAM,OACN,eAAgB,GAEhB,0BAAA4E,EAEA,UAAAT,EACA,eAAAqB,EAEA,uBAAAG,EACA,mBAAAC,CAAA,EAGK,CAAE,OAAA1E,CAAA,EAAW,KAAK,cAAcH,CAAK,EAE3C,OAAAA,EAAM,MAAQG,EAEPH,CACR,CAEA,2BAA2B8E,EAA8C,CACxE,IAAIC,EACJ,MAAMC,EAAiBF,GAAU,SAAY,CAAA,EAC7C,GAAI,OAAOE,GAAmB,SAC7B,GAAI,CACHD,EAAS,KAAK,MAAMC,CAAc,CACnC,OAASC,EAAO,CACf,QAAQ,MAAM,4CAA6CA,CAAK,EAChEF,EAAS,CAAE,YAAa,UAAA,CACzB,MAEAA,EAASC,EAEV,MAAO,CACN,GAAGD,EACH,aAAcD,GAAU,YAAA,CAE1B,CACD"}
1
+ {"version":3,"file":"TemplateCreatorHelper.js","sources":["../../../../../src/components/template-preview/helpers/TemplateCreatorHelper.ts"],"sourcesContent":["import { format } from 'date-fns';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\teditableVarPattern,\n\tplaceHolderNamePattern,\n\tspecialCharPattern,\n} from '../constants/regexPatterns';\nimport {\n\tBODY_LEN_ERROR,\n\tBODY_TEXT_LEN_LIMIT,\n\tBUTTON_EMOJI_ERROR,\n\tCREATE_TEMPLATE_DOM_IDS,\n\tHEADER_ASSET_LINK_ERROR,\n\tHEADER_LEN_ERROR,\n\tHEADER_TEXT_LEN_LIMIT,\n\tNAME_LEN_ERROR,\n\tNAME_LEN_LIMIT,\n\tNO_SPECIAL_CHAR,\n\tONE_VAR_ALLOWED,\n\tQUICK_REPLY_BTN_TEXT_LIMIT,\n\tQUICK_REPLY_LEN_ERROR,\n\tQUICK_REPLY_NAME_ERROR,\n\tQUICK_REPLY_NAME_LEN_LIMIT,\n\tREQUIRED_FIELD,\n\tVALID_PHONE_NUMBER,\n} from '../constants/TemplateConstants';\nimport {\n\tRCS_TEMPLATE_TYPE,\n\tRCSTemplateConfig,\n\tRCSTemplateType,\n} from '../models/RCSTemplate';\nimport {\n\tACTIONS_TYPES,\n\tHEADER_TYPES,\n\tQUICK_REPLY_BUTTON,\n} from '../models/TemplateMeta';\nimport {\n\tCreateTemplateType,\n\tPOD,\n\ttemplateVariable,\n\tWhatsappPreviewButtonType,\n\tWhatsAppTemplate,\n} from '../models/WhatsAppTemplate';\nimport { TemplateHelperUtils } from '../utils/TemplateHelperUtils';\n\nexport class TemplateCreatorHelper {\n\tprivate parseDataFromHeaderComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst res: {\n\t\t\theaderType: HEADER_TYPES;\n\t\t\theaderAssetLink?: string;\n\t\t\theaderAssetName?: string;\n\t\t\theaderText?: string;\n\t\t\theaderVariables: templateVariable[];\n\t\t} = {\n\t\t\theaderType: HEADER_TYPES.NONE,\n\t\t\theaderVariables: [],\n\t\t};\n\n\t\tconst headerComponent = dbFormattedTemplate?.components?.find(\n\t\t\t(component) => component.type === 'HEADER',\n\t\t);\n\n\t\tif (headerComponent) {\n\t\t\tres.headerType = headerComponent.format as HEADER_TYPES;\n\t\t\tres.headerText = headerComponent.text;\n\n\t\t\tres.headerAssetLink = headerComponent.example?.header_handle?.[0];\n\n\t\t\tconst sampleValue = headerComponent.example?.header_text?.[0];\n\t\t\tconst headerVarPlaceholder = dbFormattedTemplate.mapping?.header?.[0];\n\t\t\tconst originalVariable = headerVarPlaceholder;\n\t\t\tif (headerVarPlaceholder) {\n\t\t\t\tconst normalizedName = headerVarPlaceholder\n\t\t\t\t\t?.replace('[[', '')\n\t\t\t\t\t.replace(']]', '')\n\t\t\t\t\t.replace('{{', '')\n\t\t\t\t\t.replace('}}', '')\n\t\t\t\t\t.replace('((', '')\n\t\t\t\t\t.replace('))', '');\n\t\t\t\tconst editable = /\\(\\(/.test(headerVarPlaceholder);\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tconst reduxHeaderVar: templateVariable = {\n\t\t\t\t\tidx: 0,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: normalizedName,\n\t\t\t\t};\n\t\t\t\tres.headerVariables = [reduxHeaderVar];\n\t\t\t\tif (headerComponent.example?.header_text?.length) {\n\t\t\t\t\tres.headerText = res.headerText?.replace(\n\t\t\t\t\t\t/** since there will be only one variable in template so hard replace */\n\t\t\t\t\t\t'{{1}}',\n\t\t\t\t\t\t`{{${normalizedName}}}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Check if current template state is ready for saving as a draft/submit-template or not\n\t * @param state\n\t */\n\tvalidateState(state: CreateTemplateType): {\n\t\tstatus: 'invalid' | 'valid';\n\t\terrors: CreateTemplateType['error'];\n\t} {\n\t\tconst emojiRegex = /\\p{Extended_Pictographic}/u;\n\t\tlet status: 'invalid' | 'valid' = 'valid';\n\t\tconst errors: CreateTemplateType['error'] = {\n\t\t\tmeta: {},\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: { btnText: '', link: '' },\n\t\t\t\twebsiteLink: { btnText: '', link: '' },\n\t\t\t},\n\t\t\tquickReply: [null, null, null],\n\t\t};\n\t\tconst templateHelperUtils = new TemplateHelperUtils();\n\t\tlet isScrolled = false;\n\n\t\tconst scrollByElementId = (elementId: string) => {\n\t\t\tdocument.getElementById(elementId)?.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t});\n\t\t};\n\n\t\tif (!state.meta?.name) {\n\t\t\terrors.meta!.name = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else if (state.meta.name?.trim().length > NAME_LEN_LIMIT) {\n\t\t\terrors.meta!.name = NAME_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t} else if (specialCharPattern.test(state.meta.name?.trim())) {\n\t\t\terrors.meta!.name = NO_SPECIAL_CHAR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors.meta!.name && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.name);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.headerType === HEADER_TYPES.TEXT) {\n\t\t\tconst text = state.headerText?.trim() ?? '';\n\t\t\tif (!text) {\n\t\t\t\terrors.header = REQUIRED_FIELD;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else if (text.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\t\terrors.header = HEADER_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else {\n\t\t\t\tconst variableList =\n\t\t\t\t\ttemplateHelperUtils.getTemplateVariablesFromState(text);\n\t\t\t\tif (variableList && variableList.length > 1) {\n\t\t\t\t\terrors.header = ONE_VAR_ALLOWED;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.headerType === HEADER_TYPES.DOCUMENT) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.IMAGE) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.VIDEO) {\n\t\t\t/** @todo add media header validations */\n\t\t}\n\n\t\tif (\n\t\t\tstate.headerType === HEADER_TYPES.DOCUMENT ||\n\t\t\tstate.headerType === HEADER_TYPES.IMAGE ||\n\t\t\tstate.headerType === HEADER_TYPES.VIDEO\n\t\t) {\n\t\t\tif (!state.headerAssetLink) {\n\t\t\t\terrors.header = HEADER_ASSET_LINK_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.header && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.header);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (!state.bodyText) {\n\t\t\terrors.body = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else {\n\t\t\tif (\n\t\t\t\tstate.bodyTextRaw &&\n\t\t\t\tstate.bodyTextRaw?.trim().length > BODY_TEXT_LEN_LIMIT\n\t\t\t) {\n\t\t\t\terrors.body = BODY_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.body && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.body);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.footerText && state.footerText.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\terrors.footer = HEADER_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors?.footer && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.footer);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\tif (state.ctaBtn?.phoneNumber?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.phoneNumber.btnText?.trim();\n\t\t\t\tconst phoneNumber = state.ctaBtn.phoneNumber.phoneNumber;\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !phoneNumber) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && phoneNumber && phoneNumber.length < 10) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = VALID_PHONE_NUMBER;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (state.ctaBtn?.websiteLinkBtn?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.websiteLinkBtn.btnText?.trim();\n\t\t\t\tconst customLink = state.ctaBtn.websiteLinkBtn.linkOpens?.trim();\n\t\t\t\tconst placeholder = state.ctaBtn.websiteLinkBtn.placeholder?.trim();\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !customLink && !placeholder) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\tconst quickReplyErrors = ['', '', ''];\n\t\t\tstate.quickReply.forEach((button, i) => {\n\t\t\t\tconst text = button.text?.trim();\n\t\t\t\tif (!text) {\n\t\t\t\t\tquickReplyErrors[i] = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (text.length > QUICK_REPLY_NAME_LEN_LIMIT) {\n\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (emojiRegex.test(text)) {\n\t\t\t\t\tquickReplyErrors[i] = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else {\n\t\t\t\t\tconst buttons = [...state.quickReply];\n\t\t\t\t\tbuttons.splice(i, 1);\n\t\t\t\t\tconst exists = buttons.find(\n\t\t\t\t\t\t(el: QUICK_REPLY_BUTTON) => el.text === text,\n\t\t\t\t\t);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_NAME_ERROR;\n\t\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\terrors.quickReply = quickReplyErrors;\n\t\t}\n\n\t\tif (\n\t\t\tstate.actionsType === ACTIONS_TYPES.CTA_BTN ||\n\t\t\tstate.actionsType === ACTIONS_TYPES.QUICK_REPLY\n\t\t) {\n\t\t\tconst quickReplyErrors = errors.quickReply?.reduce(\n\t\t\t\t(qrbErrorAcc, currentError) => qrbErrorAcc || !!currentError,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t(!!errors?.ctaBtn?.websiteLink?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.websiteLink?.btnText ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.btnText ||\n\t\t\t\t\t!!quickReplyErrors) &&\n\t\t\t\t!isScrolled\n\t\t\t) {\n\t\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.actionButtons);\n\t\t\t\tisScrolled = true;\n\t\t\t}\n\t\t}\n\n\t\treturn { status, errors };\n\t}\n\n\tprivate parseBodyComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst bodyVariable: templateVariable[] = [];\n\t\tlet bodyText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BODY',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.body_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tbodyVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\tbodyText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\tbodyText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (bodyVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = bodyVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { bodyVariable, bodyText };\n\t}\n\n\tprivate parseTitleComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t) {\n\t\tconst titleVariable: templateVariable[] = [];\n\t\tlet titleText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'TITLE',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.title_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\ttitleVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal: showSampleValues ? sampleValue : originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\ttitleText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\ttitleText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (titleVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = titleVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { titleText, titleVariables: titleVariable };\n\t}\n\n\tprivate parseFooterComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst footerComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'FOOTER',\n\t\t);\n\n\t\treturn footerComponent?.text;\n\t}\n\n\tprivate parseButtonComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst res: {\n\t\t\tactionsType: ACTIONS_TYPES;\n\t\t\tquickReply: Array<QUICK_REPLY_BUTTON>;\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tphoneNumber?: string;\n\t\t\t\t};\n\t\t\t\twebsiteLinkBtn?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tlinkOpens?: string;\n\t\t\t\t\tplaceholder?: string;\n\t\t\t\t};\n\t\t\t};\n\t\t\tallButtons: WhatsappPreviewButtonType[];\n\t\t} = {\n\t\t\tactionsType: ACTIONS_TYPES.NONE,\n\t\t\tquickReply: [],\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: undefined,\n\t\t\t\twebsiteLinkBtn: undefined,\n\t\t\t},\n\t\t\tallButtons: [],\n\t\t};\n\n\t\tconst buttonComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BUTTONS',\n\t\t);\n\n\t\tif (buttonComponent && buttonComponent?.buttons?.length) {\n\t\t\tconst actionsType =\n\t\t\t\tbuttonComponent?.buttons?.[0].type === 'QUICK_REPLY'\n\t\t\t\t\t? ACTIONS_TYPES.QUICK_REPLY\n\t\t\t\t\t: ACTIONS_TYPES.CTA_BTN;\n\n\t\t\tres.actionsType = actionsType;\n\n\t\t\tif (actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\t\tconst btnTexts = (buttonComponent?.buttons?.map((btn) => btn) ??\n\t\t\t\t\t[]) as QUICK_REPLY_BUTTON[];\n\t\t\t\tres.quickReply = btnTexts;\n\t\t\t} else if (actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\t\tbuttonComponent?.buttons?.forEach((btn) => {\n\t\t\t\t\tif (btn.phone_number) {\n\t\t\t\t\t\tres.ctaBtn.phoneNumber = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tphoneNumber: btn.phone_number,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (btn.url) {\n\t\t\t\t\t\tconst btnPlaceholder =\n\t\t\t\t\t\t\tdbFormattedTemplate?.mapping?.buttons?.[0] ?? undefined;\n\t\t\t\t\t\tlet customUrl = false;\n\n\t\t\t\t\t\tif (btnPlaceholder && editableVarPattern.test(btnPlaceholder)) {\n\t\t\t\t\t\t\tcustomUrl = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tres.ctaBtn.websiteLinkBtn = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tlinkOpens: customUrl ? btn.example?.[0] : btn.url,\n\t\t\t\t\t\t\tplaceholder: customUrl ? undefined : btnPlaceholder,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Parses buttons from template to a format preview can understand.\n\t\t\t// Since copy code does not come with a variable by default, we are adding placeholder from example.\n\t\t\tres.allButtons = buttonComponent.buttons?.map((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...button,\n\t\t\t\t\t\tplaceholder: Array.isArray(button.example)\n\t\t\t\t\t\t\t? button.example[0]\n\t\t\t\t\t\t\t: button?.example || '',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn button;\n\t\t\t}) as WhatsappPreviewButtonType[];\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Parses LTO component to a format preview can understand.\n\t * Points to Note -\n\t * 1. Takes the Copy Code from previously parsed buttons.\n\t * 2. LTO component does not have a dateTime expiry by default. Hence, while sending template to ContextMapper, send with a date or current Date and Time is picked here.\n\t */\n\tprivate parseLimitedTimeOfferComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tallButtons: WhatsappPreviewButtonType[],\n\t) {\n\t\tconst limitedTimeOfferComponent: CreateTemplateType['limitedTimeOfferComponent'] =\n\t\t\t{\n\t\t\t\ttext: '',\n\t\t\t\tdateTime: '',\n\t\t\t\tcode: '',\n\t\t\t};\n\n\t\tdbFormattedTemplate.components.forEach((component) => {\n\t\t\tif (component.type === 'limited_time_offer') {\n\t\t\t\tlimitedTimeOfferComponent.text =\n\t\t\t\t\tcomponent.limited_time_offer?.text ?? '';\n\t\t\t\tconst dateTime = component.example?.limited_time_offer;\n\t\t\t\tif (dateTime && dateTime.startsWith('{{') && dateTime.endsWith('}}')) {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = dateTime;\n\t\t\t\t} else {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = format(\n\t\t\t\t\t\tdateTime ? new Date(dateTime) : new Date(),\n\t\t\t\t\t\t'MMM dd',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tallButtons.forEach((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\tlimitedTimeOfferComponent.code = button.placeholder ?? '';\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn limitedTimeOfferComponent;\n\t}\n\n\tprivate parseCallPermissionComponent(dbFormattedTemplate: WhatsAppTemplate): {\n\t\tshowCallPermissionCard: boolean;\n\t\tcallPermissionText?: string;\n\t} {\n\t\tconst callPermissionComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => (component as any).type === 'CALL_PERMISSION_REQUEST',\n\t\t);\n\n\t\treturn {\n\t\t\tshowCallPermissionCard: Boolean(callPermissionComponent),\n\t\t\tcallPermissionText: (callPermissionComponent as any)?.text,\n\t\t};\n\t}\n\n\tasync parseUITemplateFromDBFormat(data: {\n\t\tdbFormattedTemplate: WhatsAppTemplate;\n\t\tisDuplicate?: boolean;\n\t\tshowSampleValues?: boolean;\n\t\tisV2?: boolean;\n\t\tpod?: string;\n\t}) {\n\t\tconst {\n\t\t\tdbFormattedTemplate,\n\t\t\tisDuplicate,\n\t\t\tisV2 = false,\n\t\t\tshowSampleValues,\n\t\t\tpod,\n\t\t} = data;\n\t\tconst {\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t} = await this.parseDataFromHeaderComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tundefined,\n\t\t\tpod,\n\t\t);\n\n\t\tconst { bodyText, bodyVariable: bodyVariables } =\n\t\t\tawait this.parseBodyComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t\tpod,\n\t\t\t);\n\t\tconst { titleText, titleVariables: titleVariables } =\n\t\t\tawait this.parseTitleComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t);\n\n\t\tconst { actionsType, quickReply, ctaBtn, allButtons } =\n\t\t\tawait this.parseButtonComponent(dbFormattedTemplate);\n\n\t\tconst limitedTimeOfferComponent = this.parseLimitedTimeOfferComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tallButtons,\n\t\t);\n\n\t\tconst { showCallPermissionCard, callPermissionText } =\n\t\t\tthis.parseCallPermissionComponent(dbFormattedTemplate);\n\n\t\tconst state: CreateTemplateType = {\n\t\t\tquickReply,\n\t\t\tctaBtn,\n\t\t\tallButtons,\n\t\t\tmeta: {\n\t\t\t\tname: isDuplicate\n\t\t\t\t\t? `${dbFormattedTemplate.label} Copy`\n\t\t\t\t\t: dbFormattedTemplate.label,\n\t\t\t\tcategory: dbFormattedTemplate.category?.toUpperCase(),\n\t\t\t\tsubCategory: dbFormattedTemplate.templateCategory,\n\t\t\t\tlanguage: dbFormattedTemplate.language,\n\t\t\t\ttemplateId: dbFormattedTemplate.templateId,\n\t\t\t},\n\t\t\terror: {\n\t\t\t\theader: undefined,\n\t\t\t\tbody: undefined,\n\t\t\t\tfooter: undefined,\n\t\t\t\tquickReply: undefined,\n\t\t\t\tmeta: undefined,\n\t\t\t\tctaBtn: undefined,\n\t\t\t},\n\n\t\t\tactionsType,\n\t\t\tfooterText: this.parseFooterComponent(dbFormattedTemplate),\n\t\t\t/** BODY TEXT */\n\t\t\tbodyVariables,\n\t\t\tbodyText,\n\n\t\t\t/** HEADER */\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t\talreadyAsADraft: dbFormattedTemplate.isDraft,\n\t\t\tmode: 'edit',\n\t\t\tinitialLoading: false,\n\t\t\t/* LIMITED TIME OFFER */\n\t\t\tlimitedTimeOfferComponent,\n\t\t\t/* Title for RCS */\n\t\t\ttitleText,\n\t\t\ttitleVariables,\n\t\t\t/* Call Permission */\n\t\t\tshowCallPermissionCard,\n\t\t\tcallPermissionText,\n\t\t};\n\n\t\tconst { errors } = this.validateState(state);\n\n\t\tstate.error = errors;\n\n\t\treturn state;\n\t}\n\n\tparseTemplateConfiguration(template: RCSTemplateType): RCSTemplateConfig {\n\t\tlet config: RCSTemplateConfig;\n\t\tconst templateConfig = template?.content || ({} as RCSTemplateConfig);\n\t\tif (typeof templateConfig === 'string') {\n\t\t\ttry {\n\t\t\t\tconfig = JSON.parse(templateConfig) as RCSTemplateConfig;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Error parsing rcsTemplate component JSON:', error);\n\t\t\t\tconfig = { orientation: 'VERTICAL' } as RCSTemplateConfig;\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = templateConfig;\n\t\t}\n\t\treturn {\n\t\t\t...config,\n\t\t\ttemplateType: template?.templateType as RCS_TEMPLATE_TYPE,\n\t\t\tisMediaAfterBody: this.isRcsMediaAfterBody(template),\n\t\t};\n\t}\n\n\t/**\n\t * Determines, from the original `components[]` order, whether a non-TEXT\n\t * media header appears AFTER the body component. The library preview\n\t * otherwise always renders the media first; honouring this keeps\n\t * body-then-media templates (the third-party ordering for some\n\t * `text_message_with_media` templates) correct in the preview.\n\t */\n\tisRcsMediaAfterBody(template: RCSTemplateType): boolean {\n\t\tconst components = template?.components;\n\t\tif (!Array.isArray(components)) return false;\n\n\t\tconst mediaHeaderIndex = components.findIndex(\n\t\t\t(component) =>\n\t\t\t\tcomponent.type === 'HEADER' &&\n\t\t\t\t!!component.format &&\n\t\t\t\tcomponent.format !== HEADER_TYPES.TEXT,\n\t\t);\n\t\tconst bodyIndex = components.findIndex(\n\t\t\t(component) => component.type === 'BODY',\n\t\t);\n\n\t\treturn (\n\t\t\tmediaHeaderIndex > -1 && bodyIndex > -1 && mediaHeaderIndex > bodyIndex\n\t\t);\n\t}\n}\n"],"names":["TemplateCreatorHelper","dbFormattedTemplate","showSampleValues","pod","res","HEADER_TYPES","headerComponent","component","sampleValue","headerVarPlaceholder","originalVariable","normalizedName","editable","isChatbotCustomText","POD","reduxHeaderVar","state","emojiRegex","status","errors","templateHelperUtils","TemplateHelperUtils","isScrolled","scrollByElementId","elementId","NAME_LEN_LIMIT","NAME_LEN_ERROR","specialCharPattern","NO_SPECIAL_CHAR","REQUIRED_FIELD","CREATE_TEMPLATE_DOM_IDS","text","HEADER_TEXT_LEN_LIMIT","HEADER_LEN_ERROR","variableList","ONE_VAR_ALLOWED","HEADER_ASSET_LINK_ERROR","BODY_TEXT_LEN_LIMIT","BODY_LEN_ERROR","ACTIONS_TYPES","btnText","phoneNumber","QUICK_REPLY_BTN_TEXT_LIMIT","QUICK_REPLY_LEN_ERROR","BUTTON_EMOJI_ERROR","VALID_PHONE_NUMBER","customLink","placeholder","quickReplyErrors","button","i","QUICK_REPLY_NAME_LEN_LIMIT","buttons","el","QUICK_REPLY_NAME_ERROR","qrbErrorAcc","currentError","isV2","bodyVariable","bodyText","bodyComponent","bodyVarPlaceholder","matchedPlaceholderName","placeHolderNamePattern","t","normalizeName","COLORS","titleVariable","titleText","buttonComponent","actionsType","btnTexts","btn","btnPlaceholder","customUrl","editableVarPattern","allButtons","limitedTimeOfferComponent","dateTime","format","callPermissionComponent","data","isDuplicate","headerType","headerAssetLink","headerAssetName","headerText","headerVariables","bodyVariables","titleVariables","quickReply","ctaBtn","showCallPermissionCard","callPermissionText","template","config","templateConfig","error","components","mediaHeaderIndex","bodyIndex"],"mappings":"8WA6CO,MAAMA,CAAsB,CAC1B,6BACPC,EACAC,EACAC,EACC,CACD,MAAMC,EAMF,CACH,WAAYC,EAAAA,aAAa,KACzB,gBAAiB,CAAA,CAAC,EAGbC,EAAkBL,GAAqB,YAAY,KACvDM,GAAcA,EAAU,OAAS,QAAA,EAGnC,GAAID,EAAiB,CACpBF,EAAI,WAAaE,EAAgB,OACjCF,EAAI,WAAaE,EAAgB,KAEjCF,EAAI,gBAAkBE,EAAgB,SAAS,gBAAgB,CAAC,EAEhE,MAAME,EAAcF,EAAgB,SAAS,cAAc,CAAC,EACtDG,EAAuBR,EAAoB,SAAS,SAAS,CAAC,EAC9DS,EAAmBD,EACzB,GAAIA,EAAsB,CACzB,MAAME,EAAiBF,GACpB,QAAQ,KAAM,EAAE,EACjB,QAAQ,KAAM,EAAE,EAChB,QAAQ,KAAM,EAAE,EAChB,QAAQ,KAAM,EAAE,EAChB,QAAQ,KAAM,EAAE,EAChB,QAAQ,KAAM,EAAE,EACZG,EAAW,OAAO,KAAKH,CAAoB,EAC3CI,EACLV,IAAQW,EAAAA,IAAI,SACZJ,GACAA,GAAkB,WAAW,IAAI,GACjCA,GAAkB,SAAS,I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K,EAE3C,OAAAA,EAAM,MAAQG,EAEPH,CACR,CAEA,2BAA2B8E,EAA8C,CACxE,IAAIC,EACJ,MAAMC,EAAiBF,GAAU,SAAY,CAAA,EAC7C,GAAI,OAAOE,GAAmB,SAC7B,GAAI,CACHD,EAAS,KAAK,MAAMC,CAAc,CACnC,OAASC,EAAO,CACf,QAAQ,MAAM,4CAA6CA,CAAK,EAChEF,EAAS,CAAE,YAAa,UAAA,CACzB,MAEAA,EAASC,EAEV,MAAO,CACN,GAAGD,EACH,aAAcD,GAAU,aACxB,iBAAkB,KAAK,oBAAoBA,CAAQ,CAAA,CAErD,CASA,oBAAoBA,EAAoC,CACvD,MAAMI,EAAaJ,GAAU,WAC7B,GAAI,CAAC,MAAM,QAAQI,CAAU,EAAG,MAAO,GAEvC,MAAMC,EAAmBD,EAAW,UAClC3F,GACAA,EAAU,OAAS,UACnB,CAAC,CAACA,EAAU,QACZA,EAAU,SAAWF,eAAa,IAAA,EAE9B+F,EAAYF,EAAW,UAC3B3F,GAAcA,EAAU,OAAS,MAAA,EAGnC,OACC4F,EAAmB,IAAMC,EAAY,IAAMD,EAAmBC,CAEhE,CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"RCSTemplate.js","sources":["../../../../../src/components/template-preview/models/RCSTemplate.ts"],"sourcesContent":["import { Timestamp } from 'firebase-admin/firestore';\nimport { CHANNEL_TYPE } from './Channels';\nimport { TEMPLATE_STATUS } from './TemplateMeta';\nimport { WhatsappLikePreviewTypes, WhatsAppTemplate } from './WhatsAppTemplate';\n\nexport interface RCSPreviewProps extends WhatsappLikePreviewTypes {\n\tisCarousal?: boolean;\n}\nexport interface RCSTemplateType extends WhatsAppTemplate {\n\tid: string;\n\tstatus: TEMPLATE_STATUS;\n\tname: string;\n\tcontent?: string;\n\tmapping: { [key: string]: string[] | object[] };\n\tmediaTemplateActionButtonTypes: { [key: string]: string[] | object[] };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tcreatedAt: number;\n\tupdatedAt: number;\n\ttemplateType?: RCS_TEMPLATE_TYPE;\n\trcsBroadcastConfig?: {\n\t\tmapping: { [key: string]: string | object };\n\t};\n\thtmlContentUrl?: string;\n\ttemplateId?: string;\n\tchannel: CHANNEL_TYPE;\n\theaders?: string[];\n}\n\nexport interface RCSPreviewPropsV2 extends WhatsappLikePreviewTypes {\n\ttemplateConfiguration: RCSTemplateConfig;\n}\n\nexport interface RcsTemplate {\n\tcontent?: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tstatus: TEMPLATE_STATUS;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tcreatedAt: Timestamp;\n\tupdatedAt: Timestamp;\n}\n\nexport interface CreateRcsTemplatePayload {\n\tname: string;\n\tlabel: string;\n\tstoreId: string;\n\tcategory: string;\n\tchannelTemplateId: string;\n\tchannel: string;\n\tcontent: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tbotId: string;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tstatus: TEMPLATE_STATUS;\n\tcreatedAt: Timestamp;\n\tcreatedBy: string;\n\ttemplateCategory?: string;\n\tupdatedAt: Timestamp;\n\ttemplateId?: string;\n}\n\nexport enum RCS_TEMPLATE_STATUS {\n\tACTIVE = 'active',\n\tAPPROVED = 'approved',\n\tPENDING = 'pending',\n\tREJECTED = 'rejected',\n\tFAILED = 'Failed',\n}\n\nexport enum RCS_TEMPLATE_TYPE {\n\tTEXT_MESSAGE = 'text_message', //body and button(name and url)--> custom variable\n\tTEXT_MESSAGE_WITH_PDF = 'text_message_with_pdf', //body, and button(name and url)custom\n\tCAROUSEL = 'carousel', //body, and button(name and url)custom ,title\n\tRICH_CARD = 'rich_card', //body, and button(name and url)custom ,title\n\tUNKNOWN = 'unknown',\n}\n\nexport enum RCS_BUTTON_TYPE {\n\tREPLY = 'reply',\n\tURL_ACTION = 'url_action', // url --->\n\tDIALER_ACTION = 'dialer_action',\n\tVIEW_LOCATION_LATLONG = 'view_location_latlong',\n\tVIEW_LOCATION_QUERY = 'view_location_query',\n\tSHARE_LOCATION = 'share_location',\n\tCALENDAR_EVENT = 'calendar_event',\n}\n\nexport enum MEDIA_FORMAT {\n\tIMAGE = 'image',\n\tVIDEO = 'video',\n\tDOCUMENT = 'document',\n\tOTHER = 'other',\n}\n\nexport enum IMAGE_EXTENSIONS {\n\tJPG = 'jpg',\n\tJPEG = 'jpeg',\n\tPNG = 'png',\n\tGIF = 'gif',\n\tBMP = 'bmp',\n\tWEBP = 'webp',\n}\n\nexport enum VIDEO_EXTENSIONS {\n\tMP4 = 'mp4',\n\tMOV = 'mov',\n\tAVI = 'avi',\n\tMKV = 'mkv',\n\tWEBM = 'webm',\n}\n\nexport enum DOCUMENT_EXTENSIONS {\n\tPDF = 'pdf',\n\tDOC = 'doc',\n\tDOCX = 'docx',\n\tXLS = 'xls',\n\tXLSX = 'xlsx',\n\tPPT = 'ppt',\n\tPPTX = 'pptx',\n\tTXT = 'txt',\n}\n\nexport interface RCSTemplateConfig {\n\ttemplateType: RCS_TEMPLATE_TYPE | string;\n\theight: string;\n\torientation: string;\n}\n"],"names":["RCS_TEMPLATE_TYPE"],"mappings":"gFA+EO,IAAKA,GAAAA,IACXA,EAAA,aAAe,eACfA,EAAA,sBAAwB,wBACxBA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,QAAU,UALCA,IAAAA,GAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"RCSTemplate.js","sources":["../../../../../src/components/template-preview/models/RCSTemplate.ts"],"sourcesContent":["import { Timestamp } from 'firebase-admin/firestore';\nimport { CHANNEL_TYPE } from './Channels';\nimport { TEMPLATE_STATUS } from './TemplateMeta';\nimport { WhatsappLikePreviewTypes, WhatsAppTemplate } from './WhatsAppTemplate';\n\nexport interface RCSPreviewProps extends WhatsappLikePreviewTypes {\n\tisCarousal?: boolean;\n}\nexport interface RCSTemplateType extends WhatsAppTemplate {\n\tid: string;\n\tstatus: TEMPLATE_STATUS;\n\tname: string;\n\tcontent?: string;\n\tmapping: { [key: string]: string[] | object[] };\n\tmediaTemplateActionButtonTypes: { [key: string]: string[] | object[] };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tcreatedAt: number;\n\tupdatedAt: number;\n\ttemplateType?: RCS_TEMPLATE_TYPE;\n\trcsBroadcastConfig?: {\n\t\tmapping: { [key: string]: string | object };\n\t};\n\thtmlContentUrl?: string;\n\ttemplateId?: string;\n\tchannel: CHANNEL_TYPE;\n\theaders?: string[];\n}\n\nexport interface RCSPreviewPropsV2 extends WhatsappLikePreviewTypes {\n\ttemplateConfiguration: RCSTemplateConfig;\n}\n\nexport interface RcsTemplate {\n\tcontent?: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tstatus: TEMPLATE_STATUS;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tcreatedAt: Timestamp;\n\tupdatedAt: Timestamp;\n}\n\nexport interface CreateRcsTemplatePayload {\n\tname: string;\n\tlabel: string;\n\tstoreId: string;\n\tcategory: string;\n\tchannelTemplateId: string;\n\tchannel: string;\n\tcontent: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tbotId: string;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tstatus: TEMPLATE_STATUS;\n\tcreatedAt: Timestamp;\n\tcreatedBy: string;\n\ttemplateCategory?: string;\n\tupdatedAt: Timestamp;\n\ttemplateId?: string;\n}\n\nexport enum RCS_TEMPLATE_STATUS {\n\tACTIVE = 'active',\n\tAPPROVED = 'approved',\n\tPENDING = 'pending',\n\tREJECTED = 'rejected',\n\tFAILED = 'Failed',\n}\n\nexport enum RCS_TEMPLATE_TYPE {\n\tTEXT_MESSAGE = 'text_message', //body and button(name and url)--> custom variable\n\tTEXT_MESSAGE_WITH_PDF = 'text_message_with_pdf', //body, and button(name and url)custom\n\tCAROUSEL = 'carousel', //body, and button(name and url)custom ,title\n\tRICH_CARD = 'rich_card', //body, and button(name and url)custom ,title\n\tUNKNOWN = 'unknown',\n}\n\nexport enum RCS_BUTTON_TYPE {\n\tREPLY = 'reply',\n\tURL_ACTION = 'url_action', // url --->\n\tDIALER_ACTION = 'dialer_action',\n\tVIEW_LOCATION_LATLONG = 'view_location_latlong',\n\tVIEW_LOCATION_QUERY = 'view_location_query',\n\tSHARE_LOCATION = 'share_location',\n\tCALENDAR_EVENT = 'calendar_event',\n}\n\nexport enum MEDIA_FORMAT {\n\tIMAGE = 'image',\n\tVIDEO = 'video',\n\tDOCUMENT = 'document',\n\tOTHER = 'other',\n}\n\nexport enum IMAGE_EXTENSIONS {\n\tJPG = 'jpg',\n\tJPEG = 'jpeg',\n\tPNG = 'png',\n\tGIF = 'gif',\n\tBMP = 'bmp',\n\tWEBP = 'webp',\n}\n\nexport enum VIDEO_EXTENSIONS {\n\tMP4 = 'mp4',\n\tMOV = 'mov',\n\tAVI = 'avi',\n\tMKV = 'mkv',\n\tWEBM = 'webm',\n}\n\nexport enum DOCUMENT_EXTENSIONS {\n\tPDF = 'pdf',\n\tDOC = 'doc',\n\tDOCX = 'docx',\n\tXLS = 'xls',\n\tXLSX = 'xlsx',\n\tPPT = 'ppt',\n\tPPTX = 'pptx',\n\tTXT = 'txt',\n}\n\nexport interface RCSTemplateConfig {\n\ttemplateType: RCS_TEMPLATE_TYPE | string;\n\theight: string;\n\torientation: string;\n\t/**\n\t * For VERTICAL orientation only: whether the media/header should render\n\t * AFTER the body text instead of the default media-first layout. Derived\n\t * from the original `components[]` ordering so the preview matches\n\t * third-party body-then-media templates (e.g. `text_message_with_media`).\n\t */\n\tisMediaAfterBody?: boolean;\n}\n"],"names":["RCS_TEMPLATE_TYPE"],"mappings":"gFA+EO,IAAKA,GAAAA,IACXA,EAAA,aAAe,eACfA,EAAA,sBAAwB,wBACxBA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,QAAU,UALCA,IAAAA,GAAA,CAAA,CAAA"}
@@ -1,107 +1,103 @@
1
- import { jsxs as h, jsx as e, Fragment as n } from "react/jsx-runtime";
2
- import { useMemo as H } from "react";
3
- import { useTemplateModalContext as B } from "../../template-context-mapper/context/templateModalContext.js";
4
- import { isRichAndCarouselCards as v } from "../helpers/templateMiscHelper.js";
5
- import { VariableEditorHelper as D } from "../helpers/VariableEditorHelper.js";
6
- import { HEADER_TYPES as a } from "../models/TemplateMeta.js";
7
- import { ChatBtn as V } from "../WhatsApp/ChatBtn.js";
8
- import { RCSButtons as z } from "./RCSButtons.js";
9
- import { RCSMediaCard as E, PdfMediaCard as U } from "./RCSMediaCard.js";
10
- import { RCSPreviewContainer as j, HeaderTextContainer as G, TitleTextContainer as k, RcsHtmlContainer as F, RCSChatBtnContainer as W } from "./RCSPreview.styled.js";
11
- const T = new D(), re = (M) => {
1
+ import { jsx as e, jsxs as h, Fragment as d } from "react/jsx-runtime";
2
+ import { useMemo as T } from "react";
3
+ import { useTemplateModalContext as V } from "../../template-context-mapper/context/templateModalContext.js";
4
+ import { isRichAndCarouselCards as E } from "../helpers/templateMiscHelper.js";
5
+ import { VariableEditorHelper as z } from "../helpers/VariableEditorHelper.js";
6
+ import { HEADER_TYPES as i } from "../models/TemplateMeta.js";
7
+ import { ChatBtn as U } from "../WhatsApp/ChatBtn.js";
8
+ import { RCSButtons as j } from "./RCSButtons.js";
9
+ import { RCSMediaCard as S, PdfMediaCard as G } from "./RCSMediaCard.js";
10
+ import { HeaderTextContainer as k, RCSPreviewContainer as F, TitleTextContainer as W, RcsHtmlContainer as X, RCSChatBtnContainer as Y } from "./RCSPreview.styled.js";
11
+ const u = new z(), ie = (w) => {
12
12
  const {
13
- bodyText: u,
13
+ bodyText: y,
14
14
  titleText: m,
15
15
  headerMediaType: t,
16
- headerText: S,
17
- headerAssetLink: i,
16
+ headerText: N,
17
+ headerAssetLink: l,
18
18
  headerAssetName: p,
19
19
  imagePreviewStyles: g,
20
- size: y,
21
- bodyVariableList: w,
22
- headerVariableList: N,
23
- buttons: s,
20
+ size: f,
21
+ bodyVariableList: R,
22
+ headerVariableList: b,
23
+ buttons: n,
24
24
  carouselCardIndex: r,
25
- isWhatsappCarousel: R,
26
- isPreview: b,
27
- titleVariableList: I,
25
+ isWhatsappCarousel: A,
26
+ isPreview: I,
27
+ titleVariableList: L,
28
28
  templateConfiguration: o
29
- } = M, L = T.format(
30
- u?.replace(/</g, "&lt;").replace(/>/g, "&gt;"),
31
- w
32
- ), P = T.format(
33
- S?.replace(/</g, "&lt;").replace(/>/g, "&gt;"),
34
- N
35
- ), O = T.format(
29
+ } = w, P = u.format(
30
+ y?.replace(/</g, "&lt;").replace(/>/g, "&gt;"),
31
+ R
32
+ ), B = u.format(
33
+ N?.replace(/</g, "&lt;").replace(/>/g, "&gt;"),
34
+ b
35
+ ), O = u.format(
36
36
  m?.replace(/</g, "&lt;").replace(/>/g, "&gt;"),
37
- I
37
+ L
38
38
  ), {
39
- selectedCarouselIndex: d,
39
+ selectedCarouselIndex: s,
40
40
  isProductCarouselType: x,
41
- errorIndexes: A,
42
- isCarouselHovered: _
43
- } = B(), f = H(() => v(
41
+ errorIndexes: _,
42
+ isCarouselHovered: D
43
+ } = V(), M = T(() => E(
44
44
  o?.templateType
45
- ), [o?.templateType]), l = H(() => o?.orientation == "HORIZONTAL", [o]);
45
+ ), [o?.templateType]), a = T(() => o?.orientation == "HORIZONTAL", [o]), H = T(() => !a && !!o?.isMediaAfterBody, [a, o]), v = t === i.TEXT ? /* @__PURE__ */ e(k, { dangerouslySetInnerHTML: { __html: B } }) : t !== i.NONE && l && t !== i.DOCUMENT ? /* @__PURE__ */ e(
46
+ S,
47
+ {
48
+ headerAssetLink: l,
49
+ headerAssetName: p,
50
+ mediaType: t,
51
+ imagePreviewStyles: t === i.IMAGE ? g : {}
52
+ }
53
+ ) : null;
46
54
  return /* @__PURE__ */ h(
47
- j,
55
+ F,
48
56
  {
49
57
  isCarouselCard: r != null && r > -1,
50
- showBorder: r != null && r === d || x && r != null && r > -1 && d != null && d > -1,
51
- hasError: A?.includes(r ?? -2),
52
- isWhatsappCarousel: R,
53
- isPreview: b,
54
- showDashedBorder: x && _ && (d ?? -1) < 0 && (r ?? -1) > -1,
55
- needBorder: f,
56
- isHorizontalOrientation: l,
58
+ showBorder: r != null && r === s || x && r != null && r > -1 && s != null && s > -1,
59
+ hasError: _?.includes(r ?? -2),
60
+ isWhatsappCarousel: A,
61
+ isPreview: I,
62
+ showDashedBorder: x && D && (s ?? -1) < 0 && (r ?? -1) > -1,
63
+ needBorder: M,
64
+ isHorizontalOrientation: a,
57
65
  children: [
58
- !l && /* @__PURE__ */ e(n, { children: t === a.TEXT ? /* @__PURE__ */ e(
59
- G,
60
- {
61
- dangerouslySetInnerHTML: { __html: P }
62
- }
63
- ) : t !== a.NONE && i && t !== a.DOCUMENT ? /* @__PURE__ */ e(
64
- E,
65
- {
66
- headerAssetLink: i,
67
- headerAssetName: p,
68
- mediaType: t,
69
- imagePreviewStyles: t === a.IMAGE ? g : {}
70
- }
71
- ) : null }),
72
- /* @__PURE__ */ h("div", { style: { width: l ? "50%" : "" }, children: [
73
- /* @__PURE__ */ h("div", { className: f ? "" : "text--template", children: [
74
- !!m && /* @__PURE__ */ e(n, { children: /* @__PURE__ */ e(
75
- k,
66
+ !a && !H && v,
67
+ /* @__PURE__ */ h("div", { style: { width: a ? "50%" : "" }, children: [
68
+ /* @__PURE__ */ h("div", { className: M ? "" : "text--template", children: [
69
+ !!m && /* @__PURE__ */ e(d, { children: /* @__PURE__ */ e(
70
+ W,
76
71
  {
77
72
  dangerouslySetInnerHTML: {
78
73
  __html: O
79
74
  }
80
75
  }
81
76
  ) }),
82
- !!u && /* @__PURE__ */ e(n, { children: /* @__PURE__ */ e(
83
- F,
77
+ !!y && /* @__PURE__ */ e(d, { children: /* @__PURE__ */ e(
78
+ X,
84
79
  {
85
80
  dangerouslySetInnerHTML: {
86
- __html: L
81
+ __html: P
87
82
  },
88
83
  style: { paddingTop: m ? 0 : 12 }
89
84
  }
90
85
  ) }),
91
- t === a.DOCUMENT ? /* @__PURE__ */ e(U, { headerAssetLink: i, headerAssetName: p }) : /* @__PURE__ */ e(n, {})
86
+ t === i.DOCUMENT ? /* @__PURE__ */ e(G, { headerAssetLink: l, headerAssetName: p }) : /* @__PURE__ */ e(d, {})
92
87
  ] }),
93
- s && s.length > 0 ? v(
88
+ !a && H && v,
89
+ n && n.length > 0 ? E(
94
90
  o?.templateType
95
- ) ? /* @__PURE__ */ e(n, { children: s.map((c, C) => /* @__PURE__ */ e(V, { text: c.text, size: y }, C)) }) : /* @__PURE__ */ e(W, { children: s.map((c, C) => /* @__PURE__ */ e(z, { text: c.text, size: y }, C)) }) : null
91
+ ) ? /* @__PURE__ */ e(d, { children: n.map((c, C) => /* @__PURE__ */ e(U, { text: c.text, size: f }, C)) }) : /* @__PURE__ */ e(Y, { children: n.map((c, C) => /* @__PURE__ */ e(j, { text: c.text, size: f }, C)) }) : null
96
92
  ] }),
97
- l && t !== a.NONE && i && t !== a.DOCUMENT && /* @__PURE__ */ e(
98
- E,
93
+ a && t !== i.NONE && l && t !== i.DOCUMENT && /* @__PURE__ */ e(
94
+ S,
99
95
  {
100
- headerAssetLink: i,
96
+ headerAssetLink: l,
101
97
  headerAssetName: p,
102
98
  mediaType: t,
103
- imagePreviewStyles: t === a.IMAGE ? g : {},
104
- isHorizontal: l
99
+ imagePreviewStyles: t === i.IMAGE ? g : {},
100
+ isHorizontal: a
105
101
  }
106
102
  )
107
103
  ]
@@ -109,6 +105,6 @@ const T = new D(), re = (M) => {
109
105
  );
110
106
  };
111
107
  export {
112
- re as RCSChatPreview
108
+ ie as RCSChatPreview
113
109
  };
114
110
  //# sourceMappingURL=RCSChatPreview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RCSChatPreview.js","sources":["../../../../../src/components/template-preview/RCS/RCSChatPreview.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useTemplateModalContext } from '@src/components/template-context-mapper/context/templateModalContext';\nimport { isRichAndCarouselCards } from '../helpers/templateMiscHelper';\nimport { VariableEditorHelper } from '../helpers/VariableEditorHelper';\nimport { RCS_TEMPLATE_TYPE, RCSPreviewPropsV2 } from '../models/RCSTemplate';\nimport { HEADER_TYPES } from '../models/TemplateMeta';\nimport { ChatBtn } from '../WhatsApp/ChatBtn';\nimport { RCSButtons } from './RCSButtons';\nimport { PdfMediaCard, RCSMediaCard } from './RCSMediaCard';\nimport {\n\tHeaderTextContainer,\n\tRCSChatBtnContainer,\n\tRcsHtmlContainer,\n\tRCSPreviewContainer,\n\tTitleTextContainer,\n} from './RCSPreview.styled';\n\nconst variableEditorHelper = new VariableEditorHelper();\n\nexport const RCSChatPreview = (props: RCSPreviewPropsV2) => {\n\tconst {\n\t\tbodyText,\n\t\ttitleText,\n\t\theaderMediaType,\n\t\theaderText,\n\t\theaderAssetLink,\n\t\theaderAssetName,\n\t\timagePreviewStyles,\n\t\tsize,\n\t\tbodyVariableList,\n\t\theaderVariableList,\n\t\tbuttons,\n\t\tcarouselCardIndex,\n\t\tisWhatsappCarousel,\n\t\tisPreview,\n\t\ttitleVariableList,\n\t\ttemplateConfiguration,\n\t} = props;\n\n\tconst bodyHTML = variableEditorHelper.format(\n\t\tbodyText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\tbodyVariableList,\n\t);\n\tconst headerHtml = variableEditorHelper.format(\n\t\theaderText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\theaderVariableList,\n\t);\n\tconst titleHtml = variableEditorHelper.format(\n\t\ttitleText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\ttitleVariableList,\n\t);\n\tconst {\n\t\tselectedCarouselIndex,\n\t\tisProductCarouselType,\n\t\terrorIndexes,\n\t\tisCarouselHovered,\n\t} = useTemplateModalContext();\n\n\tconst isRichCardTypeTemplate = useMemo(() => {\n\t\treturn isRichAndCarouselCards(\n\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t);\n\t}, [templateConfiguration?.templateType]);\n\n\tconst isHorizontalOrientation = useMemo(() => {\n\t\treturn templateConfiguration?.orientation == 'HORIZONTAL';\n\t}, [templateConfiguration]);\n\n\treturn (\n\t\t<RCSPreviewContainer\n\t\t\tisCarouselCard={carouselCardIndex != undefined && carouselCardIndex > -1}\n\t\t\tshowBorder={\n\t\t\t\t(carouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex === selectedCarouselIndex) ||\n\t\t\t\t(isProductCarouselType &&\n\t\t\t\t\tcarouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex > -1 &&\n\t\t\t\t\tselectedCarouselIndex != undefined &&\n\t\t\t\t\tselectedCarouselIndex > -1)\n\t\t\t}\n\t\t\thasError={errorIndexes?.includes(carouselCardIndex ?? -2)}\n\t\t\tisWhatsappCarousel={isWhatsappCarousel}\n\t\t\tisPreview={isPreview}\n\t\t\tshowDashedBorder={\n\t\t\t\tisProductCarouselType &&\n\t\t\t\tisCarouselHovered &&\n\t\t\t\t(selectedCarouselIndex ?? -1) < 0 &&\n\t\t\t\t(carouselCardIndex ?? -1) > -1\n\t\t\t}\n\t\t\tneedBorder={isRichCardTypeTemplate}\n\t\t\tisHorizontalOrientation={isHorizontalOrientation}\n\t\t>\n\t\t\t{!isHorizontalOrientation && (\n\t\t\t\t<>\n\t\t\t\t\t{headerMediaType === HEADER_TYPES.TEXT ? (\n\t\t\t\t\t\t<HeaderTextContainer\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={{ __html: headerHtml }}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : headerMediaType !== HEADER_TYPES.NONE &&\n\t\t\t\t\t headerAssetLink &&\n\t\t\t\t\t headerMediaType !== HEADER_TYPES.DOCUMENT ? (\n\t\t\t\t\t\t<RCSMediaCard\n\t\t\t\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\t\t\t\tmediaType={headerMediaType}\n\t\t\t\t\t\t\timagePreviewStyles={\n\t\t\t\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null}\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t<div style={{ width: isHorizontalOrientation ? '50%' : '' }}>\n\t\t\t\t<div className={isRichCardTypeTemplate ? '' : 'text--template'}>\n\t\t\t\t\t{!!titleText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<TitleTextContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: titleHtml,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{!!bodyText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RcsHtmlContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: bodyHTML,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tstyle={{ paddingTop: titleText ? 0 : 12 }}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t\t{headerMediaType === HEADER_TYPES.DOCUMENT ? (\n\t\t\t\t\t\t<PdfMediaCard {...{ headerAssetLink, headerAssetName }} />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<></>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t{buttons && buttons.length > 0 ? (\n\t\t\t\t\tisRichAndCarouselCards(\n\t\t\t\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t\t\t\t) ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<ChatBtn key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<RCSChatBtnContainer>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<RCSButtons key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</RCSChatBtnContainer>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{isHorizontalOrientation &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.NONE &&\n\t\t\t\theaderAssetLink &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.DOCUMENT && (\n\t\t\t\t\t<RCSMediaCard\n\t\t\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\t\t\tmediaType={headerMediaType}\n\t\t\t\t\t\timagePreviewStyles={\n\t\t\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisHorizontal={isHorizontalOrientation}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</RCSPreviewContainer>\n\t);\n};\n"],"names":["variableEditorHelper","VariableEditorHelper","RCSChatPreview","props","bodyText","titleText","headerMediaType","headerText","headerAssetLink","headerAssetName","imagePreviewStyles","size","bodyVariableList","headerVariableList","buttons","carouselCardIndex","isWhatsappCarousel","isPreview","titleVariableList","templateConfiguration","bodyHTML","headerHtml","titleHtml","selectedCarouselIndex","isProductCarouselType","errorIndexes","isCarouselHovered","useTemplateModalContext","isRichCardTypeTemplate","useMemo","isRichAndCarouselCards","isHorizontalOrientation","jsxs","RCSPreviewContainer","jsx","Fragment","HEADER_TYPES","HeaderTextContainer","RCSMediaCard","TitleTextContainer","RcsHtmlContainer","PdfMediaCard","button","i","ChatBtn","RCSChatBtnContainer","RCSButtons"],"mappings":";;;;;;;;;;AAiBA,MAAMA,IAAuB,IAAIC,EAAA,GAEpBC,KAAiB,CAACC,MAA6B;AAC3D,QAAM;AAAA,IACL,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,MAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA,IACGhB,GAEEiB,IAAWpB,EAAqB;AAAA,IACrCI,GAAU,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAAA,IACpDQ;AAAA,EAAA,GAEKS,IAAarB,EAAqB;AAAA,IACvCO,GAAY,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAAA,IACtDM;AAAA,EAAA,GAEKS,IAAYtB,EAAqB;AAAA,IACtCK,GAAW,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAAA,IACrDa;AAAA,EAAA,GAEK;AAAA,IACL,uBAAAK;AAAA,IACA,uBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,mBAAAC;AAAA,EAAA,IACGC,EAAA,GAEEC,IAAyBC,EAAQ,MAC/BC;AAAA,IACNX,GAAuB;AAAA,EAAA,GAEtB,CAACA,GAAuB,YAAY,CAAC,GAElCY,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AGA,CAAC,CAAClB,KACF,gBAAA8B,EAAAC,GAAA,EACC,UAAA,gBAAAD;AAAA,cAACM;AAAA,cAAA;AAAA,gBACA,yBAAyB;AAAA,kBACxB,QAAQpB;AAAA,gBAAA;AAAA,gBAET,OAAO,EAAE,YAAYf,IAAY,IAAI,GAAA;AAAA,cAAG;AAAA,YAAA,GAE1C;AAAA,YAEAC,MAAoB8B,EAAa,WACjC,gBAAAF,EAACO,GAAA,EAAmB,iBAAAjC,GAAiB,iBAAAC,EAAgB,CAAG,IAExD,gBAAAyB,EAAAC,GAAA,CAAA,CAAE;AAAA,UAAA,GAEJ;AAAA,UAECrB,KAAWA,EAAQ,SAAS,IAC5BgB;AAAA,YACCX,GAAuB;AAAA,UAAA,IAEvB,gBAAAe,EAAAC,GAAA,EACE,UAAArB,EAAQ,IAAI,CAAC4B,GAAQC,MACrB,gBAAAT,EAACU,GAAA,EAAgB,MAAMF,EAAO,MAAM,MAAA/B,EAAA,GAAtBgC,CAAkC,CAChD,EAAA,CACF,IAEA,gBAAAT,EAACW,GAAA,EACC,UAAA/B,EAAQ,IAAI,CAAC4B,GAAQC,MACrB,gBAAAT,EAACY,GAAA,EAAmB,MAAMJ,EAAO,MAAM,MAAA/B,EAAA,GAAtBgC,CAAkC,CACnD,GACF,IAEE;AAAA,QAAA,GACL;AAAA,QACCZ,KACAzB,MAAoB8B,EAAa,QACjC5B,KACAF,MAAoB8B,EAAa,YAChC,gBAAAF;AAAA,UAACI;AAAA,UAAA;AAAA,YACA,iBAAA9B;AAAA,YACA,iBAAAC;AAAA,YACA,WAAWH;AAAA,YACX,oBACCA,MAAoB8B,EAAa,QAAQ1B,IAAqB,CAAA;AAAA,YAE/D,cAAcqB;AAAA,UAAA;AAAA,QAAA;AAAA,MACf;AAAA,IAAA;AAAA,EAAA;AAIL;"}
1
+ {"version":3,"file":"RCSChatPreview.js","sources":["../../../../../src/components/template-preview/RCS/RCSChatPreview.tsx"],"sourcesContent":["import { useMemo } from 'react';\nimport { useTemplateModalContext } from '@src/components/template-context-mapper/context/templateModalContext';\nimport { isRichAndCarouselCards } from '../helpers/templateMiscHelper';\nimport { VariableEditorHelper } from '../helpers/VariableEditorHelper';\nimport { RCS_TEMPLATE_TYPE, RCSPreviewPropsV2 } from '../models/RCSTemplate';\nimport { HEADER_TYPES } from '../models/TemplateMeta';\nimport { ChatBtn } from '../WhatsApp/ChatBtn';\nimport { RCSButtons } from './RCSButtons';\nimport { PdfMediaCard, RCSMediaCard } from './RCSMediaCard';\nimport {\n\tHeaderTextContainer,\n\tRCSChatBtnContainer,\n\tRcsHtmlContainer,\n\tRCSPreviewContainer,\n\tTitleTextContainer,\n} from './RCSPreview.styled';\n\nconst variableEditorHelper = new VariableEditorHelper();\n\nexport const RCSChatPreview = (props: RCSPreviewPropsV2) => {\n\tconst {\n\t\tbodyText,\n\t\ttitleText,\n\t\theaderMediaType,\n\t\theaderText,\n\t\theaderAssetLink,\n\t\theaderAssetName,\n\t\timagePreviewStyles,\n\t\tsize,\n\t\tbodyVariableList,\n\t\theaderVariableList,\n\t\tbuttons,\n\t\tcarouselCardIndex,\n\t\tisWhatsappCarousel,\n\t\tisPreview,\n\t\ttitleVariableList,\n\t\ttemplateConfiguration,\n\t} = props;\n\n\tconst bodyHTML = variableEditorHelper.format(\n\t\tbodyText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\tbodyVariableList,\n\t);\n\tconst headerHtml = variableEditorHelper.format(\n\t\theaderText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\theaderVariableList,\n\t);\n\tconst titleHtml = variableEditorHelper.format(\n\t\ttitleText?.replace(/</g, '&lt;').replace(/>/g, '&gt;'),\n\t\ttitleVariableList,\n\t);\n\tconst {\n\t\tselectedCarouselIndex,\n\t\tisProductCarouselType,\n\t\terrorIndexes,\n\t\tisCarouselHovered,\n\t} = useTemplateModalContext();\n\n\tconst isRichCardTypeTemplate = useMemo(() => {\n\t\treturn isRichAndCarouselCards(\n\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t);\n\t}, [templateConfiguration?.templateType]);\n\n\tconst isHorizontalOrientation = useMemo(() => {\n\t\treturn templateConfiguration?.orientation == 'HORIZONTAL';\n\t}, [templateConfiguration]);\n\n\t// For VERTICAL templates whose original `components[]` order is\n\t// body-then-media, render the media after the body instead of the default\n\t// media-first layout. Defaults to false → unchanged behaviour.\n\tconst isMediaAfterBody = useMemo(() => {\n\t\treturn (\n\t\t\t!isHorizontalOrientation && !!templateConfiguration?.isMediaAfterBody\n\t\t);\n\t}, [isHorizontalOrientation, templateConfiguration]);\n\n\tconst verticalMediaHeader =\n\t\theaderMediaType === HEADER_TYPES.TEXT ? (\n\t\t\t<HeaderTextContainer dangerouslySetInnerHTML={{ __html: headerHtml }} />\n\t\t) : headerMediaType !== HEADER_TYPES.NONE &&\n\t\t headerAssetLink &&\n\t\t headerMediaType !== HEADER_TYPES.DOCUMENT ? (\n\t\t\t<RCSMediaCard\n\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\tmediaType={headerMediaType}\n\t\t\t\timagePreviewStyles={\n\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t}\n\t\t\t/>\n\t\t) : null;\n\n\treturn (\n\t\t<RCSPreviewContainer\n\t\t\tisCarouselCard={carouselCardIndex != undefined && carouselCardIndex > -1}\n\t\t\tshowBorder={\n\t\t\t\t(carouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex === selectedCarouselIndex) ||\n\t\t\t\t(isProductCarouselType &&\n\t\t\t\t\tcarouselCardIndex != undefined &&\n\t\t\t\t\tcarouselCardIndex > -1 &&\n\t\t\t\t\tselectedCarouselIndex != undefined &&\n\t\t\t\t\tselectedCarouselIndex > -1)\n\t\t\t}\n\t\t\thasError={errorIndexes?.includes(carouselCardIndex ?? -2)}\n\t\t\tisWhatsappCarousel={isWhatsappCarousel}\n\t\t\tisPreview={isPreview}\n\t\t\tshowDashedBorder={\n\t\t\t\tisProductCarouselType &&\n\t\t\t\tisCarouselHovered &&\n\t\t\t\t(selectedCarouselIndex ?? -1) < 0 &&\n\t\t\t\t(carouselCardIndex ?? -1) > -1\n\t\t\t}\n\t\t\tneedBorder={isRichCardTypeTemplate}\n\t\t\tisHorizontalOrientation={isHorizontalOrientation}\n\t\t>\n\t\t\t{!isHorizontalOrientation && !isMediaAfterBody && verticalMediaHeader}\n\t\t\t<div style={{ width: isHorizontalOrientation ? '50%' : '' }}>\n\t\t\t\t<div className={isRichCardTypeTemplate ? '' : 'text--template'}>\n\t\t\t\t\t{!!titleText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<TitleTextContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: titleHtml,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{!!bodyText && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RcsHtmlContainer\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t__html: bodyHTML,\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tstyle={{ paddingTop: titleText ? 0 : 12 }}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t\t{headerMediaType === HEADER_TYPES.DOCUMENT ? (\n\t\t\t\t\t\t<PdfMediaCard {...{ headerAssetLink, headerAssetName }} />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<></>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\n\t\t\t\t{!isHorizontalOrientation && isMediaAfterBody && verticalMediaHeader}\n\n\t\t\t\t{buttons && buttons.length > 0 ? (\n\t\t\t\t\tisRichAndCarouselCards(\n\t\t\t\t\t\ttemplateConfiguration?.templateType as RCS_TEMPLATE_TYPE,\n\t\t\t\t\t) ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<ChatBtn key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<RCSChatBtnContainer>\n\t\t\t\t\t\t\t{buttons.map((button, i) => (\n\t\t\t\t\t\t\t\t<RCSButtons key={i} text={button.text} size={size} />\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</RCSChatBtnContainer>\n\t\t\t\t\t)\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{isHorizontalOrientation &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.NONE &&\n\t\t\t\theaderAssetLink &&\n\t\t\t\theaderMediaType !== HEADER_TYPES.DOCUMENT && (\n\t\t\t\t\t<RCSMediaCard\n\t\t\t\t\t\theaderAssetLink={headerAssetLink}\n\t\t\t\t\t\theaderAssetName={headerAssetName}\n\t\t\t\t\t\tmediaType={headerMediaType}\n\t\t\t\t\t\timagePreviewStyles={\n\t\t\t\t\t\t\theaderMediaType === HEADER_TYPES.IMAGE ? imagePreviewStyles : {}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisHorizontal={isHorizontalOrientation}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t</RCSPreviewContainer>\n\t);\n};\n"],"names":["variableEditorHelper","VariableEditorHelper","RCSChatPreview","props","bodyText","titleText","headerMediaType","headerText","headerAssetLink","headerAssetName","imagePreviewStyles","size","bodyVariableList","headerVariableList","buttons","carouselCardIndex","isWhatsappCarousel","isPreview","titleVariableList","templateConfiguration","bodyHTML","headerHtml","titleHtml","selectedCarouselIndex","isProductCarouselType","errorIndexes","isCarouselHovered","useTemplateModalContext","isRichCardTypeTemplate","useMemo","isRichAndCarouselCards","isHorizontalOrientation","isMediaAfterBody","verticalMediaHeader","HEADER_TYPES","jsx","HeaderTextContainer","RCSMediaCard","jsxs","RCSPreviewContainer","Fragment","TitleTextContainer","RcsHtmlContainer","PdfMediaCard","button","i","ChatBtn","RCSChatBtnContainer","RCSButtons"],"mappings":";;;;;;;;;;AAiBA,MAAMA,IAAuB,IAAIC,EAAA,GAEpBC,KAAiB,CAACC,MAA6B;AAC3D,QAAM;AAAA,IACL,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,MAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,uBAAAC;AAAA,EAAA,IACGhB,GAEEiB,IAAWpB,EAAqB;AAAA,IACrCI,GAAU,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAAA,IACpDQ;AAAA,EAAA,GAEKS,IAAarB,EAAqB;AAAA,IACvCO,GAAY,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAAA,IACtDM;AAAA,EAAA,GAEKS,IAAYtB,EAAqB;AAAA,IACtCK,GAAW,QAAQ,MAAM,MAAM,EAAE,QAAQ,MAAM,MAAM;AAAA,IACrDa;AAAA,EAAA,GAEK;AAAA,IACL,uBAAAK;AAAA,IACA,uBAAAC;AAAA,IACA,cAAAC;AAAA,IACA,mBAAAC;AAAA,EAAA,IACGC,EAAA,GAEEC,IAAyBC,EAAQ,MAC/BC;AAAA,IACNX,GAAuB;AAAA,EAAA,GAEtB,CAACA,GAAuB,YAAY,CAAC,GAElCY,IAA0BF,EAAQ,MAChCV,GAAuB,eAAe,cAC3C,CAACA,CAAqB,CAAC,GAKpBa,IAAmBH,EAAQ,MAE/B,CAACE,KAA2B,CAAC,CAACZ,GAAuB,kBAEpD,CAACY,GAAyBZ,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yBAAyB;AAAA,kBACxB,QAAQtB;AAAA,gBAAA;AAAA,gBAET,OAAO,EAAE,YAAYf,IAAY,IAAI,GAAA;AAAA,cAAG;AAAA,YAAA,GAE1C;AAAA,YAEAC,MAAoB4B,EAAa,WACjC,gBAAAC,EAACQ,GAAA,EAAmB,iBAAAnC,GAAiB,iBAAAC,EAAgB,CAAG,IAExD,gBAAA0B,EAAAK,GAAA,CAAA,CAAE;AAAA,UAAA,GAEJ;AAAA,UAEC,CAACT,KAA2BC,KAAoBC;AAAA,UAEhDnB,KAAWA,EAAQ,SAAS,IAC5BgB;AAAA,YACCX,GAAuB;AAAA,UAAA,IAEvB,gBAAAgB,EAAAK,GAAA,EACE,UAAA1B,EAAQ,IAAI,CAAC8B,GAAQC,MACrB,gBAAAV,EAACW,GAAA,EAAgB,MAAMF,EAAO,MAAM,MAAAjC,EAAA,GAAtBkC,CAAkC,CAChD,EAAA,CACF,IAEA,gBAAAV,EAACY,GAAA,EACC,UAAAjC,EAAQ,IAAI,CAAC8B,GAAQC,MACrB,gBAAAV,EAACa,GAAA,EAAmB,MAAMJ,EAAO,MAAM,MAAAjC,EAAA,GAAtBkC,CAAkC,CACnD,GACF,IAEE;AAAA,QAAA,GACL;AAAA,QACCd,KACAzB,MAAoB4B,EAAa,QACjC1B,KACAF,MAAoB4B,EAAa,YAChC,gBAAAC;AAAA,UAACE;AAAA,UAAA;AAAA,YACA,iBAAA7B;AAAA,YACA,iBAAAC;AAAA,YACA,WAAWH;AAAA,YACX,oBACCA,MAAoB4B,EAAa,QAAQxB,IAAqB,CAAA;AAAA,YAE/D,cAAcqB;AAAA,UAAA;AAAA,QAAA;AAAA,MACf;AAAA,IAAA;AAAA,EAAA;AAIL;"}
@@ -30,4 +30,12 @@ export declare class TemplateCreatorHelper {
30
30
  pod?: string;
31
31
  }): Promise<CreateTemplateType>;
32
32
  parseTemplateConfiguration(template: RCSTemplateType): RCSTemplateConfig;
33
+ /**
34
+ * Determines, from the original `components[]` order, whether a non-TEXT
35
+ * media header appears AFTER the body component. The library preview
36
+ * otherwise always renders the media first; honouring this keeps
37
+ * body-then-media templates (the third-party ordering for some
38
+ * `text_message_with_media` templates) correct in the preview.
39
+ */
40
+ isRcsMediaAfterBody(template: RCSTemplateType): boolean;
33
41
  }
@@ -1,14 +1,14 @@
1
1
  import { format as w } from "date-fns";
2
2
  import { COLORS as _ } from "../../../constants/Theme.js";
3
3
  import { specialCharPattern as U, placeHolderNamePattern as B, editableVarPattern as M } from "../constants/regexPatterns.js";
4
- import { REQUIRED_FIELD as h, NAME_LEN_LIMIT as S, NAME_LEN_ERROR as H, NO_SPECIAL_CHAR as Y, HEADER_TEXT_LEN_LIMIT as N, HEADER_LEN_ERROR as R, ONE_VAR_ALLOWED as $, HEADER_ASSET_LINK_ERROR as q, BODY_TEXT_LEN_LIMIT as Q, BODY_LEN_ERROR as K, QUICK_REPLY_BTN_TEXT_LIMIT as L, QUICK_REPLY_LEN_ERROR as y, BUTTON_EMOJI_ERROR as x, VALID_PHONE_NUMBER as W, QUICK_REPLY_NAME_LEN_LIMIT as X, CREATE_TEMPLATE_DOM_IDS as u, QUICK_REPLY_NAME_ERROR as j } from "../constants/TemplateConstants.js";
5
- import { HEADER_TYPES as f, ACTIONS_TYPES as d } from "../models/TemplateMeta.js";
4
+ import { REQUIRED_FIELD as h, NAME_LEN_LIMIT as S, NAME_LEN_ERROR as H, NO_SPECIAL_CHAR as Y, HEADER_TEXT_LEN_LIMIT as R, HEADER_LEN_ERROR as N, ONE_VAR_ALLOWED as $, HEADER_ASSET_LINK_ERROR as q, BODY_TEXT_LEN_LIMIT as Q, BODY_LEN_ERROR as K, QUICK_REPLY_BTN_TEXT_LIMIT as L, QUICK_REPLY_LEN_ERROR as y, BUTTON_EMOJI_ERROR as x, VALID_PHONE_NUMBER as W, QUICK_REPLY_NAME_LEN_LIMIT as X, CREATE_TEMPLATE_DOM_IDS as u, QUICK_REPLY_NAME_ERROR as j } from "../constants/TemplateConstants.js";
5
+ import { HEADER_TYPES as m, ACTIONS_TYPES as f } from "../models/TemplateMeta.js";
6
6
  import { POD as v } from "../models/WhatsAppTemplate.js";
7
7
  import { TemplateHelperUtils as z } from "../utils/TemplateHelperUtils.js";
8
8
  class ae {
9
9
  parseDataFromHeaderComponent(t, o, n) {
10
10
  const e = {
11
- headerType: f.NONE,
11
+ headerType: m.NONE,
12
12
  headerVariables: []
13
13
  }, i = t?.components?.find(
14
14
  (r) => r.type === "HEADER"
@@ -17,14 +17,14 @@ class ae {
17
17
  e.headerType = i.format, e.headerText = i.text, e.headerAssetLink = i.example?.header_handle?.[0];
18
18
  const r = i.example?.header_text?.[0], s = t.mapping?.header?.[0], a = s;
19
19
  if (s) {
20
- const l = s?.replace("[[", "").replace("]]", "").replace("{{", "").replace("}}", "").replace("((", "").replace("))", ""), p = /\(\(/.test(s), c = n === v.CHATBOT && a && a?.startsWith("((") && a?.endsWith("))"), m = {
20
+ const l = s?.replace("[[", "").replace("]]", "").replace("{{", "").replace("}}", "").replace("((", "").replace("))", ""), c = /\(\(/.test(s), p = n === v.CHATBOT && a && a?.startsWith("((") && a?.endsWith("))"), d = {
21
21
  idx: 0,
22
- variableVal: o || c ? r : a,
23
- editable: p,
24
- editableDefaultValues: p ? void 0 : r,
22
+ variableVal: o || p ? r : a,
23
+ editable: c,
24
+ editableDefaultValues: c ? void 0 : r,
25
25
  variableName: l
26
26
  };
27
- e.headerVariables = [m], i.example?.header_text?.length && (e.headerText = e.headerText?.replace(
27
+ e.headerVariables = [d], i.example?.header_text?.length && (e.headerText = e.headerText?.replace(
28
28
  /** since there will be only one variable in template so hard replace */
29
29
  "{{1}}",
30
30
  `{{${l}}}`
@@ -55,47 +55,47 @@ class ae {
55
55
  block: "nearest"
56
56
  });
57
57
  };
58
- if (t.meta?.name ? t.meta.name?.trim().length > S ? (e.meta.name = H, n = "invalid") : U.test(t.meta.name?.trim()) && (e.meta.name = Y, n = "invalid") : (e.meta.name = h, n = "invalid"), e.meta.name && !r && (s(u.name), r = !0), t.headerType === f.TEXT) {
58
+ if (t.meta?.name ? t.meta.name?.trim().length > S ? (e.meta.name = H, n = "invalid") : U.test(t.meta.name?.trim()) && (e.meta.name = Y, n = "invalid") : (e.meta.name = h, n = "invalid"), e.meta.name && !r && (s(u.name), r = !0), t.headerType === m.TEXT) {
59
59
  const a = t.headerText?.trim() ?? "";
60
60
  if (!a)
61
61
  e.header = h, n = "invalid";
62
- else if (a.length > N)
63
- e.header = R, n = "invalid";
62
+ else if (a.length > R)
63
+ e.header = N, n = "invalid";
64
64
  else {
65
65
  const l = i.getTemplateVariablesFromState(a);
66
66
  l && l.length > 1 && (e.header = $, n = "invalid");
67
67
  }
68
- } else t.headerType === f.DOCUMENT || t.headerType === f.IMAGE || (t.headerType, f.VIDEO);
69
- if ((t.headerType === f.DOCUMENT || t.headerType === f.IMAGE || t.headerType === f.VIDEO) && (t.headerAssetLink || (e.header = q, n = "invalid")), e.header && !r && (s(u.header), r = !0), t.bodyText ? t.bodyTextRaw && t.bodyTextRaw?.trim().length > Q && (e.body = K, n = "invalid") : (e.body = h, n = "invalid"), e.body && !r && (s(u.body), r = !0), t.footerText && t.footerText.length > N && (e.footer = R, n = "invalid"), e?.footer && !r && (s(u.footer), r = !0), t.actionsType === d.CTA_BTN) {
68
+ } else t.headerType === m.DOCUMENT || t.headerType === m.IMAGE || (t.headerType, m.VIDEO);
69
+ if ((t.headerType === m.DOCUMENT || t.headerType === m.IMAGE || t.headerType === m.VIDEO) && (t.headerAssetLink || (e.header = q, n = "invalid")), e.header && !r && (s(u.header), r = !0), t.bodyText ? t.bodyTextRaw && t.bodyTextRaw?.trim().length > Q && (e.body = K, n = "invalid") : (e.body = h, n = "invalid"), e.body && !r && (s(u.body), r = !0), t.footerText && t.footerText.length > R && (e.footer = N, n = "invalid"), e?.footer && !r && (s(u.footer), r = !0), t.actionsType === f.CTA_BTN) {
70
70
  if (t.ctaBtn?.phoneNumber?.isChecked) {
71
71
  const a = t.ctaBtn.phoneNumber.btnText?.trim(), l = t.ctaBtn.phoneNumber.phoneNumber;
72
72
  e.ctaBtn && !a ? (e.ctaBtn.phoneNumber.btnText = h, n = "invalid") : e.ctaBtn && a && a.length > L ? (e.ctaBtn.phoneNumber.btnText = y, n = "invalid") : e.ctaBtn && a && o.test(a) && (e.ctaBtn.phoneNumber.btnText = x, n = "invalid"), e.ctaBtn && !l ? (e.ctaBtn.phoneNumber.link = h, n = "invalid") : e.ctaBtn && l && l.length < 10 && (e.ctaBtn.phoneNumber.link = W, n = "invalid");
73
73
  }
74
74
  if (t.ctaBtn?.websiteLinkBtn?.isChecked) {
75
- const a = t.ctaBtn.websiteLinkBtn.btnText?.trim(), l = t.ctaBtn.websiteLinkBtn.linkOpens?.trim(), p = t.ctaBtn.websiteLinkBtn.placeholder?.trim();
76
- e.ctaBtn && !a ? (e.ctaBtn.websiteLink.btnText = h, n = "invalid") : e.ctaBtn && a && a.length > L ? (e.ctaBtn.websiteLink.btnText = y, n = "invalid") : e.ctaBtn && a && o.test(a) && (e.ctaBtn.websiteLink.btnText = x, n = "invalid"), e.ctaBtn && !l && !p && (e.ctaBtn.websiteLink.link = h, n = "invalid");
75
+ const a = t.ctaBtn.websiteLinkBtn.btnText?.trim(), l = t.ctaBtn.websiteLinkBtn.linkOpens?.trim(), c = t.ctaBtn.websiteLinkBtn.placeholder?.trim();
76
+ e.ctaBtn && !a ? (e.ctaBtn.websiteLink.btnText = h, n = "invalid") : e.ctaBtn && a && a.length > L ? (e.ctaBtn.websiteLink.btnText = y, n = "invalid") : e.ctaBtn && a && o.test(a) && (e.ctaBtn.websiteLink.btnText = x, n = "invalid"), e.ctaBtn && !l && !c && (e.ctaBtn.websiteLink.link = h, n = "invalid");
77
77
  }
78
- } else if (t.actionsType === d.QUICK_REPLY) {
78
+ } else if (t.actionsType === f.QUICK_REPLY) {
79
79
  const a = ["", "", ""];
80
- t.quickReply.forEach((l, p) => {
81
- const c = l.text?.trim();
82
- if (!c)
83
- a[p] = h, n = "invalid";
84
- else if (c.length > X)
85
- a[p] = y, n = "invalid";
86
- else if (o.test(c))
87
- a[p] = x, n = "invalid";
80
+ t.quickReply.forEach((l, c) => {
81
+ const p = l.text?.trim();
82
+ if (!p)
83
+ a[c] = h, n = "invalid";
84
+ else if (p.length > X)
85
+ a[c] = y, n = "invalid";
86
+ else if (o.test(p))
87
+ a[c] = x, n = "invalid";
88
88
  else {
89
- const m = [...t.quickReply];
90
- m.splice(p, 1), m.find(
91
- (b) => b.text === c
92
- ) && (a[p] = j, n = "invalid");
89
+ const d = [...t.quickReply];
90
+ d.splice(c, 1), d.find(
91
+ (b) => b.text === p
92
+ ) && (a[c] = j, n = "invalid");
93
93
  }
94
94
  }), e.quickReply = a;
95
95
  }
96
- if (t.actionsType === d.CTA_BTN || t.actionsType === d.QUICK_REPLY) {
96
+ if (t.actionsType === f.CTA_BTN || t.actionsType === f.QUICK_REPLY) {
97
97
  const a = e.quickReply?.reduce(
98
- (l, p) => l || !!p,
98
+ (l, c) => l || !!c,
99
99
  !1
100
100
  );
101
101
  (e?.ctaBtn?.websiteLink?.link || e.ctaBtn?.websiteLink?.btnText || e.ctaBtn?.phoneNumber?.link || e.ctaBtn?.phoneNumber?.btnText || a) && !r && (s(u.actionButtons), r = !0);
@@ -109,23 +109,23 @@ class ae {
109
109
  (a) => a.type === "BODY"
110
110
  );
111
111
  return s && (s.example?.body_text?.[0]?.forEach((a, l) => {
112
- let p = t.mapping?.body?.[l];
113
- const c = p, m = p && /\(\(/.test(p), T = p?.match(
112
+ let c = t.mapping?.body?.[l];
113
+ const p = c, d = c && /\(\(/.test(c), T = c?.match(
114
114
  B
115
115
  );
116
- T?.[2] && (p = T?.[2]);
117
- const b = e === v.CHATBOT && c && c?.startsWith("((") && c?.endsWith("))");
116
+ T?.[2] && (c = T?.[2]);
117
+ const b = e === v.CHATBOT && p && p?.startsWith("((") && p?.endsWith("))");
118
118
  i.push({
119
119
  idx: l,
120
- variableVal: n || b ? a : c,
121
- editable: !!m,
122
- editableDefaultValues: m ? void 0 : a,
123
- variableName: p ?? ""
120
+ variableVal: n || b ? a : p,
121
+ editable: !!d,
122
+ editableDefaultValues: d ? void 0 : a,
123
+ variableName: c ?? ""
124
124
  });
125
125
  }), t.htmlContentUrl ? r = t.htmlContentUrl : r = s.text?.split(/\{\{[0-9]+\}\}/).length ? s.text?.split(/\{\{[0-9]+\}\}/).map((a, l) => {
126
126
  if (i?.[l]) {
127
- const p = i[l].variableName;
128
- return o ? `${a}{{${p}}}` : `${a} <span> </span><span style="color: ${_.content.brand}; text-decoration: underline;">{{${p}}}</span><span> </span>`;
127
+ const c = i[l].variableName;
128
+ return o ? `${a}{{${c}}}` : `${a} <span> </span><span style="color: ${_.content.brand}; text-decoration: underline;">{{${c}}}</span><span> </span>`;
129
129
  }
130
130
  return a;
131
131
  }).join("") : ""), { bodyVariable: i, bodyText: r };
@@ -138,14 +138,14 @@ class ae {
138
138
  );
139
139
  return r && (r.example?.title_text?.[0]?.forEach((s, a) => {
140
140
  let l = t.mapping?.body?.[a];
141
- const p = l, c = l && /\(\(/.test(l), m = l?.match(
141
+ const c = l, p = l && /\(\(/.test(l), d = l?.match(
142
142
  B
143
143
  );
144
- m?.[2] && (l = m?.[2]), e.push({
144
+ d?.[2] && (l = d?.[2]), e.push({
145
145
  idx: a,
146
- variableVal: n ? s : p,
147
- editable: !!c,
148
- editableDefaultValues: c ? void 0 : s,
146
+ variableVal: n ? s : c,
147
+ editable: !!p,
148
+ editableDefaultValues: p ? void 0 : s,
149
149
  variableName: l ?? ""
150
150
  });
151
151
  }), t.htmlContentUrl ? i = t.htmlContentUrl : i = r.text?.split(/\{\{[0-9]+\}\}/).length ? r.text?.split(/\{\{[0-9]+\}\}/).map((s, a) => {
@@ -163,7 +163,7 @@ class ae {
163
163
  }
164
164
  parseButtonComponent(t) {
165
165
  const o = {
166
- actionsType: d.NONE,
166
+ actionsType: f.NONE,
167
167
  quickReply: [],
168
168
  ctaBtn: {
169
169
  phoneNumber: void 0,
@@ -174,11 +174,11 @@ class ae {
174
174
  (e) => e.type === "BUTTONS"
175
175
  );
176
176
  if (n && n?.buttons?.length) {
177
- const e = n?.buttons?.[0].type === "QUICK_REPLY" ? d.QUICK_REPLY : d.CTA_BTN;
178
- if (o.actionsType = e, e === d.QUICK_REPLY) {
177
+ const e = n?.buttons?.[0].type === "QUICK_REPLY" ? f.QUICK_REPLY : f.CTA_BTN;
178
+ if (o.actionsType = e, e === f.QUICK_REPLY) {
179
179
  const i = n?.buttons?.map((r) => r) ?? [];
180
180
  o.quickReply = i;
181
- } else e === d.CTA_BTN && n?.buttons?.forEach((i) => {
181
+ } else e === f.CTA_BTN && n?.buttons?.forEach((i) => {
182
182
  if (i.phone_number && (o.ctaBtn.phoneNumber = {
183
183
  isChecked: !0,
184
184
  btnText: i.text,
@@ -247,13 +247,13 @@ class ae {
247
247
  headerType: s,
248
248
  headerAssetLink: a,
249
249
  headerAssetName: l,
250
- headerText: p,
251
- headerVariables: c
250
+ headerText: c,
251
+ headerVariables: p
252
252
  } = await this.parseDataFromHeaderComponent(
253
253
  o,
254
254
  void 0,
255
255
  r
256
- ), { bodyText: m, bodyVariable: T } = await this.parseBodyComponent(
256
+ ), { bodyText: d, bodyVariable: T } = await this.parseBodyComponent(
257
257
  o,
258
258
  e,
259
259
  i,
@@ -262,12 +262,12 @@ class ae {
262
262
  o,
263
263
  e,
264
264
  i
265
- ), { actionsType: k, quickReply: I, ctaBtn: g, allButtons: C } = await this.parseButtonComponent(o), A = this.parseLimitedTimeOfferComponent(
265
+ ), { actionsType: I, quickReply: k, ctaBtn: A, allButtons: C } = await this.parseButtonComponent(o), g = this.parseLimitedTimeOfferComponent(
266
266
  o,
267
267
  C
268
268
  ), { showCallPermissionCard: P, callPermissionText: D } = this.parseCallPermissionComponent(o), E = {
269
- quickReply: I,
270
- ctaBtn: g,
269
+ quickReply: k,
270
+ ctaBtn: A,
271
271
  allButtons: C,
272
272
  meta: {
273
273
  name: n ? `${o.label} Copy` : o.label,
@@ -284,22 +284,22 @@ class ae {
284
284
  meta: void 0,
285
285
  ctaBtn: void 0
286
286
  },
287
- actionsType: k,
287
+ actionsType: I,
288
288
  footerText: this.parseFooterComponent(o),
289
289
  /** BODY TEXT */
290
290
  bodyVariables: T,
291
- bodyText: m,
291
+ bodyText: d,
292
292
  /** HEADER */
293
293
  headerType: s,
294
294
  headerAssetLink: a,
295
295
  headerAssetName: l,
296
- headerText: p,
297
- headerVariables: c,
296
+ headerText: c,
297
+ headerVariables: p,
298
298
  alreadyAsADraft: o.isDraft,
299
299
  mode: "edit",
300
300
  initialLoading: !1,
301
301
  /* LIMITED TIME OFFER */
302
- limitedTimeOfferComponent: A,
302
+ limitedTimeOfferComponent: g,
303
303
  /* Title for RCS */
304
304
  titleText: b,
305
305
  titleVariables: O,
@@ -322,9 +322,27 @@ class ae {
322
322
  o = n;
323
323
  return {
324
324
  ...o,
325
- templateType: t?.templateType
325
+ templateType: t?.templateType,
326
+ isMediaAfterBody: this.isRcsMediaAfterBody(t)
326
327
  };
327
328
  }
329
+ /**
330
+ * Determines, from the original `components[]` order, whether a non-TEXT
331
+ * media header appears AFTER the body component. The library preview
332
+ * otherwise always renders the media first; honouring this keeps
333
+ * body-then-media templates (the third-party ordering for some
334
+ * `text_message_with_media` templates) correct in the preview.
335
+ */
336
+ isRcsMediaAfterBody(t) {
337
+ const o = t?.components;
338
+ if (!Array.isArray(o)) return !1;
339
+ const n = o.findIndex(
340
+ (i) => i.type === "HEADER" && !!i.format && i.format !== m.TEXT
341
+ ), e = o.findIndex(
342
+ (i) => i.type === "BODY"
343
+ );
344
+ return n > -1 && e > -1 && n > e;
345
+ }
328
346
  }
329
347
  export {
330
348
  ae as TemplateCreatorHelper
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateCreatorHelper.js","sources":["../../../../../src/components/template-preview/helpers/TemplateCreatorHelper.ts"],"sourcesContent":["import { format } from 'date-fns';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\teditableVarPattern,\n\tplaceHolderNamePattern,\n\tspecialCharPattern,\n} from '../constants/regexPatterns';\nimport {\n\tBODY_LEN_ERROR,\n\tBODY_TEXT_LEN_LIMIT,\n\tBUTTON_EMOJI_ERROR,\n\tCREATE_TEMPLATE_DOM_IDS,\n\tHEADER_ASSET_LINK_ERROR,\n\tHEADER_LEN_ERROR,\n\tHEADER_TEXT_LEN_LIMIT,\n\tNAME_LEN_ERROR,\n\tNAME_LEN_LIMIT,\n\tNO_SPECIAL_CHAR,\n\tONE_VAR_ALLOWED,\n\tQUICK_REPLY_BTN_TEXT_LIMIT,\n\tQUICK_REPLY_LEN_ERROR,\n\tQUICK_REPLY_NAME_ERROR,\n\tQUICK_REPLY_NAME_LEN_LIMIT,\n\tREQUIRED_FIELD,\n\tVALID_PHONE_NUMBER,\n} from '../constants/TemplateConstants';\nimport {\n\tRCS_TEMPLATE_TYPE,\n\tRCSTemplateConfig,\n\tRCSTemplateType,\n} from '../models/RCSTemplate';\nimport {\n\tACTIONS_TYPES,\n\tHEADER_TYPES,\n\tQUICK_REPLY_BUTTON,\n} from '../models/TemplateMeta';\nimport {\n\tCreateTemplateType,\n\tPOD,\n\ttemplateVariable,\n\tWhatsappPreviewButtonType,\n\tWhatsAppTemplate,\n} from '../models/WhatsAppTemplate';\nimport { TemplateHelperUtils } from '../utils/TemplateHelperUtils';\n\nexport class TemplateCreatorHelper {\n\tprivate parseDataFromHeaderComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst res: {\n\t\t\theaderType: HEADER_TYPES;\n\t\t\theaderAssetLink?: string;\n\t\t\theaderAssetName?: string;\n\t\t\theaderText?: string;\n\t\t\theaderVariables: templateVariable[];\n\t\t} = {\n\t\t\theaderType: HEADER_TYPES.NONE,\n\t\t\theaderVariables: [],\n\t\t};\n\n\t\tconst headerComponent = dbFormattedTemplate?.components?.find(\n\t\t\t(component) => component.type === 'HEADER',\n\t\t);\n\n\t\tif (headerComponent) {\n\t\t\tres.headerType = headerComponent.format as HEADER_TYPES;\n\t\t\tres.headerText = headerComponent.text;\n\n\t\t\tres.headerAssetLink = headerComponent.example?.header_handle?.[0];\n\n\t\t\tconst sampleValue = headerComponent.example?.header_text?.[0];\n\t\t\tconst headerVarPlaceholder = dbFormattedTemplate.mapping?.header?.[0];\n\t\t\tconst originalVariable = headerVarPlaceholder;\n\t\t\tif (headerVarPlaceholder) {\n\t\t\t\tconst normalizedName = headerVarPlaceholder\n\t\t\t\t\t?.replace('[[', '')\n\t\t\t\t\t.replace(']]', '')\n\t\t\t\t\t.replace('{{', '')\n\t\t\t\t\t.replace('}}', '')\n\t\t\t\t\t.replace('((', '')\n\t\t\t\t\t.replace('))', '');\n\t\t\t\tconst editable = /\\(\\(/.test(headerVarPlaceholder);\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tconst reduxHeaderVar: templateVariable = {\n\t\t\t\t\tidx: 0,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: normalizedName,\n\t\t\t\t};\n\t\t\t\tres.headerVariables = [reduxHeaderVar];\n\t\t\t\tif (headerComponent.example?.header_text?.length) {\n\t\t\t\t\tres.headerText = res.headerText?.replace(\n\t\t\t\t\t\t/** since there will be only one variable in template so hard replace */\n\t\t\t\t\t\t'{{1}}',\n\t\t\t\t\t\t`{{${normalizedName}}}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Check if current template state is ready for saving as a draft/submit-template or not\n\t * @param state\n\t */\n\tvalidateState(state: CreateTemplateType): {\n\t\tstatus: 'invalid' | 'valid';\n\t\terrors: CreateTemplateType['error'];\n\t} {\n\t\tconst emojiRegex = /\\p{Extended_Pictographic}/u;\n\t\tlet status: 'invalid' | 'valid' = 'valid';\n\t\tconst errors: CreateTemplateType['error'] = {\n\t\t\tmeta: {},\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: { btnText: '', link: '' },\n\t\t\t\twebsiteLink: { btnText: '', link: '' },\n\t\t\t},\n\t\t\tquickReply: [null, null, null],\n\t\t};\n\t\tconst templateHelperUtils = new TemplateHelperUtils();\n\t\tlet isScrolled = false;\n\n\t\tconst scrollByElementId = (elementId: string) => {\n\t\t\tdocument.getElementById(elementId)?.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t});\n\t\t};\n\n\t\tif (!state.meta?.name) {\n\t\t\terrors.meta!.name = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else if (state.meta.name?.trim().length > NAME_LEN_LIMIT) {\n\t\t\terrors.meta!.name = NAME_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t} else if (specialCharPattern.test(state.meta.name?.trim())) {\n\t\t\terrors.meta!.name = NO_SPECIAL_CHAR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors.meta!.name && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.name);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.headerType === HEADER_TYPES.TEXT) {\n\t\t\tconst text = state.headerText?.trim() ?? '';\n\t\t\tif (!text) {\n\t\t\t\terrors.header = REQUIRED_FIELD;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else if (text.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\t\terrors.header = HEADER_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else {\n\t\t\t\tconst variableList =\n\t\t\t\t\ttemplateHelperUtils.getTemplateVariablesFromState(text);\n\t\t\t\tif (variableList && variableList.length > 1) {\n\t\t\t\t\terrors.header = ONE_VAR_ALLOWED;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.headerType === HEADER_TYPES.DOCUMENT) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.IMAGE) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.VIDEO) {\n\t\t\t/** @todo add media header validations */\n\t\t}\n\n\t\tif (\n\t\t\tstate.headerType === HEADER_TYPES.DOCUMENT ||\n\t\t\tstate.headerType === HEADER_TYPES.IMAGE ||\n\t\t\tstate.headerType === HEADER_TYPES.VIDEO\n\t\t) {\n\t\t\tif (!state.headerAssetLink) {\n\t\t\t\terrors.header = HEADER_ASSET_LINK_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.header && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.header);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (!state.bodyText) {\n\t\t\terrors.body = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else {\n\t\t\tif (\n\t\t\t\tstate.bodyTextRaw &&\n\t\t\t\tstate.bodyTextRaw?.trim().length > BODY_TEXT_LEN_LIMIT\n\t\t\t) {\n\t\t\t\terrors.body = BODY_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.body && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.body);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.footerText && state.footerText.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\terrors.footer = HEADER_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors?.footer && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.footer);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\tif (state.ctaBtn?.phoneNumber?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.phoneNumber.btnText?.trim();\n\t\t\t\tconst phoneNumber = state.ctaBtn.phoneNumber.phoneNumber;\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !phoneNumber) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && phoneNumber && phoneNumber.length < 10) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = VALID_PHONE_NUMBER;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (state.ctaBtn?.websiteLinkBtn?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.websiteLinkBtn.btnText?.trim();\n\t\t\t\tconst customLink = state.ctaBtn.websiteLinkBtn.linkOpens?.trim();\n\t\t\t\tconst placeholder = state.ctaBtn.websiteLinkBtn.placeholder?.trim();\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !customLink && !placeholder) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\tconst quickReplyErrors = ['', '', ''];\n\t\t\tstate.quickReply.forEach((button, i) => {\n\t\t\t\tconst text = button.text?.trim();\n\t\t\t\tif (!text) {\n\t\t\t\t\tquickReplyErrors[i] = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (text.length > QUICK_REPLY_NAME_LEN_LIMIT) {\n\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (emojiRegex.test(text)) {\n\t\t\t\t\tquickReplyErrors[i] = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else {\n\t\t\t\t\tconst buttons = [...state.quickReply];\n\t\t\t\t\tbuttons.splice(i, 1);\n\t\t\t\t\tconst exists = buttons.find(\n\t\t\t\t\t\t(el: QUICK_REPLY_BUTTON) => el.text === text,\n\t\t\t\t\t);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_NAME_ERROR;\n\t\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\terrors.quickReply = quickReplyErrors;\n\t\t}\n\n\t\tif (\n\t\t\tstate.actionsType === ACTIONS_TYPES.CTA_BTN ||\n\t\t\tstate.actionsType === ACTIONS_TYPES.QUICK_REPLY\n\t\t) {\n\t\t\tconst quickReplyErrors = errors.quickReply?.reduce(\n\t\t\t\t(qrbErrorAcc, currentError) => qrbErrorAcc || !!currentError,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t(!!errors?.ctaBtn?.websiteLink?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.websiteLink?.btnText ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.btnText ||\n\t\t\t\t\t!!quickReplyErrors) &&\n\t\t\t\t!isScrolled\n\t\t\t) {\n\t\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.actionButtons);\n\t\t\t\tisScrolled = true;\n\t\t\t}\n\t\t}\n\n\t\treturn { status, errors };\n\t}\n\n\tprivate parseBodyComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst bodyVariable: templateVariable[] = [];\n\t\tlet bodyText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BODY',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.body_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tbodyVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\tbodyText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\tbodyText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (bodyVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = bodyVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { bodyVariable, bodyText };\n\t}\n\n\tprivate parseTitleComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t) {\n\t\tconst titleVariable: templateVariable[] = [];\n\t\tlet titleText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'TITLE',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.title_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\ttitleVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal: showSampleValues ? sampleValue : originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\ttitleText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\ttitleText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (titleVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = titleVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { titleText, titleVariables: titleVariable };\n\t}\n\n\tprivate parseFooterComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst footerComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'FOOTER',\n\t\t);\n\n\t\treturn footerComponent?.text;\n\t}\n\n\tprivate parseButtonComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst res: {\n\t\t\tactionsType: ACTIONS_TYPES;\n\t\t\tquickReply: Array<QUICK_REPLY_BUTTON>;\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tphoneNumber?: string;\n\t\t\t\t};\n\t\t\t\twebsiteLinkBtn?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tlinkOpens?: string;\n\t\t\t\t\tplaceholder?: string;\n\t\t\t\t};\n\t\t\t};\n\t\t\tallButtons: WhatsappPreviewButtonType[];\n\t\t} = {\n\t\t\tactionsType: ACTIONS_TYPES.NONE,\n\t\t\tquickReply: [],\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: undefined,\n\t\t\t\twebsiteLinkBtn: undefined,\n\t\t\t},\n\t\t\tallButtons: [],\n\t\t};\n\n\t\tconst buttonComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BUTTONS',\n\t\t);\n\n\t\tif (buttonComponent && buttonComponent?.buttons?.length) {\n\t\t\tconst actionsType =\n\t\t\t\tbuttonComponent?.buttons?.[0].type === 'QUICK_REPLY'\n\t\t\t\t\t? ACTIONS_TYPES.QUICK_REPLY\n\t\t\t\t\t: ACTIONS_TYPES.CTA_BTN;\n\n\t\t\tres.actionsType = actionsType;\n\n\t\t\tif (actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\t\tconst btnTexts = (buttonComponent?.buttons?.map((btn) => btn) ??\n\t\t\t\t\t[]) as QUICK_REPLY_BUTTON[];\n\t\t\t\tres.quickReply = btnTexts;\n\t\t\t} else if (actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\t\tbuttonComponent?.buttons?.forEach((btn) => {\n\t\t\t\t\tif (btn.phone_number) {\n\t\t\t\t\t\tres.ctaBtn.phoneNumber = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tphoneNumber: btn.phone_number,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (btn.url) {\n\t\t\t\t\t\tconst btnPlaceholder =\n\t\t\t\t\t\t\tdbFormattedTemplate?.mapping?.buttons?.[0] ?? undefined;\n\t\t\t\t\t\tlet customUrl = false;\n\n\t\t\t\t\t\tif (btnPlaceholder && editableVarPattern.test(btnPlaceholder)) {\n\t\t\t\t\t\t\tcustomUrl = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tres.ctaBtn.websiteLinkBtn = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tlinkOpens: customUrl ? btn.example?.[0] : btn.url,\n\t\t\t\t\t\t\tplaceholder: customUrl ? undefined : btnPlaceholder,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Parses buttons from template to a format preview can understand.\n\t\t\t// Since copy code does not come with a variable by default, we are adding placeholder from example.\n\t\t\tres.allButtons = buttonComponent.buttons?.map((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...button,\n\t\t\t\t\t\tplaceholder: Array.isArray(button.example)\n\t\t\t\t\t\t\t? button.example[0]\n\t\t\t\t\t\t\t: button?.example || '',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn button;\n\t\t\t}) as WhatsappPreviewButtonType[];\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Parses LTO component to a format preview can understand.\n\t * Points to Note -\n\t * 1. Takes the Copy Code from previously parsed buttons.\n\t * 2. LTO component does not have a dateTime expiry by default. Hence, while sending template to ContextMapper, send with a date or current Date and Time is picked here.\n\t */\n\tprivate parseLimitedTimeOfferComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tallButtons: WhatsappPreviewButtonType[],\n\t) {\n\t\tconst limitedTimeOfferComponent: CreateTemplateType['limitedTimeOfferComponent'] =\n\t\t\t{\n\t\t\t\ttext: '',\n\t\t\t\tdateTime: '',\n\t\t\t\tcode: '',\n\t\t\t};\n\n\t\tdbFormattedTemplate.components.forEach((component) => {\n\t\t\tif (component.type === 'limited_time_offer') {\n\t\t\t\tlimitedTimeOfferComponent.text =\n\t\t\t\t\tcomponent.limited_time_offer?.text ?? '';\n\t\t\t\tconst dateTime = component.example?.limited_time_offer;\n\t\t\t\tif (dateTime && dateTime.startsWith('{{') && dateTime.endsWith('}}')) {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = dateTime;\n\t\t\t\t} else {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = format(\n\t\t\t\t\t\tdateTime ? new Date(dateTime) : new Date(),\n\t\t\t\t\t\t'MMM dd',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tallButtons.forEach((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\tlimitedTimeOfferComponent.code = button.placeholder ?? '';\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn limitedTimeOfferComponent;\n\t}\n\n\tprivate parseCallPermissionComponent(dbFormattedTemplate: WhatsAppTemplate): {\n\t\tshowCallPermissionCard: boolean;\n\t\tcallPermissionText?: string;\n\t} {\n\t\tconst callPermissionComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => (component as any).type === 'CALL_PERMISSION_REQUEST',\n\t\t);\n\n\t\treturn {\n\t\t\tshowCallPermissionCard: Boolean(callPermissionComponent),\n\t\t\tcallPermissionText: (callPermissionComponent as any)?.text,\n\t\t};\n\t}\n\n\tasync parseUITemplateFromDBFormat(data: {\n\t\tdbFormattedTemplate: WhatsAppTemplate;\n\t\tisDuplicate?: boolean;\n\t\tshowSampleValues?: boolean;\n\t\tisV2?: boolean;\n\t\tpod?: string;\n\t}) {\n\t\tconst {\n\t\t\tdbFormattedTemplate,\n\t\t\tisDuplicate,\n\t\t\tisV2 = false,\n\t\t\tshowSampleValues,\n\t\t\tpod,\n\t\t} = data;\n\t\tconst {\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t} = await this.parseDataFromHeaderComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tundefined,\n\t\t\tpod,\n\t\t);\n\n\t\tconst { bodyText, bodyVariable: bodyVariables } =\n\t\t\tawait this.parseBodyComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t\tpod,\n\t\t\t);\n\t\tconst { titleText, titleVariables: titleVariables } =\n\t\t\tawait this.parseTitleComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t);\n\n\t\tconst { actionsType, quickReply, ctaBtn, allButtons } =\n\t\t\tawait this.parseButtonComponent(dbFormattedTemplate);\n\n\t\tconst limitedTimeOfferComponent = this.parseLimitedTimeOfferComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tallButtons,\n\t\t);\n\n\t\tconst { showCallPermissionCard, callPermissionText } =\n\t\t\tthis.parseCallPermissionComponent(dbFormattedTemplate);\n\n\t\tconst state: CreateTemplateType = {\n\t\t\tquickReply,\n\t\t\tctaBtn,\n\t\t\tallButtons,\n\t\t\tmeta: {\n\t\t\t\tname: isDuplicate\n\t\t\t\t\t? `${dbFormattedTemplate.label} Copy`\n\t\t\t\t\t: dbFormattedTemplate.label,\n\t\t\t\tcategory: dbFormattedTemplate.category?.toUpperCase(),\n\t\t\t\tsubCategory: dbFormattedTemplate.templateCategory,\n\t\t\t\tlanguage: dbFormattedTemplate.language,\n\t\t\t\ttemplateId: dbFormattedTemplate.templateId,\n\t\t\t},\n\t\t\terror: {\n\t\t\t\theader: undefined,\n\t\t\t\tbody: undefined,\n\t\t\t\tfooter: undefined,\n\t\t\t\tquickReply: undefined,\n\t\t\t\tmeta: undefined,\n\t\t\t\tctaBtn: undefined,\n\t\t\t},\n\n\t\t\tactionsType,\n\t\t\tfooterText: this.parseFooterComponent(dbFormattedTemplate),\n\t\t\t/** BODY TEXT */\n\t\t\tbodyVariables,\n\t\t\tbodyText,\n\n\t\t\t/** HEADER */\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t\talreadyAsADraft: dbFormattedTemplate.isDraft,\n\t\t\tmode: 'edit',\n\t\t\tinitialLoading: false,\n\t\t\t/* LIMITED TIME OFFER */\n\t\t\tlimitedTimeOfferComponent,\n\t\t\t/* Title for RCS */\n\t\t\ttitleText,\n\t\t\ttitleVariables,\n\t\t\t/* Call Permission */\n\t\t\tshowCallPermissionCard,\n\t\t\tcallPermissionText,\n\t\t};\n\n\t\tconst { errors } = this.validateState(state);\n\n\t\tstate.error = errors;\n\n\t\treturn state;\n\t}\n\n\tparseTemplateConfiguration(template: RCSTemplateType): RCSTemplateConfig {\n\t\tlet config: RCSTemplateConfig;\n\t\tconst templateConfig = template?.content || ({} as RCSTemplateConfig);\n\t\tif (typeof templateConfig === 'string') {\n\t\t\ttry {\n\t\t\t\tconfig = JSON.parse(templateConfig) as RCSTemplateConfig;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Error parsing rcsTemplate component JSON:', error);\n\t\t\t\tconfig = { orientation: 'VERTICAL' } as RCSTemplateConfig;\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = templateConfig;\n\t\t}\n\t\treturn {\n\t\t\t...config,\n\t\t\ttemplateType: template?.templateType as RCS_TEMPLATE_TYPE,\n\t\t};\n\t}\n}\n"],"names":["TemplateCreatorHelper","dbFormattedTemplate","showSampleValues","pod","res","HEADER_TYPES","headerComponent","component","sampleValue","headerVarPlaceholder","originalVariable","normalizedName","editable","isChatbotCustomText","POD","reduxHeaderVar","state","emojiRegex","status","errors","templateHelperUtils","TemplateHelperUtils","isScrolled","scrollByElementId","elementId","NAME_LEN_LIMIT","NAME_LEN_ERROR","specialCharPattern","NO_SPECIAL_CHAR","REQUIRED_FIELD","CREATE_TEMPLATE_DOM_IDS","text","HEADER_TEXT_LEN_LIMIT","HEADER_LEN_ERROR","variableList","ONE_VAR_ALLOWED","HEADER_ASSET_LINK_ERROR","BODY_TEXT_LEN_LIMIT","BODY_LEN_ERROR","ACTIONS_TYPES","btnText","phoneNumber","QUICK_REPLY_BTN_TEXT_LIMIT","QUICK_REPLY_LEN_ERROR","BUTTON_EMOJI_ERROR","VALID_PHONE_NUMBER","customLink","placeholder","quickReplyErrors","button","i","QUICK_REPLY_NAME_LEN_LIMIT","buttons","el","QUICK_REPLY_NAME_ERROR","qrbErrorAcc","currentError","isV2","bodyVariable","bodyText","bodyComponent","bodyVarPlaceholder","matchedPlaceholderName","placeHolderNamePattern","t","normalizeName","COLORS","titleVariable","titleText","buttonComponent","actionsType","btnTexts","btn","btnPlaceholder","customUrl","editableVarPattern","allButtons","limitedTimeOfferComponent","dateTime","format","callPermissionComponent","data","isDuplicate","headerType","headerAssetLink","headerAssetName","headerText","headerVariables","bodyVariables","titleVariables","quickReply","ctaBtn","showCallPermissionCard","callPermissionText","template","config","templateConfig","error"],"mappings":";;;;;;;AA6CO,MAAMA,GAAsB;AAAA,EAC1B,6BACPC,GACAC,GACAC,GACC;AACD,UAAMC,IAMF;AAAA,MACH,YAAYC,EAAa;AAAA,MACzB,iBAAiB,CAAA;AAAA,IAAC,GAGbC,IAAkBL,GAAqB,YAAY;AAAA,MACxD,CAACM,MAAcA,EAAU,SAAS;AAAA,IAAA;AAGnC,QAAID,GAAiB;AACpB,MAAAF,EAAI,aAAaE,EAAgB,QACjCF,EAAI,aAAaE,EAAgB,MAEjCF,EAAI,kBAAkBE,EAAgB,SAAS,gBAAgB,CAAC;AAEhE,YAAME,IAAcF,EAAgB,SAAS,cAAc,CAAC,GACtDG,IAAuBR,EAAoB,SAAS,SAAS,CAAC,GAC9DS,IAAmBD;AACzB,UAAIA,GAAsB;AACzB,cAAME,IAAiBF,GACpB,QAAQ,MAAM,EAAE,EACjB,QAAQ,MAAM,EAAE,EAChB,QAAQ,MAAM,EAAE,EAChB,QAAQ,MAAM,EAAE,EAChB,QAAQ,MAAM,EAAE,EAChB,QAAQ,MAAM,EAAE,GACZG,IAAW,OAAO,KAAKH,CAAoB,GAC3CI,IACLV,MAAQW,EAAI,WACZJ,KACAA,GAAkB,WAAW,IAAI,KACjCA,GAAkB,SAAS,IAAI,GAE1BK,IAAmC;AAAA,UACxC,KAAK;AAAA,UACL,aACCb,KAAoBW,IACjBL,IACAE;AAAA,UACJ,UAAAE;AAAA,UACA,uBAAuBA,IAAW,SAAYJ;AAAA,UAC9C,cAAcG;AAAA,QAAA;AAEf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zB;AAAA;AAEA,MAAAA,IAASC;AAEV,WAAO;AAAA,MACN,GAAGD;AAAA,MACH,cAAcD,GAAU;AAAA,IAAA;AAAA,EAE1B;AACD;"}
1
+ {"version":3,"file":"TemplateCreatorHelper.js","sources":["../../../../../src/components/template-preview/helpers/TemplateCreatorHelper.ts"],"sourcesContent":["import { format } from 'date-fns';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\teditableVarPattern,\n\tplaceHolderNamePattern,\n\tspecialCharPattern,\n} from '../constants/regexPatterns';\nimport {\n\tBODY_LEN_ERROR,\n\tBODY_TEXT_LEN_LIMIT,\n\tBUTTON_EMOJI_ERROR,\n\tCREATE_TEMPLATE_DOM_IDS,\n\tHEADER_ASSET_LINK_ERROR,\n\tHEADER_LEN_ERROR,\n\tHEADER_TEXT_LEN_LIMIT,\n\tNAME_LEN_ERROR,\n\tNAME_LEN_LIMIT,\n\tNO_SPECIAL_CHAR,\n\tONE_VAR_ALLOWED,\n\tQUICK_REPLY_BTN_TEXT_LIMIT,\n\tQUICK_REPLY_LEN_ERROR,\n\tQUICK_REPLY_NAME_ERROR,\n\tQUICK_REPLY_NAME_LEN_LIMIT,\n\tREQUIRED_FIELD,\n\tVALID_PHONE_NUMBER,\n} from '../constants/TemplateConstants';\nimport {\n\tRCS_TEMPLATE_TYPE,\n\tRCSTemplateConfig,\n\tRCSTemplateType,\n} from '../models/RCSTemplate';\nimport {\n\tACTIONS_TYPES,\n\tHEADER_TYPES,\n\tQUICK_REPLY_BUTTON,\n} from '../models/TemplateMeta';\nimport {\n\tCreateTemplateType,\n\tPOD,\n\ttemplateVariable,\n\tWhatsappPreviewButtonType,\n\tWhatsAppTemplate,\n} from '../models/WhatsAppTemplate';\nimport { TemplateHelperUtils } from '../utils/TemplateHelperUtils';\n\nexport class TemplateCreatorHelper {\n\tprivate parseDataFromHeaderComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst res: {\n\t\t\theaderType: HEADER_TYPES;\n\t\t\theaderAssetLink?: string;\n\t\t\theaderAssetName?: string;\n\t\t\theaderText?: string;\n\t\t\theaderVariables: templateVariable[];\n\t\t} = {\n\t\t\theaderType: HEADER_TYPES.NONE,\n\t\t\theaderVariables: [],\n\t\t};\n\n\t\tconst headerComponent = dbFormattedTemplate?.components?.find(\n\t\t\t(component) => component.type === 'HEADER',\n\t\t);\n\n\t\tif (headerComponent) {\n\t\t\tres.headerType = headerComponent.format as HEADER_TYPES;\n\t\t\tres.headerText = headerComponent.text;\n\n\t\t\tres.headerAssetLink = headerComponent.example?.header_handle?.[0];\n\n\t\t\tconst sampleValue = headerComponent.example?.header_text?.[0];\n\t\t\tconst headerVarPlaceholder = dbFormattedTemplate.mapping?.header?.[0];\n\t\t\tconst originalVariable = headerVarPlaceholder;\n\t\t\tif (headerVarPlaceholder) {\n\t\t\t\tconst normalizedName = headerVarPlaceholder\n\t\t\t\t\t?.replace('[[', '')\n\t\t\t\t\t.replace(']]', '')\n\t\t\t\t\t.replace('{{', '')\n\t\t\t\t\t.replace('}}', '')\n\t\t\t\t\t.replace('((', '')\n\t\t\t\t\t.replace('))', '');\n\t\t\t\tconst editable = /\\(\\(/.test(headerVarPlaceholder);\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tconst reduxHeaderVar: templateVariable = {\n\t\t\t\t\tidx: 0,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: normalizedName,\n\t\t\t\t};\n\t\t\t\tres.headerVariables = [reduxHeaderVar];\n\t\t\t\tif (headerComponent.example?.header_text?.length) {\n\t\t\t\t\tres.headerText = res.headerText?.replace(\n\t\t\t\t\t\t/** since there will be only one variable in template so hard replace */\n\t\t\t\t\t\t'{{1}}',\n\t\t\t\t\t\t`{{${normalizedName}}}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Check if current template state is ready for saving as a draft/submit-template or not\n\t * @param state\n\t */\n\tvalidateState(state: CreateTemplateType): {\n\t\tstatus: 'invalid' | 'valid';\n\t\terrors: CreateTemplateType['error'];\n\t} {\n\t\tconst emojiRegex = /\\p{Extended_Pictographic}/u;\n\t\tlet status: 'invalid' | 'valid' = 'valid';\n\t\tconst errors: CreateTemplateType['error'] = {\n\t\t\tmeta: {},\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: { btnText: '', link: '' },\n\t\t\t\twebsiteLink: { btnText: '', link: '' },\n\t\t\t},\n\t\t\tquickReply: [null, null, null],\n\t\t};\n\t\tconst templateHelperUtils = new TemplateHelperUtils();\n\t\tlet isScrolled = false;\n\n\t\tconst scrollByElementId = (elementId: string) => {\n\t\t\tdocument.getElementById(elementId)?.scrollIntoView({\n\t\t\t\tbehavior: 'smooth',\n\t\t\t\tblock: 'nearest',\n\t\t\t});\n\t\t};\n\n\t\tif (!state.meta?.name) {\n\t\t\terrors.meta!.name = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else if (state.meta.name?.trim().length > NAME_LEN_LIMIT) {\n\t\t\terrors.meta!.name = NAME_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t} else if (specialCharPattern.test(state.meta.name?.trim())) {\n\t\t\terrors.meta!.name = NO_SPECIAL_CHAR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors.meta!.name && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.name);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.headerType === HEADER_TYPES.TEXT) {\n\t\t\tconst text = state.headerText?.trim() ?? '';\n\t\t\tif (!text) {\n\t\t\t\terrors.header = REQUIRED_FIELD;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else if (text.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\t\terrors.header = HEADER_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t} else {\n\t\t\t\tconst variableList =\n\t\t\t\t\ttemplateHelperUtils.getTemplateVariablesFromState(text);\n\t\t\t\tif (variableList && variableList.length > 1) {\n\t\t\t\t\terrors.header = ONE_VAR_ALLOWED;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.headerType === HEADER_TYPES.DOCUMENT) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.IMAGE) {\n\t\t\t/** @todo add media header validations */\n\t\t} else if (state.headerType === HEADER_TYPES.VIDEO) {\n\t\t\t/** @todo add media header validations */\n\t\t}\n\n\t\tif (\n\t\t\tstate.headerType === HEADER_TYPES.DOCUMENT ||\n\t\t\tstate.headerType === HEADER_TYPES.IMAGE ||\n\t\t\tstate.headerType === HEADER_TYPES.VIDEO\n\t\t) {\n\t\t\tif (!state.headerAssetLink) {\n\t\t\t\terrors.header = HEADER_ASSET_LINK_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.header && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.header);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (!state.bodyText) {\n\t\t\terrors.body = REQUIRED_FIELD;\n\t\t\tstatus = 'invalid';\n\t\t} else {\n\t\t\tif (\n\t\t\t\tstate.bodyTextRaw &&\n\t\t\t\tstate.bodyTextRaw?.trim().length > BODY_TEXT_LEN_LIMIT\n\t\t\t) {\n\t\t\t\terrors.body = BODY_LEN_ERROR;\n\t\t\t\tstatus = 'invalid';\n\t\t\t}\n\t\t}\n\n\t\tif (!!errors.body && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.body);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.footerText && state.footerText.length > HEADER_TEXT_LEN_LIMIT) {\n\t\t\terrors.footer = HEADER_LEN_ERROR;\n\t\t\tstatus = 'invalid';\n\t\t}\n\n\t\tif (!!errors?.footer && !isScrolled) {\n\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.footer);\n\t\t\tisScrolled = true;\n\t\t}\n\n\t\tif (state.actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\tif (state.ctaBtn?.phoneNumber?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.phoneNumber.btnText?.trim();\n\t\t\t\tconst phoneNumber = state.ctaBtn.phoneNumber.phoneNumber;\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !phoneNumber) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && phoneNumber && phoneNumber.length < 10) {\n\t\t\t\t\terrors.ctaBtn.phoneNumber.link = VALID_PHONE_NUMBER;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (state.ctaBtn?.websiteLinkBtn?.isChecked) {\n\t\t\t\tconst btnText = state.ctaBtn.websiteLinkBtn.btnText?.trim();\n\t\t\t\tconst customLink = state.ctaBtn.websiteLinkBtn.linkOpens?.trim();\n\t\t\t\tconst placeholder = state.ctaBtn.websiteLinkBtn.placeholder?.trim();\n\n\t\t\t\tif (errors.ctaBtn && !btnText) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (\n\t\t\t\t\terrors.ctaBtn &&\n\t\t\t\t\tbtnText &&\n\t\t\t\t\tbtnText.length > QUICK_REPLY_BTN_TEXT_LIMIT\n\t\t\t\t) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (errors.ctaBtn && btnText && emojiRegex.test(btnText)) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.btnText = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\n\t\t\t\tif (errors.ctaBtn && !customLink && !placeholder) {\n\t\t\t\t\terrors.ctaBtn.websiteLink.link = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (state.actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\tconst quickReplyErrors = ['', '', ''];\n\t\t\tstate.quickReply.forEach((button, i) => {\n\t\t\t\tconst text = button.text?.trim();\n\t\t\t\tif (!text) {\n\t\t\t\t\tquickReplyErrors[i] = REQUIRED_FIELD;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (text.length > QUICK_REPLY_NAME_LEN_LIMIT) {\n\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_LEN_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else if (emojiRegex.test(text)) {\n\t\t\t\t\tquickReplyErrors[i] = BUTTON_EMOJI_ERROR;\n\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t} else {\n\t\t\t\t\tconst buttons = [...state.quickReply];\n\t\t\t\t\tbuttons.splice(i, 1);\n\t\t\t\t\tconst exists = buttons.find(\n\t\t\t\t\t\t(el: QUICK_REPLY_BUTTON) => el.text === text,\n\t\t\t\t\t);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tquickReplyErrors[i] = QUICK_REPLY_NAME_ERROR;\n\t\t\t\t\t\tstatus = 'invalid';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\terrors.quickReply = quickReplyErrors;\n\t\t}\n\n\t\tif (\n\t\t\tstate.actionsType === ACTIONS_TYPES.CTA_BTN ||\n\t\t\tstate.actionsType === ACTIONS_TYPES.QUICK_REPLY\n\t\t) {\n\t\t\tconst quickReplyErrors = errors.quickReply?.reduce(\n\t\t\t\t(qrbErrorAcc, currentError) => qrbErrorAcc || !!currentError,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t\tif (\n\t\t\t\t(!!errors?.ctaBtn?.websiteLink?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.websiteLink?.btnText ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.link ||\n\t\t\t\t\t!!errors.ctaBtn?.phoneNumber?.btnText ||\n\t\t\t\t\t!!quickReplyErrors) &&\n\t\t\t\t!isScrolled\n\t\t\t) {\n\t\t\t\tscrollByElementId(CREATE_TEMPLATE_DOM_IDS.actionButtons);\n\t\t\t\tisScrolled = true;\n\t\t\t}\n\t\t}\n\n\t\treturn { status, errors };\n\t}\n\n\tprivate parseBodyComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t\tpod?: string,\n\t) {\n\t\tconst bodyVariable: templateVariable[] = [];\n\t\tlet bodyText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BODY',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.body_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\tconst isChatbotCustomText =\n\t\t\t\t\tpod === POD.CHATBOT &&\n\t\t\t\t\toriginalVariable &&\n\t\t\t\t\toriginalVariable?.startsWith('((') &&\n\t\t\t\t\toriginalVariable?.endsWith('))');\n\n\t\t\t\tbodyVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal:\n\t\t\t\t\t\tshowSampleValues || isChatbotCustomText\n\t\t\t\t\t\t\t? sampleValue\n\t\t\t\t\t\t\t: originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\tbodyText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\tbodyText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (bodyVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = bodyVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { bodyVariable, bodyText };\n\t}\n\n\tprivate parseTitleComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tisV2 = false,\n\t\tshowSampleValues?: boolean,\n\t) {\n\t\tconst titleVariable: templateVariable[] = [];\n\t\tlet titleText = '';\n\n\t\tconst bodyComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'TITLE',\n\t\t);\n\n\t\tif (bodyComponent) {\n\t\t\tbodyComponent.example?.title_text?.[0]?.forEach((sampleValue, i) => {\n\t\t\t\tlet bodyVarPlaceholder = dbFormattedTemplate.mapping?.body?.[i];\n\t\t\t\tconst originalVariable = bodyVarPlaceholder;\n\t\t\t\tconst editable = bodyVarPlaceholder && /\\(\\(/.test(bodyVarPlaceholder);\n\t\t\t\tconst matchedPlaceholderName = bodyVarPlaceholder?.match(\n\t\t\t\t\tplaceHolderNamePattern,\n\t\t\t\t);\n\n\t\t\t\tif (matchedPlaceholderName?.[2]) {\n\t\t\t\t\tbodyVarPlaceholder = matchedPlaceholderName?.[2];\n\t\t\t\t}\n\n\t\t\t\ttitleVariable.push({\n\t\t\t\t\tidx: i,\n\t\t\t\t\tvariableVal: showSampleValues ? sampleValue : originalVariable,\n\t\t\t\t\teditable: !!editable,\n\t\t\t\t\teditableDefaultValues: editable ? undefined : sampleValue,\n\t\t\t\t\tvariableName: bodyVarPlaceholder ?? '',\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tif (dbFormattedTemplate.htmlContentUrl) {\n\t\t\t\ttitleText = dbFormattedTemplate.htmlContentUrl;\n\t\t\t} else {\n\t\t\t\ttitleText = bodyComponent.text?.split(/\\{\\{[0-9]+\\}\\}/).length\n\t\t\t\t\t? bodyComponent.text\n\t\t\t\t\t\t\t?.split(/\\{\\{[0-9]+\\}\\}/)\n\t\t\t\t\t\t\t.map((t, i) => {\n\t\t\t\t\t\t\t\tif (titleVariable?.[i]) {\n\t\t\t\t\t\t\t\t\tconst normalizeName = titleVariable[i].variableName;\n\t\t\t\t\t\t\t\t\tconst tmp = isV2\n\t\t\t\t\t\t\t\t\t\t? `${t}{{${normalizeName}}}`\n\t\t\t\t\t\t\t\t\t\t: `${t} <span> </span><span style=\"color: ${COLORS.content.brand}; text-decoration: underline;\">{{${normalizeName}}}</span><span> </span>`;\n\n\t\t\t\t\t\t\t\t\treturn tmp;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn t;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('')\n\t\t\t\t\t: '';\n\t\t\t}\n\t\t}\n\n\t\treturn { titleText, titleVariables: titleVariable };\n\t}\n\n\tprivate parseFooterComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst footerComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'FOOTER',\n\t\t);\n\n\t\treturn footerComponent?.text;\n\t}\n\n\tprivate parseButtonComponent(dbFormattedTemplate: WhatsAppTemplate) {\n\t\tconst res: {\n\t\t\tactionsType: ACTIONS_TYPES;\n\t\t\tquickReply: Array<QUICK_REPLY_BUTTON>;\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tphoneNumber?: string;\n\t\t\t\t};\n\t\t\t\twebsiteLinkBtn?: {\n\t\t\t\t\tisChecked?: boolean;\n\t\t\t\t\tbtnText?: string;\n\t\t\t\t\tlinkOpens?: string;\n\t\t\t\t\tplaceholder?: string;\n\t\t\t\t};\n\t\t\t};\n\t\t\tallButtons: WhatsappPreviewButtonType[];\n\t\t} = {\n\t\t\tactionsType: ACTIONS_TYPES.NONE,\n\t\t\tquickReply: [],\n\t\t\tctaBtn: {\n\t\t\t\tphoneNumber: undefined,\n\t\t\t\twebsiteLinkBtn: undefined,\n\t\t\t},\n\t\t\tallButtons: [],\n\t\t};\n\n\t\tconst buttonComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => component.type === 'BUTTONS',\n\t\t);\n\n\t\tif (buttonComponent && buttonComponent?.buttons?.length) {\n\t\t\tconst actionsType =\n\t\t\t\tbuttonComponent?.buttons?.[0].type === 'QUICK_REPLY'\n\t\t\t\t\t? ACTIONS_TYPES.QUICK_REPLY\n\t\t\t\t\t: ACTIONS_TYPES.CTA_BTN;\n\n\t\t\tres.actionsType = actionsType;\n\n\t\t\tif (actionsType === ACTIONS_TYPES.QUICK_REPLY) {\n\t\t\t\tconst btnTexts = (buttonComponent?.buttons?.map((btn) => btn) ??\n\t\t\t\t\t[]) as QUICK_REPLY_BUTTON[];\n\t\t\t\tres.quickReply = btnTexts;\n\t\t\t} else if (actionsType === ACTIONS_TYPES.CTA_BTN) {\n\t\t\t\tbuttonComponent?.buttons?.forEach((btn) => {\n\t\t\t\t\tif (btn.phone_number) {\n\t\t\t\t\t\tres.ctaBtn.phoneNumber = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tphoneNumber: btn.phone_number,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (btn.url) {\n\t\t\t\t\t\tconst btnPlaceholder =\n\t\t\t\t\t\t\tdbFormattedTemplate?.mapping?.buttons?.[0] ?? undefined;\n\t\t\t\t\t\tlet customUrl = false;\n\n\t\t\t\t\t\tif (btnPlaceholder && editableVarPattern.test(btnPlaceholder)) {\n\t\t\t\t\t\t\tcustomUrl = true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tres.ctaBtn.websiteLinkBtn = {\n\t\t\t\t\t\t\tisChecked: true,\n\t\t\t\t\t\t\tbtnText: btn.text,\n\t\t\t\t\t\t\tlinkOpens: customUrl ? btn.example?.[0] : btn.url,\n\t\t\t\t\t\t\tplaceholder: customUrl ? undefined : btnPlaceholder,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Parses buttons from template to a format preview can understand.\n\t\t\t// Since copy code does not come with a variable by default, we are adding placeholder from example.\n\t\t\tres.allButtons = buttonComponent.buttons?.map((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...button,\n\t\t\t\t\t\tplaceholder: Array.isArray(button.example)\n\t\t\t\t\t\t\t? button.example[0]\n\t\t\t\t\t\t\t: button?.example || '',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn button;\n\t\t\t}) as WhatsappPreviewButtonType[];\n\t\t}\n\n\t\treturn res;\n\t}\n\n\t/**\n\t * Parses LTO component to a format preview can understand.\n\t * Points to Note -\n\t * 1. Takes the Copy Code from previously parsed buttons.\n\t * 2. LTO component does not have a dateTime expiry by default. Hence, while sending template to ContextMapper, send with a date or current Date and Time is picked here.\n\t */\n\tprivate parseLimitedTimeOfferComponent(\n\t\tdbFormattedTemplate: WhatsAppTemplate,\n\t\tallButtons: WhatsappPreviewButtonType[],\n\t) {\n\t\tconst limitedTimeOfferComponent: CreateTemplateType['limitedTimeOfferComponent'] =\n\t\t\t{\n\t\t\t\ttext: '',\n\t\t\t\tdateTime: '',\n\t\t\t\tcode: '',\n\t\t\t};\n\n\t\tdbFormattedTemplate.components.forEach((component) => {\n\t\t\tif (component.type === 'limited_time_offer') {\n\t\t\t\tlimitedTimeOfferComponent.text =\n\t\t\t\t\tcomponent.limited_time_offer?.text ?? '';\n\t\t\t\tconst dateTime = component.example?.limited_time_offer;\n\t\t\t\tif (dateTime && dateTime.startsWith('{{') && dateTime.endsWith('}}')) {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = dateTime;\n\t\t\t\t} else {\n\t\t\t\t\tlimitedTimeOfferComponent.dateTime = format(\n\t\t\t\t\t\tdateTime ? new Date(dateTime) : new Date(),\n\t\t\t\t\t\t'MMM dd',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tallButtons.forEach((button) => {\n\t\t\t\tif (button.type === 'COPY_CODE') {\n\t\t\t\t\tlimitedTimeOfferComponent.code = button.placeholder ?? '';\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn limitedTimeOfferComponent;\n\t}\n\n\tprivate parseCallPermissionComponent(dbFormattedTemplate: WhatsAppTemplate): {\n\t\tshowCallPermissionCard: boolean;\n\t\tcallPermissionText?: string;\n\t} {\n\t\tconst callPermissionComponent = dbFormattedTemplate.components?.find(\n\t\t\t(component) => (component as any).type === 'CALL_PERMISSION_REQUEST',\n\t\t);\n\n\t\treturn {\n\t\t\tshowCallPermissionCard: Boolean(callPermissionComponent),\n\t\t\tcallPermissionText: (callPermissionComponent as any)?.text,\n\t\t};\n\t}\n\n\tasync parseUITemplateFromDBFormat(data: {\n\t\tdbFormattedTemplate: WhatsAppTemplate;\n\t\tisDuplicate?: boolean;\n\t\tshowSampleValues?: boolean;\n\t\tisV2?: boolean;\n\t\tpod?: string;\n\t}) {\n\t\tconst {\n\t\t\tdbFormattedTemplate,\n\t\t\tisDuplicate,\n\t\t\tisV2 = false,\n\t\t\tshowSampleValues,\n\t\t\tpod,\n\t\t} = data;\n\t\tconst {\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t} = await this.parseDataFromHeaderComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tundefined,\n\t\t\tpod,\n\t\t);\n\n\t\tconst { bodyText, bodyVariable: bodyVariables } =\n\t\t\tawait this.parseBodyComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t\tpod,\n\t\t\t);\n\t\tconst { titleText, titleVariables: titleVariables } =\n\t\t\tawait this.parseTitleComponent(\n\t\t\t\tdbFormattedTemplate,\n\t\t\t\tisV2,\n\t\t\t\tshowSampleValues,\n\t\t\t);\n\n\t\tconst { actionsType, quickReply, ctaBtn, allButtons } =\n\t\t\tawait this.parseButtonComponent(dbFormattedTemplate);\n\n\t\tconst limitedTimeOfferComponent = this.parseLimitedTimeOfferComponent(\n\t\t\tdbFormattedTemplate,\n\t\t\tallButtons,\n\t\t);\n\n\t\tconst { showCallPermissionCard, callPermissionText } =\n\t\t\tthis.parseCallPermissionComponent(dbFormattedTemplate);\n\n\t\tconst state: CreateTemplateType = {\n\t\t\tquickReply,\n\t\t\tctaBtn,\n\t\t\tallButtons,\n\t\t\tmeta: {\n\t\t\t\tname: isDuplicate\n\t\t\t\t\t? `${dbFormattedTemplate.label} Copy`\n\t\t\t\t\t: dbFormattedTemplate.label,\n\t\t\t\tcategory: dbFormattedTemplate.category?.toUpperCase(),\n\t\t\t\tsubCategory: dbFormattedTemplate.templateCategory,\n\t\t\t\tlanguage: dbFormattedTemplate.language,\n\t\t\t\ttemplateId: dbFormattedTemplate.templateId,\n\t\t\t},\n\t\t\terror: {\n\t\t\t\theader: undefined,\n\t\t\t\tbody: undefined,\n\t\t\t\tfooter: undefined,\n\t\t\t\tquickReply: undefined,\n\t\t\t\tmeta: undefined,\n\t\t\t\tctaBtn: undefined,\n\t\t\t},\n\n\t\t\tactionsType,\n\t\t\tfooterText: this.parseFooterComponent(dbFormattedTemplate),\n\t\t\t/** BODY TEXT */\n\t\t\tbodyVariables,\n\t\t\tbodyText,\n\n\t\t\t/** HEADER */\n\t\t\theaderType,\n\t\t\theaderAssetLink,\n\t\t\theaderAssetName,\n\t\t\theaderText,\n\t\t\theaderVariables,\n\t\t\talreadyAsADraft: dbFormattedTemplate.isDraft,\n\t\t\tmode: 'edit',\n\t\t\tinitialLoading: false,\n\t\t\t/* LIMITED TIME OFFER */\n\t\t\tlimitedTimeOfferComponent,\n\t\t\t/* Title for RCS */\n\t\t\ttitleText,\n\t\t\ttitleVariables,\n\t\t\t/* Call Permission */\n\t\t\tshowCallPermissionCard,\n\t\t\tcallPermissionText,\n\t\t};\n\n\t\tconst { errors } = this.validateState(state);\n\n\t\tstate.error = errors;\n\n\t\treturn state;\n\t}\n\n\tparseTemplateConfiguration(template: RCSTemplateType): RCSTemplateConfig {\n\t\tlet config: RCSTemplateConfig;\n\t\tconst templateConfig = template?.content || ({} as RCSTemplateConfig);\n\t\tif (typeof templateConfig === 'string') {\n\t\t\ttry {\n\t\t\t\tconfig = JSON.parse(templateConfig) as RCSTemplateConfig;\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Error parsing rcsTemplate component JSON:', error);\n\t\t\t\tconfig = { orientation: 'VERTICAL' } as RCSTemplateConfig;\n\t\t\t}\n\t\t} else {\n\t\t\tconfig = templateConfig;\n\t\t}\n\t\treturn {\n\t\t\t...config,\n\t\t\ttemplateType: template?.templateType as RCS_TEMPLATE_TYPE,\n\t\t\tisMediaAfterBody: this.isRcsMediaAfterBody(template),\n\t\t};\n\t}\n\n\t/**\n\t * Determines, from the original `components[]` order, whether a non-TEXT\n\t * media header appears AFTER the body component. The library preview\n\t * otherwise always renders the media first; honouring this keeps\n\t * body-then-media templates (the third-party ordering for some\n\t * `text_message_with_media` templates) correct in the preview.\n\t */\n\tisRcsMediaAfterBody(template: RCSTemplateType): boolean {\n\t\tconst components = template?.components;\n\t\tif (!Array.isArray(components)) return false;\n\n\t\tconst mediaHeaderIndex = components.findIndex(\n\t\t\t(component) =>\n\t\t\t\tcomponent.type === 'HEADER' &&\n\t\t\t\t!!component.format &&\n\t\t\t\tcomponent.format !== HEADER_TYPES.TEXT,\n\t\t);\n\t\tconst bodyIndex = components.findIndex(\n\t\t\t(component) => component.type === 'BODY',\n\t\t);\n\n\t\treturn (\n\t\t\tmediaHeaderIndex > -1 && bodyIndex > -1 && mediaHeaderIndex > bodyIndex\n\t\t);\n\t}\n}\n"],"names":["TemplateCreatorHelper","dbFormattedTemplate","showSampleValues","pod","res","HEADER_TYPES","headerComponent","component","sampleValue","headerVarPlaceholder","originalVariable","normalizedName","editable","isChatbotCustomText","POD","reduxHeaderVar","state","emojiRegex","status","errors","templateHelperUtils","TemplateHelperUtils","isScrolled","scrollByElementId","elementId","NAME_LEN_LIMIT","NAME_LEN_ERROR","specialCharPattern","NO_SPECIAL_CHAR","REQUIRED_FIELD","CREATE_TEMPLATE_DOM_IDS","text","HEADER_TEXT_LEN_LIMIT","HEADER_LEN_ERROR","variableList","ONE_VAR_ALLOWED","HEADER_ASSET_LINK_ERROR","BODY_TEXT_LEN_LIMIT","BODY_LEN_ERROR","ACTIONS_TYPES","btnText","phoneNumber","QUICK_REPLY_BTN_TEXT_LIMIT","QUICK_REPLY_LEN_ERROR","BUTTON_EMOJI_ERROR","VALID_PHONE_NUMBER","customLink","placeholder","quickReplyErrors","button","i","QUICK_REPLY_NAME_LEN_LIMIT","buttons","el","QUICK_REPLY_NAME_ERROR","qrbErrorAcc","currentError","isV2","bodyVariable","bodyText","bodyComponent","bodyVarPlaceholder","matchedPlaceholderName","placeHolderNamePattern","t","normalizeName","COLORS","titleVariable","titleText","buttonComponent","actionsType","btnTexts","btn","btnPlaceholder","customUrl","editableVarPattern","allButtons","limitedTimeOfferComponent","dateTime","format","callPermissionComponent","data","isDuplicate","headerType","headerAssetLink","headerAssetName","headerText","headerVariables","bodyVariables","titleVariables","quickReply","ctaBtn","showCallPermissionCard","callPermissionText","template","config","templateConfig","error","components","mediaHeaderIndex","bodyIndex"],"mappings":";;;;;;;AA6CO,MAAMA,GAAsB;AAAA,EAC1B,6BACPC,GACA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MACAA,EAAU,SAAS,YACnB,CAAC,CAACA,EAAU,UACZA,EAAU,WAAWF,EAAa;AAAA,IAAA,GAE9B+F,IAAYF,EAAW;AAAA,MAC5B,CAAC3F,MAAcA,EAAU,SAAS;AAAA,IAAA;AAGnC,WACC4F,IAAmB,MAAMC,IAAY,MAAMD,IAAmBC;AAAA,EAEhE;AACD;"}
@@ -136,4 +136,11 @@ export interface RCSTemplateConfig {
136
136
  templateType: RCS_TEMPLATE_TYPE | string;
137
137
  height: string;
138
138
  orientation: string;
139
+ /**
140
+ * For VERTICAL orientation only: whether the media/header should render
141
+ * AFTER the body text instead of the default media-first layout. Derived
142
+ * from the original `components[]` ordering so the preview matches
143
+ * third-party body-then-media templates (e.g. `text_message_with_media`).
144
+ */
145
+ isMediaAfterBody?: boolean;
139
146
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RCSTemplate.js","sources":["../../../../../src/components/template-preview/models/RCSTemplate.ts"],"sourcesContent":["import { Timestamp } from 'firebase-admin/firestore';\nimport { CHANNEL_TYPE } from './Channels';\nimport { TEMPLATE_STATUS } from './TemplateMeta';\nimport { WhatsappLikePreviewTypes, WhatsAppTemplate } from './WhatsAppTemplate';\n\nexport interface RCSPreviewProps extends WhatsappLikePreviewTypes {\n\tisCarousal?: boolean;\n}\nexport interface RCSTemplateType extends WhatsAppTemplate {\n\tid: string;\n\tstatus: TEMPLATE_STATUS;\n\tname: string;\n\tcontent?: string;\n\tmapping: { [key: string]: string[] | object[] };\n\tmediaTemplateActionButtonTypes: { [key: string]: string[] | object[] };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tcreatedAt: number;\n\tupdatedAt: number;\n\ttemplateType?: RCS_TEMPLATE_TYPE;\n\trcsBroadcastConfig?: {\n\t\tmapping: { [key: string]: string | object };\n\t};\n\thtmlContentUrl?: string;\n\ttemplateId?: string;\n\tchannel: CHANNEL_TYPE;\n\theaders?: string[];\n}\n\nexport interface RCSPreviewPropsV2 extends WhatsappLikePreviewTypes {\n\ttemplateConfiguration: RCSTemplateConfig;\n}\n\nexport interface RcsTemplate {\n\tcontent?: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tstatus: TEMPLATE_STATUS;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tcreatedAt: Timestamp;\n\tupdatedAt: Timestamp;\n}\n\nexport interface CreateRcsTemplatePayload {\n\tname: string;\n\tlabel: string;\n\tstoreId: string;\n\tcategory: string;\n\tchannelTemplateId: string;\n\tchannel: string;\n\tcontent: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tbotId: string;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tstatus: TEMPLATE_STATUS;\n\tcreatedAt: Timestamp;\n\tcreatedBy: string;\n\ttemplateCategory?: string;\n\tupdatedAt: Timestamp;\n\ttemplateId?: string;\n}\n\nexport enum RCS_TEMPLATE_STATUS {\n\tACTIVE = 'active',\n\tAPPROVED = 'approved',\n\tPENDING = 'pending',\n\tREJECTED = 'rejected',\n\tFAILED = 'Failed',\n}\n\nexport enum RCS_TEMPLATE_TYPE {\n\tTEXT_MESSAGE = 'text_message', //body and button(name and url)--> custom variable\n\tTEXT_MESSAGE_WITH_PDF = 'text_message_with_pdf', //body, and button(name and url)custom\n\tCAROUSEL = 'carousel', //body, and button(name and url)custom ,title\n\tRICH_CARD = 'rich_card', //body, and button(name and url)custom ,title\n\tUNKNOWN = 'unknown',\n}\n\nexport enum RCS_BUTTON_TYPE {\n\tREPLY = 'reply',\n\tURL_ACTION = 'url_action', // url --->\n\tDIALER_ACTION = 'dialer_action',\n\tVIEW_LOCATION_LATLONG = 'view_location_latlong',\n\tVIEW_LOCATION_QUERY = 'view_location_query',\n\tSHARE_LOCATION = 'share_location',\n\tCALENDAR_EVENT = 'calendar_event',\n}\n\nexport enum MEDIA_FORMAT {\n\tIMAGE = 'image',\n\tVIDEO = 'video',\n\tDOCUMENT = 'document',\n\tOTHER = 'other',\n}\n\nexport enum IMAGE_EXTENSIONS {\n\tJPG = 'jpg',\n\tJPEG = 'jpeg',\n\tPNG = 'png',\n\tGIF = 'gif',\n\tBMP = 'bmp',\n\tWEBP = 'webp',\n}\n\nexport enum VIDEO_EXTENSIONS {\n\tMP4 = 'mp4',\n\tMOV = 'mov',\n\tAVI = 'avi',\n\tMKV = 'mkv',\n\tWEBM = 'webm',\n}\n\nexport enum DOCUMENT_EXTENSIONS {\n\tPDF = 'pdf',\n\tDOC = 'doc',\n\tDOCX = 'docx',\n\tXLS = 'xls',\n\tXLSX = 'xlsx',\n\tPPT = 'ppt',\n\tPPTX = 'pptx',\n\tTXT = 'txt',\n}\n\nexport interface RCSTemplateConfig {\n\ttemplateType: RCS_TEMPLATE_TYPE | string;\n\theight: string;\n\torientation: string;\n}\n"],"names":["RCS_TEMPLATE_TYPE"],"mappings":"AA+EO,IAAKA,sBAAAA,OACXA,EAAA,eAAe,gBACfA,EAAA,wBAAwB,yBACxBA,EAAA,WAAW,YACXA,EAAA,YAAY,aACZA,EAAA,UAAU,WALCA,IAAAA,KAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"RCSTemplate.js","sources":["../../../../../src/components/template-preview/models/RCSTemplate.ts"],"sourcesContent":["import { Timestamp } from 'firebase-admin/firestore';\nimport { CHANNEL_TYPE } from './Channels';\nimport { TEMPLATE_STATUS } from './TemplateMeta';\nimport { WhatsappLikePreviewTypes, WhatsAppTemplate } from './WhatsAppTemplate';\n\nexport interface RCSPreviewProps extends WhatsappLikePreviewTypes {\n\tisCarousal?: boolean;\n}\nexport interface RCSTemplateType extends WhatsAppTemplate {\n\tid: string;\n\tstatus: TEMPLATE_STATUS;\n\tname: string;\n\tcontent?: string;\n\tmapping: { [key: string]: string[] | object[] };\n\tmediaTemplateActionButtonTypes: { [key: string]: string[] | object[] };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tcreatedAt: number;\n\tupdatedAt: number;\n\ttemplateType?: RCS_TEMPLATE_TYPE;\n\trcsBroadcastConfig?: {\n\t\tmapping: { [key: string]: string | object };\n\t};\n\thtmlContentUrl?: string;\n\ttemplateId?: string;\n\tchannel: CHANNEL_TYPE;\n\theaders?: string[];\n}\n\nexport interface RCSPreviewPropsV2 extends WhatsappLikePreviewTypes {\n\ttemplateConfiguration: RCSTemplateConfig;\n}\n\nexport interface RcsTemplate {\n\tcontent?: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tstatus: TEMPLATE_STATUS;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tcreatedAt: Timestamp;\n\tupdatedAt: Timestamp;\n}\n\nexport interface CreateRcsTemplatePayload {\n\tname: string;\n\tlabel: string;\n\tstoreId: string;\n\tcategory: string;\n\tchannelTemplateId: string;\n\tchannel: string;\n\tcontent: string;\n\tcomponents: string;\n\tmapping: { [key: string]: string | object };\n\tmediaTemplateActionButtonTypes: { [key: string]: string | object };\n\tcustomParams?: Record<string, string>;\n\tdestinationUrl?: Record<string, string>;\n\tbotId: string;\n\texternalStatus: RCS_TEMPLATE_STATUS;\n\ttemplateType: string;\n\tstatus: TEMPLATE_STATUS;\n\tcreatedAt: Timestamp;\n\tcreatedBy: string;\n\ttemplateCategory?: string;\n\tupdatedAt: Timestamp;\n\ttemplateId?: string;\n}\n\nexport enum RCS_TEMPLATE_STATUS {\n\tACTIVE = 'active',\n\tAPPROVED = 'approved',\n\tPENDING = 'pending',\n\tREJECTED = 'rejected',\n\tFAILED = 'Failed',\n}\n\nexport enum RCS_TEMPLATE_TYPE {\n\tTEXT_MESSAGE = 'text_message', //body and button(name and url)--> custom variable\n\tTEXT_MESSAGE_WITH_PDF = 'text_message_with_pdf', //body, and button(name and url)custom\n\tCAROUSEL = 'carousel', //body, and button(name and url)custom ,title\n\tRICH_CARD = 'rich_card', //body, and button(name and url)custom ,title\n\tUNKNOWN = 'unknown',\n}\n\nexport enum RCS_BUTTON_TYPE {\n\tREPLY = 'reply',\n\tURL_ACTION = 'url_action', // url --->\n\tDIALER_ACTION = 'dialer_action',\n\tVIEW_LOCATION_LATLONG = 'view_location_latlong',\n\tVIEW_LOCATION_QUERY = 'view_location_query',\n\tSHARE_LOCATION = 'share_location',\n\tCALENDAR_EVENT = 'calendar_event',\n}\n\nexport enum MEDIA_FORMAT {\n\tIMAGE = 'image',\n\tVIDEO = 'video',\n\tDOCUMENT = 'document',\n\tOTHER = 'other',\n}\n\nexport enum IMAGE_EXTENSIONS {\n\tJPG = 'jpg',\n\tJPEG = 'jpeg',\n\tPNG = 'png',\n\tGIF = 'gif',\n\tBMP = 'bmp',\n\tWEBP = 'webp',\n}\n\nexport enum VIDEO_EXTENSIONS {\n\tMP4 = 'mp4',\n\tMOV = 'mov',\n\tAVI = 'avi',\n\tMKV = 'mkv',\n\tWEBM = 'webm',\n}\n\nexport enum DOCUMENT_EXTENSIONS {\n\tPDF = 'pdf',\n\tDOC = 'doc',\n\tDOCX = 'docx',\n\tXLS = 'xls',\n\tXLSX = 'xlsx',\n\tPPT = 'ppt',\n\tPPTX = 'pptx',\n\tTXT = 'txt',\n}\n\nexport interface RCSTemplateConfig {\n\ttemplateType: RCS_TEMPLATE_TYPE | string;\n\theight: string;\n\torientation: string;\n\t/**\n\t * For VERTICAL orientation only: whether the media/header should render\n\t * AFTER the body text instead of the default media-first layout. Derived\n\t * from the original `components[]` ordering so the preview matches\n\t * third-party body-then-media templates (e.g. `text_message_with_media`).\n\t */\n\tisMediaAfterBody?: boolean;\n}\n"],"names":["RCS_TEMPLATE_TYPE"],"mappings":"AA+EO,IAAKA,sBAAAA,OACXA,EAAA,eAAe,gBACfA,EAAA,wBAAwB,yBACxBA,EAAA,WAAW,YACXA,EAAA,YAAY,aACZA,EAAA,UAAU,WALCA,IAAAA,KAAA,CAAA,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.817",
3
+ "version": "0.0.818",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",