(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,690003,e=>{"use strict";function r(e){return[...new Set(e)]}e.s(["uniq",()=>r])},605573,e=>{"use strict";function r(e){return Array.isArray(e)}e.s(["isArray",()=>r])},840247,e=>{"use strict";var r=e.i(652669);let a=e=>null!==e&&"object"==typeof e,t=function(e,r){let t=(e,r)=>{let i=a(e),l=a(r);if(!i)return!0;if(!l){for(let r in e)if("type"===r||a(e[r])&&!t(e[r],null))return!1;return!0}let o=e.type,s=r.type,n=a(o);if(!n&&o!==s)return!1;for(let a of new Set([...Object.keys(e),...Object.keys(r)]))if(("type"!==a||n)&&!t(e[a],r[a]))return!1;return!0};return t(e,r)};e.s(["default",0,()=>{let{data:e,isLoading:a}=(0,r.useSchemaTypeDefinitions)();return{isLoading:a,schemaTypeDefinitions:e}},"getMatchedSchemaType",0,(e,r)=>{if(!r||null==e)return"";let a=r.find(r=>t(e,r.schema));return a?a.name:""}],840247)},671258,754210,472663,e=>{"use strict";e.i(187243);var r,a=e.i(989425),t=e.i(390622);e.i(905691);var i=e.i(97672),l=e.i(840247);let o=[{name:"datasource_type",type:t.VarType.string,description:"local_file, online_document, website_crawl"}],s=[{name:"file",type:t.VarType.file,description:"file",subItems:[{name:"name",type:t.VarType.string,description:"file name"},{name:"size",type:t.VarType.number,description:"file size"},{name:"type",type:t.VarType.string,description:"file type"},{name:"extension",type:t.VarType.string,description:"file extension"},{name:"mime_type",type:t.VarType.string,description:"file mime type"},{name:"transfer_method",type:t.VarType.string,description:"file transfer method"},{name:"url",type:t.VarType.string,description:"file url"},{name:"related_id",type:t.VarType.string,description:"file related id"}]}];e.s(["COMMON_OUTPUT",0,o,"LOCAL_FILE_OUTPUT",0,s],754210),e.i(705848);var n=((r={}).localFile="local_file",r.websiteCrawl="website_crawl",r.onlineDocument="online_document",r.onlineDrive="online_drive",r);e.s(["DataSourceClassification",()=>n],472663);let p="errorMsg",c=(0,i.genNodeMetaData)({sort:-1,type:t.BlockEnum.DataSource,isStart:!0,isRequired:!0});e.s(["default",0,{metaData:c,defaultValue:{datasource_parameters:{},datasource_configurations:{}},checkValid(e,r,t){let{dataSourceInputsSchema:i,notAuthed:l}=t,o="";return l&&(o=r(`${p}.authRequired`,{ns:"workflow"})),o||i.filter(e=>e.required).forEach(t=>{let i=e.datasource_parameters[t.variable];if(!i){o=r(`${p}.fieldRequired`,{ns:"workflow",field:t.label});return}let{type:l,value:s}=i;l===a.VarType.variable?o||s&&0!==s.length||(o=r(`${p}.fieldRequired`,{ns:"workflow",field:t.label})):o||null!=s&&""!==s||(o=r(`${p}.fieldRequired`,{ns:"workflow",field:t.label}))}),{isValid:!o,errorMessage:o}},getOutputVars(e,r){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],{schemaTypeDefinitions:t}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{schemaTypeDefinitions:[]},{plugin_id:i,datasource_name:p,provider_type:c}=e,u=c===n.localFile,y=r.dataSourceList?.find(e=>e.plugin_id===i),b=y?.tools?.find(e=>e.name===p),d=b?.output_schema,m=[];return d?.properties&&Object.keys(d.properties).forEach(e=>{let r=d.properties[e],a=r.type,i="array"===a?`array[${r.items?.type.slice(0,1).toLocaleLowerCase()}${r.items?.type.slice(1)}]`:`${a.slice(0,1).toLocaleLowerCase()}${a.slice(1)}`,o=l.getMatchedSchemaType?.(r,t);"object"===i&&"file"===o&&(i="file"),m.push({variable:e,type:i,description:r.description,schemaType:o,children:"object"===r.type?{schema:{type:"object",properties:r.properties}}:void 0})}),[...o.map(e=>({variable:e.name,type:e.type})),...u?s.map(e=>({variable:e.name,type:e.type})):[],...a,...m]}}],671258)},710441,e=>{"use strict";var r=e.i(746628),a=e.i(390622);e.i(905691);var t=e.i(97672);let i="nodes.humanInput.errorMsg",l=(0,t.genNodeMetaData)({classification:r.BlockClassificationEnum.Logic,sort:1,type:a.BlockEnum.HumanInput});e.s(["default",0,{metaData:l,defaultValue:{delivery_methods:[],user_actions:[],form_content:"",inputs:[],timeout:3,timeout_unit:"day"},checkValid(e,r){let a="";if(a||e.delivery_methods.length||(a=r(`${i}.noDeliveryMethod`,{ns:"workflow"})),a||!(e.delivery_methods.length>0)||e.delivery_methods.some(e=>e.enabled)||(a=r(`${i}.noDeliveryMethodEnabled`,{ns:"workflow"})),a||e.user_actions.length||(a=r(`${i}.noUserActions`,{ns:"workflow"})),!a&&e.user_actions.length>0){let t=e.user_actions.map(e=>e.id);t.length!==new Set(t).size&&(a=r(`${i}.duplicateActionId`,{ns:"workflow"}))}return!a&&e.user_actions.length>0&&e.user_actions.some(e=>!e.id?.trim())&&(a=r(`${i}.emptyActionId`,{ns:"workflow"})),!a&&e.user_actions.length>0&&e.user_actions.some(e=>!e.title?.trim())&&(a=r(`${i}.emptyActionTitle`,{ns:"workflow"})),{isValid:!a,errorMessage:a}},getOutputVars:(e,r,t)=>e.inputs.map(e=>e.output_variable_name).map(e=>({variable:e,type:a.VarType.string}))}])},144480,938123,e=>{"use strict";var r=e.i(946700);e.i(187243);var a=e.i(989425),t=e.i(390622);e.i(905691);var i=e.i(97672),l=e.i(842090),o=e.i(959752),s=e.i(669744),n=e.i(840247);let p=e=>{if(!e)return;let{type:r,properties:a,items:t,oneOf:i,anyOf:l,allOf:o}=e;if(Array.isArray(r))return r.find(e=>e&&"null"!==e)||r[0];if("string"==typeof r)return r;for(let e of[i,l,o].filter(e=>Array.isArray(e)).flat()){let r=p(e);if(r)return r}return a?"object":t?"array":void 0},c=(e,r)=>{let a=(0,n.getMatchedSchemaType)(e,r);switch(p(e)){case"string":return{type:t.VarType.string,schemaType:a};case"number":return{type:t.VarType.number,schemaType:a};case"integer":return{type:t.VarType.integer,schemaType:a};case"boolean":return{type:t.VarType.boolean,schemaType:a};case"object":if("file"===a)return{type:t.VarType.file,schemaType:a};return{type:t.VarType.object,schemaType:a};case"array":{let i=(e=>{if(e&&e.items)return Array.isArray(e.items)?e.items[0]:e.items})(e);if(!i)return{type:t.VarType.array,schemaType:a};let{type:l,schemaType:o}=c(i,r),s=a||o;if("file"===o)return{type:t.VarType.arrayFile,schemaType:s};switch(l){case t.VarType.string:return{type:t.VarType.arrayString,schemaType:s};case t.VarType.number:case t.VarType.integer:return{type:t.VarType.arrayNumber,schemaType:s};case t.VarType.boolean:return{type:t.VarType.arrayBoolean,schemaType:s};case t.VarType.object:return{type:t.VarType.arrayObject,schemaType:s};case t.VarType.file:return{type:t.VarType.arrayFile,schemaType:s};default:return{type:t.VarType.array,schemaType:s}}}default:return{type:t.VarType.any,schemaType:a}}};e.s(["normalizeJsonSchemaType",0,p,"resolveVarType",0,c],938123);let u="errorMsg",y=(0,i.genNodeMetaData)({sort:-1,type:t.BlockEnum.Tool,helpLinkUri:"tools"});e.s(["default",0,{metaData:y,defaultValue:{tool_parameters:{},tool_configurations:{},tool_node_version:"2"},checkValid(e,r,t){let{toolInputsSchema:i,toolSettingSchema:l,language:o,notAuthed:s}=t,n="";return s&&(n=r(`${u}.authRequired`,{ns:"workflow"})),n||i.filter(e=>e.required).forEach(t=>{let i=e.tool_parameters[t.variable];if(!i){n=r(`${u}.fieldRequired`,{ns:"workflow",field:t.label});return}let{type:l,value:o}=i;l===a.VarType.variable?n||o&&0!==o.length||(n=r(`${u}.fieldRequired`,{ns:"workflow",field:t.label})):n||null!=o&&""!==o||(n=r(`${u}.fieldRequired`,{ns:"workflow",field:t.label}))}),n||l.filter(e=>e.required).forEach(a=>{let t=e.tool_configurations[a.variable];n||null!=t&&""!==t||(n=r(`${u}.fieldRequired`,{ns:"workflow",field:a.label[o]})),!n&&"object"==typeof t&&t.type&&(void 0===t.value||null===t.value||""===t.value||Array.isArray(t.value)&&0===t.value.length)&&(n=r(`${u}.fieldRequired`,{ns:"workflow",field:a.label[o]}))}),{isValid:!n,errorMessage:n}},getOutputVars(e,a,t){let{schemaTypeDefinitions:i}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{schemaTypeDefinitions:[]},{provider_id:n,provider_type:p}=e,u=[];switch(p){case r.CollectionType.builtIn:u=a.buildInTools??[];break;case r.CollectionType.custom:u=a.customTools??[];break;case r.CollectionType.workflow:u=a.workflowTools??[];break;case r.CollectionType.mcp:u=a.mcpTools??[];break;default:u=[]}let y=u.find(e=>(0,l.canFindTool)(e.id,n)),b=y?.tools.find(r=>r.name===e.tool_name),d=b?.output_schema,m=[];if(d&&d.properties){let e=[];Object.keys(d.properties).forEach(r=>{let a=d.properties[r],{type:t,schemaType:l}=c(a,i);e.push({variable:r,type:t,des:a.description,schemaType:l,children:"object"===a.type?{schema:{type:s.Type.object,properties:a.properties,additionalProperties:!1}}:void 0})}),m=[...o.TOOL_OUTPUT_STRUCT,...e]}else m=o.TOOL_OUTPUT_STRUCT;return m}}],144480)},963855,476255,245695,e=>{"use strict";var r=e.i(690003),a=e.i(605573),t=e.i(805735),i=e.i(959752),l=e.i(671258),o=e.i(710441),s=e.i(144480),n=e.i(390622);e.i(905691);var p=e.i(97672),c=e.i(705848),u=e.i(669744);let y=e=>{if(!e)return;let{type:r,properties:a,items:t,oneOf:i,anyOf:l,allOf:o}=e;if(Array.isArray(r))return r.find(e=>e&&"null"!==e)||r[0];if("string"==typeof r)return r;for(let e of[i,l,o].filter(e=>Array.isArray(e)).flat()){let r=y(e);if(r)return r}return a?"object":t?"array":void 0},b=e=>{if(e&&e.items)return Array.isArray(e.items)?e.items[0]:e.items},d=(e,r)=>{if(!e)return;let a=e.schema_type||e.schemaType;if("string"==typeof a&&a.trim().length>0)return a},m=(e,r)=>{let a=d(e,r);switch(y(e)){case"string":return{type:n.VarType.string,schemaType:a};case"number":return{type:n.VarType.number,schemaType:a};case"integer":return{type:n.VarType.integer,schemaType:a};case"boolean":return{type:n.VarType.boolean,schemaType:a};case"object":return{type:n.VarType.object,schemaType:a};case"array":{let t=b(e);if(!t)return{type:n.VarType.array,schemaType:a};let{type:i,schemaType:l}=m(t,r),o=a||l;if("file"===l)return{type:n.VarType.arrayFile,schemaType:o};switch(i){case n.VarType.string:return{type:n.VarType.arrayString,schemaType:o};case n.VarType.number:case n.VarType.integer:return{type:n.VarType.arrayNumber,schemaType:o};case n.VarType.boolean:return{type:n.VarType.arrayBoolean,schemaType:o};case n.VarType.object:return{type:n.VarType.arrayObject,schemaType:o};case n.VarType.file:return{type:n.VarType.arrayFile,schemaType:o};default:return{type:n.VarType.array,schemaType:o}}}default:return{type:n.VarType.any,schemaType:a}}},T=(e,r)=>{let a=d(e,r),t=((e,r)=>{if("file"===r)return"array"===e?u.Type.array:u.Type.file;switch(e){case"number":case"integer":return u.Type.number;case"boolean":return u.Type.boolean;case"object":return u.Type.object;case"array":return u.Type.array;default:return u.Type.string}})(y(e),a),i={type:t};if(e?.description&&(i.description=e.description),a&&(i.schemaType=a),Array.isArray(e?.enum)&&(i.enum=e.enum),t===u.Type.object){i.properties=Object.entries(e?.properties||{}).reduce((e,a)=>{let[t,i]=a;return e[t]=T(i,r),e},{});let a=Array.isArray(e?.required)?e.required.filter(Boolean):void 0;i.required=a&&a.length>0?a:void 0,i.additionalProperties=!1}if(t===u.Type.array){let a=b(e);if(a){let{type:e,...t}=T(a,r);i.items={...t,type:e===u.Type.array?u.Type.object:e}}}return i},v={metaData:(0,p.genNodeMetaData)({sort:1,type:n.BlockEnum.TriggerPlugin,helpLinkUri:"trigger/plugin-trigger",isStart:!0}),defaultValue:{plugin_id:"",event_name:"",event_parameters:{},config:{}},checkValid(e,r){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t="";e.subscription_id||(t=r("nodes.triggerPlugin.subscriptionRequired",{ns:"workflow"}));let{triggerInputsSchema:i=[],isReadyForCheckValid:l=!0}=a||{};return!t&&l&&i.filter(e=>e.required).forEach(a=>{if(t)return;let i=e.event_parameters?.[a.variable]??e.config?.[a.variable];if(!i){t=r("errorMsg.fieldRequired",{ns:"workflow",field:a.label});return}let{type:l,value:o}="object"==typeof i&&null!==i&&"type"in i?i:{type:c.VarKindType.constant,value:i};l===c.VarKindType.variable?(!o||Array.isArray(o)&&0===o.length)&&(t=r("errorMsg.fieldRequired",{ns:"workflow",field:a.label})):(null==o||""===o||Array.isArray(o)&&0===o.length)&&(t=r("errorMsg.fieldRequired",{ns:"workflow",field:a.label}))}),{isValid:!t,errorMessage:t}},getOutputVars(e,r,a){let{schemaTypeDefinitions:t}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{schemaTypeDefinitions:[]};var i=e.output_schema||{};if(!i||"object"!=typeof i)return[];let l=i.properties;return l?Object.entries(l).map(e=>{let[r,a]=e,{type:i,schemaType:l}=m(a,t),o=y(a),s={variable:r,type:i,des:a?.description,...l?{schemaType:l}:{}};if("object"===o){let e=a?.properties?Object.entries(a.properties).reduce((e,r)=>{let[a,i]=r;return e[a]=T(i,t),e},{}):{},r=Array.isArray(a?.required)?a.required.filter(Boolean):void 0;s.children={schema:{type:u.Type.object,properties:e,required:r&&r.length>0?r:void 0,additionalProperties:!1}}}return s}):[]}};e.s(["default",0,v],476255);var f=e.i(925521),_=e.i(648404);let g=[{value:_.TransferMethod.local_file,i18nKey:"localUpload"},{value:_.TransferMethod.remote_url,i18nKey:"url"}],k=["type","size","name","url","extension","mime_type","transfer_method","related_id"],h=k.filter(e=>"transfer_method"!==e);e.s(["FILE_TYPE_OPTIONS",0,[{value:"image",i18nKey:"image"},{value:"document",i18nKey:"doc"},{value:"audio",i18nKey:"audio"},{value:"video",i18nKey:"video"}],"OUTPUT_FILE_SUB_VARIABLES",0,h,"SUB_VARIABLES",0,k,"TRANSFER_METHOD",0,g],245695),e.i(187243);var V=e.i(989425);let E=e=>"sys"===e[0]||"sys"===e[1],j=e=>!(!E(e)||["query","files"].includes(e[1])),B=e=>"env"===e[0],O=e=>"conversation"===e[0],A=e=>!!e&&"rag"===e[0],w=e=>["sys","env","conversation","rag"].includes(e),S=e=>e&&(Array.isArray(e)&&e.length>0||!Array.isArray(e)&&Object.keys(e?.schema?.properties||{}).length>0),U=e=>({[n.InputVarType.number]:n.VarType.number,[n.InputVarType.checkbox]:n.VarType.boolean,[n.InputVarType.singleFile]:n.VarType.file,[n.InputVarType.multiFiles]:n.VarType.arrayFile,[n.InputVarType.jsonObject]:n.VarType.object})[e]||n.VarType.string,R=(e,r)=>r?({[u.Type.string]:n.VarType.arrayString,[u.Type.number]:n.VarType.arrayNumber,[u.Type.object]:n.VarType.arrayObject})[e]||n.VarType.string:({[u.Type.string]:n.VarType.string,[u.Type.number]:n.VarType.number,[u.Type.boolean]:n.VarType.boolean,[u.Type.object]:n.VarType.object,[u.Type.array]:n.VarType.array})[e]||n.VarType.string,I=(e,r)=>(0,t.produce)(e,a=>(Object.keys(e).forEach(a=>{let t=e[a],i=t.type===u.Type.object,l=t.type===u.Type.array,o=t.items?.type;i||r({variable:a,type:R(l?o:t.type,l)},[a])?t.type===u.Type.object&&t.properties&&(t.properties=I(t.properties,r)):delete e[a]}),a)),L=(e,r,a,i)=>{let l,{children:o}=e;if(o?.schema?.properties)l=(0,t.produce)(o,e=>{let a=e.schema.properties;return Object.keys(a).forEach(e=>{let t=a[e],i=t.type===u.Type.object,l=t.type===u.Type.array,o=t.items?.type;i||r({variable:e,type:R(l?o:t.type,l)},[e])?t.type===u.Type.object&&t.properties&&(t.properties=I(t.properties,r)):delete a[e]}),e});else l=Array.isArray(o)?o.map(e=>{let t,{children:i}=e,l=[...a,e.variable];if(!i)return{item:e,filteredObj:null,passesFilter:r(e,l)};let o=L(e,r,l,!1),s=S(o.children);return t=(e.type===n.VarType.object||e.type===n.VarType.file)&&i?s||r(e,l):s,{item:e,filteredObj:o,passesFilter:t}}).filter(e=>{let{passesFilter:r}=e;return r}).map(e=>{let{item:r,filteredObj:a}=e,{children:t}=r;return t&&a?{...r,children:a.children}:r}):[];return{variable:e.variable,type:i?n.VarType.file:n.VarType.object,children:l,schemaType:e.schemaType}},q=function(e,r,a,t,p){let c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[],{id:u,data:y}=e,b={nodeId:u,title:y.title,vars:[]};switch(y.type){case n.BlockEnum.Start:{let{variables:e}=y;b.vars=e.map(e=>{let r=U(e.type),a={variable:e.variable,type:r,isParagraph:e.type===n.InputVarType.paragraph,isSelect:e.type===n.InputVarType.select,options:e.options,required:e.required};try{r===n.VarType.object&&e.json_schema&&(a.children={schema:"string"==typeof e.json_schema?JSON.parse(e.json_schema):e.json_schema})}catch(e){console.error("Error formatting variable:",e)}return a}),r&&b.vars.push({variable:"sys.query",type:n.VarType.string}),b.vars.push({variable:"sys.files",type:n.VarType.arrayFile});break}case n.BlockEnum.TriggerWebhook:{let{variables:e=[]}=y;b.vars=e.map(e=>{let r=e.value_type||n.VarType.string;return{variable:e.variable,type:r,isParagraph:!1,isSelect:!1,options:e.options,required:e.required}});break}case n.BlockEnum.LLM:b.vars=[...i.LLM_OUTPUT_STRUCT],y.structured_output_enabled&&y.structured_output?.schema?.properties&&Object.keys(y.structured_output.schema.properties).length>0&&b.vars.push({variable:"structured_output",type:n.VarType.object,children:y.structured_output});break;case n.BlockEnum.KnowledgeRetrieval:b.vars=i.KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT;break;case n.BlockEnum.Code:{let{outputs:e}=y;b.vars=e?Object.keys(e).map(r=>({variable:r,type:e[r].type})):[];break}case n.BlockEnum.TemplateTransform:b.vars=i.TEMPLATE_TRANSFORM_OUTPUT_STRUCT;break;case n.BlockEnum.QuestionClassifier:b.vars=i.QUESTION_CLASSIFIER_OUTPUT_STRUCT;break;case n.BlockEnum.HttpRequest:b.vars=i.HTTP_REQUEST_OUTPUT_STRUCT;break;case n.BlockEnum.VariableAssigner:{let{output_type:e,advanced_settings:r}=y;r?.group_enabled?b.vars=r?.groups.map(e=>({variable:e.group_name,type:n.VarType.object,children:[{variable:"output",type:e.output_type}]})):b.vars=[{variable:"output",type:e}];break}case n.BlockEnum.VariableAggregator:{let{output_type:e,advanced_settings:r}=y;r?.group_enabled?b.vars=r?.groups.map(e=>({variable:e.group_name,type:n.VarType.object,children:[{variable:"output",type:e.output_type}]})):b.vars=[{variable:"output",type:e}];break}case n.BlockEnum.Tool:b.vars=s.default.getOutputVars?.(y,t,[],{schemaTypeDefinitions:c})||[];break;case n.BlockEnum.ParameterExtractor:b.vars=[...(y.parameters||[]).map(e=>({variable:e.name,type:e.type})),...i.PARAMETER_EXTRACTOR_COMMON_STRUCT];break;case n.BlockEnum.Iteration:b.vars=[{variable:"output",type:y.output_type||n.VarType.arrayString}];break;case n.BlockEnum.Loop:{let{loop_variables:e}=y;b.isLoop=!0,b.vars=e?.map(e=>({variable:e.label,type:e.var_type,isLoopVariable:!0,nodeId:b.nodeId}))||[];break}case n.BlockEnum.DocExtractor:b.vars=[{variable:"text",type:y.is_array_file?n.VarType.arrayString:n.VarType.string}];break;case n.BlockEnum.ListFilter:if(!y.var_type)break;b.vars=[{variable:"result",type:y.var_type},{variable:"first_record",type:y.item_var_type},{variable:"last_record",type:y.item_var_type}];break;case n.BlockEnum.Agent:{let e=[];Object.keys(y.output_schema?.properties||{}).forEach(r=>{let a=y.output_schema.properties[r];e.push({variable:r,type:"array"===a.type?`Array[${a.items?.type?a.items.type.slice(0,1).toLocaleUpperCase()+a.items.type.slice(1):"Unknown"}]`:`${a.type?a.type.slice(0,1).toLocaleUpperCase()+a.type.slice(1):"Unknown"}`})}),b.vars=[...e,...i.TOOL_OUTPUT_STRUCT,...i.AGENT_OUTPUT_STRUCT];break}case n.BlockEnum.DataSource:b.vars=l.default.getOutputVars?.(y,t,p,{schemaTypeDefinitions:c})||[];break;case n.BlockEnum.TriggerPlugin:b.vars=v.getOutputVars?.(y,t,[],{schemaTypeDefinitions:c})||[];break;case n.BlockEnum.HumanInput:b.vars=[...o.default.getOutputVars?.(y,t,[],{schemaTypeDefinitions:c})||[],...i.HUMAN_INPUT_OUTPUT_STRUCT];break;case"env":b.vars=y.envList.map(e=>({variable:`env.${e.name}`,type:e.value_type,description:e.description}));break;case"conversation":b.vars=y.chatVarList.map(e=>({variable:`conversation.${e.name}`,type:e.value_type,description:e.description}));break;case"global":b.vars=y.globalVarList;break;case"rag":b.vars=y.ragVariables.map(e=>({variable:`rag.shared.${e.variable}`,type:U(e.type),des:e.label,isRagVariable:!0}))}let{error_strategy:d}=y;d&&(b.vars=[...b.vars,{variable:"error_message",type:n.VarType.string,isException:!0},{variable:"error_type",type:n.VarType.string,isException:!0}]);let m=[u];return b.vars=b.vars.filter(e=>{if(a(e,(()=>{let r=e.variable.split("."),[a]=r;return w(a)?r:[...m,...r]})()))return!0;let r=e.type===n.VarType.file,t=r?h.map(e=>{let r=i.FILE_STRUCT.find(r=>r.variable===e);return{variable:e,type:r?.type||n.VarType.string}}):e.children;if(!t)return!1;let l=L(r?{...e,children:t}:e,a,m,r);return S(l?.children)}).map(e=>{let r=e.type===n.VarType.file,{children:t}=r?{children:h.map(e=>{let r=i.FILE_STRUCT.find(r=>r.variable===e);return{variable:e,type:r?.type||n.VarType.string}})}:e;return t?L(r?{...e,children:t}:e,a,m,r):e}),b},C=function(e,r){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:(e,r)=>!0,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[],s=arguments.length>6?arguments[6]:void 0,p=arguments.length>7?arguments[7]:void 0,c={id:"global",data:{title:"SYSTEM",type:"global",globalVarList:(0,i.getGlobalVars)(r)}},u={id:"rag",data:{title:"SHARED INPUTS",type:"rag",ragVariables:o.filter(e=>"shared"===e.belong_to_node_id)}};return[...[...e].sort((e,r)=>e.data.type===n.BlockEnum.Start?1:r.data.type===n.BlockEnum.Start?-1:"env"===e.data.type?1:"env"===r.data.type?-1:"conversation"===e.data.type?1:"conversation"===r.data.type?-1:"global"===e.data.type?1:"global"===r.data.type?-1:(r.position?.x||0)-(e.position?.x||0)).filter(e=>i.SUPPORT_OUTPUT_VARS_NODE.includes(e?.data?.type)),...t.length>0?[{id:"env",data:{title:"ENVIRONMENT",type:"env",envList:t}}]:[],...r&&l.length>0?[{id:"conversation",data:{title:"CONVERSATION",type:"conversation",chatVarList:l}}]:[],c,...u.data.ragVariables.length>0?[u]:[]].map(e=>{let t=[];return e.data.type===n.BlockEnum.DataSource&&(t=o.filter(r=>r.belong_to_node_id===e.id)),{...q(e,r,a,s,t.map(r=>({variable:`rag.${e.id}.${r.variable}`,type:U(r.type),description:r.label,isRagVariable:!0})),p),isStartNode:e.data.type===n.BlockEnum.Start}}).filter(e=>e.vars.length>0)},N=e=>{let{valueSelector:r,beforeNodesOutputVars:a}=e,t=r[0],i=E(r),l=O(r),o=i?a.find(e=>e.isStartNode):a.find(e=>e.nodeId===t);if(!o)return n.VarType.string;let s=n.VarType.string,p=o.vars;if(i||l)s=p.find(e=>e.variable===r.join("."))?.type;else for(let e=1;ee.variable===a):[],t?s=p?.type:(p?.type===n.VarType.object||p?.type===n.VarType.file)&&(p=p.children||[])}switch(s){case n.VarType.arrayString:return n.VarType.string;case n.VarType.arrayNumber:return n.VarType.number;case n.VarType.arrayBoolean:return n.VarType.boolean;case n.VarType.arrayObject:return n.VarType.object;case n.VarType.array:return n.VarType.arrayObject;case n.VarType.arrayFile:return n.VarType.file;default:return n.VarType.string}},P=e=>{let{valueSelector:r,beforeNodesOutputVars:a}=e,t=r[0],i=E(r),l=i?a.find(e=>e.isStartNode):a.find(e=>e.nodeId===t);if(!l)return n.VarType.string;let o=n.VarType.string,s=l.vars;switch(i?o=s.find(e=>e.variable===r.join("."))?.type:r.slice(1).forEach((e,a)=>{let t=a===r.length-2;s=s?.find(r=>r.variable===e),t?o=s?.type:(s?.type===n.VarType.object||s?.type===n.VarType.file)&&(s=s.children)}),o){case n.VarType.arrayString:return n.VarType.string;case n.VarType.arrayNumber:return n.VarType.number;case n.VarType.arrayObject:return n.VarType.object;case n.VarType.arrayBoolean:return n.VarType.boolean;case n.VarType.array:return n.VarType.any;case n.VarType.arrayFile:return n.VarType.file;default:return n.VarType.string}},M=e=>{let{parentNode:r,valueSelector:a,isIterationItem:t,isLoopItem:i,availableNodes:l,isChatMode:o,isConstant:s,environmentVariables:p=[],conversationVariables:c=[],ragVariables:u=[],allPluginInfoList:y,schemaTypeDefinitions:b,preferSchemaType:d}=e;if(s)return n.VarType.string;let m=C(l,o,void 0,p,c,u,y,b),T=r?.data.type===n.BlockEnum.Iteration;if(t)return N({valueSelector:a,beforeNodesOutputVars:m});if(T){if("item"===a[1])return N({valueSelector:r?.data?.iterator_selector||[],beforeNodesOutputVars:m});if("index"===a[1])return n.VarType.number}let v=r?.data.type===n.BlockEnum.Loop;if(i)return P({valueSelector:a,beforeNodesOutputVars:m});if(v){if("item"===a[1])return P({valueSelector:r?.data?.iterator_selector||[],beforeNodesOutputVars:m});if("index"===a[1])return n.VarType.number}let f=j(a),_=E(a)&&!f,g=B(a),k=O(a),h=A(a)&&"shared"===a[1],V=A(a)&&"shared"!==a[1],w=l.find(e=>e?.data.type===n.BlockEnum.Start),S=_?w?.id:f?"global":V?a[1]:a[0],U=m.find(e=>e.nodeId===S);if(!U)return n.VarType.string;let I=n.VarType.string,L=U.vars;if(_||g||k||h||f)return L.find(e=>e.variable===a.join("."))?.type;{let e=L.find(e=>V?e.variable===a.join("."):e.variable===a[1]);if(!e)return n.VarType.string;if(V)return e.type;if(e.children?.schema?.properties){if(2===a.length)return d&&e.schemaType?e.schemaType:n.VarType.object;let r=e.children.schema;return a.slice(2).forEach((e,t)=>{let i=t===a.length-3;r&&(r=r.properties[e],i&&(I=R(r?.type)))}),I}return a.slice(1).forEach((e,r)=>{let t=r===a.length-2;Array.isArray(L)&&(L=L?.find(r=>r.variable===e)),t?I=d&&L?.schemaType?L?.schemaType:L?.type:(L?.type===n.VarType.object||L?.type===n.VarType.file)&&(L=L.children)}),I}},x=e=>{if(!e)return[];let a=[];return e.forEach(e=>{f.VAR_REGEX.lastIndex=0,"string"==typeof e&&a.push(...e.match(f.VAR_REGEX)||[])}),(0,r.uniq)(a).map(e=>e.replaceAll("{{#","").replace("#}}","").split("."))},$=(e,r,a)=>e&&"string"==typeof e&&a&&0!==a.length?e.replaceAll(`{{#${r.join(".")}#}}`,`{{#${a.join(".")}#}}`):e,F=e=>{let{data:r}=e,{type:a}=r,t=[];switch(a){case n.BlockEnum.End:t=r.outputs?.map(e=>e.value_selector);break;case n.BlockEnum.Answer:t=x([r.answer]);break;case n.BlockEnum.LLM:{let e=r.model?.mode===_.AppModeEnum.CHAT,a=[];e?(a=r.prompt_template?.map(e=>e.text)||[],r.memory?.query_prompt_template&&a.push(r.memory.query_prompt_template)):a=[r.prompt_template.text],t=[...x(a),...r.context?.variable_selector?[r.context?.variable_selector]:[]];break}case n.BlockEnum.KnowledgeRetrieval:{let{query_variable_selector:e,query_attachment_selector:a=[]}=r;t=[e,a];break}case n.BlockEnum.IfElse:(t=[]).push(...(r.cases||[]).flatMap(e=>e.conditions||[]).flatMap(e=>{let r=[];return e.variable_selector&&r.push(e.variable_selector),e.sub_variable_condition&&e.sub_variable_condition.conditions&&r.push(...e.sub_variable_condition.conditions.map(e=>e.variable_selector||[]).filter(e=>e.length>0)),r}));break;case n.BlockEnum.Code:t=r.variables?.map(e=>e.value_selector);break;case n.BlockEnum.TemplateTransform:t=r.variables?.map(e=>e.value_selector);break;case n.BlockEnum.QuestionClassifier:{t=[r.query_variable_selector];let e=x([r.instruction||""]);t.push(...e);let a=r.classes.map(e=>e.name);t.push(...x(a));break}case n.BlockEnum.HttpRequest:t=x([r.url,r.headers,r.params,"string"==typeof r.body.data?r.body.data:r.body.data.map(e=>e.value).join("")]);break;case n.BlockEnum.Tool:t=[...x(Object.keys(r.tool_parameters)?.filter(e=>r.tool_parameters[e].type===V.VarType.mixed).map(e=>r.tool_parameters[e].value)),...Object.keys(r.tool_parameters).filter(e=>r.tool_parameters[e].type===V.VarType.variable).map(e=>r.tool_parameters[e].value)||[]];break;case n.BlockEnum.DataSource:t=[...x(Object.keys(r.datasource_parameters)?.filter(e=>r.datasource_parameters[e].type===V.VarType.mixed).map(e=>r.datasource_parameters[e].value)),...Object.keys(r.datasource_parameters).filter(e=>r.datasource_parameters[e].type===V.VarType.variable).map(e=>r.datasource_parameters[e].value)||[]];break;case n.BlockEnum.VariableAssigner:case n.BlockEnum.VariableAggregator:t=r?.variables;break;case n.BlockEnum.ParameterExtractor:{t=[r.query];let e=x([r.instruction||""]);t.push(...e);break}case n.BlockEnum.Iteration:t=[r.iterator_selector];break;case n.BlockEnum.Loop:t=r.break_conditions?.map(e=>e.variable_selector||[])||[];break;case n.BlockEnum.ListFilter:t=[r.variable];break;case n.BlockEnum.Agent:{let e=[];if(!r.agent_parameters)break;Object.keys(r.agent_parameters||{}).forEach(a=>{let{value:t}=r.agent_parameters[a];"string"==typeof t&&e.push(...x([t]))}),t=e;break}case n.BlockEnum.HumanInput:t=x([r.form_content])}return t||[]},D=(e,r,a)=>{if(!e.variable)return;a.push([...r,e.variable]);let t=!!e.children?.schema?.properties;e.children?.length>0&&e.children.forEach(t=>{D(t,[...r,e.variable],a)}),t&&Object.keys(e.children?.schema?.properties||{}).forEach(t=>{let i=e.children?.schema?.properties[t].type,l=i===u.Type.array,o=e.children?.schema?.properties[t].items?.type;D({variable:t,type:R(l?o:i,l)},[...r,e.variable],a)})},H=(e,r,a)=>{Array.isArray(e)&&e.forEach(e=>{D(e,r,a)}),D(e,r,a)};e.s(["findUsedVarNodes",0,(e,r)=>{let a=[];return r.forEach(r=>{F(r).find(r=>r.join(".")===e.join("."))&&a.push(r)}),a},"getNodeInfoById",0,(e,r)=>{if((0,a.isArray)(e))return e.find(e=>e.id===r)},"getNodeOutputVars",0,(e,r)=>{let{data:a,id:t}=e,{type:l}=a,o=[];switch(l){case n.BlockEnum.Start:{let{variables:e}=a;o=e.map(e=>[t,e.variable]),r&&(o.push([t,"sys","query"]),o.push([t,"sys","files"]));break}case n.BlockEnum.LLM:{let e=[...i.LLM_OUTPUT_STRUCT];a.structured_output_enabled&&a.structured_output?.schema?.properties&&Object.keys(a.structured_output.schema.properties).length>0&&e.push({variable:"structured_output",type:n.VarType.object,children:a.structured_output}),H(e,[t],o);break}case n.BlockEnum.KnowledgeRetrieval:H(i.KNOWLEDGE_RETRIEVAL_OUTPUT_STRUCT,[t],o);break;case n.BlockEnum.Code:{let{outputs:e}=a;Object.keys(e).forEach(e=>{o.push([t,e])});break}case n.BlockEnum.TemplateTransform:H(i.TEMPLATE_TRANSFORM_OUTPUT_STRUCT,[t],o);break;case n.BlockEnum.QuestionClassifier:H(i.QUESTION_CLASSIFIER_OUTPUT_STRUCT,[t],o);break;case n.BlockEnum.HttpRequest:H(i.HTTP_REQUEST_OUTPUT_STRUCT,[t],o);break;case n.BlockEnum.VariableAssigner:case n.BlockEnum.VariableAggregator:o.push([t,"output"]);break;case n.BlockEnum.Tool:H(i.TOOL_OUTPUT_STRUCT,[t],o);break;case n.BlockEnum.ParameterExtractor:{let{parameters:e}=a;e?.length>0&&e.forEach(e=>{o.push([t,e.name])});break}case n.BlockEnum.Iteration:case n.BlockEnum.Loop:o.push([t,"output"]);break;case n.BlockEnum.DocExtractor:o.push([t,"text"]);break;case n.BlockEnum.ListFilter:o.push([t,"result"]),o.push([t,"first_record"]),o.push([t,"last_record"])}return o},"getNodeUsedVarPassToServerKey",0,(e,r)=>{let{data:a}=e,{type:t}=a,i="";switch(t){case n.BlockEnum.LLM:i=[`#${r.join(".")}#`],a.context?.variable_selector.join(".")===r.join(".")&&i.push("#context#");break;case n.BlockEnum.KnowledgeRetrieval:i="query";break;case n.BlockEnum.IfElse:{let e=a=>{for(let t of a)for(let a of t.conditions||[]){if(a.variable_selector?.join(".")===r.join("."))return a;if(a.sub_variable_condition){let r=e([a.sub_variable_condition]);if(r)return r}}};e(a.cases||[])&&(i=`#${r.join(".")}#`);break}case n.BlockEnum.Code:{let e=a.variables?.find(e=>Array.isArray(e.value_selector)&&e.value_selector&&e.value_selector.join(".")===r.join("."));e&&(i=e.variable);break}case n.BlockEnum.TemplateTransform:{let e=a.variables?.find(e=>Array.isArray(e.value_selector)&&e.value_selector&&e.value_selector.join(".")===r.join("."));e&&(i=e.variable);break}case n.BlockEnum.QuestionClassifier:i="query";break;case n.BlockEnum.HttpRequest:case n.BlockEnum.Tool:case n.BlockEnum.VariableAssigner:case n.BlockEnum.VariableAggregator:i=`#${r.join(".")}#`;break;case n.BlockEnum.ParameterExtractor:i="query";break;case n.BlockEnum.HumanInput:i=`#${r.join(".")}#`}return i},"getNodeUsedVars",0,F,"getVarType",0,M,"inputVarTypeToVarType",0,U,"isConversationVar",0,O,"isENV",0,B,"isGlobalVar",0,j,"isRagVariableVar",0,A,"isSpecialVar",0,w,"isSystemVar",0,E,"removeFileVars",0,e=>e.map(e=>({...e,vars:e.vars.filter(e=>e.type!==n.VarType.file&&e.type!==n.VarType.arrayFile)})).filter(e=>e.vars.length>0),"toNodeAvailableVars",0,e=>{let{parentNode:r,t:a,beforeNodes:t,isChatMode:i,environmentVariables:l,conversationVariables:o,ragVariables:s,filterVar:p,allPluginInfoList:c,schemaTypeDefinitions:u}=e,y=C(t,i,p,l,o,s,c,u);if(r?.data.type===n.BlockEnum.Iteration){let e=M({parentNode:r,isIterationItem:!0,valueSelector:r?.data.iterator_selector||[],availableNodes:t,isChatMode:i,environmentVariables:l,conversationVariables:o,allPluginInfoList:c,schemaTypeDefinitions:u}),s=e===n.VarType.file?{children:h.map(e=>({variable:e,type:"size"===e?n.VarType.number:n.VarType.string}))}:{},p={nodeId:r?.id,title:a("nodes.iteration.currentIteration",{ns:"workflow"}),vars:[{variable:"item",type:e,...s},{variable:"index",type:n.VarType.number}]},b=y.findIndex(e=>e.nodeId===r?.id);b>-1&&y.splice(b,1),y.unshift(p)}return y},"toNodeOutputVars",0,C,"updateNodeVars",0,(e,r,a)=>(0,t.produce)(e,e=>{let{data:t}=e,{type:i}=t;switch(i){case n.BlockEnum.End:t.outputs&&(t.outputs=t.outputs.map(e=>(e.value_selector.join(".")===r.join(".")&&(e.value_selector=a),e)));break;case n.BlockEnum.Answer:t.variables&&(t.variables=t.variables.map(e=>(e.value_selector.join(".")===r.join(".")&&(e.value_selector=a),e)));break;case n.BlockEnum.LLM:t.model?.mode===_.AppModeEnum.CHAT?(t.prompt_template=t.prompt_template.map(e=>({...e,text:$(e.text,r,a)})),t.memory?.query_prompt_template&&(t.memory.query_prompt_template=$(t.memory.query_prompt_template,r,a))):t.prompt_template={...t.prompt_template,text:$(t.prompt_template.text,r,a)},t.context?.variable_selector?.join(".")===r.join(".")&&(t.context.variable_selector=a);break;case n.BlockEnum.KnowledgeRetrieval:t.query_variable_selector.join(".")===r.join(".")&&(t.query_variable_selector=a),t.query_attachment_selector?.join(".")===r.join(".")&&(t.query_attachment_selector=a);break;case n.BlockEnum.IfElse:t.cases&&(t.cases=t.cases.map(e=>(e.conditions&&(e.conditions=e.conditions.map(e=>(e.variable_selector?.join(".")===r.join(".")&&(e.variable_selector=a),e.sub_variable_condition&&e.sub_variable_condition.conditions&&(e.sub_variable_condition.conditions=e.sub_variable_condition.conditions.map(e=>(e.variable_selector?.join(".")===r.join(".")&&(e.variable_selector=a),e))),e))),e)));break;case n.BlockEnum.Code:t.variables&&(t.variables=t.variables.map(e=>(e.value_selector.join(".")===r.join(".")&&(e.value_selector=a),e)));break;case n.BlockEnum.TemplateTransform:t.variables&&(t.variables=t.variables.map(e=>(e.value_selector.join(".")===r.join(".")&&(e.value_selector=a),e)));break;case n.BlockEnum.QuestionClassifier:t.query_variable_selector.join(".")===r.join(".")&&(t.query_variable_selector=a),t.instruction=$(t.instruction,r,a);break;case n.BlockEnum.HttpRequest:t.url=$(t.url,r,a),t.headers=$(t.headers,r,a),t.params=$(t.params,r,a),"string"==typeof t.body.data?t.body.data=$(t.body.data,r,a):t.body.data=t.body.data.map(e=>({...e,value:$(e.value||"",r,a)}));break;case n.BlockEnum.Tool:Object.keys(t.tool_parameters)?.filter(e=>t.tool_parameters[e].type!==V.VarType.constant)&&Object.keys(t.tool_parameters).forEach(e=>{let i=t.tool_parameters[e],{type:l}=i;l===V.VarType.variable&&i.value.join(".")===r.join(".")&&(t.tool_parameters[e]={...i,value:a}),l===V.VarType.mixed&&(t.tool_parameters[e]={...i,value:$(t.tool_parameters[e].value,r,a)})});break;case n.BlockEnum.DataSource:Object.keys(t.datasource_parameters)?.filter(e=>t.datasource_parameters[e].type!==V.VarType.constant)&&Object.keys(t.datasource_parameters).forEach(e=>{let i=t.datasource_parameters[e],{type:l}=i;l===V.VarType.variable&&i.value.join(".")===r.join(".")&&(t.datasource_parameters[e]={...i,value:a}),l===V.VarType.mixed&&(t.datasource_parameters[e]={...i,value:$(t.datasource_parameters[e].value,r,a)})});break;case n.BlockEnum.VariableAssigner:t.variables&&(t.variables=t.variables.map(e=>(e.join(".")===r.join(".")&&(e=a),e)));break;case n.BlockEnum.VariableAggregator:t.variables&&(t.variables=t.variables.map(e=>(e.join(".")===r.join(".")&&(e=a),e)));break;case n.BlockEnum.ParameterExtractor:t.query.join(".")===r.join(".")&&(t.query=a),t.instruction=$(t.instruction,r,a);break;case n.BlockEnum.Iteration:t.iterator_selector.join(".")===r.join(".")&&(t.iterator_selector=a);break;case n.BlockEnum.Loop:t.break_conditions&&(t.break_conditions=t.break_conditions.map(e=>(e.variable_selector?.join(".")===r.join(".")&&(e.variable_selector=a),e)));break;case n.BlockEnum.ListFilter:t.variable.join(".")===r.join(".")&&(t.variable=a);break;case n.BlockEnum.HumanInput:t.form_content=$(t.form_content,r,a)}}),"varTypeToStructType",0,e=>({[n.VarType.string]:u.Type.string,[n.VarType.number]:u.Type.number,[n.VarType.boolean]:u.Type.boolean,[n.VarType.object]:u.Type.object,[n.VarType.array]:u.Type.array,[n.VarType.arrayString]:u.Type.array,[n.VarType.arrayNumber]:u.Type.array,[n.VarType.arrayObject]:u.Type.array,[n.VarType.arrayFile]:u.Type.array})[e]||u.Type.string],963855)},534042,141167,e=>{"use strict";var r,a=((r={}).blue="blue",r.cyan="cyan",r.green="green",r.yellow="yellow",r.pink="pink",r.violet="violet",r);e.s(["NoteTheme",()=>a],141167);let t={[a.blue]:{outer:"border-util-colors-blue-blue-500",title:"bg-util-colors-blue-blue-100",bg:"bg-util-colors-blue-blue-50",border:"border-util-colors-blue-blue-300"},[a.cyan]:{outer:"border-util-colors-cyan-cyan-500",title:"bg-util-colors-cyan-cyan-100",bg:"bg-util-colors-cyan-cyan-50",border:"border-util-colors-cyan-cyan-300"},[a.green]:{outer:"border-util-colors-green-green-500",title:"bg-util-colors-green-green-100",bg:"bg-util-colors-green-green-50",border:"border-util-colors-green-green-300"},[a.yellow]:{outer:"border-util-colors-yellow-yellow-500",title:"bg-util-colors-yellow-yellow-100",bg:"bg-util-colors-yellow-yellow-50",border:"border-util-colors-yellow-yellow-300"},[a.pink]:{outer:"border-util-colors-pink-pink-500",title:"bg-util-colors-pink-pink-100",bg:"bg-util-colors-pink-pink-50",border:"border-util-colors-pink-pink-300"},[a.violet]:{outer:"border-util-colors-violet-violet-500",title:"bg-util-colors-violet-violet-100",bg:"bg-util-colors-violet-violet-100",border:"border-util-colors-violet-violet-300"}};e.s(["CUSTOM_NOTE_NODE",0,"custom-note","THEME_MAP",0,t],534042)}]);