1"use strict";(self.webpackChunkredefine_retail=self.webpackChunkredefine_retail||[]).push([[6996],{6996(_e,O,p){p.d(O,{RetailStoreStepperComponent:()=>Se});var m=p(6213),e=p(1360),F=p(643),w=p(6697),N=p(3117),R=p(3623),M=p(1413),V=p(152),G=p(3294),g=p(6977),b=p(1942),l=p(8),v=p(9467),E=p(8681),S=p(5565),j=p(5794);function $(o,c){if(1&o&&(e.j41(0,"div",3),e.nrm(1,"img",4),e.j41(2,"div",5),e.EFF(3),e.k0s()()),2&o){const t=e.XpG();e.R7$(3),e.SpI(" ",(null==t.data?null:t.data.message)||"Loading..."," ")}}function H(o,c){if(1&o&&(e.j41(0,"div")(1,"strong"),e.EFF(2),e.k0s(),e.EFF(3),e.k0s()),2&o){const t=c.$implicit;e.R7$(2),e.JRh(t.label),e.R7$(),e.SpI(" : ",t.value," ")}}function X(o,c){if(1&o&&(e.qex(0),e.DNE(1,H,4,2,"div",7),e.bVm()),2&o){const t=e.XpG(2).$implicit,a=e.XpG(2);e.R7$(),e.Y8G("ngForOf",a.formatOperationalHours(t.value))}}function W(o,c){if(1&o&&(e.nrm(0,"div",16),e.nI1(1,"safeHtml")),2&o){const t=e.XpG(2).$implicit,a=e.XpG(2);e.Y8G("innerHTML",e.i5U(1,1,a.formatValue(t.value),"html"),e.npT)}}function B(o,c){if(1&o&&(e.j41(0,"div",17)(1,"div",18),e.EFF(2),e.nI1(3,"titlecase"),e.k0s(),e.nrm(4,"div",19),e.nI1(5,"safeHtml"),e.k0s()),2&o){const t=e.XpG(2).$implicit,a=e.XpG(2);e.R7$(2),e.SpI(" ",e.bMT(3,2,t.key)," - Reasoning "),e.R7$(2),e.Y8G("innerHTML",e.i5U(5,4,a.getReasonForField(t.key),"html"),e.npT)}}function U(o,c){if(1&o&&(e.j41(0,"div",10)(1,"div",11)(2,"div",12),e.EFF(3),e.k0s(),e.j41(4,"div",13),e.DNE(5,X,2,1,"ng-container",14)(6,W,2,4,"ng-template",null,0,e.C5r),e.k0s()(),e.DNE(8,B,6,7,"div",15),e.k0s()),2&o){const t=e.sdS(7),a=e.XpG().$implicit,i=e.XpG(2);e.R7$(3),e.SpI(" ",i.formatKey(a.key)," "),e.R7$(2),e.Y8G("ngIf","operational_hours"===a.key)("ngIfElse",t),e.R7$(3),e.Y8G("ngIf",i.getReasonForField(a.key))}}function Y(o,c){if(1&o&&(e.qex(0),e.DNE(1,U,9,4,"div",9),e.bVm()),2&o){const t=c.$implicit,a=e.XpG(2);e.R7$(),e.Y8G("ngIf",a.isFieldVisible(t.key,t.value))}}function q(o,c){1&o&&(e.nrm(0,"div",16),e.nI1(1,"safeHtml")),2&o&&e.Y8G("innerHTML",e.i5U(1,1,c.$implicit,"html"),e.npT)}function K(o,c){if(1&o&&(e.j41(0,"div",20)(1,"div",18),e.EFF(2," Reasoning "),e.k0s(),e.j41(3,"div",21),e.DNE(4,q,2,4,"div",22),e.k0s()()),2&o){const t=e.XpG(2);e.R7$(4),e.Y8G("ngForOf",t.getUnmatchedReasoning())}}function Q(o,c){if(1&o&&(e.j41(0,"div",6),e.DNE(1,Y,2,1,"ng-container",7),e.nI1(2,"keyvalue"),e.DNE(3,K,5,1,"div",8),e.k0s()),2&o){const t=e.XpG();e.R7$(),e.Y8G("ngForOf",e.bMT(2,2,t.resultObj)),e.R7$(2),e.Y8G("ngIf",t.getUnmatchedReasoning().length)}}let z=(()=>{class o{data;dialogRef;resultObj={};reasoningText="";parsed=!1;constructor(t,a){this.data=t,this.dialogRef=a}ngDoCheck(){if(!this.parsed&&this.data?.result){this.parsed=!0;const t=void 0!==this.data.result.data?this.data.result.data:this.data.result;if("string"==typeof t)try{const a=t.replace(/```json|```/g,"").trim(),i=a.match(/\{[\s\S]*\}/);if(i){const n=i[0];this.resultObj=JSON.parse(n),this.data.result=this.resultObj,this.reasoningText=a.replace(n,"").trim()}else this.resultObj={Response:t}}catch(a){console.error("AI response parsing failed",a),this.resultObj={Response:t}}else"object"==typeof t&&null!==t?(this.resultObj=t,this.data.result=this.resultObj):this.resultObj={Response:String(t)}}}isFieldVisible(t,a){return!0}isOperationalHoursValid(t){return!!t&&t.monday_friday?.start&&t.monday_friday?.end&&t.saturday?.start&&t.saturday?.end&&t.sunday_public_holidays?.start&&t.sunday_public_holidays?.end}formatOperationalHours(t){return[{label:"Mon \u2013 Fri",value:t?.monday_friday?.start&&t?.monday_friday?.end?`${t.monday_friday.start} \u2013 ${t.monday_friday.end}`:"Not Available"},{label:"Saturday",value:t?.saturday?.start&&t?.saturday?.end?`${t.saturday.start} \u2013 ${t.saturday.end}`:"Not Available"},{label:"Sunday",value:t?.sunday?.start&&t?.sunday?.end?`${t.sunday.start} \u2013 ${t.sunday.end}`:"Closed"},{label:"Public Holidays",value:t?.public_holidays?.start&&t?.public_holidays?.end?`${t.public_holidays.start} \u2013 ${t.public_holidays.end}`:"Closed"}]}formatValue(t){return null==t?"Not Available":"object"==typeof t?JSON.stringify(t,null,2):String(t)}getReasonForField(t){return this.reasoningText&&this.reasoningText.split("\n").find(n=>n.toLowerCase().includes(t.toLowerCase()))||null}getUnmatchedReasoning(){if(!this.reasoningText)return[];const t=this.reasoningText.split("\n"),a=Object.keys(this.resultObj).map(i=>i.toLowerCase());return t.filter(i=>!a.some(n=>i.toLowerCase().includes(n)))}formatKey(t){return t?t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()):""}apply(){this.dialogRef.close(this.resultObj)}cancel(){this.dialogRef.close(null)}static \u0275fac=function(a){return new(a||o)(e.rXU(S.e),e.rXU(S.m))};static \u0275cmp=e.VBU({type:o,selectors:[["app-ai-form-data"]],decls:2,vars:2,consts:[["normalValue",""],["class","loader",4,"ngIf"],["class","ai-result",4,"ngIf"],[1,"loader"],["src","assets/images/loader.svg","alt","loader icon",2,"width","10%"],[1,"loading-text"],[1,"ai-result"],[4,"ngFor","ngForOf"],["class","reason-box unmatched",4,"ngIf"],["class","row-block",4,"ngIf"],[1,"row-block"],[1,"row-main"],[1,"label"],[1,"value"],[4,"ngIf","ngIfElse"],["class","reason-box",4,"ngIf"],[3,"innerHTML"],[1,"reason-box"],[1,"reason-title"],[1,"reason-content",3,"innerHTML"],[1,"reason-box","unmatched"],[1,"reason-content"],[3,"innerHTML",4,"ngFor","ngForOf"]],template:function(a,i){1&a&&e.DNE(0,$,4,1,"div",1)(1,Q,4,4,"div",2),2&a&&(e.Y8G("ngIf",null==i.data?null:i.data.loading),e.R7$(),e.Y8G("ngIf",!(null!=i.data&&i.data.loading)))},dependencies:[m.MD,m.Sq,m.bT,m.PV,m.lG,j.$],styles:[".ai-result[_ngcontent-%COMP%]{display:block;gap:10px;height:430px;overflow-x:hidden}.row-main[_ngcontent-%COMP%]{display:grid;grid-template-columns:240px 1fr;padding:8px 0;border-bottom:1px solid #e5e5e5}.label[_ngcontent-%COMP%]{font-weight:600;color:#333}.value[_ngcontent-%COMP%]{color:#222}.reason-box[_ngcontent-%COMP%]{margin-top:8px;padding:12px;background:#f5f5f5;border-left:4px solid #999;font-size:14px;color:#555;max-height:200px;overflow-y:auto}.reason-title[_ngcontent-%COMP%]{font-style:italic;font-weight:600;margin-bottom:6px}.reason-content[_ngcontent-%COMP%]{white-space:pre-line}.row-main[_ngcontent-%COMP%]{display:grid;grid-template-columns:220px 1fr;padding:8px 0;border-bottom:1px solid #e5e5e5}.label[_ngcontent-%COMP%]{font-weight:600}.reason-box[_ngcontent-%COMP%]{margin-top:8px;padding:12px;background:#f5f5f5;border-left:4px solid #999;max-height:180px;overflow:auto}.reason-title[_ngcontent-%COMP%]{font-style:italic;margin-bottom:6px}.loader[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px}.loading-text[_ngcontent-%COMP%]{font-size:14px;color:#666}.loader[_ngcontent-%COMP%] svg.mdc-circular-progress__indeterminate-circle-graphic[_ngcontent-%COMP%]{stroke:#c00018!important}"]})}return o}
1)();var L=p(8342),A=p(8989),C=p(9417),y=p(7198);function J(o,c){if(1&o&&(e.j41(0,"div",2),e.nrm(1,"img",3),e.j41(2,"div",4),e.EFF(3),e.k0s()()),2&o){const t=e.XpG();e.R7$(3),e.SpI(" ",(null==t.data?null:t.data.message)||"Loading..."," ")}}function Z(o,c){if(1&o){const t=e.RV6();e.j41(0,"div")(1,"app-dynamic-form",5),e.bIt("fieldValueChanged",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.onRadioFieldChange(i))})("formSubmit",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.submitAiDes(i))})("formCancel",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.cancel())}),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(),e.Y8G("fields",t.fields)("columns",t.createcolumns)("submitButtonText","Generate")}}let ee=(()=>{class o extends v.h{data;cdr;commonService;dialogRef;dynamicForm;NO_LOADER=(new A._y).set(L.u,!0);constructor(t,a,i,n){super(),this.data=t,this.cdr=a,this.commonService=i,this.dialogRef=n}fields;createcolumns;loading=!1;ngOnInit(){this.initializeFields(),this.prefillFields()}initializeFields(){this.fields=[{type:"radio",label:"",name:"webDescriptionType",value:"web",wrapperClass:"col-12 mb-3",validators:{required:!0},required:!0,options:[{label:"Website",value:"web"},{label:"Short Description",value:"sd"}]},{type:"text",label:"Website",name:"Website",placeholder:"Enter URL",value:"",wrapperClass:"col-12 col-md-12",visibleFor:["web"],id:"Website",validators:{required:!0,maxLength:255,pattern:l.XF.URL_PATTERN}},{type:"textarea",label:"Short Description",name:"ShortDescription",placeholder:"Enter short description",value:"",visibleFor:["sd"],wrapperClass:"col-12 col-md-12 d-none",required:!1,validators:{required:!1,maxLength:5e3},id:"ShortDescription"}],this.updateCreateColumns(),this.cdr.markForCheck(),this.cdr.detectChanges()}updateCreateColumns(){this.createcolumns=[{label:"Store Details",value:this.fields}]}onRadioFieldChange(t){this.applyOperationHoursVisibility(t.value),this.updateRequiredValidators(t.value)}updateRequiredValidators(t){if(!this.dynamicForm?.form)return;const a=this.dynamicForm.form.get("Website"),i=this.dynamicForm.form.get("ShortDescription");"web"===t?(a?.setValidators([C.k0.required,C.k0.pattern(l.XF.URL_PATTERN.PATTERN)]),i?.clearValidators()):"sd"===t&&(a?.clearValidators(),i?.clearValidators()),a?.updateValueAndValidity(),i?.updateValueAndValidity(),this.cdr.detectChanges()}submitAiDes(t){const a={Store:this.data.Name,Center:this.centerName,Website:"",ShortDescription:""},{Website:i,ShortDescription:n,webDescriptionType:d}=t;switch(d){case"web":a.Website=i,this.getAiDescription(a);break;case"sd":a.ShortDescription=n,this.getAiDescription(a);break;default:console.warn("Invalid description type")}}prefillFields(){this.data&&((a=>{if(a?.length)for(const i of a){const n=this.data[i.name];null!=n&&(i.value=n)}})(this.fields),this.updateCreateColumns(),this.cdr.detectChanges())}applyOperationHoursVisibility(t){this.fields&&(this.fields=this.fields.map(a=>{if(!a.visibleFor)return a;const i=a.wrapperClass?.replace("d-none","").trim(),n=a.visibleFor.includes(t);return{...a,wrapperClass:n?i:`${i} d-none`.trim()}}),this.updateCreateColumns(),this.cdr.detectChanges())}getAiDescription(t){this.loading=!0,this.commonService.post(`${l.ts.RETAIL_STORE_AI_DESCRIPTION}`,t,this.NO_LOADER).subscribe({next:a=>{this.loading=!1,this.dialogRef.close(a.data)},error:a=>{}})}cancel(){this.dialogRef.close()}static \u0275fac=function(a){return new(a||o)(e.rXU(S.e),e.rXU(e.gRc),e.rXU(y.h),e.rXU(S.m))};static \u0275cmp=e.VBU({type:o,selectors:[["app-ai-auto-genarated-description"]],viewQuery:function(a,i){if(1&a&&e.GBs(b.f,5),2&a){let n;e.mGM(n=e.lsd())&&(i.dynamicForm=n.first)}},features:[e.Vt3],decls:2,vars:2,consts:[["class","loader",4,"ngIf"],[4,"ngIf"],[1,"loader"],["src","assets/images/loader.svg","alt","loader icon",2,"width","10%"],[1,"loading-text"],[3,"fieldValueChanged","formSubmit","formCancel","fields","columns","submitButtonText"]],template:function(a,i){1&a&&e.DNE(0,J,4,1,"div",0)(1,Z,2,3,"div",1),2&a&&(e.Y8G("ngIf",i.loading),e.R7$(),e.Y8G("ngIf",i.createcolumns&&i.fields&&!i.loading))},dependencies:[b.f,m.MD,m.bT],styles:[".loader[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center}"]})}return o}
1)();var te=p(5558),k=p(7673),x=p(1358),P=p(5575),ie=p(345);const ae=(o,c)=>({logoPreview:o,aiTrigger:c});function ne(o,c){if(1&o){const t=e.RV6();e.j41(0,"button",5),e.bIt("click",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.generateDataFromAI())}),e.j41(1,"span",6),e.nrm(2,"img",7),e.k0s(),e.j41(3,"span",8),e.EFF(4,"Auto populate store data with AI"),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(2),e.FS9("src",t.sparkleIcon,e.B4B)}}function oe(o,c){if(1&o&&(e.j41(0,"div",11)(1,"label",12),e.EFF(2,"Store Logo"),e.k0s(),e.j41(3,"div",13),e.nrm(4,"img",14),e.k0s()()),2&o){const t=e.XpG(3);e.R7$(4),e.Y8G("src",t.logoPreviewUrl,e.B4B)}}function re(o,c){if(1&o&&e.DNE(0,oe,5,1,"div",10),2&o){const t=e.XpG(2);e.Y8G("ngIf",t.logoPreviewUrl)}}function se(o,c){if(1&o){const t=e.RV6();e.j41(0,"div",16)(1,"button",17),e.bIt("click",function(){e.eBV(t);const i=e.XpG(3);return e.Njj(i.generateDataFromAI())}),e.j41(2,"span",6),e.nrm(3,"img",7),e.k0s(),e.j41(4,"span",8),e.EFF(5," Auto populate store data with AI "),e.k0s()()()}if(2&o){const t=e.XpG(3);e.R7$(),e.Y8G("disabled",!t.isAiEnabled),e.R7$(2),e.Y8G("src",t.sparkleIcon,e.B4B)}}function le(o,c){if(1&o&&e.DNE(0,se,6,2,"div",15),2&o){const t=e.XpG(2);e.Y8G("ngIf",!t.isEdit)}}function de(o,c){if(1&o){const t=e.RV6();e.j41(0,"div")(1,"app-dynamic-form",9),e.bIt("formSubmit",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.submitRetailStore(i))})("formCancel",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.cancel())})("uploadfile",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.onUpload(i))})("aiButtonTemplate",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.aiGeneratedDescription(i))})("fieldValueChanged",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.onDynamicFieldChange(i))}),e.k0s(),e.DNE(2,re,1,1,"ng-template",null,0,e.C5r)(4,le,1,1,"ng-template",null,1,e.C5r),e.k0s()}if(2&o){const t=e.sdS(3),a=e.sdS(5),i=e.XpG();e.R7$(),e.Y8G("fields",i.fields)("columns",i.createcolumns)("submitButtonText","Next")("dropdownButtonText","Save & Next")("additionalTest",!0)("customTemplates",e.l_i(6,ae,t,a))}}let D=(()=>{class o extends v.h{router;cdr;commonService;toast;dialog;commonStoreService;sanitizer;retailStoreId;isEdit=!1;stepCompleted=new e.bkB;initialData;dynamicForm;aiRawData=new e.bkB;submitRequested=new e.bkB;selectedFiles;logoPreviewUrl;isAiEnabled=!1;seoDraft=null;logoRequestUpdate=new e.bkB;NO_LOADER=(new A._y).set(L.u,!0);destroy$=new M.B;createcolumns;loadingSkeleton=!0;sparkleIcon="../../../../../../../../../assets/images/ph--sparkle-light.svg";fields;fields2;fields3=[];fields4;centreTimeCache={};customTimeCache={};currentOperationMode=null;isSubmitDisabled=(0,e.vPA)(!0);address;configMode;lastFetchedName="";logoCache=new Map;constructor(t,a,i,n,d,r,s){super(),this.router=t,this.cdr=a,this.commonService=i,this.toast=n,this.dialog=d,this.commonStoreService=r,this.sanitizer=s}ngOnInit(){this.configMode=this.getFormConfig(),"create"==this.configMode.operation?(this.initializeFields(),this.getCenterHoursFromWebsite(),this.loadCategories(this.websiteId),this.loadFloorLevels(this.websiteId),setTimeout(()=>{this.handleOperationHoursToggle("1")})):this.isEdit=!0,this.websiteId=this.getWebSiteId()}get isCreate(){return"create"===this.configMode?.operation}ngOnChanges(){this.initialData&&this.isEdit&&(this.initializeFields(),this.loadCategories(this.websiteId),this.loadFloorLevels(this.websiteId),this.prefillFields())}ngAfterViewInit(){const t=this.dynamicForm?.form;if(!t)return;const a=t.get("Name");a?.valueChanges.pipe((0,V.B)(400),(0,G.F)(),(0,g.Q)(this.destroy$),(0,te.n)(i=>{const n=i?.trim();return!n||n.length<3?(this.logoPreviewUrl=null,this.lastFetchedName="",this.cdr.markForCheck(),(0,k.of)(null)):n===this.lastFetchedName?(0,k.of)(null):this.logoCache.has(n)?(this.logoPreviewUrl=this.logoCache.get(n),this.cdr.markForCheck(),(0,k.of)(null)):(this.lastFetchedName=n,this.commonService.post(l.ts.RETAIL_STORE_LOGO,{Name:n},this.NO_LOADER))})).subscribe(i=>{i?.data?this.logoPreviewUrl=i.data:null!==i&&(this.logoPreviewUrl=null),this.cdr.markForCheck()}),a?.valueChanges.pipe((0,g.Q)(this.destroy$)).subscribe(()=>this.updateAiState()),t.get("StoreCategoryId")?.valueChanges.pipe((0,g.Q)(this.destroy$)).subscribe(()=>this.updateAiState()),this.updateAiState()}updateAiState(){const t=this.dynamicForm?.form;if(!t)return;const a=t.get("Name")?.value?.trim(),i=t.get("StoreCategoryId")?.value;this.isAiEnabled=!!a&&!!i,this.cdr.markForCheck()}initializeFields(){this.fields=[{type:"file",id:"storeLogo",label:"Store Logo",fileSizeLabel:"Recommended Height size:284px",name:"Image",layout:"square",fileType:["image/png","image/jpg","image/jpeg","image/svg","image/webp"],multiple:!1,reorder:!1,isreplace:!0,wrapperClass:this.isEdit?"col-12 col-md-12":"d-none",required:!1,validators:{required:!1},showDeleteIcon:!1,hideWhenEmpty:!0,shouldShow:this.isEdit,innerLabel:'Drag & drop file here or <span class="browse-link">browse</span>'}
1,{type:"custom",name:"logoPreview",label:"",wrapperClass:this.isCreate?"col-12 mb-3":"d-none",shouldShow:this.isCreate,realtime:!0},{type:"text",label:"Store Name",name:"Name",placeholder:"Enter Store Name",value:"",wrapperClass:"col-12 col-md-12",validators:{required:!0,maxLength:255,whitespace:!0},required:!0,id:"storeName",readonly:!1},{type:"select",label:"Store Category",name:"StoreCategoryId",placeholder:"Select Store Category",wrapperClass:"col-12 col-md-12",bindLabel:"Title",bindValue:"Id",value:"",options:[],shouldShow:!0,validators:{required:!0},id:"storeCategory"},{type:"custom",label:"",name:"aiTrigger",wrapperClass:"col-12 mb-2",shouldShow:!this.isEdit},{type:"textareaeditor",label:"Store Description",name:"Description",showAIButton:!0,placeholder:"Enter Description",value:"",wrapperClass:"col-12 col-md-12",id:"description",validators:{required:!0,maxLength:5e3}},{type:"select",label:"Floor Level",name:"FloorLevelId",placeholder:"Select Floor Level",wrapperClass:"col-12 col-md-6",bindLabel:"Title",bindValue:"Id",options:[],readonly:!1,disabled:!1,value:"",shouldShow:!0,id:"floorLevel",validators:{required:!0}},{type:"text",label:"Store Number",name:"StoreNumber",placeholder:"Enter Store Number",value:"",wrapperClass:"col-12 col-md-6",readonly:!1,validators:{required:!0,maxLength:255,whitespace:!0},id:"storeNumber"}],this.fields2=[{type:"text",label:"Contact Person",name:"ContactPerson",placeholder:"Enter contact person name",value:"",wrapperClass:"col-12 col-md-6",validators:{maxLength:255},id:"ContactPerson"},{type:"text",label:"Tel Number",name:"TelNumber",placeholder:"Enter telephone number",value:"",wrapperClass:"col-12 col-md-6",validators:{maxLength:50,pattern:l.XF.PHONE_NUMBER_MIN9_MAX16},id:"TelNumber"},{type:"email",label:"Email Address",name:"Email",placeholder:"Enter email address",value:"",wrapperClass:"col-12 col-md-12",validators:{maxLength:255,pattern:l.XF.EMAIL_PATTERN},id:"Email"}],this.fields3=[{type:"radio",label:"",name:"OperationHoursType",value:"1",wrapperClass:"col-12 mb-3",validators:{required:!0},required:!0,options:[{label:"Centre Trading Hours",value:"1"},{label:"Custom Trading Hours",value:"2"}]},{type:"note",label:"Trading Hours Note",name:"OperationHoursTypeNote",wrapperClass:"col-12",noteVariant:"warning",visibleFor:["1"],noteText:"Note: The below times are the Centre Trading hours, should you need to change this select Custom Trading Hours"},{type:"time",label:"Monday - Thursday: Start",name:"MonFriStart",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Monday - Thursday: Start",name:"MonFriStart1",wrapperClass:"col-12 col-md-6",visibleFor:["2"]},{type:"time",label:"Monday - Thursday: End",name:"MonFriEnd",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Monday - Thursday: End",name:"MonFriEnd1",wrapperClass:"col-12 col-md-6",visibleFor:["2"]},{type:"time",label:"Friday: Start (Leave blank for Closed)",name:"FriStart",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Friday: Start (Leave blank for Closed)",name:"FriStart1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"time",label:"Friday: End (Leave blank for Closed)",name:"FriEnd",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Friday: End (Leave blank for Closed)",name:"FriEnd1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"time",label:"Saturday: Start (Leave blank for Closed)",name:"SatStart",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Saturday: Start (Leave blank for Closed)",name:"SatStart1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"time",label:"Saturday: End (Leave blank for Closed)",name:"SatEnd",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Saturday: End (Leave blank for Closed)",name:"SatEnd1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"time",label:"Sunday: Start (Leave blank for Closed)",name:"SunPubStart",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Sunday: End (Leave blank for Closed)",name:"SunPubEnd",wrapperClass:"col-12 col-md-6",visibleFor:["1"]},{type:"time",label:"Public Holidays: Start (Leave blank for Closed)",name:"PubHolStart",wrapperClass:"col-12 col-md-6",visibleFor:["1"],resetTime:!1},{type:"time",label:"Public Holidays: End (Leave blank for Closed)",name:"PubHolEnd",wrapperClass:"col-12 col-md-6",visibleFor:["1"],resetTime:!1},{type:"time",label:"Sunday: Start (Leave blank for Closed)",name:"SunPubStart1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"time",label:"Sunday: End (Leave blank for Closed)",name:"SunPubEnd1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"time",label:"Public Holidays: Start (Leave blank for Closed)",name:"PubHolStart1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"time",label:"Public Holidays: End (Leave blank for Closed)",name:"PubHolEnd1",wrapperClass:"col-12 col-md-6",visibleFor:["2"],resetTime:!0},{type:"textareaeditor",label:"Trading Hours Additional Details",name:"Additional",placeholder:"Description of trading hours",wrapperClass:"col-12 col-md-12 d-none",id:"additionalDetails",validators:{maxLength:5e3},visibleFor:["2"]}],this.fields4=[{type:"switch",label:"Website Link",name:"buttonSwitch",value:!1,wrapperClass:"col-12 col-md-6",i
1d:"isActiveButton",toggleChangedField:["Website"]},{type:"text",label:"Website Link",name:"Website",placeholder:"Enter Website Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"Website",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"Facebook Link",name:"facebookLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveFacebookLink",toggleChangedField:["Facebook"]},{type:"text",label:"Facebook Link",name:"Facebook",placeholder:"Enter Facebook Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"FacebookLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"Instagram Link",name:"instagramLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveInstagramLink",toggleChangedField:["Instagram"]},{type:"text",label:"Instagram Link",name:"Instagram",placeholder:"Enter Instagram Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"InstagramLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"LinkedIn Link",name:"linkedInLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveLinkedInLink",toggleChangedField:["LinkedIn"]},{type:"text",label:"LinkedIn Link",name:"LinkedIn",placeholder:"Enter LinkedIn Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"LinkedInLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"TikTok Link",name:"tikTokLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveTikTokLink",toggleChangedField:["TikTok"]},{type:"text",label:"TikTok Link",name:"TikTok",placeholder:"Enter TikTok Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"TikTokLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"YouTube Link",name:"youTubeLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveYouTubeLink",toggleChangedField:["YouTube"]},{type:"text",label:"YouTube Link",name:"YouTube",placeholder:"Enter YouTube Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"YouTubeLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"WhatsApp Link",name:"whatsAppLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveWhatsAppLink",toggleChangedField:["WhatsApp"]},{type:"text",label:"WhatsApp Link",name:"WhatsApp",placeholder:"Enter WhatsApp Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"WhatsAppLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"Snapchat Link",name:"snapchatLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveSnapchatLink",toggleChangedField:["Snapchat"]},{type:"text",label:"Snapchat Link",name:"Snapchat",placeholder:"Enter Snapchat Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"SnapchatLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0},{type:"switch",label:"X Link",name:"xLinkSwitch",value:!1,wrapperClass:"col-12 col-md-6",id:"isActiveXLink",toggleChangedField:["X"]},{type:"text",label:"X Link",name:"X",placeholder:"Enter X Link",value:"",wrapperClass:"col-12 col-md-12 d-none",id:"XLink",toggleInputField:!1,validators:{maxLength:255,pattern:l.XF.URL_PATTERN},required:!0}],this.updateCreateColumns(),this.loadingSkeleton=!1,this.cdr.markForCheck()}aiFieldMap={retail_store_name:"Name",contact_person:"ContactPerson",tel_number:"TelNumber",email:"Email",website:"Website",facebook:"Facebook",instagram:"Instagram",linkedin:"LinkedIn",tiktok:"TikTok",youtube:"YouTube",whatsapp:"WhatsApp",snapchat:"Snapchat",x:"X",store_description:"Description",trading_hours_additional_details:"Additional"};submitRetailStore(t){if(!this.dynamicForm?.form)return;const a=this.dynamicForm.form.getRawValue();let i=this.prepareOperationHoursPayload({...a,Status:t?.Status??null});!this.isEdit&&this.seoDraft&&(i={...i,MetaTitle:this.seoDraft.MetaTitle,MetaKeywords:this.seoDraft.MetaKeywords,MetaDescription:this.seoDraft.MetaDescription}),this.submitRequested.emit(i)}cancel(){this.router.navigate([l.a$.MANAGE_RETAIL_STORE])}onUpload(t){if(!t?.controlname||!t?.fileList)return;const a=t.fileList.map(i=>i instanceof File?i:i.file??i.raw).filter(i=>i instanceof File);a.length&&this.logoRequestUpdate.emit({controlname:t.controlname,files:a})}updateCreateColumns(){this.createcolumns=[{label:"Store Details",id:"row-from-section row section-0",value:this.fields},{label:"Contact Information",id:"row-from-section row section-1",value:this.fields2},{label:"Trading Hours ",id:"row-from-section row section-2",value:this.fields3},{label:"Store Website & Social Links",id:"row-from-section row section-3",value:this.fields4,buttonPosition:!0}]}loadCategories(t){this.commonService.getData(l.ts.STORE_CATEGORY_DROPDOWN,{WebsiteId:t}).pipe((0,g.Q)(this.destroy$)).subscribe({next:a=>{this.fields?.forEach(i=>
1{"StoreCategoryId"===i.name&&(i.options=a)}),this.cdr.detectChanges()},error:a=>{}})}loadFloorLevels(t){this.commonService.getData(l.ts.FLOOR_LEVEL_DROPDOWN,{WebsiteId:t}).pipe((0,g.Q)(this.destroy$)).subscribe({next:a=>{this.fields?.forEach(i=>{"FloorLevelId"===i.name&&(i.options=a)}),this.cdr.detectChanges()},error:a=>{}})}prefillFields(){if(!this.initialData)return;const t=a=>{if(a?.length)for(const i of a){if("StoreCategoryId"===i.name&&this.initialData.StoreCategoryId)i.value=this.initialData.StoreCategoryId;else if("FloorLevelId"===i.name&&this.initialData.FloorLevelId)i.value=this.initialData.FloorLevelId;else if("file"===i.type&&"Image"===i.name){const d=this.fieldImagePatch(this.initialData);d&&(Object.assign(i,{squarefileList:d.fileList,selectedFileList:d.fileList,value:d.value}),i.validators&&delete i.validators.required);continue}const n=this.initialData[i.name];void 0!==n&&(i.value=n)}};t(this.fields),t(this.fields2),t(this.fields3),t(this.fields4),this.handleTogglePrefill(),this.patchOperationHours(),this.updateCreateColumns(),setTimeout(()=>{if(!this.dynamicForm?.form)return;const a=this.initialData?.OperationHoursData;!a?.MonFriStart&&!a?.MonFriEnd&&!a?.SatStart&&!a?.SatEnd&&!a?.SunPubStart&&!a?.SunPubEnd&&(this.initialData.OperationHoursType="1",this.dynamicForm.form.patchValue({OperationHoursType:"1"}),this.handleOperationHoursToggle("1"))}),setTimeout(()=>{if(!this.dynamicForm?.form)return;const i={};["Website","Facebook","Instagram","LinkedIn","TikTok","YouTube","WhatsApp","Snapchat","X"].forEach(n=>{this.initialData[n]&&(i[n]=this.initialData[n])}),this.dynamicForm.form.patchValue(i)})}handleTogglePrefill(){this.fields4?.length&&(this.fields4.forEach(t=>{if("text"===t.type&&this.initialData[t.name]){t.value=this.initialData[t.name],t.wrapperClass=t.wrapperClass?.replace("d-none","").trim(),t.toggleInputField=!0;const a=this.fields4?.find(i=>"switch"===i.type&&i.toggleChangedField?.includes(t.name));a&&(a.value=!0)}}),this.cdr.detectChanges(),this.cdr.markForCheck())}patchOperationHours(){if(!this.initialData?.OperationHoursData)return;const t=this.initialData.OperationHoursData,a=this.initialData.OperationHoursType?.toString();let i={OperationHoursType:a,Additional:t.Additional??null};"1"===a?(i={...i,MonFriStart:t.MonFriStart??null,MonFriEnd:t.MonFriEnd??null,FriStart:t.FriStart??null,FriEnd:t.FriEnd??null,SatStart:t.SatStart??null,SatEnd:t.SatEnd??null,SunPubStart:t.SunPubStart??null,SunPubEnd:t.SunPubEnd??null,PubHolStart:t.PubHolStart??null,PubHolEnd:t.PubHolEnd??null},this.centreTimeCache={...i}):"2"===a&&(i={...i,MonFriStart1:t.MonFriStart??null,MonFriEnd1:t.MonFriEnd??null,FriStart1:t.FriStart??null,FriEnd1:t.FriEnd??null,SatStart1:t.SatStart??null,SatEnd1:t.SatEnd??null,SunPubStart1:t.SunPubStart??null,SunPubEnd1:t.SunPubEnd??null,PubHolStart1:t.PubHolStart??null,PubHolEnd1:t.PubHolEnd??null},this.customTimeCache={...i}),this.currentOperationMode=a,setTimeout(()=>{this.dynamicForm?.form&&this.dynamicForm.form.patchValue(i)}),setTimeout(()=>{this.handleOperationHoursToggle(a)})}prepareOperationHoursPayload(t){return"2"===t.OperationHoursType&&(t.MonFriStart=t.MonFriStart1??null,t.MonFriEnd=t.MonFriEnd1??null,t.FriStart=t.FriStart1??null,t.FriEnd=t.FriEnd1??null,t.SatStart=t.SatStart1??null,t.SatEnd=t.SatEnd1??null,t.SunPubStart=t.SunPubStart1??null,t.SunPubEnd=t.SunPubEnd1??null,t.PubHolStart=t.PubHolStart1??null,t.PubHolEnd=t.PubHolEnd1??null),delete t.MonFriStart1,delete t.MonFriEnd1,delete t.SatStart1,delete t.SatEnd1,delete t.SunPubStart1,delete t.SunPubEnd1,delete t.PubHolStart1,delete t.PubHolEnd1,t}fieldImagePatch(t){if(t?.LogoMediaId&&t?.LogoName&&t?.LogoUrl){const a=[{url:t.LogoUrl,type:"image",name:t.LogoName}];return{fileList:a,value:a,isDragnDrop:!1}}return null}onDynamicFieldChange(t){if("OperationHoursType"===t.field){const a=t.value;"1"===a&&"2"===this.currentOperationMode&&(["MonFriStart","MonFriEnd","SatStart","SatEnd","SunPubStart","SunPubEnd"].some(r=>this.centreTimeCache[r])?setTimeout(()=>{this.dynamicForm?.form?.patchValue(this.centreTimeCache),this.cdr.detectChanges()}):this.getCenterHoursFromWebsite()),this.handleOperationHoursToggle(a)}}handleOperationHoursToggle(t){const a=this.dynamicForm?.form?.getRawValue();if(this.applyOperationHoursVisibility(t),!this.fields3?.length||!this.dynamicForm?.form)return;const i=["MonFriStart","MonFriEnd"],n=["MonFriStart1","MonFriEnd1"],d=this.dynamicForm.form;this.fields3.forEach(r=>{const s=d.get(r.name);s&&(r.validators||(r.validators={}),"1"===t&&(i.includes(r.name)?(r.validators.required=!0,s.setValidators([C.k0.required])):(r.validators.required=!1,s.clearValidators())),"2"===t&&(n.includes(r.name)?(r.validators.required=!0,s.setValidators([C.k0.required])):(r.validators.required=!1,s.clearValidators())),s.updateV
1alueAndValidity())}),this.updateCreateColumns(),setTimeout(()=>{this.dynamicForm?.form?.patchValue(a)}),this.cdr.detectChanges(),this.currentOperationMode=t}applyOperationHoursVisibility(t){if(!this.fields3)return;const a="1"===t;this.fields3=this.fields3.map(i=>{if(!i.visibleFor)return i;const n=i.wrapperClass?.replace("d-none","").trim(),d=i.visibleFor.includes(t);return{...i,wrapperClass:d?n:`${n} d-none`.trim(),readonly:"time"===i.type?a:i.readonly}}),this.updateCreateColumns(),this.cdr.detectChanges()}generateDataFromAI(){const t=this.dynamicForm?.form;if(!t)return;const a=t.get("Name")?.value?.trim(),i=t.get("StoreCategoryId")?.value;a||i?a?i?this.dialog.open(E.r,{width:"600px",data:{title:"Generate Retail Store Details using AI",description:"If you generate data from AI, all existing data will be replaced. Do you want to continue?",confirmButtonLabel:"Yes, Generate",cancelButtonLabel:"No, Cancel"}}).afterClosed().subscribe(d=>{if(!d)return;const r={loading:!0,message:"Please wait while auto populating store data...",result:null,title:""},s=this.dialog.open(E.r,{width:"700px",disableClose:!0,data:{component:z,componentData:r,closeBtn:!1}});this.commonService.getData(`${l.ts.WEBSITE_CONTACT_AI_DETAILS}`,{WebsiteId:this.websiteId},this.NO_LOADER).subscribe({next:u=>{const h={Store:this.dynamicForm?.form?.get("Name")?.value,Center:this.centerName,CenterAddress:u.Address};this.commonService.post(`${l.ts.AI_STORE_DETAILS}`,h,this.NO_LOADER).subscribe({next:T=>{r.loading=!1,r.result=T,s.disableClose=!1,s.componentInstance.data={...s.componentInstance.data,title:"Preview AI Data",closeBtn:!0,confirmButtonLabel:"Apply",cancelButtonLabel:"Cancel"}},error:()=>{r.loading=!1,s.componentInstance.data.cancelButtonLabel="Close"}})},error:()=>{s.close()}}),s.afterClosed().subscribe(u=>{if(u){const _=u?.step_by_step_reasoning?{...u}:u;this.patchAIData(_),this.isEdit?this.updateSeo(u):(this.seoDraft={MetaTitle:this.trimValue(u.meta_title||u.MetaTitle,255),MetaKeywords:this.trimValue(u.meta_keywords||u.MetaKeywords,255),MetaDescription:this.trimValue(u.meta_description||u.MetaDescription,500)},this.aiRawData.emit(u))}})}):this.toast.error("Please select Store Category before generating AI data."):this.toast.error("Please enter Store Name before generating AI data."):this.toast.error("Please enter Store Name and select Store Category before generating AI data.")}trimValue(t,a){return t&&"string"==typeof t&&t.length>a?t.slice(0,a):t}patchAIData(t){if(!this.dynamicForm?.form)return;const a=this.dynamicForm.form;Object.keys(this.aiFieldMap).forEach(s=>{const f=this.aiFieldMap[s];let u=t[s];if(null!=u&&a.get(f)){if("Name"===f)return;"Description"===f?setTimeout(()=>{a.patchValue({Description:u}),this.cdr.detectChanges()},0):a.patchValue({[f]:u})}}),[{key:"Website",switch:"buttonSwitch"},{key:"Facebook",switch:"facebookLinkSwitch"},{key:"Instagram",switch:"instagramLinkSwitch"},{key:"LinkedIn",switch:"linkedInLinkSwitch"}
1,{key:"TikTok",switch:"tikTokLinkSwitch"},{key:"YouTube",switch:"youTubeLinkSwitch"},{key:"WhatsApp",switch:"whatsAppLinkSwitch"},{key:"Snapchat",switch:"snapchatLinkSwitch"},{key:"X",switch:"xLinkSwitch"}].forEach(s=>{const f=a.get(s.key)?.value,u=!(!f||!f.toString().trim()),_=a.get(s.switch);if(_){_.setValue(u);const h=this.fields4?.find(I=>I.name===s.key),T=this.fields4?.find(I=>I.name===s.switch);h&&T&&(T.value=u,u?(h.wrapperClass=h.wrapperClass?.replace("d-none","").trim(),h.toggleInputField=!0):(h.wrapperClass?.includes("d-none")||(h.wrapperClass=`${h.wrapperClass} d-none`.trim()),h.toggleInputField=!1))}});const n=t?.operational_hours;if(!n)return this.updateCreateColumns(),void this.cdr.detectChanges();Object.values(n).every(s=>s?.start&&s?.end),n.monday_friday?.start||n.monday_friday?.end||n.saturday?.start||n.saturday?.end||n.sunday?.start||n.sunday?.end||n.public_holidays?.start||n.public_holidays?.end?(a.patchValue({OperationHoursType:"2",MonFriStart1:this.convertTo24Hour(n.monday_friday.start),MonFriEnd1:this.convertTo24Hour(n.monday_friday.end),FriStart1:this.convertTo24Hour(n.monday_friday.start),FriEnd1:this.convertTo24Hour(n.monday_friday.end),SatStart1:this.convertTo24Hour(n.saturday.start),SatEnd1:this.convertTo24Hour(n.saturday.end),SunPubStart1:this.convertTo24Hour(n.sunday.start),SunPubEnd1:this.convertTo24Hour(n.sunday.end),PubHolStart1:this.convertTo24Hour(n.public_holidays?.start??null),PubHolEnd1:this.convertTo24Hour(n.public_holidays?.end??null)}),this.handleOperationHoursToggle("2"),this.applyOperationHoursVisibility("2")):(this.updateCreateColumns(),this.cdr.detectChanges())}convertTo24Hour(t){if(!t)return null;const[a,i]=t.split(" ");let[n,d]=a.split(":").map(Number);return"PM"===i&&12!==n&&(n+=12),"AM"===i&&12===n&&(n=0),`${n.toString().padStart(2,"0")}:${d.toString().padStart(2,"0")}`}aiGeneratedDescription(t){const a=this.dynamicForm?.form;a&&(a.get("Name")?.value?.trim()?this.dialog.open(E.r,{width:"560px",data:{title:"Request Type",component:ee,componentData:t.formValue}}).afterClosed().subscribe(d=>{if(!d||!this.dynamicForm?.form)return;let r=d;"string"==typeof d&&(r=JSON.parse(d)),this.isEdit?this.updateSeo(r):(this.seoDraft={MetaTitle:this.trimValue(r.meta_title||r.MetaTitle,255),MetaKeywords:this.trimValue(r.meta_keywords||r.MetaKeywords,255),MetaDescription:this.trimValue(r.meta_description||r.MetaDescription,500)},this.aiRawData.emit(r));const s=r?.StoreDescription;s&&this.dynamicForm.form.patchValue({Description:s})}):this.toast.error("Please enter Store Name before generating AI data."))}updateSeo(t){const a={MetaTitle:this.trimValue(t.meta_title||t.MetaTitle,255),MetaKeywords:this.trimValue(t.meta_keywords||t.MetaKeywords,255),MetaDescription:this.trimValue(t.meta_description||t.MetaDescription,500),WebsiteId:this.websiteId};this.commonService.post(`${l.ts.RETAIL_STORE_UPDATE_SEO}/${this.getFormConfig().id}`,a,this.NO_LOADER).subscribe({next:i=>{},error:()=>{}})}getCenterHoursFromWebsite(){let t={WebsiteId:Number};t.WebsiteId=super.getWebSiteId(),this.commonService.get(`${l.ts.WEBSITE_CONTACT_DETAILS}`,t).subscribe({next:a=>{const i=a.data.OperationHours;i&&(this.centreTimeCache={MonFriStart:i.MonFriStart??null,MonFriEnd:i.MonFriEnd??null,SatStart:i.SatStart??null,SatEnd:i.SatEnd??null,FriStart:i.FriStart??null,FriEnd:i.FriEnd??null,SunPubStart:i.SunPubStart??null,SunPubEnd:i.SunPubEnd??null,PubHolStart:i.PubHolStart??null,PubHolEnd:i.PubHolEnd??null},setTimeout(()=>{this.dynamicForm?.form&&(this.dynamicForm.form.patchValue(this.centreTimeCache),this.cdr.detectChanges())}))},error:()=>{}})}getFormConfig(){const t=this.storageService.get("form-config");return t?JSON.parse(t):null}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}static \u0275fac=function(a){return new(a||o)(e.rXU(F.Ix),e.rXU(e.gRc),e.rXU(y.h),e.rXU(x.f),e.rXU(S.j),e.rXU(P.S),e.rXU(ie.up))};static \u0275cmp=e.VBU({type:o,selectors:[["app-retail-store-details"]],viewQuery:function(a,i){if(1&a&&e.GBs(b.f,5),2&a){let n;e.mGM(n=e.lsd())&&(i.dynamicForm=n.first)}},inputs:{retailStoreId:"retailStoreId",isEdit:"isEdit",initialData:"initialData"},outputs:{stepCompleted:"stepCompleted",aiRawData:"aiRawData",submitRequested:"submitRequested",logoRequestUpdate:"logoRequestUpdate"},features:[e.Vt3,e.OA$],decls:3,vars:2,consts:[["logoPreviewTemplate",""],["aiButtonTemplate",""],[1,"retail-store-details-form-container","position-relative"],["type","button","class","rd-generate-btn rd-ai-button",3,"click",4,"ngIf"],[4,"ngIf"],["type","button",1,"rd-generate-btn","rd-ai-button",3,"click"],[1,"rd-sparkle-icon","px-1"],[3,"src"],[1,"px-2"],[3,"formSubmit","formCancel","uploadfile","aiButtonTemplate","fieldValueChanged","fields","columns","submitButtonText","dropdownButtonText","additionalTest","customTemplates"],["class","logo-preview-container",4,"ngIf"],[1,"logo-preview-container"],[1,"form-label"],[1,"logo-preview"],["alt","Store Logo",3,"src"],["class","col-12 d-flex justify-content-end mt-2",4,"ngIf"],[1,"col-12","d-flex","justify-content-end","mt-2"],["type","button",1,"rd-generate-btn1","rd-ai-button",3,"click","disabled"]],template:function(a,i){1&a&&(e.j41(0,"div",2),e.DNE(1,ne,5,1,"button",3)(2,de,6,9,"div",4),e.k0s()),2&a&&(e.R7$(),e.Y8G("ngIf",i.isEdit),e.R7$(),e.Y8G("ngIf",!i.loadingSkeleton&&i.createcolumns&&i.fields&&i.fields4))},dependencies:[b.f,m.MD,m.bT],styles:[".retail-store-details-form-container[_ngcontent-%COMP%]{width:fit-content}.rd-generate-btn.rd-ai-button[_ngcontent-%COMP%]{position:absolute;top:15px;right:15px;z-index:10}.rd-ai-button[_ngcontent-%COMP%]:disabled{background-color:#cfcfcf;cursor:not-allowed;opacity:.7}.rd-ai-button[_ngcontent-%COMP%]:disabled .rd-sparkle-icon[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{filter:grayscale(100%);opacity:.6}@media(max-width:768px){[_nghost-%COMP%] .square-upload-container{max-width:100%!important}[_nghost-%COMP%] .square-left, [_nghost-%COMP%] .square-right{max-width:100%!important}}.rd-ai-button[_ngcontent-%COMP%]{background-color:#75b897;padding:7px 14px;border-radius:50px;z-index:10;text-align:left;cursor:pointer}.rd-generate-btn[_ngcontent-%COMP%]{color:#fff;text-align:center}.rd-sparkle-icon[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:24px;height:24px}@media(max-width:768px){.rd-generate-btn[_ngcontent-%COMP%]{font-size:small}.rd-ai-button[_ngcontent-%COMP%]{width:160px;padding:10px 12px}.rd-sparkle-icon[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:18px;height:18px}}@media(max-width:425px){.rd-ai-button[_ngcontent-%COMP%]{right:12px;min-width:80px;padding:6px 8px;display:flex;align-items:center;gap:8px}.rd-generate-btn[_ngcontent-%COMP%] .px-2[_ngcontent-%COMP%]{display:inline-block;font-size:12px;white-space:normal;max-width:160px;line-height:1.1;overflow:visible;text-overflow:clip}.rd-generate-btn[_ngcontent-%COMP%]{white-space:normal;overflow:visible;text-align:center}}@media(max-width:375px){.rd-ai-button[_ngcontent-%COMP%]{right:8px;min-width:70px;padding:5px 6px}.rd-sparkle-icon[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:15px;height:15px}.rd-generate-btn[_ngcontent-%COMP%] .px-2[_ngcontent-%COMP%]{display:inline-block;font-size:11px;max-width:120px;white-space:normal;line-height:1.1}}.logo-preview[_ngcontent-%COMP%]{padding:12px;border:1px dashed #ddd;border-radius:8px;text-align:center;background:#fafafa;width:30%}.logo-preview[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{max-height:120px;object-fit:contain;width:100%}"],changeDetection:0})}return o}
1)();function ce(o,c){if(1&o){const t=e.RV6();e.j41(0,"div")(1,"app-dynamic-form",1),e.bIt("formCancel",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.cancel())})("formSubmit",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.submitSeo(i))}),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(),e.Y8G("fields",t.fields)("columns",t.createcolumns)("submitButtonText","Submit & Finish")("flexiWidth",!0)}}function pe(o,c){1&o&&(e.j41(0,"div"),e.nrm(1,"app-skeleton-loader",2),e.k0s()),2&o&&(e.R7$(),e.Y8G("type","user-form"))}let ue=(()=>{class o extends v.h{retailStoreId;initialData;isEdit=!1;stepCompleted=new e.bkB;aiData;loadingSkeleton=!0;fields;createcolumns;destroy$=new M.B;cdr=(0,e.WQX)(e.gRc);router=(0,e.WQX)(F.Ix);toasterService=(0,e.WQX)(x.f);commonService=(0,e.WQX)(y.h);META_DATA_KEY="Meta_Data";ngOnInit(){this.initializeFields(),this.aiData?this.patchSeoFromAI(this.aiData):this.isEdit&&this.retailStoreId&&this.fetchSeoData()}ngOnChanges(){this.aiData&&this.fields?.length&&this.patchSeoFromAI(this.aiData)}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}patchSeoFromAI(t){if(!this.fields?.length)return;const a={MetaTitle:t?.MetaTitle||t?.meta_title,MetaKeywords:t?.MetaKeywords||t?.meta_keywords,MetaDescription:t?.MetaDescription||t?.meta_description};this.fields=this.fields.map(i=>{const n=a[i.name];return{...i,value:n??i.value}}),this.createcolumns=[{value:this.fields}],this.cdr.detectChanges()}prefillFields(t){if(!this.fields||!t)return;const a={MetaTitle:t.MetaTitle||"",MetaKeywords:t.MetaKeywords||"",MetaDescription:t.MetaDescription||""};this.fields.forEach(i=>{const n=a[i.name];void 0!==n&&(i.value=n)}),this.createcolumns=[{value:this.fields}],this.loadingSkeleton=!1,this.cdr.detectChanges()}fetchSeoData(){this.loadingSkeleton=!0;const t=`${l.ts.RETAIL_STORE_DETAIL}/${this.retailStoreId}`,a=this.getWebSiteId();this.commonService.get(t,{WebsiteId:a}).pipe((0,g.Q)(this.destroy$)).subscribe({next:i=>{this.prefillFields(i?.data||{})},error:()=>{this.loadingSkeleton=!1,this.cdr.detectChanges(),this.toasterService.error("Failed to load SEO details")}})}initializeFields(){this.loadingSkeleton=!1,this.fields=[{type:"text",label:"Meta Title",name:"MetaTitle",placeholder:"Enter meta title",value:"",wrapperClass:"col-12 col-md-12",validators:{maxLength:255},id:"metaTitle"},{type:"text",label:"Meta Keyword",name:"MetaKeywords",placeholder:"Enter meta keyword",value:"",wrapperClass:"col-12 col-md-12",validators:{maxLength:255},id:"MetaKeywords"},{type:"textarea",label:"Meta Description",name:"MetaDescription",placeholder:"Enter meta description",value:"",wrapperClass:"col-12 col-md-12",validators:{maxLength:500},id:"metaDescription"}],this.createcolumns=[{value:this.fields}]}submitSeo(t){if(!this.retailStoreId)return void this.toasterService.error("Retail Store ID is missing.");const a={...t,MetaTitle:"string"==typeof t.MetaTitle?t.MetaTitle.slice(0,255):t.MetaTitle,MetaKeywords:"string"==typeof t.MetaKeywords?t.MetaKeywords.slice(0,255):t.MetaKeywords,MetaDescription:"string"==typeof t.MetaDescription?t.MetaDescription.slice(0,500):t.MetaDescription,WebsiteId:this.getWebSiteId()};this.commonService.post(`${l.ts.RETAIL_STORE_UPDATE_SEO}/${this.retailStoreId}`,a).pipe((0,g.Q)(this.destroy$)).subscribe({next:n=>{this.router.navigateByUrl(l.a$.MANAGE_RETAIL_STORE).then(()=>this.toasterService.success(n.message)),this.stepCompleted.emit()},error:n=>this.toasterService.error(n?.error?.message)})}cancel(){this.router.navigate([l.a$.MANAGE_RETAIL_STORE])}static \u0275fac=(()=>{let t;return function(i){return(t||(t=e.xGo(o)))(i||o)}})();static \u0275cmp=e.VBU({type:o,selectors:[["app-retail-store-seo"]],inputs:{retailStoreId:"retailStoreId",initialData:"initialData",isEdit:"isEdit",aiData:"aiData"},outputs:{stepCompleted:"stepCompleted"},features:[e.Vt3,e.OA$],decls:2,vars:2,consts:[[4,"ngIf"],[3,"formCancel","formSubmit","fields","columns","submitButtonText","flexiWidth"],[3,"type"]],template:function(a,i){1&a&&e.DNE(0,ce,2,4,"div",0)(1,pe,2,1,"div",0),2&a&&(e.Y8G("ngIf",!i.loadingSkeleton&&i.createcolumns&&i.fields),e.R7$(),e.Y8G("ngIf",i.loadingSkeleton))},dependencies:[b.f,m.MD,m.bT,R.W],encapsulation:2})}return o}
1)();function me(o,c){if(1&o&&(e.j41(0,"span",16),e.EFF(1),e.k0s()),2&o){let t;const a=e.XpG(2);e.R7$(),e.SpI(" - ",null==(t=a.initialData())?null:t.Name," ")}}function he(o,c){if(1&o&&(e.j41(0,"span"),e.DNE(1,me,2,1,"span",15),e.EFF(2),e.k0s()),2&o){let t,a;const i=e.XpG();e.R7$(),e.Y8G("ngIf","edit"===(null==i.configMode?null:i.configMode.operation)&&(null==(t=i.initialData())?null:t.Name)),e.R7$(),e.SpI("(",(null==(a=i.getWebSite())?null:a.Center)||(null==(a=i.getWebSite())?null:a.Name),")")}}function fe(o,c){1&o&&e.nrm(0,"app-skeleton-loader",17),2&o&&e.Y8G("type","stepper-form-steps")}function ge(o,c){if(1&o){const t=e.RV6();e.j41(0,"app-retail-store-details",18),e.bIt("stepCompleted",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.onRetailStoreDetailsCompleted(i))})("submitRequested",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.onRetailStoreSubmit(i))})("aiRawData",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.handleAiRawData(i))})("logoRequestUpdate",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.onLogoRequestUpdate(i))}),e.k0s()}if(2&o){const t=e.XpG();e.AVh("form-hidden",t.loadingSkeleton()),e.Y8G("initialData",t.initialData())("isEdit","edit"===(null==t.configMode?null:t.configMode.operation))("retailStoreId","edit"===(null==t.configMode?null:t.configMode.operation)?t.retailStoreId:void 0)}}function be(o,c){if(1&o){const t=e.RV6();e.j41(0,"app-retail-store-seo",19),e.bIt("stepCompleted",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.onSeoCompleted())}),e.k0s()}if(2&o){const t=e.XpG();e.Y8G("retailStoreId",t.retailStoreId)("initialData",t.initialData())("isEdit","edit"===(null==t.configMode?null:t.configMode.operation))("aiData",t.aiGeneratedData)}}let Se=(()=>{class o extends v.h{backUrl=l.a$.MANAGE_RETAIL_STORE;currentStep=1;retailStoreId;configMode;initialData=(0,e.vPA)(null);loadingSkeleton=(0,e.vPA)(!0);isSeoStepEnabled=(0,e.vPA)(!1);aiGeneratedData=null;cdr=(0,e.WQX)(e.gRc);retailDetailsCmp=e.ebz.required(D);commonService=(0,e.WQX)(y.h);commonStore=(0,e.WQX)(P.S);toasterService=(0,e.WQX)(x.f);router=(0,e.WQX)(F.Ix);STATE_STEP_KEY="RETAIL_STORE_SELECTED_STEP";ngOnInit(){const t=this.getFormConfig();this.configMode=t,this.restoreStep("edit"===t?.operation&&t?.id),"edit"===t?.operation&&t?.id?(this.retailStoreId=t.id,this.loadStoreDetail(t.id),this.isSeoStepEnabled.set(!0)):this.loadingSkeleton.set(!1)}ngOnDestroy(){this.storageService.remove("form-config"),this.storageService.remove(this.STATE_
1STEP_KEY,"local")}restoreStep(t){this.currentStep=2===Number(this.storageService.get(this.STATE_STEP_KEY,"local"))&&t?2:1}loadStoreDetail(t){const a=this.getWebSiteId();this.commonService.get(`${l.ts.RETAIL_STORE_DETAIL}/${t}`,{WebsiteId:a}).pipe((0,w.s)(1)).subscribe({next:i=>{this.initialData.set(i.data),this.setStoreWebite(i.data.Website),this.loadingSkeleton.set(!1)},error:()=>this.router.navigate([this.backUrl])})}onRetailStoreSubmit(t){const a=this.getWebSiteId(),i="edit"===this.configMode?.operation;this.commonService.post(i?`${l.ts.UPDATE_RETAIL_STORE}/${this.retailStoreId}`:l.ts.CREATE_RETAIL_STORE,{...t,WebsiteId:a}).pipe((0,w.s)(1)).subscribe({next:d=>{this.toasterService.success(d?.message),this.onRetailStoreDetailsCompleted(i?this.retailStoreId:d?.data?.RetailStoreId)},error:d=>this.toasterService.error(d?.error?.message)})}onRetailStoreDetailsCompleted(t){this.retailStoreId=t,"edit"!==this.configMode?.operation&&(this.configMode={id:t,module:"Retail Store",operation:"edit"},this.commonStore.setFormConfig(this.configMode),this.loadStoreDetail(t)),this.isSeoStepEnabled.set(!0),this.goToStep(2)}goToStep(t){2===t&&!this.isSeoStepEnabled()||(1===t&&"edit"===this.configMode?.operation&&this.retailStoreId&&this.loadStoreDetail(this.retailStoreId),this.currentStep=t,this.storageService.set(this.STATE_
1STEP_KEY,t.toString(),"local"),this.cdr.detectChanges())}onSeoCompleted(){this.router.navigate([this.backUrl])}onLogoRequestUpdate(t){if(!this.retailStoreId||"edit"!==this.configMode?.operation)return;const{files:a}=t;if(!a?.length)return void this.toasterService.info("No files selected.");const i=new FormData;let n=0;a.forEach(r=>{const s=r instanceof File?r:r.file??r.raw;s instanceof File&&(i.append("Logo",s,s.name),n++)}),0!==n?(i.append("WebsiteId",this.getWebSiteId()),this.commonService.post(`${l.ts.STORE_LOGO_APPROVAL_REQUEST}${this.retailStoreId}`,i).pipe((0,w.s)(1)).subscribe({next:r=>{this.toasterService.success(r?.message),this.loadStoreDetail(this.retailStoreId)},error:r=>this.toasterService.error(r?.error?.message)})):this.toasterService.info("No new files to upload.")}getFormConfig(){const t=this.storageService.get("form-config");return t?JSON.parse(t):null}setStoreWebite(t){this.storageService.set("store_website_url",t,"local")}handleAiRawData(t){this.aiGeneratedData=t}static \u0275fac=(()=>{let t;return function(i){return(t||(t=e.xGo(o)))(i||o)}})();static \u0275cmp=e.VBU({type:o,selectors:[["app-retail-store-stepper"]],viewQuery:function(a,i){1&a&&e.wEZ(i.retailDetailsCmp,D,5),2&a&&e.NyB()},features:[e.Vt3],decls:23,vars:14,consts:[[1,"rd-container-header"],[1,"rd-container-header-left"],[3,"url"],[1,"rd-heading","rd-heading-lg"],[4,"ngIf"],[1,"container","mt-4"],[3,"type",4,"ngIf"],[1,"row"],[1,"col-md-3","col-12"],[1,"list-group","stepper"],[1,"left-stepper-item",3,"click"],[1,"step-number"],[1,"col-md-9","col-12"],[3,"initialData","isEdit","retailStoreId","form-hidden"],[3,"retailStoreId","initialData","isEdit","aiData"],["class","rd-title-text",4,"ngIf"],[1,"rd-title-text"],[3,"type"],[3,"stepCompleted","submitRequested","aiRawData","logoRequestUpdate","initialData","isEdit","retailStoreId"],[3,"stepCompleted","retailStoreId","initialData","isEdit","aiData"]],template:function(a,i){if(1&a&&(e.j41(0,"div",0)(1,"div",1)(2,"div"),e.nrm(3,"back-button",2),e.k0s(),e.j41(4,"div",3),e.EFF(5),e.DNE(6,he,3,2,"span",4),e.k0s()()(),e.j41(7,"div",5),e.DNE(8,fe,1,1,"app-skeleton-loader",6),e.j41(9,"div",7)(10,"div",8)(11,"ul",9)(12,"li",10),e.bIt("click",function(){return i.goToStep(1)}),e.j41(13,"span",11),e.EFF(14,"1"),e.k0s(),e.EFF(15," Retail Store Details "),e.k0s(),e.j41(16,"li",10),e.bIt("click",function(){return i.goToStep(2)}),e.j41(17,"span",11),e.EFF(18,"2"),e.k0s(),e.EFF(19," SEO "),e.k0s()()(),e.j41(20,"div",12),e.DNE(21,ge,1,5,"app-retail-store-details",13)(22,be,1,4,"app-retail-store-seo",14),e.k0s()()()),2&a){let n;e.R7$(3),e.Y8G("url",i.backUrl),e.R7$(2),e.SpI(" ","edit"===(null==i.configMode?null:i.configMode.operation)?"Edit Store":"Create New - Retail Store",""),e.R7$(),e.Y8G("ngIf",(null==(n=i.getWebSite())?null:n.Center)||(null==(n=i.getWebSite())?null:n.Name)),e.R7$(2),e.Y8G("ngIf",i.loadingSkeleton()),e.R7$(),e.AVh("form-hidden",i.loadingSkeleton()),e.R7$(3),e.AVh("active",1===i.currentStep),e.R7$(4),e.AVh("active",2===i.currentStep)("disabled",!i.isSeoStepEnabled()),e.R7$(5),e.vxM(1===i.currentStep?21:-1),e.R7$(),e.vxM(2===i.currentStep&&i.retailStoreId?22:-1)}},dependencies:[m.MD,m.bT,N.X,D,ue,R.W],styles:[".left-stepper-item[_ngcontent-%COMP%]{width:100%;height:50px;display:flex;align-items:center;justify-content:flex-start;margin-bottom:10px;padding:10px 15px;border:1px solid #dfdfdf;border-radius:12px;font-weight:600;font-size:16px;line-height:19px;color:#b8b8b8;background:#fcfcfc;transition:all .3s ease-in;cursor:pointer}.left-stepper-item.active[_ngcontent-%COMP%]{color:#c00018;background:#fff}.left-stepper-item.disabled[_ngcontent-%COMP%]{opacity:.6;cursor:not-allowed;pointer-events:none}.step-number[_ngcontent-%COMP%]{width:32px;height:32px;display:flex;align-items:center;justify-content:center;margin-right:15px;border:1px solid #b8b8b8;border-radius:50%}.left-stepper-item.active[_ngcontent-%COMP%] .step-number[_ngcontent-%COMP%]{border-color:#c00018}.rd-title-text[_ngcontent-%COMP%]{font-weight:600;margin-left:8px;color:#555;font-size:22px}.form-hidden[_ngcontent-%COMP%]{opacity:0;pointer-events:none}"]})}return o}
1)()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.