qtype 0.0.12__py3-none-any.whl → 0.0.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. qtype/application/converters/tools_from_api.py +476 -11
  2. qtype/application/converters/tools_from_module.py +37 -13
  3. qtype/application/converters/types.py +14 -0
  4. qtype/application/facade.py +17 -20
  5. qtype/commands/convert.py +36 -2
  6. qtype/commands/generate.py +48 -0
  7. qtype/commands/run.py +1 -0
  8. qtype/commands/serve.py +11 -1
  9. qtype/commands/validate.py +8 -11
  10. qtype/commands/visualize.py +0 -3
  11. qtype/dsl/model.py +190 -4
  12. qtype/dsl/validator.py +2 -1
  13. qtype/interpreter/api.py +5 -1
  14. qtype/interpreter/batch/file_sink_source.py +162 -0
  15. qtype/interpreter/batch/flow.py +1 -1
  16. qtype/interpreter/batch/sql_source.py +3 -6
  17. qtype/interpreter/batch/step.py +12 -1
  18. qtype/interpreter/batch/utils.py +8 -9
  19. qtype/interpreter/step.py +2 -2
  20. qtype/interpreter/steps/tool.py +194 -28
  21. qtype/interpreter/ui/404/index.html +1 -1
  22. qtype/interpreter/ui/404.html +1 -1
  23. qtype/interpreter/ui/_next/static/chunks/393-8fd474427f8e19ce.js +36 -0
  24. qtype/interpreter/ui/_next/static/chunks/{964-ed4ab073db645007.js → 964-2b041321a01cbf56.js} +1 -1
  25. qtype/interpreter/ui/_next/static/chunks/app/{layout-5ccbc44fd528d089.js → layout-a05273ead5de2c41.js} +1 -1
  26. qtype/interpreter/ui/_next/static/chunks/app/page-7e26b6156cfb55d3.js +1 -0
  27. qtype/interpreter/ui/_next/static/chunks/{main-6d261b6c5d6fb6c2.js → main-e26b9cb206da2cac.js} +1 -1
  28. qtype/interpreter/ui/_next/static/chunks/webpack-08642e441b39b6c2.js +1 -0
  29. qtype/interpreter/ui/_next/static/css/b40532b0db09cce3.css +3 -0
  30. qtype/interpreter/ui/_next/static/media/4cf2300e9c8272f7-s.p.woff2 +0 -0
  31. qtype/interpreter/ui/index.html +1 -1
  32. qtype/interpreter/ui/index.txt +4 -4
  33. qtype/loader.py +2 -1
  34. qtype/semantic/generate.py +6 -2
  35. qtype/semantic/model.py +132 -77
  36. qtype/semantic/visualize.py +24 -6
  37. {qtype-0.0.12.dist-info → qtype-0.0.14.dist-info}/METADATA +5 -2
  38. {qtype-0.0.12.dist-info → qtype-0.0.14.dist-info}/RECORD +44 -43
  39. qtype/interpreter/ui/_next/static/chunks/736-7fc606e244fedcb1.js +0 -36
  40. qtype/interpreter/ui/_next/static/chunks/app/page-c72e847e888e549d.js +0 -1
  41. qtype/interpreter/ui/_next/static/chunks/webpack-8289c17c67827f22.js +0 -1
  42. qtype/interpreter/ui/_next/static/css/a262c53826df929b.css +0 -3
  43. qtype/interpreter/ui/_next/static/media/569ce4b8f30dc480-s.p.woff2 +0 -0
  44. /qtype/interpreter/ui/_next/static/{OT8QJQW3J70VbDWWfrEMT → nUaw6_IwRwPqkzwe5s725}/_buildManifest.js +0 -0
  45. /qtype/interpreter/ui/_next/static/{OT8QJQW3J70VbDWWfrEMT → nUaw6_IwRwPqkzwe5s725}/_ssgManifest.js +0 -0
  46. {qtype-0.0.12.dist-info → qtype-0.0.14.dist-info}/WHEEL +0 -0
  47. {qtype-0.0.12.dist-info → qtype-0.0.14.dist-info}/entry_points.txt +0 -0
  48. {qtype-0.0.12.dist-info → qtype-0.0.14.dist-info}/licenses/LICENSE +0 -0
  49. {qtype-0.0.12.dist-info → qtype-0.0.14.dist-info}/top_level.txt +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{5688:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_6de60c",variable:"__variable_6de60c"}},8866:(e,a,s)=>{Promise.resolve().then(s.t.bind(s,5688,23)),Promise.resolve().then(s.t.bind(s,9432,23)),Promise.resolve().then(s.t.bind(s,9324,23))},9324:()=>{},9432:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_152ec0",variable:"__variable_152ec0"}}},e=>{e.O(0,[261,441,964,358],()=>e(e.s=8866)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{5688:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_c57559",variable:"__variable_c57559"}},8866:(e,a,s)=>{Promise.resolve().then(s.t.bind(s,5688,23)),Promise.resolve().then(s.t.bind(s,9432,23)),Promise.resolve().then(s.t.bind(s,9324,23))},9324:()=>{},9432:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_152ec0",variable:"__variable_152ec0"}}},e=>{e.O(0,[261,441,964,358],()=>e(e.s=8866)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{2941:(e,t,r)=>{Promise.resolve().then(r.bind(r,8785))},8785:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>eO});var a=r(5155),s=r(2115),n=r(838),l=r(2596),i=r(9688);function o(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return(0,i.QP)((0,l.$)(t))}function d(e,t){if(!e)return null;if("$ref"in e){let r=e.$ref.replace("#/","").split("/"),a=t;for(let e of r)a=null==a?void 0:a[e];return d(a,t)}if("object"===e.type&&e.properties){let r={};for(let[a,s]of Object.entries(e.properties)){let e=d(s,t);e&&(r[a]=e)}return{...e,properties:r}}if("array"===e.type&&e.items){let r=d(e.items,t);return{...e,items:r}}return e}var c=r(9509);class u extends Error{constructor(e,t,r){super(e),this.name="ApiClientError",this.status=t,this.detail=r}}class m{async fetchWithTimeout(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new AbortController,a=setTimeout(()=>r.abort(),this.config.timeout);try{let s=await fetch(e,{...t,signal:r.signal,headers:{"Content-Type":"application/json",...t.headers}});if(clearTimeout(a),!s.ok){let e;try{e=await s.json()}catch(t){e={message:s.statusText}}let t="API request failed: ".concat(s.status," ").concat(s.statusText);if(null==e?void 0:e.detail){let r="string"==typeof e.detail?e.detail:JSON.stringify(e.detail,null,2);t+="\n".concat(r)}throw new u(t,s.status,e)}return s}catch(e){if(clearTimeout(a),e instanceof u)throw e;if(e instanceof Error&&"AbortError"===e.name)throw new u("Request timeout",408);throw new u("Network error: ".concat(e instanceof Error?e.message:"Unknown error"),0)}}getUrl(e){let t=this.config.baseUrl.endsWith("/")?this.config.baseUrl.slice(0,-1):this.config.baseUrl,r=e.startsWith("/")?e:"/".concat(e);return"".concat(t).concat(r)}async get(e){return(await this.fetchWithTimeout(this.getUrl(e),{method:"GET"})).json()}async post(e,t){return(await this.fetchWithTimeout(this.getUrl(e),{method:"POST",body:t?JSON.stringify(t):void 0})).json()}async executeFlow(e,t){return this.post(e,t)}async getOpenApiSpec(){return this.get("/openapi.json")}async healthCheck(){try{return await this.getOpenApiSpec(),{status:"healthy",timestamp:new Date().toISOString()}}catch(e){throw new u("Health check failed: ".concat(e instanceof Error?e.message:"Unknown error"),500,e)}}getBaseUrl(){return this.config.baseUrl}setBaseUrl(e){this.config.baseUrl=e}constructor(e){this.config={baseUrl:c.env.NEXT_PUBLIC_QTYPE_HOST||"../",timeout:5e5,...e}}}let x=new m,p=()=>x.getOpenApiSpec();function f(){let{data:e,error:t,isLoading:r,mutate:a}=(0,n.Ay)("/openapi.json",p,{refreshInterval:3e5,revalidateOnFocus:!1,errorRetryCount:3,errorRetryInterval:5e3});return{spec:e,isLoading:r,error:t,refresh:a}}var g=r(4056);function h(e){let{className:t,...r}=e;return(0,a.jsx)(g.bL,{"data-slot":"tabs",className:o("flex flex-col gap-2",t),...r})}function b(e){let{className:t,...r}=e;return(0,a.jsx)(g.B8,{"data-slot":"tabs-list",className:o("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",t),...r})}function v(e){let{className:t,...r}=e;return(0,a.jsx)(g.l9,{"data-slot":"tabs-trigger",className:o("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r})}function y(e){let{className:t,...r}=e;return(0,a.jsx)(g.UC,{"data-slot":"tabs-content",className:o("flex-1 outline-none",t),...r})}var j=r(2085);let N=(0,j.F)("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function w(e){let{className:t,variant:r,...s}=e;return(0,a.jsx)("div",{"data-slot":"alert",role:"alert",className:o(N({variant:r}),t),...s})}function k(e){let{className:t,...r}=e;return(0,a.jsx)("div",{"data-slot":"alert-title",className:o("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...r})}function _(e){let{className:t,...r}=e;return(0,a.jsx)("div",{"data-slot":"alert-description",className:o("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...r})}var C=r(5339);function S(e){let{className:t,type:r,...s}=e;return(0,a.jsx)("input",{type:r,"data-slot":"input",className:o("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...s})}function z(e){let{name:t,property:r,required:s,value:n="",onChange:l}=e;return(0,a.jsx)(S,{type:"text",placeholder:r.description||"Enter ".concat(r.title||t),value:String(n||""),onChange:e=>{null==l||l(t,e.target.value)},required:s,className:"w-full"})}var A=r(239);function E(e){let{className:t,...r}=e;return(0,a.jsx)(A.bL,{"data-slot":"switch",className:o("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...r,children:(0,a.jsx)(A.zi,{"data-slot":"switch-thumb",className:o("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function T(e){let{name:t,property:r,required:s,value:n=!1,onChange:l}=e;return(0,a.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,a.jsx)(E,{checked:!!n,onCheckedChange:e=>{null==l||l(t,e)},required:s}),(0,a.jsx)("div",{className:"flex-1",children:(0,a.jsx)("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:n?"Enabled":"Disabled"})})]})}function q(e){let{name:t,property:r,required:s,value:n,onChange:l}=e,i="integer"===r.type||"int32"===r.format||"int64"===r.format?1:"any";return(0,a.jsx)(S,{type:"number",placeholder:r.description||"Enter ".concat(r.title||t),value:String(n||""),onChange:e=>{let a,s=e.target.value;if(""===s){null==l||l(t,0);return}isNaN(a="integer"===r.type||"int32"===r.format||"int64"===r.format?parseInt(s,10):parseFloat(s))||null==l||l(t,a)},required:s,step:i,min:r.minimum,max:r.maximum,className:"w-full"})}var U=r(9074),O=r(3008),F=r(9708);let P=(0,j.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function M(e){let{className:t,variant:r,size:s,asChild:n=!1,...l}=e,i=n?F.DX:"button";return(0,a.jsx)(i,{"data-slot":"button",className:o(P({variant:r,size:s,className:t})),...l})}var D=r(5933),L=r(2355),I=r(3052),R=r(6474),B=r(713),W=r(8934);function H(){let e=(0,D._)(["rtl:**:[.rdp-button_next>svg]:rotate-180"],["rtl:**:[.rdp-button\\_next>svg]:rotate-180"]);return H=function(){return e},e}function G(){let e=(0,D._)(["rtl:**:[.rdp-button_previous>svg]:rotate-180"],["rtl:**:[.rdp-button\\_previous>svg]:rotate-180"]);return G=function(){return e},e}function V(e){let{className:t,classNames:r,showOutsideDays:s=!0,captionLayout:n="label",buttonVariant:l="ghost",formatters:i,components:d,...c}=e,u=(0,B.a)();return(0,a.jsx)(W.h,{showOutsideDays:s,className:o("bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw(H()),String.raw(G()),t),captionLayout:n,formatters:{formatMonthDropdown:e=>e.toLocaleString("default",{month:"short"}),...i},classNames:{root:o("w-fit",u.root),months:o("flex gap-4 flex-col md:flex-row relative",u.months),month:o("flex flex-col w-full gap-4",u.month),nav:o("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",u.nav),button_previous:o(P({variant:l}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",u.button_previous),button_next:o(P({variant:l}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",u.button_next),month_caption:o("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",u.month_caption),dropdowns:o("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",u.dropdowns),dropdown_root:o("relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",u.dropdown_root),dropdown:o("absolute bg-popover inset-0 opacity-0",u.dropdown),caption_label:o("select-none font-medium","label"===n?"text-sm":"rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",u.caption_label),table:"w-full border-collapse",weekdays:o("flex",u.weekdays),weekday:o("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",u.weekday),week:o("flex w-full mt-2",u.week),week_number_header:o("select-none w-(--cell-size)",u.week_number_header),week_number:o("text-[0.8rem] select-none text-muted-foreground",u.week_number),day:o("relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",u.day),range_start:o("rounded-l-md bg-accent",u.range_start),range_middle:o("rounded-none",u.range_middle),range_end:o("rounded-r-md bg-accent",u.range_end),today:o("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",u.today),outside:o("text-muted-foreground aria-selected:text-muted-foreground",u.outside),disabled:o("text-muted-foreground opacity-50",u.disabled),hidden:o("invisible",u.hidden),...r},components:{Root:e=>{let{className:t,rootRef:r,...s}=e;return(0,a.jsx)("div",{"data-slot":"calendar",ref:r,className:o(t),...s})},Chevron:e=>{let{className:t,orientation:r,...s}=e;return"left"===r?(0,a.jsx)(L.A,{className:o("size-4",t),...s}):"right"===r?(0,a.jsx)(I.A,{className:o("size-4",t),...s}):(0,a.jsx)(R.A,{className:o("size-4",t),...s})},DayButton:$,WeekNumber:e=>{let{children:t,...r}=e;return(0,a.jsx)("td",{...r,children:(0,a.jsx)("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:t})})},...d},...c})}function $(e){let{className:t,day:r,modifiers:n,...l}=e,i=(0,B.a)(),d=s.useRef(null);return s.useEffect(()=>{var e;n.focused&&(null==(e=d.current)||e.focus())},[n.focused]),(0,a.jsx)(M,{ref:d,variant:"ghost",size:"icon","data-day":r.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:o("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",i.day,t),...l})}var J=r(6059);function K(e){let{...t}=e;return(0,a.jsx)(J.bL,{"data-slot":"popover",...t})}function Q(e){let{...t}=e;return(0,a.jsx)(J.l9,{"data-slot":"popover-trigger",...t})}function X(e){let{className:t,align:r="center",sideOffset:s=4,...n}=e;return(0,a.jsx)(J.ZL,{children:(0,a.jsx)(J.UC,{"data-slot":"popover-content",align:r,sideOffset:s,className:o("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...n})})}function Y(e){let{name:t,property:r,value:n,onChange:l,required:i}=e,[d,c]=s.useState(n&&"string"==typeof n?new Date(n):void 0);return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:[r.title||"Date"," ",i&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)(K,{children:[(0,a.jsx)(Q,{asChild:!0,children:(0,a.jsxs)(M,{variant:"outline",className:o("w-full justify-start text-left font-normal",!d&&"text-muted-foreground"),children:[(0,a.jsx)(U.A,{className:"mr-2 h-4 w-4"}),d?(0,O.GP)(d,"PPP"):"Select a date"]})}),(0,a.jsx)(X,{className:"w-auto p-0",children:(0,a.jsx)(V,{mode:"single",selected:d,onSelect:e=>{if(c(e),e){let r=(0,O.GP)(e,"yyyy-MM-dd");null==l||l(t,r)}},initialFocus:!0})})]}),r.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description})]})}function Z(e){let{name:t,property:r,value:n,onChange:l,required:i}=e,[o,d]=s.useState(String(n||""));return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:[r.title||"Time"," ",i&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)(S,{type:"time",value:o,onChange:e=>{var r;d(r=e.target.value),null==l||l(t,r)},step:"1",className:"w-full",placeholder:"HH:MM:SS"}),r.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description})]})}function ee(e){let{name:t,property:r,value:n,onChange:l,required:i}=e,{date:d,time:c}=(e=>{var t;if(!e)return{date:void 0,time:""};let r=new Date(e);return isNaN(r.getTime())?{date:void 0,time:""}:{date:r,time:e.includes("T")&&(null==(t=e.split("T")[1])?void 0:t.split(".")[0])||""}})("string"==typeof n?n:void 0),[u,m]=s.useState(d),[x,p]=s.useState(c),f=(e,r)=>{if(!e)return;let a=(0,O.GP)(e,"yyyy-MM-dd"),s="".concat(a,"T").concat(r||"00:00:00");null==l||l(t,s)};return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"text-sm font-medium",children:[r.title||"Date & Time"," ",i&&(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"flex flex-col space-y-2",children:[(0,a.jsxs)(K,{children:[(0,a.jsx)(Q,{asChild:!0,children:(0,a.jsxs)(M,{variant:"outline",className:o("w-full justify-start text-left font-normal",!u&&"text-muted-foreground"),children:[(0,a.jsx)(U.A,{className:"mr-2 h-4 w-4"}),u?(0,a.jsxs)("span",{children:[(0,O.GP)(u,"PPP"),x&&(0,a.jsxs)("span",{className:"text-muted-foreground ml-2",children:["at ",x]})]}):"Select date and time"]})}),(0,a.jsx)(X,{className:"w-auto p-0",children:(0,a.jsx)(V,{mode:"single",selected:u,onSelect:e=>{m(e),f(e,x)},initialFocus:!0})})]}),(0,a.jsx)(S,{type:"time",value:x,onChange:e=>{var t;p(t=e.target.value),f(u,t)},step:"1",placeholder:"HH:MM:SS",className:"w-full"})]}),r.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:r.description})]})}function et(e){let{name:t,property:r,required:s,value:n,onChange:l}=e;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[r.title||t,s&&(0,a.jsx)("span",{className:"text-red-500 ml-1",children:"*"})]}),r.description&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r.description}),(()=>{switch(r.qtype_type){case"text":return(0,a.jsx)(z,{name:t,property:r,required:s,value:n,onChange:l});case"date":return(0,a.jsx)(Y,{name:t,property:r,required:s,value:n,onChange:l});case"time":return(0,a.jsx)(Z,{name:t,property:r,required:s,value:n,onChange:l});case"datetime":return(0,a.jsx)(ee,{name:t,property:r,required:s,value:n,onChange:l});case"boolean":return(0,a.jsx)(T,{name:t,property:r,required:s,value:n,onChange:l});case"number":case"int":case"float":return(0,a.jsx)(q,{name:t,property:r,required:s,value:n,onChange:l});case"bytes":case"file":case"image":case"audio":case"video":return(0,a.jsx)("div",{className:"bg-gray-50 dark:bg-gray-900 p-3 rounded border",children:(0,a.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"File upload input coming soon..."})});default:return(0,a.jsx)(w,{variant:"destructive",children:(0,a.jsxs)(_,{children:["Unknown input type: ",(0,a.jsx)("code",{className:"font-mono text-sm",children:r.type})]})})}})()]})}function er(e){let{requestSchema:t,onInputChange:r}=e,[n,l]=(0,s.useState)({});if(!t)return(0,a.jsx)("div",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No input parameters required for this flow."});let i=t.properties||{},o=t.required||[],d=(e,t)=>{let a={...n,[e]:t};l(a),null==r||r(a)};return 0===Object.keys(i).length?(0,a.jsx)("div",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No input parameters defined for this flow."}):(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("h5",{className:"font-medium text-gray-900 dark:text-white",children:"Inputs"}),(0,a.jsx)("div",{className:"space-y-4",children:Object.entries(i).map(e=>{let[t,r]=e;return(0,a.jsx)(et,{name:t,property:r,required:o.includes(t),value:n[t],onChange:d},t)})})]})}var ea=r(8240),es=r(4823);function en(e){let{name:t,property:r,value:s}=e;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:r.title||t}),r.description&&(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r.description}),(()=>{switch(r.qtype_type){case"text":return(0,a.jsx)("div",{className:"bg-gray-50 dark:bg-gray-900 p-3 rounded",children:(0,a.jsx)(ea.oz,{remarkPlugins:[es.A],components:{code:e=>{let{children:t,...r}=e;return r.className?(0,a.jsx)("pre",{className:"bg-gray-100 dark:bg-gray-800 p-2 rounded text-xs overflow-x-auto",children:(0,a.jsx)("code",{...r,children:t})}):(0,a.jsx)("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded text-xs",...r,children:t})},table:e=>{let{children:t}=e;return(0,a.jsx)("div",{className:"overflow-x-auto mb-4",children:(0,a.jsx)("table",{className:"min-w-full border-collapse border border-gray-300 dark:border-gray-600",children:t})})},thead:e=>{let{children:t}=e;return(0,a.jsx)("thead",{className:"bg-gray-100 dark:bg-gray-800",children:t})},tbody:e=>{let{children:t}=e;return(0,a.jsx)("tbody",{children:t})},tr:e=>{let{children:t}=e;return(0,a.jsx)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:t})},th:e=>{let{children:t}=e;return(0,a.jsx)("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-700 dark:text-gray-300 border-r border-gray-300 dark:border-gray-600 last:border-r-0",children:t})},td:e=>{let{children:t}=e;return(0,a.jsx)("td",{className:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400 border-r border-gray-300 dark:border-gray-600 last:border-r-0",children:t})},h1:e=>{let{children:t}=e;return(0,a.jsx)("h1",{className:"text-xl font-bold mb-4 mt-6 text-gray-900 dark:text-gray-100 border-b border-gray-200 dark:border-gray-700 pb-2",children:t})},h2:e=>{let{children:t}=e;return(0,a.jsx)("h2",{className:"text-lg font-semibold mb-3 mt-5 text-gray-900 dark:text-gray-100",children:t})},h3:e=>{let{children:t}=e;return(0,a.jsx)("h3",{className:"text-base font-semibold mb-2 mt-4 text-gray-800 dark:text-gray-200",children:t})},h4:e=>{let{children:t}=e;return(0,a.jsx)("h4",{className:"text-sm font-medium mb-2 mt-3 text-gray-700 dark:text-gray-300",children:t})},ul:e=>{let{children:t}=e;return(0,a.jsx)("ul",{className:"mb-3 pl-0 space-y-1 text-gray-800 dark:text-gray-200",children:t})},ol:e=>{let{children:t}=e;return(0,a.jsx)("ol",{className:"mb-3 pl-0 space-y-1 text-gray-800 dark:text-gray-200",children:t})},li:e=>{let{children:t}=e;return(0,a.jsxs)("li",{className:"flex items-start ml-4",children:[(0,a.jsx)("span",{className:"mr-2 text-gray-500 dark:text-gray-400 select-none",children:"•"}),(0,a.jsx)("span",{className:"flex-1",children:t})]})},p:e=>{let{children:t}=e;return(0,a.jsx)("p",{className:"mb-3 text-gray-800 dark:text-gray-200 leading-relaxed",children:t})},strong:e=>{let{children:t}=e;return(0,a.jsx)("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",children:t})},blockquote:e=>{let{children:t}=e;return(0,a.jsx)("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic mb-3 text-gray-700 dark:text-gray-300",children:t})}},children:String(s||"")})});case"boolean":return(0,a.jsx)("div",{className:"bg-gray-50 dark:bg-gray-900 p-3 rounded",children:(0,a.jsx)("p",{className:"text-gray-800 dark:text-gray-200",children:String(s)})});case"number":case"int":case"float":return(0,a.jsx)("div",{className:"bg-gray-50 dark:bg-gray-900 p-3 rounded",children:(0,a.jsx)("p",{className:"text-gray-800 dark:text-gray-200 font-mono",children:String(s)})});default:return(0,a.jsx)(w,{variant:"destructive",children:(0,a.jsxs)(_,{children:["Unsupported response type: ",(0,a.jsx)("code",{className:"font-mono text-sm",children:r.qtype_type||r.type})]})})}})()]})}function el(e){let{responseSchema:t,responseData:r}=e;if(!r)return(0,a.jsx)("div",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No response data to display"});if(!(null==t?void 0:t.properties))return(0,a.jsx)("div",{className:"bg-gray-50 dark:bg-gray-900 p-4 rounded",children:(0,a.jsx)("pre",{className:"text-xs text-gray-800 dark:text-gray-200 overflow-x-auto whitespace-pre-wrap",children:JSON.stringify(r,null,2)})});let s=r&&"object"==typeof r?r.outputs||r:r||{};return(0,a.jsx)("div",{className:"space-y-4",children:t.properties&&Object.entries(t.properties).map(e=>{let[t,r]=e,n=s[t];return null==n?null:(0,a.jsx)(en,{name:t,property:r,value:n},t)})})}function ei(e){var t,r;let{flow:n}=e,[l,i]=(0,s.useState)({}),[o,d]=(0,s.useState)(!1),[c,m]=(0,s.useState)(null),[p,f]=(0,s.useState)(null),g=async()=>{d(!0),f(null),m(null);try{let e=await x.executeFlow(n.path,l);m(e)}catch(e){e instanceof u?f(e.message):f(e instanceof Error?e.message:"An unknown error occurred")}finally{d(!1)}};return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"border-b pb-4",children:[(0,a.jsx)("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:n.name}),(0,a.jsxs)("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:[n.path," • ",n.method.toUpperCase()]}),n.description&&(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-300 mt-2",children:n.description})]}),(0,a.jsx)(er,{requestSchema:n.requestSchema||null,onInputChange:e=>{i(e)}}),(0,a.jsxs)("div",{children:[p&&(0,a.jsx)(w,{variant:"destructive",className:"mb-4",children:(0,a.jsx)(_,{children:(0,a.jsxs)("div",{className:"whitespace-pre-line",children:[(0,a.jsx)("span",{className:"font-medium",children:"Error:"}),(0,a.jsx)("br",{}),p]})})}),c&&(0,a.jsx)(el,{responseSchema:null==(r=n.responseSchema)||null==(t=r.properties)?void 0:t.outputs,responseData:c})]}),(0,a.jsx)("div",{className:"mt-6 pt-4 border-t",children:(0,a.jsx)(M,{disabled:o,onClick:g,children:o?"Executing...":"Execute Flow"})})]})}var eo=r(8827),ed=r(3736);function ec(e){let{className:t,...r}=e;return(0,a.jsx)("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...r})}function eu(e){let{className:t,...r}=e;return(0,a.jsx)("div",{"data-slot":"card-header",className:o("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...r})}function em(e){let{className:t,...r}=e;return(0,a.jsx)("div",{"data-slot":"card-title",className:o("leading-none font-semibold",t),...r})}function ex(e){let{className:t,...r}=e;return(0,a.jsx)("div",{"data-slot":"card-description",className:o("text-muted-foreground text-sm",t),...r})}function ep(e){let{className:t,...r}=e;return(0,a.jsx)("div",{"data-slot":"card-content",className:o("px-6",t),...r})}var ef=r(9051);function eg(e){let{className:t,children:r,...s}=e;return(0,a.jsxs)(ef.bL,{"data-slot":"scroll-area",className:o("relative",t),...s,children:[(0,a.jsx)(ef.LM,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:r}),(0,a.jsx)(eh,{}),(0,a.jsx)(ef.OK,{})]})}function eh(e){let{className:t,orientation:r="vertical",...s}=e;return(0,a.jsx)(ef.VM,{"data-slot":"scroll-area-scrollbar",orientation:r,className:o("flex touch-none p-px transition-colors select-none","vertical"===r&&"h-full w-2.5 border-l border-l-transparent","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent",t),...s,children:(0,a.jsx)(ef.lr,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var eb=r(5657),ev=r(5736),ey=r(492),ej=r(1154),eN=r(2486),ew=r(4011);function ek(e){let{className:t,...r}=e;return(0,a.jsx)(ew.bL,{"data-slot":"avatar",className:o("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...r})}function e_(e){let{className:t,...r}=e;return(0,a.jsx)(ew.H4,{"data-slot":"avatar-fallback",className:o("bg-muted flex size-full items-center justify-center rounded-full",t),...r})}var eC=r(1007);function eS(e){let{mediaType:t,filename:r,url:s,size:n}=e;if(!s)return null;let l=null==t?void 0:t.startsWith("image/");return(0,a.jsx)("div",{className:"border rounded p-2 bg-background",children:l?(0,a.jsx)("img",{src:s,alt:r||"Attached image",className:"max-w-full h-auto rounded",style:{maxHeight:"200px"}}):(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(ey.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:r||"Attachment"}),t&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",t,")"]}),n&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["- ","".concat((n/1048576).toFixed(1)," MB")]})]})})}function ez(e){let{message:t}=e,r="user"===t.role,n=(0,s.useMemo)(()=>{var e;return t.content||(null==(e=t.parts)?void 0:e.filter(e=>"text"===e.type).map(e=>"text"in e?e.text:"").join(""))||""},[t]),l=(0,s.useMemo)(()=>{var e;return t.files||t.experimental_attachments||(null==(e=t.parts)?void 0:e.filter(e=>"file"===e.type))||[]},[t]);return(0,a.jsxs)("div",{className:"flex gap-3 w-full ".concat(r?"justify-end":"justify-start"),children:[!r&&(0,a.jsx)(ek,{className:"h-8 w-8 flex-shrink-0",children:(0,a.jsx)(e_,{children:(0,a.jsx)(eb.A,{className:"h-4 w-4"})})}),(0,a.jsxs)("div",{className:"flex-1 max-w-[75%] space-y-2",children:[n&&(0,a.jsx)("div",{className:"rounded-lg px-3 py-2 text-sm whitespace-pre-wrap break-words ".concat(r?"bg-primary text-primary-foreground":"bg-muted"),children:n}),l.map((e,t)=>(0,a.jsx)(eS,{mediaType:e.mediaType,filename:e.filename,url:e.url,size:e.size},"".concat(e.filename,"-").concat(t)))]}),r&&(0,a.jsx)(ek,{className:"h-8 w-8 flex-shrink-0",children:(0,a.jsx)(e_,{children:(0,a.jsx)(eC.A,{className:"h-4 w-4"})})})]})}var eA=r(4416);function eE(e){let{files:t,onRemoveFile:r,onClearAll:s}=e;return(0,a.jsxs)("div",{className:"mb-3 p-2 bg-muted rounded",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsxs)("span",{className:"text-sm font-medium",children:["Attachments (",t.length,")"]}),(0,a.jsx)(M,{type:"button",variant:"ghost",size:"sm",onClick:s,className:"h-6 px-2",children:"Clear all"})]}),(0,a.jsx)("div",{className:"space-y-1",children:t.map((e,t)=>{let s;return(0,a.jsxs)("div",{className:"flex items-center justify-between bg-background rounded p-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)(ey.A,{className:"h-4 w-4 flex-shrink-0"}),(0,a.jsx)("span",{className:"text-sm truncate",children:e.filename}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",(s=e.size||0,"".concat((s/1048576).toFixed(1)," MB")),")"]})]}),(0,a.jsx)(M,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(t),className:"h-6 w-6 p-0 flex-shrink-0","aria-label":"Remove ".concat(e.filename),children:(0,a.jsx)(eA.A,{className:"h-3 w-3"})})]},"".concat(e.filename,"-").concat(t))})})]})}let eT=()=>"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,12));function eq(e){let{flow:t}=e,[r,n]=(0,s.useState)(()=>eT()),[l,i]=(0,s.useState)(""),[o,d]=(0,s.useState)([]),[c,u]=(0,s.useState)(null),[m,p]=(0,s.useState)(null),f=(0,s.useRef)(null),g=(0,s.useRef)(null),h=(0,s.useRef)(null),b=(0,s.useMemo)(()=>new ed.rL({api:"".concat(x.getBaseUrl().replace(/\/$/,"")).concat(t.path)}),[t.path]),{messages:v,sendMessage:y,status:j,error:N,setMessages:w}=(0,eo.Y_)({id:r,transport:b,onFinish:()=>{p(null)}}),k="streaming"===j||"submitted"===j,_=("ready"===j||"error"===j)&&(l.trim()||o.length>0),C=(0,s.useCallback)(()=>{var e;null==(e=h.current)||e.scrollIntoView({behavior:"smooth"})},[]);(0,s.useEffect)(()=>{C()},[v,C]),(0,s.useEffect)(()=>{N&&m&&(i(m.input),d(m.files),p(null),w(e=>((e=e.filter(e=>e.parts.length>0)).length>0&&e.pop(),e)))},[N,m]),(0,s.useEffect)(()=>{var e;"ready"===j&&(null==(e=f.current)||e.focus())},[j]);let z=(0,s.useCallback)(()=>{i(""),d([]),u(null),g.current&&(g.current.value="")},[]),A=(0,s.useCallback)(()=>{n(eT()),w([]),p(null),z()},[w,z]),E=(0,s.useCallback)(e=>new Promise((t,r)=>{let a=new FileReader;a.onload=()=>t(a.result),a.onerror=r,a.readAsDataURL(e)}),[]),T=(0,s.useCallback)(async e=>{let t=e.target.files;if(t){u(null);try{let e=await Promise.all(Array.from(t).map(async e=>{let t=await E(e);return{type:"file",mediaType:e.type||"application/octet-stream",filename:e.name,url:t,size:e.size}}));d(t=>[...t,...e])}catch(t){let e=t instanceof Error?t.message:"Unknown error occurred";u("Failed to process files: ".concat(e))}}},[E]),q=(0,s.useCallback)(e=>{d(t=>t.filter((t,r)=>r!==e))},[]),U=(0,s.useCallback)(()=>{d([]),g.current&&(g.current.value="")},[]),O=(0,s.useCallback)(async e=>{if(e.preventDefault(),!_)return;let t=l.trim(),r=[...o];p({input:t,files:r}),z(),r.length>0?await y({role:"user",parts:[{type:"text",text:t||"[Files attached]"},...r.map(e=>({type:"file",mediaType:e.mediaType,filename:e.filename,url:e.url,size:e.size}))]}):await y({text:t})},[_,l,o,y,z]);return(0,a.jsxs)(ec,{className:"w-full max-w-4xl mx-auto h-[calc(100vh-12rem)] flex flex-col",children:[(0,a.jsx)(eu,{className:"flex-shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(em,{className:"flex items-center gap-2",children:[(0,a.jsx)(eb.A,{className:"h-5 w-5"}),t.name]}),t.description&&(0,a.jsx)(ex,{children:t.description})]}),(0,a.jsxs)(M,{variant:"outline",size:"sm",onClick:A,disabled:k,className:"flex items-center gap-2",children:[(0,a.jsx)(ev.A,{className:"h-4 w-4"}),"New Conversation"]})]})}),(0,a.jsxs)(ep,{className:"flex-1 flex flex-col p-0 min-h-0",children:[(0,a.jsx)(eg,{className:"flex-1 min-h-0",children:(0,a.jsxs)("div",{className:"space-y-4 p-4",children:[0===v.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center text-muted-foreground",children:[(0,a.jsx)(eb.A,{className:"h-12 w-12 mb-4 opacity-50"}),(0,a.jsx)("p",{children:"Start a conversation!"})]}):v.map(e=>(0,a.jsx)(ez,{message:e},e.id)),(0,a.jsx)("div",{ref:h})]})}),(0,a.jsxs)("div",{className:"border-t p-4",children:[N&&(0,a.jsxs)("div",{className:"mb-3 p-2 bg-destructive/10 text-destructive text-sm rounded",children:["Error: ",N.message]}),c&&(0,a.jsx)("div",{className:"mb-3 p-2 bg-destructive/10 text-destructive text-sm rounded",children:c}),o.length>0&&(0,a.jsx)(eE,{files:o,onRemoveFile:q,onClearAll:U}),(0,a.jsxs)("form",{onSubmit:O,className:"flex gap-2",children:[(0,a.jsx)("input",{ref:g,type:"file",multiple:!0,onChange:T,className:"hidden",accept:"*"}),(0,a.jsx)(M,{type:"button",variant:"outline",size:"icon",onClick:()=>{var e;return null==(e=g.current)?void 0:e.click()},disabled:k,"aria-label":"Attach file",children:(0,a.jsx)(ey.A,{className:"h-4 w-4"})}),(0,a.jsx)(S,{ref:f,value:l,onChange:e=>i(e.target.value),onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&_&&(e.preventDefault(),O(e))},disabled:k,placeholder:"Type your message... (Enter to send, Shift+Enter for new line)",className:"flex-1",autoFocus:!0}),(0,a.jsx)(M,{type:"submit",disabled:!_,size:"icon","aria-label":"Send message",children:k?(0,a.jsx)(ej.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(eN.A,{className:"h-4 w-4"})})]})]})]})]})}function eU(){var e;let{spec:t,isLoading:r,error:s}=f(),n=function(e){if(!(null==e?void 0:e.paths))return[];let t=[];return Object.entries(e.paths).forEach(r=>{let[a,s]=r;s&&["get","post","put","delete","patch","head","options","trace"].forEach(r=>{var n;let l=s[r];if(l&&(a.startsWith("/flows/")||(null==(n=l.tags)?void 0:n.includes("flow")))){let s,n=a.endsWith("/chat"),i=a.split("/");s=n?i[i.length-2]:i[i.length-1];let o="".concat(r,"-").concat(a.replace(/[^a-zA-Z0-9]/g,"_")),c=function(e,t){var r;if(!e.requestBody)return null;let a=e.requestBody.content;if(!a)return null;let s=Object.keys(a);if(0===s.length)return null;let n=null==(r=a[s[0]])?void 0:r.schema;return n?d(n,t):null}(l,e),u=function(e,t){var r;if(!e.responses)return null;let a=e.responses["200"];if(!a)return null;let s=a.content;if(!s)return null;let n=Object.keys(s);if(0===n.length)return null;let l=null==(r=s[n[0]])?void 0:r.schema;return l?d(l,t):null}(l,e);t.push({id:o,name:s.split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),path:a,method:r,mode:n?"Chat":"Complete",description:l.description||l.summary,operationId:l.operationId,tags:l.tags||[],requestSchema:c,responseSchema:u})}})}),t}(t||{});if(r)return(0,a.jsx)("p",{className:"text-muted-foreground text-sm",children:"Loading flows..."});if(s)return(0,a.jsxs)(w,{variant:"destructive",children:[(0,a.jsx)(C.A,{className:"h-4 w-4"}),(0,a.jsx)(k,{children:"Failed to load flows"}),(0,a.jsx)(_,{children:s.message})]});if(!n.length)return(0,a.jsxs)(w,{children:[(0,a.jsx)(C.A,{className:"h-4 w-4"}),(0,a.jsx)(k,{children:"No flows found"}),(0,a.jsx)(_,{children:'No flows were found in the API specification. Make sure your FastAPI server has endpoints tagged with "flow" or paths starting with "/flows/".'})]});if(1===n.length){let e=n[0];return(0,a.jsx)("div",{className:"w-full",children:"Chat"===e.mode?(0,a.jsx)(eq,{flow:e}):(0,a.jsx)(ei,{flow:e})})}return(0,a.jsx)("div",{className:"w-full",children:(0,a.jsxs)(h,{defaultValue:null==(e=n[0])?void 0:e.id,className:"w-full",children:[(0,a.jsx)(b,{className:"grid w-full",style:{gridTemplateColumns:"repeat(".concat(n.length,", minmax(0, 1fr))")},children:n.map(e=>(0,a.jsx)(v,{value:e.id,className:"text-sm",children:e.name},e.id))}),n.map(e=>(0,a.jsx)(y,{value:e.id,className:"mt-6",children:"Chat"===e.mode?(0,a.jsx)(eq,{flow:e}):(0,a.jsx)(ei,{flow:e})},e.id))]})})}function eO(){var e,t;let{spec:r,isLoading:n}=f(),l=(null==r||null==(e=r.info)?void 0:e.title)||"QType Frontend";return(0,s.useEffect)(()=>{n||(document.title=l)},[l,n]),(0,a.jsx)("div",{className:"font-sans min-h-screen p-6 sm:p-8",children:(0,a.jsxs)("main",{className:"max-w-6xl mx-auto space-y-6",children:[(0,a.jsxs)("div",{className:"text-center border-b pb-4",children:[(0,a.jsx)("h1",{className:"text-4xl font-bold text-gray-900 dark:text-white mb-2",children:l}),(null==r||null==(t=r.info)?void 0:t.description)&&(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-400 text-lg",children:r.info.description})]}),(0,a.jsx)(eU,{})]})})}}},e=>{e.O(0,[803,393,441,964,358],()=>e(e.s=2941)),_N_E=e.O()}]);