@nice2dev/ui-ai 1.0.22 → 1.0.24
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/dist/index.cjs +21 -21
- package/dist/index.mjs +66 -66
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react");class qe{constructor(a={},r){this.timestamps=[],this.tokenCount=0,this.warningEmitted=!1,this.config={maxRequestsPerMinute:a.maxRequestsPerMinute??30,maxTokensPerSession:a.maxTokensPerSession??1e4,warnThresholdPercent:a.warnThresholdPercent??80},this.onWarning=r}canRequest(){return this.pruneOldTimestamps(),!(this.timestamps.length>=this.config.maxRequestsPerMinute||this.tokenCount>=this.config.maxTokensPerSession)}recordRequest(){return this.canRequest()?(this.timestamps.push(Date.now()),!0):!1}recordTokens(a){this.tokenCount+=a,this.checkWarning()}getStatus(){this.pruneOldTimestamps();const a=this.config.maxTokensPerSession>0?this.tokenCount/this.config.maxTokensPerSession*100:0,r=this.config.maxRequestsPerMinute>0?this.timestamps.length/this.config.maxRequestsPerMinute*100:0;return{requestsThisMinute:this.timestamps.length,tokensThisSession:this.tokenCount,isLimited:!this.canRequest(),isWarning:a>=this.config.warnThresholdPercent||r>=this.config.warnThresholdPercent}}reset(){this.timestamps=[],this.tokenCount=0,this.warningEmitted=!1}pruneOldTimestamps(){const a=Date.now()-6e4;this.timestamps=this.timestamps.filter(r=>r>a)}checkWarning(){var r;if(this.warningEmitted)return;this.getStatus().isWarning&&(this.warningEmitted=!0,(r=this.onWarning)==null||r.call(this))}}const We=c.createContext(null);function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react");class qe{constructor(a={},r){this.timestamps=[],this.tokenCount=0,this.warningEmitted=!1,this.config={maxRequestsPerMinute:a.maxRequestsPerMinute??30,maxTokensPerSession:a.maxTokensPerSession??1e4,warnThresholdPercent:a.warnThresholdPercent??80},this.onWarning=r}canRequest(){return this.pruneOldTimestamps(),!(this.timestamps.length>=this.config.maxRequestsPerMinute||this.tokenCount>=this.config.maxTokensPerSession)}recordRequest(){return this.canRequest()?(this.timestamps.push(Date.now()),!0):!1}recordTokens(a){this.tokenCount+=a,this.checkWarning()}getStatus(){this.pruneOldTimestamps();const a=this.config.maxTokensPerSession>0?this.tokenCount/this.config.maxTokensPerSession*100:0,r=this.config.maxRequestsPerMinute>0?this.timestamps.length/this.config.maxRequestsPerMinute*100:0;return{requestsThisMinute:this.timestamps.length,tokensThisSession:this.tokenCount,isLimited:!this.canRequest(),isWarning:a>=this.config.warnThresholdPercent||r>=this.config.warnThresholdPercent}}reset(){this.timestamps=[],this.tokenCount=0,this.warningEmitted=!1}pruneOldTimestamps(){const a=Date.now()-6e4;this.timestamps=this.timestamps.filter(r=>r>a)}checkWarning(){var r;if(this.warningEmitted)return;this.getStatus().isWarning&&(this.warningEmitted=!0,(r=this.onWarning)==null||r.call(this))}}const We=c.createContext(null);function Ia({config:i,rateLimits:a,enabled:r=!0,onRateLimitWarning:t,children:n}){const s=c.useRef(null);s.current||(s.current=new qe(a,t));const l=c.useCallback(()=>s.current.getStatus(),[]),o=c.useMemo(()=>({config:i,enabled:r,rateLimiter:s.current,getRateLimitStatus:l}),[i,r,l]);return e.jsx(We.Provider,{value:o,children:n})}function Q(){return c.useContext(We)}async function*Ge(i,a){var s,l,o,f,h,y,w,C,S;const r=(s=i.body)==null?void 0:s.getReader();if(!r)throw new Error("Response body is not readable");const t=new TextDecoder;let n="";try{for(;!(a!=null&&a.aborted);){const{done:P,value:k}=await r.read();if(P)break;n+=t.decode(k,{stream:!0});const $=n.split(`
|
|
2
2
|
`);n=$.pop()??"";for(const g of $){const d=g.trim();if(!(!d||d===":")){if(d.startsWith("data:")){const j=d.slice(5).trim();if(j==="[DONE]"){yield{token:"",done:!0};return}try{const N=JSON.parse(j),m=((f=(o=(l=N.choices)==null?void 0:l[0])==null?void 0:o.delta)==null?void 0:f.content)??"",v=((y=(h=N.choices)==null?void 0:h[0])==null?void 0:y.finish_reason)==="stop";(m||v)&&(yield{token:m,done:v,usage:N.usage})}catch{j&&(yield{token:j,done:!1})}continue}try{const j=JSON.parse(d),N=j.text??j.content??j.token??"";N&&(yield{token:N,done:!1})}catch{d&&(yield{token:d,done:!1})}}}}if(n.trim()){const P=n.trim();if(P.startsWith("data:")){const k=P.slice(5).trim();if(k&&k!=="[DONE]")try{const g=((S=(C=(w=JSON.parse(k).choices)==null?void 0:w[0])==null?void 0:C.delta)==null?void 0:S.content)??"";g&&(yield{token:g,done:!0})}catch{yield{token:k,done:!0}}}}}finally{r.releaseLock()}}async function Ve(i){var r,t,n,s;const a=await i.json();if((n=(t=(r=a.choices)==null?void 0:r[0])==null?void 0:t.message)!=null&&n.content)return{text:a.choices[0].message.content,usage:a.usage};if((s=a.message)!=null&&s.content)return{text:a.message.content};if(typeof a.text=="string")return{text:a.text};if(typeof a.content=="string")return{text:a.content};if(typeof a.response=="string")return{text:a.response};throw new Error("Unrecognized AI response format")}const se=new Map;function Oe(i,a){const r=a?{...i,fieldValue:void 0,formContext:void 0}:i;return JSON.stringify(r)}function La(i,a){const r=[],t=a.systemPrompt??"You are a helpful assistant providing concise contextual hints for form fields. Keep responses short (1-3 sentences). Be specific and actionable.";r.push({role:"system",content:t});const n=[];if(i.fieldLabel&&n.push(`Field: "${i.fieldLabel}"`),i.fieldType&&n.push(`Type: ${i.fieldType}`),!a.privacyMode&&i.fieldValue!==void 0){const l=typeof i.fieldValue=="string"?i.fieldValue:JSON.stringify(i.fieldValue);n.push(`Current value: ${l}`)}i.validationRules&&Object.keys(i.validationRules).length>0&&n.push(`Validation: ${JSON.stringify(i.validationRules)}`),i.schema&&Object.keys(i.schema).length>0&&n.push(`Schema: ${JSON.stringify(i.schema)}`),!a.privacyMode&&i.formContext&&Object.keys(i.formContext).length>0&&n.push(`Form context: ${JSON.stringify(i.formContext)}`),i.customPrompt&&n.push(i.customPrompt);const s=n.length>0?`Provide a helpful hint for this field:
|
|
3
3
|
${n.join(`
|
|
4
|
-
`)}`:"Provide a helpful suggestion.";return r.push({role:"user",content:s}),r}function X(i={},a={}){i=i??{},a=a??{};const{debounceMs:r=500,disabled:t=!1}=a,n=Q(),[s,l]=c.useState(""),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(!1),S=c.useRef(null),P=c.useRef(0),k=c.useCallback(async()=>{var _,M,R;if(!n||!n.enabled||t)return;const{config:d,rateLimiter:j}=n;if(!j.recordRequest()){y("Rate limit exceeded. Please wait before requesting another hint.");return}const N=Oe(i,d.privacyMode??!1),m=se.get(N);if(m){l(m),f(!1),y(null),C(!1);return}(_=S.current)==null||_.abort();const v=new AbortController;S.current=v,f(!0),y(null),l(""),C(!1);const x=La(i,d),p=d.stream!==!1;try{const T={"Content-Type":"application/json",...d.headers};d.apiKey&&(T.Authorization=`Bearer ${d.apiKey}`);const u=JSON.stringify({model:d.model??"gpt-3.5-turbo",messages:x,temperature:d.temperature??.7,max_tokens:d.maxTokens??256,stream:p}),b=await fetch(d.endpoint,{method:"POST",headers:T,body:u,signal:v.signal});if(!b.ok){const
|
|
4
|
+
`)}`:"Provide a helpful suggestion.";return r.push({role:"user",content:s}),r}function X(i={},a={}){i=i??{},a=a??{};const{debounceMs:r=500,disabled:t=!1}=a,n=Q(),[s,l]=c.useState(""),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(!1),S=c.useRef(null),P=c.useRef(0),k=c.useCallback(async()=>{var _,M,R;if(!n||!n.enabled||t)return;const{config:d,rateLimiter:j}=n;if(!j.recordRequest()){y("Rate limit exceeded. Please wait before requesting another hint.");return}const N=Oe(i,d.privacyMode??!1),m=se.get(N);if(m){l(m),f(!1),y(null),C(!1);return}(_=S.current)==null||_.abort();const v=new AbortController;S.current=v,f(!0),y(null),l(""),C(!1);const x=La(i,d),p=d.stream!==!1;try{const T={"Content-Type":"application/json",...d.headers};d.apiKey&&(T.Authorization=`Bearer ${d.apiKey}`);const u=JSON.stringify({model:d.model??"gpt-3.5-turbo",messages:x,temperature:d.temperature??.7,max_tokens:d.maxTokens??256,stream:p}),b=await fetch(d.endpoint,{method:"POST",headers:T,body:u,signal:v.signal});if(!b.ok){const z=await b.text().catch(()=>b.statusText);throw new Error(`AI request failed (${b.status}): ${z}`)}if(p){C(!0);let z="";for await(const D of Ge(b,v.signal))if(v.signal.aborted||(z+=D.token,l(z),(M=D.usage)!=null&&M.completion_tokens&&j.recordTokens(D.usage.completion_tokens),D.done))break;if(z.length>0){const D=Math.ceil(z.length/4);j.recordTokens(D)}se.set(N,z)}else{const z=await Ve(b);l(z.text),se.set(N,z.text),(R=z.usage)!=null&&R.completion_tokens?j.recordTokens(z.usage.completion_tokens):j.recordTokens(Math.ceil(z.text.length/4))}}catch(T){if(T instanceof DOMException&&T.name==="AbortError")return;y(T instanceof Error?T.message:"AI hint request failed")}finally{v.signal.aborted||(f(!1),C(!1))}},[n,i,t]);c.useEffect(()=>{if(!n||!n.enabled||t)return;const d=setTimeout(k,r);return()=>clearTimeout(d)},[i==null?void 0:i.fieldLabel,i==null?void 0:i.fieldType,i==null?void 0:i.fieldValue,i==null?void 0:i.customPrompt,r,t,n==null?void 0:n.enabled,P.current]),c.useEffect(()=>()=>{var d;(d=S.current)==null||d.abort()},[]);const $=c.useCallback(()=>{var d;(d=S.current)==null||d.abort(),f(!1),C(!1)},[]),g=c.useCallback(()=>{if(n){const d=Oe(i,n.config.privacyMode??!1);se.delete(d)}P.current+=1,k()},[n,i,k]);return!n||!n.enabled?{text:"",loading:!1,error:null,streaming:!1,abort:()=>{},refresh:()=>{},hint:null,fetchHint:async()=>{}}:{text:s,loading:o,error:h,streaming:w,abort:$,refresh:g,hint:s?{content:s}:null,fetchHint:async()=>{await k()}}}function Oa(){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5z"}),e.jsx("path",{d:"M19 15l.5 2 2 .5-2 .5-.5 2-.5-2-2-.5 2-.5z"}),e.jsx("path",{d:"M5 19l.5 1.5 1.5.5-1.5.5-.5 1.5-.5-1.5-1.5-.5 1.5-.5z"})]})}function Ea(i,a){if(i!=="auto"||!a)return i==="auto"?"top":i;const r=a.top,t=window.innerHeight-a.bottom,n=a.left,s=window.innerWidth-a.right,l=Math.max(r,t,n,s);return l===r?"top":l===t?"bottom":l===s?"right":"left"}function Da(i){const a={position:"absolute",zIndex:9999,minWidth:200,maxWidth:320,padding:"8px 12px",borderRadius:8,fontSize:13,lineHeight:1.5,backgroundColor:"var(--ntd-ai-bg, #1e1e2e)",color:"var(--ntd-ai-fg, #cdd6f4)",border:"1px solid var(--ntd-ai-border, #45475a)",boxShadow:"0 4px 16px var(--nice-overlay-25, rgba(0, 0, 0, 0.25))",wordWrap:"break-word"};switch(i){case"top":return{...a,bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6};case"bottom":return{...a,top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:6};case"left":return{...a,right:"100%",top:"50%",transform:"translateY(-50%)",marginRight:6};case"right":return{...a,left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:6};default:return{...a,bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6}}}const Se=c.forwardRef(({context:i,position:a="auto",debounceMs:r=500,showOnHover:t=!1,triggerIcon:n,className:s,style:l},o)=>{var N;const f=Q(),[h,y]=c.useState(!1),[w,C]=c.useState(!1),S=c.useRef(null),P=c.useRef(null),k=X(i,{debounceMs:r,disabled:!w});c.useEffect(()=>{if(!h)return;const m=v=>{var p,_;const x=v.target;(p=S.current)!=null&&p.contains(x)||(_=P.current)!=null&&_.contains(x)||(y(!1),C(!1))};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[h]),c.useEffect(()=>{if(!h)return;const m=v=>{v.key==="Escape"&&(y(!1),C(!1),k.abort())};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[h,k]);const $=c.useCallback(m=>{if(m.stopPropagation(),t)return;const v=!h;y(v),C(v)},[h,t]),g=c.useCallback(()=>{t&&(y(!0),C(!0))},[t]),d=c.useCallback(()=>{t&&(y(!1),C(!1))},[t]);if(!f||!f.enabled)return null;const j=Ea(a,((N=S.current)==null?void 0:N.getBoundingClientRect())??null);return e.jsxs("span",{ref:o,className:s,style:{position:"relative",display:"inline-flex",...l},onMouseEnter:g,onMouseLeave:d,children:[e.jsx("button",{ref:S,type:"button",onClick:$,"aria-label":"AI hint","aria-expanded":h,className:"ntd-ai-trigger",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",padding:2,borderRadius:4,color:"var(--ntd-ai-trigger-color, #a78bfa)",opacity:.7,transition:"opacity 0.2s, transform 0.2s"},children:n??e.jsx(Oa,{})}),h&&e.jsxs("div",{ref:P,role:"tooltip",className:"ntd-ai-popover",style:Da(j),children:[k.loading&&!k.text&&e.jsxs("div",{className:"ntd-ai-loading",style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{display:"inline-block",width:12,height:12,border:"2px solid var(--ntd-ai-border, #45475a)",borderTopColor:"var(--ntd-ai-trigger-color, #a78bfa)",borderRadius:"50%",animation:"ntd-ai-spin 0.8s linear infinite"}}),e.jsx("span",{style:{opacity:.6},children:"Thinking..."})]}),k.text&&e.jsxs("div",{className:"ntd-ai-content",children:[k.text,k.streaming&&e.jsx("span",{className:"ntd-ai-cursor",style:{display:"inline-block",width:2,height:"1em",backgroundColor:"var(--ntd-ai-trigger-color, #a78bfa)",marginLeft:1,animation:"ntd-ai-blink 0.8s step-end infinite",verticalAlign:"text-bottom"}})]}),k.error&&e.jsx("div",{className:"ntd-ai-error",style:{color:"var(--ntd-ai-error, #f38ba8)"},children:k.error}),k.text&&!k.streaming&&e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:4,marginTop:6,paddingTop:6,borderTop:"1px solid var(--ntd-ai-border, #45475a)"},children:[e.jsx("button",{type:"button",onClick:()=>k.refresh(),className:"ntd-ai-action",style:{fontSize:11,padding:"2px 6px",border:"1px solid var(--ntd-ai-border, #45475a)",borderRadius:4,background:"transparent",color:"inherit",cursor:"pointer"},children:"↻ Refresh"}),e.jsx("button",{type:"button",onClick:()=>{var m;(m=navigator.clipboard)==null||m.writeText(k.text)},className:"ntd-ai-action",style:{fontSize:11,padding:"2px 6px",border:"1px solid var(--ntd-ai-border, #45475a)",borderRadius:4,background:"transparent",color:"inherit",cursor:"pointer"},children:"⎘ Copy"})]})]})]})});Se.displayName="NiceAIHintBubble";function Te(i,a,r){return{fieldLabel:i,fieldType:"text",fieldValue:a,validationRules:{...(r==null?void 0:r.maxLength)!=null?{maxLength:r.maxLength}:{},...r!=null&&r.pattern?{pattern:r.pattern}:{}},customPrompt:r!=null&&r.placeholder?`Placeholder: "${r.placeholder}". Suggest content or correct grammar.`:"Suggest content, correct grammar, or auto-complete the text."}}function Ae(i,a,r){return{fieldLabel:i,fieldType:"number",fieldValue:a,validationRules:{...(r==null?void 0:r.min)!=null?{min:r.min}:{},...(r==null?void 0:r.max)!=null?{max:r.max}:{},...(r==null?void 0:r.step)!=null?{step:r.step}:{}},customPrompt:r!=null&&r.unit?`Unit: ${r.unit}. Suggest a reasonable value or range for this field.`:"Suggest a reasonable value or range for this field based on the label and constraints."}}function Re(i,a,r){return{fieldLabel:i,fieldType:r!=null&&r.multiple?"multi-select":"select",fieldValue:a,schema:r!=null&&r.options?{availableOptions:r.options.slice(0,20).map(t=>t.label)}:{},customPrompt:"Suggest the most likely selection. Explain why this option is recommended."}}function Me(i,a,r){const t=a instanceof Date?a.toISOString().split("T")[0]:a;return{fieldLabel:i,fieldType:"date",fieldValue:t,validationRules:{...r!=null&&r.min?{min:r.min}:{},...r!=null&&r.max?{max:r.max}:{},...r!=null&&r.disableWeekends?{noWeekends:!0}:{}},customPrompt:'Suggest a date. For example: "next business day", "end of month", "in 2 weeks". Explain your suggestion briefly.'}}function Pe(i,a,r){return{fieldLabel:i,fieldType:"color",fieldValue:a,schema:r!=null&&r.palette?{currentPalette:r.palette}:{},customPrompt:r!=null&&r.industry?`Industry: ${r.industry}. Suggest a color palette (3-5 hex colors) suitable for this context.`:"Suggest a color or palette of colors that works well for this context. Provide hex values."}}function Ha(i,a){return{fieldLabel:i,fieldType:"data-grid",schema:{...a!=null&&a.columns?{columns:a.columns}:{},...(a==null?void 0:a.rowCount)!=null?{totalRows:a.rowCount}:{}},formContext:{...a!=null&&a.currentFilters?{filters:a.currentFilters}:{},...a!=null&&a.currentSorts?{sorts:a.currentSorts}:{}},customPrompt:"Suggest column configuration, useful filters, or highlight potential data anomalies."}}function Ba(i,a){return{fieldLabel:i,fieldType:"chart",schema:{...a!=null&&a.currentType?{chartType:a.currentType}:{},...(a==null?void 0:a.seriesCount)!=null?{series:a.seriesCount}:{},...(a==null?void 0:a.pointCount)!=null?{dataPoints:a.pointCount}:{}},customPrompt:a!=null&&a.dataDescription?`Data: ${a.dataDescription}. Suggest the best chart type and labeling strategy.`:"Suggest the most effective chart type for this data. Explain your recommendation."}}function Ke(i,a){return{fieldLabel:"Form auto-fill",fieldType:"form",schema:{fields:a},customPrompt:`User description: "${i}"
|
|
5
5
|
Parse this description and return suggested values for each field as JSON: { ${a.map(r=>`"${r.label}": "value"`).join(", ")} }`}}function Ye(i,a,r,t,n){return{fieldLabel:i,fieldType:a,fieldValue:r,validationRules:n==null?void 0:n.rules,customPrompt:`Current validation error: "${t}". Provide a friendly, specific error message with an example of a valid value. Do NOT say "field is required" — instead explain what the user should enter.`}}function Fa(i,a,r){const t=c.useMemo(()=>Te(i,a,r),[i,a,r==null?void 0:r.placeholder,r==null?void 0:r.maxLength,r==null?void 0:r.pattern]);return X(t,r)}function Ja(i,a,r){const t=c.useMemo(()=>Ae(i,a,r),[i,a,r==null?void 0:r.min,r==null?void 0:r.max,r==null?void 0:r.step,r==null?void 0:r.unit]);return X(t,r)}function Ua(i,a,r){const t=c.useMemo(()=>Re(i,a,r),[i,a,r==null?void 0:r.multiple]);return X(t,r)}function qa(i,a,r){const t=c.useMemo(()=>Me(i,a,r),[i,a,r==null?void 0:r.min,r==null?void 0:r.max,r==null?void 0:r.disableWeekends]);return X(t,r)}function Wa(i,a,r){const t=c.useMemo(()=>Pe(i,a,r),[i,a,r==null?void 0:r.industry]);return X(t,r)}function Ga(i,a,r,t,n){const s=c.useMemo(()=>t?Ye(i,a,r,t,n):{fieldLabel:i,fieldType:a},[i,a,r,t]);return X(s,{...n,disabled:!t||(n==null?void 0:n.disabled)})}function Va(i,a,r){const t=c.useMemo(()=>i?Ke(i,a):{fieldLabel:"Form"},[i,a]);return X(t,{...r,disabled:!i||(r==null?void 0:r.disabled)})}function Xe(i,a,r){const n=(a==null?void 0:a.split(`
|
|
6
6
|
`))??[],s=(r==null?void 0:r.cursorLine)!=null?n.slice(Math.max(0,r.cursorLine-8),r.cursorLine+3).join(`
|
|
7
7
|
`):n.slice(0,8*2).join(`
|
|
@@ -33,12 +33,12 @@ Return the ${(a==null?void 0:a.limit)??5} most semantically relevant icon names
|
|
|
33
33
|
}
|
|
34
34
|
.nice-tutorial-button--sm { width: 16px; height: 16px; font-size: 11px; }
|
|
35
35
|
.nice-tutorial-button--md { width: 20px; height: 20px; font-size: 12px; }
|
|
36
|
-
`,document.head.appendChild(i)}c.createContext(null);c.createContext(null);c.createContext(null);const da={space1:"4px",space2:"8px",space3:"12px",space4:"16px",space5:"20px",space6:"24px",space8:"32px"},ua={fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontSizeXs:"0.75rem",fontSizeSm:"0.8125rem",fontSizeMd:"0.875rem",fontSizeLg:"1rem",fontSizeXl:"1.125rem",fontWeightNormal:400,fontWeightMedium:500,fontWeightSemibold:600,fontWeightBold:700,lineHeight:1.5},pa={fast:"120ms ease",normal:"200ms ease",slow:"300ms ease"},ma=i=>({color:i,radiusSm:"4px",radiusMd:"6px",radiusLg:"8px",radiusXl:"12px",radiusFull:"9999px"}),Cr={sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"},Sr={sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.4)"};function E(i,a,r,t,n){return{name:i,darkMode:"light",colors:{...a,surface:a.surface??r.primary,surfaceHover:a.surfaceHover??r.secondary},backgrounds:{...r,elevated:r.elevated??r.primary,inset:r.inset??r.tertiary,canvas:r.canvas??r.primary},text:{...t,inverse:t.inverse??"#ffffff"},borders:ma(n),shadows:Cr,spacing:da,typography:ua,transitions:pa}}function K(i,a,r,t,n){return{name:i,darkMode:"dark",colors:{...a,surface:a.surface??r.secondary,surfaceHover:a.surfaceHover??r.tertiary},backgrounds:{...r,elevated:r.elevated??r.secondary,inset:r.inset??r.primary,canvas:r.canvas??r.primary},text:{...t,inverse:t.inverse??"#0f172a"},borders:ma(n),shadows:Sr,spacing:da,typography:ua,transitions:pa}}E("Slate",{primary:"#64748b",primaryHover:"#475569",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#1e293b",secondary:"#475569",muted:"#94a3b8"},"#cbd5e1");E("Zinc",{primary:"#71717a",primaryHover:"#52525b",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fafafa",secondary:"#f4f4f5",tertiary:"#e4e4e7",hover:"#e4e4e7"},{primary:"#18181b",secondary:"#3f3f46",muted:"#a1a1aa"},"#d4d4d8");E("Stone",{primary:"#78716c",primaryHover:"#57534e",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#1c1917",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");E("Cool Gray",{primary:"#6b7280",primaryHover:"#4b5563",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#d1d5db");E("Warm Gray",{primary:"#7c7568",primaryHover:"#5c564c",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf9f7",secondary:"#f5f4f0",tertiary:"#e8e6e1",hover:"#e8e6e1"},{primary:"#1f1d19",secondary:"#4a463d",muted:"#a09888"},"#d4d0c8");E("Silver",{primary:"#94a3b8",primaryHover:"#64748b",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#38bdf8"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#334155",secondary:"#64748b",muted:"#94a3b8"},"#cbd5e1");E("Charcoal",{primary:"#374151",primaryHover:"#1f2937",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#6b7280"},"#d1d5db");E("Ivory",{primary:"#92876d",primaryHover:"#7a6f55",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffef7",secondary:"#faf6eb",tertiary:"#f0ead6",hover:"#f0ead6"},{primary:"#2b2517",secondary:"#5c5340",muted:"#9c9280"},"#ddd8c4");E("Rose",{primary:"#e11d48",primaryHover:"#be123c",success:"#16a34a",warning:"#ea580c",error:"#dc2626",info:"#0891b2"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f43f5e"},"#fda4af");E("Emerald",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#34d399"},"#6ee7b7");E("Amber",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0284c7"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#f59e0b"},"#fcd34d");E("Violet",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#2e1065",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");E("Teal",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");E("Indigo",{primary:"#4f46e5",primaryHover:"#4338ca",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#eef2ff",secondary:"#e0e7ff",tertiary:"#c7d2fe",hover:"#e0e7ff"},{primary:"#1e1b4b",secondary:"#312e81",muted:"#818cf8"},"#a5b4fc");E("Cyan",{primary:"#0891b2",primaryHover:"#0e7490",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#0284c7"},{primary:"#ecfeff",secondary:"#cffafe",tertiary:"#a5f3fc",hover:"#cffafe"},{primary:"#164e63",secondary:"#155e75",muted:"#22d3ee"},"#67e8f9");E("Lime",{primary:"#65a30d",primaryHover:"#4d7c0f",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f7fee7",secondary:"#ecfccb",tertiary:"#d9f99d",hover:"#ecfccb"},{primary:"#1a2e05",secondary:"#365314",muted:"#84cc16"},"#bef264");E("Pink",{primary:"#db2777",primaryHover:"#be185d",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#500724",secondary:"#831843",muted:"#f472b6"},"#f9a8d4");E("Orange",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#7c2d12",muted:"#fb923c"},"#fdba74");E("Fuchsia",{primary:"#c026d3",primaryHover:"#a21caf",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf4ff",secondary:"#fae8ff",tertiary:"#f5d0fe",hover:"#fae8ff"},{primary:"#4a044e",secondary:"#701a75",muted:"#d946ef"},"#e879f9");E("Sky",{primary:"#0284c7",primaryHover:"#0369a1",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#075985",muted:"#38bdf8"},"#7dd3fc");E("Ruby",{primary:"#be123c",primaryHover:"#9f1239",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#fb7185"},"#fda4af");E("Coral",{primary:"#f97316",primaryHover:"#ea580c",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#fb923c"},"#fdba74");K("Midnight",{primary:"#818cf8",primaryHover:"#6366f1",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#020617",secondary:"#0f172a",tertiary:"#1e293b",hover:"#1e293b"},{primary:"#f1f5f9",secondary:"#94a3b8",muted:"#475569"},"#1e293b");K("Obsidian",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#facc15",error:"#fb7185",info:"#38bdf8"},{primary:"#09090b",secondary:"#18181b",tertiary:"#27272a",hover:"#27272a"},{primary:"#fafafa",secondary:"#a1a1aa",muted:"#52525b"},"#3f3f46");K("Eclipse",{primary:"#c084fc",primaryHover:"#a855f7",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#67e8f9"},{primary:"#0c0a1d",secondary:"#1a1533",tertiary:"#2a2248",hover:"#2a2248"},{primary:"#f5f3ff",secondary:"#a78bfa",muted:"#6d5eac"},"#3b3266");K("Onyx",{primary:"#60a5fa",primaryHover:"#3b82f6",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#000000",secondary:"#0a0a0a",tertiary:"#171717",hover:"#171717"},{primary:"#ffffff",secondary:"#a3a3a3",muted:"#525252"},"#262626");K("Carbon",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#67e8f9"},{primary:"#161616",secondary:"#262626",tertiary:"#393939",hover:"#393939"},{primary:"#f4f4f4",secondary:"#c6c6c6",muted:"#6f6f6f"},"#525252");K("Cosmos",{primary:"#6366f1",primaryHover:"#4f46e5",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#030712",secondary:"#111827",tertiary:"#1f2937",hover:"#1f2937"},{primary:"#e5e7eb",secondary:"#9ca3af",muted:"#4b5563"},"#374151");K("Nebula",{primary:"#e879f9",primaryHover:"#d946ef",success:"#4ade80",warning:"#fbbf24",error:"#fb7185",info:"#67e8f9"},{primary:"#0d0117",secondary:"#1a0533",tertiary:"#2d0a52",hover:"#2d0a52"},{primary:"#fae8ff",secondary:"#d8b4fe",muted:"#7c3aed"},"#581c87");K("Abyss",{primary:"#22d3ee",primaryHover:"#06b6d4",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#001219",secondary:"#002a3a",tertiary:"#003e54",hover:"#003e54"},{primary:"#e0f2fe",secondary:"#7dd3fc",muted:"#0369a1"},"#075985");K("Shadow",{primary:"#a3a3a3",primaryHover:"#737373",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#38bdf8"},{primary:"#171717",secondary:"#1f1f1f",tertiary:"#2a2a2a",hover:"#2a2a2a"},{primary:"#e5e5e5",secondary:"#a3a3a3",muted:"#525252"},"#404040");K("Emerald Dark",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#022c22",secondary:"#064e3b",tertiary:"#065f46",hover:"#065f46"},{primary:"#ecfdf5",secondary:"#6ee7b7",muted:"#047857"},"#047857");E("Forest",{primary:"#166534",primaryHover:"#14532d",success:"#22c55e",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");E("Ocean",{primary:"#0369a1",primaryHover:"#075985",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#38bdf8"},"#7dd3fc");E("Desert",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#422006",secondary:"#713f12",muted:"#ca8a04"},"#fde047");E("Sunset",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#f97316"},"#fdba74");E("Aurora",{primary:"#0d9488",primaryHover:"#0f766e",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");E("Lavender",{primary:"#7e22ce",primaryHover:"#6b21a8",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#3b0764",secondary:"#581c87",muted:"#a855f7"},"#d8b4fe");E("Autumn",{primary:"#c2410c",primaryHover:"#9a3412",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#7f1d1d",muted:"#f87171"},"#fca5a5");E("Spring",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#14532d",secondary:"#166534",muted:"#4ade80"},"#86efac");E("Arctic",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");E("Tropical",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");E("Pastel Rose",{primary:"#f472b6",primaryHover:"#ec4899",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#f9a8d4");E("Pastel Sky",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#075985",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");E("Pastel Mint",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#065f46",secondary:"#047857",muted:"#6ee7b7"},"#a7f3d0");E("Pastel Peach",{primary:"#fb923c",primaryHover:"#f97316",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#7c2d12",secondary:"#9a3412",muted:"#fdba74"},"#fed7aa");E("Pastel Lavender",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#4c1d95",secondary:"#5b21b6",muted:"#c4b5fd"},"#ddd6fe");E("Pastel Lemon",{primary:"#facc15",primaryHover:"#eab308",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#713f12",secondary:"#854d0e",muted:"#fde047"},"#fef08a");E("Pastel Sage",{primary:"#86efac",primaryHover:"#4ade80",success:"#22c55e",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#166534",secondary:"#15803d",muted:"#86efac"},"#bbf7d0");E("Pastel Coral",{primary:"#fb7185",primaryHover:"#f43f5e",success:"#4ade80",warning:"#fcd34d",error:"#ef4444",info:"#67e8f9"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#881337",secondary:"#9f1239",muted:"#fda4af"},"#fecdd3");E("Banking",{primary:"#1e3a5f",primaryHover:"#152c4a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#334155",muted:"#94a3b8"},"#cbd5e1");E("Healthcare",{primary:"#0891b2",primaryHover:"#0e7490",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#e0f7fa",tertiary:"#b2ebf2",hover:"#e0f7fa"},{primary:"#134e4a",secondary:"#1a6b6a",muted:"#80cbc4"},"#b2dfdb");E("Legal",{primary:"#1e293b",primaryHover:"#0f172a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#0f172a",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");E("Tech Startup",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#1e1b4b",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");E("Enterprise",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#60a5fa"},"#93c5fd");E("Government",{primary:"#1d4ed8",primaryHover:"#1e40af",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#1e293b",muted:"#64748b"},"#cbd5e1");E("Education",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#0891b2"},{primary:"#f0fdf9",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");E("Real Estate",{primary:"#92400e",primaryHover:"#78350f",success:"#059669",warning:"#b45309",error:"#dc2626",info:"#0891b2"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#422006",secondary:"#713f12",muted:"#d97706"},"#fcd34d");E("Nord",{primary:"#5e81ac",primaryHover:"#4c6b90",success:"#a3be8c",warning:"#ebcb8b",error:"#bf616a",info:"#88c0d0"},{primary:"#eceff4",secondary:"#e5e9f0",tertiary:"#d8dee9",hover:"#d8dee9"},{primary:"#2e3440",secondary:"#3b4252",muted:"#4c566a"},"#d8dee9");K("Dracula",{primary:"#bd93f9",primaryHover:"#9d79d9",success:"#50fa7b",warning:"#f1fa8c",error:"#ff5555",info:"#8be9fd"},{primary:"#282a36",secondary:"#343746",tertiary:"#44475a",hover:"#44475a"},{primary:"#f8f8f2",secondary:"#c0c0c0",muted:"#6272a4"},"#44475a");E("Solarized Light",{primary:"#268bd2",primaryHover:"#1a6da0",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#fdf6e3",secondary:"#eee8d5",tertiary:"#e0dbc7",hover:"#eee8d5"},{primary:"#073642",secondary:"#586e75",muted:"#93a1a1"},"#eee8d5");K("Solarized Dark",{primary:"#268bd2",primaryHover:"#3d98db",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#002b36",secondary:"#073642",tertiary:"#0a4858",hover:"#073642"},{primary:"#eee8d5",secondary:"#93a1a1",muted:"#586e75"},"#073642");K("Monokai",{primary:"#66d9ef",primaryHover:"#45c0d6",success:"#a6e22e",warning:"#e6db74",error:"#f92672",info:"#66d9ef"},{primary:"#272822",secondary:"#34352e",tertiary:"#3e3d32",hover:"#3e3d32"},{primary:"#f8f8f2",secondary:"#cfcfc2",muted:"#75715e"},"#3e3d32");K("One Dark",{primary:"#61afef",primaryHover:"#4b9ee0",success:"#98c379",warning:"#e5c07b",error:"#e06c75",info:"#56b6c2"},{primary:"#282c34",secondary:"#2c313a",tertiary:"#353b45",hover:"#353b45"},{primary:"#abb2bf",secondary:"#828997",muted:"#545862"},"#3e4452");K("Synthwave",{primary:"#ff7edb",primaryHover:"#e660c2",success:"#72f1b8",warning:"#fede5d",error:"#fe4450",info:"#36f9f6"},{primary:"#241b2f",secondary:"#2d2140",tertiary:"#362a50",hover:"#362a50"},{primary:"#f0e4fc",secondary:"#b4a0cc",muted:"#6c5c84"},"#4a3866");E("Vaporwave",{primary:"#ff71ce",primaryHover:"#e655b5",success:"#78dcca",warning:"#ffb86c",error:"#ff5555",info:"#76e8fc"},{primary:"#fce4f7",secondary:"#e8d0f4",tertiary:"#d4bcf0",hover:"#e8d0f4"},{primary:"#4a1a4e",secondary:"#7b3f7d",muted:"#c080c0"},"#d8a8e8");K("Terminal Green",{primary:"#00ff41",primaryHover:"#00cc34",success:"#00ff41",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0a0a0a",secondary:"#0d1a0d",tertiary:"#1a2e1a",hover:"#1a2e1a"},{primary:"#00ff41",secondary:"#00cc33",muted:"#008822"},"#003300");E("Sepia",{primary:"#8b6914",primaryHover:"#704f10",success:"#6b8e23",warning:"#cd853f",error:"#b22222",info:"#5f9ea0"},{primary:"#faf0e6",secondary:"#f5e6d3",tertiary:"#eddcc7",hover:"#f5e6d3"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#d7ccc8");E("Vintage",{primary:"#8d6e63",primaryHover:"#6d4c41",success:"#66bb6a",warning:"#ffb300",error:"#e53935",info:"#29b6f6"},{primary:"#efebe9",secondary:"#d7ccc8",tertiary:"#bcaaa4",hover:"#d7ccc8"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#bcaaa4");K("Cyberpunk",{primary:"#00f0ff",primaryHover:"#00c8d4",success:"#39ff14",warning:"#ffff00",error:"#ff003c",info:"#bf00ff"},{primary:"#0a0e17",secondary:"#131824",tertiary:"#1c2333",hover:"#1c2333"},{primary:"#e0fbfc",secondary:"#80d4dd",muted:"#3a6b72"},"#1c3a44");K("Neon",{primary:"#ff00ff",primaryHover:"#cc00cc",success:"#00ff00",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0d0d0d",secondary:"#1a1a1a",tertiary:"#262626",hover:"#262626"},{primary:"#ffffff",secondary:"#cccccc",muted:"#666666"},"#333333");K("Retrowave",{primary:"#f77fbe",primaryHover:"#e462a3",success:"#72f1b8",warning:"#ffe261",error:"#ff4444",info:"#79e8fb"},{primary:"#1b0a2e",secondary:"#261440",tertiary:"#321e52",hover:"#321e52"},{primary:"#ffe6f7",secondary:"#c9a0c9",muted:"#6b4c7a"},"#4a2d66");E("Christmas",{primary:"#c41e3a",primaryHover:"#a01830",success:"#228b22",warning:"#ffd700",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");K("Halloween",{primary:"#ff6600",primaryHover:"#e05500",success:"#4ade80",warning:"#fbbf24",error:"#ff0000",info:"#9333ea"},{primary:"#1a0a00",secondary:"#2d1500",tertiary:"#402000",hover:"#402000"},{primary:"#ffedd5",secondary:"#fdba74",muted:"#9a5c28"},"#5c3400");E("Valentine",{primary:"#e11d48",primaryHover:"#be123c",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#ec4899"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f9a8d4"},"#fda4af");E("Easter",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fef9ff",secondary:"#f3e8ff",tertiary:"#e8d5ff",hover:"#f3e8ff"},{primary:"#581c87",secondary:"#6d28d9",muted:"#c4b5fd"},"#ddd6fe");E("Summer Beach",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#fcd34d");E("Winter Frost",{primary:"#3b82f6",primaryHover:"#2563eb",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#93c5fd"},"#bfdbfe");E("Cherry Blossom",{primary:"#ec4899",primaryHover:"#db2777",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#fbcfe8");E("Harvest",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#d97706"},"#fcd34d");E("Japanese Zen",{primary:"#6b7280",primaryHover:"#4b5563",success:"#6b8e23",warning:"#d4a017",error:"#c0392b",info:"#5f9ea0"},{primary:"#faf9f6",secondary:"#f0ece3",tertiary:"#e6e0d4",hover:"#f0ece3"},{primary:"#2c2c2c",secondary:"#5c5c5c",muted:"#a0998a"},"#d5cec0");E("Moroccan",{primary:"#c2410c",primaryHover:"#9a3412",success:"#15803d",warning:"#ca8a04",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbf0",secondary:"#fef3e0",tertiary:"#fde6c4",hover:"#fef3e0"},{primary:"#3a1a00",secondary:"#7c2d12",muted:"#d97706"},"#f5d0a0");E("Scandinavian",{primary:"#4b5563",primaryHover:"#374151",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ffffff",secondary:"#f9fafb",tertiary:"#f3f4f6",hover:"#f3f4f6"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#e5e7eb");E("Mediterranean",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#2563eb",muted:"#93c5fd"},"#bfdbfe");E("Chinese New Year",{primary:"#dc2626",primaryHover:"#b91c1c",success:"#16a34a",warning:"#d4a017",error:"#ef4444",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#991b1b",muted:"#f87171"},"#fca5a5");E("Indian Festive",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#7c3aed"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#92400e",muted:"#f59e0b"},"#fcd34d");E("Brazilian Carnival",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#facc15",error:"#ef4444",info:"#0ea5e9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");E("African Earth",{primary:"#92400e",primaryHover:"#78350f",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf5f0",secondary:"#f0e6d6",tertiary:"#e6d5bb",hover:"#f0e6d6"},{primary:"#2b1a0e",secondary:"#5c3d1e",muted:"#a08060"},"#d4b896");K("High Contrast Dark",{primary:"#ffff00",primaryHover:"#cccc00",success:"#00ff00",warning:"#ff8c00",error:"#ff0000",info:"#00ffff"},{primary:"#000000",secondary:"#1a1a1a",tertiary:"#333333",hover:"#333333"},{primary:"#ffffff",secondary:"#ffffff",muted:"#cccccc"},"#ffffff");E("Monochrome",{primary:"#404040",primaryHover:"#262626",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fafafa",secondary:"#f0f0f0",tertiary:"#e0e0e0",hover:"#e0e0e0"},{primary:"#1a1a1a",secondary:"#404040",muted:"#808080"},"#c0c0c0");E("Enhanced Contrast",{primary:"#0050b3",primaryHover:"#003d8c",success:"#006400",warning:"#cc7000",error:"#cc0000",info:"#006680"},{primary:"#ffffff",secondary:"#f5f5f5",tertiary:"#ebebeb",hover:"#ebebeb"},{primary:"#000000",secondary:"#1a1a1a",muted:"#595959"},"#8c8c8c");E("Minimalist",{primary:"#18181b",primaryHover:"#27272a",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"},{primary:"#ffffff",secondary:"#fafafa",tertiary:"#f5f5f5",hover:"#f5f5f5"},{primary:"#0a0a0a",secondary:"#404040",muted:"#a3a3a3"},"#e5e5e5");K("Warm Dark",{primary:"#f59e0b",primaryHover:"#d97706",success:"#10b981",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#1c1917",secondary:"#292524",tertiary:"#44403c",hover:"#44403c"},{primary:"#fafaf9",secondary:"#d6d3d1",muted:"#78716c"},"#57534e");K("Soft Dark",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#34d399",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#1e1e2e",secondary:"#262637",tertiary:"#313147",hover:"#313147"},{primary:"#e8e8f0",secondary:"#a0a0b8",muted:"#5c5c74"},"#3e3e58");E("Coffee",{primary:"#6f4e37",primaryHover:"#5c3d28",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf6f1",secondary:"#f0e8dc",tertiary:"#e6d8c6",hover:"#f0e8dc"},{primary:"#2c1a0e",secondary:"#5c3d28",muted:"#a08868"},"#d4c4a8");E("Wine",{primary:"#7f1d1d",primaryHover:"#641717",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");c.createContext(null);const Tr={id:crypto.randomUUID(),name:"New ML Project",type:"classification",status:"draft",datasets:[],experiments:[],models:[],createdAt:new Date,updatedAt:new Date},De={classification:[{id:"logistic-regression",name:"Logistic Regression"},{id:"random-forest",name:"Random Forest"},{id:"gradient-boosting",name:"Gradient Boosting"},{id:"svm",name:"Support Vector Machine"},{id:"neural-network",name:"Neural Network"},{id:"xgboost",name:"XGBoost"}],regression:[{id:"linear-regression",name:"Linear Regression"},{id:"ridge",name:"Ridge Regression"},{id:"lasso",name:"Lasso Regression"},{id:"random-forest-reg",name:"Random Forest"},{id:"gradient-boosting-reg",name:"Gradient Boosting"}],clustering:[{id:"kmeans",name:"K-Means"},{id:"dbscan",name:"DBSCAN"},{id:"hierarchical",name:"Hierarchical Clustering"}]},He={classification:["accuracy","precision","recall","f1-score","auc-roc"],regression:["mse","rmse","mae","r2"],clustering:["silhouette","calinski-harabasz","davies-bouldin"]},Ar=[{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"}],Rr=({project:i,onProjectChange:a,onExperimentRun:r,onModelDeploy:t,className:n="",tutorial:s})=>{var T;const[l,o]=c.useState(i||Tr),[f,h]=c.useState("data"),[y,w]=c.useState(null),[C,S]=c.useState(null),[P,k]=c.useState(null),[$,g]=c.useState(!1),[d,j]=c.useState({algorithm:"",hyperparameters:{},preprocessing:[]}),N=c.useCallback(u=>{const b={...l,...u,updatedAt:new Date};o(b),a==null||a(b)},[l,a]),m=async u=>{for(const b of Array.from(u)){const I={id:crypto.randomUUID(),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(`
|
|
37
|
-
`),Y=J[0].split(",").map(V=>V.trim());I.rowCount=J.length-1,I.columns=Y.map(V=>({name:V,type:"text",nullable:!0,unique:0,missing:0})),I.splits=I.splits.map(V=>({...V,rowCount:Math.floor(I.rowCount*V.ratio)}))}N({datasets:[...l.datasets,I]})}},v=u=>{N({datasets:l.datasets.filter(b=>b.id!==u)}),y===u&&w(null)},x=async()=>{if(!d.algorithm||!y)return;const u={id:crypto.randomUUID(),name:`Experiment ${l.experiments.length+1}`,status:"pending",config:d,metrics:[],artifacts:[],logs:[]};if(N({experiments:[...l.experiments,u]}),g(!1),r){N({experiments:l.experiments.map(b=>b.id===u.id?{...b,status:"running",startedAt:new Date}:b)});try{await r(u);const b=(He[l.type]||He.classification).map(I=>({name:I,value:Math.random()*.3+.7,split:"validation"}));N({experiments:l.experiments.map(I=>I.id===u.id?{...I,status:"completed",completedAt:new Date,metrics:b}:I)})}catch{N({experiments:l.experiments.map(b=>b.id===u.id?{...b,status:"failed"}:b)})}}},p=u=>{const b=l.experiments.find(D=>D.id===u);if(!b)return;const I={id:crypto.randomUUID(),name:`Model from ${b.name}`,version:"1.0.0",algorithm:b.config.algorithm,experimentId:u,status:"registered",metrics:b.metrics,size:Math.floor(Math.random()*100)*1024*1024,artifacts:[],deployments:[],createdAt:new Date};N({models:[...l.models,I]})},_=async u=>{const b=l.models.find(D=>D.id===u);if(!b||!t)return;const I=await t(b);N({models:l.models.map(D=>D.id===u?{...D,status:"production",deployments:[...D.deployments,I]}:D)})},M=u=>u<1024?`${u} B`:u<1024*1024?`${(u/1024).toFixed(1)} KB`:u<1024*1024*1024?`${(u/1024/1024).toFixed(1)} MB`:`${(u/1024/1024/1024).toFixed(1)} GB`,R=u=>{switch(u){case"completed":case"production":case"running":return"status-badge--success";case"pending":case"staging":return"status-badge--warning";case"failed":return"status-badge--error";default:return""}};return e.jsxs("div",{className:`nice-ml-studio ${n}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Nr,{steps:jr(s,Ar)})}),e.jsxs("header",{className:"ml-studio__header",children:[e.jsxs("div",{className:"header__info",children:[e.jsx("input",{type:"text",value:l.name,onChange:u=>N({name:u.target.value}),className:"project-name-input"}),e.jsxs("select",{value:l.type,onChange:u=>N({type:u.target.value}),className:"project-type-select",children:[e.jsx("option",{value:"classification",children:"Classification"}),e.jsx("option",{value:"regression",children:"Regression"}),e.jsx("option",{value:"clustering",children:"Clustering"}),e.jsx("option",{value:"object-detection",children:"Object Detection"}),e.jsx("option",{value:"nlp",children:"NLP"}),e.jsx("option",{value:"time-series",children:"Time Series"})]})]}),e.jsx("div",{className:"header__tabs",children:["data","experiments","models","deploy"].map(u=>e.jsx("button",{className:`tab-button ${f===u?"tab-button--active":""}`,onClick:()=>h(u),children:u.charAt(0).toUpperCase()+u.slice(1)},u))})]}),e.jsxs("div",{className:"ml-studio__content",children:[f==="data"&&e.jsxs("div",{className:"data-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Datasets"}),e.jsxs("label",{className:"upload-button",children:[e.jsx("input",{type:"file",multiple:!0,accept:".csv,.json,.parquet",onChange:u=>u.target.files&&m(u.target.files),hidden:!0}),"+ Upload Dataset"]})]}),e.jsx("div",{className:"datasets-grid",children:l.datasets.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"📊"}),e.jsx("p",{children:"No datasets uploaded yet"}),e.jsx("p",{className:"hint",children:"Upload CSV, JSON, or Parquet files to get started"})]}):l.datasets.map(u=>e.jsxs("div",{className:`dataset-card ${y===u.id?"dataset-card--selected":""}`,onClick:()=>w(u.id),children:[e.jsxs("div",{className:"card-header",children:[e.jsx("span",{className:"dataset-icon",children:"📁"}),e.jsx("h3",{children:u.name}),e.jsx("button",{className:"remove-button",onClick:b=>{b.stopPropagation(),v(u.id)},children:"×"})]}),e.jsxs("div",{className:"card-stats",children:[e.jsxs("span",{children:[u.rowCount.toLocaleString()," rows"]}),e.jsxs("span",{children:[u.columns.length," columns"]}),e.jsx("span",{children:M(u.size)})]}),e.jsx("div",{className:"splits-bar",children:u.splits.map(b=>e.jsx("div",{className:`split split--${b.name}`,style:{width:`${b.ratio*100}%`},title:`${b.name}: ${(b.ratio*100).toFixed(0)}%`},b.name))})]},u.id))}),y&&e.jsx("div",{className:"dataset-details",children:(()=>{const u=l.datasets.find(b=>b.id===y);return u?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Columns"}),e.jsxs("table",{className:"columns-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Missing"}),e.jsx("th",{children:"Unique"})]})}),e.jsx("tbody",{children:u.columns.map(b=>e.jsxs("tr",{children:[e.jsx("td",{children:b.name}),e.jsx("td",{children:e.jsxs("select",{value:b.type,onChange:I=>{N({datasets:l.datasets.map(D=>D.id===u.id?{...D,columns:D.columns.map(J=>J.name===b.name?{...J,type:I.target.value}:J)}:D)})},children:[e.jsx("option",{value:"numeric",children:"Numeric"}),e.jsx("option",{value:"categorical",children:"Categorical"}),e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"datetime",children:"DateTime"}),e.jsx("option",{value:"boolean",children:"Boolean"})]})}),e.jsx("td",{children:b.missing}),e.jsx("td",{children:b.unique})]},b.name))})]})]}):null})()})]}),f==="experiments"&&e.jsxs("div",{className:"experiments-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Experiments"}),e.jsx("button",{className:"primary-button",onClick:()=>g(!0),disabled:l.datasets.length===0,children:"+ New Experiment"})]}),$&&e.jsxs("div",{className:"new-experiment-form",children:[e.jsx("h3",{children:"Configure Experiment"}),e.jsxs("div",{className:"form-grid",children:[e.jsxs("label",{children:["Dataset",e.jsxs("select",{value:y||"",onChange:u=>w(u.target.value),children:[e.jsx("option",{value:"",children:"Select dataset..."}),l.datasets.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]})]}),e.jsxs("label",{children:["Algorithm",e.jsxs("select",{value:d.algorithm,onChange:u=>j({...d,algorithm:u.target.value}),children:[e.jsx("option",{value:"",children:"Select algorithm..."}),(De[l.type]||De.classification).map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]})]}),y&&e.jsxs("label",{children:["Target Column",e.jsxs("select",{value:d.targetColumn||"",onChange:u=>j({...d,targetColumn:u.target.value}),children:[e.jsx("option",{value:"",children:"Select target..."}),(T=l.datasets.find(u=>u.id===y))==null?void 0:T.columns.map(u=>e.jsx("option",{value:u.name,children:u.name},u.name))]})]})]}),e.jsxs("div",{className:"form-actions",children:[e.jsx("button",{className:"secondary-button",onClick:()=>g(!1),children:"Cancel"}),e.jsx("button",{className:"primary-button",onClick:x,disabled:!d.algorithm||!y,children:"Run Experiment"})]})]}),e.jsx("div",{className:"experiments-list",children:l.experiments.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"🧪"}),e.jsx("p",{children:"No experiments yet"}),e.jsx("p",{className:"hint",children:"Create an experiment to train and evaluate models"})]}):l.experiments.map(u=>e.jsxs("div",{className:`experiment-card ${C===u.id?"experiment-card--selected":""}`,onClick:()=>S(u.id),children:[e.jsxs("div",{className:"card-header",children:[e.jsx("h3",{children:u.name}),e.jsx("span",{className:`status-badge ${R(u.status)}`,children:u.status})]}),e.jsxs("div",{className:"card-meta",children:[e.jsxs("span",{children:["Algorithm: ",u.config.algorithm]}),u.duration&&e.jsxs("span",{children:["Duration: ",Math.round(u.duration),"s"]})]}),u.metrics.length>0&&e.jsx("div",{className:"metrics-row",children:u.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"metric-item",children:[e.jsx("span",{className:"metric-name",children:b.name}),e.jsxs("span",{className:"metric-value",children:[(b.value*100).toFixed(1),"%"]})]},b.name))}),u.status==="completed"&&e.jsx("button",{className:"action-button",onClick:b=>{b.stopPropagation(),p(u.id)},children:"Register Model"})]},u.id))})]}),f==="models"&&e.jsxs("div",{className:"models-panel",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h2",{children:"Models"})}),e.jsx("div",{className:"models-list",children:l.models.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"🤖"}),e.jsx("p",{children:"No models registered yet"}),e.jsx("p",{className:"hint",children:"Complete experiments and register models"})]}):l.models.map(u=>e.jsxs("div",{className:`model-card ${P===u.id?"model-card--selected":""}`,onClick:()=>k(u.id),children:[e.jsxs("div",{className:"card-header",children:[e.jsx("h3",{children:u.name}),e.jsx("span",{className:`status-badge ${R(u.status)}`,children:u.status})]}),e.jsxs("div",{className:"card-meta",children:[e.jsxs("span",{children:["Algorithm: ",u.algorithm]}),e.jsxs("span",{children:["Version: ",u.version]}),e.jsxs("span",{children:["Size: ",M(u.size)]})]}),u.metrics.length>0&&e.jsx("div",{className:"metrics-row",children:u.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"metric-item",children:[e.jsx("span",{className:"metric-name",children:b.name}),e.jsxs("span",{className:"metric-value",children:[(b.value*100).toFixed(1),"%"]})]},b.name))}),e.jsxs("div",{className:"card-actions",children:[e.jsx("button",{className:"action-button",children:"Download"}),e.jsx("button",{className:"action-button action-button--primary",onClick:b=>{b.stopPropagation(),_(u.id)},disabled:u.status==="production",children:u.status==="production"?"Deployed":"Deploy"})]})]},u.id))})]}),f==="deploy"&&e.jsxs("div",{className:"deploy-panel",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h2",{children:"Deployments"})}),e.jsx("div",{className:"deployments-list",children:l.models.filter(u=>u.deployments.length>0).length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"🚀"}),e.jsx("p",{children:"No deployments yet"}),e.jsx("p",{className:"hint",children:"Deploy a model to create inference endpoints"})]}):l.models.filter(u=>u.deployments.length>0).flatMap(u=>u.deployments.map(b=>({model:u,deployment:b}))).map(({model:u,deployment:b})=>e.jsxs("div",{className:"deployment-card",children:[e.jsxs("div",{className:"card-header",children:[e.jsx("h3",{children:b.name}),e.jsx("span",{className:`status-badge ${R(b.status)}`,children:b.status})]}),e.jsxs("div",{className:"card-meta",children:[e.jsxs("span",{children:["Model: ",u.name]}),e.jsxs("span",{children:["Endpoint: ",b.endpoint]})]}),e.jsxs("div",{className:"resources-info",children:[e.jsxs("span",{children:["CPU: ",b.resources.cpu," cores"]}),e.jsxs("span",{children:["Memory: ",b.resources.memory," GB"]}),e.jsxs("span",{children:["Replicas: ",b.resources.replicas]})]})]},b.id))})]})]})]})},Mr={id:crypto.randomUUID(),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},Be=["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-accent-pink, #d946ef)","var(--nice-accent-pink, #ec4899)","var(--nice-danger, #f43f5e)"],Pr=({project:i,onProjectChange:a,onLabelSave:r,onExport:t,className:n=""})=>{var ee;const[s,l]=c.useState(i||Mr),[o,f]=c.useState("label"),[h,y]=c.useState(0),[w,C]=c.useState(null),[S,P]=c.useState("select"),[k,$]=c.useState(!1),[g,d]=c.useState(null),[j,N]=c.useState(1),[m,v]=c.useState(!1),[x,p]=c.useState("all"),_=c.useRef(null),M=c.useRef(null),R=s.items[h];c.useEffect(()=>{i&&l(i)},[i]);const T=c.useCallback(A=>{const L={...s,...A};L.statistics={totalItems:L.items.length,labeled:L.items.filter(H=>H.status!=="pending").length,reviewed:L.items.filter(H=>H.status==="review"||H.status==="approved").length,approved:L.items.filter(H=>H.status==="approved").length,byClass:L.labelSchema.classes.map(H=>({classId:H.id,count:L.items.flatMap(O=>O.labels).filter(O=>O.classId===H.id).length}))},l(L),a==null||a(L)},[s,a]),u=()=>{const A={id:crypto.randomUUID(),name:`Class ${s.labelSchema.classes.length+1}`,color:Be[s.labelSchema.classes.length%Be.length],shortcut:String(s.labelSchema.classes.length+1)};T({labelSchema:{...s.labelSchema,classes:[...s.labelSchema.classes,A]}})},b=A=>{T({labelSchema:{...s.labelSchema,classes:s.labelSchema.classes.filter(L=>L.id!==A)},items:s.items.map(L=>({...L,labels:L.labels.filter(H=>H.classId!==A)}))})},I=(A,L)=>{T({labelSchema:{...s.labelSchema,classes:s.labelSchema.classes.map(H=>H.id===A?{...H,...L}:H)}})},D=(A,L)=>{if(!R)return;const H={id:crypto.randomUUID(),classId:A,type:s.type==="classification"?"class":s.type==="bounding-box"?"bbox":"class",data:L||{},createdBy:"current-user",createdAt:new Date},O={...R,labels:[...R.labels,H],status:"labeled"};T({items:s.items.map(B=>B.id===R.id?O:B)}),r==null||r(O)},J=A=>{if(!R)return;const L={...R,labels:R.labels.filter(H=>H.id!==A),status:R.labels.length<=1?"pending":"labeled"};T({items:s.items.map(H=>H.id===R.id?L:H)})},Y=A=>{var B;if(S!=="bbox"||!w)return;const L=(B=_.current)==null?void 0:B.getBoundingClientRect();if(!L)return;const H=(A.clientX-L.left)/j,O=(A.clientY-L.top)/j;$(!0),d({x:H,y:O,width:0,height:0})},V=A=>{var B;if(!k||!g)return;const L=(B=_.current)==null?void 0:B.getBoundingClientRect();if(!L)return;const H=(A.clientX-L.left)/j,O=(A.clientY-L.top)/j;d({...g,width:H-g.x,height:O-g.y})},z=()=>{!k||!g||!w||($(!1),Math.abs(g.width)>10&&Math.abs(g.height)>10&&D(w,{x:g.width<0?g.x+g.width:g.x,y:g.height<0?g.y+g.height:g.y,width:Math.abs(g.width),height:Math.abs(g.height)}),d(null))},F=A=>{const L=x==="all"?s.items:s.items.filter(O=>O.status===x),H=L.findIndex(O=>O.id===(R==null?void 0:R.id));if(A==="prev"&&H>0){const O=L[H-1];y(s.items.findIndex(B=>B.id===O.id))}else if(A==="next"&&H<L.length-1){const O=L[H+1];y(s.items.findIndex(B=>B.id===O.id))}},U=()=>{if(!R)return;const A={...R,status:"approved"};T({items:s.items.map(L=>L.id===R.id?A:L)}),F("next")},W=()=>{if(!R)return;const A={...R,status:"rejected"};T({items:s.items.map(L=>L.id===R.id?A:L)}),F("next")},q=async A=>{t&&await t(A)};c.useEffect(()=>{const A=L=>{const H=L.key,O=s.labelSchema.classes.find(B=>B.shortcut===H);O&&(s.type==="classification"?(D(O.id),F("next")):C(O.id)),L.key==="ArrowLeft"||L.key==="a"?F("prev"):(L.key==="ArrowRight"||L.key==="d")&&F("next"),L.key==="Enter"?U():L.key==="Backspace"&&W()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[R,s.labelSchema.classes,s.type]);const Z=A=>{switch(A){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 ${n}`,children:[e.jsxs("header",{className:"labeler__header",children:[e.jsxs("div",{className:"header__info",children:[e.jsx("input",{type:"text",value:s.name,onChange:A=>T({name:A.target.value}),className:"project-name-input"}),e.jsxs("div",{className:"progress-bar",children:[e.jsx("div",{className:"progress-fill",style:{width:`${s.statistics.labeled/Math.max(s.statistics.totalItems,1)*100}%`}}),e.jsxs("span",{className:"progress-text",children:[s.statistics.labeled," / ",s.statistics.totalItems," labeled"]})]})]}),e.jsx("div",{className:"header__tabs",children:["label","schema","review","export"].map(A=>e.jsx("button",{className:`tab-button ${o===A?"tab-button--active":""}`,onClick:()=>f(A),children:A.charAt(0).toUpperCase()+A.slice(1)},A))}),e.jsx("button",{className:"shortcuts-button",onClick:()=>v(!m),children:"⌨️ Shortcuts"})]}),e.jsxs("div",{className:"labeler__content",children:[o==="label"&&e.jsxs("div",{className:"label-panel",children:[e.jsxs("div",{className:"label-toolbar",children:[e.jsxs("div",{className:"tool-group",children:[e.jsx("button",{className:`tool-button ${S==="select"?"tool-button--active":""}`,onClick:()=>P("select"),children:"↖️ Select"}),(s.type==="bounding-box"||s.type==="multi-label")&&e.jsx("button",{className:`tool-button ${S==="bbox"?"tool-button--active":""}`,onClick:()=>P("bbox"),children:"⬜ Box"}),s.type==="polygon"&&e.jsx("button",{className:`tool-button ${S==="polygon"?"tool-button--active":""}`,onClick:()=>P("polygon"),children:"⬡ Polygon"})]}),e.jsxs("div",{className:"zoom-group",children:[e.jsx("button",{onClick:()=>N(Math.max(.25,j-.25)),children:"-"}),e.jsxs("span",{children:[Math.round(j*100),"%"]}),e.jsx("button",{onClick:()=>N(Math.min(4,j+.25)),children:"+"})]}),e.jsxs("div",{className:"navigation-group",children:[e.jsx("button",{onClick:()=>F("prev"),disabled:h===0,children:"← Prev"}),e.jsxs("span",{children:[h+1," / ",s.items.length]}),e.jsx("button",{onClick:()=>F("next"),disabled:h>=s.items.length-1,children:"Next →"})]})]}),e.jsxs("div",{className:"label-workspace",children:[e.jsx("div",{className:"canvas-container",ref:M,children:R?e.jsxs(e.Fragment,{children:[R.data.type==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:R.data.url,alt:"Labeling item",className:"labeling-image",style:{transform:`scale(${j})`}}),e.jsx("canvas",{ref:_,className:"labeling-canvas",onMouseDown:Y,onMouseMove:V,onMouseUp:z,onMouseLeave:z,style:{transform:`scale(${j})`,cursor:S==="bbox"?"crosshair":"default"}}),e.jsxs("div",{className:"annotations-overlay",style:{transform:`scale(${j})`},children:[R.labels.filter(A=>A.type==="bbox"&&A.data.x!==void 0).map(A=>{const L=s.labelSchema.classes.find(H=>H.id===A.classId);return e.jsxs("div",{className:"bbox-annotation",style:{left:A.data.x,top:A.data.y,width:A.data.width,height:A.data.height,borderColor:(L==null?void 0:L.color)||"var(--nice-danger, #ff0000)"},children:[e.jsx("span",{className:"bbox-label",style:{backgroundColor:(L==null?void 0:L.color)||"var(--nice-danger, #ff0000)"},children:L==null?void 0:L.name}),e.jsx("button",{className:"bbox-remove",onClick:()=>J(A.id),children:"×"})]},A.id)}),g&&e.jsx("div",{className:"bbox-drawing",style:{left:g.width<0?g.x+g.width:g.x,top:g.height<0?g.y+g.height:g.y,width:Math.abs(g.width),height:Math.abs(g.height),borderColor:(ee=s.labelSchema.classes.find(A=>A.id===w))==null?void 0:ee.color}})]})]}),R.data.type==="text"&&e.jsx("div",{className:"text-labeling",children:e.jsx("p",{className:"text-content",children:R.data.text})})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"📋"}),e.jsx("p",{children:"No items to label"})]})}),e.jsxs("aside",{className:"class-sidebar",children:[e.jsx("h3",{children:"Classes"}),e.jsx("div",{className:"class-list",children:s.labelSchema.classes.map(A=>e.jsxs("button",{className:`class-button ${w===A.id?"class-button--active":""}`,style:{borderLeftColor:A.color},onClick:()=>{s.type==="classification"?(D(A.id),F("next")):C(A.id)},children:[e.jsx("span",{className:"class-color",style:{backgroundColor:A.color}}),e.jsx("span",{className:"class-name",children:A.name}),A.shortcut&&e.jsx("span",{className:"class-shortcut",children:A.shortcut})]},A.id))}),R&&R.labels.length>0&&e.jsxs("div",{className:"current-labels",children:[e.jsx("h4",{children:"Labels"}),R.labels.map(A=>{const L=s.labelSchema.classes.find(H=>H.id===A.classId);return e.jsxs("div",{className:"label-item",children:[e.jsx("span",{className:"label-color",style:{backgroundColor:L==null?void 0:L.color}}),e.jsx("span",{className:"label-name",children:L==null?void 0:L.name}),e.jsx("button",{onClick:()=>J(A.id),children:"×"})]},A.id)})]}),o==="label"&&R&&e.jsxs("div",{className:"label-actions",children:[e.jsx("button",{className:"approve-button",onClick:U,children:"✓ Approve"}),e.jsx("button",{className:"reject-button",onClick:W,children:"✗ Reject"})]})]})]})]}),o==="schema"&&e.jsxs("div",{className:"schema-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Label Schema"}),e.jsx("button",{className:"primary-button",onClick:u,children:"+ Add Class"})]}),e.jsxs("div",{className:"schema-settings",children:[e.jsxs("label",{children:["Labeling Type",e.jsxs("select",{value:s.type,onChange:A=>T({type:A.target.value}),children:[e.jsx("option",{value:"classification",children:"Single Classification"}),e.jsx("option",{value:"multi-label",children:"Multi-Label Classification"}),e.jsx("option",{value:"bounding-box",children:"Bounding Box"}),e.jsx("option",{value:"polygon",children:"Polygon"}),e.jsx("option",{value:"segmentation",children:"Segmentation"}),e.jsx("option",{value:"ner",children:"Named Entity Recognition"})]})]}),e.jsxs("label",{children:["Data Type",e.jsxs("select",{value:s.dataType,onChange:A=>T({dataType:A.target.value}),children:[e.jsx("option",{value:"image",children:"Image"}),e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"audio",children:"Audio"}),e.jsx("option",{value:"video",children:"Video"})]})]})]}),e.jsx("div",{className:"classes-list",children:s.labelSchema.classes.map((A,L)=>e.jsxs("div",{className:"class-editor",children:[e.jsx("input",{type:"color",value:A.color,onChange:H=>I(A.id,{color:H.target.value}),className:"color-picker"}),e.jsx("input",{type:"text",value:A.name,onChange:H=>I(A.id,{name:H.target.value}),className:"class-name-input",placeholder:"Class name"}),e.jsx("input",{type:"text",value:A.shortcut||"",onChange:H=>I(A.id,{shortcut:H.target.value}),className:"shortcut-input",placeholder:"Key",maxLength:1}),e.jsx("button",{className:"remove-class-button",onClick:()=>b(A.id),children:"🗑️"})]},A.id))}),e.jsxs("div",{className:"guidelines-section",children:[e.jsx("h3",{children:"Labeling Guidelines"}),e.jsx("textarea",{value:s.guidelines||"",onChange:A=>T({guidelines:A.target.value}),placeholder:"Enter labeling guidelines for annotators...",rows:6})]})]}),o==="review"&&e.jsxs("div",{className:"review-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Review Labels"}),e.jsx("div",{className:"filter-group",children:e.jsxs("select",{value:x,onChange:A=>p(A.target.value),children:[e.jsx("option",{value:"all",children:"All Items"}),e.jsx("option",{value:"labeled",children:"Labeled"}),e.jsx("option",{value:"review",children:"Needs Review"}),e.jsx("option",{value:"approved",children:"Approved"}),e.jsx("option",{value:"rejected",children:"Rejected"})]})})]}),e.jsx("div",{className:"items-grid",children:s.items.filter(A=>x==="all"||A.status===x).map((A,L)=>{var H;return e.jsxs("div",{className:`item-card ${h===s.items.indexOf(A)?"item-card--active":""}`,onClick:()=>{y(s.items.indexOf(A)),f("label")},children:[A.data.type==="image"&&e.jsx("img",{src:A.data.url,alt:`Item ${L+1}`,className:"item-thumbnail"}),A.data.type==="text"&&e.jsxs("p",{className:"item-text-preview",children:[(H=A.data.text)==null?void 0:H.slice(0,100),"..."]}),e.jsxs("div",{className:"item-footer",children:[e.jsx("span",{className:"status-dot",style:{backgroundColor:Z(A.status)}}),e.jsxs("span",{children:[A.labels.length," labels"]})]})]},A.id)})})]}),o==="export"&&e.jsxs("div",{className:"export-panel",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h2",{children:"Export Labels"})}),e.jsxs("div",{className:"export-stats",children:[e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.statistics.totalItems}),e.jsx("span",{className:"stat-label",children:"Total Items"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.statistics.labeled}),e.jsx("span",{className:"stat-label",children:"Labeled"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.statistics.approved}),e.jsx("span",{className:"stat-label",children:"Approved"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.labelSchema.classes.length}),e.jsx("span",{className:"stat-label",children:"Classes"})]})]}),e.jsxs("div",{className:"export-formats",children:[e.jsx("h3",{children:"Export Format"}),e.jsxs("div",{className:"format-grid",children:[e.jsxs("button",{className:"format-button",onClick:()=>q("coco"),children:[e.jsx("span",{className:"format-icon",children:"📦"}),e.jsx("span",{className:"format-name",children:"COCO JSON"}),e.jsx("span",{className:"format-desc",children:"Common format for object detection"})]}),e.jsxs("button",{className:"format-button",onClick:()=>q("voc"),children:[e.jsx("span",{className:"format-icon",children:"📄"}),e.jsx("span",{className:"format-name",children:"Pascal VOC"}),e.jsx("span",{className:"format-desc",children:"XML format for bounding boxes"})]}),e.jsxs("button",{className:"format-button",onClick:()=>q("yolo"),children:[e.jsx("span",{className:"format-icon",children:"⚡"}),e.jsx("span",{className:"format-name",children:"YOLO"}),e.jsx("span",{className:"format-desc",children:"Text format for YOLO models"})]}),e.jsxs("button",{className:"format-button",onClick:()=>q("csv"),children:[e.jsx("span",{className:"format-icon",children:"📊"}),e.jsx("span",{className:"format-name",children:"CSV"}),e.jsx("span",{className:"format-desc",children:"Tabular format for classification"})]})]})]}),e.jsxs("div",{className:"class-distribution",children:[e.jsx("h3",{children:"Class Distribution"}),e.jsx("div",{className:"distribution-bars",children:s.statistics.byClass.map(A=>{const L=s.labelSchema.classes.find(O=>O.id===A.classId),H=A.count/Math.max(s.statistics.labeled,1)*100;return e.jsxs("div",{className:"distribution-row",children:[e.jsx("span",{className:"class-name",style:{color:L==null?void 0:L.color},children:L==null?void 0:L.name}),e.jsx("div",{className:"bar-container",children:e.jsx("div",{className:"bar-fill",style:{width:`${H}%`,backgroundColor:L==null?void 0:L.color}})}),e.jsx("span",{className:"count",children:A.count})]},A.classId)})})]})]})]}),m&&e.jsx("div",{className:"shortcuts-modal",children:e.jsxs("div",{className:"modal-content",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Keyboard Shortcuts"}),e.jsx("button",{onClick:()=>v(!1),children:"×"})]}),e.jsxs("div",{className:"shortcuts-list",children:[e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"← / A"}),e.jsx("span",{className:"description",children:"Previous item"})]}),e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"→ / D"}),e.jsx("span",{className:"description",children:"Next item"})]}),e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"Enter"}),e.jsx("span",{className:"description",children:"Approve item"})]}),e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"Backspace"}),e.jsx("span",{className:"description",children:"Reject item"})]}),s.labelSchema.classes.map(A=>A.shortcut&&e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:A.shortcut}),e.jsxs("span",{className:"description",children:["Label as ",A.name]})]},A.id))]})]})})]})},$r={id:crypto.randomUUID(),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:[]},Ir=({endpoint:i,onInference:a,showMetrics:r=!0,showLogs:t=!0,className:n=""})=>{const[s,l]=c.useState(i||$r),[o,f]=c.useState("test"),[h,y]=c.useState("text"),[w,C]=c.useState(""),[S,P]=c.useState("{}"),[k,$]=c.useState(null),[g,d]=c.useState({temperature:.7,topK:50,topP:.9,maxTokens:256,threshold:.5}),[j,N]=c.useState(null),[m,v]=c.useState(!1),[x,p]=c.useState(null),[_,M]=c.useState([]),[R,T]=c.useState(null),u=c.useRef(null),b=z=>{var U;const F=(U=z.target.files)==null?void 0:U[0];if(F){const W=new FileReader;W.onload=q=>{var Z;$((Z=q.target)==null?void 0:Z.result)},W.readAsDataURL(F)}},I=async()=>{if(!a){p("No inference handler provided");return}v(!0),p(null),N(null);const z=[];switch(h){case"text":z.push({type:"text",data:w});break;case"image":k&&z.push({type:"image",data:k});break;case"json":try{z.push({type:"json",data:JSON.parse(S)})}catch{p("Invalid JSON input"),v(!1);return}break;case"tabular":try{z.push({type:"tabular",data:JSON.parse(S)})}catch{p("Invalid tabular data"),v(!1);return}break}const F={inputs:z,parameters:g};try{const U=Date.now(),W=await a(F),q=Date.now()-U;N(W),l(Z=>({...Z,metrics:{...Z.metrics,requestsTotal:Z.metrics.requestsTotal+1,latencyP50:(Z.metrics.latencyP50+q)/2},logs:[{timestamp:new Date,requestId:W.requestId,duration:q,status:"success",inputSize:JSON.stringify(z).length,outputSize:JSON.stringify(W.predictions).length},...Z.logs.slice(0,99)]}))}catch(U){const W=U instanceof Error?U.message:"Inference failed";p(W),l(q=>({...q,metrics:{...q.metrics,requestsTotal:q.metrics.requestsTotal+1,errorRate:(q.metrics.errorRate*q.metrics.requestsTotal+1)/(q.metrics.requestsTotal+1)},logs:[{timestamp:new Date,requestId:crypto.randomUUID(),duration:0,status:"error",inputSize:JSON.stringify(z).length,outputSize:0,error:W},...q.logs.slice(0,99)]}))}finally{v(!1)}},D=async z=>{if(a){T(0),M([]);for(let F=0;F<z.length;F++){const U={inputs:[z[F]],parameters:g};try{const W=await a(U);M(q=>[...q,W])}catch(W){console.error("Batch item failed:",W)}T((F+1)/z.length*100)}T(null)}},J=z=>z<1e3?`${z.toFixed(0)}ms`:`${(z/1e3).toFixed(2)}s`,Y=z=>z.toLocaleTimeString(),V=(z,F)=>e.jsxs("div",{className:"prediction-item",children:[z.label&&e.jsxs("div",{className:"prediction-label",children:[e.jsx("span",{className:"label-name",children:z.label}),z.confidence!==void 0&&e.jsxs("span",{className:"confidence-badge",style:{backgroundColor:`hsl(${z.confidence*120}, 70%, 40%)`},children:[(z.confidence*100).toFixed(1),"%"]})]}),z.score!==void 0&&e.jsxs("div",{className:"prediction-score",children:[e.jsx("span",{className:"score-label",children:"Score:"}),e.jsx("span",{className:"score-value",children:z.score.toFixed(4)})]}),z.text&&e.jsx("div",{className:"prediction-text",children:e.jsx("pre",{children:z.text})}),z.bbox&&e.jsx("div",{className:"prediction-bbox",children:e.jsxs("span",{children:["Box: (",z.bbox.x,", ",z.bbox.y,") - ",z.bbox.width,"×",z.bbox.height]})}),z.raw!==void 0&&z.raw!==null&&e.jsxs("details",{className:"raw-output",children:[e.jsx("summary",{children:"Raw Output"}),e.jsx("pre",{children:JSON.stringify(z.raw,null,2)})]})]},F);return e.jsxs("div",{className:`nice-model-inference ${n}`,children:[e.jsxs("header",{className:"inference__header",children:[e.jsxs("div",{className:"header__info",children:[e.jsx("h2",{children:s.name}),e.jsx("span",{className:`status-badge status-badge--${s.status}`,children:s.status})]}),e.jsxs("div",{className:"header__tabs",children:[e.jsx("button",{className:`tab-button ${o==="test"?"tab-button--active":""}`,onClick:()=>f("test"),children:"Test"}),e.jsx("button",{className:`tab-button ${o==="batch"?"tab-button--active":""}`,onClick:()=>f("batch"),children:"Batch"}),r&&e.jsx("button",{className:`tab-button ${o==="metrics"?"tab-button--active":""}`,onClick:()=>f("metrics"),children:"Metrics"}),t&&e.jsx("button",{className:`tab-button ${o==="logs"?"tab-button--active":""}`,onClick:()=>f("logs"),children:"Logs"})]})]}),e.jsxs("div",{className:"inference__content",children:[o==="test"&&e.jsxs("div",{className:"test-panel",children:[e.jsxs("div",{className:"input-section",children:[e.jsx("div",{className:"input-type-selector",children:["text","image","json","tabular"].map(z=>e.jsx("button",{className:`type-button ${h===z?"type-button--active":""}`,onClick:()=>y(z),children:z.charAt(0).toUpperCase()+z.slice(1)},z))}),e.jsxs("div",{className:"input-area",children:[h==="text"&&e.jsx("textarea",{value:w,onChange:z=>C(z.target.value),placeholder:"Enter text input...",rows:6,className:"text-input"}),h==="image"&&e.jsx("div",{className:"image-input",children:k?e.jsxs("div",{className:"image-preview",children:[e.jsx("img",{src:k,alt:"Input preview"}),e.jsx("button",{className:"clear-button",onClick:()=>$(null),children:"Clear"})]}):e.jsxs("label",{className:"upload-zone",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:b,hidden:!0}),e.jsx("span",{className:"upload-icon",children:"🖼️"}),e.jsx("span",{children:"Click or drag to upload image"})]})}),(h==="json"||h==="tabular")&&e.jsx("textarea",{value:S,onChange:z=>P(z.target.value),placeholder:h==="json"?`{
|
|
36
|
+
`,document.head.appendChild(i)}c.createContext(null);c.createContext(null);c.createContext(null);const da={space1:"4px",space2:"8px",space3:"12px",space4:"16px",space5:"20px",space6:"24px",space8:"32px"},ua={fontFamily:"'Inter', system-ui, -apple-system, sans-serif",fontSizeXs:"0.75rem",fontSizeSm:"0.8125rem",fontSizeMd:"0.875rem",fontSizeLg:"1rem",fontSizeXl:"1.125rem",fontWeightNormal:400,fontWeightMedium:500,fontWeightSemibold:600,fontWeightBold:700,lineHeight:1.5},pa={fast:"120ms ease",normal:"200ms ease",slow:"300ms ease"},ma=i=>({color:i,radiusSm:"4px",radiusMd:"6px",radiusLg:"8px",radiusXl:"12px",radiusFull:"9999px"}),Cr={sm:"0 1px 2px rgba(0,0,0,0.05)",md:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)",lg:"0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1)",xl:"0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1)"},Sr={sm:"0 1px 2px rgba(0,0,0,0.3)",md:"0 4px 6px -1px rgba(0,0,0,0.4)",lg:"0 10px 15px -3px rgba(0,0,0,0.4)",xl:"0 20px 25px -5px rgba(0,0,0,0.4)"};function E(i,a,r,t,n){return{name:i,darkMode:"light",colors:{...a,surface:a.surface??r.primary,surfaceHover:a.surfaceHover??r.secondary},backgrounds:{...r,elevated:r.elevated??r.primary,inset:r.inset??r.tertiary,canvas:r.canvas??r.primary},text:{...t,inverse:t.inverse??"#ffffff"},borders:ma(n),shadows:Cr,spacing:da,typography:ua,transitions:pa}}function K(i,a,r,t,n){return{name:i,darkMode:"dark",colors:{...a,surface:a.surface??r.secondary,surfaceHover:a.surfaceHover??r.tertiary},backgrounds:{...r,elevated:r.elevated??r.secondary,inset:r.inset??r.primary,canvas:r.canvas??r.primary},text:{...t,inverse:t.inverse??"#0f172a"},borders:ma(n),shadows:Sr,spacing:da,typography:ua,transitions:pa}}E("Slate",{primary:"#64748b",primaryHover:"#475569",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#1e293b",secondary:"#475569",muted:"#94a3b8"},"#cbd5e1");E("Zinc",{primary:"#71717a",primaryHover:"#52525b",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fafafa",secondary:"#f4f4f5",tertiary:"#e4e4e7",hover:"#e4e4e7"},{primary:"#18181b",secondary:"#3f3f46",muted:"#a1a1aa"},"#d4d4d8");E("Stone",{primary:"#78716c",primaryHover:"#57534e",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#1c1917",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");E("Cool Gray",{primary:"#6b7280",primaryHover:"#4b5563",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#d1d5db");E("Warm Gray",{primary:"#7c7568",primaryHover:"#5c564c",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf9f7",secondary:"#f5f4f0",tertiary:"#e8e6e1",hover:"#e8e6e1"},{primary:"#1f1d19",secondary:"#4a463d",muted:"#a09888"},"#d4d0c8");E("Silver",{primary:"#94a3b8",primaryHover:"#64748b",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#38bdf8"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#334155",secondary:"#64748b",muted:"#94a3b8"},"#cbd5e1");E("Charcoal",{primary:"#374151",primaryHover:"#1f2937",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f9fafb",secondary:"#f3f4f6",tertiary:"#e5e7eb",hover:"#e5e7eb"},{primary:"#111827",secondary:"#374151",muted:"#6b7280"},"#d1d5db");E("Ivory",{primary:"#92876d",primaryHover:"#7a6f55",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffef7",secondary:"#faf6eb",tertiary:"#f0ead6",hover:"#f0ead6"},{primary:"#2b2517",secondary:"#5c5340",muted:"#9c9280"},"#ddd8c4");E("Rose",{primary:"#e11d48",primaryHover:"#be123c",success:"#16a34a",warning:"#ea580c",error:"#dc2626",info:"#0891b2"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f43f5e"},"#fda4af");E("Emerald",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#34d399"},"#6ee7b7");E("Amber",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0284c7"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#f59e0b"},"#fcd34d");E("Violet",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#2e1065",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");E("Teal",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");E("Indigo",{primary:"#4f46e5",primaryHover:"#4338ca",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#eef2ff",secondary:"#e0e7ff",tertiary:"#c7d2fe",hover:"#e0e7ff"},{primary:"#1e1b4b",secondary:"#312e81",muted:"#818cf8"},"#a5b4fc");E("Cyan",{primary:"#0891b2",primaryHover:"#0e7490",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#0284c7"},{primary:"#ecfeff",secondary:"#cffafe",tertiary:"#a5f3fc",hover:"#cffafe"},{primary:"#164e63",secondary:"#155e75",muted:"#22d3ee"},"#67e8f9");E("Lime",{primary:"#65a30d",primaryHover:"#4d7c0f",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f7fee7",secondary:"#ecfccb",tertiary:"#d9f99d",hover:"#ecfccb"},{primary:"#1a2e05",secondary:"#365314",muted:"#84cc16"},"#bef264");E("Pink",{primary:"#db2777",primaryHover:"#be185d",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#500724",secondary:"#831843",muted:"#f472b6"},"#f9a8d4");E("Orange",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#7c2d12",muted:"#fb923c"},"#fdba74");E("Fuchsia",{primary:"#c026d3",primaryHover:"#a21caf",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf4ff",secondary:"#fae8ff",tertiary:"#f5d0fe",hover:"#fae8ff"},{primary:"#4a044e",secondary:"#701a75",muted:"#d946ef"},"#e879f9");E("Sky",{primary:"#0284c7",primaryHover:"#0369a1",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#075985",muted:"#38bdf8"},"#7dd3fc");E("Ruby",{primary:"#be123c",primaryHover:"#9f1239",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#fb7185"},"#fda4af");E("Coral",{primary:"#f97316",primaryHover:"#ea580c",success:"#10b981",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#fb923c"},"#fdba74");K("Midnight",{primary:"#818cf8",primaryHover:"#6366f1",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#020617",secondary:"#0f172a",tertiary:"#1e293b",hover:"#1e293b"},{primary:"#f1f5f9",secondary:"#94a3b8",muted:"#475569"},"#1e293b");K("Obsidian",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#facc15",error:"#fb7185",info:"#38bdf8"},{primary:"#09090b",secondary:"#18181b",tertiary:"#27272a",hover:"#27272a"},{primary:"#fafafa",secondary:"#a1a1aa",muted:"#52525b"},"#3f3f46");K("Eclipse",{primary:"#c084fc",primaryHover:"#a855f7",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#67e8f9"},{primary:"#0c0a1d",secondary:"#1a1533",tertiary:"#2a2248",hover:"#2a2248"},{primary:"#f5f3ff",secondary:"#a78bfa",muted:"#6d5eac"},"#3b3266");K("Onyx",{primary:"#60a5fa",primaryHover:"#3b82f6",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#000000",secondary:"#0a0a0a",tertiary:"#171717",hover:"#171717"},{primary:"#ffffff",secondary:"#a3a3a3",muted:"#525252"},"#262626");K("Carbon",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#67e8f9"},{primary:"#161616",secondary:"#262626",tertiary:"#393939",hover:"#393939"},{primary:"#f4f4f4",secondary:"#c6c6c6",muted:"#6f6f6f"},"#525252");K("Cosmos",{primary:"#6366f1",primaryHover:"#4f46e5",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#030712",secondary:"#111827",tertiary:"#1f2937",hover:"#1f2937"},{primary:"#e5e7eb",secondary:"#9ca3af",muted:"#4b5563"},"#374151");K("Nebula",{primary:"#e879f9",primaryHover:"#d946ef",success:"#4ade80",warning:"#fbbf24",error:"#fb7185",info:"#67e8f9"},{primary:"#0d0117",secondary:"#1a0533",tertiary:"#2d0a52",hover:"#2d0a52"},{primary:"#fae8ff",secondary:"#d8b4fe",muted:"#7c3aed"},"#581c87");K("Abyss",{primary:"#22d3ee",primaryHover:"#06b6d4",success:"#34d399",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#001219",secondary:"#002a3a",tertiary:"#003e54",hover:"#003e54"},{primary:"#e0f2fe",secondary:"#7dd3fc",muted:"#0369a1"},"#075985");K("Shadow",{primary:"#a3a3a3",primaryHover:"#737373",success:"#4ade80",warning:"#facc15",error:"#f87171",info:"#38bdf8"},{primary:"#171717",secondary:"#1f1f1f",tertiary:"#2a2a2a",hover:"#2a2a2a"},{primary:"#e5e5e5",secondary:"#a3a3a3",muted:"#525252"},"#404040");K("Emerald Dark",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fbbf24",error:"#f87171",info:"#22d3ee"},{primary:"#022c22",secondary:"#064e3b",tertiary:"#065f46",hover:"#065f46"},{primary:"#ecfdf5",secondary:"#6ee7b7",muted:"#047857"},"#047857");E("Forest",{primary:"#166534",primaryHover:"#14532d",success:"#22c55e",warning:"#ca8a04",error:"#dc2626",info:"#0891b2"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");E("Ocean",{primary:"#0369a1",primaryHover:"#075985",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#38bdf8"},"#7dd3fc");E("Desert",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#422006",secondary:"#713f12",muted:"#ca8a04"},"#fde047");E("Sunset",{primary:"#ea580c",primaryHover:"#c2410c",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#431407",secondary:"#9a3412",muted:"#f97316"},"#fdba74");E("Aurora",{primary:"#0d9488",primaryHover:"#0f766e",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdfa",secondary:"#ccfbf1",tertiary:"#99f6e4",hover:"#ccfbf1"},{primary:"#134e4a",secondary:"#115e59",muted:"#2dd4bf"},"#5eead4");E("Lavender",{primary:"#7e22ce",primaryHover:"#6b21a8",success:"#16a34a",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#3b0764",secondary:"#581c87",muted:"#a855f7"},"#d8b4fe");E("Autumn",{primary:"#c2410c",primaryHover:"#9a3412",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#7f1d1d",muted:"#f87171"},"#fca5a5");E("Spring",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#06b6d4"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#14532d",secondary:"#166534",muted:"#4ade80"},"#86efac");E("Arctic",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");E("Tropical",{primary:"#0d9488",primaryHover:"#0f766e",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");E("Pastel Rose",{primary:"#f472b6",primaryHover:"#ec4899",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#f9a8d4");E("Pastel Sky",{primary:"#38bdf8",primaryHover:"#0ea5e9",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#075985",secondary:"#0369a1",muted:"#7dd3fc"},"#bae6fd");E("Pastel Mint",{primary:"#34d399",primaryHover:"#10b981",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#ecfdf5",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#065f46",secondary:"#047857",muted:"#6ee7b7"},"#a7f3d0");E("Pastel Peach",{primary:"#fb923c",primaryHover:"#f97316",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fff7ed",secondary:"#ffedd5",tertiary:"#fed7aa",hover:"#ffedd5"},{primary:"#7c2d12",secondary:"#9a3412",muted:"#fdba74"},"#fed7aa");E("Pastel Lavender",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f5f3ff",secondary:"#ede9fe",tertiary:"#ddd6fe",hover:"#ede9fe"},{primary:"#4c1d95",secondary:"#5b21b6",muted:"#c4b5fd"},"#ddd6fe");E("Pastel Lemon",{primary:"#facc15",primaryHover:"#eab308",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fefce8",secondary:"#fef9c3",tertiary:"#fef08a",hover:"#fef9c3"},{primary:"#713f12",secondary:"#854d0e",muted:"#fde047"},"#fef08a");E("Pastel Sage",{primary:"#86efac",primaryHover:"#4ade80",success:"#22c55e",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#166534",secondary:"#15803d",muted:"#86efac"},"#bbf7d0");E("Pastel Coral",{primary:"#fb7185",primaryHover:"#f43f5e",success:"#4ade80",warning:"#fcd34d",error:"#ef4444",info:"#67e8f9"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#881337",secondary:"#9f1239",muted:"#fda4af"},"#fecdd3");E("Banking",{primary:"#1e3a5f",primaryHover:"#152c4a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#334155",muted:"#94a3b8"},"#cbd5e1");E("Healthcare",{primary:"#0891b2",primaryHover:"#0e7490",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#f0fdfa",secondary:"#e0f7fa",tertiary:"#b2ebf2",hover:"#e0f7fa"},{primary:"#134e4a",secondary:"#1a6b6a",muted:"#80cbc4"},"#b2dfdb");E("Legal",{primary:"#1e293b",primaryHover:"#0f172a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0284c7"},{primary:"#fafaf9",secondary:"#f5f5f4",tertiary:"#e7e5e4",hover:"#e7e5e4"},{primary:"#0f172a",secondary:"#44403c",muted:"#a8a29e"},"#d6d3d1");E("Tech Startup",{primary:"#7c3aed",primaryHover:"#6d28d9",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#faf5ff",secondary:"#f3e8ff",tertiary:"#e9d5ff",hover:"#f3e8ff"},{primary:"#1e1b4b",secondary:"#4c1d95",muted:"#a78bfa"},"#c4b5fd");E("Enterprise",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#60a5fa"},"#93c5fd");E("Government",{primary:"#1d4ed8",primaryHover:"#1e40af",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#f8fafc",secondary:"#f1f5f9",tertiary:"#e2e8f0",hover:"#e2e8f0"},{primary:"#0f172a",secondary:"#1e293b",muted:"#64748b"},"#cbd5e1");E("Education",{primary:"#059669",primaryHover:"#047857",success:"#16a34a",warning:"#f59e0b",error:"#ef4444",info:"#0891b2"},{primary:"#f0fdf9",secondary:"#d1fae5",tertiary:"#a7f3d0",hover:"#d1fae5"},{primary:"#064e3b",secondary:"#065f46",muted:"#6ee7b7"},"#a7f3d0");E("Real Estate",{primary:"#92400e",primaryHover:"#78350f",success:"#059669",warning:"#b45309",error:"#dc2626",info:"#0891b2"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#422006",secondary:"#713f12",muted:"#d97706"},"#fcd34d");E("Nord",{primary:"#5e81ac",primaryHover:"#4c6b90",success:"#a3be8c",warning:"#ebcb8b",error:"#bf616a",info:"#88c0d0"},{primary:"#eceff4",secondary:"#e5e9f0",tertiary:"#d8dee9",hover:"#d8dee9"},{primary:"#2e3440",secondary:"#3b4252",muted:"#4c566a"},"#d8dee9");K("Dracula",{primary:"#bd93f9",primaryHover:"#9d79d9",success:"#50fa7b",warning:"#f1fa8c",error:"#ff5555",info:"#8be9fd"},{primary:"#282a36",secondary:"#343746",tertiary:"#44475a",hover:"#44475a"},{primary:"#f8f8f2",secondary:"#c0c0c0",muted:"#6272a4"},"#44475a");E("Solarized Light",{primary:"#268bd2",primaryHover:"#1a6da0",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#fdf6e3",secondary:"#eee8d5",tertiary:"#e0dbc7",hover:"#eee8d5"},{primary:"#073642",secondary:"#586e75",muted:"#93a1a1"},"#eee8d5");K("Solarized Dark",{primary:"#268bd2",primaryHover:"#3d98db",success:"#859900",warning:"#b58900",error:"#dc322f",info:"#2aa198"},{primary:"#002b36",secondary:"#073642",tertiary:"#0a4858",hover:"#073642"},{primary:"#eee8d5",secondary:"#93a1a1",muted:"#586e75"},"#073642");K("Monokai",{primary:"#66d9ef",primaryHover:"#45c0d6",success:"#a6e22e",warning:"#e6db74",error:"#f92672",info:"#66d9ef"},{primary:"#272822",secondary:"#34352e",tertiary:"#3e3d32",hover:"#3e3d32"},{primary:"#f8f8f2",secondary:"#cfcfc2",muted:"#75715e"},"#3e3d32");K("One Dark",{primary:"#61afef",primaryHover:"#4b9ee0",success:"#98c379",warning:"#e5c07b",error:"#e06c75",info:"#56b6c2"},{primary:"#282c34",secondary:"#2c313a",tertiary:"#353b45",hover:"#353b45"},{primary:"#abb2bf",secondary:"#828997",muted:"#545862"},"#3e4452");K("Synthwave",{primary:"#ff7edb",primaryHover:"#e660c2",success:"#72f1b8",warning:"#fede5d",error:"#fe4450",info:"#36f9f6"},{primary:"#241b2f",secondary:"#2d2140",tertiary:"#362a50",hover:"#362a50"},{primary:"#f0e4fc",secondary:"#b4a0cc",muted:"#6c5c84"},"#4a3866");E("Vaporwave",{primary:"#ff71ce",primaryHover:"#e655b5",success:"#78dcca",warning:"#ffb86c",error:"#ff5555",info:"#76e8fc"},{primary:"#fce4f7",secondary:"#e8d0f4",tertiary:"#d4bcf0",hover:"#e8d0f4"},{primary:"#4a1a4e",secondary:"#7b3f7d",muted:"#c080c0"},"#d8a8e8");K("Terminal Green",{primary:"#00ff41",primaryHover:"#00cc34",success:"#00ff41",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0a0a0a",secondary:"#0d1a0d",tertiary:"#1a2e1a",hover:"#1a2e1a"},{primary:"#00ff41",secondary:"#00cc33",muted:"#008822"},"#003300");E("Sepia",{primary:"#8b6914",primaryHover:"#704f10",success:"#6b8e23",warning:"#cd853f",error:"#b22222",info:"#5f9ea0"},{primary:"#faf0e6",secondary:"#f5e6d3",tertiary:"#eddcc7",hover:"#f5e6d3"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#d7ccc8");E("Vintage",{primary:"#8d6e63",primaryHover:"#6d4c41",success:"#66bb6a",warning:"#ffb300",error:"#e53935",info:"#29b6f6"},{primary:"#efebe9",secondary:"#d7ccc8",tertiary:"#bcaaa4",hover:"#d7ccc8"},{primary:"#3e2723",secondary:"#5d4037",muted:"#a1887f"},"#bcaaa4");K("Cyberpunk",{primary:"#00f0ff",primaryHover:"#00c8d4",success:"#39ff14",warning:"#ffff00",error:"#ff003c",info:"#bf00ff"},{primary:"#0a0e17",secondary:"#131824",tertiary:"#1c2333",hover:"#1c2333"},{primary:"#e0fbfc",secondary:"#80d4dd",muted:"#3a6b72"},"#1c3a44");K("Neon",{primary:"#ff00ff",primaryHover:"#cc00cc",success:"#00ff00",warning:"#ffff00",error:"#ff0000",info:"#00ffff"},{primary:"#0d0d0d",secondary:"#1a1a1a",tertiary:"#262626",hover:"#262626"},{primary:"#ffffff",secondary:"#cccccc",muted:"#666666"},"#333333");K("Retrowave",{primary:"#f77fbe",primaryHover:"#e462a3",success:"#72f1b8",warning:"#ffe261",error:"#ff4444",info:"#79e8fb"},{primary:"#1b0a2e",secondary:"#261440",tertiary:"#321e52",hover:"#321e52"},{primary:"#ffe6f7",secondary:"#c9a0c9",muted:"#6b4c7a"},"#4a2d66");E("Christmas",{primary:"#c41e3a",primaryHover:"#a01830",success:"#228b22",warning:"#ffd700",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");K("Halloween",{primary:"#ff6600",primaryHover:"#e05500",success:"#4ade80",warning:"#fbbf24",error:"#ff0000",info:"#9333ea"},{primary:"#1a0a00",secondary:"#2d1500",tertiary:"#402000",hover:"#402000"},{primary:"#ffedd5",secondary:"#fdba74",muted:"#9a5c28"},"#5c3400");E("Valentine",{primary:"#e11d48",primaryHover:"#be123c",success:"#10b981",warning:"#f59e0b",error:"#dc2626",info:"#ec4899"},{primary:"#fff1f2",secondary:"#ffe4e6",tertiary:"#fecdd3",hover:"#ffe4e6"},{primary:"#4c0519",secondary:"#881337",muted:"#f9a8d4"},"#fda4af");E("Easter",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#4ade80",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#fef9ff",secondary:"#f3e8ff",tertiary:"#e8d5ff",hover:"#f3e8ff"},{primary:"#581c87",secondary:"#6d28d9",muted:"#c4b5fd"},"#ddd6fe");E("Summer Beach",{primary:"#0ea5e9",primaryHover:"#0284c7",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#0c4a6e",secondary:"#0369a1",muted:"#7dd3fc"},"#fcd34d");E("Winter Frost",{primary:"#3b82f6",primaryHover:"#2563eb",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#f0f9ff",secondary:"#e0f2fe",tertiary:"#bae6fd",hover:"#e0f2fe"},{primary:"#1e3a5f",secondary:"#1e40af",muted:"#93c5fd"},"#bfdbfe");E("Cherry Blossom",{primary:"#ec4899",primaryHover:"#db2777",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#06b6d4"},{primary:"#fdf2f8",secondary:"#fce7f3",tertiary:"#fbcfe8",hover:"#fce7f3"},{primary:"#831843",secondary:"#9d174d",muted:"#f9a8d4"},"#fbcfe8");E("Harvest",{primary:"#b45309",primaryHover:"#92400e",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#78350f",muted:"#d97706"},"#fcd34d");E("Japanese Zen",{primary:"#6b7280",primaryHover:"#4b5563",success:"#6b8e23",warning:"#d4a017",error:"#c0392b",info:"#5f9ea0"},{primary:"#faf9f6",secondary:"#f0ece3",tertiary:"#e6e0d4",hover:"#f0ece3"},{primary:"#2c2c2c",secondary:"#5c5c5c",muted:"#a0998a"},"#d5cec0");E("Moroccan",{primary:"#c2410c",primaryHover:"#9a3412",success:"#15803d",warning:"#ca8a04",error:"#b91c1c",info:"#0e7490"},{primary:"#fffbf0",secondary:"#fef3e0",tertiary:"#fde6c4",hover:"#fef3e0"},{primary:"#3a1a00",secondary:"#7c2d12",muted:"#d97706"},"#f5d0a0");E("Scandinavian",{primary:"#4b5563",primaryHover:"#374151",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#ffffff",secondary:"#f9fafb",tertiary:"#f3f4f6",hover:"#f3f4f6"},{primary:"#111827",secondary:"#374151",muted:"#9ca3af"},"#e5e7eb");E("Mediterranean",{primary:"#1e40af",primaryHover:"#1e3a8a",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#eff6ff",secondary:"#dbeafe",tertiary:"#bfdbfe",hover:"#dbeafe"},{primary:"#1e3a5f",secondary:"#2563eb",muted:"#93c5fd"},"#bfdbfe");E("Chinese New Year",{primary:"#dc2626",primaryHover:"#b91c1c",success:"#16a34a",warning:"#d4a017",error:"#ef4444",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fee2e2",tertiary:"#fecaca",hover:"#fee2e2"},{primary:"#450a0a",secondary:"#991b1b",muted:"#f87171"},"#fca5a5");E("Indian Festive",{primary:"#d97706",primaryHover:"#b45309",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",info:"#7c3aed"},{primary:"#fffbeb",secondary:"#fef3c7",tertiary:"#fde68a",hover:"#fef3c7"},{primary:"#451a03",secondary:"#92400e",muted:"#f59e0b"},"#fcd34d");E("Brazilian Carnival",{primary:"#16a34a",primaryHover:"#15803d",success:"#22c55e",warning:"#facc15",error:"#ef4444",info:"#0ea5e9"},{primary:"#f0fdf4",secondary:"#dcfce7",tertiary:"#bbf7d0",hover:"#dcfce7"},{primary:"#052e16",secondary:"#166534",muted:"#4ade80"},"#86efac");E("African Earth",{primary:"#92400e",primaryHover:"#78350f",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf5f0",secondary:"#f0e6d6",tertiary:"#e6d5bb",hover:"#f0e6d6"},{primary:"#2b1a0e",secondary:"#5c3d1e",muted:"#a08060"},"#d4b896");K("High Contrast Dark",{primary:"#ffff00",primaryHover:"#cccc00",success:"#00ff00",warning:"#ff8c00",error:"#ff0000",info:"#00ffff"},{primary:"#000000",secondary:"#1a1a1a",tertiary:"#333333",hover:"#333333"},{primary:"#ffffff",secondary:"#ffffff",muted:"#cccccc"},"#ffffff");E("Monochrome",{primary:"#404040",primaryHover:"#262626",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#fafafa",secondary:"#f0f0f0",tertiary:"#e0e0e0",hover:"#e0e0e0"},{primary:"#1a1a1a",secondary:"#404040",muted:"#808080"},"#c0c0c0");E("Enhanced Contrast",{primary:"#0050b3",primaryHover:"#003d8c",success:"#006400",warning:"#cc7000",error:"#cc0000",info:"#006680"},{primary:"#ffffff",secondary:"#f5f5f5",tertiary:"#ebebeb",hover:"#ebebeb"},{primary:"#000000",secondary:"#1a1a1a",muted:"#595959"},"#8c8c8c");E("Minimalist",{primary:"#18181b",primaryHover:"#27272a",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"},{primary:"#ffffff",secondary:"#fafafa",tertiary:"#f5f5f5",hover:"#f5f5f5"},{primary:"#0a0a0a",secondary:"#404040",muted:"#a3a3a3"},"#e5e5e5");K("Warm Dark",{primary:"#f59e0b",primaryHover:"#d97706",success:"#10b981",warning:"#fbbf24",error:"#f87171",info:"#38bdf8"},{primary:"#1c1917",secondary:"#292524",tertiary:"#44403c",hover:"#44403c"},{primary:"#fafaf9",secondary:"#d6d3d1",muted:"#78716c"},"#57534e");K("Soft Dark",{primary:"#a78bfa",primaryHover:"#8b5cf6",success:"#34d399",warning:"#fcd34d",error:"#fb7185",info:"#67e8f9"},{primary:"#1e1e2e",secondary:"#262637",tertiary:"#313147",hover:"#313147"},{primary:"#e8e8f0",secondary:"#a0a0b8",muted:"#5c5c74"},"#3e3e58");E("Coffee",{primary:"#6f4e37",primaryHover:"#5c3d28",success:"#4d7c0f",warning:"#a16207",error:"#b91c1c",info:"#0e7490"},{primary:"#faf6f1",secondary:"#f0e8dc",tertiary:"#e6d8c6",hover:"#f0e8dc"},{primary:"#2c1a0e",secondary:"#5c3d28",muted:"#a08868"},"#d4c4a8");E("Wine",{primary:"#7f1d1d",primaryHover:"#641717",success:"#059669",warning:"#d97706",error:"#dc2626",info:"#0891b2"},{primary:"#fef2f2",secondary:"#fde8e8",tertiary:"#f8d0d0",hover:"#fde8e8"},{primary:"#3b0a0a",secondary:"#7f1d1d",muted:"#dc6868"},"#e8a0a0");c.createContext(null);const Tr={id:crypto.randomUUID(),name:"New ML Project",type:"classification",status:"draft",datasets:[],experiments:[],models:[],createdAt:new Date,updatedAt:new Date},De={classification:[{id:"logistic-regression",name:"Logistic Regression"},{id:"random-forest",name:"Random Forest"},{id:"gradient-boosting",name:"Gradient Boosting"},{id:"svm",name:"Support Vector Machine"},{id:"neural-network",name:"Neural Network"},{id:"xgboost",name:"XGBoost"}],regression:[{id:"linear-regression",name:"Linear Regression"},{id:"ridge",name:"Ridge Regression"},{id:"lasso",name:"Lasso Regression"},{id:"random-forest-reg",name:"Random Forest"},{id:"gradient-boosting-reg",name:"Gradient Boosting"}],clustering:[{id:"kmeans",name:"K-Means"},{id:"dbscan",name:"DBSCAN"},{id:"hierarchical",name:"Hierarchical Clustering"}]},He={classification:["accuracy","precision","recall","f1-score","auc-roc"],regression:["mse","rmse","mae","r2"],clustering:["silhouette","calinski-harabasz","davies-bouldin"]},Ar=[{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"}],Rr=({project:i,onProjectChange:a,onExperimentRun:r,onModelDeploy:t,className:n="",tutorial:s})=>{var T;const[l,o]=c.useState(i||Tr),[f,h]=c.useState("data"),[y,w]=c.useState(null),[C,S]=c.useState(null),[P,k]=c.useState(null),[$,g]=c.useState(!1),[d,j]=c.useState({algorithm:"",hyperparameters:{},preprocessing:[]}),N=c.useCallback(u=>{const b={...l,...u,updatedAt:new Date};o(b),a==null||a(b)},[l,a]),m=async u=>{for(const b of Array.from(u)){const z={id:crypto.randomUUID(),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(`
|
|
37
|
+
`),Y=J[0].split(",").map(V=>V.trim());z.rowCount=J.length-1,z.columns=Y.map(V=>({name:V,type:"text",nullable:!0,unique:0,missing:0})),z.splits=z.splits.map(V=>({...V,rowCount:Math.floor(z.rowCount*V.ratio)}))}N({datasets:[...l.datasets,z]})}},v=u=>{N({datasets:l.datasets.filter(b=>b.id!==u)}),y===u&&w(null)},x=async()=>{if(!d.algorithm||!y)return;const u={id:crypto.randomUUID(),name:`Experiment ${l.experiments.length+1}`,status:"pending",config:d,metrics:[],artifacts:[],logs:[]};if(N({experiments:[...l.experiments,u]}),g(!1),r){N({experiments:l.experiments.map(b=>b.id===u.id?{...b,status:"running",startedAt:new Date}:b)});try{await r(u);const b=(He[l.type]||He.classification).map(z=>({name:z,value:Math.random()*.3+.7,split:"validation"}));N({experiments:l.experiments.map(z=>z.id===u.id?{...z,status:"completed",completedAt:new Date,metrics:b}:z)})}catch{N({experiments:l.experiments.map(b=>b.id===u.id?{...b,status:"failed"}:b)})}}},p=u=>{const b=l.experiments.find(D=>D.id===u);if(!b)return;const z={id:crypto.randomUUID(),name:`Model from ${b.name}`,version:"1.0.0",algorithm:b.config.algorithm,experimentId:u,status:"registered",metrics:b.metrics,size:Math.floor(Math.random()*100)*1024*1024,artifacts:[],deployments:[],createdAt:new Date};N({models:[...l.models,z]})},_=async u=>{const b=l.models.find(D=>D.id===u);if(!b||!t)return;const z=await t(b);N({models:l.models.map(D=>D.id===u?{...D,status:"production",deployments:[...D.deployments,z]}:D)})},M=u=>u<1024?`${u} B`:u<1024*1024?`${(u/1024).toFixed(1)} KB`:u<1024*1024*1024?`${(u/1024/1024).toFixed(1)} MB`:`${(u/1024/1024/1024).toFixed(1)} GB`,R=u=>{switch(u){case"completed":case"production":case"running":return"status-badge--success";case"pending":case"staging":return"status-badge--warning";case"failed":return"status-badge--error";default:return""}};return e.jsxs("div",{className:`nice-ml-studio ${n}`,style:{position:"relative"},children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:30},children:e.jsx(Nr,{steps:jr(s,Ar)})}),e.jsxs("header",{className:"ml-studio__header",children:[e.jsxs("div",{className:"header__info",children:[e.jsx("input",{type:"text",value:l.name,onChange:u=>N({name:u.target.value}),className:"project-name-input"}),e.jsxs("select",{value:l.type,onChange:u=>N({type:u.target.value}),className:"project-type-select",children:[e.jsx("option",{value:"classification",children:"Classification"}),e.jsx("option",{value:"regression",children:"Regression"}),e.jsx("option",{value:"clustering",children:"Clustering"}),e.jsx("option",{value:"object-detection",children:"Object Detection"}),e.jsx("option",{value:"nlp",children:"NLP"}),e.jsx("option",{value:"time-series",children:"Time Series"})]})]}),e.jsx("div",{className:"header__tabs",children:["data","experiments","models","deploy"].map(u=>e.jsx("button",{className:`tab-button ${f===u?"tab-button--active":""}`,onClick:()=>h(u),children:u.charAt(0).toUpperCase()+u.slice(1)},u))})]}),e.jsxs("div",{className:"ml-studio__content",children:[f==="data"&&e.jsxs("div",{className:"data-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Datasets"}),e.jsxs("label",{className:"upload-button",children:[e.jsx("input",{type:"file",multiple:!0,accept:".csv,.json,.parquet",onChange:u=>u.target.files&&m(u.target.files),hidden:!0}),"+ Upload Dataset"]})]}),e.jsx("div",{className:"datasets-grid",children:l.datasets.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"📊"}),e.jsx("p",{children:"No datasets uploaded yet"}),e.jsx("p",{className:"hint",children:"Upload CSV, JSON, or Parquet files to get started"})]}):l.datasets.map(u=>e.jsxs("div",{className:`dataset-card ${y===u.id?"dataset-card--selected":""}`,onClick:()=>w(u.id),children:[e.jsxs("div",{className:"card-header",children:[e.jsx("span",{className:"dataset-icon",children:"📁"}),e.jsx("h3",{children:u.name}),e.jsx("button",{className:"remove-button",onClick:b=>{b.stopPropagation(),v(u.id)},children:"×"})]}),e.jsxs("div",{className:"card-stats",children:[e.jsxs("span",{children:[u.rowCount.toLocaleString()," rows"]}),e.jsxs("span",{children:[u.columns.length," columns"]}),e.jsx("span",{children:M(u.size)})]}),e.jsx("div",{className:"splits-bar",children:u.splits.map(b=>e.jsx("div",{className:`split split--${b.name}`,style:{width:`${b.ratio*100}%`},title:`${b.name}: ${(b.ratio*100).toFixed(0)}%`},b.name))})]},u.id))}),y&&e.jsx("div",{className:"dataset-details",children:(()=>{const u=l.datasets.find(b=>b.id===y);return u?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Columns"}),e.jsxs("table",{className:"columns-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Missing"}),e.jsx("th",{children:"Unique"})]})}),e.jsx("tbody",{children:u.columns.map(b=>e.jsxs("tr",{children:[e.jsx("td",{children:b.name}),e.jsx("td",{children:e.jsxs("select",{value:b.type,onChange:z=>{N({datasets:l.datasets.map(D=>D.id===u.id?{...D,columns:D.columns.map(J=>J.name===b.name?{...J,type:z.target.value}:J)}:D)})},children:[e.jsx("option",{value:"numeric",children:"Numeric"}),e.jsx("option",{value:"categorical",children:"Categorical"}),e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"datetime",children:"DateTime"}),e.jsx("option",{value:"boolean",children:"Boolean"})]})}),e.jsx("td",{children:b.missing}),e.jsx("td",{children:b.unique})]},b.name))})]})]}):null})()})]}),f==="experiments"&&e.jsxs("div",{className:"experiments-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Experiments"}),e.jsx("button",{className:"primary-button",onClick:()=>g(!0),disabled:l.datasets.length===0,children:"+ New Experiment"})]}),$&&e.jsxs("div",{className:"new-experiment-form",children:[e.jsx("h3",{children:"Configure Experiment"}),e.jsxs("div",{className:"form-grid",children:[e.jsxs("label",{children:["Dataset",e.jsxs("select",{value:y||"",onChange:u=>w(u.target.value),children:[e.jsx("option",{value:"",children:"Select dataset..."}),l.datasets.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]})]}),e.jsxs("label",{children:["Algorithm",e.jsxs("select",{value:d.algorithm,onChange:u=>j({...d,algorithm:u.target.value}),children:[e.jsx("option",{value:"",children:"Select algorithm..."}),(De[l.type]||De.classification).map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]})]}),y&&e.jsxs("label",{children:["Target Column",e.jsxs("select",{value:d.targetColumn||"",onChange:u=>j({...d,targetColumn:u.target.value}),children:[e.jsx("option",{value:"",children:"Select target..."}),(T=l.datasets.find(u=>u.id===y))==null?void 0:T.columns.map(u=>e.jsx("option",{value:u.name,children:u.name},u.name))]})]})]}),e.jsxs("div",{className:"form-actions",children:[e.jsx("button",{className:"secondary-button",onClick:()=>g(!1),children:"Cancel"}),e.jsx("button",{className:"primary-button",onClick:x,disabled:!d.algorithm||!y,children:"Run Experiment"})]})]}),e.jsx("div",{className:"experiments-list",children:l.experiments.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"🧪"}),e.jsx("p",{children:"No experiments yet"}),e.jsx("p",{className:"hint",children:"Create an experiment to train and evaluate models"})]}):l.experiments.map(u=>e.jsxs("div",{className:`experiment-card ${C===u.id?"experiment-card--selected":""}`,onClick:()=>S(u.id),children:[e.jsxs("div",{className:"card-header",children:[e.jsx("h3",{children:u.name}),e.jsx("span",{className:`status-badge ${R(u.status)}`,children:u.status})]}),e.jsxs("div",{className:"card-meta",children:[e.jsxs("span",{children:["Algorithm: ",u.config.algorithm]}),u.duration&&e.jsxs("span",{children:["Duration: ",Math.round(u.duration),"s"]})]}),u.metrics.length>0&&e.jsx("div",{className:"metrics-row",children:u.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"metric-item",children:[e.jsx("span",{className:"metric-name",children:b.name}),e.jsxs("span",{className:"metric-value",children:[(b.value*100).toFixed(1),"%"]})]},b.name))}),u.status==="completed"&&e.jsx("button",{className:"action-button",onClick:b=>{b.stopPropagation(),p(u.id)},children:"Register Model"})]},u.id))})]}),f==="models"&&e.jsxs("div",{className:"models-panel",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h2",{children:"Models"})}),e.jsx("div",{className:"models-list",children:l.models.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"🤖"}),e.jsx("p",{children:"No models registered yet"}),e.jsx("p",{className:"hint",children:"Complete experiments and register models"})]}):l.models.map(u=>e.jsxs("div",{className:`model-card ${P===u.id?"model-card--selected":""}`,onClick:()=>k(u.id),children:[e.jsxs("div",{className:"card-header",children:[e.jsx("h3",{children:u.name}),e.jsx("span",{className:`status-badge ${R(u.status)}`,children:u.status})]}),e.jsxs("div",{className:"card-meta",children:[e.jsxs("span",{children:["Algorithm: ",u.algorithm]}),e.jsxs("span",{children:["Version: ",u.version]}),e.jsxs("span",{children:["Size: ",M(u.size)]})]}),u.metrics.length>0&&e.jsx("div",{className:"metrics-row",children:u.metrics.slice(0,3).map(b=>e.jsxs("div",{className:"metric-item",children:[e.jsx("span",{className:"metric-name",children:b.name}),e.jsxs("span",{className:"metric-value",children:[(b.value*100).toFixed(1),"%"]})]},b.name))}),e.jsxs("div",{className:"card-actions",children:[e.jsx("button",{className:"action-button",children:"Download"}),e.jsx("button",{className:"action-button action-button--primary",onClick:b=>{b.stopPropagation(),_(u.id)},disabled:u.status==="production",children:u.status==="production"?"Deployed":"Deploy"})]})]},u.id))})]}),f==="deploy"&&e.jsxs("div",{className:"deploy-panel",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h2",{children:"Deployments"})}),e.jsx("div",{className:"deployments-list",children:l.models.filter(u=>u.deployments.length>0).length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"🚀"}),e.jsx("p",{children:"No deployments yet"}),e.jsx("p",{className:"hint",children:"Deploy a model to create inference endpoints"})]}):l.models.filter(u=>u.deployments.length>0).flatMap(u=>u.deployments.map(b=>({model:u,deployment:b}))).map(({model:u,deployment:b})=>e.jsxs("div",{className:"deployment-card",children:[e.jsxs("div",{className:"card-header",children:[e.jsx("h3",{children:b.name}),e.jsx("span",{className:`status-badge ${R(b.status)}`,children:b.status})]}),e.jsxs("div",{className:"card-meta",children:[e.jsxs("span",{children:["Model: ",u.name]}),e.jsxs("span",{children:["Endpoint: ",b.endpoint]})]}),e.jsxs("div",{className:"resources-info",children:[e.jsxs("span",{children:["CPU: ",b.resources.cpu," cores"]}),e.jsxs("span",{children:["Memory: ",b.resources.memory," GB"]}),e.jsxs("span",{children:["Replicas: ",b.resources.replicas]})]})]},b.id))})]})]})]})},Mr={id:crypto.randomUUID(),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},Be=["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-accent-pink, #d946ef)","var(--nice-accent-pink, #ec4899)","var(--nice-danger, #f43f5e)"],Pr=({project:i,onProjectChange:a,onLabelSave:r,onExport:t,className:n=""})=>{var ee;const[s,l]=c.useState(i||Mr),[o,f]=c.useState("label"),[h,y]=c.useState(0),[w,C]=c.useState(null),[S,P]=c.useState("select"),[k,$]=c.useState(!1),[g,d]=c.useState(null),[j,N]=c.useState(1),[m,v]=c.useState(!1),[x,p]=c.useState("all"),_=c.useRef(null),M=c.useRef(null),R=s.items[h];c.useEffect(()=>{i&&l(i)},[i]);const T=c.useCallback(A=>{const L={...s,...A};L.statistics={totalItems:L.items.length,labeled:L.items.filter(H=>H.status!=="pending").length,reviewed:L.items.filter(H=>H.status==="review"||H.status==="approved").length,approved:L.items.filter(H=>H.status==="approved").length,byClass:L.labelSchema.classes.map(H=>({classId:H.id,count:L.items.flatMap(O=>O.labels).filter(O=>O.classId===H.id).length}))},l(L),a==null||a(L)},[s,a]),u=()=>{const A={id:crypto.randomUUID(),name:`Class ${s.labelSchema.classes.length+1}`,color:Be[s.labelSchema.classes.length%Be.length],shortcut:String(s.labelSchema.classes.length+1)};T({labelSchema:{...s.labelSchema,classes:[...s.labelSchema.classes,A]}})},b=A=>{T({labelSchema:{...s.labelSchema,classes:s.labelSchema.classes.filter(L=>L.id!==A)},items:s.items.map(L=>({...L,labels:L.labels.filter(H=>H.classId!==A)}))})},z=(A,L)=>{T({labelSchema:{...s.labelSchema,classes:s.labelSchema.classes.map(H=>H.id===A?{...H,...L}:H)}})},D=(A,L)=>{if(!R)return;const H={id:crypto.randomUUID(),classId:A,type:s.type==="classification"?"class":s.type==="bounding-box"?"bbox":"class",data:L||{},createdBy:"current-user",createdAt:new Date},O={...R,labels:[...R.labels,H],status:"labeled"};T({items:s.items.map(B=>B.id===R.id?O:B)}),r==null||r(O)},J=A=>{if(!R)return;const L={...R,labels:R.labels.filter(H=>H.id!==A),status:R.labels.length<=1?"pending":"labeled"};T({items:s.items.map(H=>H.id===R.id?L:H)})},Y=A=>{var B;if(S!=="bbox"||!w)return;const L=(B=_.current)==null?void 0:B.getBoundingClientRect();if(!L)return;const H=(A.clientX-L.left)/j,O=(A.clientY-L.top)/j;$(!0),d({x:H,y:O,width:0,height:0})},V=A=>{var B;if(!k||!g)return;const L=(B=_.current)==null?void 0:B.getBoundingClientRect();if(!L)return;const H=(A.clientX-L.left)/j,O=(A.clientY-L.top)/j;d({...g,width:H-g.x,height:O-g.y})},I=()=>{!k||!g||!w||($(!1),Math.abs(g.width)>10&&Math.abs(g.height)>10&&D(w,{x:g.width<0?g.x+g.width:g.x,y:g.height<0?g.y+g.height:g.y,width:Math.abs(g.width),height:Math.abs(g.height)}),d(null))},F=A=>{const L=x==="all"?s.items:s.items.filter(O=>O.status===x),H=L.findIndex(O=>O.id===(R==null?void 0:R.id));if(A==="prev"&&H>0){const O=L[H-1];y(s.items.findIndex(B=>B.id===O.id))}else if(A==="next"&&H<L.length-1){const O=L[H+1];y(s.items.findIndex(B=>B.id===O.id))}},U=()=>{if(!R)return;const A={...R,status:"approved"};T({items:s.items.map(L=>L.id===R.id?A:L)}),F("next")},W=()=>{if(!R)return;const A={...R,status:"rejected"};T({items:s.items.map(L=>L.id===R.id?A:L)}),F("next")},q=async A=>{t&&await t(A)};c.useEffect(()=>{const A=L=>{const H=L.key,O=s.labelSchema.classes.find(B=>B.shortcut===H);O&&(s.type==="classification"?(D(O.id),F("next")):C(O.id)),L.key==="ArrowLeft"||L.key==="a"?F("prev"):(L.key==="ArrowRight"||L.key==="d")&&F("next"),L.key==="Enter"?U():L.key==="Backspace"&&W()};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[R,s.labelSchema.classes,s.type]);const Z=A=>{switch(A){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 ${n}`,children:[e.jsxs("header",{className:"labeler__header",children:[e.jsxs("div",{className:"header__info",children:[e.jsx("input",{type:"text",value:s.name,onChange:A=>T({name:A.target.value}),className:"project-name-input"}),e.jsxs("div",{className:"progress-bar",children:[e.jsx("div",{className:"progress-fill",style:{width:`${s.statistics.labeled/Math.max(s.statistics.totalItems,1)*100}%`}}),e.jsxs("span",{className:"progress-text",children:[s.statistics.labeled," / ",s.statistics.totalItems," labeled"]})]})]}),e.jsx("div",{className:"header__tabs",children:["label","schema","review","export"].map(A=>e.jsx("button",{className:`tab-button ${o===A?"tab-button--active":""}`,onClick:()=>f(A),children:A.charAt(0).toUpperCase()+A.slice(1)},A))}),e.jsx("button",{className:"shortcuts-button",onClick:()=>v(!m),children:"⌨️ Shortcuts"})]}),e.jsxs("div",{className:"labeler__content",children:[o==="label"&&e.jsxs("div",{className:"label-panel",children:[e.jsxs("div",{className:"label-toolbar",children:[e.jsxs("div",{className:"tool-group",children:[e.jsx("button",{className:`tool-button ${S==="select"?"tool-button--active":""}`,onClick:()=>P("select"),children:"↖️ Select"}),(s.type==="bounding-box"||s.type==="multi-label")&&e.jsx("button",{className:`tool-button ${S==="bbox"?"tool-button--active":""}`,onClick:()=>P("bbox"),children:"⬜ Box"}),s.type==="polygon"&&e.jsx("button",{className:`tool-button ${S==="polygon"?"tool-button--active":""}`,onClick:()=>P("polygon"),children:"⬡ Polygon"})]}),e.jsxs("div",{className:"zoom-group",children:[e.jsx("button",{onClick:()=>N(Math.max(.25,j-.25)),children:"-"}),e.jsxs("span",{children:[Math.round(j*100),"%"]}),e.jsx("button",{onClick:()=>N(Math.min(4,j+.25)),children:"+"})]}),e.jsxs("div",{className:"navigation-group",children:[e.jsx("button",{onClick:()=>F("prev"),disabled:h===0,children:"← Prev"}),e.jsxs("span",{children:[h+1," / ",s.items.length]}),e.jsx("button",{onClick:()=>F("next"),disabled:h>=s.items.length-1,children:"Next →"})]})]}),e.jsxs("div",{className:"label-workspace",children:[e.jsx("div",{className:"canvas-container",ref:M,children:R?e.jsxs(e.Fragment,{children:[R.data.type==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:R.data.url,alt:"Labeling item",className:"labeling-image",style:{transform:`scale(${j})`}}),e.jsx("canvas",{ref:_,className:"labeling-canvas",onMouseDown:Y,onMouseMove:V,onMouseUp:I,onMouseLeave:I,style:{transform:`scale(${j})`,cursor:S==="bbox"?"crosshair":"default"}}),e.jsxs("div",{className:"annotations-overlay",style:{transform:`scale(${j})`},children:[R.labels.filter(A=>A.type==="bbox"&&A.data.x!==void 0).map(A=>{const L=s.labelSchema.classes.find(H=>H.id===A.classId);return e.jsxs("div",{className:"bbox-annotation",style:{left:A.data.x,top:A.data.y,width:A.data.width,height:A.data.height,borderColor:(L==null?void 0:L.color)||"var(--nice-danger, #ff0000)"},children:[e.jsx("span",{className:"bbox-label",style:{backgroundColor:(L==null?void 0:L.color)||"var(--nice-danger, #ff0000)"},children:L==null?void 0:L.name}),e.jsx("button",{className:"bbox-remove",onClick:()=>J(A.id),children:"×"})]},A.id)}),g&&e.jsx("div",{className:"bbox-drawing",style:{left:g.width<0?g.x+g.width:g.x,top:g.height<0?g.y+g.height:g.y,width:Math.abs(g.width),height:Math.abs(g.height),borderColor:(ee=s.labelSchema.classes.find(A=>A.id===w))==null?void 0:ee.color}})]})]}),R.data.type==="text"&&e.jsx("div",{className:"text-labeling",children:e.jsx("p",{className:"text-content",children:R.data.text})})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx("span",{className:"icon",children:"📋"}),e.jsx("p",{children:"No items to label"})]})}),e.jsxs("aside",{className:"class-sidebar",children:[e.jsx("h3",{children:"Classes"}),e.jsx("div",{className:"class-list",children:s.labelSchema.classes.map(A=>e.jsxs("button",{className:`class-button ${w===A.id?"class-button--active":""}`,style:{borderLeftColor:A.color},onClick:()=>{s.type==="classification"?(D(A.id),F("next")):C(A.id)},children:[e.jsx("span",{className:"class-color",style:{backgroundColor:A.color}}),e.jsx("span",{className:"class-name",children:A.name}),A.shortcut&&e.jsx("span",{className:"class-shortcut",children:A.shortcut})]},A.id))}),R&&R.labels.length>0&&e.jsxs("div",{className:"current-labels",children:[e.jsx("h4",{children:"Labels"}),R.labels.map(A=>{const L=s.labelSchema.classes.find(H=>H.id===A.classId);return e.jsxs("div",{className:"label-item",children:[e.jsx("span",{className:"label-color",style:{backgroundColor:L==null?void 0:L.color}}),e.jsx("span",{className:"label-name",children:L==null?void 0:L.name}),e.jsx("button",{onClick:()=>J(A.id),children:"×"})]},A.id)})]}),o==="label"&&R&&e.jsxs("div",{className:"label-actions",children:[e.jsx("button",{className:"approve-button",onClick:U,children:"✓ Approve"}),e.jsx("button",{className:"reject-button",onClick:W,children:"✗ Reject"})]})]})]})]}),o==="schema"&&e.jsxs("div",{className:"schema-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Label Schema"}),e.jsx("button",{className:"primary-button",onClick:u,children:"+ Add Class"})]}),e.jsxs("div",{className:"schema-settings",children:[e.jsxs("label",{children:["Labeling Type",e.jsxs("select",{value:s.type,onChange:A=>T({type:A.target.value}),children:[e.jsx("option",{value:"classification",children:"Single Classification"}),e.jsx("option",{value:"multi-label",children:"Multi-Label Classification"}),e.jsx("option",{value:"bounding-box",children:"Bounding Box"}),e.jsx("option",{value:"polygon",children:"Polygon"}),e.jsx("option",{value:"segmentation",children:"Segmentation"}),e.jsx("option",{value:"ner",children:"Named Entity Recognition"})]})]}),e.jsxs("label",{children:["Data Type",e.jsxs("select",{value:s.dataType,onChange:A=>T({dataType:A.target.value}),children:[e.jsx("option",{value:"image",children:"Image"}),e.jsx("option",{value:"text",children:"Text"}),e.jsx("option",{value:"audio",children:"Audio"}),e.jsx("option",{value:"video",children:"Video"})]})]})]}),e.jsx("div",{className:"classes-list",children:s.labelSchema.classes.map((A,L)=>e.jsxs("div",{className:"class-editor",children:[e.jsx("input",{type:"color",value:A.color,onChange:H=>z(A.id,{color:H.target.value}),className:"color-picker"}),e.jsx("input",{type:"text",value:A.name,onChange:H=>z(A.id,{name:H.target.value}),className:"class-name-input",placeholder:"Class name"}),e.jsx("input",{type:"text",value:A.shortcut||"",onChange:H=>z(A.id,{shortcut:H.target.value}),className:"shortcut-input",placeholder:"Key",maxLength:1}),e.jsx("button",{className:"remove-class-button",onClick:()=>b(A.id),children:"🗑️"})]},A.id))}),e.jsxs("div",{className:"guidelines-section",children:[e.jsx("h3",{children:"Labeling Guidelines"}),e.jsx("textarea",{value:s.guidelines||"",onChange:A=>T({guidelines:A.target.value}),placeholder:"Enter labeling guidelines for annotators...",rows:6})]})]}),o==="review"&&e.jsxs("div",{className:"review-panel",children:[e.jsxs("div",{className:"panel-header",children:[e.jsx("h2",{children:"Review Labels"}),e.jsx("div",{className:"filter-group",children:e.jsxs("select",{value:x,onChange:A=>p(A.target.value),children:[e.jsx("option",{value:"all",children:"All Items"}),e.jsx("option",{value:"labeled",children:"Labeled"}),e.jsx("option",{value:"review",children:"Needs Review"}),e.jsx("option",{value:"approved",children:"Approved"}),e.jsx("option",{value:"rejected",children:"Rejected"})]})})]}),e.jsx("div",{className:"items-grid",children:s.items.filter(A=>x==="all"||A.status===x).map((A,L)=>{var H;return e.jsxs("div",{className:`item-card ${h===s.items.indexOf(A)?"item-card--active":""}`,onClick:()=>{y(s.items.indexOf(A)),f("label")},children:[A.data.type==="image"&&e.jsx("img",{src:A.data.url,alt:`Item ${L+1}`,className:"item-thumbnail"}),A.data.type==="text"&&e.jsxs("p",{className:"item-text-preview",children:[(H=A.data.text)==null?void 0:H.slice(0,100),"..."]}),e.jsxs("div",{className:"item-footer",children:[e.jsx("span",{className:"status-dot",style:{backgroundColor:Z(A.status)}}),e.jsxs("span",{children:[A.labels.length," labels"]})]})]},A.id)})})]}),o==="export"&&e.jsxs("div",{className:"export-panel",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h2",{children:"Export Labels"})}),e.jsxs("div",{className:"export-stats",children:[e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.statistics.totalItems}),e.jsx("span",{className:"stat-label",children:"Total Items"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.statistics.labeled}),e.jsx("span",{className:"stat-label",children:"Labeled"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.statistics.approved}),e.jsx("span",{className:"stat-label",children:"Approved"})]}),e.jsxs("div",{className:"stat-card",children:[e.jsx("span",{className:"stat-value",children:s.labelSchema.classes.length}),e.jsx("span",{className:"stat-label",children:"Classes"})]})]}),e.jsxs("div",{className:"export-formats",children:[e.jsx("h3",{children:"Export Format"}),e.jsxs("div",{className:"format-grid",children:[e.jsxs("button",{className:"format-button",onClick:()=>q("coco"),children:[e.jsx("span",{className:"format-icon",children:"📦"}),e.jsx("span",{className:"format-name",children:"COCO JSON"}),e.jsx("span",{className:"format-desc",children:"Common format for object detection"})]}),e.jsxs("button",{className:"format-button",onClick:()=>q("voc"),children:[e.jsx("span",{className:"format-icon",children:"📄"}),e.jsx("span",{className:"format-name",children:"Pascal VOC"}),e.jsx("span",{className:"format-desc",children:"XML format for bounding boxes"})]}),e.jsxs("button",{className:"format-button",onClick:()=>q("yolo"),children:[e.jsx("span",{className:"format-icon",children:"⚡"}),e.jsx("span",{className:"format-name",children:"YOLO"}),e.jsx("span",{className:"format-desc",children:"Text format for YOLO models"})]}),e.jsxs("button",{className:"format-button",onClick:()=>q("csv"),children:[e.jsx("span",{className:"format-icon",children:"📊"}),e.jsx("span",{className:"format-name",children:"CSV"}),e.jsx("span",{className:"format-desc",children:"Tabular format for classification"})]})]})]}),e.jsxs("div",{className:"class-distribution",children:[e.jsx("h3",{children:"Class Distribution"}),e.jsx("div",{className:"distribution-bars",children:s.statistics.byClass.map(A=>{const L=s.labelSchema.classes.find(O=>O.id===A.classId),H=A.count/Math.max(s.statistics.labeled,1)*100;return e.jsxs("div",{className:"distribution-row",children:[e.jsx("span",{className:"class-name",style:{color:L==null?void 0:L.color},children:L==null?void 0:L.name}),e.jsx("div",{className:"bar-container",children:e.jsx("div",{className:"bar-fill",style:{width:`${H}%`,backgroundColor:L==null?void 0:L.color}})}),e.jsx("span",{className:"count",children:A.count})]},A.classId)})})]})]})]}),m&&e.jsx("div",{className:"shortcuts-modal",children:e.jsxs("div",{className:"modal-content",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Keyboard Shortcuts"}),e.jsx("button",{onClick:()=>v(!1),children:"×"})]}),e.jsxs("div",{className:"shortcuts-list",children:[e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"← / A"}),e.jsx("span",{className:"description",children:"Previous item"})]}),e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"→ / D"}),e.jsx("span",{className:"description",children:"Next item"})]}),e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"Enter"}),e.jsx("span",{className:"description",children:"Approve item"})]}),e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:"Backspace"}),e.jsx("span",{className:"description",children:"Reject item"})]}),s.labelSchema.classes.map(A=>A.shortcut&&e.jsxs("div",{className:"shortcut-item",children:[e.jsx("span",{className:"keys",children:A.shortcut}),e.jsxs("span",{className:"description",children:["Label as ",A.name]})]},A.id))]})]})})]})},$r={id:crypto.randomUUID(),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:[]},zr=({endpoint:i,onInference:a,showMetrics:r=!0,showLogs:t=!0,className:n=""})=>{const[s,l]=c.useState(i||$r),[o,f]=c.useState("test"),[h,y]=c.useState("text"),[w,C]=c.useState(""),[S,P]=c.useState("{}"),[k,$]=c.useState(null),[g,d]=c.useState({temperature:.7,topK:50,topP:.9,maxTokens:256,threshold:.5}),[j,N]=c.useState(null),[m,v]=c.useState(!1),[x,p]=c.useState(null),[_,M]=c.useState([]),[R,T]=c.useState(null),u=c.useRef(null),b=I=>{var U;const F=(U=I.target.files)==null?void 0:U[0];if(F){const W=new FileReader;W.onload=q=>{var Z;$((Z=q.target)==null?void 0:Z.result)},W.readAsDataURL(F)}},z=async()=>{if(!a){p("No inference handler provided");return}v(!0),p(null),N(null);const I=[];switch(h){case"text":I.push({type:"text",data:w});break;case"image":k&&I.push({type:"image",data:k});break;case"json":try{I.push({type:"json",data:JSON.parse(S)})}catch{p("Invalid JSON input"),v(!1);return}break;case"tabular":try{I.push({type:"tabular",data:JSON.parse(S)})}catch{p("Invalid tabular data"),v(!1);return}break}const F={inputs:I,parameters:g};try{const U=Date.now(),W=await a(F),q=Date.now()-U;N(W),l(Z=>({...Z,metrics:{...Z.metrics,requestsTotal:Z.metrics.requestsTotal+1,latencyP50:(Z.metrics.latencyP50+q)/2},logs:[{timestamp:new Date,requestId:W.requestId,duration:q,status:"success",inputSize:JSON.stringify(I).length,outputSize:JSON.stringify(W.predictions).length},...Z.logs.slice(0,99)]}))}catch(U){const W=U instanceof Error?U.message:"Inference failed";p(W),l(q=>({...q,metrics:{...q.metrics,requestsTotal:q.metrics.requestsTotal+1,errorRate:(q.metrics.errorRate*q.metrics.requestsTotal+1)/(q.metrics.requestsTotal+1)},logs:[{timestamp:new Date,requestId:crypto.randomUUID(),duration:0,status:"error",inputSize:JSON.stringify(I).length,outputSize:0,error:W},...q.logs.slice(0,99)]}))}finally{v(!1)}},D=async I=>{if(a){T(0),M([]);for(let F=0;F<I.length;F++){const U={inputs:[I[F]],parameters:g};try{const W=await a(U);M(q=>[...q,W])}catch(W){console.error("Batch item failed:",W)}T((F+1)/I.length*100)}T(null)}},J=I=>I<1e3?`${I.toFixed(0)}ms`:`${(I/1e3).toFixed(2)}s`,Y=I=>I.toLocaleTimeString(),V=(I,F)=>e.jsxs("div",{className:"prediction-item",children:[I.label&&e.jsxs("div",{className:"prediction-label",children:[e.jsx("span",{className:"label-name",children:I.label}),I.confidence!==void 0&&e.jsxs("span",{className:"confidence-badge",style:{backgroundColor:`hsl(${I.confidence*120}, 70%, 40%)`},children:[(I.confidence*100).toFixed(1),"%"]})]}),I.score!==void 0&&e.jsxs("div",{className:"prediction-score",children:[e.jsx("span",{className:"score-label",children:"Score:"}),e.jsx("span",{className:"score-value",children:I.score.toFixed(4)})]}),I.text&&e.jsx("div",{className:"prediction-text",children:e.jsx("pre",{children:I.text})}),I.bbox&&e.jsx("div",{className:"prediction-bbox",children:e.jsxs("span",{children:["Box: (",I.bbox.x,", ",I.bbox.y,") - ",I.bbox.width,"×",I.bbox.height]})}),I.raw!==void 0&&I.raw!==null&&e.jsxs("details",{className:"raw-output",children:[e.jsx("summary",{children:"Raw Output"}),e.jsx("pre",{children:JSON.stringify(I.raw,null,2)})]})]},F);return e.jsxs("div",{className:`nice-model-inference ${n}`,children:[e.jsxs("header",{className:"inference__header",children:[e.jsxs("div",{className:"header__info",children:[e.jsx("h2",{children:s.name}),e.jsx("span",{className:`status-badge status-badge--${s.status}`,children:s.status})]}),e.jsxs("div",{className:"header__tabs",children:[e.jsx("button",{className:`tab-button ${o==="test"?"tab-button--active":""}`,onClick:()=>f("test"),children:"Test"}),e.jsx("button",{className:`tab-button ${o==="batch"?"tab-button--active":""}`,onClick:()=>f("batch"),children:"Batch"}),r&&e.jsx("button",{className:`tab-button ${o==="metrics"?"tab-button--active":""}`,onClick:()=>f("metrics"),children:"Metrics"}),t&&e.jsx("button",{className:`tab-button ${o==="logs"?"tab-button--active":""}`,onClick:()=>f("logs"),children:"Logs"})]})]}),e.jsxs("div",{className:"inference__content",children:[o==="test"&&e.jsxs("div",{className:"test-panel",children:[e.jsxs("div",{className:"input-section",children:[e.jsx("div",{className:"input-type-selector",children:["text","image","json","tabular"].map(I=>e.jsx("button",{className:`type-button ${h===I?"type-button--active":""}`,onClick:()=>y(I),children:I.charAt(0).toUpperCase()+I.slice(1)},I))}),e.jsxs("div",{className:"input-area",children:[h==="text"&&e.jsx("textarea",{value:w,onChange:I=>C(I.target.value),placeholder:"Enter text input...",rows:6,className:"text-input"}),h==="image"&&e.jsx("div",{className:"image-input",children:k?e.jsxs("div",{className:"image-preview",children:[e.jsx("img",{src:k,alt:"Input preview"}),e.jsx("button",{className:"clear-button",onClick:()=>$(null),children:"Clear"})]}):e.jsxs("label",{className:"upload-zone",children:[e.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:b,hidden:!0}),e.jsx("span",{className:"upload-icon",children:"🖼️"}),e.jsx("span",{children:"Click or drag to upload image"})]})}),(h==="json"||h==="tabular")&&e.jsx("textarea",{value:S,onChange:I=>P(I.target.value),placeholder:h==="json"?`{
|
|
38
38
|
"key": "value"
|
|
39
39
|
}`:`[
|
|
40
40
|
{"col1": "value1", "col2": "value2"}
|
|
41
|
-
]`,rows:10,className:"json-input"})]}),e.jsxs("div",{className:"parameters-section",children:[e.jsx("h4",{children:"Parameters"}),e.jsxs("div",{className:"parameters-grid",children:[e.jsxs("label",{children:["Temperature",e.jsx("input",{type:"number",value:g.temperature,onChange:
|
|
41
|
+
]`,rows:10,className:"json-input"})]}),e.jsxs("div",{className:"parameters-section",children:[e.jsx("h4",{children:"Parameters"}),e.jsxs("div",{className:"parameters-grid",children:[e.jsxs("label",{children:["Temperature",e.jsx("input",{type:"number",value:g.temperature,onChange:I=>d({...g,temperature:parseFloat(I.target.value)}),min:"0",max:"2",step:"0.1"})]}),e.jsxs("label",{children:["Top K",e.jsx("input",{type:"number",value:g.topK,onChange:I=>d({...g,topK:parseInt(I.target.value)}),min:"1",max:"100"})]}),e.jsxs("label",{children:["Top P",e.jsx("input",{type:"number",value:g.topP,onChange:I=>d({...g,topP:parseFloat(I.target.value)}),min:"0",max:"1",step:"0.05"})]}),e.jsxs("label",{children:["Threshold",e.jsx("input",{type:"number",value:g.threshold,onChange:I=>d({...g,threshold:parseFloat(I.target.value)}),min:"0",max:"1",step:"0.05"})]})]})]}),e.jsx("button",{className:"run-button",onClick:z,disabled:m||!w&&!k&&S==="{}",children:m?"Running...":"Run Inference"})]}),e.jsxs("div",{className:"output-section",children:[e.jsx("h3",{children:"Output"}),x&&e.jsxs("div",{className:"error-message",children:[e.jsx("span",{className:"error-icon",children:"⚠️"}),x]}),j&&e.jsxs("div",{className:"result-container",children:[e.jsxs("div",{className:"result-meta",children:[e.jsxs("span",{children:["Request ID: ",j.requestId]}),e.jsxs("span",{children:["Latency: ",J(j.latency)]}),e.jsxs("span",{children:["Model: ",j.modelVersion]})]}),e.jsx("div",{className:"predictions-list",children:j.predictions.map((I,F)=>V(I,F))})]}),!x&&!j&&e.jsxs("div",{className:"empty-output",children:[e.jsx("span",{className:"icon",children:"📤"}),e.jsx("p",{children:"Run inference to see results"})]})]})]}),o==="batch"&&e.jsxs("div",{className:"batch-panel",children:[e.jsxs("div",{className:"batch-upload",children:[e.jsx("h3",{children:"Batch Inference"}),e.jsx("p",{className:"hint",children:"Upload a file with multiple inputs for batch processing"}),e.jsxs("label",{className:"upload-zone",children:[e.jsx("input",{type:"file",accept:".json,.csv,.txt",onChange:async I=>{var U;const F=(U=I.target.files)==null?void 0:U[0];if(F){const W=await F.text();try{const q=JSON.parse(W);if(Array.isArray(q)){const Z=q.map(ee=>({type:"json",data:ee}));D(Z)}}catch{p("Invalid batch file format")}}},hidden:!0}),e.jsx("span",{className:"upload-icon",children:"📁"}),e.jsx("span",{children:"Upload JSON array file"})]})]}),R!==null&&e.jsxs("div",{className:"batch-progress",children:[e.jsx("div",{className:"progress-bar",children:e.jsx("div",{className:"progress-fill",style:{width:`${R}%`}})}),e.jsxs("span",{children:[Math.round(R),"%"]})]}),_.length>0&&e.jsxs("div",{className:"batch-results",children:[e.jsxs("h3",{children:["Results (",_.length,")"]}),e.jsx("div",{className:"results-list",children:_.map((I,F)=>e.jsxs("div",{className:"batch-result-item",children:[e.jsxs("span",{className:"result-index",children:["#",F+1]}),I.predictions.map((U,W)=>e.jsxs("span",{className:"result-prediction",children:[U.label,": ",(U.confidence||U.score||0*100).toFixed(1),"%"]},W))]},F))})]})]}),o==="metrics"&&r&&e.jsxs("div",{className:"metrics-panel",children:[e.jsxs("div",{className:"metrics-grid",children:[e.jsxs("div",{className:"metric-card",children:[e.jsx("span",{className:"metric-value",children:s.metrics.requestsTotal}),e.jsx("span",{className:"metric-label",children:"Total Requests"})]}),e.jsxs("div",{className:"metric-card",children:[e.jsx("span",{className:"metric-value",children:s.metrics.requestsPerSecond.toFixed(1)}),e.jsx("span",{className:"metric-label",children:"Requests/sec"})]}),e.jsxs("div",{className:"metric-card",children:[e.jsx("span",{className:"metric-value",children:J(s.metrics.latencyP50)}),e.jsx("span",{className:"metric-label",children:"P50 Latency"})]}),e.jsxs("div",{className:"metric-card",children:[e.jsx("span",{className:"metric-value",children:J(s.metrics.latencyP95)}),e.jsx("span",{className:"metric-label",children:"P95 Latency"})]}),e.jsxs("div",{className:"metric-card",children:[e.jsx("span",{className:"metric-value",children:J(s.metrics.latencyP99)}),e.jsx("span",{className:"metric-label",children:"P99 Latency"})]}),e.jsxs("div",{className:"metric-card",children:[e.jsxs("span",{className:"metric-value",children:[s.metrics.successRate.toFixed(1),"%"]}),e.jsx("span",{className:"metric-label",children:"Success Rate"})]}),e.jsxs("div",{className:"metric-card",children:[e.jsxs("span",{className:"metric-value",children:[(s.metrics.errorRate*100).toFixed(2),"%"]}),e.jsx("span",{className:"metric-label",children:"Error Rate"})]})]}),e.jsxs("div",{className:"latency-histogram",children:[e.jsx("h3",{children:"Latency Distribution"}),e.jsx("div",{className:"histogram-bars",children:[10,25,50,75,90,95,99].map(I=>e.jsxs("div",{className:"histogram-bar",children:[e.jsx("div",{className:"bar-fill",style:{height:`${Math.min(100,s.metrics.latencyP50*I/100)}px`}}),e.jsxs("span",{className:"percentile-label",children:["P",I]})]},I))})]})]}),o==="logs"&&t&&e.jsxs("div",{className:"logs-panel",children:[e.jsxs("div",{className:"logs-header",children:[e.jsx("h3",{children:"Request Logs"}),e.jsx("button",{className:"clear-logs-button",onClick:()=>l(I=>({...I,logs:[]})),children:"Clear Logs"})]}),e.jsx("div",{className:"logs-table",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Time"}),e.jsx("th",{children:"Request ID"}),e.jsx("th",{children:"Duration"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Input Size"}),e.jsx("th",{children:"Output Size"})]})}),e.jsx("tbody",{children:s.logs.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"empty-logs",children:"No logs yet"})}):s.logs.map((I,F)=>e.jsxs("tr",{className:`log-row log-row--${I.status}`,children:[e.jsx("td",{children:Y(I.timestamp)}),e.jsx("td",{className:"request-id",children:I.requestId.slice(0,8)}),e.jsx("td",{children:J(I.duration)}),e.jsx("td",{children:e.jsx("span",{className:`status-badge status-badge--${I.status}`,children:I.status})}),e.jsxs("td",{children:[I.inputSize," B"]}),e.jsxs("td",{children:[I.outputSize," B"]})]},F))})]})})]})]})]})};class ne{constructor(a){this.abortController=null,this.config={timeout:3e4,maxRetries:3,retryDelay:1e3,...a}}async healthCheck(){try{return(await this.chat({messages:[{role:"user",content:"Hi"}],maxTokens:5})).choices.length>0}catch{return!1}}async fetchWithRetry(a,r,t=this.config.maxRetries){let n=null;for(let s=0;s<=t;s++)try{this.abortController=new AbortController;const l=setTimeout(()=>{var f;return(f=this.abortController)==null?void 0:f.abort()},this.config.timeout),o=await fetch(a,{...r,signal:this.abortController.signal});if(clearTimeout(l),o.ok)return o;if(o.status>=400&&o.status<500){const f=await o.text();throw new Error(`API Error ${o.status}: ${f}`)}n=new Error(`HTTP ${o.status}`)}catch(l){n=l,s<t&&await this.delay(this.config.retryDelay*(s+1))}throw n??new Error("Request failed after retries")}delay(a){return new Promise(r=>setTimeout(r,a))}async parseSSEStream(a,r,t,n){var f;const s=(f=a.body)==null?void 0:f.getReader();if(!s){n==null||n(new Error("No response body"));return}const l=new TextDecoder;let o="";try{for(;;){const{done:h,value:y}=await s.read();if(h)break;o+=l.decode(y,{stream:!0});const w=o.split(`
|
|
42
42
|
`);o=w.pop()||"";for(const C of w)if(C.startsWith("data: ")){const S=C.slice(6).trim();if(S==="[DONE]"){t==null||t();return}try{const P=JSON.parse(S);r(this.normalizeStreamChunk(P))}catch{}}}t==null||t()}catch(h){n==null||n(h)}finally{s.releaseLock()}}}class fa extends ne{constructor(a){super(a),this.type="openai",this.name="OpenAI",this.baseUrl=a.baseUrl||"https://api.openai.com/v1"}async chat(a){const t=await(await this.fetchWithRetry(`${this.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`,...this.config.headers},body:JSON.stringify(this.buildRequestBody(a))})).json();return this.normalizeResponse(t,a)}async chatStream(a,r,t,n){try{const s=await this.fetchWithRetry(`${this.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`,...this.config.headers},body:JSON.stringify({...this.buildRequestBody(a),stream:!0})});await this.parseSSEStream(s,r,t,n)}catch(s){n==null||n(s)}}async listModels(){return((await(await this.fetchWithRetry(`${this.baseUrl}/models`,{method:"GET",headers:{Authorization:`Bearer ${this.config.apiKey}`,...this.config.headers}})).json()).data||[]).filter(t=>t.id.includes("gpt")).map(t=>t.id)}buildRequestBody(a){return{model:a.model||this.config.model||"gpt-4o-mini",messages:a.messages,temperature:a.temperature??.7,max_tokens:a.maxTokens??1024,top_p:a.topP,frequency_penalty:a.frequencyPenalty,presence_penalty:a.presencePenalty,stop:a.stop,functions:a.functions,function_call:a.functionCall}}normalizeResponse(a,r){const t=a;return{id:t.id,model:t.model,choices:t.choices.map(n=>({index:n.index,message:n.message,finishReason:n.finish_reason})),usage:{promptTokens:t.usage.prompt_tokens,completionTokens:t.usage.completion_tokens,totalTokens:t.usage.total_tokens},estimatedCost:this.estimateCost(t.model,t.usage.prompt_tokens,t.usage.completion_tokens)}}normalizeStreamChunk(a){const r=a;return{id:r.id,choices:r.choices.map(t=>({index:t.index,delta:t.delta,finishReason:t.finish_reason}))}}estimateCost(a,r,t){const n={"gpt-4o":{input:2.5,output:10},"gpt-4o-mini":{input:.15,output:.6},"gpt-4-turbo":{input:10,output:30},"gpt-4":{input:30,output:60},"gpt-3.5-turbo":{input:.5,output:1.5}},s=Object.keys(n).find(o=>a.includes(o)),l=s?n[s]:n["gpt-4o-mini"];return r/1e6*l.input+t/1e6*l.output}}class ha extends ne{constructor(a){super(a),this.type="anthropic",this.name="Anthropic Claude",this.baseUrl=a.baseUrl||"https://api.anthropic.com/v1"}async chat(a){const t=await(await this.fetchWithRetry(`${this.baseUrl}/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.config.apiKey,"anthropic-version":"2023-06-01",...this.config.headers},body:JSON.stringify(this.buildRequestBody(a))})).json();return this.normalizeResponse(t)}async chatStream(a,r,t,n){try{const s=await this.fetchWithRetry(`${this.baseUrl}/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.config.apiKey,"anthropic-version":"2023-06-01",...this.config.headers},body:JSON.stringify({...this.buildRequestBody(a),stream:!0})});await this.parseAnthropicStream(s,r,t,n)}catch(s){n==null||n(s)}}buildRequestBody(a){const r=a.messages.find(n=>n.role==="system"),t=a.messages.filter(n=>n.role!=="system");return{model:a.model||this.config.model||"claude-3-5-sonnet-20241022",max_tokens:a.maxTokens??1024,system:r==null?void 0:r.content,messages:t.map(n=>({role:n.role==="assistant"?"assistant":"user",content:n.content})),temperature:a.temperature??.7}}normalizeResponse(a){const r=a,t=r.content.find(n=>n.type==="text");return{id:r.id,model:r.model,choices:[{index:0,message:{role:"assistant",content:(t==null?void 0:t.text)||""},finishReason:r.stop_reason==="end_turn"?"stop":"length"}],usage:{promptTokens:r.usage.input_tokens,completionTokens:r.usage.output_tokens,totalTokens:r.usage.input_tokens+r.usage.output_tokens},estimatedCost:this.estimateCost(r.model,r.usage.input_tokens,r.usage.output_tokens)}}normalizeStreamChunk(a){var t;const r=a;return{id:"",choices:[{index:r.index||0,delta:{content:((t=r.delta)==null?void 0:t.text)||""},finishReason:r.type==="message_stop"?"stop":null}]}}async parseAnthropicStream(a,r,t,n){var f;const s=(f=a.body)==null?void 0:f.getReader();if(!s){n==null||n(new Error("No response body"));return}const l=new TextDecoder;let o="";try{for(;;){const{done:h,value:y}=await s.read();if(h)break;o+=l.decode(y,{stream:!0});const w=o.split(`
|
|
43
43
|
`);o=w.pop()||"";for(const C of w)if(C.startsWith("data: "))try{const S=JSON.parse(C.slice(6));if(S.type==="content_block_delta")r(this.normalizeStreamChunk(S));else if(S.type==="message_stop"){t==null||t();return}}catch{}}t==null||t()}catch(h){n==null||n(h)}finally{s.releaseLock()}}estimateCost(a,r,t){const n={"claude-3-5-sonnet":{input:3,output:15},"claude-3-5-haiku":{input:.25,output:1.25},"claude-3-opus":{input:15,output:75},"claude-3-sonnet":{input:3,output:15},"claude-3-haiku":{input:.25,output:1.25}},s=Object.keys(n).find(o=>a.includes(o)),l=s?n[s]:n["claude-3-5-sonnet"];return r/1e6*l.input+t/1e6*l.output}}class ga extends ne{constructor(a){if(super(a),this.type="azure-openai",this.name="Azure OpenAI",!a.baseUrl||!a.deployment)throw new Error("Azure OpenAI requires baseUrl and deployment")}async chat(a){const r=`${this.config.baseUrl}/openai/deployments/${this.config.deployment}/chat/completions?api-version=${this.config.apiVersion||"2024-02-01"}`,n=await(await this.fetchWithRetry(r,{method:"POST",headers:{"Content-Type":"application/json","api-key":this.config.apiKey,...this.config.headers},body:JSON.stringify(this.buildRequestBody(a))})).json();return this.normalizeResponse(n)}async chatStream(a,r,t,n){const s=`${this.config.baseUrl}/openai/deployments/${this.config.deployment}/chat/completions?api-version=${this.config.apiVersion||"2024-02-01"}`;try{const l=await this.fetchWithRetry(s,{method:"POST",headers:{"Content-Type":"application/json","api-key":this.config.apiKey,...this.config.headers},body:JSON.stringify({...this.buildRequestBody(a),stream:!0})});await this.parseSSEStream(l,r,t,n)}catch(l){n==null||n(l)}}buildRequestBody(a){return{messages:a.messages,temperature:a.temperature??.7,max_tokens:a.maxTokens??1024,top_p:a.topP,frequency_penalty:a.frequencyPenalty,presence_penalty:a.presencePenalty,stop:a.stop}}normalizeResponse(a){const r=a;return{id:r.id,model:r.model,choices:r.choices.map(t=>({index:t.index,message:t.message,finishReason:t.finish_reason})),usage:{promptTokens:r.usage.prompt_tokens,completionTokens:r.usage.completion_tokens,totalTokens:r.usage.total_tokens}}}normalizeStreamChunk(a){const r=a;return{id:r.id,choices:r.choices.map(t=>({index:t.index,delta:t.delta,finishReason:t.finish_reason}))}}}class ya extends ne{constructor(a){super(a),this.type="ollama",this.name="Ollama (Local)",this.baseUrl=a.baseUrl||"http://localhost:11434"}async chat(a){const t=await(await this.fetchWithRetry(`${this.baseUrl}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json",...this.config.headers},body:JSON.stringify({model:a.model||this.config.model||"llama3",messages:a.messages,stream:!1,options:{temperature:a.temperature??.7,num_predict:a.maxTokens??1024}})})).json();return this.normalizeResponse(t)}async chatStream(a,r,t,n){try{const s=await this.fetchWithRetry(`${this.baseUrl}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json",...this.config.headers},body:JSON.stringify({model:a.model||this.config.model||"llama3",messages:a.messages,stream:!0,options:{temperature:a.temperature??.7,num_predict:a.maxTokens??1024}})});await this.parseOllamaStream(s,r,t,n)}catch(s){n==null||n(s)}}async listModels(){try{return((await(await this.fetchWithRetry(`${this.baseUrl}/api/tags`,{method:"GET"})).json()).models||[]).map(t=>t.name)}catch{return[]}}normalizeResponse(a){const r=a;return{id:`ollama-${Date.now()}`,model:r.model,choices:[{index:0,message:r.message,finishReason:r.done?"stop":null}],usage:{promptTokens:r.prompt_eval_count||0,completionTokens:r.eval_count||0,totalTokens:(r.prompt_eval_count||0)+(r.eval_count||0)},estimatedCost:0}}normalizeStreamChunk(a){var t;const r=a;return{id:`ollama-${Date.now()}`,choices:[{index:0,delta:{content:((t=r.message)==null?void 0:t.content)||""},finishReason:r.done?"stop":null}]}}async parseOllamaStream(a,r,t,n){var f;const s=(f=a.body)==null?void 0:f.getReader();if(!s){n==null||n(new Error("No response body"));return}const l=new TextDecoder;let o="";try{for(;;){const{done:h,value:y}=await s.read();if(h)break;o+=l.decode(y,{stream:!0});const w=o.split(`
|
|
44
44
|
`);o=w.pop()||"";for(const C of w)if(C.trim())try{const S=JSON.parse(C);if(r(this.normalizeStreamChunk(S)),S.done){t==null||t();return}}catch{}}t==null||t()}catch(h){n==null||n(h)}finally{s.releaseLock()}}}class ba extends ne{constructor(a){super(a),this.type="groq",this.name="Groq",this.baseUrl=a.baseUrl||"https://api.groq.com/openai/v1"}async chat(a){const t=await(await this.fetchWithRetry(`${this.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`,...this.config.headers},body:JSON.stringify({model:a.model||this.config.model||"llama-3.1-70b-versatile",messages:a.messages,temperature:a.temperature??.7,max_tokens:a.maxTokens??1024})})).json();return this.normalizeResponse(t)}async chatStream(a,r,t,n){try{const s=await this.fetchWithRetry(`${this.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`,...this.config.headers},body:JSON.stringify({model:a.model||this.config.model||"llama-3.1-70b-versatile",messages:a.messages,temperature:a.temperature??.7,max_tokens:a.maxTokens??1024,stream:!0})});await this.parseSSEStream(s,r,t,n)}catch(s){n==null||n(s)}}normalizeResponse(a){const r=a;return{id:r.id,model:r.model,choices:r.choices.map(t=>({index:t.index,message:t.message,finishReason:t.finish_reason})),usage:{promptTokens:r.usage.prompt_tokens,completionTokens:r.usage.completion_tokens,totalTokens:r.usage.total_tokens},estimatedCost:0}}normalizeStreamChunk(a){const r=a;return{id:r.id,choices:r.choices.map(t=>({index:t.index,delta:t.delta,finishReason:t.finish_reason}))}}}function te(i){switch(i.type){case"openai":return new fa(i);case"anthropic":return new ha(i);case"azure-openai":return new ga(i);case"ollama":return new ya(i);case"groq":return new ba(i);default:throw new Error(`Unsupported provider type: ${i.type}`)}}function G(i){const a=i.endpoint.toLowerCase();let r="custom";a.includes("openai.com")?r="openai":a.includes("anthropic.com")?r="anthropic":a.includes("azure.com")||a.includes("openai.azure.com")?r="azure-openai":a.includes("localhost:11434")||a.includes("ollama")?r="ollama":a.includes("groq.com")&&(r="groq");const t=new URL(i.endpoint),n=`${t.protocol}//${t.host}`;return te({type:r,apiKey:i.apiKey,baseUrl:n,model:i.model,headers:i.headers})}function ae(i,a){for(const n of i.variables)if(n.required&&!(n.name in a)&&!n.default)throw new Error(`Missing required variable: ${n.name}`);const r={};for(const n of i.variables)r[n.name]=a[n.name]??n.default;const t=n=>n.replace(/\{\{(\w+)\}\}/g,(s,l)=>{const o=r[l];return o===void 0?`{{${l}}}`:typeof o=="object"?JSON.stringify(o,null,2):String(o)});return{system:t(i.system),user:t(i.user),metadata:{templateId:i.id,variables:r,timestamp:Date.now()}}}const ce={id:"data-grid-filter",name:"DataGrid Natural Language Filter",description:"Convert natural language queries to DataGrid filter configurations",category:"data-query",system:`You are a filter query generator for a data grid component.
|
|
@@ -378,7 +378,7 @@ Format output as structured JSON:
|
|
|
378
378
|
|
|
379
379
|
{{#if context}}Context: {{context}}{{/if}}
|
|
380
380
|
|
|
381
|
-
Provide summary and insights:`,variables:[{name:"data",description:"Data to summarize (JSON or CSV)",required:!0,type:"string"},{name:"context",description:"Business context",required:!1,type:"string"}],suggestedTemperature:.4,maxTokens:1024},ye={[ce.id]:ce,[oe.id]:oe,[le.id]:le,[de.id]:de,[ue.id]:ue,[pe.id]:pe,[me.id]:me,[fe.id]:fe,[je.id]:je,[ke.id]:ke,[Ne.id]:Ne};function zr(i){return ye[i]}function Lr(i){return Object.values(ye).filter(a=>a.category===i)}function Or(){return Object.keys(ye)}class Ie{constructor(){this.records=new Map}async save(a,r){const t=this.records.get(a)||[];this.records.set(a,[...t,...r])}async load(a,r,t){const n=this.records.get(a)||[];return!r&&!t?n:n.filter(s=>!(r&&s.timestamp<r.getTime()||t&&s.timestamp>t.getTime()))}async clear(a,r){if(!r)this.records.delete(a);else{const t=this.records.get(a)||[];this.records.set(a,t.filter(n=>n.timestamp>=r.getTime()))}}}class xa{constructor(){this.prefix="nice2dev-ai-cost:"}async save(a,r){if(typeof window>"u")return;const t=`${this.prefix}${a}`,s=[...JSON.parse(localStorage.getItem(t)||"[]"),...r],l=Date.now()-30*24*60*60*1e3,o=s.filter(f=>f.timestamp>l);localStorage.setItem(t,JSON.stringify(o))}async load(a,r,t){if(typeof window>"u")return[];const n=`${this.prefix}${a}`,s=JSON.parse(localStorage.getItem(n)||"[]");return!r&&!t?s:s.filter(l=>!(r&&l.timestamp<r.getTime()||t&&l.timestamp>t.getTime()))}async clear(a,r){if(typeof window>"u")return;const t=`${this.prefix}${a}`;if(!r)localStorage.removeItem(t);else{const n=JSON.parse(localStorage.getItem(t)||"[]");localStorage.setItem(t,JSON.stringify(n.filter(s=>s.timestamp>=r.getTime())))}}}class va{constructor(a,r){this.pendingRecords=[],this.flushTimer=null,this.alertCallbacks=[],this.minuteCounter=new Map,this.dayCounter=new Map,this.storage=a||new Ie,this.budgetConfig={monthlyBudget:100,dailyBudget:10,maxTokensPerRequest:4096,maxRequestsPerMinute:30,maxRequestsPerDay:1e3,alertThresholds:[50,80,90,100],...r}}async recordUsage(a,r){const t={...r,id:this.generateId(),timestamp:Date.now()};this.pendingRecords.push(t),this.updateCounters(a),this.scheduleFlush(a);const n=await this.getBudgetStatus(a);this.checkAlerts(a,n)}async canMakeRequest(a){const r=await this.getBudgetStatus(a);return r.isOverBudget?{allowed:!1,reason:"Budget exceeded"}:this.budgetConfig.maxRequestsPerMinute&&r.requestsThisMinute>=this.budgetConfig.maxRequestsPerMinute?{allowed:!1,reason:"Rate limit exceeded (per minute)"}:this.budgetConfig.maxRequestsPerDay&&r.requestsToday>=this.budgetConfig.maxRequestsPerDay?{allowed:!1,reason:"Daily request limit exceeded"}:{allowed:!0}}async getBudgetStatus(a){const r=new Date,t=new Date(r.getFullYear(),r.getMonth(),r.getDate()),n=new Date(r.getFullYear(),r.getMonth(),1),s=await this.storage.load(a,t),l=await this.storage.load(a,n),o=s.reduce((P,k)=>P+k.estimatedCost,0),f=l.reduce((P,k)=>P+k.estimatedCost,0),h=this.budgetConfig.dailyBudget||1/0,y=this.budgetConfig.monthlyBudget||1/0,w=h?o/h*100:0,C=y?f/y*100:0,S=[];for(const P of this.budgetConfig.alertThresholds||[])w>=P&&S.push(`Daily budget ${P}% used`),C>=P&&S.push(`Monthly budget ${P}% used`);return{dailyUsed:o,dailyRemaining:Math.max(0,h-o),dailyPercent:w,monthlyUsed:f,monthlyRemaining:Math.max(0,y-f),monthlyPercent:C,requestsToday:s.length,requestsThisMinute:this.getMinuteCount(a),isOverBudget:o>=h||f>=y,alerts:S}}async getUsageStats(a,r,t){const n=await this.storage.load(a,r,t),s={totalRequests:n.length,totalTokens:0,totalPromptTokens:0,totalCompletionTokens:0,totalCost:0,averageLatency:0,errorCount:0,cacheHitRate:0,byModel:{},byFeature:{},byDay:{}};let l=0,o=0;for(const f of n){s.totalTokens+=f.totalTokens,s.totalPromptTokens+=f.promptTokens,s.totalCompletionTokens+=f.completionTokens,s.totalCost+=f.estimatedCost,l+=f.latencyMs,f.error&&s.errorCount++,f.cached&&o++,s.byModel[f.model]||(s.byModel[f.model]={requests:0,tokens:0,cost:0}),s.byModel[f.model].requests++,s.byModel[f.model].tokens+=f.totalTokens,s.byModel[f.model].cost+=f.estimatedCost;const h=f.feature||"unknown";s.byFeature[h]||(s.byFeature[h]={requests:0,tokens:0,cost:0}),s.byFeature[h].requests++,s.byFeature[h].tokens+=f.totalTokens,s.byFeature[h].cost+=f.estimatedCost;const y=new Date(f.timestamp).toISOString().split("T")[0];s.byDay[y]||(s.byDay[y]={requests:0,tokens:0,cost:0}),s.byDay[y].requests++,s.byDay[y].tokens+=f.totalTokens,s.byDay[y].cost+=f.estimatedCost}return n.length>0&&(s.averageLatency=l/n.length,s.cacheHitRate=o/n.length),s}onAlert(a){return this.alertCallbacks.push(a),()=>{const r=this.alertCallbacks.indexOf(a);r>=0&&this.alertCallbacks.splice(r,1)}}setBudgetConfig(a){this.budgetConfig={...this.budgetConfig,...a}}async clearUsage(a,r){await this.storage.clear(a,r)}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}updateCounters(a){const r=Date.now(),t=r-6e4,n=this.minuteCounter.get(a)||[];n.push(r),this.minuteCounter.set(a,n.filter(o=>o>t));const s=new Date().toISOString().split("T")[0],l=`${a}:${s}`;this.dayCounter.set(l,(this.dayCounter.get(l)||0)+1)}getMinuteCount(a){const t=Date.now()-6e4;return(this.minuteCounter.get(a)||[]).filter(s=>s>t).length}scheduleFlush(a){this.flushTimer||(this.flushTimer=setTimeout(async()=>{this.flushTimer=null,this.pendingRecords.length>0&&(await this.storage.save(a,this.pendingRecords),this.pendingRecords=[])},1e3))}checkAlerts(a,r){if(r.alerts.length!==0)for(const t of r.alerts)for(const n of this.alertCallbacks)try{n(t,r)}catch{}}}function Er(i,a){const r=c.useRef(null),[t,n]=c.useState(null),[s,l]=c.useState(null),[o,f]=c.useState(!0);c.useEffect(()=>{const C=typeof window<"u"?new xa:new Ie;r.current=new va(C,a);const S=r.current.onAlert(P=>{console.warn(`[AI Cost Alert] ${P}`)});return()=>{S()}},[]);const h=c.useCallback(async()=>{if(r.current){f(!0);try{const[C,S]=await Promise.all([r.current.getBudgetStatus(i),r.current.getUsageStats(i)]);n(C),l(S)}finally{f(!1)}}},[i]);c.useEffect(()=>{h()},[h]);const y=c.useCallback(async C=>{r.current&&(await r.current.recordUsage(i,C),await h())},[i,h]),w=c.useCallback(async()=>r.current?r.current.canMakeRequest(i):{allowed:!0},[i]);return{status:t,stats:s,loading:o,recordUsage:y,canMakeRequest:w,refresh:h}}class Dr{constructor(a=100,r=36e5){this.cache=new Map,this.maxSize=a,this.ttl=r}hashRequest(a){const r=JSON.stringify({messages:a.messages,model:a.model,temperature:a.temperature});let t=0;for(let n=0;n<r.length;n++){const s=r.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return t.toString(36)}get(a){const r=this.hashRequest(a),t=this.cache.get(r);return t?Date.now()-t.timestamp>this.ttl?(this.cache.delete(r),null):t.response:null}set(a,r){const t=this.hashRequest(a);if(this.cache.size>=this.maxSize){const n=this.cache.keys().next().value;n&&this.cache.delete(n)}this.cache.set(t,{request:t,response:r,timestamp:Date.now()})}clear(){this.cache.clear()}}class _a{constructor(a,r){this.backupProviders=[],this.circuitBreakers=new Map,this.primaryProvider=a,this.config={strategies:["retry","failover","cache","graceful-degrade"],maxRetries:3,retryDelay:1e3,backoffMultiplier:2,backupProviders:[],cacheTTL:36e5,offlineConfig:void 0,circuitBreakerThreshold:5,circuitBreakerResetTime:6e4,onFallback:void 0,...r},this.cache=new Dr(100,this.config.cacheTTL);for(const t of this.config.backupProviders||[])this.backupProviders.push(te(t));this.config.offlineConfig&&(this.offlineProvider=te(this.config.offlineConfig))}async chat(a){if(this.isCircuitOpen(this.primaryProvider.type))return this.executeWithFallback(a,new Error("Circuit breaker open"));try{const r=await this.primaryProvider.chat(a);return this.cache.set(a,r),this.resetCircuitBreaker(this.primaryProvider.type),r}catch(r){return this.recordFailure(this.primaryProvider.type),this.executeWithFallback(a,r)}}async executeWithFallback(a,r){var t,n;for(const s of this.config.strategies)try{const l=await this.executeStrategy(s,a,r);if(l)return(n=(t=this.config).onFallback)==null||n.call(t,s,r),l}catch{}throw new Error(`All fallback strategies failed. Original error: ${r.message}`)}async executeStrategy(a,r,t){switch(a){case"retry":return this.retryStrategy(r);case"failover":return this.failoverStrategy(r);case"cache":return this.cacheStrategy(r);case"offline":return this.offlineStrategy(r);case"graceful-degrade":return this.gracefulDegradeStrategy(r,t);case"circuit-breaker":return this.openCircuitBreaker(this.primaryProvider.type),null;default:return null}}async retryStrategy(a){let r=this.config.retryDelay;for(let t=0;t<this.config.maxRetries;t++){await this.delay(r);try{const n=await this.primaryProvider.chat(a);return this.cache.set(a,n),n}catch{r*=this.config.backoffMultiplier}}return null}async failoverStrategy(a){for(const r of this.backupProviders)if(!this.isCircuitOpen(r.type))try{const t=await r.chat(a);return this.cache.set(a,t),t}catch{this.recordFailure(r.type)}return null}cacheStrategy(a){const r=this.cache.get(a);return r?{...r,id:`cached-${r.id}`}:null}async offlineStrategy(a){if(!this.offlineProvider)return null;try{return await this.offlineProvider.chat(a)}catch{return null}}gracefulDegradeStrategy(a,r){const t=[...a.messages].reverse().find(n=>n.role==="user");return{id:`degraded-${Date.now()}`,model:"fallback",choices:[{index:0,message:{role:"assistant",content:this.generateDegradedResponse((t==null?void 0:t.content)||"",r)},finishReason:"stop"}],usage:{promptTokens:0,completionTokens:0,totalTokens:0}}}generateDegradedResponse(a,r){return a.toLowerCase().includes("filter")||a.toLowerCase().includes("show")?JSON.stringify({filters:[],logic:"and"}):a.toLowerCase().includes("form")||a.toLowerCase().includes("create")?JSON.stringify({title:"Form",fields:[{id:"field1",type:"text",label:"Field 1"}]}):a.toLowerCase().includes("chart")||a.toLowerCase().includes("graph")?JSON.stringify({type:"bar",title:"Chart",data:{source:"data"}}):`I'm sorry, I couldn't process your request at this time. The service is temporarily unavailable. Please try again later or contact support. (Error: ${r.message.substring(0,50)})`}isCircuitOpen(a){const r=this.circuitBreakers.get(a);return r&&r.isOpen?Date.now()-r.lastFailure>this.config.circuitBreakerResetTime?(this.resetCircuitBreaker(a),!1):!0:!1}recordFailure(a){const r=this.circuitBreakers.get(a)||{failures:0,lastFailure:0,isOpen:!1};r.failures++,r.lastFailure=Date.now(),r.failures>=this.config.circuitBreakerThreshold&&(r.isOpen=!0),this.circuitBreakers.set(a,r)}openCircuitBreaker(a){this.circuitBreakers.set(a,{failures:this.config.circuitBreakerThreshold,lastFailure:Date.now(),isOpen:!0})}resetCircuitBreaker(a){this.circuitBreakers.delete(a)}delay(a){return new Promise(r=>setTimeout(r,a))}addBackupProvider(a){this.backupProviders.push(a)}setOfflineProvider(a){this.offlineProvider=a}clearCache(){this.cache.clear()}resetAllCircuitBreakers(){this.circuitBreakers.clear()}getCircuitBreakerStatus(){const a={};for(const[r,t]of this.circuitBreakers)a[r]={...t};return a}async healthCheck(){const a={};a[this.primaryProvider.type]=await this.primaryProvider.healthCheck();for(const r of this.backupProviders)a[`backup-${r.type}`]=await r.healthCheck();return this.offlineProvider&&(a.offline=await this.offlineProvider.healthCheck()),a}}function wa(i,a){const r=te(i);return new _a(r,a)}function Hr(i,a){const r={strategies:["retry","failover","cache","graceful-degrade"],maxRetries:3,retryDelay:1e3,backoffMultiplier:2,backupProviders:a?[a]:[],circuitBreakerThreshold:5,circuitBreakerResetTime:6e4};return typeof window>"u"&&(r.offlineConfig={type:"ollama",model:"llama3"}),wa(i,r)}function ja(i){const{columns:a,config:r,onFilterGenerated:t,onSortGenerated:n,onError:s}=i,l=Q(),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(null),[S,P]=c.useState([]),k=c.useRef(null),$=r||(l==null?void 0:l.config),g=c.useMemo(()=>a.map(m=>({id:m.id,label:m.label,type:m.type,...m.options?{options:m.options}:{}})),[a]),d=c.useCallback(async m=>{var x;if(!$){const p="AI not configured. Provide config or wrap in NiceAIProvider.";return s==null||s(p),{type:"filter",error:p}}f(!0),y(m);const v=performance.now();(x=k.current)==null||x.abort(),k.current=new AbortController;try{const p=G($),_=m.toLowerCase(),M=_.includes("sort")||_.includes("order")||_.includes("arrange")||_.includes("by highest")||_.includes("by lowest"),R=_.includes("show")||_.includes("find")||_.includes("filter")||_.includes("where")||_.includes("with")||_.includes("only")||!M,T={type:"combined"};if(R){const u=ae(ce,{columns:g,query:m}),b=await p.chat({messages:[{role:"system",content:u.system},{role:"user",content:u.user}],temperature:.2,maxTokens:512}),I=Br(b);I&&(T.filterConfig=I,T.type="filter",t==null||t(I))}if(M){const u=ae(oe,{columns:g,query:m}),b=await p.chat({messages:[{role:"system",content:u.system},{role:"user",content:u.user}],temperature:.1,maxTokens:256}),I=Fr(b);I&&(T.sortConfig=I,T.type=T.filterConfig?"combined":"sort",n==null||n(I))}return T.latencyMs=performance.now()-v,C(T),P(u=>[...u.slice(-9),{query:m,result:T}]),T}catch(p){const _=p instanceof Error?p.message:"AI request failed",M={type:"filter",error:_,latencyMs:performance.now()-v};return C(M),s==null||s(_),M}finally{f(!1)}},[$,g,t,n,s]),j=c.useCallback(()=>{y(null),C(null)},[]),N=c.useCallback(()=>{var m;(m=k.current)==null||m.abort(),f(!1)},[]);return c.useEffect(()=>()=>{var m;(m=k.current)==null||m.abort()},[]),{processQuery:d,loading:o,lastQuery:h,lastResult:w,history:S,clearResults:j,abort:N,isConfigured:!!$}}function Br(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.filters&&Array.isArray(o.filters))return{filters:o.filters,logic:o.logic||"and",confidence:o.confidence,explanation:o.explanation}}catch{}return null}function Fr(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.sort&&Array.isArray(o.sort))return{sort:o.sort,confidence:o.confidence}}catch{}return null}function Jr({columns:i,config:a,onFilter:r,onSort:t,placeholder:n='Ask AI to filter or sort data... (e.g., "show orders from last week")',showHistory:s=!0,showSuggestions:l=!0,className:o,style:f}){const[h,y]=c.useState(""),[w,C]=c.useState(!1),S=c.useRef(null),{processQuery:P,loading:k,lastResult:$,history:g,isConfigured:d}=ja({columns:i,config:a,onFilterGenerated:r,onSortGenerated:t}),j=c.useMemo(()=>{if(!l||i.length===0)return[];const p=[],_=i.filter(u=>u.type==="string");_.length>0&&p.push(`Show ${_[0].label}s containing "example"`);const M=i.filter(u=>u.type==="number");M.length>0&&(p.push(`${M[0].label} greater than 100`),p.push(`Sort by highest ${M[0].label}`));const R=i.filter(u=>u.type==="date");R.length>0&&(p.push(`${R[0].label} in the last 7 days`),p.push(`Sort by newest ${R[0].label}`));const T=i.filter(u=>{var b;return u.type==="enum"&&((b=u.options)==null?void 0:b.length)});return T.length>0&&T[0].options&&p.push(`Where ${T[0].label} is ${T[0].options[0]}`),p.slice(0,5)},[i,l]),N=async()=>{!h.trim()||k||(await P(h.trim()),C(!1))},m=p=>{p.key==="Enter"?(p.preventDefault(),N()):p.key==="Escape"&&C(!1)},v=p=>{var _;y(p),C(!1),(_=S.current)==null||_.focus()},x=p=>{y(p),C(!1),P(p)};return d?e.jsxs("div",{className:`nice-datagrid-ai ${o||""}`,style:f,children:[e.jsxs("div",{className:"nice-datagrid-ai__input-wrapper",children:[e.jsx("span",{className:"nice-datagrid-ai__icon",children:e.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.94-.49-7-3.85-7-7.93s3.05-7.44 7-7.93v15.86zm2-15.86c1.03.13 2 .45 2.87.93H13v-.93zM13 7h5.24c.25.31.48.65.68 1H13V7zm0 3h6.74c.08.33.15.66.19 1H13v-1zm0 9.93V19h2.87c-.87.48-1.84.8-2.87.93zM18.24 17H13v-1h5.92c-.2.35-.43.69-.68 1zm1.5-3H13v-1h6.93c-.04.34-.11.67-.19 1z"})})}),e.jsx("input",{ref:S,type:"text",value:h,onChange:p=>y(p.target.value),onKeyDown:m,onFocus:()=>C(!0),onBlur:()=>setTimeout(()=>C(!1),200),placeholder:n,className:"nice-datagrid-ai__input",disabled:k,"aria-label":"AI query input"}),k?e.jsx("span",{className:"nice-datagrid-ai__spinner"}):e.jsx("button",{type:"button",onClick:N,className:"nice-datagrid-ai__submit",disabled:!h.trim(),"aria-label":"Submit query",children:e.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:e.jsx("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})})})]}),w&&(j.length>0||s&&g.length>0)&&e.jsxs("div",{className:"nice-datagrid-ai__dropdown",children:[l&&j.length>0&&e.jsxs("div",{className:"nice-datagrid-ai__section",children:[e.jsx("div",{className:"nice-datagrid-ai__section-title",children:"Suggestions"}),j.map((p,_)=>e.jsxs("button",{type:"button",className:"nice-datagrid-ai__item",onClick:()=>v(p),children:[e.jsx("span",{className:"nice-datagrid-ai__item-icon",children:"💡"}),p]},_))]}),s&&g.length>0&&e.jsxs("div",{className:"nice-datagrid-ai__section",children:[e.jsx("div",{className:"nice-datagrid-ai__section-title",children:"Recent"}),g.slice(-5).reverse().map((p,_)=>e.jsxs("button",{type:"button",className:"nice-datagrid-ai__item",onClick:()=>x(p.query),children:[e.jsx("span",{className:"nice-datagrid-ai__item-icon",children:"🕐"}),p.query,p.result.error&&e.jsx("span",{className:"nice-datagrid-ai__item-error",children:"⚠️"})]},_))]})]}),$&&!$.error&&e.jsxs("div",{className:"nice-datagrid-ai__result",children:[$.filterConfig&&e.jsxs("span",{className:"nice-datagrid-ai__badge nice-datagrid-ai__badge--filter",children:[$.filterConfig.filters.length," filter",$.filterConfig.filters.length!==1?"s":""," applied"]}),$.sortConfig&&e.jsxs("span",{className:"nice-datagrid-ai__badge nice-datagrid-ai__badge--sort",children:["Sorted by ",$.sortConfig.sort.map(p=>p.column).join(", ")]}),$.latencyMs&&e.jsxs("span",{className:"nice-datagrid-ai__latency",children:[Math.round($.latencyMs),"ms"]})]}),($==null?void 0:$.error)&&e.jsx("div",{className:"nice-datagrid-ai__error",children:$.error}),e.jsx("style",{children:`
|
|
381
|
+
Provide summary and insights:`,variables:[{name:"data",description:"Data to summarize (JSON or CSV)",required:!0,type:"string"},{name:"context",description:"Business context",required:!1,type:"string"}],suggestedTemperature:.4,maxTokens:1024},ye={[ce.id]:ce,[oe.id]:oe,[le.id]:le,[de.id]:de,[ue.id]:ue,[pe.id]:pe,[me.id]:me,[fe.id]:fe,[je.id]:je,[ke.id]:ke,[Ne.id]:Ne};function Ir(i){return ye[i]}function Lr(i){return Object.values(ye).filter(a=>a.category===i)}function Or(){return Object.keys(ye)}class ze{constructor(){this.records=new Map}async save(a,r){const t=this.records.get(a)||[];this.records.set(a,[...t,...r])}async load(a,r,t){const n=this.records.get(a)||[];return!r&&!t?n:n.filter(s=>!(r&&s.timestamp<r.getTime()||t&&s.timestamp>t.getTime()))}async clear(a,r){if(!r)this.records.delete(a);else{const t=this.records.get(a)||[];this.records.set(a,t.filter(n=>n.timestamp>=r.getTime()))}}}class xa{constructor(){this.prefix="nice2dev-ai-cost:"}async save(a,r){if(typeof window>"u")return;const t=`${this.prefix}${a}`,s=[...JSON.parse(localStorage.getItem(t)||"[]"),...r],l=Date.now()-30*24*60*60*1e3,o=s.filter(f=>f.timestamp>l);localStorage.setItem(t,JSON.stringify(o))}async load(a,r,t){if(typeof window>"u")return[];const n=`${this.prefix}${a}`,s=JSON.parse(localStorage.getItem(n)||"[]");return!r&&!t?s:s.filter(l=>!(r&&l.timestamp<r.getTime()||t&&l.timestamp>t.getTime()))}async clear(a,r){if(typeof window>"u")return;const t=`${this.prefix}${a}`;if(!r)localStorage.removeItem(t);else{const n=JSON.parse(localStorage.getItem(t)||"[]");localStorage.setItem(t,JSON.stringify(n.filter(s=>s.timestamp>=r.getTime())))}}}class va{constructor(a,r){this.pendingRecords=[],this.flushTimer=null,this.alertCallbacks=[],this.minuteCounter=new Map,this.dayCounter=new Map,this.storage=a||new ze,this.budgetConfig={monthlyBudget:100,dailyBudget:10,maxTokensPerRequest:4096,maxRequestsPerMinute:30,maxRequestsPerDay:1e3,alertThresholds:[50,80,90,100],...r}}async recordUsage(a,r){const t={...r,id:this.generateId(),timestamp:Date.now()};this.pendingRecords.push(t),this.updateCounters(a),this.scheduleFlush(a);const n=await this.getBudgetStatus(a);this.checkAlerts(a,n)}async canMakeRequest(a){const r=await this.getBudgetStatus(a);return r.isOverBudget?{allowed:!1,reason:"Budget exceeded"}:this.budgetConfig.maxRequestsPerMinute&&r.requestsThisMinute>=this.budgetConfig.maxRequestsPerMinute?{allowed:!1,reason:"Rate limit exceeded (per minute)"}:this.budgetConfig.maxRequestsPerDay&&r.requestsToday>=this.budgetConfig.maxRequestsPerDay?{allowed:!1,reason:"Daily request limit exceeded"}:{allowed:!0}}async getBudgetStatus(a){const r=new Date,t=new Date(r.getFullYear(),r.getMonth(),r.getDate()),n=new Date(r.getFullYear(),r.getMonth(),1),s=await this.storage.load(a,t),l=await this.storage.load(a,n),o=s.reduce((P,k)=>P+k.estimatedCost,0),f=l.reduce((P,k)=>P+k.estimatedCost,0),h=this.budgetConfig.dailyBudget||1/0,y=this.budgetConfig.monthlyBudget||1/0,w=h?o/h*100:0,C=y?f/y*100:0,S=[];for(const P of this.budgetConfig.alertThresholds||[])w>=P&&S.push(`Daily budget ${P}% used`),C>=P&&S.push(`Monthly budget ${P}% used`);return{dailyUsed:o,dailyRemaining:Math.max(0,h-o),dailyPercent:w,monthlyUsed:f,monthlyRemaining:Math.max(0,y-f),monthlyPercent:C,requestsToday:s.length,requestsThisMinute:this.getMinuteCount(a),isOverBudget:o>=h||f>=y,alerts:S}}async getUsageStats(a,r,t){const n=await this.storage.load(a,r,t),s={totalRequests:n.length,totalTokens:0,totalPromptTokens:0,totalCompletionTokens:0,totalCost:0,averageLatency:0,errorCount:0,cacheHitRate:0,byModel:{},byFeature:{},byDay:{}};let l=0,o=0;for(const f of n){s.totalTokens+=f.totalTokens,s.totalPromptTokens+=f.promptTokens,s.totalCompletionTokens+=f.completionTokens,s.totalCost+=f.estimatedCost,l+=f.latencyMs,f.error&&s.errorCount++,f.cached&&o++,s.byModel[f.model]||(s.byModel[f.model]={requests:0,tokens:0,cost:0}),s.byModel[f.model].requests++,s.byModel[f.model].tokens+=f.totalTokens,s.byModel[f.model].cost+=f.estimatedCost;const h=f.feature||"unknown";s.byFeature[h]||(s.byFeature[h]={requests:0,tokens:0,cost:0}),s.byFeature[h].requests++,s.byFeature[h].tokens+=f.totalTokens,s.byFeature[h].cost+=f.estimatedCost;const y=new Date(f.timestamp).toISOString().split("T")[0];s.byDay[y]||(s.byDay[y]={requests:0,tokens:0,cost:0}),s.byDay[y].requests++,s.byDay[y].tokens+=f.totalTokens,s.byDay[y].cost+=f.estimatedCost}return n.length>0&&(s.averageLatency=l/n.length,s.cacheHitRate=o/n.length),s}onAlert(a){return this.alertCallbacks.push(a),()=>{const r=this.alertCallbacks.indexOf(a);r>=0&&this.alertCallbacks.splice(r,1)}}setBudgetConfig(a){this.budgetConfig={...this.budgetConfig,...a}}async clearUsage(a,r){await this.storage.clear(a,r)}generateId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}updateCounters(a){const r=Date.now(),t=r-6e4,n=this.minuteCounter.get(a)||[];n.push(r),this.minuteCounter.set(a,n.filter(o=>o>t));const s=new Date().toISOString().split("T")[0],l=`${a}:${s}`;this.dayCounter.set(l,(this.dayCounter.get(l)||0)+1)}getMinuteCount(a){const t=Date.now()-6e4;return(this.minuteCounter.get(a)||[]).filter(s=>s>t).length}scheduleFlush(a){this.flushTimer||(this.flushTimer=setTimeout(async()=>{this.flushTimer=null,this.pendingRecords.length>0&&(await this.storage.save(a,this.pendingRecords),this.pendingRecords=[])},1e3))}checkAlerts(a,r){if(r.alerts.length!==0)for(const t of r.alerts)for(const n of this.alertCallbacks)try{n(t,r)}catch{}}}function Er(i,a){const r=c.useRef(null),[t,n]=c.useState(null),[s,l]=c.useState(null),[o,f]=c.useState(!0);c.useEffect(()=>{const C=typeof window<"u"?new xa:new ze;r.current=new va(C,a);const S=r.current.onAlert(P=>{console.warn(`[AI Cost Alert] ${P}`)});return()=>{S()}},[]);const h=c.useCallback(async()=>{if(r.current){f(!0);try{const[C,S]=await Promise.all([r.current.getBudgetStatus(i),r.current.getUsageStats(i)]);n(C),l(S)}finally{f(!1)}}},[i]);c.useEffect(()=>{h()},[h]);const y=c.useCallback(async C=>{r.current&&(await r.current.recordUsage(i,C),await h())},[i,h]),w=c.useCallback(async()=>r.current?r.current.canMakeRequest(i):{allowed:!0},[i]);return{status:t,stats:s,loading:o,recordUsage:y,canMakeRequest:w,refresh:h}}class Dr{constructor(a=100,r=36e5){this.cache=new Map,this.maxSize=a,this.ttl=r}hashRequest(a){const r=JSON.stringify({messages:a.messages,model:a.model,temperature:a.temperature});let t=0;for(let n=0;n<r.length;n++){const s=r.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return t.toString(36)}get(a){const r=this.hashRequest(a),t=this.cache.get(r);return t?Date.now()-t.timestamp>this.ttl?(this.cache.delete(r),null):t.response:null}set(a,r){const t=this.hashRequest(a);if(this.cache.size>=this.maxSize){const n=this.cache.keys().next().value;n&&this.cache.delete(n)}this.cache.set(t,{request:t,response:r,timestamp:Date.now()})}clear(){this.cache.clear()}}class _a{constructor(a,r){this.backupProviders=[],this.circuitBreakers=new Map,this.primaryProvider=a,this.config={strategies:["retry","failover","cache","graceful-degrade"],maxRetries:3,retryDelay:1e3,backoffMultiplier:2,backupProviders:[],cacheTTL:36e5,offlineConfig:void 0,circuitBreakerThreshold:5,circuitBreakerResetTime:6e4,onFallback:void 0,...r},this.cache=new Dr(100,this.config.cacheTTL);for(const t of this.config.backupProviders||[])this.backupProviders.push(te(t));this.config.offlineConfig&&(this.offlineProvider=te(this.config.offlineConfig))}async chat(a){if(this.isCircuitOpen(this.primaryProvider.type))return this.executeWithFallback(a,new Error("Circuit breaker open"));try{const r=await this.primaryProvider.chat(a);return this.cache.set(a,r),this.resetCircuitBreaker(this.primaryProvider.type),r}catch(r){return this.recordFailure(this.primaryProvider.type),this.executeWithFallback(a,r)}}async executeWithFallback(a,r){var t,n;for(const s of this.config.strategies)try{const l=await this.executeStrategy(s,a,r);if(l)return(n=(t=this.config).onFallback)==null||n.call(t,s,r),l}catch{}throw new Error(`All fallback strategies failed. Original error: ${r.message}`)}async executeStrategy(a,r,t){switch(a){case"retry":return this.retryStrategy(r);case"failover":return this.failoverStrategy(r);case"cache":return this.cacheStrategy(r);case"offline":return this.offlineStrategy(r);case"graceful-degrade":return this.gracefulDegradeStrategy(r,t);case"circuit-breaker":return this.openCircuitBreaker(this.primaryProvider.type),null;default:return null}}async retryStrategy(a){let r=this.config.retryDelay;for(let t=0;t<this.config.maxRetries;t++){await this.delay(r);try{const n=await this.primaryProvider.chat(a);return this.cache.set(a,n),n}catch{r*=this.config.backoffMultiplier}}return null}async failoverStrategy(a){for(const r of this.backupProviders)if(!this.isCircuitOpen(r.type))try{const t=await r.chat(a);return this.cache.set(a,t),t}catch{this.recordFailure(r.type)}return null}cacheStrategy(a){const r=this.cache.get(a);return r?{...r,id:`cached-${r.id}`}:null}async offlineStrategy(a){if(!this.offlineProvider)return null;try{return await this.offlineProvider.chat(a)}catch{return null}}gracefulDegradeStrategy(a,r){const t=[...a.messages].reverse().find(n=>n.role==="user");return{id:`degraded-${Date.now()}`,model:"fallback",choices:[{index:0,message:{role:"assistant",content:this.generateDegradedResponse((t==null?void 0:t.content)||"",r)},finishReason:"stop"}],usage:{promptTokens:0,completionTokens:0,totalTokens:0}}}generateDegradedResponse(a,r){return a.toLowerCase().includes("filter")||a.toLowerCase().includes("show")?JSON.stringify({filters:[],logic:"and"}):a.toLowerCase().includes("form")||a.toLowerCase().includes("create")?JSON.stringify({title:"Form",fields:[{id:"field1",type:"text",label:"Field 1"}]}):a.toLowerCase().includes("chart")||a.toLowerCase().includes("graph")?JSON.stringify({type:"bar",title:"Chart",data:{source:"data"}}):`I'm sorry, I couldn't process your request at this time. The service is temporarily unavailable. Please try again later or contact support. (Error: ${r.message.substring(0,50)})`}isCircuitOpen(a){const r=this.circuitBreakers.get(a);return r&&r.isOpen?Date.now()-r.lastFailure>this.config.circuitBreakerResetTime?(this.resetCircuitBreaker(a),!1):!0:!1}recordFailure(a){const r=this.circuitBreakers.get(a)||{failures:0,lastFailure:0,isOpen:!1};r.failures++,r.lastFailure=Date.now(),r.failures>=this.config.circuitBreakerThreshold&&(r.isOpen=!0),this.circuitBreakers.set(a,r)}openCircuitBreaker(a){this.circuitBreakers.set(a,{failures:this.config.circuitBreakerThreshold,lastFailure:Date.now(),isOpen:!0})}resetCircuitBreaker(a){this.circuitBreakers.delete(a)}delay(a){return new Promise(r=>setTimeout(r,a))}addBackupProvider(a){this.backupProviders.push(a)}setOfflineProvider(a){this.offlineProvider=a}clearCache(){this.cache.clear()}resetAllCircuitBreakers(){this.circuitBreakers.clear()}getCircuitBreakerStatus(){const a={};for(const[r,t]of this.circuitBreakers)a[r]={...t};return a}async healthCheck(){const a={};a[this.primaryProvider.type]=await this.primaryProvider.healthCheck();for(const r of this.backupProviders)a[`backup-${r.type}`]=await r.healthCheck();return this.offlineProvider&&(a.offline=await this.offlineProvider.healthCheck()),a}}function wa(i,a){const r=te(i);return new _a(r,a)}function Hr(i,a){const r={strategies:["retry","failover","cache","graceful-degrade"],maxRetries:3,retryDelay:1e3,backoffMultiplier:2,backupProviders:a?[a]:[],circuitBreakerThreshold:5,circuitBreakerResetTime:6e4};return typeof window>"u"&&(r.offlineConfig={type:"ollama",model:"llama3"}),wa(i,r)}function ja(i){const{columns:a,config:r,onFilterGenerated:t,onSortGenerated:n,onError:s}=i,l=Q(),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(null),[S,P]=c.useState([]),k=c.useRef(null),$=r||(l==null?void 0:l.config),g=c.useMemo(()=>a.map(m=>({id:m.id,label:m.label,type:m.type,...m.options?{options:m.options}:{}})),[a]),d=c.useCallback(async m=>{var x;if(!$){const p="AI not configured. Provide config or wrap in NiceAIProvider.";return s==null||s(p),{type:"filter",error:p}}f(!0),y(m);const v=performance.now();(x=k.current)==null||x.abort(),k.current=new AbortController;try{const p=G($),_=m.toLowerCase(),M=_.includes("sort")||_.includes("order")||_.includes("arrange")||_.includes("by highest")||_.includes("by lowest"),R=_.includes("show")||_.includes("find")||_.includes("filter")||_.includes("where")||_.includes("with")||_.includes("only")||!M,T={type:"combined"};if(R){const u=ae(ce,{columns:g,query:m}),b=await p.chat({messages:[{role:"system",content:u.system},{role:"user",content:u.user}],temperature:.2,maxTokens:512}),z=Br(b);z&&(T.filterConfig=z,T.type="filter",t==null||t(z))}if(M){const u=ae(oe,{columns:g,query:m}),b=await p.chat({messages:[{role:"system",content:u.system},{role:"user",content:u.user}],temperature:.1,maxTokens:256}),z=Fr(b);z&&(T.sortConfig=z,T.type=T.filterConfig?"combined":"sort",n==null||n(z))}return T.latencyMs=performance.now()-v,C(T),P(u=>[...u.slice(-9),{query:m,result:T}]),T}catch(p){const _=p instanceof Error?p.message:"AI request failed",M={type:"filter",error:_,latencyMs:performance.now()-v};return C(M),s==null||s(_),M}finally{f(!1)}},[$,g,t,n,s]),j=c.useCallback(()=>{y(null),C(null)},[]),N=c.useCallback(()=>{var m;(m=k.current)==null||m.abort(),f(!1)},[]);return c.useEffect(()=>()=>{var m;(m=k.current)==null||m.abort()},[]),{processQuery:d,loading:o,lastQuery:h,lastResult:w,history:S,clearResults:j,abort:N,isConfigured:!!$}}function Br(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.filters&&Array.isArray(o.filters))return{filters:o.filters,logic:o.logic||"and",confidence:o.confidence,explanation:o.explanation}}catch{}return null}function Fr(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.sort&&Array.isArray(o.sort))return{sort:o.sort,confidence:o.confidence}}catch{}return null}function Jr({columns:i,config:a,onFilter:r,onSort:t,placeholder:n='Ask AI to filter or sort data... (e.g., "show orders from last week")',showHistory:s=!0,showSuggestions:l=!0,className:o,style:f}){const[h,y]=c.useState(""),[w,C]=c.useState(!1),S=c.useRef(null),{processQuery:P,loading:k,lastResult:$,history:g,isConfigured:d}=ja({columns:i,config:a,onFilterGenerated:r,onSortGenerated:t}),j=c.useMemo(()=>{if(!l||i.length===0)return[];const p=[],_=i.filter(u=>u.type==="string");_.length>0&&p.push(`Show ${_[0].label}s containing "example"`);const M=i.filter(u=>u.type==="number");M.length>0&&(p.push(`${M[0].label} greater than 100`),p.push(`Sort by highest ${M[0].label}`));const R=i.filter(u=>u.type==="date");R.length>0&&(p.push(`${R[0].label} in the last 7 days`),p.push(`Sort by newest ${R[0].label}`));const T=i.filter(u=>{var b;return u.type==="enum"&&((b=u.options)==null?void 0:b.length)});return T.length>0&&T[0].options&&p.push(`Where ${T[0].label} is ${T[0].options[0]}`),p.slice(0,5)},[i,l]),N=async()=>{!h.trim()||k||(await P(h.trim()),C(!1))},m=p=>{p.key==="Enter"?(p.preventDefault(),N()):p.key==="Escape"&&C(!1)},v=p=>{var _;y(p),C(!1),(_=S.current)==null||_.focus()},x=p=>{y(p),C(!1),P(p)};return d?e.jsxs("div",{className:`nice-datagrid-ai ${o||""}`,style:f,children:[e.jsxs("div",{className:"nice-datagrid-ai__input-wrapper",children:[e.jsx("span",{className:"nice-datagrid-ai__icon",children:e.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.94-.49-7-3.85-7-7.93s3.05-7.44 7-7.93v15.86zm2-15.86c1.03.13 2 .45 2.87.93H13v-.93zM13 7h5.24c.25.31.48.65.68 1H13V7zm0 3h6.74c.08.33.15.66.19 1H13v-1zm0 9.93V19h2.87c-.87.48-1.84.8-2.87.93zM18.24 17H13v-1h5.92c-.2.35-.43.69-.68 1zm1.5-3H13v-1h6.93c-.04.34-.11.67-.19 1z"})})}),e.jsx("input",{ref:S,type:"text",value:h,onChange:p=>y(p.target.value),onKeyDown:m,onFocus:()=>C(!0),onBlur:()=>setTimeout(()=>C(!1),200),placeholder:n,className:"nice-datagrid-ai__input",disabled:k,"aria-label":"AI query input"}),k?e.jsx("span",{className:"nice-datagrid-ai__spinner"}):e.jsx("button",{type:"button",onClick:N,className:"nice-datagrid-ai__submit",disabled:!h.trim(),"aria-label":"Submit query",children:e.jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:e.jsx("path",{d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})})})]}),w&&(j.length>0||s&&g.length>0)&&e.jsxs("div",{className:"nice-datagrid-ai__dropdown",children:[l&&j.length>0&&e.jsxs("div",{className:"nice-datagrid-ai__section",children:[e.jsx("div",{className:"nice-datagrid-ai__section-title",children:"Suggestions"}),j.map((p,_)=>e.jsxs("button",{type:"button",className:"nice-datagrid-ai__item",onClick:()=>v(p),children:[e.jsx("span",{className:"nice-datagrid-ai__item-icon",children:"💡"}),p]},_))]}),s&&g.length>0&&e.jsxs("div",{className:"nice-datagrid-ai__section",children:[e.jsx("div",{className:"nice-datagrid-ai__section-title",children:"Recent"}),g.slice(-5).reverse().map((p,_)=>e.jsxs("button",{type:"button",className:"nice-datagrid-ai__item",onClick:()=>x(p.query),children:[e.jsx("span",{className:"nice-datagrid-ai__item-icon",children:"🕐"}),p.query,p.result.error&&e.jsx("span",{className:"nice-datagrid-ai__item-error",children:"⚠️"})]},_))]})]}),$&&!$.error&&e.jsxs("div",{className:"nice-datagrid-ai__result",children:[$.filterConfig&&e.jsxs("span",{className:"nice-datagrid-ai__badge nice-datagrid-ai__badge--filter",children:[$.filterConfig.filters.length," filter",$.filterConfig.filters.length!==1?"s":""," applied"]}),$.sortConfig&&e.jsxs("span",{className:"nice-datagrid-ai__badge nice-datagrid-ai__badge--sort",children:["Sorted by ",$.sortConfig.sort.map(p=>p.column).join(", ")]}),$.latencyMs&&e.jsxs("span",{className:"nice-datagrid-ai__latency",children:[Math.round($.latencyMs),"ms"]})]}),($==null?void 0:$.error)&&e.jsx("div",{className:"nice-datagrid-ai__error",children:$.error}),e.jsx("style",{children:`
|
|
382
382
|
.nice-datagrid-ai {
|
|
383
383
|
position: relative;
|
|
384
384
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
@@ -560,7 +560,7 @@ Provide summary and insights:`,variables:[{name:"data",description:"Data to summ
|
|
|
560
560
|
border-radius: var(--nice-radius-sm, 4px);
|
|
561
561
|
font-size: 13px;
|
|
562
562
|
}
|
|
563
|
-
`})]}):e.jsx("div",{className:`nice-datagrid-ai nice-datagrid-ai--disabled ${o||""}`,style:f,children:e.jsx("input",{type:"text",placeholder:"AI not configured",disabled:!0,className:"nice-datagrid-ai__input"})})}function ka(i={}){const{config:a,schema:r,context:t,onFormGenerated:n,onError:s}=i,l=Q(),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(null),[S,P]=c.useState([]),k=c.useRef(null),$=a||(l==null?void 0:l.config),g=c.useCallback(async m=>{var x,p,_;if(!$){const M="AI not configured. Provide config or wrap in NiceAIProvider.";return s==null||s(M),{error:M}}f(!0),y(m);const v=performance.now();(x=k.current)==null||x.abort(),k.current=new AbortController;try{const M=G($),R=ae(le,{description:m,schema:r?JSON.stringify(r,null,2):void 0,context:t}),T=await M.chat({messages:[{role:"system",content:R.system},{role:"user",content:R.user}],temperature:.5,maxTokens:2048}),u=Ur(T),b={config:u||void 0,rawResponse:(_=(p=T.choices[0])==null?void 0:p.message)==null?void 0:_.content,latencyMs:performance.now()-v,error:u?void 0:"Failed to parse form configuration"};return u&&(n==null||n(u)),C(b),P(
|
|
563
|
+
`})]}):e.jsx("div",{className:`nice-datagrid-ai nice-datagrid-ai--disabled ${o||""}`,style:f,children:e.jsx("input",{type:"text",placeholder:"AI not configured",disabled:!0,className:"nice-datagrid-ai__input"})})}function ka(i={}){const{config:a,schema:r,context:t,onFormGenerated:n,onError:s}=i,l=Q(),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(null),[S,P]=c.useState([]),k=c.useRef(null),$=a||(l==null?void 0:l.config),g=c.useCallback(async m=>{var x,p,_;if(!$){const M="AI not configured. Provide config or wrap in NiceAIProvider.";return s==null||s(M),{error:M}}f(!0),y(m);const v=performance.now();(x=k.current)==null||x.abort(),k.current=new AbortController;try{const M=G($),R=ae(le,{description:m,schema:r?JSON.stringify(r,null,2):void 0,context:t}),T=await M.chat({messages:[{role:"system",content:R.system},{role:"user",content:R.user}],temperature:.5,maxTokens:2048}),u=Ur(T),b={config:u||void 0,rawResponse:(_=(p=T.choices[0])==null?void 0:p.message)==null?void 0:_.content,latencyMs:performance.now()-v,error:u?void 0:"Failed to parse form configuration"};return u&&(n==null||n(u)),C(b),P(z=>[...z.slice(-9),{description:m,result:b}]),b}catch(M){const R=M instanceof Error?M.message:"AI request failed",T={error:R,latencyMs:performance.now()-v};return C(T),s==null||s(R),T}finally{f(!1)}},[$,r,t,n,s]),d=c.useCallback(async m=>{if(!(w!=null&&w.config))return{error:"No form to refine. Generate a form first."};const v=`
|
|
564
564
|
Modify this existing form based on the following instructions:
|
|
565
565
|
|
|
566
566
|
Current form: ${JSON.stringify(w.config,null,2)}
|
|
@@ -892,7 +892,7 @@ Provide summary and insights:`,variables:[{name:"data",description:"Data to summ
|
|
|
892
892
|
cursor: not-allowed;
|
|
893
893
|
opacity: 0.7;
|
|
894
894
|
}
|
|
895
|
-
`})]})}function Na(i={}){const{config:a,dataFields:r,context:t,onChartGenerated:n,onError:s}=i,l=Q(),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(null),[S,P]=c.useState([]),k=c.useRef(null),$=a||(l==null?void 0:l.config),g=c.useMemo(()=>{if(r)return r.map(v=>{var x;return{name:v.name,type:v.type,label:v.label||v.name,...(x=v.sampleValues)!=null&&x.length?{samples:v.sampleValues.slice(0,3)}:{}}})},[r]),d=c.useCallback(async v=>{var p,_,M;if(!$){const R="AI not configured. Provide config or wrap in NiceAIProvider.";return s==null||s(R),{error:R}}f(!0),y(v);const x=performance.now();(p=k.current)==null||p.abort(),k.current=new AbortController;try{const R=G($),T=ae(de,{request:v,data:g?JSON.stringify(g,null,2):void 0,context:t}),u=await R.chat({messages:[{role:"system",content:T.system},{role:"user",content:T.user}],temperature:.4,maxTokens:1024}),b=Gr(u),
|
|
895
|
+
`})]})}function Na(i={}){const{config:a,dataFields:r,context:t,onChartGenerated:n,onError:s}=i,l=Q(),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState(null),[S,P]=c.useState([]),k=c.useRef(null),$=a||(l==null?void 0:l.config),g=c.useMemo(()=>{if(r)return r.map(v=>{var x;return{name:v.name,type:v.type,label:v.label||v.name,...(x=v.sampleValues)!=null&&x.length?{samples:v.sampleValues.slice(0,3)}:{}}})},[r]),d=c.useCallback(async v=>{var p,_,M;if(!$){const R="AI not configured. Provide config or wrap in NiceAIProvider.";return s==null||s(R),{error:R}}f(!0),y(v);const x=performance.now();(p=k.current)==null||p.abort(),k.current=new AbortController;try{const R=G($),T=ae(de,{request:v,data:g?JSON.stringify(g,null,2):void 0,context:t}),u=await R.chat({messages:[{role:"system",content:T.system},{role:"user",content:T.user}],temperature:.4,maxTokens:1024}),b=Gr(u),z={config:b||void 0,rawResponse:(M=(_=u.choices[0])==null?void 0:_.message)==null?void 0:M.content,latencyMs:performance.now()-x,error:b?void 0:"Failed to parse chart configuration",suggestions:Vr(b)};return b&&(n==null||n(b)),C(z),P(D=>[...D.slice(-9),{request:v,result:z}]),z}catch(R){const T=R instanceof Error?R.message:"AI request failed",u={error:T,latencyMs:performance.now()-x};return C(u),s==null||s(T),u}finally{f(!1)}},[$,g,t,n,s]),j=c.useCallback(async()=>w!=null&&w.config?{line:["area","bar","scatter"],area:["line","bar","column"],bar:["column","line","pie"],column:["bar","line","area"],pie:["donut","bar","treemap"],donut:["pie","funnel","gauge"],scatter:["bubble","line","heatmap"],bubble:["scatter","treemap"],heatmap:["treemap","bar"],treemap:["pie","heatmap","bar"],funnel:["bar","donut"],radar:["bar","polar"],polar:["radar","pie"],gauge:["donut","bar"],candlestick:["line","area"],sankey:["funnel","bar"]}[w.config.type]||[]:[],[w]),N=c.useCallback(()=>{y(null),C(null)},[]),m=c.useCallback(()=>{var v;(v=k.current)==null||v.abort(),f(!1)},[]);return c.useEffect(()=>()=>{var v;(v=k.current)==null||v.abort()},[]),{generateChart:d,suggestAlternatives:j,loading:o,lastRequest:h,lastResult:w,history:S,clearResults:N,abort:m,isConfigured:!!$}}function Gr(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.type)return{type:o.type,title:o.title,subtitle:o.subtitle,data:o.data||{},xAxis:o.xAxis,yAxis:o.yAxis,options:o.options}}catch{}return null}function Vr(i){var r;if(!i)return[];const a=[];return(i.type==="line"||i.type==="bar")&&(a.push("Add trend line for forecasting"),a.push("Stack series for comparison")),(i.type==="pie"||i.type==="donut")&&(a.push("Convert to bar chart for better comparison"),a.push("Add data labels for percentages")),(r=i.options)!=null&&r.animation||a.push("Enable animations for better UX"),a.slice(0,3)}function Kr({config:i,dataFields:a,context:r,onGenerate:t,placeholder:n='Describe the chart you want... (e.g., "Show monthly sales as a line chart")',showTypeSelector:s=!0,showPreview:l=!0,className:o,style:f,renderChart:h}){var _;const[y,w]=c.useState(""),[C,S]=c.useState(null),P=c.useRef(null),{generateChart:k,suggestAlternatives:$,loading:g,lastResult:d,isConfigured:j}=Na({config:i,dataFields:a,context:r,onChartGenerated:t}),N=[{type:"line",icon:"📈",label:"Line"},{type:"bar",icon:"📊",label:"Bar"},{type:"pie",icon:"🥧",label:"Pie"},{type:"area",icon:"📉",label:"Area"},{type:"scatter",icon:"⚬",label:"Scatter"},{type:"donut",icon:"🍩",label:"Donut"},{type:"heatmap",icon:"🔥",label:"Heatmap"},{type:"funnel",icon:"⏬",label:"Funnel"},{type:"gauge",icon:"⏱️",label:"Gauge"},{type:"radar",icon:"🎯",label:"Radar"}],m=async()=>{if(!y.trim()||g)return;const M=C?`Create a ${C} chart: ${y}`:y;await k(M)},v=M=>{M.key==="Enter"&&(M.preventDefault(),m())},x=M=>{S(C===M?null:M)},p=async M=>{if(!(d!=null&&d.config))return;const R={...d.config,type:M};t==null||t(R)};return j?e.jsxs("div",{className:`nice-chart-ai ${o||""}`,style:f,children:[s&&e.jsx("div",{className:"nice-chart-ai__types",children:N.map(({type:M,icon:R,label:T})=>e.jsxs("button",{type:"button",className:`nice-chart-ai__type ${C===M?"nice-chart-ai__type--selected":""}`,onClick:()=>x(M),title:T,children:[e.jsx("span",{className:"nice-chart-ai__type-icon",children:R}),e.jsx("span",{className:"nice-chart-ai__type-label",children:T})]},M))}),e.jsxs("div",{className:"nice-chart-ai__input-wrapper",children:[e.jsx("span",{className:"nice-chart-ai__icon",children:"📊"}),e.jsx("input",{ref:P,type:"text",value:y,onChange:M=>w(M.target.value),onKeyDown:v,placeholder:n,className:"nice-chart-ai__input",disabled:g}),g?e.jsx("span",{className:"nice-chart-ai__spinner"}):e.jsx("button",{type:"button",onClick:m,className:"nice-chart-ai__submit",disabled:!y.trim(),children:"Generate"})]}),a&&a.length>0&&e.jsxs("div",{className:"nice-chart-ai__fields",children:[e.jsx("span",{className:"nice-chart-ai__fields-label",children:"Available fields:"}),a.map(M=>e.jsx("span",{className:"nice-chart-ai__field-badge",title:M.type,children:M.label||M.name},M.name))]}),d&&e.jsx("div",{className:"nice-chart-ai__result",children:d.error?e.jsx("div",{className:"nice-chart-ai__error",children:d.error}):d.config&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-chart-ai__result-header",children:[e.jsxs("div",{className:"nice-chart-ai__result-info",children:[e.jsxs("span",{className:"nice-chart-ai__chart-type",children:[(_=N.find(M=>M.type===d.config.type))==null?void 0:_.icon,d.config.type.charAt(0).toUpperCase()+d.config.type.slice(1)," ","Chart"]}),d.config.title&&e.jsx("span",{className:"nice-chart-ai__chart-title",children:d.config.title})]}),d.latencyMs&&e.jsxs("span",{className:"nice-chart-ai__latency",children:[Math.round(d.latencyMs),"ms"]}),e.jsx("button",{type:"button",onClick:()=>t==null?void 0:t(d.config),className:"nice-chart-ai__use-btn",children:"Use This Chart"})]}),e.jsxs("div",{className:"nice-chart-ai__alternatives",children:[e.jsx("span",{children:"Try also:"}),N.filter(M=>M.type!==d.config.type).slice(0,4).map(({type:M,icon:R})=>e.jsx("button",{type:"button",className:"nice-chart-ai__alternative",onClick:()=>p(M),title:`Convert to ${M}`,children:R},M))]}),l&&e.jsx("div",{className:"nice-chart-ai__preview",children:h?h(d.config):e.jsx(Yr,{config:d.config})}),e.jsxs("details",{className:"nice-chart-ai__json",children:[e.jsx("summary",{children:"View Configuration"}),e.jsx("pre",{children:JSON.stringify(d.config,null,2)})]})]})}),e.jsx("style",{children:`
|
|
896
896
|
.nice-chart-ai {
|
|
897
897
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
898
898
|
}
|
|
@@ -1197,11 +1197,11 @@ Provide summary and insights:`,variables:[{name:"data",description:"Data to summ
|
|
|
1197
1197
|
height: 12px;
|
|
1198
1198
|
border-radius: var(--nice-radius-sm, 2px);
|
|
1199
1199
|
}
|
|
1200
|
-
`})]})}function Ca(i={}){const{config:a,language:r="typescript",context:t,maxSuggestions:n=3,debounceMs:s=300,onSuggestion:l,onError:o}=i,f=Q(),[h,y]=c.useState(!1),[w,C]=c.useState([]),[S,P]=c.useState(-1),k=c.useRef(null),$=c.useRef(null),g=a||(f==null?void 0:f.config),d=c.useCallback(async(T,u)=>{var
|
|
1201
|
-
`),
|
|
1200
|
+
`})]})}function Ca(i={}){const{config:a,language:r="typescript",context:t,maxSuggestions:n=3,debounceMs:s=300,onSuggestion:l,onError:o}=i,f=Q(),[h,y]=c.useState(!1),[w,C]=c.useState([]),[S,P]=c.useState(-1),k=c.useRef(null),$=c.useRef(null),g=a||(f==null?void 0:f.config),d=c.useCallback(async(T,u)=>{var z,D,J;if(!g)return{suggestions:[],error:"AI not configured"};y(!0),(z=k.current)==null||z.abort(),k.current=new AbortController;const b=performance.now();try{const Y=G(g),V=T.split(`
|
|
1201
|
+
`),I=V[u.line]||"",F=I.substring(0,u.column),U=I.substring(u.column),W=V.slice(Math.max(0,u.line-20),u.line).join(`
|
|
1202
1202
|
`),q=V.slice(u.line+1,u.line+10).join(`
|
|
1203
|
-
`),Z=ae(ue,{language:r,code_context:W,prefix:F,suffix:U,context_after:q,context:t}),ee=await Y.chat({messages:[{role:"system",content:Z.system},{role:"user",content:Z.user}],temperature:.2,maxTokens:512}),A=Xr(ee,u,n),L={suggestions:A,rawResponse:(J=(D=ee.choices[0])==null?void 0:D.message)==null?void 0:J.content,latencyMs:performance.now()-b};return C(A),P(A.length>0?0:-1),l==null||l(A),L}catch(Y){const V=Y instanceof Error?Y.message:"Completion failed";return o==null||o(V),{suggestions:[],error:V,latencyMs:performance.now()-b}}finally{y(!1)}},[g,r,t,n,l,o]),j=c.useCallback((T,u)=>{$.current&&clearTimeout($.current),$.current=setTimeout(()=>{d(T,u)},s)},[d,s]),N=c.useCallback(async T=>{if(!g)return null;y(!0);try{const b=await G(g).chat({messages:[{role:"system",content:`You are a code explanation assistant. Explain the following ${r} code clearly and concisely. Return JSON with: { "summary": string, "details": string, "complexity": "low"|"medium"|"high", "suggestions": string[] }`},{role:"user",content:T}],temperature:.3,maxTokens:1024});return Zr(b)}catch{return null}finally{y(!1)}},[g,r]),m=c.useCallback(async T=>{if(!g)return[];y(!0);try{const b=await G(g).chat({messages:[{role:"system",content:`You are a code refactoring assistant. Analyze the following ${r} 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:T}],temperature:.4,maxTokens:2048});return Qr(b)}catch{return[]}finally{y(!1)}},[g,r]),v=c.useCallback(async(T,u)=>{var b,
|
|
1204
|
-
`).filter(o=>o.trim()).slice(0,r).map((o,f)=>({id:`suggestion-${Date.now()}-${f}`,text:o.trim(),type:"inline",preview:o.trim().slice(0,50),confidence:.8-f*.1,insertPosition:a}))}catch{return[]}}function Zr(i){var a,r;try{const t=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",n=t.match(/\{[\s\S]*\}/);return n?JSON.parse(n[0]):{summary:t}}catch{return null}}function Qr(i){var a,r;try{const n=(((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"").match(/\[[\s\S]*\]/);if(n)return JSON.parse(n[0])}catch{}return[]}function ei(i){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"}[i]||"unit test"}function ai(i){return{javascript:"jsdoc",typescript:"tsdoc",python:"docstring",java:"javadoc",kotlin:"javadoc"}[i]||"jsdoc"}function ri({code:i="",language:a="typescript",config:r,onChange:t,onAcceptSuggestion:n,showToolbar:s=!0,enableInlineSuggestions:l=!0,placeholder:o="Start typing code...",className:f,style:h,renderEditor:y}){const[w,C]=c.useState(i),[S,P]=c.useState(null),[k,$]=c.useState(null),[g,d]=c.useState([]),[j,N]=c.useState(null),[m,v]=c.useState(null),x=c.useRef(null),{getCompletionsDebounced:p,suggestions:_,activeSuggestion:M,acceptSuggestion:R,dismissSuggestions:T,navigateSuggestions:u,explainCode:b,suggestRefactoring:
|
|
1203
|
+
`),Z=ae(ue,{language:r,code_context:W,prefix:F,suffix:U,context_after:q,context:t}),ee=await Y.chat({messages:[{role:"system",content:Z.system},{role:"user",content:Z.user}],temperature:.2,maxTokens:512}),A=Xr(ee,u,n),L={suggestions:A,rawResponse:(J=(D=ee.choices[0])==null?void 0:D.message)==null?void 0:J.content,latencyMs:performance.now()-b};return C(A),P(A.length>0?0:-1),l==null||l(A),L}catch(Y){const V=Y instanceof Error?Y.message:"Completion failed";return o==null||o(V),{suggestions:[],error:V,latencyMs:performance.now()-b}}finally{y(!1)}},[g,r,t,n,l,o]),j=c.useCallback((T,u)=>{$.current&&clearTimeout($.current),$.current=setTimeout(()=>{d(T,u)},s)},[d,s]),N=c.useCallback(async T=>{if(!g)return null;y(!0);try{const b=await G(g).chat({messages:[{role:"system",content:`You are a code explanation assistant. Explain the following ${r} code clearly and concisely. Return JSON with: { "summary": string, "details": string, "complexity": "low"|"medium"|"high", "suggestions": string[] }`},{role:"user",content:T}],temperature:.3,maxTokens:1024});return Zr(b)}catch{return null}finally{y(!1)}},[g,r]),m=c.useCallback(async T=>{if(!g)return[];y(!0);try{const b=await G(g).chat({messages:[{role:"system",content:`You are a code refactoring assistant. Analyze the following ${r} 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:T}],temperature:.4,maxTokens:2048});return Qr(b)}catch{return[]}finally{y(!1)}},[g,r]),v=c.useCallback(async(T,u)=>{var b,z;if(!g)return null;y(!0);try{const D=G(g),J=u||ei(r);return((z=(b=(await D.chat({messages:[{role:"system",content:`You are a testing expert. Generate comprehensive unit tests for the following ${r} code using ${J}. Include edge cases and error scenarios. Return only the test code.`},{role:"user",content:T}],temperature:.3,maxTokens:2048})).choices[0])==null?void 0:b.message)==null?void 0:z.content)||null}catch{return null}finally{y(!1)}},[g,r]),x=c.useCallback(async(T,u)=>{var b,z;if(!g)return null;y(!0);try{const D=G(g),J=u||ai(r);return((z=(b=(await D.chat({messages:[{role:"system",content:`Generate ${J} documentation for the following ${r} code. Include descriptions for parameters, return values, and examples where appropriate. Return only the documented code.`},{role:"user",content:T}],temperature:.3,maxTokens:2048})).choices[0])==null?void 0:b.message)==null?void 0:z.content)||null}catch{return null}finally{y(!1)}},[g,r]),p=c.useCallback((T=S)=>{const u=w[T];return C([]),P(-1),u},[w,S]),_=c.useCallback(()=>{C([]),P(-1)},[]),M=c.useCallback(T=>{w.length!==0&&P(u=>T==="up"?u<=0?w.length-1:u-1:u>=w.length-1?0:u+1)},[w.length]),R=c.useCallback(()=>{var T;(T=k.current)==null||T.abort(),$.current&&clearTimeout($.current),y(!1)},[]);return c.useEffect(()=>()=>{var T;(T=k.current)==null||T.abort(),$.current&&clearTimeout($.current)},[]),{getCompletions:d,getCompletionsDebounced:j,suggestions:w,activeSuggestion:S,acceptSuggestion:p,dismissSuggestions:_,navigateSuggestions:M,explainCode:N,suggestRefactoring:m,generateTests:v,generateDocs:x,loading:h,abort:R,isConfigured:!!g}}function Xr(i,a,r){var t,n;try{return(((n=(t=i.choices[0])==null?void 0:t.message)==null?void 0:n.content)||"").split(`
|
|
1204
|
+
`).filter(o=>o.trim()).slice(0,r).map((o,f)=>({id:`suggestion-${Date.now()}-${f}`,text:o.trim(),type:"inline",preview:o.trim().slice(0,50),confidence:.8-f*.1,insertPosition:a}))}catch{return[]}}function Zr(i){var a,r;try{const t=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",n=t.match(/\{[\s\S]*\}/);return n?JSON.parse(n[0]):{summary:t}}catch{return null}}function Qr(i){var a,r;try{const n=(((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"").match(/\[[\s\S]*\]/);if(n)return JSON.parse(n[0])}catch{}return[]}function ei(i){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"}[i]||"unit test"}function ai(i){return{javascript:"jsdoc",typescript:"tsdoc",python:"docstring",java:"javadoc",kotlin:"javadoc"}[i]||"jsdoc"}function ri({code:i="",language:a="typescript",config:r,onChange:t,onAcceptSuggestion:n,showToolbar:s=!0,enableInlineSuggestions:l=!0,placeholder:o="Start typing code...",className:f,style:h,renderEditor:y}){const[w,C]=c.useState(i),[S,P]=c.useState(null),[k,$]=c.useState(null),[g,d]=c.useState([]),[j,N]=c.useState(null),[m,v]=c.useState(null),x=c.useRef(null),{getCompletionsDebounced:p,suggestions:_,activeSuggestion:M,acceptSuggestion:R,dismissSuggestions:T,navigateSuggestions:u,explainCode:b,suggestRefactoring:z,generateTests:D,generateDocs:J,loading:Y,isConfigured:V}=Ca({config:r,language:a}),I=O=>{if(C(O),t==null||t(O),l&&x.current){const B=ii(x.current);p(O,B)}},F=O=>{if(_.length>0)if(O.key==="ArrowUp")O.preventDefault(),u("up");else if(O.key==="ArrowDown")O.preventDefault(),u("down");else if(O.key==="Tab"||O.key==="Enter"){if(M>=0){O.preventDefault();const B=R(M);B&&(U(B),n==null||n(B))}}else O.key==="Escape"&&T()},U=O=>{if(!x.current)return;const B=x.current,re=B.selectionStart,Ie=w.slice(0,re)+O.text+w.slice(re);C(Ie),t==null||t(Ie);const Le=re+O.text.length;setTimeout(()=>{B.focus(),B.setSelectionRange(Le,Le)},0)},W=async()=>{const O=S||w;if(!O.trim())return;v("explain");const B=await b(O);$(B)},q=async()=>{const O=S||w;if(!O.trim())return;v("refactor");const B=await z(O);d(B)},Z=async()=>{if(!w.trim())return;v("tests");const O=await D(w);N(O)},ee=async()=>{if(!w.trim())return;v("docs");const O=await J(w);N(O)},A=O=>{const B=w.replace(O.before,O.after);C(B),t==null||t(B),v(null)},L=()=>{j&&navigator.clipboard.writeText(j)},H=()=>{if(x.current){const O=x.current.selectionStart,B=x.current.selectionEnd;P(O!==B?w.slice(O,B):null)}};return V?y?e.jsx("div",{className:`nice-code-editor-ai ${f||""}`,style:h,children:y({code:w,onChange:I,suggestions:_,onAccept:O=>{const B=R(O);B&&(n==null||n(B))}})}):e.jsxs("div",{className:`nice-code-editor-ai ${f||""}`,style:h,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.jsx("button",{type:"button",onClick:W,disabled:Y||!w.trim(),title:"Explain code",children:"💡 Explain"}),e.jsx("button",{type:"button",onClick:q,disabled:Y||!w.trim(),title:"Suggest refactoring",children:"🔧 Refactor"}),e.jsx("button",{type:"button",onClick:Z,disabled:Y||!w.trim(),title:"Generate tests",children:"🧪 Tests"}),e.jsx("button",{type:"button",onClick:ee,disabled:Y||!w.trim(),title:"Generate docs",children:"📝 Docs"})]}),Y&&e.jsx("span",{className:"nice-code-editor-ai__loading",children:"Processing..."})]}),e.jsxs("div",{className:"nice-code-editor-ai__editor-wrapper",children:[e.jsx("textarea",{ref:x,value:w,onChange:O=>I(O.target.value),onKeyDown:F,onSelect:H,placeholder:o,className:"nice-code-editor-ai__textarea",spellCheck:!1}),_.length>0&&e.jsxs("div",{className:"nice-code-editor-ai__suggestions",children:[_.map((O,B)=>e.jsxs("div",{className:`nice-code-editor-ai__suggestion ${B===M?"nice-code-editor-ai__suggestion--active":""}`,onClick:()=>{const re=R(B);re&&(U(re),n==null||n(re))},children:[e.jsx("span",{className:"nice-code-editor-ai__suggestion-text",children:O.text}),e.jsxs("span",{className:"nice-code-editor-ai__suggestion-confidence",children:[Math.round(O.confidence*100),"%"]})]},O.id)),e.jsx("div",{className:"nice-code-editor-ai__suggestions-hint",children:"↑↓ navigate • Tab accept • Esc dismiss"})]})]}),m&&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:[m==="explain"&&"💡 Explanation",m==="refactor"&&"🔧 Refactoring Suggestions",m==="tests"&&"🧪 Generated Tests",m==="docs"&&"📝 Generated Documentation"]}),e.jsx("button",{type:"button",onClick:()=>v(null),children:"✕"})]}),e.jsxs("div",{className:"nice-code-editor-ai__panel-content",children:[m==="explain"&&k&&e.jsxs("div",{className:"nice-code-editor-ai__explanation",children:[e.jsx("div",{className:"nice-code-editor-ai__explanation-summary",children:k.summary}),k.details&&e.jsx("div",{className:"nice-code-editor-ai__explanation-details",children:k.details}),k.complexity&&e.jsxs("span",{className:`nice-code-editor-ai__complexity nice-code-editor-ai__complexity--${k.complexity}`,children:["Complexity: ",k.complexity]}),k.suggestions&&k.suggestions.length>0&&e.jsx("ul",{className:"nice-code-editor-ai__explanation-suggestions",children:k.suggestions.map((O,B)=>e.jsx("li",{children:O},B))})]}),m==="refactor"&&g.length>0&&e.jsx("div",{className:"nice-code-editor-ai__refactorings",children:g.map((O,B)=>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:O.title}),e.jsx("span",{className:`nice-code-editor-ai__refactoring-type nice-code-editor-ai__refactoring-type--${O.type}`,children:O.type})]}),e.jsx("p",{className:"nice-code-editor-ai__refactoring-desc",children:O.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:"Before:"}),e.jsx("pre",{children:O.before})]}),e.jsxs("div",{className:"nice-code-editor-ai__refactoring-after",children:[e.jsx("span",{children:"After:"}),e.jsx("pre",{children:O.after})]})]}),e.jsx("button",{type:"button",className:"nice-code-editor-ai__refactoring-apply",onClick:()=>A(O),children:"Apply"})]},B))}),(m==="tests"||m==="docs")&&j&&e.jsxs("div",{className:"nice-code-editor-ai__generated",children:[e.jsx("pre",{children:j}),e.jsx("button",{type:"button",onClick:L,children:"📋 Copy"})]})]})]}),e.jsx("style",{children:`
|
|
1205
1205
|
.nice-code-editor-ai {
|
|
1206
1206
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
1207
1207
|
display: flex;
|
|
@@ -1507,11 +1507,11 @@ Provide summary and insights:`,variables:[{name:"data",description:"Data to summ
|
|
|
1507
1507
|
border-radius: var(--nice-radius-md, 6px);
|
|
1508
1508
|
cursor: pointer;
|
|
1509
1509
|
}
|
|
1510
|
-
`})]}):e.jsxs("div",{className:`nice-code-editor-ai nice-code-editor-ai--disabled ${f||""}`,style:h,children:[e.jsx("p",{children:"AI not configured. Please provide config or wrap in NiceAIProvider."}),e.jsx("textarea",{value:w,onChange:O=>
|
|
1510
|
+
`})]}):e.jsxs("div",{className:`nice-code-editor-ai nice-code-editor-ai--disabled ${f||""}`,style:h,children:[e.jsx("p",{children:"AI not configured. Please provide config or wrap in NiceAIProvider."}),e.jsx("textarea",{value:w,onChange:O=>I(O.target.value),placeholder:o,className:"nice-code-editor-ai__textarea"})]})}function ii(i){const r=i.value.substring(0,i.selectionStart).split(`
|
|
1511
1511
|
`);return{line:r.length-1,column:r[r.length-1].length}}function Sa(i={}){const{config:a,context:r,existingRoles:t,existingVariables:n,onWorkflowGenerated:s,onError:l}=i,o=Q(),[f,h]=c.useState(!1),[y,w]=c.useState(null),[C,S]=c.useState([]),P=c.useRef(null),k=a||(o==null?void 0:o.config),$=c.useCallback(async v=>{var p,_,M;if(!k){const R="AI not configured";return l==null||l(R),{error:R}}h(!0);const x=performance.now();(p=P.current)==null||p.abort(),P.current=new AbortController;try{const R=G(k),T=[r,t!=null&&t.length?`Available roles: ${t.join(", ")}`:"",n!=null&&n.length?`Existing variables: ${n.join(", ")}`:""].filter(Boolean).join(`
|
|
1512
|
-
`),u=ae(pe,{description:v,context:T}),b=await R.chat({messages:[{role:"system",content:u.system},{role:"user",content:u.user}],temperature:.5,maxTokens:2048}),
|
|
1512
|
+
`),u=ae(pe,{description:v,context:T}),b=await R.chat({messages:[{role:"system",content:u.system},{role:"user",content:u.user}],temperature:.5,maxTokens:2048}),z=Fe(b),D={workflow:z||void 0,rawResponse:(M=(_=b.choices[0])==null?void 0:_.message)==null?void 0:M.content,latencyMs:performance.now()-x,error:z?void 0:"Failed to generate workflow",suggestions:ni(z)};return z&&(s==null||s(z)),w(D),S(J=>[...J.slice(-9),{request:v,result:D}]),D}catch(R){const T=R instanceof Error?R.message:"Workflow generation failed",u={error:T,latencyMs:performance.now()-x};return w(u),l==null||l(T),u}finally{h(!1)}},[k,r,t,n,s,l]),g=c.useCallback(async v=>{if(!k)return{error:"AI not configured"};h(!0);const x=performance.now();try{const _=await G(k).chat({messages:[{role:"system",content:"You are a workflow optimization expert. Analyze the following BPMN workflow and suggest improvements for efficiency, clarity, and error handling. Return the optimized workflow in JSON format with the same structure."},{role:"user",content:JSON.stringify(v,null,2)}],temperature:.4,maxTokens:2048});return{workflow:Fe(_)||void 0,latencyMs:performance.now()-x}}catch(p){return{error:p instanceof Error?p.message:"Optimization failed"}}finally{h(!1)}},[k]),d=c.useCallback(async(v,x)=>{var p,_;if(!k)return[];h(!0);try{const M=G(k),R=v.nodes.find(z=>z.id===x),b=(((_=(p=(await M.chat({messages:[{role:"system",content:'Given the current workflow state, suggest 2-3 possible next steps after the specified node. Return JSON array of nodes: [{ "id": string, "type": string, "label": string, "description": string }]'},{role:"user",content:`Workflow: ${v.name}
|
|
1513
1513
|
Current node: ${(R==null?void 0:R.label)||x}
|
|
1514
|
-
Existing nodes: ${v.nodes.map(
|
|
1514
|
+
Existing nodes: ${v.nodes.map(z=>z.label).join(", ")}`}],temperature:.6,maxTokens:512})).choices[0])==null?void 0:p.message)==null?void 0:_.content)||"").match(/\[[\s\S]*\]/);if(b)return JSON.parse(b[0])}catch{}finally{h(!1)}return[]},[k]),j=c.useCallback(async v=>{var x,p;if(!k)return[];h(!0);try{const T=(((p=(x=(await G(k).chat({messages:[{role:"system",content:'Analyze the BPMN workflow for potential issues. Check for: dead ends, unreachable nodes, missing error handling, infinite loops, unclear conditions, missing assignments. Return JSON array of issues: [{ "severity": "error"|"warning"|"info", "message": string, "nodeId": string? }]'},{role:"user",content:JSON.stringify(v,null,2)}],temperature:.3,maxTokens:1024})).choices[0])==null?void 0:x.message)==null?void 0:p.content)||"").match(/\[[\s\S]*\]/);if(T)return JSON.parse(T[0]).map(b=>`[${b.severity}] ${b.message}`)}catch{}finally{h(!1)}return[]},[k]),N=c.useCallback(()=>{w(null)},[]),m=c.useCallback(()=>{var v;(v=P.current)==null||v.abort(),h(!1)},[]);return c.useEffect(()=>()=>{var v;(v=P.current)==null||v.abort()},[]),{generateWorkflow:$,optimizeWorkflow:g,suggestNextStep:d,validateWorkflow:j,loading:f,lastResult:y,history:C,clearResults:N,abort:m,isConfigured:!!k}}function Fe(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.nodes&&Array.isArray(o.nodes)){const f=o.nodes.map((h,y)=>({...h,id:h.id||`node_${y}`,position:h.position||ti(y,o.nodes.length)}));return{id:o.id||`workflow_${Date.now()}`,name:o.name||"Generated Workflow",description:o.description,version:o.version||"1.0",nodes:f,edges:o.edges||[],lanes:o.lanes,variables:o.variables,metadata:o.metadata}}}catch{}return null}function ti(i,a){const s=Math.floor(i/5);return{x:100+i%5*200,y:100+s*100}}function ni(i){if(!i)return[];const a=[];return i.nodes.some(s=>s.type==="event-error")||a.push("Add error boundary events for critical tasks"),!i.nodes.some(s=>s.type==="gateway-parallel")&&i.nodes.length>5&&a.push("Consider parallel gateways for independent tasks"),(!i.lanes||i.lanes.length===0)&&a.push("Add swimlanes to clarify responsibilities"),i.nodes.some(s=>s.type==="event-timer")||a.push("Add timer events for SLA monitoring"),a.slice(0,3)}const si=["Employee onboarding process with HR approval","Purchase order approval with budget check","Customer support ticket escalation workflow","Document review and approval process","Leave request with manager and HR approval"];function ci({config:i,context:a,roles:r,onGenerate:t,placeholder:n='Describe the workflow process... (e.g., "Leave request with manager approval")',showExamples:s=!0,showPreview:l=!0,className:o,style:f,renderWorkflow:h}){const[y,w]=c.useState(""),[C,S]=c.useState([]),P=c.useRef(null),{generateWorkflow:k,validateWorkflow:$,loading:g,lastResult:d,isConfigured:j}=Sa({config:i,context:a,existingRoles:r,onWorkflowGenerated:t}),N=async()=>{!y.trim()||g||await k(y)},m=p=>{var _;w(p),(_=P.current)==null||_.focus()},v=async()=>{if(!(d!=null&&d.workflow))return;const p=await $(d.workflow);S(p)},x=()=>{if(!(d!=null&&d.workflow))return;const p=li(d.workflow),_=new Blob([p],{type:"application/xml"}),M=URL.createObjectURL(_),R=document.createElement("a");R.href=M,R.download=`${d.workflow.name.replace(/\s+/g,"_")}.bpmn`,R.click(),URL.revokeObjectURL(M)};return j?e.jsxs("div",{className:`nice-workflow-ai ${o||""}`,style:f,children:[e.jsxs("div",{className:"nice-workflow-ai__input-section",children:[e.jsx("textarea",{ref:P,value:y,onChange:p=>w(p.target.value),placeholder:n,className:"nice-workflow-ai__input",rows:3,disabled:g}),e.jsx("button",{type:"button",onClick:N,className:"nice-workflow-ai__submit",disabled:g||!y.trim(),children:g?e.jsx("span",{className:"nice-workflow-ai__spinner"}):"🔄 Generate Workflow"})]}),s&&e.jsxs("div",{className:"nice-workflow-ai__examples",children:[e.jsx("span",{className:"nice-workflow-ai__examples-label",children:"Try:"}),si.slice(0,3).map((p,_)=>e.jsx("button",{type:"button",className:"nice-workflow-ai__example",onClick:()=>m(p),children:p},_))]}),d&&e.jsx("div",{className:"nice-workflow-ai__result",children:d.error?e.jsx("div",{className:"nice-workflow-ai__error",children:d.error}):d.workflow&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-workflow-ai__result-header",children:[e.jsxs("div",{className:"nice-workflow-ai__workflow-info",children:[e.jsx("span",{className:"nice-workflow-ai__workflow-name",children:d.workflow.name}),d.workflow.description&&e.jsx("span",{className:"nice-workflow-ai__workflow-desc",children:d.workflow.description})]}),e.jsxs("div",{className:"nice-workflow-ai__result-meta",children:[e.jsxs("span",{className:"nice-workflow-ai__stat",children:[d.workflow.nodes.length," nodes"]}),e.jsxs("span",{className:"nice-workflow-ai__stat",children:[d.workflow.edges.length," connections"]}),d.latencyMs&&e.jsxs("span",{className:"nice-workflow-ai__latency",children:[Math.round(d.latencyMs),"ms"]})]})]}),e.jsxs("div",{className:"nice-workflow-ai__actions",children:[e.jsx("button",{type:"button",onClick:()=>t==null?void 0:t(d.workflow),children:"✅ Use Workflow"}),e.jsx("button",{type:"button",onClick:v,children:"🔍 Validate"}),e.jsx("button",{type:"button",onClick:x,children:"📥 Export BPMN"})]}),C.length>0&&e.jsxs("div",{className:"nice-workflow-ai__validation",children:[e.jsx("div",{className:"nice-workflow-ai__validation-title",children:"Validation Issues:"}),e.jsx("ul",{children:C.map((p,_)=>e.jsx("li",{className:`nice-workflow-ai__issue nice-workflow-ai__issue--${p.startsWith("[error]")?"error":p.startsWith("[warning]")?"warning":"info"}`,children:p},_))})]}),l&&e.jsx("div",{className:"nice-workflow-ai__preview",children:h?h(d.workflow):e.jsx(oi,{workflow:d.workflow})}),d.suggestions&&d.suggestions.length>0&&e.jsxs("div",{className:"nice-workflow-ai__suggestions",children:[e.jsx("span",{className:"nice-workflow-ai__suggestions-title",children:"💡 Suggestions:"}),e.jsx("ul",{children:d.suggestions.map((p,_)=>e.jsx("li",{children:p},_))})]}),e.jsxs("details",{className:"nice-workflow-ai__json",children:[e.jsx("summary",{children:"View JSON Definition"}),e.jsx("pre",{children:JSON.stringify(d.workflow,null,2)})]})]})}),e.jsx("style",{children:`
|
|
1515
1515
|
.nice-workflow-ai {
|
|
1516
1516
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
1517
1517
|
}
|
|
@@ -1873,9 +1873,9 @@ ${r}
|
|
|
1873
1873
|
${t}
|
|
1874
1874
|
</bpmn:process>
|
|
1875
1875
|
</bpmn:definitions>`}function be(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ta(i={}){const{config:a,dataSources:r,context:t,onReportGenerated:n,onError:s}=i,l=Q(),[o,f]=c.useState(!1),[h,y]=c.useState(null),[w,C]=c.useState([]),S=c.useRef(null),P=a||(l==null?void 0:l.config),k=c.useCallback(async m=>{var x,p,_;if(!P){const M="AI not configured";return s==null||s(M),{error:M}}f(!0);const v=performance.now();(x=S.current)==null||x.abort(),S.current=new AbortController;try{const M=G(P),R=r?r.map(D=>`- ${D.name} (${D.id}): ${D.fields.join(", ")}`).join(`
|
|
1876
|
-
`):void 0,T=ae(me,{description:m,data_sources:R,context:t}),u=await M.chat({messages:[{role:"system",content:T.system},{role:"user",content:T.user}],temperature:.5,maxTokens:2048}),b=di(u),
|
|
1876
|
+
`):void 0,T=ae(me,{description:m,data_sources:R,context:t}),u=await M.chat({messages:[{role:"system",content:T.system},{role:"user",content:T.user}],temperature:.5,maxTokens:2048}),b=di(u),z={layout:b||void 0,rawResponse:(_=(p=u.choices[0])==null?void 0:p.message)==null?void 0:_.content,latencyMs:performance.now()-v,error:b?void 0:"Failed to generate report layout",suggestions:ui(b)};return b&&(n==null||n(b)),y(z),C(D=>[...D.slice(-9),{request:m,result:z}]),z}catch(M){const R=M instanceof Error?M.message:"Report generation failed",T={error:R,latencyMs:performance.now()-v};return y(T),s==null||s(R),T}finally{f(!1)}},[P,r,t,n,s]),$=c.useCallback(async m=>{var v,x;if(!P)return[];f(!0);try{const R=(((x=(v=(await G(P).chat({messages:[{role:"system",content:"Given the existing report layout, suggest 2-3 additional sections that would enhance it. Return JSON array of sections with: id, type, title, order, config."},{role:"user",content:`Report: ${m.name}
|
|
1877
1877
|
Existing sections: ${m.sections.map(T=>T.type).join(", ")}`}],temperature:.6,maxTokens:1024})).choices[0])==null?void 0:v.message)==null?void 0:x.content)||"").match(/\[[\s\S]*\]/);if(R)return JSON.parse(R[0])}catch{}finally{f(!1)}return[]},[P]),g=c.useCallback(async m=>{var v,x;if(!P)return null;f(!0);try{return((x=(v=(await G(P).chat({messages:[{role:"system",content:"Generate a concise executive summary (2-3 paragraphs) based on the provided data. Highlight key metrics, trends, and actionable insights."},{role:"user",content:JSON.stringify(m,null,2)}],temperature:.5,maxTokens:512})).choices[0])==null?void 0:v.message)==null?void 0:x.content)||null}catch{return null}finally{f(!1)}},[P]),d=c.useCallback(async(m,v)=>{var x,p,_;if(!P)return"bar";try{const M=G(P),R=m.slice(0,5),u=(_=(p=(x=(await M.chat({messages:[{role:"system",content:"Based on the data sample and description, recommend the best chart type. Return only the chart type: line, bar, pie, donut, area, column, scatter, combo, gauge, or heatmap."},{role:"user",content:`Data: ${JSON.stringify(R)}
|
|
1878
|
-
Purpose: ${v}`}],temperature:.3,maxTokens:20})).choices[0])==null?void 0:x.message)==null?void 0:p.content)==null?void 0:_.toLowerCase().trim();return["line","bar","pie","donut","area","column","scatter","combo","gauge","heatmap"].find(
|
|
1878
|
+
Purpose: ${v}`}],temperature:.3,maxTokens:20})).choices[0])==null?void 0:x.message)==null?void 0:p.content)==null?void 0:_.toLowerCase().trim();return["line","bar","pie","donut","area","column","scatter","combo","gauge","heatmap"].find(z=>u==null?void 0:u.includes(z))||"bar"}catch{return"bar"}},[P]),j=c.useCallback(()=>{y(null)},[]),N=c.useCallback(()=>{var m;(m=S.current)==null||m.abort(),f(!1)},[]);return c.useEffect(()=>()=>{var m;(m=S.current)==null||m.abort()},[]),{generateReport:k,suggestSections:$,generateSummary:g,suggestChartType:d,loading:o,lastResult:h,history:w,clearResults:j,abort:N,isConfigured:!!P}}function di(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.sections&&Array.isArray(o.sections)){const f=o.sections.map((h,y)=>({...h,id:h.id||`section_${y}`,order:h.order??y,config:h.config||{}}));return{id:o.id||`report_${Date.now()}`,name:o.name||"Generated Report",description:o.description,orientation:o.orientation||"portrait",pageSize:o.pageSize||"A4",margins:o.margins||{top:20,right:20,bottom:20,left:20},sections:f,dataSources:o.dataSources,parameters:o.parameters,styles:o.styles}}}catch{}return null}function ui(i){if(!i)return[];const a=[],r=new Set(i.sections.map(t=>t.type));return r.has("summary")||a.push("Add an executive summary for quick insights"),r.has("kpi")||a.push("Include KPI cards for key metrics"),r.has("chart")||a.push("Add visualizations to make data more accessible"),r.has("footer")||a.push("Add a footer with page numbers and date"),i.sections.length>5&&!r.has("toc")&&a.push("Consider adding a table of contents"),a.slice(0,3)}const pi=[{icon:"📊",name:"Sales Report",prompt:"Monthly sales report with revenue KPIs, sales by region chart, and top products table"},{icon:"📈",name:"Financial Summary",prompt:"Quarterly financial summary with P&L, cash flow chart, and expense breakdown"},{icon:"👥",name:"HR Dashboard",prompt:"Employee report with headcount KPIs, department breakdown, and turnover trends"},{icon:"📦",name:"Inventory Report",prompt:"Inventory status report with stock levels, low stock alerts, and turnover analysis"},{icon:"🎯",name:"KPI Dashboard",prompt:"Executive KPI dashboard with performance metrics, trends, and target comparison"}];function mi({config:i,dataSources:a,context:r,onGenerate:t,placeholder:n='Describe the report you need... (e.g., "Monthly sales report with KPIs and charts")',showTemplates:s=!0,showPreview:l=!0,className:o,style:f,renderReport:h}){const[y,w]=c.useState(""),C=c.useRef(null),{generateReport:S,loading:P,lastResult:k,isConfigured:$}=Ta({config:i,dataSources:a,context:r,onReportGenerated:t}),g=async()=>{!y.trim()||P||await S(y)},d=N=>{var m;w(N.prompt),(m=C.current)==null||m.focus()},j=()=>{if(!(k!=null&&k.layout))return;const N=JSON.stringify(k.layout,null,2),m=new Blob([N],{type:"application/json"}),v=URL.createObjectURL(m),x=document.createElement("a");x.href=v,x.download=`${k.layout.name.replace(/\s+/g,"_")}.json`,x.click(),URL.revokeObjectURL(v)};return $?e.jsxs("div",{className:`nice-report-ai ${o||""}`,style:f,children:[s&&e.jsx("div",{className:"nice-report-ai__templates",children:pi.map((N,m)=>e.jsxs("button",{type:"button",className:"nice-report-ai__template",onClick:()=>d(N),children:[e.jsx("span",{className:"nice-report-ai__template-icon",children:N.icon}),e.jsx("span",{className:"nice-report-ai__template-name",children:N.name})]},m))}),e.jsxs("div",{className:"nice-report-ai__input-section",children:[e.jsx("textarea",{ref:C,value:y,onChange:N=>w(N.target.value),placeholder:n,className:"nice-report-ai__input",rows:3,disabled:P}),e.jsx("button",{type:"button",onClick:g,className:"nice-report-ai__submit",disabled:P||!y.trim(),children:P?e.jsx("span",{className:"nice-report-ai__spinner"}):"📄 Generate Report"})]}),a&&a.length>0&&e.jsxs("div",{className:"nice-report-ai__datasources",children:[e.jsx("span",{className:"nice-report-ai__datasources-label",children:"Available data:"}),a.map(N=>e.jsx("span",{className:"nice-report-ai__datasource",children:N.name},N.id))]}),k&&e.jsx("div",{className:"nice-report-ai__result",children:k.error?e.jsx("div",{className:"nice-report-ai__error",children:k.error}):k.layout&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-report-ai__result-header",children:[e.jsxs("div",{className:"nice-report-ai__report-info",children:[e.jsx("span",{className:"nice-report-ai__report-name",children:k.layout.name}),k.layout.description&&e.jsx("span",{className:"nice-report-ai__report-desc",children:k.layout.description})]}),e.jsxs("div",{className:"nice-report-ai__result-meta",children:[e.jsxs("span",{className:"nice-report-ai__stat",children:[k.layout.sections.length," sections"]}),e.jsxs("span",{className:"nice-report-ai__stat",children:[k.layout.pageSize," ",k.layout.orientation]}),k.latencyMs&&e.jsxs("span",{className:"nice-report-ai__latency",children:[Math.round(k.latencyMs),"ms"]})]})]}),e.jsxs("div",{className:"nice-report-ai__actions",children:[e.jsx("button",{type:"button",onClick:()=>t==null?void 0:t(k.layout),children:"✅ Use Report"}),e.jsx("button",{type:"button",onClick:j,children:"📥 Export JSON"})]}),e.jsxs("div",{className:"nice-report-ai__sections",children:[e.jsx("div",{className:"nice-report-ai__sections-title",children:"Report Structure:"}),e.jsx("div",{className:"nice-report-ai__sections-list",children:k.layout.sections.map((N,m)=>e.jsxs("div",{className:"nice-report-ai__section",children:[e.jsx("span",{className:"nice-report-ai__section-number",children:m+1}),e.jsx("span",{className:"nice-report-ai__section-icon",children:Aa(N.type)}),e.jsx("span",{className:"nice-report-ai__section-type",children:N.type}),N.title&&e.jsx("span",{className:"nice-report-ai__section-title",children:N.title})]},N.id))})]}),l&&e.jsx("div",{className:"nice-report-ai__preview",children:h?h(k.layout):e.jsx(fi,{layout:k.layout})}),k.suggestions&&k.suggestions.length>0&&e.jsxs("div",{className:"nice-report-ai__suggestions",children:[e.jsx("span",{className:"nice-report-ai__suggestions-title",children:"💡 Suggestions:"}),e.jsx("ul",{children:k.suggestions.map((N,m)=>e.jsx("li",{children:N},m))})]}),e.jsxs("details",{className:"nice-report-ai__json",children:[e.jsx("summary",{children:"View JSON Definition"}),e.jsx("pre",{children:JSON.stringify(k.layout,null,2)})]})]})}),e.jsx("style",{children:`
|
|
1879
1879
|
.nice-report-ai {
|
|
1880
1880
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
1881
1881
|
}
|
|
@@ -2274,7 +2274,7 @@ Adjustments: ${j}`}],temperature:.4,maxTokens:2048});return Je(m).light||null}ca
|
|
|
2274
2274
|
${j.join(`
|
|
2275
2275
|
`)}
|
|
2276
2276
|
}`},[]),k=c.useCallback(d=>{const j={theme:{extend:{colors:{primary:{DEFAULT:d.colors.primary,light:d.colors.primaryLight,dark:d.colors.primaryDark},secondary:{DEFAULT:d.colors.secondary,light:d.colors.secondaryLight,dark:d.colors.secondaryDark},accent:d.colors.accent,success:d.colors.success,warning:d.colors.warning,error:d.colors.error,info:d.colors.info},fontFamily:{sans:[d.typography.fontFamily],mono:[d.typography.fontFamilyMono]},borderRadius:d.borderRadius,boxShadow:d.shadows}}};return`// tailwind.config.js
|
|
2277
|
-
module.exports = ${JSON.stringify(j,null,2)}`},[]),$=c.useCallback(()=>{h(null)},[]),g=c.useCallback(()=>{var d;(d=y.current)==null||d.abort(),o(!1)},[]);return c.useEffect(()=>()=>{var d;(d=y.current)==null||d.abort()},[]),{generateTheme:C,adjustTheme:S,toCSSVariables:P,toTailwindConfig:k,loading:l,lastResult:f,clearResults:$,abort:g,isConfigured:!!w}}function Je(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.light||o.theme)return{light:xe(o.light||o.theme),dark:o.dark?xe(o.dark):null};if(o.colors)return{light:xe(o),dark:null}}catch{}return{light:null,dark:null}}function xe(i){return{id:i.id||`theme_${Date.now()}`,name:i.name||"Generated Theme",description:i.description,mode:i.mode||"light",colors:{primary:"var(--nice-primary, #0066cc)",primaryLight:"#4d94db",primaryDark:"#004499",secondary:"var(--nice-text-secondary, #6c757d)",secondaryLight:"var(--nice-text-muted, #9ca3af)",secondaryDark:"var(--nice-text-secondary, #4b5563)",accent:"#ff6b35",background:"var(--nice-bg, #fff)",surface:"var(--nice-bg-secondary, #f8f9fa)",text:"var(--nice-text, #212529)",textMuted:"var(--nice-text-secondary, #6c757d)",textInverse:"var(--nice-bg, #fff)",border:"var(--nice-border, #dee2e6)",success:"var(--nice-success, #28a745)",warning:"var(--nice-warning, #ffc107)",error:"var(--nice-danger, #dc3545)",info:"var(--nice-info, #17a2b8)",...i.colors},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontFamilyMono:"ui-monospace, monospace",fontSizeBase:"16px",fontSizeXs:"12px",fontSizeSm:"14px",fontSizeMd:"16px",fontSizeLg:"18px",fontSizeXl:"20px",fontSize2xl:"24px",fontSize3xl:"30px",fontWeightLight:300,fontWeightNormal:400,fontWeightMedium:500,fontWeightSemibold:600,fontWeightBold:700,lineHeightTight:1.25,lineHeightNormal:1.5,lineHeightRelaxed:1.75,letterSpacing:"normal",...i.typography},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px","3xl":"64px","4xl":"80px",...i.spacing},borderRadius:{none:"0",sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px",...i.borderRadius},shadows:{none:"none",sm:"0 1px 2px var(--nice-overlay-5, rgba(0, 0, 0, 0.05))",md:"0 4px 6px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",lg:"0 10px 15px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",xl:"0 20px 25px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",...i.shadows},animations:{durationFast:"150ms",durationNormal:"300ms",durationSlow:"500ms",easeIn:"cubic-bezier(0.4, 0, 1, 1)",easeOut:"cubic-bezier(0, 0, 0.2, 1)",easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",...i.animations},components:i.components,cssVariables:i.cssVariables}}function hi(i){if(!i)return[];const a=[];return a.push("Verify WCAG contrast ratios for text on background"),a.push("Test the theme in both light and dark environments"),a.push("Ensure button and input styles are consistent"),a.slice(0,3)}function ve(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}const gi=[{icon:"🏢",name:"Corporate",prompt:"Professional corporate theme with blue and gray tones"},{icon:"🎨",name:"Creative",prompt:"Vibrant creative agency theme with bold colors"},{icon:"🌿",name:"Natural",prompt:"Organic natural theme with earth tones and greens"},{icon:"🌙",name:"Dark Pro",prompt:"Modern dark theme for developer tools"},{icon:"🍬",name:"Playful",prompt:"Fun playful theme with candy colors for kids"},{icon:"💎",name:"Luxury",prompt:"Elegant luxury brand theme with gold accents"}];function yi({config:i,generateDarkMode:a=!0,onGenerate:r,showPresets:t=!0,showPreview:n=!0,className:s,style:l}){const[o,f]=c.useState("description"),[h,y]=c.useState(""),[w,C]=c.useState(""),[S,P]=c.useState(""),[k,$]=c.useState("var(--nice-primary, #0066cc)"),[g,d]=c.useState("light"),{generateTheme:j,toCSSVariables:N,toTailwindConfig:m,loading:v,lastResult:x,isConfigured:p}=Ra({config:i,generateDarkMode:a,onThemeGenerated:r}),_=async()=>{if(v)return;let b;switch(o){case"brand":if(!w.trim())return;b={type:"brand",value:{name:w,industry:S||void 0}};break;case"colors":b={type:"colors",value:{primary:k}};break;default:if(!h.trim())return;b={type:"description",value:h}}await j(b)},M=b=>{f("description"),y(b.prompt)},R=()=>{if(!(x!=null&&x.theme))return;const b=N(x.theme),
|
|
2277
|
+
module.exports = ${JSON.stringify(j,null,2)}`},[]),$=c.useCallback(()=>{h(null)},[]),g=c.useCallback(()=>{var d;(d=y.current)==null||d.abort(),o(!1)},[]);return c.useEffect(()=>()=>{var d;(d=y.current)==null||d.abort()},[]),{generateTheme:C,adjustTheme:S,toCSSVariables:P,toTailwindConfig:k,loading:l,lastResult:f,clearResults:$,abort:g,isConfigured:!!w}}function Je(i){var a,r,t;try{const n=((r=(a=i.choices[0])==null?void 0:a.message)==null?void 0:r.content)||"",l=((t=(n.match(/```(?:json)?\s*([\s\S]*?)```/)||[null,n])[1])==null?void 0:t.trim())||n,o=JSON.parse(l);if(o.light||o.theme)return{light:xe(o.light||o.theme),dark:o.dark?xe(o.dark):null};if(o.colors)return{light:xe(o),dark:null}}catch{}return{light:null,dark:null}}function xe(i){return{id:i.id||`theme_${Date.now()}`,name:i.name||"Generated Theme",description:i.description,mode:i.mode||"light",colors:{primary:"var(--nice-primary, #0066cc)",primaryLight:"#4d94db",primaryDark:"#004499",secondary:"var(--nice-text-secondary, #6c757d)",secondaryLight:"var(--nice-text-muted, #9ca3af)",secondaryDark:"var(--nice-text-secondary, #4b5563)",accent:"#ff6b35",background:"var(--nice-bg, #fff)",surface:"var(--nice-bg-secondary, #f8f9fa)",text:"var(--nice-text, #212529)",textMuted:"var(--nice-text-secondary, #6c757d)",textInverse:"var(--nice-bg, #fff)",border:"var(--nice-border, #dee2e6)",success:"var(--nice-success, #28a745)",warning:"var(--nice-warning, #ffc107)",error:"var(--nice-danger, #dc3545)",info:"var(--nice-info, #17a2b8)",...i.colors},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontFamilyMono:"ui-monospace, monospace",fontSizeBase:"16px",fontSizeXs:"12px",fontSizeSm:"14px",fontSizeMd:"16px",fontSizeLg:"18px",fontSizeXl:"20px",fontSize2xl:"24px",fontSize3xl:"30px",fontWeightLight:300,fontWeightNormal:400,fontWeightMedium:500,fontWeightSemibold:600,fontWeightBold:700,lineHeightTight:1.25,lineHeightNormal:1.5,lineHeightRelaxed:1.75,letterSpacing:"normal",...i.typography},spacing:{xs:"4px",sm:"8px",md:"16px",lg:"24px",xl:"32px","2xl":"48px","3xl":"64px","4xl":"80px",...i.spacing},borderRadius:{none:"0",sm:"4px",md:"8px",lg:"12px",xl:"16px",full:"9999px",...i.borderRadius},shadows:{none:"none",sm:"0 1px 2px var(--nice-overlay-5, rgba(0, 0, 0, 0.05))",md:"0 4px 6px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",lg:"0 10px 15px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",xl:"0 20px 25px var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",...i.shadows},animations:{durationFast:"150ms",durationNormal:"300ms",durationSlow:"500ms",easeIn:"cubic-bezier(0.4, 0, 1, 1)",easeOut:"cubic-bezier(0, 0, 0.2, 1)",easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",...i.animations},components:i.components,cssVariables:i.cssVariables}}function hi(i){if(!i)return[];const a=[];return a.push("Verify WCAG contrast ratios for text on background"),a.push("Test the theme in both light and dark environments"),a.push("Ensure button and input styles are consistent"),a.slice(0,3)}function ve(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}const gi=[{icon:"🏢",name:"Corporate",prompt:"Professional corporate theme with blue and gray tones"},{icon:"🎨",name:"Creative",prompt:"Vibrant creative agency theme with bold colors"},{icon:"🌿",name:"Natural",prompt:"Organic natural theme with earth tones and greens"},{icon:"🌙",name:"Dark Pro",prompt:"Modern dark theme for developer tools"},{icon:"🍬",name:"Playful",prompt:"Fun playful theme with candy colors for kids"},{icon:"💎",name:"Luxury",prompt:"Elegant luxury brand theme with gold accents"}];function yi({config:i,generateDarkMode:a=!0,onGenerate:r,showPresets:t=!0,showPreview:n=!0,className:s,style:l}){const[o,f]=c.useState("description"),[h,y]=c.useState(""),[w,C]=c.useState(""),[S,P]=c.useState(""),[k,$]=c.useState("var(--nice-primary, #0066cc)"),[g,d]=c.useState("light"),{generateTheme:j,toCSSVariables:N,toTailwindConfig:m,loading:v,lastResult:x,isConfigured:p}=Ra({config:i,generateDarkMode:a,onThemeGenerated:r}),_=async()=>{if(v)return;let b;switch(o){case"brand":if(!w.trim())return;b={type:"brand",value:{name:w,industry:S||void 0}};break;case"colors":b={type:"colors",value:{primary:k}};break;default:if(!h.trim())return;b={type:"description",value:h}}await j(b)},M=b=>{f("description"),y(b.prompt)},R=()=>{if(!(x!=null&&x.theme))return;const b=N(x.theme),z=new Blob([b],{type:"text/css"}),D=URL.createObjectURL(z),J=document.createElement("a");J.href=D,J.download=`${x.theme.name.replace(/\s+/g,"-").toLowerCase()}.css`,J.click(),URL.revokeObjectURL(D)},T=()=>{if(!(x!=null&&x.theme))return;const b=m(x.theme),z=new Blob([b],{type:"text/javascript"}),D=URL.createObjectURL(z),J=document.createElement("a");J.href=D,J.download="tailwind.config.js",J.click(),URL.revokeObjectURL(D)},u=g==="dark"&&(x!=null&&x.darkTheme)?x.darkTheme:x==null?void 0:x.theme;return p?e.jsxs("div",{className:`nice-theme-ai ${s||""}`,style:l,children:[t&&e.jsx("div",{className:"nice-theme-ai__presets",children:gi.map((b,z)=>e.jsxs("button",{type:"button",className:"nice-theme-ai__preset",onClick:()=>M(b),children:[e.jsx("span",{className:"nice-theme-ai__preset-icon",children:b.icon}),e.jsx("span",{className:"nice-theme-ai__preset-name",children:b.name})]},z))}),e.jsxs("div",{className:"nice-theme-ai__tabs",children:[e.jsx("button",{type:"button",className:`nice-theme-ai__tab ${o==="description"?"nice-theme-ai__tab--active":""}`,onClick:()=>f("description"),children:"📝 Description"}),e.jsx("button",{type:"button",className:`nice-theme-ai__tab ${o==="brand"?"nice-theme-ai__tab--active":""}`,onClick:()=>f("brand"),children:"🏷️ Brand"}),e.jsx("button",{type:"button",className:`nice-theme-ai__tab ${o==="colors"?"nice-theme-ai__tab--active":""}`,onClick:()=>f("colors"),children:"🎨 Colors"})]}),e.jsxs("div",{className:"nice-theme-ai__input-section",children:[o==="description"&&e.jsx("textarea",{value:h,onChange:b=>y(b.target.value),placeholder:"Describe the theme you want... (e.g., 'Modern tech startup with blue and green')",className:"nice-theme-ai__textarea",rows:3,disabled:v}),o==="brand"&&e.jsxs("div",{className:"nice-theme-ai__brand-inputs",children:[e.jsx("input",{type:"text",value:w,onChange:b=>C(b.target.value),placeholder:"Brand name",className:"nice-theme-ai__input",disabled:v}),e.jsx("input",{type:"text",value:S,onChange:b=>P(b.target.value),placeholder:"Industry (optional)",className:"nice-theme-ai__input",disabled:v})]}),o==="colors"&&e.jsx("div",{className:"nice-theme-ai__color-input",children:e.jsxs("label",{children:["Primary Color:",e.jsx("input",{type:"color",value:k,onChange:b=>$(b.target.value),className:"nice-theme-ai__color-picker",disabled:v}),e.jsx("span",{className:"nice-theme-ai__color-value",children:k})]})}),e.jsx("button",{type:"button",onClick:_,className:"nice-theme-ai__submit",disabled:v,children:v?e.jsx("span",{className:"nice-theme-ai__spinner"}):"✨ Generate Theme"})]}),x&&u&&e.jsxs("div",{className:"nice-theme-ai__result",children:[e.jsxs("div",{className:"nice-theme-ai__result-header",children:[e.jsxs("div",{className:"nice-theme-ai__theme-info",children:[e.jsx("span",{className:"nice-theme-ai__theme-name",children:u.name}),u.description&&e.jsx("span",{className:"nice-theme-ai__theme-desc",children:u.description})]}),e.jsxs("div",{className:"nice-theme-ai__actions",children:[x.darkTheme&&e.jsxs("div",{className:"nice-theme-ai__mode-toggle",children:[e.jsx("button",{type:"button",className:g==="light"?"active":"",onClick:()=>d("light"),children:"☀️"}),e.jsx("button",{type:"button",className:g==="dark"?"active":"",onClick:()=>d("dark"),children:"🌙"})]}),e.jsx("button",{type:"button",onClick:R,children:"📥 CSS"}),e.jsx("button",{type:"button",onClick:T,children:"📥 Tailwind"})]})]}),n&&e.jsx(bi,{theme:u}),e.jsxs("div",{className:"nice-theme-ai__palette",children:[e.jsx("div",{className:"nice-theme-ai__palette-title",children:"Color Palette"}),e.jsx("div",{className:"nice-theme-ai__colors",children:Object.entries(u.colors).map(([b,z])=>e.jsxs("div",{className:"nice-theme-ai__color",children:[e.jsx("div",{className:"nice-theme-ai__color-swatch",style:{backgroundColor:z}}),e.jsx("span",{className:"nice-theme-ai__color-name",children:b}),e.jsx("span",{className:"nice-theme-ai__color-hex",children:z})]},b))})]}),e.jsxs("div",{className:"nice-theme-ai__typography",children:[e.jsx("div",{className:"nice-theme-ai__typography-title",children:"Typography"}),e.jsxs("div",{style:{fontFamily:u.typography.fontFamily},children:[e.jsx("p",{style:{fontSize:u.typography.fontSize3xl,fontWeight:u.typography.fontWeightBold},children:"Heading 1"}),e.jsx("p",{style:{fontSize:u.typography.fontSizeLg},children:"Body text: The quick brown fox jumps over the lazy dog."}),e.jsx("p",{style:{fontFamily:u.typography.fontFamilyMono,fontSize:u.typography.fontSizeSm},children:'const code = "Monospace font"'})]})]})]}),e.jsx("style",{children:`
|
|
2278
2278
|
.nice-theme-ai {
|
|
2279
2279
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
2280
2280
|
}
|
|
@@ -3237,7 +3237,7 @@ ${d}`}],temperature:.3,maxTokens:2048})).choices[0])==null?void 0:j.message)==nu
|
|
|
3237
3237
|
margin-bottom: var(--nice-space-1-5, 6px);
|
|
3238
3238
|
font-size: 14px;
|
|
3239
3239
|
}
|
|
3240
|
-
`})]}):e.jsx("div",{className:`nice-a11y-ai nice-a11y-ai--disabled ${n||""}`,style:s,children:e.jsx("p",{children:"AI not configured. Please provide config or wrap in NiceAIProvider."})})}const we=[{name:"home",category:"navigation",keywords:["home","house","start","main"],svgPath:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"},{name:"menu",category:"navigation",keywords:["menu","hamburger","nav","bars"],svgPath:"M4 6h16M4 12h16M4 18h16"},{name:"arrow-left",category:"navigation",keywords:["back","previous","left","arrow"],svgPath:"M10 19l-7-7m0 0l7-7m-7 7h18"},{name:"arrow-right",category:"navigation",keywords:["next","forward","right","arrow"],svgPath:"M14 5l7 7m0 0l-7 7m7-7H3"},{name:"chevron-down",category:"navigation",keywords:["expand","dropdown","down","chevron"],svgPath:"M19 9l-7 7-7-7"},{name:"chevron-up",category:"navigation",keywords:["collapse","up","chevron"],svgPath:"M5 15l7-7 7 7"},{name:"plus",category:"action",keywords:["add","create","new","plus"],svgPath:"M12 4v16m8-8H4"},{name:"minus",category:"action",keywords:["remove","subtract","minus"],svgPath:"M20 12H4"},{name:"x",category:"action",keywords:["close","cancel","delete","remove","x"],svgPath:"M6 18L18 6M6 6l12 12"},{name:"check",category:"action",keywords:["done","complete","success","check","tick"],svgPath:"M5 13l4 4L19 7"},{name:"edit",category:"action",keywords:["edit","modify","pencil","write"],svgPath:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"},{name:"trash",category:"action",keywords:["delete","remove","trash","bin"],svgPath:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"},{name:"search",category:"action",keywords:["search","find","magnify","lookup"],svgPath:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},{name:"filter",category:"action",keywords:["filter","sort","funnel"],svgPath:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"},{name:"download",category:"action",keywords:["download","save","export"],svgPath:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"},{name:"upload",category:"action",keywords:["upload","import","send"],svgPath:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"},{name:"refresh",category:"action",keywords:["refresh","reload","sync"],svgPath:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},{name:"copy",category:"action",keywords:["copy","duplicate","clone"],svgPath:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"},{name:"mail",category:"communication",keywords:["email","mail","message","envelope"],svgPath:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"},{name:"phone",category:"communication",keywords:["phone","call","telephone","contact"],svgPath:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"},{name:"chat",category:"communication",keywords:["chat","message","comment","bubble"],svgPath:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"},{name:"bell",category:"notification",keywords:["notification","bell","alert","alarm"],svgPath:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"},{name:"file",category:"file",keywords:["file","document","page"],svgPath:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"},{name:"folder",category:"file",keywords:["folder","directory","category"],svgPath:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"},{name:"image",category:"image",keywords:["image","photo","picture","gallery"],svgPath:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"},{name:"video",category:"av",keywords:["video","movie","film","camera"],svgPath:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"},{name:"user",category:"social",keywords:["user","person","account","profile"],svgPath:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"},{name:"users",category:"social",keywords:["users","group","team","people"],svgPath:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"},{name:"settings",category:"action",keywords:["settings","config","gear","cog","preferences"],svgPath:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z"},{name:"calendar",category:"business",keywords:["calendar","date","schedule","event"],svgPath:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"},{name:"clock",category:"business",keywords:["time","clock","schedule","hour"],svgPath:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"credit-card",category:"finance",keywords:["payment","card","credit","money"],svgPath:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"},{name:"chart",category:"business",keywords:["chart","graph","analytics","statistics"],svgPath:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"},{name:"lock",category:"security",keywords:["lock","secure","private","password"],svgPath:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},{name:"unlock",category:"security",keywords:["unlock","open","access"],svgPath:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"},{name:"shield",category:"security",keywords:["shield","security","protect","safe"],svgPath:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"},{name:"eye",category:"action",keywords:["view","show","visible","eye","visibility"],svgPath:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},{name:"eye-off",category:"action",keywords:["hide","invisible","hidden","eye-off"],svgPath:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},{name:"info",category:"alert",keywords:["info","information","help","about"],svgPath:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"warning",category:"alert",keywords:["warning","caution","alert","attention"],svgPath:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"},{name:"error",category:"alert",keywords:["error","danger","fail","problem"],svgPath:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"success",category:"alert",keywords:["success","done","complete","check-circle"],svgPath:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"star",category:"action",keywords:["star","favorite","bookmark","rating"],svgPath:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"},{name:"heart",category:"social",keywords:["heart","love","like","favorite"],svgPath:"M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"},{name:"share",category:"social",keywords:["share","send","forward"],svgPath:"M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z"},{name:"link",category:"action",keywords:["link","url","chain","hyperlink"],svgPath:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"},{name:"external-link",category:"action",keywords:["external","open","new-window"],svgPath:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"}];function Ia(i={}){const{config:a,defaultLibrary:r="lucide",defaultStyle:t="outline",maxSuggestions:n=10,onSuggestion:s,onError:l}=i,o=Q(),[f,h]=c.useState(!1),[y,w]=c.useState(null),C=c.useRef(null),S=a||(o==null?void 0:o.config),P=c.useCallback(N=>{const m=N.toLowerCase(),v=m.split(/\s+/);return we.map(x=>{let p=0;return x.name===m?p+=100:x.name.includes(m)&&(p+=50),v.forEach(_=>{x.keywords.forEach(M=>{M===_?p+=30:(M.includes(_)||_.includes(M))&&(p+=15)})}),x.category===m&&(p+=20),{id:`icon_${x.name}`,name:x.name,displayName:x.name.replace(/-/g," ").replace(/\b\w/g,_=>_.toUpperCase()),category:x.category,style:t,library:r,relevanceScore:p,keywords:x.keywords,svgPath:x.svgPath}}).filter(x=>x.relevanceScore>0).sort((x,p)=>p.relevanceScore-x.relevanceScore).slice(0,n)},[r,t,n]),k=c.useCallback(async(N,m)=>{var p,_,M,R;const v=performance.now(),x=P(N);if(!S){const T={query:N,suggestions:x,latencyMs:performance.now()-v};return w(T),s==null||s(T),T}h(!0),(p=C.current)==null||p.abort(),C.current=new AbortController;try{const T=G(S),u=m?`
|
|
3240
|
+
`})]}):e.jsx("div",{className:`nice-a11y-ai nice-a11y-ai--disabled ${n||""}`,style:s,children:e.jsx("p",{children:"AI not configured. Please provide config or wrap in NiceAIProvider."})})}const we=[{name:"home",category:"navigation",keywords:["home","house","start","main"],svgPath:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"},{name:"menu",category:"navigation",keywords:["menu","hamburger","nav","bars"],svgPath:"M4 6h16M4 12h16M4 18h16"},{name:"arrow-left",category:"navigation",keywords:["back","previous","left","arrow"],svgPath:"M10 19l-7-7m0 0l7-7m-7 7h18"},{name:"arrow-right",category:"navigation",keywords:["next","forward","right","arrow"],svgPath:"M14 5l7 7m0 0l-7 7m7-7H3"},{name:"chevron-down",category:"navigation",keywords:["expand","dropdown","down","chevron"],svgPath:"M19 9l-7 7-7-7"},{name:"chevron-up",category:"navigation",keywords:["collapse","up","chevron"],svgPath:"M5 15l7-7 7 7"},{name:"plus",category:"action",keywords:["add","create","new","plus"],svgPath:"M12 4v16m8-8H4"},{name:"minus",category:"action",keywords:["remove","subtract","minus"],svgPath:"M20 12H4"},{name:"x",category:"action",keywords:["close","cancel","delete","remove","x"],svgPath:"M6 18L18 6M6 6l12 12"},{name:"check",category:"action",keywords:["done","complete","success","check","tick"],svgPath:"M5 13l4 4L19 7"},{name:"edit",category:"action",keywords:["edit","modify","pencil","write"],svgPath:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"},{name:"trash",category:"action",keywords:["delete","remove","trash","bin"],svgPath:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"},{name:"search",category:"action",keywords:["search","find","magnify","lookup"],svgPath:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},{name:"filter",category:"action",keywords:["filter","sort","funnel"],svgPath:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"},{name:"download",category:"action",keywords:["download","save","export"],svgPath:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"},{name:"upload",category:"action",keywords:["upload","import","send"],svgPath:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"},{name:"refresh",category:"action",keywords:["refresh","reload","sync"],svgPath:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"},{name:"copy",category:"action",keywords:["copy","duplicate","clone"],svgPath:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"},{name:"mail",category:"communication",keywords:["email","mail","message","envelope"],svgPath:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"},{name:"phone",category:"communication",keywords:["phone","call","telephone","contact"],svgPath:"M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"},{name:"chat",category:"communication",keywords:["chat","message","comment","bubble"],svgPath:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"},{name:"bell",category:"notification",keywords:["notification","bell","alert","alarm"],svgPath:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"},{name:"file",category:"file",keywords:["file","document","page"],svgPath:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"},{name:"folder",category:"file",keywords:["folder","directory","category"],svgPath:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"},{name:"image",category:"image",keywords:["image","photo","picture","gallery"],svgPath:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"},{name:"video",category:"av",keywords:["video","movie","film","camera"],svgPath:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"},{name:"user",category:"social",keywords:["user","person","account","profile"],svgPath:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"},{name:"users",category:"social",keywords:["users","group","team","people"],svgPath:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"},{name:"settings",category:"action",keywords:["settings","config","gear","cog","preferences"],svgPath:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z"},{name:"calendar",category:"business",keywords:["calendar","date","schedule","event"],svgPath:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"},{name:"clock",category:"business",keywords:["time","clock","schedule","hour"],svgPath:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"credit-card",category:"finance",keywords:["payment","card","credit","money"],svgPath:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"},{name:"chart",category:"business",keywords:["chart","graph","analytics","statistics"],svgPath:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"},{name:"lock",category:"security",keywords:["lock","secure","private","password"],svgPath:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},{name:"unlock",category:"security",keywords:["unlock","open","access"],svgPath:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"},{name:"shield",category:"security",keywords:["shield","security","protect","safe"],svgPath:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"},{name:"eye",category:"action",keywords:["view","show","visible","eye","visibility"],svgPath:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},{name:"eye-off",category:"action",keywords:["hide","invisible","hidden","eye-off"],svgPath:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},{name:"info",category:"alert",keywords:["info","information","help","about"],svgPath:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"warning",category:"alert",keywords:["warning","caution","alert","attention"],svgPath:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"},{name:"error",category:"alert",keywords:["error","danger","fail","problem"],svgPath:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"success",category:"alert",keywords:["success","done","complete","check-circle"],svgPath:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"},{name:"star",category:"action",keywords:["star","favorite","bookmark","rating"],svgPath:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"},{name:"heart",category:"social",keywords:["heart","love","like","favorite"],svgPath:"M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"},{name:"share",category:"social",keywords:["share","send","forward"],svgPath:"M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z"},{name:"link",category:"action",keywords:["link","url","chain","hyperlink"],svgPath:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"},{name:"external-link",category:"action",keywords:["external","open","new-window"],svgPath:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"}];function za(i={}){const{config:a,defaultLibrary:r="lucide",defaultStyle:t="outline",maxSuggestions:n=10,onSuggestion:s,onError:l}=i,o=Q(),[f,h]=c.useState(!1),[y,w]=c.useState(null),C=c.useRef(null),S=a||(o==null?void 0:o.config),P=c.useCallback(N=>{const m=N.toLowerCase(),v=m.split(/\s+/);return we.map(x=>{let p=0;return x.name===m?p+=100:x.name.includes(m)&&(p+=50),v.forEach(_=>{x.keywords.forEach(M=>{M===_?p+=30:(M.includes(_)||_.includes(M))&&(p+=15)})}),x.category===m&&(p+=20),{id:`icon_${x.name}`,name:x.name,displayName:x.name.replace(/-/g," ").replace(/\b\w/g,_=>_.toUpperCase()),category:x.category,style:t,library:r,relevanceScore:p,keywords:x.keywords,svgPath:x.svgPath}}).filter(x=>x.relevanceScore>0).sort((x,p)=>p.relevanceScore-x.relevanceScore).slice(0,n)},[r,t,n]),k=c.useCallback(async(N,m)=>{var p,_,M,R;const v=performance.now(),x=P(N);if(!S){const T={query:N,suggestions:x,latencyMs:performance.now()-v};return w(T),s==null||s(T),T}h(!0),(p=C.current)==null||p.abort(),C.current=new AbortController;try{const T=G(S),u=m?`
|
|
3241
3241
|
Context:
|
|
3242
3242
|
- Component type: ${m.componentType||"any"}
|
|
3243
3243
|
- Purpose: ${m.purpose||"general"}
|
|
@@ -3255,7 +3255,7 @@ Return JSON array of 5-10 icon suggestions:
|
|
|
3255
3255
|
"usage": "Brief usage description"
|
|
3256
3256
|
}]
|
|
3257
3257
|
|
|
3258
|
-
Focus on semantic meaning and common UI patterns.`},{role:"user",content:`Suggest icons for: "${N}"${u}`}],temperature:.5,maxTokens:1024})).choices[0])==null?void 0:M.message)==null?void 0:R.content)||"").match(/\[[\s\S]*\]/);let J=[];if(D)try{J=JSON.parse(D[0]).map((F,U)=>({id:F.id||`ai_icon_${U}`,name:F.name||"unknown",displayName:F.displayName||F.name||"Unknown",category:F.category||"action",style:(m==null?void 0:m.preferredStyle)||t,library:(m==null?void 0:m.preferredLibrary)||r,relevanceScore:F.relevanceScore||50,keywords:F.keywords||[],usage:F.usage}))}catch{}const Y=Ti(x,J,n),V={query:N,suggestions:Y,latencyMs:performance.now()-v};return w(V),s==null||s(V),V}catch(T){const u=T instanceof Error?T.message:"Suggestion failed",b={query:N,suggestions:x,latencyMs:performance.now()-v,error:u};return w(b),l==null||l(u),b}finally{h(!1)}},[S,r,t,n,P,s,l]),$=c.useCallback(N=>we.filter(m=>m.category===N).map(m=>({id:`icon_${m.name}`,name:m.name,displayName:m.name.replace(/-/g," ").replace(/\b\w/g,v=>v.toUpperCase()),category:m.category,style:t,library:r,relevanceScore:100,keywords:m.keywords,svgPath:m.svgPath})),[r,t]),g=c.useMemo(()=>{const N=new Set;return we.forEach(m=>N.add(m.category)),Array.from(N)},[]),d=c.useCallback(()=>{w(null)},[]),j=c.useCallback(()=>{var N;(N=C.current)==null||N.abort(),h(!1)},[]);return c.useEffect(()=>()=>{var N;(N=C.current)==null||N.abort()},[]),{suggestIcons:k,localSearch:P,getByCategory:$,categories:g,loading:f,lastResult:y,clearResults:d,abort:j,isConfigured:!!S}}function Ti(i,a,r){const t=new Set,n=[];for(const s of i)t.has(s.name)||(t.add(s.name),n.push(s));for(const s of a)!t.has(s.name)&&n.length<r&&(t.add(s.name),n.push(s));return n.slice(0,r)}function Ai({config:i,defaultLibrary:a="lucide",defaultStyle:r="outline",maxSuggestions:t=10,onSelect:n,showCategories:s=!0,showPreview:l=!0,className:o,style:f}){const[h,y]=c.useState(""),[w,C]=c.useState(null),[S,P]=c.useState(null),{suggestIcons:k,getByCategory:$,categories:g,loading:d,lastResult:j}=
|
|
3258
|
+
Focus on semantic meaning and common UI patterns.`},{role:"user",content:`Suggest icons for: "${N}"${u}`}],temperature:.5,maxTokens:1024})).choices[0])==null?void 0:M.message)==null?void 0:R.content)||"").match(/\[[\s\S]*\]/);let J=[];if(D)try{J=JSON.parse(D[0]).map((F,U)=>({id:F.id||`ai_icon_${U}`,name:F.name||"unknown",displayName:F.displayName||F.name||"Unknown",category:F.category||"action",style:(m==null?void 0:m.preferredStyle)||t,library:(m==null?void 0:m.preferredLibrary)||r,relevanceScore:F.relevanceScore||50,keywords:F.keywords||[],usage:F.usage}))}catch{}const Y=Ti(x,J,n),V={query:N,suggestions:Y,latencyMs:performance.now()-v};return w(V),s==null||s(V),V}catch(T){const u=T instanceof Error?T.message:"Suggestion failed",b={query:N,suggestions:x,latencyMs:performance.now()-v,error:u};return w(b),l==null||l(u),b}finally{h(!1)}},[S,r,t,n,P,s,l]),$=c.useCallback(N=>we.filter(m=>m.category===N).map(m=>({id:`icon_${m.name}`,name:m.name,displayName:m.name.replace(/-/g," ").replace(/\b\w/g,v=>v.toUpperCase()),category:m.category,style:t,library:r,relevanceScore:100,keywords:m.keywords,svgPath:m.svgPath})),[r,t]),g=c.useMemo(()=>{const N=new Set;return we.forEach(m=>N.add(m.category)),Array.from(N)},[]),d=c.useCallback(()=>{w(null)},[]),j=c.useCallback(()=>{var N;(N=C.current)==null||N.abort(),h(!1)},[]);return c.useEffect(()=>()=>{var N;(N=C.current)==null||N.abort()},[]),{suggestIcons:k,localSearch:P,getByCategory:$,categories:g,loading:f,lastResult:y,clearResults:d,abort:j,isConfigured:!!S}}function Ti(i,a,r){const t=new Set,n=[];for(const s of i)t.has(s.name)||(t.add(s.name),n.push(s));for(const s of a)!t.has(s.name)&&n.length<r&&(t.add(s.name),n.push(s));return n.slice(0,r)}function Ai({config:i,defaultLibrary:a="lucide",defaultStyle:r="outline",maxSuggestions:t=10,onSelect:n,showCategories:s=!0,showPreview:l=!0,className:o,style:f}){const[h,y]=c.useState(""),[w,C]=c.useState(null),[S,P]=c.useState(null),{suggestIcons:k,getByCategory:$,categories:g,loading:d,lastResult:j}=za({config:i,defaultLibrary:a,defaultStyle:r,maxSuggestions:t}),N=async()=>{h.trim()&&(C(null),await k(h))},m=_=>{_.key==="Enter"&&N()},v=_=>{w===_?C(null):(C(_),y(""))},x=_=>{P(_),n==null||n(_)},p=w?$(w):(j==null?void 0:j.suggestions)||[];return e.jsxs("div",{className:`nice-icon-ai ${o||""}`,style:f,children:[e.jsxs("div",{className:"nice-icon-ai__search",children:[e.jsx("input",{type:"text",value:h,onChange:_=>y(_.target.value),onKeyDown:m,placeholder:"Search icons... (e.g., 'save', 'notification', 'user profile')",className:"nice-icon-ai__input",disabled:d}),e.jsx("button",{type:"button",onClick:N,className:"nice-icon-ai__search-btn",disabled:d||!h.trim(),children:d?e.jsx("span",{className:"nice-icon-ai__spinner"}):"🔍"})]}),s&&e.jsx("div",{className:"nice-icon-ai__categories",children:g.map(_=>e.jsx("button",{type:"button",className:`nice-icon-ai__category ${w===_?"nice-icon-ai__category--selected":""}`,onClick:()=>v(_),children:_},_))}),p.length>0&&e.jsx("div",{className:"nice-icon-ai__results",children:p.map(_=>e.jsxs("button",{type:"button",className:`nice-icon-ai__icon ${(S==null?void 0:S.id)===_.id?"nice-icon-ai__icon--selected":""}`,onClick:()=>x(_),title:_.displayName,children:[e.jsx(Ue,{icon:_}),e.jsx("span",{className:"nice-icon-ai__icon-name",children:_.displayName})]},_.id))}),l&&S&&e.jsxs("div",{className:"nice-icon-ai__preview",children:[e.jsx("div",{className:"nice-icon-ai__preview-icon",children:e.jsx(Ue,{icon:S,size:64})}),e.jsxs("div",{className:"nice-icon-ai__preview-info",children:[e.jsx("div",{className:"nice-icon-ai__preview-name",children:S.displayName}),e.jsxs("div",{className:"nice-icon-ai__preview-details",children:[e.jsxs("span",{children:["Category: ",S.category]}),e.jsxs("span",{children:["Library: ",S.library]})]}),e.jsx("div",{className:"nice-icon-ai__preview-keywords",children:S.keywords.map(_=>e.jsx("span",{className:"nice-icon-ai__keyword",children:_},_))}),S.usage&&e.jsx("div",{className:"nice-icon-ai__preview-usage",children:S.usage}),e.jsxs("div",{className:"nice-icon-ai__preview-actions",children:[e.jsx("button",{type:"button",onClick:()=>n==null?void 0:n(S),children:"✅ Use Icon"}),e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(S.name)},children:"📋 Copy Name"}),S.svgPath&&e.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(`<svg viewBox="0 0 24 24"><path d="${S.svgPath}" /></svg>`)},children:"📋 Copy SVG"})]})]})]}),e.jsx("style",{children:`
|
|
3259
3259
|
.nice-icon-ai {
|
|
3260
3260
|
font-family: var(--nice-font-family, system-ui, sans-serif);
|
|
3261
3261
|
}
|
|
@@ -3452,4 +3452,4 @@ Focus on semantic meaning and common UI patterns.`},{role:"user",content:`Sugges
|
|
|
3452
3452
|
color: white;
|
|
3453
3453
|
border: none;
|
|
3454
3454
|
}
|
|
3455
|
-
`})]})}function Ue({icon:i,size:a=32}){return i.svgPath?e.jsx("svg",{viewBox:"0 0 24 24",width:a,height:a,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:i.svgPath})}):e.jsx("div",{style:{width:a,height:a,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-secondary, #f0f0f0)",borderRadius:6,fontSize:a*.5,fontWeight:600,color:"var(--nice-text-secondary, #666)"},children:i.name.charAt(0).toUpperCase()})}exports.ACCESSIBILITY_CHECKER_TEMPLATE=je;exports.AnthropicProvider=ha;exports.AzureOpenAIProvider=ga;exports.CHART_CONFIG_TEMPLATE=de;exports.CODE_COMPLETION_TEMPLATE=ue;exports.CostTracker=va;exports.DATA_GRID_FILTER_TEMPLATE=ce;exports.DATA_GRID_SORT_TEMPLATE=oe;exports.FORM_BUILDER_TEMPLATE=le;exports.GroqProvider=ba;exports.InMemoryCostStorage=
|
|
3455
|
+
`})]})}function Ue({icon:i,size:a=32}){return i.svgPath?e.jsx("svg",{viewBox:"0 0 24 24",width:a,height:a,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:i.svgPath})}):e.jsx("div",{style:{width:a,height:a,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--nice-bg-secondary, #f0f0f0)",borderRadius:6,fontSize:a*.5,fontWeight:600,color:"var(--nice-text-secondary, #666)"},children:i.name.charAt(0).toUpperCase()})}exports.ACCESSIBILITY_CHECKER_TEMPLATE=je;exports.AnthropicProvider=ha;exports.AzureOpenAIProvider=ga;exports.CHART_CONFIG_TEMPLATE=de;exports.CODE_COMPLETION_TEMPLATE=ue;exports.CostTracker=va;exports.DATA_GRID_FILTER_TEMPLATE=ce;exports.DATA_GRID_SORT_TEMPLATE=oe;exports.FORM_BUILDER_TEMPLATE=le;exports.GroqProvider=ba;exports.InMemoryCostStorage=ze;exports.LocalStorageCostStorage=xa;exports.NiceAIHintBubble=Se;exports.NiceAIProvider=Ia;exports.NiceAccessibilityAI=Si;exports.NiceChartAI=Kr;exports.NiceCodeEditorAI=ri;exports.NiceDataGridAI=Jr;exports.NiceDataLabeler=Pr;exports.NiceFormBuilderAI=qr;exports.NiceIconSuggestorAI=Ai;exports.NiceLayoutAI=wi;exports.NiceMLStudio=Rr;exports.NiceModelInference=zr;exports.NiceReportBuilderAI=mi;exports.NiceThemeGeneratorAI=yi;exports.NiceWorkflowDesignerAI=ci;exports.OllamaProvider=ya;exports.OpenAIProvider=fa;exports.PROMPT_TEMPLATES=ye;exports.REPORT_LAYOUT_TEMPLATE=me;exports.RateLimiter=qe;exports.ResilientLLMClient=_a;exports.SUMMARIZE_DATA_TEMPLATE=Ne;exports.THEME_GENERATOR_TEMPLATE=fe;exports.TRANSLATION_TEMPLATE=ke;exports.WORKFLOW_GENERATOR_TEMPLATE=pe;exports.build3DSceneContext=ea;exports.buildAudioContext=Qe;exports.buildChartContext=Ba;exports.buildCodeEditorContext=Xe;exports.buildColorPickerContext=Pe;exports.buildDataGridContext=Ha;exports.buildDatePickerContext=Me;exports.buildDiagramLayoutContext=ta;exports.buildFormFillContext=Ke;exports.buildGameEngineContext=ia;exports.buildGraphicsContext=aa;exports.buildHtmlEditorContext=Ze;exports.buildIconSearchContext=ra;exports.buildNumberInputContext=Ae;exports.buildPresentationGenerateContext=na;exports.buildSelectContext=Re;exports.buildSlideDesignContext=sa;exports.buildTextInputContext=Te;exports.buildValidationContext=Ye;exports.colorControlContext=dr;exports.compileTemplate=ae;exports.createLLMProvider=te;exports.createProviderFromConfig=G;exports.createResilientClient=wa;exports.createResilientClientWithDefaults=Hr;exports.dateControlContext=lr;exports.getTemplate=Ir;exports.getTemplatesByCategory=Lr;exports.listTemplates=Or;exports.numberControlContext=cr;exports.parseJSONResponse=Ve;exports.parseSSEStream=Ge;exports.selectControlContext=or;exports.textControlContext=sr;exports.useAI3DHint=Za;exports.useAIAudioHint=Xa;exports.useAICodeHint=Ka;exports.useAIColorHint=Wa;exports.useAIContext=Q;exports.useAIDateHint=qa;exports.useAIDiagramLayout=rr;exports.useAIFormFill=Va;exports.useAIGraphicsHint=Qa;exports.useAIHtmlHint=Ya;exports.useAIIconSearch=er;exports.useAINpcHint=ar;exports.useAINumberHint=Ja;exports.useAIPresentationGenerate=ir;exports.useAISelectHint=Ua;exports.useAISlideDesign=tr;exports.useAITextHint=Fa;exports.useAIValidation=Ga;exports.useAccessibilityAI=$a;exports.useChartAI=Na;exports.useCodeEditorAI=Ca;exports.useCostTracker=Er;exports.useDataGridAI=ja;exports.useFormBuilderAI=ka;exports.useIconSuggestorAI=za;exports.useLayoutAI=Ma;exports.useNiceAIHint=X;exports.useReportBuilderAI=Ta;exports.useThemeGeneratorAI=Ra;exports.useWorkflowDesignerAI=Sa;exports.withAIHint=nr;
|