more-desk-one 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +111 -109
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),V=require("more-sso-sdk"),fe=require("@radix-ui/react-popover");function me(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(s,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return s.default=e,Object.freeze(s)}const l=me(i),R=me(fe);let de=null;function ge(e){de=e}function xe(e){de?.(e)}const ue=i.createContext(void 0),ye=({children:e,appName:s,apiKey:r,token:a})=>{const[c,h]=i.useState(!!a),[u,b]=i.useState(a),[p,o]=i.useState(!0),[w,_]=i.useState(null);return i.useEffect(()=>{ge(b)},[]),t.jsx(ue.Provider,{value:{appName:s,apiKey:r,accessToken:u,authorized:c,setAuthorized:h,isChatScreen:p,setIsChatScreen:o,profileInfo:w,setProfileInfo:_},children:e})},$=()=>{const e=i.useContext(ue);if(!e)throw new Error("useSdkContext must be used inside SDKProvider");return e},Ce=e=>l.createElement("svg",{width:36,height:36,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M15.8261 8.67349C12.4046 8.67349 9.63062 11.447 9.63062 14.8685C9.63062 18.29 12.4046 21.064 15.8261 21.064C16.1656 21.064 16.4991 21.0365 16.8241 20.984C15.0221 20.4765 13.7006 18.8205 13.7006 16.856C13.7006 14.4875 15.6206 12.568 17.9886 12.568C19.8251 12.568 21.3921 13.722 22.0031 15.345C22.0151 15.188 22.0211 15.029 22.0211 14.8685C22.0211 11.447 19.2476 8.67349 15.8261 8.67349Z",fill:"#B72402"}),l.createElement("path",{d:"M17.9984 7.621C13.0309 7.621 9.00342 11.6485 9.00342 16.616C9.00342 20.526 11.4949 23.8495 14.9744 25.0915V27.785C14.9744 28.228 15.4404 28.515 15.8349 28.3125C17.5759 27.4215 21.5219 25.332 23.5549 23.696C23.6114 23.65 23.6674 23.6065 23.7214 23.5605C23.7624 23.527 23.8009 23.494 23.8394 23.4605C25.7724 21.8115 26.9964 19.356 26.9964 16.616C26.9964 11.6485 22.9689 7.621 17.9989 7.621H17.9984ZM15.8274 21.064C15.5379 21.064 15.2539 21.0435 14.9749 21.005C11.9559 20.59 9.63092 18.0015 9.63092 14.8675C9.63092 11.4465 12.4039 8.6735 15.8274 8.6735C19.2509 8.6735 22.0214 11.4465 22.0214 14.8675C22.0214 15.0265 22.0164 15.185 22.0034 15.341C21.8319 17.6225 20.4259 19.5555 18.4544 20.48C17.9424 20.7205 17.3919 20.892 16.8154 20.9845C16.4929 21.036 16.1624 21.064 15.8269 21.064H15.8274Z",fill:"#FA4B16"})),we=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M14.4167 3.58334L14.4167 5.13334L5.58341 5.13333L5.58341 3.58333L14.4167 3.58334ZM2.66675 4.5L6.06675 8.01667L2.68341 11.5167L1.56675 10.4L3.86675 8.01667L1.55008 5.61667L2.66675 4.5ZM14.4167 7.25L14.4167 8.81667L7.48341 8.81667L7.48341 7.25L14.4167 7.25ZM14.4167 10.8667L14.4167 12.4333L5.58341 12.4333L5.58341 10.8667L14.4167 10.8667Z",fill:"#172128"})),_e=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M13.25 14.45L8.7667 9.98335C8.44448 10.238 8.06414 10.4378 7.6257 10.5827C7.18725 10.7276 6.71203 10.8 6.20003 10.8C4.92048 10.8 3.8367 10.3556 2.9487 9.46668C2.0607 8.57779 1.6167 7.50557 1.6167 6.25001C1.6167 4.99446 2.06114 3.92223 2.95003 3.03335C3.83892 2.14446 4.91392 1.70001 6.17503 1.70001C7.43614 1.70001 8.50837 2.14446 9.3917 3.03335C10.275 3.92223 10.7167 4.99529 10.7167 6.25251C10.7167 6.75085 10.6473 7.2139 10.5084 7.64168C10.3695 8.06946 10.1611 8.47223 9.88337 8.85001L14.3834 13.3167L13.25 14.45ZM6.1892 9.23335C7.02142 9.23335 7.72298 8.94307 8.29387 8.36251C8.86464 7.78196 9.15003 7.07779 9.15003 6.25001C9.15003 5.42223 8.86381 4.71807 8.29137 4.13751C7.71892 3.55696 7.0182 3.26668 6.1892 3.26668C5.35109 3.26668 4.64059 3.55696 4.0577 4.13751C3.47481 4.71807 3.18337 5.42223 3.18337 6.25001C3.18337 7.07779 3.47398 7.78196 4.0552 8.36251C4.63642 8.94307 5.34775 9.23335 6.1892 9.23335Z",fill:"#172128"})),ke=e=>l.createElement("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M10.0417 19.3958V17.7292H16.0625V16.6042H12.7292V9.70833H16.0625V8.77083C16.0625 7.10417 15.4757 5.67014 14.3021 4.46875C13.1285 3.26736 11.7049 2.66667 10.0312 2.66667C8.38542 2.66667 6.95833 3.26736 5.75 4.46875C4.54167 5.67014 3.9375 7.10417 3.9375 8.77083V9.70833H7.27083V16.6042H1.97917V8.775C1.97917 7.66722 2.19229 6.62306 2.61854 5.6425C3.04479 4.66195 3.62132 3.80319 4.34812 3.06625C5.07493 2.32931 5.92903 1.74861 6.91042 1.32417C7.89167 0.899722 8.93667 0.6875 10.0454 0.6875C11.154 0.6875 12.1944 0.899306 13.1667 1.32292C14.1389 1.74653 14.9868 2.32424 15.7104 3.05604C16.4342 3.78785 17.0036 4.64278 17.4187 5.62083C17.834 6.59889 18.0417 7.64889 18.0417 8.77083V19.3958H10.0417ZM3.9375 14.625H5.3125V11.6875H3.9375V14.625ZM14.7083 14.625H16.0625V11.6875H14.7083V14.625Z",fill:"#172128"})),ve=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M1.58334 12.6167V11.0333H14.4333V12.6167H1.58334ZM1.58334 8.78333V7.21666H14.4333V8.78333H1.58334ZM1.58334 4.96666V3.38333H14.4333V4.96666H1.58334Z",fill:"#172128"})),je=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M12.7833 10.679C12.7833 11.9375 12.3239 12.9861 11.4053 13.825C10.4867 14.6639 9.39228 15.0834 8.12194 15.0834C6.85172 15.0834 5.76105 14.6639 4.84994 13.825C3.93883 12.9861 3.48328 11.9389 3.48328 10.6834V4.08336C3.48328 3.17869 3.81383 2.42197 4.47494 1.81319C5.13605 1.20441 5.92083 0.900024 6.82928 0.900024C7.73783 0.900024 8.52117 1.20441 9.17928 1.81319C9.8375 2.42197 10.1666 3.17869 10.1666 4.08336V10.35C10.1666 10.8935 9.96383 11.3543 9.55828 11.7325C9.15272 12.1109 8.673 12.3 8.11911 12.3C7.56533 12.3 7.09033 12.1127 6.69411 11.738C6.298 11.3634 6.09994 10.9007 6.09994 10.35V4.18336H7.54994V10.35C7.54994 10.4945 7.60711 10.6139 7.72144 10.7084C7.83578 10.8028 7.97267 10.85 8.13211 10.85C8.29155 10.85 8.42883 10.8036 8.54394 10.7109C8.65905 10.6181 8.71661 10.4978 8.71661 10.35V4.10002C8.72772 3.59714 8.54439 3.17975 8.16661 2.84786C7.78883 2.51597 7.34322 2.35002 6.82978 2.35002C6.31633 2.35002 5.87189 2.51352 5.49644 2.84052C5.121 3.16752 4.93328 3.5818 4.93328 4.08336V10.6834C4.94439 11.5417 5.26367 12.2507 5.89111 12.8105C6.51855 13.3702 7.2715 13.65 8.14994 13.65C9.01294 13.65 9.762 13.3695 10.3971 12.8084C11.0323 12.2472 11.3444 11.5389 11.3333 10.6834V3.70002H12.7833V10.679Z",fill:"white"})),Se=e=>l.createElement("svg",{width:41,height:12,viewBox:"0 0 41 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("g",{clipPath:"url(#clip0_100_2379)"},l.createElement("path",{d:"M21.1825 7.56627H22.1696V5.46029C21.9697 5.38454 21.6628 5.35825 21.4373 5.35825C20.6381 5.35825 19.9407 5.89477 19.9261 6.85195H19.8885L19.4834 5.40815H17.7463V11.7965H20.0681V8.80642C20.0681 8.10324 20.2821 7.56672 21.1825 7.56672V7.56627Z",fill:"#172128"}),l.createElement("path",{d:"M2.31875 8.00074C2.31875 7.40005 2.55889 7.11976 3.04271 7.11976C3.48584 7.11976 3.69989 7.3996 3.69989 8.00074V11.7956H6.0217V8.00074C6.0217 7.40005 6.26184 7.11976 6.74256 7.11976C7.18835 7.11976 7.4024 7.3996 7.4024 8.00074V11.7956H9.72111V7.32385C9.72111 6.14831 9.12761 5.21786 7.68013 5.21786C6.74212 5.21786 6.14862 5.53603 5.78111 6.25036H5.75502C5.4627 5.62605 4.8661 5.21786 3.98028 5.21786C3.04227 5.21786 2.45761 5.53603 2.10426 6.25036H2.07817L1.80043 5.40725H3.8147e-05V11.7956H2.31875V8.00074Z",fill:"#172128"}),l.createElement("path",{d:"M10.1851 8.7301C10.1851 10.8129 11.8701 12 13.7227 12C15.5753 12 17.2837 10.8129 17.2837 8.7301V8.47342C17.2837 6.37903 15.5726 5.20349 13.7227 5.20349C11.8728 5.20349 10.1851 6.38215 10.1851 8.47342V8.7301ZM13.7346 7.02071C14.5975 7.02071 14.9765 7.70919 14.9765 8.59017C14.9765 9.47116 14.597 10.1743 13.7346 10.1743C12.8722 10.1743 12.4928 9.47116 12.4928 8.59017C12.4928 7.70919 12.8749 7.02071 13.7346 7.02071Z",fill:"#172128"}),l.createElement("path",{d:"M25.7969 5.20346C23.9324 5.20346 22.3867 6.43158 22.3867 8.47339V8.73007C22.3867 10.8623 24.0602 12 25.8982 12C27.3545 12 28.7874 11.2589 29.0797 9.70151H26.975C26.8101 10.1333 26.3669 10.2764 25.9618 10.2764C25.2264 10.2764 24.7837 9.76301 24.7315 9.08611H29.0912C29.1173 8.87044 29.1173 8.60173 29.1173 8.38293C29.1173 6.08444 27.3686 5.20346 25.7969 5.20346ZM24.7576 7.75862C24.8067 7.19848 25.137 6.71143 25.846 6.71143H25.8491C26.4948 6.71143 26.8623 7.19581 26.8623 7.75862H24.7576Z",fill:"#172128"}),l.createElement("path",{d:"M34.376 3.1975C33.6653 3.44883 32.9979 3.86058 32.4292 4.43319C31.8605 5.00581 31.4523 5.67824 31.2028 6.39435C30.9538 5.67824 30.5448 5.00581 29.9765 4.43275C29.4082 3.86013 28.7408 3.44838 28.0301 3.19705C28.7408 2.94572 29.4082 2.53398 29.9769 1.96136C30.5452 1.38874 30.9538 0.716307 31.2033 -0.000244141C31.4527 0.716307 31.8613 1.3883 32.4301 1.96136C32.9984 2.53398 33.6657 2.94572 34.3764 3.19705L34.376 3.1975Z",fill:"url(#paint0_linear_100_2379)"}),l.createElement("path",{d:"M35.4872 12.0001C34.8667 12.0001 34.2696 11.7715 33.9119 11.3869C33.5895 11.0621 33.4108 10.6655 33.4108 10.1722V10.1C33.4108 8.82507 34.4611 8.12769 35.9051 8.12769C36.4061 8.12769 36.9077 8.17581 37.3729 8.34426V7.94721C37.3729 6.92497 37.0027 6.27571 35.8812 6.27571C35.1413 6.27571 34.4492 6.5404 34.4134 7.38217H33.6854V7.30998C33.8287 6.0471 34.7835 5.61441 35.8578 5.61441C37.1708 5.61441 38.0898 6.17945 38.0898 7.93563V11.808H37.5768C37.4932 11.5915 37.4335 11.3508 37.3499 11.1347H37.326C36.932 11.6516 36.1682 12.0005 35.488 12.0005L35.4872 12.0001ZM37.3729 9.54697V9.01803C36.8718 8.84958 36.3823 8.76536 35.8812 8.76536C35.01 8.76536 34.1507 9.13834 34.1507 10.0643C34.1507 10.9061 34.7831 11.3152 35.6066 11.3152C36.43 11.3152 37.3729 10.5937 37.3729 9.54742V9.54697Z",fill:"#172128"}),l.createElement("path",{d:"M40.9998 3.77446C40.9998 4.09931 40.7371 4.3395 40.4152 4.3395C40.0932 4.3395 39.8305 4.09887 39.8305 3.77446V3.7504C39.8305 3.40148 40.0932 3.19739 40.4152 3.19739C40.7371 3.19739 40.9998 3.40193 40.9998 3.7504V3.77446ZM40.0569 11.8076V5.79444H40.7729V11.8076H40.0569Z",fill:"#172128"})),l.createElement("defs",null,l.createElement("linearGradient",{id:"paint0_linear_100_2379",x1:31.3237,y1:301678e-10,x2:34.1742,y2:2.06507,gradientUnits:"userSpaceOnUse"},l.createElement("stop",{stopColor:"#FA4B16"}),l.createElement("stop",{offset:1,stopColor:"#8E64EF"})),l.createElement("clipPath",{id:"clip0_100_2379"},l.createElement("rect",{width:41,height:12,fill:"white"})))),Ne=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M14.4241 8.00167C12.9851 8.50672 11.6338 9.33413 10.4822 10.4848C9.33067 11.6355 8.50415 12.9868 7.9991 14.4258C7.49495 12.9868 6.66664 11.6355 5.51596 10.4839C4.36528 9.33324 3.01402 8.50582 1.575 8.00078C3.01402 7.49573 4.36528 6.66832 5.51686 5.51764C6.66754 4.36696 7.49495 3.01569 8 1.57578C8.50504 3.01569 9.33246 4.36606 10.484 5.51764C11.6347 6.66832 12.986 7.49573 14.425 8.00078L14.4241 8.00167Z",fill:"url(#paint0_linear_100_2352)"}),l.createElement("defs",null,l.createElement("linearGradient",{id:"paint0_linear_100_2352",x1:8.24377,y1:1.57633,x2:13.9855,y2:5.76743,gradientUnits:"userSpaceOnUse"},l.createElement("stop",{stopColor:"#FA4B16"}),l.createElement("stop",{offset:1,stopColor:"#8E64EF"}))));function Te({children:e,side:s="top",align:r="end"}){const{setIsChatScreen:a,isChatScreen:c}=$(),h=()=>{c||a(!0)};return t.jsxs(R.Root,{children:[t.jsx(R.Trigger,{asChild:!0,className:"data-[state=open]:mhb-outline data-[state=open]:mhb-outline-neutral-110",children:t.jsx("button",{type:"button",className:"mhb-h-12 mhb-w-12 mhb-rounded-[16px] mhb-bg-neutral-10 mhb-flex mhb-items-center mhb-justify-center",onClick:h,children:t.jsx(ke,{className:"mhb-h-5 mhb-w-5"})})}),t.jsx(R.Portal,{children:t.jsx(R.Content,{side:s,align:r,sideOffset:12,className:`mhb-popover
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),V=require("more-sso-sdk"),fe=require("@radix-ui/react-popover");function me(e){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(s,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return s.default=e,Object.freeze(s)}const l=me(i),$=me(fe);let de=null;function ge(e){de=e}function xe(e){de?.(e)}const ue=i.createContext(void 0),ye=({children:e,appName:s,apiKey:r,token:a})=>{const[c,h]=i.useState(!!a),[p,b]=i.useState(a),[m,o]=i.useState(!0),[w,_]=i.useState(null);return i.useEffect(()=>{ge(b)},[]),t.jsx(ue.Provider,{value:{appName:s,apiKey:r,accessToken:p,authorized:c,setAuthorized:h,isChatScreen:m,setIsChatScreen:o,profileInfo:w,setProfileInfo:_},children:e})},R=()=>{const e=i.useContext(ue);if(!e)throw new Error("useSdkContext must be used inside SDKProvider");return e},Ce=e=>l.createElement("svg",{width:36,height:36,viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M15.8261 8.67349C12.4046 8.67349 9.63062 11.447 9.63062 14.8685C9.63062 18.29 12.4046 21.064 15.8261 21.064C16.1656 21.064 16.4991 21.0365 16.8241 20.984C15.0221 20.4765 13.7006 18.8205 13.7006 16.856C13.7006 14.4875 15.6206 12.568 17.9886 12.568C19.8251 12.568 21.3921 13.722 22.0031 15.345C22.0151 15.188 22.0211 15.029 22.0211 14.8685C22.0211 11.447 19.2476 8.67349 15.8261 8.67349Z",fill:"#B72402"}),l.createElement("path",{d:"M17.9984 7.621C13.0309 7.621 9.00342 11.6485 9.00342 16.616C9.00342 20.526 11.4949 23.8495 14.9744 25.0915V27.785C14.9744 28.228 15.4404 28.515 15.8349 28.3125C17.5759 27.4215 21.5219 25.332 23.5549 23.696C23.6114 23.65 23.6674 23.6065 23.7214 23.5605C23.7624 23.527 23.8009 23.494 23.8394 23.4605C25.7724 21.8115 26.9964 19.356 26.9964 16.616C26.9964 11.6485 22.9689 7.621 17.9989 7.621H17.9984ZM15.8274 21.064C15.5379 21.064 15.2539 21.0435 14.9749 21.005C11.9559 20.59 9.63092 18.0015 9.63092 14.8675C9.63092 11.4465 12.4039 8.6735 15.8274 8.6735C19.2509 8.6735 22.0214 11.4465 22.0214 14.8675C22.0214 15.0265 22.0164 15.185 22.0034 15.341C21.8319 17.6225 20.4259 19.5555 18.4544 20.48C17.9424 20.7205 17.3919 20.892 16.8154 20.9845C16.4929 21.036 16.1624 21.064 15.8269 21.064H15.8274Z",fill:"#FA4B16"})),we=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M14.4167 3.58334L14.4167 5.13334L5.58341 5.13333L5.58341 3.58333L14.4167 3.58334ZM2.66675 4.5L6.06675 8.01667L2.68341 11.5167L1.56675 10.4L3.86675 8.01667L1.55008 5.61667L2.66675 4.5ZM14.4167 7.25L14.4167 8.81667L7.48341 8.81667L7.48341 7.25L14.4167 7.25ZM14.4167 10.8667L14.4167 12.4333L5.58341 12.4333L5.58341 10.8667L14.4167 10.8667Z",fill:"#172128"})),_e=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M13.25 14.45L8.7667 9.98335C8.44448 10.238 8.06414 10.4378 7.6257 10.5827C7.18725 10.7276 6.71203 10.8 6.20003 10.8C4.92048 10.8 3.8367 10.3556 2.9487 9.46668C2.0607 8.57779 1.6167 7.50557 1.6167 6.25001C1.6167 4.99446 2.06114 3.92223 2.95003 3.03335C3.83892 2.14446 4.91392 1.70001 6.17503 1.70001C7.43614 1.70001 8.50837 2.14446 9.3917 3.03335C10.275 3.92223 10.7167 4.99529 10.7167 6.25251C10.7167 6.75085 10.6473 7.2139 10.5084 7.64168C10.3695 8.06946 10.1611 8.47223 9.88337 8.85001L14.3834 13.3167L13.25 14.45ZM6.1892 9.23335C7.02142 9.23335 7.72298 8.94307 8.29387 8.36251C8.86464 7.78196 9.15003 7.07779 9.15003 6.25001C9.15003 5.42223 8.86381 4.71807 8.29137 4.13751C7.71892 3.55696 7.0182 3.26668 6.1892 3.26668C5.35109 3.26668 4.64059 3.55696 4.0577 4.13751C3.47481 4.71807 3.18337 5.42223 3.18337 6.25001C3.18337 7.07779 3.47398 7.78196 4.0552 8.36251C4.63642 8.94307 5.34775 9.23335 6.1892 9.23335Z",fill:"#172128"})),ke=e=>l.createElement("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M10.0417 19.3958V17.7292H16.0625V16.6042H12.7292V9.70833H16.0625V8.77083C16.0625 7.10417 15.4757 5.67014 14.3021 4.46875C13.1285 3.26736 11.7049 2.66667 10.0312 2.66667C8.38542 2.66667 6.95833 3.26736 5.75 4.46875C4.54167 5.67014 3.9375 7.10417 3.9375 8.77083V9.70833H7.27083V16.6042H1.97917V8.775C1.97917 7.66722 2.19229 6.62306 2.61854 5.6425C3.04479 4.66195 3.62132 3.80319 4.34812 3.06625C5.07493 2.32931 5.92903 1.74861 6.91042 1.32417C7.89167 0.899722 8.93667 0.6875 10.0454 0.6875C11.154 0.6875 12.1944 0.899306 13.1667 1.32292C14.1389 1.74653 14.9868 2.32424 15.7104 3.05604C16.4342 3.78785 17.0036 4.64278 17.4187 5.62083C17.834 6.59889 18.0417 7.64889 18.0417 8.77083V19.3958H10.0417ZM3.9375 14.625H5.3125V11.6875H3.9375V14.625ZM14.7083 14.625H16.0625V11.6875H14.7083V14.625Z",fill:"#172128"})),ve=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M1.58334 12.6167V11.0333H14.4333V12.6167H1.58334ZM1.58334 8.78333V7.21666H14.4333V8.78333H1.58334ZM1.58334 4.96666V3.38333H14.4333V4.96666H1.58334Z",fill:"#172128"})),je=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M12.7833 10.679C12.7833 11.9375 12.3239 12.9861 11.4053 13.825C10.4867 14.6639 9.39228 15.0834 8.12194 15.0834C6.85172 15.0834 5.76105 14.6639 4.84994 13.825C3.93883 12.9861 3.48328 11.9389 3.48328 10.6834V4.08336C3.48328 3.17869 3.81383 2.42197 4.47494 1.81319C5.13605 1.20441 5.92083 0.900024 6.82928 0.900024C7.73783 0.900024 8.52117 1.20441 9.17928 1.81319C9.8375 2.42197 10.1666 3.17869 10.1666 4.08336V10.35C10.1666 10.8935 9.96383 11.3543 9.55828 11.7325C9.15272 12.1109 8.673 12.3 8.11911 12.3C7.56533 12.3 7.09033 12.1127 6.69411 11.738C6.298 11.3634 6.09994 10.9007 6.09994 10.35V4.18336H7.54994V10.35C7.54994 10.4945 7.60711 10.6139 7.72144 10.7084C7.83578 10.8028 7.97267 10.85 8.13211 10.85C8.29155 10.85 8.42883 10.8036 8.54394 10.7109C8.65905 10.6181 8.71661 10.4978 8.71661 10.35V4.10002C8.72772 3.59714 8.54439 3.17975 8.16661 2.84786C7.78883 2.51597 7.34322 2.35002 6.82978 2.35002C6.31633 2.35002 5.87189 2.51352 5.49644 2.84052C5.121 3.16752 4.93328 3.5818 4.93328 4.08336V10.6834C4.94439 11.5417 5.26367 12.2507 5.89111 12.8105C6.51855 13.3702 7.2715 13.65 8.14994 13.65C9.01294 13.65 9.762 13.3695 10.3971 12.8084C11.0323 12.2472 11.3444 11.5389 11.3333 10.6834V3.70002H12.7833V10.679Z",fill:"white"})),Se=e=>l.createElement("svg",{width:41,height:12,viewBox:"0 0 41 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("g",{clipPath:"url(#clip0_100_2379)"},l.createElement("path",{d:"M21.1825 7.56627H22.1696V5.46029C21.9697 5.38454 21.6628 5.35825 21.4373 5.35825C20.6381 5.35825 19.9407 5.89477 19.9261 6.85195H19.8885L19.4834 5.40815H17.7463V11.7965H20.0681V8.80642C20.0681 8.10324 20.2821 7.56672 21.1825 7.56672V7.56627Z",fill:"#172128"}),l.createElement("path",{d:"M2.31875 8.00074C2.31875 7.40005 2.55889 7.11976 3.04271 7.11976C3.48584 7.11976 3.69989 7.3996 3.69989 8.00074V11.7956H6.0217V8.00074C6.0217 7.40005 6.26184 7.11976 6.74256 7.11976C7.18835 7.11976 7.4024 7.3996 7.4024 8.00074V11.7956H9.72111V7.32385C9.72111 6.14831 9.12761 5.21786 7.68013 5.21786C6.74212 5.21786 6.14862 5.53603 5.78111 6.25036H5.75502C5.4627 5.62605 4.8661 5.21786 3.98028 5.21786C3.04227 5.21786 2.45761 5.53603 2.10426 6.25036H2.07817L1.80043 5.40725H3.8147e-05V11.7956H2.31875V8.00074Z",fill:"#172128"}),l.createElement("path",{d:"M10.1851 8.7301C10.1851 10.8129 11.8701 12 13.7227 12C15.5753 12 17.2837 10.8129 17.2837 8.7301V8.47342C17.2837 6.37903 15.5726 5.20349 13.7227 5.20349C11.8728 5.20349 10.1851 6.38215 10.1851 8.47342V8.7301ZM13.7346 7.02071C14.5975 7.02071 14.9765 7.70919 14.9765 8.59017C14.9765 9.47116 14.597 10.1743 13.7346 10.1743C12.8722 10.1743 12.4928 9.47116 12.4928 8.59017C12.4928 7.70919 12.8749 7.02071 13.7346 7.02071Z",fill:"#172128"}),l.createElement("path",{d:"M25.7969 5.20346C23.9324 5.20346 22.3867 6.43158 22.3867 8.47339V8.73007C22.3867 10.8623 24.0602 12 25.8982 12C27.3545 12 28.7874 11.2589 29.0797 9.70151H26.975C26.8101 10.1333 26.3669 10.2764 25.9618 10.2764C25.2264 10.2764 24.7837 9.76301 24.7315 9.08611H29.0912C29.1173 8.87044 29.1173 8.60173 29.1173 8.38293C29.1173 6.08444 27.3686 5.20346 25.7969 5.20346ZM24.7576 7.75862C24.8067 7.19848 25.137 6.71143 25.846 6.71143H25.8491C26.4948 6.71143 26.8623 7.19581 26.8623 7.75862H24.7576Z",fill:"#172128"}),l.createElement("path",{d:"M34.376 3.1975C33.6653 3.44883 32.9979 3.86058 32.4292 4.43319C31.8605 5.00581 31.4523 5.67824 31.2028 6.39435C30.9538 5.67824 30.5448 5.00581 29.9765 4.43275C29.4082 3.86013 28.7408 3.44838 28.0301 3.19705C28.7408 2.94572 29.4082 2.53398 29.9769 1.96136C30.5452 1.38874 30.9538 0.716307 31.2033 -0.000244141C31.4527 0.716307 31.8613 1.3883 32.4301 1.96136C32.9984 2.53398 33.6657 2.94572 34.3764 3.19705L34.376 3.1975Z",fill:"url(#paint0_linear_100_2379)"}),l.createElement("path",{d:"M35.4872 12.0001C34.8667 12.0001 34.2696 11.7715 33.9119 11.3869C33.5895 11.0621 33.4108 10.6655 33.4108 10.1722V10.1C33.4108 8.82507 34.4611 8.12769 35.9051 8.12769C36.4061 8.12769 36.9077 8.17581 37.3729 8.34426V7.94721C37.3729 6.92497 37.0027 6.27571 35.8812 6.27571C35.1413 6.27571 34.4492 6.5404 34.4134 7.38217H33.6854V7.30998C33.8287 6.0471 34.7835 5.61441 35.8578 5.61441C37.1708 5.61441 38.0898 6.17945 38.0898 7.93563V11.808H37.5768C37.4932 11.5915 37.4335 11.3508 37.3499 11.1347H37.326C36.932 11.6516 36.1682 12.0005 35.488 12.0005L35.4872 12.0001ZM37.3729 9.54697V9.01803C36.8718 8.84958 36.3823 8.76536 35.8812 8.76536C35.01 8.76536 34.1507 9.13834 34.1507 10.0643C34.1507 10.9061 34.7831 11.3152 35.6066 11.3152C36.43 11.3152 37.3729 10.5937 37.3729 9.54742V9.54697Z",fill:"#172128"}),l.createElement("path",{d:"M40.9998 3.77446C40.9998 4.09931 40.7371 4.3395 40.4152 4.3395C40.0932 4.3395 39.8305 4.09887 39.8305 3.77446V3.7504C39.8305 3.40148 40.0932 3.19739 40.4152 3.19739C40.7371 3.19739 40.9998 3.40193 40.9998 3.7504V3.77446ZM40.0569 11.8076V5.79444H40.7729V11.8076H40.0569Z",fill:"#172128"})),l.createElement("defs",null,l.createElement("linearGradient",{id:"paint0_linear_100_2379",x1:31.3237,y1:301678e-10,x2:34.1742,y2:2.06507,gradientUnits:"userSpaceOnUse"},l.createElement("stop",{stopColor:"#FA4B16"}),l.createElement("stop",{offset:1,stopColor:"#8E64EF"})),l.createElement("clipPath",{id:"clip0_100_2379"},l.createElement("rect",{width:41,height:12,fill:"white"})))),Ne=e=>l.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"M14.4241 8.00167C12.9851 8.50672 11.6338 9.33413 10.4822 10.4848C9.33067 11.6355 8.50415 12.9868 7.9991 14.4258C7.49495 12.9868 6.66664 11.6355 5.51596 10.4839C4.36528 9.33324 3.01402 8.50582 1.575 8.00078C3.01402 7.49573 4.36528 6.66832 5.51686 5.51764C6.66754 4.36696 7.49495 3.01569 8 1.57578C8.50504 3.01569 9.33246 4.36606 10.484 5.51764C11.6347 6.66832 12.986 7.49573 14.425 8.00078L14.4241 8.00167Z",fill:"url(#paint0_linear_100_2352)"}),l.createElement("defs",null,l.createElement("linearGradient",{id:"paint0_linear_100_2352",x1:8.24377,y1:1.57633,x2:13.9855,y2:5.76743,gradientUnits:"userSpaceOnUse"},l.createElement("stop",{stopColor:"#FA4B16"}),l.createElement("stop",{offset:1,stopColor:"#8E64EF"}))));function Te({children:e,side:s="top",align:r="end"}){const{setIsChatScreen:a,isChatScreen:c}=R(),h=()=>{c||a(!0)};return t.jsxs($.Root,{children:[t.jsx($.Trigger,{asChild:!0,className:"data-[state=open]:mhb-outline data-[state=open]:mhb-outline-neutral-110",children:t.jsx("button",{type:"button",className:"mhb-h-12 mhb-w-12 mhb-rounded-[16px] mhb-bg-neutral-10 mhb-flex mhb-items-center mhb-justify-center",onClick:h,children:t.jsx(ke,{className:"mhb-h-5 mhb-w-5"})})}),t.jsx($.Portal,{children:t.jsx($.Content,{side:s,align:r,sideOffset:12,className:`mhb-popover
|
|
2
2
|
mhb-flex mhb-flex-col
|
|
3
3
|
mhb-h-[460px] mhb-max-h-[460px]
|
|
4
4
|
mhb-w-[323px]
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
mhb-overflow-visible
|
|
20
20
|
placeholder:mhb-text-neutral-40
|
|
21
21
|
focus:mhb-outline-none
|
|
22
|
-
`})]}),He=i.forwardRef((e,s)=>t.jsx(Ee,{...e,forwardedRef:s})),W=()=>t.jsx("div",{className:"mhb-flex mhb-items-center mhb-justify-center",children:t.jsx("svg",{className:"mhb-w-8 mhb-h-8 mhb-animate-spin mhb-text-neutral-110",viewBox:"0 0 50 50",children:t.jsx("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"100",strokeDashoffset:"60"})})});let S=null,z=0,Y=!1,Me=0;const M={};let O=!1,P="",be="",F="",Q=[],G=!1;function Le(){const s={host:new URL(P).hostname,"x-api-key":F},r={},a=btoa(JSON.stringify(s)),c=btoa(JSON.stringify(r)),h=`${be}?header=${a}&payload=${c}`;return new WebSocket(h,["graphql-ws"])}const pe=()=>{Y=!1,S=Le(),O=!1,S.onopen=()=>{z=0,S?.send(JSON.stringify({type:"connection_init"}))},S.onmessage=e=>{const s=JSON.parse(e.data);if(O)s.type==="error"||(s.type==="data"&&M[s.id]?M[s.id].callback(s.payload.data):s.type==="complete"&&M[s.id]&&delete M[s.id]);else if(s.type==="connection_ack"){O=!0;for(const r in M)S?.send(JSON.stringify(M[r].message))}},S.onclose=()=>{if(Y)return;const e=Math.min(1e3*Math.pow(2,z)+Math.random()*1e3,3e4);setTimeout(()=>{z++,pe()},e)},S.onerror=()=>{S?.close()}},ae=(e,s=null)=>{Q.forEach(({resolve:r,reject:a})=>{e?a(e):s&&r(s)}),Q=[]};function Ae(){return new Promise((e,s)=>{Q.push({resolve:e,reject:s})})}const Ie=e=>{P=e.apiURL,F=e.apiKey,be=e.apiURL.replace("https://","wss://").replace("appsync-api","appsync-realtime-api"),pe();const s=async(r,a={},c)=>{const
|
|
22
|
+
`})]}),He=i.forwardRef((e,s)=>t.jsx(Ee,{...e,forwardedRef:s})),W=()=>t.jsx("div",{className:"mhb-flex mhb-items-center mhb-justify-center",children:t.jsx("svg",{className:"mhb-w-8 mhb-h-8 mhb-animate-spin mhb-text-neutral-110",viewBox:"0 0 50 50",children:t.jsx("circle",{cx:"25",cy:"25",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeDasharray:"100",strokeDashoffset:"60"})})});let S=null,z=0,Y=!1,Me=0;const M={};let O=!1,P="",be="",F="",Q=[],G=!1;function Le(){const s={host:new URL(P).hostname,"x-api-key":F},r={},a=btoa(JSON.stringify(s)),c=btoa(JSON.stringify(r)),h=`${be}?header=${a}&payload=${c}`;return new WebSocket(h,["graphql-ws"])}const pe=()=>{Y=!1,S=Le(),O=!1,S.onopen=()=>{z=0,S?.send(JSON.stringify({type:"connection_init"}))},S.onmessage=e=>{const s=JSON.parse(e.data);if(O)s.type==="error"||(s.type==="data"&&M[s.id]?M[s.id].callback(s.payload.data):s.type==="complete"&&M[s.id]&&delete M[s.id]);else if(s.type==="connection_ack"){O=!0;for(const r in M)S?.send(JSON.stringify(M[r].message))}},S.onclose=()=>{if(Y)return;const e=Math.min(1e3*Math.pow(2,z)+Math.random()*1e3,3e4);setTimeout(()=>{z++,pe()},e)},S.onerror=()=>{S?.close()}},ae=(e,s=null)=>{Q.forEach(({resolve:r,reject:a})=>{e?a(e):s&&r(s)}),Q=[]};function Ae(){return new Promise((e,s)=>{Q.push({resolve:e,reject:s})})}const Ie=e=>{P=e.apiURL,F=e.apiKey,be=e.apiURL.replace("https://","wss://").replace("appsync-api","appsync-realtime-api"),pe();const s=async(r,a={},c)=>{const p=await(await fetch(P,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":F,...c?{Authorization:`Bearer ${c}`}:{}},body:JSON.stringify({query:r,variables:a})})).json(),b=Array.isArray(p.errors)?p.errors:[];console.log(b,"check errors");const m=b.some(o=>{const w=o.message?.toLowerCase()??"";return w.includes("unauthorized")||w.includes("jwt")||w.includes("expired")});if(console.log(m,"check shouldRefresh"),m){if(console.log(m,"inside shouldRefresh"),G){const o=await Ae();return s(r,a,o)}G=!0;try{let o=null;if(process.env.NODE_ENV==="development")o=await V.SSOAuthorization.getDevToken("432896");else{const w=window.location.href,_=encodeURIComponent(w);o=await V.SSOAuthorization.getToken(_),console.log(o,"refreshResult check")}if(!o?.token)throw new Error("Refresh did not return an access token");return xe(o.token),ae(null,o.token),s(r,a,o.token)}catch(o){throw console.log(o,"check updating refresh"),ae(o,null),o}finally{G=!1}}if(b.length>0)throw new Error(b.map(o=>o.message).join(", "));return p.data};return{executeGraphql:s,subscribe:(r,a={},c)=>{if(!r.trim().startsWith("subscription"))return()=>{};const h=`${++Me}`,p={id:h,type:"start",payload:{data:JSON.stringify({query:r,variables:a}),extensions:{authorization:{host:new URL(P).hostname,"x-api-key":F}}}};return M[h]={message:p,callback:c},O&&S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify(p)),()=>{S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify({id:h,type:"stop"})),delete M[h]}},close:()=>{Y=!0,S?.close()}}};let L;const Ve=e=>{L||(L=Ie(e))},U=async(e,s={},r)=>{if(!L)throw new Error("client is not created");return L.executeGraphql(e,s,r)},K=async(e,s={},r)=>{if(!L)throw new Error("client is not created");return L.executeGraphql(e,s,r)},De=(e,s={},r)=>{if(!L)throw new Error("client is not created");return L.subscribe(e,s,r)},ie=`query AssistHistory($limit: Int, $offset: Int , $ticket_id: Int) {
|
|
23
23
|
assistHistory(limit: $limit, offset: $offset, ticket_id: $ticket_id) {
|
|
24
24
|
message_id
|
|
25
25
|
text
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
chat_handover
|
|
68
68
|
is_new
|
|
69
69
|
}
|
|
70
|
-
}`,le=10
|
|
70
|
+
}`,le=10,Re=()=>{const[e,s]=i.useState([]),[r,a]=i.useState(!0),[c,h]=i.useState(null),[p,b]=i.useState(!1),[m,o]=i.useState(""),w=i.useRef(!0),{accessToken:_}=R(),k=()=>{U(oe,{limit:le,search_key:m},_).then(async g=>{s(g?.EmployeeAssistTickets??[])}).catch(g=>{h(g)}).finally(()=>{a(!1)})};return i.useEffect(()=>{if(w.current){w.current=!1,k();return}const g=setTimeout(()=>{k()},400);return()=>clearTimeout(g)},[m]),{ticketData:e,loading:r,error:c,getNextPageTicketData:g=>{_&&(p||(b(!0),U(oe,{limit:le,offset:g},_).then(async j=>{const{EmployeeAssistTickets:T}=j;s(E=>[...E,...T])}).catch(j=>{h(j)}).finally(()=>{b(!1)})))},isLoadingMore:p,setSearchText:o}};function q(e){return(e?new Date(e):new Date).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",timeZone:"Asia/Kolkata"})}function $e(e,s="Asia/Kolkata",r="en-GB"){const a=new Date(e);if(Number.isNaN(a.getTime()))return"";const c=new Intl.DateTimeFormat(r,{day:"2-digit",month:"short",year:"2-digit",timeZone:s}).formatToParts(a),h=c.find(o=>o.type==="day")?.value??"",p=c.find(o=>o.type==="month")?.value??"",b=c.find(o=>o.type==="year")?.value??"",m=new Intl.DateTimeFormat(r,{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:s}).format(a);return`${h} ${p} ‘${b}, ${m}`}const X=(e,s)=>{sessionStorage.setItem(e,JSON.stringify(s))},D=e=>{const s=sessionStorage.getItem(e);return s?JSON.parse(s):null},Oe=()=>{const e=i.useRef(null),s=i.useRef(null),r=i.useRef(null),{ticketData:a,loading:c,getNextPageTicketData:h,isLoadingMore:p,setSearchText:b}=Re(),{setIsChatScreen:m,profileInfo:o}=R();i.useLayoutEffect(()=>{e.current},[a.length]);const w=d=>{const g=d.currentTarget;if(r.current?.blur(),g.scrollHeight<=g.clientHeight)return;const j=g.scrollHeight-g.scrollTop-g.clientHeight,T=a.length;s.current!==T&&j<=20&&!c&&(s.current=T,h(T))},_=d=>{X("userAndTicket",{ticket_id:d,employee_id:o?.employee_id}),m(g=>!g)},k=d=>{d.preventDefault();const g=r.current?.value?.trim();b(g??null)};return t.jsxs("div",{className:"mhb-flex mhb-flex-col mhb-h-full mhb-min-h-0",children:[t.jsx("div",{className:"mhb-searchbarContainer mhb-flex mhb-flex-col mhb-border-b mhb-border-neutral-20",children:t.jsx(He,{ref:r,onChangeHandler:k})}),t.jsx("div",{ref:e,onScroll:w,className:"mhb-history-main-container mhb-no-scrollbar mhb-py-3 mhb-flex mhb-flex-col mhb-gap-1 mhb-overflow-y-auto mhb-flex-1 mhb-min-h-0",children:c?t.jsx(W,{}):t.jsxs(t.Fragment,{children:[a.map(d=>t.jsxs("button",{type:"button",className:"mhb-btn-reset mhb-history-container mhb-p-3 mhb-flex mhb-flex-col mhb-rounded-[12px] mhb-bg-neutral-10 mhb-gap-2 mhb-items-start",onClick:()=>_(d.ticket_id),children:[t.jsx("div",{className:"mhb-flex mhb-items-start",children:t.jsx("p",{className:"mhb-typography-para-thick-30 mhb-text-neutral-110 mhb-m-0 mhb-min-w-0 mhb-break-words mhb-whitespace-normal mhb-text-left",children:d.title})}),t.jsx("p",{className:"mhb-typography-para-30 mhb-text-neutral-60 mhb-m-0",children:$e(d.created_at)})]},d.ticket_id)),p&&t.jsx(W,{})]})})]})},Pe=({isChatScreen:e,setIsChatScreen:s})=>{const r=()=>{s(c=>!c)},a=()=>{sessionStorage.removeItem("userAndTicket"),s(c=>!c)};return t.jsxs("div",{className:"mhb-header mhb-border-b mhb-border-neutral-20 mhb-flex mhb-items-center mhb-justify-between",children:[t.jsx(Ce,{className:"h-[36px] w-[36px] fill-current"}),t.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[e?t.jsx("div",{className:"mhb-btn-reset mhb-p-3 mhb-invisible mhb-typography-para-thick-30",children:"new chat"}):t.jsx("button",{type:"button",onClick:a,className:"mhb-btn-reset mhb-p-3 mhb-bg-neutral-10 mhb-typography-para-thick-30 mhb-rounded-[9999px]",children:"new chat"}),t.jsx("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-flex mhb-items-center mhb-justify-center mhb-rounded-full mhb-bg-neutral-10",onClick:r,children:e?t.jsx(ve,{className:"mhb-h-[16px] mhb-w-[16px] fill-current"}):t.jsx(we,{className:"mhb-h-[16px] mhb-w-[16px]"})})]})]})},ce=`
|
|
71
71
|
mutation AssistChat(
|
|
72
72
|
$message: String!
|
|
73
73
|
$ticket_id: Int
|
|
@@ -124,7 +124,7 @@ mutation AssistChat(
|
|
|
124
124
|
user_type
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
}`,J=10,Ue=()=>{const[e,s]=i.useState([]),[r,a]=i.useState(!0),[c,h]=i.useState(null),[u,b]=i.useState(!1),[p,o]=i.useState(!1),[w,_]=i.useState(!0),{accessToken:k,profileInfo:m}=$(),g=D("userAndTicket")?.ticket_id,j=D("userAndTicket")?.employee_id,T=i.useMemo(()=>e.find(f=>f.ticket_id!=null)?.ticket_id??null,[e]);let E=g??T??null;return i.useEffect(()=>{if(!E||!m)return;if(j&&m?.employee_id!=j){sessionStorage.removeItem("userAndTicket");return}const f=De(Ze,{ticket_id:E},n=>{const d=n;d?.onAssistChat?.user?.user_type==="agent"&&s(x=>[...x,d.onAssistChat])});return()=>f()},[E,m]),i.useEffect(()=>{if(!k||!m)return;j&&m?.employee_id!==j&&(sessionStorage.removeItem("userAndTicket"),E=null);const f={...E&&{ticket_id:E},limit:J};U(ie,f,k).then(async n=>{s(n?.assistHistory??[])}).catch(n=>{h(n)}).finally(()=>{a(!1)})},[m]),{historyData:e,msgLoading:r,msgError:c,isSending:p,sendMessage:f=>{const n=e.find(y=>y.ticket_id!=null)?.ticket_id??null,d=e.find(y=>y.handover==!0)?.handover??!1,x={...n&&{ticket_id:n},message:f,handover:d,attachments:[],text:f,message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:m?.full_name,user_type:"employee"}};o(!0),s(y=>[...y,x]),K(ce,x,k).then(async y=>{const C=y;C.assistChat.user.user_type!=="employee"&&s(N=>[...N,C.assistChat]),!D("userAndTicket")&&C.assistChat?.ticket_id&&m&&X("userAndTicket",{ticket_id:C.assistChat?.ticket_id,employee_id:m.employee_id})}).catch(()=>s(y=>y.slice(0,-1))).finally(()=>o(!1))},getNextPageData:f=>{if(!k||u)return;const n=D("userAndTicket")?.ticket_id,d={...n&&{ticket_id:n},limit:J,offset:f};b(!0),U(ie,d,k).then(async x=>{const C=x?.assistHistory??[];s(N=>[...C,...N]),C.length<J&&_(!1)}).catch(x=>{h(x)}).finally(()=>{b(!1)})},isLoadingMore:u,upload:async f=>{o(!0);const n={files:f.files.map(d=>`${f.ticketId}/${d.name}`),signature_type:f.signature_type};try{const d=await K(Fe,n,k);for(const[v,A]of f.files.entries()){const I=d.GetPresignedLink[v]?.url;I&&await fetch(I,{method:"PUT",body:A,headers:{"Content-Type":A.type}})}const x=e.find(v=>v.handover)?.handover??!1,y=f.files.map(v=>({url:URL.createObjectURL(v),filename:v.name})),C={ticket_id:f.ticketId,handover:x,attachments:y,text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:m?.full_name,user_type:"employee"}};s(v=>[...v,C]);const N={ticket_id:f.ticketId,handover:x,attachments:f.files.map(v=>`${f.ticketId}/${v.name}`),message:"",text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:m?.full_name,user_type:"employee"}},H=await K(ce,N,k);H.assistChat.user.user_type!=="employee"&&s(v=>[...v,H.assistChat]),!D("userAndTicket")&&H.assistChat?.ticket_id&&m&&X("userAndTicket",{ticket_id:H.assistChat.ticket_id,employee_id:m.employee_id})}catch{s(x=>x.slice(0,-1))}finally{o(!1)}},hasMore:w}},Be=({toastMsg:e})=>t.jsxs("div",{id:"toast-simple",className:"mhb-border-red-60 mhb-fixed mhb-bottom-6 mhb-right-6 mhb-z-50 mhb-flex mhb-max-w-xs mhb-items-center mhb-space-x-4 mhb-divide-x mhb-divide-gray-200 mhb-rounded-lg mhb-border mhb-bg-white mhb-p-4 mhb-text-gray-700 mhb-shadow-lg dark:mhb-divide-gray-700 dark:mhb-border-gray-600 dark:mhb-bg-gray-800 dark:mhb-text-gray-300",role:"alert",children:[t.jsx("svg",{className:"mhb-text-red-60 mhb-h-3 mhb-w-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:t.jsx("path",{stroke:"currentColor",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),t.jsx("div",{className:"mhb-text-red-60 mhb-typography-label-thick-30 mhb-ps-4",children:e})]}),ze=i.memo(({url:e,msg:s,isFirstInGroup:r,fileType:a})=>{const[c,h]=i.useState(!1),u=async()=>{const b=s.attachments[0],o=await(await fetch(b.url)).blob(),w=URL.createObjectURL(o),_=document.createElement("a");_.href=w,_.download=b.filename||"download.pdf",_.click(),URL.revokeObjectURL(w)};return t.jsxs(t.Fragment,{children:[(a==="jpg"||a==="jpeg"||a==="png")&&t.jsx("div",{className:"mhb-flex",children:t.jsx("div",{className:`mhb-rounded-[16px] mhb-bg-white ${s?.user?.user_type==="customer"?"mhb-ml-auto":"mhb-mr-auto"} ${r?s?.user?.user_type==="customer"?"mhb-rounded-tr-[4px]":"mhb-rounded-tl-[4px]":""}`,children:t.jsx("div",{className:"mhb-overflow-x-auto mhb-rounded-[16px] mhb-bg-neutral-10 mhb-px-1 mhb-py-1",children:t.jsx("div",{className:"mhb-flex mhb-w-fit mhb-space-x-1",children:t.jsx("div",{className:"mhb-h-[44px] mhb-w-[44px] mhb-flex-shrink-0 mhb-rounded-[12px] mhb-bg-white",children:t.jsx("img",{src:e,alt:"Attachment",className:"mhb-h-[44px] mhb-w-[44px] mhb-rounded-[12px] mhb-object-cover",onClick:()=>h(!0)})})})})})}),a==="pdf"&&t.jsxs("button",{className:"mhb-flex mhb-w-full mhb-items-center mhb-justify-between mhb-gap-3 mhb-rounded-[20px] mhb-mhb-border mhb-border-neutral-10 mhb-bg-white p-3 focus:mhb-outline-none",onClick:()=>u(),children:[t.jsx("div",{className:"mhb-relative mhb-flex mhb-h-[36px] mhb-w-[36px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-bg-neutral-20",children:t.jsx("p",{className:"mhb-absolute mhb-text-white mhb-typography-para-40",children:"pdf"})}),t.jsx("p",{className:"mhb-max-w-[50px] mhb-overflow-hidden mhb-text-ellipsis mhb-whitespace-nowrap mhb-text-neutral-110 mhb-typography-para-thick-30",children:s.attachments[0].filename.split(/[/_]/).pop()})]})]})},(e,s)=>e.url===s.url&&e.isFirstInGroup===s.isFirstInGroup&&e.msg.user?.user_type===s.msg.user?.user_type&&e.fileType===s.fileType),he=["image/jpeg","image/jpg","image/png","application/pdf"],Ge=()=>{const[e,s]=i.useState(""),r=i.useRef(null),a=i.useRef(null),c=i.useRef(null),h=i.useRef(0),u=i.useRef(0),b=i.useRef(!1),{historyData:p,sendMessage:o,getNextPageData:w,isLoadingMore:_,isSending:k,upload:m,msgLoading:g,hasMore:j}=Ue();i.useLayoutEffect(()=>{const n=r.current;if(n)if(b.current){const d=h.current,x=u.current,C=n.scrollHeight-d;n.scrollTop=x+C,b.current=!1}else n.scrollTop=n.scrollHeight},[p?.length]);const T=()=>{const n=a.current?.value?.trim();j||(b.current=!1),n&&(o(n),a.current&&(a.current.value=""))},E=n=>{k||n.key==="Enter"&&(n.preventDefault(),T())},te=n=>{const d=n.currentTarget;if(d.scrollHeight>d.clientHeight&&d.scrollTop<=20&&!_){const y=p.length;h.current=d.scrollHeight,u.current=d.scrollTop,b.current=!0,w(y)}},se=n=>{const d=Array.from(n.target.files||[]),x=d.filter(N=>he.includes(N.type));if(d.filter(N=>!he.includes(N.type)).length>0){s("Only JPG, PNG, and PDF files are allowed. Other files like videos are not supported."),setTimeout(()=>s(null),3e3),n.target.value="";return}const C=p[p?.length-1]?.ticket_id;x.length>0&&C&&m({files:x,signature_type:"upload",ticketId:C})},ne=()=>{c.current?.click()},f=i.useMemo(()=>p?.some(n=>n.handover==!0),[p]);return console.log(p,"historyData"),t.jsxs("div",{className:"mhb-flex mhb-h-full mhb-flex-col mhb-overflow-hidden mhb-bg-white",children:[t.jsx(t.Fragment,{children:g?t.jsx("div",{className:"mhb-py-3",children:t.jsx(W,{})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:r,className:"mhb-flex-grow mhb-overflow-y-auto mhb-py-3 [&>*]:[mhb-overflow-anchor:none]",onScroll:te,children:t.jsx("div",{className:"mhb-flex mhb-min-h-full mhb-flex-col mhb-justify-end mhb-gap-1",children:p?.map((n,d)=>{const x="user"in n&&d===0||p[d-1]?.user?.user_type!==n?.user?.user_type,y=new Date(n.created_at??""),C=d>0?new Date(p[d-1].created_at??""):null,N=!C||y.getDate()!==C.getDate()||y.getMonth()!==C.getMonth()||y.getFullYear()!==C.getFullYear(),re=C&&y.getTime()-C.getTime()>120*1e3,H=n.hasOwnProperty("user")&&(x||N||re),v=n?.attachments?.some(A=>{const I=A.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase();return["jpg","jpeg","png"].includes(I||"")});return t.jsx("div",{className:`mhb-flex ${n.user.user_type==="bot"||n.user.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:t.jsxs("div",{className:"mhb-max-w-[75%",children:[H&&t.jsx("div",{className:`mhb-mb-1 mhb-flex mhb-items-center ${n.user.user_type==="bot"||n.user.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:n.user.user_type==="bot"?t.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[t.jsxs("div",{className:"mhb-flex mhb-items-center mhb-gap-1",children:[t.jsx(Ne,{}),t.jsx("div",{className:"mhb-mb-1",children:t.jsx(Se,{})})]}),t.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-[2px] mhb-items-center",children:[t.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),t.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:q(n.created_at)})]})]}):n.user.user_type==="employee"?t.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[t.jsxs("div",{className:"mhb-flex mhb-gap-1",children:[t.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:q(n.created_at)}),t.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60 mhb-flex mhb-self-center"})]}),t.jsx(V.Avatar,{name:n?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"})]}):n.user.user_type==="agent"?t.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[t.jsx(V.Avatar,{name:n?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"}),t.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-1 mhb-items-center",children:[t.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),t.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:q(n.created_at)})]})]}):null}),t.jsx("div",{className:"mhb-flex mhb-overflow-hidden mhb-min-w-0",children:Array.isArray(n?.attachments)&&n?.attachments?.length>0?t.jsx("div",{className:`mhb-p-1 mhb-rounded-[16px] ${n.user.user_type==="bot"||n.user.user_type==="agent"?`mhb-bg-orange-60 ${H?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"}`:`mhb-bg-neutral-10 ${H?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"}`} ${v?"mhb-overflow-x-auto mhb-flex":"mhb-flex mhb-flex-col mhb-gap-1"}`,children:n.attachments.map((A,I)=>t.jsx("div",{children:t.jsx(ze,{url:A.url,msg:n,isFirstInGroup:!1,fileType:A?.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase()||""})},I))}):t.jsx("p",{className:`mhb-whitespace-pre-line mhb-break-words mhb-rounded-[16px] mhb-p-3
|
|
127
|
+
}`,J=10,Ue=()=>{const[e,s]=i.useState([]),[r,a]=i.useState(!0),[c,h]=i.useState(null),[p,b]=i.useState(!1),[m,o]=i.useState(!1),[w,_]=i.useState(!0),{accessToken:k,profileInfo:d}=R(),g=D("userAndTicket")?.ticket_id,j=D("userAndTicket")?.employee_id,T=i.useMemo(()=>e.find(f=>f.ticket_id!=null)?.ticket_id??null,[e]);let E=g??T??null;return i.useEffect(()=>{if(!E||!d)return;if(j&&d?.employee_id!=j){sessionStorage.removeItem("userAndTicket");return}const f=De(Ze,{ticket_id:E},n=>{const u=n;u?.onAssistChat?.user?.user_type==="agent"&&s(x=>[...x,u.onAssistChat])});return()=>f()},[E,d]),i.useEffect(()=>{if(!k||!d)return;j&&d?.employee_id!==j&&(sessionStorage.removeItem("userAndTicket"),E=null);const f={...E&&{ticket_id:E},limit:J};U(ie,f,k).then(async n=>{s(n?.assistHistory??[])}).catch(n=>{h(n)}).finally(()=>{a(!1)})},[d]),{historyData:e,msgLoading:r,msgError:c,isSending:m,sendMessage:f=>{const n=e.find(y=>y.ticket_id!=null)?.ticket_id??null,u=e.find(y=>y.handover==!0)?.handover??!1,x={...n&&{ticket_id:n},message:f,handover:u,attachments:[],text:f,message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:d?.full_name,user_type:"employee"}};o(!0),s(y=>[...y,x]),K(ce,x,k).then(async y=>{const C=y;C.assistChat.user.user_type!=="employee"&&s(N=>[...N,C.assistChat]),!D("userAndTicket")&&C.assistChat?.ticket_id&&d&&X("userAndTicket",{ticket_id:C.assistChat?.ticket_id,employee_id:d.employee_id})}).catch(()=>s(y=>y.slice(0,-1))).finally(()=>o(!1))},getNextPageData:f=>{if(!k||p)return;const n=D("userAndTicket")?.ticket_id,u={...n&&{ticket_id:n},limit:J,offset:f};b(!0),U(ie,u,k).then(async x=>{const C=x?.assistHistory??[];s(N=>[...C,...N]),C.length<J&&_(!1)}).catch(x=>{h(x)}).finally(()=>{b(!1)})},isLoadingMore:p,upload:async f=>{o(!0);const n={files:f.files.map(u=>`${f.ticketId}/${u.name}`),signature_type:f.signature_type};try{const u=await K(Fe,n,k);for(const[v,A]of f.files.entries()){const I=u.GetPresignedLink[v]?.url;I&&await fetch(I,{method:"PUT",body:A,headers:{"Content-Type":A.type}})}const x=e.find(v=>v.handover)?.handover??!1,y=f.files.map(v=>({url:URL.createObjectURL(v),filename:v.name})),C={ticket_id:f.ticketId,handover:x,attachments:y,text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:d?.full_name,user_type:"employee"}};s(v=>[...v,C]);const N={ticket_id:f.ticketId,handover:x,attachments:f.files.map(v=>`${f.ticketId}/${v.name}`),message:"",text:"",message_id:Math.random(),created_at:new Date().toISOString(),user:{user_name:d?.full_name,user_type:"employee"}},H=await K(ce,N,k);H.assistChat.user.user_type!=="employee"&&s(v=>[...v,H.assistChat]),!D("userAndTicket")&&H.assistChat?.ticket_id&&d&&X("userAndTicket",{ticket_id:H.assistChat.ticket_id,employee_id:d.employee_id})}catch{s(x=>x.slice(0,-1))}finally{o(!1)}},hasMore:w}},Be=({toastMsg:e})=>t.jsxs("div",{id:"toast-simple",className:"mhb-border-red-60 mhb-fixed mhb-bottom-6 mhb-right-6 mhb-z-50 mhb-flex mhb-max-w-xs mhb-items-center mhb-space-x-4 mhb-divide-x mhb-divide-gray-200 mhb-rounded-lg mhb-border mhb-bg-white mhb-p-4 mhb-text-gray-700 mhb-shadow-lg dark:mhb-divide-gray-700 dark:mhb-border-gray-600 dark:mhb-bg-gray-800 dark:mhb-text-gray-300",role:"alert",children:[t.jsx("svg",{className:"mhb-text-red-60 mhb-h-3 mhb-w-3","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 14 14",children:t.jsx("path",{stroke:"currentColor",d:"m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"})}),t.jsx("div",{className:"mhb-text-red-60 mhb-typography-label-thick-30 mhb-ps-4",children:e})]}),ze=i.memo(({url:e,msg:s,isFirstInGroup:r,fileType:a})=>{const[c,h]=i.useState(!1),p=async()=>{const b=s.attachments[0],o=await(await fetch(b.url)).blob(),w=URL.createObjectURL(o),_=document.createElement("a");_.href=w,_.download=b.filename||"download.pdf",_.click(),URL.revokeObjectURL(w)};return t.jsxs(t.Fragment,{children:[(a==="jpg"||a==="jpeg"||a==="png")&&t.jsx("div",{className:"mhb-flex",children:t.jsx("div",{className:`mhb-rounded-[16px] mhb-bg-white ${s?.user?.user_type==="customer"?"mhb-ml-auto":"mhb-mr-auto"} ${r?s?.user?.user_type==="customer"?"mhb-rounded-tr-[4px]":"mhb-rounded-tl-[4px]":""}`,children:t.jsx("div",{className:"mhb-overflow-x-auto mhb-rounded-[16px] mhb-bg-neutral-10 mhb-px-1 mhb-py-1",children:t.jsx("div",{className:"mhb-flex mhb-w-fit mhb-space-x-1",children:t.jsx("div",{className:"mhb-h-[44px] mhb-w-[44px] mhb-flex-shrink-0 mhb-rounded-[12px] mhb-bg-white",children:t.jsx("img",{src:e,alt:"Attachment",className:"mhb-h-[44px] mhb-w-[44px] mhb-rounded-[12px] mhb-object-cover",onClick:()=>h(!0)})})})})})}),a==="pdf"&&t.jsxs("button",{className:"mhb-flex mhb-w-full mhb-items-center mhb-justify-between mhb-gap-3 mhb-rounded-[20px] mhb-mhb-border mhb-border-neutral-10 mhb-bg-white p-3 focus:mhb-outline-none",onClick:()=>p(),children:[t.jsx("div",{className:"mhb-relative mhb-flex mhb-h-[36px] mhb-w-[36px] mhb-items-center mhb-justify-center mhb-rounded-[8px] mhb-bg-neutral-20",children:t.jsx("p",{className:"mhb-absolute mhb-text-white mhb-typography-para-40",children:"pdf"})}),t.jsx("p",{className:"mhb-max-w-[50px] mhb-overflow-hidden mhb-text-ellipsis mhb-whitespace-nowrap mhb-text-neutral-110 mhb-typography-para-thick-30",children:s.attachments[0].filename.split(/[/_]/).pop()})]})]})},(e,s)=>e.url===s.url&&e.isFirstInGroup===s.isFirstInGroup&&e.msg.user?.user_type===s.msg.user?.user_type&&e.fileType===s.fileType),he=["image/jpeg","image/jpg","image/png","application/pdf"],Ge=()=>{const[e,s]=i.useState(""),r=i.useRef(null),a=i.useRef(null),c=i.useRef(null),h=i.useRef(0),p=i.useRef(0),b=i.useRef(!1),{historyData:m,sendMessage:o,getNextPageData:w,isLoadingMore:_,isSending:k,upload:d,msgLoading:g,hasMore:j}=Ue();i.useLayoutEffect(()=>{const n=r.current;if(n)if(b.current){const u=h.current,x=p.current,C=n.scrollHeight-u;n.scrollTop=x+C,b.current=!1}else n.scrollTop=n.scrollHeight},[m?.length]);const T=()=>{const n=a.current?.value?.trim();j||(b.current=!1),n&&(o(n),a.current&&(a.current.value=""))},E=n=>{k||n.key==="Enter"&&(n.preventDefault(),T())},te=n=>{const u=n.currentTarget;if(u.scrollHeight>u.clientHeight&&u.scrollTop<=20&&!_){const y=m.length;h.current=u.scrollHeight,p.current=u.scrollTop,b.current=!0,w(y)}},se=n=>{const u=Array.from(n.target.files||[]),x=u.filter(N=>he.includes(N.type));if(u.filter(N=>!he.includes(N.type)).length>0){s("Only JPG, PNG, and PDF files are allowed. Other files like videos are not supported."),setTimeout(()=>s(null),3e3),n.target.value="";return}const C=m[m?.length-1]?.ticket_id;x.length>0&&C&&d({files:x,signature_type:"upload",ticketId:C})},ne=()=>{c.current?.click()},f=i.useMemo(()=>m?.some(n=>n.handover==!0),[m]);return console.log(m,"historyData"),t.jsxs("div",{className:"mhb-flex mhb-h-full mhb-flex-col mhb-overflow-hidden mhb-bg-white",children:[t.jsx(t.Fragment,{children:g?t.jsx("div",{className:"mhb-py-3",children:t.jsx(W,{})}):t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:r,className:"mhb-flex-grow mhb-overflow-y-auto mhb-py-3 [&>*]:[mhb-overflow-anchor:none]",onScroll:te,children:t.jsx("div",{className:"mhb-flex mhb-min-h-full mhb-flex-col mhb-justify-end mhb-gap-1",children:m?.map((n,u)=>{const x="user"in n&&u===0||m[u-1]?.user?.user_type!==n?.user?.user_type,y=new Date(n.created_at??""),C=u>0?new Date(m[u-1].created_at??""):null,N=!C||y.getDate()!==C.getDate()||y.getMonth()!==C.getMonth()||y.getFullYear()!==C.getFullYear(),re=C&&y.getTime()-C.getTime()>120*1e3,H=n.hasOwnProperty("user")&&(x||N||re),v=n?.attachments?.some(A=>{const I=A.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase();return["jpg","jpeg","png"].includes(I||"")});return t.jsx("div",{className:`mhb-flex ${n.user.user_type==="bot"||n.user.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:t.jsxs("div",{className:"mhb-max-w-[75%",children:[H&&t.jsx("div",{className:`mhb-mb-1 mhb-flex mhb-items-center ${n.user.user_type==="bot"||n.user.user_type==="agent"?"mhb-justify-start":"mhb-justify-end"}`,children:n.user.user_type==="bot"?t.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[t.jsxs("div",{className:"mhb-flex mhb-items-center mhb-gap-1",children:[t.jsx(Ne,{}),t.jsx("div",{className:"mhb-mb-1",children:t.jsx(Se,{})})]}),t.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-[2px] mhb-items-center",children:[t.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),t.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:q(n.created_at)})]})]}):n.user.user_type==="employee"?t.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[t.jsxs("div",{className:"mhb-flex mhb-gap-1",children:[t.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:q(n.created_at)}),t.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60 mhb-flex mhb-self-center"})]}),t.jsx(V.Avatar,{name:n?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"})]}):n.user.user_type==="agent"?t.jsxs("div",{className:"mhb-flex mhb-gap-2 mhb-items-center",children:[t.jsx(V.Avatar,{name:n?.user?.user_name||"",employeeId:"",className:"mhb-size-4 mhb-shrink-0 mhb-rounded-full mhb-select-none"}),t.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-mt-1 mhb-items-center",children:[t.jsx("div",{className:"mhb-h-[2px] mhb-w-[2px] mhb-rounded-full mhb-bg-neutral-60"}),t.jsx("p",{className:"mhb-typography-para-40 mhb-text-neutral-60",children:q(n.created_at)})]})]}):null}),t.jsx("div",{className:"mhb-flex mhb-overflow-hidden mhb-min-w-0",children:Array.isArray(n?.attachments)&&n?.attachments?.length>0?t.jsx("div",{className:`mhb-p-1 mhb-rounded-[16px] ${n.user.user_type==="bot"||n.user.user_type==="agent"?`mhb-bg-orange-60 ${H?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"}`:`mhb-bg-neutral-10 ${H?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"}`} ${v?"mhb-overflow-x-auto mhb-flex":"mhb-flex mhb-flex-col mhb-gap-1"}`,children:n.attachments.map((A,I)=>t.jsx("div",{children:t.jsx(ze,{url:A.url,msg:n,isFirstInGroup:!1,fileType:A?.filename.match(/\.([a-zA-Z0-9]+)(?:\?|$)/)?.[1]?.toLowerCase()||""})},I))}):t.jsx("p",{className:`mhb-whitespace-pre-line mhb-break-words mhb-rounded-[16px] mhb-p-3
|
|
128
128
|
mhb-typography-para-30 ${n.user.user_type==="bot"||n.user.user_type==="agent"?`mhb-bg-orange-60 mhb-text-white ${H?"mhb-rounded-tl-[4px]":"mhb-rounded-[20px]"} `:`mhb-bg-neutral-10 mhb-text-neutral-110 mhb-ml-auto ${H?"mhb-rounded-tr-[4px]":"mhb-rounded-[20px]"} `}
|
|
129
|
-
`,children:n?.text})})]})},n.message_id)})})}),t.jsx("div",{className:"mhb-chat-input-container mhb-sticky mhb-bottom-0 mhb-bg-white mhb-py-3 mhb-flex mhb-items-center mhb-gap-2",children:t.jsxs("div",{className:"mhb-bg-neutral-10 mhb-flex mhb-h-[80px] mhb-flex-1 mhb-rounded-xl mhb-p-3",children:[t.jsx("div",{className:"mhb-flex mhb-flex-1",children:t.jsx("textarea",{ref:a,placeholder:"Type your message here...",className:"mhb-btn-reset mhb-textarea mhb-flex-grow mhb-text-neutral-70 mhb-caret-orange-70 mhb-typography-para-30 mhb-bg-transparent mhb-resize-none placeholder:mhb-text-neutral-40",onKeyDown:E})}),t.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-justify-end mhb-items-end",children:[f&&t.jsxs("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-rounded-full mhb-bg-neutral-100 mhb-flex mhb-items-center mhb-justify-center mhb-outline-none",disabled:k,onClick:ne,children:[t.jsx(je,{className:"h-[16px] w-[16px] mhb-fill-current"}),t.jsx("input",{type:"file",accept:".jpg,.jpeg,.png,.pdf",ref:c,onChange:se,className:"hidden"})]}),t.jsx("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-rounded-[9999px] mhb-bg-orange-60 mhb-flex mhb-p-3 mhb-items-center mhb-justify-center mhb-shadow-[0_4px_12px_0_rgba(250,75,22,0.50)] mhb-outline-none",disabled:k,onClick:T,children:t.jsx("p",{className:"mhb-typography-label-thick-30 mhb-text-white",children:"Send"})})]})]})})]})}),e&&t.jsx(Be,{toastMsg:e})]})};function Ke({side:e="top",align:s="end"}){const{authorized:r,isChatScreen:a,setIsChatScreen:c,accessToken:h,setProfileInfo:
|
|
129
|
+
`,children:n?.text})})]})},n.message_id)})})}),t.jsx("div",{className:"mhb-chat-input-container mhb-sticky mhb-bottom-0 mhb-bg-white mhb-py-3 mhb-flex mhb-items-center mhb-gap-2",children:t.jsxs("div",{className:"mhb-bg-neutral-10 mhb-flex mhb-h-[80px] mhb-flex-1 mhb-rounded-xl mhb-p-3",children:[t.jsx("div",{className:"mhb-flex mhb-flex-1",children:t.jsx("textarea",{ref:a,placeholder:"Type your message here...",className:"mhb-btn-reset mhb-textarea mhb-flex-grow mhb-text-neutral-70 mhb-caret-orange-70 mhb-typography-para-30 mhb-bg-transparent mhb-resize-none placeholder:mhb-text-neutral-40",onKeyDown:E})}),t.jsxs("div",{className:"mhb-flex mhb-gap-1 mhb-justify-end mhb-items-end",children:[f&&t.jsxs("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-w-[36px] mhb-rounded-full mhb-bg-neutral-100 mhb-flex mhb-items-center mhb-justify-center mhb-outline-none",disabled:k,onClick:ne,children:[t.jsx(je,{className:"h-[16px] w-[16px] mhb-fill-current"}),t.jsx("input",{type:"file",accept:".jpg,.jpeg,.png,.pdf",ref:c,onChange:se,className:"hidden"})]}),t.jsx("button",{type:"button",className:"mhb-btn-reset mhb-h-[36px] mhb-rounded-[9999px] mhb-bg-orange-60 mhb-flex mhb-p-3 mhb-items-center mhb-justify-center mhb-shadow-[0_4px_12px_0_rgba(250,75,22,0.50)] mhb-outline-none",disabled:k,onClick:T,children:t.jsx("p",{className:"mhb-typography-label-thick-30 mhb-text-white",children:"Send"})})]})]})})]})}),e&&t.jsx(Be,{toastMsg:e})]})};function Ke({side:e="top",align:s="end"}){const{authorized:r,isChatScreen:a,setIsChatScreen:c,accessToken:h,setProfileInfo:p}=R(),b=async()=>{const m=await V.SSOAuthorization.getProfileDetails();p(m)};return i.useEffect(()=>{h&&b()},[]),t.jsx("div",{className:"mhb-root",children:t.jsx(Te,{side:e,align:s,children:t.jsxs("div",{className:"mhb-h-full mhb-w-full mhb-flex mhb-flex-col mhb-min-h-0",children:[t.jsx(Pe,{isChatScreen:a,setIsChatScreen:c}),a?t.jsx(Ge,{}):t.jsx(Oe,{})]})})})}function qe(e){const{apiKey:s,accessToken:r}=e;if(!s||!r)throw new Error("Missing parameters: apiKey, and accessToken are required")}let ee=null,B=!1,Z=[];function Je(){for(const e of Z)e()}function We(e){B||(qe(e),V.SSOAuthorization.init({env:e.env,redirectUrl:e.redirectUrl,app:e.app,idp:e.idp}),ee=e,B=!0,Je(),Ve({apiKey:e.apiKey,apiURL:e.apiURL}))}function Ye(e){const[s,r]=i.useState({initialized:B,sdkOptions:ee});return i.useEffect(()=>{const a=()=>{r({initialized:B,sdkOptions:ee})};return Z.push(a),()=>{Z=Z.filter(c=>c!==a)}},[]),!s.initialized||!s.sdkOptions?null:t.jsx(ye,{appName:s.sdkOptions.app,apiKey:s.sdkOptions.apiKey,token:s.sdkOptions.accessToken,children:t.jsx(Ke,{...e})})}exports.ChatButton=Ye;exports.init=We;
|
|
130
130
|
//# sourceMappingURL=index.cjs.map
|