1import{cJ as e,fP as t,cr as a,fQ as s,fR as o,cm as d,cu as i,cn as n,a$ as r,fS as u,aX as l,fT as c,cK as m,b0 as I,cO as f,d7 as h,bk as E,eJ as p,N as g,au as N,fU as v,cF as T,ap as A,x as S,fV as _,fW as D,y as w,ar as O,o as M}from"./DCCPWw9Y.js";import"./Bx1xfRBz.js";import{H as y,A as U,l as b,r as R,y as C}from"./CmUz1GCm.js";import{v as L,w as F,x as G,y as x,z as k,s as V}from"./DnT-784C.js";function P(e,t,a=16e4){if(!e||!t||e<=0||t<=0)return{width:400,height:400};const s=e/t;return{width:Math.round(Math.sqrt(a*s)),height:Math.round(Math.sqrt(a/s))}}const W=(e=10)=>{let t="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",a="",s=0|e;for(;s--;)a+=t[62*Math.random()|0];return a},H=e=>e.startsWith("text-"),$=e=>e.startsWith("image-"),j=e=>e.startsWith("video-"),K=e=>e.startsWith("audio-"),X=e=>e?.endsWith("-generator"),z=e=>X(e.type),q=e=>$(e.type),B=e=>j(e.type),J=e=>H(e.type),Y=e=>$(e.type)&&X(e.type),Q=e=>j(e.type)&&X(e.type),Z=e=>e?.result??{},ee=e=>e?.result?.images??[],te=e=>{const t=ee(e);return t.length>1?t.find((e=>e&&e?.primary))??null:t[0]??null},ae=e=>e?.result?.videos?.[0]??null,se=e=>{if(Y(e)){const t=te(e.data);return Boolean(t?.sensitive)}if(Q(e)){const t=ae(e.data);return Boolean(t?.sensitive)}return!1},oe=e=>{const t=H(e.type),a=$(e.type),s=j(e.type),o=X(e.type),d=K(e.type),n=se(e),r={nodeId:e.id,mediaType:"",url:"",coverUrl:"",previewUrl:"",text:"",illegal:n,sensitive:n,promptId:"",publishable:!1};if(o){if(a){const t=te(e.data);r.url=t?.url||"",r.previewUrl=t?.thumbnailUrl||"",r.coverUrl=t?.url||"",r.mediaType=i.IMAGE,r.publishable=t?.publishable??!1,r.promptId=e.data?.result?.promptId??""}else if(s){const t=ae(e.data);r.url=t?.videoUrl||"",r.previewUrl=t?.thumbnailCoverUrl||"",r.coverUrl=t?.coverUrl||"",r.mediaType=i.VIDEO,r.publishable=t?.publishable??!1,r.promptId=e.data?.result?.promptId??""}else if(t){const t=(e=>e?.result?.text??"")(e.data);r.text=t,r.mediaType=i.TEXT}}else a?(r.url=e.data?.url||"",r.mediaType=i.IMAGE):s?(r.url=e.data?.url||"",r.mediaType=i.VIDEO):t?(r.text=e.data?.prompt||"",r.mediaType=i.TEXT):d&&(r.url=e.data?.url||"",r.mediaType=i.AUDIO);return r},de=e=>{if(Boolean(e)){if(z(e)){if(q(e)){const t=te(e.data);return{...e.data,url:t?.url}}if(B(e)){const t=ae(e.data);return{...e.data,url:t?.videoUrl}}return e.data}return e.data}return null},ie=e=>e.map((e=>oe(e))).filter((e=>Boolean(e.url))),ne=(e,{textModelList:t=[],imageModelList:a=[],videoModelList:s=[]}={})=>X(e)?H(e)?t:$(e)?a:j(e)?s:[]:[],re=(d,i)=>{const{config:n}=e(i),r=(e=>{const t=s(e),a={};return Object.keys(t).forEach((e=>{const s=o[e];if(void 0!==s)if("function"==typeof s){const{key:o,value:d}=s(t[e]);a[o]=d}else a[s]=t[e]})),a})(n),u={width:0,height:0,data:null};if(t(n)){const e=P(r.aspectRatio.width,r.aspectRatio.height);u.width=e.width,u.height=e.height,u.data={modelId:i,...r}}else{const e=a[d];u.width=e.width,u.height=e.height,u.data={modelId:i,...r}}return u},ue=e=>e?.type===d.VIDEO_INPUT?e.data?.duration||0:e?.type===d.VIDEO_GENERATOR&&ae(e.data)?.duration||0,le=(e,t)=>e.reduce(((e,a)=>
1a.targetHandle===Ue.VIDEO_IN&&a.target===t?e+ue(a.sourceNode):e),0),ce=e=>e?.type===d.AUDIO_INPUT&&e.data?.duration||0,me=(e,t)=>e.reduce(((e,a)=>a.targetHandle===Ue.AUDIO_IN&&a.target===t?e+ce(a.sourceNode):e),0),Ie=(e,t=[])=>t.filter((t=>t.source===e.id)).length>0,fe=(e,t)=>{if(q(e)){const a=ee(e.data).map((e=>(e.url===t&&(e.publishable=!1),e)));return{result:{...e.data.result,images:a}}}if(B(e)){const s=(a=e.data,a?.result?.videos??[]).map((e=>(e.videoUrl===t&&(e.publishable=!1),e)));return{result:{...e.data.result,videos:s}}}return{};var a},he=(e,t)=>{if(q(e)){const a=ee(e.data),s=a.findIndex((e=>e.url===t));if(-1===s)return{};if(a.length<=1)return{nodeStatus:n.PENDING};const o=a.filter(((e,t)=>t!==s));return!o.some((e=>e.primary))&&o[0]&&(o[0]={...o[0],primary:!0}),{result:{...e.data.result,images:o}}}return{nodeStatus:n.PENDING}},Ee=(e="æ£æµéè¿",t=!1)=>({isValid:!0,message:e,showMessage:t}),pe=(e,t=!0)=>({isValid:!1,message:e,showMessage:t}),ge=({edges:e,targetNode:t,targetHandle:a})=>{if(a===Ue.IMAGE_IN_ENDFRAME){return Oe(e,t.id,Ue.IMAGE_IN_STARTFRAME).length>0?Ee():pe("Please add a start frame before connecting an end frame.")}return Ee("é尾叧奿")},Ne=({edges:e,targetNode:t,targetHandle:a})=>{if(a===Ue.AUDIO_IN){const a=Oe(e,t.id,Ue.IMAGE_IN),s=Oe(e,t.id,Ue.VIDEO_IN);return a.length>0||s.length>0?Ee():pe("Please add an image or video before connecting audio.")}return Ee("éé³é¢ç±»å奿")},ve=({edges:e,sourceHandle:t,sourceNode:a,targetNode:s})=>{if(z(a)){if(Pe(t)&&a.data?.nodeStatus===n.SUCCESS){const{videoDuration:t}=ze(s?.data?.modelId),o=le(e,s?.id),d=ue(a),i=e.some((e=>e.target===s?.id&&e.targetHandle===Ue.VIDEO_IN&&e.source===a?.id))?o:o+d,{min:n=0,max:r=0}=t??{};return i>=n&&i<=r&&d>=n?Ee():pe(`Video duration must be between ${n}s and ${r}s.`)}return Ee("éè§é¢ç±»å奿")}if(Pe(t)){const{videoDuration:t}=ze(s?.data?.modelId),o=le(e,s?.id),d=ue(a),i=e.some((e=>e.target===s?.id&&e.targetHandle===Ue.VIDEO_IN&&e.source===a?.id))?o:o+d,{min:n=0,max:r=0}=t??{};return i>=n&&i<=r&&d>=n?Ee():pe(`Video duration must be between ${n}s and ${r}s.`)}return Ee("éè§é¢ç±»å奿")},Te=({sourceHandle:e,sourceNode:t,targetNode:a})=>{if(Pe(e)&&t.data?.nodeStatus===n.SUCCESS){const{videoPixel:e}=ze(a?.data?.modelId),s=(e=>{if(e?.type===d.VIDEO_INPUT)return(e.data?.width??0)*(e.data?.height??0);if(e?.type===d.VIDEO_GENERATOR){const t=ae(e.data);return(t?.width??0)*(t?.height??0)}return 0})(t),{min:o=0,max:i=0}=e??{};return s>=o&&s<=i?Ee():pe(`The total pixel count (width x height) of the video's start frame must be between ${o} and ${i}.`)}return Ee("éè§é¢ç±»å奿")},Ae=({edges:e,sourceHandle:t,sourceNode:a,targetNode:s})=>{if(z(a)){if(We(t)&&a.data?.nodeStatus===n.SUCCESS){const{audioDuration:t}=ze(s?.data?.modelId),o=me(e,s?.id),d=ce(a),i=e.some((e=>e.target===s?.id&&e.targetHandle===Ue.AUDIO_IN&&e.source===a?.id))?o:o+d,{min:n=0,max:r=0}=t??{};return i>=n&&i<=r&&d>=n?Ee():pe(`Audio duration must be between ${n}s and ${r}s.`)}return Ee("éé³é¢ç±»å奿")}if(We(t)){const{audioDuration:t}=ze(s?.data?.modelId),o=me(e,s?.id),d=ce(a),i=e.some((e=>e.target===s?.id&&e.targetHandle===Ue.AUDIO_IN&&e.source===a?.id))?o:o+d,{min:n=0,max:r=0}=t??{};return i>=n&&i<=r&&d>=n?Ee():pe(`Audio duration must be between ${n}s and ${r}s.`)}return Ee("éé³é¢ç±»å奿")},Se=({sourceHandle:e,sourceNode:t,targetNode:a})=>{const s=(e,t)=>{const{imageRatio:a}=ze(e),{width:s,height:o}=(e=>{if(e.type===d.IMAGE_INPUT)return{width:e.data?.width??0,height:e.data?.height??0};if(Y(e)){const t=te(e.data);return{width:t?.width??0,height:t?.height??0}}return{width:0,height:0}})(t);if(a.enable){const{min:e=0,max:t=0}=a??{},d=s/o;return d>=e&&d<=t?Ee():pe(`The ratio of the image's width and height must be between ${e} and ${t}.`)}return Ee("å¾ç宽髿¯æ ¡éªè§åæªå¯ç¨")},o=(e,t)=>{const{videoRatio:a}=ze(e),{width:s,height:o}=(e=>{if(e.type===d.VIDEO_INPUT)return{width:e.data?.width??0,height:e.data?.height??0};if(Q(e)){const t=ae(e.data);return{width:t?.width??0,height:t?.height??0}}return{width:0,height:0}})(t);if(a.enable){const{min:e=0,max:t=0}=a??{},d=s/o;return d>=e&&d<=t?Ee():pe(`The ratio of the video's width and height must be between ${e} and ${t}.`)}return Ee("è§é¢å®½é«æ¯æ ¡éªè§åæªå¯ç¨")};return z(t)?Ve(e)&&t.data?.nodeStatus===n.SUCCESS?s(a?.data?.modelId,t):Pe(e)&&t.data?.nodeStatus===n.SUCCESS?o(a?.data?.modelId,t):Ee("éå¾çæè§é¢ç±»å奿"):Ve(e)?s(a?.data?.modelId,t):Pe(e)?o(a?.data?.modelId,t):Ee("éå¾çæè§é¢ç±»å奿")}
1,_e=[{modelMatch:e=>r(e),checks:[ge,Ne,ve,Te,Ae]},{modelMatch:e=>u({model_id:e}),checks:[Se]},{modelMatch:e=>l({model_id:e}),checks:[ge,ve,Te,Ae]},{modelMatch:e=>c({model_id:e}),checks:[ge]},{modelMatch:e=>m({model_id:e}),checks:[ve]},{modelMatch:e=>I(e),checks:[ge,ve,Te,Ae,Se]},{modelMatch:e=>f({model_id:e}),checks:[ge,Ne,ve,Te,Ae,Se]}],De=(e,t,a)=>{if(!t)return[];const s=e.filter((e=>e.target===t.id)),o=[Ue.IMAGE_IN,Ue.VIDEO_IN,Ue.AUDIO_IN];return o.includes(a)?s.filter((e=>be.includes(e.targetHandle))).map((e=>e.id)):be.includes(a)?s.filter((e=>o.includes(e.targetHandle))).map((e=>e.id)):[]},we=[{modelMatch:e=>r(e)||c({model_id:e})||I(e),resolves:[De]},{modelMatch:e=>l({model_id:e}),resolves:[De]},{modelMatch:e=>f({model_id:e}),resolves:[De]}],Oe=(e=[],t,a)=>e.filter((e=>e.target===t&&e.targetHandle===a)),Me=(e,t,a)=>we.reduce(((s,o)=>{if(o.modelMatch(t.data?.modelId)){const d=o.resolves.map((s=>s(e,t,a.targetHandle))).flat();return[...s,...d]}return s}),[]),ye=(e,t,a)=>{const s=((e,t)=>{if(!t||!X(t.type))return[];const a=Ke(t.data?.modelId),s=[];for(const[o,d]of Object.entries(a)){if(!d||d===1/0)continue;const a=Oe(e,t.id,o);a.length>d&&s.push(...a.slice(0,a.length-d).map((e=>e.id)))}return s})(e,t);return[...s,...Me(e,t,a)]},Ue={TEXT_IN:"text-in",TEXT_OUT:"text-out",IMAGE_IN_STARTFRAME:"image-in-startframe",IMAGE_IN_ENDFRAME:"image-in-endframe",IMAGE_IN:"image-in",IMAGE_OUT:"image-out",VIDEO_IN:"video-in",VIDEO_OUT:"video-out",AUDIO_IN:"audio-in",AUDIO_OUT:"audio-out"},be=[Ue.IMAGE_IN_STARTFRAME,Ue.IMAGE_IN_ENDFRAME],Re={TARGET:"target",SOURCE:"source"},Ce={"audio-in":"Audio","audio-out":"Audio","text-in":"Text","text-out":"Text","image-in-startframe":"Start Image","image-in-endframe":"End Image","image-in":"References Image","image-out":"Image","video-in":"References Video","video-out":"Video"},Le={text:"line-text",image:"line-image",video:"line-video",audio:"line-audio"},Fe=e=>e.split("-")?.[0]??"",Ge=e=>{const[t="",a="",s=""]=e?.split("-")??[];return{type:t,direction:a,operation:s}},xe=e=>{if(!e)return"";const t=Fe(e);return Le[t]??""},ke=e=>{const t=xe(e.sourceHandle);return t?{...e,class:t}:e},Ve=e=>e?.startsWith("image-"),Pe=e=>e?.startsWith("video-"),We=e=>e?.startsWith("audio-"),He=new Map,$e=e=>e?(He.has(e)||He.set(e,je(e)),He.get(e)):{limits:{},enableMap:{},configFlat:{}},je=t=>{if(!t)return{limits:{},enableMap:{},configFlat:{}};const{config:a}=e(t),s=a?.options??{},o=s.mediaReference?.props??{},d=s.frameReference?.props??{},i=o.frameProps??{},n=s.multiShots?.props??{},r=(s.prompt?.props||s.multiShots?.props)??{},u=!!(d.enableStart||o.keyframe&&i.enableStart),l=!!(d.enableEnd||o.keyframe&&i.enableEnd),c=!!s.mediaReference,m=c&&!1!==o.imageEnable,I=c&&!!o.videoEnable,f=c&&!!o.audioEnable,h=!!s.prompt||!!s.multiShots;return{limits:{[Ue.TEXT_IN]:h?1/0:0,[Ue.IMAGE_IN_STARTFRAME]:u?1:0,[Ue.IMAGE_IN_ENDFRAME]:l?1:0,[Ue.IMAGE_IN]:m?o.imageMaxCount??1:0,[Ue.VIDEO_IN]:I?o.videoMaxCount??1:0,[Ue.AUDIO_IN]:f?o.audioMaxCount??1:0,[Ue.TEXT_OUT]:1/0,[Ue.IMAGE_OUT]:1/0,[Ue.VIDEO_OUT]:1/0,[Ue.AUDIO_OUT]:1/0},enableMap:{[Ue.TEXT_IN]:h,[Ue.IMAGE_IN_STARTFRAME]:u,[Ue.IMAGE_IN_ENDFRAME]:l,[Ue.IMAGE_IN]:m,[Ue.VIDEO_IN]:I,[Ue.AUDIO_IN]:f,[Ue.TEXT_OUT]:!0,[Ue.IMAGE_OUT]:!0,[Ue.VIDEO_OUT]:!0,[Ue.AUDIO_OUT]:!0},configFlat:{mentionEnable:Boolean(s.mention?.componentName||n?.mentionEnable),imageRatio:o?.imageRatio,videoRatio:o?.videoRatio,videoDuration:o?.videoDuration,videoPixel:o?.videoPixel,audioDuration:o?.audioDuration,promptLimit:{min:r?.minlength??0,max:r?.maxlength??2500}}}},Ke=e=>$e(e).limits,Xe=e=>$e(e).enableMap,ze=e=>$e(e).configFlat,qe=(e,t,a,s,o)=>{if(!(t&&a&&s&&o))return{isValid:!1,message:"åæ°é误"};const d=((e,t)=>{if(X(e?.type))return Xe(e.data?.modelId)[t]?Ee():pe("Parameter not available.",!1);return Ee("éçæèç¹")})(s,o);if(!d.isValid)return d;const i=((e,t,a)=>{if(X(e?.type)){const s=Ke(e.data?.modelId)[t]??1/0;return a<s?Ee():pe(`Too many references. This model supports up to ${s}`)}return Ee("éçæèç¹")})(s,o,Oe(e,s.id,o).length);if(!i.isValid)return i;const n={edges:e,sourceNode:t,sourceHandle:a,targetNode:s,targetHandle:o};for(const r of _e)if(r.modelMatch(s.data?.modelId))for(const e of r.checks){const t=e(n);if(!t.isValid)return t}return Ee("æ£æµéè¿")},Be=(e,t,a)=>{if(!t.length)return null;const s=((e,t)=>e===d.IMAGE_GENERATOR&&t.some((e=>e.id===h))?h:t[0].id)(e,t);if(!a?.handleId)return s;if(a.handleType===Re.TARGET)return s;const o=t.find((e=>((e,t)=>{const a=Xe(e),{type:s,direction:o}=Ge(t);return Object.entries(a).some((([e,t])=>
1{if(!t)return!1;const a=Ge(e);return a.type===s&&a.direction!==o}))})(e.id,a.handleId)));return o?.id??s},Je={FLOW:{TASK:{START:"flow:task-start",CREATED:"flow:task-created",SUCCESS:"flow:task-success",FAILED:"flow:task-failed"},HOTKEY:{DUPLICATE:"flow:hotkey:duplicate"},SAVE:"flow:save",REFRESH:"flow:refresh",SYNC_COMPLETE:"flow:sync-complete"}},Ye=()=>{const{$eventBus:e}=E(),t=U(),a=e=>"function"==typeof e?e():e;return{EVENTS:Je,on(s,o){const d=a(s);return e.on(d,o),t&&y((()=>e.off(d,o))),()=>e.off(d,o)},once(s,o){const d=a(s);return e.once(d,o),t&&y((()=>e.off(d,o))),()=>e.off(d,o)},emit(t,...s){const o=a(t);e.emit(o,...s)},off(t,s){const o=a(t);e.off(o,s)},raw:e}},Qe="Untitled Canvas",Ze=p("flowStore",(()=>{const{checkPermission:e}=A(),t=R(""),a=R(""),s=R(0),o=C({position:[0,0],viewport:{x:0,y:0,zoom:1},zoom:1}),i=R([]),r=R([]),u=b((()=>({...o,nodes:i.value,edges:r.value}))),l=R(!1),c=C({id:"",title:""}),m=e=>{c.id=e.id,c.title=e.title},I=R([]),f=R([]),h=R([]),E=R([]),p=b((()=>[...I.value,...f.value,...h.value])),g=({text:e=[],image:t=[],video:a=[]})=>(I.value=e,f.value=t,h.value=a,p.value),N=C({node:0,edge:0}),v=S();return{flowId:t,flowName:a,flowConfig:o,todoList:E,plNodes:i,plEdges:r,textModelList:I,imageModelList:f,videoModelList:h,modelList:p,totalFlowCount:s,initFlowData:async e=>{if(!e)return w(v("/canvas"));t.value=e;try{const{status:t,data:s}=await x({projectId:e});if(0!==t)return w(v("/canvas"));a.value=s?.projectName||Qe,m({id:s?.sourceId||"",title:s?.templateTitle||""});const{nodes:u,edges:l,...c}=s?.viewData,I=u?.map((e=>e.viewData))||[];return i.value=((e=[])=>e?.map((e=>{if(e?.data?.nodeStatus===n.SUCCESS)switch(e.type){case d.IMAGE_GENERATOR:e.data?.result?.images||(e.data.nodeStatus=n.PENDING);break;case d.VIDEO_GENERATOR:e.data?.result?.videos||(e.data.nodeStatus=n.PENDING)}return e})))(I),r.value=l?.map((e=>e.viewData))||[],o.position=c?.position||[0,0],o.zoom=c?.zoom||1,o.viewport=c?.viewport||{x:0,y:0,zoom:1},!!i.value.length}catch(s){}},createFlow:async(t=[])=>{const a=await k({name:Qe,viewData:{...o,nodes:i.value,edges:r.value}});if(a.status!==T.FLOW_EXCEED_LIMIT)return E.value=[],t.length&&E.value.push(...t.map((e=>({...e,type:"add"})))),a.data?.id;await e(O.CREATE_FLOW_LIMIT,s.value+1)&&trackEvent("canvas_paywall_modal_view",{el:"source_surface=canvas_home&trigger_type=canvas_project_limit&node_type=null"})},updateFlow:async()=>{const{status:e,data:s,message:o}=await V({id:t.value,name:a.value});return 0!==e?M.error(o):(M.success(o),s?.id)},fromObjectData:u,setModelList:g,getFlowModelList:async()=>{const{data:e,status:t,message:a}=await G();if(0!==t)return;const s=e["text-generator"]||[],o=e["image-generator"]||[],d=e["video-generator"]||[],i=new Set(s.map((e=>e.modelId))),n=new Set(o.map((e=>e.modelId))),r=new Set(d.map((e=>e.modelId))),u=[...s,...o,...d].map((e=>({...e,modelDisplay:e.name}))),l=_(u).flatMap((e=>Object.values(e.model))),c=[],m=[],I=[];for(const f of l){const e=f.modelId;D(e)&&(i.has(e)&&c.push(f),n.has(e)&&m.push(f),r.has(e)&&I.push(f))}g({text:c,image:m,video:I})},idCounter:N,initIdCounter:()=>{N.node=0,N.edge=0},clearElements:()=>{i.value=[],r.value=[]},updateTotalFlowCount:e=>{s.value=Number(e)||0},showGuide:l,setShowGuide:e=>{l.value=e},templateInfo:c,setTemplateInfo:m}})),et=p("flowTask",(()=>{const e=Ye(),t=g(),a=N(),s={PENDING:"PENDING",RUNNING:"RUNNING",SUCCESS:"SUCCESS",FAILED:"FAILED"},o=R([]),d=R(!1),i=R({}),n=b((()=>o.value.filter((e=>[s.PENDING,s.RUNNING].includes(e.status))).length)),r=e=>{const t=o.value.find((t=>t.nodeId===e));return!(!t||![s.PENDING,s.RUNNING].includes(t.status))},u=(e,t)=>{const a=o.value.find((t=>t.taskId===e||t.nodeId===e));a&&Object.assign(a,t)},l=()=>{d.value||(d.value=!0,c())},c=async()=>{const a=o.value.filter((e=>e.taskId&&e.status===s.RUNNING));if(0!==a.length){try{const o=a.map((e=>({taskId:e.taskId,nodeCodes:[e.nodeId]}))),{status:d,data:i,message:n}=await F(o);if(0!==d)throw new Error(n);for(const r of i){const{taskId:o,schedulingNodeStates:d=[],nextPollNodeCodes:i,runFinished:n}=r||{};if(n&&0===d.length){const t=a.find((e=>e.taskId===o));t&&(u(t.nodeId,{status:s.FAILED,result:r}),e.emit(e.EVENTS.FLOW.TASK.FAILED,{nodeId:t.nodeId,result:{errorCode:T.FLOW_UNKNOWN}}))}
1d.forEach((a=>{[v.COMPLETED,v.FAILED].includes(a.status)&&t.updateRemainLumens(),a.status===v.COMPLETED?(u(a.nodeCode,{status:s.SUCCESS,result:r}),e.emit(e.EVENTS.FLOW.TASK.SUCCESS,{nodeId:a.nodeCode,result:a})):a.status===v.FAILED&&(u(a.nodeCode,{status:s.FAILED,result:r}),e.emit(e.EVENTS.FLOW.TASK.FAILED,{nodeId:a.nodeCode,result:a}))}))}}catch(i){for(const t of a)u(t.nodeId,{status:s.FAILED,result:i}),e.emit(e.EVENTS.FLOW.TASK.FAILED,{nodeId:t.nodeId,result:{errorCode:T.FLOW_UNKNOWN}})}d.value&&setTimeout(c,3e3)}else d.value=!1};return{tasks:o,activeTaskCount:n,executeTask:async(d,i)=>{if(r(i))return{status:3001,message:"ä»»å¡å·²å¨è¿è¡ä¸ï¼è¯·çå¾
宿"};if(n.value>=a.queueLimit.queueMax)return{status:3002,message:`ä»»å¡éåå·²æ»¡ï¼æå¤æ¯æ${a.queueLimit.queueMax}个è¿è¡ä»»å¡ï¼`};const c=o.value.findIndex((e=>e.nodeId===i)),m={taskId:"",nodeId:i,status:s.PENDING,result:null};c>-1?o.value[c]=m:o.value.push(m),e.emit(e.EVENTS.FLOW.TASK.START,{nodeId:i,status:s.PENDING});try{const{status:t,data:a,message:o}=await L({mode:"SINGLE_NODE",projectId:d,groupCode:"",nodeCode:i});if(0===t){const{taskId:t,schedulingNodeStates:o,nextPollNodes:d}=a,n=o.find((e=>e.nodeCode===i));n.status===v.FAILED?(u(i,{taskId:t,status:s.FAILED,result:a}),e.emit(e.EVENTS.FLOW.TASK.FAILED,{nodeId:i,result:n})):(u(i,{taskId:t,status:s.RUNNING,result:a}),e.emit(e.EVENTS.FLOW.TASK.CREATED,{nodeId:i,taskId:t}),l())}else u(i,{status:s.FAILED,result:a}),e.emit(e.EVENTS.FLOW.TASK.FAILED,{nodeId:i,result:{}})}catch(I){u(i,{status:s.FAILED,result:I}),e.emit(e.EVENTS.FLOW.TASK.FAILED,{nodeId:i,result:{}})}finally{t.updateRemainLumens()}},isGenerating:r,clearTasks:e=>{const t=new Set(Array.isArray(e)?e:[e]);t.size&&(o.value=o.value.filter((e=>!t.has(e.nodeId))))},restoreTask:(e=[])=>{const t=e.filter((e=>"generating"===e.data?.nodeStatus&&e.data?.taskId));for(const a of t){o.value.findIndex((e=>e.nodeId===a.id))>-1?u(a.id,{status:s.RUNNING,taskId:a.data.taskId,result:null}):o.value.push({nodeId:a.id,status:s.RUNNING,taskId:a.data.taskId,result:null})}t.length>0&&l()},destroyTasks:()=>{o.value=[],d.value&&(d.value=!1)},setNodeLumenCost:(e,t)=>{e&&null!=t&&(i.value={...i.value,[e]:Number(t)||0})},consumeNodeLumenCost:e=>{const t=i.value[e];if(null==t)return;const a={...i.value};return delete a[e],i.value=a,t}}}));export{ae as A,X as B,se as C,xe as D,Ce as E,de as F,et as G,Re as H,ze as I,Me as J,B as K,ue as L,q as M,J as N,ne as a,re as b,Fe as c,qe as d,ye as e,Ue as f,W as g,Ie as h,Xe as i,Ye as j,ie as k,$ as l,j as m,oe as n,Z as o,he as p,fe as q,Be as r,P as s,Ve as t,Ze as u,Pe as v,ke as w,We as x,K as y,te as z};
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.