(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,445924,e=>{"use strict";var t,o=e.i(162115),s=e.i(942347),a=e.i(13117),l=e.i(841501),r=e.i(818719),n=e.i(550907),i=e.i(959752),d=e.i(490525),c=e.i(786191),p=e.i(4520),m=e.i(534042),u=e.i(794611),x=e.i(322034),h=e.i(935139),f=e.i(174383),g=e.i(381086),b=e.i(390622);e.i(905691);var v=e.i(735900);let _=(0,s.memo)(e=>{let{id:t,data:a,sourceHandleId:r,sourceX:n,sourceY:i,targetX:d,targetY:c,selected:p}=e,[m]=(0,l.getBezierPath)({sourceX:n-8,sourceY:i,sourcePosition:l.Position.Right,targetX:d+8,targetY:c,targetPosition:l.Position.Left,curvature:.16}),{_sourceRunningStatus:u,_targetRunningStatus:x}=a,h=(0,s.useMemo)(()=>{if((u===b.NodeRunningStatus.Succeeded||u===b.NodeRunningStatus.Failed||u===b.NodeRunningStatus.Exception)&&(x===b.NodeRunningStatus.Succeeded||x===b.NodeRunningStatus.Failed||x===b.NodeRunningStatus.Exception||x===b.NodeRunningStatus.Running))return t},[u,x,t]),_=(0,s.useMemo)(()=>p?(0,v.getEdgeColor)(b.NodeRunningStatus.Running):h?`url(#${h})`:a?._connectedNodeIsHovering?(0,v.getEdgeColor)(b.NodeRunningStatus.Running,r===g.ErrorHandleTypeEnum.failBranch):(0,v.getEdgeColor)(),[a._connectedNodeIsHovering,h,p,r]);return(0,o.jsxs)(o.Fragment,{children:[h&&(0,o.jsx)(f.default,{id:h,startColor:(0,v.getEdgeColor)(u),stopColor:(0,v.getEdgeColor)(x),position:{x1:n,y1:i,x2:d,y2:c}}),(0,o.jsx)(l.BaseEdge,{id:t,path:m,style:{stroke:_,strokeWidth:2,opacity:a._waitingRun?.7:1}})]})});e.i(816688);var w=e.i(675066),y=e.i(421001),j=e.i(120219),N=e.i(911684);let k=(0,s.memo)(e=>{let{data:t,handleId:s,handleClassName:a}=e,r=t._connectedTargetHandleIds?.includes(s);return(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(l.Handle,{id:s,type:"target",position:l.Position.Left,className:(0,h.cn)("z-[1] !h-4 !w-4 !rounded-none !border-none !bg-transparent !outline-none","after:absolute after:left-1.5 after:top-1 after:h-2 after:w-0.5 after:bg-workflow-link-line-handle","transition-all hover:scale-125",!r&&"after:opacity-0",(t.type===b.BlockEnum.Start||t.type===b.BlockEnum.TriggerWebhook||t.type===b.BlockEnum.TriggerSchedule||t.type===b.BlockEnum.TriggerPlugin)&&"opacity-0",a)})})});k.displayName="NodeTargetHandle";let T=(0,s.memo)(e=>{let{data:t,handleId:s,handleClassName:a}=e,r=t._connectedSourceHandleIds?.includes(s);return(0,o.jsx)(l.Handle,{id:s,type:"source",position:l.Position.Right,className:(0,h.cn)("group/handle z-[1] !h-4 !w-4 !rounded-none !border-none !bg-transparent !outline-none","after:absolute after:right-1.5 after:top-1 after:h-2 after:w-0.5 after:bg-workflow-link-line-handle","transition-all hover:scale-125",!r&&"after:opacity-0",a)})});T.displayName="NodeSourceHandle";let C=e=>{let{id:t,data:a}=e,{t:r}=(0,w.useTranslation)(),{error_strategy:n}=a,i=(0,l.useUpdateNodeInternals)();return((0,s.useEffect)(()=>{n===g.ErrorHandleTypeEnum.failBranch&&i(t)},[n,t,i]),n)?(0,o.jsx)("div",{className:"relative px-3 pb-2 pt-1",children:(0,o.jsxs)("div",{className:(0,h.cn)("relative flex h-6 items-center justify-between rounded-md bg-workflow-block-parma-bg px-[5px]",a._runningStatus===b.NodeRunningStatus.Exception&&"border-[0.5px] border-components-badge-status-light-warning-halo bg-state-warning-hover"),children:[(0,o.jsx)("div",{className:"system-xs-medium-uppercase text-text-tertiary",children:r("common.onFailure",{ns:"workflow"})}),(0,o.jsxs)("div",{className:(0,h.cn)("system-xs-medium text-text-secondary",a._runningStatus===b.NodeRunningStatus.Exception&&"text-text-warning"),children:[n===g.ErrorHandleTypeEnum.defaultValue&&r("nodes.common.errorHandle.defaultValue.output",{ns:"workflow"}),n===g.ErrorHandleTypeEnum.failBranch&&r("nodes.common.errorHandle.failBranch.title",{ns:"workflow"})]}),n===g.ErrorHandleTypeEnum.failBranch&&(0,o.jsx)(T,{id:t,data:a,handleId:g.ErrorHandleTypeEnum.failBranch,handleClassName:"!top-1/2 !-right-[21px] !-translate-y-1/2 after:!bg-workflow-link-line-failure-button-bg"})]})}):null},E=(0,s.memo)(e=>{let{id:t,data:a,children:l}=e,{t:r}=(0,w.useTranslation)();return(0,o.jsx)("div",{className:(0,h.cn)("flex rounded-2xl border-[2px] border-transparent"),style:{width:a.type===b.BlockEnum.Iteration||a.type===b.BlockEnum.Loop?a.width:"auto",height:a.type===b.BlockEnum.Iteration||a.type===b.BlockEnum.Loop?a.height:"auto"},children:(0,o.jsxs)("div",{className:(0,h.cn)("group relative pb-1 shadow-xs","rounded-[15px] border border-transparent","bg-workflow-block-bg hover:shadow-lg"),style:{width:a.type===b.BlockEnum.Iteration||a.type===b.BlockEnum.Loop?a.width:"240px",height:a.type===b.BlockEnum.Iteration||a.type===b.BlockEnum.Loop?a.height:"auto"},children:[(0,o.jsxs)("div",{className:(0,h.cn)("flex items-center rounded-t-2xl px-3 pb-2 pt-3"),children:[(0,o.jsx)(k,{id:t,data:a,handleClassName:"!top-4 !-left-[9px] !translate-y-0",handleId:"target"}),a.type!==b.BlockEnum.IfElse&&a.type!==b.BlockEnum.QuestionClassifier&&a.type!==b.BlockEnum.HumanInput&&(0,o.jsx)(T,{id:t,data:a,handleClassName:"!top-4 !-right-[9px] !translate-y-0",handleId:"source"}),(0,o.jsx)(j.default,{className:"mr-2 shrink-0",type:a.type,size:"md"}),(0,o.jsxs)("div",{title:a.title,className:"system-sm-semibold-uppercase mr-1 flex grow items-center truncate text-text-primary",children:[(0,o.jsx)("div",{children:a.title}),a.type===b.BlockEnum.Iteration&&a.is_parallel&&(0,o.jsx)(y.default,{popupContent:(0,o.jsxs)("div",{className:"w-[180px]",children:[(0,o.jsx)("div",{className:"font-extrabold",children:r("nodes.iteration.parallelModeEnableTitle",{ns:"workflow"})}),r("nodes.iteration.parallelModeEnableDesc",{ns:"workflow"})]}),children:(0,o.jsx)("div",{className:"system-2xs-medium-uppercase ml-1 flex items-center justify-center rounded-[5px] border-[1px] border-text-warning px-[5px] py-[3px] text-text-warning ",children:r("nodes.iteration.parallelModeUpper",{ns:"workflow"})})})]})]}),a.type!==b.BlockEnum.Iteration&&a.type!==b.BlockEnum.Loop&&l&&(0,s.cloneElement)(l,{id:t,data:a}),(a.type===b.BlockEnum.Iteration||a.type===b.BlockEnum.Loop)&&l&&(0,o.jsx)("div",{className:"h-[calc(100%-42px)] w-full grow pb-1 pl-1 pr-1",children:(0,s.cloneElement)(l,{id:t,data:a})}),(0,N.hasErrorHandleNode)(a.type)&&(0,o.jsx)(C,{id:t,data:a}),a.desc&&a.type!==b.BlockEnum.Iteration&&a.type!==b.BlockEnum.Loop&&(0,o.jsx)("div",{className:"system-xs-regular whitespace-pre-line break-words px-3 pb-2 pt-1 text-text-tertiary",children:a.desc})]})})});var S=e.i(555503),I=e.i(166211),A=e.i(146106);let P="nodes.ifElse",L=s.memo(e=>{let{data:t}=e,{t:a}=(0,w.useTranslation)(),{cases:l}=t,r=l.length,n=(0,s.useCallback)(e=>!!e.variable_selector&&0!==e.variable_selector.length&&(e.sub_variable_condition?e.sub_variable_condition.conditions.every(e=>!!e.comparison_operator&&(!!(0,A.isEmptyRelatedOperator)(e.comparison_operator)||!!e.value)):!!(0,A.isEmptyRelatedOperator)(e.comparison_operator)||!!e.value),[]),i=(0,o.jsx)("div",{className:"flex h-6 items-center space-x-1 rounded-md bg-workflow-block-parma-bg px-1 text-xs font-normal text-text-secondary",children:a(`${P}.conditionNotSetup`,{ns:"workflow"})});return(0,o.jsxs)("div",{className:"px-3",children:[l.map((t,s)=>(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"relative flex h-6 items-center px-1",children:[(0,o.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,o.jsx)("div",{className:"text-[10px] font-semibold text-text-tertiary",children:r>1&&`CASE ${s+1}`}),(0,o.jsx)("div",{className:"text-[12px] font-semibold text-text-secondary",children:0===s?"IF":"ELIF"})]}),(0,o.jsx)(T,{...e,handleId:t.case_id,handleClassName:"!top-1/2 !-right-[21px] !-translate-y-1/2"})]}),(0,o.jsx)("div",{className:"space-y-0.5",children:t.conditions.map((e,s)=>(0,o.jsxs)("div",{className:"relative",children:[n(e)?!(0,A.isEmptyRelatedOperator)(e.comparison_operator)&&e.sub_variable_condition?(0,o.jsx)(S.default,{condition:e}):(0,o.jsx)(I.default,{variableSelector:e.variable_selector,operator:e.comparison_operator,value:e.value}):i,s!==t.conditions.length-1&&(0,o.jsx)("div",{className:"absolute bottom-[-10px] right-1 z-10 text-[10px] font-medium uppercase leading-4 text-text-accent",children:a(`${P}.${t.logical_operator}`,{ns:"workflow"})})]},e.id))})]},t.case_id)),(0,o.jsxs)("div",{className:"relative flex h-6 items-center px-1",children:[(0,o.jsx)("div",{className:"w-full text-right text-xs font-semibold text-text-secondary",children:"ELSE"}),(0,o.jsx)(T,{...e,handleId:"false",handleClassName:"!top-1/2 !-right-[21px] !-translate-y-1/2"})]})]})}),D=(0,s.memo)(e=>{let{id:t}=e,{zoom:s}=(0,l.useViewport)();return(0,o.jsx)("div",{className:(0,h.cn)("relative h-full min-h-[90px] w-full min-w-[240px] rounded-2xl bg-workflow-canvas-workflow-bg"),children:(0,o.jsx)(r.Background,{id:`iteration-background-${t}`,className:"!z-0 rounded-2xl",gap:[14/s,14/s],size:2/s,color:"var(--color-workflow-canvas-workflow-dot-color)"})})});var M=e.i(805735);let R=(0,s.memo)(e=>{let t,{id:a,data:n}=e,{zoom:d}=(0,l.useViewport)(),c=(0,l.useNodesInitialized)(),{handleNodeLoopRerender:p}=(t=(0,l.useStoreApi)(),{handleNodeLoopRerender:(0,s.useCallback)(e=>{let o,s,{getNodes:a,setNodes:l}=t.getState(),r=a(),n=r.find(t=>t.id===e);r.filter(t=>t.parentId===e).forEach(e=>{o?e.position.x+e.width>o.position.x+o.width&&(o=e):o=e,s?e.position.y+e.height>s.position.y+s.height&&(s=e):s=e});let d=o&&n.width{t.forEach(t=>{t.id===e&&(d&&(t.data.width=o.position.x+o.width+i.LOOP_PADDING.right,t.width=o.position.x+o.width+i.LOOP_PADDING.right),c&&(t.data.height=s.position.y+s.height+i.LOOP_PADDING.bottom,t.height=s.position.y+s.height+i.LOOP_PADDING.bottom))})}))},[t])});return(0,s.useEffect)(()=>{c&&p(a)},[c,a,p]),(0,o.jsx)("div",{className:(0,h.cn)("relative h-full min-h-[90px] w-full min-w-[240px] rounded-2xl bg-workflow-canvas-workflow-bg"),children:(0,o.jsx)(r.Background,{id:`loop-background-${a}`,className:"!z-0 rounded-2xl",gap:[14/d,14/d],size:2/d,color:"var(--color-workflow-canvas-workflow-dot-color)"})})});var z=e.i(617178);let F=s.memo(e=>{let{t}=(0,w.useTranslation)(),{data:s}=e,a=s.classes;return(0,o.jsx)("div",{className:"mb-1 px-3 py-1",children:!!a.length&&(0,o.jsx)("div",{className:"mt-2 space-y-0.5",children:a.map((s,a)=>(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(z.default,{title:`${t("nodes.questionClassifiers.class",{ns:"workflow"})} ${a+1}`,content:""}),(0,o.jsx)(T,{...e,handleId:s.id,handleClassName:"!top-1/2 !-translate-y-1/2 !-right-[21px]"})]},a))})})}),O={[b.BlockEnum.QuestionClassifier]:F,[b.BlockEnum.IfElse]:L,[b.BlockEnum.Iteration]:D,[b.BlockEnum.Loop]:R},B=e=>{let t=O[e.data.type];return(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(E,{...e,children:t&&(0,o.jsx)(t,{})})})};var U=e.i(869931);let H=(0,s.memo)(e=>{let{id:t,data:s}=e,{t:a}=(0,w.useTranslation)();return(0,o.jsxs)("div",{className:"nodrag group mt-1 flex h-11 w-11 items-center justify-center rounded-2xl border border-workflow-block-border bg-workflow-block-bg shadow-xs",children:[(0,o.jsx)(y.default,{popupContent:a("blocks.iteration-start",{ns:"workflow"}),asChild:!1,children:(0,o.jsx)("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border-[0.5px] border-components-panel-border-subtle bg-util-colors-blue-brand-blue-brand-500",children:(0,o.jsx)(U.RiHome5Fill,{className:"h-3 w-3 text-text-primary-on-surface"})})}),(0,o.jsx)(T,{id:t,data:s,handleClassName:"!top-1/2 !-right-[9px] !-translate-y-1/2",handleId:"source"})]})}),G=(0,s.memo)(e=>{let{id:t,data:s}=e,{t:a}=(0,w.useTranslation)();return(0,o.jsxs)("div",{className:"nodrag group mt-1 flex h-11 w-11 items-center justify-center rounded-2xl border border-workflow-block-border bg-workflow-block-bg",children:[(0,o.jsx)(y.default,{popupContent:a("blocks.loop-start",{ns:"workflow"}),asChild:!1,children:(0,o.jsx)("div",{className:"flex h-6 w-6 items-center justify-center rounded-full border-[0.5px] border-components-panel-border-subtle bg-util-colors-blue-brand-blue-brand-500",children:(0,o.jsx)(U.RiHome5Fill,{className:"h-3 w-3 text-text-primary-on-surface"})})}),(0,o.jsx)(T,{id:t,data:s,handleClassName:"!top-1/2 !-right-[9px] !-translate-y-1/2",handleId:"source"})]})});e.i(444462);var q=e.i(212838),$=e.i(378675);let V=(0,s.memo)(e=>{let{data:t}=e,{t:a}=(0,w.useTranslation)(),l=(0,s.useRef)(null),r=t.theme;return(0,o.jsx)("div",{className:(0,h.cn)("relative flex flex-col rounded-md border shadow-xs hover:shadow-md",m.THEME_MAP[r].bg,t.selected?m.THEME_MAP[r].border:"border-black/5"),style:{width:t.width,height:t.height},ref:l,children:(0,o.jsx)($.NoteEditorContextProvider,{value:t.text,editable:!1,children:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:(0,h.cn)("h-2 shrink-0 rounded-t-md opacity-50",m.THEME_MAP[r].title)}),(0,o.jsx)("div",{className:"grow overflow-y-auto px-3 py-2.5",children:(0,o.jsx)("div",{className:(0,h.cn)(t.selected&&"nodrag nopan nowheel cursor-text"),children:(0,o.jsx)(q.NoteEditor,{containerElement:l.current,placeholder:a("nodes.note.editor.placeholder",{ns:"workflow"})||""})})}),t.showAuthor&&(0,o.jsx)("div",{className:"p-3 pt-0 text-xs text-text-tertiary",children:t.author})]})})})});var W=e.i(757198),K=e.i(391185),X=e.i(175179),Q=e.i(194902),Y=((t=Y||{}).zoomIn="zoomIn",t.zoomOut="zoomOut",t.zoomToFit="zoomToFit",t.zoomTo25="zoomTo25",t.zoomTo50="zoomTo50",t.zoomTo75="zoomTo75",t.zoomTo100="zoomTo100",t.zoomTo200="zoomTo200",t);let Z=(0,s.memo)(()=>{let{t:e}=(0,w.useTranslation)(),{zoomIn:t,zoomOut:a,zoomTo:r,fitView:n}=(0,l.useReactFlow)(),{zoom:i}=(0,l.useViewport)(),[d,c]=(0,s.useState)(!1),p=[[{key:"zoomTo200",text:"200%"},{key:"zoomTo100",text:"100%"},{key:"zoomTo75",text:"75%"},{key:"zoomTo50",text:"50%"},{key:"zoomTo25",text:"25%"}],[{key:"zoomToFit",text:e("operator.zoomToFit",{ns:"workflow"})}]],m=(0,s.useCallback)(()=>{c(e=>!e)},[]);return(0,o.jsxs)(K.PortalToFollowElem,{placement:"top-start",open:d,onOpenChange:c,offset:{mainAxis:4,crossAxis:-2},children:[(0,o.jsx)(K.PortalToFollowElemTrigger,{asChild:!0,children:(0,o.jsx)("div",{className:(0,h.cn)("h-9 cursor-pointer rounded-lg border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg","p-0.5 text-[13px] shadow-lg backdrop-blur-[5px]","hover:bg-state-base-hover"),children:(0,o.jsxs)("div",{className:(0,h.cn)("flex h-8 w-[98px] items-center justify-between rounded-lg"),children:[(0,o.jsx)(X.default,{title:e("operator.zoomOut",{ns:"workflow"}),shortcuts:["ctrl","-"],children:(0,o.jsx)("div",{className:`flex h-8 w-8 items-center justify-center rounded-lg ${i<=.25?"cursor-not-allowed":"cursor-pointer hover:bg-black/5"}`,onClick:e=>{i<=.25||(e.stopPropagation(),a())},children:(0,o.jsx)(U.RiZoomOutLine,{className:"h-4 w-4 text-text-tertiary hover:text-text-secondary"})})}),(0,o.jsxs)("div",{onClick:m,className:(0,h.cn)("system-sm-medium w-[34px] text-text-tertiary hover:text-text-secondary"),children:[Number.parseFloat(`${100*i}`).toFixed(0),"%"]}),(0,o.jsx)(X.default,{title:e("operator.zoomIn",{ns:"workflow"}),shortcuts:["ctrl","+"],children:(0,o.jsx)("div",{className:`flex h-8 w-8 items-center justify-center rounded-lg ${i>=2?"cursor-not-allowed":"cursor-pointer hover:bg-black/5"}`,onClick:e=>{i>=2||(e.stopPropagation(),t())},children:(0,o.jsx)(U.RiZoomInLine,{className:"h-4 w-4 text-text-tertiary hover:text-text-secondary"})})})]})})}),(0,o.jsx)(K.PortalToFollowElemContent,{className:"z-10",children:(0,o.jsx)("div",{className:"w-[145px] rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-[5px]",children:p.map((e,t)=>(0,o.jsxs)(s.Fragment,{children:[0!==t&&(0,o.jsx)(W.default,{className:"m-0"}),(0,o.jsx)("div",{className:"p-1",children:e.map(e=>(0,o.jsxs)("div",{className:"system-md-regular flex h-8 cursor-pointer items-center justify-between space-x-1 rounded-lg py-1.5 pl-3 pr-2 text-text-secondary hover:bg-state-base-hover",onClick:()=>{var t;"zoomToFit"===(t=e.key)&&n(),"zoomTo25"===t&&r(.25),"zoomTo50"===t&&r(.5),"zoomTo75"===t&&r(.75),"zoomTo100"===t&&r(1),"zoomTo200"===t&&r(2)},children:[(0,o.jsx)("span",{children:e.text}),(0,o.jsxs)("div",{className:"flex items-center space-x-0.5",children:["zoomToFit"===e.key&&(0,o.jsx)(Q.default,{keys:["ctrl","1"]}),"zoomTo50"===e.key&&(0,o.jsx)(Q.default,{keys:["shift","5"]}),"zoomTo100"===e.key&&(0,o.jsx)(Q.default,{keys:["shift","1"]})]})]},e.key))})]},t))})})]})}),J={[i.CUSTOM_NODE]:B,[m.CUSTOM_NOTE_NODE]:V,[u.CUSTOM_SIMPLE_NODE]:B,[c.CUSTOM_ITERATION_START_NODE]:H,[p.CUSTOM_LOOP_START_NODE]:G},ee={[i.CUSTOM_EDGE]:_},et=e=>{let{nodes:t,edges:c,viewport:p,className:m,miniMapToRight:u}=e,[f,g]=(0,s.useState)(()=>(0,x.initialNodes)(t,c)),[b,v]=(0,s.useState)(()=>(0,x.initialEdges)(c,t)),_=(0,s.useCallback)(e=>g(t=>(0,l.applyNodeChanges)(e,t)),[]),w=(0,s.useCallback)(e=>v(t=>(0,l.applyEdgeChanges)(e,t)),[]);return(0,o.jsxs)("div",{id:"workflow-container",className:(0,h.cn)("relative h-full w-full",m),children:[(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.MiniMap,{pannable:!0,zoomable:!0,style:{width:102,height:72},maskColor:"var(--color-workflow-minimap-bg)",className:(0,h.cn)("!absolute !bottom-14 z-[9] !m-0 !h-[72px] !w-[102px] !rounded-lg !border-[0.5px] !border-divider-subtle !bg-background-default-subtle !shadow-md !shadow-shadow-shadow-5",u?"!right-4":"!left-4")}),(0,o.jsx)("div",{className:"absolute bottom-4 left-4 z-[9] mt-1 flex items-center gap-2",children:(0,o.jsx)(Z,{})})]}),(0,o.jsx)(a.default,{nodeTypes:J,edgeTypes:ee,nodes:f,onNodesChange:_,edges:b,onEdgesChange:w,connectionLineComponent:d.default,connectionLineContainerStyle:{zIndex:i.ITERATION_CHILDREN_Z_INDEX},defaultViewport:p,multiSelectionKeyCode:null,deleteKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,nodesFocusable:!1,edgesFocusable:!1,panOnScroll:!1,selectionKeyCode:null,selectionMode:l.SelectionMode.Partial,minZoom:.25,children:(0,o.jsx)(r.Background,{gap:[14,14],size:2,className:"bg-workflow-canvas-workflow-bg",color:"var(--color-workflow-canvas-workflow-dot-color)"})})]})};e.s(["default",0,e=>(0,o.jsx)(l.ReactFlowProvider,{children:(0,o.jsx)(et,{...e})})],445924)},182368,e=>{"use strict";var t=e.i(893936),o=e.i(942347);e.i(816688);var s=e.i(675066),a=e.i(734962),l=e.i(967484),r=e.i(925521),n=e.i(751992),i=e.i(815488),d=e.i(972282),c=e.i(586871);e.s(["useImportDSL",0,()=>{let{t:e}=(0,s.useTranslation)(),{notify:p}=(0,a.useToastContext)(),[m,u]=(0,o.useState)(!1),{handleCheckPluginDependencies:x}=(0,l.usePluginDependencies)(),h=(0,n.useSelector)(e=>e.isCurrentWorkspaceEditor),{push:f}=(0,t.useRouter)(),[g,b]=(0,o.useState)(),v=(0,o.useRef)("");return{handleImportDSL:(0,o.useCallback)(async(t,o)=>{let{onSuccess:s,onPending:a,onFailed:l}=o;if(!m){u(!0);try{let o=await (0,d.importDSL)(t);if(!o)return;let{id:n,status:m,app_id:u,app_mode:g,imported_dsl_version:_,current_dsl_version:w}=o;if(m===i.DSLImportStatus.COMPLETED||m===i.DSLImportStatus.COMPLETED_WITH_WARNINGS){if(!u)return;p({type:m===i.DSLImportStatus.COMPLETED?"success":"warning",message:e(m===i.DSLImportStatus.COMPLETED?"newApp.appCreated":"newApp.caution",{ns:"app"}),children:m===i.DSLImportStatus.COMPLETED_WITH_WARNINGS&&e("newApp.appCreateDSLWarning",{ns:"app"})}),s?.(),localStorage.setItem(r.NEED_REFRESH_APP_LIST_KEY,"1"),await x(u),(0,c.getRedirection)(h,{id:u,mode:g},f)}else m===i.DSLImportStatus.PENDING?(b({importedVersion:_??"",systemVersion:w??""}),v.current=n,a?.(o)):(p({type:"error",message:e("newApp.appCreateFailed",{ns:"app"})}),l?.())}catch{p({type:"error",message:e("newApp.appCreateFailed",{ns:"app"})}),l?.()}finally{u(!1)}}},[e,p,x,h,f,m]),handleImportDSLConfirm:(0,o.useCallback)(async t=>{let{onSuccess:o,onFailed:s}=t;if(!m&&(u(!0),v.current))try{let{status:t,app_id:a,app_mode:l}=await (0,d.importDSLConfirm)({import_id:v.current});if(!a)return;t===i.DSLImportStatus.COMPLETED?(o?.(),p({type:"success",message:e("newApp.appCreated",{ns:"app"})}),await x(a),localStorage.setItem(r.NEED_REFRESH_APP_LIST_KEY,"1"),(0,c.getRedirection)(h,{id:a,mode:l},f)):t===i.DSLImportStatus.FAILED&&(p({type:"error",message:e("newApp.appCreateFailed",{ns:"app"})}),s?.())}catch{p({type:"error",message:e("newApp.appCreateFailed",{ns:"app"})}),s?.()}finally{u(!1)}},[e,p,x,h,f,m]),versions:g,isFetching:m}}])},293792,e=>{"use strict";var t=e.i(162115);e.i(816688);var o=e.i(675066),s=e.i(151094),a=e.i(21151);e.s(["default",0,e=>{let{versions:l={importedVersion:"",systemVersion:""},onCancel:r,onConfirm:n,confirmDisabled:i=!1}=e,{t:d}=(0,o.useTranslation)();return(0,t.jsxs)(a.default,{isShow:!0,onClose:()=>r(),className:"w-[480px]",children:[(0,t.jsxs)("div",{className:"flex flex-col items-start gap-2 self-stretch pb-4",children:[(0,t.jsx)("div",{className:"title-2xl-semi-bold text-text-primary",children:d("newApp.appCreateDSLErrorTitle",{ns:"app"})}),(0,t.jsxs)("div",{className:"system-md-regular flex grow flex-col text-text-secondary",children:[(0,t.jsx)("div",{children:d("newApp.appCreateDSLErrorPart1",{ns:"app"})}),(0,t.jsx)("div",{children:d("newApp.appCreateDSLErrorPart2",{ns:"app"})}),(0,t.jsx)("br",{}),(0,t.jsxs)("div",{children:[d("newApp.appCreateDSLErrorPart3",{ns:"app"}),(0,t.jsx)("span",{className:"system-md-medium",children:l.importedVersion})]}),(0,t.jsxs)("div",{children:[d("newApp.appCreateDSLErrorPart4",{ns:"app"}),(0,t.jsx)("span",{className:"system-md-medium",children:l.systemVersion})]})]})]}),(0,t.jsxs)("div",{className:"flex items-start justify-end gap-2 self-stretch pt-6",children:[(0,t.jsx)(s.default,{variant:"secondary",onClick:()=>r(),children:d("newApp.Cancel",{ns:"app"})}),(0,t.jsx)(s.default,{variant:"primary",destructive:!0,onClick:n,disabled:i,children:d("newApp.Confirm",{ns:"app"})})]})]})}])},787586,e=>{"use strict";var t,o=e.i(162115),s=e.i(942347),a=e.i(592160),l=e.i(449980),r=e.i(21151),n=e.i(925521),i=e.i(494268),d=e.i(934557),c=e.i(151094),p=e.i(261484),m=e.i(869931),u=e.i(666023);e.i(816688);var x=e.i(675066),h=e.i(654313),f=e.i(294237),g=e.i(935139);let b=(0,f.cva)("",{variants:{type:{info:"from-components-badge-status-light-normal-halo to-background-gradient-mask-transparent"}}}),v=(0,s.memo)(e=>{let{type:t="info",message:s,onHide:a,className:l}=e;return(0,o.jsx)("div",{className:(0,g.cn)("pointer-events-none w-full",l),children:(0,o.jsxs)("div",{className:"relative flex space-x-1 overflow-hidden rounded-xl border border-components-panel-border bg-components-panel-bg-blur p-3 shadow-lg",children:[(0,o.jsx)("div",{className:(0,g.cn)("pointer-events-none absolute inset-0 bg-gradient-to-r opacity-[0.4]",b({type:t})),"data-testid":"alert-gradient"}),(0,o.jsx)("div",{className:"flex h-6 w-6 items-center justify-center",children:(0,o.jsx)("span",{className:"i-ri-information-2-fill text-text-accent","data-testid":"info-icon"})}),(0,o.jsx)("div",{className:"p-1",children:(0,o.jsx)("div",{className:"text-text-secondary system-xs-regular","data-testid":"msg-container",children:s})}),(0,o.jsx)("div",{className:"pointer-events-auto flex h-6 w-6 cursor-pointer items-center justify-center",onClick:a,children:(0,o.jsx)("span",{className:"i-ri-close-line h-4 w-4 text-text-tertiary","data-testid":"close-icon"})})]})})});var _=e.i(257899),w=e.i(617727),y=e.i(830622),j=e.i(484377),N=e.i(696565),k=e.i(421001),T=e.i(271743),C=e.i(447301),E=e.i(199947);let S=s.memo(e=>{let{appId:t,appDetail:a,className:l}=e,{t:r}=(0,x.useTranslation)(),n=(0,T.default)()===T.MediaType.mobile,i=(0,E.useThemeContext)(),{removeConversationIdInfo:d,...c}=(0,j.useEmbeddedChatbot)(C.AppSourceType.tryApp,t),p=c.currentConversationId,f=c.inputsForms;(0,s.useEffect)(()=>{t&&d(t)},[t]);let[b,{setTrue:S}]=(0,u.useBoolean)(!1);return(0,o.jsx)(y.EmbeddedChatbotContext.Provider,{value:{...c,disableFeedback:!0,isMobile:n,themeBuilder:i},children:(0,o.jsxs)("div",{className:(0,g.cn)("flex h-full flex-col rounded-2xl bg-background-section-burn",l),children:[(0,o.jsxs)("div",{className:"flex shrink-0 justify-between p-3",children:[(0,o.jsxs)("div",{className:"flex grow items-center space-x-2",children:[(0,o.jsx)(_.default,{size:"large",iconType:a.site.icon_type,icon:a.site.icon,background:a.site.icon_background,imageUrl:a.site.icon_url}),(0,o.jsx)("div",{className:"system-md-semibold grow truncate text-text-primary",title:a.name,children:a.name})]}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[p&&(0,o.jsx)(k.default,{popupContent:r("chat.resetChat",{ns:"share"}),children:(0,o.jsx)(h.default,{size:"l",onClick:()=>{d(t),c.handleNewConversation()},children:(0,o.jsx)(m.RiResetLeftLine,{className:"h-[18px] w-[18px]"})})}),p&&f.length>0&&(0,o.jsx)(N.default,{})]})]}),(0,o.jsxs)("div",{className:"mx-auto mt-4 flex h-[0] w-[769px] grow flex-col",children:[!b&&(0,o.jsx)(v,{className:"mb-4 shrink-0",message:r("tryApp.tryInfo",{ns:"explore"}),onHide:S}),(0,o.jsx)(w.default,{})]})]})})});var I=e.i(220365),A=e.i(210807),P=e.i(874914),L=e.i(608846),D=e.i(648404),M=e.i(680884),R=e.i(727163);let z=s.memo(e=>{let{appId:t,className:a,isWorkflow:r,appData:i}=e,{t:c}=(0,x.useTranslation)(),p=(0,T.default)()===T.MediaType.pc,[m,h]=(0,s.useState)({}),f=(0,s.useRef)(m),b=(0,s.useCallback)(e=>{h(e),f.current=e},[]),w=(0,L.useWebAppStore)(e=>e.updateAppInfo),{data:y}=(0,d.useGetTryAppParams)(t),j=(0,L.useWebAppStore)(e=>e.updateAppParams),N=(0,L.useWebAppStore)(e=>e.appParams),[k,E]=(0,s.useState)(null),[S,z]=(0,s.useState)(null),[F,O]=(0,s.useState)(null),[B,U]=(0,s.useState)(null),[H,G]=(0,s.useState)(null),[q,$]=(0,s.useState)(0),[V,W]=(0,s.useState)({enabled:!1,number_limits:2,detail:D.Resolution.low,transfer_methods:[D.TransferMethod.local_file]}),[K,X]=(0,s.useState)([]),[Q,{setTrue:Y,setFalse:Z}]=(0,u.useBoolean)(!1),J=()=>{setTimeout(()=>{Y()},0)},[ee,et]=(0,s.useState)(!1);(0,s.useEffect)(()=>{i&&w(i)},[i,w]),(0,s.useEffect)(()=>{y&&j(y)},[y,j]),(0,s.useEffect)(()=>{(async()=>{if(!i||!N)return;let{site:e,custom_config:t}=i;E(e),O(t);let{user_input_form:o,more_like_this:s,file_upload:a,text_to_speech:l}=N;W({...a,transfer_methods:a?.allowed_file_upload_methods||a?.allowed_upload_methods,image_file_size_limit:N?.system_parameters.image_file_size_limit,fileUploadConfig:N?.system_parameters}),z({prompt_template:"",prompt_variables:(0,M.userInputsFormToPromptVariables)(o)}),U(s),G(l)})()},[i,N]);let[eo,es]=(0,s.useState)(!1),ea=(0,s.useCallback)(()=>{es(!0)},[]),[el,{setTrue:er}]=(0,u.useBoolean)(!1),en=(0,o.jsx)("div",{className:(0,g.cn)("relative flex h-full flex-col","rounded-r-2xl bg-chatbot-bg"),children:(0,o.jsxs)("div",{className:(0,g.cn)("flex h-0 grow flex-col overflow-y-auto p-6"),children:[eo&&!el&&(0,o.jsx)(v,{className:"mb-3 shrink-0",message:c("tryApp.tryInfo",{ns:"explore"}),onHide:er}),(0,o.jsx)(A.default,{isWorkflow:!!r,isCallBatchAPI:!1,isPC:p,isMobile:!p,appSourceType:C.AppSourceType.tryApp,appId:t,isError:void 0===P.TaskStatus.failed,promptConfig:S,moreLikeThisEnabled:!!B?.enabled,inputs:m,controlSend:q,onShowRes:J,handleSaveMessage:I.noop,taskId:void 0,onCompleted:ea,visionConfig:V,completionFiles:K,isShowTextToSpeech:!!H?.enabled,siteInfo:k,onRunStart:()=>et(!0)},void 0)]})});return k&&S?(0,o.jsxs)("div",{className:(0,g.cn)("rounded-2xl border border-components-panel-border bg-background-section-burn",p&&"flex",!p&&"flex-col","h-full rounded-2xl shadow-md",a),children:[(0,o.jsxs)("div",{className:(0,g.cn)("relative flex h-full shrink-0 flex-col",p&&"w-[600px] max-w-[50%]","rounded-l-2xl bg-components-panel-bg"),children:[(0,o.jsxs)("div",{className:(0,g.cn)("shrink-0 space-y-4 pb-2",p?" p-8 pb-0":"p-4 pb-0"),children:[(0,o.jsxs)("div",{className:"flex items-center gap-3",children:[(0,o.jsx)(_.default,{size:p?"large":"small",iconType:k.icon_type,icon:k.icon,background:k.icon_background||n.appDefaultIconBackground,imageUrl:k.icon_url}),(0,o.jsx)("div",{className:"system-md-semibold grow truncate text-text-secondary",children:k.title})]}),k.description&&(0,o.jsx)("div",{className:"system-xs-regular text-text-tertiary",children:k.description})]}),(0,o.jsx)("div",{className:(0,g.cn)("h-0 grow overflow-y-auto",p?"px-8":"px-4",!p&&ee&&F?.remove_webapp_brand&&"rounded-b-2xl border-b-[0.5px] border-divider-regular"),children:(0,o.jsx)(R.default,{siteInfo:k,inputs:m,inputsRef:f,onInputsChange:b,promptConfig:S,onSend:()=>{$(Date.now()),J()},visionConfig:V,onVisionFilesChange:X})})]}),(0,o.jsxs)("div",{className:(0,g.cn)("h-full w-0 grow"),children:[!p&&(0,o.jsx)("div",{className:(0,g.cn)(Q?"flex items-center justify-center p-2 pt-6":"absolute left-0 top-0 z-10 flex w-full items-center justify-center px-2 pb-[57px] pt-[3px]"),onClick:()=>{Q?Z():J()},children:(0,o.jsx)("div",{className:"h-1 w-8 cursor-grab rounded bg-divider-solid"})}),en]})]}):(0,o.jsx)("div",{className:(0,g.cn)("flex h-screen items-center",a),children:(0,o.jsx)(l.default,{type:"app"})})}),F=s.memo(e=>{let{appId:t,appDetail:s}=e,a=s?.mode,l=["chat","advanced-chat","agent-chat"].includes(a);return(0,p.default)(s?.site?.title||""),(0,o.jsxs)("div",{className:"flex h-full w-full",children:[l&&(0,o.jsx)(S,{appId:t,appDetail:s,className:"h-full grow"}),!l&&(0,o.jsx)(z,{appId:t,className:"h-full grow",isWorkflow:"workflow"===a,appData:{app_id:t,custom_config:{},...s}})]})});var O=e.i(446717),B=e.i(964001),U=e.i(390622);let H={model:{google:"gemini"},tool:{stepfun:"stepfun_tool",jina:"jina_tool",siliconflow:"siliconflow_tool",gitee_ai:"gitee_ai_tool"}},G=(e,t)=>{let o,s,a=(o=e.split("/").filter(Boolean)).length?1===o.length?{organization:"langgenius",providerName:o[0]}:{organization:o[0],providerName:o[1]}:null;if(!a)return"";let l=encodeURIComponent(a.organization),r=encodeURIComponent((s=a.providerName,H[t][s]||s));return`${n.MARKETPLACE_API_PREFIX}/plugins/${l}/${r}/icon`},q="system-sm-semibold-uppercase text-text-secondary mb-3",$=e=>{let{iconUrl:t}=e,[a,l]=s.useState(null);return t&&a!==t?(0,o.jsx)("img",{className:"size-5 rounded-md object-cover shadow-xs",src:t,alt:"","aria-hidden":"true",width:20,height:20,onError:()=>l(t)}):(0,o.jsx)("div",{className:"flex size-5 items-center justify-center overflow-hidden rounded-[6px] border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge",children:(0,o.jsx)("div",{className:"i-custom-public-other-default-tool-icon size-3 text-text-tertiary"})})},V=s.memo(e=>{let{appId:t,className:s,category:a,appDetail:l,onCreate:r}=e,{t:n}=(0,x.useTranslation)(),i=l?.mode,{requirements:p}=(e=>{let{appDetail:t,appId:o}=e,s=["chat","completion","agent-chat"].includes(t.mode),a="agent-chat"===t.mode,l=!s,{data:r}=(0,d.useGetTryAppFlowPreview)(o,s),n=[];if(s){let e=t.model_config.model.provider,o=t.model_config.model.provider.split("/").pop()||"";n.push({name:o,iconUrl:G(e,"model")})}if(a&&n.push(...t.model_config.agent_mode.tools.filter(e=>e.enabled).map(e=>({name:e.tool_label,iconUrl:G(e.provider_id,"tool")}))),l&&r&&r?.graph?.nodes?.length>0){let e=r.graph.nodes,t=e.filter(e=>e.data.type===U.BlockEnum.LLM);n.push(...t.map(e=>{let t=e.data;return{name:t.model.name,iconUrl:G(t.model.provider,"model")}}));let o=e.filter(e=>e.data.type===U.BlockEnum.Tool);n.push(...o.map(e=>{let t=e.data;return{name:t.tool_label,iconUrl:G(t.provider_id,"tool")}}))}return{requirements:(0,B.uniqBy)(n,"name")}})({appDetail:l,appId:t});return(0,o.jsxs)("div",{className:(0,g.cn)("flex h-full flex-col px-4 pt-2",s),children:[(0,o.jsxs)("div",{className:"flex shrink-0 grow-0 items-center gap-3",children:[(0,o.jsxs)("div",{className:"relative shrink-0",children:[(0,o.jsx)(_.default,{size:"large",iconType:l.site.icon_type,icon:l.site.icon,background:l.site.icon_background,imageUrl:l.site.icon_url}),(0,o.jsx)(O.AppTypeIcon,{wrapperClassName:"absolute -bottom-0.5 -right-0.5 w-4 h-4 shadow-sm",className:"h-3 w-3",type:i})]}),(0,o.jsxs)("div",{className:"w-0 grow py-[1px]",children:[(0,o.jsx)("div",{className:"flex items-center text-sm font-semibold leading-5 text-text-secondary",children:(0,o.jsx)("div",{className:"truncate",title:l.name,children:l.name})}),(0,o.jsxs)("div",{className:"flex items-center text-[10px] font-medium leading-[18px] text-text-tertiary",children:["advanced-chat"===i&&(0,o.jsx)("div",{className:"truncate",children:n("types.advanced",{ns:"app"}).toUpperCase()}),"chat"===i&&(0,o.jsx)("div",{className:"truncate",children:n("types.chatbot",{ns:"app"}).toUpperCase()}),"agent-chat"===i&&(0,o.jsx)("div",{className:"truncate",children:n("types.agent",{ns:"app"}).toUpperCase()}),"workflow"===i&&(0,o.jsx)("div",{className:"truncate",children:n("types.workflow",{ns:"app"}).toUpperCase()}),"completion"===i&&(0,o.jsx)("div",{className:"truncate",children:n("types.completion",{ns:"app"}).toUpperCase()})]})]})]}),l.description&&(0,o.jsx)("div",{className:"mt-[14px] shrink-0 text-text-secondary system-sm-regular",children:l.description}),(0,o.jsxs)(c.default,{variant:"primary",className:"mt-3 flex w-full max-w-full",onClick:r,children:[(0,o.jsx)("span",{className:"i-ri-add-line mr-1 size-4 shrink-0"}),(0,o.jsx)("span",{className:"truncate",children:n("tryApp.createFromSampleApp",{ns:"explore"})})]}),a&&(0,o.jsxs)("div",{className:"mt-6 shrink-0",children:[(0,o.jsx)("div",{className:q,children:n("tryApp.category",{ns:"explore"})}),(0,o.jsx)("div",{className:"text-text-secondary system-md-regular",children:a})]}),p.length>0&&(0,o.jsxs)("div",{className:"mt-5 grow overflow-y-auto",children:[(0,o.jsx)("div",{className:q,children:n("tryApp.requirements",{ns:"explore"})}),(0,o.jsx)("div",{className:"space-y-0.5",children:p.map(e=>(0,o.jsxs)("div",{className:"flex items-center space-x-2 py-1",children:[(0,o.jsx)($,{iconUrl:e.iconUrl}),(0,o.jsx)("div",{className:"w-0 grow truncate text-text-secondary system-md-regular",children:e.name})]},e.name))})]})]})});var W=e.i(14656),K=e.i(875489),X=e.i(315765);e.i(458266);var Q=e.i(733437),Y=e.i(471981),Z=e.i(739255),J=e.i(265630),ee=e.i(923978),et=e.i(154033),eo=e.i(842090),es=e.i(168014),ea=e.i(225162);let el={provider:"langgenius/openai/openai",model_id:"gpt-3.5-turbo",mode:D.ModelModeType.unset,configs:{prompt_template:"",prompt_variables:[]},more_like_this:null,opening_statement:"",suggested_questions:[],sensitive_word_avoidance:null,speech_to_text:null,text_to_speech:null,file_upload:null,suggested_questions_after_answer:null,retriever_resource:null,annotation_reply:null,dataSets:[],agentConfig:n.DEFAULT_AGENT_SETTING},er=s.memo(e=>{let{appId:t}=e,a=(0,T.default)()===T.MediaType.mobile,{data:r,isLoading:i}=(0,d.useGetTryAppInfo)(t),{data:c,isLoading:p}=(0,et.useAllToolProviders)(),m=c?.map(e=>({...e,icon:es.basePath&&"string"==typeof e.icon&&!e.icon.includes(es.basePath)?`${es.basePath}${e.icon}`:e.icon})),u=(()=>{if(i)return[];let e=r?.model_config;if(!e)return[];let t=null;return(e.agent_mode?.tools?.find(e=>{let{dataset:t}=e;return t?.enabled})?t=e.agent_mode?.tools.filter(e=>{let{dataset:t}=e;return t?.enabled}):e.dataset_configs.datasets?.datasets?.length>0&&(t=e.dataset_configs?.datasets?.datasets),t?.length&&t?.length>0)?t.map(e=>{let{dataset:t}=e;return t.id}):[]})(),{data:x,isLoading:h}=(0,d.useGetTryAppDataSets)(t,u),f=x?.data||[],g=i||h||p,b=(e=>{if(g||!e)return el;let t=e.model;return{provider:(0,eo.correctModelProvider)(t.provider),model_id:t.name,mode:t.mode,configs:{prompt_template:e.pre_prompt||"",prompt_variables:(0,M.userInputsFormToPromptVariables)([...e.user_input_form,...e.external_data_tools?.length?e.external_data_tools.map(e=>({external_data_tool:{variable:e.variable,label:e.label,enabled:e.enabled,type:e.type,config:e.config,required:!0,icon:e.icon,icon_background:e.icon_background}})):[]],e.dataset_query_variable)},more_like_this:e.more_like_this,opening_statement:e.opening_statement,suggested_questions:e.suggested_questions,sensitive_word_avoidance:e.sensitive_word_avoidance,speech_to_text:e.speech_to_text,text_to_speech:e.text_to_speech,file_upload:e.file_upload,suggested_questions_after_answer:e.suggested_questions_after_answer,retriever_resource:e.retriever_resource,annotation_reply:e.annotation_reply,external_data_tools:e.external_data_tools,dataSets:f,agentConfig:r?.mode==="agent-chat"?{max_iteration:n.DEFAULT_AGENT_SETTING.max_iteration,...e.agent_mode,enabled:!0,tools:e.agent_mode?.tools.filter(e=>!e.dataset).map(e=>{let t=m?.find(t=>e.provider_id===t.id);return{...e,isDeleted:r?.deleted_tools?.some(t=>t.id===e.id&&t.tool_name===e.tool_name),notAuthor:t?.is_team_authorization===!1,..."builtin"===e.provider_type?{provider_id:(0,eo.correctToolProvider)(e.provider_name,!!t),provider_name:(0,eo.correctToolProvider)(e.provider_name,!!t)}:{}}})}:n.DEFAULT_AGENT_SETTING}})(r?.model_config),v=r?.mode,_=b?.prompt_type===ee.PromptMode.advanced?ee.PromptMode.advanced:ee.PromptMode.simple,w=_===ee.PromptMode.advanced,y=w?b?.chat_prompt_config||(0,W.clone)(n.DEFAULT_CHAT_PROMPT_CONFIG):void 0,j=b?.suggested_questions||[],N=b?.more_like_this||{enabled:!1},k=b?.suggested_questions_after_answer||{enabled:!1},C=b?.speech_to_text||{enabled:!1},E=b?.text_to_speech||{enabled:!1,voice:"",language:""},S=b?.retriever_resource||{enabled:!1},A=b?.annotation_reply||{id:"",enabled:!1,score_threshold:n.ANNOTATION_DEFAULT.score_threshold,embedding_model:{embedding_provider_name:"",embedding_model_name:""}},P=b?.sensitive_word_avoidance||{enabled:!1},L=b?.completion_prompt_config||(0,W.clone)(n.DEFAULT_COMPLETION_PROMPT_CONFIG),R={},z=(0,s.useState)({}),{currentModel:F}=(0,ea.useTextGenerationCurrentProviderAndModelAndModelList)({provider:b.provider,model:b.model_id}),O=!!F?.features?.includes(Z.ModelFeatureEnum.vision),B=!!F?.features?.includes(Z.ModelFeatureEnum.document),H=!!F?.features?.includes(Z.ModelFeatureEnum.audio),G=!!F?.features?.includes(Z.ModelFeatureEnum.video),q={enabled:!1,number_limits:2,detail:D.Resolution.low,transfer_methods:[D.TransferMethod.local_file]},$=(0,s.useMemo)(()=>({moreLikeThis:b.more_like_this||{enabled:!1},opening:{enabled:!!b.opening_statement,opening_statement:b.opening_statement||"",suggested_questions:b.suggested_questions||[]},moderation:b.sensitive_word_avoidance||{enabled:!1},speech2text:b.speech_to_text||{enabled:!1},text2speech:b.text_to_speech||{enabled:!1},file:{image:{detail:b.file_upload?.image?.detail||D.Resolution.high,enabled:!!b.file_upload?.image?.enabled,number_limits:b.file_upload?.image?.number_limits||3,transfer_methods:b.file_upload?.image?.transfer_methods||["local_file","remote_url"]},enabled:!!(b.file_upload?.enabled||b.file_upload?.image?.enabled),allowed_file_types:b.file_upload?.allowed_file_types||[],allowed_file_extensions:b.file_upload?.allowed_file_extensions||[...Y.FILE_EXTS[U.SupportUploadFileTypes.image],...Y.FILE_EXTS[U.SupportUploadFileTypes.video]].map(e=>`.${e}`),allowed_file_upload_methods:b.file_upload?.allowed_file_upload_methods||b.file_upload?.image?.transfer_methods||["local_file","remote_url"],number_limits:b.file_upload?.number_limits||b.file_upload?.image?.number_limits||3,fileUploadConfig:{}},suggested:b.suggested_questions_after_answer||{enabled:!1},citation:b.retriever_resource||{enabled:!1},annotationReply:b.annotation_reply||{enabled:!1}}),[b]);if(g)return(0,o.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,o.jsx)(l.default,{type:"area"})});let V={readonly:!0,appId:t,isAPIKeySet:!0,isTrailFinished:!1,mode:v,modelModeType:"",promptMode:_,isAdvancedMode:w,isAgent:"agent-chat"===v,isOpenAI:!1,isFunctionCall:!1,collectionList:[],setPromptMode:I.noop,canReturnToSimpleMode:!1,setCanReturnToSimpleMode:I.noop,chatPromptConfig:y,completionPromptConfig:L,currentAdvancedPrompt:"",setCurrentAdvancedPrompt:I.noop,conversationHistoriesRole:L.conversation_histories_role,showHistoryModal:!1,setConversationHistoriesRole:I.noop,hasSetBlockStatus:!0,conversationId:"",introduction:"",setIntroduction:I.noop,suggestedQuestions:j,setSuggestedQuestions:I.noop,setConversationId:I.noop,controlClearChatMessage:!1,setControlClearChatMessage:I.noop,prevPromptConfig:{},setPrevPromptConfig:I.noop,moreLikeThisConfig:N,setMoreLikeThisConfig:I.noop,suggestedQuestionsAfterAnswerConfig:k,setSuggestedQuestionsAfterAnswerConfig:I.noop,speechToTextConfig:C,setSpeechToTextConfig:I.noop,textToSpeechConfig:E,setTextToSpeechConfig:I.noop,citationConfig:S,setCitationConfig:I.noop,annotationConfig:A,setAnnotationConfig:I.noop,moderationConfig:P,setModerationConfig:I.noop,externalDataToolsConfig:{},setExternalDataToolsConfig:I.noop,formattingChanged:!1,setFormattingChanged:I.noop,inputs:R,setInputs:I.noop,query:"",setQuery:I.noop,completionParams:z,setCompletionParams:I.noop,modelConfig:b,setModelConfig:I.noop,showSelectDataSet:I.noop,dataSets:f,setDataSets:I.noop,datasetConfigs:[],datasetConfigsRef:{},setDatasetConfigs:I.noop,hasSetContextVar:!0,isShowVisionConfig:O,visionConfig:q,setVisionConfig:I.noop,isAllowVideoUpload:G,isShowDocumentConfig:B,isShowAudioConfig:H,rerankSettingModalOpen:!1,setRerankSettingModalOpen:I.noop};return(0,o.jsx)(J.default.Provider,{value:V,children:(0,o.jsx)(Q.FeaturesProvider,{features:$,children:(0,o.jsx)("div",{className:"flex h-full w-full flex-col bg-components-panel-on-panel-item-bg",children:(0,o.jsxs)("div",{className:"relative flex h-[200px] grow",children:[(0,o.jsx)("div",{className:"flex h-full w-full shrink-0 flex-col sm:w-1/2",children:(0,o.jsx)(K.default,{})}),!a&&(0,o.jsx)("div",{className:"relative flex h-full w-1/2 grow flex-col overflow-y-auto ",style:{borderColor:"rgba(0, 0, 0, 0.02)"},children:(0,o.jsx)("div",{className:"flex grow flex-col rounded-tl-2xl border-l-[0.5px] border-t-[0.5px] border-components-panel-border bg-chatbot-bg ",children:(0,o.jsx)(X.default,{isAPIKeySet:!0,onSetting:I.noop,inputs:R,modelParameterParams:{setModel:I.noop,onCompletionParamsChange:I.noop},debugWithMultipleModel:!1,multipleModelConfigs:[],onMultipleModelConfigsChange:I.noop})})})]})})})})});var en=e.i(445924);let ei=s.memo(e=>{let{appId:t,className:s}=e,{data:a,isLoading:r}=(0,d.useGetTryAppFlowPreview)(t);return r?(0,o.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,o.jsx)(l.default,{type:"area"})}):a?(0,o.jsx)("div",{className:"h-full w-full",children:(0,o.jsx)(en.default,{...a.graph,className:(0,g.cn)(s),miniMapToRight:!0})}):null}),ed=s.memo(e=>{let{appId:t,appDetail:s}=e,a=["agent-chat","chat","completion"].includes(s.mode);return(0,o.jsx)("div",{className:"h-full w-full",children:a?(0,o.jsx)(er,{appId:t}):(0,o.jsx)(ei,{appId:t,className:"h-full"})})});var ec=e.i(366892),ep=((t={}).TRY="try",t.DETAIL="detail",t);let em=s.memo(e=>{let{value:t,onChange:a,disableTry:l}=e,{t:r}=(0,x.useTranslation)(),i=s.useMemo(()=>[n.IS_CLOUD_EDITION?{id:"try",name:r("tryApp.tabHeader.try",{ns:"explore"}),disabled:l}:null,{id:"detail",name:r("tryApp.tabHeader.detail",{ns:"explore"})}].filter(e=>null!==e),[r,l]);return(0,o.jsx)(ec.default,{items:i,value:t,onChange:a,itemClassName:"ml-0 system-md-semibold-uppercase",itemWrapClassName:"pt-2",activeItemClassName:"border-util-colors-blue-brand-blue-brand-500"})}),eu=s.memo(e=>{let{appId:t,app:p,category:m,onClose:u,onCreate:x}=e,{systemFeatures:h}=(0,i.useGlobalPublicStore)(),f=!!(p&&p.can_trial&&h.enable_trial_app),g=n.IS_CLOUD_EDITION&&(!p||f),[b,v]=(0,s.useState)(()=>g?ep.TRY:ep.DETAIL),_=g?b:ep.DETAIL,{data:w,isLoading:y,isError:j,error:N}=(0,d.useGetTryAppInfo)(t);return(0,o.jsx)(r.default,{isShow:!0,onClose:u,className:"h-[calc(100vh-32px)] min-w-[1280px] max-w-[calc(100vw-32px)] overflow-x-auto p-2",children:y?(0,o.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,o.jsx)(l.default,{type:"area"})}):j?(0,o.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,o.jsx)(a.default,{className:"h-auto w-auto",isUnknownReason:!N,unknownReason:N instanceof Error?N.message:void 0})}):w?(0,o.jsxs)("div",{className:"flex h-full flex-col",children:[(0,o.jsxs)("div",{className:"flex shrink-0 justify-between pl-4",children:[(0,o.jsx)(em,{value:_,onChange:v,disableTry:!!p&&!f}),(0,o.jsx)(c.default,{size:"large",variant:"tertiary",className:"flex size-7 items-center justify-center rounded-[10px] p-0 text-components-button-tertiary-text",onClick:u,children:(0,o.jsx)("span",{className:"i-ri-close-line size-5"})})]}),(0,o.jsxs)("div",{className:"mt-2 flex h-0 grow justify-between space-x-2",children:[_===ep.TRY?(0,o.jsx)(F,{appId:t,appDetail:w}):(0,o.jsx)(ed,{appId:t,appDetail:w}),(0,o.jsx)(V,{className:"w-[360px] shrink-0",appDetail:w,appId:t,category:m,onCreate:x})]})]}):(0,o.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,o.jsx)(a.default,{className:"h-auto w-auto",isUnknownReason:!0})})})});e.s(["default",0,eu],787586)}]);