"use strict";(self.webpackChunkflow_web_extension=self.webpackChunkflow_web_extension||[]).push([["66219"],{156543:function(e,r,o){o.r(r),o.d(r,{initDeepResearchStore:()=>w,useDeepResearchStore:()=>m});var t,a=o(698127),s=o(837222),i=o(531484),c=o(890310),n=o(230869),d=o(771197),l=o(706790),u=o(497176),v=o(434463),f=o(330459),p=o(41139),h=()=>({isConfigInitialed:!1,isConfigLoading:!1,fetchConfigFailed:!1,sendDisabled:!1,blockIdToProcess:{},isProcessDataLoading:!1,blockIdToProcessHasInitialized:{},breakModalDestroyers:{},blockIdToConvIdWithAsyncState:{}}),y=(e,r)=>{var o;return(0,c.Z)(h(),{fetchDeepResearchProcessData:(o=(0,d._)(function*(o){var t,{blockId:s,resourceId:i}=o;if(null===(t=r().blockIdToProcessHasInitialized)||void 0===t||!t[s])try{e((0,u.Uy)(e=>{e.isProcessDataLoading=!0}));var{data:c}=yield v.mH.GetDeepResearchResource({resource_id:i}),{blocks:n=[]}=null!=c?c:{},d=n.map(e=>{var r;return(0,l._)((0,a._)({},e),{content_obj:(0,f.R)(e.content,{}),id:null!==(r=null==e?void 0:e.block_id)&&void 0!==r?r:""})});e((0,u.Uy)(e=>{e.blockIdToProcess[s]||(e.blockIdToProcess[s]=[]),e.blockIdToProcess[s]=d,e.isProcessDataLoading=!1,e.blockIdToProcessHasInitialized[s]=!0}))}catch(r){e((0,u.Uy)(e=>{e.isProcessDataLoading=!1,e.blockIdToProcessHasInitialized[s]=!0})),p.k.persist.warning({eventName:"fetch_DeepResearch_process_data_error"})}}),function(e){return o.apply(this,arguments)}),updateDeepResearchProcessData(r){var{blockId:o,value:t}=r;e((0,u.Uy)(e=>{e.blockIdToProcess[o]||(e.blockIdToProcess[o]=[]),e.blockIdToProcess[o]=t}))},updateBlockIdToConvId:o=>{var{blockId:t,convId:a,status:s}=o;e((0,u.Uy)(e=>{e.blockIdToConvIdWithAsyncState[t]||(e.blockIdToConvIdWithAsyncState[t]={}),e.blockIdToConvIdWithAsyncState[t]={convId:a,status:s};var o,i,c=null!==(o=r().blockIdToProcess)&&void 0!==o?o:{},n=null!==(i=e.blockIdToConvIdWithAsyncState)&&void 0!==i?i:{};Object.keys(c).forEach(r=>{var o,t;(null===(o=n[r])||void 0===o?void 0:o.convId)!==a&&(null===(t=n[r])||void 0===t?void 0:t.status)&&(delete e.blockIdToProcess[r],e.blockIdToProcessHasInitialized[r]=!1)})}))},updateSendDisabledState:r=>{e((0,u.Uy)(e=>{e.sendDisabled=r}))},updateBreakModalDestroyers(r){e((0,u.Uy)(e=>{e.breakModalDestroyers=r}))},addBreakModalDestroyer:(r,o)=>{e((0,u.Uy)(e=>{e.breakModalDestroyers[r]=o}))},removeBreakModalDestroyer:r=>{e((0,u.Uy)(e=>{delete e.breakModalDestroyers[r]}))}})},b=o(932842),k=o(917612),I=o(781667),D=(t=(0,d._)(function*(e){var r,{conversationId:o,artifactId:t}=e,{data:a}=yield v.mH.SearchArtifact({conversation_id:o,artifact_id:t}),s=null!==(r=null==a?void 0:a.artifacts)&&void 0!==r?r:[];return(0,I.Z)(s,e=>e.version)}),function(e){return t.apply(this,arguments)}),P=()=>({artifactMap:{}}),_=(e,r)=>{var o;return(0,c.Z)(P(),{fetchArtifactList:(o=(0,d._)(function*(r){var{conversationId:o,artifactId:t,hasAbort:a}=r;try{var s=yield(0,k.aG)({value:()=>D({conversationId:o,artifactId:t}),ifRetry:e=>!e.length,count:5});if(a)return;return e((0,u.Uy)(e=>{var{artifactMap:r}=e;r[o]||(r[o]={}),r[o][t]=s})),s}catch(e){throw p.k.persist.error({eventName:"search_artifact_error",error:e}),e}}),function(e){return o.apply(this,arguments)}),refreshArtifactList:()=>(0,d._)(function*(){var{conversationId:e,canvasContent:o}=(0,b.GX)("chatViewCanvasStore"),t=null==o?void 0:o.artifactId;if(e&&t)return r().fetchArtifactList({conversationId:e,artifactId:t})})()})},T=e=>{try{return{blockIdToProcess:e.blockIdToProcess}}catch(e){return p.k.persist.error({message:"[@deep-research-store] persist state limit error",error:e instanceof Error?e:Error(String(e))}),{}}},g=function(){for(var e=arguments.length,r=Array(e),o=0;o<e;o++)r[o]=arguments[o];return(0,c.Z)(y(...r),_(...r))},S=e=>{var{isEnableDebug:r,reduxDevToolsSnapshot:o,merge:t,partialize:a,storage:c}=e,d=(0,n.C1)({name:"deep-research-store",prefix:"samantha-web",storage:c,partialize:null!=a?a:T,version:1.5,merge:t}),l=(0,s.tJ)((0,s.XR)(g),d);return r&&o?(0,i.Ue)()((0,s.mW)(l,{name:"samantha-web-deep-research-store"})):(0,i.Ue)()(l)},m=function(){for(var e=arguments.length,r=Array(e),o=0;o<e;o++)r[o]=arguments[o];var{_useDeepResearchStore:t}=m.prototype;if(t)return t(...r);throw Error("useDeepResearchStore is not initialized")};function w(e){var{_useDeepResearchStore:r}=m.prototype||{};if(!r){var o=S((0,a._)({},e));Object.setPrototypeOf(m.prototype,o),Object.defineProperties(m,(0,a._)({},Object.getOwnPropertyDescriptors(o))),m.prototype._useDeepResearchStore=o}}}}]);
//# sourceMappingURL=66219.js.map