@chatpanel/events 0.430.1 โ†’ 0.433.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ const v="1.0",p="https://chatpanel.net/a2ui/chap/v1/catalog.json",f="https://a2ui.org/specification/v1_0/catalogs/basic/catalog.json",e=(r,i)=>({name:r,kind:"string",...i}),n=(r,i,l)=>({name:r,kind:"enum",values:i,...l}),m=["start","center","end","spaceBetween","spaceAround","spaceEvenly","stretch"],d=["start","center","end","stretch"],h=Object.freeze({accountCircle:"๐Ÿ‘ค",add:"๏ผ‹",arrowBack:"โ†",arrowForward:"โ†’",attachFile:"๐Ÿ“Ž",calendarToday:"๐Ÿ“…",call:"๐Ÿ“ž",camera:"๐Ÿ“ท",check:"โœ“",close:"โœ•",delete:"๐Ÿ—‘",download:"โฌ‡",edit:"โœŽ",event:"๐Ÿ“…",error:"โš ",fastForward:"โฉ",favorite:"โ™ฅ",favoriteOff:"โ™ก",folder:"๐Ÿ“",help:"?",home:"โŒ‚",info:"โ„น",locationOn:"๐Ÿ“",lock:"๐Ÿ”’",lockOpen:"๐Ÿ”“",mail:"โœ‰",menu:"โ˜ฐ",moreVert:"โ‹ฎ",moreHoriz:"โ‹ฏ",notificationsOff:"๐Ÿ”•",notifications:"๐Ÿ””",pause:"โธ",payment:"๐Ÿ’ณ",person:"๐Ÿ‘ค",phone:"๐Ÿ“ฑ",photo:"๐Ÿ–ผ",play:"โ–ถ",print:"๐Ÿ–จ",refresh:"โ†ป",rewind:"โช",search:"๐Ÿ”",send:"โžค",settings:"โš™",share:"โ‡ช",shoppingCart:"๐Ÿ›’",skipNext:"โญ",skipPrevious:"โฎ",star:"โ˜…",starHalf:"โฏช",starOff:"โ˜†",stop:"โน",upload:"โฌ†",visibility:"๐Ÿ‘",visibilityOff:"๐Ÿ™ˆ",volumeDown:"๐Ÿ”‰",volumeMute:"๐Ÿ”ˆ",volumeOff:"๐Ÿ”‡",volumeUp:"๐Ÿ”Š",warning:"โš ",sunny:"โ˜€",cloudy:"โ˜",rain:"๐ŸŒง",snow:"โ„",storm:"โ›ˆ",wind:"๐Ÿ’จ",trendingUp:"โ†—",trendingDown:"โ†˜",time:"๐Ÿ•’",link:"๐Ÿ”—",place:"๐Ÿ“",money:"๐Ÿ’ฐ",chart:"๐Ÿ“Š"}),c=Object.freeze({catalogId:p,version:"1.0",components:Object.freeze({Text:{about:"a line or paragraph of text",props:[e("text",{required:!0}),n("variant",["h1","h2","h3","body","caption"])]},Image:{about:"an https image",props:[{name:"url",kind:"url",required:!0},e("description"),n("fit",["contain","cover","fill","none","scaleDown"]),n("variant",["icon","avatar","smallFeature","mediumFeature","largeFeature","header"])]},Icon:{about:"a small glyph",props:[{name:"name",kind:"icon",required:!0}]},Row:{about:"children side by side",props:[{name:"children",kind:"children",required:!0},n("justify",m),n("align",d)]},Column:{about:"children stacked",props:[{name:"children",kind:"children",required:!0},n("justify",m),n("align",d)]},List:{about:"a list, often from _template",props:[{name:"children",kind:"children",required:!0},n("direction",["vertical","horizontal"]),n("align",d)]},Card:{about:"a bordered box around one child",props:[{name:"child",kind:"child",required:!0}]},Tabs:{about:"tabbed panes",props:[{name:"tabs",kind:"tabs",required:!0}]},Divider:{about:"a rule",props:[n("axis",["horizontal","vertical"])]},Button:{about:"a button that sends an Event or runs openUrl",props:[{name:"child",kind:"child",required:!0},n("variant",["default","primary","borderless"]),{name:"action",kind:"action",required:!0}]},TextField:{about:"a text input bound to a path",props:[e("label",{required:!0}),e("value",{required:!0,bindable:!0}),e("placeholder"),n("variant",["longText","number","shortText","obscured"])]},CheckBox:{about:"a checkbox bound to a path",props:[e("label",{required:!0}),{name:"value",kind:"boolean",required:!0,bindable:!0}]},ChoicePicker:{about:"choose one or many",props:[e("label"),n("variant",["multipleSelection","mutuallyExclusive"]),{name:"options",kind:"options",required:!0},{name:"value",kind:"list",required:!0,bindable:!0},n("displayStyle",["checkbox","chips"])]},Slider:{about:"a number slider bound to a path",props:[e("label"),{name:"min",kind:"number"},{name:"max",kind:"number",required:!0},{name:"value",kind:"number",required:!0,bindable:!0},{name:"steps",kind:"number"}]},DateTimeInput:{about:"a date/time input bound to a path",props:[e("value",{required:!0,bindable:!0}),{name:"enableDate",kind:"boolean"},{name:"enableTime",kind:"boolean"},e("label")]},Table:{about:"columns + rows (rows: arrays or objects keyed by column)",props:[{name:"columns",kind:"list",required:!0},{name:"rows",kind:"rows",required:!0},e("caption")]},Stat:{about:"a big number with a label",props:[e("label",{required:!0}),e("value",{required:!0}),e("delta"),n("trend",["up","down","flat"])]},Badge:{about:"a short coloured tag",props:[e("text",{required:!0}),n("tone",["neutral","good","warn","bad","info"])]},Link:{about:"a link the person opens",props:[e("text",{required:!0}),{name:"url",kind:"url",required:!0}]},Chart:{about:"a small bar or line chart",props:[n("kind",["bar","line"],{required:!0}),{name:"labels",kind:"list",required:!0},{name:"values",kind:"list",required:!0},e("title"),e("unit")]}}),functions:Object.freeze({formatString:{args:[e("value",{required:!0})],returns:"string"},formatNumber:{args:[{name:"value",kind:"number",required:!0},{name:"decimals",kind:"number"},{name:"grouping",kind:"boolean"}],returns:"string"},formatCurrency:{args:[{name:"value",kind:"number",required:!0},e("currency",{required:!0}),{name:"decimals",kind:"number"},{name:"grouping",kind:"boolean"}],returns:"string"},formatDate:{args:[e("value",{required:!0}),e("format",{required:!0})],returns:"string"},pluralize:{args:[{name:"value",kind:"number",required:!0},e("zero"),e("one"),e("two"),e("few"),e("many"),e("other",{required:!0})],returns:"string"},openUrl:{args:[{name:"url",kind:"url",required:!0}],returns:"void",user:!0}})}),g=new Map([[p,c],[f,c]]);function q(r){return g.get(String(r||""))||null}function k(r,i){const l=i.props||i.args||[];return`${r}(${l.map(u=>u.name+(u.required?"":"?")).join(", ")})`}const y=Object.freeze(["Card","Column","Row","List","Text","Icon","Stat","Badge","Table","Chart","Link","Button","ChoicePicker"]);function $(r=c,{components:i=y}={}){const l=i.filter(a=>r.components[a]),u=l.map(a=>k(a,r.components[a])),s=[];for(const a of l)for(const t of r.components[a].props)t.kind==="enum"&&["variant","tone","trend","kind"].includes(t.name)&&s.push(`${a}.${t.name} ${t.values.join("|")}`);return["For a card, table, chart or choice, add ONE ```a2ui block (A2UI Express) after a short sentence. Plain questions get plain text.",`Components: ${u.join(" ")}`,`Enums: ${s.join("; ")}. Icons: sunny cloudy rain snow check warning info star place time money link.`,'One statement per line; root = โ€ฆ is the top; args positional or name=value, _ skips; $/x = value sets data, $/x reads it; _template($/list, Comp) repeats per item, $field reads the item; action: Event("name", {k: $/x}) or openUrl("https://โ€ฆ"); ChoicePicker options are strings.','Example:\n```a2ui\n$/days = [{d: "Mon", t: "18ยฐ"}, {d: "Tue", t: "21ยฐ"}]\nroot = Card(Column([Text("Paris", "h2"), Stat("Now", "19ยฐC", "+2ยฐ", "up"), List(_template($/days, Row([Text($d), Text($t, "caption")])))]))\n```'].join(`
2
+ `)}const o="common_types.json#/$defs/";function b(r){switch(r.kind){case"string":case"url":return{$ref:`${o}DynamicString`};case"number":return{$ref:`${o}DynamicNumber`};case"boolean":return{$ref:`${o}DynamicBoolean`};case"enum":return{type:"string",enum:[...r.values]};case"icon":return{type:"string",enum:Object.keys(h)};case"child":return{$ref:`${o}Child`};case"children":return{$ref:`${o}ChildList`};case"action":return{$ref:`${o}Action`};case"list":return{$ref:`${o}DynamicStringList`};case"rows":return{$ref:`${o}DynamicValue`};case"tabs":return{type:"array",items:{type:"object",properties:{title:{$ref:`${o}DynamicString`},child:{$ref:`${o}Child`}},required:["title","child"]}};case"options":return{type:"array",items:{type:"object",properties:{label:{$ref:`${o}DynamicString`},value:{type:"string"}},required:["label","value"]}};default:return{}}}function x(r=c){const i={};for(const[u,s]of Object.entries(r.components)){const a={component:{const:u}};for(const t of s.props)a[t.name]=b(t);i[u]={type:"object",description:s.about,allOf:[{$ref:`${o}ComponentCommon`},{properties:a,required:["component",...s.props.filter(t=>t.required).map(t=>t.name)]}],unevaluatedProperties:!1}}const l={};for(const[u,s]of Object.entries(r.functions)){const a={};for(const t of s.args)a[t.name]=b(t);l[u]={type:"object",returnType:s.returns,...s.user?{requiresUserActivation:!0}:{},properties:{"@call":{const:u},args:{type:"object",properties:a,required:s.args.filter(t=>t.required).map(t=>t.name)}},required:["@call","args"]}}return{$schema:"https://json-schema.org/draft/2020-12/schema",$id:r.catalogId,catalogId:r.catalogId,protocolVersion:r.version,title:"Chap",description:"The components a Chap reply may contain.",components:i,functions:l}}export{v as A2UI_VERSION,f as BASIC_CATALOG_ID,c as CHAP_CATALOG,p as CHAP_CATALOG_ID,h as ICONS,y as PROMPT_COMPONENTS,q as catalogFor,$ as describeExpress,k as signatureOf,x as toCatalogJson};
package/a2ui-chart.js ADDED
@@ -0,0 +1 @@
1
+ const v=320,H=160,e={l:34,r:8,t:22,b:26},S=24;function h(s){return String(s??"").replace(/[&<>"']/g,r=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[r])}function g(s){const r=Math.abs(s);return r>=1e9?(s/1e9).toFixed(1).replace(/\.0$/,"")+"B":r>=1e6?(s/1e6).toFixed(1).replace(/\.0$/,"")+"M":r>=1e4?(s/1e3).toFixed(1).replace(/\.0$/,"")+"k":Number.isInteger(s)?String(s):s.toFixed(1)}function N({kind:s="bar",labels:r=[],values:F=[],title:u="",unit:d=""}={}){const c=F.slice(0,S).map(t=>Number.isFinite(Number(t))?Number(t):0),y=c.map((t,i)=>String(r[i]??"").slice(0,10)),f=c.length,o=['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 160" width="320" height="160" font-family="system-ui,sans-serif" font-size="10">'];if(u&&o.push(`<text x="${e.l}" y="13" font-size="11" font-weight="600" fill="#7a8494">${h(String(u).slice(0,60))}</text>`),!f)return o.push("</svg>"),o.join("");const $=Math.max(0,...c),a=Math.min(0,...c),b=$-a||1,w=320-e.l-e.r,m=160-e.t-e.b,n=t=>e.t+m-(t-a)/b*m;o.push(`<line x1="${e.l}" x2="${320-e.r}" y1="${n(0).toFixed(1)}" y2="${n(0).toFixed(1)}" stroke="#8a93a3" stroke-opacity=".5"/>`),o.push(`<text x="${e.l-4}" y="${(n($)+3).toFixed(1)}" text-anchor="end" fill="#8a93a3">${h(g($)+d)}</text>`),a<0&&o.push(`<text x="${e.l-4}" y="${(n(a)+3).toFixed(1)}" text-anchor="end" fill="#8a93a3">${h(g(a)+d)}</text>`);const l=w/f,M=Math.ceil(f/8);if(y.forEach((t,i)=>{i%M||o.push(`<text x="${(e.l+l*(i+.5)).toFixed(1)}" y="152" text-anchor="middle" fill="#8a93a3">${h(t)}</text>`)}),s==="line"){const t=c.map((i,x)=>`${(e.l+l*(x+.5)).toFixed(1)},${n(i).toFixed(1)}`);o.push(`<polyline points="${t.join(" ")}" fill="none" stroke="#4f7fd6" stroke-width="2" stroke-linejoin="round"/>`);for(const i of t){const[x,p]=i.split(",");o.push(`<circle cx="${x}" cy="${p}" r="2.5" fill="#4f7fd6"/>`)}}else{const t=Math.max(2,l*.62);c.forEach((i,x)=>{const p=n(Math.max(i,0)),k=Math.max(1,Math.abs(n(i)-n(0)));o.push(`<rect x="${(e.l+l*x+(l-t)/2).toFixed(1)}" y="${p.toFixed(1)}" width="${t.toFixed(1)}" height="${k.toFixed(1)}" rx="2" fill="${i<0?"#d4694f":"#4f7fd6"}"/>`)})}return o.push("</svg>"),o.join("")}export{N as chartSvg};
@@ -0,0 +1,5 @@
1
+ import{A2UI_VERSION as D,CHAP_CATALOG as H}from"./a2ui-catalog.js";const U=64*1024,F=400,L=/[\p{ID_Start}_]/u,V=/[\p{ID_Continue}]/u,X=/[^\s,()[\]{}=:"]/u;function G(a){const f=[];let t=0,r=1;const w=(s,v,i)=>f.push({t:s,v,line:r,...i});for(;t<a.length;){const s=a[t];if(s===`
2
+ `){w("nl"),r++,t++;continue}if(s===" "||s===" "||s==="\r"){t++;continue}if(s==="#"||s==="/"&&a[t+1]==="/"){for(;t<a.length&&a[t]!==`
3
+ `;)t++;continue}if("()[]{},:=".includes(s)){w(s),t++;continue}if(s==='"'||(s==="r"||s==="R")&&a[t+1]==='"'){const i=s!=='"';i&&t++;const x=a.startsWith('"""',t)?'"""':'"';t+=x.length;let o="",u=!1;for(;t<a.length;){if(a.startsWith(x,t)){t+=x.length,u=!0;break}const g=a[t];if(g===`
4
+ `&&r++,g==="\\"&&!i){const k=a[t+1];o+=k==="n"?`
5
+ `:k==="t"?" ":k==='"'?'"':k==="\\"?"\\":k==="$"?"\\$":"\\"+(k??""),t+=2;continue}o+=g,t++}if(!u)return{toks:f,error:{line:r,message:"unterminated string"}};w("str",o);continue}const v=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/.exec(a.slice(t,t+40));if(v&&(/[\d.]/.test(s)||(s==="-"||s==="+")&&/[\d.]/.test(a[t+1]||""))){const i=Number(v[0]);if(!Number.isFinite(i))return{toks:f,error:{line:r,message:`number out of range: ${v[0]}`}};w("num",i),t+=v[0].length;continue}if(s==="$"){let i=t+1;for(;i<a.length&&X.test(a[i]);)i++;w("path",a.slice(t+1,i)),t=i;continue}if(s==="?"||s==="@"){let i=t+1;for(;i<a.length&&V.test(a[i]);)i++;if(i===t+1)return{toks:f,error:{line:r,message:`stray "${s}"`}};w(s==="?"?"check":"sys",a.slice(t,i)),t=i;continue}if(L.test(s)){let i=t+1;for(;i<a.length&&V.test(a[i]);)i++;w("id",a.slice(t,i)),t=i;continue}return{toks:f,error:{line:r,message:`unexpected character "${s}"`}}}return w("eof"),{toks:f}}class C extends Error{constructor(f,t){super(f),this.line=t}}function K(a){let f=0;const t=(o=0)=>a[f+o],r=()=>a[f++],w=o=>{const u=r();if(u.t!==o)throw new C(`expected "${o}" but found ${u.t==="eof"?"the end":`"${u.v??u.t}"`}`,u.line);return u},s=()=>{for(;t().t==="nl";)f++};function v(o,u){const g=[];for(s();t().t!==o;){if(g.push(u()),s(),t().t===","){r(),s();continue}if(t().t!==o)throw new C(`expected "," or "${o}"`,t().line)}return r(),g}function i(){const o=t();switch(o.t){case"str":return r(),{t:"lit",v:o.v};case"num":return r(),{t:"lit",v:o.v};case"path":return r(),{t:"path",p:o.v};case"[":return r(),{t:"arr",items:v("]",i)};case"{":return r(),{t:"map",entries:v("}",()=>{const u=r();if(u.t!=="id"&&u.t!=="str")throw new C("expected a key",u.line);return w(":"),s(),[u.v,i()]})};case"check":{r();const u=t().t==="("?(r(),v(")",i)):[];return{t:"check",name:o.v.slice(1),args:u}}case"sys":case"id":{if(r(),o.t==="id"&&t().t!=="(")return o.v==="true"||o.v==="false"?{t:"lit",v:o.v==="true"}:o.v==="null"?{t:"lit",v:null}:o.v==="_"?{t:"skip"}:{t:"var",name:o.v};w("(");const u=v(")",()=>{if(t().t==="id"&&(t(1).t==="="||t(1).t===":")){const g=r().v;return r(),s(),{name:g,value:i()}}return{value:i()}});return{t:"call",name:o.v,args:u}}default:throw new C(`unexpected ${o.t==="eof"?"end":`"${o.v??o.t}"`}`,o.line)}}const b=[],x=[];for(;t().t!=="eof";){if(t().t==="nl"){f++;continue}const o=f,u=t().line;try{let g=null;if((t().t==="id"||t().t==="path")&&t(1).t==="="){const d=r();r(),s(),g=d.t==="path"?{path:d.v}:{name:d.v}}const k=i();if(t().t!=="nl"&&t().t!=="eof")throw new C("expected the end of the statement",t().line);b.push({target:g,value:k,line:u})}catch(g){if(!(g instanceof C))throw g;for(x.push({line:g.line??u,message:g.message}),f=o+1;t().t!=="eof"&&!(a[f-1].t==="nl"&&(t().t==="id"||t().t==="path")&&t(1).t==="=");)f++}if(b.length>F){x.push({line:u,message:"too many statements"});break}}return{statements:b,errors:x}}class l extends Error{}class j extends l{}const z=new Set(["id"]);function B(a,f,t){const r=f.split("/").slice(1).map(v=>v.replace(/~1/g,"/").replace(/~0/g,"~"));if(!r.length||r.length===1&&r[0]===""){if(!t||typeof t!="object"||Array.isArray(t))throw new l("only a map can replace the whole data model");for(const v of Object.keys(a))delete a[v];Object.assign(a,t);return}let w=a;for(let v=0;v<r.length-1;v++){const i=r[v];(w[i]==null||typeof w[i]!="object")&&(w[i]=/^(?:0|[1-9]\d{0,3}|10000)$/.test(r[v+1])?[]:{}),w=w[i]}const s=r[r.length-1];if(Array.isArray(w)&&/^\d+$/.test(s))for(;w.length<Number(s);)w.push(null);t===null?Array.isArray(w)?w[s]=null:delete w[s]:w[s]=t}function Z(a,{catalog:f=H,surfaceId:t="main",partial:r=!1}={}){const w=String(a??"").slice(0,U),s=[],v=G(w);let i=v.toks;if(v.error){r||s.push(v.error);let d=i.length;for(;d>0&&i[d-1].t!=="nl";)d--;i=i.slice(0,d),i.push({t:"eof",line:v.error.line})}const b=K(i),x=b.statements.length?b.statements[b.statements.length-1].line:0;for(const d of b.errors)r&&d.line>=x||s.push(d);const o=[];let u={surfaceId:t,update:!1,sendDataModel:!1,statements:[]};const g=()=>{(u.statements.length||u.explicit)&&o.push(u)},k=[];for(const d of b.statements){const E=d.value;if(!d.target&&E.t==="call"&&(E.name==="surface"||E.name==="deleteSurface")){const O=E.args.find(S=>!S.name)?.value;if(!O||O.t!=="lit"||typeof O.v!="string"){s.push({line:d.line,message:`${E.name}() needs a surface id string`});continue}if(E.name==="deleteSurface"){g(),u={surfaceId:t,update:!1,sendDataModel:!1,statements:[]},k.push({version:D,deleteSurface:{surfaceId:O.v}});continue}g();const I=Object.fromEntries(E.args.filter(S=>S.name).map(S=>[S.name,S.value]));u={surfaceId:O.v,update:I.update?.v===!0,sendDataModel:I.sendDataModel?.v===!0,statements:[],explicit:!0};continue}u.statements.push(d)}g();for(const d of o)J(d,f,k,s,r);return{messages:k,errors:s}}function J(a,f,t,r,w){const s=new Map,v=[],i=[];for(const e of a.statements){if(e.target?.path!=null){v.push(e);continue}if(e.target?.name){const n=e.target.name;if(["true","false","null","_"].includes(n)){r.push({line:e.line,message:`"${n}" cannot be a variable name`});continue}s.set(n,e);continue}if(e.value.t==="call"&&Object.prototype.hasOwnProperty.call(f.components,e.value.name)){i.push(e);continue}r.push({line:e.line,message:"a statement must assign: name = Component(...) or $/path = value"})}if(i.length&&!s.has("root")&&!a.update){const e=i.length===1?i[0].value:{t:"call",name:"Column",args:[{value:{t:"arr",items:i.map(n=>n.value)}}]};s.set("root",{target:{name:"root"},value:e,line:i[0].line})}else if(i.length)for(const e of i)r.push({line:e.line,message:"a statement must assign: name = Component(...)"});const b=[],x=new Set,o=new Set,u=new Set,g=e=>Object.prototype.hasOwnProperty.call(f.components,e),k=e=>Object.prototype.hasOwnProperty.call(f.functions,e);function d(e,n,h){if(e.t==="call"&&g(e.name))return O(e,n,h);if(e.t==="var"){const p=s.get(e.name);if(!p){if(a.update||!s.has("root")||w)return e.name;throw new l(`"${e.name}" is not defined`)}if(o.has(e.name))throw new j;if(p.value.t!=="call"||!g(p.value.name))throw new l(`"${e.name}" is not a component`);return E(e.name)}if(e.t==="lit"&&typeof e.v=="string")return a.update||!s.has("root")?e.v:O({t:"call",name:"Text",args:[{value:e}]},n,h);throw new l("expected a component here")}function E(e){const n=s.get(e),h=n.value.args.find(c=>c.name==="id")?.value,p=h?.t==="lit"&&typeof h.v=="string"?h.v:e;if(x.has(e))return p;if(u.has(e))throw new l(`"${e}" contains itself`);u.add(e);try{O(n.value,p,n.line),x.add(e)}catch(c){throw!(c instanceof l)||c instanceof j?c:(o.add(e),r.push({line:n.line,message:`${e}: ${c.message}`}),new j)}finally{u.delete(e)}return p}function O(e,n,h){const p=f.components[e.name];if(!p)throw new l(`unknown component ${e.name}`);const c=e.args.find(m=>m.name==="id")?.value;c?.t==="lit"&&typeof c.v=="string"&&(n=c.v);const y={id:n,component:e.name};let $=0;for(const m of e.args){let _;if(m.name){if(z.has(m.name))continue;if(_=p.props.find(A=>A.name===m.name),!_)throw new l(`${e.name} has no "${m.name}" โ€” ${T(e.name,p)}`)}else if(_=p.props[$++],!_)throw new l(`too many arguments to ${T(e.name,p)}`);if(m.value.t!=="skip")try{y[_.name]=I(_,m.value,`${n}_${_.name}`,h)}catch(A){if(_.required||A instanceof j||!(A instanceof l))throw A;r.push({line:h,message:`${n}: ${A.message} (left out)`})}}for(const m of p.props)if(m.required&&!(m.name in y))throw new l(`${e.name} needs "${m.name}" โ€” ${T(e.name,p)}`);return b.push(y),n}function I(e,n,h,p){switch(e.kind){case"child":return d(n,h,p);case"children":{if(n.t==="call"&&n.name==="_template"){const[y,$]=n.args.map(m=>m.value);if(!y||y.t!=="path"||!$)throw new l("_template($/list, Component) needs a path and a component");return{componentId:d($,`${h}_item`,p),path:y.p}}if(n.t!=="arr")throw new l(`"${e.name}" takes a list [ โ€ฆ ] or _template(โ€ฆ)`);const c=[];return n.items.forEach((y,$)=>{try{c.push(d(y,`${h}_${$}`,p))}catch(m){if(m instanceof j)return;if(!(m instanceof l))throw m;r.push({line:p,message:`${h}_${$}: ${m.message}`})}}),c}case"action":return S(n);case"enum":{if(n.t!=="lit"||!e.values.includes(n.v))throw new l(`"${e.name}" is one of ${e.values.join(", ")}`);return n.v}case"tabs":{if(n.t!=="arr")throw new l('tabs takes [{title: "โ€ฆ", child: Component}]');return n.items.map((c,y)=>{if(c.t!=="map")throw new l('each tab is {title: "โ€ฆ", child: Component}');const $=new Map(c.entries);if(!$.has("title")||!$.has("child"))throw new l("each tab needs title and child");return{title:M($.get("title")),child:d($.get("child"),`${h}_${y}`,p)}})}case"options":{if(n.t!=="arr")throw new l('options takes [{label: "โ€ฆ", value: "โ€ฆ"}]');return n.items.map(c=>{if(c.t==="lit"&&typeof c.v=="string")return{label:c.v,value:c.v};if(c.t!=="map")throw new l("each option is {label, value}");const y=new Map(c.entries),$=y.get("value");return{label:M(y.get("label")??$),value:$?.t==="lit"?String($.v):""}})}default:return M(n)}}function S(e){if(e.t==="var"){const n=s.get(e.name);if(!n)throw new l(`"${e.name}" is not defined`);return S(n.value)}if(e.t==="lit"&&typeof e.v=="string"&&/^[\w-]{1,64}$/.test(e.v))return{event:{name:e.v,context:{}}};if(e.t!=="call")throw new l('an action is Event("name", {โ€ฆ}) or openUrl("https://โ€ฆ")');if(e.name==="Event"){const n=e.args.filter(m=>!m.name).map(m=>m.value),h=Object.fromEntries(e.args.filter(m=>m.name).map(m=>[m.name,m.value]));for(const m of Object.keys(h))if(m!=="context"&&m!=="userMessage")throw new l(`Event has no "${m}"`);const p=n[0];if(!p||p.t!=="lit"||typeof p.v!="string"||!p.v)throw new l("Event needs a name string");const c=h.context??n[1],y={};if(c){if(c.t!=="map")throw new l("the Event context is a map {key: value}");for(const[m,_]of c.entries)y[m]=M(_)}const $={name:p.v,context:y};return h.userMessage&&($.userMessage=M(h.userMessage)),{event:$}}if(k(e.name))return{functionCall:R(e)};throw new l(`unknown action ${e.name}`)}function R(e){const n=f.functions[e.name];if(!n)throw new l(`unknown function ${e.name}`);const h={};let p=0;for(const c of e.args){const y=c.name?n.args.find($=>$.name===c.name):n.args[p++];if(!y)throw new l(`bad argument to ${T(e.name,n)}`);c.value.t!=="skip"&&(h[y.name]=M(c.value))}for(const c of n.args)if(c.required&&!(c.name in h))throw new l(`${e.name} needs "${c.name}"`);return{"@call":e.name,args:h}}function M(e){switch(e.t){case"lit":return e.v;case"path":return{"@path":e.p};case"arr":return e.items.map(M);case"map":return Object.fromEntries(e.entries.map(([n,h])=>[n,M(h)]));case"var":{const n=s.get(e.name);if(!n)throw new l(`"${e.name}" is not defined`);if(n.value.t==="call"&&g(n.value.name))throw new l(`"${e.name}" is a component, not a value`);return M(n.value)}case"call":if(e.name==="@index"){const n=e.args[0]?.value;return{"@call":"@index",args:n?.t==="lit"?{offset:n.v}:{}}}if(k(e.name))return R(e);throw g(e.name)?new l(`${e.name} is a component; it goes in a child slot`):new l(`unknown function ${e.name}`);default:throw new l("expected a value")}}const N={},q=[];for(const e of v)try{const n=P(e.value);a.update||!s.has("root")?q.push({path:e.target.path||"/",value:n}):B(N,e.target.path,n)}catch(n){if(!(n instanceof l))throw n;r.push({line:e.line,message:n.message})}const W=s.has("root")?["root",...[...s.keys()].filter(e=>e!=="root")]:[...s.keys()];for(const e of W){const n=s.get(e);if(n.value.t==="call"&&!g(n.value.name)&&!k(n.value.name)&&!["Event","_template"].includes(n.value.name)&&!n.value.name.startsWith("@")){r.push({line:n.line,message:`${e}: unknown component ${n.value.name} โ€” the components are ${Object.keys(f.components).join(", ")}`});continue}if(!(n.value.t!=="call"||!g(n.value.name))&&!o.has(e))try{E(e)}catch(h){if(h instanceof j)continue;if(!(h instanceof l))throw h;r.push({line:n.line,message:`${e}: ${h.message}`})}}if(s.has("root")&&!a.update){const e={surfaceId:a.surfaceId,catalogId:f.catalogId};a.sendDataModel&&(e.sendDataModel=!0),e.components=b,Object.keys(N).length&&(e.dataModel=N),t.push({version:D,createSurface:e})}else{b.length&&t.push({version:D,updateComponents:{surfaceId:a.surfaceId,components:b}});for(const e of q)t.push({version:D,updateDataModel:{surfaceId:a.surfaceId,path:e.path,value:e.value}})}}function P(a){switch(a.t){case"lit":return a.v;case"arr":return a.items.map(P);case"map":return Object.fromEntries(a.entries.map(([f,t])=>[f,P(t)]));default:throw new l("data values are literals: strings, numbers, lists and maps")}}function T(a,f){const t=f.props||f.args||[];return`${a}(${t.map(r=>r.name+(r.required?"":"?")).join(", ")})`}export{Z as compileExpress};
package/a2ui-html.js ADDED
@@ -0,0 +1 @@
1
+ import{chartSvg as p}from"./a2ui-chart.js";function e(t){return String(t??"").replace(/[&<>"']/g,s=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[s])}const r=(...t)=>t.filter(Boolean).join(" "),n=(t,s)=>s==null||s===""?"":` ${t}="${e(s)}"`;function o(t,s){return t.children.map(a=>$(a,s)).join("")}function $(t,s=!1){const a=b(t,s);return t.weight&&!s&&a?`<div class="a2ui-weight-${t.weight}">${a}</div>`:a}function b(t,s){const a=t.props;switch(t.type){case"Text":{const i=a.variant||"body",l=s?"span":i==="h1"?"h3":i==="h2"?"h4":i==="h3"?"h5":"p";return`<${l} class="${r("a2ui-text",`a2ui-text-${i}`)}">${e(a.text)}</${l}>`}case"Image":return a.url?`<img class="${r("a2ui-image",a.variant&&`a2ui-image-${a.variant}`,a.fit&&`a2ui-fit-${a.fit}`)}" src="${e(a.url)}" alt="${e(a.description||"")}" loading="lazy" referrerpolicy="no-referrer">`:"";case"Icon":return`<span class="a2ui-icon" aria-hidden="true">${e(a.glyph)}</span>`;case"Row":case"Column":case"List":{if(s)return`<span class="a2ui-inline">${o(t,!0)}</span>`;const i=t.type==="List"?a.direction==="horizontal"?"row":"column":t.type.toLowerCase();return`<${t.type==="List"?'div role="list"':"div"} class="${r("a2ui-stack",`a2ui-${i}`,a.justify&&`a2ui-justify-${a.justify}`,a.align&&`a2ui-align-${a.align}`)}">${o(t)}</div>`}case"Card":return`<div class="a2ui-card">${o(t)}</div>`;case"Divider":return`<hr class="${r("a2ui-divider",a.axis==="vertical"&&"a2ui-divider-v")}">`;case"Tabs":{const i=t.tabs||[],l=i.map((d,u)=>`<button type="button" class="${r("a2ui-tab",u===0&&"is-active")}" data-a2ui-tab="${u}">${e(d.title)}</button>`).join(""),c=i.map((d,u)=>`<div class="a2ui-tabpane" data-a2ui-pane="${u}"${u?" hidden":""}>${$(d.node)}</div>`).join("");return`<div class="a2ui-tabs"><div class="a2ui-tabbar" role="tablist">${l}</div>${c}</div>`}case"Button":return`<button type="button" class="${r("a2ui-btn",`a2ui-btn-${a.variant||"default"}`)}" data-a2ui-key="${e(t.key)}"${t.hasAction?"":" disabled"}>${o(t,!0)}</button>`;case"TextField":{const i=a.variant==="number"?"number":a.variant==="obscured"?"password":"text",l=a.variant==="longText"?`<textarea class="a2ui-input"${n("data-a2ui-bind",t.bind)}${n("placeholder",a.placeholder)} rows="3">${e(a.value)}</textarea>`:`<input class="a2ui-input" type="${i}"${n("data-a2ui-bind",t.bind)}${n("placeholder",a.placeholder)} value="${e(a.value)}" data-a2ui-type="${i==="number"?"number":"string"}">`;return`<label class="a2ui-field"><span class="a2ui-label">${e(a.label)}</span>${l}</label>`}case"CheckBox":return`<label class="a2ui-check"><input type="checkbox"${n("data-a2ui-bind",t.bind)} data-a2ui-type="boolean"${a.value?" checked":""}> <span>${e(a.label)}</span></label>`;case"ChoicePicker":{const i=a.variant!=="mutuallyExclusive",l=new Set(a.value||[]),c=`a2ui-${e(t.key)}`,d=(a.options||[]).map(u=>`<label class="a2ui-choice"><input type="${i?"checkbox":"radio"}" name="${c}" value="${e(u.value)}"${n("data-a2ui-bind",t.bind)} data-a2ui-type="list"${l.has(u.value)?" checked":""}> <span>${e(u.label)}</span></label>`).join("");return`<fieldset class="${r("a2ui-choices",a.displayStyle==="chips"&&"a2ui-chips")}">${a.label?`<legend class="a2ui-label">${e(a.label)}</legend>`:""}${d}</fieldset>`}case"Slider":return`<label class="a2ui-field"><span class="a2ui-label">${e(a.label)}</span><input class="a2ui-slider" type="range"${n("min",a.min??0)}${n("max",a.max)}${n("step",a.steps?(a.max-(a.min??0))/a.steps:"any")} value="${e(a.value??0)}"${n("data-a2ui-bind",t.bind)} data-a2ui-type="number"></label>`;case"DateTimeInput":{const i=a.enableTime&&a.enableDate!==!1?"datetime-local":a.enableTime?"time":"date";return`<label class="a2ui-field"><span class="a2ui-label">${e(a.label)}</span><input class="a2ui-input" type="${i}" value="${e(a.value)}"${n("data-a2ui-bind",t.bind)} data-a2ui-type="string"></label>`}case"Table":{const i=(a.columns||[]).map(c=>`<th>${e(c)}</th>`).join(""),l=(a.rows||[]).map(c=>`<tr>${c.map(d=>`<td>${e(d)}</td>`).join("")}</tr>`).join("");return`<div class="a2ui-table-wrap"><table class="a2ui-table">${a.caption?`<caption>${e(a.caption)}</caption>`:""}<thead><tr>${i}</tr></thead><tbody>${l}</tbody></table></div>`}case"Stat":return`<div class="a2ui-stat"><span class="a2ui-stat-label">${e(a.label)}</span><span class="a2ui-stat-value">${e(a.value)}</span>${a.delta?`<span class="${r("a2ui-stat-delta",a.trend&&`a2ui-trend-${a.trend}`)}">${e(a.delta)}</span>`:""}</div>`;case"Badge":return`<span class="${r("a2ui-badge",`a2ui-tone-${a.tone||"neutral"}`)}">${e(a.text)}</span>`;case"Link":return a.url?`<a class="md-link a2ui-link" data-href="${e(a.url)}" role="link" tabindex="0">${e(a.text)}</a>`:`<span class="a2ui-link">${e(a.text)}</span>`;case"Chart":return`<img class="a2ui-chart" alt="${e(a.title||"chart")}" src="data:image/svg+xml;utf8,${encodeURIComponent(p(a))}">`;case"Missing":case"Truncated":return"";default:return""}}function h(t){return t?.root?`<div class="a2ui-surface" data-a2ui-surface="${e(t.surfaceId)}">${$(t.root)}</div>`:""}export{h as renderA2uiHtml};
package/a2ui-reply.js ADDED
@@ -0,0 +1,11 @@
1
+ import{compileExpress as x}from"./a2ui-express.js";import{createSurfaceSet as d}from"./a2ui-surface.js";import{renderA2uiText as y}from"./a2ui-text.js";import{CHAP_CATALOG as h}from"./a2ui-catalog.js";const A=Object.freeze(["a2ui","a2ui-json"]);function _(r){return A.includes(String(r||"").toLowerCase())}function v(r){const e=String(r??"");return e.includes("<a2ui")?e.replace(/<a2ui-json>\s*([\s\S]*?)\s*<\/a2ui-json>/g,(s,t)=>`
2
+ \`\`\`a2ui-json
3
+ ${t}
4
+ \`\`\`
5
+ `).replace(/<a2ui>\s*([\s\S]*?)\s*<\/a2ui>/g,(s,t)=>`
6
+ \`\`\`a2ui
7
+ ${t}
8
+ \`\`\`
9
+ `):e}function j(r){try{const e=JSON.parse(String(r||"").trim());return{messages:Array.isArray(e)?e:[e],errors:[]}}catch(e){return{messages:[],errors:[{line:0,message:`not JSON: ${String(e.message||e).slice(0,120)}`}]}}}function J(r,{lang:e="a2ui",surfaceId:s="main",urlPolicy:t,now:g,partial:p=!1,catalog:S=h}={}){const a=String(e).toLowerCase()==="a2ui-json"?j(r):x(r,{catalog:S,surfaceId:s,partial:p}),o=d({urlPolicy:t,now:g}),u=[...a.errors];let l=null;for(const c of a.messages)u.push(...o.apply(c)),c?.createSurface?.surfaceId&&(l=c.createSurface.surfaceId);const f=l||s,n=o.has(f)?o.resolve(f):null,i=!!n&&n.root.type!=="Missing";return{surfaces:o,tree:i?n:null,text:i?y(n):"",messages:a.messages,errors:u,ok:i,trivial:i&&m(n.root)}}function m(r){return r.type==="Text"?!0:(r.type==="Card"||r.type==="Column")&&r.children.length===1?m(r.children[0]):!1}function N(r){const e=r?.action;if(!e)return"";const s=e.userMessage||String(e.name||"").replace(/[_-]+/g," ").trim(),t=e.context&&Object.keys(e.context).length?` ${JSON.stringify(e.context).slice(0,2e3)}`:"";return`${s}
10
+
11
+ (chose "${e.name}" in the card${t})`}export{A as A2UI_FENCES,J as a2uiBlock,N as actionTurnText,v as fencesFromTags,_ as isA2uiFence};
package/a2ui-style.js ADDED
@@ -0,0 +1,105 @@
1
+ const n=`:root {
2
+ --a2ui-good-bg: #dcfce7; --a2ui-good-fg: #166534; --a2ui-warn-bg: #fef3c7; --a2ui-warn-fg: #92400e;
3
+ --a2ui-bad-bg: #fee2e2; --a2ui-bad-fg: #991b1b; --a2ui-up: #15803d; --a2ui-down: #b45309;
4
+ }
5
+ @media (prefers-color-scheme: dark) {
6
+ :root:not([data-theme='light']) {
7
+ --a2ui-good-bg: #12351f; --a2ui-good-fg: #86efac; --a2ui-warn-bg: #3a2a0c; --a2ui-warn-fg: #fcd34d;
8
+ --a2ui-bad-bg: #3b1414; --a2ui-bad-fg: #fca5a5; --a2ui-up: #4ade80; --a2ui-down: #fbbf24;
9
+ }
10
+ }
11
+ :root[data-theme='dark'] {
12
+ --a2ui-good-bg: #12351f; --a2ui-good-fg: #86efac; --a2ui-warn-bg: #3a2a0c; --a2ui-warn-fg: #fcd34d;
13
+ --a2ui-bad-bg: #3b1414; --a2ui-bad-fg: #fca5a5; --a2ui-up: #4ade80; --a2ui-down: #fbbf24;
14
+ }
15
+ .md-artifact-a2ui { position: relative; margin: 8px 0; }
16
+ .md-artifact-a2ui.a2ui-trivial p { margin: 0; }
17
+ .a2ui-host { font-size: 13px; line-height: 1.4; color: var(--text, #1b1f24); }
18
+ .a2ui-source-toggle {
19
+ position: absolute; top: 4px; right: 4px; border: 0; background: transparent; cursor: pointer;
20
+ color: var(--text-dim, #6b7280); font: 11px ui-monospace, monospace; opacity: 0; transition: opacity .15s;
21
+ }
22
+ .md-artifact-a2ui:hover .a2ui-source-toggle, .a2ui-source-toggle:focus-visible { opacity: 1; }
23
+
24
+ .a2ui-card {
25
+ border: 1px solid var(--border, #e3e6ea); border-radius: 12px; padding: 12px 14px;
26
+ background: var(--bg-elev, #fff); box-shadow: 0 1px 2px rgba(0,0,0,.04);
27
+ }
28
+ .a2ui-card + .a2ui-card, .a2ui-stack > .a2ui-card { margin: 0; }
29
+ .a2ui-stack { display: flex; gap: 8px; min-width: 0; }
30
+ .a2ui-column { flex-direction: column; }
31
+ .a2ui-row { flex-direction: row; align-items: center; flex-wrap: wrap; }
32
+ .a2ui-justify-center { justify-content: center; } .a2ui-justify-end { justify-content: flex-end; }
33
+ .a2ui-justify-spaceBetween { justify-content: space-between; } .a2ui-justify-spaceAround { justify-content: space-around; }
34
+ .a2ui-justify-spaceEvenly { justify-content: space-evenly; }
35
+ .a2ui-align-start { align-items: flex-start; } .a2ui-align-center { align-items: center; }
36
+ .a2ui-align-end { align-items: flex-end; } .a2ui-align-stretch { align-items: stretch; }
37
+ .a2ui-weight-1 { flex: 1 1 0; } .a2ui-weight-2 { flex: 2 1 0; } .a2ui-weight-3 { flex: 3 1 0; }
38
+ .a2ui-weight-4, .a2ui-weight-5, .a2ui-weight-6, .a2ui-weight-7, .a2ui-weight-8, .a2ui-weight-9,
39
+ .a2ui-weight-10, .a2ui-weight-11, .a2ui-weight-12 { flex: 4 1 0; }
40
+ .a2ui-row > .a2ui-column { flex: 1 1 0; }
41
+
42
+ .a2ui-text { margin: 0; overflow-wrap: anywhere; }
43
+ h3.a2ui-text { font-size: 17px; font-weight: 650; }
44
+ h4.a2ui-text { font-size: 15px; font-weight: 650; }
45
+ h5.a2ui-text { font-size: 13.5px; font-weight: 650; }
46
+ .a2ui-text-caption { font-size: 12px; color: var(--text-dim, #6b7280); }
47
+ .a2ui-icon { font-size: 18px; line-height: 1; width: 1.4em; text-align: center; }
48
+ .a2ui-divider { border: 0; border-top: 1px solid var(--border, #e3e6ea); margin: 4px 0; width: 100%; }
49
+ .a2ui-divider-v { border-top: 0; border-left: 1px solid var(--border, #e3e6ea); width: 0; align-self: stretch; }
50
+
51
+ .a2ui-stat { display: flex; flex-direction: column; min-width: 72px; padding: 4px 10px 4px 0; }
52
+ .a2ui-stat-label { font-size: 11.5px; color: var(--text-dim, #6b7280); text-transform: uppercase; letter-spacing: .03em; }
53
+ .a2ui-stat-value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
54
+ .a2ui-stat-delta { font-size: 12px; color: var(--text-dim, #6b7280); }
55
+ .a2ui-trend-up { color: var(--a2ui-up); } .a2ui-trend-down { color: var(--a2ui-down); }
56
+
57
+ .a2ui-badge {
58
+ display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
59
+ background: var(--bg-soft, #f6f7f9); color: var(--text-dim, #6b7280); border: 1px solid var(--border, #e3e6ea);
60
+ }
61
+ .a2ui-tone-good { background: var(--a2ui-good-bg); color: var(--a2ui-good-fg); border-color: transparent; }
62
+ .a2ui-tone-warn { background: var(--a2ui-warn-bg); color: var(--a2ui-warn-fg); border-color: transparent; }
63
+ .a2ui-tone-bad { background: var(--a2ui-bad-bg); color: var(--a2ui-bad-fg); border-color: transparent; }
64
+ .a2ui-tone-info { background: var(--accent-soft, #eef0fe); color: var(--accent, #4f46e5); border-color: transparent; }
65
+
66
+ .a2ui-table-wrap { overflow-x: auto; max-width: 100%; }
67
+ .a2ui-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
68
+ .a2ui-table caption { text-align: left; color: var(--text-dim, #6b7280); padding-bottom: 4px; }
69
+ .a2ui-table th { text-align: left; font-weight: 600; color: var(--text-dim, #6b7280); border-bottom: 1px solid var(--border, #e3e6ea); padding: 4px 8px 4px 0; }
70
+ .a2ui-table td { border-bottom: 1px solid var(--border, #e3e6ea); padding: 5px 8px 5px 0; font-variant-numeric: tabular-nums; }
71
+ .a2ui-table tr:last-child td { border-bottom: 0; }
72
+
73
+ .a2ui-chart { display: block; width: 100%; max-width: 360px; height: auto; }
74
+ .a2ui-image { max-width: 100%; border-radius: 8px; }
75
+ .a2ui-image-avatar, .a2ui-image-icon { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; }
76
+ .a2ui-link { color: var(--accent, #4f46e5); cursor: pointer; text-decoration: none; font-weight: 500; }
77
+ .a2ui-link:hover { text-decoration: underline; }
78
+
79
+ .a2ui-btn {
80
+ font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer;
81
+ border: 1px solid var(--border, #e3e6ea); background: var(--bg-soft, #f6f7f9); color: var(--text, #1b1f24); align-self: flex-start;
82
+ }
83
+ .a2ui-btn-primary { background: var(--accent, #4f46e5); border-color: var(--accent, #4f46e5); color: #fff; }
84
+ .a2ui-btn-borderless { background: transparent; border-color: transparent; color: var(--accent, #4f46e5); padding-inline: 4px; }
85
+ .a2ui-btn:disabled { opacity: .55; cursor: default; }
86
+ .a2ui-btn .a2ui-inline { display: inline-flex; gap: 6px; align-items: center; }
87
+
88
+ .a2ui-field { display: flex; flex-direction: column; gap: 4px; }
89
+ .a2ui-label { font-size: 12px; color: var(--text-dim, #6b7280); }
90
+ .a2ui-input {
91
+ font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 8px;
92
+ border: 1px solid var(--border, #e3e6ea); background: var(--bg, #fff); color: var(--text, #1b1f24);
93
+ }
94
+ .a2ui-check, .a2ui-choice { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
95
+ .a2ui-choices { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; }
96
+ .a2ui-choices legend { padding: 0 0 4px; }
97
+ .a2ui-chips .a2ui-choice { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border, #e3e6ea); background: var(--bg-soft, #f6f7f9); }
98
+ .a2ui-chips .a2ui-choice:has(input:checked) { border-color: var(--accent, #4f46e5); background: var(--accent-soft, #eef0fe); }
99
+ .a2ui-chips .a2ui-choice input { position: absolute; opacity: 0; pointer-events: none; }
100
+ .a2ui-slider { width: 100%; }
101
+
102
+ .a2ui-tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border, #e3e6ea); margin-bottom: 8px; }
103
+ .a2ui-tab { font: inherit; font-size: 12.5px; border: 0; background: transparent; padding: 6px 10px; cursor: pointer; color: var(--text-dim, #6b7280); border-bottom: 2px solid transparent; }
104
+ .a2ui-tab.is-active { color: var(--text, #1b1f24); border-bottom-color: var(--accent, #4f46e5); }
105
+ `,o="--bg:#ffffff;--bg-soft:#f6f7f9;--bg-elev:#ffffff;--border:#e3e6ea;--text:#1b1f24;--text-dim:#6b7280;--accent:#4f46e5;--accent-soft:#eef0fe;",r="--bg:#16181d;--bg-soft:#1d2026;--bg-elev:#22262e;--border:#2c313a;--text:#e8eaed;--text-dim:#9aa1ac;--accent:#818cf8;--accent-soft:#272a4a;";function d(i,{dark:a=!1,background:e=""}={}){const t=/^#[0-9a-f]{3,8}$/i.test(String(e))?e:"transparent";return`<!doctype html><html data-theme="${a?"dark":"light"}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>:root{${a?r:o}color-scheme:${a?"dark":"light"}}html,body{margin:0;padding:0;background:${t};font-family:system-ui,-apple-system,Roboto,sans-serif}${n}</style></head><body>${String(i||"")}</body></html>`}export{n as A2UI_CSS,d as a2uiDocument};
@@ -0,0 +1 @@
1
+ import{A2UI_VERSION as U,catalogFor as q,ICONS as V}from"./a2ui-catalog.js";const $=Object.freeze({components:400,depth:24,nodes:1500,templateRows:200,dataBytes:256*1024,text:4e3,surfaces:32}),_=/^[\p{ID_Start}_][\p{ID_Continue}]{0,63}$/u,K=new Set(["@accessibility","@catalogId","@metadata","@checks"]);function Z(e,{image:n=!1}={}){const t=String(e||"").trim();return n&&/^data:image\/(png|jpe?g|gif|webp|avif)[;,]/i.test(t)||/^https:\/\/[^\s"'<>]+$/i.test(t)?t:""}function O(e,n){return e===null||["string","number","boolean"].includes(typeof e)?!0:Array.isArray(e)?e.every(t=>O(t,n)):typeof e!="object"?!1:"@path"in e?typeof e["@path"]=="string"&&Object.keys(e).length===1:"@call"in e?z(e,n):Object.entries(e).every(([t,r])=>!t.startsWith("@")&&O(r,n))}function z(e,n,{action:t=!1}={}){const r=e["@call"];if(r==="@index")return!0;const p=n.functions[r];return!p||p.user&&!t||e.args!=null&&(typeof e.args!="object"||Array.isArray(e.args))?!1:Object.entries(e.args||{}).every(([h,c])=>p.args.some(f=>f.name===h)&&O(c,n))}function Q(e,n,t){switch(e.kind){case"enum":return typeof n=="string"&&e.values.includes(n);case"icon":return typeof n=="string"&&n in V||n&&typeof n=="object"&&"@path"in n;case"child":return typeof n=="string"&&_.test(n);case"children":return Array.isArray(n)?n.length<=$.components&&n.every(r=>typeof r=="string"&&_.test(r)):!!n&&typeof n=="object"&&typeof n.componentId=="string"&&_.test(n.componentId)&&typeof n.path=="string";case"action":{if(!n||typeof n!="object")return!1;if(n.event){const r=n.event;return typeof r.name=="string"&&r.name.length<=64&&(r.context==null||typeof r.context=="object"&&O(r.context,t))&&(r.userMessage==null||O(r.userMessage,t))}return n.functionCall?z(n.functionCall,t,{action:!0}):!1}case"tabs":return Array.isArray(n)&&n.length<=12&&n.every(r=>r&&O(r.title,t)&&typeof r.child=="string"&&_.test(r.child));case"options":return Array.isArray(n)&&n.length<=50&&n.every(r=>r&&O(r.label,t)&&typeof r.value=="string");default:return O(n,t)}}function X(e,n,t=""){const r=[],p=(f,b,M="VALIDATION_FAILED")=>r.push({code:M,surfaceId:t,path:f,message:b});if(!e||typeof e!="object"||Array.isArray(e))return p("","a component is an object"),{component:null,errors:r};if(typeof e.id!="string"||!_.test(e.id))return p("/id",`bad component id ${JSON.stringify(e.id)}`),{component:null,errors:r};const h=n.components[e.component];if(!h)return p(`/${e.id}`,`unknown component ${JSON.stringify(e.component)}`),{component:null,errors:r};const c={id:e.id,component:e.component};for(const[f,b]of Object.entries(e)){if(f==="id"||f==="component")continue;if(f==="weight"){typeof b=="number"&&b>=0&&b<=12?c.weight=Math.round(b):p(`/${e.id}/weight`,"weight is a number from 0 to 12");continue}if(f.startsWith("@")){if(f.startsWith("@@"))continue;if(!K.has(f)){p(`/${e.id}/${f}`,`unknown directive ${f}`);continue}f==="@accessibility"&&b&&typeof b=="object"&&(c[f]={label:typeof b.label=="string"?b.label.slice(0,200):void 0});continue}const M=h.props.find(w=>w.name===f);if(!M){p(`/${e.id}/${f}`,`${e.component} has no "${f}"`);continue}if(b!==null){if(!Q(M,b,n)){p(`/${e.id}/${f}`,`bad value for ${e.component}.${f}`);continue}c[f]=b}}for(const f of h.props)if(f.required&&!(f.name in c))return p(`/${e.id}/${f.name}`,`${e.component} needs "${f.name}"`),{component:null,errors:r};return{component:c,errors:r}}function x(e){return String(e).split("/").slice(1).map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~"))}function R(e,n){if(n===""||n==="/")return e;let t=e;for(const r of x(n)){if(t==null||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,r))return;t=t[r]}return t}function v(e,n,t){const r=x(n);if(!r.length||r.length===1&&r[0]==="")return t;const p=e&&typeof e=="object"?e:{};let h=p;for(let f=0;f<r.length-1;f++){const b=r[f];if(b==="__proto__"||b==="constructor"||b==="prototype")return p;(h[b]==null||typeof h[b]!="object")&&(h[b]=/^\d+$/.test(r[f+1])?[]:{}),h=h[b]}const c=r[r.length-1];return c==="__proto__"||c==="constructor"||c==="prototype"||(t===null?Array.isArray(h)?h[c]=null:delete h[c]:h[c]=t),p}function E(e,n){const t=String(e||"");return t.startsWith("/")?t:`${n||""}/${t}`.replace(/\/+/g,"/")}const H=typeof Intl<"u"&&typeof Intl.NumberFormat=="function";function L(e){const n=typeof e=="number"?e:Number(e);return Number.isFinite(n)?n:NaN}function J(e,n){const[t,r]=Math.abs(e).toFixed(n).split(".");return(e<0?"-":"")+t.replace(/\B(?=(\d{3})+(?!\d))/g,",")+(r?"."+r:"")}function ee(e,n,t=!0){const r=L(e);if(Number.isNaN(r))return"";const p=Number.isFinite(n)?Math.max(0,Math.min(10,n)):Number.isInteger(r)?0:2;if(H)try{return new Intl.NumberFormat(void 0,{minimumFractionDigits:p,maximumFractionDigits:p,useGrouping:t!==!1}).format(r)}catch{}return t===!1?r.toFixed(p):J(r,p)}function te(e,n,t,r=!0){const p=L(e);if(Number.isNaN(p))return"";const h=/^[A-Za-z]{3}$/.test(String(n||""))?String(n).toUpperCase():"USD",c=Number.isFinite(t)?Math.max(0,Math.min(4,t)):2;if(H)try{return new Intl.NumberFormat(void 0,{style:"currency",currency:h,minimumFractionDigits:c,maximumFractionDigits:c,useGrouping:r!==!1}).format(p)}catch{}const f={USD:"$",EUR:"โ‚ฌ",GBP:"ยฃ",JPY:"ยฅ",INR:"โ‚น"}[h];return f?`${p<0?"-":""}${f}${J(Math.abs(p),c)}`:`${h} ${J(p,c)}`}const W=["January","February","March","April","May","June","July","August","September","October","November","December"],Y=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ne(e,n){const t=new Date(typeof e=="number"?e:String(e??""));if(Number.isNaN(t.getTime()))return String(e??"");const r=c=>String(c).padStart(2,"0"),p=t.getHours()%12||12,h={yyyy:t.getFullYear(),yy:r(t.getFullYear()%100),MMMM:W[t.getMonth()],MMM:W[t.getMonth()].slice(0,3),MM:r(t.getMonth()+1),M:t.getMonth()+1,dd:r(t.getDate()),d:t.getDate(),EEEE:Y[t.getDay()],E:Y[t.getDay()].slice(0,3),HH:r(t.getHours()),H:t.getHours(),hh:r(p),h:p,mm:r(t.getMinutes()),ss:r(t.getSeconds()),a:t.getHours()<12?"AM":"PM"};return String(n||"yyyy-MM-dd").slice(0,64).replace(/'([^']*)'|yyyy|yy|MMMM|MMM|MM|M|dd|d|EEEE|E{1,3}|HH|H|hh|h|mm|ss|a/g,(c,f)=>f??String(h[c]??h[c[0]]??c))}function re(e){const n=L(e.value);let t=n===1?"one":"other";if(H&&typeof Intl.PluralRules=="function")try{t=new Intl.PluralRules().select(n)}catch{}return n===0&&e.zero!=null?String(e.zero):String(e[t]??e.other??"")}function ie({urlPolicy:e=Z,now:n=()=>""}={}){const t=new Map;function r(o){const s=[],a=(S,I,k,C="")=>(s.push({code:S,surfaceId:I,path:C,message:k}),s);if(!o||typeof o!="object"||Array.isArray(o))return a("VALIDATION_FAILED","","a message is an object");if(String(o.version||"").replace(/^v/,"")!==U)return a("VALIDATION_FAILED","",`unsupported A2UI version ${JSON.stringify(o.version)}`);const d=Object.keys(o).filter(S=>S!=="version");if(d.length!==1)return a("VALIDATION_FAILED","","a message has exactly one body");const A=d[0],l=o[A]||{},i=l.surfaceId;if(typeof i!="string"||!i||i.length>64)return a("VALIDATION_FAILED","","surfaceId is required");if(A==="createSurface"){if(t.has(i))return a("INTEGRITY_ERROR",i,`surface ${i} already exists`);if(t.size>=$.surfaces)return a("VALIDATION_FAILED",i,"too many surfaces");const S=q(l.catalogId);if(!S)return a("VALIDATION_FAILED",i,`unknown catalog ${JSON.stringify(l.catalogId)}`);const I={id:i,catalog:S,catalogId:l.catalogId,components:new Map,data:{}};return t.set(i,I),l.dataModel!=null&&s.push(...h(I,"/",l.dataModel)),l.components!=null&&s.push(...p(I,l.components)),s}const D=t.get(i);return A==="deleteSurface"?(t.delete(i),s):D?A==="updateComponents"?p(D,l.components):A==="updateDataModel"?"value"in l?h(D,l.path??"/",l.value):a("VALIDATION_FAILED",i,"updateDataModel needs a value"):a("INVALID_FUNCTION_CALL",i,`${A} is not accepted from a model`):a("VALIDATION_FAILED",i,`no surface ${i}`)}function p(o,s){const a=[];if(!Array.isArray(s))return[{code:"VALIDATION_FAILED",surfaceId:o.id,path:"/components",message:"components is a list"}];for(const m of s){if(o.components.size>=$.components&&!o.components.has(m?.id)){a.push({code:"VALIDATION_FAILED",surfaceId:o.id,path:"/components",message:`more than ${$.components} components`});break}const{component:d,errors:A}=X(m,o.catalog,o.id);a.push(...A),d&&o.components.set(d.id,d)}return a}function h(o,s,a){let m=0;try{m=JSON.stringify(a??null).length}catch{m=1/0}if(m>$.dataBytes)return[{code:"VALIDATION_FAILED",surfaceId:o.id,path:s,message:"data model too large"}];const d=a==null?null:JSON.parse(JSON.stringify(a));if(s==="/"||s===""){if(!d||typeof d!="object"||Array.isArray(d))return[{code:"VALIDATION_FAILED",surfaceId:o.id,path:s,message:"the whole data model must be a map"}];o.data=d}else o.data=v(o.data,s,d);return[]}function c(o,s,a,m){return s==null||typeof s!="object"?s:Array.isArray(s)?s.map(d=>c(o,d,a,m)):"@path"in s?R(o.data,E(s["@path"],a)):"@call"in s?f(o,s,a,m):Object.fromEntries(Object.entries(s).map(([d,A])=>[d,c(o,A,a,m)]))}function f(o,s,a,m){const d=s["@call"],A=o.catalog.functions[d];if(d==="@index")return m==null?"":m+L(s.args?.offset||0);if(!A||A.user)return"";const l={};for(const[i,D]of Object.entries(s.args||{}))l[i]=c(o,D,a,m);switch(d){case"formatString":return b(o,String(l.value??""),a);case"formatNumber":return ee(l.value,l.decimals,l.grouping);case"formatCurrency":return te(l.value,l.currency,l.decimals,l.grouping);case"formatDate":return ne(l.value,l.format);case"pluralize":return re(l);default:return""}}function b(o,s,a){return s.replace(/\\\$\{|\$\{([^}]{1,200})\}/g,(m,d)=>{if(d==null)return"${";const A=d.trim();return/^[\w/~.-]+$/.test(A)?M(R(o.data,E(A,a))):""})}function M(o){if(o==null)return"";if(typeof o=="string")return o.slice(0,$.text);if(typeof o=="number"||typeof o=="boolean")return String(o);try{return JSON.stringify(o).slice(0,$.text)}catch{return""}}function w(o){const s=t.get(o);if(!s)return null;let a=0;const m=new Map;function d(l,i,D,S,I){if(++a>$.nodes)return{key:`k${a}`,id:l,type:"Truncated",props:{},children:[]};const k=s.components.get(l);if(!k)return{key:`k${a}`,id:l,type:"Missing",props:{},children:[]};if(D>$.depth||S.has(l))return{key:`k${a}`,id:l,type:"Truncated",props:{},children:[]};const C=s.catalog.components[k.component],y={key:`k${a}`,id:l,type:k.component,props:{},children:[]};k.weight&&(y.weight=k.weight),m.set(y.key,{id:l,scope:i,index:I});const F=new Set(S).add(l);for(const N of C.props){const u=k[N.name];if(u!==void 0)switch(N.kind){case"child":y.children.push(d(u,i,D+1,F,I));break;case"children":if(Array.isArray(u))for(const g of u)y.children.push(d(g,i,D+1,F,I));else{const g=E(u.path,i),j=R(s.data,g);(Array.isArray(j)?j.slice(0,$.templateRows):[]).forEach((oe,P)=>y.children.push(d(u.componentId,`${g}/${P}`,D+1,F,P)))}break;case"tabs":y.tabs=u.map(g=>({title:M(c(s,g.title,i,I)),node:d(g.child,i,D+1,F,I)}));break;case"options":y.props.options=u.map(g=>({label:M(c(s,g.label,i,I)),value:g.value}));break;case"action":y.hasAction=!0,y.action=u.event?"event":u.functionCall?.["@call"]||"";break;case"url":y.props[N.name]=e(M(c(s,u,i,I)),{image:k.component==="Image"})||"";break;case"icon":{const g=M(c(s,u,i,I));y.props.icon=V[g]?g:"info",y.props.glyph=V[y.props.icon];break}case"list":{const g=c(s,u,i,I),j=Array.isArray(g)?g:g==null||g===""?[]:[g];y.props[N.name]=j.slice(0,$.templateRows).map(T=>typeof T=="number"?T:M(T)),N.bindable&&u&&typeof u=="object"&&"@path"in u&&(y.bind=E(u["@path"],i));break}case"rows":{const g=c(s,u,i,I);y.props.rows=Array.isArray(g)?g.slice(0,$.templateRows):[];break}case"number":{const g=L(c(s,u,i,I));y.props[N.name]=Number.isNaN(g)?void 0:g,N.bindable&&u&&typeof u=="object"&&"@path"in u&&(y.bind=E(u["@path"],i));break}case"boolean":{y.props[N.name]=c(s,u,i,I)===!0||c(s,u,i,I)==="true",N.bindable&&u&&typeof u=="object"&&"@path"in u&&(y.bind=E(u["@path"],i));break}case"enum":y.props[N.name]=u;break;default:y.props[N.name]=M(c(s,u,i,I)),N.bindable&&u&&typeof u=="object"&&"@path"in u&&(y.bind=E(u["@path"],i))}}if(y.type==="Table"){const N=y.props.columns||[];y.props.rows=y.props.rows.map(u=>(Array.isArray(u)?u:N.map(g=>u&&typeof u=="object"?u[g]??u[String(g).toLowerCase()]:"")).map(M))}return y.type==="Chart"&&(y.props.values=(y.props.values||[]).map(L).map(N=>Number.isNaN(N)?0:N)),y}const A=d("root","",0,new Set,void 0);return{surfaceId:o,root:A,keys:m}}function B(o,s){const a=o&&t.get(o.surfaceId),m=o?.keys.get(s);if(!a||!m)return null;const A=a.components.get(m.id)?.action;if(!A)return null;if(A.event){const i=A.event,D={};for(const[I,k]of Object.entries(i.context||{}))D[I]=c(a,k,m.scope,m.index);const S={version:U,action:{name:i.name,surfaceId:a.id,sourceComponentId:m.id,timestamp:n(),context:D}};return i.userMessage!=null&&(S.action.userMessage=M(c(a,i.userMessage,m.scope,m.index))),{kind:"event",message:S}}const l=A.functionCall;if(l?.["@call"]==="openUrl"){const i=e(M(c(a,l.args?.url,m.scope,m.index)),{image:!1});return i?{kind:"openUrl",url:i}:null}return null}function G(o,s,a){const m=t.get(o);return!m||typeof s!="string"||!s.startsWith("/")?!1:h(m,s,a).length===0}return{apply:r,resolve:w,click:B,setValue:G,has:o=>t.has(o),data:o=>t.get(o)?.data}}export{$ as LIMITS,ie as createSurfaceSet,Z as defaultUrlPolicy,te as formatCurrency,ne as formatDate,ee as formatNumber,X as validateComponent};
package/a2ui-text.js ADDED
@@ -0,0 +1,2 @@
1
+ function a(e){return String(e??"").replace(/\s+/g," ").trim()}function i(e){switch(e.type){case"Text":return a(e.props.text);case"Icon":return e.props.glyph||"";case"Badge":return`[${a(e.props.text)}]`;case"Link":return e.props.url?`${a(e.props.text)} (${e.props.url})`:a(e.props.text);case"Stat":return`${a(e.props.label)}: ${a(e.props.value)}${e.props.delta?` (${a(e.props.delta)})`:""}`;case"Button":return`[${e.children.map(i).filter(Boolean).join(" ")}]`;case"Row":return e.children.map(i).filter(Boolean).join(" ยท ");case"Column":return e.children.map(i).filter(Boolean).join(" โ€” ");case"List":return e.children.map(i).filter(Boolean).join(" ยท ");default:return null}}function c(e,s){const t=e.props;switch(e.type){case"Text":{const r=a(t.text);if(!r)return;s.push(t.variant==="h1"||t.variant==="h2"||t.variant==="h3"?`**${r}**`:r);return}case"Row":{const r=i(e);r&&s.push(r);return}case"List":if(t.direction==="horizontal"){const r=i(e);r&&s.push(r);return}for(const r of e.children)c(r,s);return;case"Column":case"Card":for(const r of e.children)c(r,s);return;case"Tabs":for(const r of e.tabs||[])s.push(`**${a(r.title)}**`),c(r.node,s);return;case"Divider":s.push("---");return;case"Image":t.description&&s.push(`[image: ${a(t.description)}]`);return;case"Table":{const r=(t.columns||[]).map(a);if(!r.length)return;t.caption&&s.push(a(t.caption)),s.push(`| ${r.join(" | ")} |`,`| ${r.map(()=>"---").join(" | ")} |`);for(const n of t.rows||[])s.push(`| ${r.map((o,l)=>a(n[l]).replace(/\|/g,"\\|")).join(" | ")} |`);return}case"Chart":{t.title&&s.push(`**${a(t.title)}**`),s.push((t.labels||[]).map((r,n)=>`${a(r)} ${t.values?.[n]??""}${t.unit||""}`).join(" ยท "));return}case"TextField":case"DateTimeInput":s.push(`${a(t.label)}: ${a(t.value)||"____"}`);return;case"CheckBox":s.push(`${t.value?"[x]":"[ ]"} ${a(t.label)}`);return;case"Slider":s.push(`${a(t.label)}: ${t.value??""}`);return;case"ChoicePicker":{const r=new Set(t.value||[]);s.push(`${t.label?a(t.label)+": ":""}${(t.options||[]).map(n=>r.has(n.value)?`(โ€ข) ${a(n.label)}`:`( ) ${a(n.label)}`).join(" ")}`);return}default:{const r=i(e);r&&s.push(r)}}}function p(e){if(!e?.root)return"";const s=[];return c(e.root,s),s.join(`
2
+ `)}export{p as renderA2uiText};
@@ -0,0 +1,12 @@
1
+ import{ICONS as y}from"./a2ui-catalog.js";const w="(Chap shows the person a card with these figures. Answer in one or two sentences with what matters for their question โ€” do not draw a card of it or list every figure again.)",x=8*1024;function l(n){return n==null?"null":typeof n=="number"?Number.isFinite(n)?String(n):"null":typeof n=="boolean"?String(n):Array.isArray(n)?`[${n.map(l).join(", ")}]`:typeof n=="object"?`{${Object.entries(n).map(([t,r])=>`${JSON.stringify(String(t))}: ${l(r)}`).join(", ")}}`:`"${String(n).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\t/g,"\\t")}"`}const C=/^(?:united states(?: of america)?|usa|us|liberia|myanmar|burma)$/i;function m(n){const t=String(n||"").toLowerCase();return/thunder|storm/.test(t)?"storm":/snow|sleet|blizzard|ice/.test(t)?"snow":/rain|drizzle|shower/.test(t)?"rain":/sun|clear/.test(t)?"sunny":/wind/.test(t)?"wind":/cloud|overcast|fog|mist|haze/.test(t)?"cloudy":"info"}function S(n){const t=new Date(`${String(n||"")}T12:00:00`);return Number.isNaN(t.getTime())?String(n||""):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()]}function F(n,{place:t=""}={}){if(!n?.now)return"";const r=C.test(String(n.area?.country||"").trim()),o=(i,f)=>{const $=r?f:i;return $==null?"":`${Math.round($)}ยฐ`},e=n.now,c=o(e.tempC,e.tempF);if(!c)return"";const a=t||[n.area?.name,n.area?.region&&n.area.region!==n.area?.name?n.area.region:"",n.area?.country].filter(Boolean).join(", ")||n.query||"Weather",s=o(e.feelsLikeC,e.feelsLikeF),u=r?e.windMph!=null?`${e.windMph} mph`:"":e.windKph!=null?`${e.windKph} km/h`:"",h=[e.humidity!=null?`Humidity ${e.humidity}%`:"",u?`Wind ${u}${e.windDir?` ${e.windDir}`:""}`:"",e.uv!=null?`UV ${e.uv}`:""].filter(Boolean).map(i=>({f:i})),g=(n.days||[]).map((i,f)=>({d:f===0?"Today":S(i.date),i:m(i.condition),t:[o(i.maxC,i.maxF),o(i.minC,i.minF)].filter(Boolean).join(" / "),r:i.chanceOfRain!=null?`${i.chanceOfRain}% rain`:""})).filter(i=>i.t),p=m(e.condition);return[`$/w = ${l({place:a,now:`${c}${r?"F":"C"}`,cond:e.condition||"",feels:s?`Feels like ${s}`:""})}`,`$/days = ${l(g)}`,`$/facts = ${l(h)}`,'head = Row([Icon("'+(y[p]?p:"info")+'"), Column([Text($/w/place, "h3"), Text($/w/cond, "caption")])])','reading = Row([Stat("Now", $/w/now, $/w/feels)])','extras = List(_template($/facts, Badge($f)), "horizontal")','forecast = List(_template($/days, Row([Text($d), Icon($i), Text($t), Text($r, "caption")])))',"root = Card(Column([head, reading, extras, forecast]))"].join(`
2
+ `)}function d(n){const t=n&&typeof n=="object"?n.card:null;if(!t||typeof t!="object")return null;const r=t.lang==="a2ui-json"?"a2ui-json":t.lang==="a2ui"||t.lang==null?"a2ui":null,o=typeof t.source=="string"?t.source.trim():"";return!r||!o||o.length>x||o.includes("```")?null:{lang:r,source:o}}function j(n){if(!d(n))return n;const t=typeof n.text=="string"?n.text:"";return{...n,text:`${t}
3
+
4
+ ${w}`}}const N=/(?:^|\n)[ \t]{0,3}```a2ui(?:-json)?[^\n]*\n[\s\S]*?\n[ \t]{0,3}```[ \t]*(?=\n|$)|<a2ui(?:-json)?>[\s\S]*?<\/a2ui(?:-json)?>/g;function T(n,t=[]){const r=(t||[]).filter(Boolean);if(!r.length)return n;const o=(typeof n=="string"?n:"").replace(N,"").replace(/\n{3,}/g,`
5
+
6
+ `),e=[],c=new Set;for(const a of r)c.has(a.source)||(c.add(a.source),e.push(`\`\`\`${a.lang}
7
+ ${a.source}
8
+ \`\`\``));return`${o.replace(/\s+$/,"")}${o.trim()?`
9
+
10
+ `:""}${e.join(`
11
+
12
+ `)}`}function O(n=[]){const t=Array.isArray(n)?n:[];for(let r=t.length-1;r>=0;r--)if(t[r]?.role==="user")return(t[r].attachments||[]).map(o=>o?.kind==="prefetch"?d(o):null).filter(Boolean);return[]}function R(n,{prior:t=[]}={}){const r=[...t];return{tools:n&&typeof n.execute=="function"?{...n,execute:async(e,c,a)=>{const s=await n.execute(e,c,a),u=d(s);return u?(r.push(u),j(s)):s}}:n,list:()=>[...r],apply:e=>T(e,r)}}export{w as CARD_SHOWN_NOTE,T as appendCards,d as cardOf,O as cardsFromAttachments,m as conditionIcon,R as createCardCollector,l as exprLit,F as weatherCard,j as withCardNote};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/events",
3
- "version": "0.430.1",
3
+ "version": "0.433.0",
4
4
  "description": "The canonical ChatPanel event-log and capability contracts โ€” typed durable facts, clock-free deterministic linearization, schema upcasting, and the invariants the replay harness asserts. Pure, dependency-free ESM shared by the ChatPanel extension, gateway and bridge.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -15,6 +15,15 @@
15
15
  "./a2a-board.js": "./a2a-board.js",
16
16
  "./a2a-client.js": "./a2a-client.js",
17
17
  "./a2a-task.js": "./a2a-task.js",
18
+ "./a2ui-catalog.js": "./a2ui-catalog.js",
19
+ "./a2ui-express.js": "./a2ui-express.js",
20
+ "./a2ui-surface.js": "./a2ui-surface.js",
21
+ "./a2ui-html.js": "./a2ui-html.js",
22
+ "./a2ui-text.js": "./a2ui-text.js",
23
+ "./a2ui-chart.js": "./a2ui-chart.js",
24
+ "./a2ui-reply.js": "./a2ui-reply.js",
25
+ "./a2ui-tool-cards.js": "./a2ui-tool-cards.js",
26
+ "./a2ui-style.js": "./a2ui-style.js",
18
27
  "./agent-dialects.js": "./agent-dialects.js",
19
28
  "./agent-portability.js": "./agent-portability.js",
20
29
  "./agent-session-open.js": "./agent-session-open.js",
@@ -362,6 +371,15 @@
362
371
  "a2a-board.js",
363
372
  "a2a-client.js",
364
373
  "a2a-task.js",
374
+ "a2ui-catalog.js",
375
+ "a2ui-express.js",
376
+ "a2ui-surface.js",
377
+ "a2ui-html.js",
378
+ "a2ui-text.js",
379
+ "a2ui-chart.js",
380
+ "a2ui-reply.js",
381
+ "a2ui-tool-cards.js",
382
+ "a2ui-style.js",
365
383
  "agent-dialects.js",
366
384
  "agent-portability.js",
367
385
  "agent-session-open.js",
package/prefetch.js CHANGED
@@ -1,7 +1,9 @@
1
- import{researchAsk as P,runResearch as ae}from"./web-research.js";import{frontPagesAskedAbout as ie}from"./site-pages.js";import{weatherFromSearch as ce}from"./weather-tool.js";import{PAGE_READ_ARGS as T}from"./page-context.js";const W=/(\bhow(?:'s| is| was|s) (?:the )?(?:weather|forecast|temperature)\b|\bwhat(?:'s| is|s) (?:the )?(?:weather|forecast|temperature)\b|\b(?:weather|forecast|temperature) (?:in|for|at|around|near)\b|\bis it (?:raining|snowing|hot|cold|warm|sunny|cloudy|windy)\b|\b(?:will|does) it (?:rain|snow)\b|\bhow (?:hot|cold|warm|humid|windy) is it\b|^\s*(?:weather|forecast)\b|\b(?:weather|forecast)\s*\??\s*$)/i,he=/\b(right now|now|today|tonight|this (?:morning|afternoon|evening|weekend|week)|tomorrow|currently|at the moment|these days|later)\b/gi,j=new Set(["here","there","home","outside","my location","my area","my city","where i am","it","that"]),D=8,L="(?:page|tab|article|post|thread|discussion|story|site|website|doc|document|comments?|content|piece|blog(?: post)?|paper|video|readme|pdf)",le=new RegExp(`\\b(?:this|current|the current|the open|open|that)\\s+${L}\\b`,"i"),ue=new RegExp(`^\\s*(?:(?:can you |could you |please )?(?:summari[sz]e|tl;?\\s?dr|recap|give me the gist|what are the key (?:points|takeaways))(?:\\s+(?:it|this|that|here|(?:the|this)\\s+${L}(?:\\s+and\\s+(?:the\\s+)?${L})?))?|what(?:'s| is| are)? (?:people|they|folks|commenters) (?:saying|think(?:ing)?)(?: here| about (?:it|this))?)\\s*[?.!]*\\s*$`,"i"),pe=/\b(?:my|our|your|the|this|that|last|today'?s|yesterday'?s)\s+(?:meeting|chat|conversation|call|standup|notes?|email|inbox|calendar|day|week|transcript|thread with)\b|https?:\/\//i,de=/^\s*(?:(?:please|pls|can you|could you|just|ok,?|no,?|then|so|now)\s+)*(?:use (?:the )?(?:web|internet)(?: search)?|use web ?search|(?:do|run|perform|make|start|try)(?: an?| the)? (?:(?:web|internet|online|google) ?)?search|search for (?:it|that|this)|search (?:the )?(?:web|internet|online)|web ?search(?: it)?|google(?: it| that)?|look (?:it |that )?up(?: online| on the web)?|check (?:the web|online)|try (?:the )?(?:web|internet|a web search|web search)|search (?:it|that|again|online))\b(?:\s+(?:for|about)\s+(.+?))?(?:,?\s+(?:please|pls|thanks|instead|now|then))*\s*[?.!]*\s*$/i;function fe(e){const t=de.exec(String(e||""));if(!t)return null;const n=String(t[1]||"").trim();return n?{query:n}:{}}const we=/\b(?:weather|forecast|temperature|rain|snow)\b/i,ge=/\b(?:rest of (?:the|this) (?:week|weekend|month)|(?:this|next|coming) (?:week|weekend)|(?:the|this) weekend|week ahead|the week|next (?:few|several|couple of) days|coming days|(?:5|7|10|14)[- ]?days?|extended|long[- ]range|two[- ]weeks?)\b/i,be=/\b(?:i|we) (?:asked|said|wrote|told|searched|talked|discussed|mentioned|looked up|checked)\b|\b(?:did|have|had) (?:i|we)\b|\bhow (?:many|often) (?:times )?(?:i|we|did|have)\b|\bhow many times\b|\bmy (?:chats?|notes?|history|meetings?|conversations?|questions?|searches)\b|\blast time (?:i|we)\b/i,me=/\b(?:find out more|find (?:out )?more|more (?:info|information|details)|look into (?:it|that|this)|dig (?:deeper|into (?:it|that))|get more details?|find (?:it|that) out|check (?:on )?(?:it|that) (?:again|online)|search (?:for )?more|look (?:it|that) up|find (?:the )?(?:rest|full|whole)(?: of it| forecast)?)\b/i,ke=/^\s*(?:yes|yeah|yep|yup|sure|ok(?:ay)?|k|please(?: do)?|go ahead|go for it|do it|yes please|sure thing|absolutely|of course|ok look|look|search|please search|search it)(?:[\s,.!]+(?:please|thanks|thank you|go ahead|do it|look|search|yes))*[\s.!]*$/i,ye=/\b(?:search the web|web search|search online|search for|look (?:it|that|this) up|look up|check online|find (?:it|that|out|more))\b/i,$e=/(?:web search for|search the web for|search (?:online )?for|look up|look for)\s+(?:the\s+)?(.{3,160}?)(?:\s*[?.!]|$)/i;function Se(e){const t=String(e||"").split(/\n+/).map(s=>s.trim()).filter(Boolean).slice(-3).join(" ");if(ye.test(t)&&/\?/.test(t)){const s=($e.exec(t)?.[1]||"").replace(/\s+for me$/i,"").trim();if(s)return s}const n=/\b(?:searching(?: the web| online)? for|looking up|checking(?: the web| online)? for)\s+(?:the\s+)?(.{3,160}?)(?:\.\.\.|โ€ฆ|[.!?]|$)/i.exec(t);return n?n[1].trim():""}const O=/^\s*(?:(?:no|nope|actually|but|well|sorry)\b[,.!]?\s*)?(?:i|we) (?:asked|said|meant|wanted)\b/i,F=/\b(?:did|when|how (?:many|often)|earlier|before|yesterday|last (?:time|week|month)|ago|previously|other day)\b/i;function _e(e){const t=String(e||"");if(!O.test(t)||F.test(t))return"";const n=t.replace(O,"").replace(/^\s*(?:for|about)\s+/i,"").replace(/[.;]\s+(?:and|also)\s+/gi," and ").replace(/,?\s+not\s+[^.?!]*/i,"").trim();return/^(?:the\s+)?(?:weather|forecast|temperature)\b/i.test(n)?`what is ${/^the\s/i.test(n)?"":"the "}${n}`:""}function Ee(e){const t=String(e||"");return O.test(t)&&!F.test(t)?!1:be.test(t)}const Ae=/^\s*(?:and|what about|how about|now|no,?|ok,?|same for)\b[^?.!]{0,30}[?.!]*\s*$/i,je=/(?:published|posted|shared|discussed|trending|featured|submitted)\s+(?:on|in|to|at)\s+(?:the\s+)?([a-z0-9][\w.-]*(?:\s+[a-z0-9][\w.-]*)?)/i,R=e=>String(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"");function Le(e,t){if(!t||!(t.title||t.url))return!1;const n=je.exec(String(e||""));if(!n)return!1;let s="";try{s=new URL(String(t.url||"")).hostname}catch{}const o=R(`${t.title||""} ${s}`),r=n[1].split(/\s+/);return![r.join(""),r[0]].some(l=>R(l).length>=2&&o.includes(R(l)))}function q(e){const t=String(e||"").trim();return!t||t.length>300||pe.test(t)?null:le.test(t)||ue.test(t)?{}:null}function g(e){return String(e||"").replace(he," ").replace(/[?!.,;:]+$/g,"").replace(/^\s*(the|in|at|for|around|near|of)\s+/i,"").replace(/\s+/g," ").trim()}const v=/\b(how|what|what's|whats|is|are|was|will|do|does|can|should|why|when|the|a|an|tell|me|there|here|it|like|about)\b/i;function $(e){const t=e.toLowerCase();return t.length>=2&&t.length<=60&&!j.has(t)&&!v.test(t)&&!/^(weather|forecast|temperature)$/.test(t)&&/^[\p{L}]/u.test(t)&&t.split(/\s+/).length<=5}function B(e){const t=String(e||"").trim();return!W.test(t)||S(t)||/\b(?:love|like|hate|enjoy|miss|prefer)\s+(?:this|the|that|such|today's)?\s*(?:weather|forecast)\b/i.test(t)||/\b(?:api|app|apps|service|widget|feature|code|bug|model|tool|component|test|tests|data|endpoint|sdk|library|module|page|screen)\b/i.test(t)?!1:t.split(/\s+/).length<=12}const Oe=/\s+(?:for|over|during|through|in|this|next|and)?\s*(?:the\s+)?(?:rest of (?:the|this) (?:week|weekend|day|month)|next (?:few|several|couple of|\d+) days|(?:this|next|coming) (?:week|weekend|month|few days)|the (?:weekend|week(?: ahead)?|coming days)|week ahead|\d+[- ]days?(?: forecast)?)\b/gi;function S(e){const t=String(e||"").trim();if(!W.test(t))return"";const n=t.replace(Oe,"").trim();let s=/\b(?:in|at|for|around|near)\s+([^?!.;]+?)(?:\s+(?:right now|now|today|tonight|tomorrow|currently|this \w+))*\s*[?!.]*$/i.exec(n);if(s){const o=g(s[1].split(/\s+(?:and|&|vs\.?|versus|compared (?:to|with)|then|,)\s+/i)[0]);if($(o))return o;if($(g(s[1])))return g(s[1])}return s=/^(?:what(?:'s| is) the\s+)?([\p{L}][\p{L}\s,.'-]{1,60}?)\s+(?:weather|forecast|temperature)\b/iu.exec(n),s&&$(g(s[1]))&&!x.test(g(s[1]))||(s=/\b(?:weather|forecast|temperature)\s*[:\-]?\s+([\p{L}][\p{L}\s,.'-]{1,60}?)\s*[?!.]*$/iu.exec(n),s&&$(g(s[1])))?g(s[1]):""}const x=/\b(summari[sz]e|explain|try|again|retry|do|make|write|show|tell|open|read|find|search|help|stop|continue|go|list|give|send|run|check|fix|get|fetch|pull|grab|look ?up|display|compare|bring|thanks|thank|yes|no|please|this|that|my|page|note|file|meeting|chat|sounds?|good|great|nice|cool|fine|perfect|awesome|sure|nothing|else|ok|okay|yeah|yep|nope|bye|hello|hi|hey|time|traffic|news|story|joke|stock|price|you|yourself|him|her|them|us)\b/i,Re=/^(?:(?:okay|ok|alright|all right|great|cool|thanks|thank you|fine|good|and|also|then|so|now|actually|well|um+|uh+|hmm+|oh|no|wait|sorry|oops)(?:[\s,.!โ€”-]+|$))+/i,xe=/^(?:(?:i(?: want| wanted| would like|'d like) to know|i'm wondering|i wonder|(?:can|could) you (?:tell|check) (?:me)?|tell me)\s+)/i,U=/^(?:(?:how|what) about|(?:how|what)(?:'s| is|s) it(?: like)?(?: in| at| for| around| near)?|i (?:meant|mean)(?: in)?|it(?:'s|โ€™s| is|s)(?: in)?|(?:in|at|for|around|near))\b[\s,]*/i;function M(e,t){if(!t||t.kind!=="weather")return"";const n=String(e||"").trim().replace(/[?!.]+$/,"").trim(),s=n.replace(Re,"").trim().replace(xe,"").trim();if(!s||s.split(/\s+/).length>D)return"";const o=U.test(s)||s!==n&&/^(?:and|also)\b/i.test(n),r=g(s.replace(U,"").replace(/^(?:like\s+)?(?:in|at|for|around|near)\s+/i,""));return!r||/\d/.test(r)||!o&&r.split(/\s+/).length>2||!$(r)||x.test(r)?"":r}const m="([\\p{L}$][\\p{L}\\p{N}.&'-]*(?:\\s+[\\p{L}][\\p{L}\\p{N}.&'-]*){0,3})",Ce=[new RegExp(`\\b(?:share price|stock price|stock quote|ticker)\\s+(?:of|for)\\s+${m}`,"iu"),{question:!0,re:new RegExp(`\\b(?:stock|stocks|shares?)\\s+(?:of|for|in)\\s+${m}`,"iu")},new RegExp(`\\b${m}(?:'s)?\\s+(?:stock|shares)\\s+(?:price|doing|trading|today|now|performance|performing|up|down|quote)\\b`,"iu"),new RegExp(`\\b${m}(?:'s)?\\s+(?:share price|stock price|stock quote)\\b`,"iu"),new RegExp(`^\\s*${m}(?:'s)?\\s+(?:stock|shares)\\s*\\??\\s*$`,"iu"),new RegExp(`\\b(?:how|where)(?:'s| is| are)\\s+${m}\\s+(?:stock\\s+|shares\\s+)?trading\\b`,"iu"),new RegExp(`\\bwhat(?:'s| is| are)\\s+${m}\\s+trading at\\b`,"iu"),/\$([A-Z]{1,5})\b/u],Ne=/^(?:the|a|an|my|our|your|this|that|it|its|their|market|stock market|markets|price|prices|today|now|company|companies|how|what|is|are|doing|of|for|in|weather|forecast|news|time|date|temperature|rain|you|me|us|them|those|these)$/i,Pe=/^(?:how|what|what's|whats|where|is|are|was|the|a|an|can|could|you|tell|me|about|of|for|in|and|also|so|now|then|please|check|show|give|get)$/i,Te=/\s+(?:stock|stocks|shares?|price|prices|doing|trading|today|now|right now|currently|at the moment|this (?:morning|afternoon|week)|lately|so far)\b.*$/i;function I(e){const t=e.toLowerCase();return t.length>=1&&t.length<=40&&!Ne.test(t)&&!v.test(t)&&/^[\p{L}]/u.test(t)&&t.split(/\s+/).length<=4}function We(e){const t=e.split(/\s+/).filter(Boolean);for(;t.length>1&&Pe.test(t[0]);)t.shift();return t.join(" ")}function G(e){return String(e||"").replace(/[?!.,;:]+$/g,"").replace(Te,"").replace(/(?:\s+(?:at|on|up|down|for me|please))+$/i,"").replace(/^\s*(?:the|shares? of|stock of)\s+/i,"").replace(/'s$/i,"").replace(/\s+(?:corp(?:oration)?|inc|co|company|ltd)\.?$/i,t=>t).replace(/\s+/g," ").trim()}function H(e){const t=String(e||"").trim(),n=/\?\s*$/.test(t)||/^\s*(?:(?:hey|hi|ok|okay|so|and|now)[\s,]+)*(?:how|what|where|is|are|can|could|would|will|tell|check|show|give|get|find|look up|please)\b/i.test(t);for(const s of Ce){const o=s instanceof RegExp?s:s.re;if(s.question&&!n)continue;const r=o.exec(t);if(!r)continue;const l=We(G(r[1]));if(I(l))return l}return""}function J(e,t){if(!t||t.kind!=="stock")return"";let n=String(e||"").trim().replace(/[?!.]+$/,"").trim();if(!n||n.split(/\s+/).length>D)return"";n=n.replace(/^(?:(?:okay|ok|fine|good|great|thanks|thank you|cool|alright|all right|that'?s (?:fine|good|great|ok|okay))[\s,.!โ€”-]*)+/i,"").trim();const s=/^(?:(?:and|also|then|so|now)[\s,]+)*(?:how about|what about)\b/i.test(n)||/^(?:and|also)[\s,]+/i.test(n);n=n.replace(/^(?:(?:and|also|then|so|now)[\s,]+)*(?:(?:how|what) about\b)?[\s,]*/i,"").trim();const o=G(n);return!o||!s&&(o.split(/\s+/).length>2||!/[?]\s*$/.test(String(e))&&o.split(/\s+/).length>1)||!I(o)||x.test(o)?"":o}const z=new RegExp("(?<![\\p{L}\\p{N}'])\\p{L}(?:[ \\t.,\\-โ€“]{1,3}\\p{L}(?![\\p{L}\\p{N}'])){2,}","gu");function K(e){return String(e||"").replace(z,t=>t.replace(/[^\p{L}]/gu,"").toLowerCase())}function De(e){return[...String(e||"").matchAll(z)].map(t=>t[0].replace(/[^\p{L}]/gu,"").toLowerCase())}const Fe=/\b(?:tell me (?:more |everything |all |something )?about|what do you know about|do you know (?:anything )?about|who(?:'s| is| was| are)|look up|lookup|search (?:the web |online |the internet |google )?for|search up|google|find (?:out )?(?:info(?:rmation)?|details|more|anything|something|everything) (?:on|about)|(?:info|information|background|details) (?:on|about)|research)\s+(.+)$/i,qe=/[.?!;:,()](?=\s|$)|\s(?:uh|um|umm|er|erm|hmm|like|actually|i mean|sorry|the (?:first |last |sur|family )?name|his|her|their|its|it's|it is|spelled|spelt|and (?:tell|give|find|show|let|search|look)|then|please|for me|on the web|online|on google|from the web|if you can|thanks|thank you)\b/i,ve=/^(?:it|this|that|these|those|him|her|them|me|you|yourself|us|he|she|they|we|i|my|our|your|his|their|here|there|on|in|at|to|for|with|from|going|coming|speaking|talking|calling|joining|what|how|why|when|where|which|the weather|weather)\b/i,Be=/^(?:my|our|your|this|that|today'?s|yesterday'?s|last|next|latest|recent)\b/i,Ue=/^(?:the|a|an)\b/i,Me=6;function Y(e){const n=(String(e||"").split(qe)[0]||"").replace(/\s+/g," ").replace(/^["'โ€œโ€˜]+|["'โ€โ€™]+$/g,"").trim(),s=n.split(" ").filter(Boolean);return!s.length||s.length>Me||!new RegExp("\\p{L}","u").test(n)||ve.test(n)?"":n}function Ie(e){const t=Fe.exec(K(e));return t?Y(t[1]):""}const Ge=[[/\b(?:last|sur|family|second) ?name\b|\bsurname\b/i,e=>e.length-1],[/\bfirst name\b|\bgiven name\b/i,()=>0]],He=/\b(?:it(?:'s| is)|spelled|spelt|should be|is actually|actually|but|name is)\s+["'โ€œโ€˜]?([\p{L}][\p{L}'-]{1,40})["'โ€โ€™]?\s*[.!?]*\s*$/iu,Je=/\b(?:no|nope|not|wrong|incorrect|misspel\w*|spell\w*|typo|name|actually|i meant|i mean)\b/i;function ze(e,t){const n=e.toLowerCase(),s=t.toLowerCase(),o=Array.from({length:s.length+1},(r,l)=>l);for(let r=1;r<=n.length;r++){let l=o[0];o[0]=r;for(let c=1;c<=s.length;c++){const u=o[c];o[c]=Math.min(o[c]+1,o[c-1]+1,l+(n[r-1]===s[c-1]?0:1)),l=u}}return o[s.length]}function Ke(e,t){return new RegExp("^\\p{Lu}","u").test(t)?e.charAt(0).toUpperCase()+e.slice(1):e}function X(e,t){const n=String(t||"").trim();if(!n)return null;const s=String(e||""),o=De(s),r=K(s);let l=o.at(-1)||"";if(!l&&Je.test(r)&&(l=He.exec(r)?.[1]||""),!l||l.length<2)return null;const c=n.split(/\s+/);let u=-1;for(const[a,h]of Ge)if(a.test(r)){u=h(c);break}if(u<0){let a=1/0;c.forEach((h,f)=>{const k=ze(h,l)/Math.max(h.length,l.length);k<a&&(a=k,u=f)}),a>.6&&(u=c.length===1?0:-1)}if(u<0)return null;const p=c[u];return p.toLowerCase()===l.toLowerCase()?{subject:n,replaced:""}:(c[u]=Ke(l,c.find(a=>new RegExp("^\\p{Lu}","u").test(a))||p),{subject:c.join(" "),replaced:p})}const Ye=/\b(?:search|look|google|check|find|try)\b[^.?!]{0,30}\b(?:web|online|internet|google|up|again|it|him|her|them)\b|\blook(?:ing)? (?:it|that|him|her|them)? ?up\b/i,Q=/\b(?:web|online|internet|google)\b/i;function Xe(e,t){if(!t||t.kind!=="lookup"||!t.subject)return null;const n=X(e,t.subject),s=/\b(?:not|wrong|isn'?t|incorrect|nope)\b/i.test(e);return!n&&!s&&!Ye.test(e)?null:{subject:n?.subject||t.subject,replaced:n?.replaced||"",corrected:!!n||s,web:Q.test(e)}}function V(e,t){const n=Ie(e);if(n){const o=X(e.slice(e.toLowerCase().indexOf(n.toLowerCase())+n.length),n);return{kind:"lookup",subject:o?.subject||n,replaced:o?.replaced||"",corrected:!!o?.replaced,web:Q.test(e)}}const s=Xe(e,t);return s?{kind:"lookup",...s}:null}function Z(e){return Be.test(e)||/@|\d{5,}/.test(e)||!new RegExp("\\p{L}{2,}","u").test(e)?!1:!Ue.test(e)||new RegExp("\\s\\p{Lu}","u").test(e)}const Qe=/\b(?:news|headlines|stories)\s+(?:on|about|from|in|for|regarding|around)\s+(.+)$/i,Ve=/\bwhat(?:'s| is| are)\s+(?:new|happening|going on|the latest|the news)\s+(?:with|in|on|at|around|from)\s+(.+)$/i,Ze=/^(?:(?:can|could) you (?:tell|give) me |tell me |give me |show me )?(?:the |any |some )?(?:latest |recent |top |today'?s |breaking )?(.{2,60}?)\s+news(?:\s+(?:today|this (?:morning|week|evening)|right now|lately|these days))?\s*[?.!]*$/i,et=/^(?:(?:can|could) you (?:tell|give) me |tell me |give me |show me |what(?:'s| is| are) )?(?:the |any )?(?:latest |top |today'?s |breaking )?(?:news|headlines)(?:\s+(?:today|this (?:morning|week|evening)|right now))?\s*[?.!]*$/i,ee=/\s+(?:today|tonight|this (?:morning|week|evening|year)|right now|lately|these days|recently|now)$/i;function tt(e){const t=String(e||"").trim();if(!t||ie(t).length)return null;if(et.test(t))return{subject:""};const n=Qe.exec(t)||Ze.exec(t),s=n?null:Ve.exec(t),o=n||s;if(!o)return null;const r=Y(o[1].replace(/[?.!]+$/,"").replace(ee,"")).replace(ee,"");return s&&r.split(/\s+/).length>4||!r||!Z(r)||/^(?:the )?(?:weather|stock|stocks|market)$/i.test(r)?null:{subject:r}}function ft(e){return/^\s*No (?:history matches|web results)\b/.test(String(e||""))}const te=Object.freeze({page:15e3,web:12e3,lookup:12e3}),nt=6e3;function wt(e){return Object.hasOwn(te,e?.kind)?te[e.kind]:nt}const st=/^\s*(?:(?:and|also|ok(?:ay)?|so|then)[,\s]+)?(?:(?:what|how) about|how(?:'s|โ€™s| is| will| does)?(?: it| the weather| things)?(?: be| look(?:ing)?)?|is it|and|for)?\s*(?:(?:right )?now|currently|today|tonight|tomorrow(?: morning| afternoon| evening| night)?|(?:a |the )?day after tomorrow|later(?: today| tonight)?|(?:this|next|the) (?:morning|afternoon|evening|night|weekend|week)|(?:the )?rest of (?:the|this) week|(?:on |this |next )?(?:mon|tues|wednes|thurs|fri|satur|sun)day|outside|out there)\s*[?!.]*\s*$/i;function ne(e,t){if(!t||t.kind!=="weather")return"";const n=String(t.subject||"");if(!n||j.has(n.toLowerCase()))return"";const s=String(e||"").toLowerCase();return[...j].some(o=>o!=="it"&&o!=="that"&&new RegExp(`\\b${o}\\b`).test(s))?"":n}function se(e,t){return!t||t.kind!=="weather"?"":st.test(String(e||""))?String(t.subject||"here"):""}function ot(e,t){const n=S(e)||se(e,t)||M(e,t);if(n)return{kind:"weather",subject:n};if(B(e))return{kind:"weather",subject:ne(e,t)||"here"};const s=H(e)||J(e,t);if(s)return{kind:"stock",subject:s};const o=V(String(e||""),t);if(o)return o;const r=P(e,{previous:t});return r?{kind:"research",subject:r.subject,research:r}:null}function gt(e){const t=(Array.isArray(e)?e:[]).filter(o=>o&&!o.pending&&(o.role==="user"||o.role==="assistant")),n=[];for(let o=0;o<t.length;o++)t[o].role==="user"&&n.push(o);if(n.length<2)return null;let s=null;for(let o=0;o<n.length-1;o++){const r=t[n[o]],l=t[n[o]+1]?.role==="assistant"?t[n[o]+1]:null,c=(r.attachments||[]).find(h=>h?.kind==="prefetch"),u=typeof r.content=="string"?r.content:"",p=ot(u,s)||(c?{kind:c.prefetch,...c.research?{research:c.research}:{}}:null)||((l?.steps||[]).some(h=>h?.input?.action==="weather"||h?.tool==="weather")?{kind:"weather"}:null),a=rt(c?.text);s=p&&{...p,...a?{resolved:a}:s?.resolved&&s.kind===p.kind?{resolved:s.resolved}:{}}}return s}function rt(e){const t=/(?:^|\n)\w+ for ([^\n(]+?)\s*\(asked:/.exec(String(e||""));return t?t[1].trim():""}function at(e,t,n){if(!e?.resolved||e.kind!==t||/,/.test(String(n||"")))return"";const s=String(e.resolved).split(",").map(o=>o.trim()).filter(Boolean);return s.length>1?s.slice(1).join(", "):""}function bt({text:e="",previous:t=null,previousText:n="",previousAnswer:s="",reach:o=new Set,lookup:r=!1,research:l=!1,page:c=!1,tab:u=null,now:p=Date.now()}={}){const a=o instanceof Set?o:new Set(Array.isArray(o)?o:[]),h=[];if(Ee(e))return r?oe(e,t,a):[];const f=ke.test(String(e||""))?Se(s):"",k=String(e||"").trim().split(/\s+/).length,_=fe(e)||(f?{query:f}:null)||(me.test(String(e||""))&&k<=14?{}:null);if(_&&(a.has("find:web_search")||a.has("web_search"))){const i=_.query||String(n||"").trim();if(i){const d=a.has("find:web_search"),w=!_.query;return[{kind:"web",tool:d?"find":"web_search",input:d?{action:"web_search",args:{query:i}}:{query:i},label:`Web โ€” ${i.slice(0,60)}`,subject:i,...we.test(i)?{weather:!0}:{},...w?{borrowed:!0}:{}}]}}if(c&&(a.has("page:read_page")||a.has("read_page"))&&q(e)&&!Le(e,u)){const i=a.has("page:read_page"),d=Ae.test(e)&&q(n)?String(n).trim():"";return[{kind:"page",tool:i?"page":"read_page",input:i?{action:"read_page",args:{...T}}:{...T},label:"This page",...d?{ask:d}:{}}]}const E=a.has("find:weather"),re=a.has("weather");if(E||re){e=_e(e)||e;const i=S(e)?"":se(e,t),d=S(e)||(i?i!=="here"?i:"":M(e,t)),w=d||(B(e)?ne(e,t)||"here":i?"here":"");if(w){const A=w!=="here"?at(t,"weather",w):"",C=y=>E?{action:"weather",args:{location:y}}:{location:y};if(h.push({kind:"weather",tool:E?"find":"weather",input:C(w),label:d?`Weather โ€” ${d}`:"Weather โ€” near you",...d?{about:d}:{},...A?{retry:{input:C(`${w}, ${A}`),context:A.split(",")[0].trim()}}:{}}),d&&ge.test(String(e||""))&&(a.has("find:web_search")||a.has("web_search"))){const y=`${d} 10 day weather forecast`,N=a.has("find:web_search");h.push({kind:"web",tool:N?"find":"web_search",input:N?{action:"web_search",args:{query:y}}:{query:y},label:`Web โ€” ${d} extended forecast`,subject:y,weather:!0})}}}const b=a.has("find:web_search");if(!h.length&&(b||a.has("web_search"))){const i=H(e)||J(e,t);if(i){const d=`${i} stock price today`;h.push({kind:"stock",tool:b?"find":"web_search",input:b?{action:"web_search",args:{query:d}}:{query:d},label:`Stock โ€” ${i}`,about:i})}}if(!h.length&&(b||a.has("web_search"))){const i=tt(e);if(i){const d=i.subject?`${i.subject} news today`:"top news today";h.push({kind:"news",tool:b?"find":"web_search",input:b?{action:"web_search",args:{query:d}}:{query:d},label:i.subject?`News โ€” ${i.subject}`:"News โ€” today",subject:i.subject,...i.subject?{about:i.subject}:{}})}}if(l&&!h.length&&(b||a.has("web_search"))){const i=P(e,{previous:t,now:p});if(i){const d=b?"find":"web_search";h.push({kind:"research",tool:d,input:d==="find"?{action:"web_search",args:{query:i.queries[0]}}:{query:i.queries[0]},label:`Research โ€” ${i.subject}`,subject:i.subject,research:[...a].some(w=>/^(?:page:)?(?:open_tab|navigate)$/.test(w))?{...i,browse:!0}:i})}}return r&&!h.length&&h.push(...oe(e,t,a)),h}function oe(e,t,n){const s=V(String(e||""),t);if(!s)return[];const{subject:o}=s,r=s.corrected?`The user corrected the name: it is "${o}"${s.replaced?`, not "${s.replaced}"`:""} โ€” use this spelling; earlier answers in this chat were about the wrong name.`:"",l=a=>n.has(`find:${a}`)?{tool:"find",input:h=>({action:a,args:h})}:n.has(a)?{tool:a,input:h=>h}:null,c=[],u=l("history_search"),p=l("web_search");return u&&!s.web&&c.push({kind:"lookup",tool:u.tool,input:u.input({query:o}),label:`Library โ€” ${o}`,subject:o,note:r}),p&&(s.web||Z(o))&&c.push({kind:"lookup",tool:p.tool,input:p.input({query:o}),label:`Web โ€” ${o}`,subject:o,about:o,note:r,fallback:c.length>0}),c}function mt(e=[]){const t=Array.isArray(e)?e:[];for(let n=t.length-1;n>=0;n--)if(t[n]?.role==="user")return(t[n].attachments||[]).some(s=>s?.kind==="prefetch"&&String(s.text||"").trim());return!1}function kt(e){const t=typeof e=="string"?e:e&&typeof e.text=="string"?e.text:JSON.stringify(e??""),n=e&&typeof e=="object"&&typeof e.note=="string"?e.note:"";return{text:t,note:n}}function it(e,t=""){const n=String(t||"").replace(/^ChatPanel\s*ยท\s*/u,"").trim();return n&&n!=="ChatPanel"?`${e?.label||""} ยท ${n}`:e?.label||""}function ct(e){const t=String(e||"");if(!t.startsWith("{"))return t;try{const n=JSON.parse(t);return typeof n?.text!="string"?t:[typeof n.note=="string"?n.note:"",n.text,n.truncated?"(The page continues past what was read.)":""].filter(Boolean).join(`
1
+ import{researchAsk as P,runResearch as ce}from"./web-research.js";import{frontPagesAskedAbout as he}from"./site-pages.js";import{weatherFromSearch as le}from"./weather-tool.js";import{cardOf as T,CARD_SHOWN_NOTE as ue}from"./a2ui-tool-cards.js";import{PAGE_READ_ARGS as W}from"./page-context.js";const D=/(\bhow(?:'s| is| was|s) (?:the )?(?:weather|forecast|temperature)\b|\bwhat(?:'s| is|s) (?:the )?(?:weather|forecast|temperature)\b|\b(?:weather|forecast|temperature) (?:in|for|at|around|near)\b|\bis it (?:raining|snowing|hot|cold|warm|sunny|cloudy|windy)\b|\b(?:will|does) it (?:rain|snow)\b|\bhow (?:hot|cold|warm|humid|windy) is it\b|^\s*(?:weather|forecast)\b|\b(?:weather|forecast)\s*\??\s*$)/i,pe=/\b(right now|now|today|tonight|this (?:morning|afternoon|evening|weekend|week)|tomorrow|currently|at the moment|these days|later)\b/gi,j=new Set(["here","there","home","outside","my location","my area","my city","where i am","it","that"]),F=8,L="(?:page|tab|article|post|thread|discussion|story|site|website|doc|document|comments?|content|piece|blog(?: post)?|paper|video|readme|pdf)",de=new RegExp(`\\b(?:this|current|the current|the open|open|that)\\s+${L}\\b`,"i"),fe=new RegExp(`^\\s*(?:(?:can you |could you |please )?(?:summari[sz]e|tl;?\\s?dr|recap|give me the gist|what are the key (?:points|takeaways))(?:\\s+(?:it|this|that|here|(?:the|this)\\s+${L}(?:\\s+and\\s+(?:the\\s+)?${L})?))?|what(?:'s| is| are)? (?:people|they|folks|commenters) (?:saying|think(?:ing)?)(?: here| about (?:it|this))?)\\s*[?.!]*\\s*$`,"i"),we=/\b(?:my|our|your|the|this|that|last|today'?s|yesterday'?s)\s+(?:meeting|chat|conversation|call|standup|notes?|email|inbox|calendar|day|week|transcript|thread with)\b|https?:\/\//i,ge=/^\s*(?:(?:please|pls|can you|could you|just|ok,?|no,?|then|so|now)\s+)*(?:use (?:the )?(?:web|internet)(?: search)?|use web ?search|(?:do|run|perform|make|start|try)(?: an?| the)? (?:(?:web|internet|online|google) ?)?search|search for (?:it|that|this)|search (?:the )?(?:web|internet|online)|web ?search(?: it)?|google(?: it| that)?|look (?:it |that )?up(?: online| on the web)?|check (?:the web|online)|try (?:the )?(?:web|internet|a web search|web search)|search (?:it|that|again|online))\b(?:\s+(?:for|about)\s+(.+?))?(?:,?\s+(?:please|pls|thanks|instead|now|then))*\s*[?.!]*\s*$/i;function be(e){const t=ge.exec(String(e||""));if(!t)return null;const n=String(t[1]||"").trim();return n?{query:n}:{}}const me=/\b(?:weather|forecast|temperature|rain|snow)\b/i,ke=/\b(?:rest of (?:the|this) (?:week|weekend|month)|(?:this|next|coming) (?:week|weekend)|(?:the|this) weekend|week ahead|the week|next (?:few|several|couple of) days|coming days|(?:5|7|10|14)[- ]?days?|extended|long[- ]range|two[- ]weeks?)\b/i,ye=/\b(?:i|we) (?:asked|said|wrote|told|searched|talked|discussed|mentioned|looked up|checked)\b|\b(?:did|have|had) (?:i|we)\b|\bhow (?:many|often) (?:times )?(?:i|we|did|have)\b|\bhow many times\b|\bmy (?:chats?|notes?|history|meetings?|conversations?|questions?|searches)\b|\blast time (?:i|we)\b/i,$e=/\b(?:find out more|find (?:out )?more|more (?:info|information|details)|look into (?:it|that|this)|dig (?:deeper|into (?:it|that))|get more details?|find (?:it|that) out|check (?:on )?(?:it|that) (?:again|online)|search (?:for )?more|look (?:it|that) up|find (?:the )?(?:rest|full|whole)(?: of it| forecast)?)\b/i,Se=/^\s*(?:yes|yeah|yep|yup|sure|ok(?:ay)?|k|please(?: do)?|go ahead|go for it|do it|yes please|sure thing|absolutely|of course|ok look|look|search|please search|search it)(?:[\s,.!]+(?:please|thanks|thank you|go ahead|do it|look|search|yes))*[\s.!]*$/i,_e=/\b(?:search the web|web search|search online|search for|look (?:it|that|this) up|look up|check online|find (?:it|that|out|more))\b/i,Ee=/(?:web search for|search the web for|search (?:online )?for|look up|look for)\s+(?:the\s+)?(.{3,160}?)(?:\s*[?.!]|$)/i;function Ae(e){const t=String(e||"").split(/\n+/).map(s=>s.trim()).filter(Boolean).slice(-3).join(" ");if(_e.test(t)&&/\?/.test(t)){const s=(Ee.exec(t)?.[1]||"").replace(/\s+for me$/i,"").trim();if(s)return s}const n=/\b(?:searching(?: the web| online)? for|looking up|checking(?: the web| online)? for)\s+(?:the\s+)?(.{3,160}?)(?:\.\.\.|โ€ฆ|[.!?]|$)/i.exec(t);return n?n[1].trim():""}const O=/^\s*(?:(?:no|nope|actually|but|well|sorry)\b[,.!]?\s*)?(?:i|we) (?:asked|said|meant|wanted)\b/i,q=/\b(?:did|when|how (?:many|often)|earlier|before|yesterday|last (?:time|week|month)|ago|previously|other day)\b/i;function je(e){const t=String(e||"");if(!O.test(t)||q.test(t))return"";const n=t.replace(O,"").replace(/^\s*(?:for|about)\s+/i,"").replace(/[.;]\s+(?:and|also)\s+/gi," and ").replace(/,?\s+not\s+[^.?!]*/i,"").trim();return/^(?:the\s+)?(?:weather|forecast|temperature)\b/i.test(n)?`what is ${/^the\s/i.test(n)?"":"the "}${n}`:""}function Le(e){const t=String(e||"");return O.test(t)&&!q.test(t)?!1:ye.test(t)}const Oe=/^\s*(?:and|what about|how about|now|no,?|ok,?|same for)\b[^?.!]{0,30}[?.!]*\s*$/i,Re=/(?:published|posted|shared|discussed|trending|featured|submitted)\s+(?:on|in|to|at)\s+(?:the\s+)?([a-z0-9][\w.-]*(?:\s+[a-z0-9][\w.-]*)?)/i,R=e=>String(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"");function xe(e,t){if(!t||!(t.title||t.url))return!1;const n=Re.exec(String(e||""));if(!n)return!1;let s="";try{s=new URL(String(t.url||"")).hostname}catch{}const o=R(`${t.title||""} ${s}`),r=n[1].split(/\s+/);return![r.join(""),r[0]].some(l=>R(l).length>=2&&o.includes(R(l)))}function v(e){const t=String(e||"").trim();return!t||t.length>300||we.test(t)?null:de.test(t)||fe.test(t)?{}:null}function b(e){return String(e||"").replace(pe," ").replace(/[?!.,;:]+$/g,"").replace(/^\s*(the|in|at|for|around|near|of)\s+/i,"").replace(/\s+/g," ").trim()}const B=/\b(how|what|what's|whats|is|are|was|will|do|does|can|should|why|when|the|a|an|tell|me|there|here|it|like|about)\b/i;function S(e){const t=e.toLowerCase();return t.length>=2&&t.length<=60&&!j.has(t)&&!B.test(t)&&!/^(weather|forecast|temperature)$/.test(t)&&/^[\p{L}]/u.test(t)&&t.split(/\s+/).length<=5}function U(e){const t=String(e||"").trim();return!D.test(t)||_(t)||/\b(?:love|like|hate|enjoy|miss|prefer)\s+(?:this|the|that|such|today's)?\s*(?:weather|forecast)\b/i.test(t)||/\b(?:api|app|apps|service|widget|feature|code|bug|model|tool|component|test|tests|data|endpoint|sdk|library|module|page|screen)\b/i.test(t)?!1:t.split(/\s+/).length<=12}const Ce=/\s+(?:for|over|during|through|in|this|next|and)?\s*(?:the\s+)?(?:rest of (?:the|this) (?:week|weekend|day|month)|next (?:few|several|couple of|\d+) days|(?:this|next|coming) (?:week|weekend|month|few days)|the (?:weekend|week(?: ahead)?|coming days)|week ahead|\d+[- ]days?(?: forecast)?)\b/gi;function _(e){const t=String(e||"").trim();if(!D.test(t))return"";const n=t.replace(Ce,"").trim();let s=/\b(?:in|at|for|around|near)\s+([^?!.;]+?)(?:\s+(?:right now|now|today|tonight|tomorrow|currently|this \w+))*\s*[?!.]*$/i.exec(n);if(s){const o=b(s[1].split(/\s+(?:and|&|vs\.?|versus|compared (?:to|with)|then|,)\s+/i)[0]);if(S(o))return o;if(S(b(s[1])))return b(s[1])}return s=/^(?:what(?:'s| is) the\s+)?([\p{L}][\p{L}\s,.'-]{1,60}?)\s+(?:weather|forecast|temperature)\b/iu.exec(n),s&&S(b(s[1]))&&!x.test(b(s[1]))||(s=/\b(?:weather|forecast|temperature)\s*[:\-]?\s+([\p{L}][\p{L}\s,.'-]{1,60}?)\s*[?!.]*$/iu.exec(n),s&&S(b(s[1])))?b(s[1]):""}const x=/\b(summari[sz]e|explain|try|again|retry|do|make|write|show|tell|open|read|find|search|help|stop|continue|go|list|give|send|run|check|fix|get|fetch|pull|grab|look ?up|display|compare|bring|thanks|thank|yes|no|please|this|that|my|page|note|file|meeting|chat|sounds?|good|great|nice|cool|fine|perfect|awesome|sure|nothing|else|ok|okay|yeah|yep|nope|bye|hello|hi|hey|time|traffic|news|story|joke|stock|price|you|yourself|him|her|them|us)\b/i,Ne=/^(?:(?:okay|ok|alright|all right|great|cool|thanks|thank you|fine|good|and|also|then|so|now|actually|well|um+|uh+|hmm+|oh|no|wait|sorry|oops)(?:[\s,.!โ€”-]+|$))+/i,Pe=/^(?:(?:i(?: want| wanted| would like|'d like) to know|i'm wondering|i wonder|(?:can|could) you (?:tell|check) (?:me)?|tell me)\s+)/i,M=/^(?:(?:how|what) about|(?:how|what)(?:'s| is|s) it(?: like)?(?: in| at| for| around| near)?|i (?:meant|mean)(?: in)?|it(?:'s|โ€™s| is|s)(?: in)?|(?:in|at|for|around|near))\b[\s,]*/i;function I(e,t){if(!t||t.kind!=="weather")return"";const n=String(e||"").trim().replace(/[?!.]+$/,"").trim(),s=n.replace(Ne,"").trim().replace(Pe,"").trim();if(!s||s.split(/\s+/).length>F)return"";const o=M.test(s)||s!==n&&/^(?:and|also)\b/i.test(n),r=b(s.replace(M,"").replace(/^(?:like\s+)?(?:in|at|for|around|near)\s+/i,""));return!r||/\d/.test(r)||!o&&r.split(/\s+/).length>2||!S(r)||x.test(r)?"":r}const k="([\\p{L}$][\\p{L}\\p{N}.&'-]*(?:\\s+[\\p{L}][\\p{L}\\p{N}.&'-]*){0,3})",Te=[new RegExp(`\\b(?:share price|stock price|stock quote|ticker)\\s+(?:of|for)\\s+${k}`,"iu"),{question:!0,re:new RegExp(`\\b(?:stock|stocks|shares?)\\s+(?:of|for|in)\\s+${k}`,"iu")},new RegExp(`\\b${k}(?:'s)?\\s+(?:stock|shares)\\s+(?:price|doing|trading|today|now|performance|performing|up|down|quote)\\b`,"iu"),new RegExp(`\\b${k}(?:'s)?\\s+(?:share price|stock price|stock quote)\\b`,"iu"),new RegExp(`^\\s*${k}(?:'s)?\\s+(?:stock|shares)\\s*\\??\\s*$`,"iu"),new RegExp(`\\b(?:how|where)(?:'s| is| are)\\s+${k}\\s+(?:stock\\s+|shares\\s+)?trading\\b`,"iu"),new RegExp(`\\bwhat(?:'s| is| are)\\s+${k}\\s+trading at\\b`,"iu"),/\$([A-Z]{1,5})\b/u],We=/^(?:the|a|an|my|our|your|this|that|it|its|their|market|stock market|markets|price|prices|today|now|company|companies|how|what|is|are|doing|of|for|in|weather|forecast|news|time|date|temperature|rain|you|me|us|them|those|these)$/i,De=/^(?:how|what|what's|whats|where|is|are|was|the|a|an|can|could|you|tell|me|about|of|for|in|and|also|so|now|then|please|check|show|give|get)$/i,Fe=/\s+(?:stock|stocks|shares?|price|prices|doing|trading|today|now|right now|currently|at the moment|this (?:morning|afternoon|week)|lately|so far)\b.*$/i;function G(e){const t=e.toLowerCase();return t.length>=1&&t.length<=40&&!We.test(t)&&!B.test(t)&&/^[\p{L}]/u.test(t)&&t.split(/\s+/).length<=4}function qe(e){const t=e.split(/\s+/).filter(Boolean);for(;t.length>1&&De.test(t[0]);)t.shift();return t.join(" ")}function H(e){return String(e||"").replace(/[?!.,;:]+$/g,"").replace(Fe,"").replace(/(?:\s+(?:at|on|up|down|for me|please))+$/i,"").replace(/^\s*(?:the|shares? of|stock of)\s+/i,"").replace(/'s$/i,"").replace(/\s+(?:corp(?:oration)?|inc|co|company|ltd)\.?$/i,t=>t).replace(/\s+/g," ").trim()}function J(e){const t=String(e||"").trim(),n=/\?\s*$/.test(t)||/^\s*(?:(?:hey|hi|ok|okay|so|and|now)[\s,]+)*(?:how|what|where|is|are|can|could|would|will|tell|check|show|give|get|find|look up|please)\b/i.test(t);for(const s of Te){const o=s instanceof RegExp?s:s.re;if(s.question&&!n)continue;const r=o.exec(t);if(!r)continue;const l=qe(H(r[1]));if(G(l))return l}return""}function z(e,t){if(!t||t.kind!=="stock")return"";let n=String(e||"").trim().replace(/[?!.]+$/,"").trim();if(!n||n.split(/\s+/).length>F)return"";n=n.replace(/^(?:(?:okay|ok|fine|good|great|thanks|thank you|cool|alright|all right|that'?s (?:fine|good|great|ok|okay))[\s,.!โ€”-]*)+/i,"").trim();const s=/^(?:(?:and|also|then|so|now)[\s,]+)*(?:how about|what about)\b/i.test(n)||/^(?:and|also)[\s,]+/i.test(n);n=n.replace(/^(?:(?:and|also|then|so|now)[\s,]+)*(?:(?:how|what) about\b)?[\s,]*/i,"").trim();const o=H(n);return!o||!s&&(o.split(/\s+/).length>2||!/[?]\s*$/.test(String(e))&&o.split(/\s+/).length>1)||!G(o)||x.test(o)?"":o}const K=new RegExp("(?<![\\p{L}\\p{N}'])\\p{L}(?:[ \\t.,\\-โ€“]{1,3}\\p{L}(?![\\p{L}\\p{N}'])){2,}","gu");function Y(e){return String(e||"").replace(K,t=>t.replace(/[^\p{L}]/gu,"").toLowerCase())}function ve(e){return[...String(e||"").matchAll(K)].map(t=>t[0].replace(/[^\p{L}]/gu,"").toLowerCase())}const Be=/\b(?:tell me (?:more |everything |all |something )?about|what do you know about|do you know (?:anything )?about|who(?:'s| is| was| are)|look up|lookup|search (?:the web |online |the internet |google )?for|search up|google|find (?:out )?(?:info(?:rmation)?|details|more|anything|something|everything) (?:on|about)|(?:info|information|background|details) (?:on|about)|research)\s+(.+)$/i,Ue=/[.?!;:,()](?=\s|$)|\s(?:uh|um|umm|er|erm|hmm|like|actually|i mean|sorry|the (?:first |last |sur|family )?name|his|her|their|its|it's|it is|spelled|spelt|and (?:tell|give|find|show|let|search|look)|then|please|for me|on the web|online|on google|from the web|if you can|thanks|thank you)\b/i,Me=/^(?:it|this|that|these|those|him|her|them|me|you|yourself|us|he|she|they|we|i|my|our|your|his|their|here|there|on|in|at|to|for|with|from|going|coming|speaking|talking|calling|joining|what|how|why|when|where|which|the weather|weather)\b/i,Ie=/^(?:my|our|your|this|that|today'?s|yesterday'?s|last|next|latest|recent)\b/i,Ge=/^(?:the|a|an)\b/i,He=6;function X(e){const n=(String(e||"").split(Ue)[0]||"").replace(/\s+/g," ").replace(/^["'โ€œโ€˜]+|["'โ€โ€™]+$/g,"").trim(),s=n.split(" ").filter(Boolean);return!s.length||s.length>He||!new RegExp("\\p{L}","u").test(n)||Me.test(n)?"":n}function Je(e){const t=Be.exec(Y(e));return t?X(t[1]):""}const ze=[[/\b(?:last|sur|family|second) ?name\b|\bsurname\b/i,e=>e.length-1],[/\bfirst name\b|\bgiven name\b/i,()=>0]],Ke=/\b(?:it(?:'s| is)|spelled|spelt|should be|is actually|actually|but|name is)\s+["'โ€œโ€˜]?([\p{L}][\p{L}'-]{1,40})["'โ€โ€™]?\s*[.!?]*\s*$/iu,Ye=/\b(?:no|nope|not|wrong|incorrect|misspel\w*|spell\w*|typo|name|actually|i meant|i mean)\b/i;function Xe(e,t){const n=e.toLowerCase(),s=t.toLowerCase(),o=Array.from({length:s.length+1},(r,l)=>l);for(let r=1;r<=n.length;r++){let l=o[0];o[0]=r;for(let c=1;c<=s.length;c++){const p=o[c];o[c]=Math.min(o[c]+1,o[c-1]+1,l+(n[r-1]===s[c-1]?0:1)),l=p}}return o[s.length]}function Qe(e,t){return new RegExp("^\\p{Lu}","u").test(t)?e.charAt(0).toUpperCase()+e.slice(1):e}function Q(e,t){const n=String(t||"").trim();if(!n)return null;const s=String(e||""),o=ve(s),r=Y(s);let l=o.at(-1)||"";if(!l&&Ye.test(r)&&(l=Ke.exec(r)?.[1]||""),!l||l.length<2)return null;const c=n.split(/\s+/);let p=-1;for(const[a,h]of ze)if(a.test(r)){p=h(c);break}if(p<0){let a=1/0;c.forEach((h,f)=>{const w=Xe(h,l)/Math.max(h.length,l.length);w<a&&(a=w,p=f)}),a>.6&&(p=c.length===1?0:-1)}if(p<0)return null;const u=c[p];return u.toLowerCase()===l.toLowerCase()?{subject:n,replaced:""}:(c[p]=Qe(l,c.find(a=>new RegExp("^\\p{Lu}","u").test(a))||u),{subject:c.join(" "),replaced:u})}const Ve=/\b(?:search|look|google|check|find|try)\b[^.?!]{0,30}\b(?:web|online|internet|google|up|again|it|him|her|them)\b|\blook(?:ing)? (?:it|that|him|her|them)? ?up\b/i,V=/\b(?:web|online|internet|google)\b/i;function Ze(e,t){if(!t||t.kind!=="lookup"||!t.subject)return null;const n=Q(e,t.subject),s=/\b(?:not|wrong|isn'?t|incorrect|nope)\b/i.test(e);return!n&&!s&&!Ve.test(e)?null:{subject:n?.subject||t.subject,replaced:n?.replaced||"",corrected:!!n||s,web:V.test(e)}}function Z(e,t){const n=Je(e);if(n){const o=Q(e.slice(e.toLowerCase().indexOf(n.toLowerCase())+n.length),n);return{kind:"lookup",subject:o?.subject||n,replaced:o?.replaced||"",corrected:!!o?.replaced,web:V.test(e)}}const s=Ze(e,t);return s?{kind:"lookup",...s}:null}function ee(e){return Ie.test(e)||/@|\d{5,}/.test(e)||!new RegExp("\\p{L}{2,}","u").test(e)?!1:!Ge.test(e)||new RegExp("\\s\\p{Lu}","u").test(e)}const et=/\b(?:news|headlines|stories)\s+(?:on|about|from|in|for|regarding|around)\s+(.+)$/i,tt=/\bwhat(?:'s| is| are)\s+(?:new|happening|going on|the latest|the news)\s+(?:with|in|on|at|around|from)\s+(.+)$/i,nt=/^(?:(?:can|could) you (?:tell|give) me |tell me |give me |show me )?(?:the |any |some )?(?:latest |recent |top |today'?s |breaking )?(.{2,60}?)\s+news(?:\s+(?:today|this (?:morning|week|evening)|right now|lately|these days))?\s*[?.!]*$/i,st=/^(?:(?:can|could) you (?:tell|give) me |tell me |give me |show me |what(?:'s| is| are) )?(?:the |any )?(?:latest |top |today'?s |breaking )?(?:news|headlines)(?:\s+(?:today|this (?:morning|week|evening)|right now))?\s*[?.!]*$/i,te=/\s+(?:today|tonight|this (?:morning|week|evening|year)|right now|lately|these days|recently|now)$/i;function ot(e){const t=String(e||"").trim();if(!t||he(t).length)return null;if(st.test(t))return{subject:""};const n=et.exec(t)||nt.exec(t),s=n?null:tt.exec(t),o=n||s;if(!o)return null;const r=X(o[1].replace(/[?.!]+$/,"").replace(te,"")).replace(te,"");return s&&r.split(/\s+/).length>4||!r||!ee(r)||/^(?:the )?(?:weather|stock|stocks|market)$/i.test(r)?null:{subject:r}}function bt(e){return/^\s*No (?:history matches|web results)\b/.test(String(e||""))}const ne=Object.freeze({page:15e3,web:12e3,lookup:12e3}),rt=6e3;function mt(e){return Object.hasOwn(ne,e?.kind)?ne[e.kind]:rt}const at=/^\s*(?:(?:and|also|ok(?:ay)?|so|then)[,\s]+)?(?:(?:what|how) about|how(?:'s|โ€™s| is| will| does)?(?: it| the weather| things)?(?: be| look(?:ing)?)?|is it|and|for)?\s*(?:(?:right )?now|currently|today|tonight|tomorrow(?: morning| afternoon| evening| night)?|(?:a |the )?day after tomorrow|later(?: today| tonight)?|(?:this|next|the) (?:morning|afternoon|evening|night|weekend|week)|(?:the )?rest of (?:the|this) week|(?:on |this |next )?(?:mon|tues|wednes|thurs|fri|satur|sun)day|outside|out there)\s*[?!.]*\s*$/i;function se(e,t){if(!t||t.kind!=="weather")return"";const n=String(t.subject||"");if(!n||j.has(n.toLowerCase()))return"";const s=String(e||"").toLowerCase();return[...j].some(o=>o!=="it"&&o!=="that"&&new RegExp(`\\b${o}\\b`).test(s))?"":n}function oe(e,t){return!t||t.kind!=="weather"?"":at.test(String(e||""))?String(t.subject||"here"):""}function it(e,t){const n=_(e)||oe(e,t)||I(e,t);if(n)return{kind:"weather",subject:n};if(U(e))return{kind:"weather",subject:se(e,t)||"here"};const s=J(e)||z(e,t);if(s)return{kind:"stock",subject:s};const o=Z(String(e||""),t);if(o)return o;const r=P(e,{previous:t});return r?{kind:"research",subject:r.subject,research:r}:null}function kt(e){const t=(Array.isArray(e)?e:[]).filter(o=>o&&!o.pending&&(o.role==="user"||o.role==="assistant")),n=[];for(let o=0;o<t.length;o++)t[o].role==="user"&&n.push(o);if(n.length<2)return null;let s=null;for(let o=0;o<n.length-1;o++){const r=t[n[o]],l=t[n[o]+1]?.role==="assistant"?t[n[o]+1]:null,c=(r.attachments||[]).find(h=>h?.kind==="prefetch"),p=typeof r.content=="string"?r.content:"",u=it(p,s)||(c?{kind:c.prefetch,...c.research?{research:c.research}:{}}:null)||((l?.steps||[]).some(h=>h?.input?.action==="weather"||h?.tool==="weather")?{kind:"weather"}:null),a=ct(c?.text);s=u&&{...u,...a?{resolved:a}:s?.resolved&&s.kind===u.kind?{resolved:s.resolved}:{}}}return s}function ct(e){const t=/(?:^|\n)\w+ for ([^\n(]+?)\s*\(asked:/.exec(String(e||""));return t?t[1].trim():""}function ht(e,t,n){if(!e?.resolved||e.kind!==t||/,/.test(String(n||"")))return"";const s=String(e.resolved).split(",").map(o=>o.trim()).filter(Boolean);return s.length>1?s.slice(1).join(", "):""}function yt({text:e="",previous:t=null,previousText:n="",previousAnswer:s="",reach:o=new Set,lookup:r=!1,research:l=!1,page:c=!1,tab:p=null,now:u=Date.now()}={}){const a=o instanceof Set?o:new Set(Array.isArray(o)?o:[]),h=[];if(Le(e))return r?re(e,t,a):[];const f=Se.test(String(e||""))?Ae(s):"",w=String(e||"").trim().split(/\s+/).length,$=be(e)||(f?{query:f}:null)||($e.test(String(e||""))&&w<=14?{}:null);if($&&(a.has("find:web_search")||a.has("web_search"))){const i=$.query||String(n||"").trim();if(i){const d=a.has("find:web_search"),g=!$.query;return[{kind:"web",tool:d?"find":"web_search",input:d?{action:"web_search",args:{query:i}}:{query:i},label:`Web โ€” ${i.slice(0,60)}`,subject:i,...me.test(i)?{weather:!0}:{},...g?{borrowed:!0}:{}}]}}if(c&&(a.has("page:read_page")||a.has("read_page"))&&v(e)&&!xe(e,p)){const i=a.has("page:read_page"),d=Oe.test(e)&&v(n)?String(n).trim():"";return[{kind:"page",tool:i?"page":"read_page",input:i?{action:"read_page",args:{...W}}:{...W},label:"This page",...d?{ask:d}:{}}]}const E=a.has("find:weather"),ie=a.has("weather");if(E||ie){e=je(e)||e;const i=_(e)?"":oe(e,t),d=_(e)||(i?i!=="here"?i:"":I(e,t)),g=d||(U(e)?se(e,t)||"here":i?"here":"");if(g){const A=g!=="here"?ht(t,"weather",g):"",C=y=>E?{action:"weather",args:{location:y}}:{location:y};if(h.push({kind:"weather",tool:E?"find":"weather",input:C(g),label:d?`Weather โ€” ${d}`:"Weather โ€” near you",...d?{about:d}:{},...A?{retry:{input:C(`${g}, ${A}`),context:A.split(",")[0].trim()}}:{}}),d&&ke.test(String(e||""))&&(a.has("find:web_search")||a.has("web_search"))){const y=`${d} 10 day weather forecast`,N=a.has("find:web_search");h.push({kind:"web",tool:N?"find":"web_search",input:N?{action:"web_search",args:{query:y}}:{query:y},label:`Web โ€” ${d} extended forecast`,subject:y,weather:!0})}}}const m=a.has("find:web_search");if(!h.length&&(m||a.has("web_search"))){const i=J(e)||z(e,t);if(i){const d=`${i} stock price today`;h.push({kind:"stock",tool:m?"find":"web_search",input:m?{action:"web_search",args:{query:d}}:{query:d},label:`Stock โ€” ${i}`,about:i})}}if(!h.length&&(m||a.has("web_search"))){const i=ot(e);if(i){const d=i.subject?`${i.subject} news today`:"top news today";h.push({kind:"news",tool:m?"find":"web_search",input:m?{action:"web_search",args:{query:d}}:{query:d},label:i.subject?`News โ€” ${i.subject}`:"News โ€” today",subject:i.subject,...i.subject?{about:i.subject}:{}})}}if(l&&!h.length&&(m||a.has("web_search"))){const i=P(e,{previous:t,now:u});if(i){const d=m?"find":"web_search";h.push({kind:"research",tool:d,input:d==="find"?{action:"web_search",args:{query:i.queries[0]}}:{query:i.queries[0]},label:`Research โ€” ${i.subject}`,subject:i.subject,research:[...a].some(g=>/^(?:page:)?(?:open_tab|navigate)$/.test(g))?{...i,browse:!0}:i})}}return r&&!h.length&&h.push(...re(e,t,a)),h}function re(e,t,n){const s=Z(String(e||""),t);if(!s)return[];const{subject:o}=s,r=s.corrected?`The user corrected the name: it is "${o}"${s.replaced?`, not "${s.replaced}"`:""} โ€” use this spelling; earlier answers in this chat were about the wrong name.`:"",l=a=>n.has(`find:${a}`)?{tool:"find",input:h=>({action:a,args:h})}:n.has(a)?{tool:a,input:h=>h}:null,c=[],p=l("history_search"),u=l("web_search");return p&&!s.web&&c.push({kind:"lookup",tool:p.tool,input:p.input({query:o}),label:`Library โ€” ${o}`,subject:o,note:r}),u&&(s.web||ee(o))&&c.push({kind:"lookup",tool:u.tool,input:u.input({query:o}),label:`Web โ€” ${o}`,subject:o,about:o,note:r,fallback:c.length>0}),c}function $t(e=[]){const t=Array.isArray(e)?e:[];for(let n=t.length-1;n>=0;n--)if(t[n]?.role==="user")return(t[n].attachments||[]).some(s=>s?.kind==="prefetch"&&String(s.text||"").trim());return!1}function St(e){const t=typeof e=="string"?e:e&&typeof e.text=="string"?e.text:JSON.stringify(e??""),n=e&&typeof e=="object"&&typeof e.note=="string"?e.note:"",s=T(e);return s?{text:t,note:n,card:s}:{text:t,note:n}}function lt(e,t=""){const n=String(t||"").replace(/^ChatPanel\s*ยท\s*/u,"").trim();return n&&n!=="ChatPanel"?`${e?.label||""} ยท ${n}`:e?.label||""}function ut(e){const t=String(e||"");if(!t.startsWith("{"))return t;try{const n=JSON.parse(t);return typeof n?.text!="string"?t:[typeof n.note=="string"?n.note:"",n.text,n.truncated?"(The page continues past what was read.)":""].filter(Boolean).join(`
2
2
 
3
- `)}catch{return t}}function ht(e,t,{now:n=Date.now(),note:s=""}={}){if(e.kind==="web"&&e.weather&&(t=ce(t)||t),e.kind==="page"&&(t=ct(t)),e.kind==="research"){const u=String(t||""),{question:p,domain:a,subject:h,slots:f}=e.research||{};return{id:`prefetch_research_${n}`,kind:"prefetch",prefetch:"research",subject:e.subject||h||"",research:{question:p,domain:a,subject:h,slots:f},title:e.label,text:u,chars:u.length}}const o=e.kind==="page"?"this is the page they mean.":e.kind==="web"?`these are web results for "${String(e.subject||"").slice(0,80)}" โ€” answer from them; search again only with different words.`:e.kind==="stock"?`do not call ${e.tool} or any search tool again for the same company. Say the price and change it gives; if it gives none, say you could not find a current price โ€” never estimate one.`:e.kind==="lookup"?`if it is about someone or something else, or found nothing, search again with DIFFERENT words (another spelling, the other source โ€” library or web) โ€” never the same query.${e.note?` ${e.note}`:""}`:`do not call ${e.tool} or any weather/search tool again for the same place.`,r=e.kind==="lookup"||e.kind==="web"?`SEARCHED for "${e.subject}"`:e.kind==="page"?"READ the page the user has open":"FETCHED",l=e.kind==="page"&&e.ask?`
3
+ `)}catch{return t}}function ae(e,t,{now:n=Date.now(),note:s="",card:o=null}={}){const r=T({card:o});if(r)return{...ae(e,`${String(t||"")}
4
4
 
5
- The question about this page: ${e.ask.slice(0,200)}`:"",c=`(ALREADY ${r} for the question below, with ${e.tool}. Answer from this; ${o})
5
+ ${ue}`,{now:n,note:s}),card:r};if(e.kind==="web"&&e.weather&&(t=le(t)||t),e.kind==="page"&&(t=ut(t)),e.kind==="research"){const a=String(t||""),{question:h,domain:f,subject:w,slots:$}=e.research||{};return{id:`prefetch_research_${n}`,kind:"prefetch",prefetch:"research",subject:e.subject||w||"",research:{question:h,domain:f,subject:w,slots:$},title:e.label,text:a,chars:a.length}}const l=e.kind==="page"?"this is the page they mean.":e.kind==="web"?`these are web results for "${String(e.subject||"").slice(0,80)}" โ€” answer from them; search again only with different words.`:e.kind==="stock"?`do not call ${e.tool} or any search tool again for the same company. Say the price and change it gives; if it gives none, say you could not find a current price โ€” never estimate one.`:e.kind==="lookup"?`if it is about someone or something else, or found nothing, search again with DIFFERENT words (another spelling, the other source โ€” library or web) โ€” never the same query.${e.note?` ${e.note}`:""}`:`do not call ${e.tool} or any weather/search tool again for the same place.`,c=e.kind==="lookup"||e.kind==="web"?`SEARCHED for "${e.subject}"`:e.kind==="page"?"READ the page the user has open":"FETCHED",p=e.kind==="page"&&e.ask?`
6
6
 
7
- ${String(t||"")}${l}`;return{id:`prefetch_${e.kind}${e.kind==="lookup"?`_${e.input?.action||e.tool}`:""}_${n}`,kind:"prefetch",prefetch:e.kind,...e.subject?{subject:e.subject}:{},title:it(e,s),text:c,chars:c.length}}async function yt(e,{execute:t,until:n=null,now:s=()=>Date.now(),onActivity:o=()=>{},read:r=null,rerank:l=null}={}){const c=s(),u=p=>{try{o({type:"tool",name:"research",prefetched:!0,...p})}catch{}};u({phase:"start",input:e.input,summary:e.label});try{const{text:p,result:a}=await ae(e,{execute:t,until:n,now:s,read:r,rerank:l,onProgress:k=>u({phase:"progress",summary:`${e.label} โ€” ${k.label}`})});if(!p)return u({phase:"done",status:"skipped",summary:e.label,ms:s()-c}),{attachment:null,text:"",result:a,note:"",status:"skipped"};const h=a.stats,f=`${h.searches} search${h.searches===1?"":"es"} ยท ${h.sites} site${h.sites===1?"":"s"} ยท ${(h.ms/1e3).toFixed(1)} s`;return u({phase:"done",status:"ok",summary:`${e.label} โ€” ${f}`,ms:s()-c}),{attachment:ht(e,p,{now:s()}),text:p,result:a,note:f,status:"ok"}}catch(p){const a=`error: ${String(p?.message||p).slice(0,80)}`;return u({phase:"done",status:a,summary:e.label,ms:s()-c}),{attachment:null,text:"",result:null,note:"",status:a}}}export{Ee as aboutOwnPast,mt as answeredByPrefetch,at as borrowedContext,ne as carriedPlace,X as correctedSubject,K as joinSpelled,Xe as lookupFollowup,it as lookupLabel,kt as lookupResult,Ie as lookupSubject,tt as newsAsk,Se as offeredSearch,q as pageAsk,Le as placedElsewhere,ht as prefetchAttachment,wt as prefetchBudgetMs,ft as prefetchMissed,bt as prefetchPlan,gt as previousAsk,rt as resolvedOf,_e as restatedWeather,yt as runResearchItem,J as stockFollowupSubject,H as stockSubject,M as weatherFollowupPlace,se as weatherFollowupWhen,B as weatherHere,S as weatherPlace,fe as webRedoAsk};
7
+ The question about this page: ${e.ask.slice(0,200)}`:"",u=`(ALREADY ${c} for the question below, with ${e.tool}. Answer from this; ${l})
8
+
9
+ ${String(t||"")}${p}`;return{id:`prefetch_${e.kind}${e.kind==="lookup"?`_${e.input?.action||e.tool}`:""}_${n}`,kind:"prefetch",prefetch:e.kind,...e.subject?{subject:e.subject}:{},title:lt(e,s),text:u,chars:u.length}}async function _t(e,{execute:t,until:n=null,now:s=()=>Date.now(),onActivity:o=()=>{},read:r=null,rerank:l=null}={}){const c=s(),p=u=>{try{o({type:"tool",name:"research",prefetched:!0,...u})}catch{}};p({phase:"start",input:e.input,summary:e.label});try{const{text:u,result:a}=await ce(e,{execute:t,until:n,now:s,read:r,rerank:l,onProgress:w=>p({phase:"progress",summary:`${e.label} โ€” ${w.label}`})});if(!u)return p({phase:"done",status:"skipped",summary:e.label,ms:s()-c}),{attachment:null,text:"",result:a,note:"",status:"skipped"};const h=a.stats,f=`${h.searches} search${h.searches===1?"":"es"} ยท ${h.sites} site${h.sites===1?"":"s"} ยท ${(h.ms/1e3).toFixed(1)} s`;return p({phase:"done",status:"ok",summary:`${e.label} โ€” ${f}`,ms:s()-c}),{attachment:ae(e,u,{now:s()}),text:u,result:a,note:f,status:"ok"}}catch(u){const a=`error: ${String(u?.message||u).slice(0,80)}`;return p({phase:"done",status:a,summary:e.label,ms:s()-c}),{attachment:null,text:"",result:null,note:"",status:a}}}export{Le as aboutOwnPast,$t as answeredByPrefetch,ht as borrowedContext,se as carriedPlace,Q as correctedSubject,Y as joinSpelled,Ze as lookupFollowup,lt as lookupLabel,St as lookupResult,Je as lookupSubject,ot as newsAsk,Ae as offeredSearch,v as pageAsk,xe as placedElsewhere,ae as prefetchAttachment,mt as prefetchBudgetMs,bt as prefetchMissed,yt as prefetchPlan,kt as previousAsk,ct as resolvedOf,je as restatedWeather,_t as runResearchItem,z as stockFollowupSubject,J as stockSubject,I as weatherFollowupPlace,oe as weatherFollowupWhen,U as weatherHere,_ as weatherPlace,be as webRedoAsk};