1import{d as ae,j as e,ak as j,bW as U,by as q,hx as Ae,r as a,v as Re,L as M,hy as E,V as ze,bd as $,W as se,eD as Ze,a1 as S,c as ge,ek as be,d2 as We,aS as Oe,br as A,a4 as O,bw as Ue}from"./index-2CwtICst.js";import{x as qe,y as $e,l as Ce,z as Ke,A as Ye}from"./index-D-uFs3Zw.js";import{R as Ne}from"./EditOutlined-DNdDFaOm.js";import{R as Je}from"./InfoCircleOutlined-WJAwMEA5.js";import{R as Qe}from"./PlusOutlined-BhrmrG55.js";import{C as Xe}from"./index-IOqWghCC.js";import{D as et}from"./index-BCDMll3A.js";import{F as T}from"./index-CcQVicQJ.js";import{a as tt}from"./modal_header-Zzno9Dew.js";import{M as at}from"./index-BC4zRIry.js";import{f as st}from"./utils-LWmzMYKk.js";import"./PlusOutlined-ByZyTB3m.js";import"./index-CUYKYEVB.js";import"./Portal-m7W4unkL.js";import"./getScrollBarSize-CHB1zEd-.js";import"./CloseIcon-CdU2swGf.js";import"./QuestionCircleOutlined-CkfPyHQh.js";import"./col-MZTILiOt.js";import"./DialogWrap-DDRffVA8.js";import"./useId-BeW6vcu-.js";import"./index-BS6LE1GZ.js";import"./index-B3E771uX.js";import"./api-GdgXwhxd.js";import"./index-sjF6j1Zg.js";const rt="_container_4xrrd_10",nt="_divider_4xrrd_13",it="_card_4xrrd_16",lt="_headerTitle_4xrrd_26",ot="_headerSubtitle_4xrrd_33",dt="_optionCard_4xrrd_40",ct="_optionHeader_4xrrd_53",ut="_radio_4xrrd_58",pt="_radioActive_4xrrd_68",mt="_optionCardActive_4xrrd_79",_t="_centralDeselectedCard_4xrrd_84",ht="_optionTitle_4xrrd_94",xt="_stateOptionCard_4xrrd_99",Ct="_stateOptionTitle_4xrrd_104",ft="_stateOptionDesc_4xrrd_112",yt="_stateTableWrap_4xrrd_119",gt="_stateTableHeader_4xrrd_127",bt="_th_4xrrd_137",Nt="_thPadded_4xrrd_144",St="_cellPadded_4xrrd_147",jt="_infoIcon_4xrrd_150",vt="_stateTableRow_4xrrd_154",Gt="_stateCell_4xrrd_164",wt="_gstinCell_4xrrd_170",It="_gstinValue_4xrrd_175",Tt="_primaryPill_4xrrd_181",Ft="_addrCell_4xrrd_194",Bt="_actionCell_4xrrd_200",Vt="_addGstinBtn_4xrrd_204",kt="_addGstinIcon_4xrrd_220",Ht="_addGstinText_4xrrd_223",Lt="_editBtn_4xrrd_226",Mt="_stateTableEmpty_4xrrd_238",Et="_gstModalGrid2_4xrrd_269",Pt="_gstinStateSuffix_4xrrd_274",Dt="_labeledInput_4xrrd_284",At="_drawerFormItem_4xrrd_322",Rt="_drawerFooter_4xrrd_325",zt="_primaryCheckboxField_4xrrd_331",Zt="_drawerCancelBtn_4xrrd_340",Wt="_drawerUpdateBtn_4xrrd_357",Ot="_optionDesc_4xrrd_376",Ut="_kvRow_4xrrd_383",qt="_kvLabel_4xrrd_401",$t="_kvValue_4xrrd_409",Kt="_centralGstinValueRow_4xrrd_418",Yt="_centralGstinValue_4xrrd_418",Jt="_actions_4xrrd_428",Qt="_saveBtn_4xrrd_431",t={container:rt,divider:nt,card:it,headerTitle:lt,headerSubtitle:ot,optionCard:dt,optionHeader:ct,radio:ut,radioActive:pt,optionCardActive:mt,centralDeselectedCard:_t,optionTitle:ht,stateOptionCard:xt,stateOptionTitle:Ct,stateOptionDesc:ft,stateTableWrap:yt,stateTableHeader:gt,th:bt,thPadded:Nt,cellPadded:St,infoIcon:jt,stateTableRow:vt,stateCell:Gt,gstinCell:wt,gstinValue:It,primaryPill:Tt,addrCell:Ft,actionCell:Bt,addGstinBtn:Vt,addGstinIcon:kt,addGstinText:Ht,editBtn:Lt,stateTableEmpty:Mt,gstModalGrid2:Et,gstinStateSuffix:Pt,labeledInput:Dt,drawerFormItem:At,drawerFooter:Rt,primaryCheckboxField:zt,drawerCancelBtn:Zt,drawerUpdateBtn:Wt,optionDesc:Ot,kvRow:Ut,kvLabel:qt,kvValue:$t,centralGstinValueRow:Kt,centralGstinValue:Yt,actions:Jt,saveBtn:Qt},Xt=({active:r,onSelect:m,gstin:l,billingAddress:y,onEditGstin:_})=>{const{isShipfastChildUser:c}=ae(),x=u=>{u.stopPropagation(),!c&&(_==null||_())};return e.jsxs("div",{className:j(t.optionCard,r&&t.optionCardActive,!r&&t.centralDeselectedCard),onClick:m,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),m())},role:"button",tabIndex:0,"aria-pressed":r,children:[e.jsxs("div",{className:t.optionHeader,children:[e.jsx("span",{className:j(t.radio,r&&t.radioActive)}),e.jsxs("div",{children:[e.jsx("p",{className:t.optionTitle,children:"Central GST (Default)"}),e.jsx("p",{className:t.optionDesc,children:"Select this if you have one pickup warehouse or if all your pickup locations are registered under a single GSTIN (as per KYC record)."})]})]}),r&&e.jsxs("div",{className:t.kvRow,children:[e.jsxs("div",{children:[e.jsx("p",{className:t.kvLabel,children:"GSTIN"}
1),e.jsxs("div",{className:t.centralGstinValueRow,children:[e.jsx("p",{className:j(t.kvValue,t.centralGstinValue),children:l||"-"}),_&&e.jsx(U,{color:"#FFFFFF",overlayInnerStyle:{color:"#3D3D6B"},title:c?"You donât have permission to edit GSTIN. Please contact your admin.":"",children:e.jsx("div",{children:e.jsx(q,{size:"small",className:t.editBtn,disabled:c,icon:e.jsx(Ne,{}),"aria-label":"Edit GSTIN",onClick:x})})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:t.kvLabel,children:"Billing Address"}),e.jsx("p",{className:t.kvValue,children:y||"-"})]})]})]})},ea={title:"If GSTIN is missing, the invoice, label, and buyerâs invoice (if applicable) will be generated without GSTIN.",color:"#FFFFFF",overlayInnerStyle:{color:"#3D3D6B",paddingLeft:19}},ta=({active:r,onSelect:m,rows:l,onAddGstin:y,onEditGstin:_})=>{const c=46+Math.max(l.length,1)*77,{isShipfastChildUser:x}=ae(),u=n=>v=>{v.stopPropagation(),y(n)},g=n=>v=>{v.stopPropagation(),_(n)};return e.jsxs("div",{className:j(t.optionCard,t.stateOptionCard,r&&t.optionCardActive),onClick:m,role:"button",tabIndex:0,children:[e.jsxs("div",{className:t.optionHeader,children:[e.jsx("span",{className:j(t.radio,r&&t.radioActive)}),e.jsxs("div",{children:[e.jsx("p",{className:t.stateOptionTitle,children:"State GST"}),e.jsx("p",{className:t.stateOptionDesc,children:"Select this If you have multiple pickup warehouses and want one consolidated state level invoice for each state."})]})]}),r&&e.jsxs("div",{className:t.stateTableWrap,style:{minHeight:c},children:[e.jsxs("div",{className:t.stateTableHeader,children:[e.jsx("span",{className:t.th,children:"State"}),e.jsx("span",{className:j(t.th,t.thPadded),children:"GSTIN"}),e.jsx("span",{className:j(t.th,t.thPadded),children:"GSTIN Billing Address"}),e.jsx("span",{className:j(t.th,t.thPadded),children:"Action"})]}),l.length===0?e.jsx("div",{className:t.stateTableEmpty,children:"No states found."}):l.map(n=>e.jsxs("div",{className:t.stateTableRow,children:[e.jsx("div",{className:t.stateCell,children:n.state}),e.jsxs("div",{className:j(t.gstinCell,t.cellPadded),children:[e.jsxs("div",{className:t.gstinValue,children:[n.gstin,n.gstin==="NA"&&e.jsx(U,{...ea,children:e.jsx(Je,{className:t.infoIcon})})]}),n.isPrimary&&e.jsx("span",{className:t.primaryPill,children:"Primary GSTIN for VAS billing"})]}),e.jsx("div",{className:j(t.addrCell,t.cellPadded),children:n.billingAddress}),e.jsx("div",{className:j(t.actionCell,t.cellPadded),children:e.jsx(U,{color:"#FFFFFF",overlayInnerStyle:{color:"#3D3D6B"},title:x?"You donât have permission to add GSTIN. Please contact your admin.":"",children:e.jsx("div",{children:n.gstin==="NA"?e.jsxs(q,{size:"small",className:t.addGstinBtn,disabled:x,onClick:u(n),children:[e.jsx(Qe,{className:t.addGstinIcon}),e.jsx("span",{className:t.addGstinText,children:"ADD GSTIN"})]}):e.jsx(q,{size:"small",className:t.editBtn,disabled:x,icon:e.jsx(Ne,{}),"aria-label":"Edit GSTIN",onClick:g(n)})})})})]},n.key))]})]})},aa=Object.freeze({"01":"Jammu and Kashmir","02":"Himachal Pradesh","03":"Punjab","04":"Chandigarh","05":"Uttarakhand","06":"Haryana","07":"Delhi","08":"Rajasthan","09":"Uttar Pradesh",10:"Bihar",11:"Sikkim",12:"Arunachal Pradesh",13:"Nagaland",14:"Manipur",15:"Mizoram",16:"Tripura",17:"Meghalaya",18:"Assam",19:"West Bengal",20:"Jharkhand",21:"Odisha",22:"Chhattisgarh",23:"Madhya Pradesh",24:"Gujarat",25:"Daman and Diu",26:"Dadra and Nagar Haveli",27:"Maharashtra",28:"Andhra Pradesh",29:"Karnataka",30:"Goa",31:"Lakshadweep",32:"Kerala",33:"Tamil Nadu",34:"Puducherry",35:"Andaman and Nicobar Islands",36:"Telangana",37:"Andhra Pradesh"}),sa=({open:r,mode:m,stateName:l,initialValues:y,submitting:_,onClose:c,onSubmit:x})=>{const[u]=T.useForm(),{stateList:g}=Ae(),n=void 0,v=a.useMemo(()=>{const b=m==="add"?"Add":"Edit";return l?`${b} GST for state '${l}'`:`${b} GST`},[m,l]),F=a.useMemo(()=>{const b=g||[],I={};for(const N of b){const V=(N==null?void 0:N.attributes)||{},d=String(V.short_code||"").trim(),G=String(V.name||"").trim();if(!d||!G)continue;const L=d.padStart(2,"0");I[L]=G}return{codeToName:I}},[g]),C=T.useWatch("pincode",u),H=T.useWatch("gstin",u),f=a.useMemo(()=>{var N;const b=(H||"").toString().trim().toUpperCase();if(!b||b.length<2||!Re.gst(b))return"";const I=b.slice(0,2);return((N=F.codeToName)==null?void 0:N[I])||aa[I]||""},[H,F.codeToName]);return a.useEffect(()=>{if(!r)return;let b=!1;return(async()=>{var R;const N=String(C||"").trim();if(N.length!==6)return;const{ok:V,data:d}=await Ze(N);if(b)return;if(!V){S("Location with this pincode does not exist");return}const G=(R=d==null?void 0:d.data)==null?void 0:R.attributes,L=G==null?void 0:G.city_name,P=G==null?void 0:G.state_name;L&&u.setFieldsValue({city:L}),!f&&P&&u.setFieldsValue({state:P})})(),()=>{b=!0}},[u,f,r,C]),a.useEffect(()=>{r&&f&&u.setFieldsValue({state:f})},[u,f,r]),e.jsx(Xe,{open:r,onClose:c,destroyOnClose:!0,header:e.jsx(et,{headerTitle:v,onClose:c}),footer:e.jsxs($,{justify:"flex-end",gap:40,className:t.drawerFooter,children:[e.jsx(q,{size:"small",className:t.drawerCancelBtn,onClick:c,children:"CANCEL"}),e.jsx(se,{size:"small",className:t.drawerUpdateBtn,loading:!!_,disabled:!!_,onClick:()=>u.submit(),children:m==="add"?"ADD":"UPDATE"})]}),children:e.jsxs(T,{form:u,layout:"vertical",initialValues:y,onFinish:x,children:[e.jsx(T.Item,{name:"gstin",rules:[{required:!0,message:"GSTIN is required"}],required:!0,className:t.drawerFormItem,children:e.jsx(M,{required:!0,component:E,label:"Enter GSTIN",placeholder:"Enter GSTIN",wrapperClassName:t.labeledInput,innerRef:n,suffix:e.jsx("span",{className:t.gstinStateSuffix,children:f})})}),e.jsxs("div",{className:`ui-labeled-input ${t.primaryCheckboxField}`,children:[e.jsx("label",{className:"ui-labeled-input__label",children:"Primary GSTIN"}),e.jsx(T.Item,{name:"isPrimary",valuePropName:"checked",noStyle:!0,children:e.jsx(ze,{children:"Select this GSTIN as the Primary GSTIN for VAS billing."})})]}),e.jsx(T.Item,{name:"streetAddress",rules:[{required:!0,message:"Billing address is required"}],required:!0,className:t.drawerFormItem,children:e.jsx(M,{required:!0,component:E,label:"Billing Address",placeholder:"Enter billing address",wrapperClassName:t.labeledInput,innerRef:n})}),e.jsxs("div",{className:t.gstModalGrid2,children:[e.jsx(T.Item,{name:"pincode",rules:[{required:!0,message:"Pincode is required"}],required:!0,className:t.drawerFormItem,children:e.jsx(M,{required:!0,component:E,label:"Pincode",placeholder:"Enter pincode",wrapperClassName:t.labeledInput,innerRef:n})}),e.jsx(T.Item,{name:"city",rules:[{required:!0,message:"City is required"}],required:!0,className:t.drawerFormItem,children:e.jsx(M,{required:!0,component:E,label:"City",placeholder:"Enter city",wrapperClassName:t.labeledInput,disabled:!0,innerRef:n})})]}),e.jsxs("div",{className:t.gstModalGrid2,children:[e.jsx(T.Item,{name:"country",rules:[{required:!0,message:"Country is required"}],required:!0,className:t.drawerFormItem,children:e.jsx(M,{required:!0,component:E,label:"Country",wrapperClassName:t.labeledInput,disabled:!0,innerRef:n})}),e.jsx(T.Item,{name:"state",rules:[{required:!0,message:"State is required"}],required:!0,className:t.drawerFormItem,children:e.jsx(M,{required:!0,component:E,label:"State",disabled:!0,wrapperClassName:t.labeledInput,innerRef:n,placeholder:"Enter state"})})]})]})})},ra=r=>a.createElement("svg",{width:33,height:33,viewBox:"0 0 33 33",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},a.createElement("path",{d:"M22.3984 0.0078125V8.57145H32.995V6.29716C32.995 3.66997 31.5217 1.42095 29.4279 0.479357C28.7532 0.175775 28.0127 0.00
178125 27.2371 0.0078125H22.3984Z",fill:"#AFCAFF"}),a.createElement("path",{d:"M7.34375 6.437V32.5713H19.6391C22.6544 32.5713 25.0988 30.1269 25.0988 27.1116V8.57159H25.0733V7.09906C25.0733 5.141 25.835 3.36788 27.066 2.08451C27.7327 1.38847 28.5383 0.837976 29.4353 0.479357C28.799 0.175775 28.1007 0.0078125 27.3695 0.0078125H13.5132C10.1055 0.0078125 7.34375 2.88641 7.34375 6.437Z",fill:"#D1DFFB"}),a.createElement("path",{d:"M3.30469 31.9673C3.3922 32.0124 3.47972 32.0548 3.57008 32.0957C4.24492 32.3993 4.98472 32.5673 5.75971 32.5673H18.9271C19.2955 32.5673 19.6556 32.5335 20.0057 32.4699C22.8984 31.9376 25.0965 29.3062 25.0965 26.1381V0.00390625H12.8015C9.78606 0.00390625 7.34081 2.44765 7.34081 5.46309V12.1703C7.84769 11.96 8.39819 11.8457 8.96432 11.8457C9.28339 11.8457 9.60668 11.881 9.92861 11.9557C10.9281 12.1887 11.7892 12.7605 12.3878 13.5792C12.4528 13.6668 12.5135 13.7558 12.5714 13.8489C12.7423 14.1227 12.8792 14.4108 12.9809 14.7086C13.2406 15.4569 13.2843 16.2658 13.0995 17.0564C12.8976 17.9247 12.4402 18.6687 11.8261 19.2262C10.9663 20.0098 9.79883 20.429 8.58898 20.3218C8.39411 20.3048 8.19653 20.2723 8.0003 20.2272C7.77159 20.1735 7.55131 20.103 7.34095 20.014V24.0037H7.36636V25.476C7.36636 27.4341 6.60537 29.2072 5.37432 30.4906C4.78279 31.1075 4.08117 31.6116 3.30469 31.9673Z",fill:"#E5EDFF"}),a.createElement("path",{d:"M0 24.0039V26.2782C0 28.7925 1.34968 30.961 3.30204 31.9676C3.38955 32.0127 3.47707 32.0551 3.56744 32.096C4.24228 32.3996 4.98193 32.5675 5.75706 32.5675H20.1964V32.5041C20.1314 32.4942 20.068 32.4829 20.003 32.4702C19.5936 32.3912 19.1998 32.2641 18.8257 32.0961C16.7321 31.1545 15.2582 28.9055 15.2582 26.2783V24.004H0V24.0039Z",fill:"#AFCAFF"}),a.createElement("path",{d:"M16.8826 4.28906H9.48438V5.29045H16.8826V4.28906Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M22.363 4.28906H17.6094V5.29045H22.363V4.28906Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M16.8748 8.73047H9.47656V9.73172H16.8748V8.73047Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M22.3474 8.73047H17.5938V9.73172H22.3474V8.73047Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M16.8826 6.125H9.48438V7.12625H16.8826V6.125Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M22.6717 19.2891H15.2734V20.2903H22.6717V19.2891Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M16.4998 21.5117H9.10156V22.513H16.4998V21.5117Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M22.6761 21.5117H16.8906V22.513H22.6761V21.5117Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M13.8943 19.2891H9.14062V20.2903H13.8943V19.2891Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M22.3992 11.793H15.7031V12.7942H22.3992V11.793Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M14.3318 11.793H9.57812V12.7942H14.3318V11.793Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M22.3211 13.668H15.625V14.6692H22.3211V13.668Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M14.2458 13.668H9.49219V14.6692H14.2458V13.668Z",fill:"#B8C2FF"}),a.createElement("path",{d:"M29.2785 28.3199C29.606 26.3185 28.249 24.4304 26.2475 24.1029C24.2461 23.7754 22.3581 25.1324 22.0305 27.1338C21.703 29.1353 23.06 31.0233 25.0615 31.3509C27.0629 31.6784 28.9509 30.3214 29.2785 28.3199Z",fill:"white"}),a.createElement("path",{d:"M28.6604 28.5845C29.1317 26.6121 27.9148 24.631 25.9423 24.1597C23.9698 23.6884 21.9888 24.9053 21.5175 26.8778C21.0461 28.8502 22.2631 30.8313 24.2355 31.3026C26.208 31.7739 28.1891 30.557 28.6604 28.5845Z",fill:"#1AB746"}),a.createElement("path",{d:"M24.9403 29.243L22.9688 27.7019L23.3873 27.1665L24.8568 28.3154L26.861 26.0664L27.3681 26.5184L24.9403 29.243Z",fill:"white"}),a.createElement("path",{d:"M10.8533 12.0367L10.6356 11.656L10.6367 11.6541L1.11581 6.10688C0.905454 5.98431 0.635704 6.05551 0.51313 6.26587C0.390555 6.47624 0.461764 6.74612 0.672125 6.86855L10.1929 12.4157L10.1939 12.4138L10.6325 12.4155L10.9646 12.4169C11.0119 12.417 11.0416 12.3659 11.0181 12.3249L10.8533 12.0367Z",fill:"#407BFF"}),a.createElement("path",{d:"M2.80515 8.47567C2.78816 8.47567 2.77091 8.47173 2.75487 8.46344C2.70282 8.43667 1.47653 7.80327 0.941119 7.4062C0.450413 7.04228 0.58223 6.57264 0.720568 6.37518C0.755356 6.32531 0.823982 6.31308 0.87399 6.34814C0.923726 6.38293 0.935956 6.45128 0.901439 6.50102C0.873446 6.54192 0.640935 6.9091 1.07253 7.22913C1.59354 7.61561 2.8432 8.26109 2.8557 8.26762C2.90979 8.29547 2.93112 8.36192 2.90327 8.41601C2.8837 8.45392 2.8451 8.47567 2.80515 8.47567Z",fill:"#FFAF45"}),a.createElement("path",{d:"M10.194 11.5931C10.1905 11.5931 10.1868 11.5921 10.1836 11.5902L8.38531 10.5425C8.37552 10.5368 8.37199 10.524 8.37783 10.5142C8.38354 10.5043 8.39631 10.5009 8.40623 10.5068L10.2045 11.5546C10.2143 11.5603 10.2178 11.5731 10.212 11.5829C10.2082 11.5894 10.2012 11.5931 10.194 11.5931Z",fill:"white"})),na=r=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},a.createElement("path",{d:"M2 3.993C2.00183 3.73038 2.1069 3.47902 2.29251 3.29322C2.47813 3.10742 2.72938 3.00209 2.992 3H21.008C21.556 3 22 3.445 22 3.993V20.007C21.9982 20.2696 21.8931 20.521 21.7075 20.7068C21.5219 20.8926 21.2706 20.9979 21.008 21H2.992C2.72881 20.9997 2.4765 20.895 2.29049 20.7088C2.10448 20.5226 2 20.2702 2 20.007V3.993ZM4 5V19H20V5H4ZM6 7H12V13H6V7ZM8 9V11H10V9H8ZM6 15H18V17H6V15ZM14 7H18V9H14V7ZM14 11H18V13H14V11Z",fill:"#2BD65B"}
1)),ia="_modalWrap_1zcuy_10",la="_container_1zcuy_31",oa="_header_1zcuy_38",da="_closeButtonWrap_1zcuy_48",ca="_headerCopy_1zcuy_54",ua="_title_1zcuy_58",pa="_subtitle_1zcuy_67",ma="_body_1zcuy_77",_a="_loadingWrap_1zcuy_83",ha="_sectionRow_1zcuy_87",xa="_sectionLabel_1zcuy_95",Ca="_emptyState_1zcuy_104",fa="_optionRow_1zcuy_111",ya="_optionRowSelected_1zcuy_129",ga="_radioGroup_1zcuy_144",ba="_checkbox_1zcuy_149",Na="_gstIconWrap_1zcuy_166",Sa="_optionRowList_1zcuy_179",ja="_gstListIconWrap_1zcuy_184",va="_gstinText_1zcuy_196",Ga="_currentBadge_1zcuy_204",wa="_dividerLine_1zcuy_224",Ia="_optionList_1zcuy_232",Ta="_footer_1zcuy_237",Fa="_footerBtn_1zcuy_244",Ba="_cancelBtn_1zcuy_257",Va="_updateBtn_1zcuy_268",i={modalWrap:ia,container:la,header:oa,closeButtonWrap:da,headerCopy:ca,title:ua,subtitle:pa,body:ma,loadingWrap:_a,sectionRow:ha,sectionLabel:xa,emptyState:Ca,optionRow:fa,optionRowSelected:ya,radioGroup:ga,checkbox:ba,gstIconWrap:Na,optionRowList:Sa,gstListIconWrap:ja,gstinText:va,currentBadge:Ga,dividerLine:wa,optionList:Ia,footer:Ta,footerBtn:Fa,cancelBtn:Ba,updateBtn:Va},ka=({open:r,currentGstin:m,gstIntegrations:l,loading:y,submitting:_,onClose:c,onConfirm:x})=>{const u=a.useMemo(()=>{const C=(l||[]).map(f=>String((f==null?void 0:f.integration_service_id)||"")).filter(Boolean),H=m?[m,...C]:C;return Array.from(new Set(H.map(f=>f.toUpperCase())))},[m,l]),g=(m||"").toUpperCase(),[n,v]=a.useState(g);a.useEffect(()=>{r&&v(g)},[r,g]);const F=u.filter(C=>C!==g);return e.jsx(at,{open:r,onCancel:c,footer:null,centered:!0,closable:!1,width:528,wrapClassName:i.modalWrap,destroyOnClose:!0,children:e.jsxs("div",{className:i.container,children:[e.jsxs("div",{className:i.header,children:[e.jsx("div",{className:i.closeButtonWrap,children:e.jsx(tt,{onClose:c})}),e.jsxs("div",{className:i.headerCopy,children:[e.jsx("p",{className:i.title,children:"Update GST"}),e.jsx("p",{className:i.subtitle,children:"Replace the current GST with one from your previously fetched GSTs"})]})]}),e.jsx("div",{className:i.body,children:y?e.jsx($,{justify:"center",align:"center",className:i.loadingWrap,children:e.jsx(ge,{})}):u.length===0?e.jsx("p",{className:i.emptyState,children:"No GSTIN found"}):e.jsxs(be.Group,{value:n,onChange:C=>v(C.target.value),className:i.radioGroup,children:[g?e.jsx(fe,{gstin:g,selected:!0,isCurrent:!0}):null,F.length>0&&e.jsxs("div",{className:i.sectionRow,children:[e.jsx("p",{className:i.sectionLabel,children:"Select GST to update"}),e.jsx("div",{className:i.dividerLine})]}),e.jsx("div",{className:i.optionList,children:F.map(C=>e.jsx(fe,{gstin:C,checked:n===C,listIcon:!0,onSelect:()=>v(C)},C))})]})}),e.jsxs("div",{className:i.footer,children:[e.jsx(We,{size:"small",className:j(i.footerBtn,i.cancelBtn),disabled:!!_,onClick:c,children:"CANCEL"}),e.jsx(se,{size:"small",className:j(i.footerBtn,i.updateBtn),loading:!!_,disabled:!!y||!n||n===g||!!_,onClick:()=>x(n),children:"UPDATE"})]})]})})},fe=({gstin:r,checked:m,selected:l,isCurrent:y,listIcon:_,onSelect:c}
1)=>e.jsxs("div",{className:j(i.optionRow,l&&i.optionRowSelected,_&&i.optionRowList),onClick:c,onKeyDown:x=>{c&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c())},role:l?void 0:"radio","aria-checked":l?void 0:m,tabIndex:l||!c?-1:0,children:[!l&&e.jsx(be,{value:r,checked:m,className:i.checkbox,onClick:x=>x.stopPropagation()}),e.jsx("span",{className:j(i.gstIconWrap,_&&i.gstListIconWrap),children:_?e.jsx(na,{}):e.jsx(ra,{})}),e.jsx("span",{className:i.gstinText,children:r}),y?e.jsx("span",{className:i.currentBadge,children:"Current Selected GST"}):null]}),ye="India",Ha=r=>r?[r.street_address,r.city,r.state,r.country,r.zip].filter(Boolean).join(", "):"",ns=()=>{var le,oe,de;const{shipfastProfile:r,isLoading:m,reloadShipfastProfile:l}=Oe(),{invoiceAddresses:y,isLoading:_}=qe(),{clientGsts:c,isLoading:x,reloadClientGsts:u}=$e(),{isShipfastChildUser:g,profile:n}=ae(),[v,F]=a.useState("central"),C=a.useRef(!1),[H,f]=a.useState(!1),[b,I]=a.useState(!1),[N,V]=a.useState("add"),[d,G]=a.useState(null),[L,P]=a.useState(!1),[R,K]=a.useState([]),[Se,Y]=a.useState(!1),B=a.useMemo(()=>r!=null&&r.id?String(r.id):"",[r==null?void 0:r.id]),z=((le=r==null?void 0:r.attributes)==null?void 0:le.gst_no)||"",J=((oe=r==null?void 0:r.attributes)==null?void 0:oe.billing_gst_mode)||"",Z=a.useMemo(()=>Ha(y==null?void 0:y[0]),[y]),k=z,re=((de=n==null?void 0:n.company)==null?void 0:de.company_type)==="private",Q=a.useMemo(()=>(c||[]).map((s,p)=>{var xe;const o=(s==null?void 0:s.attributes)||((xe=s==null?void 0:s.data)==null?void 0:xe.attributes)||{},h=o.billing_address||{},w=o.state_name||h.state||o.state||"NA",ke=o.gstin||o.gst_no||"NA",ce=(h==null?void 0:h.street_address)||"",ue=(h==null?void 0:h.city)||"",pe=(h==null?void 0:h.state)||"",me=(h==null?void 0:h.zip)||"",_e=(h==null?void 0:h.country)||"",he=[ce,ue,pe,_e,me].filter(Boolean),He=he.length?he.join(", "):"NA",Le=ce||o.street_address||"",Me=ue||o.city||"",Ee=me||o.zip||o.pincode||"",Pe=_e||o.country||"",De=!!(o.is_primary??o.primary);return{key:String((s==null?void 0:s.id)||w),id:s!=null&&s.id?String(s.id):void 0,state:w,gstin:ke,billingAddress:He,isPrimary:De,address:{street_address:Le,city:Me,zip:Ee,country:Pe,state:pe||w}}}),[c]),D=a.useMemo(()=>(Q||[]).filter(s=>s.gstin&&s.gstin!=="NA"),[Q]),X=a.useMemo(()=>D.filter(s=>s.isPrimary),[D]),ne=a.useMemo(()=>{if(!d)return null;if(N==="add"){const p=d.address||{};return{gstin:"",isPrimary:!!d.isPrimary,streetAddress:p.street_address||"",pincode:p.zip||"",city:p.city||"",country:p.country||ye,state:p.state||d.state||""}}const s=d.address||{};return{gstin:d.gstin==="NA"?"":d.gstin,isPrimary:!!d.isPrimary,streetAddress:s.street_address||"",pincode:s.zip||"",city:s.city||"",country:s.country||ye,state:s.state||d.state||""}},[N,d]),je=!!k&&!!Z,ve=D.length>0&&X.length===1;a.useEffect(()=>{if(C.current)return;if(J==="state"){F("state");return}if(J==="central"){F("central");return}const s=(c||[]).some(p=>{var w;const o=(p==null?void 0:p.attributes)||((w=p==null?void 0:p.data)==null?void 0:w.attributes)||{};return(o.gstin||o.gst_no||"")===z});F(s&&z?"state":"central")},[c,z,J]);const W=a.useCallback(async s=>{if(!B)return S("Client ID not found. Please refresh and try again."),!1;const o=await Ce({clientId:B,payload:s==="central"?{billing_gst_mode:s,gst_no:k}:{billing_gst_mode:s}});return o.ok?(await(l==null?void 0:l()),O("GSTIN preference saved"),!0):(S(A(o.data,"Unable to update GST mode")),!1)},[k,B,l]),Ge=a.useCallback(async()=>{if(!k){S("GSTIN not available. Please complete GST details first.");return}if(!Z){S("Billing address not available. Please add your billing address first.");return}f(!0);try{await W("central")}finally{f(!1)}},[Z,k,W]),we=a.useCallback(async()=>{if(D.length===0){S("Please add at least one GSTIN for State GST.");return}if(X.length!==1){S("Please mark exactly one GSTIN as primary for VAS billing.");return}f(!0);try{await W("state")}finally{f(!1)}},[X.length,W,D.length]),ie=a.useCallback(s=>{C.current=!0,F(s)},[]),Ie=a.useCallback(s=>{V("add"),G(s)},[]),Te=a.useCallback(s=>{V("edit"),G(s)},[]),ee=a.useCallback(()=>G(null),[]),Fe=a.useCallback(async()=>{P(!0),Y(!0);try{const{ok:s,data:p,gstIntegrations:o}=await st();if(!s){S(A(p,"Unable to fetch GST integrations")),K([]);return}K(o)}finally{Y(!1)}},[]),te=a.useCallback(()=>{P(!1),K([]),Y(!1)},[]),Be=a.useCallback(async s=>{if(!B){S("Client ID not found. Please refresh and try again.");return}const p=s.trim().toUpperCase();if(!p){S("GSTIN is required");return}I(!0);try{const o=await Ce({clientId:B,payload:{gst_no:p}});if(!o.ok){S(A(o.data,"Unable to update GSTIN"));return}await(l==null?void 0:l()),O("GSTIN updated"),te()}finally{I(!1)}},[B,te,l]),Ve=a.useCallback(async s=>{if(!B){S("Client ID not found. Please refresh and try again.");return}const p={gstin:s.gstin,is_primary:!!s.isPrimary,billing_address:{street_address:s.streetAddress,city:s.city,state:s.state,zip:s.pincode,country:s.country}};I(!0);try{const o=d==null?void 0:d.id;if(N==="edit"||!!o){if(!o){S("Unable to update GSTIN (missing GST ID).");return}const w=await Ke({clientId:B,gstId:o,payload:p});if(!w.ok){S(A(w.data,"Unable to update GSTIN"));return}O("GSTIN updated")}else{const w=await Ye({clientId:B,payload:p});if(!w.ok){S(A(w.data,"Unable to add GSTIN"));return}O("GSTIN added")}await u(),ee()}finally{I(!1)}},[B,ee,N,d==null?void 0:d.id,u]);return m||_||x?e.jsx(ge,{}):e.jsxs($,{vertical:!0,gap:16,className:t.container,children:[e.jsx(Ue,{className:t.divider}),e.jsxs("div",{className:t.card,children:[e.jsx("p",{className:t.headerTitle,children:"GSTIN Preference"}),e.jsx("p",{className:t.headerSubtitle,children:"Select the GST option best suited for your business"}),e.jsxs($,{vertical:!0,gap:14,style:{marginTop:14},children:[e.jsx(Xt,{active:v==="central",onSelect:()=>ie("central"),gstin:k,billingAddress:Z,onEditGstin:re?Fe:void 0}),e.jsx(ta,{active:v==="state",onSelect:()=>ie("state"),rows:Q,onAddGstin:Ie,onEditGstin:Te})]}),e.jsx("div",{className:t.actions,children:e.jsx(U,{color:"#FFFFFF",overlayInnerStyle:{color:"#3D3D6B"},title:g?"You donât have permission to make changes. Please contact your admin.":"",children:e.jsx(e.Fragment,{children:e.jsx(se,{loading:H,onClick:v==="central"?Ge:we,disabled:(v==="central"?!je:!ve)||g,className:t.
1saveBtn,children:"Save"})})})})]}),d&&ne&&e.jsx(sa,{open:!!d,mode:N,stateName:d.state,initialValues:ne,onClose:ee,submitting:b,onSubmit:Ve}),re&&e.jsx(ka,{open:L,currentGstin:k,gstIntegrations:R,loading:Se,submitting:b,onClose:te,onConfirm:Be})]})};export{ns as Component};
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.