1"use strict";(self.webpackChunkmy_webpack_project=self.webpackChunkmy_webpack_project||[]).push([[2484],{66502(e,t,a){var n,r,i=a(39471);function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},l.apply(null,arguments)}a.d(t,["A",0,e=>i.createElement("svg",l({xmlns:"http://www.w3.org/2000/svg",width:32,height:36,fill:"none"},e),n||(n=i.createElement("g",{clipPath:"url(#Isolation_Mode_svg__a)"},i.createElement("g",{fill:"#34B5B1",clipPath:"url(#Isolation_Mode_svg__b)"},i.createElement("path",{d:"M4.897 18.583C3.194 18.32 1.86 17.48.917 15.986a5.8 5.8 0 0 1-.911-3.132C-.003 9.789 0 6.724.003 3.66c0-.78.471-1.31 1.14-1.306.67 0 1.113.52 1.113 1.321v9.274c0 1.756 1.218 3.274 2.777 3.462 1.73.206 3.214-.884 3.602-2.661.052-.246.075-.505.075-.755 0-3.064-.006-6.129 0-9.194 0-.563-.122-1.04-.654-1.278-.665-.292-1.397.21-1.423.983-.02.548-.006 1.096-.006 1.645v8.63c0 .643-.379 1.149-.914 1.25-.555.105-1.076-.194-1.27-.751a1.6 1.6 0 0 1-.072-.508q-.005-5.06 0-10.118c0-1.543.642-2.69 1.964-3.318 1.31-.628 2.531-.36 3.616.669.118.114.338.148.512.148 4.186.009 8.368.006 12.554.006h3.468C28.568 1.162 30 2.674 30 4.883v27.421c0 2.196-1.42 3.693-3.486 3.696H8.383c-2.077 0-3.48-1.488-3.48-3.693V18.583zm2.26-.222v13.853c0 .97.39 1.38 1.316 1.38h17.946c.946 0 1.328-.403 1.325-1.407q-.026-13.61-.055-27.224c0-1.001-.353-1.371-1.305-1.374H11.015v8.017h.512c4.122 0 8.245-.003 12.367.006.266 0 .558.053.795.176.454.234.665.82.544 1.334a1.16 1.16 0 0 1-1.146.914c-.815.013-1.634.004-2.45.004-3.468 0-6.936.003-10.405-.007-.283 0-.408.074-.491.388a6 6 0 0 1-.492 1.25c-.689 1.32-1.739 2.19-3.09 2.687z"}),i.createElement("path",{d:"M17.008 24h-6.844c-.581 0-1.054-.341-1.145-.803-.1-.515.193-.974.739-1.14.14-.044.298-.057.447-.057h13.54c.756 0 1.25.387 1.255.982.006.613-.49 1.018-1.259 1.018h-6.7330000000000005M17.499 19h-6.422c-.523 0-.92-.446-1.043-1.128-.116-.638.07-1.32.482-1.631.18-.135.402-.231.608-.231q6.37-.016 12.739-.008c.657 0 1.142.666 1.137 1.513-.003.854-.485 1.481-1.15 1.481-2.118.004-4.236 0-6.351 0z"})))),r||(r=i.createElement("defs",null,i.createElement("clipPath",{id:"Isolation_Mode_svg__a"},i.createElement("path",{fill:"#fff",d:"M0 0h32v36H0z"})),i.createElement("clipPath",{id:"Isolation_Mode_svg__b"},i.createElement("path",{fill:"#fff",d:"M0-.121h30v36H0z"})))))])},1834(e,t,a){a.d(t,{lw:()=>c,KR:()=>s});var n=a(39471);const r=e=>{if(!e)return!1;const t=e.custom||e.custom_data;return!0===(null==t?void 0:t.vision_enabled)},i=(e,t,a)=>{const n={message:e=>{if(r(e.message)){const t=(e=>{if(!r(e))return null;const t=e.custom||e.custom_data,a=e.file||e;return{image_id:null==t?void 0:t.image_id,image_url:(null==a?void 0:a.url)||(null==a?void 0:a.fileUrl),uploaded_by:null==t?void 0:t.uploaded_by,influencer_id:null==t?void 0:t.influencer_id,metadata:(null==t?void 0:t.metadata)||{}}})(e.message);t&&a&&a(t)}}};return e.addListener(n),e.subscribe({channels:[t]}),()=>{e.removeListener(n),e.unsubscribe({channels:[t]})}};function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,r,i,l,o=[],s=!0,c=!1;try{if(i=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;s=!1}else for(;!(s=(n=i.call(a)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){c=!0,r=e}finally{try{if(!s&&null!=a.return&&(l=a.return(),Object(l)!==l))return}finally{if(c)throw r}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}const s=function(e,t,a){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;
1const o=l((0,n.useState)([]),2),s=o[0],c=o[1],u=l((0,n.useState)(!1),2),d=u[0],m=u[1],g=l((0,n.useState)([]),2),v=g[0],f=g[1],h=(0,n.useCallback)(e=>{console.log("[VisionChat] Image uploaded:",e),console.log("[VisionChat] Image auto-published by backend as USER message:",e.image_id),console.log('[VisionChat] Bot prompt "You can ask me about this image!" also published'),console.log("[VisionChat] Backend will auto-retrieve this image when user asks visual questions")},[]),p=(0,n.useCallback)((n,r,i)=>{if(!e||e.readyState!==WebSocket.OPEN)return console.error("[VisionChat] WebSocket not connected"),void(i&&i({statusCode:500},{error:"WebSocket not connected"}));console.log("[VisionChat] Sending message:",n),console.log("[VisionChat] Backend will auto-detect visual questions and retrieve images"),e.send(JSON.stringify({type:"publish_user_message",message:n,channel:t,inf_id:a,contain_emoji:!0})),i&&i({statusCode:200},{success:!0})},[e,t,a]),b=(0,n.useCallback)(e=>{c(t=>t.filter(t=>t.id!==e))},[]),y=(0,n.useCallback)(()=>{c([])},[]),_=(0,n.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;if(r&&t)try{const a=await function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;return new Promise((n,r)=>{e.fetchMessages({channels:[t],count:a},(e,a)=>{if(e.error)return console.error("[PubNub] Error fetching images:",e),void r(e.error);try{var i;const e=((null==a||null===(i=a.channels)||void 0===i?void 0:i[t])||[]).filter(e=>{var t,a;const n=(null===(t=e.message)||void 0===t?void 0:t.custom)||(null===(a=e.message)||void 0===a?void 0:a.custom_data);return!0===(null==n?void 0:n.vision_enabled)}).map(e=>{var t,a,n;const r=(null===(t=e.message)||void 0===t?void 0:t.custom)||(null===(a=e.message)||void 0===a?void 0:a.custom_data),i=(null===(n=e.message)||void 0===n?void 0:n.file)||e.message;return{image_id:null==r?void 0:r.image_id,image_url:(null==i?void 0:i.url)||(null==i?void 0:i.fileUrl),uploaded_by:null==r?void 0:r.uploaded_by,influencer_id:null==r?void 0:r.influencer_id,timestamp:e.timetoken,metadata:(null==r?void 0:r.metadata)||{},uploaded_at:new Date(e.timetoken/1e4).toISOString()}}).filter(e=>e.image_url);console.log("[PubNub] Fetched ".concat(e.length," images from history")),n(e)}catch(e){console.error("[PubNub] Error parsing image messages:",e),r(e)}})})}(r,t,e);f(a),console.log("[VisionChat] Loaded ".concat(a.length," images from history"))}catch(e){console.error("[VisionChat] Failed to load image history:",e)}else console.warn("[VisionChat] PubNub or channelId not available for history")},[r,t]);return(0,n.useEffect)(()=>{if(!r||!t)return;const e=i(r,t,e=>{console.log("[VisionChat] New image received:",e),f(t=>[e,...t])});return _(),e},[r,t,_]),{uploadedImages:s,isUploadingImage:d,setIsUploadingImage:m,handleImageUploaded:h,sendMessageWithVision:p,removeImage:b,clearImages:y,hasImages:s.length>0,imageHistory:v,loadImageHistory:_,hasHistory:v.length>0}},c=e=>{let t=e.images,a=e.onRemove;return t&&0!==t.length?React.createElement("div",{className:"uploaded-images-preview"},React.createElement("div",{className:"preview-header"},React.createElement("span",{className:"preview-count"},t.length," image",t.length>1?"s":""," in conversation")),React.createElement("div",{className:"preview-images"},t.map(e=>React.createElement("div",{key:e.id,className:"preview-image-item"},React.createElement("img",{src:e.url,alt:"Uploaded",className:"preview-thumbnail"}),a&&React.createElement("button",{onClick:()=>a(e.id),className:"preview-remove-btn",title:"Remove image"},"Ã"))))):null}},68103(e,t,a){a.d(t,{A:()=>g});var n,r,i,l,o=a(39471),s=a(52470),c=a(51794);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},u.apply(null,arguments)}const d=e=>o.createElement("svg",u({xmlns:"http://www.w3.org/2000/svg",width:40,height:40,fill:"none"},e),n||(n=o.createElement("rect",{width:32,height:24,x:4,y:8,stroke:"#34B5B1",strokeWidth:2.5,rx:2})),r||(r=o.createElement("path",{fill:"#34B5B1",d:"m4 25 8-9 6 6 8-10 10 12v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z",opacity:.5})),i||(i=o.createElement("circle",{cx:29,cy:14,r:3.5,fill:"#34B5B1"})),l||(l=o.createElement("path",{stroke:"#34B5B1",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M30 4v9m0-9-4 4m4-4 4 4"})));function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}const g=e=>{let t=e.channelId,a=e.infId,n=e.onImageUploaded,r=e.onError,i=e.onSuccess,l=e.disabled,u=void 0!==l&&l;const g=(p=(0,o.useState)(!1),b=2,function(e){if(Array.isArray(e))return e}(p)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,r,i,l,o=[],s=!0,c=!1;try{if(i=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;s=!1}else for(;!(s=(n=i.call(a)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){c=!0,r=e}
1finally{try{if(!s&&null!=a.return&&(l=a.return(),Object(l)!==l))return}finally{if(c)throw r}}return o}}(p,b)||function(e,t){if(e){if("string"==typeof e)return m(e,t);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?m(e,t):void 0}}(p,b)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),v=g[0],f=g[1],h=(0,o.useRef)(null);var p,b;return o.createElement("div",{className:"image-upload-container"},o.createElement("input",{ref:h,type:"file",accept:"image/jpeg,image/jpg,image/png",onChange:async e=>{const l=e.target.files[0];if(!l)return;const o=(e=>{if(!e.type.startsWith("image/"))return"Please select an image file (JPEG or PNG)";if(!["image/jpeg","image/jpg","image/png"].includes(e.type))return"Only JPEG and PNG images are supported";if(e.size>10485760){const t=(e.size/1048576).toFixed(2);return"Image size (".concat(t,"MB) exceeds maximum (10MB)")}return null})(l);if(o)return r&&r(o),void(h.current&&(h.current.value=""));f(!0);try{const e=new FormData;
1e.append("image",l),e.append("channel_id",t),e.append("inf_id",a);const r=(await c.o0.post("/interface/vision/image-upload/",e)).data,o=r.image_id,s=r.image_url,u=r.metadata;if(console.log("[ImageUpload] Image uploaded successfully:",{image_id:o,size:u.size_bytes,dimensions:"".concat(u.width,"x").concat(u.height)}),i){const e=(u.size_bytes/1048576).toFixed(2);i("Image uploaded successfully (".concat(e,"MB)"))}n&&n({image_id:o,image_url:s,metadata:u}),h.current&&(h.current.value="")}catch(e){var s,u,d,m;console.error("[ImageUpload] Upload failed:",e);let t="Failed to upload image. Please try again.";null!==(s=e.response)&&void 0!==s&&null!==(s=s.data)&&void 0!==s&&s.message?t=e.response.data.message:null!==(u=e.response)&&void 0!==u&&null!==(u=u.data)&&void 0!==u&&u.error?t=e.response.data.error:401===(null===(d=e.response)||void 0===d?void 0:d.status)?t="Authentication failed. Please log in again.":413===(null===(m=e.response)||void 0===m?void 0:m.status)?t="Image is too large. Maximum size is 10MB.":navigator.onLine||(t="No internet connection. Please check your network."),r&&r(t),h.current&&(h.current.value="")}finally{f(!1)}},style:{display:"none"},disabled:u||v}),o.createElement("button",{onClick:()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.click()},disabled:u||v,className:"upload-btn",type:"button"},v?o.createElement(s.PSR,{className:"animate-spin",size:20}):o.createElement(d,null)))}},58752(e,t,a){a(39471),a(58252)}}]);
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.