@nice2dev/ui-ai 1.2.2 → 1.3.0
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.
- package/CHANGELOG.md +376 -0
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +568 -555
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ Parse this description and return suggested values for each field as JSON: { ${a
|
|
|
8
8
|
`);return{fieldLabel:`Code editor (${t})`,fieldType:"code-editor",fieldValue:s||a,schema:{language:t,...i!=null&&i.framework?{framework:i.framework}:{},...(i==null?void 0:i.cursorLine)!=null?{cursorLine:i.cursorLine,cursorCol:i.cursorCol}:{}},customPrompt:`Language: ${t}${i!=null&&i.framework?`, framework: ${i.framework}`:""}.
|
|
9
9
|
Provide a concise inline completion or improvement hint for the code near the cursor. Limit response to ${(i==null?void 0:i.maxSuggestLines)??5} lines of code. If unsure, suggest the most idiomatic approach for this language/framework.`}}function ra(t,a,i){var s;const n=(i==null?void 0:i.mode)??"grammar",r={seo:"Analyze this HTML for SEO: missing meta tags, heading hierarchy (h1→h2→h3), keyword density, image alt attributes. Return a prioritized list of improvements.",accessibility:"Audit this HTML for WCAG 2.1 AA issues: missing aria labels, alt text, heading structure, color contrast hints, keyboard navigation. List specific fixes.",grammar:"Fix grammar, punctuation, and writing style in the visible text content. Return the corrected text only (no HTML tags in response).",cleanup:"Clean up malformed, redundant, or overly nested HTML. Simplify structure while preserving semantics and content."};return{fieldLabel:t,fieldType:"html-editor",fieldValue:a==null?void 0:a.slice(0,2e3),schema:{mode:n,...(s=i==null?void 0:i.targetKeywords)!=null&&s.length?{targetKeywords:i.targetKeywords}:{},...i!=null&&i.locale?{locale:i.locale}:{}},customPrompt:r[n]}}function na(t,a){const i=(a==null?void 0:a.mode)??"tag",n=`"${t}"`+((a==null?void 0:a.bpm)!=null?`, BPM: ${a.bpm}`:"")+(a!=null&&a.key?`, Key: ${a.key}`:"")+(a!=null&&a.genre?`, Genre: ${a.genre}`:"")+((a==null?void 0:a.duration)!=null?`, Duration: ${a.duration}s`:""),r={tag:`Audio: ${n}. Suggest genre tags, mood descriptors and playlist categories. Return as JSON array of strings.`,bpm:`Audio: ${n}. Suggest likely BPM range and musical key based on metadata. Return as JSON: { bpm: number, key: string }.`,mix:`Track: ${n}. Suggest EQ curve (JSON array of {freq, gain, q}), compression settings, and 2-3 compatible tracks for mixing.`,transcribe:"Return a transcription of the spoken audio content as JSON: { transcript: string, language: string, confidence: number }."};return{fieldLabel:`Audio: ${t}`,fieldType:"audio",schema:{mode:i,...(a==null?void 0:a.bpm)!=null?{bpm:a.bpm}:{},...a!=null&&a.key?{key:a.key}:{},...(a==null?void 0:a.duration)!=null?{duration:a.duration}:{},...a!=null&&a.genre?{genre:a.genre}:{}},customPrompt:r[i]}}function sa(t,a){var s;const i=(a==null?void 0:a.mode)??"material",n=(a==null?void 0:a.targetDevice)??"web",r={material:`Scene "${t}", ${(a==null?void 0:a.meshCount)??"?"} meshes. Materials: ${((s=a==null?void 0:a.materials)==null?void 0:s.join(", "))||"none"}. Suggest PBR properties (roughness, metalness, baseColor) and texture maps for each material.`,optimize:`Scene "${t}", triangles: ${(a==null?void 0:a.triangleCount)??"?"}, target: ${n}. Identify budget issues and suggest LOD levels, mesh merging, and texture atlas strategy.`,lighting:`Scene "${t}", target: ${n}. Suggest a complete lighting setup (types, intensity, color, shadow settings) for realistic rendering.`,animation:`Rig in scene "${t}". Suggest animation approach (FK/IK, bone count), keyframe timing and easing curves for natural movement.`};return{fieldLabel:`3D scene: ${t}`,fieldType:"3d-scene",schema:{mode:i,...(a==null?void 0:a.meshCount)!=null?{meshes:a.meshCount}:{},...(a==null?void 0:a.triangleCount)!=null?{triangles:a.triangleCount}:{},...a!=null&&a.targetDevice?{target:a.targetDevice}:{}},customPrompt:r[i]}}function ca(t,a){const i=(a==null?void 0:a.mode)??"palette",n=(a==null?void 0:a.width)!=null?`${a.width}×${a.height??"?"}px`:"unknown dimensions",r={filter:`Image "${t}" (${n}). Suggest CSS/SVG filter parameters (brightness, contrast, saturate, hue-rotate, blur) as JSON: { brightness, contrast, saturate, hueRotate, blur }.`,palette:`Image "${t}". Extract or suggest a harmonious 5-color palette as JSON: { primary, secondary, accent, background, text }.`,upscale:`Image "${t}" at ${n}. Recommend upscaling strategy: model (ESRGAN/RealSR/SRCNN), scale factor, and expected quality gain.`,"style-transfer":`Image "${t}", target style: "${(a==null?void 0:a.targetStyle)??"artistic"}". Suggest style-transfer settings as JSON: { contentWeight, styleWeight, iterations, patchSize }.`};return{fieldLabel:`Graphics: ${t}`,fieldType:"graphics",schema:{mode:i,...(a==null?void 0:a.width)!=null?{width:a.width,height:a.height}:{},...a!=null&&a.targetStyle?{targetStyle:a.targetStyle}:{}},customPrompt:r[i]}}function oa(t,a){var i;return{fieldLabel:"Icon search",fieldType:"icon-picker",fieldValue:t,schema:{...a!=null&&a.style?{iconStyle:a.style}:{},...(a==null?void 0:a.limit)!=null?{maxResults:a.limit}:{},...(i=a==null?void 0:a.availableIcons)!=null&&i.length?{sampleIcons:a.availableIcons.slice(0,30)}:{}},customPrompt:`User query: "${t}"
|
|
10
10
|
Return the ${(a==null?void 0:a.limit)??5} most semantically relevant icon names from the available set as a JSON array of strings, ordered by relevance. Prefer specific over generic names.`}}function Ka(t,a,i){const n=l.useMemo(()=>ta(t,a,i),[t,a,i==null?void 0:i.cursorLine,i==null?void 0:i.cursorCol,i==null?void 0:i.framework]);return Q(n,i)}function Va(t,a,i){const n=l.useMemo(()=>ra(t,a,i),[t,a,i==null?void 0:i.mode,i==null?void 0:i.locale]);return Q(n,i)}function Ya(t,a){const i=l.useMemo(()=>na(t,a),[t,a==null?void 0:a.bpm,a==null?void 0:a.key,a==null?void 0:a.duration,a==null?void 0:a.mode]);return Q(i,a)}function Xa(t,a){const i=l.useMemo(()=>sa(t,a),[t,a==null?void 0:a.meshCount,a==null?void 0:a.triangleCount,a==null?void 0:a.targetDevice,a==null?void 0:a.mode]);return Q(i,a)}function Qa(t,a){const i=l.useMemo(()=>ca(t,a),[t,a==null?void 0:a.width,a==null?void 0:a.height,a==null?void 0:a.mode,a==null?void 0:a.targetStyle]);return Q(i,a)}function Za(t,a){const i=l.useMemo(()=>oa(t,a),[t,a==null?void 0:a.limit,a==null?void 0:a.style]);return Q(i,{...a,disabled:!t||(a==null?void 0:a.disabled)})}function la(t,a){var s;const i=(a==null?void 0:a.mode)??"npc-decision",n=(a==null?void 0:a.genre)??"fantasy",r={"npc-decision":`You are an AI game director. The NPC "${t}" must make a decision. Available BT nodes: ${JSON.stringify((a==null?void 0:a.btStatus)??[])}. Game state: ${JSON.stringify((a==null?void 0:a.gameState)??{})}. Return the name of the BT node to activate next, and one sentence of reasoning.`,dialogue:`You are a ${n} RPG writer. Write a short in-character dialogue line for NPC "${t}". Game state: ${JSON.stringify((a==null?void 0:a.gameState)??{})}. Max 2 sentences, no narrative descriptions.`,"procedural-level":`You are a ${n} game designer. Suggest a procedural level layout for a zone containing "${t}". Describe room count, enemy placement, loot, and one unique mechanic. Keep it under 150 words.`,"quest-description":`You are a ${n} quest designer. Write a compelling quest description involving "${t}". Include: objective, giver NPC, rewards, and a short flavour paragraph. Keep it under 120 words.`,"item-description":`You are a ${n} lore writer. Write a short item description for an item related to "${t}". Include: item name, rarity, flavour text, and one special property. Keep it under 80 words.`};return{fieldLabel:t,fieldType:`game-engine:${i}`,fieldValue:a==null?void 0:a.gameState,customPrompt:r[i],schema:{genre:n,mode:i,btNodes:(s=a==null?void 0:a.btStatus)==null?void 0:s.map(o=>o.node)}}}function ei(t,a){const i=JSON.stringify(a==null?void 0:a.btStatus),n=JSON.stringify(a==null?void 0:a.gameState),r=l.useMemo(()=>la(t,a),[t,a==null?void 0:a.mode,a==null?void 0:a.genre,i,n]);return Q(r,a)}function da(t,a,i){const n=(i==null?void 0:i.mode)??"layout",r=(i==null?void 0:i.diagramType)??"flowchart",s={layout:`You are a diagram layout optimizer. Given this ${r} with ${t.length} nodes and ${a.length} edges, suggest optimal positions for each node to minimize edge crossings and improve readability. Return JSON: { suggestions: [{ id: string, x: number, y: number, reason: string }] }. Consider flow direction (top-to-bottom or left-to-right) and grouping related nodes.`,structure:`You are a diagram analyst. Analyze this ${r} structure. Identify: 1) Missing connections, 2) Potential bottlenecks, 3) Orphan nodes, 4) Cycles or loops. Return JSON: { issues: [{ type: string, description: string, nodeIds: string[] }], score: number }`,simplify:`You are a diagram simplifier. Suggest how to simplify this ${r} while preserving meaning. Identify: nodes that could be merged, redundant edges, or overly complex branches. Return JSON: { simplifications: [{ action: 'merge'|'remove'|'group', ids: string[], reason: string }] }`,group:`You are a diagram organizer. Suggest logical groupings for nodes in this ${r}. Consider semantic relationships, data flow patterns, and visual clustering. Return JSON: { groups: [{ name: string, nodeIds: string[], color?: string }] }`},o=t.map(m=>{var p;return{id:m.id,type:m.type,label:(p=m.label)==null?void 0:p.slice(0,30),pos:[Math.round(m.x),Math.round(m.y)]}}),c=a.map(m=>({id:m.id,src:m.source,tgt:m.target}));return{fieldLabel:`Diagram (${r})`,fieldType:`diagram:${n}`,fieldValue:JSON.stringify({nodes:o,edges:c}),schema:{diagramType:r,mode:n,nodeCount:t.length,edgeCount:a.length,containerSize:i==null?void 0:i.containerSize},customPrompt:s[n]}}function ai(t,a,i){const n=l.useMemo(()=>da(t,a,i),[JSON.stringify(t),JSON.stringify(a),i==null?void 0:i.mode,i==null?void 0:i.diagramType]);return Q(n,{...i,disabled:t.length===0||(i==null?void 0:i.disabled)})}function ua(t,a){const i=(a==null?void 0:a.mode)??"generate",n=(a==null?void 0:a.presentationType)??"business",r=(a==null?void 0:a.duration)??15,s=Math.ceil(r/2),o={generate:`You are a presentation designer. Create a ${n} presentation outline based on: "${t}". Target audience: ${(a==null?void 0:a.audience)??"general"}. Duration: ${r} minutes (~${s} slides). Return JSON: { title: string, slides: [{ title: string, layout: 'title'|'content'|'two-column'|'chart'|'image', bullets?: string[], chartType?: string, speakerNotes?: string }] }. Include: clear slide titles, 3-5 bullet points per content slide, and brief speaker notes.`,summarize:`You are a presentation optimizer. Summarize this presentation to be more concise: "${t}". Reduce slide count by 30% while preserving key messages. Return JSON: { summary: string, reducedSlides: [{ title: string, keyPoints: string[] }] }`,expand:`You are a presentation expert. Expand this brief outline into a detailed presentation: "${t}". Add supporting details, examples, and transitions. Target: ${s} slides. Return JSON: { slides: [{ title: string, content: string, transitions?: string, animations?: string[] }] }`,improve:`You are a presentation coach. Review and improve this presentation structure: "${t}". Suggest: better flow, stronger opening/closing, clearer data visualization. Return JSON: { improvements: [{ slide: number, issue: string, suggestion: string }], score: number }`};return{fieldLabel:`Presentation (${n})`,fieldType:`presentation:${i}`,fieldValue:t,schema:{presentationType:n,mode:i,duration:r,slideCount:s,audience:a==null?void 0:a.audience,hasData:(a==null?void 0:a.dataContext)!=null},customPrompt:o[i]}}function ii(t,a){const i=l.useMemo(()=>ua(t,a),[t,a==null?void 0:a.mode,a==null?void 0:a.presentationType,a==null?void 0:a.duration,a==null?void 0:a.audience]);return Q(i,{...a,disabled:!t||(a==null?void 0:a.disabled)})}function ma(t,a){var r;const i=(a==null?void 0:a.mode)??"all",n={alignment:"Analyze element alignment on this slide. Suggest adjustments to create visual harmony. Return JSON: { suggestions: [{ elementIndex: number, issue: string, fixX?: number, fixY?: number }] }",contrast:"Analyze color contrast and readability. Suggest improvements for accessibility (WCAG AA). Return JSON: { suggestions: [{ area: string, currentContrast: number, suggestedFix: string }] }",spacing:"Analyze whitespace and element spacing. Apply the rule of thirds and consistent margins. Return JSON: { suggestions: [{ elementIndex: number, issue: string, suggestedMargin: number }] }",typography:"Analyze typography: hierarchy, font sizes, line heights, readability. Return JSON: { suggestions: [{ area: string, issue: string, suggestedFontSize?: number }] }",all:"Perform a complete design review of this slide. Check alignment, contrast, spacing, and typography. Return JSON: { score: number, suggestions: [{ category: string, issue: string, fix: string }] }. Prioritize issues by impact on visual clarity."};return{fieldLabel:t.title??"Slide Design",fieldType:`slide-design:${i}`,fieldValue:JSON.stringify(t),schema:{mode:i,hasElements:(((r=t.elements)==null?void 0:r.length)??0)>0,layout:t.layout,brandColors:a==null?void 0:a.brandColors},customPrompt:n[i]}}function ti(t,a){const i=l.useMemo(()=>ma(t,a),[JSON.stringify(t),a==null?void 0:a.mode,JSON.stringify(a==null?void 0:a.brandColors)]);return Q(i,a)}function ri(t,a,i){const n=l.forwardRef((r,s)=>{const{aiEnabled:o=!0,aiPosition:c="right",aiPrompt:m,aiDebounceMs:p=500,aiShowOnHover:d=!1,aiTriggerIcon:x,...N}=r,A=l.useMemo(()=>{const R=a(N);return m&&(R.customPrompt=m),R},[N,m]);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(t,{...N,ref:s}),o&&e.jsx(ea,{context:A,position:c,debounceMs:p,showOnHover:d,triggerIcon:x})]})});return n.displayName=i??`withAIHint(${t.displayName??t.name??"Component"})`,n}function ni(t){return Le(t.label??"Text",t.value,{placeholder:t.placeholder,maxLength:t.maxLength})}function si(t){return ze(t.label??"Number",t.value,{min:t.min,max:t.max,step:t.step})}function ci(t){return Me(t.label??"Select",t.value,{options:t.options,multiple:t.multiple})}function oi(t){return $e(t.label??"Date",t.value,{min:t.min,max:t.max})}function li(t){return Pe(t.label??"Color",t.value)}const di=t=>({id:T.createId(),name:t,type:"classification",status:"draft",datasets:[],experiments:[],models:[],createdAt:new Date,updatedAt:new Date}),je={classification:[{id:"logistic-regression",key:"mlStudio.alg.logisticRegression",name:"Logistic Regression"},{id:"random-forest",key:"mlStudio.alg.randomForest",name:"Random Forest"},{id:"gradient-boosting",key:"mlStudio.alg.gradientBoosting",name:"Gradient Boosting"},{id:"svm",key:"mlStudio.alg.svm",name:"Support Vector Machine"},{id:"neural-network",key:"mlStudio.alg.neuralNetwork",name:"Neural Network"},{id:"xgboost",key:"mlStudio.alg.xgboost",name:"XGBoost"}],regression:[{id:"linear-regression",key:"mlStudio.alg.linearRegression",name:"Linear Regression"},{id:"ridge",key:"mlStudio.alg.ridge",name:"Ridge Regression"},{id:"lasso",key:"mlStudio.alg.lasso",name:"Lasso Regression"},{id:"random-forest-reg",key:"mlStudio.alg.randomForest",name:"Random Forest"},{id:"gradient-boosting-reg",key:"mlStudio.alg.gradientBoosting",name:"Gradient Boosting"}],clustering:[{id:"kmeans",key:"mlStudio.alg.kmeans",name:"K-Means"},{id:"dbscan",key:"mlStudio.alg.dbscan",name:"DBSCAN"},{id:"hierarchical",key:"mlStudio.alg.hierarchical",name:"Hierarchical Clustering"}]},ui=Object.values(je).flat(),Fe=(t,a)=>{const i=ui.find(n=>n.id===t);return i?a(i.key,i.name):t},mi=[["classification","mlStudio.type.classification","Classification"],["regression","mlStudio.type.regression","Regression"],["clustering","mlStudio.type.clustering","Clustering"],["object-detection","mlStudio.type.objectDetection","Object Detection"],["nlp","mlStudio.type.nlp","NLP"],["time-series","mlStudio.type.timeSeries","Time Series"]],pi=[["data","mlStudio.tab.data","Data"],["experiments","mlStudio.tab.experiments","Experiments"],["models","mlStudio.tab.models","Models"],["deploy","mlStudio.tab.deploy","Deploy"]],gi=[["numeric","mlStudio.colType.numeric","Numeric"],["categorical","mlStudio.colType.categorical","Categorical"],["text","mlStudio.colType.text","Text"],["datetime","mlStudio.colType.datetime","DateTime"],["boolean","mlStudio.colType.boolean","Boolean"],["embedding","mlStudio.colType.embedding","Embedding"]],hi={train:["mlStudio.split.train","Train"],validation:["mlStudio.split.validation","Validation"],test:["mlStudio.split.test","Test"]},fi={pending:["mlStudio.experimentStatus.pending","Pending"],running:["mlStudio.experimentStatus.running","Running"],completed:["mlStudio.experimentStatus.completed","Completed"],failed:["mlStudio.experimentStatus.failed","Failed"],cancelled:["mlStudio.experimentStatus.cancelled","Cancelled"]},xi={draft:["mlStudio.modelStatus.draft","Draft"],registered:["mlStudio.modelStatus.registered","Registered"],staging:["mlStudio.modelStatus.staging","Staging"],production:["mlStudio.modelStatus.production","Production"],archived:["mlStudio.modelStatus.archived","Archived"]},bi={pending:["mlStudio.deploymentStatus.pending","Pending"],deploying:["mlStudio.deploymentStatus.deploying","Deploying"],running:["mlStudio.deploymentStatus.running","Running"],stopped:["mlStudio.deploymentStatus.stopped","Stopped"],failed:["mlStudio.deploymentStatus.failed","Failed"]},ce=(t,a,i)=>t?i(t[0],t[1]):a,yi=new Set(["accuracy","precision","recall","f1-score","auc-roc"]),Je=({name:t,value:a},i)=>yi.has(t)?`${(a*100).toLocaleString(i,{minimumFractionDigits:1,maximumFractionDigits:1})}%`:a.toLocaleString(i,{maximumFractionDigits:3}),vi=[{target:".nice-ml-studio",titleKey:"tutorial.mlStudio.intro.title",title:"ML studio",contentKey:"tutorial.mlStudio.intro.content",content:"Work through the tabs: prepare datasets, run experiments, compare and pick models, then deploy the best one.",placement:"auto"}],_i=({project:t,onProjectChange:a,onExperimentRun:i,onModelDeploy:n,onModelDownload:r,className:s="",tutorial:o})=>{var X;const{t:c,lang:m}=T.useNiceTranslation(),[p,d]=l.useState(()=>t||di(c("mlStudio.newProject","New ML Project"))),[x,N]=l.useState("data"),[A,R]=l.useState(null),[$,M]=l.useState(null),[g,u]=l.useState(null),[y,_]=l.useState(!1),[C,v]=l.useState({algorithm:"",hyperparameters:{},preprocessing:[]}),h=l.useRef(p),w=l.useCallback(S=>{const b=h.current,B={...b,...typeof S=="function"?S(b):S,updatedAt:new Date};h.current=B,d(B),a==null||a(B)},[a]),f=async S=>{for(const b of Array.from(S)){const B={id:T.createId(),name:b.name.replace(/\.[^.]+$/,""),type:"tabular",source:{type:"file",uri:b.name},size:b.size,rowCount:0,columns:[],splits:[{name:"train",ratio:.8,rowCount:0},{name:"validation",ratio:.1,rowCount:0},{name:"test",ratio:.1,rowCount:0}],createdAt:new Date};if(b.name.endsWith(".csv")){const J=(await b.text()).split(`
|
|
11
|
-
`),H=J[0].split(",").map(V=>V.trim());B.rowCount=J.length-1,B.columns=H.map(V=>({name:V,type:"text",nullable:!0,unique:0,missing:0})),B.splits=B.splits.map(V=>({...V,rowCount:Math.floor(B.rowCount*V.ratio)}))}w(U=>({datasets:[...U.datasets,B]}))}},j=S=>{w({datasets:p.datasets.filter(b=>b.id!==S)}),A===S&&R(null)},k=async()=>{if(!C.algorithm||!A)return;const S={id:T.createId(),name:c("mlStudio.experimentName","Experiment {n}").replace("{n}",String(p.experiments.length+1)),status:"pending",config:C,metrics:[],artifacts:[],logs:[]},b=U=>w(J=>({experiments:J.experiments.map(H=>H.id===S.id?{...H,...U}:H)}));if(w(U=>({experiments:[...U.experiments,S]})),_(!1),!i)return;const B=new Date;b({status:"running",startedAt:B});try{const U=await i(S),J=typeof U=="object"&&U!==null?U:{},H=new Date;b({status:"completed",completedAt:H,duration:J.duration??(H.getTime()-B.getTime())/1e3,metrics:J.metrics??[],artifacts:J.artifacts??[],logs:J.logs??[]})}catch{b({status:"failed"})}},I=S=>{const b=p.experiments.find(J=>J.id===S);if(!b)return;const B=b.artifacts.filter(J=>J.type==="model"),U={id:T.createId(),name:c("mlStudio.modelFrom","Model from {name}").replace("{name}",b.name),version:"1.0.0",algorithm:b.config.algorithm,experimentId:S,status:"registered",metrics:b.metrics,size:B.reduce((J,H)=>J+H.size,0),artifacts:B,deployments:[],createdAt:new Date};w(J=>({models:[...J.models,U]}))},z=async S=>{const b=p.models.find(U=>U.id===S);if(!b||!n)return;const B=await n(b);w(U=>({models:U.models.map(J=>J.id===S?{...J,status:"production",deployments:[...J.deployments,B]}:J)}))},E=S=>S<1024?`${S} B`:S<1024*1024?`${(S/1024).toFixed(1)} KB`:S<1024*1024*1024?`${(S/1024/1024).toFixed(1)} MB`:`${(S/1024/1024/1024).toFixed(1)} GB`,P=S=>{switch(S){case"completed":case"production":case"running":return"success";case"pending":case"staging":return"pending";case"failed":return"error";case"deploying":case"stopped":return S;default:return"neutral"}},F=e.jsxs("div",{className:"nice-ml-studio__header-info",children:[e.jsx("input",{type:"text",value:p.name,onChange:S=>w({name:S.target.value}),className:"nice-ml-studio__project-name-input","aria-label":c("mlStudio.projectName","Project name")}),e.jsx("select",{value:p.type,onChange:S=>w({type:S.target.value}),className:"nice-ml-studio__project-type-select","aria-label":c("mlStudio.projectType","Project type"),children:mi.map(([S,b,B])=>e.jsx("option",{value:S,children:c(b,B)},S))})]}),G=e.jsx("div",{className:"nice-ml-studio__header-tabs",children:pi.map(([S,b,B])=>e.jsx("button",{className:`nice-ml-studio__tab-button ${x===S?"nice-ml-studio__tab-button--active":""}`,onClick:()=>N(S),children:c(b,B)},S))}),K=e.jsxs("div",{className:"nice-ml-studio__content",children:[x==="data"&&e.jsxs("div",{className:"nice-ml-studio__data-panel",children:[e.jsxs("div",{className:"nice-ml-studio__panel-header",children:[e.jsx("h2",{children:c("mlStudio.datasets","Datasets")}),e.jsxs("label",{className:"nice-ml-studio__upload-button",children:[e.jsx("input",{type:"file",multiple:!0,accept:".csv,.json,.parquet",onChange:S=>S.target.files&&f(S.target.files),hidden:!0}),e.jsx(T.NiceIcon,{name:"plus",size:14})," ",c("mlStudio.uploadDataset","Upload Dataset")]})]}),e.jsx("div",{className:"nice-ml-studio__datasets-grid",children:p.datasets.length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"bar-chart",size:32})}),e.jsx("p",{children:c("mlStudio.noDatasets","No datasets uploaded yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noDatasetsHint","Upload CSV, JSON, or Parquet files to get started")})]}):p.datasets.map(S=>e.jsxs("div",{className:`nice-ml-studio__dataset-card ${A===S.id?"nice-ml-studio__dataset-card--selected":""}`,onClick:()=>R(S.id),children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("span",{className:"nice-ml-studio__dataset-icon",children:e.jsx(T.NiceIcon,{name:"folder",size:16})}),e.jsx("h3",{children:S.name}),e.jsx("button",{className:"nice-ml-studio__remove-button","aria-label":c("mlStudio.removeDataset","Remove dataset"),onClick:b=>{b.stopPropagation(),j(S.id)},children:e.jsx(T.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-ml-studio__card-stats",children:[e.jsx("span",{children:c("mlStudio.rows","{count} rows").replace("{count}",S.rowCount.toLocaleString(m))}),e.jsx("span",{children:c("mlStudio.columnCount","{count} columns").replace("{count}",String(S.columns.length))}),e.jsx("span",{children:E(S.size)})]}),e.jsx("div",{className:"nice-ml-studio__splits-bar",children:S.splits.map(b=>e.jsx("div",{className:`nice-ml-studio__split nice-ml-studio__split--${b.name}`,style:{width:`${b.ratio*100}%`},title:`${ce(hi[b.name],b.name,c)}: ${(b.ratio*100).toFixed(0)}%`},b.name))})]},S.id))}),A&&e.jsx("div",{className:"nice-ml-studio__dataset-details",children:(()=>{const S=p.datasets.find(b=>b.id===A);return S?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:c("mlStudio.columns","Columns")}),e.jsxs("table",{className:"nice-ml-studio__columns-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:c("mlStudio.col.name","Name")}),e.jsx("th",{children:c("mlStudio.col.type","Type")}),e.jsx("th",{children:c("mlStudio.col.missing","Missing")}),e.jsx("th",{children:c("mlStudio.col.unique","Unique")})]})}),e.jsx("tbody",{children:S.columns.map(b=>e.jsxs("tr",{children:[e.jsx("td",{children:b.name}),e.jsx("td",{children:e.jsx("select",{value:b.type,"aria-label":c("mlStudio.col.type","Type"),onChange:B=>{w({datasets:p.datasets.map(U=>U.id===S.id?{...U,columns:U.columns.map(J=>J.name===b.name?{...J,type:B.target.value}:J)}:U)})},children:gi.map(([B,U,J])=>e.jsx("option",{value:B,children:c(U,J)},B))})}),e.jsx("td",{children:b.missing}),e.jsx("td",{children:b.unique})]},b.name))})]})]}):null})()})]}),x==="experiments"&&e.jsxs("div",{className:"nice-ml-studio__experiments-panel",children:[e.jsxs("div",{className:"nice-ml-studio__panel-header",children:[e.jsx("h2",{children:c("mlStudio.tab.experiments","Experiments")}),e.jsxs("button",{className:"nice-ml-studio__primary-button",onClick:()=>_(!0),disabled:p.datasets.length===0,children:[e.jsx(T.NiceIcon,{name:"plus",size:14})," ",c("mlStudio.newExperiment","New Experiment")]})]}),y&&e.jsxs("div",{className:"nice-ml-studio__new-experiment-form",children:[e.jsx("h3",{children:c("mlStudio.configureExperiment","Configure Experiment")}),e.jsxs("div",{className:"nice-ml-studio__form-grid",children:[e.jsxs("label",{children:[c("mlStudio.dataset","Dataset"),e.jsxs("select",{value:A||"",onChange:S=>R(S.target.value),children:[e.jsx("option",{value:"",children:c("mlStudio.selectDataset","Select dataset...")}),p.datasets.map(S=>e.jsx("option",{value:S.id,children:S.name},S.id))]})]}),e.jsxs("label",{children:[c("mlStudio.algorithm","Algorithm"),e.jsxs("select",{value:C.algorithm,onChange:S=>v({...C,algorithm:S.target.value}),children:[e.jsx("option",{value:"",children:c("mlStudio.selectAlgorithm","Select algorithm...")}),(je[p.type]||je.classification).map(S=>e.jsx("option",{value:S.id,children:c(S.key,S.name)},S.id))]})]}),A&&e.jsxs("label",{children:[c("mlStudio.targetColumn","Target Column"),e.jsxs("select",{value:C.targetColumn||"",onChange:S=>v({...C,targetColumn:S.target.value}),children:[e.jsx("option",{value:"",children:c("mlStudio.selectTarget","Select target...")}),(X=p.datasets.find(S=>S.id===A))==null?void 0:X.columns.map(S=>e.jsx("option",{value:S.name,children:S.name},S.name))]})]})]}),e.jsxs("div",{className:"nice-ml-studio__form-actions",children:[e.jsx("button",{className:"nice-ml-studio__secondary-button",onClick:()=>_(!1),children:c("cancel","Cancel")}),e.jsx("button",{className:"nice-ml-studio__primary-button",onClick:k,disabled:!C.algorithm||!A,children:c("mlStudio.runExperiment","Run Experiment")})]})]}),e.jsx("div",{className:"nice-ml-studio__experiments-list",children:p.experiments.length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"flask",size:32})}),e.jsx("p",{children:c("mlStudio.noExperiments","No experiments yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noExperimentsHint","Create an experiment to train and evaluate models")})]}):p.experiments.map(S=>e.jsxs("div",{className:`nice-ml-studio__experiment-card ${$===S.id?"nice-ml-studio__experiment-card--selected":""}`,onClick:()=>M(S.id),children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("h3",{children:S.name}),e.jsx("span",{className:`nice-ml-studio__status-badge nice-ml-studio__status-badge--${P(S.status)}`,children:ce(fi[S.status],S.status,c)})]}),e.jsxs("div",{className:"nice-ml-studio__card-meta",children:[e.jsx("span",{children:c("mlStudio.algorithmValue","Algorithm: {name}").replace("{name}",Fe(S.config.algorithm,c))}),S.duration!==void 0&&e.jsx("span",{children:c("mlStudio.duration","Duration: {seconds}s").replace("{seconds}",String(Math.round(S.duration)))})]}),S.metrics.length>0&&e.jsx("div",{className:"nice-ml-studio__metrics-row",children:S.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"nice-ml-studio__metric-item",children:[e.jsx("span",{className:"nice-ml-studio__metric-name",children:b.name}),e.jsx("span",{className:"nice-ml-studio__metric-value",children:Je(b,m)})]},b.name))}),S.status==="completed"&&e.jsx("button",{className:"nice-ml-studio__action-button",onClick:b=>{b.stopPropagation(),I(S.id)},children:c("mlStudio.registerModel","Register Model")})]},S.id))})]}),x==="models"&&e.jsxs("div",{className:"nice-ml-studio__models-panel",children:[e.jsx("div",{className:"nice-ml-studio__panel-header",children:e.jsx("h2",{children:c("mlStudio.tab.models","Models")})}),e.jsx("div",{className:"nice-ml-studio__models-list",children:p.models.length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"wand",size:32})}),e.jsx("p",{children:c("mlStudio.noModels","No models registered yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noModelsHint","Complete experiments and register models")})]}):p.models.map(S=>e.jsxs("div",{className:`nice-ml-studio__model-card ${g===S.id?"nice-ml-studio__model-card--selected":""}`,onClick:()=>u(S.id),children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("h3",{children:S.name}),e.jsx("span",{className:`nice-ml-studio__status-badge nice-ml-studio__status-badge--${P(S.status)}`,children:ce(xi[S.status],S.status,c)})]}),e.jsxs("div",{className:"nice-ml-studio__card-meta",children:[e.jsx("span",{children:c("mlStudio.algorithmValue","Algorithm: {name}").replace("{name}",Fe(S.algorithm,c))}),e.jsx("span",{children:c("mlStudio.version","Version: {version}").replace("{version}",S.version)}),S.size>0&&e.jsx("span",{children:c("mlStudio.size","Size: {size}").replace("{size}",E(S.size))})]}),S.metrics.length>0&&e.jsx("div",{className:"nice-ml-studio__metrics-row",children:S.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"nice-ml-studio__metric-item",children:[e.jsx("span",{className:"nice-ml-studio__metric-name",children:b.name}),e.jsx("span",{className:"nice-ml-studio__metric-value",children:Je(b,m)})]},b.name))}),e.jsxs("div",{className:"nice-ml-studio__card-actions",children:[e.jsx("button",{className:"nice-ml-studio__action-button",onClick:b=>{b.stopPropagation(),r==null||r(S)},disabled:!r,title:r?void 0:c("mlStudio.downloadNotSetUp","Downloading models is not set up"),children:c("download","Download")}),e.jsx("button",{className:"nice-ml-studio__action-button nice-ml-studio__action-button--primary",onClick:b=>{b.stopPropagation(),z(S.id)},disabled:S.status==="production"||!n,title:n?void 0:c("mlStudio.deployNotSetUp","Deploying models is not set up"),children:S.status==="production"?c("mlStudio.deployed","Deployed"):c("mlStudio.deploy","Deploy")})]})]},S.id))})]}),x==="deploy"&&e.jsxs("div",{className:"nice-ml-studio__deploy-panel",children:[e.jsx("div",{className:"nice-ml-studio__panel-header",children:e.jsx("h2",{children:c("mlStudio.deployments","Deployments")})}),e.jsx("div",{className:"nice-ml-studio__deployments-list",children:p.models.filter(S=>S.deployments.length>0).length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"rocket",size:32})}),e.jsx("p",{children:c("mlStudio.noDeployments","No deployments yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noDeploymentsHint","Deploy a model to create inference endpoints")})]}):p.models.filter(S=>S.deployments.length>0).flatMap(S=>S.deployments.map(b=>({model:S,deployment:b}))).map(({model:S,deployment:b})=>e.jsxs("div",{className:"nice-ml-studio__deployment-card",children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("h3",{children:b.name}),e.jsx("span",{className:`nice-ml-studio__status-badge nice-ml-studio__status-badge--${P(b.status)}`,children:ce(bi[b.status],b.status,c)})]}),e.jsxs("div",{className:"nice-ml-studio__card-meta",children:[e.jsx("span",{children:c("mlStudio.modelValue","Model: {name}").replace("{name}",S.name)}),e.jsx("span",{children:c("mlStudio.endpoint","Endpoint: {url}").replace("{url}",b.endpoint)})]}),e.jsxs("div",{className:"nice-ml-studio__resources-info",children:[e.jsx("span",{children:c("mlStudio.cpu","CPU: {count} cores").replace("{count}",String(b.resources.cpu))}),e.jsx("span",{children:c("mlStudio.memory","Memory: {gb} GB").replace("{gb}",String(b.resources.memory))}),e.jsx("span",{children:c("mlStudio.replicas","Replicas: {count}").replace("{count}",String(b.resources.replicas))})]})]},b.id))})]})]});return e.jsxs("div",{className:`nice-ml-studio ${s}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(T.NiceTutorialButton,{steps:T.resolveTutorial(o,vi)})}),e.jsx(Ma.NiceAppShell,{flush:!0,menubar:F,toolbar:G,children:K})]})},wi={id:T.createId(),name:"New Labeling Project",type:"classification",dataType:"image",status:"setup",labelSchema:{classes:[],attributes:[]},items:[],collaborators:[],statistics:{totalItems:0,labeled:0,reviewed:0,approved:0,byClass:[]},createdAt:new Date},qe=["var(--nice-danger, #ef4444)","var(--nice-warning, #f97316)","var(--nice-warning, #f59e0b)","var(--nice-success, #84cc16)","var(--nice-success, #22c55e)","var(--nice-info, #14b8a6)","var(--nice-info, #06b6d4)","var(--nice-primary, #3b82f6)","var(--nice-info, #6366f1)","var(--nice-accent, #8b5cf6)","var(--nice-accent, #a855f7)","var(--nice-color-accent-pink, #d946ef)","var(--nice-color-accent-pink, #ec4899)","var(--nice-danger, #f43f5e)"],ji={label:"Label",schema:"Schema",review:"Review",export:"Export"},ki=({project:t,onProjectChange:a,onLabelSave:i,onExport:n,className:r=""})=>{var ne;const{t:s}=T.useNiceTranslation(),[o,c]=l.useState(t||wi),[m,p]=l.useState("label"),[d,x]=l.useState(0),[N,A]=l.useState(null),[R,$]=l.useState("select"),[M,g]=l.useState(!1),[u,y]=l.useState(null),[_,C]=l.useState(1),[v,h]=l.useState(!1),[w,f]=l.useState("all"),j=l.useRef(null),k=l.useRef(null),I=o.items[d];l.useEffect(()=>{t&&c(t)},[t]);const z=l.useCallback(L=>{const O={...o,...L};O.statistics={totalItems:O.items.length,labeled:O.items.filter(q=>q.status!=="pending").length,reviewed:O.items.filter(q=>q.status==="review"||q.status==="approved").length,approved:O.items.filter(q=>q.status==="approved").length,byClass:O.labelSchema.classes.map(q=>({classId:q.id,count:O.items.flatMap(D=>D.labels).filter(D=>D.classId===q.id).length}))},c(O),a==null||a(O)},[o,a]),E=()=>{const L={id:T.createId(),name:`Class ${o.labelSchema.classes.length+1}`,color:qe[o.labelSchema.classes.length%qe.length],shortcut:String(o.labelSchema.classes.length+1)};z({labelSchema:{...o.labelSchema,classes:[...o.labelSchema.classes,L]}})},P=L=>{z({labelSchema:{...o.labelSchema,classes:o.labelSchema.classes.filter(O=>O.id!==L)},items:o.items.map(O=>({...O,labels:O.labels.filter(q=>q.classId!==L)}))})},F=(L,O)=>{z({labelSchema:{...o.labelSchema,classes:o.labelSchema.classes.map(q=>q.id===L?{...q,...O}:q)}})},G=(L,O)=>{if(!I)return;const q={id:T.createId(),classId:L,type:o.type==="classification"?"class":o.type==="bounding-box"?"bbox":"class",data:O||{},createdBy:"current-user",createdAt:new Date},D={...I,labels:[...I.labels,q],status:"labeled"};z({items:o.items.map(W=>W.id===I.id?D:W)}),i==null||i(D)},K=L=>{if(!I)return;const O={...I,labels:I.labels.filter(q=>q.id!==L),status:I.labels.length<=1?"pending":"labeled"};z({items:o.items.map(q=>q.id===I.id?O:q)})},X=L=>{var W;if(R!=="bbox"||!N)return;const O=(W=j.current)==null?void 0:W.getBoundingClientRect();if(!O)return;const q=(L.clientX-O.left)/_,D=(L.clientY-O.top)/_;g(!0),y({x:q,y:D,width:0,height:0})},S=L=>{var W;if(!M||!u)return;const O=(W=j.current)==null?void 0:W.getBoundingClientRect();if(!O)return;const q=(L.clientX-O.left)/_,D=(L.clientY-O.top)/_;y({...u,width:q-u.x,height:D-u.y})},b=()=>{!M||!u||!N||(g(!1),Math.abs(u.width)>10&&Math.abs(u.height)>10&&G(N,{x:u.width<0?u.x+u.width:u.x,y:u.height<0?u.y+u.height:u.y,width:Math.abs(u.width),height:Math.abs(u.height)}),y(null))},B=L=>{const O=w==="all"?o.items:o.items.filter(D=>D.status===w),q=O.findIndex(D=>D.id===(I==null?void 0:I.id));if(L==="prev"&&q>0){const D=O[q-1];x(o.items.findIndex(W=>W.id===D.id))}else if(L==="next"&&q<O.length-1){const D=O[q+1];x(o.items.findIndex(W=>W.id===D.id))}},U=()=>{if(!I)return;const L={...I,status:"approved"};z({items:o.items.map(O=>O.id===I.id?L:O)}),B("next")},J=()=>{if(!I)return;const L={...I,status:"rejected"};z({items:o.items.map(O=>O.id===I.id?L:O)}),B("next")},H=async L=>{n&&await n(L)},V=l.useRef(()=>{});V.current=L=>{const O=L.target instanceof HTMLElement?L.target:null;if(m!=="label"||L.defaultPrevented||L.ctrlKey||L.metaKey||L.altKey||O!=null&&O.isContentEditable||O&&/^(INPUT|TEXTAREA|SELECT)$/.test(O.tagName)||L.key==="Enter"&&(O!=null&&O.closest("button, a")))return;const q=L.key,D=o.labelSchema.classes.find(W=>W.shortcut===q);D&&(o.type==="classification"?(G(D.id),B("next")):A(D.id)),L.key==="ArrowLeft"||L.key==="a"?B("prev"):(L.key==="ArrowRight"||L.key==="d")&&B("next"),L.key==="Enter"?U():L.key==="Backspace"&&J()},l.useEffect(()=>{const L=O=>V.current(O);return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const te=L=>{switch(L){case"approved":return"var(--nice-success, #22c55e)";case"labeled":return"var(--nice-primary, #3b82f6)";case"review":return"var(--nice-warning, #f59e0b)";case"rejected":return"var(--nice-danger, #ef4444)";default:return"var(--nice-text-secondary, #6b7280)"}};return e.jsxs("div",{className:`nice-data-labeler ${r}`,children:[e.jsxs("header",{className:"nice-data-labeler__header",children:[e.jsxs("div",{className:"nice-data-labeler__header-info",children:[e.jsx("input",{type:"text",value:o.name,onChange:L=>z({name:L.target.value}),className:"nice-data-labeler__project-name-input"}),e.jsxs("div",{className:"nice-data-labeler__progress-bar",children:[e.jsx("div",{className:"nice-data-labeler__progress-fill",style:{width:`${o.statistics.labeled/Math.max(o.statistics.totalItems,1)*100}%`}}),e.jsx("span",{className:"nice-data-labeler__progress-text",children:s("dataLabeler.progress","{labeled} / {total} labeled").replace("{labeled}",String(o.statistics.labeled)).replace("{total}",String(o.statistics.totalItems))})]})]}),e.jsx("div",{className:"nice-data-labeler__header-tabs",children:["label","schema","review","export"].map(L=>e.jsx("button",{className:`nice-data-labeler__tab-button ${m===L?"nice-data-labeler__tab-button--active":""}`,onClick:()=>p(L),children:s(`dataLabeler.tab.${L}`,ji[L])},L))}),e.jsx("button",{className:"nice-data-labeler__shortcuts-button",onClick:()=>h(!v),children:s("dataLabeler.shortcuts","Shortcuts")})]}),e.jsxs("div",{className:"nice-data-labeler__content",children:[m==="label"&&e.jsxs("div",{className:"nice-data-labeler__label-panel",children:[e.jsxs("div",{className:"nice-data-labeler__label-toolbar",children:[e.jsxs("div",{className:"nice-data-labeler__tool-group",children:[e.jsxs("button",{className:`nice-data-labeler__tool-button ${R==="select"?"nice-data-labeler__tool-button--active":""}`,onClick:()=>$("select"),children:[e.jsx(T.NiceIcon,{name:"cursor",size:14})," ",s("dataLabeler.select","Select")]}),(o.type==="bounding-box"||o.type==="multi-label")&&e.jsxs("button",{className:`nice-data-labeler__tool-button ${R==="bbox"?"nice-data-labeler__tool-button--active":""}`,onClick:()=>$("bbox"),children:[e.jsx(T.NiceIcon,{name:"square",size:14})," ",s("dataLabeler.box","Box")]}),o.type==="polygon"&&e.jsxs("button",{className:`nice-data-labeler__tool-button ${R==="polygon"?"nice-data-labeler__tool-button--active":""}`,onClick:()=>$("polygon"),children:[e.jsx(T.NiceIcon,{name:"hexagon",size:14})," ",s("dataLabeler.polygon","Polygon")]})]}),e.jsxs("div",{className:"nice-data-labeler__zoom-group",children:[e.jsx("button",{"aria-label":s("dataLabeler.zoomOut","Zoom out"),onClick:()=>C(Math.max(.25,_-.25)),children:e.jsx(T.NiceIcon,{name:"minus",size:14})}),e.jsxs("span",{children:[Math.round(_*100),"%"]}),e.jsx("button",{"aria-label":s("dataLabeler.zoomIn","Zoom in"),onClick:()=>C(Math.min(4,_+.25)),children:e.jsx(T.NiceIcon,{name:"plus",size:14})})]}),e.jsxs("div",{className:"nice-data-labeler__navigation-group",children:[e.jsxs("button",{onClick:()=>B("prev"),disabled:d===0,children:[e.jsx(T.NiceIcon,{name:"arrow-left",size:14})," ",s("dataLabeler.prev","Prev")]}),e.jsxs("span",{children:[d+1," / ",o.items.length]}),e.jsxs("button",{onClick:()=>B("next"),disabled:d>=o.items.length-1,children:[s("dataLabeler.next","Next")," ",e.jsx(T.NiceIcon,{name:"arrow-right",size:14})]})]})]}),e.jsxs("div",{className:"nice-data-labeler__label-workspace",children:[e.jsx("div",{className:"nice-data-labeler__canvas-container",ref:k,children:I?e.jsxs(e.Fragment,{children:[I.data.type==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:I.data.url,alt:s("dataLabeler.labelingItem","Labeling item"),className:"nice-data-labeler__labeling-image",style:{transform:`scale(${_})`}}),e.jsx("canvas",{ref:j,className:"nice-data-labeler__labeling-canvas",onMouseDown:X,onMouseMove:S,onMouseUp:b,onMouseLeave:b,style:{transform:`scale(${_})`,cursor:R==="bbox"?"crosshair":"default"}}),e.jsxs("div",{className:"nice-data-labeler__annotations-overlay",style:{transform:`scale(${_})`},children:[I.labels.filter(L=>L.type==="bbox"&&L.data.x!==void 0).map(L=>{const O=o.labelSchema.classes.find(q=>q.id===L.classId);return e.jsxs("div",{className:"nice-data-labeler__bbox-annotation",style:{left:L.data.x,top:L.data.y,width:L.data.width,height:L.data.height,borderColor:(O==null?void 0:O.color)||"var(--nice-danger, #ff0000)"},children:[e.jsx("span",{className:"nice-data-labeler__bbox-label",style:{backgroundColor:(O==null?void 0:O.color)||"var(--nice-danger, #ff0000)"},children:O==null?void 0:O.name}),e.jsx("button",{className:"nice-data-labeler__bbox-remove","aria-label":s("dataLabeler.removeLabel","Remove label"),onClick:()=>K(L.id),children:e.jsx(T.NiceIcon,{name:"close",size:12})})]},L.id)}),u&&e.jsx("div",{className:"nice-data-labeler__bbox-drawing",style:{left:u.width<0?u.x+u.width:u.x,top:u.height<0?u.y+u.height:u.y,width:Math.abs(u.width),height:Math.abs(u.height),borderColor:(ne=o.labelSchema.classes.find(L=>L.id===N))==null?void 0:ne.color}})]})]}),I.data.type==="text"&&e.jsx("div",{className:"nice-data-labeler__text-labeling",children:e.jsx("p",{className:"nice-data-labeler__text-content",children:I.data.text})})]}):e.jsxs("div",{className:"nice-data-labeler__empty-state",children:[e.jsx("span",{className:"nice-data-labeler__icon",children:e.jsx(T.NiceIcon,{name:"clipboard",size:32})}),e.jsx("p",{children:s("dataLabeler.noItemsToLabel","No items to label")})]})}),e.jsxs("aside",{className:"nice-data-labeler__class-sidebar",children:[e.jsx("h3",{children:s("dataLabeler.classes","Classes")}),e.jsx("div",{className:"nice-data-labeler__class-list",children:o.labelSchema.classes.map(L=>e.jsxs("button",{className:`nice-data-labeler__class-button ${N===L.id?"nice-data-labeler__class-button--active":""}`,style:{borderLeftColor:L.color},onClick:()=>{o.type==="classification"?(G(L.id),B("next")):A(L.id)},children:[e.jsx("span",{className:"nice-data-labeler__class-color",style:{backgroundColor:L.color}}),e.jsx("span",{className:"nice-data-labeler__class-name",children:L.name}),L.shortcut&&e.jsx("span",{className:"nice-data-labeler__class-shortcut",children:L.shortcut})]},L.id))}),I&&I.labels.length>0&&e.jsxs("div",{className:"nice-data-labeler__current-labels",children:[e.jsx("h4",{children:s("dataLabeler.labels","Labels")}),I.labels.map(L=>{const O=o.labelSchema.classes.find(q=>q.id===L.classId);return e.jsxs("div",{className:"nice-data-labeler__label-item",children:[e.jsx("span",{className:"nice-data-labeler__label-color",style:{backgroundColor:O==null?void 0:O.color}}),e.jsx("span",{className:"nice-data-labeler__label-name",children:O==null?void 0:O.name}),e.jsx("button",{"aria-label":s("dataLabeler.removeLabel","Remove label"),onClick:()=>K(L.id),children:e.jsx(T.NiceIcon,{name:"close",size:14})})]},L.id)})]}),m==="label"&&I&&e.jsxs("div",{className:"nice-data-labeler__label-actions",children:[e.jsxs("button",{className:"nice-data-labeler__approve-button",onClick:U,children:[e.jsx(T.NiceIcon,{name:"check",size:14})," ",s("dataLabeler.approve","Approve")]}),e.jsxs("button",{className:"nice-data-labeler__reject-button",onClick:J,children:[e.jsx(T.NiceIcon,{name:"close",size:14})," ",s("dataLabeler.reject","Reject")]})]})]})]})]}),m==="schema"&&e.jsxs("div",{className:"nice-data-labeler__schema-panel",children:[e.jsxs("div",{className:"nice-data-labeler__panel-header",children:[e.jsx("h2",{children:s("dataLabeler.labelSchema","Label Schema")}),e.jsxs("button",{className:"nice-data-labeler__primary-button",onClick:E,children:[e.jsx(T.NiceIcon,{name:"plus",size:14})," ",s("dataLabeler.addClass","Add Class")]})]}),e.jsxs("div",{className:"nice-data-labeler__schema-settings",children:[e.jsxs("label",{children:[s("dataLabeler.labelingType","Labeling Type"),e.jsxs("select",{value:o.type,onChange:L=>z({type:L.target.value}),children:[e.jsx("option",{value:"classification",children:s("dataLabeler.singleClassification","Single Classification")}),e.jsx("option",{value:"multi-label",children:s("dataLabeler.multiLabelClassification","Multi-Label Classification")}),e.jsx("option",{value:"bounding-box",children:s("dataLabeler.boundingBox","Bounding Box")}),e.jsx("option",{value:"polygon",children:s("dataLabeler.polygon","Polygon")}),e.jsx("option",{value:"segmentation",children:s("dataLabeler.segmentation","Segmentation")}),e.jsx("option",{value:"ner",children:s("dataLabeler.namedEntityRecognition","Named Entity Recognition")})]})]}),e.jsxs("label",{children:[s("dataLabeler.dataType","Data Type"),e.jsxs("select",{value:o.dataType,onChange:L=>z({dataType:L.target.value}),children:[e.jsx("option",{value:"image",children:s("dataLabeler.image","Image")}),e.jsx("option",{value:"text",children:s("dataLabeler.text","Text")}),e.jsx("option",{value:"audio",children:s("dataLabeler.audio","Audio")}),e.jsx("option",{value:"video",children:s("dataLabeler.video","Video")})]})]})]}),e.jsx("div",{className:"nice-data-labeler__classes-list",children:o.labelSchema.classes.map((L,O)=>e.jsxs("div",{className:"nice-data-labeler__class-editor",children:[e.jsx("input",{type:"color",value:L.color,onChange:q=>F(L.id,{color:q.target.value}),className:"nice-data-labeler__color-picker"}),e.jsx("input",{type:"text",value:L.name,onChange:q=>F(L.id,{name:q.target.value}),className:"nice-data-labeler__class-name-input",placeholder:s("dataLabeler.classNamePlaceholder","Class name")}),e.jsx("input",{type:"text",value:L.shortcut||"",onChange:q=>F(L.id,{shortcut:q.target.value}),className:"nice-data-labeler__shortcut-input",placeholder:s("dataLabeler.shortcutKeyPlaceholder","Key"),maxLength:1}),e.jsx("button",{className:"nice-data-labeler__remove-class-button","aria-label":s("dataLabeler.removeClass","Remove class"),onClick:()=>P(L.id),children:e.jsx(T.NiceIcon,{name:"trash",size:16})})]},L.id))}),e.jsxs("div",{className:"nice-data-labeler__guidelines-section",children:[e.jsx("h3",{children:s("dataLabeler.labelingGuidelines","Labeling Guidelines")}),e.jsx("textarea",{value:o.guidelines||"",onChange:L=>z({guidelines:L.target.value}),placeholder:s("dataLabeler.guidelinesPlaceholder","Enter labeling guidelines for annotators..."),rows:6})]})]}),m==="review"&&e.jsxs("div",{className:"nice-data-labeler__review-panel",children:[e.jsxs("div",{className:"nice-data-labeler__panel-header",children:[e.jsx("h2",{children:s("dataLabeler.reviewLabels","Review Labels")}),e.jsx("div",{className:"nice-data-labeler__filter-group",children:e.jsxs("select",{value:w,onChange:L=>f(L.target.value),children:[e.jsx("option",{value:"all",children:s("dataLabeler.allItems","All Items")}),e.jsx("option",{value:"labeled",children:s("dataLabeler.labeled","Labeled")}),e.jsx("option",{value:"review",children:s("dataLabeler.needsReview","Needs Review")}),e.jsx("option",{value:"approved",children:s("dataLabeler.approved","Approved")}),e.jsx("option",{value:"rejected",children:s("dataLabeler.rejected","Rejected")})]})})]}),e.jsx("div",{className:"nice-data-labeler__items-grid",children:o.items.filter(L=>w==="all"||L.status===w).map((L,O)=>{var q;return e.jsxs("div",{className:`nice-data-labeler__item-card ${d===o.items.indexOf(L)?"nice-data-labeler__item-card--active":""}`,onClick:()=>{x(o.items.indexOf(L)),p("label")},children:[L.data.type==="image"&&e.jsx("img",{src:L.data.url,alt:s("dataLabeler.item","Item {index}").replace("{index}",String(O+1)),className:"nice-data-labeler__item-thumbnail"}),L.data.type==="text"&&e.jsxs("p",{className:"nice-data-labeler__item-text-preview",children:[(q=L.data.text)==null?void 0:q.slice(0,100),"..."]}),e.jsxs("div",{className:"nice-data-labeler__item-footer",children:[e.jsx("span",{className:"nice-data-labeler__status-dot",style:{backgroundColor:te(L.status)}}),e.jsx("span",{children:s("dataLabeler.labelCount","{count} labels").replace("{count}",String(L.labels.length))})]})]},L.id)})})]}),m==="export"&&e.jsxs("div",{className:"nice-data-labeler__export-panel",children:[e.jsx("div",{className:"nice-data-labeler__panel-header",children:e.jsx("h2",{children:s("dataLabeler.exportLabels","Export Labels")})}),e.jsxs("div",{className:"nice-data-labeler__export-stats",children:[e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.statistics.totalItems}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.totalItems","Total Items")})]}),e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.statistics.labeled}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.labeled","Labeled")})]}),e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.statistics.approved}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.approved","Approved")})]}),e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.labelSchema.classes.length}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.classes","Classes")})]})]}),e.jsxs("div",{className:"nice-data-labeler__export-formats",children:[e.jsx("h3",{children:s("dataLabeler.exportFormat","Export Format")}),e.jsxs("div",{className:"nice-data-labeler__format-grid",children:[e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("coco"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"box",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:s("dataLabeler.cocoJson","COCO JSON")}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.cocoDesc","Common format for object detection")})]}),e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("voc"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"file",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:s("dataLabeler.pascalVoc","Pascal VOC")}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.vocDesc","XML format for bounding boxes")})]}),e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("yolo"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"zap",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:s("dataLabeler.yolo","YOLO")}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.yoloDesc","Text format for YOLO models")})]}),e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("csv"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"bar-chart",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:"CSV"}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.csvDesc","Tabular format for classification")})]})]})]}),e.jsxs("div",{className:"nice-data-labeler__class-distribution",children:[e.jsx("h3",{children:s("dataLabeler.classDistribution","Class Distribution")}),e.jsx("div",{className:"nice-data-labeler__distribution-bars",children:o.statistics.byClass.map(L=>{const O=o.labelSchema.classes.find(D=>D.id===L.classId),q=L.count/Math.max(o.statistics.labeled,1)*100;return e.jsxs("div",{className:"nice-data-labeler__distribution-row",children:[e.jsx("span",{className:"nice-data-labeler__class-name",style:{color:O==null?void 0:O.color},children:O==null?void 0:O.name}),e.jsx("div",{className:"nice-data-labeler__bar-container",children:e.jsx("div",{className:"nice-data-labeler__bar-fill",style:{width:`${q}%`,backgroundColor:O==null?void 0:O.color}})}),e.jsx("span",{className:"nice-data-labeler__count",children:L.count})]},L.classId)})})]})]})]}),v&&e.jsx("div",{className:"nice-data-labeler__shortcuts-modal",children:e.jsxs("div",{className:"nice-data-labeler__modal-content",children:[e.jsxs("div",{className:"nice-data-labeler__modal-header",children:[e.jsx("h3",{children:s("dataLabeler.keyboardShortcuts","Keyboard Shortcuts")}),e.jsx("button",{"aria-label":s("dataLabeler.close","Close"),onClick:()=>h(!1),children:e.jsx(T.NiceIcon,{name:"close",size:16})})]}),e.jsxs("div",{className:"nice-data-labeler__shortcuts-list",children:[e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsxs("span",{className:"nice-data-labeler__keys",children:[e.jsx(T.NiceIcon,{name:"arrow-left",size:14})," / A"]}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.previousItem","Previous item")})]}),e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsxs("span",{className:"nice-data-labeler__keys",children:[e.jsx(T.NiceIcon,{name:"arrow-right",size:14})," / D"]}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.nextItem","Next item")})]}),e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsx("span",{className:"nice-data-labeler__keys",children:s("dataLabeler.enterKey","Enter")}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.approveItem","Approve item")})]}),e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsx("span",{className:"nice-data-labeler__keys",children:s("dataLabeler.backspaceKey","Backspace")}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.rejectItem","Reject item")})]}),o.labelSchema.classes.map(L=>L.shortcut&&e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsx("span",{className:"nice-data-labeler__keys",children:L.shortcut}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.labelAs","Label as {name}").replace("{name}",L.name)})]},L.id))]})]})})]})},Ni={id:T.createId(),name:"Model Endpoint",modelId:"",modelVersion:"1.0.0",status:"stopped",url:"",authentication:{type:"api-key"},metrics:{requestsTotal:0,requestsPerSecond:0,latencyP50:0,latencyP95:0,latencyP99:0,errorRate:0,successRate:100},logs:[]},Si=({endpoint:t,onInference:a,showMetrics:i=!0,showLogs:n=!0,className:r=""})=>{const{t:s}=T.useNiceTranslation(),[o,c]=l.useState(t||Ni),[m,p]=l.useState("test"),[d,x]=l.useState("text"),[N,A]=l.useState(""),[R,$]=l.useState("{}"),[M,g]=l.useState(null),[u,y]=l.useState({temperature:.7,topK:50,topP:.9,maxTokens:256,threshold:.5}),[_,C]=l.useState(null),[v,h]=l.useState(!1),[w,f]=l.useState(null),[j,k]=l.useState([]),[I,z]=l.useState(null),E=l.useRef(null),P=b=>{var U;const B=(U=b.target.files)==null?void 0:U[0];if(B){const J=new FileReader;J.onload=H=>{var V;g((V=H.target)==null?void 0:V.result)},J.readAsDataURL(B)}},F=async()=>{if(!a){f(s("modelInference.noInferenceHandlerProvided","No inference handler provided"));return}h(!0),f(null),C(null);const b=[];switch(d){case"text":b.push({type:"text",data:N});break;case"image":M&&b.push({type:"image",data:M});break;case"json":try{b.push({type:"json",data:JSON.parse(R)})}catch{f(s("modelInference.invalidJsonInput","Invalid JSON input")),h(!1);return}break;case"tabular":try{b.push({type:"tabular",data:JSON.parse(R)})}catch{f(s("modelInference.invalidTabularData","Invalid tabular data")),h(!1);return}break}const B={inputs:b,parameters:u};try{const U=Date.now(),J=await a(B),H=Date.now()-U;C(J),c(V=>({...V,metrics:{...V.metrics,requestsTotal:V.metrics.requestsTotal+1,latencyP50:(V.metrics.latencyP50+H)/2},logs:[{timestamp:new Date,requestId:J.requestId,duration:H,status:"success",inputSize:JSON.stringify(b).length,outputSize:JSON.stringify(J.predictions).length},...V.logs.slice(0,99)]}))}catch(U){const J=U instanceof Error?U.message:s("modelInference.inferenceFailed","Inference failed");f(J),c(H=>({...H,metrics:{...H.metrics,requestsTotal:H.metrics.requestsTotal+1,errorRate:(H.metrics.errorRate*H.metrics.requestsTotal+1)/(H.metrics.requestsTotal+1)},logs:[{timestamp:new Date,requestId:T.createId(),duration:0,status:"error",inputSize:JSON.stringify(b).length,outputSize:0,error:J},...H.logs.slice(0,99)]}))}finally{h(!1)}},G=async b=>{if(a){z(0),k([]);for(let B=0;B<b.length;B++){const U={inputs:[b[B]],parameters:u};try{const J=await a(U);k(H=>[...H,J])}catch(J){console.error("Batch item failed:",J)}z((B+1)/b.length*100)}z(null)}},K=b=>b<1e3?`${b.toFixed(0)}ms`:`${(b/1e3).toFixed(2)}s`,X=b=>b.toLocaleTimeString(),S=(b,B)=>e.jsxs("div",{className:"nice-model-inference__prediction-item",children:[b.label&&e.jsxs("div",{className:"nice-model-inference__prediction-label",children:[e.jsx("span",{className:"nice-model-inference__label-name",children:b.label}),b.confidence!==void 0&&e.jsxs("span",{className:"nice-model-inference__confidence-badge",style:{backgroundColor:`hsl(${b.confidence*120}, 70%, 40%)`},children:[(b.confidence*100).toFixed(1),"%"]})]}),b.score!==void 0&&e.jsxs("div",{className:"nice-model-inference__prediction-score",children:[e.jsx("span",{className:"nice-model-inference__score-label",children:s("modelInference.score","Score:")}),e.jsx("span",{className:"nice-model-inference__score-value",children:b.score.toFixed(4)})]}),b.text&&e.jsx("div",{className:"nice-model-inference__prediction-text",children:e.jsx("pre",{children:b.text})}),b.bbox&&e.jsx("div",{className:"nice-model-inference__prediction-bbox",children:e.jsx("span",{children:s("modelInference.box","Box: ({x}, {y}) - {width}×{height}").replace("{x}",String(b.bbox.x)).replace("{y}",String(b.bbox.y)).replace("{width}",String(b.bbox.width)).replace("{height}",String(b.bbox.height))})}),b.raw!==void 0&&b.raw!==null&&e.jsxs("details",{className:"nice-model-inference__raw-output",children:[e.jsx("summary",{children:s("modelInference.rawOutput","Raw Output")}),e.jsx("pre",{children:JSON.stringify(b.raw,null,2)})]})]},B);return e.jsxs("div",{className:`nice-model-inference ${r}`,children:[e.jsxs("header",{className:"nice-model-inference__header",children:[e.jsxs("div",{className:"nice-model-inference__header-info",children:[e.jsx("h2",{children:o.name}),e.jsx("span",{className:`nice-model-inference__status-badge nice-model-inference__status-badge--${o.status}`,children:o.status})]}),e.jsxs("div",{className:"nice-model-inference__header-tabs",children:[e.jsx("button",{className:`nice-model-inference__tab-button ${m==="test"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("test"),children:s("modelInference.test","Test")}),e.jsx("button",{className:`nice-model-inference__tab-button ${m==="batch"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("batch"),children:s("modelInference.batch","Batch")}),i&&e.jsx("button",{className:`nice-model-inference__tab-button ${m==="metrics"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("metrics"),children:s("modelInference.metrics","Metrics")}),n&&e.jsx("button",{className:`nice-model-inference__tab-button ${m==="logs"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("logs"),children:s("modelInference.logs","Logs")})]})]}),e.jsxs("div",{className:"nice-model-inference__content",children:[m==="test"&&e.jsxs("div",{className:"nice-model-inference__test-panel",children:[e.jsxs("div",{className:"nice-model-inference__input-section",children:[e.jsx("div",{className:"nice-model-inference__input-type-selector",children:["text","image","json","tabular"].map(b=>e.jsx("button",{className:`nice-model-inference__type-button ${d===b?"nice-model-inference__type-button--active":""}`,onClick:()=>x(b),children:b.charAt(0).toUpperCase()+b.slice(1)},b))}),e.jsxs("div",{className:"nice-model-inference__input-area",children:[d==="text"&&e.jsx("textarea",{value:N,onChange:b=>A(b.target.value),placeholder:s("modelInference.enterTextInput","Enter text input..."),rows:6,className:"nice-model-inference__text-input"}),d==="image"&&e.jsx("div",{className:"nice-model-inference__image-input",children:M?e.jsxs("div",{className:"nice-model-inference__image-preview",children:[e.jsx("img",{src:M,alt:s("modelInference.inputPreview","Input preview")}),e.jsx("button",{className:"nice-model-inference__clear-button",onClick:()=>g(null),children:s("modelInference.clear","Clear")})]}):e.jsxs("label",{className:"nice-model-inference__upload-zone",children:[e.jsx("input",{ref:E,type:"file",accept:"image/*",onChange:P,hidden:!0}),e.jsx("span",{className:"nice-model-inference__upload-icon",children:e.jsx(T.NiceIcon,{name:"image",size:32})}),e.jsx("span",{children:s("modelInference.clickOrDragToUpload","Click or drag to upload image")})]})}),(d==="json"||d==="tabular")&&e.jsx("textarea",{value:R,onChange:b=>$(b.target.value),placeholder:d==="json"?`{
|
|
11
|
+
`),H=J[0].split(",").map(V=>V.trim());B.rowCount=J.length-1,B.columns=H.map(V=>({name:V,type:"text",nullable:!0,unique:0,missing:0})),B.splits=B.splits.map(V=>({...V,rowCount:Math.floor(B.rowCount*V.ratio)}))}w(U=>({datasets:[...U.datasets,B]}))}},j=S=>{w({datasets:p.datasets.filter(b=>b.id!==S)}),A===S&&R(null)},k=async()=>{if(!C.algorithm||!A)return;const S={id:T.createId(),name:c("mlStudio.experimentName","Experiment {n}").replace("{n}",String(p.experiments.length+1)),status:"pending",config:C,metrics:[],artifacts:[],logs:[]},b=U=>w(J=>({experiments:J.experiments.map(H=>H.id===S.id?{...H,...U}:H)}));if(w(U=>({experiments:[...U.experiments,S]})),_(!1),!i)return;const B=new Date;b({status:"running",startedAt:B});try{const U=await i(S),J=typeof U=="object"&&U!==null?U:{},H=new Date;b({status:"completed",completedAt:H,duration:J.duration??(H.getTime()-B.getTime())/1e3,metrics:J.metrics??[],artifacts:J.artifacts??[],logs:J.logs??[]})}catch{b({status:"failed"})}},I=S=>{const b=p.experiments.find(J=>J.id===S);if(!b)return;const B=b.artifacts.filter(J=>J.type==="model"),U={id:T.createId(),name:c("mlStudio.modelFrom","Model from {name}").replace("{name}",b.name),version:"1.0.0",algorithm:b.config.algorithm,experimentId:S,status:"registered",metrics:b.metrics,size:B.reduce((J,H)=>J+H.size,0),artifacts:B,deployments:[],createdAt:new Date};w(J=>({models:[...J.models,U]}))},z=async S=>{const b=p.models.find(U=>U.id===S);if(!b||!n)return;const B=await n(b);w(U=>({models:U.models.map(J=>J.id===S?{...J,status:"production",deployments:[...J.deployments,B]}:J)}))},E=S=>S<1024?`${S} B`:S<1024*1024?`${(S/1024).toFixed(1)} KB`:S<1024*1024*1024?`${(S/1024/1024).toFixed(1)} MB`:`${(S/1024/1024/1024).toFixed(1)} GB`,P=S=>{switch(S){case"completed":case"production":case"running":return"success";case"pending":case"staging":return"pending";case"failed":return"error";case"deploying":case"stopped":return S;default:return"neutral"}},F=e.jsxs("div",{className:"nice-ml-studio__header-info",children:[e.jsx("input",{type:"text",value:p.name,onChange:S=>w({name:S.target.value}),className:"nice-ml-studio__project-name-input","aria-label":c("mlStudio.projectName","Project name")}),e.jsx("select",{value:p.type,onChange:S=>w({type:S.target.value}),className:"nice-ml-studio__project-type-select","aria-label":c("mlStudio.projectType","Project type"),children:mi.map(([S,b,B])=>e.jsx("option",{value:S,children:c(b,B)},S))})]}),G=e.jsx("div",{className:"nice-ml-studio__header-tabs",children:pi.map(([S,b,B])=>e.jsx("button",{className:`nice-ml-studio__tab-button ${x===S?"nice-ml-studio__tab-button--active":""}`,onClick:()=>N(S),children:c(b,B)},S))}),K=e.jsxs("div",{className:"nice-ml-studio__content",children:[x==="data"&&e.jsxs("div",{className:"nice-ml-studio__data-panel",children:[e.jsxs("div",{className:"nice-ml-studio__panel-header",children:[e.jsx("h2",{children:c("mlStudio.datasets","Datasets")}),e.jsxs("label",{className:"nice-ml-studio__upload-button",children:[e.jsx("input",{type:"file",multiple:!0,accept:".csv,.json,.parquet",onChange:S=>S.target.files&&f(S.target.files),hidden:!0}),e.jsx(T.NiceIcon,{name:"plus",size:14})," ",c("mlStudio.uploadDataset","Upload Dataset")]})]}),e.jsx("div",{className:"nice-ml-studio__datasets-grid",children:p.datasets.length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"bar-chart",size:32})}),e.jsx("p",{children:c("mlStudio.noDatasets","No datasets uploaded yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noDatasetsHint","Upload CSV, JSON, or Parquet files to get started")})]}):p.datasets.map(S=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:T.clickOnActivationKey,className:`nice-ml-studio__dataset-card ${A===S.id?"nice-ml-studio__dataset-card--selected":""}`,onClick:()=>R(S.id),children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("span",{className:"nice-ml-studio__dataset-icon",children:e.jsx(T.NiceIcon,{name:"folder",size:16})}),e.jsx("h3",{children:S.name}),e.jsx("button",{className:"nice-ml-studio__remove-button","aria-label":c("mlStudio.removeDataset","Remove dataset"),onClick:b=>{b.stopPropagation(),j(S.id)},children:e.jsx(T.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-ml-studio__card-stats",children:[e.jsx("span",{children:c("mlStudio.rows","{count} rows").replace("{count}",S.rowCount.toLocaleString(m))}),e.jsx("span",{children:c("mlStudio.columnCount","{count} columns").replace("{count}",String(S.columns.length))}),e.jsx("span",{children:E(S.size)})]}),e.jsx("div",{className:"nice-ml-studio__splits-bar",children:S.splits.map(b=>e.jsx("div",{className:`nice-ml-studio__split nice-ml-studio__split--${b.name}`,style:{width:`${b.ratio*100}%`},title:`${ce(hi[b.name],b.name,c)}: ${(b.ratio*100).toFixed(0)}%`},b.name))})]},S.id))}),A&&e.jsx("div",{className:"nice-ml-studio__dataset-details",children:(()=>{const S=p.datasets.find(b=>b.id===A);return S?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:c("mlStudio.columns","Columns")}),e.jsxs("table",{className:"nice-ml-studio__columns-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:c("mlStudio.col.name","Name")}),e.jsx("th",{children:c("mlStudio.col.type","Type")}),e.jsx("th",{children:c("mlStudio.col.missing","Missing")}),e.jsx("th",{children:c("mlStudio.col.unique","Unique")})]})}),e.jsx("tbody",{children:S.columns.map(b=>e.jsxs("tr",{children:[e.jsx("td",{children:b.name}),e.jsx("td",{children:e.jsx("select",{value:b.type,"aria-label":c("mlStudio.col.type","Type"),onChange:B=>{w({datasets:p.datasets.map(U=>U.id===S.id?{...U,columns:U.columns.map(J=>J.name===b.name?{...J,type:B.target.value}:J)}:U)})},children:gi.map(([B,U,J])=>e.jsx("option",{value:B,children:c(U,J)},B))})}),e.jsx("td",{children:b.missing}),e.jsx("td",{children:b.unique})]},b.name))})]})]}):null})()})]}),x==="experiments"&&e.jsxs("div",{className:"nice-ml-studio__experiments-panel",children:[e.jsxs("div",{className:"nice-ml-studio__panel-header",children:[e.jsx("h2",{children:c("mlStudio.tab.experiments","Experiments")}),e.jsxs("button",{className:"nice-ml-studio__primary-button",onClick:()=>_(!0),disabled:p.datasets.length===0,children:[e.jsx(T.NiceIcon,{name:"plus",size:14})," ",c("mlStudio.newExperiment","New Experiment")]})]}),y&&e.jsxs("div",{className:"nice-ml-studio__new-experiment-form",children:[e.jsx("h3",{children:c("mlStudio.configureExperiment","Configure Experiment")}),e.jsxs("div",{className:"nice-ml-studio__form-grid",children:[e.jsxs("label",{children:[c("mlStudio.dataset","Dataset"),e.jsxs("select",{value:A||"",onChange:S=>R(S.target.value),children:[e.jsx("option",{value:"",children:c("mlStudio.selectDataset","Select dataset...")}),p.datasets.map(S=>e.jsx("option",{value:S.id,children:S.name},S.id))]})]}),e.jsxs("label",{children:[c("mlStudio.algorithm","Algorithm"),e.jsxs("select",{value:C.algorithm,onChange:S=>v({...C,algorithm:S.target.value}),children:[e.jsx("option",{value:"",children:c("mlStudio.selectAlgorithm","Select algorithm...")}),(je[p.type]||je.classification).map(S=>e.jsx("option",{value:S.id,children:c(S.key,S.name)},S.id))]})]}),A&&e.jsxs("label",{children:[c("mlStudio.targetColumn","Target Column"),e.jsxs("select",{value:C.targetColumn||"",onChange:S=>v({...C,targetColumn:S.target.value}),children:[e.jsx("option",{value:"",children:c("mlStudio.selectTarget","Select target...")}),(X=p.datasets.find(S=>S.id===A))==null?void 0:X.columns.map(S=>e.jsx("option",{value:S.name,children:S.name},S.name))]})]})]}),e.jsxs("div",{className:"nice-ml-studio__form-actions",children:[e.jsx("button",{className:"nice-ml-studio__secondary-button",onClick:()=>_(!1),children:c("cancel","Cancel")}),e.jsx("button",{className:"nice-ml-studio__primary-button",onClick:k,disabled:!C.algorithm||!A,children:c("mlStudio.runExperiment","Run Experiment")})]})]}),e.jsx("div",{className:"nice-ml-studio__experiments-list",children:p.experiments.length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"flask",size:32})}),e.jsx("p",{children:c("mlStudio.noExperiments","No experiments yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noExperimentsHint","Create an experiment to train and evaluate models")})]}):p.experiments.map(S=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:T.clickOnActivationKey,className:`nice-ml-studio__experiment-card ${$===S.id?"nice-ml-studio__experiment-card--selected":""}`,onClick:()=>M(S.id),children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("h3",{children:S.name}),e.jsx("span",{className:`nice-ml-studio__status-badge nice-ml-studio__status-badge--${P(S.status)}`,children:ce(fi[S.status],S.status,c)})]}),e.jsxs("div",{className:"nice-ml-studio__card-meta",children:[e.jsx("span",{children:c("mlStudio.algorithmValue","Algorithm: {name}").replace("{name}",Fe(S.config.algorithm,c))}),S.duration!==void 0&&e.jsx("span",{children:c("mlStudio.duration","Duration: {seconds}s").replace("{seconds}",String(Math.round(S.duration)))})]}),S.metrics.length>0&&e.jsx("div",{className:"nice-ml-studio__metrics-row",children:S.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"nice-ml-studio__metric-item",children:[e.jsx("span",{className:"nice-ml-studio__metric-name",children:b.name}),e.jsx("span",{className:"nice-ml-studio__metric-value",children:Je(b,m)})]},b.name))}),S.status==="completed"&&e.jsx("button",{className:"nice-ml-studio__action-button",onClick:b=>{b.stopPropagation(),I(S.id)},children:c("mlStudio.registerModel","Register Model")})]},S.id))})]}),x==="models"&&e.jsxs("div",{className:"nice-ml-studio__models-panel",children:[e.jsx("div",{className:"nice-ml-studio__panel-header",children:e.jsx("h2",{children:c("mlStudio.tab.models","Models")})}),e.jsx("div",{className:"nice-ml-studio__models-list",children:p.models.length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"wand",size:32})}),e.jsx("p",{children:c("mlStudio.noModels","No models registered yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noModelsHint","Complete experiments and register models")})]}):p.models.map(S=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:T.clickOnActivationKey,className:`nice-ml-studio__model-card ${g===S.id?"nice-ml-studio__model-card--selected":""}`,onClick:()=>u(S.id),children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("h3",{children:S.name}),e.jsx("span",{className:`nice-ml-studio__status-badge nice-ml-studio__status-badge--${P(S.status)}`,children:ce(xi[S.status],S.status,c)})]}),e.jsxs("div",{className:"nice-ml-studio__card-meta",children:[e.jsx("span",{children:c("mlStudio.algorithmValue","Algorithm: {name}").replace("{name}",Fe(S.algorithm,c))}),e.jsx("span",{children:c("mlStudio.version","Version: {version}").replace("{version}",S.version)}),S.size>0&&e.jsx("span",{children:c("mlStudio.size","Size: {size}").replace("{size}",E(S.size))})]}),S.metrics.length>0&&e.jsx("div",{className:"nice-ml-studio__metrics-row",children:S.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"nice-ml-studio__metric-item",children:[e.jsx("span",{className:"nice-ml-studio__metric-name",children:b.name}),e.jsx("span",{className:"nice-ml-studio__metric-value",children:Je(b,m)})]},b.name))}),e.jsxs("div",{className:"nice-ml-studio__card-actions",children:[e.jsx("button",{className:"nice-ml-studio__action-button",onClick:b=>{b.stopPropagation(),r==null||r(S)},disabled:!r,title:r?void 0:c("mlStudio.downloadNotSetUp","Downloading models is not set up"),children:c("download","Download")}),e.jsx("button",{className:"nice-ml-studio__action-button nice-ml-studio__action-button--primary",onClick:b=>{b.stopPropagation(),z(S.id)},disabled:S.status==="production"||!n,title:n?void 0:c("mlStudio.deployNotSetUp","Deploying models is not set up"),children:S.status==="production"?c("mlStudio.deployed","Deployed"):c("mlStudio.deploy","Deploy")})]})]},S.id))})]}),x==="deploy"&&e.jsxs("div",{className:"nice-ml-studio__deploy-panel",children:[e.jsx("div",{className:"nice-ml-studio__panel-header",children:e.jsx("h2",{children:c("mlStudio.deployments","Deployments")})}),e.jsx("div",{className:"nice-ml-studio__deployments-list",children:p.models.filter(S=>S.deployments.length>0).length===0?e.jsxs("div",{className:"nice-ml-studio__empty-state",children:[e.jsx("span",{className:"nice-ml-studio__icon",children:e.jsx(T.NiceIcon,{name:"rocket",size:32})}),e.jsx("p",{children:c("mlStudio.noDeployments","No deployments yet")}),e.jsx("p",{className:"nice-ml-studio__hint",children:c("mlStudio.noDeploymentsHint","Deploy a model to create inference endpoints")})]}):p.models.filter(S=>S.deployments.length>0).flatMap(S=>S.deployments.map(b=>({model:S,deployment:b}))).map(({model:S,deployment:b})=>e.jsxs("div",{className:"nice-ml-studio__deployment-card",children:[e.jsxs("div",{className:"nice-ml-studio__card-header",children:[e.jsx("h3",{children:b.name}),e.jsx("span",{className:`nice-ml-studio__status-badge nice-ml-studio__status-badge--${P(b.status)}`,children:ce(bi[b.status],b.status,c)})]}),e.jsxs("div",{className:"nice-ml-studio__card-meta",children:[e.jsx("span",{children:c("mlStudio.modelValue","Model: {name}").replace("{name}",S.name)}),e.jsx("span",{children:c("mlStudio.endpoint","Endpoint: {url}").replace("{url}",b.endpoint)})]}),e.jsxs("div",{className:"nice-ml-studio__resources-info",children:[e.jsx("span",{children:c("mlStudio.cpu","CPU: {count} cores").replace("{count}",String(b.resources.cpu))}),e.jsx("span",{children:c("mlStudio.memory","Memory: {gb} GB").replace("{gb}",String(b.resources.memory))}),e.jsx("span",{children:c("mlStudio.replicas","Replicas: {count}").replace("{count}",String(b.resources.replicas))})]})]},b.id))})]})]});return e.jsxs("div",{className:`nice-ml-studio ${s}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(T.NiceTutorialButton,{steps:T.resolveTutorial(o,vi)})}),e.jsx(Ma.NiceAppShell,{flush:!0,menubar:F,toolbar:G,children:K})]})},wi={id:T.createId(),name:"New Labeling Project",type:"classification",dataType:"image",status:"setup",labelSchema:{classes:[],attributes:[]},items:[],collaborators:[],statistics:{totalItems:0,labeled:0,reviewed:0,approved:0,byClass:[]},createdAt:new Date},qe=["var(--nice-danger, #ef4444)","var(--nice-warning, #f97316)","var(--nice-warning, #f59e0b)","var(--nice-success, #84cc16)","var(--nice-success, #22c55e)","var(--nice-info, #14b8a6)","var(--nice-info, #06b6d4)","var(--nice-primary, #3b82f6)","var(--nice-info, #6366f1)","var(--nice-accent, #8b5cf6)","var(--nice-accent, #a855f7)","var(--nice-color-accent-pink, #d946ef)","var(--nice-color-accent-pink, #ec4899)","var(--nice-danger, #f43f5e)"],ji={label:"Label",schema:"Schema",review:"Review",export:"Export"},ki=({project:t,onProjectChange:a,onLabelSave:i,onExport:n,className:r=""})=>{var ne;const{t:s}=T.useNiceTranslation(),[o,c]=l.useState(t||wi),[m,p]=l.useState("label"),[d,x]=l.useState(0),[N,A]=l.useState(null),[R,$]=l.useState("select"),[M,g]=l.useState(!1),[u,y]=l.useState(null),[_,C]=l.useState(1),[v,h]=l.useState(!1),[w,f]=l.useState("all"),j=l.useRef(null),k=l.useRef(null),I=o.items[d];l.useEffect(()=>{t&&c(t)},[t]);const z=l.useCallback(L=>{const O={...o,...L};O.statistics={totalItems:O.items.length,labeled:O.items.filter(q=>q.status!=="pending").length,reviewed:O.items.filter(q=>q.status==="review"||q.status==="approved").length,approved:O.items.filter(q=>q.status==="approved").length,byClass:O.labelSchema.classes.map(q=>({classId:q.id,count:O.items.flatMap(D=>D.labels).filter(D=>D.classId===q.id).length}))},c(O),a==null||a(O)},[o,a]),E=()=>{const L={id:T.createId(),name:`Class ${o.labelSchema.classes.length+1}`,color:qe[o.labelSchema.classes.length%qe.length],shortcut:String(o.labelSchema.classes.length+1)};z({labelSchema:{...o.labelSchema,classes:[...o.labelSchema.classes,L]}})},P=L=>{z({labelSchema:{...o.labelSchema,classes:o.labelSchema.classes.filter(O=>O.id!==L)},items:o.items.map(O=>({...O,labels:O.labels.filter(q=>q.classId!==L)}))})},F=(L,O)=>{z({labelSchema:{...o.labelSchema,classes:o.labelSchema.classes.map(q=>q.id===L?{...q,...O}:q)}})},G=(L,O)=>{if(!I)return;const q={id:T.createId(),classId:L,type:o.type==="classification"?"class":o.type==="bounding-box"?"bbox":"class",data:O||{},createdBy:"current-user",createdAt:new Date},D={...I,labels:[...I.labels,q],status:"labeled"};z({items:o.items.map(W=>W.id===I.id?D:W)}),i==null||i(D)},K=L=>{if(!I)return;const O={...I,labels:I.labels.filter(q=>q.id!==L),status:I.labels.length<=1?"pending":"labeled"};z({items:o.items.map(q=>q.id===I.id?O:q)})},X=L=>{var W;if(R!=="bbox"||!N)return;const O=(W=j.current)==null?void 0:W.getBoundingClientRect();if(!O)return;const q=(L.clientX-O.left)/_,D=(L.clientY-O.top)/_;g(!0),y({x:q,y:D,width:0,height:0})},S=L=>{var W;if(!M||!u)return;const O=(W=j.current)==null?void 0:W.getBoundingClientRect();if(!O)return;const q=(L.clientX-O.left)/_,D=(L.clientY-O.top)/_;y({...u,width:q-u.x,height:D-u.y})},b=()=>{!M||!u||!N||(g(!1),Math.abs(u.width)>10&&Math.abs(u.height)>10&&G(N,{x:u.width<0?u.x+u.width:u.x,y:u.height<0?u.y+u.height:u.y,width:Math.abs(u.width),height:Math.abs(u.height)}),y(null))},B=L=>{const O=w==="all"?o.items:o.items.filter(D=>D.status===w),q=O.findIndex(D=>D.id===(I==null?void 0:I.id));if(L==="prev"&&q>0){const D=O[q-1];x(o.items.findIndex(W=>W.id===D.id))}else if(L==="next"&&q<O.length-1){const D=O[q+1];x(o.items.findIndex(W=>W.id===D.id))}},U=()=>{if(!I)return;const L={...I,status:"approved"};z({items:o.items.map(O=>O.id===I.id?L:O)}),B("next")},J=()=>{if(!I)return;const L={...I,status:"rejected"};z({items:o.items.map(O=>O.id===I.id?L:O)}),B("next")},H=async L=>{n&&await n(L)},V=l.useRef(()=>{});V.current=L=>{const O=L.target instanceof HTMLElement?L.target:null;if(m!=="label"||L.defaultPrevented||L.ctrlKey||L.metaKey||L.altKey||O!=null&&O.isContentEditable||O&&/^(INPUT|TEXTAREA|SELECT)$/.test(O.tagName)||L.key==="Enter"&&(O!=null&&O.closest("button, a")))return;const q=L.key,D=o.labelSchema.classes.find(W=>W.shortcut===q);D&&(o.type==="classification"?(G(D.id),B("next")):A(D.id)),L.key==="ArrowLeft"||L.key==="a"?B("prev"):(L.key==="ArrowRight"||L.key==="d")&&B("next"),L.key==="Enter"?U():L.key==="Backspace"&&J()},l.useEffect(()=>{const L=O=>V.current(O);return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const te=L=>{switch(L){case"approved":return"var(--nice-success, #22c55e)";case"labeled":return"var(--nice-primary, #3b82f6)";case"review":return"var(--nice-warning, #f59e0b)";case"rejected":return"var(--nice-danger, #ef4444)";default:return"var(--nice-text-secondary, #6b7280)"}};return e.jsxs("div",{className:`nice-data-labeler ${r}`,children:[e.jsxs("header",{className:"nice-data-labeler__header",children:[e.jsxs("div",{className:"nice-data-labeler__header-info",children:[e.jsx("input",{type:"text",value:o.name,onChange:L=>z({name:L.target.value}),className:"nice-data-labeler__project-name-input"}),e.jsxs("div",{className:"nice-data-labeler__progress-bar",children:[e.jsx("div",{className:"nice-data-labeler__progress-fill",style:{width:`${o.statistics.labeled/Math.max(o.statistics.totalItems,1)*100}%`}}),e.jsx("span",{className:"nice-data-labeler__progress-text",children:s("dataLabeler.progress","{labeled} / {total} labeled").replace("{labeled}",String(o.statistics.labeled)).replace("{total}",String(o.statistics.totalItems))})]})]}),e.jsx("div",{className:"nice-data-labeler__header-tabs",children:["label","schema","review","export"].map(L=>e.jsx("button",{className:`nice-data-labeler__tab-button ${m===L?"nice-data-labeler__tab-button--active":""}`,onClick:()=>p(L),children:s(`dataLabeler.tab.${L}`,ji[L])},L))}),e.jsx("button",{className:"nice-data-labeler__shortcuts-button",onClick:()=>h(!v),children:s("dataLabeler.shortcuts","Shortcuts")})]}),e.jsxs("div",{className:"nice-data-labeler__content",children:[m==="label"&&e.jsxs("div",{className:"nice-data-labeler__label-panel",children:[e.jsxs("div",{className:"nice-data-labeler__label-toolbar",children:[e.jsxs("div",{className:"nice-data-labeler__tool-group",children:[e.jsxs("button",{className:`nice-data-labeler__tool-button ${R==="select"?"nice-data-labeler__tool-button--active":""}`,onClick:()=>$("select"),children:[e.jsx(T.NiceIcon,{name:"cursor",size:14})," ",s("dataLabeler.select","Select")]}),(o.type==="bounding-box"||o.type==="multi-label")&&e.jsxs("button",{className:`nice-data-labeler__tool-button ${R==="bbox"?"nice-data-labeler__tool-button--active":""}`,onClick:()=>$("bbox"),children:[e.jsx(T.NiceIcon,{name:"square",size:14})," ",s("dataLabeler.box","Box")]}),o.type==="polygon"&&e.jsxs("button",{className:`nice-data-labeler__tool-button ${R==="polygon"?"nice-data-labeler__tool-button--active":""}`,onClick:()=>$("polygon"),children:[e.jsx(T.NiceIcon,{name:"hexagon",size:14})," ",s("dataLabeler.polygon","Polygon")]})]}),e.jsxs("div",{className:"nice-data-labeler__zoom-group",children:[e.jsx("button",{"aria-label":s("dataLabeler.zoomOut","Zoom out"),onClick:()=>C(Math.max(.25,_-.25)),children:e.jsx(T.NiceIcon,{name:"minus",size:14})}),e.jsxs("span",{children:[Math.round(_*100),"%"]}),e.jsx("button",{"aria-label":s("dataLabeler.zoomIn","Zoom in"),onClick:()=>C(Math.min(4,_+.25)),children:e.jsx(T.NiceIcon,{name:"plus",size:14})})]}),e.jsxs("div",{className:"nice-data-labeler__navigation-group",children:[e.jsxs("button",{onClick:()=>B("prev"),disabled:d===0,children:[e.jsx(T.NiceIcon,{name:"arrow-left",size:14})," ",s("dataLabeler.prev","Prev")]}),e.jsxs("span",{children:[d+1," / ",o.items.length]}),e.jsxs("button",{onClick:()=>B("next"),disabled:d>=o.items.length-1,children:[s("dataLabeler.next","Next")," ",e.jsx(T.NiceIcon,{name:"arrow-right",size:14})]})]})]}),e.jsxs("div",{className:"nice-data-labeler__label-workspace",children:[e.jsx("div",{className:"nice-data-labeler__canvas-container",ref:k,children:I?e.jsxs(e.Fragment,{children:[I.data.type==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:I.data.url,alt:s("dataLabeler.labelingItem","Labeling item"),className:"nice-data-labeler__labeling-image",style:{transform:`scale(${_})`}}),e.jsx("canvas",{ref:j,className:"nice-data-labeler__labeling-canvas",onMouseDown:X,onMouseMove:S,onMouseUp:b,onMouseLeave:b,style:{transform:`scale(${_})`,cursor:R==="bbox"?"crosshair":"default"}}),e.jsxs("div",{className:"nice-data-labeler__annotations-overlay",style:{transform:`scale(${_})`},children:[I.labels.filter(L=>L.type==="bbox"&&L.data.x!==void 0).map(L=>{const O=o.labelSchema.classes.find(q=>q.id===L.classId);return e.jsxs("div",{className:"nice-data-labeler__bbox-annotation",style:{left:L.data.x,top:L.data.y,width:L.data.width,height:L.data.height,borderColor:(O==null?void 0:O.color)||"var(--nice-danger, #ff0000)"},children:[e.jsx("span",{className:"nice-data-labeler__bbox-label",style:{backgroundColor:(O==null?void 0:O.color)||"var(--nice-danger, #ff0000)"},children:O==null?void 0:O.name}),e.jsx("button",{className:"nice-data-labeler__bbox-remove","aria-label":s("dataLabeler.removeLabel","Remove label"),onClick:()=>K(L.id),children:e.jsx(T.NiceIcon,{name:"close",size:12})})]},L.id)}),u&&e.jsx("div",{className:"nice-data-labeler__bbox-drawing",style:{left:u.width<0?u.x+u.width:u.x,top:u.height<0?u.y+u.height:u.y,width:Math.abs(u.width),height:Math.abs(u.height),borderColor:(ne=o.labelSchema.classes.find(L=>L.id===N))==null?void 0:ne.color}})]})]}),I.data.type==="text"&&e.jsx("div",{className:"nice-data-labeler__text-labeling",children:e.jsx("p",{className:"nice-data-labeler__text-content",children:I.data.text})})]}):e.jsxs("div",{className:"nice-data-labeler__empty-state",children:[e.jsx("span",{className:"nice-data-labeler__icon",children:e.jsx(T.NiceIcon,{name:"clipboard",size:32})}),e.jsx("p",{children:s("dataLabeler.noItemsToLabel","No items to label")})]})}),e.jsxs("aside",{className:"nice-data-labeler__class-sidebar",children:[e.jsx("h3",{children:s("dataLabeler.classes","Classes")}),e.jsx("div",{className:"nice-data-labeler__class-list",children:o.labelSchema.classes.map(L=>e.jsxs("button",{className:`nice-data-labeler__class-button ${N===L.id?"nice-data-labeler__class-button--active":""}`,style:{borderLeftColor:L.color},onClick:()=>{o.type==="classification"?(G(L.id),B("next")):A(L.id)},children:[e.jsx("span",{className:"nice-data-labeler__class-color",style:{backgroundColor:L.color}}),e.jsx("span",{className:"nice-data-labeler__class-name",children:L.name}),L.shortcut&&e.jsx("span",{className:"nice-data-labeler__class-shortcut",children:L.shortcut})]},L.id))}),I&&I.labels.length>0&&e.jsxs("div",{className:"nice-data-labeler__current-labels",children:[e.jsx("h4",{children:s("dataLabeler.labels","Labels")}),I.labels.map(L=>{const O=o.labelSchema.classes.find(q=>q.id===L.classId);return e.jsxs("div",{className:"nice-data-labeler__label-item",children:[e.jsx("span",{className:"nice-data-labeler__label-color",style:{backgroundColor:O==null?void 0:O.color}}),e.jsx("span",{className:"nice-data-labeler__label-name",children:O==null?void 0:O.name}),e.jsx("button",{"aria-label":s("dataLabeler.removeLabel","Remove label"),onClick:()=>K(L.id),children:e.jsx(T.NiceIcon,{name:"close",size:14})})]},L.id)})]}),m==="label"&&I&&e.jsxs("div",{className:"nice-data-labeler__label-actions",children:[e.jsxs("button",{className:"nice-data-labeler__approve-button",onClick:U,children:[e.jsx(T.NiceIcon,{name:"check",size:14})," ",s("dataLabeler.approve","Approve")]}),e.jsxs("button",{className:"nice-data-labeler__reject-button",onClick:J,children:[e.jsx(T.NiceIcon,{name:"close",size:14})," ",s("dataLabeler.reject","Reject")]})]})]})]})]}),m==="schema"&&e.jsxs("div",{className:"nice-data-labeler__schema-panel",children:[e.jsxs("div",{className:"nice-data-labeler__panel-header",children:[e.jsx("h2",{children:s("dataLabeler.labelSchema","Label Schema")}),e.jsxs("button",{className:"nice-data-labeler__primary-button",onClick:E,children:[e.jsx(T.NiceIcon,{name:"plus",size:14})," ",s("dataLabeler.addClass","Add Class")]})]}),e.jsxs("div",{className:"nice-data-labeler__schema-settings",children:[e.jsxs("label",{children:[s("dataLabeler.labelingType","Labeling Type"),e.jsxs("select",{value:o.type,onChange:L=>z({type:L.target.value}),children:[e.jsx("option",{value:"classification",children:s("dataLabeler.singleClassification","Single Classification")}),e.jsx("option",{value:"multi-label",children:s("dataLabeler.multiLabelClassification","Multi-Label Classification")}),e.jsx("option",{value:"bounding-box",children:s("dataLabeler.boundingBox","Bounding Box")}),e.jsx("option",{value:"polygon",children:s("dataLabeler.polygon","Polygon")}),e.jsx("option",{value:"segmentation",children:s("dataLabeler.segmentation","Segmentation")}),e.jsx("option",{value:"ner",children:s("dataLabeler.namedEntityRecognition","Named Entity Recognition")})]})]}),e.jsxs("label",{children:[s("dataLabeler.dataType","Data Type"),e.jsxs("select",{value:o.dataType,onChange:L=>z({dataType:L.target.value}),children:[e.jsx("option",{value:"image",children:s("dataLabeler.image","Image")}),e.jsx("option",{value:"text",children:s("dataLabeler.text","Text")}),e.jsx("option",{value:"audio",children:s("dataLabeler.audio","Audio")}),e.jsx("option",{value:"video",children:s("dataLabeler.video","Video")})]})]})]}),e.jsx("div",{className:"nice-data-labeler__classes-list",children:o.labelSchema.classes.map((L,O)=>e.jsxs("div",{className:"nice-data-labeler__class-editor",children:[e.jsx("input",{type:"color",value:L.color,onChange:q=>F(L.id,{color:q.target.value}),className:"nice-data-labeler__color-picker"}),e.jsx("input",{type:"text",value:L.name,onChange:q=>F(L.id,{name:q.target.value}),className:"nice-data-labeler__class-name-input",placeholder:s("dataLabeler.classNamePlaceholder","Class name")}),e.jsx("input",{type:"text",value:L.shortcut||"",onChange:q=>F(L.id,{shortcut:q.target.value}),className:"nice-data-labeler__shortcut-input",placeholder:s("dataLabeler.shortcutKeyPlaceholder","Key"),maxLength:1}),e.jsx("button",{className:"nice-data-labeler__remove-class-button","aria-label":s("dataLabeler.removeClass","Remove class"),onClick:()=>P(L.id),children:e.jsx(T.NiceIcon,{name:"trash",size:16})})]},L.id))}),e.jsxs("div",{className:"nice-data-labeler__guidelines-section",children:[e.jsx("h3",{children:s("dataLabeler.labelingGuidelines","Labeling Guidelines")}),e.jsx("textarea",{value:o.guidelines||"",onChange:L=>z({guidelines:L.target.value}),placeholder:s("dataLabeler.guidelinesPlaceholder","Enter labeling guidelines for annotators..."),rows:6})]})]}),m==="review"&&e.jsxs("div",{className:"nice-data-labeler__review-panel",children:[e.jsxs("div",{className:"nice-data-labeler__panel-header",children:[e.jsx("h2",{children:s("dataLabeler.reviewLabels","Review Labels")}),e.jsx("div",{className:"nice-data-labeler__filter-group",children:e.jsxs("select",{value:w,onChange:L=>f(L.target.value),children:[e.jsx("option",{value:"all",children:s("dataLabeler.allItems","All Items")}),e.jsx("option",{value:"labeled",children:s("dataLabeler.labeled","Labeled")}),e.jsx("option",{value:"review",children:s("dataLabeler.needsReview","Needs Review")}),e.jsx("option",{value:"approved",children:s("dataLabeler.approved","Approved")}),e.jsx("option",{value:"rejected",children:s("dataLabeler.rejected","Rejected")})]})})]}),e.jsx("div",{className:"nice-data-labeler__items-grid",children:o.items.filter(L=>w==="all"||L.status===w).map((L,O)=>{var q;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:T.clickOnActivationKey,className:`nice-data-labeler__item-card ${d===o.items.indexOf(L)?"nice-data-labeler__item-card--active":""}`,onClick:()=>{x(o.items.indexOf(L)),p("label")},children:[L.data.type==="image"&&e.jsx("img",{src:L.data.url,alt:s("dataLabeler.item","Item {index}").replace("{index}",String(O+1)),className:"nice-data-labeler__item-thumbnail"}),L.data.type==="text"&&e.jsxs("p",{className:"nice-data-labeler__item-text-preview",children:[(q=L.data.text)==null?void 0:q.slice(0,100),"..."]}),e.jsxs("div",{className:"nice-data-labeler__item-footer",children:[e.jsx("span",{className:"nice-data-labeler__status-dot",style:{backgroundColor:te(L.status)}}),e.jsx("span",{children:s("dataLabeler.labelCount","{count} labels").replace("{count}",String(L.labels.length))})]})]},L.id)})})]}),m==="export"&&e.jsxs("div",{className:"nice-data-labeler__export-panel",children:[e.jsx("div",{className:"nice-data-labeler__panel-header",children:e.jsx("h2",{children:s("dataLabeler.exportLabels","Export Labels")})}),e.jsxs("div",{className:"nice-data-labeler__export-stats",children:[e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.statistics.totalItems}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.totalItems","Total Items")})]}),e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.statistics.labeled}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.labeled","Labeled")})]}),e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.statistics.approved}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.approved","Approved")})]}),e.jsxs("div",{className:"nice-data-labeler__stat-card",children:[e.jsx("span",{className:"nice-data-labeler__stat-value",children:o.labelSchema.classes.length}),e.jsx("span",{className:"nice-data-labeler__stat-label",children:s("dataLabeler.classes","Classes")})]})]}),e.jsxs("div",{className:"nice-data-labeler__export-formats",children:[e.jsx("h3",{children:s("dataLabeler.exportFormat","Export Format")}),e.jsxs("div",{className:"nice-data-labeler__format-grid",children:[e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("coco"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"box",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:s("dataLabeler.cocoJson","COCO JSON")}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.cocoDesc","Common format for object detection")})]}),e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("voc"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"file",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:s("dataLabeler.pascalVoc","Pascal VOC")}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.vocDesc","XML format for bounding boxes")})]}),e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("yolo"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"zap",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:s("dataLabeler.yolo","YOLO")}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.yoloDesc","Text format for YOLO models")})]}),e.jsxs("button",{className:"nice-data-labeler__format-button",onClick:()=>H("csv"),children:[e.jsx("span",{className:"nice-data-labeler__format-icon",children:e.jsx(T.NiceIcon,{name:"bar-chart",size:24})}),e.jsx("span",{className:"nice-data-labeler__format-name",children:"CSV"}),e.jsx("span",{className:"nice-data-labeler__format-desc",children:s("dataLabeler.csvDesc","Tabular format for classification")})]})]})]}),e.jsxs("div",{className:"nice-data-labeler__class-distribution",children:[e.jsx("h3",{children:s("dataLabeler.classDistribution","Class Distribution")}),e.jsx("div",{className:"nice-data-labeler__distribution-bars",children:o.statistics.byClass.map(L=>{const O=o.labelSchema.classes.find(D=>D.id===L.classId),q=L.count/Math.max(o.statistics.labeled,1)*100;return e.jsxs("div",{className:"nice-data-labeler__distribution-row",children:[e.jsx("span",{className:"nice-data-labeler__class-name",style:{color:O==null?void 0:O.color},children:O==null?void 0:O.name}),e.jsx("div",{className:"nice-data-labeler__bar-container",children:e.jsx("div",{className:"nice-data-labeler__bar-fill",style:{width:`${q}%`,backgroundColor:O==null?void 0:O.color}})}),e.jsx("span",{className:"nice-data-labeler__count",children:L.count})]},L.classId)})})]})]})]}),v&&e.jsx("div",{className:"nice-data-labeler__shortcuts-modal",children:e.jsxs("div",{className:"nice-data-labeler__modal-content",children:[e.jsxs("div",{className:"nice-data-labeler__modal-header",children:[e.jsx("h3",{children:s("dataLabeler.keyboardShortcuts","Keyboard Shortcuts")}),e.jsx("button",{"aria-label":s("dataLabeler.close","Close"),onClick:()=>h(!1),children:e.jsx(T.NiceIcon,{name:"close",size:16})})]}),e.jsxs("div",{className:"nice-data-labeler__shortcuts-list",children:[e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsxs("span",{className:"nice-data-labeler__keys",children:[e.jsx(T.NiceIcon,{name:"arrow-left",size:14})," / A"]}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.previousItem","Previous item")})]}),e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsxs("span",{className:"nice-data-labeler__keys",children:[e.jsx(T.NiceIcon,{name:"arrow-right",size:14})," / D"]}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.nextItem","Next item")})]}),e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsx("span",{className:"nice-data-labeler__keys",children:s("dataLabeler.enterKey","Enter")}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.approveItem","Approve item")})]}),e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsx("span",{className:"nice-data-labeler__keys",children:s("dataLabeler.backspaceKey","Backspace")}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.rejectItem","Reject item")})]}),o.labelSchema.classes.map(L=>L.shortcut&&e.jsxs("div",{className:"nice-data-labeler__shortcut-item",children:[e.jsx("span",{className:"nice-data-labeler__keys",children:L.shortcut}),e.jsx("span",{className:"nice-data-labeler__description",children:s("dataLabeler.labelAs","Label as {name}").replace("{name}",L.name)})]},L.id))]})]})})]})},Ni={id:T.createId(),name:"Model Endpoint",modelId:"",modelVersion:"1.0.0",status:"stopped",url:"",authentication:{type:"api-key"},metrics:{requestsTotal:0,requestsPerSecond:0,latencyP50:0,latencyP95:0,latencyP99:0,errorRate:0,successRate:100},logs:[]},Si=({endpoint:t,onInference:a,showMetrics:i=!0,showLogs:n=!0,className:r=""})=>{const{t:s}=T.useNiceTranslation(),[o,c]=l.useState(t||Ni),[m,p]=l.useState("test"),[d,x]=l.useState("text"),[N,A]=l.useState(""),[R,$]=l.useState("{}"),[M,g]=l.useState(null),[u,y]=l.useState({temperature:.7,topK:50,topP:.9,maxTokens:256,threshold:.5}),[_,C]=l.useState(null),[v,h]=l.useState(!1),[w,f]=l.useState(null),[j,k]=l.useState([]),[I,z]=l.useState(null),E=l.useRef(null),P=b=>{var U;const B=(U=b.target.files)==null?void 0:U[0];if(B){const J=new FileReader;J.onload=H=>{var V;g((V=H.target)==null?void 0:V.result)},J.readAsDataURL(B)}},F=async()=>{if(!a){f(s("modelInference.noInferenceHandlerProvided","No inference handler provided"));return}h(!0),f(null),C(null);const b=[];switch(d){case"text":b.push({type:"text",data:N});break;case"image":M&&b.push({type:"image",data:M});break;case"json":try{b.push({type:"json",data:JSON.parse(R)})}catch{f(s("modelInference.invalidJsonInput","Invalid JSON input")),h(!1);return}break;case"tabular":try{b.push({type:"tabular",data:JSON.parse(R)})}catch{f(s("modelInference.invalidTabularData","Invalid tabular data")),h(!1);return}break}const B={inputs:b,parameters:u};try{const U=Date.now(),J=await a(B),H=Date.now()-U;C(J),c(V=>({...V,metrics:{...V.metrics,requestsTotal:V.metrics.requestsTotal+1,latencyP50:(V.metrics.latencyP50+H)/2},logs:[{timestamp:new Date,requestId:J.requestId,duration:H,status:"success",inputSize:JSON.stringify(b).length,outputSize:JSON.stringify(J.predictions).length},...V.logs.slice(0,99)]}))}catch(U){const J=U instanceof Error?U.message:s("modelInference.inferenceFailed","Inference failed");f(J),c(H=>({...H,metrics:{...H.metrics,requestsTotal:H.metrics.requestsTotal+1,errorRate:(H.metrics.errorRate*H.metrics.requestsTotal+1)/(H.metrics.requestsTotal+1)},logs:[{timestamp:new Date,requestId:T.createId(),duration:0,status:"error",inputSize:JSON.stringify(b).length,outputSize:0,error:J},...H.logs.slice(0,99)]}))}finally{h(!1)}},G=async b=>{if(a){z(0),k([]);for(let B=0;B<b.length;B++){const U={inputs:[b[B]],parameters:u};try{const J=await a(U);k(H=>[...H,J])}catch(J){console.error("Batch item failed:",J)}z((B+1)/b.length*100)}z(null)}},K=b=>b<1e3?`${b.toFixed(0)}ms`:`${(b/1e3).toFixed(2)}s`,X=b=>b.toLocaleTimeString(),S=(b,B)=>e.jsxs("div",{className:"nice-model-inference__prediction-item",children:[b.label&&e.jsxs("div",{className:"nice-model-inference__prediction-label",children:[e.jsx("span",{className:"nice-model-inference__label-name",children:b.label}),b.confidence!==void 0&&e.jsxs("span",{className:"nice-model-inference__confidence-badge",style:{backgroundColor:`hsl(${b.confidence*120}, 70%, 40%)`},children:[(b.confidence*100).toFixed(1),"%"]})]}),b.score!==void 0&&e.jsxs("div",{className:"nice-model-inference__prediction-score",children:[e.jsx("span",{className:"nice-model-inference__score-label",children:s("modelInference.score","Score:")}),e.jsx("span",{className:"nice-model-inference__score-value",children:b.score.toFixed(4)})]}),b.text&&e.jsx("div",{className:"nice-model-inference__prediction-text",children:e.jsx("pre",{children:b.text})}),b.bbox&&e.jsx("div",{className:"nice-model-inference__prediction-bbox",children:e.jsx("span",{children:s("modelInference.box","Box: ({x}, {y}) - {width}×{height}").replace("{x}",String(b.bbox.x)).replace("{y}",String(b.bbox.y)).replace("{width}",String(b.bbox.width)).replace("{height}",String(b.bbox.height))})}),b.raw!==void 0&&b.raw!==null&&e.jsxs("details",{className:"nice-model-inference__raw-output",children:[e.jsx("summary",{children:s("modelInference.rawOutput","Raw Output")}),e.jsx("pre",{children:JSON.stringify(b.raw,null,2)})]})]},B);return e.jsxs("div",{className:`nice-model-inference ${r}`,children:[e.jsxs("header",{className:"nice-model-inference__header",children:[e.jsxs("div",{className:"nice-model-inference__header-info",children:[e.jsx("h2",{children:o.name}),e.jsx("span",{className:`nice-model-inference__status-badge nice-model-inference__status-badge--${o.status}`,children:o.status})]}),e.jsxs("div",{className:"nice-model-inference__header-tabs",children:[e.jsx("button",{className:`nice-model-inference__tab-button ${m==="test"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("test"),children:s("modelInference.test","Test")}),e.jsx("button",{className:`nice-model-inference__tab-button ${m==="batch"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("batch"),children:s("modelInference.batch","Batch")}),i&&e.jsx("button",{className:`nice-model-inference__tab-button ${m==="metrics"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("metrics"),children:s("modelInference.metrics","Metrics")}),n&&e.jsx("button",{className:`nice-model-inference__tab-button ${m==="logs"?"nice-model-inference__tab-button--active":""}`,onClick:()=>p("logs"),children:s("modelInference.logs","Logs")})]})]}),e.jsxs("div",{className:"nice-model-inference__content",children:[m==="test"&&e.jsxs("div",{className:"nice-model-inference__test-panel",children:[e.jsxs("div",{className:"nice-model-inference__input-section",children:[e.jsx("div",{className:"nice-model-inference__input-type-selector",children:["text","image","json","tabular"].map(b=>e.jsx("button",{className:`nice-model-inference__type-button ${d===b?"nice-model-inference__type-button--active":""}`,onClick:()=>x(b),children:b.charAt(0).toUpperCase()+b.slice(1)},b))}),e.jsxs("div",{className:"nice-model-inference__input-area",children:[d==="text"&&e.jsx("textarea",{value:N,onChange:b=>A(b.target.value),placeholder:s("modelInference.enterTextInput","Enter text input..."),rows:6,className:"nice-model-inference__text-input"}),d==="image"&&e.jsx("div",{className:"nice-model-inference__image-input",children:M?e.jsxs("div",{className:"nice-model-inference__image-preview",children:[e.jsx("img",{src:M,alt:s("modelInference.inputPreview","Input preview")}),e.jsx("button",{className:"nice-model-inference__clear-button",onClick:()=>g(null),children:s("modelInference.clear","Clear")})]}):e.jsxs("label",{className:"nice-model-inference__upload-zone",children:[e.jsx("input",{ref:E,type:"file",accept:"image/*",onChange:P,hidden:!0}),e.jsx("span",{className:"nice-model-inference__upload-icon",children:e.jsx(T.NiceIcon,{name:"image",size:32})}),e.jsx("span",{children:s("modelInference.clickOrDragToUpload","Click or drag to upload image")})]})}),(d==="json"||d==="tabular")&&e.jsx("textarea",{value:R,onChange:b=>$(b.target.value),placeholder:d==="json"?`{
|
|
12
12
|
"key": "value"
|
|
13
13
|
}`:`[
|
|
14
14
|
{"col1": "value1", "col2": "value2"}
|
|
@@ -1190,7 +1190,7 @@ Provide summary and insights:`,variables:[{name:"data",description:"Data to summ
|
|
|
1190
1190
|
`),B=[S.substring(z.column),...X.slice(z.line+1,z.line+10)].join(`
|
|
1191
1191
|
`),U=ae(me,{language:i,prefix:b,suffix:B,context:n}),J=await K.chat({messages:[{role:"system",content:U.system},{role:"user",content:U.user}],temperature:.2,maxTokens:512}),H=Ui(J,z,r),V={suggestions:H,rawResponse:(G=(F=J.choices[0])==null?void 0:F.message)==null?void 0:G.content,latencyMs:performance.now()-E};return N(H),R(H.length>0?0:-1),o==null||o(H),V}catch(K){const X=K instanceof Error?K.message:"Completion failed";return c==null||c(X),{suggestions:[],error:X,latencyMs:performance.now()-E}}finally{d(!1)}},[g,i,n,r,o,c]),y=l.useCallback((I,z)=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{u(I,z)},s)},[u,s]),_=l.useCallback(async I=>{if(!g)return null;d(!0);try{const E=await Y(g).chat({messages:[{role:"system",content:`You are a code explanation assistant. Explain the following ${i} code clearly and concisely. Return JSON with: { "summary": string, "details": string, "complexity": "low"|"medium"|"high", "suggestions": string[] }`},{role:"user",content:I}],temperature:.3,maxTokens:1024});return Wi(E)}catch{return null}finally{d(!1)}},[g,i]),C=l.useCallback(async I=>{if(!g)return[];d(!0);try{const E=await Y(g).chat({messages:[{role:"system",content:`You are a code refactoring assistant. Analyze the following ${i} code and suggest improvements. Return JSON array with: [{ "title": string, "description": string, "before": string, "after": string, "type": "extract-function"|"rename"|"simplify"|"optimize"|"security"|"style" }]`},{role:"user",content:I}],temperature:.4,maxTokens:2048});return Hi(E)}catch{return[]}finally{d(!1)}},[g,i]),v=l.useCallback(async(I,z)=>{var E,P;if(!g)return null;d(!0);try{const F=Y(g),G=z||Ki(i);return((P=(E=(await F.chat({messages:[{role:"system",content:`You are a testing expert. Generate comprehensive unit tests for the following ${i} code using ${G}. Include edge cases and error scenarios. Return only the test code.`},{role:"user",content:I}],temperature:.3,maxTokens:2048})).choices[0])==null?void 0:E.message)==null?void 0:P.content)||null}catch{return null}finally{d(!1)}},[g,i]),h=l.useCallback(async(I,z)=>{var E,P;if(!g)return null;d(!0);try{const F=Y(g),G=z||Vi(i);return((P=(E=(await F.chat({messages:[{role:"system",content:`Generate ${G} documentation for the following ${i} code. Include descriptions for parameters, return values, and examples where appropriate. Return only the documented code.`},{role:"user",content:I}],temperature:.3,maxTokens:2048})).choices[0])==null?void 0:E.message)==null?void 0:P.content)||null}catch{return null}finally{d(!1)}},[g,i]),w=l.useCallback((I=A)=>{const z=x[I];return N([]),R(-1),z},[x,A]),f=l.useCallback(()=>{N([]),R(-1)},[]),j=l.useCallback(I=>{x.length!==0&&R(z=>I==="up"?z<=0?x.length-1:z-1:z>=x.length-1?0:z+1)},[x.length]),k=l.useCallback(()=>{var I;(I=$.current)==null||I.abort(),M.current&&clearTimeout(M.current),d(!1)},[]);return l.useEffect(()=>()=>{var I;(I=$.current)==null||I.abort(),M.current&&clearTimeout(M.current)},[]),{getCompletions:u,getCompletionsDebounced:y,suggestions:x,activeSuggestion:A,acceptSuggestion:w,dismissSuggestions:f,navigateSuggestions:j,explainCode:_,suggestRefactoring:C,generateTests:v,generateDocs:h,loading:p,abort:k,isConfigured:!!g}}function Ui(t,a,i){var o,c;const n=((c=(o=t.choices[0])==null?void 0:o.message)==null?void 0:c.content)||"",r=/^\s*```[\w+#.-]*\n([\s\S]*?)\n?```\s*$/.exec(n),s=(r?r[1]:n).replace(/^\n+/,"").replace(/\s+$/,"");return!s.trim()||i<1?[]:[{id:`suggestion-${Date.now()}-0`,text:s,type:s.includes(`
|
|
1192
1192
|
`)?"block":"inline",preview:s.trim().split(`
|
|
1193
|
-
`)[0].slice(0,50),confidence:.8,insertPosition:a}]}function Wi(t){var a,i;try{const n=((i=(a=t.choices[0])==null?void 0:a.message)==null?void 0:i.content)||"",r=n.match(/\{[\s\S]*\}/);return r?JSON.parse(r[0]):{summary:n}}catch{return null}}function Hi(t){var a,i;try{const r=(((i=(a=t.choices[0])==null?void 0:a.message)==null?void 0:i.content)||"").match(/\[[\s\S]*\]/);if(r)return JSON.parse(r[0])}catch{}return[]}function Ki(t){return{javascript:"Jest",typescript:"Jest",python:"pytest",java:"JUnit 5",csharp:"xUnit",go:"testing",rust:"cargo test",ruby:"RSpec",php:"PHPUnit",swift:"XCTest",kotlin:"JUnit 5",dart:"flutter_test"}[t]||"unit test"}function Vi(t){return{javascript:"jsdoc",typescript:"tsdoc",python:"docstring",java:"javadoc",kotlin:"javadoc"}[t]||"jsdoc"}function Yi({code:t="",language:a="typescript",config:i,onChange:n,onAcceptSuggestion:r,showToolbar:s=!0,enableInlineSuggestions:o=!0,placeholder:c,className:m,style:p,renderEditor:d}){const{t:x}=T.useNiceTranslation(),N=c??x("codeEditorAI.startTypingCode","Start typing code..."),[A,R]=l.useState(t),[$,M]=l.useState(null),[g,u]=l.useState(null),[y,_]=l.useState([]),[C,v]=l.useState(null),[h,w]=l.useState(null),f=l.useRef(null),{getCompletionsDebounced:j,suggestions:k,activeSuggestion:I,acceptSuggestion:z,dismissSuggestions:E,navigateSuggestions:P,explainCode:F,suggestRefactoring:G,generateTests:K,generateDocs:X,loading:S,isConfigured:b}=ka({config:i,language:a}),B=D=>{if(R(D),n==null||n(D),o&&f.current){const W=Xi(f.current);j(D,W)}},U=D=>{if(k.length>0)if(D.key==="ArrowUp")D.preventDefault(),P("up");else if(D.key==="ArrowDown")D.preventDefault(),P("down");else if(D.key==="Tab"||D.key==="Enter"){if(I>=0){D.preventDefault();const W=z(I);W&&(J(W),r==null||r(W))}}else D.key==="Escape"&&E()},J=D=>{if(!f.current)return;const W=f.current,ie=W.selectionStart,Ee=A.slice(0,ie)+D.text+A.slice(ie);R(Ee),n==null||n(Ee);const De=ie+D.text.length;setTimeout(()=>{W.focus(),W.setSelectionRange(De,De)},0)},H=async()=>{const D=$||A;if(!D.trim())return;w("explain");const W=await F(D);u(W)},V=async()=>{const D=$||A;if(!D.trim())return;w("refactor");const W=await G(D);_(W)},te=async()=>{if(!A.trim())return;w("tests");const D=await K(A);v(D)},ne=async()=>{if(!A.trim())return;w("docs");const D=await X(A);v(D)},L=D=>{const W=A.replace(D.before,D.after);R(W),n==null||n(W),w(null)},O=()=>{C&&navigator.clipboard.writeText(C)},q=()=>{if(f.current){const D=f.current.selectionStart,W=f.current.selectionEnd;M(D!==W?A.slice(D,W):null)}};return b?d?e.jsx("div",{className:`nice-code-editor-ai ${m||""}`,style:p,children:d({code:A,onChange:B,suggestions:k,onAccept:D=>{const W=z(D);W&&(r==null||r(W))}})}):e.jsxs("div",{className:`nice-code-editor-ai ${m||""}`,style:p,children:[s&&e.jsxs("div",{className:"nice-code-editor-ai__toolbar",children:[e.jsx("span",{className:"nice-code-editor-ai__lang-badge",children:a}),e.jsxs("div",{className:"nice-code-editor-ai__actions",children:[e.jsxs("button",{type:"button",onClick:H,disabled:S||!A.trim(),title:x("codeEditorAI.explainCode","Explain code"),children:[e.jsx(T.NiceIcon,{name:"lightbulb",size:14})," ",x("codeEditorAI.explain","Explain")]}),e.jsxs("button",{type:"button",onClick:V,disabled:S||!A.trim(),title:x("codeEditorAI.suggestRefactoring","Suggest refactoring"),children:[e.jsx(T.NiceIcon,{name:"settings",size:14})," ",x("codeEditorAI.refactor","Refactor")]}),e.jsxs("button",{type:"button",onClick:te,disabled:S||!A.trim(),title:x("codeEditorAI.generateTests","Generate tests"),children:[e.jsx(T.NiceIcon,{name:"flask",size:14})," ",x("codeEditorAI.tests","Tests")]}),e.jsxs("button",{type:"button",onClick:ne,disabled:S||!A.trim(),title:x("codeEditorAI.generateDocs","Generate docs"),children:[e.jsx(T.NiceIcon,{name:"edit",size:14})," ",x("codeEditorAI.docs","Docs")]})]}),S&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:x("codeEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx("textarea",{ref:f,value:A,onChange:D=>B(D.target.value),onKeyDown:U,onSelect:q,placeholder:N,className:"nice-code-editor-ai__textarea",spellCheck:!1}),k.length>0&&e.jsxs("div",{className:"nice-code-editor-ai__suggestions",children:[k.map((D,W)=>e.jsxs("div",{className:`nice-code-editor-ai__suggestion ${W===I?"nice-code-editor-ai__suggestion--active":""}`,onClick:()=>{const ie=z(W);ie&&(J(ie),r==null||r(ie))},children:[e.jsx("span",{className:"nice-code-editor-ai__suggestion-text",children:D.text}),e.jsxs("span",{className:"nice-code-editor-ai__suggestion-confidence",children:[Math.round(D.confidence*100),"%"]})]},D.id)),e.jsxs("div",{className:"nice-code-editor-ai__suggestions-hint",children:[e.jsx(T.NiceIcon,{name:"arrow-up",size:11}),e.jsx(T.NiceIcon,{name:"arrow-down",size:11})," ",x("codeEditorAI.navigateTabAcceptEscDismiss","navigate • Tab accept • Esc dismiss")]})]})]}),h&&e.jsxs("div",{className:"nice-code-editor-ai__panel",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("span",{children:[h==="explain"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"lightbulb",size:14})," ",x("codeEditorAI.explanation","Explanation")]}),h==="refactor"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"settings",size:14})," ",x("codeEditorAI.refactoringSuggestions","Refactoring Suggestions")]}),h==="tests"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"flask",size:14})," ",x("codeEditorAI.generatedTests","Generated Tests")]}),h==="docs"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"edit",size:14})," ",x("codeEditorAI.generatedDocumentation","Generated Documentation")]})]}),e.jsx("button",{type:"button",onClick:()=>w(null),"aria-label":x("codeEditorAI.closePanel","Close panel"),children:e.jsx(T.NiceIcon,{name:"close",size:16})})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-content",children:[h==="explain"&&g&&e.jsxs("div",{className:"nice-code-editor-ai__explanation",children:[e.jsx("div",{className:"nice-code-editor-ai__explanation-summary",children:g.summary}),g.details&&e.jsx("div",{className:"nice-code-editor-ai__explanation-details",children:g.details}),g.complexity&&e.jsx("span",{className:`nice-code-editor-ai__complexity nice-code-editor-ai__complexity--${g.complexity}`,children:x("codeEditorAI.complexity","Complexity: {complexity}").replace("{complexity}",String(g.complexity))}),g.suggestions&&g.suggestions.length>0&&e.jsx("ul",{className:"nice-code-editor-ai__explanation-suggestions",children:g.suggestions.map((D,W)=>e.jsx("li",{children:D},W))})]}),h==="refactor"&&y.length>0&&e.jsx("div",{className:"nice-code-editor-ai__refactorings",children:y.map((D,W)=>e.jsxs("div",{className:"nice-code-editor-ai__refactoring",children:[e.jsxs("div",{className:"nice-code-editor-ai__refactoring-header",children:[e.jsx("span",{className:"nice-code-editor-ai__refactoring-title",children:D.title}),e.jsx("span",{className:`nice-code-editor-ai__refactoring-type nice-code-editor-ai__refactoring-type--${D.type}`,children:D.type})]}),e.jsx("p",{className:"nice-code-editor-ai__refactoring-desc",children:D.description}),e.jsxs("div",{className:"nice-code-editor-ai__refactoring-diff",children:[e.jsxs("div",{className:"nice-code-editor-ai__refactoring-before",children:[e.jsx("span",{children:x("codeEditorAI.before","Before:")}),e.jsx("pre",{children:D.before})]}),e.jsxs("div",{className:"nice-code-editor-ai__refactoring-after",children:[e.jsx("span",{children:x("codeEditorAI.after","After:")}),e.jsx("pre",{children:D.after})]})]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactoring-apply",onClick:()=>L(D),children:x("codeEditorAI.apply","Apply")})]},W))}),(h==="tests"||h==="docs")&&C&&e.jsxs("div",{className:"nice-code-editor-ai__generated",children:[e.jsx("pre",{children:C}),e.jsxs("button",{type:"button",onClick:O,children:[e.jsx(T.NiceIcon,{name:"clipboard",size:14})," ",x("codeEditorAI.copy","Copy")]})]})]})]}),e.jsx("style",{children:`
|
|
1193
|
+
`)[0].slice(0,50),confidence:.8,insertPosition:a}]}function Wi(t){var a,i;try{const n=((i=(a=t.choices[0])==null?void 0:a.message)==null?void 0:i.content)||"",r=n.match(/\{[\s\S]*\}/);return r?JSON.parse(r[0]):{summary:n}}catch{return null}}function Hi(t){var a,i;try{const r=(((i=(a=t.choices[0])==null?void 0:a.message)==null?void 0:i.content)||"").match(/\[[\s\S]*\]/);if(r)return JSON.parse(r[0])}catch{}return[]}function Ki(t){return{javascript:"Jest",typescript:"Jest",python:"pytest",java:"JUnit 5",csharp:"xUnit",go:"testing",rust:"cargo test",ruby:"RSpec",php:"PHPUnit",swift:"XCTest",kotlin:"JUnit 5",dart:"flutter_test"}[t]||"unit test"}function Vi(t){return{javascript:"jsdoc",typescript:"tsdoc",python:"docstring",java:"javadoc",kotlin:"javadoc"}[t]||"jsdoc"}function Yi({code:t="",language:a="typescript",config:i,onChange:n,onAcceptSuggestion:r,showToolbar:s=!0,enableInlineSuggestions:o=!0,placeholder:c,className:m,style:p,renderEditor:d}){const{t:x}=T.useNiceTranslation(),N=c??x("codeEditorAI.startTypingCode","Start typing code..."),[A,R]=l.useState(t),[$,M]=l.useState(null),[g,u]=l.useState(null),[y,_]=l.useState([]),[C,v]=l.useState(null),[h,w]=l.useState(null),f=l.useRef(null),{getCompletionsDebounced:j,suggestions:k,activeSuggestion:I,acceptSuggestion:z,dismissSuggestions:E,navigateSuggestions:P,explainCode:F,suggestRefactoring:G,generateTests:K,generateDocs:X,loading:S,isConfigured:b}=ka({config:i,language:a}),B=D=>{if(R(D),n==null||n(D),o&&f.current){const W=Xi(f.current);j(D,W)}},U=D=>{if(k.length>0)if(D.key==="ArrowUp")D.preventDefault(),P("up");else if(D.key==="ArrowDown")D.preventDefault(),P("down");else if(D.key==="Tab"||D.key==="Enter"){if(I>=0){D.preventDefault();const W=z(I);W&&(J(W),r==null||r(W))}}else D.key==="Escape"&&E()},J=D=>{if(!f.current)return;const W=f.current,ie=W.selectionStart,Ee=A.slice(0,ie)+D.text+A.slice(ie);R(Ee),n==null||n(Ee);const De=ie+D.text.length;setTimeout(()=>{W.focus(),W.setSelectionRange(De,De)},0)},H=async()=>{const D=$||A;if(!D.trim())return;w("explain");const W=await F(D);u(W)},V=async()=>{const D=$||A;if(!D.trim())return;w("refactor");const W=await G(D);_(W)},te=async()=>{if(!A.trim())return;w("tests");const D=await K(A);v(D)},ne=async()=>{if(!A.trim())return;w("docs");const D=await X(A);v(D)},L=D=>{const W=A.replace(D.before,D.after);R(W),n==null||n(W),w(null)},O=()=>{C&&navigator.clipboard.writeText(C)},q=()=>{if(f.current){const D=f.current.selectionStart,W=f.current.selectionEnd;M(D!==W?A.slice(D,W):null)}};return b?d?e.jsx("div",{className:`nice-code-editor-ai ${m||""}`,style:p,children:d({code:A,onChange:B,suggestions:k,onAccept:D=>{const W=z(D);W&&(r==null||r(W))}})}):e.jsxs("div",{className:`nice-code-editor-ai ${m||""}`,style:p,children:[s&&e.jsxs("div",{className:"nice-code-editor-ai__toolbar",children:[e.jsx("span",{className:"nice-code-editor-ai__lang-badge",children:a}),e.jsxs("div",{className:"nice-code-editor-ai__actions",children:[e.jsxs("button",{type:"button",onClick:H,disabled:S||!A.trim(),title:x("codeEditorAI.explainCode","Explain code"),children:[e.jsx(T.NiceIcon,{name:"lightbulb",size:14})," ",x("codeEditorAI.explain","Explain")]}),e.jsxs("button",{type:"button",onClick:V,disabled:S||!A.trim(),title:x("codeEditorAI.suggestRefactoring","Suggest refactoring"),children:[e.jsx(T.NiceIcon,{name:"settings",size:14})," ",x("codeEditorAI.refactor","Refactor")]}),e.jsxs("button",{type:"button",onClick:te,disabled:S||!A.trim(),title:x("codeEditorAI.generateTests","Generate tests"),children:[e.jsx(T.NiceIcon,{name:"flask",size:14})," ",x("codeEditorAI.tests","Tests")]}),e.jsxs("button",{type:"button",onClick:ne,disabled:S||!A.trim(),title:x("codeEditorAI.generateDocs","Generate docs"),children:[e.jsx(T.NiceIcon,{name:"edit",size:14})," ",x("codeEditorAI.docs","Docs")]})]}),S&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:x("codeEditorAI.processing","Processing...")})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx("textarea",{ref:f,value:A,onChange:D=>B(D.target.value),onKeyDown:U,onSelect:q,placeholder:N,className:"nice-code-editor-ai__textarea",spellCheck:!1}),k.length>0&&e.jsxs("div",{className:"nice-code-editor-ai__suggestions",children:[k.map((D,W)=>e.jsxs("div",{role:"presentation",className:`nice-code-editor-ai__suggestion ${W===I?"nice-code-editor-ai__suggestion--active":""}`,onClick:()=>{const ie=z(W);ie&&(J(ie),r==null||r(ie))},children:[e.jsx("span",{className:"nice-code-editor-ai__suggestion-text",children:D.text}),e.jsxs("span",{className:"nice-code-editor-ai__suggestion-confidence",children:[Math.round(D.confidence*100),"%"]})]},D.id)),e.jsxs("div",{className:"nice-code-editor-ai__suggestions-hint",children:[e.jsx(T.NiceIcon,{name:"arrow-up",size:11}),e.jsx(T.NiceIcon,{name:"arrow-down",size:11})," ",x("codeEditorAI.navigateTabAcceptEscDismiss","navigate • Tab accept • Esc dismiss")]})]})]}),h&&e.jsxs("div",{className:"nice-code-editor-ai__panel",children:[e.jsxs("div",{className:"nice-code-editor-ai__panel-header",children:[e.jsxs("span",{children:[h==="explain"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"lightbulb",size:14})," ",x("codeEditorAI.explanation","Explanation")]}),h==="refactor"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"settings",size:14})," ",x("codeEditorAI.refactoringSuggestions","Refactoring Suggestions")]}),h==="tests"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"flask",size:14})," ",x("codeEditorAI.generatedTests","Generated Tests")]}),h==="docs"&&e.jsxs(e.Fragment,{children:[e.jsx(T.NiceIcon,{name:"edit",size:14})," ",x("codeEditorAI.generatedDocumentation","Generated Documentation")]})]}),e.jsx("button",{type:"button",onClick:()=>w(null),"aria-label":x("codeEditorAI.closePanel","Close panel"),children:e.jsx(T.NiceIcon,{name:"close",size:16})})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-content",children:[h==="explain"&&g&&e.jsxs("div",{className:"nice-code-editor-ai__explanation",children:[e.jsx("div",{className:"nice-code-editor-ai__explanation-summary",children:g.summary}),g.details&&e.jsx("div",{className:"nice-code-editor-ai__explanation-details",children:g.details}),g.complexity&&e.jsx("span",{className:`nice-code-editor-ai__complexity nice-code-editor-ai__complexity--${g.complexity}`,children:x("codeEditorAI.complexity","Complexity: {complexity}").replace("{complexity}",String(g.complexity))}),g.suggestions&&g.suggestions.length>0&&e.jsx("ul",{className:"nice-code-editor-ai__explanation-suggestions",children:g.suggestions.map((D,W)=>e.jsx("li",{children:D},W))})]}),h==="refactor"&&y.length>0&&e.jsx("div",{className:"nice-code-editor-ai__refactorings",children:y.map((D,W)=>e.jsxs("div",{className:"nice-code-editor-ai__refactoring",children:[e.jsxs("div",{className:"nice-code-editor-ai__refactoring-header",children:[e.jsx("span",{className:"nice-code-editor-ai__refactoring-title",children:D.title}),e.jsx("span",{className:`nice-code-editor-ai__refactoring-type nice-code-editor-ai__refactoring-type--${D.type}`,children:D.type})]}),e.jsx("p",{className:"nice-code-editor-ai__refactoring-desc",children:D.description}),e.jsxs("div",{className:"nice-code-editor-ai__refactoring-diff",children:[e.jsxs("div",{className:"nice-code-editor-ai__refactoring-before",children:[e.jsx("span",{children:x("codeEditorAI.before","Before:")}),e.jsx("pre",{children:D.before})]}),e.jsxs("div",{className:"nice-code-editor-ai__refactoring-after",children:[e.jsx("span",{children:x("codeEditorAI.after","After:")}),e.jsx("pre",{children:D.after})]})]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactoring-apply",onClick:()=>L(D),children:x("codeEditorAI.apply","Apply")})]},W))}),(h==="tests"||h==="docs")&&C&&e.jsxs("div",{className:"nice-code-editor-ai__generated",children:[e.jsx("pre",{children:C}),e.jsxs("button",{type:"button",onClick:O,children:[e.jsx(T.NiceIcon,{name:"clipboard",size:14})," ",x("codeEditorAI.copy","Copy")]})]})]})]}),e.jsx("style",{children:`
|
|
1194
1194
|
.nice-code-editor-ai {
|
|
1195
1195
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
1196
1196
|
display: flex;
|