@wodecorp/openui-vue-intelligent-ui-library 0.1.5 → 0.1.6
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 +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@wodecorp/openui-vue-ui"),l=require("vue"),u=require("@wodecorp/openui-vue-lang"),d=require("@wodecorp/openui-vue-ui/icons"),f=require("zod/v4"),p=require("katex");p=s(p,1);const m={font:`var(--openui-intelligent-font, var(--openui-font-body, "Inter", sans-serif))`,mono:`var(--openui-intelligent-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,canvas:`var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))`,hover:`var(--openui-intelligent-hover, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 5%, transparent))`,pressed:`var(--openui-intelligent-pressed, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,surface:`var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent))`,surfaceStrong:`var(--openui-intelligent-surface-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,ink:`var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0)))`,inkHover:`var(--openui-intelligent-ink-hover, color-mix(in oklch, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 82%, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))))`,onInk:`var(--openui-intelligent-on-ink, var(--openui-foreground, oklch(0.994 0 89.876)))`,muted:`var(--openui-intelligent-muted, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,faint:`var(--openui-intelligent-faint, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,border:`var(--openui-intelligent-border, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,borderStrong:`var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent))`,rangeTrack:`var(--openui-intelligent-range-track, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,rangeThumb:`var(--openui-intelligent-range-thumb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,focus:`var(--openui-intelligent-focus, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,glass:`var(--openui-intelligent-glass, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassHover:`var(--openui-intelligent-glass-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,glassRing:`var(--openui-intelligent-glass-ring, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassRingHover:`var(--openui-intelligent-glass-ring-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,shadow:`var(--openui-intelligent-shadow, var(--openui-shadow-l, 0 4px 4px -2px oklch(0 0 0 / 0.05), 0 4px 8px -2px oklch(0 0 0 / 0.04)))`,shadowSm:`var(--openui-intelligent-shadow-sm, var(--openui-shadow-s, 0 1px 3px -2px oklch(0 0 0 / 0.02), 0 2px 5px -2px oklch(0 0 0 / 0.04)))`,info:`var(--openui-intelligent-info, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,infoSoft:`var(--openui-intelligent-info-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,success:`var(--openui-intelligent-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,successSoft:`var(--openui-intelligent-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,warning:`var(--openui-intelligent-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,warningSoft:`var(--openui-intelligent-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,danger:`var(--openui-intelligent-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,dangerSoft:`var(--openui-intelligent-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,purple:`var(--openui-intelligent-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,purpleSoft:`var(--openui-intelligent-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,pink:`var(--openui-intelligent-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,pinkSoft:`var(--openui-intelligent-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,badgeNeutralSoft:`var(--openui-intelligent-badge-neutral-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,badgeSuccess:`var(--openui-intelligent-badge-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,badgeSuccessSoft:`var(--openui-intelligent-badge-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,badgeWarning:`var(--openui-intelligent-badge-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,badgeWarningSoft:`var(--openui-intelligent-badge-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,badgeDanger:`var(--openui-intelligent-badge-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,badgeDangerSoft:`var(--openui-intelligent-badge-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,badgePurple:`var(--openui-intelligent-badge-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,badgePurpleSoft:`var(--openui-intelligent-badge-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,badgePink:`var(--openui-intelligent-badge-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,badgePinkSoft:`var(--openui-intelligent-badge-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,chart1:`var(--openui-intelligent-chart-1, #0285ff)`,chart2:`var(--openui-intelligent-chart-2, #00a67d)`,chart3:`var(--openui-intelligent-chart-3, #8b5cf6)`,chart4:`var(--openui-intelligent-chart-4, #f4a340)`,chart5:`var(--openui-intelligent-chart-5, #e46d91)`,chart6:`var(--openui-intelligent-chart-6, #4b9ca6)`,spaceTight:`var(--openui-intelligent-space-tight, 4px)`,spaceInner:`var(--openui-intelligent-space-inner, 8px)`,spaceGroup:`var(--openui-intelligent-space-group, 12px)`,spaceGroupLg:`var(--openui-intelligent-space-group-lg, 16px)`,spaceSection:`var(--openui-intelligent-space-section, 24px)`,controlGap:`var(--openui-intelligent-control-gap, 8px)`,fieldGap:`var(--openui-intelligent-field-gap, 24px)`,actionGap:`var(--openui-intelligent-action-gap, 40px)`,radiusSm:`var(--openui-intelligent-radius-sm, 6px)`,radiusMd:`var(--openui-intelligent-radius-md, 10px)`,radiusLg:`var(--openui-intelligent-radius-lg, 12px)`,radiusXl:`var(--openui-intelligent-radius-xl, 14px)`,photoEmpty:`var(--openui-intelligent-photo-empty, var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent)))`,photoEmptyIcon:`var(--openui-intelligent-photo-empty-icon, var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent)))`},ee={intelligentMono:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,intelligentChart1:`#0285ff`,intelligentChart2:`#00a67d`,intelligentChart3:`#8b5cf6`,intelligentChart4:`#f4a340`,intelligentChart5:`#e46d91`,intelligentChart6:`#4b9ca6`,intelligentSpaceTight:`4px`,intelligentSpaceInner:`8px`,intelligentSpaceGroup:`12px`,intelligentSpaceGroupLg:`16px`,intelligentSpaceSection:`24px`,intelligentControlGap:`8px`,intelligentFieldGap:`24px`,intelligentActionGap:`40px`,intelligentRadiusSm:`6px`,intelligentRadiusMd:`10px`,intelligentRadiusLg:`12px`,intelligentRadiusXl:`14px`},te={...ee},ne={...ee},h=Symbol(`OpenUI.IntelligentTheme`);function re(){return(0,l.inject)(h,null)}function ie(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z])/g,`$1-$2`).replace(/([a-z])(\d)/g,`$1-$2`).toLowerCase()}function ae(e){let t={},n={};for(let[r,i]of Object.entries(e??{}))r.startsWith(`intelligent`)&&r.length>11?typeof i==`string`&&(n[r]=i):t[r]=i;return{components:t,intelligent:n}}function oe(e){return Object.entries(e).filter(([,e])=>typeof e==`string`).map(([e,t])=>`--openui-${ie(e)}: ${t};`).join(` `)}function se(e){return e.replace(/[^a-zA-Z0-9-_]/g,``)}const ce=(0,l.defineComponent)({name:`OpenUIIntelligentVariables`,props:{id:{type:String,required:!0},scope:{type:String,required:!0},mode:{type:String,required:!0},theme:{type:Object,required:!0}},setup(e){let{portalThemeClassName:t}=(0,c.useTheme)(),n=(0,l.computed)(()=>{let n=`color-scheme: ${e.mode}; color: var(--openui-text-neutral-primary); font-family: ${m.font}; ${oe(e.theme)}`,r=[`.${e.scope}`];return t.value&&r.push(`.${t.value}`),`${r.join(`, `)} { ${n} }`}),r,i=()=>{if(typeof document>`u`||r?.textContent===n.value)return;r?.remove(),r=document.createElement(`style`);let t=window.__nonce__;t&&(r.nonce=t),r.setAttribute(`data-openui-intelligent-theme`,e.id),r.textContent=n.value,document.head.appendChild(r)};return(0,l.onMounted)(i),(0,l.onUpdated)(i),(0,l.onBeforeUnmount)(()=>r?.remove()),()=>(n.value,null)}}),le=(0,l.defineComponent)({name:`OpenUIIntelligentThemeProvider`,inheritAttrs:!1,props:{mode:String,lightTheme:Object,darkTheme:Object},setup(e,{slots:t}){let n=se((0,l.useId)()),r=(0,l.inject)(h,null),{mode:i}=(0,c.useTheme)(),a=(0,l.computed)(()=>e.mode??r?.mode.value??i.value??`light`),o=`openui-intelligent-theme-${n}`,s=(0,l.computed)(()=>({light:{...r?.overrides.value.light,...e.lightTheme},dark:{...r?.overrides.value.dark,...e.darkTheme??e.lightTheme}})),u=(0,l.computed)(()=>ae(s.value.light)),d=(0,l.computed)(()=>ae(s.value.dark)),f=(0,l.computed)(()=>a.value===`light`?{...te,...u.value.intelligent}:{...ne,...d.value.intelligent});return(0,l.provide)(h,{mode:a,theme:f,overrides:s}),()=>(0,l.h)(`div`,{class:o,"data-openui-intelligent-mode":a.value,style:{display:`contents`}},[(0,l.h)(c.ThemeProvider,{mode:a.value,cssSelector:`.${o}`,lightTheme:u.value.components,darkTheme:d.value.components},{default:()=>[(0,l.h)(ce,{id:n,scope:o,mode:a.value,theme:f.value}),t.default?.()]})])}}),ue=(0,l.defineComponent)({name:`OpenUIIntelligentRootTheme`,inheritAttrs:!1,setup(e,{slots:t}){let n=(0,l.inject)(h,null);return()=>n?t.default?.():(0,l.h)(le,null,{default:()=>t.default?.()})}}),de=/(url|image|image-set|cross-fade|element|expression|paint|var|attr|env)\s*\(|@import|[\\;{}<>]/i,fe=e=>!de.test(e),pe=[`info`,`success`,`warning`,`danger`,`purple`,`pink`],me={ink:m.ink,muted:m.muted,faint:m.faint,canvas:m.canvas,surface:m.surface,...Object.fromEntries(pe.map(e=>[e,m[e]])),chart1:m.chart1,chart2:m.chart2,chart3:m.chart3,chart4:m.chart4,chart5:m.chart5,chart6:m.chart6},he={...me,surface:m.surface,"surface-strong":m.surfaceStrong,border:m.border,...Object.fromEntries(pe.map(e=>[e,m[`${e}Soft`]]))},ge=e=>typeof e==`string`&&e.trim()&&fe(e)?e.trim():void 0,g=e=>typeof e==`string`?me[e]??ge(e):void 0,_e=e=>typeof e==`string`?he[e]??ge(e):void 0,ve=e=>e in he,_=e=>typeof e==`number`&&Number.isFinite(e)?`${Math.max(0,e)*4}px`:void 0;function v(e){if(typeof e==`number`&&Number.isFinite(e))return`${Math.max(0,e)}px`;if(typeof e==`string`)return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:/^\d+(\.\d+)?(px|%|em|rem|vh|vw|fr)$|^auto$/.test(e.trim())?e.trim():void 0}const ye={sm:m.radiusSm,md:m.radiusMd,lg:m.radiusLg,xl:m.radiusXl,full:`999px`},be=e=>typeof e==`string`?ye[e]:v(e),xe={start:`flex-start`,end:`flex-end`,center:`center`,stretch:`stretch`,between:`space-between`},Se=(e,t=!1)=>({gap:_(e.gap),alignItems:e.align?xe[e.align]:void 0,justifyContent:e.justify?xe[e.justify]:void 0,flexWrap:e.wrap?`wrap`:void 0,textAlign:t&&(e.align===`center`||e.align===`end`)?e.align:void 0}),Ce=/* @__PURE__ */ new Map,y=(0,l.defineComponent)({name:`OpenUIIntelligentLucideIcon`,props:{name:{type:String,required:!0},size:{type:Number,default:16},color:String},setup(e){let t=(0,l.shallowRef)(null);return(0,l.watch)(()=>e.name,e=>{if(!e){t.value=null;return}let n=Ce.get(e);if(n){t.value=n;return}let r=(0,d.getIconImport)(e);if(!r){t.value=null;return}let i=!1;return r().then(n=>{if(i)return;let r=n?.default;r&&(Ce.set(e,r),t.value=r)}).catch(()=>{i||(t.value=null)}),()=>{i=!0}},{immediate:!0}),()=>{let n=t.value,r=g(e.color)??`currentColor`;return n?(0,l.h)(n,{size:e.size,color:r,style:{display:`inline-block`,flexShrink:0,verticalAlign:`middle`}}):(0,l.h)(`span`,{class:`openui-intelligent-icon-placeholder`,"data-icon":e.name,"aria-hidden":`true`,style:{display:`inline-block`,width:`${e.size}px`,height:`${e.size}px`,verticalAlign:`middle`}})}}}),we=e=>(e?.innerText??``).replace(/\s+/g,` `).trim().slice(0,120),b=e=>e==null?``:String(e),Te=e=>typeof e!=`number`||!Number.isFinite(e)?``:e.toLocaleString(`en-US`,{maximumFractionDigits:2}),Ee=f.z.object({text:f.z.string(),color:f.z.enum([`neutral`,`info`,`success`,`warning`,`danger`,`purple`,`pink`]).optional(),icon:f.z.string().optional()}),De={neutral:{bg:m.badgeNeutralSoft,fg:m.ink},info:{bg:m.infoSoft,fg:m.info},success:{bg:m.badgeSuccessSoft,fg:m.badgeSuccess},warning:{bg:m.badgeWarningSoft,fg:m.badgeWarning},danger:{bg:m.badgeDangerSoft,fg:m.badgeDanger},purple:{bg:m.badgePurpleSoft,fg:m.badgePurple},pink:{bg:m.badgePinkSoft,fg:m.badgePink}},Oe=(0,u.defineComponent)({name:`Badge`,props:Ee,description:`Pill tag; icon is an optional leading lucide name.`,component:({props:e})=>{let t=De[e.color??`neutral`]??De.neutral;return(0,l.h)(`span`,{class:`openui-intelligent-badge`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`2px 8px`,borderRadius:`999px`,fontSize:`12px`,fontWeight:500,lineHeight:1.4,background:t.bg,color:t.fg,verticalAlign:`middle`}},[e.icon?(0,l.h)(y,{name:e.icon,size:12}):null,b(e.text)])}});function ke(e){if(typeof e!=`string`||ve(e))return;let t=null,n=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(e.trim());if(n){let e=n[1].length===3?n[1].replace(/./g,`$&$&`):n[1];t=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}else{let n=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());n&&(t=[n[1],n[2],n[3]].map(Number))}if(!t)return;let[r,i,a]=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a>.36?`#0d0d0d`:`#ffffff`}const Ae=e=>`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='${e}' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5'/%3E%3C/svg%3E")`;function je(e){let t=ke(e);if(!t)return{};let n=t!==`#ffffff`;return{color:t,"--openui-intelligent-ink":t,"--openui-intelligent-muted":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-faint":`color-mix(in srgb, ${t} 55%, transparent)`,"--openui-text-neutral-primary":t,"--openui-text-neutral-secondary":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-on-ink":n?`#ffffff`:`#0d0d0d`,"--_openui-intelligent-pressable-check-icon":Ae(n?`white`:`%230d0d0d`)}}function Me(e){try{return new URL(e.trim()).protocol}catch{return null}}function Ne(e){if(typeof e!=`string`)return null;let t=Me(e);return t===`http:`||t===`https:`?e.trim():null}const Pe=f.z.any();(0,u.tagSchemaId)(Pe,`Node`);const x=f.z.array(Pe),S=f.z.string();(0,u.tagSchemaId)(S,`Color`);const C=f.z.union([f.z.number(),f.z.string()]);(0,u.tagSchemaId)(C,`Length`);const w=f.z.union([f.z.enum([`sm`,`md`,`lg`,`xl`,`full`]),f.z.number()]);(0,u.tagSchemaId)(w,`Radius`);const Fe=f.z.enum([`cover`,`contain`]),T=f.z.object({required:f.z.boolean().optional(),email:f.z.boolean().optional(),url:f.z.boolean().optional(),numeric:f.z.boolean().optional(),min:f.z.number().optional(),max:f.z.number().optional(),minLength:f.z.number().optional(),maxLength:f.z.number().optional(),pattern:f.z.string().optional()});(0,u.tagSchemaId)(T,`Rules`);const Ie=f.z.union([f.z.string(),f.z.object({value:f.z.string(),label:f.z.string()})]);function Le(e){if(e==null)return null;if(typeof e!=`object`)return{value:String(e),label:String(e)};let{value:t,label:n,description:r}=e,i=n??t;return i==null?null:{value:String(t??n),label:String(i),...typeof r==`string`&&{description:r}}}const Re=f.z.enum([`start`,`center`,`end`,`stretch`]),ze=f.z.enum([`start`,`center`,`end`,`between`]),E=f.z.union([f.z.string(),x]),D=/(\*\*([^*]+)\*\*|\*([^*]+)\*|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\))/g;function O(e){if(!e)return``;let t=[],n=0;D.lastIndex=0;let r;for(;(r=D.exec(e))!==null;){if(r.index>n&&t.push(e.slice(n,r.index)),r[2]!==void 0)t.push((0,l.h)(`strong`,null,r[2]));else if(r[3]!==void 0)t.push((0,l.h)(`em`,null,r[3]));else if(r[4]!==void 0)t.push((0,l.h)(`code`,{style:{fontFamily:m.mono,fontSize:`0.88em`,padding:`0.1em 0.35em`,borderRadius:m.radiusSm,background:m.surface}},r[4]));else if(r[5]!==void 0&&r[6]!==void 0){let e=Ne(r[6]);e?t.push((0,l.h)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,style:{color:m.info,textDecoration:`underline`}},r[5])):t.push(r[5])}n=D.lastIndex}return n<e.length&&t.push(e.slice(n)),t.length===1?t[0]:t}const k=(e,t)=>typeof e==`string`||typeof e==`number`?O(String(e)):t(Array.isArray(e)?e.flat():e),Be=e=>!!e&&typeof e==`object`&&e.type===`element`,Ve=f.z.object({children:x.optional(),direction:f.z.enum([`row`,`col`]).optional(),gap:f.z.number().optional(),padding:f.z.number().optional(),background:S.optional(),radius:w.optional(),border:f.z.boolean().optional(),width:C.optional(),height:C.optional(),flex:f.z.number().optional(),align:Re.optional(),justify:ze.optional(),wrap:f.z.boolean().optional()}),He=(0,u.defineComponent)({name:`Box`,props:Ve,description:`Flex container, a column by default. radius also clips the content.`,component:({props:e,renderNode:t})=>{let n=e.direction!==`row`,r=be(e.radius),i={display:`flex`,flexDirection:n?`column`:`row`,padding:_(e.padding),background:_e(e.background),borderRadius:r,overflow:r?`hidden`:void 0,border:e.border?`1px solid ${m.border}`:void 0,width:v(e.width),height:v(e.height),flex:typeof e.flex==`number`&&Number.isFinite(e.flex)?e.flex:void 0,...Se(e,n),...je(e.background)};return(0,l.h)(`div`,{class:`openui-intelligent-box`,style:i},[t(e.children)])}}),Ue=e=>{let t=e?.steps;return!t||t.some(e=>e.type===u.ACTION_STEPS.ToAssistant||e.type===`custom_action`||e.type===u.ACTION_STEPS.Run&&e.refType===`mutation`)};function We(){let e=(0,u.useTriggerAction)(),t=(0,u.useFormName)(),n=(0,u.useFormValidation)();return(r,i,a)=>{(i||a)&&(!n||i&&!Ue(i)||n.validateForm())&&(i?e(r,t.value,i):e(r,t.value))}}function A(e,t,n){let r=(0,u.useFormValidation)(),i=(0,l.computed)(()=>(0,u.parseStructuredRules)((0,l.toValue)(t))),a=(0,l.computed)(()=>!!r&&i.value.length>0),o=null;return(0,l.watchEffect)(()=>{let t=(0,l.toValue)(e),a=i.value;o&&o!==t&&(r?.unregisterField(o),o=null),r&&a.length>0?(r.registerField(t,a,()=>(0,l.toValue)(n)),o=t):o&&=(r?.unregisterField(o),null)}),(0,l.onScopeDispose)(()=>{o&&=(r?.unregisterField(o),null)}),{required:(0,l.computed)(()=>a.value&&i.value.some(e=>e.type===`required`)),error:(0,l.computed)(()=>a.value?r?.errors[(0,l.toValue)(e)]:void 0),check:()=>{a.value&&r&&r.validateField((0,l.toValue)(e),(0,l.toValue)(n),i.value)},clear:()=>{a.value&&r&&r.clearFieldError((0,l.toValue)(e))}}}function j(e,t){let n=(0,l.useId)();return(0,l.computed)(()=>{let r=(0,l.toValue)(t);if(r)return r;let i=(0,l.toValue)(e);return typeof i==`string`&&i?i:n})}function M(e){return(0,l.h)(`div`,{class:`openui-intelligent-field`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:m.font}},[e.label?(0,l.h)(`label`,{style:{fontSize:`13px`,fontWeight:500,color:m.ink,display:`inline-flex`,alignItems:`center`,gap:`4px`}},[e.label,e.required?(0,l.h)(`span`,{style:{color:m.danger},"aria-hidden":`true`},`*`):null]):null,e.control,e.error?(0,l.h)(`div`,{role:`alert`,style:{fontSize:`12px`,color:m.danger}},e.error):null])}const Ge=f.z.array(Ie),N=e=>Array.isArray(e)?e.flat().flatMap(e=>Le(e)??[]):[],Ke=f.z.union([f.z.string(),f.z.object({value:f.z.string(),label:f.z.string(),description:f.z.string().optional()})]),qe=e=>N(e),Je=f.z.object({label:f.z.string(),action:(0,u.action)().optional(),variant:f.z.enum([`solid`,`outline`,`soft`,`ghost`]).optional(),color:f.z.enum([`primary`,`danger`,`success`]).optional(),size:f.z.enum([`sm`,`md`,`lg`]).optional(),icon:f.z.string().optional(),disabled:f.z.boolean().optional(),block:f.z.boolean().optional()}),Ye={sm:{padding:`5px 10px`,fontSize:`12px`,borderRadius:m.radiusSm},md:{padding:`8px 14px`,fontSize:`13px`,borderRadius:m.radiusMd},lg:{padding:`10px 18px`,fontSize:`14px`,borderRadius:m.radiusMd}},Xe=(0,l.defineComponent)({name:`OpenUIIntelligentButton`,props:{props:{type:Object,required:!0}},setup(e){let t=We(),n=(0,u.useIsStreaming)();return()=>{let r=e.props.variant??`solid`,i=e.props.color??`primary`,a=e.props.size??`md`,o=!!(e.props.disabled||n.value),s=b(e.props.label),c=i===`danger`?m.danger:i===`success`?m.success:m.ink,u=i===`danger`?m.dangerSoft:i===`success`?m.successSoft:m.surface,d=r===`solid`?{background:c,color:i===`primary`?m.onInk:`#ffffff`,border:`1px solid transparent`}:r===`outline`?{background:`transparent`,color:c,border:`1px solid ${m.borderStrong}`}:r===`soft`?{background:u,color:c,border:`1px solid transparent`}:{background:`transparent`,color:c,border:`1px solid transparent`};return(0,l.h)(`button`,{type:`button`,disabled:o,class:`openui-intelligent-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,fontFamily:m.font,fontWeight:500,cursor:o?`not-allowed`:`pointer`,opacity:o?.55:1,width:e.props.block?`100%`:void 0,...Ye[a],...d},onClick:()=>{o||t(s,e.props.action,!0)}},[e.props.icon?(0,l.h)(y,{name:e.props.icon,size:a===`sm`?13:15}):null,s])}}}),Ze=(0,u.defineComponent)({name:`Button`,props:Je,description:`icon is a lucide name. Without an action it sends its label to the assistant.`,component:Xe}),Qe=f.z.object({text:f.z.string(),color:S.optional()}),$e=(0,u.defineComponent)({name:`Caption`,props:Qe,description:`Small secondary text.`,component:({props:e})=>(0,l.h)(`span`,{class:`openui-intelligent-caption`,style:{fontSize:`12px`,lineHeight:1.45,color:g(e.color)??m.muted}},b(e.text))}),et=f.z.object({children:x,variant:f.z.enum([`outline`,`soft`]).optional(),gap:f.z.number().optional(),padding:f.z.number().optional()}),tt=(0,u.defineComponent)({name:`Card`,props:et,description:`Panel with a border; soft is a filled panel for summaries.`,component:({props:e,renderNode:t})=>{let n=e.variant===`soft`;return(0,l.h)(`div`,{class:[`openui-intelligent-card`,n?`openui-intelligent-card--soft`:`openui-intelligent-card--outline`],style:{display:`flex`,flexDirection:`column`,gap:_(e.gap)??m.spaceGroup,padding:_(e.padding)??m.spaceGroupLg,borderRadius:m.radiusLg,background:n?m.surface:m.canvas,border:n?`1px solid transparent`:`1px solid ${m.border}`}},[t(e.children)])}}),nt=f.z.object({children:x,itemWidth:f.z.number().optional(),gap:f.z.number().optional()}),rt=(0,u.defineComponent)({name:`Carousel`,props:nt,description:`Horizontal row that scrolls and snaps, each child an item itemWidth px wide (default 240): photos, cards, options, days.`,component:({props:e,renderNode:t})=>{let n=typeof e.itemWidth==`number`&&e.itemWidth>0?e.itemWidth:240,r=Array.isArray(e.children)?e.children.flat():[];return(0,l.h)(`div`,{class:`openui-intelligent-carousel`,style:{display:`flex`,flexDirection:`row`,gap:_(e.gap)??m.spaceGroup,overflowX:`auto`,scrollSnapType:`x mandatory`,paddingBottom:`4px`}},r.map((e,r)=>(0,l.h)(`div`,{key:r,style:{flex:`0 0 ${n}px`,maxWidth:`100%`,scrollSnapAlign:`start`}},[t(e)])))}}),it=f.z.object({when:f.z.boolean()}),at=[m.chart1,m.chart2,m.chart3,m.chart4,m.chart5,m.chart6],ot=(0,l.defineComponent)({name:`OpenUIIntelligentCelebration`,props:{props:{type:Object,required:!0}},setup(e){let t=(0,u.useIsStreaming)(),n=(0,l.ref)(!1),r=null;return(0,l.watch)(()=>[e.props.when===!0,t.value],([e,t],i)=>{let a=i?.[0]??!1;e&&!t&&!a&&(n.value=!0,r&&clearTimeout(r),r=setTimeout(()=>{n.value=!1},2200))},{immediate:!0}),()=>n.value?(0,l.h)(`div`,{"aria-hidden":`true`,class:`openui-intelligent-celebration`,style:{position:`relative`,height:`12px`,overflow:`visible`,pointerEvents:`none`,display:`flex`,justifyContent:`space-around`}},Array.from({length:12},(e,t)=>(0,l.h)(`span`,{key:t,style:{width:`8px`,height:`8px`,borderRadius:t%2==0?`999px`:`2px`,background:at[t%at.length],display:`inline-block`,transform:`rotate(${t*37%360}deg)`}}))):null}}),st=(0,u.defineComponent)({name:`Celebration`,props:it,description:`Bursts confetti when its condition turns true, e.g. Celebration($score == 5) at the end of a quiz.`,component:ot}),ct=f.z.object({type:f.z.enum([`bar`,`line`,`area`,`pie`,`donut`,`scatter`]),data:f.z.array(f.z.record(f.z.string(),f.z.union([f.z.string(),f.z.number()]))),x:f.z.string().optional(),series:f.z.array(f.z.string()).optional(),format:f.z.enum([`number`,`percent`]).optional(),stacked:f.z.boolean().optional(),height:f.z.number().optional()}),lt=e=>Array.isArray(e)?e.filter(e=>e&&typeof e==`object`):[],ut=(e,t)=>{if(t)return t;let n=e[0]??{};return Object.keys(n).find(e=>typeof n[e]==`string`)??Object.keys(n)[0]??``},dt=(e,t,n)=>{if(n?.length)return n;let r=e[0]??{};return Object.keys(r).filter(e=>e!==t&&typeof r[e]==`number`)},ft=(e,t,n)=>e.map(e=>{let r={[t]:e[t]??``};for(let t of n)r[t]=typeof e[t]==`number`?e[t]:0;return r}),pt=[`intelligentChart1`,`intelligentChart2`,`intelligentChart3`,`intelligentChart4`,`intelligentChart5`,`intelligentChart6`];function mt(e,t){let n=e?.theme.value??te,r=pt.map(e=>n[e]??te[e]??`#0285ff`),i=Array.from({length:Math.max(t,1)},(e,t)=>r[t%r.length]);return i.length>2&&i.length%2==0&&i.unshift(i.pop()),i}const ht=(0,l.defineComponent)({name:`OpenUIIntelligentChart`,props:{props:{type:Object,required:!0}},setup(e){let t=re();return()=>{let n=lt(e.props.data),r=ut(n,e.props.x),i=dt(n,r,e.props.series),a=typeof e.props.height==`number`?e.props.height:void 0;if(!n.length||!r)return null;if(e.props.type===`pie`||e.props.type===`donut`)return(0,l.h)(c.PieChart,{data:n,categoryKey:r,dataKey:i[0]??``,variant:e.props.type,format:e.props.format===`percent`?`percentage`:`number`,customPalette:mt(t,n.length),isAnimationActive:!1});if(e.props.type===`scatter`){let e=i.map(e=>({name:e,data:n.map(t=>({x:Number(t[r]??0),y:Number(t[e]??0)}))}));return(0,l.h)(c.ScatterChart,{data:e,xAxisDataKey:`x`,yAxisDataKey:`y`,height:a,customPalette:mt(t,e.length),isAnimationActive:!1})}let o={data:ft(n,r,i),categoryKey:r,height:a,customPalette:mt(t,i.length),isAnimationActive:!1};return e.props.type===`line`?(0,l.h)(c.LineChart,o):e.props.type===`area`?(0,l.h)(c.AreaChart,{...o,stacked:e.props.stacked===!0}):(0,l.h)(c.BarChart,{...o,variant:e.props.stacked?`stacked`:`grouped`})}}}),gt=(0,u.defineComponent)({name:`Chart`,props:ct,description:`Rows of data; x is the category key (a number key for scatter), series the value keys (default: every number key). format applies to pie and donut only: "percent" shows each slice as a share of the total, "number" its value. stacked stacks bar and area series. height sets the plot height in px; pie and donut ignore it and size themselves.`,component:ht}),_t=f.z.object({checked:(0,u.reactive)(f.z.boolean()),label:f.z.string(),lineThrough:f.z.boolean().optional(),rules:T.optional()}),vt=(0,l.defineComponent)({name:`OpenUIIntelligentCheckbox`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.checked),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=n.value===!0;return(0,l.h)(`div`,{class:`openui-intelligent-checkbox`,style:{display:`flex`,flexDirection:`column`,gap:`4px`}},[(0,l.h)(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:`8px`,cursor:i.value?`not-allowed`:`pointer`,fontSize:`14px`,color:t&&e.props.lineThrough?m.muted:m.ink,textDecoration:t&&e.props.lineThrough?`line-through`:void 0}},[(0,l.h)(`input`,{type:`checkbox`,checked:t,disabled:i.value,style:{width:`16px`,height:`16px`,accentColor:m.ink},onChange:e=>{r.clear(),n.setValue(e.target.checked)}}),(0,l.h)(`span`,null,[b(e.props.label),r.required.value?(0,l.h)(`span`,{style:{color:m.danger,marginLeft:`4px`}},`*`):null])]),r.error.value?(0,l.h)(`div`,{role:`alert`,style:{fontSize:`12px`,color:m.danger}},r.error.value):null])}}}),yt=(0,u.defineComponent)({name:`Checkbox`,props:_t,description:`lineThrough strikes the label when checked, for to-do lists. rules takes only required.`,component:vt}),bt=f.z.object({code:f.z.string(),language:f.z.string().optional()}),xt=(0,u.defineComponent)({name:`Code`,props:bt,description:`Code block with a copy button.`,component:({props:e})=>(0,l.h)(c.CodeBlock,{language:b(e.language)||`text`,codeString:b(e.code)})}),St=f.z.object({children:x,gap:f.z.number().optional(),align:Re.optional()}),Ct=(0,l.defineComponent)({name:`OpenUIIntelligentCol`,inheritAttrs:!1,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){return()=>{let t=(0,l.h)(`div`,{class:`openui-intelligent-col`,style:{display:`flex`,flexDirection:`column`,gap:e.props.gap===void 0?m.spaceGroup:void 0,...Se(e.props,!0)}},e.renderNode(e.props.children));return e.statementId===`root`?(0,l.h)(ue,null,{default:()=>t}):t}}}),wt=(0,u.defineComponent)({name:`Col`,props:St,description:`Vertical layout. Without gap it spaces blocks like an article.`,component:Ct}),Tt=f.z.object({value:(0,u.reactive)(f.z.string()),label:f.z.string().optional(),min:f.z.string().optional(),max:f.z.string().optional(),rules:T.optional()}),Et=(0,l.defineComponent)({name:`OpenUIIntelligentDatePicker`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`input`,{type:`date`,value:n.value==null?``:String(n.value),min:e.props.min?b(e.props.min):void 0,max:e.props.max?b(e.props.max):void 0,disabled:i.value,class:`openui-intelligent-date-picker`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}),Dt=(0,u.defineComponent)({name:`DatePicker`,props:Tt,description:`Dates, min and max are "YYYY-MM-DD". rules takes only required.`,component:Et}),Ot=f.z.object({}),kt=(0,u.defineComponent)({name:`Divider`,props:Ot,description:`A thin horizontal rule between blocks.`,component:()=>(0,l.h)(`hr`,{class:`openui-intelligent-divider`,style:{border:`none`,borderTop:`1px solid ${m.border}`,margin:`4px 0`,width:`100%`}})}),At=f.z.object({front:E,back:E,hint:f.z.string().optional()}),jt=(0,l.defineComponent)({name:`OpenUIIntelligentFlashcard`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=(0,l.ref)(!1);return()=>{let n=t.value?e.props.back:e.props.front,r=typeof n==`string`?(0,l.h)(`div`,{style:{fontSize:`20px`,fontWeight:600,color:m.ink,textAlign:`center`}},n):k(n,e.renderNode),i=b(e.props.hint);return(0,l.h)(`button`,{type:`button`,"aria-pressed":t.value,class:[`openui-intelligent-flashcard`,t.value?`openui-intelligent-flashcard--back`:`openui-intelligent-flashcard--front`],style:{width:`100%`,minHeight:`140px`,padding:`20px`,borderRadius:m.radiusLg,border:`1px solid ${m.borderStrong}`,background:t.value?m.surface:m.canvas,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`10px`,cursor:`pointer`,font:`inherit`,color:m.ink},onClick:()=>{t.value=!t.value}},[r,!t.value&&i?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},i):(0,l.h)(`span`,{style:{fontSize:`11px`,color:m.faint}},t.value?`Back · tap to flip`:`Tap to flip`)])}}}),Mt=(0,u.defineComponent)({name:`Flashcard`,props:At,description:`Card that flips between front and back when tapped. Put several in a Carousel or Grid.`,component:jt}),Nt=f.z.object({children:x}),Pt=(0,l.defineComponent)({name:`OpenUIIntelligentForm`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){let t=(0,l.useId)(),n=(0,u.useCreateFormValidation)();return(0,l.provide)(u.FormValidationContext,n),(0,l.provide)(u.FormNameContext,()=>e.statementId??t),()=>(0,l.h)(`form`,{class:`openui-intelligent-form`,novalidate:!0,style:{display:`flex`,flexDirection:`column`,gap:m.spaceGroupLg},onSubmit:e=>{e.preventDefault()}},e.renderNode(e.props.children))}}),Ft=(0,u.defineComponent)({name:`Form`,props:Nt,description:`Groups fields; their values go with any @ToAssistant inside, once every field's rules pass.`,component:Pt}),It=f.z.object({children:x,columns:f.z.number().optional(),minChildWidth:f.z.number().optional(),gap:f.z.number().optional()}),Lt=(0,u.defineComponent)({name:`Grid`,props:It,description:`Equal columns, 1 to 12 (default 2). With minChildWidth (px), columns drop on narrow screens.`,component:({props:e,renderNode:t})=>{let n=typeof e.columns==`number`&&Number.isFinite(e.columns)?Math.min(12,Math.max(1,Math.round(e.columns))):2,r=typeof e.minChildWidth==`number`&&e.minChildWidth>0?Math.round(e.minChildWidth):void 0,i=r?`repeat(auto-fit, minmax(min(${r}px, 100%), 1fr))`:`repeat(${n}, minmax(0, 1fr))`;return(0,l.h)(`div`,{class:`openui-intelligent-grid`,style:{display:`grid`,gridTemplateColumns:i,gap:_(e.gap)??m.spaceGroup}},[t(e.children)])}});function Rt(){let e=re(),t=(0,c.useTheme)();return(0,l.computed)(()=>e?.mode.value??t.mode.value??`light`)}const zt=f.z.object({html:f.z.string(),height:f.z.number().optional(),title:f.z.string().optional()}),Bt=`https://cdn.jsdelivr.net https://unpkg.com https://cdnjs.cloudflare.com https://esm.sh`,Vt=[`default-src 'none'`,`script-src 'unsafe-inline' ${Bt}`,`style-src 'unsafe-inline' ${Bt} https://fonts.googleapis.com`,`font-src https://fonts.gstatic.com data:`,`img-src data: blob: https:`,`media-src data: blob:`,`connect-src ${Bt}`,`frame-src 'none'`,`form-action 'none'`,`base-uri 'none'`].join(`; `),Ht=2400;function Ut(e,t){return`<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${Vt}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>:root{color-scheme:${t}}html,body{margin:0}body{font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}</style><script>(function(){var last=0;function send(){var h=Math.ceil(document.documentElement.getBoundingClientRect().height);if(Math.abs(h-last)>1){last=h;parent.postMessage({type:"openui-intelligent-html-view-height",height:h},"*")}}addEventListener("message",function(e){if(e.source===parent&&e.data==="openui-intelligent-html-view-measure"){last=0;send()}});addEventListener("load",send);new ResizeObserver(send).observe(document.documentElement);send()})()<\/script>${e}`}const Wt=(0,l.defineComponent)({name:`OpenUIIntelligentHtmlView`,props:{props:{type:Object,required:!0}},setup(e){let t=(0,u.useIsStreaming)(),n=Rt(),r=(0,l.ref)(null),i=(0,l.ref)(null),a=(0,l.computed)(()=>typeof e.props.height==`number`&&e.props.height>0?Math.min(Ht,Math.max(80,e.props.height)):null),o=(0,l.computed)(()=>Ut(typeof e.props.html==`string`?e.props.html:``,n.value)),s=e=>{if(a.value!==null||e.source!==r.value?.contentWindow)return;let t=e.data;t?.type===`openui-intelligent-html-view-height`&&typeof t.height==`number`&&Number.isFinite(t.height)&&(i.value=Math.min(Ht,Math.max(80,t.height)))};return(0,l.onMounted)(()=>{typeof window<`u`&&(window.addEventListener(`message`,s),r.value?.contentWindow?.postMessage(`openui-intelligent-html-view-measure`,`*`))}),(0,l.onBeforeUnmount)(()=>{typeof window<`u`&&window.removeEventListener(`message`,s)}),()=>{let n=a.value??i.value??360;return(0,l.h)(`div`,{class:`openui-intelligent-html-view`,style:{width:`100%`,height:`${n}px`,borderRadius:m.radiusMd,border:`1px solid ${m.border}`,overflow:`hidden`,background:m.surface}},t.value?[(0,l.h)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,color:m.muted,fontSize:`13px`}},`Preparing the interactive view…`)]:[(0,l.h)(`iframe`,{ref:r,title:e.props.title||`Interactive view`,sandbox:`allow-scripts`,srcdoc:o.value,referrerpolicy:`no-referrer`,loading:`lazy`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})])}}}),Gt=(0,u.defineComponent)({name:`HtmlView`,props:zt,description:`Sandboxed HTML page with inline JS, for games and canvas. No network except script CDNs. Fits its content unless height is set.`,component:Wt}),Kt=f.z.object({name:f.z.string(),size:f.z.enum([`sm`,`md`,`lg`,`xl`]).optional(),color:S.optional()}),qt={sm:14,md:18,lg:22,xl:28},Jt=(0,u.defineComponent)({name:`Icon`,props:Kt,description:`Lucide icon by name, e.g. "map-pin".`,component:({props:e})=>(0,l.h)(y,{name:b(e.name),size:qt[e.size??`md`]??18,color:e.color})}),Yt=f.z.object({icon:f.z.string(),action:(0,u.action)().optional(),label:f.z.string().optional(),variant:f.z.enum([`outline`,`ghost`,`solid`]).optional()}),Xt=(0,l.defineComponent)({name:`OpenUIIntelligentIconButton`,props:{props:{type:Object,required:!0}},setup(e){let t=We(),n=(0,u.useIsStreaming)();return()=>{let r=e.props.variant??`outline`,i=b(e.props.label)||b(e.props.icon),a=n.value,o=r===`solid`?{background:m.ink,color:m.onInk,border:`1px solid transparent`}:r===`ghost`?{background:`transparent`,color:m.ink,border:`1px solid transparent`}:{background:m.canvas,color:m.ink,border:`1px solid ${m.borderStrong}`};return(0,l.h)(`button`,{type:`button`,disabled:a,"aria-label":i,title:i,class:`openui-intelligent-icon-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`34px`,height:`34px`,borderRadius:`999px`,cursor:a?`not-allowed`:`pointer`,opacity:a?.55:1,...o},onClick:()=>{a||t(i,e.props.action,!1)}},[(0,l.h)(y,{name:b(e.props.icon),size:16})])}}}),Zt=(0,u.defineComponent)({name:`IconButton`,props:Yt,description:`Round icon-only button; label is read aloud. Needs an action.`,component:Xt}),Qt=f.z.object({src:f.z.string(),alt:f.z.string(),aspectRatio:f.z.number().optional(),radius:w.optional(),fit:Fe.optional()}),$t=(0,l.defineComponent)({name:`OpenUIIntelligentImage`,props:{props:{type:Object,required:!0}},setup(e){let t=(0,l.ref)(!1);return()=>{let n=Ne(e.props.src),r=typeof e.props.aspectRatio==`number`&&Number.isFinite(e.props.aspectRatio)?Math.min(5,Math.max(.2,e.props.aspectRatio)):1.5,i=be(e.props.radius)??m.radiusMd,a={width:`100%`,aspectRatio:String(r),borderRadius:i,overflow:`hidden`,background:m.photoEmpty,display:`flex`,alignItems:`center`,justifyContent:`center`};return!n||t.value?(0,l.h)(`div`,{role:`img`,"aria-label":b(e.props.alt)||`Image unavailable`,class:`openui-intelligent-image openui-intelligent-image--empty`,style:a},[(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},b(e.props.alt)||`Image`)]):(0,l.h)(`div`,{class:`openui-intelligent-image`,style:a},[(0,l.h)(`img`,{src:n,alt:b(e.props.alt),loading:`lazy`,referrerpolicy:`no-referrer`,style:{width:`100%`,height:`100%`,objectFit:e.props.fit===`contain`?`contain`:`cover`,display:`block`},onError:()=>{t.value=!0}})])}}}),en=(0,u.defineComponent)({name:`Image`,props:Qt,description:`Photo from a URL the user or a tool gave; never invent a URL. If it fails to load, an empty photo placeholder shows. aspectRatio is 0.2 to 5 (default 1.5).`,component:$t}),tn=f.z.object({value:(0,u.reactive)(f.z.union([f.z.string(),f.z.number()])),label:f.z.string().optional(),type:f.z.enum([`text`,`number`]).optional(),placeholder:f.z.string().optional(),rules:T.optional()}),nn=(0,l.defineComponent)({name:`OpenUIIntelligentInput`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=e.props.type===`number`,a=n.value==null?``:String(n.value);return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`input`,{type:t?`number`:`text`,value:a,placeholder:e.props.placeholder?b(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-input`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,outline:`none`,boxSizing:`border-box`},onInput:e=>{let i=e.target.value;if(r.clear(),t){if(i.trim()===``)n.setValue(null);else{let e=Number(i);n.setValue(Number.isFinite(e)?e:null)}}else n.setValue(i)},onBlur:()=>r.check()})})}}}),rn=(0,u.defineComponent)({name:`Input`,props:tn,description:`Text or number field; a number field stores numbers, and null when emptied.`,component:nn}),an=f.z.object({text:f.z.string()}),on=(0,u.defineComponent)({name:`Label`,props:an,description:`Field or group label.`,component:({props:e})=>(0,l.h)(`span`,{class:`openui-intelligent-label`,style:{fontSize:`12px`,fontWeight:600,letterSpacing:`0.02em`,color:m.muted}},b(e.text))}),sn=f.z.object({text:f.z.string(),url:f.z.string()}),cn=(0,u.defineComponent)({name:`Link`,props:sn,description:`Opens an http(s) URL in a new tab.`,component:({props:e})=>{let t=Ne(e.url),n=b(e.text);return t?(0,l.h)(`a`,{class:`openui-intelligent-link`,href:t,target:`_blank`,rel:`noopener noreferrer`,style:{color:m.info,textDecoration:`underline`,textUnderlineOffset:`2px`}},n):(0,l.h)(`span`,{class:`openui-intelligent-link`},n)}}),ln=f.z.object({title:f.z.string(),description:f.z.string().optional(),marker:f.z.string().optional(),children:x.optional()});function un(e){return f.z.object({items:f.z.array(f.z.union([f.z.string(),e.ref])),marker:f.z.enum([`bullet`,`number`,`none`]).optional(),timeline:f.z.boolean().optional()})}function dn(e,t){return(0,l.h)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,minWidth:0,flex:1}},[(0,l.h)(`div`,{style:{fontWeight:500,color:m.ink,lineHeight:1.45}},[O(b(e.title))]),e.description?(0,l.h)(`div`,{style:{fontSize:`13px`,color:m.muted,lineHeight:1.45}},[O(b(e.description))]):null,e.children?(0,l.h)(`div`,{style:{marginTop:`4px`}},[t(e.children)]):null])}const fn=(0,u.defineComponent)({name:`ListItem`,props:ln,description:`marker replaces the bullet or number, e.g. a time or an emoji.`,component:({props:e,renderNode:t})=>(0,l.h)(`div`,{class:`openui-intelligent-list-item`,style:{display:`flex`,gap:`8px`,alignItems:`flex-start`}},[typeof e.marker==`string`&&e.marker?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted,flexShrink:0}},e.marker):null,dn(e,t)])}),pn=e=>Be(e)&&e.typeName===`ListItem`,mn=(0,u.defineComponent)({name:`List`,props:un(fn),description:`timeline joins the markers with a line.`,component:({props:e,renderNode:t})=>{let n=(Array.isArray(e.items)?e.items.flat():[]).filter(e=>e!=null),r=e.marker??`bullet`,i=e.timeline===!0;return(0,l.h)(r===`number`?`ol`:`ul`,{class:[`openui-intelligent-list`,i?`openui-intelligent-list--timeline`:null],style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:i?`12px`:`8px`}},n.map((e,n)=>{let a=pn(e)?e.props:null,o=a&&typeof a.marker==`string`?a.marker:void 0,s=o??(r===`none`?null:r===`number`?`${n+1}.`:`•`);return(0,l.h)(`li`,{key:n,style:{display:`flex`,gap:`10px`,alignItems:`flex-start`,position:`relative`,paddingLeft:i?`4px`:void 0,borderLeft:i?`2px solid ${m.borderStrong}`:void 0}},[s?(0,l.h)(`span`,{style:{minWidth:o?`auto`:`18px`,fontSize:`13px`,color:m.muted,fontWeight:500,flexShrink:0}},s):null,a?dn(a,t):(0,l.h)(`div`,{style:{flex:1,lineHeight:1.5,color:m.ink}},[O(b(e))])])}))}}),hn=f.z.object({text:f.z.string()}),gn=(0,u.defineComponent)({name:`Markdown`,props:hn,description:`Prose with headings, lists, quotes, code and tables.`,component:({props:e})=>(0,l.h)(c.MarkDownRenderer,{textMarkdown:b(e.text),className:`openui-intelligent-markdown`})}),_n=f.z.object({tex:f.z.string(),inline:f.z.boolean().optional()}),vn=(0,u.defineComponent)({name:`Math`,props:_n,description:`LaTeX formula, e.g. Math("E = mc^2"); inline true to sit in a Text list.`,component:({props:e})=>{let t=b(e.tex),n=e.inline===!0,r=``;try{r=p.default.renderToString(t,{displayMode:!n,throwOnError:!1,strict:!1})}catch{return(0,l.h)(n?`span`:`div`,{class:`openui-intelligent-math`},t)}return(0,l.h)(n?`span`:`div`,{class:[`openui-intelligent-math`,n?`openui-intelligent-math--inline`:`openui-intelligent-math--block`],style:n?void 0:{overflowX:`auto`,padding:`4px 0`},innerHTML:r})}}),yn=f.z.object({trigger:E,content:E}),bn=(0,l.defineComponent)({name:`OpenUIIntelligentPopover`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=(0,l.ref)(!1);return()=>(0,l.h)(`span`,{class:`openui-intelligent-popover`,style:{position:`relative`,display:`inline-flex`,alignItems:`center`}},[(0,l.h)(`button`,{type:`button`,"aria-expanded":t.value,onClick:()=>{t.value=!t.value},style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,background:`transparent`,border:`none`,padding:`2px 4px`,cursor:`pointer`,color:`inherit`,font:`inherit`,borderRadius:m.radiusSm}},[k(e.props.trigger,e.renderNode)]),t.value?(0,l.h)(`div`,{role:`dialog`,class:`openui-intelligent-popover-panel`,style:{position:`absolute`,top:`calc(100% + 6px)`,left:0,zIndex:40,minWidth:`200px`,maxWidth:`320px`,padding:m.spaceGroup,borderRadius:m.radiusMd,background:m.canvas,color:m.ink,border:`1px solid ${m.borderStrong}`,boxShadow:m.shadow}},[k(e.props.content,e.renderNode)]):null])}}),xn=(0,u.defineComponent)({name:`Popover`,props:yn,description:`Shows content in a small panel when the trigger is clicked: a definition, a source, details behind an Icon("info", "sm"). The trigger is text or an Icon, never a Button: it is a button already.`,component:bn}),Sn=f.z.object({children:x,action:(0,u.action)().optional(),selected:f.z.boolean().optional(),padding:f.z.number().optional(),background:S.optional(),radius:w.optional()}),Cn=(0,l.defineComponent)({name:`OpenUIIntelligentPressable`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=We(),n=(0,u.useIsStreaming)(),r=(0,l.ref)(null);return()=>{let i=e.props.selected===!0,a=n.value,o={display:`flex`,flexDirection:`column`,textAlign:`left`,padding:_(e.props.padding)??m.spaceGroup,borderRadius:be(e.props.radius)??m.radiusMd,background:_e(e.props.background)??(i?m.surfaceStrong:m.canvas),border:i?`2px solid ${m.ink}`:`1px solid ${m.border}`,cursor:a?`not-allowed`:`pointer`,width:`100%`,font:`inherit`,color:`inherit`,...je(e.props.background)};return(0,l.h)(`button`,{ref:r,type:`button`,disabled:a,"aria-pressed":i,class:[`openui-intelligent-pressable`,i?`openui-intelligent-pressable--selected`:null],style:o,onClick:()=>{a||t(we(r.value),e.props.action,!1)}},e.renderNode(e.props.children))}}}),wn=(0,u.defineComponent)({name:`Pressable`,props:Sn,description:`Makes any content clickable, such as a tile or a swatch. Needs an action.`,component:Cn}),Tn=f.z.object({text:f.z.string(),cite:f.z.string().optional()}),En=(0,u.defineComponent)({name:`Quote`,props:Tn,description:`A quotation or a callout with a side rule; cite names the source.`,component:({props:e})=>(0,l.h)(`blockquote`,{class:`openui-intelligent-quote`,style:{margin:0,padding:`8px 14px`,borderLeft:`3px solid ${m.borderStrong}`,background:m.surface,borderRadius:`0 ${m.radiusSm} ${m.radiusSm} 0`,display:`flex`,flexDirection:`column`,gap:`6px`}},[(0,l.h)(`div`,{style:{color:m.ink,lineHeight:1.55}},[O(b(e.text))]),e.cite?(0,l.h)(`cite`,{style:{fontSize:`12px`,color:m.muted,fontStyle:`normal`}},`— ${b(e.cite)}`):null])}),Dn=f.z.object({value:(0,u.reactive)(f.z.string()),options:f.z.array(Ke),label:f.z.string().optional(),variant:f.z.enum([`list`,`pills`,`cards`]).optional(),rules:T.optional()}),On=(0,l.defineComponent)({name:`OpenUIIntelligentRadioGroup`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let a=qe(e.props.options),o=n.value==null?``:String(n.value),s=e.props.variant??`list`,c=(0,l.h)(`div`,{role:`radiogroup`,class:`openui-intelligent-radio-group openui-intelligent-radio-group--${s}`,style:{display:`flex`,flexDirection:s===`pills`?`row`:`column`,flexWrap:s===`pills`?`wrap`:void 0,gap:`8px`}},a.map(e=>{let a=o===e.value;return s===`pills`?(0,l.h)(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":a,disabled:i.value,style:{padding:`6px 12px`,borderRadius:`999px`,fontSize:`13px`,fontWeight:500,cursor:i.value?`not-allowed`:`pointer`,background:a?m.ink:m.surface,color:a?m.onInk:m.ink,border:`1px solid ${a?m.ink:m.border}`},onClick:()=>{i.value||(r.clear(),n.setValue(e.value))}},e.label):(0,l.h)(`label`,{key:e.value,style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:s===`cards`?`10px 12px`:`4px 0`,borderRadius:s===`cards`?m.radiusMd:void 0,border:s===`cards`?`1px solid ${a?m.ink:m.border}`:void 0,background:s===`cards`&&a?m.surface:void 0,cursor:i.value?`not-allowed`:`pointer`}},[(0,l.h)(`input`,{type:`radio`,name:t.value,value:e.value,checked:a,disabled:i.value,style:{marginTop:`3px`,accentColor:m.ink},onChange:()=>{r.clear(),n.setValue(e.value)}}),(0,l.h)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[(0,l.h)(`span`,{style:{fontSize:`14px`,fontWeight:s===`cards`?500:400,color:m.ink}},e.label),e.description?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},e.description):null])])}));return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:c})}}}),kn=(0,u.defineComponent)({name:`RadioGroup`,props:Dn,description:`pills for short choices; cards for choices that need a description line.`,component:On}),An=f.z.object({children:x,gap:f.z.number().optional(),align:Re.optional(),justify:ze.optional(),wrap:f.z.boolean().optional()}),jn=(0,u.defineComponent)({name:`Row`,props:An,description:`Horizontal layout; items are vertically centered.`,component:({props:e,renderNode:t})=>(0,l.h)(`div`,{class:`openui-intelligent-row`,style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:e.gap===void 0?m.spaceInner:void 0,...Se(e,!1)}},[t(e.children)])}),Mn=f.z.object({value:(0,u.reactive)(f.z.string()),options:Ge,block:f.z.boolean().optional()}),Nn=(0,l.defineComponent)({name:`OpenUIIntelligentSegmentedControl`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>`segmented`,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=(0,u.useIsStreaming)();return()=>{let t=N(e.props.options),i=n.value==null?``:String(n.value);return(0,l.h)(`div`,{role:`tablist`,class:`openui-intelligent-segmented`,style:{display:e.props.block?`flex`:`inline-flex`,flexShrink:0,width:e.props.block?`100%`:void 0,padding:`3px`,gap:`2px`,background:m.surface,borderRadius:m.radiusMd,border:`1px solid ${m.border}`}},t.map(t=>{let a=i===t.value;return(0,l.h)(`button`,{key:t.value,type:`button`,role:`tab`,"aria-selected":a,disabled:r.value,style:{flex:e.props.block?`1 1 0%`:`0 0 auto`,padding:`6px 12px`,fontSize:`13px`,fontWeight:a?600:500,fontFamily:m.font,whiteSpace:`nowrap`,borderRadius:m.radiusSm,border:`none`,cursor:r.value?`not-allowed`:`pointer`,background:a?m.canvas:`transparent`,color:a?m.ink:m.muted,boxShadow:a?m.shadowSm:void 0},onClick:()=>{r.value||n.setValue(t.value)}},t.label)}))}}}),Pn=(0,u.defineComponent)({name:`SegmentedControl`,props:Mn,description:`2 to 4 short choices in a row.`,component:Nn}),Fn=f.z.object({value:(0,u.reactive)(f.z.string()),options:Ge,label:f.z.string().optional(),placeholder:f.z.string().optional(),rules:T.optional()}),In=(0,l.defineComponent)({name:`OpenUIIntelligentSelect`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=N(e.props.options),a=n.value==null?``:String(n.value);return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,width:`100%`}},[(0,l.h)(`select`,{value:a,disabled:i.value,class:`openui-intelligent-select`,style:{appearance:`none`,WebkitAppearance:`none`,width:`100%`,padding:`8px 32px 8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,boxSizing:`border-box`,cursor:i.value?`not-allowed`:`pointer`},onChange:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()},[e.props.placeholder&&!a?(0,l.h)(`option`,{value:``,disabled:!0},b(e.props.placeholder)):null,...t.map(e=>(0,l.h)(`option`,{key:e.value,value:e.value},e.label))]),(0,l.h)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,style:{position:`absolute`,right:`10px`,pointerEvents:`none`,color:m.muted}},[(0,l.h)(`path`,{d:`M3 4.5L6 7.5L9 4.5`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})])])})}}}),Ln=(0,u.defineComponent)({name:`Select`,props:Fn,description:`Dropdown, for long option lists.`,component:In}),Rn=f.z.object({value:(0,u.reactive)(f.z.number()),min:f.z.number(),max:f.z.number(),step:f.z.number().optional(),label:f.z.string().optional(),unit:f.z.string().optional(),marks:f.z.array(f.z.object({value:f.z.number(),label:f.z.string()})).optional()}),zn=(0,l.defineComponent)({name:`OpenUIIntelligentSlider`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=(0,u.useIsStreaming)();return()=>{let t=typeof e.props.min==`number`&&Number.isFinite(e.props.min)?e.props.min:0,i=typeof e.props.max==`number`&&Number.isFinite(e.props.max)?e.props.max:100,a=typeof e.props.step==`number`&&e.props.step>0?e.props.step:1,o=typeof n.value==`number`&&Number.isFinite(n.value)?n.value:t,s=e.props.unit?b(e.props.unit):``,c=s===`$`||s===`€`||s===`£`||s===`¥`?`${s}${Te(o)}`:`${Te(o)}${s}`;return(0,l.h)(`div`,{class:`openui-intelligent-slider`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:m.font}},[(0,l.h)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,gap:`8px`}},[e.props.label?(0,l.h)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:m.ink}},b(e.props.label)):(0,l.h)(`span`),(0,l.h)(`span`,{style:{fontSize:`13px`,fontWeight:600,fontVariantNumeric:`tabular-nums`,color:m.ink}},c)]),(0,l.h)(`input`,{type:`range`,min:t,max:i,step:a,value:o,disabled:r.value,style:{width:`100%`,accentColor:m.rangeThumb,cursor:r.value?`not-allowed`:`pointer`},onInput:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n.setValue(t)}}),Array.isArray(e.props.marks)&&e.props.marks.length>0?(0,l.h)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:`11px`,color:m.muted}},e.props.marks.map((e,t)=>(0,l.h)(`span`,{key:t},b(e.label)))):null])}}}),Bn=(0,u.defineComponent)({name:`Slider`,props:Rn,description:`Shows label and value; unit like "%" or "$" formats the value.`,component:zn}),Vn=f.z.object({}),Hn=(0,u.defineComponent)({name:`Spacer`,props:Vn,description:`Fills the free space in a Row.`,component:()=>(0,l.h)(`div`,{class:`openui-intelligent-spacer`,style:{flex:`1 1 auto`}})}),Un=Symbol(`OpenUI.Intelligent.InSvg`),P=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,Wn=e=>P(e)===void 0?void 0:Math.min(1,Math.max(0,e)),Gn=/^[\d\s,.eE+-]*$/,Kn=/^[MmLlHhVvCcSsQqTtAaZz\d\s,.eE+-]*$/,qn=/^\s*-?\d+(\.\d+)?[\s,]+-?\d+(\.\d+)?[\s,]+\d+(\.\d+)?[\s,]+\d+(\.\d+)?\s*$/,F=(e,t)=>typeof e==`string`&&e.length<2e4&&t.test(e)?e:void 0,I={fill:S.optional(),stroke:S.optional(),strokeWidth:f.z.number().optional(),opacity:f.z.number().optional()},L=(e,t)=>({fill:e.fill===void 0?t&&e.stroke===void 0?`currentColor`:`none`:g(e.fill)??`none`,stroke:e.stroke===void 0?t?void 0:`currentColor`:g(e.stroke),"stroke-width":P(e.strokeWidth)??(t?void 0:2),opacity:Wn(e.opacity),"stroke-linecap":`round`,"stroke-linejoin":`round`}),Jn=(0,l.defineComponent)({name:`OpenUIIntelligentSvgCanvas`,props:{viewBox:{type:String,required:!0},label:String,width:[Number,String],height:[Number,String]},setup(e,{slots:t}){return(0,l.provide)(Un,!0),()=>{let n=F(e.viewBox,qn)??`0 0 100 100`;return(0,l.h)(`svg`,{class:`openui-intelligent-svg`,viewBox:n,role:e.label?`img`:void 0,"aria-label":e.label||void 0,"aria-hidden":e.label?void 0:`true`,style:{display:`block`,maxWidth:`100%`,width:v(e.width)??`100%`,height:v(e.height)??`auto`,color:m.ink}},t.default?.())}}}),R=(0,l.defineComponent)({name:`OpenUIIntelligentSvgStandalone`,setup(e,{slots:t}){let n=(0,l.inject)(Un,!1);return()=>n?t.default?.():(0,l.h)(Jn,{viewBox:`0 0 100 100`,width:160},{default:()=>t.default?.()})}}),Yn=f.z.object({cx:f.z.number(),cy:f.z.number(),r:f.z.number(),...I}),Xn=(0,u.defineComponent)({name:`Circle`,props:Yn,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`circle`,{cx:P(e.cx),cy:P(e.cy),r:Math.max(0,P(e.r)??0),...L(e,!0)})})}),Zn=f.z.object({cx:f.z.number(),cy:f.z.number(),rx:f.z.number(),ry:f.z.number(),...I}),Qn=(0,u.defineComponent)({name:`Ellipse`,props:Zn,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`ellipse`,{cx:P(e.cx),cy:P(e.cy),rx:Math.max(0,P(e.rx)??0),ry:Math.max(0,P(e.ry)??0),...L(e,!0)})})}),$n=f.z.object({x:f.z.number(),y:f.z.number(),width:f.z.number(),height:f.z.number(),...I,rx:f.z.number().optional()}),er=(0,u.defineComponent)({name:`Rect`,props:$n,description:`rx rounds the corners; fill defaults to the text color, and with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`rect`,{x:P(e.x),y:P(e.y),width:Math.max(0,P(e.width)??0),height:Math.max(0,P(e.height)??0),rx:P(e.rx),...L(e,!0)})})}),tr=f.z.object({x1:f.z.number(),y1:f.z.number(),x2:f.z.number(),y2:f.z.number(),stroke:S.optional(),strokeWidth:f.z.number().optional(),opacity:f.z.number().optional()}),nr=(0,u.defineComponent)({name:`Line`,props:tr,description:`Stroked in the text color, 2 wide, unless stroke and strokeWidth are set.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`line`,{x1:P(e.x1),y1:P(e.y1),x2:P(e.x2),y2:P(e.y2),...L(e,!1)})})}),rr={m:2,l:2,t:2,h:1,v:1,c:6,s:4,q:4,a:7,z:0},ir=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?/i,ar=/^[01]/,or=e=>{let t=e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*$/i)?.[0];if(!t)return e.trim()===``;let n=rr[t[0].toLowerCase()],r=t.slice(1),i=0;for(;r=r.replace(/^[\s,]+/,``),r;){let e=i%7,t=(n===7&&(e===3||e===4)?ar:ir).exec(r);if(!t)return!1;r=r.slice(t[0].length),i++}return/[.eE+-]$/.test(t.trimEnd())?!1:n===0?i===0:i>0&&i%n===0},sr=f.z.object({d:f.z.string(),...I}),cr=(0,u.defineComponent)({name:`Path`,props:sr,description:`d is SVG path data only (M, L, C, A, Z...), else nothing draws; unfilled unless fill is set.`,component:({props:e})=>{let t=F(e.d,Kn);return(0,l.h)(R,null,{default:()=>(0,l.h)(`path`,{d:t!==void 0&&or(t)?t:void 0,...L(e,e.fill!==void 0)})})}}),lr=f.z.object({points:f.z.string(),fill:S.optional(),stroke:S.optional(),strokeWidth:f.z.number().optional(),opacity:f.z.number().optional()}),ur=(0,u.defineComponent)({name:`Polyline`,props:lr,description:`points like "0,0 10,5 20,0".`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`polyline`,{points:F(e.points,Gn),...L(e,!1)})})}),dr=f.z.object({points:f.z.string(),...I}),fr=(0,u.defineComponent)({name:`Polygon`,props:dr,description:`Closed shape; points like "0,0 10,5 20,0". fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`polygon`,{points:F(e.points,Gn),...L(e,!0)})})}),pr=f.z.object({text:f.z.string(),x:f.z.number(),y:f.z.number(),size:f.z.number().optional(),fill:S.optional(),anchor:f.z.enum([`start`,`middle`,`end`]).optional(),weight:f.z.enum([`normal`,`medium`,`semibold`]).optional()}),mr=[Xn,Qn,er,nr,cr,ur,fr,(0,u.defineComponent)({name:`SvgText`,props:pr,description:`A text label at x, y; anchor sets which end sits on x.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`text`,{x:P(e.x),y:P(e.y),"font-size":P(e.size)??12,fill:g(e.fill)??`currentColor`,"text-anchor":e.anchor??`start`,"font-weight":e.weight===`semibold`?640:e.weight===`medium`?560:440,"font-family":m.font},String(e.text??``))})})],hr=f.z.array(f.z.union(mr.map(e=>e.ref))),gr={translate:[1,2],rotate:[1,3],scale:[1,2],skewX:[1],skewY:[1],matrix:[6]};function _r(e){if(typeof e!=`string`||e.length>500)return;let t=[...e.matchAll(/\s*([a-zA-Z]+)\(([^()]*)\)\s*/g)];if(t.length&&t.map(e=>e[0]).join(``)===e)return t.every(([,e,t])=>{let n=t.trim().split(/\s*,\s*|\s+/).filter(Boolean);return(gr[e]?.includes(n.length)??!1)&&n.every(e=>Number.isFinite(Number(e)))})?e.trim():void 0}const vr=f.z.object({children:hr,transform:f.z.string().optional(),opacity:f.z.number().optional()}),yr=(0,u.defineComponent)({name:`G`,props:vr,description:`Group; transform like "rotate(30 50 50)" or "translate(10 0)"; one with the wrong number of arguments is dropped.`,component:({props:e,renderNode:t})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`g`,{transform:_r(e.transform),opacity:Wn(e.opacity)},[t(e.children)])})}),br=/* @__PURE__ */ new Set([...mr.map(e=>e.name),yr.name]),xr=f.z.object({children:f.z.array(f.z.union([...hr.element.options,yr.ref])),viewBox:f.z.string(),label:f.z.string().optional(),width:C.optional(),height:C.optional()}),Sr=[(0,u.defineComponent)({name:`Svg`,props:xr,description:`A drawing for steps, parts, mechanisms, diagrams and layouts. Scales to its width; its shapes take expressions, so state can move them. label says in a few words what it shows, for screen readers: always give one.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.children)?e.children:[],r=e=>Be(e)&&br.has(String(e.typeName)),i=n.filter(e=>!r(e));return(0,l.h)(l.Fragment,null,[(0,l.h)(Jn,{viewBox:e.viewBox,label:e.label,width:e.width,height:e.height},{default:()=>t(n.filter(r))}),i.length?t(i):null])}}),...mr,yr],Cr=f.z.object({columns:f.z.array(f.z.string()),rows:f.z.array(f.z.array(f.z.any()))}),wr=(0,u.defineComponent)({name:`Table`,props:Cr,description:`Each row lists its cells in column order; a cell may be a component. Number columns align right.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.columns)?e.columns.map(b):[],r=Array.isArray(e.rows)?e.rows.filter(e=>Array.isArray(e)):[],i=n.map((e,t)=>r.length>0&&r.every(e=>e[t]==null||typeof e[t]==`number`));return(0,l.h)(`div`,{class:`openui-intelligent-table-wrap`,style:{width:`100%`,overflowX:`auto`,border:`1px solid ${m.border}`,borderRadius:m.radiusMd}},[(0,l.h)(`table`,{class:`openui-intelligent-table`,style:{width:`100%`,borderCollapse:`collapse`,fontSize:`13px`,fontFamily:m.font}},[(0,l.h)(`thead`,null,(0,l.h)(`tr`,{style:{background:m.surface,borderBottom:`1px solid ${m.border}`}},n.map((e,t)=>(0,l.h)(`th`,{key:t,style:{padding:`8px 12px`,textAlign:i[t]?`right`:`left`,fontWeight:600,color:m.muted,whiteSpace:`nowrap`}},e)))),(0,l.h)(`tbody`,null,r.map((e,a)=>(0,l.h)(`tr`,{key:a,style:{borderBottom:a<r.length-1?`1px solid ${m.border}`:void 0}},n.map((n,r)=>{let a=e[r],o=Be(a)||Array.isArray(a)?t(a):typeof a==`number`?Te(a):O(b(a));return(0,l.h)(`td`,{key:r,style:{padding:`8px 12px`,textAlign:i[r]?`right`:`left`,fontVariantNumeric:i[r]?`tabular-nums`:void 0,color:m.ink}},[o])}))))])])}}),Tr=f.z.union([f.z.string(),x]),Er=f.z.object({text:Tr,size:f.z.enum([`xs`,`sm`,`md`,`lg`]).optional(),color:S.optional(),weight:f.z.enum([`normal`,`medium`,`semibold`]).optional(),italic:f.z.boolean().optional(),lineThrough:f.z.boolean().optional(),tabularNums:f.z.boolean().optional(),maxLines:f.z.number().optional()}),Dr={xs:`12px`,sm:`13px`,md:`14px`,lg:`16px`},Or={normal:400,medium:500,semibold:600},kr=(0,u.defineComponent)({name:`Text`,props:Er,description:'Paragraph; supports **bold**, *italic*, `code` and [links](https://…). text may be a list mixing strings and inline components: [Icon("clock", "sm"), " 25 min · ", Badge("Easy")].',component:({props:e,renderNode:t})=>{let n={margin:0,fontSize:Dr[e.size??`md`]??`14px`,lineHeight:1.55,color:g(e.color)??m.ink,fontWeight:e.weight?Or[e.weight]:void 0,fontStyle:e.italic?`italic`:void 0,textDecoration:e.lineThrough?`line-through`:void 0,fontVariantNumeric:e.tabularNums?`tabular-nums`:void 0};typeof e.maxLines==`number`&&e.maxLines>0&&(n.display=`-webkit-box`,n.WebkitLineClamp=String(Math.round(e.maxLines)),n.WebkitBoxOrient=`vertical`,n.overflow=`hidden`);let r=Array.isArray(e.text)?e.text.flat().map(e=>k(e,t)):k(e.text,t);return(0,l.h)(`p`,{class:`openui-intelligent-text`,style:n},[r])}}),Ar=f.z.object({value:(0,u.reactive)(f.z.string()),label:f.z.string().optional(),placeholder:f.z.string().optional(),rows:f.z.number().optional(),rules:T.optional()}),jr=(0,l.defineComponent)({name:`OpenUIIntelligentTextArea`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=typeof e.props.rows==`number`&&Number.isFinite(e.props.rows)?Math.min(20,Math.max(2,Math.round(e.props.rows))):3;return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`textarea`,{rows:t,value:n.value==null?``:String(n.value),placeholder:e.props.placeholder?b(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-textarea`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,outline:`none`,resize:`vertical`,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}}),Mr=(0,u.defineComponent)({name:`TextArea`,props:Ar,description:`Multi-line text field; rows is 2 to 20 (default 3).`,component:jr}),Nr=f.z.object({seconds:(0,u.reactive)(f.z.number()),label:f.z.string().optional()});function Pr(e){let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}const Fr=(0,l.defineComponent)({name:`OpenUIIntelligentTimer`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.seconds),r=(0,u.useIsStreaming)(),i=(0,l.ref)(typeof n.value==`number`&&Number.isFinite(n.value)?n.value:0),a=(0,l.ref)(!1),o=null,s=()=>{a.value=!1,o!==null&&(clearInterval(o),o=null)},c=()=>{r.value||a.value||Number(n.value??0)<=0||(a.value=!0,o=setInterval(()=>{let e=Number(n.value??0);e<=1?(n.setValue(0),s()):n.setValue(e-1)},1e3))},d=()=>{s(),n.setValue(i.value)};return(0,l.onBeforeUnmount)(s),()=>{let t=typeof n.value==`number`?n.value:Number(n.value??0),i=typeof document<`u`&&document.documentElement.lang.toLowerCase().startsWith(`zh`);return(0,l.h)(`div`,{class:`openui-intelligent-timer`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,padding:`12px 14px`,borderRadius:m.radiusMd,background:m.surface,border:`1px solid ${m.border}`}},[(0,l.h)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[e.props.label?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},b(e.props.label)):null,(0,l.h)(`span`,{style:{fontSize:`24px`,fontWeight:700,fontVariantNumeric:`tabular-nums`,color:m.ink}},Pr(t))]),(0,l.h)(`div`,{style:{display:`flex`,gap:`8px`,flexShrink:0}},[(0,l.h)(`button`,{type:`button`,disabled:r.value||!a.value&&t<=0,onClick:()=>a.value?s():c(),style:{padding:`6px 12px`,borderRadius:m.radiusSm,border:`none`,background:m.ink,color:m.onInk,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},a.value?i?`暂停`:`Pause`:i?`开始`:`Start`),(0,l.h)(`button`,{type:`button`,disabled:r.value,onClick:d,style:{padding:`6px 12px`,borderRadius:m.radiusSm,border:`1px solid ${m.borderStrong}`,background:m.canvas,color:m.ink,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},i?`重置`:`Reset`)])])}}}),Ir=(0,u.defineComponent)({name:`Timer`,props:Nr,description:`Countdown with start, pause and reset. It counts the bound seconds down to 0, so other statements can react, e.g. $left == 0.`,component:Fr}),Lr=f.z.object({text:f.z.string(),size:f.z.enum([`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`]).optional(),color:S.optional()}),Rr={sm:{fontSize:`14px`,lineHeight:`1.35`,fontWeight:600},md:{fontSize:`16px`,lineHeight:`1.35`,fontWeight:600},lg:{fontSize:`20px`,lineHeight:`1.28`,fontWeight:650},xl:{fontSize:`24px`,lineHeight:`1.22`,fontWeight:650},"2xl":{fontSize:`32px`,lineHeight:`1.15`,fontWeight:700},"3xl":{fontSize:`40px`,lineHeight:`1.1`,fontWeight:700}},zr=(0,u.defineComponent)({name:`Title`,props:Lr,description:`Heading; md for a card title, lg for a section, 2xl for a big number.`,component:({props:e})=>{let t=Rr[e.size??`md`]??Rr.md;return(0,l.h)(`div`,{role:`heading`,"aria-level":e.size===`3xl`||e.size===`2xl`?2:e.size===`xl`||e.size===`lg`?3:4,class:`openui-intelligent-title`,style:{margin:0,color:g(e.color)??m.ink,letterSpacing:`-0.015em`,...t}},b(e.text))}}),Br=f.z.object({video:f.z.string(),title:f.z.string().optional()}),z=/^[A-Za-z0-9_-]{11}$/;function Vr(e){let t=e.trim();if(z.test(t))return t;try{let e=new URL(t),n=e.hostname.replace(/^www\./,``);if(n===`youtu.be`){let t=e.pathname.slice(1).split(`/`)[0]??``;return z.test(t)?t:null}if(n===`youtube.com`||n===`m.youtube.com`||n===`youtube-nocookie.com`){let t=e.searchParams.get(`v`);if(t&&z.test(t))return t;let n=e.pathname.split(`/`).filter(Boolean),r=n[1]??``;if((n[0]===`embed`||n[0]===`shorts`)&&z.test(r))return r}}catch{return null}return null}const Hr=[wt,jn,He,Lt,tt,rt,xn,kt,Hn,zr,kr,$e,on,Oe,cn,mn,fn,gn,En,xt,vn,Ze,Zt,wn,rn,Mr,Ln,Pn,Bn,yt,kn,Dt,Ir,Ft,en,Jt,wr,gt,(0,u.defineComponent)({name:`YouTube`,props:Br,description:`Embedded YouTube video by id or URL. Only a video you know exists.`,component:({props:e})=>{let t=Vr(b(e.video));return t?(0,l.h)(`div`,{class:`openui-intelligent-youtube`,style:{width:`100%`,aspectRatio:`16 / 9`,borderRadius:m.radiusMd,overflow:`hidden`,background:m.surface}},[(0,l.h)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${t}`,title:b(e.title)||`YouTube video`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowfullscreen:!0,loading:`lazy`,referrerpolicy:`strict-origin-when-cross-origin`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})]):null}}),Mt,st,...Sr,Gt],Ur=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Wr(e){let t=Ur.exec(e.trim());if(!t)throw Error(`not a hex color: ${e}`);let n=t[1].length===3?t[1].replace(/./g,`$&$&`):t[1];return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}const Gr=[(0,u.defineFunction)({name:`MixColor`,description:`The hex color a fraction t of the way from one hex color to another, e.g. @MixColor("#ffffff", "#0285ff", 0.5) for a heatmap or a tint`,params:f.z.object({from:f.z.string(),to:f.z.string(),t:f.z.number()}),returns:f.z.string(),fn:({from:e,to:t,t:n})=>{let r=Wr(e),i=Wr(t),a=Math.min(1,Math.max(0,n));return`#${r.map((e,t)=>Math.round(e+(i[t]-e)*a).toString(16).padStart(2,`0`)).join(``)}`}})],B=()=>f.z.array(f.z.any()),Kr=()=>f.z.array(f.z.number()),V=()=>f.z.union([f.z.string(),f.z.number()]),qr=()=>f.z.enum([`sum`,`avg`,`count`,`min`,`max`]);function H(e,t){if(!t)return e;let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function U(e,t){if(e===t)return!0;if(typeof e==`number`&&typeof t==`string`||typeof e==`string`&&typeof t==`number`)return String(e)===String(t);if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e))return e.length===t.length&&e.every((e,n)=>U(e,t[n]));let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&U(e[n],t[n]))}function W(e){if(!Number.isFinite(e))throw Error(`result is not a finite number`);return e}function G(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function Jr(e,t,n){if(n===`count`)return e.length;let r=e.map(e=>G(H(e,t??``))).filter(e=>e!==null);if(!r.length)return 0;switch(n){case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.reduce((e,t)=>e+t,0)/r.length;case`min`:return Math.min(...r);case`max`:return Math.max(...r)}}function K(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=H(r,t),i=typeof e==`number`?e:e==null||e===``?`Unknown`:String(e),a=n.get(i);a?a.push(r):n.set(i,[r])}return n}const q=1e4,J=864e5,Yr=/^(\d{4})-(\d{2})-(\d{2})$/;function Y(e){if(typeof e==`string`){let t=Yr.exec(e.trim());if(t){let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=Date.UTC(n,r-1,i),o=new Date(a);if(o.getUTCMonth()!==r-1||o.getUTCDate()!==i)throw Error(`invalid date "${e}"`);return{day:a/J,instant:null}}}let t=new Date(e);if(Number.isNaN(t.getTime()))throw Error(`invalid date "${e}"`);return{day:Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/J,instant:t}}function X(e){return(/* @__PURE__ */ new Date(e*J)).toISOString().slice(0,10)}const Xr={date:{month:`short`,day:`numeric`,year:`numeric`},short:{month:`short`,day:`numeric`},long:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`},weekday:{weekday:`short`},month:{month:`short`,year:`numeric`},time:{hour:`numeric`,minute:`2-digit`},datetime:{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}},Zr=(0,u.defineFunction)({name:`Now`,description:`The current date and time as an ISO string`,params:f.z.object({}),returns:f.z.string(),fn:()=>(/* @__PURE__ */ new Date()).toISOString()}),Qr=(0,u.defineFunction)({name:`FormatDate`,description:`A date as text: "date" Oct 9, 2026 (default), "short" Oct 9, "long" Friday, October 9, 2026, "weekday" Fri, "month" Oct 2026, "time" 9:30 PM, "datetime", "iso" 2026-10-09. Dates are "YYYY-MM-DD", ISO or a timestamp; "time" and "datetime" need a timestamp or an ISO date-time, as a plain date has no time`,params:f.z.object({date:V(),style:f.z.enum([`date`,`short`,`long`,`weekday`,`month`,`time`,`datetime`,`iso`]).optional()}),returns:f.z.string(),fn:({date:e,style:t=`date`})=>{let{day:n,instant:r}=Y(e);return t===`iso`?X(n):(r??/* @__PURE__ */ new Date(n*J)).toLocaleString(`en-US`,{...Xr[t],...r?{}:{timeZone:`UTC`}})}}),$r=(0,u.defineFunction)({name:`AddDays`,description:`The date days later (negative: earlier), as "YYYY-MM-DD"`,params:f.z.object({date:V(),days:f.z.number()}),returns:f.z.string(),fn:({date:e,days:t})=>X(Y(e).day+Math.trunc(t))}),ei=(0,u.defineFunction)({name:`DaysBetween`,description:`Calendar days from one date to another (negative if to is earlier)`,params:f.z.object({from:V(),to:V()}),returns:f.z.number(),fn:({from:e,to:t})=>Y(t).day-Y(e).day}),ti=(0,u.defineFunction)({name:`Today`,description:`Today's date in the viewer's time zone, as "YYYY-MM-DD"`,params:f.z.object({}),returns:f.z.string(),fn:()=>X(Y(Date.now()).day)});function Z(e){let t=/* @__PURE__ */ new Date(e*J);return[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]}const ni=[Zr,ti,Qr,$r,(0,u.defineFunction)({name:`AddMonths`,description:`The date months later (negative: earlier), kept within the month (Jan 31 + 1 is Feb 28), as "YYYY-MM-DD"; 12 months is a year`,params:f.z.object({date:V(),months:f.z.number()}),returns:f.z.string(),fn:({date:e,months:t})=>{let[n,r,i]=Z(Y(e).day),a=r+Math.trunc(t),o=new Date(Date.UTC(n,a+1,0)).getUTCDate();return X(Date.UTC(n,a,Math.min(i,o))/J)}}),ei,(0,u.defineFunction)({name:`MonthsBetween`,description:`Whole months from one date to another (negative if to is earlier); @Floor(@MonthsBetween(birthday, @Today()) / 12) is an age`,params:f.z.object({from:V(),to:V()}),returns:f.z.number(),fn:({from:e,to:t})=>{let[n,r,i]=Z(Y(e).day),[a,o,s]=Z(Y(t).day),c=(a-n)*12+(o-r);return c>0&&s<i&&--c,c<0&&s>i&&(c+=1),c}}),(0,u.defineFunction)({name:`StartOf`,description:`First day of the date's "week" (Monday), "month" or "year", as "YYYY-MM-DD"`,params:f.z.object({date:V(),unit:f.z.enum([`week`,`month`,`year`])}),returns:f.z.string(),fn:({date:e,unit:t})=>{let n=Y(e).day,[r,i]=Z(n);return X(t===`week`?n-((/* @__PURE__ */ new Date(n*J)).getUTCDay()+6)%7:Date.UTC(r,t===`month`?i:0,1)/J)}})],ri=()=>f.z.array(f.z.object({key:f.z.union([f.z.string(),f.z.number()]),value:f.z.number()})),ii=e=>e.filter(e=>typeof e==`number`&&Number.isFinite(e)),ai=(e,t)=>t??(e?`sum`:`count`);function oi(e,t,n){return e.map((e,r)=>t?{...e,[t]:n[r]}:n[r])}const si=(0,u.defineFunction)({name:`GroupBy`,description:`One row per distinct key, in first-seen order; value is agg of field (default "sum"), or the row count without a field`,params:f.z.object({rows:B(),key:f.z.string(),field:f.z.string().optional(),agg:qr().optional()}),returns:ri(),fn:({rows:e,key:t,field:n,agg:r})=>[...K(e,t)].map(([e,t])=>({key:e,value:Jr(t,n,ai(n,r))}))}),ci=(0,u.defineFunction)({name:`Pivot`,description:`One row per rowKey value, under key, with a column per colKey value holding agg of field, for stacked or grouped charts`,params:f.z.object({rows:B(),rowKey:f.z.string(),colKey:f.z.string(),field:f.z.string().optional(),agg:qr().optional()}),returns:f.z.array(f.z.record(f.z.string(),f.z.union([f.z.string(),f.z.number()]))),fn:({rows:e,rowKey:t,colKey:n,field:r,agg:i})=>{let a=[...K(e,n).keys()].map(String);return[...K(e,t)].map(([e,t])=>{let o={key:e};for(let e of a)o[e]=0;for(let[e,a]of K(t,n))o[String(e)]=Jr(a,r,ai(r,i));return o})}}),li=(0,u.defineFunction)({name:`Top`,description:`The n rows with the largest field ("asc": the smallest)`,params:f.z.object({rows:B(),field:f.z.string(),n:f.z.number(),direction:f.z.enum([`desc`,`asc`]).optional()}),returns:B(),fn:({rows:e,field:t,n,direction:r=`desc`})=>{let i=r===`asc`?1:-1;return e.map((e,n)=>({row:e,i:n,v:G(H(e,t))})).sort((e,t)=>e.v===null||t.v===null?e.v===t.v?e.i-t.i:e.v===null?1:-1:(e.v-t.v)*i||e.i-t.i).slice(0,Math.max(0,Math.trunc(n))).map(e=>e.row)}}),ui=/^\d{4}-\d{2}-\d{2}/,Q=e=>typeof e==`string`&&ui.test(e.trim());function di(e,t){let n=G(e),r=G(t);if(n!==null&&r!==null)return n-r;if((Q(e)||Q(t))&&(Q(e)||n!==null)&&(Q(t)||r!==null))try{return Y(e).day-Y(t).day}catch{}let i=String(e),a=String(t);return i<a?-1:+(i>a)}const fi=(0,u.defineFunction)({name:`Between`,description:`Rows whose field is from min to max, both included; compares numbers, dates by day ("YYYY-MM-DD", ISO or a timestamp), or text. Leave min or max null for an open end`,params:f.z.object({rows:B(),field:f.z.string(),min:f.z.any().optional(),max:f.z.any().optional()}),returns:B(),fn:({rows:e,field:t,min:n,max:r})=>e.filter(e=>{let i=H(e,t);return i!=null&&(n==null||di(i,n)>=0)&&(r==null||di(i,r)<=0)})});function pi(e,t){if(t===`day`)return e;if(t===`week`)return e-((/* @__PURE__ */ new Date(e*864e5)).getUTCDay()+6)%7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)/864e5}function mi(e,t){if(t===`day`)return e+1;if(t===`week`)return e+7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1)/864e5}const hi=[si,ci,li,fi,(0,u.defineFunction)({name:`Bucket`,description:`Rows per day, week (from Monday) or month of dateField, in date order, empty periods 0 for sum and count; key is "YYYY-MM-DD", or "YYYY-MM" for months`,params:f.z.object({rows:B(),dateField:f.z.string(),unit:f.z.enum([`day`,`week`,`month`]),field:f.z.string().optional(),agg:qr().optional()}),returns:ri(),fn:({rows:e,dateField:t,unit:n,field:r,agg:i})=>{let a=/* @__PURE__ */ new Map;for(let r of e){let e=H(r,t);if(typeof e!=`string`&&typeof e!=`number`)continue;let i;try{i=Y(e).day}catch{continue}let o=pi(i,n),s=a.get(o);s?s.push(r):a.set(o,[r])}if(!a.size)return[];let o=ai(r,i),s=o===`sum`||o===`count`,c=e=>n===`month`?X(e).slice(0,7):X(e),l=[...a.keys()].sort((e,t)=>e-t),u=[];for(let e=l[0];e<=l[l.length-1];e=mi(e,n)){let t=a.get(e);if(t?u.push({key:c(e),value:Jr(t,r,o)}):s&&u.push({key:c(e),value:0}),u.length>1e4)throw Error(`more than ${q} periods`)}return u}}),(0,u.defineFunction)({name:`Cumulative`,description:`Copy of the rows with field replaced by its running total (field "" for a list of numbers)`,params:f.z.object({rows:B(),field:f.z.string()}),returns:B(),fn:({rows:e,field:t})=>{let n=0;return oi(e,t,e.map(e=>n+=G(H(e,t))??0))}}),(0,u.defineFunction)({name:`MovingAvg`,description:`Copy of the rows with field replaced by the average of its last window values (field "" for a list of numbers)`,params:f.z.object({rows:B(),field:f.z.string(),window:f.z.number()}),returns:B(),fn:({rows:e,field:t,window:n})=>{let r=Math.trunc(n);if(r<1)throw Error(`window must be at least 1`);let i=e.map(e=>G(H(e,t))??0);return oi(e,t,i.map((e,t)=>{let n=i.slice(Math.max(0,t-r+1),t+1);return n.reduce((e,t)=>e+t,0)/n.length}))}}),(0,u.defineFunction)({name:`Change`,description:`Percent change from previous to current, e.g. @Change(120, 100) is 20; null when previous is 0`,params:f.z.object({current:f.z.number(),previous:f.z.number()}),returns:f.z.number().nullable(),fn:({current:e,previous:t})=>t===0?null:W((e-t)/Math.abs(t)*100)}),(0,u.defineFunction)({name:`Histogram`,description:`Counts numbers into equal-width bins as {key, value} rows: key is the bin's start, value the count; min and max fix the range, default the data's`,params:f.z.object({values:Kr(),bins:f.z.number(),min:f.z.number().optional(),max:f.z.number().optional()}),returns:f.z.array(f.z.object({key:f.z.string(),value:f.z.number()})),fn:({values:e,bins:t,min:n,max:r})=>{let i=ii(e),a=Math.trunc(t);if(a<1||a>500)throw Error(`bins must be from 1 to 500`);let o=n??(i.length?Math.min(...i):0),s=r??(i.length?Math.max(...i):1);s<=o&&(s=o+1);let c=(s-o)/a,l=Math.max(0,1-Math.floor(Math.log10(c))),u=Array(a).fill(0);for(let e of i)e<o||e>s||u[Math.min(a-1,Math.floor((e-o)/c))]++;return u.map((e,t)=>({key:String(Number((o+t*c).toFixed(l))),value:e}))}}),(0,u.defineFunction)({name:`Stats`,description:`Summary of numbers, all zeros for an empty list`,params:f.z.object({values:Kr()}),returns:f.z.object({count:f.z.number(),min:f.z.number(),max:f.z.number(),mean:f.z.number(),median:f.z.number(),stdev:f.z.number()}),fn:({values:e})=>{let t=ii(e),n=t.length;if(!n)return{count:0,min:0,max:0,mean:0,median:0,stdev:0};let r=[...t].sort((e,t)=>e-t),i=t.reduce((e,t)=>e+t,0)/n,a=Math.floor(n/2),o=n%2?r[a]:(r[a-1]+r[a])/2,s=Math.sqrt(t.reduce((e,t)=>e+(t-i)**2,0)/n);return{count:n,min:r[0],max:r[n-1],mean:i,median:o,stdev:s}}})],gi=(e,t)=>e<0?t+e:e,_i=[(0,u.defineFunction)({name:`Append`,description:`Copy of the list with item added at the end`,params:f.z.object({list:B(),item:f.z.any()}),returns:B(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${q} items`);return[...e,t]}}),(0,u.defineFunction)({name:`Prepend`,description:`Copy of the list with item added at the start`,params:f.z.object({list:B(),item:f.z.any()}),returns:B(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${q} items`);return[t,...e]}}),(0,u.defineFunction)({name:`Concat`,description:`Joins two lists`,params:f.z.object({list:B(),more:B()}),returns:B(),fn:({list:e,more:t})=>{if(e.length+t.length>1e4)throw Error(`more than ${q} items`);return[...e,...t]}}),(0,u.defineFunction)({name:`Remove`,description:`Copy without the items whose field equals value; field "" compares the items themselves`,params:f.z.object({list:B(),field:f.z.string(),value:f.z.any()}),returns:B(),fn:({list:e,field:t,value:n})=>e.filter(e=>!U(H(e,t),n))}),(0,u.defineFunction)({name:`RemoveAt`,description:`Copy without the item at index (0-based; negative counts from the end)`,params:f.z.object({list:B(),index:f.z.number()}),returns:B(),fn:({list:e,index:t})=>{let n=gi(Math.trunc(t),e.length);return e.filter((e,t)=>t!==n)}}),(0,u.defineFunction)({name:`Update`,description:`Copy where items whose field equals value get setField set to setValue`,params:f.z.object({list:B(),field:f.z.string(),value:f.z.any(),setField:f.z.string(),setValue:f.z.any()}),returns:B(),fn:({list:e,field:t,value:n,setField:r,setValue:i})=>e.map(e=>e&&typeof e==`object`&&!Array.isArray(e)&&U(H(e,t),n)?{...e,[r]:i}:e)}),(0,u.defineFunction)({name:`Toggle`,description:`Adds item if missing, removes it if present (a set of strings or numbers)`,params:f.z.object({list:B(),item:f.z.any()}),returns:B(),fn:({list:e,item:t})=>e.some(e=>U(e,t))?e.filter(e=>!U(e,t)):[...e,t]}),(0,u.defineFunction)({name:`Includes`,description:`True if the list has item, or the text contains it`,params:f.z.object({list:f.z.union([B(),f.z.string()]),item:f.z.any()}),returns:f.z.boolean(),fn:({list:e,item:t})=>typeof e==`string`?t!=null&&e.includes(String(t)):e.some(e=>U(e,t))}),(0,u.defineFunction)({name:`Find`,description:`First item whose field equals value, or null`,params:f.z.object({list:B(),field:f.z.string(),value:f.z.any()}),returns:f.z.any(),fn:({list:e,field:t,value:n})=>e.find(e=>U(H(e,t),n))??null}),(0,u.defineFunction)({name:`IndexOf`,description:`Index of item in the list, or -1`,params:f.z.object({list:B(),item:f.z.any()}),returns:f.z.number(),fn:({list:e,item:t})=>e.findIndex(e=>U(e,t))}),(0,u.defineFunction)({name:`Take`,description:`The first n items; a negative n takes the last n`,params:f.z.object({list:B(),n:f.z.number()}),returns:B(),fn:({list:e,n:t})=>{let n=Math.trunc(t);return n>=0?e.slice(0,n):e.slice(n)}}),(0,u.defineFunction)({name:`Slice`,description:`Items, or characters of text, from start up to end (not included); negative counts from the end`,params:f.z.object({list:f.z.union([B(),f.z.string()]),start:f.z.number(),end:f.z.number().optional()}),returns:f.z.union([B(),f.z.string()]),fn:({list:e,start:t,end:n})=>{let r=n===void 0?void 0:Math.trunc(n);return e.slice(Math.trunc(t),r)}}),(0,u.defineFunction)({name:`Unique`,description:`Distinct items in first-seen order`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>{let t=/* @__PURE__ */ new Set,n=[];return e.filter(e=>{if(typeof e!=`object`||!e){let n=String(e);return!t.has(n)&&(t.add(n),!0)}return!n.some(t=>U(t,e))&&(n.push(e),!0)})}}),(0,u.defineFunction)({name:`Reverse`,description:`Copy in reverse order`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>[...e].reverse()}),(0,u.defineFunction)({name:`Range`,description:`Numbers from start up to end (not included) by step (default 1), e.g. @Range(0, 3) is [0, 1, 2]`,params:f.z.object({start:f.z.number(),end:f.z.number(),step:f.z.number().optional()}),returns:f.z.array(f.z.number()),fn:({start:e,end:t,step:n=1})=>{if(n===0||!Number.isFinite(n))throw Error(`step must be a non-zero number`);let r=Math.max(0,Math.ceil((t-e)/n));if(r>1e4)throw Error(`more than ${q} items`);let i=Number.isInteger(e)&&Number.isInteger(n);return Array.from({length:r},(t,r)=>i?e+r*n:Number((e+r*n).toPrecision(12)))}}),(0,u.defineFunction)({name:`Pick`,description:`A random item, or null for an empty list; draws anew each time, so call it inside @Set`,params:f.z.object({list:B()}),returns:f.z.any(),fn:({list:e})=>e.length?e[Math.floor(Math.random()*e.length)]:null}),(0,u.defineFunction)({name:`Shuffle`,description:`Copy in random order; call it inside @Set`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}}),(0,u.defineFunction)({name:`Flatten`,description:`One list from a list of lists, e.g. [[1, 2], [3]] is [1, 2, 3]`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>{let t=e.flatMap(e=>Array.isArray(e)?e:[e]);if(t.length>1e4)throw Error(`more than ${q} items`);return t}}),(0,u.defineFunction)({name:`Chunk`,description:`The list cut into lists of size items, e.g. for weeks of 7 days or pages`,params:f.z.object({list:B(),size:f.z.number()}),returns:f.z.array(B()),fn:({list:e,size:t})=>{let n=Math.trunc(t);if(n<1)throw Error(`size must be 1 or more`);let r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}})],vi=(0,u.defineFunction)({name:`Pow`,description:`base raised to exponent`,params:f.z.object({base:f.z.number(),exponent:f.z.number()}),returns:f.z.number(),fn:({base:e,exponent:t})=>W(e**+t)}),yi=(0,u.defineFunction)({name:`Sqrt`,description:`Square root; null for a negative number`,params:f.z.object({number:f.z.number()}),returns:f.z.number().nullable(),fn:({number:e})=>e<0?null:W(Math.sqrt(e))}),bi=(0,u.defineFunction)({name:`Random`,description:`Random number from min to max (integer true: a whole number, max included); draws anew each time, so call it inside @Set`,params:f.z.object({min:f.z.number(),max:f.z.number(),integer:f.z.boolean().optional()}),returns:f.z.number(),fn:({min:e,max:t,integer:n})=>{if(!Number.isFinite(e)||!Number.isFinite(t))throw Error(`min and max must be numbers`);let r=Math.min(e,t),i=Math.max(e,t);if(!n)return r+Math.random()*(i-r);let a=Math.ceil(r),o=Math.floor(i);if(a>o)throw Error(`no whole number between min and max`);return a+Math.floor(Math.random()*(o-a+1))}}),xi=(0,u.defineFunction)({name:`Clamp`,description:`number kept between min and max`,params:f.z.object({number:f.z.number(),min:f.z.number(),max:f.z.number()}),returns:f.z.number(),fn:({number:e,min:t,max:n})=>W(Math.min(Math.max(e,Math.min(t,n)),Math.max(t,n)))}),Si=(0,u.defineFunction)({name:`Percent`,description:`part / total * 100, e.g. @Percent(3, 4) is 75; 0 when total is 0`,params:f.z.object({part:f.z.number(),total:f.z.number()}),returns:f.z.number(),fn:({part:e,total:t})=>t===0?0:W(e/t*100)}),Ci=(0,u.defineFunction)({name:`Lerp`,description:`The value a fraction t of the way from a to b`,params:f.z.object({a:f.z.number(),b:f.z.number(),t:f.z.number()}),returns:f.z.number(),fn:({a:e,b:t,t:n})=>W(e+(t-e)*n)}),wi=(0,u.defineFunction)({name:`Allocate`,description:`Splits total in proportion to weights, rounded to decimals (default 2), so the parts add up to exactly total, e.g. @Allocate(100, [1, 1, 1]) is [33.34, 33.33, 33.33]`,params:f.z.object({total:f.z.number(),weights:Kr(),decimals:f.z.number().optional()}),returns:f.z.array(f.z.number()),fn:({total:e,weights:t,decimals:n})=>{let r=t.reduce((e,t)=>e+t,0);if(!t.length||t.some(e=>!Number.isFinite(e)||e<0))throw Error(`weights must be zero or more`);if(r===0)return t.map(()=>0);let i=10**Math.min(6,Math.max(0,Math.round(n!==void 0&&Number.isFinite(n)?n:2))),a=Math.round(Math.abs(e)*i),o=t.map(e=>a*e/r),s=o.map(Math.floor),c=a-s.reduce((e,t)=>e+t,0),l=o.map((e,t)=>({i:t,rest:e-Math.floor(e)})).sort((e,t)=>t.rest-e.rest||e.i-t.i);for(let{i:e}of l){if(c<=0)break;s[e]+=1,--c}return s.map(t=>(e<0?-t:t)/i)}}),Ti=(0,u.defineFunction)({name:`Payment`,description:`Payment per period that repays principal over periods at rate percent per period, e.g. a 30-year loan at 6% a year: @Payment(300000, 6 / 12, 360)`,params:f.z.object({principal:f.z.number(),rate:f.z.number(),periods:f.z.number()}),returns:f.z.number(),fn:({principal:e,rate:t,periods:n})=>{if(!(n>0))throw Error(`periods must be positive`);let r=t/100;return W(r===0?e/n:e*r/(1-(1+r)**+-n))}}),Ei={mm:[`length`,.001],cm:[`length`,.01],m:[`length`,1],km:[`length`,1e3],in:[`length`,.0254],ft:[`length`,.3048],yd:[`length`,.9144],mi:[`length`,1609.344],mg:[`mass`,1e-6],g:[`mass`,.001],kg:[`mass`,1],oz:[`mass`,.028349523125],lb:[`mass`,.45359237],st:[`mass`,6.35029318],ml:[`volume`,.001],l:[`volume`,1],tsp:[`volume`,.00492892159375],tbsp:[`volume`,.0147867647812],floz:[`volume`,.0295735295625],cup:[`volume`,.2365882365],pt:[`volume`,.473176473],qt:[`volume`,.946352946],gal:[`volume`,3.785411784],"m/s":[`speed`,1],"km/h":[`speed`,1/3.6],mph:[`speed`,.44704],kn:[`speed`,.514444],m2:[`area`,1],km2:[`area`,1e6],ft2:[`area`,.09290304],ha:[`area`,1e4],acre:[`area`,4046.8564224]},Di=[`c`,`f`,`k`],Oi=(e,t)=>t===`f`?(e-32)*5/9:t===`k`?e-273.15:e,ki=(e,t)=>t===`f`?e*9/5+32:t===`k`?e+273.15:e,Ai=[vi,yi,bi,xi,Si,Ci,wi,Ti,(0,u.defineFunction)({name:`Convert`,description:`value from one unit to another: mm cm m km in ft yd mi; mg g kg oz lb st; ml l tsp tbsp floz cup pt qt gal (US); m/s km/h mph kn; m2 km2 ft2 ha acre; c f k`,params:f.z.object({value:f.z.number(),from:f.z.string(),to:f.z.string()}),returns:f.z.number(),fn:({value:e,from:t,to:n})=>{let[r,i]=[t.trim().toLowerCase(),n.trim().toLowerCase()];if(Di.includes(r)&&Di.includes(i))return W(ki(Oi(e,r),i));let[a,o]=[Ei[r],Ei[i]];if(!a||!o||a[0]!==o[0])throw Error(`cannot convert ${t} to ${n}`);return W(e*a[1]/o[1])}})],ji=`en-US`;function Mi(e){let t=(e??`USD`).toUpperCase();return/^[A-Z]{3}$/.test(t)?t:`USD`}function $(e,t){try{return e.toLocaleString(ji,t)}catch{return e.toLocaleString(ji,{...t,currency:`USD`})}}const Ni=[(0,u.defineFunction)({name:`Format`,description:`Number as text: "number" 12,345.6, "currency" $12,345.68 (currency is a code like "EUR"), "percent" 45 -> 45%, "compact" 1.2M ($1.2M with a currency)`,params:f.z.object({value:f.z.number(),kind:f.z.enum([`number`,`currency`,`percent`,`compact`]).optional(),decimals:f.z.number().optional(),currency:f.z.string().optional()}),returns:f.z.string(),fn:({value:e,kind:t=`number`,decimals:n,currency:r})=>{if(!Number.isFinite(e))throw Error(`value is not a finite number`);let i=n===void 0?void 0:Math.min(Math.max(Math.trunc(n),0),10),a=(e,t=0)=>i===void 0?{minimumFractionDigits:t,maximumFractionDigits:e}:{minimumFractionDigits:t&&i,maximumFractionDigits:i};switch(t){case`currency`:return $(e,{style:`currency`,currency:Mi(r),...a(2,2)});case`percent`:return`${$(e,a(1))}%`;case`compact`:return $(e,{notation:`compact`,...a(1),...r?{style:`currency`,currency:Mi(r)}:{}});default:return $(e,a(2))}}}),(0,u.defineFunction)({name:`Join`,description:`Joins the items (or their field) into text with sep (default ", "), skipping nulls`,params:f.z.object({list:B(),sep:f.z.string().optional(),field:f.z.string().optional()}),returns:f.z.string(),fn:({list:e,sep:t=`, `,field:n=``})=>e.map(e=>H(e,n)).filter(e=>e!=null).map(e=>typeof e==`object`?JSON.stringify(e):String(e)).join(t)}),(0,u.defineFunction)({name:`Plural`,description:`Count and word: @Plural(1, "guest") is "1 guest", 3 gives "3 guests"; plural defaults to word + "s"`,params:f.z.object({n:f.z.number(),word:f.z.string(),plural:f.z.string().optional()}),returns:f.z.string(),fn:({n:e,word:t,plural:n})=>`${$(e,{maximumFractionDigits:2})} ${Math.abs(e)===1?t:n??`${t}s`}`}),(0,u.defineFunction)({name:`Pad`,description:`Pads the start of value to length with char (default "0"), e.g. 7 -> "07"`,params:f.z.object({value:f.z.union([f.z.string(),f.z.number()]),length:f.z.number(),char:f.z.string().optional()}),returns:f.z.string(),fn:({value:e,length:t,char:n=`0`})=>String(e).padStart(Math.min(Math.trunc(t),1e3),n||`0`)}),(0,u.defineFunction)({name:`Upper`,description:`Text in upper case`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.toUpperCase()}),(0,u.defineFunction)({name:`Lower`,description:`Text in lower case`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.toLowerCase()}),(0,u.defineFunction)({name:`Trim`,description:`Text without spaces at the start and end`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.trim()}),(0,u.defineFunction)({name:`Capitalize`,description:`Each word with a capital first letter, e.g. "new york" is "New York"`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.replace(/(^|[\s\-(/"])(\p{L})/gu,(e,t,n)=>t+n.toUpperCase())}),(0,u.defineFunction)({name:`Split`,description:`List of the parts of text between sep (default ","), each trimmed, empty parts dropped, e.g. @Split("a, b,,c") is ["a", "b", "c"]`,params:f.z.object({text:f.z.string(),sep:f.z.string().optional()}),returns:f.z.array(f.z.string()),fn:({text:e,sep:t=`,`})=>{let n=e.split(t===``?``:t).map(e=>e.trim()).filter(e=>e!==``);if(n.length>1e4)throw Error(`more than ${q} items`);return n}}),(0,u.defineFunction)({name:`Replace`,description:`Text with every find replaced by replacement`,params:f.z.object({text:f.z.string(),find:f.z.string(),replacement:f.z.string()}),returns:f.z.string(),fn:({text:e,find:t,replacement:n})=>t===``?e:e.split(t).join(n)}),(0,u.defineFunction)({name:`Duration`,description:`Seconds as text: "short" 1h 20m, 4m 05s, 45s (default); "clock" 1:20:00, 4:05`,params:f.z.object({seconds:f.z.number(),style:f.z.enum([`short`,`clock`]).optional()}),returns:f.z.string(),fn:({seconds:e,style:t=`short`})=>{if(!Number.isFinite(e))throw Error(`seconds is not a finite number`);let n=e<0?`-`:``,r=Math.round(Math.abs(e)),[i,a,o]=[Math.floor(r/3600),Math.floor(r%3600/60),r%60],s=e=>String(e).padStart(2,`0`);return t===`clock`?n+(i?`${i}:${s(a)}:${s(o)}`:`${a}:${s(o)}`):i?`${n}${i}h${a?` ${a}m`:``}`:a?`${n}${a}m${o?` ${s(o)}s`:``}`:`${n}${o}s`}}),(0,u.defineFunction)({name:`Default`,description:`value, or fallback when value is null, "" or not a number, e.g. an empty number input: @Default($weight, 0)`,params:f.z.object({value:f.z.any().optional(),fallback:f.z.any()}),returns:f.z.any(),fn:({value:e,fallback:t})=>e==null||e===``||typeof e==`number`&&Number.isNaN(e)?t:e})],Pi=[..._i,...Ai,...Ni,...Gr,...ni,...hi],Fi=[{name:`Layout`,components:[`Col`,`Row`,`Box`,`Grid`,`Card`,`Carousel`,`Popover`,`Divider`,`Spacer`],notes:[`- gap and padding count 4px steps. Length is px or a CSS length like "50%". Radius is "sm", "md", "lg", "xl", "full" or px.`,`- Color is "ink", "muted", "faint", "surface", "info", "success", "warning", "danger", "purple", "pink", "chart1" to "chart6", or a CSS color. As a background, status colors are soft tints.`]},{name:`Text`,components:[`Title`,`Text`,`Caption`,`Label`,`Badge`,`Link`,`List`,`ListItem`,`Markdown`,`Quote`,`Code`,`Math`]},{name:`Inputs`,components:[`Button`,`IconButton`,`Pressable`,`Input`,`TextArea`,`Select`,`SegmentedControl`,`Slider`,`Checkbox`,`RadioGroup`,`DatePicker`,`Timer`,`Form`],notes:[`- An input's first argument is its value, usually a $variable that other statements read.`,`- Every input either changes something shown on the page, or sits in a Form whose submit Button sends a short first-person @ToAssistant ("Help me choose a bike"); the form values go with it. No dead inputs.`,`- In a Form, a field's last argument rules is checked before the form sends, and an error shows under the field. Rules is {required?, min?, max?, minLength?, maxLength?, email?, url?, numeric?, pattern?}: Input($email, "Email", "text", null, {required: true, email: true}).`]},{name:`Media and data`,components:[`Image`,`Icon`,`Table`,`Chart`,`YouTube`]},{name:`Play`,components:[`Flashcard`,`Celebration`]},{name:`Drawing`,components:[`Svg`,`G`,`Circle`,`Ellipse`,`Rect`,`Line`,`Path`,`Polyline`,`Polygon`,`SvgText`,`HtmlView`]}],Ii=(0,u.createLibrary)({root:`Col`,components:Hr,functions:Pi,componentGroups:Fi}),Li=[`Compose the answer like a page, not a form letter: a Title, a short Text, then a mix of blocks that show the content. Row, Grid and Carousel to set things side by side; Badge rows for quick facts; Card only to group a block; Popover for an aside.`,`Use Image only with a URL the user or a tool gave in this conversation. Never write an image URL yourself, even for a famous place or product: it will often be wrong. Without a URL, show the subject with an Icon, Badges or an Svg drawing instead.`,`Spacing is a system with three tiers that always nest: inner (gap 1-2, 4-8px) for a title with its subtitle, tags or line; group (gap 3-4, 12-16px) between blocks inside a Card or grid cell; section (24px) between the blocks of the page. Leave gap unset on the page's root Col and on a Card's own contents: the app applies these tiers. Set it on a Row, a Grid or an inner Col. Never use one gap for everything, and never a gap larger than the section gap.`,`A photo beside text is a media row: Row([Box([Image(url, alt, 1.33)]), Col([Title(..., "md"), Row([Badge(...), Badge(...)], 1, null, null, true), Text(..., "sm")], 2)], 4, "start"). The app sizes the photo to a third of the row (at most 200px) and top-aligns the text. Facts are Badges, never Buttons or boxed pills.`,`Keep cards compact and scannable: Title "md" for a card heading (xl or 2xl only for a single big number), Text "sm" for the body, at most one short paragraph, then facts as Badges or label/value rows (Caption label, Spacer, Text value). Don't write bold-lead paragraphs like "**Weekend rhythm:** ..." or long prose in a card. Cards side by side in a Grid share the same blocks in the same order and the same Image aspect ratio, so they line up. For example: c = Card([Col([Title("Sonoma", "md"), Row([Badge("1 h drive", null, "car"), Badge("Wine country", "purple")], 1, null, null, true)], 2), Text("A slow plaza, tasting rooms and quiet back roads.", "sm"), Col([Row([Caption("Best for"), Spacer(), Text("Food and wine", "sm")]), Row([Caption("Trade-off"), Spacer(), Text("Tastings add up", "sm")])], 1)])`,`Answer with a working tool whenever the request involves numbers, choices, lists, steps, a game or something to explore: keep inputs and lists in $variables, compute everything shown from them with expressions and @functions, and change them with @Set. The page must work on its own, without another message.`,`When the request leaves out a detail the answer depends on (a model, a size, a count), don't stop to ask: assume the most common case, say so in one short line, and build the whole answer, with a SegmentedControl or Select to switch to the other cases where they differ.`,`Use @ToAssistant only for what the page cannot compute: a Form's submit Button, or a new request ("Plan another day"). Its message is short and first person, like the user typing it ("Help me choose a bike"); the form values travel with it, so never repeat them in the message.`,`$variable defaults are literals (numbers, strings, lists, objects), never expressions or @calls. Edit lists with @Append, @Remove, @RemoveAt and @Update; track selections with @Toggle and @Includes.`,`cond ? a : b also picks between components; there is no @If. Use only the listed @functions; you cannot define your own.`,`Derive rows once in a statement with @Each(list, "x", {...}), then reuse them in @Each, Table, Chart, @Sum(rows.field) and @Join. @Each(@Range(0, n), "i", ...) builds a series or repeats a step.`,`@Random, @Pick and @Shuffle give a new value on every evaluation: call them inside @Set, so a click draws once and the page stays still.`,`Pick the medium that shows the idea: Chart for numbers across time or categories; Svg drawings for shapes, parts and movement; Table for comparisons; Flashcard and Celebration for learning and games; HtmlView only for a game or animation that needs a loop.`,`Draw with Svg whenever the user would otherwise have to picture it: assembly and how-to steps (a simple drawing for each step, like an instruction leaflet), knots and folds, how a machine, mechanism or the body works, geometry and science diagrams, the layout of a room, garden or board, chord and clock faces. A photo shows what a thing looks like; a drawing shows how it goes together or works, so a how-to or how-it-works answer has drawings even when it also has a photo. Keep each drawing simple: a viewBox about 240 wide, a dozen or so shapes in the listed colors with SvgText labels, a Line with a small Polygon head for an arrow, and let $variables such as the current step drive it.`,`Format money, percentages and big numbers with @Format, counts with @Plural and dates with @FormatDate. @Percent is unrounded, so show it as @Format(@Percent(part, total), "percent"), never @Percent(...) + "%".`,`Dates relative to now (today, this week, next month) start from @Today(), never a fixed date. <, >, <= and >= compare numbers only, so order two dates with @DaysBetween(a, b) > 0.`,`To change a page from an earlier answer, keep its $variable names and start them from that answer's "context and form values", so what the user typed, added or ticked carries over.`,`Read a number input for a count or amount through @Default and @Clamp with a sensible minimum, e.g. @Clamp(@Default($people, 1), 1, 50), so 0, empty or negative cannot divide by zero or zero out the page.`,`Answer a plain knowledge or safety question with Markdown text, adding a Quote only where it helps.`],Ri=[`Example 1: A guest stepper that rescales a shopping list, with a checklist and a button that clears it:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@wodecorp/openui-vue-ui"),l=require("vue"),u=require("@wodecorp/openui-vue-lang"),d=require("@wodecorp/openui-vue-ui/icons"),f=require("zod/v4"),p=require("katex");p=s(p,1);const m={font:`var(--openui-intelligent-font, var(--openui-font-body, "Inter", sans-serif))`,mono:`var(--openui-intelligent-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,canvas:`var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))`,hover:`var(--openui-intelligent-hover, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 5%, transparent))`,pressed:`var(--openui-intelligent-pressed, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,surface:`var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent))`,surfaceStrong:`var(--openui-intelligent-surface-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,ink:`var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0)))`,inkHover:`var(--openui-intelligent-ink-hover, color-mix(in oklch, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 82%, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))))`,onInk:`var(--openui-intelligent-on-ink, var(--openui-foreground, oklch(0.994 0 89.876)))`,muted:`var(--openui-intelligent-muted, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,faint:`var(--openui-intelligent-faint, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,border:`var(--openui-intelligent-border, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,borderStrong:`var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent))`,rangeTrack:`var(--openui-intelligent-range-track, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,rangeThumb:`var(--openui-intelligent-range-thumb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,focus:`var(--openui-intelligent-focus, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,glass:`var(--openui-intelligent-glass, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassHover:`var(--openui-intelligent-glass-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,glassRing:`var(--openui-intelligent-glass-ring, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassRingHover:`var(--openui-intelligent-glass-ring-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,shadow:`var(--openui-intelligent-shadow, var(--openui-shadow-l, 0 4px 4px -2px oklch(0 0 0 / 0.05), 0 4px 8px -2px oklch(0 0 0 / 0.04)))`,shadowSm:`var(--openui-intelligent-shadow-sm, var(--openui-shadow-s, 0 1px 3px -2px oklch(0 0 0 / 0.02), 0 2px 5px -2px oklch(0 0 0 / 0.04)))`,info:`var(--openui-intelligent-info, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,infoSoft:`var(--openui-intelligent-info-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,success:`var(--openui-intelligent-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,successSoft:`var(--openui-intelligent-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,warning:`var(--openui-intelligent-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,warningSoft:`var(--openui-intelligent-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,danger:`var(--openui-intelligent-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,dangerSoft:`var(--openui-intelligent-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,purple:`var(--openui-intelligent-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,purpleSoft:`var(--openui-intelligent-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,pink:`var(--openui-intelligent-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,pinkSoft:`var(--openui-intelligent-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,badgeNeutralSoft:`var(--openui-intelligent-badge-neutral-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,badgeSuccess:`var(--openui-intelligent-badge-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,badgeSuccessSoft:`var(--openui-intelligent-badge-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,badgeWarning:`var(--openui-intelligent-badge-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,badgeWarningSoft:`var(--openui-intelligent-badge-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,badgeDanger:`var(--openui-intelligent-badge-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,badgeDangerSoft:`var(--openui-intelligent-badge-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,badgePurple:`var(--openui-intelligent-badge-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,badgePurpleSoft:`var(--openui-intelligent-badge-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,badgePink:`var(--openui-intelligent-badge-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,badgePinkSoft:`var(--openui-intelligent-badge-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,chart1:`var(--openui-intelligent-chart-1, #0285ff)`,chart2:`var(--openui-intelligent-chart-2, #00a67d)`,chart3:`var(--openui-intelligent-chart-3, #8b5cf6)`,chart4:`var(--openui-intelligent-chart-4, #f4a340)`,chart5:`var(--openui-intelligent-chart-5, #e46d91)`,chart6:`var(--openui-intelligent-chart-6, #4b9ca6)`,spaceTight:`var(--openui-intelligent-space-tight, 4px)`,spaceInner:`var(--openui-intelligent-space-inner, 8px)`,spaceGroup:`var(--openui-intelligent-space-group, 12px)`,spaceGroupLg:`var(--openui-intelligent-space-group-lg, 16px)`,spaceSection:`var(--openui-intelligent-space-section, 24px)`,controlGap:`var(--openui-intelligent-control-gap, 8px)`,fieldGap:`var(--openui-intelligent-field-gap, 24px)`,actionGap:`var(--openui-intelligent-action-gap, 40px)`,radiusSm:`var(--openui-intelligent-radius-sm, 6px)`,radiusMd:`var(--openui-intelligent-radius-md, 10px)`,radiusLg:`var(--openui-intelligent-radius-lg, 12px)`,radiusXl:`var(--openui-intelligent-radius-xl, 14px)`,photoEmpty:`var(--openui-intelligent-photo-empty, var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent)))`,photoEmptyIcon:`var(--openui-intelligent-photo-empty-icon, var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent)))`},ee={intelligentMono:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,intelligentChart1:`#0285ff`,intelligentChart2:`#00a67d`,intelligentChart3:`#8b5cf6`,intelligentChart4:`#f4a340`,intelligentChart5:`#e46d91`,intelligentChart6:`#4b9ca6`,intelligentSpaceTight:`4px`,intelligentSpaceInner:`8px`,intelligentSpaceGroup:`12px`,intelligentSpaceGroupLg:`16px`,intelligentSpaceSection:`24px`,intelligentControlGap:`8px`,intelligentFieldGap:`24px`,intelligentActionGap:`40px`,intelligentRadiusSm:`6px`,intelligentRadiusMd:`10px`,intelligentRadiusLg:`12px`,intelligentRadiusXl:`14px`},te={...ee},ne={...ee},h=Symbol(`OpenUI.IntelligentTheme`);function re(){return(0,l.inject)(h,null)}function ie(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z])/g,`$1-$2`).replace(/([a-z])(\d)/g,`$1-$2`).toLowerCase()}function ae(e){let t={},n={};for(let[r,i]of Object.entries(e??{}))r.startsWith(`intelligent`)&&r.length>11?typeof i==`string`&&(n[r]=i):t[r]=i;return{components:t,intelligent:n}}function oe(e){return Object.entries(e).filter(([,e])=>typeof e==`string`).map(([e,t])=>`--openui-${ie(e)}: ${t};`).join(` `)}function se(e){return e.replace(/[^a-zA-Z0-9-_]/g,``)}const ce=(0,l.defineComponent)({name:`OpenUIIntelligentVariables`,props:{id:{type:String,required:!0},scope:{type:String,required:!0},mode:{type:String,required:!0},theme:{type:Object,required:!0}},setup(e){let{portalThemeClassName:t}=(0,c.useTheme)(),n=(0,l.computed)(()=>{let n=`color-scheme: ${e.mode}; color: var(--openui-text-neutral-primary); font-family: ${m.font}; ${oe(e.theme)}`,r=[`.${e.scope}`];return t.value&&r.push(`.${t.value}`),`${r.join(`, `)} { ${n} }`}),r,i=()=>{if(typeof document>`u`||r?.textContent===n.value)return;r?.remove(),r=document.createElement(`style`);let t=window.__nonce__;t&&(r.nonce=t),r.setAttribute(`data-openui-intelligent-theme`,e.id),r.textContent=n.value,document.head.appendChild(r)};return(0,l.onMounted)(i),(0,l.onUpdated)(i),(0,l.onBeforeUnmount)(()=>r?.remove()),()=>(n.value,null)}}),le=(0,l.defineComponent)({name:`OpenUIIntelligentThemeProvider`,inheritAttrs:!1,props:{mode:String,lightTheme:Object,darkTheme:Object},setup(e,{slots:t}){let n=se((0,c.useId)()),r=(0,l.inject)(h,null),{mode:i}=(0,c.useTheme)(),a=(0,l.computed)(()=>e.mode??r?.mode.value??i.value??`light`),o=`openui-intelligent-theme-${n}`,s=(0,l.computed)(()=>({light:{...r?.overrides.value.light,...e.lightTheme},dark:{...r?.overrides.value.dark,...e.darkTheme??e.lightTheme}})),u=(0,l.computed)(()=>ae(s.value.light)),d=(0,l.computed)(()=>ae(s.value.dark)),f=(0,l.computed)(()=>a.value===`light`?{...te,...u.value.intelligent}:{...ne,...d.value.intelligent});return(0,l.provide)(h,{mode:a,theme:f,overrides:s}),()=>(0,l.h)(`div`,{class:o,"data-openui-intelligent-mode":a.value,style:{display:`contents`}},[(0,l.h)(c.ThemeProvider,{mode:a.value,cssSelector:`.${o}`,lightTheme:u.value.components,darkTheme:d.value.components},{default:()=>[(0,l.h)(ce,{id:n,scope:o,mode:a.value,theme:f.value}),t.default?.()]})])}}),ue=(0,l.defineComponent)({name:`OpenUIIntelligentRootTheme`,inheritAttrs:!1,setup(e,{slots:t}){let n=(0,l.inject)(h,null);return()=>n?t.default?.():(0,l.h)(le,null,{default:()=>t.default?.()})}}),de=/(url|image|image-set|cross-fade|element|expression|paint|var|attr|env)\s*\(|@import|[\\;{}<>]/i,fe=e=>!de.test(e),pe=[`info`,`success`,`warning`,`danger`,`purple`,`pink`],me={ink:m.ink,muted:m.muted,faint:m.faint,canvas:m.canvas,surface:m.surface,...Object.fromEntries(pe.map(e=>[e,m[e]])),chart1:m.chart1,chart2:m.chart2,chart3:m.chart3,chart4:m.chart4,chart5:m.chart5,chart6:m.chart6},he={...me,surface:m.surface,"surface-strong":m.surfaceStrong,border:m.border,...Object.fromEntries(pe.map(e=>[e,m[`${e}Soft`]]))},ge=e=>typeof e==`string`&&e.trim()&&fe(e)?e.trim():void 0,g=e=>typeof e==`string`?me[e]??ge(e):void 0,_e=e=>typeof e==`string`?he[e]??ge(e):void 0,ve=e=>e in he,_=e=>typeof e==`number`&&Number.isFinite(e)?`${Math.max(0,e)*4}px`:void 0;function v(e){if(typeof e==`number`&&Number.isFinite(e))return`${Math.max(0,e)}px`;if(typeof e==`string`)return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:/^\d+(\.\d+)?(px|%|em|rem|vh|vw|fr)$|^auto$/.test(e.trim())?e.trim():void 0}const ye={sm:m.radiusSm,md:m.radiusMd,lg:m.radiusLg,xl:m.radiusXl,full:`999px`},be=e=>typeof e==`string`?ye[e]:v(e),xe={start:`flex-start`,end:`flex-end`,center:`center`,stretch:`stretch`,between:`space-between`},Se=(e,t=!1)=>({gap:_(e.gap),alignItems:e.align?xe[e.align]:void 0,justifyContent:e.justify?xe[e.justify]:void 0,flexWrap:e.wrap?`wrap`:void 0,textAlign:t&&(e.align===`center`||e.align===`end`)?e.align:void 0}),Ce=/* @__PURE__ */ new Map,y=(0,l.defineComponent)({name:`OpenUIIntelligentLucideIcon`,props:{name:{type:String,required:!0},size:{type:Number,default:16},color:String},setup(e){let t=(0,l.shallowRef)(null);return(0,l.watch)(()=>e.name,e=>{if(!e){t.value=null;return}let n=Ce.get(e);if(n){t.value=n;return}let r=(0,d.getIconImport)(e);if(!r){t.value=null;return}let i=!1;return r().then(n=>{if(i)return;let r=n?.default;r&&(Ce.set(e,r),t.value=r)}).catch(()=>{i||(t.value=null)}),()=>{i=!0}},{immediate:!0}),()=>{let n=t.value,r=g(e.color)??`currentColor`;return n?(0,l.h)(n,{size:e.size,color:r,style:{display:`inline-block`,flexShrink:0,verticalAlign:`middle`}}):(0,l.h)(`span`,{class:`openui-intelligent-icon-placeholder`,"data-icon":e.name,"aria-hidden":`true`,style:{display:`inline-block`,width:`${e.size}px`,height:`${e.size}px`,verticalAlign:`middle`}})}}}),we=e=>(e?.innerText??``).replace(/\s+/g,` `).trim().slice(0,120),b=e=>e==null?``:String(e),Te=e=>typeof e!=`number`||!Number.isFinite(e)?``:e.toLocaleString(`en-US`,{maximumFractionDigits:2}),Ee=f.z.object({text:f.z.string(),color:f.z.enum([`neutral`,`info`,`success`,`warning`,`danger`,`purple`,`pink`]).optional(),icon:f.z.string().optional()}),De={neutral:{bg:m.badgeNeutralSoft,fg:m.ink},info:{bg:m.infoSoft,fg:m.info},success:{bg:m.badgeSuccessSoft,fg:m.badgeSuccess},warning:{bg:m.badgeWarningSoft,fg:m.badgeWarning},danger:{bg:m.badgeDangerSoft,fg:m.badgeDanger},purple:{bg:m.badgePurpleSoft,fg:m.badgePurple},pink:{bg:m.badgePinkSoft,fg:m.badgePink}},Oe=(0,u.defineComponent)({name:`Badge`,props:Ee,description:`Pill tag; icon is an optional leading lucide name.`,component:({props:e})=>{let t=De[e.color??`neutral`]??De.neutral;return(0,l.h)(`span`,{class:`openui-intelligent-badge`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`2px 8px`,borderRadius:`999px`,fontSize:`12px`,fontWeight:500,lineHeight:1.4,background:t.bg,color:t.fg,verticalAlign:`middle`}},[e.icon?(0,l.h)(y,{name:e.icon,size:12}):null,b(e.text)])}});function ke(e){if(typeof e!=`string`||ve(e))return;let t=null,n=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(e.trim());if(n){let e=n[1].length===3?n[1].replace(/./g,`$&$&`):n[1];t=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}else{let n=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());n&&(t=[n[1],n[2],n[3]].map(Number))}if(!t)return;let[r,i,a]=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a>.36?`#0d0d0d`:`#ffffff`}const Ae=e=>`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='${e}' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5'/%3E%3C/svg%3E")`;function je(e){let t=ke(e);if(!t)return{};let n=t!==`#ffffff`;return{color:t,"--openui-intelligent-ink":t,"--openui-intelligent-muted":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-faint":`color-mix(in srgb, ${t} 55%, transparent)`,"--openui-text-neutral-primary":t,"--openui-text-neutral-secondary":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-on-ink":n?`#ffffff`:`#0d0d0d`,"--_openui-intelligent-pressable-check-icon":Ae(n?`white`:`%230d0d0d`)}}function Me(e){try{return new URL(e.trim()).protocol}catch{return null}}function Ne(e){if(typeof e!=`string`)return null;let t=Me(e);return t===`http:`||t===`https:`?e.trim():null}const Pe=f.z.any();(0,u.tagSchemaId)(Pe,`Node`);const x=f.z.array(Pe),S=f.z.string();(0,u.tagSchemaId)(S,`Color`);const C=f.z.union([f.z.number(),f.z.string()]);(0,u.tagSchemaId)(C,`Length`);const w=f.z.union([f.z.enum([`sm`,`md`,`lg`,`xl`,`full`]),f.z.number()]);(0,u.tagSchemaId)(w,`Radius`);const Fe=f.z.enum([`cover`,`contain`]),T=f.z.object({required:f.z.boolean().optional(),email:f.z.boolean().optional(),url:f.z.boolean().optional(),numeric:f.z.boolean().optional(),min:f.z.number().optional(),max:f.z.number().optional(),minLength:f.z.number().optional(),maxLength:f.z.number().optional(),pattern:f.z.string().optional()});(0,u.tagSchemaId)(T,`Rules`);const Ie=f.z.union([f.z.string(),f.z.object({value:f.z.string(),label:f.z.string()})]);function Le(e){if(e==null)return null;if(typeof e!=`object`)return{value:String(e),label:String(e)};let{value:t,label:n,description:r}=e,i=n??t;return i==null?null:{value:String(t??n),label:String(i),...typeof r==`string`&&{description:r}}}const Re=f.z.enum([`start`,`center`,`end`,`stretch`]),ze=f.z.enum([`start`,`center`,`end`,`between`]),E=f.z.union([f.z.string(),x]),D=/(\*\*([^*]+)\*\*|\*([^*]+)\*|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\))/g;function O(e){if(!e)return``;let t=[],n=0;D.lastIndex=0;let r;for(;(r=D.exec(e))!==null;){if(r.index>n&&t.push(e.slice(n,r.index)),r[2]!==void 0)t.push((0,l.h)(`strong`,null,r[2]));else if(r[3]!==void 0)t.push((0,l.h)(`em`,null,r[3]));else if(r[4]!==void 0)t.push((0,l.h)(`code`,{style:{fontFamily:m.mono,fontSize:`0.88em`,padding:`0.1em 0.35em`,borderRadius:m.radiusSm,background:m.surface}},r[4]));else if(r[5]!==void 0&&r[6]!==void 0){let e=Ne(r[6]);e?t.push((0,l.h)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,style:{color:m.info,textDecoration:`underline`}},r[5])):t.push(r[5])}n=D.lastIndex}return n<e.length&&t.push(e.slice(n)),t.length===1?t[0]:t}const k=(e,t)=>typeof e==`string`||typeof e==`number`?O(String(e)):t(Array.isArray(e)?e.flat():e),Be=e=>!!e&&typeof e==`object`&&e.type===`element`,Ve=f.z.object({children:x.optional(),direction:f.z.enum([`row`,`col`]).optional(),gap:f.z.number().optional(),padding:f.z.number().optional(),background:S.optional(),radius:w.optional(),border:f.z.boolean().optional(),width:C.optional(),height:C.optional(),flex:f.z.number().optional(),align:Re.optional(),justify:ze.optional(),wrap:f.z.boolean().optional()}),He=(0,u.defineComponent)({name:`Box`,props:Ve,description:`Flex container, a column by default. radius also clips the content.`,component:({props:e,renderNode:t})=>{let n=e.direction!==`row`,r=be(e.radius),i={display:`flex`,flexDirection:n?`column`:`row`,padding:_(e.padding),background:_e(e.background),borderRadius:r,overflow:r?`hidden`:void 0,border:e.border?`1px solid ${m.border}`:void 0,width:v(e.width),height:v(e.height),flex:typeof e.flex==`number`&&Number.isFinite(e.flex)?e.flex:void 0,...Se(e,n),...je(e.background)};return(0,l.h)(`div`,{class:`openui-intelligent-box`,style:i},[t(e.children)])}}),Ue=e=>{let t=e?.steps;return!t||t.some(e=>e.type===u.ACTION_STEPS.ToAssistant||e.type===`custom_action`||e.type===u.ACTION_STEPS.Run&&e.refType===`mutation`)};function We(){let e=(0,u.useTriggerAction)(),t=(0,u.useFormName)(),n=(0,u.useFormValidation)();return(r,i,a)=>{(i||a)&&(!n||i&&!Ue(i)||n.validateForm())&&(i?e(r,t.value,i):e(r,t.value))}}function A(e,t,n){let r=(0,u.useFormValidation)(),i=(0,l.computed)(()=>(0,u.parseStructuredRules)((0,l.toValue)(t))),a=(0,l.computed)(()=>!!r&&i.value.length>0),o=null;return(0,l.watchEffect)(()=>{let t=(0,l.toValue)(e),a=i.value;o&&o!==t&&(r?.unregisterField(o),o=null),r&&a.length>0?(r.registerField(t,a,()=>(0,l.toValue)(n)),o=t):o&&=(r?.unregisterField(o),null)}),(0,l.onScopeDispose)(()=>{o&&=(r?.unregisterField(o),null)}),{required:(0,l.computed)(()=>a.value&&i.value.some(e=>e.type===`required`)),error:(0,l.computed)(()=>a.value?r?.errors[(0,l.toValue)(e)]:void 0),check:()=>{a.value&&r&&r.validateField((0,l.toValue)(e),(0,l.toValue)(n),i.value)},clear:()=>{a.value&&r&&r.clearFieldError((0,l.toValue)(e))}}}function j(e,t){let n=(0,c.useId)();return(0,l.computed)(()=>{let r=(0,l.toValue)(t);if(r)return r;let i=(0,l.toValue)(e);return typeof i==`string`&&i?i:n})}function M(e){return(0,l.h)(`div`,{class:`openui-intelligent-field`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:m.font}},[e.label?(0,l.h)(`label`,{style:{fontSize:`13px`,fontWeight:500,color:m.ink,display:`inline-flex`,alignItems:`center`,gap:`4px`}},[e.label,e.required?(0,l.h)(`span`,{style:{color:m.danger},"aria-hidden":`true`},`*`):null]):null,e.control,e.error?(0,l.h)(`div`,{role:`alert`,style:{fontSize:`12px`,color:m.danger}},e.error):null])}const Ge=f.z.array(Ie),N=e=>Array.isArray(e)?e.flat().flatMap(e=>Le(e)??[]):[],Ke=f.z.union([f.z.string(),f.z.object({value:f.z.string(),label:f.z.string(),description:f.z.string().optional()})]),qe=e=>N(e),Je=f.z.object({label:f.z.string(),action:(0,u.action)().optional(),variant:f.z.enum([`solid`,`outline`,`soft`,`ghost`]).optional(),color:f.z.enum([`primary`,`danger`,`success`]).optional(),size:f.z.enum([`sm`,`md`,`lg`]).optional(),icon:f.z.string().optional(),disabled:f.z.boolean().optional(),block:f.z.boolean().optional()}),Ye={sm:{padding:`5px 10px`,fontSize:`12px`,borderRadius:m.radiusSm},md:{padding:`8px 14px`,fontSize:`13px`,borderRadius:m.radiusMd},lg:{padding:`10px 18px`,fontSize:`14px`,borderRadius:m.radiusMd}},Xe=(0,l.defineComponent)({name:`OpenUIIntelligentButton`,props:{props:{type:Object,required:!0}},setup(e){let t=We(),n=(0,u.useIsStreaming)();return()=>{let r=e.props.variant??`solid`,i=e.props.color??`primary`,a=e.props.size??`md`,o=!!(e.props.disabled||n.value),s=b(e.props.label),c=i===`danger`?m.danger:i===`success`?m.success:m.ink,u=i===`danger`?m.dangerSoft:i===`success`?m.successSoft:m.surface,d=r===`solid`?{background:c,color:i===`primary`?m.onInk:`#ffffff`,border:`1px solid transparent`}:r===`outline`?{background:`transparent`,color:c,border:`1px solid ${m.borderStrong}`}:r===`soft`?{background:u,color:c,border:`1px solid transparent`}:{background:`transparent`,color:c,border:`1px solid transparent`};return(0,l.h)(`button`,{type:`button`,disabled:o,class:`openui-intelligent-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,fontFamily:m.font,fontWeight:500,cursor:o?`not-allowed`:`pointer`,opacity:o?.55:1,width:e.props.block?`100%`:void 0,...Ye[a],...d},onClick:()=>{o||t(s,e.props.action,!0)}},[e.props.icon?(0,l.h)(y,{name:e.props.icon,size:a===`sm`?13:15}):null,s])}}}),Ze=(0,u.defineComponent)({name:`Button`,props:Je,description:`icon is a lucide name. Without an action it sends its label to the assistant.`,component:Xe}),Qe=f.z.object({text:f.z.string(),color:S.optional()}),$e=(0,u.defineComponent)({name:`Caption`,props:Qe,description:`Small secondary text.`,component:({props:e})=>(0,l.h)(`span`,{class:`openui-intelligent-caption`,style:{fontSize:`12px`,lineHeight:1.45,color:g(e.color)??m.muted}},b(e.text))}),et=f.z.object({children:x,variant:f.z.enum([`outline`,`soft`]).optional(),gap:f.z.number().optional(),padding:f.z.number().optional()}),tt=(0,u.defineComponent)({name:`Card`,props:et,description:`Panel with a border; soft is a filled panel for summaries.`,component:({props:e,renderNode:t})=>{let n=e.variant===`soft`;return(0,l.h)(`div`,{class:[`openui-intelligent-card`,n?`openui-intelligent-card--soft`:`openui-intelligent-card--outline`],style:{display:`flex`,flexDirection:`column`,gap:_(e.gap)??m.spaceGroup,padding:_(e.padding)??m.spaceGroupLg,borderRadius:m.radiusLg,background:n?m.surface:m.canvas,border:n?`1px solid transparent`:`1px solid ${m.border}`}},[t(e.children)])}}),nt=f.z.object({children:x,itemWidth:f.z.number().optional(),gap:f.z.number().optional()}),rt=(0,u.defineComponent)({name:`Carousel`,props:nt,description:`Horizontal row that scrolls and snaps, each child an item itemWidth px wide (default 240): photos, cards, options, days.`,component:({props:e,renderNode:t})=>{let n=typeof e.itemWidth==`number`&&e.itemWidth>0?e.itemWidth:240,r=Array.isArray(e.children)?e.children.flat():[];return(0,l.h)(`div`,{class:`openui-intelligent-carousel`,style:{display:`flex`,flexDirection:`row`,gap:_(e.gap)??m.spaceGroup,overflowX:`auto`,scrollSnapType:`x mandatory`,paddingBottom:`4px`}},r.map((e,r)=>(0,l.h)(`div`,{key:r,style:{flex:`0 0 ${n}px`,maxWidth:`100%`,scrollSnapAlign:`start`}},[t(e)])))}}),it=f.z.object({when:f.z.boolean()}),at=[m.chart1,m.chart2,m.chart3,m.chart4,m.chart5,m.chart6],ot=(0,l.defineComponent)({name:`OpenUIIntelligentCelebration`,props:{props:{type:Object,required:!0}},setup(e){let t=(0,u.useIsStreaming)(),n=(0,l.ref)(!1),r=null;return(0,l.watch)(()=>[e.props.when===!0,t.value],([e,t],i)=>{let a=i?.[0]??!1;e&&!t&&!a&&(n.value=!0,r&&clearTimeout(r),r=setTimeout(()=>{n.value=!1},2200))},{immediate:!0}),()=>n.value?(0,l.h)(`div`,{"aria-hidden":`true`,class:`openui-intelligent-celebration`,style:{position:`relative`,height:`12px`,overflow:`visible`,pointerEvents:`none`,display:`flex`,justifyContent:`space-around`}},Array.from({length:12},(e,t)=>(0,l.h)(`span`,{key:t,style:{width:`8px`,height:`8px`,borderRadius:t%2==0?`999px`:`2px`,background:at[t%at.length],display:`inline-block`,transform:`rotate(${t*37%360}deg)`}}))):null}}),st=(0,u.defineComponent)({name:`Celebration`,props:it,description:`Bursts confetti when its condition turns true, e.g. Celebration($score == 5) at the end of a quiz.`,component:ot}),ct=f.z.object({type:f.z.enum([`bar`,`line`,`area`,`pie`,`donut`,`scatter`]),data:f.z.array(f.z.record(f.z.string(),f.z.union([f.z.string(),f.z.number()]))),x:f.z.string().optional(),series:f.z.array(f.z.string()).optional(),format:f.z.enum([`number`,`percent`]).optional(),stacked:f.z.boolean().optional(),height:f.z.number().optional()}),lt=e=>Array.isArray(e)?e.filter(e=>e&&typeof e==`object`):[],ut=(e,t)=>{if(t)return t;let n=e[0]??{};return Object.keys(n).find(e=>typeof n[e]==`string`)??Object.keys(n)[0]??``},dt=(e,t,n)=>{if(n?.length)return n;let r=e[0]??{};return Object.keys(r).filter(e=>e!==t&&typeof r[e]==`number`)},ft=(e,t,n)=>e.map(e=>{let r={[t]:e[t]??``};for(let t of n)r[t]=typeof e[t]==`number`?e[t]:0;return r}),pt=[`intelligentChart1`,`intelligentChart2`,`intelligentChart3`,`intelligentChart4`,`intelligentChart5`,`intelligentChart6`];function mt(e,t){let n=e?.theme.value??te,r=pt.map(e=>n[e]??te[e]??`#0285ff`),i=Array.from({length:Math.max(t,1)},(e,t)=>r[t%r.length]);return i.length>2&&i.length%2==0&&i.unshift(i.pop()),i}const ht=(0,l.defineComponent)({name:`OpenUIIntelligentChart`,props:{props:{type:Object,required:!0}},setup(e){let t=re();return()=>{let n=lt(e.props.data),r=ut(n,e.props.x),i=dt(n,r,e.props.series),a=typeof e.props.height==`number`?e.props.height:void 0;if(!n.length||!r)return null;if(e.props.type===`pie`||e.props.type===`donut`)return(0,l.h)(c.PieChart,{data:n,categoryKey:r,dataKey:i[0]??``,variant:e.props.type,format:e.props.format===`percent`?`percentage`:`number`,customPalette:mt(t,n.length),isAnimationActive:!1});if(e.props.type===`scatter`){let e=i.map(e=>({name:e,data:n.map(t=>({x:Number(t[r]??0),y:Number(t[e]??0)}))}));return(0,l.h)(c.ScatterChart,{data:e,xAxisDataKey:`x`,yAxisDataKey:`y`,height:a,customPalette:mt(t,e.length),isAnimationActive:!1})}let o={data:ft(n,r,i),categoryKey:r,height:a,customPalette:mt(t,i.length),isAnimationActive:!1};return e.props.type===`line`?(0,l.h)(c.LineChart,o):e.props.type===`area`?(0,l.h)(c.AreaChart,{...o,stacked:e.props.stacked===!0}):(0,l.h)(c.BarChart,{...o,variant:e.props.stacked?`stacked`:`grouped`})}}}),gt=(0,u.defineComponent)({name:`Chart`,props:ct,description:`Rows of data; x is the category key (a number key for scatter), series the value keys (default: every number key). format applies to pie and donut only: "percent" shows each slice as a share of the total, "number" its value. stacked stacks bar and area series. height sets the plot height in px; pie and donut ignore it and size themselves.`,component:ht}),_t=f.z.object({checked:(0,u.reactive)(f.z.boolean()),label:f.z.string(),lineThrough:f.z.boolean().optional(),rules:T.optional()}),vt=(0,l.defineComponent)({name:`OpenUIIntelligentCheckbox`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.checked),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=n.value===!0;return(0,l.h)(`div`,{class:`openui-intelligent-checkbox`,style:{display:`flex`,flexDirection:`column`,gap:`4px`}},[(0,l.h)(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:`8px`,cursor:i.value?`not-allowed`:`pointer`,fontSize:`14px`,color:t&&e.props.lineThrough?m.muted:m.ink,textDecoration:t&&e.props.lineThrough?`line-through`:void 0}},[(0,l.h)(`input`,{type:`checkbox`,checked:t,disabled:i.value,style:{width:`16px`,height:`16px`,accentColor:m.ink},onChange:e=>{r.clear(),n.setValue(e.target.checked)}}),(0,l.h)(`span`,null,[b(e.props.label),r.required.value?(0,l.h)(`span`,{style:{color:m.danger,marginLeft:`4px`}},`*`):null])]),r.error.value?(0,l.h)(`div`,{role:`alert`,style:{fontSize:`12px`,color:m.danger}},r.error.value):null])}}}),yt=(0,u.defineComponent)({name:`Checkbox`,props:_t,description:`lineThrough strikes the label when checked, for to-do lists. rules takes only required.`,component:vt}),bt=f.z.object({code:f.z.string(),language:f.z.string().optional()}),xt=(0,u.defineComponent)({name:`Code`,props:bt,description:`Code block with a copy button.`,component:({props:e})=>(0,l.h)(c.CodeBlock,{language:b(e.language)||`text`,codeString:b(e.code)})}),St=f.z.object({children:x,gap:f.z.number().optional(),align:Re.optional()}),Ct=(0,l.defineComponent)({name:`OpenUIIntelligentCol`,inheritAttrs:!1,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){return()=>{let t=(0,l.h)(`div`,{class:`openui-intelligent-col`,style:{display:`flex`,flexDirection:`column`,gap:e.props.gap===void 0?m.spaceGroup:void 0,...Se(e.props,!0)}},e.renderNode(e.props.children));return e.statementId===`root`?(0,l.h)(ue,null,{default:()=>t}):t}}}),wt=(0,u.defineComponent)({name:`Col`,props:St,description:`Vertical layout. Without gap it spaces blocks like an article.`,component:Ct}),Tt=f.z.object({value:(0,u.reactive)(f.z.string()),label:f.z.string().optional(),min:f.z.string().optional(),max:f.z.string().optional(),rules:T.optional()}),Et=(0,l.defineComponent)({name:`OpenUIIntelligentDatePicker`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`input`,{type:`date`,value:n.value==null?``:String(n.value),min:e.props.min?b(e.props.min):void 0,max:e.props.max?b(e.props.max):void 0,disabled:i.value,class:`openui-intelligent-date-picker`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}),Dt=(0,u.defineComponent)({name:`DatePicker`,props:Tt,description:`Dates, min and max are "YYYY-MM-DD". rules takes only required.`,component:Et}),Ot=f.z.object({}),kt=(0,u.defineComponent)({name:`Divider`,props:Ot,description:`A thin horizontal rule between blocks.`,component:()=>(0,l.h)(`hr`,{class:`openui-intelligent-divider`,style:{border:`none`,borderTop:`1px solid ${m.border}`,margin:`4px 0`,width:`100%`}})}),At=f.z.object({front:E,back:E,hint:f.z.string().optional()}),jt=(0,l.defineComponent)({name:`OpenUIIntelligentFlashcard`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=(0,l.ref)(!1);return()=>{let n=t.value?e.props.back:e.props.front,r=typeof n==`string`?(0,l.h)(`div`,{style:{fontSize:`20px`,fontWeight:600,color:m.ink,textAlign:`center`}},n):k(n,e.renderNode),i=b(e.props.hint);return(0,l.h)(`button`,{type:`button`,"aria-pressed":t.value,class:[`openui-intelligent-flashcard`,t.value?`openui-intelligent-flashcard--back`:`openui-intelligent-flashcard--front`],style:{width:`100%`,minHeight:`140px`,padding:`20px`,borderRadius:m.radiusLg,border:`1px solid ${m.borderStrong}`,background:t.value?m.surface:m.canvas,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`10px`,cursor:`pointer`,font:`inherit`,color:m.ink},onClick:()=>{t.value=!t.value}},[r,!t.value&&i?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},i):(0,l.h)(`span`,{style:{fontSize:`11px`,color:m.faint}},t.value?`Back · tap to flip`:`Tap to flip`)])}}}),Mt=(0,u.defineComponent)({name:`Flashcard`,props:At,description:`Card that flips between front and back when tapped. Put several in a Carousel or Grid.`,component:jt}),Nt=f.z.object({children:x}),Pt=(0,l.defineComponent)({name:`OpenUIIntelligentForm`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){let t=(0,c.useId)(),n=(0,u.useCreateFormValidation)();return(0,l.provide)(u.FormValidationContext,n),(0,l.provide)(u.FormNameContext,()=>e.statementId??t),()=>(0,l.h)(`form`,{class:`openui-intelligent-form`,novalidate:!0,style:{display:`flex`,flexDirection:`column`,gap:m.spaceGroupLg},onSubmit:e=>{e.preventDefault()}},e.renderNode(e.props.children))}}),Ft=(0,u.defineComponent)({name:`Form`,props:Nt,description:`Groups fields; their values go with any @ToAssistant inside, once every field's rules pass.`,component:Pt}),It=f.z.object({children:x,columns:f.z.number().optional(),minChildWidth:f.z.number().optional(),gap:f.z.number().optional()}),Lt=(0,u.defineComponent)({name:`Grid`,props:It,description:`Equal columns, 1 to 12 (default 2). With minChildWidth (px), columns drop on narrow screens.`,component:({props:e,renderNode:t})=>{let n=typeof e.columns==`number`&&Number.isFinite(e.columns)?Math.min(12,Math.max(1,Math.round(e.columns))):2,r=typeof e.minChildWidth==`number`&&e.minChildWidth>0?Math.round(e.minChildWidth):void 0,i=r?`repeat(auto-fit, minmax(min(${r}px, 100%), 1fr))`:`repeat(${n}, minmax(0, 1fr))`;return(0,l.h)(`div`,{class:`openui-intelligent-grid`,style:{display:`grid`,gridTemplateColumns:i,gap:_(e.gap)??m.spaceGroup}},[t(e.children)])}});function Rt(){let e=re(),t=(0,c.useTheme)();return(0,l.computed)(()=>e?.mode.value??t.mode.value??`light`)}const zt=f.z.object({html:f.z.string(),height:f.z.number().optional(),title:f.z.string().optional()}),Bt=`https://cdn.jsdelivr.net https://unpkg.com https://cdnjs.cloudflare.com https://esm.sh`,Vt=[`default-src 'none'`,`script-src 'unsafe-inline' ${Bt}`,`style-src 'unsafe-inline' ${Bt} https://fonts.googleapis.com`,`font-src https://fonts.gstatic.com data:`,`img-src data: blob: https:`,`media-src data: blob:`,`connect-src ${Bt}`,`frame-src 'none'`,`form-action 'none'`,`base-uri 'none'`].join(`; `),Ht=2400;function Ut(e,t){return`<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${Vt}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>:root{color-scheme:${t}}html,body{margin:0}body{font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}</style><script>(function(){var last=0;function send(){var h=Math.ceil(document.documentElement.getBoundingClientRect().height);if(Math.abs(h-last)>1){last=h;parent.postMessage({type:"openui-intelligent-html-view-height",height:h},"*")}}addEventListener("message",function(e){if(e.source===parent&&e.data==="openui-intelligent-html-view-measure"){last=0;send()}});addEventListener("load",send);new ResizeObserver(send).observe(document.documentElement);send()})()<\/script>${e}`}const Wt=(0,l.defineComponent)({name:`OpenUIIntelligentHtmlView`,props:{props:{type:Object,required:!0}},setup(e){let t=(0,u.useIsStreaming)(),n=Rt(),r=(0,l.ref)(null),i=(0,l.ref)(null),a=(0,l.computed)(()=>typeof e.props.height==`number`&&e.props.height>0?Math.min(Ht,Math.max(80,e.props.height)):null),o=(0,l.computed)(()=>Ut(typeof e.props.html==`string`?e.props.html:``,n.value)),s=e=>{if(a.value!==null||e.source!==r.value?.contentWindow)return;let t=e.data;t?.type===`openui-intelligent-html-view-height`&&typeof t.height==`number`&&Number.isFinite(t.height)&&(i.value=Math.min(Ht,Math.max(80,t.height)))};return(0,l.onMounted)(()=>{typeof window<`u`&&(window.addEventListener(`message`,s),r.value?.contentWindow?.postMessage(`openui-intelligent-html-view-measure`,`*`))}),(0,l.onBeforeUnmount)(()=>{typeof window<`u`&&window.removeEventListener(`message`,s)}),()=>{let n=a.value??i.value??360;return(0,l.h)(`div`,{class:`openui-intelligent-html-view`,style:{width:`100%`,height:`${n}px`,borderRadius:m.radiusMd,border:`1px solid ${m.border}`,overflow:`hidden`,background:m.surface}},t.value?[(0,l.h)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,color:m.muted,fontSize:`13px`}},`Preparing the interactive view…`)]:[(0,l.h)(`iframe`,{ref:r,title:e.props.title||`Interactive view`,sandbox:`allow-scripts`,srcdoc:o.value,referrerpolicy:`no-referrer`,loading:`lazy`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})])}}}),Gt=(0,u.defineComponent)({name:`HtmlView`,props:zt,description:`Sandboxed HTML page with inline JS, for games and canvas. No network except script CDNs. Fits its content unless height is set.`,component:Wt}),Kt=f.z.object({name:f.z.string(),size:f.z.enum([`sm`,`md`,`lg`,`xl`]).optional(),color:S.optional()}),qt={sm:14,md:18,lg:22,xl:28},Jt=(0,u.defineComponent)({name:`Icon`,props:Kt,description:`Lucide icon by name, e.g. "map-pin".`,component:({props:e})=>(0,l.h)(y,{name:b(e.name),size:qt[e.size??`md`]??18,color:e.color})}),Yt=f.z.object({icon:f.z.string(),action:(0,u.action)().optional(),label:f.z.string().optional(),variant:f.z.enum([`outline`,`ghost`,`solid`]).optional()}),Xt=(0,l.defineComponent)({name:`OpenUIIntelligentIconButton`,props:{props:{type:Object,required:!0}},setup(e){let t=We(),n=(0,u.useIsStreaming)();return()=>{let r=e.props.variant??`outline`,i=b(e.props.label)||b(e.props.icon),a=n.value,o=r===`solid`?{background:m.ink,color:m.onInk,border:`1px solid transparent`}:r===`ghost`?{background:`transparent`,color:m.ink,border:`1px solid transparent`}:{background:m.canvas,color:m.ink,border:`1px solid ${m.borderStrong}`};return(0,l.h)(`button`,{type:`button`,disabled:a,"aria-label":i,title:i,class:`openui-intelligent-icon-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`34px`,height:`34px`,borderRadius:`999px`,cursor:a?`not-allowed`:`pointer`,opacity:a?.55:1,...o},onClick:()=>{a||t(i,e.props.action,!1)}},[(0,l.h)(y,{name:b(e.props.icon),size:16})])}}}),Zt=(0,u.defineComponent)({name:`IconButton`,props:Yt,description:`Round icon-only button; label is read aloud. Needs an action.`,component:Xt}),Qt=f.z.object({src:f.z.string(),alt:f.z.string(),aspectRatio:f.z.number().optional(),radius:w.optional(),fit:Fe.optional()}),$t=(0,l.defineComponent)({name:`OpenUIIntelligentImage`,props:{props:{type:Object,required:!0}},setup(e){let t=(0,l.ref)(!1);return()=>{let n=Ne(e.props.src),r=typeof e.props.aspectRatio==`number`&&Number.isFinite(e.props.aspectRatio)?Math.min(5,Math.max(.2,e.props.aspectRatio)):1.5,i=be(e.props.radius)??m.radiusMd,a={width:`100%`,aspectRatio:String(r),borderRadius:i,overflow:`hidden`,background:m.photoEmpty,display:`flex`,alignItems:`center`,justifyContent:`center`};return!n||t.value?(0,l.h)(`div`,{role:`img`,"aria-label":b(e.props.alt)||`Image unavailable`,class:`openui-intelligent-image openui-intelligent-image--empty`,style:a},[(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},b(e.props.alt)||`Image`)]):(0,l.h)(`div`,{class:`openui-intelligent-image`,style:a},[(0,l.h)(`img`,{src:n,alt:b(e.props.alt),loading:`lazy`,referrerpolicy:`no-referrer`,style:{width:`100%`,height:`100%`,objectFit:e.props.fit===`contain`?`contain`:`cover`,display:`block`},onError:()=>{t.value=!0}})])}}}),en=(0,u.defineComponent)({name:`Image`,props:Qt,description:`Photo from a URL the user or a tool gave; never invent a URL. If it fails to load, an empty photo placeholder shows. aspectRatio is 0.2 to 5 (default 1.5).`,component:$t}),tn=f.z.object({value:(0,u.reactive)(f.z.union([f.z.string(),f.z.number()])),label:f.z.string().optional(),type:f.z.enum([`text`,`number`]).optional(),placeholder:f.z.string().optional(),rules:T.optional()}),nn=(0,l.defineComponent)({name:`OpenUIIntelligentInput`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=e.props.type===`number`,a=n.value==null?``:String(n.value);return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`input`,{type:t?`number`:`text`,value:a,placeholder:e.props.placeholder?b(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-input`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,outline:`none`,boxSizing:`border-box`},onInput:e=>{let i=e.target.value;if(r.clear(),t){if(i.trim()===``)n.setValue(null);else{let e=Number(i);n.setValue(Number.isFinite(e)?e:null)}}else n.setValue(i)},onBlur:()=>r.check()})})}}}),rn=(0,u.defineComponent)({name:`Input`,props:tn,description:`Text or number field; a number field stores numbers, and null when emptied.`,component:nn}),an=f.z.object({text:f.z.string()}),on=(0,u.defineComponent)({name:`Label`,props:an,description:`Field or group label.`,component:({props:e})=>(0,l.h)(`span`,{class:`openui-intelligent-label`,style:{fontSize:`12px`,fontWeight:600,letterSpacing:`0.02em`,color:m.muted}},b(e.text))}),sn=f.z.object({text:f.z.string(),url:f.z.string()}),cn=(0,u.defineComponent)({name:`Link`,props:sn,description:`Opens an http(s) URL in a new tab.`,component:({props:e})=>{let t=Ne(e.url),n=b(e.text);return t?(0,l.h)(`a`,{class:`openui-intelligent-link`,href:t,target:`_blank`,rel:`noopener noreferrer`,style:{color:m.info,textDecoration:`underline`,textUnderlineOffset:`2px`}},n):(0,l.h)(`span`,{class:`openui-intelligent-link`},n)}}),ln=f.z.object({title:f.z.string(),description:f.z.string().optional(),marker:f.z.string().optional(),children:x.optional()});function un(e){return f.z.object({items:f.z.array(f.z.union([f.z.string(),e.ref])),marker:f.z.enum([`bullet`,`number`,`none`]).optional(),timeline:f.z.boolean().optional()})}function dn(e,t){return(0,l.h)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,minWidth:0,flex:1}},[(0,l.h)(`div`,{style:{fontWeight:500,color:m.ink,lineHeight:1.45}},[O(b(e.title))]),e.description?(0,l.h)(`div`,{style:{fontSize:`13px`,color:m.muted,lineHeight:1.45}},[O(b(e.description))]):null,e.children?(0,l.h)(`div`,{style:{marginTop:`4px`}},[t(e.children)]):null])}const fn=(0,u.defineComponent)({name:`ListItem`,props:ln,description:`marker replaces the bullet or number, e.g. a time or an emoji.`,component:({props:e,renderNode:t})=>(0,l.h)(`div`,{class:`openui-intelligent-list-item`,style:{display:`flex`,gap:`8px`,alignItems:`flex-start`}},[typeof e.marker==`string`&&e.marker?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted,flexShrink:0}},e.marker):null,dn(e,t)])}),pn=e=>Be(e)&&e.typeName===`ListItem`,mn=(0,u.defineComponent)({name:`List`,props:un(fn),description:`timeline joins the markers with a line.`,component:({props:e,renderNode:t})=>{let n=(Array.isArray(e.items)?e.items.flat():[]).filter(e=>e!=null),r=e.marker??`bullet`,i=e.timeline===!0;return(0,l.h)(r===`number`?`ol`:`ul`,{class:[`openui-intelligent-list`,i?`openui-intelligent-list--timeline`:null],style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:i?`12px`:`8px`}},n.map((e,n)=>{let a=pn(e)?e.props:null,o=a&&typeof a.marker==`string`?a.marker:void 0,s=o??(r===`none`?null:r===`number`?`${n+1}.`:`•`);return(0,l.h)(`li`,{key:n,style:{display:`flex`,gap:`10px`,alignItems:`flex-start`,position:`relative`,paddingLeft:i?`4px`:void 0,borderLeft:i?`2px solid ${m.borderStrong}`:void 0}},[s?(0,l.h)(`span`,{style:{minWidth:o?`auto`:`18px`,fontSize:`13px`,color:m.muted,fontWeight:500,flexShrink:0}},s):null,a?dn(a,t):(0,l.h)(`div`,{style:{flex:1,lineHeight:1.5,color:m.ink}},[O(b(e))])])}))}}),hn=f.z.object({text:f.z.string()}),gn=(0,u.defineComponent)({name:`Markdown`,props:hn,description:`Prose with headings, lists, quotes, code and tables.`,component:({props:e})=>(0,l.h)(c.MarkDownRenderer,{textMarkdown:b(e.text),className:`openui-intelligent-markdown`})}),_n=f.z.object({tex:f.z.string(),inline:f.z.boolean().optional()}),vn=(0,u.defineComponent)({name:`Math`,props:_n,description:`LaTeX formula, e.g. Math("E = mc^2"); inline true to sit in a Text list.`,component:({props:e})=>{let t=b(e.tex),n=e.inline===!0,r=``;try{r=p.default.renderToString(t,{displayMode:!n,throwOnError:!1,strict:!1})}catch{return(0,l.h)(n?`span`:`div`,{class:`openui-intelligent-math`},t)}return(0,l.h)(n?`span`:`div`,{class:[`openui-intelligent-math`,n?`openui-intelligent-math--inline`:`openui-intelligent-math--block`],style:n?void 0:{overflowX:`auto`,padding:`4px 0`},innerHTML:r})}}),yn=f.z.object({trigger:E,content:E}),bn=(0,l.defineComponent)({name:`OpenUIIntelligentPopover`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=(0,l.ref)(!1);return()=>(0,l.h)(`span`,{class:`openui-intelligent-popover`,style:{position:`relative`,display:`inline-flex`,alignItems:`center`}},[(0,l.h)(`button`,{type:`button`,"aria-expanded":t.value,onClick:()=>{t.value=!t.value},style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,background:`transparent`,border:`none`,padding:`2px 4px`,cursor:`pointer`,color:`inherit`,font:`inherit`,borderRadius:m.radiusSm}},[k(e.props.trigger,e.renderNode)]),t.value?(0,l.h)(`div`,{role:`dialog`,class:`openui-intelligent-popover-panel`,style:{position:`absolute`,top:`calc(100% + 6px)`,left:0,zIndex:40,minWidth:`200px`,maxWidth:`320px`,padding:m.spaceGroup,borderRadius:m.radiusMd,background:m.canvas,color:m.ink,border:`1px solid ${m.borderStrong}`,boxShadow:m.shadow}},[k(e.props.content,e.renderNode)]):null])}}),xn=(0,u.defineComponent)({name:`Popover`,props:yn,description:`Shows content in a small panel when the trigger is clicked: a definition, a source, details behind an Icon("info", "sm"). The trigger is text or an Icon, never a Button: it is a button already.`,component:bn}),Sn=f.z.object({children:x,action:(0,u.action)().optional(),selected:f.z.boolean().optional(),padding:f.z.number().optional(),background:S.optional(),radius:w.optional()}),Cn=(0,l.defineComponent)({name:`OpenUIIntelligentPressable`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=We(),n=(0,u.useIsStreaming)(),r=(0,l.ref)(null);return()=>{let i=e.props.selected===!0,a=n.value,o={display:`flex`,flexDirection:`column`,textAlign:`left`,padding:_(e.props.padding)??m.spaceGroup,borderRadius:be(e.props.radius)??m.radiusMd,background:_e(e.props.background)??(i?m.surfaceStrong:m.canvas),border:i?`2px solid ${m.ink}`:`1px solid ${m.border}`,cursor:a?`not-allowed`:`pointer`,width:`100%`,font:`inherit`,color:`inherit`,...je(e.props.background)};return(0,l.h)(`button`,{ref:r,type:`button`,disabled:a,"aria-pressed":i,class:[`openui-intelligent-pressable`,i?`openui-intelligent-pressable--selected`:null],style:o,onClick:()=>{a||t(we(r.value),e.props.action,!1)}},e.renderNode(e.props.children))}}}),wn=(0,u.defineComponent)({name:`Pressable`,props:Sn,description:`Makes any content clickable, such as a tile or a swatch. Needs an action.`,component:Cn}),Tn=f.z.object({text:f.z.string(),cite:f.z.string().optional()}),En=(0,u.defineComponent)({name:`Quote`,props:Tn,description:`A quotation or a callout with a side rule; cite names the source.`,component:({props:e})=>(0,l.h)(`blockquote`,{class:`openui-intelligent-quote`,style:{margin:0,padding:`8px 14px`,borderLeft:`3px solid ${m.borderStrong}`,background:m.surface,borderRadius:`0 ${m.radiusSm} ${m.radiusSm} 0`,display:`flex`,flexDirection:`column`,gap:`6px`}},[(0,l.h)(`div`,{style:{color:m.ink,lineHeight:1.55}},[O(b(e.text))]),e.cite?(0,l.h)(`cite`,{style:{fontSize:`12px`,color:m.muted,fontStyle:`normal`}},`— ${b(e.cite)}`):null])}),Dn=f.z.object({value:(0,u.reactive)(f.z.string()),options:f.z.array(Ke),label:f.z.string().optional(),variant:f.z.enum([`list`,`pills`,`cards`]).optional(),rules:T.optional()}),On=(0,l.defineComponent)({name:`OpenUIIntelligentRadioGroup`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let a=qe(e.props.options),o=n.value==null?``:String(n.value),s=e.props.variant??`list`,c=(0,l.h)(`div`,{role:`radiogroup`,class:`openui-intelligent-radio-group openui-intelligent-radio-group--${s}`,style:{display:`flex`,flexDirection:s===`pills`?`row`:`column`,flexWrap:s===`pills`?`wrap`:void 0,gap:`8px`}},a.map(e=>{let a=o===e.value;return s===`pills`?(0,l.h)(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":a,disabled:i.value,style:{padding:`6px 12px`,borderRadius:`999px`,fontSize:`13px`,fontWeight:500,cursor:i.value?`not-allowed`:`pointer`,background:a?m.ink:m.surface,color:a?m.onInk:m.ink,border:`1px solid ${a?m.ink:m.border}`},onClick:()=>{i.value||(r.clear(),n.setValue(e.value))}},e.label):(0,l.h)(`label`,{key:e.value,style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:s===`cards`?`10px 12px`:`4px 0`,borderRadius:s===`cards`?m.radiusMd:void 0,border:s===`cards`?`1px solid ${a?m.ink:m.border}`:void 0,background:s===`cards`&&a?m.surface:void 0,cursor:i.value?`not-allowed`:`pointer`}},[(0,l.h)(`input`,{type:`radio`,name:t.value,value:e.value,checked:a,disabled:i.value,style:{marginTop:`3px`,accentColor:m.ink},onChange:()=>{r.clear(),n.setValue(e.value)}}),(0,l.h)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[(0,l.h)(`span`,{style:{fontSize:`14px`,fontWeight:s===`cards`?500:400,color:m.ink}},e.label),e.description?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},e.description):null])])}));return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:c})}}}),kn=(0,u.defineComponent)({name:`RadioGroup`,props:Dn,description:`pills for short choices; cards for choices that need a description line.`,component:On}),An=f.z.object({children:x,gap:f.z.number().optional(),align:Re.optional(),justify:ze.optional(),wrap:f.z.boolean().optional()}),jn=(0,u.defineComponent)({name:`Row`,props:An,description:`Horizontal layout; items are vertically centered.`,component:({props:e,renderNode:t})=>(0,l.h)(`div`,{class:`openui-intelligent-row`,style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:e.gap===void 0?m.spaceInner:void 0,...Se(e,!1)}},[t(e.children)])}),Mn=f.z.object({value:(0,u.reactive)(f.z.string()),options:Ge,block:f.z.boolean().optional()}),Nn=(0,l.defineComponent)({name:`OpenUIIntelligentSegmentedControl`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>`segmented`,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=(0,u.useIsStreaming)();return()=>{let t=N(e.props.options),i=n.value==null?``:String(n.value);return(0,l.h)(`div`,{role:`tablist`,class:`openui-intelligent-segmented`,style:{display:e.props.block?`flex`:`inline-flex`,flexShrink:0,width:e.props.block?`100%`:void 0,padding:`3px`,gap:`2px`,background:m.surface,borderRadius:m.radiusMd,border:`1px solid ${m.border}`}},t.map(t=>{let a=i===t.value;return(0,l.h)(`button`,{key:t.value,type:`button`,role:`tab`,"aria-selected":a,disabled:r.value,style:{flex:e.props.block?`1 1 0%`:`0 0 auto`,padding:`6px 12px`,fontSize:`13px`,fontWeight:a?600:500,fontFamily:m.font,whiteSpace:`nowrap`,borderRadius:m.radiusSm,border:`none`,cursor:r.value?`not-allowed`:`pointer`,background:a?m.canvas:`transparent`,color:a?m.ink:m.muted,boxShadow:a?m.shadowSm:void 0},onClick:()=>{r.value||n.setValue(t.value)}},t.label)}))}}}),Pn=(0,u.defineComponent)({name:`SegmentedControl`,props:Mn,description:`2 to 4 short choices in a row.`,component:Nn}),Fn=f.z.object({value:(0,u.reactive)(f.z.string()),options:Ge,label:f.z.string().optional(),placeholder:f.z.string().optional(),rules:T.optional()}),In=(0,l.defineComponent)({name:`OpenUIIntelligentSelect`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=N(e.props.options),a=n.value==null?``:String(n.value);return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,width:`100%`}},[(0,l.h)(`select`,{value:a,disabled:i.value,class:`openui-intelligent-select`,style:{appearance:`none`,WebkitAppearance:`none`,width:`100%`,padding:`8px 32px 8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,boxSizing:`border-box`,cursor:i.value?`not-allowed`:`pointer`},onChange:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()},[e.props.placeholder&&!a?(0,l.h)(`option`,{value:``,disabled:!0},b(e.props.placeholder)):null,...t.map(e=>(0,l.h)(`option`,{key:e.value,value:e.value},e.label))]),(0,l.h)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,style:{position:`absolute`,right:`10px`,pointerEvents:`none`,color:m.muted}},[(0,l.h)(`path`,{d:`M3 4.5L6 7.5L9 4.5`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})])])})}}}),Ln=(0,u.defineComponent)({name:`Select`,props:Fn,description:`Dropdown, for long option lists.`,component:In}),Rn=f.z.object({value:(0,u.reactive)(f.z.number()),min:f.z.number(),max:f.z.number(),step:f.z.number().optional(),label:f.z.string().optional(),unit:f.z.string().optional(),marks:f.z.array(f.z.object({value:f.z.number(),label:f.z.string()})).optional()}),zn=(0,l.defineComponent)({name:`OpenUIIntelligentSlider`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=(0,u.useIsStreaming)();return()=>{let t=typeof e.props.min==`number`&&Number.isFinite(e.props.min)?e.props.min:0,i=typeof e.props.max==`number`&&Number.isFinite(e.props.max)?e.props.max:100,a=typeof e.props.step==`number`&&e.props.step>0?e.props.step:1,o=typeof n.value==`number`&&Number.isFinite(n.value)?n.value:t,s=e.props.unit?b(e.props.unit):``,c=s===`$`||s===`€`||s===`£`||s===`¥`?`${s}${Te(o)}`:`${Te(o)}${s}`;return(0,l.h)(`div`,{class:`openui-intelligent-slider`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:m.font}},[(0,l.h)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,gap:`8px`}},[e.props.label?(0,l.h)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:m.ink}},b(e.props.label)):(0,l.h)(`span`),(0,l.h)(`span`,{style:{fontSize:`13px`,fontWeight:600,fontVariantNumeric:`tabular-nums`,color:m.ink}},c)]),(0,l.h)(`input`,{type:`range`,min:t,max:i,step:a,value:o,disabled:r.value,style:{width:`100%`,accentColor:m.rangeThumb,cursor:r.value?`not-allowed`:`pointer`},onInput:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n.setValue(t)}}),Array.isArray(e.props.marks)&&e.props.marks.length>0?(0,l.h)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:`11px`,color:m.muted}},e.props.marks.map((e,t)=>(0,l.h)(`span`,{key:t},b(e.label)))):null])}}}),Bn=(0,u.defineComponent)({name:`Slider`,props:Rn,description:`Shows label and value; unit like "%" or "$" formats the value.`,component:zn}),Vn=f.z.object({}),Hn=(0,u.defineComponent)({name:`Spacer`,props:Vn,description:`Fills the free space in a Row.`,component:()=>(0,l.h)(`div`,{class:`openui-intelligent-spacer`,style:{flex:`1 1 auto`}})}),Un=Symbol(`OpenUI.Intelligent.InSvg`),P=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,Wn=e=>P(e)===void 0?void 0:Math.min(1,Math.max(0,e)),Gn=/^[\d\s,.eE+-]*$/,Kn=/^[MmLlHhVvCcSsQqTtAaZz\d\s,.eE+-]*$/,qn=/^\s*-?\d+(\.\d+)?[\s,]+-?\d+(\.\d+)?[\s,]+\d+(\.\d+)?[\s,]+\d+(\.\d+)?\s*$/,F=(e,t)=>typeof e==`string`&&e.length<2e4&&t.test(e)?e:void 0,I={fill:S.optional(),stroke:S.optional(),strokeWidth:f.z.number().optional(),opacity:f.z.number().optional()},L=(e,t)=>({fill:e.fill===void 0?t&&e.stroke===void 0?`currentColor`:`none`:g(e.fill)??`none`,stroke:e.stroke===void 0?t?void 0:`currentColor`:g(e.stroke),"stroke-width":P(e.strokeWidth)??(t?void 0:2),opacity:Wn(e.opacity),"stroke-linecap":`round`,"stroke-linejoin":`round`}),Jn=(0,l.defineComponent)({name:`OpenUIIntelligentSvgCanvas`,props:{viewBox:{type:String,required:!0},label:String,width:[Number,String],height:[Number,String]},setup(e,{slots:t}){return(0,l.provide)(Un,!0),()=>{let n=F(e.viewBox,qn)??`0 0 100 100`;return(0,l.h)(`svg`,{class:`openui-intelligent-svg`,viewBox:n,role:e.label?`img`:void 0,"aria-label":e.label||void 0,"aria-hidden":e.label?void 0:`true`,style:{display:`block`,maxWidth:`100%`,width:v(e.width)??`100%`,height:v(e.height)??`auto`,color:m.ink}},t.default?.())}}}),R=(0,l.defineComponent)({name:`OpenUIIntelligentSvgStandalone`,setup(e,{slots:t}){let n=(0,l.inject)(Un,!1);return()=>n?t.default?.():(0,l.h)(Jn,{viewBox:`0 0 100 100`,width:160},{default:()=>t.default?.()})}}),Yn=f.z.object({cx:f.z.number(),cy:f.z.number(),r:f.z.number(),...I}),Xn=(0,u.defineComponent)({name:`Circle`,props:Yn,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`circle`,{cx:P(e.cx),cy:P(e.cy),r:Math.max(0,P(e.r)??0),...L(e,!0)})})}),Zn=f.z.object({cx:f.z.number(),cy:f.z.number(),rx:f.z.number(),ry:f.z.number(),...I}),Qn=(0,u.defineComponent)({name:`Ellipse`,props:Zn,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`ellipse`,{cx:P(e.cx),cy:P(e.cy),rx:Math.max(0,P(e.rx)??0),ry:Math.max(0,P(e.ry)??0),...L(e,!0)})})}),$n=f.z.object({x:f.z.number(),y:f.z.number(),width:f.z.number(),height:f.z.number(),...I,rx:f.z.number().optional()}),er=(0,u.defineComponent)({name:`Rect`,props:$n,description:`rx rounds the corners; fill defaults to the text color, and with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`rect`,{x:P(e.x),y:P(e.y),width:Math.max(0,P(e.width)??0),height:Math.max(0,P(e.height)??0),rx:P(e.rx),...L(e,!0)})})}),tr=f.z.object({x1:f.z.number(),y1:f.z.number(),x2:f.z.number(),y2:f.z.number(),stroke:S.optional(),strokeWidth:f.z.number().optional(),opacity:f.z.number().optional()}),nr=(0,u.defineComponent)({name:`Line`,props:tr,description:`Stroked in the text color, 2 wide, unless stroke and strokeWidth are set.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`line`,{x1:P(e.x1),y1:P(e.y1),x2:P(e.x2),y2:P(e.y2),...L(e,!1)})})}),rr={m:2,l:2,t:2,h:1,v:1,c:6,s:4,q:4,a:7,z:0},ir=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?/i,ar=/^[01]/,or=e=>{let t=e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*$/i)?.[0];if(!t)return e.trim()===``;let n=rr[t[0].toLowerCase()],r=t.slice(1),i=0;for(;r=r.replace(/^[\s,]+/,``),r;){let e=i%7,t=(n===7&&(e===3||e===4)?ar:ir).exec(r);if(!t)return!1;r=r.slice(t[0].length),i++}return/[.eE+-]$/.test(t.trimEnd())?!1:n===0?i===0:i>0&&i%n===0},sr=f.z.object({d:f.z.string(),...I}),cr=(0,u.defineComponent)({name:`Path`,props:sr,description:`d is SVG path data only (M, L, C, A, Z...), else nothing draws; unfilled unless fill is set.`,component:({props:e})=>{let t=F(e.d,Kn);return(0,l.h)(R,null,{default:()=>(0,l.h)(`path`,{d:t!==void 0&&or(t)?t:void 0,...L(e,e.fill!==void 0)})})}}),lr=f.z.object({points:f.z.string(),fill:S.optional(),stroke:S.optional(),strokeWidth:f.z.number().optional(),opacity:f.z.number().optional()}),ur=(0,u.defineComponent)({name:`Polyline`,props:lr,description:`points like "0,0 10,5 20,0".`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`polyline`,{points:F(e.points,Gn),...L(e,!1)})})}),dr=f.z.object({points:f.z.string(),...I}),fr=(0,u.defineComponent)({name:`Polygon`,props:dr,description:`Closed shape; points like "0,0 10,5 20,0". fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`polygon`,{points:F(e.points,Gn),...L(e,!0)})})}),pr=f.z.object({text:f.z.string(),x:f.z.number(),y:f.z.number(),size:f.z.number().optional(),fill:S.optional(),anchor:f.z.enum([`start`,`middle`,`end`]).optional(),weight:f.z.enum([`normal`,`medium`,`semibold`]).optional()}),mr=[Xn,Qn,er,nr,cr,ur,fr,(0,u.defineComponent)({name:`SvgText`,props:pr,description:`A text label at x, y; anchor sets which end sits on x.`,component:({props:e})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`text`,{x:P(e.x),y:P(e.y),"font-size":P(e.size)??12,fill:g(e.fill)??`currentColor`,"text-anchor":e.anchor??`start`,"font-weight":e.weight===`semibold`?640:e.weight===`medium`?560:440,"font-family":m.font},String(e.text??``))})})],hr=f.z.array(f.z.union(mr.map(e=>e.ref))),gr={translate:[1,2],rotate:[1,3],scale:[1,2],skewX:[1],skewY:[1],matrix:[6]};function _r(e){if(typeof e!=`string`||e.length>500)return;let t=[...e.matchAll(/\s*([a-zA-Z]+)\(([^()]*)\)\s*/g)];if(t.length&&t.map(e=>e[0]).join(``)===e)return t.every(([,e,t])=>{let n=t.trim().split(/\s*,\s*|\s+/).filter(Boolean);return(gr[e]?.includes(n.length)??!1)&&n.every(e=>Number.isFinite(Number(e)))})?e.trim():void 0}const vr=f.z.object({children:hr,transform:f.z.string().optional(),opacity:f.z.number().optional()}),yr=(0,u.defineComponent)({name:`G`,props:vr,description:`Group; transform like "rotate(30 50 50)" or "translate(10 0)"; one with the wrong number of arguments is dropped.`,component:({props:e,renderNode:t})=>(0,l.h)(R,null,{default:()=>(0,l.h)(`g`,{transform:_r(e.transform),opacity:Wn(e.opacity)},[t(e.children)])})}),br=/* @__PURE__ */ new Set([...mr.map(e=>e.name),yr.name]),xr=f.z.object({children:f.z.array(f.z.union([...hr.element.options,yr.ref])),viewBox:f.z.string(),label:f.z.string().optional(),width:C.optional(),height:C.optional()}),Sr=[(0,u.defineComponent)({name:`Svg`,props:xr,description:`A drawing for steps, parts, mechanisms, diagrams and layouts. Scales to its width; its shapes take expressions, so state can move them. label says in a few words what it shows, for screen readers: always give one.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.children)?e.children:[],r=e=>Be(e)&&br.has(String(e.typeName)),i=n.filter(e=>!r(e));return(0,l.h)(l.Fragment,null,[(0,l.h)(Jn,{viewBox:e.viewBox,label:e.label,width:e.width,height:e.height},{default:()=>t(n.filter(r))}),i.length?t(i):null])}}),...mr,yr],Cr=f.z.object({columns:f.z.array(f.z.string()),rows:f.z.array(f.z.array(f.z.any()))}),wr=(0,u.defineComponent)({name:`Table`,props:Cr,description:`Each row lists its cells in column order; a cell may be a component. Number columns align right.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.columns)?e.columns.map(b):[],r=Array.isArray(e.rows)?e.rows.filter(e=>Array.isArray(e)):[],i=n.map((e,t)=>r.length>0&&r.every(e=>e[t]==null||typeof e[t]==`number`));return(0,l.h)(`div`,{class:`openui-intelligent-table-wrap`,style:{width:`100%`,overflowX:`auto`,border:`1px solid ${m.border}`,borderRadius:m.radiusMd}},[(0,l.h)(`table`,{class:`openui-intelligent-table`,style:{width:`100%`,borderCollapse:`collapse`,fontSize:`13px`,fontFamily:m.font}},[(0,l.h)(`thead`,null,(0,l.h)(`tr`,{style:{background:m.surface,borderBottom:`1px solid ${m.border}`}},n.map((e,t)=>(0,l.h)(`th`,{key:t,style:{padding:`8px 12px`,textAlign:i[t]?`right`:`left`,fontWeight:600,color:m.muted,whiteSpace:`nowrap`}},e)))),(0,l.h)(`tbody`,null,r.map((e,a)=>(0,l.h)(`tr`,{key:a,style:{borderBottom:a<r.length-1?`1px solid ${m.border}`:void 0}},n.map((n,r)=>{let a=e[r],o=Be(a)||Array.isArray(a)?t(a):typeof a==`number`?Te(a):O(b(a));return(0,l.h)(`td`,{key:r,style:{padding:`8px 12px`,textAlign:i[r]?`right`:`left`,fontVariantNumeric:i[r]?`tabular-nums`:void 0,color:m.ink}},[o])}))))])])}}),Tr=f.z.union([f.z.string(),x]),Er=f.z.object({text:Tr,size:f.z.enum([`xs`,`sm`,`md`,`lg`]).optional(),color:S.optional(),weight:f.z.enum([`normal`,`medium`,`semibold`]).optional(),italic:f.z.boolean().optional(),lineThrough:f.z.boolean().optional(),tabularNums:f.z.boolean().optional(),maxLines:f.z.number().optional()}),Dr={xs:`12px`,sm:`13px`,md:`14px`,lg:`16px`},Or={normal:400,medium:500,semibold:600},kr=(0,u.defineComponent)({name:`Text`,props:Er,description:'Paragraph; supports **bold**, *italic*, `code` and [links](https://…). text may be a list mixing strings and inline components: [Icon("clock", "sm"), " 25 min · ", Badge("Easy")].',component:({props:e,renderNode:t})=>{let n={margin:0,fontSize:Dr[e.size??`md`]??`14px`,lineHeight:1.55,color:g(e.color)??m.ink,fontWeight:e.weight?Or[e.weight]:void 0,fontStyle:e.italic?`italic`:void 0,textDecoration:e.lineThrough?`line-through`:void 0,fontVariantNumeric:e.tabularNums?`tabular-nums`:void 0};typeof e.maxLines==`number`&&e.maxLines>0&&(n.display=`-webkit-box`,n.WebkitLineClamp=String(Math.round(e.maxLines)),n.WebkitBoxOrient=`vertical`,n.overflow=`hidden`);let r=Array.isArray(e.text)?e.text.flat().map(e=>k(e,t)):k(e.text,t);return(0,l.h)(`p`,{class:`openui-intelligent-text`,style:n},[r])}}),Ar=f.z.object({value:(0,u.reactive)(f.z.string()),label:f.z.string().optional(),placeholder:f.z.string().optional(),rows:f.z.number().optional(),rules:T.optional()}),jr=(0,l.defineComponent)({name:`OpenUIIntelligentTextArea`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.value),r=A(t,()=>e.props.rules,()=>n.value),i=(0,u.useIsStreaming)();return()=>{let t=typeof e.props.rows==`number`&&Number.isFinite(e.props.rows)?Math.min(20,Math.max(2,Math.round(e.props.rows))):3;return M({label:e.props.label?b(e.props.label):void 0,required:r.required.value,error:r.error.value,control:(0,l.h)(`textarea`,{rows:t,value:n.value==null?``:String(n.value),placeholder:e.props.placeholder?b(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-textarea`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:m.font,color:m.ink,background:m.canvas,border:`1px solid ${r.error.value?m.danger:m.borderStrong}`,borderRadius:m.radiusMd,outline:`none`,resize:`vertical`,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}}),Mr=(0,u.defineComponent)({name:`TextArea`,props:Ar,description:`Multi-line text field; rows is 2 to 20 (default 3).`,component:jr}),Nr=f.z.object({seconds:(0,u.reactive)(f.z.number()),label:f.z.string().optional()});function Pr(e){let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}const Fr=(0,l.defineComponent)({name:`OpenUIIntelligentTimer`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=j(()=>e.props.label,()=>e.statementId),n=(0,u.useStateField)(t,()=>e.props.seconds),r=(0,u.useIsStreaming)(),i=(0,l.ref)(typeof n.value==`number`&&Number.isFinite(n.value)?n.value:0),a=(0,l.ref)(!1),o=null,s=()=>{a.value=!1,o!==null&&(clearInterval(o),o=null)},c=()=>{r.value||a.value||Number(n.value??0)<=0||(a.value=!0,o=setInterval(()=>{let e=Number(n.value??0);e<=1?(n.setValue(0),s()):n.setValue(e-1)},1e3))},d=()=>{s(),n.setValue(i.value)};return(0,l.onBeforeUnmount)(s),()=>{let t=typeof n.value==`number`?n.value:Number(n.value??0),i=typeof document<`u`&&document.documentElement.lang.toLowerCase().startsWith(`zh`);return(0,l.h)(`div`,{class:`openui-intelligent-timer`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,padding:`12px 14px`,borderRadius:m.radiusMd,background:m.surface,border:`1px solid ${m.border}`}},[(0,l.h)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[e.props.label?(0,l.h)(`span`,{style:{fontSize:`12px`,color:m.muted}},b(e.props.label)):null,(0,l.h)(`span`,{style:{fontSize:`24px`,fontWeight:700,fontVariantNumeric:`tabular-nums`,color:m.ink}},Pr(t))]),(0,l.h)(`div`,{style:{display:`flex`,gap:`8px`,flexShrink:0}},[(0,l.h)(`button`,{type:`button`,disabled:r.value||!a.value&&t<=0,onClick:()=>a.value?s():c(),style:{padding:`6px 12px`,borderRadius:m.radiusSm,border:`none`,background:m.ink,color:m.onInk,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},a.value?i?`暂停`:`Pause`:i?`开始`:`Start`),(0,l.h)(`button`,{type:`button`,disabled:r.value,onClick:d,style:{padding:`6px 12px`,borderRadius:m.radiusSm,border:`1px solid ${m.borderStrong}`,background:m.canvas,color:m.ink,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},i?`重置`:`Reset`)])])}}}),Ir=(0,u.defineComponent)({name:`Timer`,props:Nr,description:`Countdown with start, pause and reset. It counts the bound seconds down to 0, so other statements can react, e.g. $left == 0.`,component:Fr}),Lr=f.z.object({text:f.z.string(),size:f.z.enum([`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`]).optional(),color:S.optional()}),Rr={sm:{fontSize:`14px`,lineHeight:`1.35`,fontWeight:600},md:{fontSize:`16px`,lineHeight:`1.35`,fontWeight:600},lg:{fontSize:`20px`,lineHeight:`1.28`,fontWeight:650},xl:{fontSize:`24px`,lineHeight:`1.22`,fontWeight:650},"2xl":{fontSize:`32px`,lineHeight:`1.15`,fontWeight:700},"3xl":{fontSize:`40px`,lineHeight:`1.1`,fontWeight:700}},zr=(0,u.defineComponent)({name:`Title`,props:Lr,description:`Heading; md for a card title, lg for a section, 2xl for a big number.`,component:({props:e})=>{let t=Rr[e.size??`md`]??Rr.md;return(0,l.h)(`div`,{role:`heading`,"aria-level":e.size===`3xl`||e.size===`2xl`?2:e.size===`xl`||e.size===`lg`?3:4,class:`openui-intelligent-title`,style:{margin:0,color:g(e.color)??m.ink,letterSpacing:`-0.015em`,...t}},b(e.text))}}),Br=f.z.object({video:f.z.string(),title:f.z.string().optional()}),z=/^[A-Za-z0-9_-]{11}$/;function Vr(e){let t=e.trim();if(z.test(t))return t;try{let e=new URL(t),n=e.hostname.replace(/^www\./,``);if(n===`youtu.be`){let t=e.pathname.slice(1).split(`/`)[0]??``;return z.test(t)?t:null}if(n===`youtube.com`||n===`m.youtube.com`||n===`youtube-nocookie.com`){let t=e.searchParams.get(`v`);if(t&&z.test(t))return t;let n=e.pathname.split(`/`).filter(Boolean),r=n[1]??``;if((n[0]===`embed`||n[0]===`shorts`)&&z.test(r))return r}}catch{return null}return null}const Hr=[wt,jn,He,Lt,tt,rt,xn,kt,Hn,zr,kr,$e,on,Oe,cn,mn,fn,gn,En,xt,vn,Ze,Zt,wn,rn,Mr,Ln,Pn,Bn,yt,kn,Dt,Ir,Ft,en,Jt,wr,gt,(0,u.defineComponent)({name:`YouTube`,props:Br,description:`Embedded YouTube video by id or URL. Only a video you know exists.`,component:({props:e})=>{let t=Vr(b(e.video));return t?(0,l.h)(`div`,{class:`openui-intelligent-youtube`,style:{width:`100%`,aspectRatio:`16 / 9`,borderRadius:m.radiusMd,overflow:`hidden`,background:m.surface}},[(0,l.h)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${t}`,title:b(e.title)||`YouTube video`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowfullscreen:!0,loading:`lazy`,referrerpolicy:`strict-origin-when-cross-origin`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})]):null}}),Mt,st,...Sr,Gt],Ur=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Wr(e){let t=Ur.exec(e.trim());if(!t)throw Error(`not a hex color: ${e}`);let n=t[1].length===3?t[1].replace(/./g,`$&$&`):t[1];return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}const Gr=[(0,u.defineFunction)({name:`MixColor`,description:`The hex color a fraction t of the way from one hex color to another, e.g. @MixColor("#ffffff", "#0285ff", 0.5) for a heatmap or a tint`,params:f.z.object({from:f.z.string(),to:f.z.string(),t:f.z.number()}),returns:f.z.string(),fn:({from:e,to:t,t:n})=>{let r=Wr(e),i=Wr(t),a=Math.min(1,Math.max(0,n));return`#${r.map((e,t)=>Math.round(e+(i[t]-e)*a).toString(16).padStart(2,`0`)).join(``)}`}})],B=()=>f.z.array(f.z.any()),Kr=()=>f.z.array(f.z.number()),V=()=>f.z.union([f.z.string(),f.z.number()]),qr=()=>f.z.enum([`sum`,`avg`,`count`,`min`,`max`]);function H(e,t){if(!t)return e;let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function U(e,t){if(e===t)return!0;if(typeof e==`number`&&typeof t==`string`||typeof e==`string`&&typeof t==`number`)return String(e)===String(t);if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e))return e.length===t.length&&e.every((e,n)=>U(e,t[n]));let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&U(e[n],t[n]))}function W(e){if(!Number.isFinite(e))throw Error(`result is not a finite number`);return e}function G(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function Jr(e,t,n){if(n===`count`)return e.length;let r=e.map(e=>G(H(e,t??``))).filter(e=>e!==null);if(!r.length)return 0;switch(n){case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.reduce((e,t)=>e+t,0)/r.length;case`min`:return Math.min(...r);case`max`:return Math.max(...r)}}function K(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=H(r,t),i=typeof e==`number`?e:e==null||e===``?`Unknown`:String(e),a=n.get(i);a?a.push(r):n.set(i,[r])}return n}const q=1e4,J=864e5,Yr=/^(\d{4})-(\d{2})-(\d{2})$/;function Y(e){if(typeof e==`string`){let t=Yr.exec(e.trim());if(t){let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=Date.UTC(n,r-1,i),o=new Date(a);if(o.getUTCMonth()!==r-1||o.getUTCDate()!==i)throw Error(`invalid date "${e}"`);return{day:a/J,instant:null}}}let t=new Date(e);if(Number.isNaN(t.getTime()))throw Error(`invalid date "${e}"`);return{day:Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/J,instant:t}}function X(e){return(/* @__PURE__ */ new Date(e*J)).toISOString().slice(0,10)}const Xr={date:{month:`short`,day:`numeric`,year:`numeric`},short:{month:`short`,day:`numeric`},long:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`},weekday:{weekday:`short`},month:{month:`short`,year:`numeric`},time:{hour:`numeric`,minute:`2-digit`},datetime:{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}},Zr=(0,u.defineFunction)({name:`Now`,description:`The current date and time as an ISO string`,params:f.z.object({}),returns:f.z.string(),fn:()=>(/* @__PURE__ */ new Date()).toISOString()}),Qr=(0,u.defineFunction)({name:`FormatDate`,description:`A date as text: "date" Oct 9, 2026 (default), "short" Oct 9, "long" Friday, October 9, 2026, "weekday" Fri, "month" Oct 2026, "time" 9:30 PM, "datetime", "iso" 2026-10-09. Dates are "YYYY-MM-DD", ISO or a timestamp; "time" and "datetime" need a timestamp or an ISO date-time, as a plain date has no time`,params:f.z.object({date:V(),style:f.z.enum([`date`,`short`,`long`,`weekday`,`month`,`time`,`datetime`,`iso`]).optional()}),returns:f.z.string(),fn:({date:e,style:t=`date`})=>{let{day:n,instant:r}=Y(e);return t===`iso`?X(n):(r??/* @__PURE__ */ new Date(n*J)).toLocaleString(`en-US`,{...Xr[t],...r?{}:{timeZone:`UTC`}})}}),$r=(0,u.defineFunction)({name:`AddDays`,description:`The date days later (negative: earlier), as "YYYY-MM-DD"`,params:f.z.object({date:V(),days:f.z.number()}),returns:f.z.string(),fn:({date:e,days:t})=>X(Y(e).day+Math.trunc(t))}),ei=(0,u.defineFunction)({name:`DaysBetween`,description:`Calendar days from one date to another (negative if to is earlier)`,params:f.z.object({from:V(),to:V()}),returns:f.z.number(),fn:({from:e,to:t})=>Y(t).day-Y(e).day}),ti=(0,u.defineFunction)({name:`Today`,description:`Today's date in the viewer's time zone, as "YYYY-MM-DD"`,params:f.z.object({}),returns:f.z.string(),fn:()=>X(Y(Date.now()).day)});function Z(e){let t=/* @__PURE__ */ new Date(e*J);return[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]}const ni=[Zr,ti,Qr,$r,(0,u.defineFunction)({name:`AddMonths`,description:`The date months later (negative: earlier), kept within the month (Jan 31 + 1 is Feb 28), as "YYYY-MM-DD"; 12 months is a year`,params:f.z.object({date:V(),months:f.z.number()}),returns:f.z.string(),fn:({date:e,months:t})=>{let[n,r,i]=Z(Y(e).day),a=r+Math.trunc(t),o=new Date(Date.UTC(n,a+1,0)).getUTCDate();return X(Date.UTC(n,a,Math.min(i,o))/J)}}),ei,(0,u.defineFunction)({name:`MonthsBetween`,description:`Whole months from one date to another (negative if to is earlier); @Floor(@MonthsBetween(birthday, @Today()) / 12) is an age`,params:f.z.object({from:V(),to:V()}),returns:f.z.number(),fn:({from:e,to:t})=>{let[n,r,i]=Z(Y(e).day),[a,o,s]=Z(Y(t).day),c=(a-n)*12+(o-r);return c>0&&s<i&&--c,c<0&&s>i&&(c+=1),c}}),(0,u.defineFunction)({name:`StartOf`,description:`First day of the date's "week" (Monday), "month" or "year", as "YYYY-MM-DD"`,params:f.z.object({date:V(),unit:f.z.enum([`week`,`month`,`year`])}),returns:f.z.string(),fn:({date:e,unit:t})=>{let n=Y(e).day,[r,i]=Z(n);return X(t===`week`?n-((/* @__PURE__ */ new Date(n*J)).getUTCDay()+6)%7:Date.UTC(r,t===`month`?i:0,1)/J)}})],ri=()=>f.z.array(f.z.object({key:f.z.union([f.z.string(),f.z.number()]),value:f.z.number()})),ii=e=>e.filter(e=>typeof e==`number`&&Number.isFinite(e)),ai=(e,t)=>t??(e?`sum`:`count`);function oi(e,t,n){return e.map((e,r)=>t?{...e,[t]:n[r]}:n[r])}const si=(0,u.defineFunction)({name:`GroupBy`,description:`One row per distinct key, in first-seen order; value is agg of field (default "sum"), or the row count without a field`,params:f.z.object({rows:B(),key:f.z.string(),field:f.z.string().optional(),agg:qr().optional()}),returns:ri(),fn:({rows:e,key:t,field:n,agg:r})=>[...K(e,t)].map(([e,t])=>({key:e,value:Jr(t,n,ai(n,r))}))}),ci=(0,u.defineFunction)({name:`Pivot`,description:`One row per rowKey value, under key, with a column per colKey value holding agg of field, for stacked or grouped charts`,params:f.z.object({rows:B(),rowKey:f.z.string(),colKey:f.z.string(),field:f.z.string().optional(),agg:qr().optional()}),returns:f.z.array(f.z.record(f.z.string(),f.z.union([f.z.string(),f.z.number()]))),fn:({rows:e,rowKey:t,colKey:n,field:r,agg:i})=>{let a=[...K(e,n).keys()].map(String);return[...K(e,t)].map(([e,t])=>{let o={key:e};for(let e of a)o[e]=0;for(let[e,a]of K(t,n))o[String(e)]=Jr(a,r,ai(r,i));return o})}}),li=(0,u.defineFunction)({name:`Top`,description:`The n rows with the largest field ("asc": the smallest)`,params:f.z.object({rows:B(),field:f.z.string(),n:f.z.number(),direction:f.z.enum([`desc`,`asc`]).optional()}),returns:B(),fn:({rows:e,field:t,n,direction:r=`desc`})=>{let i=r===`asc`?1:-1;return e.map((e,n)=>({row:e,i:n,v:G(H(e,t))})).sort((e,t)=>e.v===null||t.v===null?e.v===t.v?e.i-t.i:e.v===null?1:-1:(e.v-t.v)*i||e.i-t.i).slice(0,Math.max(0,Math.trunc(n))).map(e=>e.row)}}),ui=/^\d{4}-\d{2}-\d{2}/,Q=e=>typeof e==`string`&&ui.test(e.trim());function di(e,t){let n=G(e),r=G(t);if(n!==null&&r!==null)return n-r;if((Q(e)||Q(t))&&(Q(e)||n!==null)&&(Q(t)||r!==null))try{return Y(e).day-Y(t).day}catch{}let i=String(e),a=String(t);return i<a?-1:+(i>a)}const fi=(0,u.defineFunction)({name:`Between`,description:`Rows whose field is from min to max, both included; compares numbers, dates by day ("YYYY-MM-DD", ISO or a timestamp), or text. Leave min or max null for an open end`,params:f.z.object({rows:B(),field:f.z.string(),min:f.z.any().optional(),max:f.z.any().optional()}),returns:B(),fn:({rows:e,field:t,min:n,max:r})=>e.filter(e=>{let i=H(e,t);return i!=null&&(n==null||di(i,n)>=0)&&(r==null||di(i,r)<=0)})});function pi(e,t){if(t===`day`)return e;if(t===`week`)return e-((/* @__PURE__ */ new Date(e*864e5)).getUTCDay()+6)%7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)/864e5}function mi(e,t){if(t===`day`)return e+1;if(t===`week`)return e+7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1)/864e5}const hi=[si,ci,li,fi,(0,u.defineFunction)({name:`Bucket`,description:`Rows per day, week (from Monday) or month of dateField, in date order, empty periods 0 for sum and count; key is "YYYY-MM-DD", or "YYYY-MM" for months`,params:f.z.object({rows:B(),dateField:f.z.string(),unit:f.z.enum([`day`,`week`,`month`]),field:f.z.string().optional(),agg:qr().optional()}),returns:ri(),fn:({rows:e,dateField:t,unit:n,field:r,agg:i})=>{let a=/* @__PURE__ */ new Map;for(let r of e){let e=H(r,t);if(typeof e!=`string`&&typeof e!=`number`)continue;let i;try{i=Y(e).day}catch{continue}let o=pi(i,n),s=a.get(o);s?s.push(r):a.set(o,[r])}if(!a.size)return[];let o=ai(r,i),s=o===`sum`||o===`count`,c=e=>n===`month`?X(e).slice(0,7):X(e),l=[...a.keys()].sort((e,t)=>e-t),u=[];for(let e=l[0];e<=l[l.length-1];e=mi(e,n)){let t=a.get(e);if(t?u.push({key:c(e),value:Jr(t,r,o)}):s&&u.push({key:c(e),value:0}),u.length>1e4)throw Error(`more than ${q} periods`)}return u}}),(0,u.defineFunction)({name:`Cumulative`,description:`Copy of the rows with field replaced by its running total (field "" for a list of numbers)`,params:f.z.object({rows:B(),field:f.z.string()}),returns:B(),fn:({rows:e,field:t})=>{let n=0;return oi(e,t,e.map(e=>n+=G(H(e,t))??0))}}),(0,u.defineFunction)({name:`MovingAvg`,description:`Copy of the rows with field replaced by the average of its last window values (field "" for a list of numbers)`,params:f.z.object({rows:B(),field:f.z.string(),window:f.z.number()}),returns:B(),fn:({rows:e,field:t,window:n})=>{let r=Math.trunc(n);if(r<1)throw Error(`window must be at least 1`);let i=e.map(e=>G(H(e,t))??0);return oi(e,t,i.map((e,t)=>{let n=i.slice(Math.max(0,t-r+1),t+1);return n.reduce((e,t)=>e+t,0)/n.length}))}}),(0,u.defineFunction)({name:`Change`,description:`Percent change from previous to current, e.g. @Change(120, 100) is 20; null when previous is 0`,params:f.z.object({current:f.z.number(),previous:f.z.number()}),returns:f.z.number().nullable(),fn:({current:e,previous:t})=>t===0?null:W((e-t)/Math.abs(t)*100)}),(0,u.defineFunction)({name:`Histogram`,description:`Counts numbers into equal-width bins as {key, value} rows: key is the bin's start, value the count; min and max fix the range, default the data's`,params:f.z.object({values:Kr(),bins:f.z.number(),min:f.z.number().optional(),max:f.z.number().optional()}),returns:f.z.array(f.z.object({key:f.z.string(),value:f.z.number()})),fn:({values:e,bins:t,min:n,max:r})=>{let i=ii(e),a=Math.trunc(t);if(a<1||a>500)throw Error(`bins must be from 1 to 500`);let o=n??(i.length?Math.min(...i):0),s=r??(i.length?Math.max(...i):1);s<=o&&(s=o+1);let c=(s-o)/a,l=Math.max(0,1-Math.floor(Math.log10(c))),u=Array(a).fill(0);for(let e of i)e<o||e>s||u[Math.min(a-1,Math.floor((e-o)/c))]++;return u.map((e,t)=>({key:String(Number((o+t*c).toFixed(l))),value:e}))}}),(0,u.defineFunction)({name:`Stats`,description:`Summary of numbers, all zeros for an empty list`,params:f.z.object({values:Kr()}),returns:f.z.object({count:f.z.number(),min:f.z.number(),max:f.z.number(),mean:f.z.number(),median:f.z.number(),stdev:f.z.number()}),fn:({values:e})=>{let t=ii(e),n=t.length;if(!n)return{count:0,min:0,max:0,mean:0,median:0,stdev:0};let r=[...t].sort((e,t)=>e-t),i=t.reduce((e,t)=>e+t,0)/n,a=Math.floor(n/2),o=n%2?r[a]:(r[a-1]+r[a])/2,s=Math.sqrt(t.reduce((e,t)=>e+(t-i)**2,0)/n);return{count:n,min:r[0],max:r[n-1],mean:i,median:o,stdev:s}}})],gi=(e,t)=>e<0?t+e:e,_i=[(0,u.defineFunction)({name:`Append`,description:`Copy of the list with item added at the end`,params:f.z.object({list:B(),item:f.z.any()}),returns:B(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${q} items`);return[...e,t]}}),(0,u.defineFunction)({name:`Prepend`,description:`Copy of the list with item added at the start`,params:f.z.object({list:B(),item:f.z.any()}),returns:B(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${q} items`);return[t,...e]}}),(0,u.defineFunction)({name:`Concat`,description:`Joins two lists`,params:f.z.object({list:B(),more:B()}),returns:B(),fn:({list:e,more:t})=>{if(e.length+t.length>1e4)throw Error(`more than ${q} items`);return[...e,...t]}}),(0,u.defineFunction)({name:`Remove`,description:`Copy without the items whose field equals value; field "" compares the items themselves`,params:f.z.object({list:B(),field:f.z.string(),value:f.z.any()}),returns:B(),fn:({list:e,field:t,value:n})=>e.filter(e=>!U(H(e,t),n))}),(0,u.defineFunction)({name:`RemoveAt`,description:`Copy without the item at index (0-based; negative counts from the end)`,params:f.z.object({list:B(),index:f.z.number()}),returns:B(),fn:({list:e,index:t})=>{let n=gi(Math.trunc(t),e.length);return e.filter((e,t)=>t!==n)}}),(0,u.defineFunction)({name:`Update`,description:`Copy where items whose field equals value get setField set to setValue`,params:f.z.object({list:B(),field:f.z.string(),value:f.z.any(),setField:f.z.string(),setValue:f.z.any()}),returns:B(),fn:({list:e,field:t,value:n,setField:r,setValue:i})=>e.map(e=>e&&typeof e==`object`&&!Array.isArray(e)&&U(H(e,t),n)?{...e,[r]:i}:e)}),(0,u.defineFunction)({name:`Toggle`,description:`Adds item if missing, removes it if present (a set of strings or numbers)`,params:f.z.object({list:B(),item:f.z.any()}),returns:B(),fn:({list:e,item:t})=>e.some(e=>U(e,t))?e.filter(e=>!U(e,t)):[...e,t]}),(0,u.defineFunction)({name:`Includes`,description:`True if the list has item, or the text contains it`,params:f.z.object({list:f.z.union([B(),f.z.string()]),item:f.z.any()}),returns:f.z.boolean(),fn:({list:e,item:t})=>typeof e==`string`?t!=null&&e.includes(String(t)):e.some(e=>U(e,t))}),(0,u.defineFunction)({name:`Find`,description:`First item whose field equals value, or null`,params:f.z.object({list:B(),field:f.z.string(),value:f.z.any()}),returns:f.z.any(),fn:({list:e,field:t,value:n})=>e.find(e=>U(H(e,t),n))??null}),(0,u.defineFunction)({name:`IndexOf`,description:`Index of item in the list, or -1`,params:f.z.object({list:B(),item:f.z.any()}),returns:f.z.number(),fn:({list:e,item:t})=>e.findIndex(e=>U(e,t))}),(0,u.defineFunction)({name:`Take`,description:`The first n items; a negative n takes the last n`,params:f.z.object({list:B(),n:f.z.number()}),returns:B(),fn:({list:e,n:t})=>{let n=Math.trunc(t);return n>=0?e.slice(0,n):e.slice(n)}}),(0,u.defineFunction)({name:`Slice`,description:`Items, or characters of text, from start up to end (not included); negative counts from the end`,params:f.z.object({list:f.z.union([B(),f.z.string()]),start:f.z.number(),end:f.z.number().optional()}),returns:f.z.union([B(),f.z.string()]),fn:({list:e,start:t,end:n})=>{let r=n===void 0?void 0:Math.trunc(n);return e.slice(Math.trunc(t),r)}}),(0,u.defineFunction)({name:`Unique`,description:`Distinct items in first-seen order`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>{let t=/* @__PURE__ */ new Set,n=[];return e.filter(e=>{if(typeof e!=`object`||!e){let n=String(e);return!t.has(n)&&(t.add(n),!0)}return!n.some(t=>U(t,e))&&(n.push(e),!0)})}}),(0,u.defineFunction)({name:`Reverse`,description:`Copy in reverse order`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>[...e].reverse()}),(0,u.defineFunction)({name:`Range`,description:`Numbers from start up to end (not included) by step (default 1), e.g. @Range(0, 3) is [0, 1, 2]`,params:f.z.object({start:f.z.number(),end:f.z.number(),step:f.z.number().optional()}),returns:f.z.array(f.z.number()),fn:({start:e,end:t,step:n=1})=>{if(n===0||!Number.isFinite(n))throw Error(`step must be a non-zero number`);let r=Math.max(0,Math.ceil((t-e)/n));if(r>1e4)throw Error(`more than ${q} items`);let i=Number.isInteger(e)&&Number.isInteger(n);return Array.from({length:r},(t,r)=>i?e+r*n:Number((e+r*n).toPrecision(12)))}}),(0,u.defineFunction)({name:`Pick`,description:`A random item, or null for an empty list; draws anew each time, so call it inside @Set`,params:f.z.object({list:B()}),returns:f.z.any(),fn:({list:e})=>e.length?e[Math.floor(Math.random()*e.length)]:null}),(0,u.defineFunction)({name:`Shuffle`,description:`Copy in random order; call it inside @Set`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}}),(0,u.defineFunction)({name:`Flatten`,description:`One list from a list of lists, e.g. [[1, 2], [3]] is [1, 2, 3]`,params:f.z.object({list:B()}),returns:B(),fn:({list:e})=>{let t=e.flatMap(e=>Array.isArray(e)?e:[e]);if(t.length>1e4)throw Error(`more than ${q} items`);return t}}),(0,u.defineFunction)({name:`Chunk`,description:`The list cut into lists of size items, e.g. for weeks of 7 days or pages`,params:f.z.object({list:B(),size:f.z.number()}),returns:f.z.array(B()),fn:({list:e,size:t})=>{let n=Math.trunc(t);if(n<1)throw Error(`size must be 1 or more`);let r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}})],vi=(0,u.defineFunction)({name:`Pow`,description:`base raised to exponent`,params:f.z.object({base:f.z.number(),exponent:f.z.number()}),returns:f.z.number(),fn:({base:e,exponent:t})=>W(e**+t)}),yi=(0,u.defineFunction)({name:`Sqrt`,description:`Square root; null for a negative number`,params:f.z.object({number:f.z.number()}),returns:f.z.number().nullable(),fn:({number:e})=>e<0?null:W(Math.sqrt(e))}),bi=(0,u.defineFunction)({name:`Random`,description:`Random number from min to max (integer true: a whole number, max included); draws anew each time, so call it inside @Set`,params:f.z.object({min:f.z.number(),max:f.z.number(),integer:f.z.boolean().optional()}),returns:f.z.number(),fn:({min:e,max:t,integer:n})=>{if(!Number.isFinite(e)||!Number.isFinite(t))throw Error(`min and max must be numbers`);let r=Math.min(e,t),i=Math.max(e,t);if(!n)return r+Math.random()*(i-r);let a=Math.ceil(r),o=Math.floor(i);if(a>o)throw Error(`no whole number between min and max`);return a+Math.floor(Math.random()*(o-a+1))}}),xi=(0,u.defineFunction)({name:`Clamp`,description:`number kept between min and max`,params:f.z.object({number:f.z.number(),min:f.z.number(),max:f.z.number()}),returns:f.z.number(),fn:({number:e,min:t,max:n})=>W(Math.min(Math.max(e,Math.min(t,n)),Math.max(t,n)))}),Si=(0,u.defineFunction)({name:`Percent`,description:`part / total * 100, e.g. @Percent(3, 4) is 75; 0 when total is 0`,params:f.z.object({part:f.z.number(),total:f.z.number()}),returns:f.z.number(),fn:({part:e,total:t})=>t===0?0:W(e/t*100)}),Ci=(0,u.defineFunction)({name:`Lerp`,description:`The value a fraction t of the way from a to b`,params:f.z.object({a:f.z.number(),b:f.z.number(),t:f.z.number()}),returns:f.z.number(),fn:({a:e,b:t,t:n})=>W(e+(t-e)*n)}),wi=(0,u.defineFunction)({name:`Allocate`,description:`Splits total in proportion to weights, rounded to decimals (default 2), so the parts add up to exactly total, e.g. @Allocate(100, [1, 1, 1]) is [33.34, 33.33, 33.33]`,params:f.z.object({total:f.z.number(),weights:Kr(),decimals:f.z.number().optional()}),returns:f.z.array(f.z.number()),fn:({total:e,weights:t,decimals:n})=>{let r=t.reduce((e,t)=>e+t,0);if(!t.length||t.some(e=>!Number.isFinite(e)||e<0))throw Error(`weights must be zero or more`);if(r===0)return t.map(()=>0);let i=10**Math.min(6,Math.max(0,Math.round(n!==void 0&&Number.isFinite(n)?n:2))),a=Math.round(Math.abs(e)*i),o=t.map(e=>a*e/r),s=o.map(Math.floor),c=a-s.reduce((e,t)=>e+t,0),l=o.map((e,t)=>({i:t,rest:e-Math.floor(e)})).sort((e,t)=>t.rest-e.rest||e.i-t.i);for(let{i:e}of l){if(c<=0)break;s[e]+=1,--c}return s.map(t=>(e<0?-t:t)/i)}}),Ti=(0,u.defineFunction)({name:`Payment`,description:`Payment per period that repays principal over periods at rate percent per period, e.g. a 30-year loan at 6% a year: @Payment(300000, 6 / 12, 360)`,params:f.z.object({principal:f.z.number(),rate:f.z.number(),periods:f.z.number()}),returns:f.z.number(),fn:({principal:e,rate:t,periods:n})=>{if(!(n>0))throw Error(`periods must be positive`);let r=t/100;return W(r===0?e/n:e*r/(1-(1+r)**+-n))}}),Ei={mm:[`length`,.001],cm:[`length`,.01],m:[`length`,1],km:[`length`,1e3],in:[`length`,.0254],ft:[`length`,.3048],yd:[`length`,.9144],mi:[`length`,1609.344],mg:[`mass`,1e-6],g:[`mass`,.001],kg:[`mass`,1],oz:[`mass`,.028349523125],lb:[`mass`,.45359237],st:[`mass`,6.35029318],ml:[`volume`,.001],l:[`volume`,1],tsp:[`volume`,.00492892159375],tbsp:[`volume`,.0147867647812],floz:[`volume`,.0295735295625],cup:[`volume`,.2365882365],pt:[`volume`,.473176473],qt:[`volume`,.946352946],gal:[`volume`,3.785411784],"m/s":[`speed`,1],"km/h":[`speed`,1/3.6],mph:[`speed`,.44704],kn:[`speed`,.514444],m2:[`area`,1],km2:[`area`,1e6],ft2:[`area`,.09290304],ha:[`area`,1e4],acre:[`area`,4046.8564224]},Di=[`c`,`f`,`k`],Oi=(e,t)=>t===`f`?(e-32)*5/9:t===`k`?e-273.15:e,ki=(e,t)=>t===`f`?e*9/5+32:t===`k`?e+273.15:e,Ai=[vi,yi,bi,xi,Si,Ci,wi,Ti,(0,u.defineFunction)({name:`Convert`,description:`value from one unit to another: mm cm m km in ft yd mi; mg g kg oz lb st; ml l tsp tbsp floz cup pt qt gal (US); m/s km/h mph kn; m2 km2 ft2 ha acre; c f k`,params:f.z.object({value:f.z.number(),from:f.z.string(),to:f.z.string()}),returns:f.z.number(),fn:({value:e,from:t,to:n})=>{let[r,i]=[t.trim().toLowerCase(),n.trim().toLowerCase()];if(Di.includes(r)&&Di.includes(i))return W(ki(Oi(e,r),i));let[a,o]=[Ei[r],Ei[i]];if(!a||!o||a[0]!==o[0])throw Error(`cannot convert ${t} to ${n}`);return W(e*a[1]/o[1])}})],ji=`en-US`;function Mi(e){let t=(e??`USD`).toUpperCase();return/^[A-Z]{3}$/.test(t)?t:`USD`}function $(e,t){try{return e.toLocaleString(ji,t)}catch{return e.toLocaleString(ji,{...t,currency:`USD`})}}const Ni=[(0,u.defineFunction)({name:`Format`,description:`Number as text: "number" 12,345.6, "currency" $12,345.68 (currency is a code like "EUR"), "percent" 45 -> 45%, "compact" 1.2M ($1.2M with a currency)`,params:f.z.object({value:f.z.number(),kind:f.z.enum([`number`,`currency`,`percent`,`compact`]).optional(),decimals:f.z.number().optional(),currency:f.z.string().optional()}),returns:f.z.string(),fn:({value:e,kind:t=`number`,decimals:n,currency:r})=>{if(!Number.isFinite(e))throw Error(`value is not a finite number`);let i=n===void 0?void 0:Math.min(Math.max(Math.trunc(n),0),10),a=(e,t=0)=>i===void 0?{minimumFractionDigits:t,maximumFractionDigits:e}:{minimumFractionDigits:t&&i,maximumFractionDigits:i};switch(t){case`currency`:return $(e,{style:`currency`,currency:Mi(r),...a(2,2)});case`percent`:return`${$(e,a(1))}%`;case`compact`:return $(e,{notation:`compact`,...a(1),...r?{style:`currency`,currency:Mi(r)}:{}});default:return $(e,a(2))}}}),(0,u.defineFunction)({name:`Join`,description:`Joins the items (or their field) into text with sep (default ", "), skipping nulls`,params:f.z.object({list:B(),sep:f.z.string().optional(),field:f.z.string().optional()}),returns:f.z.string(),fn:({list:e,sep:t=`, `,field:n=``})=>e.map(e=>H(e,n)).filter(e=>e!=null).map(e=>typeof e==`object`?JSON.stringify(e):String(e)).join(t)}),(0,u.defineFunction)({name:`Plural`,description:`Count and word: @Plural(1, "guest") is "1 guest", 3 gives "3 guests"; plural defaults to word + "s"`,params:f.z.object({n:f.z.number(),word:f.z.string(),plural:f.z.string().optional()}),returns:f.z.string(),fn:({n:e,word:t,plural:n})=>`${$(e,{maximumFractionDigits:2})} ${Math.abs(e)===1?t:n??`${t}s`}`}),(0,u.defineFunction)({name:`Pad`,description:`Pads the start of value to length with char (default "0"), e.g. 7 -> "07"`,params:f.z.object({value:f.z.union([f.z.string(),f.z.number()]),length:f.z.number(),char:f.z.string().optional()}),returns:f.z.string(),fn:({value:e,length:t,char:n=`0`})=>String(e).padStart(Math.min(Math.trunc(t),1e3),n||`0`)}),(0,u.defineFunction)({name:`Upper`,description:`Text in upper case`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.toUpperCase()}),(0,u.defineFunction)({name:`Lower`,description:`Text in lower case`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.toLowerCase()}),(0,u.defineFunction)({name:`Trim`,description:`Text without spaces at the start and end`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.trim()}),(0,u.defineFunction)({name:`Capitalize`,description:`Each word with a capital first letter, e.g. "new york" is "New York"`,params:f.z.object({text:f.z.string()}),returns:f.z.string(),fn:({text:e})=>e.replace(/(^|[\s\-(/"])(\p{L})/gu,(e,t,n)=>t+n.toUpperCase())}),(0,u.defineFunction)({name:`Split`,description:`List of the parts of text between sep (default ","), each trimmed, empty parts dropped, e.g. @Split("a, b,,c") is ["a", "b", "c"]`,params:f.z.object({text:f.z.string(),sep:f.z.string().optional()}),returns:f.z.array(f.z.string()),fn:({text:e,sep:t=`,`})=>{let n=e.split(t===``?``:t).map(e=>e.trim()).filter(e=>e!==``);if(n.length>1e4)throw Error(`more than ${q} items`);return n}}),(0,u.defineFunction)({name:`Replace`,description:`Text with every find replaced by replacement`,params:f.z.object({text:f.z.string(),find:f.z.string(),replacement:f.z.string()}),returns:f.z.string(),fn:({text:e,find:t,replacement:n})=>t===``?e:e.split(t).join(n)}),(0,u.defineFunction)({name:`Duration`,description:`Seconds as text: "short" 1h 20m, 4m 05s, 45s (default); "clock" 1:20:00, 4:05`,params:f.z.object({seconds:f.z.number(),style:f.z.enum([`short`,`clock`]).optional()}),returns:f.z.string(),fn:({seconds:e,style:t=`short`})=>{if(!Number.isFinite(e))throw Error(`seconds is not a finite number`);let n=e<0?`-`:``,r=Math.round(Math.abs(e)),[i,a,o]=[Math.floor(r/3600),Math.floor(r%3600/60),r%60],s=e=>String(e).padStart(2,`0`);return t===`clock`?n+(i?`${i}:${s(a)}:${s(o)}`:`${a}:${s(o)}`):i?`${n}${i}h${a?` ${a}m`:``}`:a?`${n}${a}m${o?` ${s(o)}s`:``}`:`${n}${o}s`}}),(0,u.defineFunction)({name:`Default`,description:`value, or fallback when value is null, "" or not a number, e.g. an empty number input: @Default($weight, 0)`,params:f.z.object({value:f.z.any().optional(),fallback:f.z.any()}),returns:f.z.any(),fn:({value:e,fallback:t})=>e==null||e===``||typeof e==`number`&&Number.isNaN(e)?t:e})],Pi=[..._i,...Ai,...Ni,...Gr,...ni,...hi],Fi=[{name:`Layout`,components:[`Col`,`Row`,`Box`,`Grid`,`Card`,`Carousel`,`Popover`,`Divider`,`Spacer`],notes:[`- gap and padding count 4px steps. Length is px or a CSS length like "50%". Radius is "sm", "md", "lg", "xl", "full" or px.`,`- Color is "ink", "muted", "faint", "surface", "info", "success", "warning", "danger", "purple", "pink", "chart1" to "chart6", or a CSS color. As a background, status colors are soft tints.`]},{name:`Text`,components:[`Title`,`Text`,`Caption`,`Label`,`Badge`,`Link`,`List`,`ListItem`,`Markdown`,`Quote`,`Code`,`Math`]},{name:`Inputs`,components:[`Button`,`IconButton`,`Pressable`,`Input`,`TextArea`,`Select`,`SegmentedControl`,`Slider`,`Checkbox`,`RadioGroup`,`DatePicker`,`Timer`,`Form`],notes:[`- An input's first argument is its value, usually a $variable that other statements read.`,`- Every input either changes something shown on the page, or sits in a Form whose submit Button sends a short first-person @ToAssistant ("Help me choose a bike"); the form values go with it. No dead inputs.`,`- In a Form, a field's last argument rules is checked before the form sends, and an error shows under the field. Rules is {required?, min?, max?, minLength?, maxLength?, email?, url?, numeric?, pattern?}: Input($email, "Email", "text", null, {required: true, email: true}).`]},{name:`Media and data`,components:[`Image`,`Icon`,`Table`,`Chart`,`YouTube`]},{name:`Play`,components:[`Flashcard`,`Celebration`]},{name:`Drawing`,components:[`Svg`,`G`,`Circle`,`Ellipse`,`Rect`,`Line`,`Path`,`Polyline`,`Polygon`,`SvgText`,`HtmlView`]}],Ii=(0,u.createLibrary)({root:`Col`,components:Hr,functions:Pi,componentGroups:Fi}),Li=[`Compose the answer like a page, not a form letter: a Title, a short Text, then a mix of blocks that show the content. Row, Grid and Carousel to set things side by side; Badge rows for quick facts; Card only to group a block; Popover for an aside.`,`Use Image only with a URL the user or a tool gave in this conversation. Never write an image URL yourself, even for a famous place or product: it will often be wrong. Without a URL, show the subject with an Icon, Badges or an Svg drawing instead.`,`Spacing is a system with three tiers that always nest: inner (gap 1-2, 4-8px) for a title with its subtitle, tags or line; group (gap 3-4, 12-16px) between blocks inside a Card or grid cell; section (24px) between the blocks of the page. Leave gap unset on the page's root Col and on a Card's own contents: the app applies these tiers. Set it on a Row, a Grid or an inner Col. Never use one gap for everything, and never a gap larger than the section gap.`,`A photo beside text is a media row: Row([Box([Image(url, alt, 1.33)]), Col([Title(..., "md"), Row([Badge(...), Badge(...)], 1, null, null, true), Text(..., "sm")], 2)], 4, "start"). The app sizes the photo to a third of the row (at most 200px) and top-aligns the text. Facts are Badges, never Buttons or boxed pills.`,`Keep cards compact and scannable: Title "md" for a card heading (xl or 2xl only for a single big number), Text "sm" for the body, at most one short paragraph, then facts as Badges or label/value rows (Caption label, Spacer, Text value). Don't write bold-lead paragraphs like "**Weekend rhythm:** ..." or long prose in a card. Cards side by side in a Grid share the same blocks in the same order and the same Image aspect ratio, so they line up. For example: c = Card([Col([Title("Sonoma", "md"), Row([Badge("1 h drive", null, "car"), Badge("Wine country", "purple")], 1, null, null, true)], 2), Text("A slow plaza, tasting rooms and quiet back roads.", "sm"), Col([Row([Caption("Best for"), Spacer(), Text("Food and wine", "sm")]), Row([Caption("Trade-off"), Spacer(), Text("Tastings add up", "sm")])], 1)])`,`Answer with a working tool whenever the request involves numbers, choices, lists, steps, a game or something to explore: keep inputs and lists in $variables, compute everything shown from them with expressions and @functions, and change them with @Set. The page must work on its own, without another message.`,`When the request leaves out a detail the answer depends on (a model, a size, a count), don't stop to ask: assume the most common case, say so in one short line, and build the whole answer, with a SegmentedControl or Select to switch to the other cases where they differ.`,`Use @ToAssistant only for what the page cannot compute: a Form's submit Button, or a new request ("Plan another day"). Its message is short and first person, like the user typing it ("Help me choose a bike"); the form values travel with it, so never repeat them in the message.`,`$variable defaults are literals (numbers, strings, lists, objects), never expressions or @calls. Edit lists with @Append, @Remove, @RemoveAt and @Update; track selections with @Toggle and @Includes.`,`cond ? a : b also picks between components; there is no @If. Use only the listed @functions; you cannot define your own.`,`Derive rows once in a statement with @Each(list, "x", {...}), then reuse them in @Each, Table, Chart, @Sum(rows.field) and @Join. @Each(@Range(0, n), "i", ...) builds a series or repeats a step.`,`@Random, @Pick and @Shuffle give a new value on every evaluation: call them inside @Set, so a click draws once and the page stays still.`,`Pick the medium that shows the idea: Chart for numbers across time or categories; Svg drawings for shapes, parts and movement; Table for comparisons; Flashcard and Celebration for learning and games; HtmlView only for a game or animation that needs a loop.`,`Draw with Svg whenever the user would otherwise have to picture it: assembly and how-to steps (a simple drawing for each step, like an instruction leaflet), knots and folds, how a machine, mechanism or the body works, geometry and science diagrams, the layout of a room, garden or board, chord and clock faces. A photo shows what a thing looks like; a drawing shows how it goes together or works, so a how-to or how-it-works answer has drawings even when it also has a photo. Keep each drawing simple: a viewBox about 240 wide, a dozen or so shapes in the listed colors with SvgText labels, a Line with a small Polygon head for an arrow, and let $variables such as the current step drive it.`,`Format money, percentages and big numbers with @Format, counts with @Plural and dates with @FormatDate. @Percent is unrounded, so show it as @Format(@Percent(part, total), "percent"), never @Percent(...) + "%".`,`Dates relative to now (today, this week, next month) start from @Today(), never a fixed date. <, >, <= and >= compare numbers only, so order two dates with @DaysBetween(a, b) > 0.`,`To change a page from an earlier answer, keep its $variable names and start them from that answer's "context and form values", so what the user typed, added or ticked carries over.`,`Read a number input for a count or amount through @Default and @Clamp with a sensible minimum, e.g. @Clamp(@Default($people, 1), 1, 50), so 0, empty or negative cannot divide by zero or zero out the page.`,`Answer a plain knowledge or safety question with Markdown text, adding a Quote only where it helps.`],Ri=[`Example 1: A guest stepper that rescales a shopping list, with a checklist and a button that clears it:
|
|
2
2
|
|
|
3
3
|
root = Col([title, card])
|
|
4
4
|
card = Card([stepper, list, clear])
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{AreaChart as e,BarChart as t,CodeBlock as n,LineChart as r,MarkDownRenderer as i,PieChart as a,ScatterChart as o,ThemeProvider as s,useTheme as c}from"@wodecorp/openui-vue-ui";import{Fragment as l,computed as u,defineComponent as d,h as f,inject as ee,onBeforeUnmount as p,onMounted as te,onScopeDispose as ne,onUpdated as re,provide as ie,ref as m,shallowRef as ae,toValue as h,useId as oe,watch as se,watchEffect as ce}from"vue";import{ACTION_STEPS as le,FormNameContext as ue,FormValidationContext as de,action as fe,createLibrary as pe,defineComponent as g,defineFunction as _,parseStructuredRules as me,reactive as v,tagSchemaId as y,useCreateFormValidation as he,useFormName as ge,useFormValidation as _e,useIsStreaming as b,useStateField as x,useTriggerAction as ve}from"@wodecorp/openui-vue-lang";import{getIconImport as ye}from"@wodecorp/openui-vue-ui/icons";import{z as S}from"zod/v4";import be from"katex";const C={font:`var(--openui-intelligent-font, var(--openui-font-body, "Inter", sans-serif))`,mono:`var(--openui-intelligent-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,canvas:`var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))`,hover:`var(--openui-intelligent-hover, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 5%, transparent))`,pressed:`var(--openui-intelligent-pressed, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,surface:`var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent))`,surfaceStrong:`var(--openui-intelligent-surface-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,ink:`var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0)))`,inkHover:`var(--openui-intelligent-ink-hover, color-mix(in oklch, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 82%, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))))`,onInk:`var(--openui-intelligent-on-ink, var(--openui-foreground, oklch(0.994 0 89.876)))`,muted:`var(--openui-intelligent-muted, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,faint:`var(--openui-intelligent-faint, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,border:`var(--openui-intelligent-border, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,borderStrong:`var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent))`,rangeTrack:`var(--openui-intelligent-range-track, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,rangeThumb:`var(--openui-intelligent-range-thumb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,focus:`var(--openui-intelligent-focus, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,glass:`var(--openui-intelligent-glass, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassHover:`var(--openui-intelligent-glass-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,glassRing:`var(--openui-intelligent-glass-ring, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassRingHover:`var(--openui-intelligent-glass-ring-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,shadow:`var(--openui-intelligent-shadow, var(--openui-shadow-l, 0 4px 4px -2px oklch(0 0 0 / 0.05), 0 4px 8px -2px oklch(0 0 0 / 0.04)))`,shadowSm:`var(--openui-intelligent-shadow-sm, var(--openui-shadow-s, 0 1px 3px -2px oklch(0 0 0 / 0.02), 0 2px 5px -2px oklch(0 0 0 / 0.04)))`,info:`var(--openui-intelligent-info, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,infoSoft:`var(--openui-intelligent-info-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,success:`var(--openui-intelligent-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,successSoft:`var(--openui-intelligent-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,warning:`var(--openui-intelligent-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,warningSoft:`var(--openui-intelligent-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,danger:`var(--openui-intelligent-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,dangerSoft:`var(--openui-intelligent-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,purple:`var(--openui-intelligent-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,purpleSoft:`var(--openui-intelligent-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,pink:`var(--openui-intelligent-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,pinkSoft:`var(--openui-intelligent-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,badgeNeutralSoft:`var(--openui-intelligent-badge-neutral-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,badgeSuccess:`var(--openui-intelligent-badge-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,badgeSuccessSoft:`var(--openui-intelligent-badge-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,badgeWarning:`var(--openui-intelligent-badge-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,badgeWarningSoft:`var(--openui-intelligent-badge-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,badgeDanger:`var(--openui-intelligent-badge-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,badgeDangerSoft:`var(--openui-intelligent-badge-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,badgePurple:`var(--openui-intelligent-badge-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,badgePurpleSoft:`var(--openui-intelligent-badge-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,badgePink:`var(--openui-intelligent-badge-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,badgePinkSoft:`var(--openui-intelligent-badge-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,chart1:`var(--openui-intelligent-chart-1, #0285ff)`,chart2:`var(--openui-intelligent-chart-2, #00a67d)`,chart3:`var(--openui-intelligent-chart-3, #8b5cf6)`,chart4:`var(--openui-intelligent-chart-4, #f4a340)`,chart5:`var(--openui-intelligent-chart-5, #e46d91)`,chart6:`var(--openui-intelligent-chart-6, #4b9ca6)`,spaceTight:`var(--openui-intelligent-space-tight, 4px)`,spaceInner:`var(--openui-intelligent-space-inner, 8px)`,spaceGroup:`var(--openui-intelligent-space-group, 12px)`,spaceGroupLg:`var(--openui-intelligent-space-group-lg, 16px)`,spaceSection:`var(--openui-intelligent-space-section, 24px)`,controlGap:`var(--openui-intelligent-control-gap, 8px)`,fieldGap:`var(--openui-intelligent-field-gap, 24px)`,actionGap:`var(--openui-intelligent-action-gap, 40px)`,radiusSm:`var(--openui-intelligent-radius-sm, 6px)`,radiusMd:`var(--openui-intelligent-radius-md, 10px)`,radiusLg:`var(--openui-intelligent-radius-lg, 12px)`,radiusXl:`var(--openui-intelligent-radius-xl, 14px)`,photoEmpty:`var(--openui-intelligent-photo-empty, var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent)))`,photoEmptyIcon:`var(--openui-intelligent-photo-empty-icon, var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent)))`},xe={intelligentMono:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,intelligentChart1:`#0285ff`,intelligentChart2:`#00a67d`,intelligentChart3:`#8b5cf6`,intelligentChart4:`#f4a340`,intelligentChart5:`#e46d91`,intelligentChart6:`#4b9ca6`,intelligentSpaceTight:`4px`,intelligentSpaceInner:`8px`,intelligentSpaceGroup:`12px`,intelligentSpaceGroupLg:`16px`,intelligentSpaceSection:`24px`,intelligentControlGap:`8px`,intelligentFieldGap:`24px`,intelligentActionGap:`40px`,intelligentRadiusSm:`6px`,intelligentRadiusMd:`10px`,intelligentRadiusLg:`12px`,intelligentRadiusXl:`14px`},Se={...xe},Ce={...xe},we=Symbol(`OpenUI.IntelligentTheme`);function Te(){return ee(we,null)}function Ee(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z])/g,`$1-$2`).replace(/([a-z])(\d)/g,`$1-$2`).toLowerCase()}function De(e){let t={},n={};for(let[r,i]of Object.entries(e??{}))r.startsWith(`intelligent`)&&r.length>11?typeof i==`string`&&(n[r]=i):t[r]=i;return{components:t,intelligent:n}}function Oe(e){return Object.entries(e).filter(([,e])=>typeof e==`string`).map(([e,t])=>`--openui-${Ee(e)}: ${t};`).join(` `)}function ke(e){return e.replace(/[^a-zA-Z0-9-_]/g,``)}const Ae=d({name:`OpenUIIntelligentVariables`,props:{id:{type:String,required:!0},scope:{type:String,required:!0},mode:{type:String,required:!0},theme:{type:Object,required:!0}},setup(e){let{portalThemeClassName:t}=c(),n=u(()=>{let n=`color-scheme: ${e.mode}; color: var(--openui-text-neutral-primary); font-family: ${C.font}; ${Oe(e.theme)}`,r=[`.${e.scope}`];return t.value&&r.push(`.${t.value}`),`${r.join(`, `)} { ${n} }`}),r,i=()=>{if(typeof document>`u`||r?.textContent===n.value)return;r?.remove(),r=document.createElement(`style`);let t=window.__nonce__;t&&(r.nonce=t),r.setAttribute(`data-openui-intelligent-theme`,e.id),r.textContent=n.value,document.head.appendChild(r)};return te(i),re(i),p(()=>r?.remove()),()=>(n.value,null)}}),je=d({name:`OpenUIIntelligentThemeProvider`,inheritAttrs:!1,props:{mode:String,lightTheme:Object,darkTheme:Object},setup(e,{slots:t}){let n=ke(oe()),r=ee(we,null),{mode:i}=c(),a=u(()=>e.mode??r?.mode.value??i.value??`light`),o=`openui-intelligent-theme-${n}`,l=u(()=>({light:{...r?.overrides.value.light,...e.lightTheme},dark:{...r?.overrides.value.dark,...e.darkTheme??e.lightTheme}})),d=u(()=>De(l.value.light)),p=u(()=>De(l.value.dark)),te=u(()=>a.value===`light`?{...Se,...d.value.intelligent}:{...Ce,...p.value.intelligent});return ie(we,{mode:a,theme:te,overrides:l}),()=>f(`div`,{class:o,"data-openui-intelligent-mode":a.value,style:{display:`contents`}},[f(s,{mode:a.value,cssSelector:`.${o}`,lightTheme:d.value.components,darkTheme:p.value.components},{default:()=>[f(Ae,{id:n,scope:o,mode:a.value,theme:te.value}),t.default?.()]})])}}),Me=d({name:`OpenUIIntelligentRootTheme`,inheritAttrs:!1,setup(e,{slots:t}){let n=ee(we,null);return()=>n?t.default?.():f(je,null,{default:()=>t.default?.()})}}),Ne=/(url|image|image-set|cross-fade|element|expression|paint|var|attr|env)\s*\(|@import|[\\;{}<>]/i,Pe=e=>!Ne.test(e),Fe=[`info`,`success`,`warning`,`danger`,`purple`,`pink`],Ie={ink:C.ink,muted:C.muted,faint:C.faint,canvas:C.canvas,surface:C.surface,...Object.fromEntries(Fe.map(e=>[e,C[e]])),chart1:C.chart1,chart2:C.chart2,chart3:C.chart3,chart4:C.chart4,chart5:C.chart5,chart6:C.chart6},Le={...Ie,surface:C.surface,"surface-strong":C.surfaceStrong,border:C.border,...Object.fromEntries(Fe.map(e=>[e,C[`${e}Soft`]]))},Re=e=>typeof e==`string`&&e.trim()&&Pe(e)?e.trim():void 0,w=e=>typeof e==`string`?Ie[e]??Re(e):void 0,ze=e=>typeof e==`string`?Le[e]??Re(e):void 0,Be=e=>e in Le,T=e=>typeof e==`number`&&Number.isFinite(e)?`${Math.max(0,e)*4}px`:void 0;function E(e){if(typeof e==`number`&&Number.isFinite(e))return`${Math.max(0,e)}px`;if(typeof e==`string`)return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:/^\d+(\.\d+)?(px|%|em|rem|vh|vw|fr)$|^auto$/.test(e.trim())?e.trim():void 0}const Ve={sm:C.radiusSm,md:C.radiusMd,lg:C.radiusLg,xl:C.radiusXl,full:`999px`},He=e=>typeof e==`string`?Ve[e]:E(e),Ue={start:`flex-start`,end:`flex-end`,center:`center`,stretch:`stretch`,between:`space-between`},We=(e,t=!1)=>({gap:T(e.gap),alignItems:e.align?Ue[e.align]:void 0,justifyContent:e.justify?Ue[e.justify]:void 0,flexWrap:e.wrap?`wrap`:void 0,textAlign:t&&(e.align===`center`||e.align===`end`)?e.align:void 0}),Ge=/* @__PURE__ */ new Map,D=d({name:`OpenUIIntelligentLucideIcon`,props:{name:{type:String,required:!0},size:{type:Number,default:16},color:String},setup(e){let t=ae(null);return se(()=>e.name,e=>{if(!e){t.value=null;return}let n=Ge.get(e);if(n){t.value=n;return}let r=ye(e);if(!r){t.value=null;return}let i=!1;return r().then(n=>{if(i)return;let r=n?.default;r&&(Ge.set(e,r),t.value=r)}).catch(()=>{i||(t.value=null)}),()=>{i=!0}},{immediate:!0}),()=>{let n=t.value,r=w(e.color)??`currentColor`;return n?f(n,{size:e.size,color:r,style:{display:`inline-block`,flexShrink:0,verticalAlign:`middle`}}):f(`span`,{class:`openui-intelligent-icon-placeholder`,"data-icon":e.name,"aria-hidden":`true`,style:{display:`inline-block`,width:`${e.size}px`,height:`${e.size}px`,verticalAlign:`middle`}})}}}),Ke=e=>(e?.innerText??``).replace(/\s+/g,` `).trim().slice(0,120),O=e=>e==null?``:String(e),qe=e=>typeof e!=`number`||!Number.isFinite(e)?``:e.toLocaleString(`en-US`,{maximumFractionDigits:2}),Je=S.object({text:S.string(),color:S.enum([`neutral`,`info`,`success`,`warning`,`danger`,`purple`,`pink`]).optional(),icon:S.string().optional()}),Ye={neutral:{bg:C.badgeNeutralSoft,fg:C.ink},info:{bg:C.infoSoft,fg:C.info},success:{bg:C.badgeSuccessSoft,fg:C.badgeSuccess},warning:{bg:C.badgeWarningSoft,fg:C.badgeWarning},danger:{bg:C.badgeDangerSoft,fg:C.badgeDanger},purple:{bg:C.badgePurpleSoft,fg:C.badgePurple},pink:{bg:C.badgePinkSoft,fg:C.badgePink}},Xe=g({name:`Badge`,props:Je,description:`Pill tag; icon is an optional leading lucide name.`,component:({props:e})=>{let t=Ye[e.color??`neutral`]??Ye.neutral;return f(`span`,{class:`openui-intelligent-badge`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`2px 8px`,borderRadius:`999px`,fontSize:`12px`,fontWeight:500,lineHeight:1.4,background:t.bg,color:t.fg,verticalAlign:`middle`}},[e.icon?f(D,{name:e.icon,size:12}):null,O(e.text)])}});function Ze(e){if(typeof e!=`string`||Be(e))return;let t=null,n=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(e.trim());if(n){let e=n[1].length===3?n[1].replace(/./g,`$&$&`):n[1];t=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}else{let n=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());n&&(t=[n[1],n[2],n[3]].map(Number))}if(!t)return;let[r,i,a]=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a>.36?`#0d0d0d`:`#ffffff`}const Qe=e=>`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='${e}' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5'/%3E%3C/svg%3E")`;function $e(e){let t=Ze(e);if(!t)return{};let n=t!==`#ffffff`;return{color:t,"--openui-intelligent-ink":t,"--openui-intelligent-muted":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-faint":`color-mix(in srgb, ${t} 55%, transparent)`,"--openui-text-neutral-primary":t,"--openui-text-neutral-secondary":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-on-ink":n?`#ffffff`:`#0d0d0d`,"--_openui-intelligent-pressable-check-icon":Qe(n?`white`:`%230d0d0d`)}}function et(e){try{return new URL(e.trim()).protocol}catch{return null}}function tt(e){if(typeof e!=`string`)return null;let t=et(e);return t===`http:`||t===`https:`?e.trim():null}const nt=S.any();y(nt,`Node`);const k=S.array(nt),A=S.string();y(A,`Color`);const j=S.union([S.number(),S.string()]);y(j,`Length`);const rt=S.union([S.enum([`sm`,`md`,`lg`,`xl`,`full`]),S.number()]);y(rt,`Radius`);const it=S.enum([`cover`,`contain`]),M=S.object({required:S.boolean().optional(),email:S.boolean().optional(),url:S.boolean().optional(),numeric:S.boolean().optional(),min:S.number().optional(),max:S.number().optional(),minLength:S.number().optional(),maxLength:S.number().optional(),pattern:S.string().optional()});y(M,`Rules`);const at=S.union([S.string(),S.object({value:S.string(),label:S.string()})]);function ot(e){if(e==null)return null;if(typeof e!=`object`)return{value:String(e),label:String(e)};let{value:t,label:n,description:r}=e,i=n??t;return i==null?null:{value:String(t??n),label:String(i),...typeof r==`string`&&{description:r}}}const st=S.enum([`start`,`center`,`end`,`stretch`]),ct=S.enum([`start`,`center`,`end`,`between`]),lt=S.union([S.string(),k]),ut=/(\*\*([^*]+)\*\*|\*([^*]+)\*|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\))/g;function N(e){if(!e)return``;let t=[],n=0;ut.lastIndex=0;let r;for(;(r=ut.exec(e))!==null;){if(r.index>n&&t.push(e.slice(n,r.index)),r[2]!==void 0)t.push(f(`strong`,null,r[2]));else if(r[3]!==void 0)t.push(f(`em`,null,r[3]));else if(r[4]!==void 0)t.push(f(`code`,{style:{fontFamily:C.mono,fontSize:`0.88em`,padding:`0.1em 0.35em`,borderRadius:C.radiusSm,background:C.surface}},r[4]));else if(r[5]!==void 0&&r[6]!==void 0){let e=tt(r[6]);e?t.push(f(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,style:{color:C.info,textDecoration:`underline`}},r[5])):t.push(r[5])}n=ut.lastIndex}return n<e.length&&t.push(e.slice(n)),t.length===1?t[0]:t}const P=(e,t)=>typeof e==`string`||typeof e==`number`?N(String(e)):t(Array.isArray(e)?e.flat():e),dt=e=>!!e&&typeof e==`object`&&e.type===`element`,ft=S.object({children:k.optional(),direction:S.enum([`row`,`col`]).optional(),gap:S.number().optional(),padding:S.number().optional(),background:A.optional(),radius:rt.optional(),border:S.boolean().optional(),width:j.optional(),height:j.optional(),flex:S.number().optional(),align:st.optional(),justify:ct.optional(),wrap:S.boolean().optional()}),pt=g({name:`Box`,props:ft,description:`Flex container, a column by default. radius also clips the content.`,component:({props:e,renderNode:t})=>{let n=e.direction!==`row`,r=He(e.radius),i={display:`flex`,flexDirection:n?`column`:`row`,padding:T(e.padding),background:ze(e.background),borderRadius:r,overflow:r?`hidden`:void 0,border:e.border?`1px solid ${C.border}`:void 0,width:E(e.width),height:E(e.height),flex:typeof e.flex==`number`&&Number.isFinite(e.flex)?e.flex:void 0,...We(e,n),...$e(e.background)};return f(`div`,{class:`openui-intelligent-box`,style:i},[t(e.children)])}}),mt=e=>{let t=e?.steps;return!t||t.some(e=>e.type===le.ToAssistant||e.type===`custom_action`||e.type===le.Run&&e.refType===`mutation`)};function ht(){let e=ve(),t=ge(),n=_e();return(r,i,a)=>{(i||a)&&(!n||i&&!mt(i)||n.validateForm())&&(i?e(r,t.value,i):e(r,t.value))}}function F(e,t,n){let r=_e(),i=u(()=>me(h(t))),a=u(()=>!!r&&i.value.length>0),o=null;return ce(()=>{let t=h(e),a=i.value;o&&o!==t&&(r?.unregisterField(o),o=null),r&&a.length>0?(r.registerField(t,a,()=>h(n)),o=t):o&&=(r?.unregisterField(o),null)}),ne(()=>{o&&=(r?.unregisterField(o),null)}),{required:u(()=>a.value&&i.value.some(e=>e.type===`required`)),error:u(()=>a.value?r?.errors[h(e)]:void 0),check:()=>{a.value&&r&&r.validateField(h(e),h(n),i.value)},clear:()=>{a.value&&r&&r.clearFieldError(h(e))}}}function I(e,t){let n=oe();return u(()=>{let r=h(t);if(r)return r;let i=h(e);return typeof i==`string`&&i?i:n})}function L(e){return f(`div`,{class:`openui-intelligent-field`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:C.font}},[e.label?f(`label`,{style:{fontSize:`13px`,fontWeight:500,color:C.ink,display:`inline-flex`,alignItems:`center`,gap:`4px`}},[e.label,e.required?f(`span`,{style:{color:C.danger},"aria-hidden":`true`},`*`):null]):null,e.control,e.error?f(`div`,{role:`alert`,style:{fontSize:`12px`,color:C.danger}},e.error):null])}const gt=S.array(at),_t=e=>Array.isArray(e)?e.flat().flatMap(e=>ot(e)??[]):[],vt=S.union([S.string(),S.object({value:S.string(),label:S.string(),description:S.string().optional()})]),yt=e=>_t(e),bt=S.object({label:S.string(),action:fe().optional(),variant:S.enum([`solid`,`outline`,`soft`,`ghost`]).optional(),color:S.enum([`primary`,`danger`,`success`]).optional(),size:S.enum([`sm`,`md`,`lg`]).optional(),icon:S.string().optional(),disabled:S.boolean().optional(),block:S.boolean().optional()}),xt={sm:{padding:`5px 10px`,fontSize:`12px`,borderRadius:C.radiusSm},md:{padding:`8px 14px`,fontSize:`13px`,borderRadius:C.radiusMd},lg:{padding:`10px 18px`,fontSize:`14px`,borderRadius:C.radiusMd}},St=d({name:`OpenUIIntelligentButton`,props:{props:{type:Object,required:!0}},setup(e){let t=ht(),n=b();return()=>{let r=e.props.variant??`solid`,i=e.props.color??`primary`,a=e.props.size??`md`,o=!!(e.props.disabled||n.value),s=O(e.props.label),c=i===`danger`?C.danger:i===`success`?C.success:C.ink,l=i===`danger`?C.dangerSoft:i===`success`?C.successSoft:C.surface,u=r===`solid`?{background:c,color:i===`primary`?C.onInk:`#ffffff`,border:`1px solid transparent`}:r===`outline`?{background:`transparent`,color:c,border:`1px solid ${C.borderStrong}`}:r===`soft`?{background:l,color:c,border:`1px solid transparent`}:{background:`transparent`,color:c,border:`1px solid transparent`};return f(`button`,{type:`button`,disabled:o,class:`openui-intelligent-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,fontFamily:C.font,fontWeight:500,cursor:o?`not-allowed`:`pointer`,opacity:o?.55:1,width:e.props.block?`100%`:void 0,...xt[a],...u},onClick:()=>{o||t(s,e.props.action,!0)}},[e.props.icon?f(D,{name:e.props.icon,size:a===`sm`?13:15}):null,s])}}}),Ct=g({name:`Button`,props:bt,description:`icon is a lucide name. Without an action it sends its label to the assistant.`,component:St}),wt=S.object({text:S.string(),color:A.optional()}),Tt=g({name:`Caption`,props:wt,description:`Small secondary text.`,component:({props:e})=>f(`span`,{class:`openui-intelligent-caption`,style:{fontSize:`12px`,lineHeight:1.45,color:w(e.color)??C.muted}},O(e.text))}),Et=S.object({children:k,variant:S.enum([`outline`,`soft`]).optional(),gap:S.number().optional(),padding:S.number().optional()}),Dt=g({name:`Card`,props:Et,description:`Panel with a border; soft is a filled panel for summaries.`,component:({props:e,renderNode:t})=>{let n=e.variant===`soft`;return f(`div`,{class:[`openui-intelligent-card`,n?`openui-intelligent-card--soft`:`openui-intelligent-card--outline`],style:{display:`flex`,flexDirection:`column`,gap:T(e.gap)??C.spaceGroup,padding:T(e.padding)??C.spaceGroupLg,borderRadius:C.radiusLg,background:n?C.surface:C.canvas,border:n?`1px solid transparent`:`1px solid ${C.border}`}},[t(e.children)])}}),Ot=S.object({children:k,itemWidth:S.number().optional(),gap:S.number().optional()}),kt=g({name:`Carousel`,props:Ot,description:`Horizontal row that scrolls and snaps, each child an item itemWidth px wide (default 240): photos, cards, options, days.`,component:({props:e,renderNode:t})=>{let n=typeof e.itemWidth==`number`&&e.itemWidth>0?e.itemWidth:240,r=Array.isArray(e.children)?e.children.flat():[];return f(`div`,{class:`openui-intelligent-carousel`,style:{display:`flex`,flexDirection:`row`,gap:T(e.gap)??C.spaceGroup,overflowX:`auto`,scrollSnapType:`x mandatory`,paddingBottom:`4px`}},r.map((e,r)=>f(`div`,{key:r,style:{flex:`0 0 ${n}px`,maxWidth:`100%`,scrollSnapAlign:`start`}},[t(e)])))}}),At=S.object({when:S.boolean()}),jt=[C.chart1,C.chart2,C.chart3,C.chart4,C.chart5,C.chart6],Mt=d({name:`OpenUIIntelligentCelebration`,props:{props:{type:Object,required:!0}},setup(e){let t=b(),n=m(!1),r=null;return se(()=>[e.props.when===!0,t.value],([e,t],i)=>{let a=i?.[0]??!1;e&&!t&&!a&&(n.value=!0,r&&clearTimeout(r),r=setTimeout(()=>{n.value=!1},2200))},{immediate:!0}),()=>n.value?f(`div`,{"aria-hidden":`true`,class:`openui-intelligent-celebration`,style:{position:`relative`,height:`12px`,overflow:`visible`,pointerEvents:`none`,display:`flex`,justifyContent:`space-around`}},Array.from({length:12},(e,t)=>f(`span`,{key:t,style:{width:`8px`,height:`8px`,borderRadius:t%2==0?`999px`:`2px`,background:jt[t%jt.length],display:`inline-block`,transform:`rotate(${t*37%360}deg)`}}))):null}}),Nt=g({name:`Celebration`,props:At,description:`Bursts confetti when its condition turns true, e.g. Celebration($score == 5) at the end of a quiz.`,component:Mt}),Pt=S.object({type:S.enum([`bar`,`line`,`area`,`pie`,`donut`,`scatter`]),data:S.array(S.record(S.string(),S.union([S.string(),S.number()]))),x:S.string().optional(),series:S.array(S.string()).optional(),format:S.enum([`number`,`percent`]).optional(),stacked:S.boolean().optional(),height:S.number().optional()}),Ft=e=>Array.isArray(e)?e.filter(e=>e&&typeof e==`object`):[],It=(e,t)=>{if(t)return t;let n=e[0]??{};return Object.keys(n).find(e=>typeof n[e]==`string`)??Object.keys(n)[0]??``},Lt=(e,t,n)=>{if(n?.length)return n;let r=e[0]??{};return Object.keys(r).filter(e=>e!==t&&typeof r[e]==`number`)},Rt=(e,t,n)=>e.map(e=>{let r={[t]:e[t]??``};for(let t of n)r[t]=typeof e[t]==`number`?e[t]:0;return r}),zt=[`intelligentChart1`,`intelligentChart2`,`intelligentChart3`,`intelligentChart4`,`intelligentChart5`,`intelligentChart6`];function Bt(e,t){let n=e?.theme.value??Se,r=zt.map(e=>n[e]??Se[e]??`#0285ff`),i=Array.from({length:Math.max(t,1)},(e,t)=>r[t%r.length]);return i.length>2&&i.length%2==0&&i.unshift(i.pop()),i}const Vt=d({name:`OpenUIIntelligentChart`,props:{props:{type:Object,required:!0}},setup(n){let i=Te();return()=>{let s=Ft(n.props.data),c=It(s,n.props.x),l=Lt(s,c,n.props.series),u=typeof n.props.height==`number`?n.props.height:void 0;if(!s.length||!c)return null;if(n.props.type===`pie`||n.props.type===`donut`)return f(a,{data:s,categoryKey:c,dataKey:l[0]??``,variant:n.props.type,format:n.props.format===`percent`?`percentage`:`number`,customPalette:Bt(i,s.length),isAnimationActive:!1});if(n.props.type===`scatter`){let e=l.map(e=>({name:e,data:s.map(t=>({x:Number(t[c]??0),y:Number(t[e]??0)}))}));return f(o,{data:e,xAxisDataKey:`x`,yAxisDataKey:`y`,height:u,customPalette:Bt(i,e.length),isAnimationActive:!1})}let d={data:Rt(s,c,l),categoryKey:c,height:u,customPalette:Bt(i,l.length),isAnimationActive:!1};return n.props.type===`line`?f(r,d):n.props.type===`area`?f(e,{...d,stacked:n.props.stacked===!0}):f(t,{...d,variant:n.props.stacked?`stacked`:`grouped`})}}}),Ht=g({name:`Chart`,props:Pt,description:`Rows of data; x is the category key (a number key for scatter), series the value keys (default: every number key). format applies to pie and donut only: "percent" shows each slice as a share of the total, "number" its value. stacked stacks bar and area series. height sets the plot height in px; pie and donut ignore it and size themselves.`,component:Vt}),Ut=S.object({checked:v(S.boolean()),label:S.string(),lineThrough:S.boolean().optional(),rules:M.optional()}),Wt=d({name:`OpenUIIntelligentCheckbox`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.checked),r=F(t,()=>e.props.rules,()=>n.value),i=b();return()=>{let t=n.value===!0;return f(`div`,{class:`openui-intelligent-checkbox`,style:{display:`flex`,flexDirection:`column`,gap:`4px`}},[f(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:`8px`,cursor:i.value?`not-allowed`:`pointer`,fontSize:`14px`,color:t&&e.props.lineThrough?C.muted:C.ink,textDecoration:t&&e.props.lineThrough?`line-through`:void 0}},[f(`input`,{type:`checkbox`,checked:t,disabled:i.value,style:{width:`16px`,height:`16px`,accentColor:C.ink},onChange:e=>{r.clear(),n.setValue(e.target.checked)}}),f(`span`,null,[O(e.props.label),r.required.value?f(`span`,{style:{color:C.danger,marginLeft:`4px`}},`*`):null])]),r.error.value?f(`div`,{role:`alert`,style:{fontSize:`12px`,color:C.danger}},r.error.value):null])}}}),Gt=g({name:`Checkbox`,props:Ut,description:`lineThrough strikes the label when checked, for to-do lists. rules takes only required.`,component:Wt}),Kt=S.object({code:S.string(),language:S.string().optional()}),qt=g({name:`Code`,props:Kt,description:`Code block with a copy button.`,component:({props:e})=>f(n,{language:O(e.language)||`text`,codeString:O(e.code)})}),Jt=S.object({children:k,gap:S.number().optional(),align:st.optional()}),Yt=d({name:`OpenUIIntelligentCol`,inheritAttrs:!1,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){return()=>{let t=f(`div`,{class:`openui-intelligent-col`,style:{display:`flex`,flexDirection:`column`,gap:e.props.gap===void 0?C.spaceGroup:void 0,...We(e.props,!0)}},e.renderNode(e.props.children));return e.statementId===`root`?f(Me,null,{default:()=>t}):t}}}),Xt=g({name:`Col`,props:Jt,description:`Vertical layout. Without gap it spaces blocks like an article.`,component:Yt}),Zt=S.object({value:v(S.string()),label:S.string().optional(),min:S.string().optional(),max:S.string().optional(),rules:M.optional()}),Qt=d({name:`OpenUIIntelligentDatePicker`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=b();return()=>L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:f(`input`,{type:`date`,value:n.value==null?``:String(n.value),min:e.props.min?O(e.props.min):void 0,max:e.props.max?O(e.props.max):void 0,disabled:i.value,class:`openui-intelligent-date-picker`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:C.font,color:C.ink,background:C.canvas,border:`1px solid ${r.error.value?C.danger:C.borderStrong}`,borderRadius:C.radiusMd,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}),$t=g({name:`DatePicker`,props:Zt,description:`Dates, min and max are "YYYY-MM-DD". rules takes only required.`,component:Qt}),en=S.object({}),tn=g({name:`Divider`,props:en,description:`A thin horizontal rule between blocks.`,component:()=>f(`hr`,{class:`openui-intelligent-divider`,style:{border:`none`,borderTop:`1px solid ${C.border}`,margin:`4px 0`,width:`100%`}})}),nn=S.object({front:lt,back:lt,hint:S.string().optional()}),rn=d({name:`OpenUIIntelligentFlashcard`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=m(!1);return()=>{let n=t.value?e.props.back:e.props.front,r=typeof n==`string`?f(`div`,{style:{fontSize:`20px`,fontWeight:600,color:C.ink,textAlign:`center`}},n):P(n,e.renderNode),i=O(e.props.hint);return f(`button`,{type:`button`,"aria-pressed":t.value,class:[`openui-intelligent-flashcard`,t.value?`openui-intelligent-flashcard--back`:`openui-intelligent-flashcard--front`],style:{width:`100%`,minHeight:`140px`,padding:`20px`,borderRadius:C.radiusLg,border:`1px solid ${C.borderStrong}`,background:t.value?C.surface:C.canvas,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`10px`,cursor:`pointer`,font:`inherit`,color:C.ink},onClick:()=>{t.value=!t.value}},[r,!t.value&&i?f(`span`,{style:{fontSize:`12px`,color:C.muted}},i):f(`span`,{style:{fontSize:`11px`,color:C.faint}},t.value?`Back · tap to flip`:`Tap to flip`)])}}}),an=g({name:`Flashcard`,props:nn,description:`Card that flips between front and back when tapped. Put several in a Carousel or Grid.`,component:rn}),on=S.object({children:k}),sn=d({name:`OpenUIIntelligentForm`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){let t=oe(),n=he();return ie(de,n),ie(ue,()=>e.statementId??t),()=>f(`form`,{class:`openui-intelligent-form`,novalidate:!0,style:{display:`flex`,flexDirection:`column`,gap:C.spaceGroupLg},onSubmit:e=>{e.preventDefault()}},e.renderNode(e.props.children))}}),cn=g({name:`Form`,props:on,description:`Groups fields; their values go with any @ToAssistant inside, once every field's rules pass.`,component:sn}),ln=S.object({children:k,columns:S.number().optional(),minChildWidth:S.number().optional(),gap:S.number().optional()}),un=g({name:`Grid`,props:ln,description:`Equal columns, 1 to 12 (default 2). With minChildWidth (px), columns drop on narrow screens.`,component:({props:e,renderNode:t})=>{let n=typeof e.columns==`number`&&Number.isFinite(e.columns)?Math.min(12,Math.max(1,Math.round(e.columns))):2,r=typeof e.minChildWidth==`number`&&e.minChildWidth>0?Math.round(e.minChildWidth):void 0,i=r?`repeat(auto-fit, minmax(min(${r}px, 100%), 1fr))`:`repeat(${n}, minmax(0, 1fr))`;return f(`div`,{class:`openui-intelligent-grid`,style:{display:`grid`,gridTemplateColumns:i,gap:T(e.gap)??C.spaceGroup}},[t(e.children)])}});function dn(){let e=Te(),t=c();return u(()=>e?.mode.value??t.mode.value??`light`)}const fn=S.object({html:S.string(),height:S.number().optional(),title:S.string().optional()}),pn=`https://cdn.jsdelivr.net https://unpkg.com https://cdnjs.cloudflare.com https://esm.sh`,mn=[`default-src 'none'`,`script-src 'unsafe-inline' ${pn}`,`style-src 'unsafe-inline' ${pn} https://fonts.googleapis.com`,`font-src https://fonts.gstatic.com data:`,`img-src data: blob: https:`,`media-src data: blob:`,`connect-src ${pn}`,`frame-src 'none'`,`form-action 'none'`,`base-uri 'none'`].join(`; `),hn=2400;function gn(e,t){return`<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${mn}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>:root{color-scheme:${t}}html,body{margin:0}body{font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}</style><script>(function(){var last=0;function send(){var h=Math.ceil(document.documentElement.getBoundingClientRect().height);if(Math.abs(h-last)>1){last=h;parent.postMessage({type:"openui-intelligent-html-view-height",height:h},"*")}}addEventListener("message",function(e){if(e.source===parent&&e.data==="openui-intelligent-html-view-measure"){last=0;send()}});addEventListener("load",send);new ResizeObserver(send).observe(document.documentElement);send()})()<\/script>${e}`}const _n=d({name:`OpenUIIntelligentHtmlView`,props:{props:{type:Object,required:!0}},setup(e){let t=b(),n=dn(),r=m(null),i=m(null),a=u(()=>typeof e.props.height==`number`&&e.props.height>0?Math.min(hn,Math.max(80,e.props.height)):null),o=u(()=>gn(typeof e.props.html==`string`?e.props.html:``,n.value)),s=e=>{if(a.value!==null||e.source!==r.value?.contentWindow)return;let t=e.data;t?.type===`openui-intelligent-html-view-height`&&typeof t.height==`number`&&Number.isFinite(t.height)&&(i.value=Math.min(hn,Math.max(80,t.height)))};return te(()=>{typeof window<`u`&&(window.addEventListener(`message`,s),r.value?.contentWindow?.postMessage(`openui-intelligent-html-view-measure`,`*`))}),p(()=>{typeof window<`u`&&window.removeEventListener(`message`,s)}),()=>{let n=a.value??i.value??360;return f(`div`,{class:`openui-intelligent-html-view`,style:{width:`100%`,height:`${n}px`,borderRadius:C.radiusMd,border:`1px solid ${C.border}`,overflow:`hidden`,background:C.surface}},t.value?[f(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,color:C.muted,fontSize:`13px`}},`Preparing the interactive view…`)]:[f(`iframe`,{ref:r,title:e.props.title||`Interactive view`,sandbox:`allow-scripts`,srcdoc:o.value,referrerpolicy:`no-referrer`,loading:`lazy`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})])}}}),vn=g({name:`HtmlView`,props:fn,description:`Sandboxed HTML page with inline JS, for games and canvas. No network except script CDNs. Fits its content unless height is set.`,component:_n}),yn=S.object({name:S.string(),size:S.enum([`sm`,`md`,`lg`,`xl`]).optional(),color:A.optional()}),bn={sm:14,md:18,lg:22,xl:28},xn=g({name:`Icon`,props:yn,description:`Lucide icon by name, e.g. "map-pin".`,component:({props:e})=>f(D,{name:O(e.name),size:bn[e.size??`md`]??18,color:e.color})}),Sn=S.object({icon:S.string(),action:fe().optional(),label:S.string().optional(),variant:S.enum([`outline`,`ghost`,`solid`]).optional()}),Cn=d({name:`OpenUIIntelligentIconButton`,props:{props:{type:Object,required:!0}},setup(e){let t=ht(),n=b();return()=>{let r=e.props.variant??`outline`,i=O(e.props.label)||O(e.props.icon),a=n.value,o=r===`solid`?{background:C.ink,color:C.onInk,border:`1px solid transparent`}:r===`ghost`?{background:`transparent`,color:C.ink,border:`1px solid transparent`}:{background:C.canvas,color:C.ink,border:`1px solid ${C.borderStrong}`};return f(`button`,{type:`button`,disabled:a,"aria-label":i,title:i,class:`openui-intelligent-icon-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`34px`,height:`34px`,borderRadius:`999px`,cursor:a?`not-allowed`:`pointer`,opacity:a?.55:1,...o},onClick:()=>{a||t(i,e.props.action,!1)}},[f(D,{name:O(e.props.icon),size:16})])}}}),wn=g({name:`IconButton`,props:Sn,description:`Round icon-only button; label is read aloud. Needs an action.`,component:Cn}),Tn=S.object({src:S.string(),alt:S.string(),aspectRatio:S.number().optional(),radius:rt.optional(),fit:it.optional()}),En=d({name:`OpenUIIntelligentImage`,props:{props:{type:Object,required:!0}},setup(e){let t=m(!1);return()=>{let n=tt(e.props.src),r=typeof e.props.aspectRatio==`number`&&Number.isFinite(e.props.aspectRatio)?Math.min(5,Math.max(.2,e.props.aspectRatio)):1.5,i=He(e.props.radius)??C.radiusMd,a={width:`100%`,aspectRatio:String(r),borderRadius:i,overflow:`hidden`,background:C.photoEmpty,display:`flex`,alignItems:`center`,justifyContent:`center`};return!n||t.value?f(`div`,{role:`img`,"aria-label":O(e.props.alt)||`Image unavailable`,class:`openui-intelligent-image openui-intelligent-image--empty`,style:a},[f(`span`,{style:{fontSize:`12px`,color:C.muted}},O(e.props.alt)||`Image`)]):f(`div`,{class:`openui-intelligent-image`,style:a},[f(`img`,{src:n,alt:O(e.props.alt),loading:`lazy`,referrerpolicy:`no-referrer`,style:{width:`100%`,height:`100%`,objectFit:e.props.fit===`contain`?`contain`:`cover`,display:`block`},onError:()=>{t.value=!0}})])}}}),Dn=g({name:`Image`,props:Tn,description:`Photo from a URL the user or a tool gave; never invent a URL. If it fails to load, an empty photo placeholder shows. aspectRatio is 0.2 to 5 (default 1.5).`,component:En}),On=S.object({value:v(S.union([S.string(),S.number()])),label:S.string().optional(),type:S.enum([`text`,`number`]).optional(),placeholder:S.string().optional(),rules:M.optional()}),kn=d({name:`OpenUIIntelligentInput`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=b();return()=>{let t=e.props.type===`number`,a=n.value==null?``:String(n.value);return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:f(`input`,{type:t?`number`:`text`,value:a,placeholder:e.props.placeholder?O(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-input`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:C.font,color:C.ink,background:C.canvas,border:`1px solid ${r.error.value?C.danger:C.borderStrong}`,borderRadius:C.radiusMd,outline:`none`,boxSizing:`border-box`},onInput:e=>{let i=e.target.value;if(r.clear(),t){if(i.trim()===``)n.setValue(null);else{let e=Number(i);n.setValue(Number.isFinite(e)?e:null)}}else n.setValue(i)},onBlur:()=>r.check()})})}}}),An=g({name:`Input`,props:On,description:`Text or number field; a number field stores numbers, and null when emptied.`,component:kn}),jn=S.object({text:S.string()}),Mn=g({name:`Label`,props:jn,description:`Field or group label.`,component:({props:e})=>f(`span`,{class:`openui-intelligent-label`,style:{fontSize:`12px`,fontWeight:600,letterSpacing:`0.02em`,color:C.muted}},O(e.text))}),Nn=S.object({text:S.string(),url:S.string()}),Pn=g({name:`Link`,props:Nn,description:`Opens an http(s) URL in a new tab.`,component:({props:e})=>{let t=tt(e.url),n=O(e.text);return t?f(`a`,{class:`openui-intelligent-link`,href:t,target:`_blank`,rel:`noopener noreferrer`,style:{color:C.info,textDecoration:`underline`,textUnderlineOffset:`2px`}},n):f(`span`,{class:`openui-intelligent-link`},n)}}),Fn=S.object({title:S.string(),description:S.string().optional(),marker:S.string().optional(),children:k.optional()});function In(e){return S.object({items:S.array(S.union([S.string(),e.ref])),marker:S.enum([`bullet`,`number`,`none`]).optional(),timeline:S.boolean().optional()})}function Ln(e,t){return f(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,minWidth:0,flex:1}},[f(`div`,{style:{fontWeight:500,color:C.ink,lineHeight:1.45}},[N(O(e.title))]),e.description?f(`div`,{style:{fontSize:`13px`,color:C.muted,lineHeight:1.45}},[N(O(e.description))]):null,e.children?f(`div`,{style:{marginTop:`4px`}},[t(e.children)]):null])}const Rn=g({name:`ListItem`,props:Fn,description:`marker replaces the bullet or number, e.g. a time or an emoji.`,component:({props:e,renderNode:t})=>f(`div`,{class:`openui-intelligent-list-item`,style:{display:`flex`,gap:`8px`,alignItems:`flex-start`}},[typeof e.marker==`string`&&e.marker?f(`span`,{style:{fontSize:`12px`,color:C.muted,flexShrink:0}},e.marker):null,Ln(e,t)])}),zn=e=>dt(e)&&e.typeName===`ListItem`,Bn=g({name:`List`,props:In(Rn),description:`timeline joins the markers with a line.`,component:({props:e,renderNode:t})=>{let n=(Array.isArray(e.items)?e.items.flat():[]).filter(e=>e!=null),r=e.marker??`bullet`,i=e.timeline===!0;return f(r===`number`?`ol`:`ul`,{class:[`openui-intelligent-list`,i?`openui-intelligent-list--timeline`:null],style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:i?`12px`:`8px`}},n.map((e,n)=>{let a=zn(e)?e.props:null,o=a&&typeof a.marker==`string`?a.marker:void 0,s=o??(r===`none`?null:r===`number`?`${n+1}.`:`•`);return f(`li`,{key:n,style:{display:`flex`,gap:`10px`,alignItems:`flex-start`,position:`relative`,paddingLeft:i?`4px`:void 0,borderLeft:i?`2px solid ${C.borderStrong}`:void 0}},[s?f(`span`,{style:{minWidth:o?`auto`:`18px`,fontSize:`13px`,color:C.muted,fontWeight:500,flexShrink:0}},s):null,a?Ln(a,t):f(`div`,{style:{flex:1,lineHeight:1.5,color:C.ink}},[N(O(e))])])}))}}),Vn=S.object({text:S.string()}),Hn=g({name:`Markdown`,props:Vn,description:`Prose with headings, lists, quotes, code and tables.`,component:({props:e})=>f(i,{textMarkdown:O(e.text),className:`openui-intelligent-markdown`})}),Un=S.object({tex:S.string(),inline:S.boolean().optional()}),Wn=g({name:`Math`,props:Un,description:`LaTeX formula, e.g. Math("E = mc^2"); inline true to sit in a Text list.`,component:({props:e})=>{let t=O(e.tex),n=e.inline===!0,r=``;try{r=be.renderToString(t,{displayMode:!n,throwOnError:!1,strict:!1})}catch{return f(n?`span`:`div`,{class:`openui-intelligent-math`},t)}return f(n?`span`:`div`,{class:[`openui-intelligent-math`,n?`openui-intelligent-math--inline`:`openui-intelligent-math--block`],style:n?void 0:{overflowX:`auto`,padding:`4px 0`},innerHTML:r})}}),Gn=S.object({trigger:lt,content:lt}),Kn=d({name:`OpenUIIntelligentPopover`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=m(!1);return()=>f(`span`,{class:`openui-intelligent-popover`,style:{position:`relative`,display:`inline-flex`,alignItems:`center`}},[f(`button`,{type:`button`,"aria-expanded":t.value,onClick:()=>{t.value=!t.value},style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,background:`transparent`,border:`none`,padding:`2px 4px`,cursor:`pointer`,color:`inherit`,font:`inherit`,borderRadius:C.radiusSm}},[P(e.props.trigger,e.renderNode)]),t.value?f(`div`,{role:`dialog`,class:`openui-intelligent-popover-panel`,style:{position:`absolute`,top:`calc(100% + 6px)`,left:0,zIndex:40,minWidth:`200px`,maxWidth:`320px`,padding:C.spaceGroup,borderRadius:C.radiusMd,background:C.canvas,color:C.ink,border:`1px solid ${C.borderStrong}`,boxShadow:C.shadow}},[P(e.props.content,e.renderNode)]):null])}}),qn=g({name:`Popover`,props:Gn,description:`Shows content in a small panel when the trigger is clicked: a definition, a source, details behind an Icon("info", "sm"). The trigger is text or an Icon, never a Button: it is a button already.`,component:Kn}),Jn=S.object({children:k,action:fe().optional(),selected:S.boolean().optional(),padding:S.number().optional(),background:A.optional(),radius:rt.optional()}),Yn=d({name:`OpenUIIntelligentPressable`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=ht(),n=b(),r=m(null);return()=>{let i=e.props.selected===!0,a=n.value,o={display:`flex`,flexDirection:`column`,textAlign:`left`,padding:T(e.props.padding)??C.spaceGroup,borderRadius:He(e.props.radius)??C.radiusMd,background:ze(e.props.background)??(i?C.surfaceStrong:C.canvas),border:i?`2px solid ${C.ink}`:`1px solid ${C.border}`,cursor:a?`not-allowed`:`pointer`,width:`100%`,font:`inherit`,color:`inherit`,...$e(e.props.background)};return f(`button`,{ref:r,type:`button`,disabled:a,"aria-pressed":i,class:[`openui-intelligent-pressable`,i?`openui-intelligent-pressable--selected`:null],style:o,onClick:()=>{a||t(Ke(r.value),e.props.action,!1)}},e.renderNode(e.props.children))}}}),Xn=g({name:`Pressable`,props:Jn,description:`Makes any content clickable, such as a tile or a swatch. Needs an action.`,component:Yn}),Zn=S.object({text:S.string(),cite:S.string().optional()}),Qn=g({name:`Quote`,props:Zn,description:`A quotation or a callout with a side rule; cite names the source.`,component:({props:e})=>f(`blockquote`,{class:`openui-intelligent-quote`,style:{margin:0,padding:`8px 14px`,borderLeft:`3px solid ${C.borderStrong}`,background:C.surface,borderRadius:`0 ${C.radiusSm} ${C.radiusSm} 0`,display:`flex`,flexDirection:`column`,gap:`6px`}},[f(`div`,{style:{color:C.ink,lineHeight:1.55}},[N(O(e.text))]),e.cite?f(`cite`,{style:{fontSize:`12px`,color:C.muted,fontStyle:`normal`}},`— ${O(e.cite)}`):null])}),$n=S.object({value:v(S.string()),options:S.array(vt),label:S.string().optional(),variant:S.enum([`list`,`pills`,`cards`]).optional(),rules:M.optional()}),er=d({name:`OpenUIIntelligentRadioGroup`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=b();return()=>{let a=yt(e.props.options),o=n.value==null?``:String(n.value),s=e.props.variant??`list`,c=f(`div`,{role:`radiogroup`,class:`openui-intelligent-radio-group openui-intelligent-radio-group--${s}`,style:{display:`flex`,flexDirection:s===`pills`?`row`:`column`,flexWrap:s===`pills`?`wrap`:void 0,gap:`8px`}},a.map(e=>{let a=o===e.value;return s===`pills`?f(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":a,disabled:i.value,style:{padding:`6px 12px`,borderRadius:`999px`,fontSize:`13px`,fontWeight:500,cursor:i.value?`not-allowed`:`pointer`,background:a?C.ink:C.surface,color:a?C.onInk:C.ink,border:`1px solid ${a?C.ink:C.border}`},onClick:()=>{i.value||(r.clear(),n.setValue(e.value))}},e.label):f(`label`,{key:e.value,style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:s===`cards`?`10px 12px`:`4px 0`,borderRadius:s===`cards`?C.radiusMd:void 0,border:s===`cards`?`1px solid ${a?C.ink:C.border}`:void 0,background:s===`cards`&&a?C.surface:void 0,cursor:i.value?`not-allowed`:`pointer`}},[f(`input`,{type:`radio`,name:t.value,value:e.value,checked:a,disabled:i.value,style:{marginTop:`3px`,accentColor:C.ink},onChange:()=>{r.clear(),n.setValue(e.value)}}),f(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[f(`span`,{style:{fontSize:`14px`,fontWeight:s===`cards`?500:400,color:C.ink}},e.label),e.description?f(`span`,{style:{fontSize:`12px`,color:C.muted}},e.description):null])])}));return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:c})}}}),tr=g({name:`RadioGroup`,props:$n,description:`pills for short choices; cards for choices that need a description line.`,component:er}),nr=S.object({children:k,gap:S.number().optional(),align:st.optional(),justify:ct.optional(),wrap:S.boolean().optional()}),rr=g({name:`Row`,props:nr,description:`Horizontal layout; items are vertically centered.`,component:({props:e,renderNode:t})=>f(`div`,{class:`openui-intelligent-row`,style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:e.gap===void 0?C.spaceInner:void 0,...We(e,!1)}},[t(e.children)])}),ir=S.object({value:v(S.string()),options:gt,block:S.boolean().optional()}),ar=d({name:`OpenUIIntelligentSegmentedControl`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>`segmented`,()=>e.statementId),n=x(t,()=>e.props.value),r=b();return()=>{let t=_t(e.props.options),i=n.value==null?``:String(n.value);return f(`div`,{role:`tablist`,class:`openui-intelligent-segmented`,style:{display:e.props.block?`flex`:`inline-flex`,flexShrink:0,width:e.props.block?`100%`:void 0,padding:`3px`,gap:`2px`,background:C.surface,borderRadius:C.radiusMd,border:`1px solid ${C.border}`}},t.map(t=>{let a=i===t.value;return f(`button`,{key:t.value,type:`button`,role:`tab`,"aria-selected":a,disabled:r.value,style:{flex:e.props.block?`1 1 0%`:`0 0 auto`,padding:`6px 12px`,fontSize:`13px`,fontWeight:a?600:500,fontFamily:C.font,whiteSpace:`nowrap`,borderRadius:C.radiusSm,border:`none`,cursor:r.value?`not-allowed`:`pointer`,background:a?C.canvas:`transparent`,color:a?C.ink:C.muted,boxShadow:a?C.shadowSm:void 0},onClick:()=>{r.value||n.setValue(t.value)}},t.label)}))}}}),or=g({name:`SegmentedControl`,props:ir,description:`2 to 4 short choices in a row.`,component:ar}),sr=S.object({value:v(S.string()),options:gt,label:S.string().optional(),placeholder:S.string().optional(),rules:M.optional()}),cr=d({name:`OpenUIIntelligentSelect`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=b();return()=>{let t=_t(e.props.options),a=n.value==null?``:String(n.value);return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:f(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,width:`100%`}},[f(`select`,{value:a,disabled:i.value,class:`openui-intelligent-select`,style:{appearance:`none`,WebkitAppearance:`none`,width:`100%`,padding:`8px 32px 8px 10px`,fontSize:`14px`,fontFamily:C.font,color:C.ink,background:C.canvas,border:`1px solid ${r.error.value?C.danger:C.borderStrong}`,borderRadius:C.radiusMd,boxSizing:`border-box`,cursor:i.value?`not-allowed`:`pointer`},onChange:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()},[e.props.placeholder&&!a?f(`option`,{value:``,disabled:!0},O(e.props.placeholder)):null,...t.map(e=>f(`option`,{key:e.value,value:e.value},e.label))]),f(`svg`,{width:`14`,height:`14`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,style:{position:`absolute`,right:`10px`,pointerEvents:`none`,color:C.muted}},[f(`path`,{d:`M3 4.5L6 7.5L9 4.5`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})])])})}}}),lr=g({name:`Select`,props:sr,description:`Dropdown, for long option lists.`,component:cr}),ur=S.object({value:v(S.number()),min:S.number(),max:S.number(),step:S.number().optional(),label:S.string().optional(),unit:S.string().optional(),marks:S.array(S.object({value:S.number(),label:S.string()})).optional()}),dr=d({name:`OpenUIIntelligentSlider`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.value),r=b();return()=>{let t=typeof e.props.min==`number`&&Number.isFinite(e.props.min)?e.props.min:0,i=typeof e.props.max==`number`&&Number.isFinite(e.props.max)?e.props.max:100,a=typeof e.props.step==`number`&&e.props.step>0?e.props.step:1,o=typeof n.value==`number`&&Number.isFinite(n.value)?n.value:t,s=e.props.unit?O(e.props.unit):``,c=s===`$`||s===`€`||s===`£`||s===`¥`?`${s}${qe(o)}`:`${qe(o)}${s}`;return f(`div`,{class:`openui-intelligent-slider`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:C.font}},[f(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,gap:`8px`}},[e.props.label?f(`span`,{style:{fontSize:`13px`,fontWeight:500,color:C.ink}},O(e.props.label)):f(`span`),f(`span`,{style:{fontSize:`13px`,fontWeight:600,fontVariantNumeric:`tabular-nums`,color:C.ink}},c)]),f(`input`,{type:`range`,min:t,max:i,step:a,value:o,disabled:r.value,style:{width:`100%`,accentColor:C.rangeThumb,cursor:r.value?`not-allowed`:`pointer`},onInput:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n.setValue(t)}}),Array.isArray(e.props.marks)&&e.props.marks.length>0?f(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:`11px`,color:C.muted}},e.props.marks.map((e,t)=>f(`span`,{key:t},O(e.label)))):null])}}}),fr=g({name:`Slider`,props:ur,description:`Shows label and value; unit like "%" or "$" formats the value.`,component:dr}),pr=S.object({}),mr=g({name:`Spacer`,props:pr,description:`Fills the free space in a Row.`,component:()=>f(`div`,{class:`openui-intelligent-spacer`,style:{flex:`1 1 auto`}})}),hr=Symbol(`OpenUI.Intelligent.InSvg`),R=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,gr=e=>R(e)===void 0?void 0:Math.min(1,Math.max(0,e)),_r=/^[\d\s,.eE+-]*$/,vr=/^[MmLlHhVvCcSsQqTtAaZz\d\s,.eE+-]*$/,yr=/^\s*-?\d+(\.\d+)?[\s,]+-?\d+(\.\d+)?[\s,]+\d+(\.\d+)?[\s,]+\d+(\.\d+)?\s*$/,z=(e,t)=>typeof e==`string`&&e.length<2e4&&t.test(e)?e:void 0,B={fill:A.optional(),stroke:A.optional(),strokeWidth:S.number().optional(),opacity:S.number().optional()},V=(e,t)=>({fill:e.fill===void 0?t&&e.stroke===void 0?`currentColor`:`none`:w(e.fill)??`none`,stroke:e.stroke===void 0?t?void 0:`currentColor`:w(e.stroke),"stroke-width":R(e.strokeWidth)??(t?void 0:2),opacity:gr(e.opacity),"stroke-linecap":`round`,"stroke-linejoin":`round`}),br=d({name:`OpenUIIntelligentSvgCanvas`,props:{viewBox:{type:String,required:!0},label:String,width:[Number,String],height:[Number,String]},setup(e,{slots:t}){return ie(hr,!0),()=>{let n=z(e.viewBox,yr)??`0 0 100 100`;return f(`svg`,{class:`openui-intelligent-svg`,viewBox:n,role:e.label?`img`:void 0,"aria-label":e.label||void 0,"aria-hidden":e.label?void 0:`true`,style:{display:`block`,maxWidth:`100%`,width:E(e.width)??`100%`,height:E(e.height)??`auto`,color:C.ink}},t.default?.())}}}),H=d({name:`OpenUIIntelligentSvgStandalone`,setup(e,{slots:t}){let n=ee(hr,!1);return()=>n?t.default?.():f(br,{viewBox:`0 0 100 100`,width:160},{default:()=>t.default?.()})}}),xr=S.object({cx:S.number(),cy:S.number(),r:S.number(),...B}),Sr=g({name:`Circle`,props:xr,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>f(H,null,{default:()=>f(`circle`,{cx:R(e.cx),cy:R(e.cy),r:Math.max(0,R(e.r)??0),...V(e,!0)})})}),Cr=S.object({cx:S.number(),cy:S.number(),rx:S.number(),ry:S.number(),...B}),wr=g({name:`Ellipse`,props:Cr,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>f(H,null,{default:()=>f(`ellipse`,{cx:R(e.cx),cy:R(e.cy),rx:Math.max(0,R(e.rx)??0),ry:Math.max(0,R(e.ry)??0),...V(e,!0)})})}),Tr=S.object({x:S.number(),y:S.number(),width:S.number(),height:S.number(),...B,rx:S.number().optional()}),Er=g({name:`Rect`,props:Tr,description:`rx rounds the corners; fill defaults to the text color, and with only a stroke it stays unfilled.`,component:({props:e})=>f(H,null,{default:()=>f(`rect`,{x:R(e.x),y:R(e.y),width:Math.max(0,R(e.width)??0),height:Math.max(0,R(e.height)??0),rx:R(e.rx),...V(e,!0)})})}),Dr=S.object({x1:S.number(),y1:S.number(),x2:S.number(),y2:S.number(),stroke:A.optional(),strokeWidth:S.number().optional(),opacity:S.number().optional()}),Or=g({name:`Line`,props:Dr,description:`Stroked in the text color, 2 wide, unless stroke and strokeWidth are set.`,component:({props:e})=>f(H,null,{default:()=>f(`line`,{x1:R(e.x1),y1:R(e.y1),x2:R(e.x2),y2:R(e.y2),...V(e,!1)})})}),kr={m:2,l:2,t:2,h:1,v:1,c:6,s:4,q:4,a:7,z:0},Ar=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?/i,jr=/^[01]/,Mr=e=>{let t=e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*$/i)?.[0];if(!t)return e.trim()===``;let n=kr[t[0].toLowerCase()],r=t.slice(1),i=0;for(;r=r.replace(/^[\s,]+/,``),r;){let e=i%7,t=(n===7&&(e===3||e===4)?jr:Ar).exec(r);if(!t)return!1;r=r.slice(t[0].length),i++}return/[.eE+-]$/.test(t.trimEnd())?!1:n===0?i===0:i>0&&i%n===0},Nr=S.object({d:S.string(),...B}),Pr=g({name:`Path`,props:Nr,description:`d is SVG path data only (M, L, C, A, Z...), else nothing draws; unfilled unless fill is set.`,component:({props:e})=>{let t=z(e.d,vr);return f(H,null,{default:()=>f(`path`,{d:t!==void 0&&Mr(t)?t:void 0,...V(e,e.fill!==void 0)})})}}),Fr=S.object({points:S.string(),fill:A.optional(),stroke:A.optional(),strokeWidth:S.number().optional(),opacity:S.number().optional()}),Ir=g({name:`Polyline`,props:Fr,description:`points like "0,0 10,5 20,0".`,component:({props:e})=>f(H,null,{default:()=>f(`polyline`,{points:z(e.points,_r),...V(e,!1)})})}),Lr=S.object({points:S.string(),...B}),Rr=g({name:`Polygon`,props:Lr,description:`Closed shape; points like "0,0 10,5 20,0". fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>f(H,null,{default:()=>f(`polygon`,{points:z(e.points,_r),...V(e,!0)})})}),zr=S.object({text:S.string(),x:S.number(),y:S.number(),size:S.number().optional(),fill:A.optional(),anchor:S.enum([`start`,`middle`,`end`]).optional(),weight:S.enum([`normal`,`medium`,`semibold`]).optional()}),Br=[Sr,wr,Er,Or,Pr,Ir,Rr,g({name:`SvgText`,props:zr,description:`A text label at x, y; anchor sets which end sits on x.`,component:({props:e})=>f(H,null,{default:()=>f(`text`,{x:R(e.x),y:R(e.y),"font-size":R(e.size)??12,fill:w(e.fill)??`currentColor`,"text-anchor":e.anchor??`start`,"font-weight":e.weight===`semibold`?640:e.weight===`medium`?560:440,"font-family":C.font},String(e.text??``))})})],Vr=S.array(S.union(Br.map(e=>e.ref))),Hr={translate:[1,2],rotate:[1,3],scale:[1,2],skewX:[1],skewY:[1],matrix:[6]};function Ur(e){if(typeof e!=`string`||e.length>500)return;let t=[...e.matchAll(/\s*([a-zA-Z]+)\(([^()]*)\)\s*/g)];if(t.length&&t.map(e=>e[0]).join(``)===e)return t.every(([,e,t])=>{let n=t.trim().split(/\s*,\s*|\s+/).filter(Boolean);return(Hr[e]?.includes(n.length)??!1)&&n.every(e=>Number.isFinite(Number(e)))})?e.trim():void 0}const Wr=S.object({children:Vr,transform:S.string().optional(),opacity:S.number().optional()}),Gr=g({name:`G`,props:Wr,description:`Group; transform like "rotate(30 50 50)" or "translate(10 0)"; one with the wrong number of arguments is dropped.`,component:({props:e,renderNode:t})=>f(H,null,{default:()=>f(`g`,{transform:Ur(e.transform),opacity:gr(e.opacity)},[t(e.children)])})}),Kr=/* @__PURE__ */ new Set([...Br.map(e=>e.name),Gr.name]),qr=S.object({children:S.array(S.union([...Vr.element.options,Gr.ref])),viewBox:S.string(),label:S.string().optional(),width:j.optional(),height:j.optional()}),Jr=[g({name:`Svg`,props:qr,description:`A drawing for steps, parts, mechanisms, diagrams and layouts. Scales to its width; its shapes take expressions, so state can move them. label says in a few words what it shows, for screen readers: always give one.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.children)?e.children:[],r=e=>dt(e)&&Kr.has(String(e.typeName)),i=n.filter(e=>!r(e));return f(l,null,[f(br,{viewBox:e.viewBox,label:e.label,width:e.width,height:e.height},{default:()=>t(n.filter(r))}),i.length?t(i):null])}}),...Br,Gr],Yr=S.object({columns:S.array(S.string()),rows:S.array(S.array(S.any()))}),Xr=g({name:`Table`,props:Yr,description:`Each row lists its cells in column order; a cell may be a component. Number columns align right.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.columns)?e.columns.map(O):[],r=Array.isArray(e.rows)?e.rows.filter(e=>Array.isArray(e)):[],i=n.map((e,t)=>r.length>0&&r.every(e=>e[t]==null||typeof e[t]==`number`));return f(`div`,{class:`openui-intelligent-table-wrap`,style:{width:`100%`,overflowX:`auto`,border:`1px solid ${C.border}`,borderRadius:C.radiusMd}},[f(`table`,{class:`openui-intelligent-table`,style:{width:`100%`,borderCollapse:`collapse`,fontSize:`13px`,fontFamily:C.font}},[f(`thead`,null,f(`tr`,{style:{background:C.surface,borderBottom:`1px solid ${C.border}`}},n.map((e,t)=>f(`th`,{key:t,style:{padding:`8px 12px`,textAlign:i[t]?`right`:`left`,fontWeight:600,color:C.muted,whiteSpace:`nowrap`}},e)))),f(`tbody`,null,r.map((e,a)=>f(`tr`,{key:a,style:{borderBottom:a<r.length-1?`1px solid ${C.border}`:void 0}},n.map((n,r)=>{let a=e[r],o=dt(a)||Array.isArray(a)?t(a):typeof a==`number`?qe(a):N(O(a));return f(`td`,{key:r,style:{padding:`8px 12px`,textAlign:i[r]?`right`:`left`,fontVariantNumeric:i[r]?`tabular-nums`:void 0,color:C.ink}},[o])}))))])])}}),Zr=S.union([S.string(),k]),Qr=S.object({text:Zr,size:S.enum([`xs`,`sm`,`md`,`lg`]).optional(),color:A.optional(),weight:S.enum([`normal`,`medium`,`semibold`]).optional(),italic:S.boolean().optional(),lineThrough:S.boolean().optional(),tabularNums:S.boolean().optional(),maxLines:S.number().optional()}),$r={xs:`12px`,sm:`13px`,md:`14px`,lg:`16px`},ei={normal:400,medium:500,semibold:600},ti=g({name:`Text`,props:Qr,description:'Paragraph; supports **bold**, *italic*, `code` and [links](https://…). text may be a list mixing strings and inline components: [Icon("clock", "sm"), " 25 min · ", Badge("Easy")].',component:({props:e,renderNode:t})=>{let n={margin:0,fontSize:$r[e.size??`md`]??`14px`,lineHeight:1.55,color:w(e.color)??C.ink,fontWeight:e.weight?ei[e.weight]:void 0,fontStyle:e.italic?`italic`:void 0,textDecoration:e.lineThrough?`line-through`:void 0,fontVariantNumeric:e.tabularNums?`tabular-nums`:void 0};typeof e.maxLines==`number`&&e.maxLines>0&&(n.display=`-webkit-box`,n.WebkitLineClamp=String(Math.round(e.maxLines)),n.WebkitBoxOrient=`vertical`,n.overflow=`hidden`);let r=Array.isArray(e.text)?e.text.flat().map(e=>P(e,t)):P(e.text,t);return f(`p`,{class:`openui-intelligent-text`,style:n},[r])}}),ni=S.object({value:v(S.string()),label:S.string().optional(),placeholder:S.string().optional(),rows:S.number().optional(),rules:M.optional()}),ri=d({name:`OpenUIIntelligentTextArea`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=b();return()=>{let t=typeof e.props.rows==`number`&&Number.isFinite(e.props.rows)?Math.min(20,Math.max(2,Math.round(e.props.rows))):3;return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:f(`textarea`,{rows:t,value:n.value==null?``:String(n.value),placeholder:e.props.placeholder?O(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-textarea`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:C.font,color:C.ink,background:C.canvas,border:`1px solid ${r.error.value?C.danger:C.borderStrong}`,borderRadius:C.radiusMd,outline:`none`,resize:`vertical`,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}}),ii=g({name:`TextArea`,props:ni,description:`Multi-line text field; rows is 2 to 20 (default 3).`,component:ri}),ai=S.object({seconds:v(S.number()),label:S.string().optional()});function oi(e){let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}const si=d({name:`OpenUIIntelligentTimer`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=x(t,()=>e.props.seconds),r=b(),i=m(typeof n.value==`number`&&Number.isFinite(n.value)?n.value:0),a=m(!1),o=null,s=()=>{a.value=!1,o!==null&&(clearInterval(o),o=null)},c=()=>{r.value||a.value||Number(n.value??0)<=0||(a.value=!0,o=setInterval(()=>{let e=Number(n.value??0);e<=1?(n.setValue(0),s()):n.setValue(e-1)},1e3))},l=()=>{s(),n.setValue(i.value)};return p(s),()=>{let t=typeof n.value==`number`?n.value:Number(n.value??0),i=typeof document<`u`&&document.documentElement.lang.toLowerCase().startsWith(`zh`);return f(`div`,{class:`openui-intelligent-timer`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,padding:`12px 14px`,borderRadius:C.radiusMd,background:C.surface,border:`1px solid ${C.border}`}},[f(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[e.props.label?f(`span`,{style:{fontSize:`12px`,color:C.muted}},O(e.props.label)):null,f(`span`,{style:{fontSize:`24px`,fontWeight:700,fontVariantNumeric:`tabular-nums`,color:C.ink}},oi(t))]),f(`div`,{style:{display:`flex`,gap:`8px`,flexShrink:0}},[f(`button`,{type:`button`,disabled:r.value||!a.value&&t<=0,onClick:()=>a.value?s():c(),style:{padding:`6px 12px`,borderRadius:C.radiusSm,border:`none`,background:C.ink,color:C.onInk,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},a.value?i?`暂停`:`Pause`:i?`开始`:`Start`),f(`button`,{type:`button`,disabled:r.value,onClick:l,style:{padding:`6px 12px`,borderRadius:C.radiusSm,border:`1px solid ${C.borderStrong}`,background:C.canvas,color:C.ink,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},i?`重置`:`Reset`)])])}}}),ci=g({name:`Timer`,props:ai,description:`Countdown with start, pause and reset. It counts the bound seconds down to 0, so other statements can react, e.g. $left == 0.`,component:si}),li=S.object({text:S.string(),size:S.enum([`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`]).optional(),color:A.optional()}),ui={sm:{fontSize:`14px`,lineHeight:`1.35`,fontWeight:600},md:{fontSize:`16px`,lineHeight:`1.35`,fontWeight:600},lg:{fontSize:`20px`,lineHeight:`1.28`,fontWeight:650},xl:{fontSize:`24px`,lineHeight:`1.22`,fontWeight:650},"2xl":{fontSize:`32px`,lineHeight:`1.15`,fontWeight:700},"3xl":{fontSize:`40px`,lineHeight:`1.1`,fontWeight:700}},di=g({name:`Title`,props:li,description:`Heading; md for a card title, lg for a section, 2xl for a big number.`,component:({props:e})=>{let t=ui[e.size??`md`]??ui.md;return f(`div`,{role:`heading`,"aria-level":e.size===`3xl`||e.size===`2xl`?2:e.size===`xl`||e.size===`lg`?3:4,class:`openui-intelligent-title`,style:{margin:0,color:w(e.color)??C.ink,letterSpacing:`-0.015em`,...t}},O(e.text))}}),fi=S.object({video:S.string(),title:S.string().optional()}),pi=/^[A-Za-z0-9_-]{11}$/;function mi(e){let t=e.trim();if(pi.test(t))return t;try{let e=new URL(t),n=e.hostname.replace(/^www\./,``);if(n===`youtu.be`){let t=e.pathname.slice(1).split(`/`)[0]??``;return pi.test(t)?t:null}if(n===`youtube.com`||n===`m.youtube.com`||n===`youtube-nocookie.com`){let t=e.searchParams.get(`v`);if(t&&pi.test(t))return t;let n=e.pathname.split(`/`).filter(Boolean),r=n[1]??``;if((n[0]===`embed`||n[0]===`shorts`)&&pi.test(r))return r}}catch{return null}return null}const hi=[Xt,rr,pt,un,Dt,kt,qn,tn,mr,di,ti,Tt,Mn,Xe,Pn,Bn,Rn,Hn,Qn,qt,Wn,Ct,wn,Xn,An,ii,lr,or,fr,Gt,tr,$t,ci,cn,Dn,xn,Xr,Ht,g({name:`YouTube`,props:fi,description:`Embedded YouTube video by id or URL. Only a video you know exists.`,component:({props:e})=>{let t=mi(O(e.video));return t?f(`div`,{class:`openui-intelligent-youtube`,style:{width:`100%`,aspectRatio:`16 / 9`,borderRadius:C.radiusMd,overflow:`hidden`,background:C.surface}},[f(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${t}`,title:O(e.title)||`YouTube video`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowfullscreen:!0,loading:`lazy`,referrerpolicy:`strict-origin-when-cross-origin`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})]):null}}),an,Nt,...Jr,vn],gi=/^#?([\da-f]{3}|[\da-f]{6})$/i;function _i(e){let t=gi.exec(e.trim());if(!t)throw Error(`not a hex color: ${e}`);let n=t[1].length===3?t[1].replace(/./g,`$&$&`):t[1];return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}const vi=[_({name:`MixColor`,description:`The hex color a fraction t of the way from one hex color to another, e.g. @MixColor("#ffffff", "#0285ff", 0.5) for a heatmap or a tint`,params:S.object({from:S.string(),to:S.string(),t:S.number()}),returns:S.string(),fn:({from:e,to:t,t:n})=>{let r=_i(e),i=_i(t),a=Math.min(1,Math.max(0,n));return`#${r.map((e,t)=>Math.round(e+(i[t]-e)*a).toString(16).padStart(2,`0`)).join(``)}`}})],U=()=>S.array(S.any()),yi=()=>S.array(S.number()),W=()=>S.union([S.string(),S.number()]),bi=()=>S.enum([`sum`,`avg`,`count`,`min`,`max`]);function G(e,t){if(!t)return e;let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function K(e,t){if(e===t)return!0;if(typeof e==`number`&&typeof t==`string`||typeof e==`string`&&typeof t==`number`)return String(e)===String(t);if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e))return e.length===t.length&&e.every((e,n)=>K(e,t[n]));let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&K(e[n],t[n]))}function q(e){if(!Number.isFinite(e))throw Error(`result is not a finite number`);return e}function J(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function xi(e,t,n){if(n===`count`)return e.length;let r=e.map(e=>J(G(e,t??``))).filter(e=>e!==null);if(!r.length)return 0;switch(n){case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.reduce((e,t)=>e+t,0)/r.length;case`min`:return Math.min(...r);case`max`:return Math.max(...r)}}function Si(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=G(r,t),i=typeof e==`number`?e:e==null||e===``?`Unknown`:String(e),a=n.get(i);a?a.push(r):n.set(i,[r])}return n}const Y=1e4,X=864e5,Ci=/^(\d{4})-(\d{2})-(\d{2})$/;function Z(e){if(typeof e==`string`){let t=Ci.exec(e.trim());if(t){let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=Date.UTC(n,r-1,i),o=new Date(a);if(o.getUTCMonth()!==r-1||o.getUTCDate()!==i)throw Error(`invalid date "${e}"`);return{day:a/X,instant:null}}}let t=new Date(e);if(Number.isNaN(t.getTime()))throw Error(`invalid date "${e}"`);return{day:Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/X,instant:t}}function Q(e){return(/* @__PURE__ */ new Date(e*X)).toISOString().slice(0,10)}const wi={date:{month:`short`,day:`numeric`,year:`numeric`},short:{month:`short`,day:`numeric`},long:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`},weekday:{weekday:`short`},month:{month:`short`,year:`numeric`},time:{hour:`numeric`,minute:`2-digit`},datetime:{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}},Ti=_({name:`Now`,description:`The current date and time as an ISO string`,params:S.object({}),returns:S.string(),fn:()=>(/* @__PURE__ */ new Date()).toISOString()}),Ei=_({name:`FormatDate`,description:`A date as text: "date" Oct 9, 2026 (default), "short" Oct 9, "long" Friday, October 9, 2026, "weekday" Fri, "month" Oct 2026, "time" 9:30 PM, "datetime", "iso" 2026-10-09. Dates are "YYYY-MM-DD", ISO or a timestamp; "time" and "datetime" need a timestamp or an ISO date-time, as a plain date has no time`,params:S.object({date:W(),style:S.enum([`date`,`short`,`long`,`weekday`,`month`,`time`,`datetime`,`iso`]).optional()}),returns:S.string(),fn:({date:e,style:t=`date`})=>{let{day:n,instant:r}=Z(e);return t===`iso`?Q(n):(r??/* @__PURE__ */ new Date(n*X)).toLocaleString(`en-US`,{...wi[t],...r?{}:{timeZone:`UTC`}})}}),Di=_({name:`AddDays`,description:`The date days later (negative: earlier), as "YYYY-MM-DD"`,params:S.object({date:W(),days:S.number()}),returns:S.string(),fn:({date:e,days:t})=>Q(Z(e).day+Math.trunc(t))}),Oi=_({name:`DaysBetween`,description:`Calendar days from one date to another (negative if to is earlier)`,params:S.object({from:W(),to:W()}),returns:S.number(),fn:({from:e,to:t})=>Z(t).day-Z(e).day}),ki=_({name:`Today`,description:`Today's date in the viewer's time zone, as "YYYY-MM-DD"`,params:S.object({}),returns:S.string(),fn:()=>Q(Z(Date.now()).day)});function Ai(e){let t=/* @__PURE__ */ new Date(e*X);return[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]}const ji=[Ti,ki,Ei,Di,_({name:`AddMonths`,description:`The date months later (negative: earlier), kept within the month (Jan 31 + 1 is Feb 28), as "YYYY-MM-DD"; 12 months is a year`,params:S.object({date:W(),months:S.number()}),returns:S.string(),fn:({date:e,months:t})=>{let[n,r,i]=Ai(Z(e).day),a=r+Math.trunc(t),o=new Date(Date.UTC(n,a+1,0)).getUTCDate();return Q(Date.UTC(n,a,Math.min(i,o))/X)}}),Oi,_({name:`MonthsBetween`,description:`Whole months from one date to another (negative if to is earlier); @Floor(@MonthsBetween(birthday, @Today()) / 12) is an age`,params:S.object({from:W(),to:W()}),returns:S.number(),fn:({from:e,to:t})=>{let[n,r,i]=Ai(Z(e).day),[a,o,s]=Ai(Z(t).day),c=(a-n)*12+(o-r);return c>0&&s<i&&--c,c<0&&s>i&&(c+=1),c}}),_({name:`StartOf`,description:`First day of the date's "week" (Monday), "month" or "year", as "YYYY-MM-DD"`,params:S.object({date:W(),unit:S.enum([`week`,`month`,`year`])}),returns:S.string(),fn:({date:e,unit:t})=>{let n=Z(e).day,[r,i]=Ai(n);return Q(t===`week`?n-((/* @__PURE__ */ new Date(n*X)).getUTCDay()+6)%7:Date.UTC(r,t===`month`?i:0,1)/X)}})],Mi=()=>S.array(S.object({key:S.union([S.string(),S.number()]),value:S.number()})),Ni=e=>e.filter(e=>typeof e==`number`&&Number.isFinite(e)),Pi=(e,t)=>t??(e?`sum`:`count`);function Fi(e,t,n){return e.map((e,r)=>t?{...e,[t]:n[r]}:n[r])}const Ii=_({name:`GroupBy`,description:`One row per distinct key, in first-seen order; value is agg of field (default "sum"), or the row count without a field`,params:S.object({rows:U(),key:S.string(),field:S.string().optional(),agg:bi().optional()}),returns:Mi(),fn:({rows:e,key:t,field:n,agg:r})=>[...Si(e,t)].map(([e,t])=>({key:e,value:xi(t,n,Pi(n,r))}))}),Li=_({name:`Pivot`,description:`One row per rowKey value, under key, with a column per colKey value holding agg of field, for stacked or grouped charts`,params:S.object({rows:U(),rowKey:S.string(),colKey:S.string(),field:S.string().optional(),agg:bi().optional()}),returns:S.array(S.record(S.string(),S.union([S.string(),S.number()]))),fn:({rows:e,rowKey:t,colKey:n,field:r,agg:i})=>{let a=[...Si(e,n).keys()].map(String);return[...Si(e,t)].map(([e,t])=>{let o={key:e};for(let e of a)o[e]=0;for(let[e,a]of Si(t,n))o[String(e)]=xi(a,r,Pi(r,i));return o})}}),Ri=_({name:`Top`,description:`The n rows with the largest field ("asc": the smallest)`,params:S.object({rows:U(),field:S.string(),n:S.number(),direction:S.enum([`desc`,`asc`]).optional()}),returns:U(),fn:({rows:e,field:t,n,direction:r=`desc`})=>{let i=r===`asc`?1:-1;return e.map((e,n)=>({row:e,i:n,v:J(G(e,t))})).sort((e,t)=>e.v===null||t.v===null?e.v===t.v?e.i-t.i:e.v===null?1:-1:(e.v-t.v)*i||e.i-t.i).slice(0,Math.max(0,Math.trunc(n))).map(e=>e.row)}}),zi=/^\d{4}-\d{2}-\d{2}/,Bi=e=>typeof e==`string`&&zi.test(e.trim());function Vi(e,t){let n=J(e),r=J(t);if(n!==null&&r!==null)return n-r;if((Bi(e)||Bi(t))&&(Bi(e)||n!==null)&&(Bi(t)||r!==null))try{return Z(e).day-Z(t).day}catch{}let i=String(e),a=String(t);return i<a?-1:+(i>a)}const Hi=_({name:`Between`,description:`Rows whose field is from min to max, both included; compares numbers, dates by day ("YYYY-MM-DD", ISO or a timestamp), or text. Leave min or max null for an open end`,params:S.object({rows:U(),field:S.string(),min:S.any().optional(),max:S.any().optional()}),returns:U(),fn:({rows:e,field:t,min:n,max:r})=>e.filter(e=>{let i=G(e,t);return i!=null&&(n==null||Vi(i,n)>=0)&&(r==null||Vi(i,r)<=0)})});function Ui(e,t){if(t===`day`)return e;if(t===`week`)return e-((/* @__PURE__ */ new Date(e*864e5)).getUTCDay()+6)%7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)/864e5}function Wi(e,t){if(t===`day`)return e+1;if(t===`week`)return e+7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1)/864e5}const Gi=[Ii,Li,Ri,Hi,_({name:`Bucket`,description:`Rows per day, week (from Monday) or month of dateField, in date order, empty periods 0 for sum and count; key is "YYYY-MM-DD", or "YYYY-MM" for months`,params:S.object({rows:U(),dateField:S.string(),unit:S.enum([`day`,`week`,`month`]),field:S.string().optional(),agg:bi().optional()}),returns:Mi(),fn:({rows:e,dateField:t,unit:n,field:r,agg:i})=>{let a=/* @__PURE__ */ new Map;for(let r of e){let e=G(r,t);if(typeof e!=`string`&&typeof e!=`number`)continue;let i;try{i=Z(e).day}catch{continue}let o=Ui(i,n),s=a.get(o);s?s.push(r):a.set(o,[r])}if(!a.size)return[];let o=Pi(r,i),s=o===`sum`||o===`count`,c=e=>n===`month`?Q(e).slice(0,7):Q(e),l=[...a.keys()].sort((e,t)=>e-t),u=[];for(let e=l[0];e<=l[l.length-1];e=Wi(e,n)){let t=a.get(e);if(t?u.push({key:c(e),value:xi(t,r,o)}):s&&u.push({key:c(e),value:0}),u.length>1e4)throw Error(`more than ${Y} periods`)}return u}}),_({name:`Cumulative`,description:`Copy of the rows with field replaced by its running total (field "" for a list of numbers)`,params:S.object({rows:U(),field:S.string()}),returns:U(),fn:({rows:e,field:t})=>{let n=0;return Fi(e,t,e.map(e=>n+=J(G(e,t))??0))}}),_({name:`MovingAvg`,description:`Copy of the rows with field replaced by the average of its last window values (field "" for a list of numbers)`,params:S.object({rows:U(),field:S.string(),window:S.number()}),returns:U(),fn:({rows:e,field:t,window:n})=>{let r=Math.trunc(n);if(r<1)throw Error(`window must be at least 1`);let i=e.map(e=>J(G(e,t))??0);return Fi(e,t,i.map((e,t)=>{let n=i.slice(Math.max(0,t-r+1),t+1);return n.reduce((e,t)=>e+t,0)/n.length}))}}),_({name:`Change`,description:`Percent change from previous to current, e.g. @Change(120, 100) is 20; null when previous is 0`,params:S.object({current:S.number(),previous:S.number()}),returns:S.number().nullable(),fn:({current:e,previous:t})=>t===0?null:q((e-t)/Math.abs(t)*100)}),_({name:`Histogram`,description:`Counts numbers into equal-width bins as {key, value} rows: key is the bin's start, value the count; min and max fix the range, default the data's`,params:S.object({values:yi(),bins:S.number(),min:S.number().optional(),max:S.number().optional()}),returns:S.array(S.object({key:S.string(),value:S.number()})),fn:({values:e,bins:t,min:n,max:r})=>{let i=Ni(e),a=Math.trunc(t);if(a<1||a>500)throw Error(`bins must be from 1 to 500`);let o=n??(i.length?Math.min(...i):0),s=r??(i.length?Math.max(...i):1);s<=o&&(s=o+1);let c=(s-o)/a,l=Math.max(0,1-Math.floor(Math.log10(c))),u=Array(a).fill(0);for(let e of i)e<o||e>s||u[Math.min(a-1,Math.floor((e-o)/c))]++;return u.map((e,t)=>({key:String(Number((o+t*c).toFixed(l))),value:e}))}}),_({name:`Stats`,description:`Summary of numbers, all zeros for an empty list`,params:S.object({values:yi()}),returns:S.object({count:S.number(),min:S.number(),max:S.number(),mean:S.number(),median:S.number(),stdev:S.number()}),fn:({values:e})=>{let t=Ni(e),n=t.length;if(!n)return{count:0,min:0,max:0,mean:0,median:0,stdev:0};let r=[...t].sort((e,t)=>e-t),i=t.reduce((e,t)=>e+t,0)/n,a=Math.floor(n/2),o=n%2?r[a]:(r[a-1]+r[a])/2,s=Math.sqrt(t.reduce((e,t)=>e+(t-i)**2,0)/n);return{count:n,min:r[0],max:r[n-1],mean:i,median:o,stdev:s}}})],Ki=(e,t)=>e<0?t+e:e,qi=[_({name:`Append`,description:`Copy of the list with item added at the end`,params:S.object({list:U(),item:S.any()}),returns:U(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${Y} items`);return[...e,t]}}),_({name:`Prepend`,description:`Copy of the list with item added at the start`,params:S.object({list:U(),item:S.any()}),returns:U(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${Y} items`);return[t,...e]}}),_({name:`Concat`,description:`Joins two lists`,params:S.object({list:U(),more:U()}),returns:U(),fn:({list:e,more:t})=>{if(e.length+t.length>1e4)throw Error(`more than ${Y} items`);return[...e,...t]}}),_({name:`Remove`,description:`Copy without the items whose field equals value; field "" compares the items themselves`,params:S.object({list:U(),field:S.string(),value:S.any()}),returns:U(),fn:({list:e,field:t,value:n})=>e.filter(e=>!K(G(e,t),n))}),_({name:`RemoveAt`,description:`Copy without the item at index (0-based; negative counts from the end)`,params:S.object({list:U(),index:S.number()}),returns:U(),fn:({list:e,index:t})=>{let n=Ki(Math.trunc(t),e.length);return e.filter((e,t)=>t!==n)}}),_({name:`Update`,description:`Copy where items whose field equals value get setField set to setValue`,params:S.object({list:U(),field:S.string(),value:S.any(),setField:S.string(),setValue:S.any()}),returns:U(),fn:({list:e,field:t,value:n,setField:r,setValue:i})=>e.map(e=>e&&typeof e==`object`&&!Array.isArray(e)&&K(G(e,t),n)?{...e,[r]:i}:e)}),_({name:`Toggle`,description:`Adds item if missing, removes it if present (a set of strings or numbers)`,params:S.object({list:U(),item:S.any()}),returns:U(),fn:({list:e,item:t})=>e.some(e=>K(e,t))?e.filter(e=>!K(e,t)):[...e,t]}),_({name:`Includes`,description:`True if the list has item, or the text contains it`,params:S.object({list:S.union([U(),S.string()]),item:S.any()}),returns:S.boolean(),fn:({list:e,item:t})=>typeof e==`string`?t!=null&&e.includes(String(t)):e.some(e=>K(e,t))}),_({name:`Find`,description:`First item whose field equals value, or null`,params:S.object({list:U(),field:S.string(),value:S.any()}),returns:S.any(),fn:({list:e,field:t,value:n})=>e.find(e=>K(G(e,t),n))??null}),_({name:`IndexOf`,description:`Index of item in the list, or -1`,params:S.object({list:U(),item:S.any()}),returns:S.number(),fn:({list:e,item:t})=>e.findIndex(e=>K(e,t))}),_({name:`Take`,description:`The first n items; a negative n takes the last n`,params:S.object({list:U(),n:S.number()}),returns:U(),fn:({list:e,n:t})=>{let n=Math.trunc(t);return n>=0?e.slice(0,n):e.slice(n)}}),_({name:`Slice`,description:`Items, or characters of text, from start up to end (not included); negative counts from the end`,params:S.object({list:S.union([U(),S.string()]),start:S.number(),end:S.number().optional()}),returns:S.union([U(),S.string()]),fn:({list:e,start:t,end:n})=>{let r=n===void 0?void 0:Math.trunc(n);return e.slice(Math.trunc(t),r)}}),_({name:`Unique`,description:`Distinct items in first-seen order`,params:S.object({list:U()}),returns:U(),fn:({list:e})=>{let t=/* @__PURE__ */ new Set,n=[];return e.filter(e=>{if(typeof e!=`object`||!e){let n=String(e);return!t.has(n)&&(t.add(n),!0)}return!n.some(t=>K(t,e))&&(n.push(e),!0)})}}),_({name:`Reverse`,description:`Copy in reverse order`,params:S.object({list:U()}),returns:U(),fn:({list:e})=>[...e].reverse()}),_({name:`Range`,description:`Numbers from start up to end (not included) by step (default 1), e.g. @Range(0, 3) is [0, 1, 2]`,params:S.object({start:S.number(),end:S.number(),step:S.number().optional()}),returns:S.array(S.number()),fn:({start:e,end:t,step:n=1})=>{if(n===0||!Number.isFinite(n))throw Error(`step must be a non-zero number`);let r=Math.max(0,Math.ceil((t-e)/n));if(r>1e4)throw Error(`more than ${Y} items`);let i=Number.isInteger(e)&&Number.isInteger(n);return Array.from({length:r},(t,r)=>i?e+r*n:Number((e+r*n).toPrecision(12)))}}),_({name:`Pick`,description:`A random item, or null for an empty list; draws anew each time, so call it inside @Set`,params:S.object({list:U()}),returns:S.any(),fn:({list:e})=>e.length?e[Math.floor(Math.random()*e.length)]:null}),_({name:`Shuffle`,description:`Copy in random order; call it inside @Set`,params:S.object({list:U()}),returns:U(),fn:({list:e})=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}}),_({name:`Flatten`,description:`One list from a list of lists, e.g. [[1, 2], [3]] is [1, 2, 3]`,params:S.object({list:U()}),returns:U(),fn:({list:e})=>{let t=e.flatMap(e=>Array.isArray(e)?e:[e]);if(t.length>1e4)throw Error(`more than ${Y} items`);return t}}),_({name:`Chunk`,description:`The list cut into lists of size items, e.g. for weeks of 7 days or pages`,params:S.object({list:U(),size:S.number()}),returns:S.array(U()),fn:({list:e,size:t})=>{let n=Math.trunc(t);if(n<1)throw Error(`size must be 1 or more`);let r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}})],Ji=_({name:`Pow`,description:`base raised to exponent`,params:S.object({base:S.number(),exponent:S.number()}),returns:S.number(),fn:({base:e,exponent:t})=>q(e**+t)}),Yi=_({name:`Sqrt`,description:`Square root; null for a negative number`,params:S.object({number:S.number()}),returns:S.number().nullable(),fn:({number:e})=>e<0?null:q(Math.sqrt(e))}),Xi=_({name:`Random`,description:`Random number from min to max (integer true: a whole number, max included); draws anew each time, so call it inside @Set`,params:S.object({min:S.number(),max:S.number(),integer:S.boolean().optional()}),returns:S.number(),fn:({min:e,max:t,integer:n})=>{if(!Number.isFinite(e)||!Number.isFinite(t))throw Error(`min and max must be numbers`);let r=Math.min(e,t),i=Math.max(e,t);if(!n)return r+Math.random()*(i-r);let a=Math.ceil(r),o=Math.floor(i);if(a>o)throw Error(`no whole number between min and max`);return a+Math.floor(Math.random()*(o-a+1))}}),Zi=_({name:`Clamp`,description:`number kept between min and max`,params:S.object({number:S.number(),min:S.number(),max:S.number()}),returns:S.number(),fn:({number:e,min:t,max:n})=>q(Math.min(Math.max(e,Math.min(t,n)),Math.max(t,n)))}),Qi=_({name:`Percent`,description:`part / total * 100, e.g. @Percent(3, 4) is 75; 0 when total is 0`,params:S.object({part:S.number(),total:S.number()}),returns:S.number(),fn:({part:e,total:t})=>t===0?0:q(e/t*100)}),$i=_({name:`Lerp`,description:`The value a fraction t of the way from a to b`,params:S.object({a:S.number(),b:S.number(),t:S.number()}),returns:S.number(),fn:({a:e,b:t,t:n})=>q(e+(t-e)*n)}),ea=_({name:`Allocate`,description:`Splits total in proportion to weights, rounded to decimals (default 2), so the parts add up to exactly total, e.g. @Allocate(100, [1, 1, 1]) is [33.34, 33.33, 33.33]`,params:S.object({total:S.number(),weights:yi(),decimals:S.number().optional()}),returns:S.array(S.number()),fn:({total:e,weights:t,decimals:n})=>{let r=t.reduce((e,t)=>e+t,0);if(!t.length||t.some(e=>!Number.isFinite(e)||e<0))throw Error(`weights must be zero or more`);if(r===0)return t.map(()=>0);let i=10**Math.min(6,Math.max(0,Math.round(n!==void 0&&Number.isFinite(n)?n:2))),a=Math.round(Math.abs(e)*i),o=t.map(e=>a*e/r),s=o.map(Math.floor),c=a-s.reduce((e,t)=>e+t,0),l=o.map((e,t)=>({i:t,rest:e-Math.floor(e)})).sort((e,t)=>t.rest-e.rest||e.i-t.i);for(let{i:e}of l){if(c<=0)break;s[e]+=1,--c}return s.map(t=>(e<0?-t:t)/i)}}),ta=_({name:`Payment`,description:`Payment per period that repays principal over periods at rate percent per period, e.g. a 30-year loan at 6% a year: @Payment(300000, 6 / 12, 360)`,params:S.object({principal:S.number(),rate:S.number(),periods:S.number()}),returns:S.number(),fn:({principal:e,rate:t,periods:n})=>{if(!(n>0))throw Error(`periods must be positive`);let r=t/100;return q(r===0?e/n:e*r/(1-(1+r)**+-n))}}),na={mm:[`length`,.001],cm:[`length`,.01],m:[`length`,1],km:[`length`,1e3],in:[`length`,.0254],ft:[`length`,.3048],yd:[`length`,.9144],mi:[`length`,1609.344],mg:[`mass`,1e-6],g:[`mass`,.001],kg:[`mass`,1],oz:[`mass`,.028349523125],lb:[`mass`,.45359237],st:[`mass`,6.35029318],ml:[`volume`,.001],l:[`volume`,1],tsp:[`volume`,.00492892159375],tbsp:[`volume`,.0147867647812],floz:[`volume`,.0295735295625],cup:[`volume`,.2365882365],pt:[`volume`,.473176473],qt:[`volume`,.946352946],gal:[`volume`,3.785411784],"m/s":[`speed`,1],"km/h":[`speed`,1/3.6],mph:[`speed`,.44704],kn:[`speed`,.514444],m2:[`area`,1],km2:[`area`,1e6],ft2:[`area`,.09290304],ha:[`area`,1e4],acre:[`area`,4046.8564224]},ra=[`c`,`f`,`k`],ia=(e,t)=>t===`f`?(e-32)*5/9:t===`k`?e-273.15:e,aa=(e,t)=>t===`f`?e*9/5+32:t===`k`?e+273.15:e,oa=[Ji,Yi,Xi,Zi,Qi,$i,ea,ta,_({name:`Convert`,description:`value from one unit to another: mm cm m km in ft yd mi; mg g kg oz lb st; ml l tsp tbsp floz cup pt qt gal (US); m/s km/h mph kn; m2 km2 ft2 ha acre; c f k`,params:S.object({value:S.number(),from:S.string(),to:S.string()}),returns:S.number(),fn:({value:e,from:t,to:n})=>{let[r,i]=[t.trim().toLowerCase(),n.trim().toLowerCase()];if(ra.includes(r)&&ra.includes(i))return q(aa(ia(e,r),i));let[a,o]=[na[r],na[i]];if(!a||!o||a[0]!==o[0])throw Error(`cannot convert ${t} to ${n}`);return q(e*a[1]/o[1])}})],sa=`en-US`;function ca(e){let t=(e??`USD`).toUpperCase();return/^[A-Z]{3}$/.test(t)?t:`USD`}function $(e,t){try{return e.toLocaleString(sa,t)}catch{return e.toLocaleString(sa,{...t,currency:`USD`})}}const la=[_({name:`Format`,description:`Number as text: "number" 12,345.6, "currency" $12,345.68 (currency is a code like "EUR"), "percent" 45 -> 45%, "compact" 1.2M ($1.2M with a currency)`,params:S.object({value:S.number(),kind:S.enum([`number`,`currency`,`percent`,`compact`]).optional(),decimals:S.number().optional(),currency:S.string().optional()}),returns:S.string(),fn:({value:e,kind:t=`number`,decimals:n,currency:r})=>{if(!Number.isFinite(e))throw Error(`value is not a finite number`);let i=n===void 0?void 0:Math.min(Math.max(Math.trunc(n),0),10),a=(e,t=0)=>i===void 0?{minimumFractionDigits:t,maximumFractionDigits:e}:{minimumFractionDigits:t&&i,maximumFractionDigits:i};switch(t){case`currency`:return $(e,{style:`currency`,currency:ca(r),...a(2,2)});case`percent`:return`${$(e,a(1))}%`;case`compact`:return $(e,{notation:`compact`,...a(1),...r?{style:`currency`,currency:ca(r)}:{}});default:return $(e,a(2))}}}),_({name:`Join`,description:`Joins the items (or their field) into text with sep (default ", "), skipping nulls`,params:S.object({list:U(),sep:S.string().optional(),field:S.string().optional()}),returns:S.string(),fn:({list:e,sep:t=`, `,field:n=``})=>e.map(e=>G(e,n)).filter(e=>e!=null).map(e=>typeof e==`object`?JSON.stringify(e):String(e)).join(t)}),_({name:`Plural`,description:`Count and word: @Plural(1, "guest") is "1 guest", 3 gives "3 guests"; plural defaults to word + "s"`,params:S.object({n:S.number(),word:S.string(),plural:S.string().optional()}),returns:S.string(),fn:({n:e,word:t,plural:n})=>`${$(e,{maximumFractionDigits:2})} ${Math.abs(e)===1?t:n??`${t}s`}`}),_({name:`Pad`,description:`Pads the start of value to length with char (default "0"), e.g. 7 -> "07"`,params:S.object({value:S.union([S.string(),S.number()]),length:S.number(),char:S.string().optional()}),returns:S.string(),fn:({value:e,length:t,char:n=`0`})=>String(e).padStart(Math.min(Math.trunc(t),1e3),n||`0`)}),_({name:`Upper`,description:`Text in upper case`,params:S.object({text:S.string()}),returns:S.string(),fn:({text:e})=>e.toUpperCase()}),_({name:`Lower`,description:`Text in lower case`,params:S.object({text:S.string()}),returns:S.string(),fn:({text:e})=>e.toLowerCase()}),_({name:`Trim`,description:`Text without spaces at the start and end`,params:S.object({text:S.string()}),returns:S.string(),fn:({text:e})=>e.trim()}),_({name:`Capitalize`,description:`Each word with a capital first letter, e.g. "new york" is "New York"`,params:S.object({text:S.string()}),returns:S.string(),fn:({text:e})=>e.replace(/(^|[\s\-(/"])(\p{L})/gu,(e,t,n)=>t+n.toUpperCase())}),_({name:`Split`,description:`List of the parts of text between sep (default ","), each trimmed, empty parts dropped, e.g. @Split("a, b,,c") is ["a", "b", "c"]`,params:S.object({text:S.string(),sep:S.string().optional()}),returns:S.array(S.string()),fn:({text:e,sep:t=`,`})=>{let n=e.split(t===``?``:t).map(e=>e.trim()).filter(e=>e!==``);if(n.length>1e4)throw Error(`more than ${Y} items`);return n}}),_({name:`Replace`,description:`Text with every find replaced by replacement`,params:S.object({text:S.string(),find:S.string(),replacement:S.string()}),returns:S.string(),fn:({text:e,find:t,replacement:n})=>t===``?e:e.split(t).join(n)}),_({name:`Duration`,description:`Seconds as text: "short" 1h 20m, 4m 05s, 45s (default); "clock" 1:20:00, 4:05`,params:S.object({seconds:S.number(),style:S.enum([`short`,`clock`]).optional()}),returns:S.string(),fn:({seconds:e,style:t=`short`})=>{if(!Number.isFinite(e))throw Error(`seconds is not a finite number`);let n=e<0?`-`:``,r=Math.round(Math.abs(e)),[i,a,o]=[Math.floor(r/3600),Math.floor(r%3600/60),r%60],s=e=>String(e).padStart(2,`0`);return t===`clock`?n+(i?`${i}:${s(a)}:${s(o)}`:`${a}:${s(o)}`):i?`${n}${i}h${a?` ${a}m`:``}`:a?`${n}${a}m${o?` ${s(o)}s`:``}`:`${n}${o}s`}}),_({name:`Default`,description:`value, or fallback when value is null, "" or not a number, e.g. an empty number input: @Default($weight, 0)`,params:S.object({value:S.any().optional(),fallback:S.any()}),returns:S.any(),fn:({value:e,fallback:t})=>e==null||e===``||typeof e==`number`&&Number.isNaN(e)?t:e})],ua=[...qi,...oa,...la,...vi,...ji,...Gi],da=[{name:`Layout`,components:[`Col`,`Row`,`Box`,`Grid`,`Card`,`Carousel`,`Popover`,`Divider`,`Spacer`],notes:[`- gap and padding count 4px steps. Length is px or a CSS length like "50%". Radius is "sm", "md", "lg", "xl", "full" or px.`,`- Color is "ink", "muted", "faint", "surface", "info", "success", "warning", "danger", "purple", "pink", "chart1" to "chart6", or a CSS color. As a background, status colors are soft tints.`]},{name:`Text`,components:[`Title`,`Text`,`Caption`,`Label`,`Badge`,`Link`,`List`,`ListItem`,`Markdown`,`Quote`,`Code`,`Math`]},{name:`Inputs`,components:[`Button`,`IconButton`,`Pressable`,`Input`,`TextArea`,`Select`,`SegmentedControl`,`Slider`,`Checkbox`,`RadioGroup`,`DatePicker`,`Timer`,`Form`],notes:[`- An input's first argument is its value, usually a $variable that other statements read.`,`- Every input either changes something shown on the page, or sits in a Form whose submit Button sends a short first-person @ToAssistant ("Help me choose a bike"); the form values go with it. No dead inputs.`,`- In a Form, a field's last argument rules is checked before the form sends, and an error shows under the field. Rules is {required?, min?, max?, minLength?, maxLength?, email?, url?, numeric?, pattern?}: Input($email, "Email", "text", null, {required: true, email: true}).`]},{name:`Media and data`,components:[`Image`,`Icon`,`Table`,`Chart`,`YouTube`]},{name:`Play`,components:[`Flashcard`,`Celebration`]},{name:`Drawing`,components:[`Svg`,`G`,`Circle`,`Ellipse`,`Rect`,`Line`,`Path`,`Polyline`,`Polygon`,`SvgText`,`HtmlView`]}],fa=pe({root:`Col`,components:hi,functions:ua,componentGroups:da}),pa=[`Compose the answer like a page, not a form letter: a Title, a short Text, then a mix of blocks that show the content. Row, Grid and Carousel to set things side by side; Badge rows for quick facts; Card only to group a block; Popover for an aside.`,`Use Image only with a URL the user or a tool gave in this conversation. Never write an image URL yourself, even for a famous place or product: it will often be wrong. Without a URL, show the subject with an Icon, Badges or an Svg drawing instead.`,`Spacing is a system with three tiers that always nest: inner (gap 1-2, 4-8px) for a title with its subtitle, tags or line; group (gap 3-4, 12-16px) between blocks inside a Card or grid cell; section (24px) between the blocks of the page. Leave gap unset on the page's root Col and on a Card's own contents: the app applies these tiers. Set it on a Row, a Grid or an inner Col. Never use one gap for everything, and never a gap larger than the section gap.`,`A photo beside text is a media row: Row([Box([Image(url, alt, 1.33)]), Col([Title(..., "md"), Row([Badge(...), Badge(...)], 1, null, null, true), Text(..., "sm")], 2)], 4, "start"). The app sizes the photo to a third of the row (at most 200px) and top-aligns the text. Facts are Badges, never Buttons or boxed pills.`,`Keep cards compact and scannable: Title "md" for a card heading (xl or 2xl only for a single big number), Text "sm" for the body, at most one short paragraph, then facts as Badges or label/value rows (Caption label, Spacer, Text value). Don't write bold-lead paragraphs like "**Weekend rhythm:** ..." or long prose in a card. Cards side by side in a Grid share the same blocks in the same order and the same Image aspect ratio, so they line up. For example: c = Card([Col([Title("Sonoma", "md"), Row([Badge("1 h drive", null, "car"), Badge("Wine country", "purple")], 1, null, null, true)], 2), Text("A slow plaza, tasting rooms and quiet back roads.", "sm"), Col([Row([Caption("Best for"), Spacer(), Text("Food and wine", "sm")]), Row([Caption("Trade-off"), Spacer(), Text("Tastings add up", "sm")])], 1)])`,`Answer with a working tool whenever the request involves numbers, choices, lists, steps, a game or something to explore: keep inputs and lists in $variables, compute everything shown from them with expressions and @functions, and change them with @Set. The page must work on its own, without another message.`,`When the request leaves out a detail the answer depends on (a model, a size, a count), don't stop to ask: assume the most common case, say so in one short line, and build the whole answer, with a SegmentedControl or Select to switch to the other cases where they differ.`,`Use @ToAssistant only for what the page cannot compute: a Form's submit Button, or a new request ("Plan another day"). Its message is short and first person, like the user typing it ("Help me choose a bike"); the form values travel with it, so never repeat them in the message.`,`$variable defaults are literals (numbers, strings, lists, objects), never expressions or @calls. Edit lists with @Append, @Remove, @RemoveAt and @Update; track selections with @Toggle and @Includes.`,`cond ? a : b also picks between components; there is no @If. Use only the listed @functions; you cannot define your own.`,`Derive rows once in a statement with @Each(list, "x", {...}), then reuse them in @Each, Table, Chart, @Sum(rows.field) and @Join. @Each(@Range(0, n), "i", ...) builds a series or repeats a step.`,`@Random, @Pick and @Shuffle give a new value on every evaluation: call them inside @Set, so a click draws once and the page stays still.`,`Pick the medium that shows the idea: Chart for numbers across time or categories; Svg drawings for shapes, parts and movement; Table for comparisons; Flashcard and Celebration for learning and games; HtmlView only for a game or animation that needs a loop.`,`Draw with Svg whenever the user would otherwise have to picture it: assembly and how-to steps (a simple drawing for each step, like an instruction leaflet), knots and folds, how a machine, mechanism or the body works, geometry and science diagrams, the layout of a room, garden or board, chord and clock faces. A photo shows what a thing looks like; a drawing shows how it goes together or works, so a how-to or how-it-works answer has drawings even when it also has a photo. Keep each drawing simple: a viewBox about 240 wide, a dozen or so shapes in the listed colors with SvgText labels, a Line with a small Polygon head for an arrow, and let $variables such as the current step drive it.`,`Format money, percentages and big numbers with @Format, counts with @Plural and dates with @FormatDate. @Percent is unrounded, so show it as @Format(@Percent(part, total), "percent"), never @Percent(...) + "%".`,`Dates relative to now (today, this week, next month) start from @Today(), never a fixed date. <, >, <= and >= compare numbers only, so order two dates with @DaysBetween(a, b) > 0.`,`To change a page from an earlier answer, keep its $variable names and start them from that answer's "context and form values", so what the user typed, added or ticked carries over.`,`Read a number input for a count or amount through @Default and @Clamp with a sensible minimum, e.g. @Clamp(@Default($people, 1), 1, 50), so 0, empty or negative cannot divide by zero or zero out the page.`,`Answer a plain knowledge or safety question with Markdown text, adding a Quote only where it helps.`],ma=[`Example 1: A guest stepper that rescales a shopping list, with a checklist and a button that clears it:
|
|
1
|
+
import{AreaChart as e,BarChart as t,CodeBlock as n,LineChart as r,MarkDownRenderer as i,PieChart as a,ScatterChart as o,ThemeProvider as s,useId as c,useTheme as l}from"@wodecorp/openui-vue-ui";import{Fragment as u,computed as d,defineComponent as f,h as p,inject as ee,onBeforeUnmount as m,onMounted as te,onScopeDispose as ne,onUpdated as re,provide as ie,ref as h,shallowRef as ae,toValue as g,watch as oe,watchEffect as se}from"vue";import{ACTION_STEPS as ce,FormNameContext as le,FormValidationContext as ue,action as de,createLibrary as fe,defineComponent as _,defineFunction as v,parseStructuredRules as pe,reactive as y,tagSchemaId as b,useCreateFormValidation as me,useFormName as he,useFormValidation as ge,useIsStreaming as x,useStateField as S,useTriggerAction as _e}from"@wodecorp/openui-vue-lang";import{getIconImport as ve}from"@wodecorp/openui-vue-ui/icons";import{z as C}from"zod/v4";import ye from"katex";const w={font:`var(--openui-intelligent-font, var(--openui-font-body, "Inter", sans-serif))`,mono:`var(--openui-intelligent-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace)`,canvas:`var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))`,hover:`var(--openui-intelligent-hover, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 5%, transparent))`,pressed:`var(--openui-intelligent-pressed, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,surface:`var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent))`,surfaceStrong:`var(--openui-intelligent-surface-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,ink:`var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0)))`,inkHover:`var(--openui-intelligent-ink-hover, color-mix(in oklch, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 82%, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876)))))`,onInk:`var(--openui-intelligent-on-ink, var(--openui-foreground, oklch(0.994 0 89.876)))`,muted:`var(--openui-intelligent-muted, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,faint:`var(--openui-intelligent-faint, var(--openui-text-neutral-secondary, oklch(0.097 0 0 / 0.6)))`,border:`var(--openui-intelligent-border, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 8%, transparent))`,borderStrong:`var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent))`,rangeTrack:`var(--openui-intelligent-range-track, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,rangeThumb:`var(--openui-intelligent-range-thumb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,focus:`var(--openui-intelligent-focus, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,glass:`var(--openui-intelligent-glass, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassHover:`var(--openui-intelligent-glass-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,glassRing:`var(--openui-intelligent-glass-ring, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 70%, transparent))`,glassRingHover:`var(--openui-intelligent-glass-ring-hover, color-mix(in srgb, var(--openui-intelligent-canvas, var(--openui-foreground, oklch(0.994 0 89.876))) 85%, transparent))`,shadow:`var(--openui-intelligent-shadow, var(--openui-shadow-l, 0 4px 4px -2px oklch(0 0 0 / 0.05), 0 4px 8px -2px oklch(0 0 0 / 0.04)))`,shadowSm:`var(--openui-intelligent-shadow-sm, var(--openui-shadow-s, 0 1px 3px -2px oklch(0 0 0 / 0.02), 0 2px 5px -2px oklch(0 0 0 / 0.04)))`,info:`var(--openui-intelligent-info, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))))`,infoSoft:`var(--openui-intelligent-info-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,success:`var(--openui-intelligent-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,successSoft:`var(--openui-intelligent-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,warning:`var(--openui-intelligent-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,warningSoft:`var(--openui-intelligent-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,danger:`var(--openui-intelligent-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,dangerSoft:`var(--openui-intelligent-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,purple:`var(--openui-intelligent-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,purpleSoft:`var(--openui-intelligent-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,pink:`var(--openui-intelligent-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,pinkSoft:`var(--openui-intelligent-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,badgeNeutralSoft:`var(--openui-intelligent-badge-neutral-soft, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 6%, transparent))`,badgeSuccess:`var(--openui-intelligent-badge-success, var(--openui-text-success-primary, oklch(0.448 0.108 151.328)))`,badgeSuccessSoft:`var(--openui-intelligent-badge-success-soft, var(--openui-success-background, oklch(0.627 0.17 149.214 / 0.12)))`,badgeWarning:`var(--openui-intelligent-badge-warning, var(--openui-text-alert-primary, oklch(0.476 0.103 61.907)))`,badgeWarningSoft:`var(--openui-intelligent-badge-warning-soft, var(--openui-alert-background, oklch(0.795 0.162 86.047 / 0.16)))`,badgeDanger:`var(--openui-intelligent-badge-danger, var(--openui-text-danger-primary, oklch(0.505 0.19 27.518)))`,badgeDangerSoft:`var(--openui-intelligent-badge-danger-soft, var(--openui-danger-background, oklch(0.577 0.215 27.325 / 0.12)))`,badgePurple:`var(--openui-intelligent-badge-purple, var(--openui-text-purple-primary, oklch(0.438 0.198 303.724)))`,badgePurpleSoft:`var(--openui-intelligent-badge-purple-soft, var(--openui-purple-background, oklch(0.627 0.233 303.9 / 0.12)))`,badgePink:`var(--openui-intelligent-badge-pink, var(--openui-text-pink-primary, oklch(0.459 0.17 3.815)))`,badgePinkSoft:`var(--openui-intelligent-badge-pink-soft, var(--openui-pink-background, oklch(0.592 0.218 0.584 / 0.12)))`,chart1:`var(--openui-intelligent-chart-1, #0285ff)`,chart2:`var(--openui-intelligent-chart-2, #00a67d)`,chart3:`var(--openui-intelligent-chart-3, #8b5cf6)`,chart4:`var(--openui-intelligent-chart-4, #f4a340)`,chart5:`var(--openui-intelligent-chart-5, #e46d91)`,chart6:`var(--openui-intelligent-chart-6, #4b9ca6)`,spaceTight:`var(--openui-intelligent-space-tight, 4px)`,spaceInner:`var(--openui-intelligent-space-inner, 8px)`,spaceGroup:`var(--openui-intelligent-space-group, 12px)`,spaceGroupLg:`var(--openui-intelligent-space-group-lg, 16px)`,spaceSection:`var(--openui-intelligent-space-section, 24px)`,controlGap:`var(--openui-intelligent-control-gap, 8px)`,fieldGap:`var(--openui-intelligent-field-gap, 24px)`,actionGap:`var(--openui-intelligent-action-gap, 40px)`,radiusSm:`var(--openui-intelligent-radius-sm, 6px)`,radiusMd:`var(--openui-intelligent-radius-md, 10px)`,radiusLg:`var(--openui-intelligent-radius-lg, 12px)`,radiusXl:`var(--openui-intelligent-radius-xl, 14px)`,photoEmpty:`var(--openui-intelligent-photo-empty, var(--openui-intelligent-surface, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 4%, transparent)))`,photoEmptyIcon:`var(--openui-intelligent-photo-empty-icon, var(--openui-intelligent-border-strong, color-mix(in srgb, var(--openui-intelligent-ink, var(--openui-text-neutral-primary, oklch(0.097 0 0))) 10%, transparent)))`},be={intelligentMono:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,intelligentChart1:`#0285ff`,intelligentChart2:`#00a67d`,intelligentChart3:`#8b5cf6`,intelligentChart4:`#f4a340`,intelligentChart5:`#e46d91`,intelligentChart6:`#4b9ca6`,intelligentSpaceTight:`4px`,intelligentSpaceInner:`8px`,intelligentSpaceGroup:`12px`,intelligentSpaceGroupLg:`16px`,intelligentSpaceSection:`24px`,intelligentControlGap:`8px`,intelligentFieldGap:`24px`,intelligentActionGap:`40px`,intelligentRadiusSm:`6px`,intelligentRadiusMd:`10px`,intelligentRadiusLg:`12px`,intelligentRadiusXl:`14px`},xe={...be},Se={...be},Ce=Symbol(`OpenUI.IntelligentTheme`);function we(){return ee(Ce,null)}function Te(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/([A-Z])([A-Z])/g,`$1-$2`).replace(/([a-z])(\d)/g,`$1-$2`).toLowerCase()}function Ee(e){let t={},n={};for(let[r,i]of Object.entries(e??{}))r.startsWith(`intelligent`)&&r.length>11?typeof i==`string`&&(n[r]=i):t[r]=i;return{components:t,intelligent:n}}function De(e){return Object.entries(e).filter(([,e])=>typeof e==`string`).map(([e,t])=>`--openui-${Te(e)}: ${t};`).join(` `)}function Oe(e){return e.replace(/[^a-zA-Z0-9-_]/g,``)}const ke=f({name:`OpenUIIntelligentVariables`,props:{id:{type:String,required:!0},scope:{type:String,required:!0},mode:{type:String,required:!0},theme:{type:Object,required:!0}},setup(e){let{portalThemeClassName:t}=l(),n=d(()=>{let n=`color-scheme: ${e.mode}; color: var(--openui-text-neutral-primary); font-family: ${w.font}; ${De(e.theme)}`,r=[`.${e.scope}`];return t.value&&r.push(`.${t.value}`),`${r.join(`, `)} { ${n} }`}),r,i=()=>{if(typeof document>`u`||r?.textContent===n.value)return;r?.remove(),r=document.createElement(`style`);let t=window.__nonce__;t&&(r.nonce=t),r.setAttribute(`data-openui-intelligent-theme`,e.id),r.textContent=n.value,document.head.appendChild(r)};return te(i),re(i),m(()=>r?.remove()),()=>(n.value,null)}}),Ae=f({name:`OpenUIIntelligentThemeProvider`,inheritAttrs:!1,props:{mode:String,lightTheme:Object,darkTheme:Object},setup(e,{slots:t}){let n=Oe(c()),r=ee(Ce,null),{mode:i}=l(),a=d(()=>e.mode??r?.mode.value??i.value??`light`),o=`openui-intelligent-theme-${n}`,u=d(()=>({light:{...r?.overrides.value.light,...e.lightTheme},dark:{...r?.overrides.value.dark,...e.darkTheme??e.lightTheme}})),f=d(()=>Ee(u.value.light)),m=d(()=>Ee(u.value.dark)),te=d(()=>a.value===`light`?{...xe,...f.value.intelligent}:{...Se,...m.value.intelligent});return ie(Ce,{mode:a,theme:te,overrides:u}),()=>p(`div`,{class:o,"data-openui-intelligent-mode":a.value,style:{display:`contents`}},[p(s,{mode:a.value,cssSelector:`.${o}`,lightTheme:f.value.components,darkTheme:m.value.components},{default:()=>[p(ke,{id:n,scope:o,mode:a.value,theme:te.value}),t.default?.()]})])}}),je=f({name:`OpenUIIntelligentRootTheme`,inheritAttrs:!1,setup(e,{slots:t}){let n=ee(Ce,null);return()=>n?t.default?.():p(Ae,null,{default:()=>t.default?.()})}}),Me=/(url|image|image-set|cross-fade|element|expression|paint|var|attr|env)\s*\(|@import|[\\;{}<>]/i,Ne=e=>!Me.test(e),Pe=[`info`,`success`,`warning`,`danger`,`purple`,`pink`],Fe={ink:w.ink,muted:w.muted,faint:w.faint,canvas:w.canvas,surface:w.surface,...Object.fromEntries(Pe.map(e=>[e,w[e]])),chart1:w.chart1,chart2:w.chart2,chart3:w.chart3,chart4:w.chart4,chart5:w.chart5,chart6:w.chart6},Ie={...Fe,surface:w.surface,"surface-strong":w.surfaceStrong,border:w.border,...Object.fromEntries(Pe.map(e=>[e,w[`${e}Soft`]]))},Le=e=>typeof e==`string`&&e.trim()&&Ne(e)?e.trim():void 0,T=e=>typeof e==`string`?Fe[e]??Le(e):void 0,Re=e=>typeof e==`string`?Ie[e]??Le(e):void 0,ze=e=>e in Ie,E=e=>typeof e==`number`&&Number.isFinite(e)?`${Math.max(0,e)*4}px`:void 0;function D(e){if(typeof e==`number`&&Number.isFinite(e))return`${Math.max(0,e)}px`;if(typeof e==`string`)return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:/^\d+(\.\d+)?(px|%|em|rem|vh|vw|fr)$|^auto$/.test(e.trim())?e.trim():void 0}const Be={sm:w.radiusSm,md:w.radiusMd,lg:w.radiusLg,xl:w.radiusXl,full:`999px`},Ve=e=>typeof e==`string`?Be[e]:D(e),He={start:`flex-start`,end:`flex-end`,center:`center`,stretch:`stretch`,between:`space-between`},Ue=(e,t=!1)=>({gap:E(e.gap),alignItems:e.align?He[e.align]:void 0,justifyContent:e.justify?He[e.justify]:void 0,flexWrap:e.wrap?`wrap`:void 0,textAlign:t&&(e.align===`center`||e.align===`end`)?e.align:void 0}),We=/* @__PURE__ */ new Map,Ge=f({name:`OpenUIIntelligentLucideIcon`,props:{name:{type:String,required:!0},size:{type:Number,default:16},color:String},setup(e){let t=ae(null);return oe(()=>e.name,e=>{if(!e){t.value=null;return}let n=We.get(e);if(n){t.value=n;return}let r=ve(e);if(!r){t.value=null;return}let i=!1;return r().then(n=>{if(i)return;let r=n?.default;r&&(We.set(e,r),t.value=r)}).catch(()=>{i||(t.value=null)}),()=>{i=!0}},{immediate:!0}),()=>{let n=t.value,r=T(e.color)??`currentColor`;return n?p(n,{size:e.size,color:r,style:{display:`inline-block`,flexShrink:0,verticalAlign:`middle`}}):p(`span`,{class:`openui-intelligent-icon-placeholder`,"data-icon":e.name,"aria-hidden":`true`,style:{display:`inline-block`,width:`${e.size}px`,height:`${e.size}px`,verticalAlign:`middle`}})}}}),Ke=e=>(e?.innerText??``).replace(/\s+/g,` `).trim().slice(0,120),O=e=>e==null?``:String(e),qe=e=>typeof e!=`number`||!Number.isFinite(e)?``:e.toLocaleString(`en-US`,{maximumFractionDigits:2}),Je=C.object({text:C.string(),color:C.enum([`neutral`,`info`,`success`,`warning`,`danger`,`purple`,`pink`]).optional(),icon:C.string().optional()}),Ye={neutral:{bg:w.badgeNeutralSoft,fg:w.ink},info:{bg:w.infoSoft,fg:w.info},success:{bg:w.badgeSuccessSoft,fg:w.badgeSuccess},warning:{bg:w.badgeWarningSoft,fg:w.badgeWarning},danger:{bg:w.badgeDangerSoft,fg:w.badgeDanger},purple:{bg:w.badgePurpleSoft,fg:w.badgePurple},pink:{bg:w.badgePinkSoft,fg:w.badgePink}},Xe=_({name:`Badge`,props:Je,description:`Pill tag; icon is an optional leading lucide name.`,component:({props:e})=>{let t=Ye[e.color??`neutral`]??Ye.neutral;return p(`span`,{class:`openui-intelligent-badge`,style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,padding:`2px 8px`,borderRadius:`999px`,fontSize:`12px`,fontWeight:500,lineHeight:1.4,background:t.bg,color:t.fg,verticalAlign:`middle`}},[e.icon?p(Ge,{name:e.icon,size:12}):null,O(e.text)])}});function Ze(e){if(typeof e!=`string`||ze(e))return;let t=null,n=/^#([\da-f]{3}|[\da-f]{6})$/i.exec(e.trim());if(n){let e=n[1].length===3?n[1].replace(/./g,`$&$&`):n[1];t=[0,2,4].map(t=>parseInt(e.slice(t,t+2),16))}else{let n=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());n&&(t=[n[1],n[2],n[3]].map(Number))}if(!t)return;let[r,i,a]=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a>.36?`#0d0d0d`:`#ffffff`}const Qe=e=>`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='${e}' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5'/%3E%3C/svg%3E")`;function $e(e){let t=Ze(e);if(!t)return{};let n=t!==`#ffffff`;return{color:t,"--openui-intelligent-ink":t,"--openui-intelligent-muted":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-faint":`color-mix(in srgb, ${t} 55%, transparent)`,"--openui-text-neutral-primary":t,"--openui-text-neutral-secondary":`color-mix(in srgb, ${t} 72%, transparent)`,"--openui-intelligent-on-ink":n?`#ffffff`:`#0d0d0d`,"--_openui-intelligent-pressable-check-icon":Qe(n?`white`:`%230d0d0d`)}}function et(e){try{return new URL(e.trim()).protocol}catch{return null}}function tt(e){if(typeof e!=`string`)return null;let t=et(e);return t===`http:`||t===`https:`?e.trim():null}const nt=C.any();b(nt,`Node`);const k=C.array(nt),A=C.string();b(A,`Color`);const j=C.union([C.number(),C.string()]);b(j,`Length`);const rt=C.union([C.enum([`sm`,`md`,`lg`,`xl`,`full`]),C.number()]);b(rt,`Radius`);const it=C.enum([`cover`,`contain`]),M=C.object({required:C.boolean().optional(),email:C.boolean().optional(),url:C.boolean().optional(),numeric:C.boolean().optional(),min:C.number().optional(),max:C.number().optional(),minLength:C.number().optional(),maxLength:C.number().optional(),pattern:C.string().optional()});b(M,`Rules`);const at=C.union([C.string(),C.object({value:C.string(),label:C.string()})]);function ot(e){if(e==null)return null;if(typeof e!=`object`)return{value:String(e),label:String(e)};let{value:t,label:n,description:r}=e,i=n??t;return i==null?null:{value:String(t??n),label:String(i),...typeof r==`string`&&{description:r}}}const st=C.enum([`start`,`center`,`end`,`stretch`]),ct=C.enum([`start`,`center`,`end`,`between`]),lt=C.union([C.string(),k]),ut=/(\*\*([^*]+)\*\*|\*([^*]+)\*|`([^`]+)`|\[([^\]]+)\]\(([^)]+)\))/g;function N(e){if(!e)return``;let t=[],n=0;ut.lastIndex=0;let r;for(;(r=ut.exec(e))!==null;){if(r.index>n&&t.push(e.slice(n,r.index)),r[2]!==void 0)t.push(p(`strong`,null,r[2]));else if(r[3]!==void 0)t.push(p(`em`,null,r[3]));else if(r[4]!==void 0)t.push(p(`code`,{style:{fontFamily:w.mono,fontSize:`0.88em`,padding:`0.1em 0.35em`,borderRadius:w.radiusSm,background:w.surface}},r[4]));else if(r[5]!==void 0&&r[6]!==void 0){let e=tt(r[6]);e?t.push(p(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,style:{color:w.info,textDecoration:`underline`}},r[5])):t.push(r[5])}n=ut.lastIndex}return n<e.length&&t.push(e.slice(n)),t.length===1?t[0]:t}const P=(e,t)=>typeof e==`string`||typeof e==`number`?N(String(e)):t(Array.isArray(e)?e.flat():e),dt=e=>!!e&&typeof e==`object`&&e.type===`element`,ft=C.object({children:k.optional(),direction:C.enum([`row`,`col`]).optional(),gap:C.number().optional(),padding:C.number().optional(),background:A.optional(),radius:rt.optional(),border:C.boolean().optional(),width:j.optional(),height:j.optional(),flex:C.number().optional(),align:st.optional(),justify:ct.optional(),wrap:C.boolean().optional()}),pt=_({name:`Box`,props:ft,description:`Flex container, a column by default. radius also clips the content.`,component:({props:e,renderNode:t})=>{let n=e.direction!==`row`,r=Ve(e.radius),i={display:`flex`,flexDirection:n?`column`:`row`,padding:E(e.padding),background:Re(e.background),borderRadius:r,overflow:r?`hidden`:void 0,border:e.border?`1px solid ${w.border}`:void 0,width:D(e.width),height:D(e.height),flex:typeof e.flex==`number`&&Number.isFinite(e.flex)?e.flex:void 0,...Ue(e,n),...$e(e.background)};return p(`div`,{class:`openui-intelligent-box`,style:i},[t(e.children)])}}),mt=e=>{let t=e?.steps;return!t||t.some(e=>e.type===ce.ToAssistant||e.type===`custom_action`||e.type===ce.Run&&e.refType===`mutation`)};function ht(){let e=_e(),t=he(),n=ge();return(r,i,a)=>{(i||a)&&(!n||i&&!mt(i)||n.validateForm())&&(i?e(r,t.value,i):e(r,t.value))}}function F(e,t,n){let r=ge(),i=d(()=>pe(g(t))),a=d(()=>!!r&&i.value.length>0),o=null;return se(()=>{let t=g(e),a=i.value;o&&o!==t&&(r?.unregisterField(o),o=null),r&&a.length>0?(r.registerField(t,a,()=>g(n)),o=t):o&&=(r?.unregisterField(o),null)}),ne(()=>{o&&=(r?.unregisterField(o),null)}),{required:d(()=>a.value&&i.value.some(e=>e.type===`required`)),error:d(()=>a.value?r?.errors[g(e)]:void 0),check:()=>{a.value&&r&&r.validateField(g(e),g(n),i.value)},clear:()=>{a.value&&r&&r.clearFieldError(g(e))}}}function I(e,t){let n=c();return d(()=>{let r=g(t);if(r)return r;let i=g(e);return typeof i==`string`&&i?i:n})}function L(e){return p(`div`,{class:`openui-intelligent-field`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:w.font}},[e.label?p(`label`,{style:{fontSize:`13px`,fontWeight:500,color:w.ink,display:`inline-flex`,alignItems:`center`,gap:`4px`}},[e.label,e.required?p(`span`,{style:{color:w.danger},"aria-hidden":`true`},`*`):null]):null,e.control,e.error?p(`div`,{role:`alert`,style:{fontSize:`12px`,color:w.danger}},e.error):null])}const gt=C.array(at),_t=e=>Array.isArray(e)?e.flat().flatMap(e=>ot(e)??[]):[],vt=C.union([C.string(),C.object({value:C.string(),label:C.string(),description:C.string().optional()})]),yt=e=>_t(e),bt=C.object({label:C.string(),action:de().optional(),variant:C.enum([`solid`,`outline`,`soft`,`ghost`]).optional(),color:C.enum([`primary`,`danger`,`success`]).optional(),size:C.enum([`sm`,`md`,`lg`]).optional(),icon:C.string().optional(),disabled:C.boolean().optional(),block:C.boolean().optional()}),xt={sm:{padding:`5px 10px`,fontSize:`12px`,borderRadius:w.radiusSm},md:{padding:`8px 14px`,fontSize:`13px`,borderRadius:w.radiusMd},lg:{padding:`10px 18px`,fontSize:`14px`,borderRadius:w.radiusMd}},St=f({name:`OpenUIIntelligentButton`,props:{props:{type:Object,required:!0}},setup(e){let t=ht(),n=x();return()=>{let r=e.props.variant??`solid`,i=e.props.color??`primary`,a=e.props.size??`md`,o=!!(e.props.disabled||n.value),s=O(e.props.label),c=i===`danger`?w.danger:i===`success`?w.success:w.ink,l=i===`danger`?w.dangerSoft:i===`success`?w.successSoft:w.surface,u=r===`solid`?{background:c,color:i===`primary`?w.onInk:`#ffffff`,border:`1px solid transparent`}:r===`outline`?{background:`transparent`,color:c,border:`1px solid ${w.borderStrong}`}:r===`soft`?{background:l,color:c,border:`1px solid transparent`}:{background:`transparent`,color:c,border:`1px solid transparent`};return p(`button`,{type:`button`,disabled:o,class:`openui-intelligent-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,fontFamily:w.font,fontWeight:500,cursor:o?`not-allowed`:`pointer`,opacity:o?.55:1,width:e.props.block?`100%`:void 0,...xt[a],...u},onClick:()=>{o||t(s,e.props.action,!0)}},[e.props.icon?p(Ge,{name:e.props.icon,size:a===`sm`?13:15}):null,s])}}}),Ct=_({name:`Button`,props:bt,description:`icon is a lucide name. Without an action it sends its label to the assistant.`,component:St}),wt=C.object({text:C.string(),color:A.optional()}),Tt=_({name:`Caption`,props:wt,description:`Small secondary text.`,component:({props:e})=>p(`span`,{class:`openui-intelligent-caption`,style:{fontSize:`12px`,lineHeight:1.45,color:T(e.color)??w.muted}},O(e.text))}),Et=C.object({children:k,variant:C.enum([`outline`,`soft`]).optional(),gap:C.number().optional(),padding:C.number().optional()}),Dt=_({name:`Card`,props:Et,description:`Panel with a border; soft is a filled panel for summaries.`,component:({props:e,renderNode:t})=>{let n=e.variant===`soft`;return p(`div`,{class:[`openui-intelligent-card`,n?`openui-intelligent-card--soft`:`openui-intelligent-card--outline`],style:{display:`flex`,flexDirection:`column`,gap:E(e.gap)??w.spaceGroup,padding:E(e.padding)??w.spaceGroupLg,borderRadius:w.radiusLg,background:n?w.surface:w.canvas,border:n?`1px solid transparent`:`1px solid ${w.border}`}},[t(e.children)])}}),Ot=C.object({children:k,itemWidth:C.number().optional(),gap:C.number().optional()}),kt=_({name:`Carousel`,props:Ot,description:`Horizontal row that scrolls and snaps, each child an item itemWidth px wide (default 240): photos, cards, options, days.`,component:({props:e,renderNode:t})=>{let n=typeof e.itemWidth==`number`&&e.itemWidth>0?e.itemWidth:240,r=Array.isArray(e.children)?e.children.flat():[];return p(`div`,{class:`openui-intelligent-carousel`,style:{display:`flex`,flexDirection:`row`,gap:E(e.gap)??w.spaceGroup,overflowX:`auto`,scrollSnapType:`x mandatory`,paddingBottom:`4px`}},r.map((e,r)=>p(`div`,{key:r,style:{flex:`0 0 ${n}px`,maxWidth:`100%`,scrollSnapAlign:`start`}},[t(e)])))}}),At=C.object({when:C.boolean()}),jt=[w.chart1,w.chart2,w.chart3,w.chart4,w.chart5,w.chart6],Mt=f({name:`OpenUIIntelligentCelebration`,props:{props:{type:Object,required:!0}},setup(e){let t=x(),n=h(!1),r=null;return oe(()=>[e.props.when===!0,t.value],([e,t],i)=>{let a=i?.[0]??!1;e&&!t&&!a&&(n.value=!0,r&&clearTimeout(r),r=setTimeout(()=>{n.value=!1},2200))},{immediate:!0}),()=>n.value?p(`div`,{"aria-hidden":`true`,class:`openui-intelligent-celebration`,style:{position:`relative`,height:`12px`,overflow:`visible`,pointerEvents:`none`,display:`flex`,justifyContent:`space-around`}},Array.from({length:12},(e,t)=>p(`span`,{key:t,style:{width:`8px`,height:`8px`,borderRadius:t%2==0?`999px`:`2px`,background:jt[t%jt.length],display:`inline-block`,transform:`rotate(${t*37%360}deg)`}}))):null}}),Nt=_({name:`Celebration`,props:At,description:`Bursts confetti when its condition turns true, e.g. Celebration($score == 5) at the end of a quiz.`,component:Mt}),Pt=C.object({type:C.enum([`bar`,`line`,`area`,`pie`,`donut`,`scatter`]),data:C.array(C.record(C.string(),C.union([C.string(),C.number()]))),x:C.string().optional(),series:C.array(C.string()).optional(),format:C.enum([`number`,`percent`]).optional(),stacked:C.boolean().optional(),height:C.number().optional()}),Ft=e=>Array.isArray(e)?e.filter(e=>e&&typeof e==`object`):[],It=(e,t)=>{if(t)return t;let n=e[0]??{};return Object.keys(n).find(e=>typeof n[e]==`string`)??Object.keys(n)[0]??``},Lt=(e,t,n)=>{if(n?.length)return n;let r=e[0]??{};return Object.keys(r).filter(e=>e!==t&&typeof r[e]==`number`)},Rt=(e,t,n)=>e.map(e=>{let r={[t]:e[t]??``};for(let t of n)r[t]=typeof e[t]==`number`?e[t]:0;return r}),zt=[`intelligentChart1`,`intelligentChart2`,`intelligentChart3`,`intelligentChart4`,`intelligentChart5`,`intelligentChart6`];function Bt(e,t){let n=e?.theme.value??xe,r=zt.map(e=>n[e]??xe[e]??`#0285ff`),i=Array.from({length:Math.max(t,1)},(e,t)=>r[t%r.length]);return i.length>2&&i.length%2==0&&i.unshift(i.pop()),i}const Vt=f({name:`OpenUIIntelligentChart`,props:{props:{type:Object,required:!0}},setup(n){let i=we();return()=>{let s=Ft(n.props.data),c=It(s,n.props.x),l=Lt(s,c,n.props.series),u=typeof n.props.height==`number`?n.props.height:void 0;if(!s.length||!c)return null;if(n.props.type===`pie`||n.props.type===`donut`)return p(a,{data:s,categoryKey:c,dataKey:l[0]??``,variant:n.props.type,format:n.props.format===`percent`?`percentage`:`number`,customPalette:Bt(i,s.length),isAnimationActive:!1});if(n.props.type===`scatter`){let e=l.map(e=>({name:e,data:s.map(t=>({x:Number(t[c]??0),y:Number(t[e]??0)}))}));return p(o,{data:e,xAxisDataKey:`x`,yAxisDataKey:`y`,height:u,customPalette:Bt(i,e.length),isAnimationActive:!1})}let d={data:Rt(s,c,l),categoryKey:c,height:u,customPalette:Bt(i,l.length),isAnimationActive:!1};return n.props.type===`line`?p(r,d):n.props.type===`area`?p(e,{...d,stacked:n.props.stacked===!0}):p(t,{...d,variant:n.props.stacked?`stacked`:`grouped`})}}}),Ht=_({name:`Chart`,props:Pt,description:`Rows of data; x is the category key (a number key for scatter), series the value keys (default: every number key). format applies to pie and donut only: "percent" shows each slice as a share of the total, "number" its value. stacked stacks bar and area series. height sets the plot height in px; pie and donut ignore it and size themselves.`,component:Vt}),Ut=C.object({checked:y(C.boolean()),label:C.string(),lineThrough:C.boolean().optional(),rules:M.optional()}),Wt=f({name:`OpenUIIntelligentCheckbox`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.checked),r=F(t,()=>e.props.rules,()=>n.value),i=x();return()=>{let t=n.value===!0;return p(`div`,{class:`openui-intelligent-checkbox`,style:{display:`flex`,flexDirection:`column`,gap:`4px`}},[p(`label`,{style:{display:`inline-flex`,alignItems:`center`,gap:`8px`,cursor:i.value?`not-allowed`:`pointer`,fontSize:`14px`,color:t&&e.props.lineThrough?w.muted:w.ink,textDecoration:t&&e.props.lineThrough?`line-through`:void 0}},[p(`input`,{type:`checkbox`,checked:t,disabled:i.value,style:{width:`16px`,height:`16px`,accentColor:w.ink},onChange:e=>{r.clear(),n.setValue(e.target.checked)}}),p(`span`,null,[O(e.props.label),r.required.value?p(`span`,{style:{color:w.danger,marginLeft:`4px`}},`*`):null])]),r.error.value?p(`div`,{role:`alert`,style:{fontSize:`12px`,color:w.danger}},r.error.value):null])}}}),Gt=_({name:`Checkbox`,props:Ut,description:`lineThrough strikes the label when checked, for to-do lists. rules takes only required.`,component:Wt}),Kt=C.object({code:C.string(),language:C.string().optional()}),qt=_({name:`Code`,props:Kt,description:`Code block with a copy button.`,component:({props:e})=>p(n,{language:O(e.language)||`text`,codeString:O(e.code)})}),Jt=C.object({children:k,gap:C.number().optional(),align:st.optional()}),Yt=f({name:`OpenUIIntelligentCol`,inheritAttrs:!1,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){return()=>{let t=p(`div`,{class:`openui-intelligent-col`,style:{display:`flex`,flexDirection:`column`,gap:e.props.gap===void 0?w.spaceGroup:void 0,...Ue(e.props,!0)}},e.renderNode(e.props.children));return e.statementId===`root`?p(je,null,{default:()=>t}):t}}}),Xt=_({name:`Col`,props:Jt,description:`Vertical layout. Without gap it spaces blocks like an article.`,component:Yt}),Zt=C.object({value:y(C.string()),label:C.string().optional(),min:C.string().optional(),max:C.string().optional(),rules:M.optional()}),Qt=f({name:`OpenUIIntelligentDatePicker`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=x();return()=>L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:p(`input`,{type:`date`,value:n.value==null?``:String(n.value),min:e.props.min?O(e.props.min):void 0,max:e.props.max?O(e.props.max):void 0,disabled:i.value,class:`openui-intelligent-date-picker`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:w.font,color:w.ink,background:w.canvas,border:`1px solid ${r.error.value?w.danger:w.borderStrong}`,borderRadius:w.radiusMd,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}),$t=_({name:`DatePicker`,props:Zt,description:`Dates, min and max are "YYYY-MM-DD". rules takes only required.`,component:Qt}),en=C.object({}),tn=_({name:`Divider`,props:en,description:`A thin horizontal rule between blocks.`,component:()=>p(`hr`,{class:`openui-intelligent-divider`,style:{border:`none`,borderTop:`1px solid ${w.border}`,margin:`4px 0`,width:`100%`}})}),nn=C.object({front:lt,back:lt,hint:C.string().optional()}),rn=f({name:`OpenUIIntelligentFlashcard`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=h(!1);return()=>{let n=t.value?e.props.back:e.props.front,r=typeof n==`string`?p(`div`,{style:{fontSize:`20px`,fontWeight:600,color:w.ink,textAlign:`center`}},n):P(n,e.renderNode),i=O(e.props.hint);return p(`button`,{type:`button`,"aria-pressed":t.value,class:[`openui-intelligent-flashcard`,t.value?`openui-intelligent-flashcard--back`:`openui-intelligent-flashcard--front`],style:{width:`100%`,minHeight:`140px`,padding:`20px`,borderRadius:w.radiusLg,border:`1px solid ${w.borderStrong}`,background:t.value?w.surface:w.canvas,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`10px`,cursor:`pointer`,font:`inherit`,color:w.ink},onClick:()=>{t.value=!t.value}},[r,!t.value&&i?p(`span`,{style:{fontSize:`12px`,color:w.muted}},i):p(`span`,{style:{fontSize:`11px`,color:w.faint}},t.value?`Back · tap to flip`:`Tap to flip`)])}}}),an=_({name:`Flashcard`,props:nn,description:`Card that flips between front and back when tapped. Put several in a Carousel or Grid.`,component:rn}),on=C.object({children:k}),sn=f({name:`OpenUIIntelligentForm`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0},statementId:String},setup(e){let t=c(),n=me();return ie(ue,n),ie(le,()=>e.statementId??t),()=>p(`form`,{class:`openui-intelligent-form`,novalidate:!0,style:{display:`flex`,flexDirection:`column`,gap:w.spaceGroupLg},onSubmit:e=>{e.preventDefault()}},e.renderNode(e.props.children))}}),cn=_({name:`Form`,props:on,description:`Groups fields; their values go with any @ToAssistant inside, once every field's rules pass.`,component:sn}),ln=C.object({children:k,columns:C.number().optional(),minChildWidth:C.number().optional(),gap:C.number().optional()}),un=_({name:`Grid`,props:ln,description:`Equal columns, 1 to 12 (default 2). With minChildWidth (px), columns drop on narrow screens.`,component:({props:e,renderNode:t})=>{let n=typeof e.columns==`number`&&Number.isFinite(e.columns)?Math.min(12,Math.max(1,Math.round(e.columns))):2,r=typeof e.minChildWidth==`number`&&e.minChildWidth>0?Math.round(e.minChildWidth):void 0,i=r?`repeat(auto-fit, minmax(min(${r}px, 100%), 1fr))`:`repeat(${n}, minmax(0, 1fr))`;return p(`div`,{class:`openui-intelligent-grid`,style:{display:`grid`,gridTemplateColumns:i,gap:E(e.gap)??w.spaceGroup}},[t(e.children)])}});function dn(){let e=we(),t=l();return d(()=>e?.mode.value??t.mode.value??`light`)}const fn=C.object({html:C.string(),height:C.number().optional(),title:C.string().optional()}),pn=`https://cdn.jsdelivr.net https://unpkg.com https://cdnjs.cloudflare.com https://esm.sh`,mn=[`default-src 'none'`,`script-src 'unsafe-inline' ${pn}`,`style-src 'unsafe-inline' ${pn} https://fonts.googleapis.com`,`font-src https://fonts.gstatic.com data:`,`img-src data: blob: https:`,`media-src data: blob:`,`connect-src ${pn}`,`frame-src 'none'`,`form-action 'none'`,`base-uri 'none'`].join(`; `),hn=2400;function gn(e,t){return`<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${mn}"><meta name="viewport" content="width=device-width,initial-scale=1"><style>:root{color-scheme:${t}}html,body{margin:0}body{font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}</style><script>(function(){var last=0;function send(){var h=Math.ceil(document.documentElement.getBoundingClientRect().height);if(Math.abs(h-last)>1){last=h;parent.postMessage({type:"openui-intelligent-html-view-height",height:h},"*")}}addEventListener("message",function(e){if(e.source===parent&&e.data==="openui-intelligent-html-view-measure"){last=0;send()}});addEventListener("load",send);new ResizeObserver(send).observe(document.documentElement);send()})()<\/script>${e}`}const _n=f({name:`OpenUIIntelligentHtmlView`,props:{props:{type:Object,required:!0}},setup(e){let t=x(),n=dn(),r=h(null),i=h(null),a=d(()=>typeof e.props.height==`number`&&e.props.height>0?Math.min(hn,Math.max(80,e.props.height)):null),o=d(()=>gn(typeof e.props.html==`string`?e.props.html:``,n.value)),s=e=>{if(a.value!==null||e.source!==r.value?.contentWindow)return;let t=e.data;t?.type===`openui-intelligent-html-view-height`&&typeof t.height==`number`&&Number.isFinite(t.height)&&(i.value=Math.min(hn,Math.max(80,t.height)))};return te(()=>{typeof window<`u`&&(window.addEventListener(`message`,s),r.value?.contentWindow?.postMessage(`openui-intelligent-html-view-measure`,`*`))}),m(()=>{typeof window<`u`&&window.removeEventListener(`message`,s)}),()=>{let n=a.value??i.value??360;return p(`div`,{class:`openui-intelligent-html-view`,style:{width:`100%`,height:`${n}px`,borderRadius:w.radiusMd,border:`1px solid ${w.border}`,overflow:`hidden`,background:w.surface}},t.value?[p(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,color:w.muted,fontSize:`13px`}},`Preparing the interactive view…`)]:[p(`iframe`,{ref:r,title:e.props.title||`Interactive view`,sandbox:`allow-scripts`,srcdoc:o.value,referrerpolicy:`no-referrer`,loading:`lazy`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})])}}}),vn=_({name:`HtmlView`,props:fn,description:`Sandboxed HTML page with inline JS, for games and canvas. No network except script CDNs. Fits its content unless height is set.`,component:_n}),yn=C.object({name:C.string(),size:C.enum([`sm`,`md`,`lg`,`xl`]).optional(),color:A.optional()}),bn={sm:14,md:18,lg:22,xl:28},xn=_({name:`Icon`,props:yn,description:`Lucide icon by name, e.g. "map-pin".`,component:({props:e})=>p(Ge,{name:O(e.name),size:bn[e.size??`md`]??18,color:e.color})}),Sn=C.object({icon:C.string(),action:de().optional(),label:C.string().optional(),variant:C.enum([`outline`,`ghost`,`solid`]).optional()}),Cn=f({name:`OpenUIIntelligentIconButton`,props:{props:{type:Object,required:!0}},setup(e){let t=ht(),n=x();return()=>{let r=e.props.variant??`outline`,i=O(e.props.label)||O(e.props.icon),a=n.value,o=r===`solid`?{background:w.ink,color:w.onInk,border:`1px solid transparent`}:r===`ghost`?{background:`transparent`,color:w.ink,border:`1px solid transparent`}:{background:w.canvas,color:w.ink,border:`1px solid ${w.borderStrong}`};return p(`button`,{type:`button`,disabled:a,"aria-label":i,title:i,class:`openui-intelligent-icon-button`,style:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`34px`,height:`34px`,borderRadius:`999px`,cursor:a?`not-allowed`:`pointer`,opacity:a?.55:1,...o},onClick:()=>{a||t(i,e.props.action,!1)}},[p(Ge,{name:O(e.props.icon),size:16})])}}}),wn=_({name:`IconButton`,props:Sn,description:`Round icon-only button; label is read aloud. Needs an action.`,component:Cn}),Tn=C.object({src:C.string(),alt:C.string(),aspectRatio:C.number().optional(),radius:rt.optional(),fit:it.optional()}),En=f({name:`OpenUIIntelligentImage`,props:{props:{type:Object,required:!0}},setup(e){let t=h(!1);return()=>{let n=tt(e.props.src),r=typeof e.props.aspectRatio==`number`&&Number.isFinite(e.props.aspectRatio)?Math.min(5,Math.max(.2,e.props.aspectRatio)):1.5,i=Ve(e.props.radius)??w.radiusMd,a={width:`100%`,aspectRatio:String(r),borderRadius:i,overflow:`hidden`,background:w.photoEmpty,display:`flex`,alignItems:`center`,justifyContent:`center`};return!n||t.value?p(`div`,{role:`img`,"aria-label":O(e.props.alt)||`Image unavailable`,class:`openui-intelligent-image openui-intelligent-image--empty`,style:a},[p(`span`,{style:{fontSize:`12px`,color:w.muted}},O(e.props.alt)||`Image`)]):p(`div`,{class:`openui-intelligent-image`,style:a},[p(`img`,{src:n,alt:O(e.props.alt),loading:`lazy`,referrerpolicy:`no-referrer`,style:{width:`100%`,height:`100%`,objectFit:e.props.fit===`contain`?`contain`:`cover`,display:`block`},onError:()=>{t.value=!0}})])}}}),Dn=_({name:`Image`,props:Tn,description:`Photo from a URL the user or a tool gave; never invent a URL. If it fails to load, an empty photo placeholder shows. aspectRatio is 0.2 to 5 (default 1.5).`,component:En}),On=C.object({value:y(C.union([C.string(),C.number()])),label:C.string().optional(),type:C.enum([`text`,`number`]).optional(),placeholder:C.string().optional(),rules:M.optional()}),kn=f({name:`OpenUIIntelligentInput`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=x();return()=>{let t=e.props.type===`number`,a=n.value==null?``:String(n.value);return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:p(`input`,{type:t?`number`:`text`,value:a,placeholder:e.props.placeholder?O(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-input`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:w.font,color:w.ink,background:w.canvas,border:`1px solid ${r.error.value?w.danger:w.borderStrong}`,borderRadius:w.radiusMd,outline:`none`,boxSizing:`border-box`},onInput:e=>{let i=e.target.value;if(r.clear(),t){if(i.trim()===``)n.setValue(null);else{let e=Number(i);n.setValue(Number.isFinite(e)?e:null)}}else n.setValue(i)},onBlur:()=>r.check()})})}}}),An=_({name:`Input`,props:On,description:`Text or number field; a number field stores numbers, and null when emptied.`,component:kn}),jn=C.object({text:C.string()}),Mn=_({name:`Label`,props:jn,description:`Field or group label.`,component:({props:e})=>p(`span`,{class:`openui-intelligent-label`,style:{fontSize:`12px`,fontWeight:600,letterSpacing:`0.02em`,color:w.muted}},O(e.text))}),Nn=C.object({text:C.string(),url:C.string()}),Pn=_({name:`Link`,props:Nn,description:`Opens an http(s) URL in a new tab.`,component:({props:e})=>{let t=tt(e.url),n=O(e.text);return t?p(`a`,{class:`openui-intelligent-link`,href:t,target:`_blank`,rel:`noopener noreferrer`,style:{color:w.info,textDecoration:`underline`,textUnderlineOffset:`2px`}},n):p(`span`,{class:`openui-intelligent-link`},n)}}),Fn=C.object({title:C.string(),description:C.string().optional(),marker:C.string().optional(),children:k.optional()});function In(e){return C.object({items:C.array(C.union([C.string(),e.ref])),marker:C.enum([`bullet`,`number`,`none`]).optional(),timeline:C.boolean().optional()})}function Ln(e,t){return p(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`4px`,minWidth:0,flex:1}},[p(`div`,{style:{fontWeight:500,color:w.ink,lineHeight:1.45}},[N(O(e.title))]),e.description?p(`div`,{style:{fontSize:`13px`,color:w.muted,lineHeight:1.45}},[N(O(e.description))]):null,e.children?p(`div`,{style:{marginTop:`4px`}},[t(e.children)]):null])}const Rn=_({name:`ListItem`,props:Fn,description:`marker replaces the bullet or number, e.g. a time or an emoji.`,component:({props:e,renderNode:t})=>p(`div`,{class:`openui-intelligent-list-item`,style:{display:`flex`,gap:`8px`,alignItems:`flex-start`}},[typeof e.marker==`string`&&e.marker?p(`span`,{style:{fontSize:`12px`,color:w.muted,flexShrink:0}},e.marker):null,Ln(e,t)])}),zn=e=>dt(e)&&e.typeName===`ListItem`,Bn=_({name:`List`,props:In(Rn),description:`timeline joins the markers with a line.`,component:({props:e,renderNode:t})=>{let n=(Array.isArray(e.items)?e.items.flat():[]).filter(e=>e!=null),r=e.marker??`bullet`,i=e.timeline===!0;return p(r===`number`?`ol`:`ul`,{class:[`openui-intelligent-list`,i?`openui-intelligent-list--timeline`:null],style:{listStyle:`none`,margin:0,padding:0,display:`flex`,flexDirection:`column`,gap:i?`12px`:`8px`}},n.map((e,n)=>{let a=zn(e)?e.props:null,o=a&&typeof a.marker==`string`?a.marker:void 0,s=o??(r===`none`?null:r===`number`?`${n+1}.`:`•`);return p(`li`,{key:n,style:{display:`flex`,gap:`10px`,alignItems:`flex-start`,position:`relative`,paddingLeft:i?`4px`:void 0,borderLeft:i?`2px solid ${w.borderStrong}`:void 0}},[s?p(`span`,{style:{minWidth:o?`auto`:`18px`,fontSize:`13px`,color:w.muted,fontWeight:500,flexShrink:0}},s):null,a?Ln(a,t):p(`div`,{style:{flex:1,lineHeight:1.5,color:w.ink}},[N(O(e))])])}))}}),Vn=C.object({text:C.string()}),Hn=_({name:`Markdown`,props:Vn,description:`Prose with headings, lists, quotes, code and tables.`,component:({props:e})=>p(i,{textMarkdown:O(e.text),className:`openui-intelligent-markdown`})}),Un=C.object({tex:C.string(),inline:C.boolean().optional()}),Wn=_({name:`Math`,props:Un,description:`LaTeX formula, e.g. Math("E = mc^2"); inline true to sit in a Text list.`,component:({props:e})=>{let t=O(e.tex),n=e.inline===!0,r=``;try{r=ye.renderToString(t,{displayMode:!n,throwOnError:!1,strict:!1})}catch{return p(n?`span`:`div`,{class:`openui-intelligent-math`},t)}return p(n?`span`:`div`,{class:[`openui-intelligent-math`,n?`openui-intelligent-math--inline`:`openui-intelligent-math--block`],style:n?void 0:{overflowX:`auto`,padding:`4px 0`},innerHTML:r})}}),Gn=C.object({trigger:lt,content:lt}),Kn=f({name:`OpenUIIntelligentPopover`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=h(!1);return()=>p(`span`,{class:`openui-intelligent-popover`,style:{position:`relative`,display:`inline-flex`,alignItems:`center`}},[p(`button`,{type:`button`,"aria-expanded":t.value,onClick:()=>{t.value=!t.value},style:{display:`inline-flex`,alignItems:`center`,gap:`4px`,background:`transparent`,border:`none`,padding:`2px 4px`,cursor:`pointer`,color:`inherit`,font:`inherit`,borderRadius:w.radiusSm}},[P(e.props.trigger,e.renderNode)]),t.value?p(`div`,{role:`dialog`,class:`openui-intelligent-popover-panel`,style:{position:`absolute`,top:`calc(100% + 6px)`,left:0,zIndex:40,minWidth:`200px`,maxWidth:`320px`,padding:w.spaceGroup,borderRadius:w.radiusMd,background:w.canvas,color:w.ink,border:`1px solid ${w.borderStrong}`,boxShadow:w.shadow}},[P(e.props.content,e.renderNode)]):null])}}),qn=_({name:`Popover`,props:Gn,description:`Shows content in a small panel when the trigger is clicked: a definition, a source, details behind an Icon("info", "sm"). The trigger is text or an Icon, never a Button: it is a button already.`,component:Kn}),Jn=C.object({children:k,action:de().optional(),selected:C.boolean().optional(),padding:C.number().optional(),background:A.optional(),radius:rt.optional()}),Yn=f({name:`OpenUIIntelligentPressable`,props:{props:{type:Object,required:!0},renderNode:{type:Function,required:!0}},setup(e){let t=ht(),n=x(),r=h(null);return()=>{let i=e.props.selected===!0,a=n.value,o={display:`flex`,flexDirection:`column`,textAlign:`left`,padding:E(e.props.padding)??w.spaceGroup,borderRadius:Ve(e.props.radius)??w.radiusMd,background:Re(e.props.background)??(i?w.surfaceStrong:w.canvas),border:i?`2px solid ${w.ink}`:`1px solid ${w.border}`,cursor:a?`not-allowed`:`pointer`,width:`100%`,font:`inherit`,color:`inherit`,...$e(e.props.background)};return p(`button`,{ref:r,type:`button`,disabled:a,"aria-pressed":i,class:[`openui-intelligent-pressable`,i?`openui-intelligent-pressable--selected`:null],style:o,onClick:()=>{a||t(Ke(r.value),e.props.action,!1)}},e.renderNode(e.props.children))}}}),Xn=_({name:`Pressable`,props:Jn,description:`Makes any content clickable, such as a tile or a swatch. Needs an action.`,component:Yn}),Zn=C.object({text:C.string(),cite:C.string().optional()}),Qn=_({name:`Quote`,props:Zn,description:`A quotation or a callout with a side rule; cite names the source.`,component:({props:e})=>p(`blockquote`,{class:`openui-intelligent-quote`,style:{margin:0,padding:`8px 14px`,borderLeft:`3px solid ${w.borderStrong}`,background:w.surface,borderRadius:`0 ${w.radiusSm} ${w.radiusSm} 0`,display:`flex`,flexDirection:`column`,gap:`6px`}},[p(`div`,{style:{color:w.ink,lineHeight:1.55}},[N(O(e.text))]),e.cite?p(`cite`,{style:{fontSize:`12px`,color:w.muted,fontStyle:`normal`}},`— ${O(e.cite)}`):null])}),$n=C.object({value:y(C.string()),options:C.array(vt),label:C.string().optional(),variant:C.enum([`list`,`pills`,`cards`]).optional(),rules:M.optional()}),er=f({name:`OpenUIIntelligentRadioGroup`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=x();return()=>{let a=yt(e.props.options),o=n.value==null?``:String(n.value),s=e.props.variant??`list`,c=p(`div`,{role:`radiogroup`,class:`openui-intelligent-radio-group openui-intelligent-radio-group--${s}`,style:{display:`flex`,flexDirection:s===`pills`?`row`:`column`,flexWrap:s===`pills`?`wrap`:void 0,gap:`8px`}},a.map(e=>{let a=o===e.value;return s===`pills`?p(`button`,{key:e.value,type:`button`,role:`radio`,"aria-checked":a,disabled:i.value,style:{padding:`6px 12px`,borderRadius:`999px`,fontSize:`13px`,fontWeight:500,cursor:i.value?`not-allowed`:`pointer`,background:a?w.ink:w.surface,color:a?w.onInk:w.ink,border:`1px solid ${a?w.ink:w.border}`},onClick:()=>{i.value||(r.clear(),n.setValue(e.value))}},e.label):p(`label`,{key:e.value,style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:s===`cards`?`10px 12px`:`4px 0`,borderRadius:s===`cards`?w.radiusMd:void 0,border:s===`cards`?`1px solid ${a?w.ink:w.border}`:void 0,background:s===`cards`&&a?w.surface:void 0,cursor:i.value?`not-allowed`:`pointer`}},[p(`input`,{type:`radio`,name:t.value,value:e.value,checked:a,disabled:i.value,style:{marginTop:`3px`,accentColor:w.ink},onChange:()=>{r.clear(),n.setValue(e.value)}}),p(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[p(`span`,{style:{fontSize:`14px`,fontWeight:s===`cards`?500:400,color:w.ink}},e.label),e.description?p(`span`,{style:{fontSize:`12px`,color:w.muted}},e.description):null])])}));return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:c})}}}),tr=_({name:`RadioGroup`,props:$n,description:`pills for short choices; cards for choices that need a description line.`,component:er}),nr=C.object({children:k,gap:C.number().optional(),align:st.optional(),justify:ct.optional(),wrap:C.boolean().optional()}),rr=_({name:`Row`,props:nr,description:`Horizontal layout; items are vertically centered.`,component:({props:e,renderNode:t})=>p(`div`,{class:`openui-intelligent-row`,style:{display:`flex`,flexDirection:`row`,alignItems:`center`,gap:e.gap===void 0?w.spaceInner:void 0,...Ue(e,!1)}},[t(e.children)])}),ir=C.object({value:y(C.string()),options:gt,block:C.boolean().optional()}),ar=f({name:`OpenUIIntelligentSegmentedControl`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>`segmented`,()=>e.statementId),n=S(t,()=>e.props.value),r=x();return()=>{let t=_t(e.props.options),i=n.value==null?``:String(n.value);return p(`div`,{role:`tablist`,class:`openui-intelligent-segmented`,style:{display:e.props.block?`flex`:`inline-flex`,flexShrink:0,width:e.props.block?`100%`:void 0,padding:`3px`,gap:`2px`,background:w.surface,borderRadius:w.radiusMd,border:`1px solid ${w.border}`}},t.map(t=>{let a=i===t.value;return p(`button`,{key:t.value,type:`button`,role:`tab`,"aria-selected":a,disabled:r.value,style:{flex:e.props.block?`1 1 0%`:`0 0 auto`,padding:`6px 12px`,fontSize:`13px`,fontWeight:a?600:500,fontFamily:w.font,whiteSpace:`nowrap`,borderRadius:w.radiusSm,border:`none`,cursor:r.value?`not-allowed`:`pointer`,background:a?w.canvas:`transparent`,color:a?w.ink:w.muted,boxShadow:a?w.shadowSm:void 0},onClick:()=>{r.value||n.setValue(t.value)}},t.label)}))}}}),or=_({name:`SegmentedControl`,props:ir,description:`2 to 4 short choices in a row.`,component:ar}),sr=C.object({value:y(C.string()),options:gt,label:C.string().optional(),placeholder:C.string().optional(),rules:M.optional()}),cr=f({name:`OpenUIIntelligentSelect`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=x();return()=>{let t=_t(e.props.options),a=n.value==null?``:String(n.value);return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:p(`div`,{style:{position:`relative`,display:`flex`,alignItems:`center`,width:`100%`}},[p(`select`,{value:a,disabled:i.value,class:`openui-intelligent-select`,style:{appearance:`none`,WebkitAppearance:`none`,width:`100%`,padding:`8px 32px 8px 10px`,fontSize:`14px`,fontFamily:w.font,color:w.ink,background:w.canvas,border:`1px solid ${r.error.value?w.danger:w.borderStrong}`,borderRadius:w.radiusMd,boxSizing:`border-box`,cursor:i.value?`not-allowed`:`pointer`},onChange:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()},[e.props.placeholder&&!a?p(`option`,{value:``,disabled:!0},O(e.props.placeholder)):null,...t.map(e=>p(`option`,{key:e.value,value:e.value},e.label))]),p(`svg`,{width:`14`,height:`14`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,style:{position:`absolute`,right:`10px`,pointerEvents:`none`,color:w.muted}},[p(`path`,{d:`M3 4.5L6 7.5L9 4.5`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})])])})}}}),lr=_({name:`Select`,props:sr,description:`Dropdown, for long option lists.`,component:cr}),ur=C.object({value:y(C.number()),min:C.number(),max:C.number(),step:C.number().optional(),label:C.string().optional(),unit:C.string().optional(),marks:C.array(C.object({value:C.number(),label:C.string()})).optional()}),dr=f({name:`OpenUIIntelligentSlider`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.value),r=x();return()=>{let t=typeof e.props.min==`number`&&Number.isFinite(e.props.min)?e.props.min:0,i=typeof e.props.max==`number`&&Number.isFinite(e.props.max)?e.props.max:100,a=typeof e.props.step==`number`&&e.props.step>0?e.props.step:1,o=typeof n.value==`number`&&Number.isFinite(n.value)?n.value:t,s=e.props.unit?O(e.props.unit):``,c=s===`$`||s===`€`||s===`£`||s===`¥`?`${s}${qe(o)}`:`${qe(o)}${s}`;return p(`div`,{class:`openui-intelligent-slider`,style:{display:`flex`,flexDirection:`column`,gap:`6px`,width:`100%`,fontFamily:w.font}},[p(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`baseline`,gap:`8px`}},[e.props.label?p(`span`,{style:{fontSize:`13px`,fontWeight:500,color:w.ink}},O(e.props.label)):p(`span`),p(`span`,{style:{fontSize:`13px`,fontWeight:600,fontVariantNumeric:`tabular-nums`,color:w.ink}},c)]),p(`input`,{type:`range`,min:t,max:i,step:a,value:o,disabled:r.value,style:{width:`100%`,accentColor:w.rangeThumb,cursor:r.value?`not-allowed`:`pointer`},onInput:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n.setValue(t)}}),Array.isArray(e.props.marks)&&e.props.marks.length>0?p(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:`11px`,color:w.muted}},e.props.marks.map((e,t)=>p(`span`,{key:t},O(e.label)))):null])}}}),fr=_({name:`Slider`,props:ur,description:`Shows label and value; unit like "%" or "$" formats the value.`,component:dr}),pr=C.object({}),mr=_({name:`Spacer`,props:pr,description:`Fills the free space in a Row.`,component:()=>p(`div`,{class:`openui-intelligent-spacer`,style:{flex:`1 1 auto`}})}),hr=Symbol(`OpenUI.Intelligent.InSvg`),R=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,gr=e=>R(e)===void 0?void 0:Math.min(1,Math.max(0,e)),_r=/^[\d\s,.eE+-]*$/,vr=/^[MmLlHhVvCcSsQqTtAaZz\d\s,.eE+-]*$/,yr=/^\s*-?\d+(\.\d+)?[\s,]+-?\d+(\.\d+)?[\s,]+\d+(\.\d+)?[\s,]+\d+(\.\d+)?\s*$/,br=(e,t)=>typeof e==`string`&&e.length<2e4&&t.test(e)?e:void 0,z={fill:A.optional(),stroke:A.optional(),strokeWidth:C.number().optional(),opacity:C.number().optional()},B=(e,t)=>({fill:e.fill===void 0?t&&e.stroke===void 0?`currentColor`:`none`:T(e.fill)??`none`,stroke:e.stroke===void 0?t?void 0:`currentColor`:T(e.stroke),"stroke-width":R(e.strokeWidth)??(t?void 0:2),opacity:gr(e.opacity),"stroke-linecap":`round`,"stroke-linejoin":`round`}),xr=f({name:`OpenUIIntelligentSvgCanvas`,props:{viewBox:{type:String,required:!0},label:String,width:[Number,String],height:[Number,String]},setup(e,{slots:t}){return ie(hr,!0),()=>{let n=br(e.viewBox,yr)??`0 0 100 100`;return p(`svg`,{class:`openui-intelligent-svg`,viewBox:n,role:e.label?`img`:void 0,"aria-label":e.label||void 0,"aria-hidden":e.label?void 0:`true`,style:{display:`block`,maxWidth:`100%`,width:D(e.width)??`100%`,height:D(e.height)??`auto`,color:w.ink}},t.default?.())}}}),V=f({name:`OpenUIIntelligentSvgStandalone`,setup(e,{slots:t}){let n=ee(hr,!1);return()=>n?t.default?.():p(xr,{viewBox:`0 0 100 100`,width:160},{default:()=>t.default?.()})}}),Sr=C.object({cx:C.number(),cy:C.number(),r:C.number(),...z}),Cr=_({name:`Circle`,props:Sr,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>p(V,null,{default:()=>p(`circle`,{cx:R(e.cx),cy:R(e.cy),r:Math.max(0,R(e.r)??0),...B(e,!0)})})}),wr=C.object({cx:C.number(),cy:C.number(),rx:C.number(),ry:C.number(),...z}),Tr=_({name:`Ellipse`,props:wr,description:`fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>p(V,null,{default:()=>p(`ellipse`,{cx:R(e.cx),cy:R(e.cy),rx:Math.max(0,R(e.rx)??0),ry:Math.max(0,R(e.ry)??0),...B(e,!0)})})}),Er=C.object({x:C.number(),y:C.number(),width:C.number(),height:C.number(),...z,rx:C.number().optional()}),Dr=_({name:`Rect`,props:Er,description:`rx rounds the corners; fill defaults to the text color, and with only a stroke it stays unfilled.`,component:({props:e})=>p(V,null,{default:()=>p(`rect`,{x:R(e.x),y:R(e.y),width:Math.max(0,R(e.width)??0),height:Math.max(0,R(e.height)??0),rx:R(e.rx),...B(e,!0)})})}),Or=C.object({x1:C.number(),y1:C.number(),x2:C.number(),y2:C.number(),stroke:A.optional(),strokeWidth:C.number().optional(),opacity:C.number().optional()}),kr=_({name:`Line`,props:Or,description:`Stroked in the text color, 2 wide, unless stroke and strokeWidth are set.`,component:({props:e})=>p(V,null,{default:()=>p(`line`,{x1:R(e.x1),y1:R(e.y1),x2:R(e.x2),y2:R(e.y2),...B(e,!1)})})}),Ar={m:2,l:2,t:2,h:1,v:1,c:6,s:4,q:4,a:7,z:0},jr=/^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?/i,Mr=/^[01]/,Nr=e=>{let t=e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*$/i)?.[0];if(!t)return e.trim()===``;let n=Ar[t[0].toLowerCase()],r=t.slice(1),i=0;for(;r=r.replace(/^[\s,]+/,``),r;){let e=i%7,t=(n===7&&(e===3||e===4)?Mr:jr).exec(r);if(!t)return!1;r=r.slice(t[0].length),i++}return/[.eE+-]$/.test(t.trimEnd())?!1:n===0?i===0:i>0&&i%n===0},Pr=C.object({d:C.string(),...z}),Fr=_({name:`Path`,props:Pr,description:`d is SVG path data only (M, L, C, A, Z...), else nothing draws; unfilled unless fill is set.`,component:({props:e})=>{let t=br(e.d,vr);return p(V,null,{default:()=>p(`path`,{d:t!==void 0&&Nr(t)?t:void 0,...B(e,e.fill!==void 0)})})}}),Ir=C.object({points:C.string(),fill:A.optional(),stroke:A.optional(),strokeWidth:C.number().optional(),opacity:C.number().optional()}),Lr=_({name:`Polyline`,props:Ir,description:`points like "0,0 10,5 20,0".`,component:({props:e})=>p(V,null,{default:()=>p(`polyline`,{points:br(e.points,_r),...B(e,!1)})})}),Rr=C.object({points:C.string(),...z}),zr=_({name:`Polygon`,props:Rr,description:`Closed shape; points like "0,0 10,5 20,0". fill defaults to the text color; with only a stroke it stays unfilled.`,component:({props:e})=>p(V,null,{default:()=>p(`polygon`,{points:br(e.points,_r),...B(e,!0)})})}),Br=C.object({text:C.string(),x:C.number(),y:C.number(),size:C.number().optional(),fill:A.optional(),anchor:C.enum([`start`,`middle`,`end`]).optional(),weight:C.enum([`normal`,`medium`,`semibold`]).optional()}),Vr=[Cr,Tr,Dr,kr,Fr,Lr,zr,_({name:`SvgText`,props:Br,description:`A text label at x, y; anchor sets which end sits on x.`,component:({props:e})=>p(V,null,{default:()=>p(`text`,{x:R(e.x),y:R(e.y),"font-size":R(e.size)??12,fill:T(e.fill)??`currentColor`,"text-anchor":e.anchor??`start`,"font-weight":e.weight===`semibold`?640:e.weight===`medium`?560:440,"font-family":w.font},String(e.text??``))})})],Hr=C.array(C.union(Vr.map(e=>e.ref))),Ur={translate:[1,2],rotate:[1,3],scale:[1,2],skewX:[1],skewY:[1],matrix:[6]};function Wr(e){if(typeof e!=`string`||e.length>500)return;let t=[...e.matchAll(/\s*([a-zA-Z]+)\(([^()]*)\)\s*/g)];if(t.length&&t.map(e=>e[0]).join(``)===e)return t.every(([,e,t])=>{let n=t.trim().split(/\s*,\s*|\s+/).filter(Boolean);return(Ur[e]?.includes(n.length)??!1)&&n.every(e=>Number.isFinite(Number(e)))})?e.trim():void 0}const Gr=C.object({children:Hr,transform:C.string().optional(),opacity:C.number().optional()}),Kr=_({name:`G`,props:Gr,description:`Group; transform like "rotate(30 50 50)" or "translate(10 0)"; one with the wrong number of arguments is dropped.`,component:({props:e,renderNode:t})=>p(V,null,{default:()=>p(`g`,{transform:Wr(e.transform),opacity:gr(e.opacity)},[t(e.children)])})}),qr=/* @__PURE__ */ new Set([...Vr.map(e=>e.name),Kr.name]),Jr=C.object({children:C.array(C.union([...Hr.element.options,Kr.ref])),viewBox:C.string(),label:C.string().optional(),width:j.optional(),height:j.optional()}),Yr=[_({name:`Svg`,props:Jr,description:`A drawing for steps, parts, mechanisms, diagrams and layouts. Scales to its width; its shapes take expressions, so state can move them. label says in a few words what it shows, for screen readers: always give one.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.children)?e.children:[],r=e=>dt(e)&&qr.has(String(e.typeName)),i=n.filter(e=>!r(e));return p(u,null,[p(xr,{viewBox:e.viewBox,label:e.label,width:e.width,height:e.height},{default:()=>t(n.filter(r))}),i.length?t(i):null])}}),...Vr,Kr],Xr=C.object({columns:C.array(C.string()),rows:C.array(C.array(C.any()))}),Zr=_({name:`Table`,props:Xr,description:`Each row lists its cells in column order; a cell may be a component. Number columns align right.`,component:({props:e,renderNode:t})=>{let n=Array.isArray(e.columns)?e.columns.map(O):[],r=Array.isArray(e.rows)?e.rows.filter(e=>Array.isArray(e)):[],i=n.map((e,t)=>r.length>0&&r.every(e=>e[t]==null||typeof e[t]==`number`));return p(`div`,{class:`openui-intelligent-table-wrap`,style:{width:`100%`,overflowX:`auto`,border:`1px solid ${w.border}`,borderRadius:w.radiusMd}},[p(`table`,{class:`openui-intelligent-table`,style:{width:`100%`,borderCollapse:`collapse`,fontSize:`13px`,fontFamily:w.font}},[p(`thead`,null,p(`tr`,{style:{background:w.surface,borderBottom:`1px solid ${w.border}`}},n.map((e,t)=>p(`th`,{key:t,style:{padding:`8px 12px`,textAlign:i[t]?`right`:`left`,fontWeight:600,color:w.muted,whiteSpace:`nowrap`}},e)))),p(`tbody`,null,r.map((e,a)=>p(`tr`,{key:a,style:{borderBottom:a<r.length-1?`1px solid ${w.border}`:void 0}},n.map((n,r)=>{let a=e[r],o=dt(a)||Array.isArray(a)?t(a):typeof a==`number`?qe(a):N(O(a));return p(`td`,{key:r,style:{padding:`8px 12px`,textAlign:i[r]?`right`:`left`,fontVariantNumeric:i[r]?`tabular-nums`:void 0,color:w.ink}},[o])}))))])])}}),Qr=C.union([C.string(),k]),$r=C.object({text:Qr,size:C.enum([`xs`,`sm`,`md`,`lg`]).optional(),color:A.optional(),weight:C.enum([`normal`,`medium`,`semibold`]).optional(),italic:C.boolean().optional(),lineThrough:C.boolean().optional(),tabularNums:C.boolean().optional(),maxLines:C.number().optional()}),ei={xs:`12px`,sm:`13px`,md:`14px`,lg:`16px`},ti={normal:400,medium:500,semibold:600},ni=_({name:`Text`,props:$r,description:'Paragraph; supports **bold**, *italic*, `code` and [links](https://…). text may be a list mixing strings and inline components: [Icon("clock", "sm"), " 25 min · ", Badge("Easy")].',component:({props:e,renderNode:t})=>{let n={margin:0,fontSize:ei[e.size??`md`]??`14px`,lineHeight:1.55,color:T(e.color)??w.ink,fontWeight:e.weight?ti[e.weight]:void 0,fontStyle:e.italic?`italic`:void 0,textDecoration:e.lineThrough?`line-through`:void 0,fontVariantNumeric:e.tabularNums?`tabular-nums`:void 0};typeof e.maxLines==`number`&&e.maxLines>0&&(n.display=`-webkit-box`,n.WebkitLineClamp=String(Math.round(e.maxLines)),n.WebkitBoxOrient=`vertical`,n.overflow=`hidden`);let r=Array.isArray(e.text)?e.text.flat().map(e=>P(e,t)):P(e.text,t);return p(`p`,{class:`openui-intelligent-text`,style:n},[r])}}),ri=C.object({value:y(C.string()),label:C.string().optional(),placeholder:C.string().optional(),rows:C.number().optional(),rules:M.optional()}),ii=f({name:`OpenUIIntelligentTextArea`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.value),r=F(t,()=>e.props.rules,()=>n.value),i=x();return()=>{let t=typeof e.props.rows==`number`&&Number.isFinite(e.props.rows)?Math.min(20,Math.max(2,Math.round(e.props.rows))):3;return L({label:e.props.label?O(e.props.label):void 0,required:r.required.value,error:r.error.value,control:p(`textarea`,{rows:t,value:n.value==null?``:String(n.value),placeholder:e.props.placeholder?O(e.props.placeholder):void 0,disabled:i.value,class:`openui-intelligent-textarea`,style:{width:`100%`,padding:`8px 10px`,fontSize:`14px`,fontFamily:w.font,color:w.ink,background:w.canvas,border:`1px solid ${r.error.value?w.danger:w.borderStrong}`,borderRadius:w.radiusMd,outline:`none`,resize:`vertical`,boxSizing:`border-box`},onInput:e=>{r.clear(),n.setValue(e.target.value)},onBlur:()=>r.check()})})}}}),ai=_({name:`TextArea`,props:ri,description:`Multi-line text field; rows is 2 to 20 (default 3).`,component:ii}),oi=C.object({seconds:y(C.number()),label:C.string().optional()});function si(e){let t=Math.max(0,Math.floor(Number.isFinite(e)?e:0)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`}const ci=f({name:`OpenUIIntelligentTimer`,props:{props:{type:Object,required:!0},statementId:String},setup(e){let t=I(()=>e.props.label,()=>e.statementId),n=S(t,()=>e.props.seconds),r=x(),i=h(typeof n.value==`number`&&Number.isFinite(n.value)?n.value:0),a=h(!1),o=null,s=()=>{a.value=!1,o!==null&&(clearInterval(o),o=null)},c=()=>{r.value||a.value||Number(n.value??0)<=0||(a.value=!0,o=setInterval(()=>{let e=Number(n.value??0);e<=1?(n.setValue(0),s()):n.setValue(e-1)},1e3))},l=()=>{s(),n.setValue(i.value)};return m(s),()=>{let t=typeof n.value==`number`?n.value:Number(n.value??0),i=typeof document<`u`&&document.documentElement.lang.toLowerCase().startsWith(`zh`);return p(`div`,{class:`openui-intelligent-timer`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,padding:`12px 14px`,borderRadius:w.radiusMd,background:w.surface,border:`1px solid ${w.border}`}},[p(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`}},[e.props.label?p(`span`,{style:{fontSize:`12px`,color:w.muted}},O(e.props.label)):null,p(`span`,{style:{fontSize:`24px`,fontWeight:700,fontVariantNumeric:`tabular-nums`,color:w.ink}},si(t))]),p(`div`,{style:{display:`flex`,gap:`8px`,flexShrink:0}},[p(`button`,{type:`button`,disabled:r.value||!a.value&&t<=0,onClick:()=>a.value?s():c(),style:{padding:`6px 12px`,borderRadius:w.radiusSm,border:`none`,background:w.ink,color:w.onInk,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},a.value?i?`暂停`:`Pause`:i?`开始`:`Start`),p(`button`,{type:`button`,disabled:r.value,onClick:l,style:{padding:`6px 12px`,borderRadius:w.radiusSm,border:`1px solid ${w.borderStrong}`,background:w.canvas,color:w.ink,fontSize:`13px`,whiteSpace:`nowrap`,cursor:`pointer`}},i?`重置`:`Reset`)])])}}}),li=_({name:`Timer`,props:oi,description:`Countdown with start, pause and reset. It counts the bound seconds down to 0, so other statements can react, e.g. $left == 0.`,component:ci}),ui=C.object({text:C.string(),size:C.enum([`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`]).optional(),color:A.optional()}),di={sm:{fontSize:`14px`,lineHeight:`1.35`,fontWeight:600},md:{fontSize:`16px`,lineHeight:`1.35`,fontWeight:600},lg:{fontSize:`20px`,lineHeight:`1.28`,fontWeight:650},xl:{fontSize:`24px`,lineHeight:`1.22`,fontWeight:650},"2xl":{fontSize:`32px`,lineHeight:`1.15`,fontWeight:700},"3xl":{fontSize:`40px`,lineHeight:`1.1`,fontWeight:700}},fi=_({name:`Title`,props:ui,description:`Heading; md for a card title, lg for a section, 2xl for a big number.`,component:({props:e})=>{let t=di[e.size??`md`]??di.md;return p(`div`,{role:`heading`,"aria-level":e.size===`3xl`||e.size===`2xl`?2:e.size===`xl`||e.size===`lg`?3:4,class:`openui-intelligent-title`,style:{margin:0,color:T(e.color)??w.ink,letterSpacing:`-0.015em`,...t}},O(e.text))}}),pi=C.object({video:C.string(),title:C.string().optional()}),mi=/^[A-Za-z0-9_-]{11}$/;function hi(e){let t=e.trim();if(mi.test(t))return t;try{let e=new URL(t),n=e.hostname.replace(/^www\./,``);if(n===`youtu.be`){let t=e.pathname.slice(1).split(`/`)[0]??``;return mi.test(t)?t:null}if(n===`youtube.com`||n===`m.youtube.com`||n===`youtube-nocookie.com`){let t=e.searchParams.get(`v`);if(t&&mi.test(t))return t;let n=e.pathname.split(`/`).filter(Boolean),r=n[1]??``;if((n[0]===`embed`||n[0]===`shorts`)&&mi.test(r))return r}}catch{return null}return null}const gi=[Xt,rr,pt,un,Dt,kt,qn,tn,mr,fi,ni,Tt,Mn,Xe,Pn,Bn,Rn,Hn,Qn,qt,Wn,Ct,wn,Xn,An,ai,lr,or,fr,Gt,tr,$t,li,cn,Dn,xn,Zr,Ht,_({name:`YouTube`,props:pi,description:`Embedded YouTube video by id or URL. Only a video you know exists.`,component:({props:e})=>{let t=hi(O(e.video));return t?p(`div`,{class:`openui-intelligent-youtube`,style:{width:`100%`,aspectRatio:`16 / 9`,borderRadius:w.radiusMd,overflow:`hidden`,background:w.surface}},[p(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${t}`,title:O(e.title)||`YouTube video`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowfullscreen:!0,loading:`lazy`,referrerpolicy:`strict-origin-when-cross-origin`,style:{width:`100%`,height:`100%`,border:`none`,display:`block`}})]):null}}),an,Nt,...Yr,vn],_i=/^#?([\da-f]{3}|[\da-f]{6})$/i;function vi(e){let t=_i.exec(e.trim());if(!t)throw Error(`not a hex color: ${e}`);let n=t[1].length===3?t[1].replace(/./g,`$&$&`):t[1];return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}const yi=[v({name:`MixColor`,description:`The hex color a fraction t of the way from one hex color to another, e.g. @MixColor("#ffffff", "#0285ff", 0.5) for a heatmap or a tint`,params:C.object({from:C.string(),to:C.string(),t:C.number()}),returns:C.string(),fn:({from:e,to:t,t:n})=>{let r=vi(e),i=vi(t),a=Math.min(1,Math.max(0,n));return`#${r.map((e,t)=>Math.round(e+(i[t]-e)*a).toString(16).padStart(2,`0`)).join(``)}`}})],H=()=>C.array(C.any()),bi=()=>C.array(C.number()),U=()=>C.union([C.string(),C.number()]),xi=()=>C.enum([`sum`,`avg`,`count`,`min`,`max`]);function W(e,t){if(!t)return e;let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function G(e,t){if(e===t)return!0;if(typeof e==`number`&&typeof t==`string`||typeof e==`string`&&typeof t==`number`)return String(e)===String(t);if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e))return e.length===t.length&&e.every((e,n)=>G(e,t[n]));let n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>Object.hasOwn(t,n)&&G(e[n],t[n]))}function K(e){if(!Number.isFinite(e))throw Error(`result is not a finite number`);return e}function q(e){if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:null}return null}function Si(e,t,n){if(n===`count`)return e.length;let r=e.map(e=>q(W(e,t??``))).filter(e=>e!==null);if(!r.length)return 0;switch(n){case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.reduce((e,t)=>e+t,0)/r.length;case`min`:return Math.min(...r);case`max`:return Math.max(...r)}}function J(e,t){let n=/* @__PURE__ */ new Map;for(let r of e){let e=W(r,t),i=typeof e==`number`?e:e==null||e===``?`Unknown`:String(e),a=n.get(i);a?a.push(r):n.set(i,[r])}return n}const Y=1e4,X=864e5,Ci=/^(\d{4})-(\d{2})-(\d{2})$/;function Z(e){if(typeof e==`string`){let t=Ci.exec(e.trim());if(t){let[n,r,i]=[Number(t[1]),Number(t[2]),Number(t[3])],a=Date.UTC(n,r-1,i),o=new Date(a);if(o.getUTCMonth()!==r-1||o.getUTCDate()!==i)throw Error(`invalid date "${e}"`);return{day:a/X,instant:null}}}let t=new Date(e);if(Number.isNaN(t.getTime()))throw Error(`invalid date "${e}"`);return{day:Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/X,instant:t}}function Q(e){return(/* @__PURE__ */ new Date(e*X)).toISOString().slice(0,10)}const wi={date:{month:`short`,day:`numeric`,year:`numeric`},short:{month:`short`,day:`numeric`},long:{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`},weekday:{weekday:`short`},month:{month:`short`,year:`numeric`},time:{hour:`numeric`,minute:`2-digit`},datetime:{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}},Ti=v({name:`Now`,description:`The current date and time as an ISO string`,params:C.object({}),returns:C.string(),fn:()=>(/* @__PURE__ */ new Date()).toISOString()}),Ei=v({name:`FormatDate`,description:`A date as text: "date" Oct 9, 2026 (default), "short" Oct 9, "long" Friday, October 9, 2026, "weekday" Fri, "month" Oct 2026, "time" 9:30 PM, "datetime", "iso" 2026-10-09. Dates are "YYYY-MM-DD", ISO or a timestamp; "time" and "datetime" need a timestamp or an ISO date-time, as a plain date has no time`,params:C.object({date:U(),style:C.enum([`date`,`short`,`long`,`weekday`,`month`,`time`,`datetime`,`iso`]).optional()}),returns:C.string(),fn:({date:e,style:t=`date`})=>{let{day:n,instant:r}=Z(e);return t===`iso`?Q(n):(r??/* @__PURE__ */ new Date(n*X)).toLocaleString(`en-US`,{...wi[t],...r?{}:{timeZone:`UTC`}})}}),Di=v({name:`AddDays`,description:`The date days later (negative: earlier), as "YYYY-MM-DD"`,params:C.object({date:U(),days:C.number()}),returns:C.string(),fn:({date:e,days:t})=>Q(Z(e).day+Math.trunc(t))}),Oi=v({name:`DaysBetween`,description:`Calendar days from one date to another (negative if to is earlier)`,params:C.object({from:U(),to:U()}),returns:C.number(),fn:({from:e,to:t})=>Z(t).day-Z(e).day}),ki=v({name:`Today`,description:`Today's date in the viewer's time zone, as "YYYY-MM-DD"`,params:C.object({}),returns:C.string(),fn:()=>Q(Z(Date.now()).day)});function Ai(e){let t=/* @__PURE__ */ new Date(e*X);return[t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()]}const ji=[Ti,ki,Ei,Di,v({name:`AddMonths`,description:`The date months later (negative: earlier), kept within the month (Jan 31 + 1 is Feb 28), as "YYYY-MM-DD"; 12 months is a year`,params:C.object({date:U(),months:C.number()}),returns:C.string(),fn:({date:e,months:t})=>{let[n,r,i]=Ai(Z(e).day),a=r+Math.trunc(t),o=new Date(Date.UTC(n,a+1,0)).getUTCDate();return Q(Date.UTC(n,a,Math.min(i,o))/X)}}),Oi,v({name:`MonthsBetween`,description:`Whole months from one date to another (negative if to is earlier); @Floor(@MonthsBetween(birthday, @Today()) / 12) is an age`,params:C.object({from:U(),to:U()}),returns:C.number(),fn:({from:e,to:t})=>{let[n,r,i]=Ai(Z(e).day),[a,o,s]=Ai(Z(t).day),c=(a-n)*12+(o-r);return c>0&&s<i&&--c,c<0&&s>i&&(c+=1),c}}),v({name:`StartOf`,description:`First day of the date's "week" (Monday), "month" or "year", as "YYYY-MM-DD"`,params:C.object({date:U(),unit:C.enum([`week`,`month`,`year`])}),returns:C.string(),fn:({date:e,unit:t})=>{let n=Z(e).day,[r,i]=Ai(n);return Q(t===`week`?n-((/* @__PURE__ */ new Date(n*X)).getUTCDay()+6)%7:Date.UTC(r,t===`month`?i:0,1)/X)}})],Mi=()=>C.array(C.object({key:C.union([C.string(),C.number()]),value:C.number()})),Ni=e=>e.filter(e=>typeof e==`number`&&Number.isFinite(e)),Pi=(e,t)=>t??(e?`sum`:`count`);function Fi(e,t,n){return e.map((e,r)=>t?{...e,[t]:n[r]}:n[r])}const Ii=v({name:`GroupBy`,description:`One row per distinct key, in first-seen order; value is agg of field (default "sum"), or the row count without a field`,params:C.object({rows:H(),key:C.string(),field:C.string().optional(),agg:xi().optional()}),returns:Mi(),fn:({rows:e,key:t,field:n,agg:r})=>[...J(e,t)].map(([e,t])=>({key:e,value:Si(t,n,Pi(n,r))}))}),Li=v({name:`Pivot`,description:`One row per rowKey value, under key, with a column per colKey value holding agg of field, for stacked or grouped charts`,params:C.object({rows:H(),rowKey:C.string(),colKey:C.string(),field:C.string().optional(),agg:xi().optional()}),returns:C.array(C.record(C.string(),C.union([C.string(),C.number()]))),fn:({rows:e,rowKey:t,colKey:n,field:r,agg:i})=>{let a=[...J(e,n).keys()].map(String);return[...J(e,t)].map(([e,t])=>{let o={key:e};for(let e of a)o[e]=0;for(let[e,a]of J(t,n))o[String(e)]=Si(a,r,Pi(r,i));return o})}}),Ri=v({name:`Top`,description:`The n rows with the largest field ("asc": the smallest)`,params:C.object({rows:H(),field:C.string(),n:C.number(),direction:C.enum([`desc`,`asc`]).optional()}),returns:H(),fn:({rows:e,field:t,n,direction:r=`desc`})=>{let i=r===`asc`?1:-1;return e.map((e,n)=>({row:e,i:n,v:q(W(e,t))})).sort((e,t)=>e.v===null||t.v===null?e.v===t.v?e.i-t.i:e.v===null?1:-1:(e.v-t.v)*i||e.i-t.i).slice(0,Math.max(0,Math.trunc(n))).map(e=>e.row)}}),zi=/^\d{4}-\d{2}-\d{2}/,Bi=e=>typeof e==`string`&&zi.test(e.trim());function Vi(e,t){let n=q(e),r=q(t);if(n!==null&&r!==null)return n-r;if((Bi(e)||Bi(t))&&(Bi(e)||n!==null)&&(Bi(t)||r!==null))try{return Z(e).day-Z(t).day}catch{}let i=String(e),a=String(t);return i<a?-1:+(i>a)}const Hi=v({name:`Between`,description:`Rows whose field is from min to max, both included; compares numbers, dates by day ("YYYY-MM-DD", ISO or a timestamp), or text. Leave min or max null for an open end`,params:C.object({rows:H(),field:C.string(),min:C.any().optional(),max:C.any().optional()}),returns:H(),fn:({rows:e,field:t,min:n,max:r})=>e.filter(e=>{let i=W(e,t);return i!=null&&(n==null||Vi(i,n)>=0)&&(r==null||Vi(i,r)<=0)})});function Ui(e,t){if(t===`day`)return e;if(t===`week`)return e-((/* @__PURE__ */ new Date(e*864e5)).getUTCDay()+6)%7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)/864e5}function Wi(e,t){if(t===`day`)return e+1;if(t===`week`)return e+7;let n=/* @__PURE__ */ new Date(e*864e5);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1)/864e5}const Gi=[Ii,Li,Ri,Hi,v({name:`Bucket`,description:`Rows per day, week (from Monday) or month of dateField, in date order, empty periods 0 for sum and count; key is "YYYY-MM-DD", or "YYYY-MM" for months`,params:C.object({rows:H(),dateField:C.string(),unit:C.enum([`day`,`week`,`month`]),field:C.string().optional(),agg:xi().optional()}),returns:Mi(),fn:({rows:e,dateField:t,unit:n,field:r,agg:i})=>{let a=/* @__PURE__ */ new Map;for(let r of e){let e=W(r,t);if(typeof e!=`string`&&typeof e!=`number`)continue;let i;try{i=Z(e).day}catch{continue}let o=Ui(i,n),s=a.get(o);s?s.push(r):a.set(o,[r])}if(!a.size)return[];let o=Pi(r,i),s=o===`sum`||o===`count`,c=e=>n===`month`?Q(e).slice(0,7):Q(e),l=[...a.keys()].sort((e,t)=>e-t),u=[];for(let e=l[0];e<=l[l.length-1];e=Wi(e,n)){let t=a.get(e);if(t?u.push({key:c(e),value:Si(t,r,o)}):s&&u.push({key:c(e),value:0}),u.length>1e4)throw Error(`more than ${Y} periods`)}return u}}),v({name:`Cumulative`,description:`Copy of the rows with field replaced by its running total (field "" for a list of numbers)`,params:C.object({rows:H(),field:C.string()}),returns:H(),fn:({rows:e,field:t})=>{let n=0;return Fi(e,t,e.map(e=>n+=q(W(e,t))??0))}}),v({name:`MovingAvg`,description:`Copy of the rows with field replaced by the average of its last window values (field "" for a list of numbers)`,params:C.object({rows:H(),field:C.string(),window:C.number()}),returns:H(),fn:({rows:e,field:t,window:n})=>{let r=Math.trunc(n);if(r<1)throw Error(`window must be at least 1`);let i=e.map(e=>q(W(e,t))??0);return Fi(e,t,i.map((e,t)=>{let n=i.slice(Math.max(0,t-r+1),t+1);return n.reduce((e,t)=>e+t,0)/n.length}))}}),v({name:`Change`,description:`Percent change from previous to current, e.g. @Change(120, 100) is 20; null when previous is 0`,params:C.object({current:C.number(),previous:C.number()}),returns:C.number().nullable(),fn:({current:e,previous:t})=>t===0?null:K((e-t)/Math.abs(t)*100)}),v({name:`Histogram`,description:`Counts numbers into equal-width bins as {key, value} rows: key is the bin's start, value the count; min and max fix the range, default the data's`,params:C.object({values:bi(),bins:C.number(),min:C.number().optional(),max:C.number().optional()}),returns:C.array(C.object({key:C.string(),value:C.number()})),fn:({values:e,bins:t,min:n,max:r})=>{let i=Ni(e),a=Math.trunc(t);if(a<1||a>500)throw Error(`bins must be from 1 to 500`);let o=n??(i.length?Math.min(...i):0),s=r??(i.length?Math.max(...i):1);s<=o&&(s=o+1);let c=(s-o)/a,l=Math.max(0,1-Math.floor(Math.log10(c))),u=Array(a).fill(0);for(let e of i)e<o||e>s||u[Math.min(a-1,Math.floor((e-o)/c))]++;return u.map((e,t)=>({key:String(Number((o+t*c).toFixed(l))),value:e}))}}),v({name:`Stats`,description:`Summary of numbers, all zeros for an empty list`,params:C.object({values:bi()}),returns:C.object({count:C.number(),min:C.number(),max:C.number(),mean:C.number(),median:C.number(),stdev:C.number()}),fn:({values:e})=>{let t=Ni(e),n=t.length;if(!n)return{count:0,min:0,max:0,mean:0,median:0,stdev:0};let r=[...t].sort((e,t)=>e-t),i=t.reduce((e,t)=>e+t,0)/n,a=Math.floor(n/2),o=n%2?r[a]:(r[a-1]+r[a])/2,s=Math.sqrt(t.reduce((e,t)=>e+(t-i)**2,0)/n);return{count:n,min:r[0],max:r[n-1],mean:i,median:o,stdev:s}}})],Ki=(e,t)=>e<0?t+e:e,qi=[v({name:`Append`,description:`Copy of the list with item added at the end`,params:C.object({list:H(),item:C.any()}),returns:H(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${Y} items`);return[...e,t]}}),v({name:`Prepend`,description:`Copy of the list with item added at the start`,params:C.object({list:H(),item:C.any()}),returns:H(),fn:({list:e,item:t})=>{if(e.length+1>1e4)throw Error(`more than ${Y} items`);return[t,...e]}}),v({name:`Concat`,description:`Joins two lists`,params:C.object({list:H(),more:H()}),returns:H(),fn:({list:e,more:t})=>{if(e.length+t.length>1e4)throw Error(`more than ${Y} items`);return[...e,...t]}}),v({name:`Remove`,description:`Copy without the items whose field equals value; field "" compares the items themselves`,params:C.object({list:H(),field:C.string(),value:C.any()}),returns:H(),fn:({list:e,field:t,value:n})=>e.filter(e=>!G(W(e,t),n))}),v({name:`RemoveAt`,description:`Copy without the item at index (0-based; negative counts from the end)`,params:C.object({list:H(),index:C.number()}),returns:H(),fn:({list:e,index:t})=>{let n=Ki(Math.trunc(t),e.length);return e.filter((e,t)=>t!==n)}}),v({name:`Update`,description:`Copy where items whose field equals value get setField set to setValue`,params:C.object({list:H(),field:C.string(),value:C.any(),setField:C.string(),setValue:C.any()}),returns:H(),fn:({list:e,field:t,value:n,setField:r,setValue:i})=>e.map(e=>e&&typeof e==`object`&&!Array.isArray(e)&&G(W(e,t),n)?{...e,[r]:i}:e)}),v({name:`Toggle`,description:`Adds item if missing, removes it if present (a set of strings or numbers)`,params:C.object({list:H(),item:C.any()}),returns:H(),fn:({list:e,item:t})=>e.some(e=>G(e,t))?e.filter(e=>!G(e,t)):[...e,t]}),v({name:`Includes`,description:`True if the list has item, or the text contains it`,params:C.object({list:C.union([H(),C.string()]),item:C.any()}),returns:C.boolean(),fn:({list:e,item:t})=>typeof e==`string`?t!=null&&e.includes(String(t)):e.some(e=>G(e,t))}),v({name:`Find`,description:`First item whose field equals value, or null`,params:C.object({list:H(),field:C.string(),value:C.any()}),returns:C.any(),fn:({list:e,field:t,value:n})=>e.find(e=>G(W(e,t),n))??null}),v({name:`IndexOf`,description:`Index of item in the list, or -1`,params:C.object({list:H(),item:C.any()}),returns:C.number(),fn:({list:e,item:t})=>e.findIndex(e=>G(e,t))}),v({name:`Take`,description:`The first n items; a negative n takes the last n`,params:C.object({list:H(),n:C.number()}),returns:H(),fn:({list:e,n:t})=>{let n=Math.trunc(t);return n>=0?e.slice(0,n):e.slice(n)}}),v({name:`Slice`,description:`Items, or characters of text, from start up to end (not included); negative counts from the end`,params:C.object({list:C.union([H(),C.string()]),start:C.number(),end:C.number().optional()}),returns:C.union([H(),C.string()]),fn:({list:e,start:t,end:n})=>{let r=n===void 0?void 0:Math.trunc(n);return e.slice(Math.trunc(t),r)}}),v({name:`Unique`,description:`Distinct items in first-seen order`,params:C.object({list:H()}),returns:H(),fn:({list:e})=>{let t=/* @__PURE__ */ new Set,n=[];return e.filter(e=>{if(typeof e!=`object`||!e){let n=String(e);return!t.has(n)&&(t.add(n),!0)}return!n.some(t=>G(t,e))&&(n.push(e),!0)})}}),v({name:`Reverse`,description:`Copy in reverse order`,params:C.object({list:H()}),returns:H(),fn:({list:e})=>[...e].reverse()}),v({name:`Range`,description:`Numbers from start up to end (not included) by step (default 1), e.g. @Range(0, 3) is [0, 1, 2]`,params:C.object({start:C.number(),end:C.number(),step:C.number().optional()}),returns:C.array(C.number()),fn:({start:e,end:t,step:n=1})=>{if(n===0||!Number.isFinite(n))throw Error(`step must be a non-zero number`);let r=Math.max(0,Math.ceil((t-e)/n));if(r>1e4)throw Error(`more than ${Y} items`);let i=Number.isInteger(e)&&Number.isInteger(n);return Array.from({length:r},(t,r)=>i?e+r*n:Number((e+r*n).toPrecision(12)))}}),v({name:`Pick`,description:`A random item, or null for an empty list; draws anew each time, so call it inside @Set`,params:C.object({list:H()}),returns:C.any(),fn:({list:e})=>e.length?e[Math.floor(Math.random()*e.length)]:null}),v({name:`Shuffle`,description:`Copy in random order; call it inside @Set`,params:C.object({list:H()}),returns:H(),fn:({list:e})=>{let t=[...e];for(let e=t.length-1;e>0;e--){let n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}}),v({name:`Flatten`,description:`One list from a list of lists, e.g. [[1, 2], [3]] is [1, 2, 3]`,params:C.object({list:H()}),returns:H(),fn:({list:e})=>{let t=e.flatMap(e=>Array.isArray(e)?e:[e]);if(t.length>1e4)throw Error(`more than ${Y} items`);return t}}),v({name:`Chunk`,description:`The list cut into lists of size items, e.g. for weeks of 7 days or pages`,params:C.object({list:H(),size:C.number()}),returns:C.array(H()),fn:({list:e,size:t})=>{let n=Math.trunc(t);if(n<1)throw Error(`size must be 1 or more`);let r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}})],Ji=v({name:`Pow`,description:`base raised to exponent`,params:C.object({base:C.number(),exponent:C.number()}),returns:C.number(),fn:({base:e,exponent:t})=>K(e**+t)}),Yi=v({name:`Sqrt`,description:`Square root; null for a negative number`,params:C.object({number:C.number()}),returns:C.number().nullable(),fn:({number:e})=>e<0?null:K(Math.sqrt(e))}),Xi=v({name:`Random`,description:`Random number from min to max (integer true: a whole number, max included); draws anew each time, so call it inside @Set`,params:C.object({min:C.number(),max:C.number(),integer:C.boolean().optional()}),returns:C.number(),fn:({min:e,max:t,integer:n})=>{if(!Number.isFinite(e)||!Number.isFinite(t))throw Error(`min and max must be numbers`);let r=Math.min(e,t),i=Math.max(e,t);if(!n)return r+Math.random()*(i-r);let a=Math.ceil(r),o=Math.floor(i);if(a>o)throw Error(`no whole number between min and max`);return a+Math.floor(Math.random()*(o-a+1))}}),Zi=v({name:`Clamp`,description:`number kept between min and max`,params:C.object({number:C.number(),min:C.number(),max:C.number()}),returns:C.number(),fn:({number:e,min:t,max:n})=>K(Math.min(Math.max(e,Math.min(t,n)),Math.max(t,n)))}),Qi=v({name:`Percent`,description:`part / total * 100, e.g. @Percent(3, 4) is 75; 0 when total is 0`,params:C.object({part:C.number(),total:C.number()}),returns:C.number(),fn:({part:e,total:t})=>t===0?0:K(e/t*100)}),$i=v({name:`Lerp`,description:`The value a fraction t of the way from a to b`,params:C.object({a:C.number(),b:C.number(),t:C.number()}),returns:C.number(),fn:({a:e,b:t,t:n})=>K(e+(t-e)*n)}),ea=v({name:`Allocate`,description:`Splits total in proportion to weights, rounded to decimals (default 2), so the parts add up to exactly total, e.g. @Allocate(100, [1, 1, 1]) is [33.34, 33.33, 33.33]`,params:C.object({total:C.number(),weights:bi(),decimals:C.number().optional()}),returns:C.array(C.number()),fn:({total:e,weights:t,decimals:n})=>{let r=t.reduce((e,t)=>e+t,0);if(!t.length||t.some(e=>!Number.isFinite(e)||e<0))throw Error(`weights must be zero or more`);if(r===0)return t.map(()=>0);let i=10**Math.min(6,Math.max(0,Math.round(n!==void 0&&Number.isFinite(n)?n:2))),a=Math.round(Math.abs(e)*i),o=t.map(e=>a*e/r),s=o.map(Math.floor),c=a-s.reduce((e,t)=>e+t,0),l=o.map((e,t)=>({i:t,rest:e-Math.floor(e)})).sort((e,t)=>t.rest-e.rest||e.i-t.i);for(let{i:e}of l){if(c<=0)break;s[e]+=1,--c}return s.map(t=>(e<0?-t:t)/i)}}),ta=v({name:`Payment`,description:`Payment per period that repays principal over periods at rate percent per period, e.g. a 30-year loan at 6% a year: @Payment(300000, 6 / 12, 360)`,params:C.object({principal:C.number(),rate:C.number(),periods:C.number()}),returns:C.number(),fn:({principal:e,rate:t,periods:n})=>{if(!(n>0))throw Error(`periods must be positive`);let r=t/100;return K(r===0?e/n:e*r/(1-(1+r)**+-n))}}),na={mm:[`length`,.001],cm:[`length`,.01],m:[`length`,1],km:[`length`,1e3],in:[`length`,.0254],ft:[`length`,.3048],yd:[`length`,.9144],mi:[`length`,1609.344],mg:[`mass`,1e-6],g:[`mass`,.001],kg:[`mass`,1],oz:[`mass`,.028349523125],lb:[`mass`,.45359237],st:[`mass`,6.35029318],ml:[`volume`,.001],l:[`volume`,1],tsp:[`volume`,.00492892159375],tbsp:[`volume`,.0147867647812],floz:[`volume`,.0295735295625],cup:[`volume`,.2365882365],pt:[`volume`,.473176473],qt:[`volume`,.946352946],gal:[`volume`,3.785411784],"m/s":[`speed`,1],"km/h":[`speed`,1/3.6],mph:[`speed`,.44704],kn:[`speed`,.514444],m2:[`area`,1],km2:[`area`,1e6],ft2:[`area`,.09290304],ha:[`area`,1e4],acre:[`area`,4046.8564224]},ra=[`c`,`f`,`k`],ia=(e,t)=>t===`f`?(e-32)*5/9:t===`k`?e-273.15:e,aa=(e,t)=>t===`f`?e*9/5+32:t===`k`?e+273.15:e,oa=[Ji,Yi,Xi,Zi,Qi,$i,ea,ta,v({name:`Convert`,description:`value from one unit to another: mm cm m km in ft yd mi; mg g kg oz lb st; ml l tsp tbsp floz cup pt qt gal (US); m/s km/h mph kn; m2 km2 ft2 ha acre; c f k`,params:C.object({value:C.number(),from:C.string(),to:C.string()}),returns:C.number(),fn:({value:e,from:t,to:n})=>{let[r,i]=[t.trim().toLowerCase(),n.trim().toLowerCase()];if(ra.includes(r)&&ra.includes(i))return K(aa(ia(e,r),i));let[a,o]=[na[r],na[i]];if(!a||!o||a[0]!==o[0])throw Error(`cannot convert ${t} to ${n}`);return K(e*a[1]/o[1])}})],sa=`en-US`;function ca(e){let t=(e??`USD`).toUpperCase();return/^[A-Z]{3}$/.test(t)?t:`USD`}function $(e,t){try{return e.toLocaleString(sa,t)}catch{return e.toLocaleString(sa,{...t,currency:`USD`})}}const la=[v({name:`Format`,description:`Number as text: "number" 12,345.6, "currency" $12,345.68 (currency is a code like "EUR"), "percent" 45 -> 45%, "compact" 1.2M ($1.2M with a currency)`,params:C.object({value:C.number(),kind:C.enum([`number`,`currency`,`percent`,`compact`]).optional(),decimals:C.number().optional(),currency:C.string().optional()}),returns:C.string(),fn:({value:e,kind:t=`number`,decimals:n,currency:r})=>{if(!Number.isFinite(e))throw Error(`value is not a finite number`);let i=n===void 0?void 0:Math.min(Math.max(Math.trunc(n),0),10),a=(e,t=0)=>i===void 0?{minimumFractionDigits:t,maximumFractionDigits:e}:{minimumFractionDigits:t&&i,maximumFractionDigits:i};switch(t){case`currency`:return $(e,{style:`currency`,currency:ca(r),...a(2,2)});case`percent`:return`${$(e,a(1))}%`;case`compact`:return $(e,{notation:`compact`,...a(1),...r?{style:`currency`,currency:ca(r)}:{}});default:return $(e,a(2))}}}),v({name:`Join`,description:`Joins the items (or their field) into text with sep (default ", "), skipping nulls`,params:C.object({list:H(),sep:C.string().optional(),field:C.string().optional()}),returns:C.string(),fn:({list:e,sep:t=`, `,field:n=``})=>e.map(e=>W(e,n)).filter(e=>e!=null).map(e=>typeof e==`object`?JSON.stringify(e):String(e)).join(t)}),v({name:`Plural`,description:`Count and word: @Plural(1, "guest") is "1 guest", 3 gives "3 guests"; plural defaults to word + "s"`,params:C.object({n:C.number(),word:C.string(),plural:C.string().optional()}),returns:C.string(),fn:({n:e,word:t,plural:n})=>`${$(e,{maximumFractionDigits:2})} ${Math.abs(e)===1?t:n??`${t}s`}`}),v({name:`Pad`,description:`Pads the start of value to length with char (default "0"), e.g. 7 -> "07"`,params:C.object({value:C.union([C.string(),C.number()]),length:C.number(),char:C.string().optional()}),returns:C.string(),fn:({value:e,length:t,char:n=`0`})=>String(e).padStart(Math.min(Math.trunc(t),1e3),n||`0`)}),v({name:`Upper`,description:`Text in upper case`,params:C.object({text:C.string()}),returns:C.string(),fn:({text:e})=>e.toUpperCase()}),v({name:`Lower`,description:`Text in lower case`,params:C.object({text:C.string()}),returns:C.string(),fn:({text:e})=>e.toLowerCase()}),v({name:`Trim`,description:`Text without spaces at the start and end`,params:C.object({text:C.string()}),returns:C.string(),fn:({text:e})=>e.trim()}),v({name:`Capitalize`,description:`Each word with a capital first letter, e.g. "new york" is "New York"`,params:C.object({text:C.string()}),returns:C.string(),fn:({text:e})=>e.replace(/(^|[\s\-(/"])(\p{L})/gu,(e,t,n)=>t+n.toUpperCase())}),v({name:`Split`,description:`List of the parts of text between sep (default ","), each trimmed, empty parts dropped, e.g. @Split("a, b,,c") is ["a", "b", "c"]`,params:C.object({text:C.string(),sep:C.string().optional()}),returns:C.array(C.string()),fn:({text:e,sep:t=`,`})=>{let n=e.split(t===``?``:t).map(e=>e.trim()).filter(e=>e!==``);if(n.length>1e4)throw Error(`more than ${Y} items`);return n}}),v({name:`Replace`,description:`Text with every find replaced by replacement`,params:C.object({text:C.string(),find:C.string(),replacement:C.string()}),returns:C.string(),fn:({text:e,find:t,replacement:n})=>t===``?e:e.split(t).join(n)}),v({name:`Duration`,description:`Seconds as text: "short" 1h 20m, 4m 05s, 45s (default); "clock" 1:20:00, 4:05`,params:C.object({seconds:C.number(),style:C.enum([`short`,`clock`]).optional()}),returns:C.string(),fn:({seconds:e,style:t=`short`})=>{if(!Number.isFinite(e))throw Error(`seconds is not a finite number`);let n=e<0?`-`:``,r=Math.round(Math.abs(e)),[i,a,o]=[Math.floor(r/3600),Math.floor(r%3600/60),r%60],s=e=>String(e).padStart(2,`0`);return t===`clock`?n+(i?`${i}:${s(a)}:${s(o)}`:`${a}:${s(o)}`):i?`${n}${i}h${a?` ${a}m`:``}`:a?`${n}${a}m${o?` ${s(o)}s`:``}`:`${n}${o}s`}}),v({name:`Default`,description:`value, or fallback when value is null, "" or not a number, e.g. an empty number input: @Default($weight, 0)`,params:C.object({value:C.any().optional(),fallback:C.any()}),returns:C.any(),fn:({value:e,fallback:t})=>e==null||e===``||typeof e==`number`&&Number.isNaN(e)?t:e})],ua=[...qi,...oa,...la,...yi,...ji,...Gi],da=[{name:`Layout`,components:[`Col`,`Row`,`Box`,`Grid`,`Card`,`Carousel`,`Popover`,`Divider`,`Spacer`],notes:[`- gap and padding count 4px steps. Length is px or a CSS length like "50%". Radius is "sm", "md", "lg", "xl", "full" or px.`,`- Color is "ink", "muted", "faint", "surface", "info", "success", "warning", "danger", "purple", "pink", "chart1" to "chart6", or a CSS color. As a background, status colors are soft tints.`]},{name:`Text`,components:[`Title`,`Text`,`Caption`,`Label`,`Badge`,`Link`,`List`,`ListItem`,`Markdown`,`Quote`,`Code`,`Math`]},{name:`Inputs`,components:[`Button`,`IconButton`,`Pressable`,`Input`,`TextArea`,`Select`,`SegmentedControl`,`Slider`,`Checkbox`,`RadioGroup`,`DatePicker`,`Timer`,`Form`],notes:[`- An input's first argument is its value, usually a $variable that other statements read.`,`- Every input either changes something shown on the page, or sits in a Form whose submit Button sends a short first-person @ToAssistant ("Help me choose a bike"); the form values go with it. No dead inputs.`,`- In a Form, a field's last argument rules is checked before the form sends, and an error shows under the field. Rules is {required?, min?, max?, minLength?, maxLength?, email?, url?, numeric?, pattern?}: Input($email, "Email", "text", null, {required: true, email: true}).`]},{name:`Media and data`,components:[`Image`,`Icon`,`Table`,`Chart`,`YouTube`]},{name:`Play`,components:[`Flashcard`,`Celebration`]},{name:`Drawing`,components:[`Svg`,`G`,`Circle`,`Ellipse`,`Rect`,`Line`,`Path`,`Polyline`,`Polygon`,`SvgText`,`HtmlView`]}],fa=fe({root:`Col`,components:gi,functions:ua,componentGroups:da}),pa=[`Compose the answer like a page, not a form letter: a Title, a short Text, then a mix of blocks that show the content. Row, Grid and Carousel to set things side by side; Badge rows for quick facts; Card only to group a block; Popover for an aside.`,`Use Image only with a URL the user or a tool gave in this conversation. Never write an image URL yourself, even for a famous place or product: it will often be wrong. Without a URL, show the subject with an Icon, Badges or an Svg drawing instead.`,`Spacing is a system with three tiers that always nest: inner (gap 1-2, 4-8px) for a title with its subtitle, tags or line; group (gap 3-4, 12-16px) between blocks inside a Card or grid cell; section (24px) between the blocks of the page. Leave gap unset on the page's root Col and on a Card's own contents: the app applies these tiers. Set it on a Row, a Grid or an inner Col. Never use one gap for everything, and never a gap larger than the section gap.`,`A photo beside text is a media row: Row([Box([Image(url, alt, 1.33)]), Col([Title(..., "md"), Row([Badge(...), Badge(...)], 1, null, null, true), Text(..., "sm")], 2)], 4, "start"). The app sizes the photo to a third of the row (at most 200px) and top-aligns the text. Facts are Badges, never Buttons or boxed pills.`,`Keep cards compact and scannable: Title "md" for a card heading (xl or 2xl only for a single big number), Text "sm" for the body, at most one short paragraph, then facts as Badges or label/value rows (Caption label, Spacer, Text value). Don't write bold-lead paragraphs like "**Weekend rhythm:** ..." or long prose in a card. Cards side by side in a Grid share the same blocks in the same order and the same Image aspect ratio, so they line up. For example: c = Card([Col([Title("Sonoma", "md"), Row([Badge("1 h drive", null, "car"), Badge("Wine country", "purple")], 1, null, null, true)], 2), Text("A slow plaza, tasting rooms and quiet back roads.", "sm"), Col([Row([Caption("Best for"), Spacer(), Text("Food and wine", "sm")]), Row([Caption("Trade-off"), Spacer(), Text("Tastings add up", "sm")])], 1)])`,`Answer with a working tool whenever the request involves numbers, choices, lists, steps, a game or something to explore: keep inputs and lists in $variables, compute everything shown from them with expressions and @functions, and change them with @Set. The page must work on its own, without another message.`,`When the request leaves out a detail the answer depends on (a model, a size, a count), don't stop to ask: assume the most common case, say so in one short line, and build the whole answer, with a SegmentedControl or Select to switch to the other cases where they differ.`,`Use @ToAssistant only for what the page cannot compute: a Form's submit Button, or a new request ("Plan another day"). Its message is short and first person, like the user typing it ("Help me choose a bike"); the form values travel with it, so never repeat them in the message.`,`$variable defaults are literals (numbers, strings, lists, objects), never expressions or @calls. Edit lists with @Append, @Remove, @RemoveAt and @Update; track selections with @Toggle and @Includes.`,`cond ? a : b also picks between components; there is no @If. Use only the listed @functions; you cannot define your own.`,`Derive rows once in a statement with @Each(list, "x", {...}), then reuse them in @Each, Table, Chart, @Sum(rows.field) and @Join. @Each(@Range(0, n), "i", ...) builds a series or repeats a step.`,`@Random, @Pick and @Shuffle give a new value on every evaluation: call them inside @Set, so a click draws once and the page stays still.`,`Pick the medium that shows the idea: Chart for numbers across time or categories; Svg drawings for shapes, parts and movement; Table for comparisons; Flashcard and Celebration for learning and games; HtmlView only for a game or animation that needs a loop.`,`Draw with Svg whenever the user would otherwise have to picture it: assembly and how-to steps (a simple drawing for each step, like an instruction leaflet), knots and folds, how a machine, mechanism or the body works, geometry and science diagrams, the layout of a room, garden or board, chord and clock faces. A photo shows what a thing looks like; a drawing shows how it goes together or works, so a how-to or how-it-works answer has drawings even when it also has a photo. Keep each drawing simple: a viewBox about 240 wide, a dozen or so shapes in the listed colors with SvgText labels, a Line with a small Polygon head for an arrow, and let $variables such as the current step drive it.`,`Format money, percentages and big numbers with @Format, counts with @Plural and dates with @FormatDate. @Percent is unrounded, so show it as @Format(@Percent(part, total), "percent"), never @Percent(...) + "%".`,`Dates relative to now (today, this week, next month) start from @Today(), never a fixed date. <, >, <= and >= compare numbers only, so order two dates with @DaysBetween(a, b) > 0.`,`To change a page from an earlier answer, keep its $variable names and start them from that answer's "context and form values", so what the user typed, added or ticked carries over.`,`Read a number input for a count or amount through @Default and @Clamp with a sensible minimum, e.g. @Clamp(@Default($people, 1), 1, 50), so 0, empty or negative cannot divide by zero or zero out the page.`,`Answer a plain knowledge or safety question with Markdown text, adding a Quote only where it helps.`],ma=[`Example 1: A guest stepper that rescales a shopping list, with a checklist and a button that clears it:
|
|
2
2
|
|
|
3
3
|
root = Col([title, card])
|
|
4
4
|
card = Card([stepper, list, clear])
|
|
@@ -30,4 +30,4 @@ s2 = Svg([Rect(40, 16, 18, 128, "surface", "ink", 2), Rect(58, 16, 130, 14, "sur
|
|
|
30
30
|
s3 = Svg([Rect(40, 16, 160, 128, "#EFE9DF", "ink", 2), Rect(40, 16, 160, 14, "surface", "ink", 2), Rect(40, 72, 160, 14, "surface", "ink", 2), Rect(40, 130, 160, 14, "surface", "ink", 2), Circle(48, 50, 2.5, "ink"), Circle(192, 50, 2.5, "ink"), Circle(48, 108, 2.5, "ink"), Circle(192, 108, 2.5, "ink"), SvgText("Back panel", 120, 56, 11, "muted", "middle")], "0 0 240 160", "The back panel nailed to the frame")
|
|
31
31
|
drawings = [s0, s1, s2, s3]
|
|
32
32
|
viewer = Card([Row([Badge("Step " + ($step + 1) + " of 4", "info"), Spacer(), Caption(@Format(@Percent($step + 1, 4), "percent") + " done")], 2), Box([drawings[$step]], null, null, 3, "surface", "lg"), Title(steps[$step].title, "md"), Text(steps[$step].text, "sm"), Row([Button("Back", @Set($step, @Clamp($step - 1, 0, 3)), "outline", null, null, "arrow-left", $step == 0), Spacer(), Button("Next step", @Set($step, @Clamp($step + 1, 0, 3)), "solid", null, null, "arrow-right", $step == 3)], 2)], null, null, 4)
|
|
33
|
-
strip = Grid(@Each(@Range(0, 4), "i", Pressable([drawings[i], Caption((i + 1) + ". " + steps[i].title)], @Set($step, i), i == $step, 2)), 4, 110, 2)`],ha={bindings:!0,additionalRules:pa,examples:ma};export{
|
|
33
|
+
strip = Grid(@Each(@Range(0, 4), "i", Pressable([drawings[i], Caption((i + 1) + ". " + steps[i].title)], @Set($step, i), i == $step, 2)), 4, 110, 2)`],ha={bindings:!0,additionalRules:pa,examples:ma};export{Ae as ThemeProvider,pa as additionalRules,da as componentGroups,ma as examples,gi as intelligentComponents,fa as library,ha as promptOptions};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wodecorp/openui-vue-intelligent-ui-library",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Intelligent UI component library (52 components + 59 @functions) for OpenUI Vue 3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "wodecorp",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@openuidev/lang-core": "^1.2.0",
|
|
47
|
-
"@wodecorp/openui-vue-lang": "^0.1.
|
|
48
|
-
"@wodecorp/openui-vue-ui": "^0.1.
|
|
47
|
+
"@wodecorp/openui-vue-lang": "^0.1.6",
|
|
48
|
+
"@wodecorp/openui-vue-ui": "^0.1.6",
|
|
49
49
|
"clsx": "^2.1.1",
|
|
50
50
|
"katex": "^0.16.44"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"vue": "^3.
|
|
53
|
+
"vue": "^3.3.0",
|
|
54
54
|
"zod": "^3.25.0 || ^4.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|