@theoremjs/studio 0.3.4-next.823.ga9dd146 → 0.3.4-next.827.gdc3858d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/page/assets/{BottomSheet-CDgXiVuF.js → BottomSheet-D8l5EiVw.js} +1 -1
- package/page/assets/{ConsoleFrame-CPNRVDBo.js → ConsoleFrame-DIqBRQ6h.js} +1 -1
- package/page/assets/{DateInput-Cjk4hML1.js → DateInput-D8jgunEH.js} +1 -1
- package/page/assets/{MenuBottomSheet-Bj_mKrh6.js → MenuBottomSheet-DuECEDvN.js} +1 -1
- package/page/assets/{SchemaFields-CkL-vai_.js → SchemaFields-wBQPYJp7.js} +1 -1
- package/page/assets/{TokenizerBottomSheet-DcYu74xd.js → TokenizerBottomSheet-BQ-YVdrH.js} +1 -1
- package/page/assets/{ToolResultCharts-CYIijshR.js → ToolResultCharts-mvzwp85f.js} +1 -1
- package/page/assets/{Toolbar-DpOR5fTo.js → Toolbar-Dph7K0gF.js} +1 -1
- package/page/assets/{TraceInspector-B003cC1O.js → TraceInspector-2hKk5NX-.js} +1 -1
- package/page/assets/{TraceOverview-CRlar-s2.js → TraceOverview-D45HL0Hf.js} +1 -1
- package/page/assets/{browser-connection-DgdBd76s.js → browser-connection-qRFid-Dw.js} +1 -1
- package/page/assets/{browser-engine-CeSJcH28.js → browser-engine-CeycUzUW.js} +1 -1
- package/page/assets/{browser-transport-D2Mx-Qnc.js → browser-transport-CsUtc1Pe.js} +2 -2
- package/page/assets/{compile-DBxEJqBO.js → compile-DYCFhHk9.js} +1 -1
- package/page/assets/egress-automata-CiZ3Vt9G.js +1 -0
- package/page/assets/{encode-files-C19H5oqI.js → encode-files-BRs8C-bs.js} +1 -1
- package/page/assets/{export-agent-CqbkC1Ia.js → export-agent-B4IKwOzc.js} +1 -1
- package/page/assets/{guardrail-tester-CAdmVyuo.js → guardrail-tester-DRs_NH1q.js} +1 -1
- package/page/assets/{index-DRUuSFSA.js → index-BA2jTPWc.js} +10 -10
- package/page/assets/{json-code-DLvskcGp.js → json-code-luSNXvne.js} +1 -1
- package/page/assets/{live-messages-A9Tq-ju5.js → live-messages-BqywxVCH.js} +1 -1
- package/page/assets/{prompt-row-deJ96dq5.js → prompt-row-DrJDr0LV.js} +1 -1
- package/page/assets/{reader-DeQkPn6F.js → reader-BBrTYWFM.js} +1 -1
- package/page/assets/{registry-CaitOCn7.js → registry-CWNE3rO6.js} +1 -1
- package/page/assets/{schema-C46sNlNM.js → schema-BgiRaskO.js} +1 -1
- package/page/assets/{shaped-data-CK3-VEaY.js → shaped-data-QPeAmaJ4.js} +1 -1
- package/page/assets/{stub-BMOs6lLs.js → stub-xIKEDapD.js} +1 -1
- package/page/assets/{studio-code-pane-BlBOcJ5N.js → studio-code-pane-s5yRjP4Z.js} +1 -1
- package/page/assets/{studio-console-C0iQI2gx.js → studio-console-7f4F4Hkd.js} +1 -1
- package/page/assets/{studio-decision-BpJEfYeU.js → studio-decision-T4qrTzYI.js} +1 -1
- package/page/assets/{studio-embedding-Bd4IQNg8.js → studio-embedding-ImGGpwTU.js} +1 -1
- package/page/assets/{studio-host-console-CBpKmTKc.js → studio-host-console-BI14iMuJ.js} +2 -2
- package/page/assets/{studio-labels-DXI0kCJG.js → studio-labels-OQ5Vc2LV.js} +1 -1
- package/page/assets/{studio-live-BcW5Imw6.js → studio-live-BPbdXowP.js} +1 -1
- package/page/assets/{studio-map-2u2Sz-vZ.js → studio-map-CmgnDmVT.js} +1 -1
- package/page/assets/{studio-trace-replay-BYe5YpFb.js → studio-trace-replay-9DFss6XN.js} +1 -1
- package/page/assets/{tool-schema-Sm_QLU6x.js → tool-schema-BMdqCPG0.js} +1 -1
- package/page/assets/{trace-record-CX7Fvi-y.js → trace-record-zDKImdlA.js} +1 -1
- package/page/assets/{tree-C7Zz83Uw.js → tree-BRzl4J61.js} +1 -1
- package/page/assets/{turn-client-oo4BR2Jy.js → turn-client-u43fclzs.js} +1 -1
- package/page/assets/{types-BRkR8qiH.js → types-5TSKtfT6.js} +1 -1
- package/page/assets/{use-one-call-DqVLm9Oz.js → use-one-call-UKtYn9P2.js} +1 -1
- package/page/assets/{workspace-Bq99kF6X.js → workspace-B0zHlpWt.js} +1 -1
- package/page/index.html +16 -16
- package/page/assets/egress-automata-CpTxDNty.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jsonMode-DYGImCy6.js","assets/editor.api-BldS301e.js","assets/preload-helper-DpV6A1kQ.js","assets/editor-DjpsE8to.css","assets/studio-monaco-C20o5PnA.js","assets/studio-monaco-BkNqudm7.css","assets/jsonMode-jMDxUeWM.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{t as r}from"./preload-helper-DpV6A1kQ.js";import{t as i}from"./HStack-CqE4exX9.js";import{a,i as o,n as s,t as c}from"./inputStyles.stylex-Dmh4r-B9.js";import{m as l}from"./index-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{t as r}from"./preload-helper-DpV6A1kQ.js";import{t as i}from"./HStack-CqE4exX9.js";import{a,i as o,n as s,t as c}from"./inputStyles.stylex-Dmh4r-B9.js";import{m as l}from"./index-BA2jTPWc.js";import{a as u,o as d,t as f}from"./editor.api-BldS301e.js";import{serveMonacoWorkers as p,studioMonacoTheme as m}from"./studio-monaco-C20o5PnA.js";var h=new class{constructor(e,t,n){this._onDidChange=new f,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(n)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}}(`json`,{validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:`warning`,schemaValidation:`warning`,comments:`error`,trailingCommas:`error`},{documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0});function g(){return r(()=>import(`./jsonMode-DYGImCy6.js`),__vite__mapDeps([0,1,2,3,4,5,6]))}d.register({id:`json`,extensions:[`.json`,`.bowerrc`,`.jshintrc`,`.jscsrc`,`.eslintrc`,`.babelrc`,`.har`],aliases:[`JSON`,`json`],mimetypes:[`application/json`]}),d.onLanguage(`json`,()=>{g().then(e=>e.setupMode(h))});var _=e(t(),1),v=n(),y=20,b=8;h.setDiagnosticsOptions({validate:!0,allowComments:!1,comments:`error`,trailingCommas:`error`,schemaValidation:`ignore`,schemaRequest:`ignore`}),h.setModeConfiguration({documentFormattingEdits:!0,documentRangeFormattingEdits:!0,diagnostics:!0,foldingRanges:!0,selectionRanges:!0,tokens:!0});var x=p(),S={language:`json`,automaticLayout:!0,editContext:!1,fixedOverflowWidgets:!0,folding:!0,fontFamily:`var(--font-family-code)`,fontSize:12,formatOnPaste:!0,glyphMargin:!1,guides:{bracketPairs:!1,indentation:!1},hideCursorInOverviewRuler:!0,lineDecorationsWidth:0,lineHeight:y,lineNumbers:`off`,lineNumbersMinChars:0,links:!1,minimap:{enabled:!1},occurrencesHighlight:`off`,overviewRulerBorder:!1,overviewRulerLanes:0,padding:{top:b,bottom:b},quickSuggestions:!1,renderLineHighlight:`none`,scrollbar:{alwaysConsumeMouseWheel:!1,handleMouseWheel:!1,horizontal:`hidden`,vertical:`hidden`},scrollBeyondLastLine:!1,selectionHighlight:!1,showFoldingControls:`mouseover`,stickyScroll:{enabled:!1},suggestOnTriggerCharacters:!1,tabSize:2,wordBasedSuggestions:`off`,wordWrap:`on`,wrappingIndent:`indent`};function C({label:e,value:t,placeholder:n,fills:r,status:d,onChange:f}){let p=(0,_.useId)(),h=(0,_.useRef)(null),g=(0,_.useRef)(void 0),b=(0,_.useRef)({value:t,placeholder:n,fills:r,onChange:f});return b.current={value:t,placeholder:n,fills:r,onChange:f},(0,_.useEffect)(()=>{let t=h.current;if(!t)return;let n=!1;return x.then(()=>{if(n)return;let r=u.create(t,{...S,ariaLabel:e,placeholder:b.current.placeholder,theme:m(),value:b.current.value});g.current=r;let i=()=>{let e=((r.getValue()===``?b.current.placeholder:void 0)?.split(`
|
|
3
3
|
`).length??1)*y+16;t.style.height=`${String(Math.max(r.getContentHeight(),e))}px`};r.onDidContentSizeChange(i),r.onDidChangeModelContent(()=>{let e=r.getValue();e!==b.current.value&&b.current.onChange(e)}),r.onKeyDown(e=>{let{value:t,fills:n,onChange:r}=b.current;l(t,n,r)(e.browserEvent)}),i()}),()=>{n=!0,g.current?.dispose(),g.current=void 0}},[e]),(0,_.useEffect)(()=>{g.current&&g.current.getValue()!==t&&g.current.setValue(t)},[t]),(0,v.jsx)(a,{label:e,isLabelHidden:!0,inputID:p,status:d,children:(0,v.jsx)(i,{xstyle:[o.base,d&&c[d.type],d&&s[d.type]],className:`json-code`,children:(0,v.jsx)(`div`,{ref:h,id:p,className:`json-code-host`})})})}export{C as JsonCode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,E as t,O as n,b as r,c as i,d as a,h as o,v as s,x as c}from"./schemas-D7cgkv3L.js";import{$n as l,Un as u,Xn as d,rr as f}from"./tool-schema-
|
|
1
|
+
import{C as e,E as t,O as n,b as r,c as i,d as a,h as o,v as s,x as c}from"./schemas-D7cgkv3L.js";import{$n as l,Un as u,Xn as d,rr as f}from"./tool-schema-BMdqCPG0.js";import{C as p,M as m,O as h,j as g}from"./reader-BBrTYWFM.js";import{n as _}from"./trace-schema--4IGmLeE.js";import{w as v}from"./turn-client-u43fclzs.js";var y=c({type:s(`open`),history:a(l).optional(),options:e(t(),t()).optional(),context:n().optional(),stated:h.optional(),model:t().optional(),effort:t().optional(),resume:c({providerState:f,awayMs:r().nonnegative()}).optional(),host:e(t(),n()).optional()}),b=o(`type`,[c({type:s(`audio`),data:t()}),c({type:s(`video`),data:t(),mimeType:t()}),c({type:s(`text`),text:t()}),c({type:s(`context`),context:n()}),c({type:s(`executeTool`),callId:t().min(1),operationId:t().min(1).max(256),decision:i(v).optional(),input:n().optional(),secret:t().optional(),output:n().optional(),grantId:t().min(1).optional(),unanswered:s(!0).optional()})]),x={ready:c({type:s(`ready`),profile:t().optional(),sessionId:t().optional()}),events:c({type:s(`events`),events:a(n())}),trace:c({type:s(`trace`),record:_}),error:c({type:s(`error`)}).and(p),executeToolResult:o(`status`,[c({type:s(`executeToolResult`),callId:t().min(1),operationId:t().min(1).max(256),status:s(`dispatched`),grantId:t().min(1),arguments:e(t(),n())}),c({type:s(`executeToolResult`),callId:t(),status:s(`settled`),operationId:t().min(1).max(256)}),c({type:s(`executeToolResult`),callId:t(),status:s(`gated`),operationId:t().min(1).max(256),gate:d}),c({type:s(`executeToolResult`),callId:t(),status:s(`refused`),operationId:t().min(1).max(256),body:p})])};function S(e){let t=g(x,e);return t.type===`events`?{type:`events`,events:t.events.map(e=>m(u,e))}:t}export{y as n,S as r,b as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n,r,u as i}from"./themeProps-Bo2jNkIC.js";import{g as a,m as o}from"./tokens.stylex-a4pw9QVe.js";import{n as s,t as c}from"./LayoutContent-ClBE78rU.js";import{t as l}from"./Stack-De5MY0tq.js";import{t as u}from"./mergeProps-ptS-gIMz.js";import{c as d,r as f,t as p}from"./Icon-Cluq4EiW.js";import{t as m}from"./Token-BZrQH6-I.js";import{t as h}from"./isRenderable-DHkzpAoQ.js";import{t as g}from"./rtlStyles-CVVETNV7.js";import{p as _}from"./useTooltip-ClCeZiOV.js";import{t as v}from"./VisuallyHidden-Dfmmn1_I.js";import{s as y,t as b}from"./Button-98PahHB4.js";import{a as ee,o as te,r as ne,t as re}from"./TextInput-BRBEgg_h.js";import{t as ie}from"./Tooltip-Dhy5lIDA.js";import{t as ae}from"./createReactComponent-DVEyVJ-p.js";import{m as oe}from"./compile-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n,r,u as i}from"./themeProps-Bo2jNkIC.js";import{g as a,m as o}from"./tokens.stylex-a4pw9QVe.js";import{n as s,t as c}from"./LayoutContent-ClBE78rU.js";import{t as l}from"./Stack-De5MY0tq.js";import{t as u}from"./mergeProps-ptS-gIMz.js";import{c as d,r as f,t as p}from"./Icon-Cluq4EiW.js";import{t as m}from"./Token-BZrQH6-I.js";import{t as h}from"./isRenderable-DHkzpAoQ.js";import{t as g}from"./rtlStyles-CVVETNV7.js";import{p as _}from"./useTooltip-ClCeZiOV.js";import{t as v}from"./VisuallyHidden-Dfmmn1_I.js";import{s as y,t as b}from"./Button-98PahHB4.js";import{a as ee,o as te,r as ne,t as re}from"./TextInput-BRBEgg_h.js";import{t as ie}from"./Tooltip-Dhy5lIDA.js";import{t as ae}from"./createReactComponent-DVEyVJ-p.js";import{m as oe}from"./compile-DYCFhHk9.js";import{t as se}from"./IconFilter-DYCjUyWk.js";import{i as ce}from"./types-5TSKtfT6.js";import{t as le,u as ue}from"./CheckboxInput-nEEHX5M1.js";import{t as de}from"./useTranslator-Ba7ULSHc.js";import{t as fe}from"./HStack-CqE4exX9.js";import{t as pe}from"./IconButton-Jbcy-K-d.js";import{a as me,i as he,n as ge,r as _e,t as ve}from"./inputStyles.stylex-Dmh4r-B9.js";import{t as ye}from"./useClipboard-CAtohmvr.js";import{l as be,n as xe,r as Se}from"./highlightRanges-B7TRPq9q.js";import{t as Ce}from"./Toolbar-Dph7K0gF.js";import{t as we}from"./LayoutFooter-QMRRAZfF.js";import{t as Te}from"./Dialog-C2GP5P7V.js";import{H as Ee,a as De,d as Oe,et as ke,f as Ae,gt as je,h as Me,nt as Ne,p as Pe,pt as Fe,rt as Ie,tt as Le}from"./index-BA2jTPWc.js";var Re=ae(`outline`,`share-off`,`ShareOff`,[[`path`,{d:`M3 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-0`}],[`path`,{d:`M15 6a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M15.861 15.896a3 3 0 0 0 4.265 4.22m.578 -3.417a3.012 3.012 0 0 0 -1.507 -1.45`,key:`svg-2`}],[`path`,{d:`M8.7 10.7l1.336 -.688m2.624 -1.352l2.64 -1.36`,key:`svg-3`}],[`path`,{d:`M8.7 13.3l6.6 3.4`,key:`svg-4`}],[`path`,{d:`M3 3l18 18`,key:`svg-5`}]]),x=e(t(),1);function ze(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);return n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function S(e,...t){throw ze(e,...t)}function Be(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Ve(){return typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0}var He=Ve();function Ue(){return He&&`documentMode`in document?document.documentMode:null}var We=Ue();function Ge(e){return He&&e.test(navigator.platform)}function Ke(e){return He&&e.test(navigator.userAgent)}var qe=Ge(/Mac|iPod|iPhone|iPad/),Je=Ke(/^(?!.*Seamonkey)(?=.*Firefox).*/i);function Ye(){return!(!He||!(`InputEvent`in window)||We)&&`getTargetRanges`in new window.InputEvent(`input`)}var Xe=Ye();function Ze(){return He&&!window.MSStream&&(/iPad|iPhone|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&navigator.maxTouchPoints>1)}var Qe=Ze(),$e=Ke(/Android/),et=Ke(/Version\/[\d.]+.*Safari/)&&!$e,tt=Ke(/^(?=.*Chrome).*/i),nt=He&&$e&&tt,rt=Ke(/AppleWebKit\/[\d.]+/)&&qe&&!tt;function it(){return 2047}var at=it(),ot=et||Qe||rt?`\xA0`:``,st=`
|
|
2
2
|
|
|
3
3
|
`,ct=Je?`\xA0`:ot,lt={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},ut={directionless:1,unmergeable:2},dt={center:2,end:6,justify:4,left:1,right:3,start:5};function ft(e){let t={};for(let n of Object.keys(e))t[e[n]]=n;return t}var pt=ft(dt),mt={normal:0,segmented:2,token:1},ht=ft(mt),gt=Symbol.for(`@lexical/ctrlOrOtherKey`),_t=`$config`;function vt(){return Hu()._blockCursorElement}function yt(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-slot`)}var bt=rt||Qe||et;function xt(){let e=V().createElement(`img`);e.setAttribute(`data-lexical-decorator-boundary`,`true`),e.alt=``;for(let[t,n]of[[`position`,`absolute`],[`width`,`0px`],[`height`,`0px`],[`border`,`0px`],[`margin`,`0px`],[`padding`,`0px`]])e.style.setProperty(t,n,`important`);return e}function St(e){return e!==null&&e.nodeType===1&&e.hasAttribute(`data-lexical-decorator-boundary`)}var Ct=class e{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}insertChild(e){let t=this.getInsertionAnchor();return t!==null&&t.parentElement!==this.element&&S(357),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&S(358),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&S(359),this.element.replaceChild(e,t),this}getFirstChild(){let e=this.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;return t===this.getInsertionAnchor()?null:t}getFirstChildAnchor(){return this.after}resolveLeafPosition(e,t,n){if(this.element===e)return t===e&&n===0?`before`:`after`;let r=wt(e,this.element);if(r===null)return`after`;let i=Array.prototype.indexOf.call(e.childNodes,r);if(i<0)return`after`;if(t===e)return n<=i?`before`:`after`;let a=wt(e,t);if(a===null)return`after`;let o=Array.prototype.indexOf.call(e.childNodes,a);return o>=0&&o<=i?`before`:`after`}getInsertionAnchor(){return this.before}};function wt(e,t){let n=t;for(;n!==null&&n.parentNode!==e;)n=n.parentNode;return n}var Tt=class e extends Ct{withBefore(t){return new e(this.element,t,this.after)}withAfter(t){return new e(this.element,this.before,t)}withElement(t){return this.element===t?this:new e(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()||this.getDecoratorBoundaryAnchor(`trailing`)}getFirstChildAnchor(){let e=super.getFirstChildAnchor(),t=e?e.nextSibling:this.element.firstChild;for(;yt(t);)e=t,t=t.nextSibling;St(t)&&(e=t,t=t.nextSibling);let n=e?e.nextSibling:this.element.firstChild;return n!==null&&n===vt()?n:e}getDecoratorBoundaryAnchor(e){let t;if(e===`leading`){let e=super.getFirstChildAnchor();for(t=e?e.nextSibling:this.element.firstChild;yt(t);)t=t.nextSibling}else t=this.before?this.before.previousSibling:this.element.lastChild,t!==null&&t===vt()&&(t=t.previousSibling);return St(t)?t:null}setDecoratorBoundaryAnchor(e,t){let n=this.getDecoratorBoundaryAnchor(e);if(t!==(n!==null)){if(n!==null)this.element.removeChild(n);else if(e===`leading`){let e=this.getFirstChildAnchor();this.element.insertBefore(xt(),e?e.nextSibling:this.element.firstChild)}else this.element.insertBefore(xt(),this.before)}}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){let t=this.element,n=this.after===null?t.firstChild:this.after.nextSibling,r=e===`empty`&&yt(n)?null:e;if(t.__lexicalLastChildKind!==r){if(t.__lexicalLastChildKind=r,r===null)this.removeManagedLineBreak();else{let e=r===`decorator`&&bt;this.insertManagedLineBreak(e)}}}removeManagedLineBreak(){let e=this.getManagedLineBreak();if(e){let t=this.element,n=e.nodeName===`IMG`?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){let t=this.getManagedLineBreak();if(t){if(e===(t.nodeName===`IMG`))return;this.removeManagedLineBreak()}let n=this.element,r=this.before||this.getDecoratorBoundaryAnchor(`trailing`),i=V().createElement(`br`);if(i.setAttribute(`data-lexical-managed-linebreak`,`true`),n.insertBefore(i,r),e){let e=V().createElement(`img`);e.setAttribute(`data-lexical-managed-linebreak`,`true`),e.style.setProperty(`display`,`inline`,`important`),e.style.setProperty(`border`,`0px`,`important`),e.style.setProperty(`margin`,`0px`,`important`),e.alt=``,n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=this.getFirstChild(),t=this.getInsertionAnchor(),n=0;for(let r=this.element.firstChild;r!==null&&r!==e&&r!==t;r=r.nextSibling)n++;return n}resolveChildIndex(e,t,n,r){if(n===this.element){let t=this.getFirstChildOffset(),n=vt(),i=this.element.childNodes,a=Math.min(r,i.length),o=0;for(let e=t;e<a;e++)i[e]!==n&&o++;return[e,Math.min(o,e.getChildrenSize())]}let i=Et(t,n);i.push(r);let a=Et(t,this.element),o=e.getIndexWithinParent();for(let e=0;e<a.length;e++){let t=i[e],n=a[e];if(t===void 0||t<n)break;if(t>n){o+=1;break}}return[e.getParentOrThrow(),o]}};function Et(e,t){let n=[],r=t;for(;r!==e&&r!==null;r=r.parentNode){let e=0;for(let t=r.previousSibling;t!==null;t=t.previousSibling)e++;n.push(e)}return r!==e&&S(225),n.reverse()}function Dt(){let e;try{e=`0.52.0+prod.esm`}catch{}return e??`"<unknown>+source"`}var Ot=Dt(),kt=class{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(e){return delete this._cache,this._front.has(e)||this._back.add(e),this}addFront(e){return delete this._cache,this._back.has(e)||this._front.add(e),this}delete(e){return delete this._cache,this._front.delete(e)||this._back.delete(e)}toArray(){let e=Array.from(this._front).reverse();for(let t of this._back)e.push(t);return e}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}},At=null;function jt(e,t=1e3){return e instanceof Mt?e.clone():e.size<t?new Map(e):new Mt().init(new Map(e),void 0,e.size)}var Mt=class e{_mutable=!1;_old=void 0;_nursery=void 0;_size=0;clone(){return this._mutable=!1,new e().init(this._old,this._nursery,this._size)}init(e,t,n){return this._old=e,this._nursery=t,this._size=n,this}get size(){return this._size}has(e){return this.get(e)!==void 0}getWithTombstone(e){let t=this._nursery&&this._nursery.get(e);return t===void 0?this._old&&this._old.get(e):t}get(e){let t=this.getWithTombstone(e);return t===At?void 0:t}shouldCompact(){return this._nursery!==void 0&&2*this._nursery.size>this._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(e=!1){if(this._nursery&&this._nursery.size>0&&(e||this.shouldCompact())){let e=new Map(this._old);for(let[t,n]of this._nursery)n===At?e.delete(t):e.set(t,n);this._old=e,this._nursery=void 0}return this._mutable=!1,this}set(e,t){let n=this.getWithTombstone(e);if(n===t)return this;let r=this.getNursery();return n!==At&&n!==void 0||(this._size++,n===At&&r.delete(e)),r.set(e,t),this}delete(e){let t=this.has(e);return t&&(this.getNursery().set(e,At),this._size--),t}getOrInsert(e,t){let n=this.get(e);return n===void 0?(this.set(e,t),t):n}getOrInsertComputed(e,t){let n=this.get(e);if(n!==void 0)return n;let r=t(e);return this.set(e,r),r}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(let e of this.entries())yield e[0]}*values(){for(let e of this.entries())yield e[1]}*entries(){let e=this._nursery,t=this._old;if(e){if(t)for(let n of t){let t=n[0],r=e.get(t);r!==At&&(r!==void 0&&(n[1]=r),yield n)}for(let n of e)n[1]===At||t&&t.has(n[0])||(yield n)}else t&&(yield*t)}forEach(e,t){t!==void 0&&(e=e.bind(t));for(let[t,n]of this.entries())e(n,t,this)}get[Symbol.toStringTag](){return`GenMap`}[Symbol.iterator](){return this.entries()}},Nt=!1;function Pt(e,t,...n){let r=Nt,i;try{Nt=e,i=t()}finally{Nt=r}var a;return(a=i)===null||typeof a!=`object`&&typeof a!=`function`||typeof a.then!=`function`||S(421),i}function Ft(){return Nt}function It(e){let t=e.exportJSON(Nt),n=e.constructor;return t.type!==n.getType()&&S(130,n.name),M(e)&&!Array.isArray(t.children)&&S(59,n.name),t}function Lt(e,t,n,r,i,a){if(M(e)){let o=e.getFirstChild();for(;o!==null;){let e=o.__key;o.__parent===t&&((M(o)||Id(o)&&o.__slots!==null)&&Lt(o,e,n,r,i,a),n.has(e)||a.delete(e),i.push(e)),o=o.getNextSibling()}}for(let o of Id(e)&&e.__slots!==null?e.__slots.values():[]){let e=r.get(o);e!==void 0&&Ld(e)&&e.__slotHost===t&&((M(e)||Id(e)&&e.__slots!==null)&&Lt(e,o,n,r,i,a),n.has(o)||a.delete(o),i.push(o))}}var Rt=!1,zt=0;function Bt(e){zt=e.timeStamp}function Vt(e,t,n){let r=e.nodeName===`BR`,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&El(e,n)!==void 0}function Ht(e,t,n){let r=_u(su(n)),i=r&&Eu(r,n._rootElement),a=null,o=null;i!==null&&i.anchorNode===e&&(a=i.anchorOffset,o=i.focusOffset);let s=e.nodeValue;s!==null&&Rl(t,s,a,o,!1)}function Ut(e,t,n){if(O(e)){let t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return ml(t)&&n.isAttached()}function Wt(e,t,n){for(let r=e;r&&!nd(r);r=$l(r)){let e=El(r,t);if(e!==void 0){let t=I(e,n);if(t)return N(t)||!H(r)?void 0:[r,t]}}}function Gt(e,t,n){Rt=!0;let r=performance.now()-zt>100;try{ec(e,()=>{let i=A()||function(e){return e.read(`latest`,()=>{let e=A();return e===null?null:e.clone()})}(e),a=new Map,o=e._editorState,s=e._blockCursorElement,c=!1,l=``;for(let n=0;n<t.length;n++){let u=t[n],d=u.type,f=u.target,p=Wt(f,e,o);if(!p)continue;let[m,h]=p;if(d===`characterData`)r&&D(h)&&ml(f)&&Ut(i,f,h)&&Ht(f,h,e);else if(d===`childList`){c=!0;let t=u.addedNodes;for(let n=0;n<t.length;n++){let r=t[n],i=wl(r),a=r.parentNode;if(!(a==null||r===s||i!==null||Vt(r,a,e)||St(r)||e._slotsUsed&&H(r)&&r.hasAttribute(`data-lexical-slot`)||nd(r))){if(Je){let e=(H(r)?r.innerText:null)||r.nodeValue;e&&(l+=e)}a.removeChild(r)}}let n=u.removedNodes,r=n.length;if(r>0){let t=0;for(let i=0;i<r;i++){let r=n[i];Vt(r,f,e)||s===r?(f.appendChild(r),t++):St(r)&&t++}r!==t&&a.set(m,h)}}}if(a.size>0)for(let[t,n]of a)n.reconcileObservedMutation(t,e);let u=n.takeRecords();if(u.length>0){for(let t=0;t<u.length;t++){let n=u[t],r=n.addedNodes,i=n.target;for(let t=0;t<r.length;t++){let n=r[t],a=n.parentNode;a==null||n.nodeName!==`BR`||Vt(n,i,e)||a.removeChild(n)}}n.takeRecords()}i!==null&&(c&&R(i),Je&&Zl(e)&&i.insertRawText(l))})}finally{Rt=!1}}function Kt(e){let t=e._observer;t!==null&&Gt(e,t.takeRecords(),t)}function qt(e){(function(e){zt===0&&su(e).addEventListener(`textInput`,Bt,!0)})(e),e._observer=new MutationObserver((t,n)=>{Gt(e,t,n)})}function Jt(e,t,n){let{isEqual:r}=e;return t===n||r!==void 0&&r(t,n)}function Yt(e,t){return Jt(e,t,e.defaultValue)}function Xt(e){return typeof e==`object`&&!!e}function Zt(e,t){let n=nn(e,t).getter;return Xt(n)&&n.getterTable!==void 0||S(405,t),tn(n.getterTable)}function Qt(e,t){let n=nn(e,t).setter;return Xt(n)&&n.setterTable!==void 0||S(406,t),tn(n.setterTable)}function $t(e,t,n){let{meta:r}=nn(e,t);for(let e=0;;)if(r.kind===`aliased`){if(e===n)return tn(r.aliases);e++,r=r.inner.meta}else r.kind===`nullable`||r.kind===`optional`?r=r.inner.meta:r.kind===`array`?r=r.item.meta:S(407,t,String(n))}function en(e,t){let n=nn(e,t),{setter:r}=n;Xt(r)&&r.setterTable!==void 0||S(408,t);let i=String(n.defaultValue);return fn(r.setterTable,i)||S(409,t,i),r.setterTable[i]}function tn(e){return Object.assign(Object.create(null),e)}function nn(e,t){let n=e.get(t);return n===void 0&&S(410,t),n}function rn(e,t,n,r,i){i!==void 0&&an.add(i);let a=n===void 0,o=a?e(void 0):n;return a&&cn(o),Object.assign(e,{accepts:i,defaultValue:o,isEqual:r,meta:t})}var an=new WeakSet,on=new WeakSet;function sn(e){return typeof e==`object`&&e&&on.add(e),e}function cn(e){if(typeof e==`object`&&e&&!Object.isFrozen(e)&&!on.has(e)){Object.freeze(e);for(let t of Object.values(e))cn(t)}}function ln(e){let{isEqual:t}=e;return t===void 0?void 0:(e,n)=>e==null||n==null?e===n:t(e,n)}function un(e,t){return n=>t(n)||dn(e,n)}function dn(e,t){let{accepts:n}=e;return n===void 0?function(e,t){let{accepts:n}=e;if(n!==void 0)return dn(e,t)?{parsed:e(t)}:void 0;let r=e(t);return Yt(e,r)&&t!==e.defaultValue?void 0:{parsed:r}}(e,t)!==void 0:n.call(e,t)}function fn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function pn(e=``){return rn(t=>typeof t==`string`?t:e,{kind:`string`},void 0,void 0,e=>typeof e==`string`)}var mn=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function hn(e=0,t={}){let{integer:n,clamp:r}=t,i=n&&t.min!==void 0?Math.ceil(t.min):t.min,a=n&&t.max!==void 0?Math.floor(t.max):t.max,o=e=>typeof e==`string`&&mn.test(e)?Number(e):e,s=e=>typeof e==`number`&&Number.isFinite(e)&&(!n||Number.isInteger(e)),c=e=>s(e)&&(i===void 0||e>=i)&&(a===void 0||e<=a);return rn(t=>{let n=o(t);return r&&s(n)?i!==void 0&&n<i?i:a!==void 0&&n>a?a:n:c(n)?n:e},{clamp:r,integer:n,kind:`number`,max:a,min:i},void 0,void 0,e=>r?s(o(e)):c(o(e)))}function gn(e=!1){return rn(t=>typeof t==`boolean`?t:e,{kind:`boolean`},void 0,void 0,e=>typeof e==`boolean`)}function _n(e,...t){let n=sn(t.length===0?e[0]:t[0]),r=new Set(e);return rn(e=>e!==void 0&&r.has(e)?e:n,{kind:`enum`,values:e},n,void 0,e=>r.has(e)&&(e!==void 0||n===void 0))}function vn(e,t={}){let{defaultAsNull:n}=t;return rn(t=>{if(t==null)return null;let r=e(t);return n&&Yt(e,r)?null:r},{defaultAsNull:n,inner:e,kind:`nullable`},void 0,ln(e),un(e,e=>e==null))}function yn(e,t={}){let{omitDefault:n}=t;return rn(t=>{if(t===void 0)return;let r=e(t);return n&&Yt(e,r)?void 0:r},{inner:e,kind:`optional`,omitDefault:n},void 0,ln(e),un(e,e=>e===void 0))}function bn(){return e=>function(e){return{meta:{fields:e,kind:`node`}}}(e)}function xn(e,t){let n=e=>typeof e==`string`&&fn(t,e);return rn(r=>n(r)?t[r]:e(r),{aliases:t,inner:e,kind:`aliased`},e.defaultValue,e.isEqual,t=>n(t)||dn(e,t))}function Sn(e){return rn(t=>{if(!Array.isArray(t))return[];let n=Array(t.length);for(let r=0;r<t.length;r++)n[r]=e(t[r]);return n},{item:e,kind:`array`},void 0,(t,n)=>{if(!Array.isArray(t)||!Array.isArray(n)||t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!Jt(e,t[r],n[r]))return!1;return!0},e=>Array.isArray(e))}function Cn(e,t){return Tn(0,e,{getter:{field:t.field,getterTable:t.getterTable,method:t.getter,when:t.when},setter:{field:t.field,method:t.setter,setterTable:t.setterTable}})}function wn(e,t){return Tn(0,e,t)}function Tn(e,t,n){return Object.assign(e=>t(e),{accepts:t.accepts,defaultValue:t.defaultValue,getter:n.getter,isEqual:t.isEqual,meta:t.meta,setter:n.setter})}var En=`latest`,Dn=class{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;schema;constructor(e,t){this.key=e;let n=`meta`in(r=t.parse)&&typeof r.meta==`object`&&r.meta!==null&&`kind`in r.meta&&typeof r.meta.kind==`string`&&`defaultValue`in r?t.parse:void 0;var r;this.schema=n,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Ln).bind(t),this.isEqual=t.isEqual?t.isEqual.bind(t):n!==void 0&&n.isEqual!==void 0?(e,t)=>Jt(n,e,t):Object.is,this.defaultValue=n===void 0?this.parse(void 0):n.defaultValue,this.resetOnCopyNode=t.resetOnCopyNode||!1}};function On(e,t){return new Dn(e,t)}function kn(e,t,n=En){let r=(n===`latest`?e.getLatest():e).__state;return r?r.getValue(t):t.defaultValue}function An(e,t,n){let r;if(Ns(),typeof n==`function`){let i=e.getLatest(),a=kn(i,t);if(r=n(a),t.isEqual(a,r))return i}else r=n;let i=e.getWritable();return Pn(i).updateFromKnown(t,r),i}function jn(e){let t=new Map,n=new Set;for(let{ownNodeConfig:r}of Ad(typeof e==`function`?e:e.replace))if(r&&r.stateConfigs)for(let e of r.stateConfigs){let r;`stateConfig`in e?(r=e.stateConfig,e.flat&&n.add(r.key)):r=e,t.set(r.key,r)}return{flatKeys:n,sharedConfigMap:t}}var Mn=new Set([`__proto__`,`constructor`,`prototype`]),Nn=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;let{sharedConfigMap:a}=this.sharedNodeState,o=i===void 0?function(e,t,n){let r=n.size;if(t)for(let i in t){let t=e.get(i);t&&n.has(t)||r++}return r}(a,n,r):i;this.size=o}getValue(e){let t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){let t=this.unknownState[e.key];t!==void 0&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){let e={...this.unknownState},t={};for(let[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(let n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return In(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;let{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(let[i,a]of Object.entries(n)){if(Mn.has(i))continue;let n=e.get(i);n?t.has(n)||t.set(n,n.parse(a)):(r||={},r[i]=a)}return r}(n.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(let e of this.knownState.keys())e.resetOnCopyNode&&this.knownState.set(e,e.defaultValue);return this}updateFromKnown(e,t){let n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);let{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=In(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){if(Mn.has(e))return;let n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){let{knownState:t}=this;for(let e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(let[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function Pn(e){let t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new Nn(t,function(e){return e.__state?e.__state.sharedNodeState:il(Hu(),e.getType()).sharedNodeState}(t));return t.__state=n,n}function Fn(e,t){let n=e.getWritable(),r=t.$;return(n.__state||r)&&Pn(e).updateFromJSON(r),n}function In(e){if(e)for(let t in e)return e}function Ln(e){return e}function Rn(e,t,n){for(let[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);let t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function zn(e,t,n){let{unknownState:r}=t,i=n?n.unknownState:void 0;if(r){for(let[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0}return!1}function Bn(e,t){let n=e.__state;return n&&n.node===e?n.getWritable(t):n}function Vn(e,t){let n=e.__mode,r=e.__format,i=e.__style,a=t.__mode,o=t.__format,s=t.__style,c=e.__state,l=t.__state;return(n===null||n===a)&&(r===null||r===o)&&(i===null||i===s)&&(e.__state===null||c===l||function(e,t){if(e===t)return!0;let n=new Set;return!(e&&Rn(n,e,t)||t&&Rn(n,t,e)||e&&zn(n,e,t)||t&&zn(n,t,e))}(c,l))}function Hn(e,t){let n=e.mergeWithSibling(t),r=j()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function Un(e){let t,n,r=e;if(r.__text!==``||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&D(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==``){if(Vn(t,r)){r=Hn(t,r);break}break}t.remove()}for(;(n=r.getNextSibling())!==null&&D(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(n.__text!==``){if(Vn(r,n)){r=Hn(r,n);break}break}n.remove()}}else r.remove()}function Wn(e){return Gn(e.anchor),Gn(e.focus),e}function Gn(e){for(;e.type===`element`;){let t=e.getNode(),n=e.offset,r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),D(r)){e.set(r.__key,i?r.getTextContentSize():0,`text`,!0);break}if(!M(r))break;e.set(r.__key,i?r.getChildrenSize():0,`element`,!0)}}var Kn=Symbol.for(`@lexical/CachedTextSize`);function qn(e,t){return cr.read(()=>{let n=0,r=e;for(let e=0;e<t&&r!==null;e++){let i=sr.get(r);if(i===void 0&&S(345,r),M(i)){let a=lr.get(r);if(a!==void 0&&M(a)&&a.__parent!==i.__parent)n+=i.getTextContentSize();else{let e=ur.get(r),t=e&&e.__lexicalTextContent;typeof t!=`string`&&S(346,i.getType()),n+=t.length}e<t-1&&!i.isInline()&&(n+=2)}else{let e=i[Kn];e===void 0&&S(347,i.getType(),r),n+=e}r=i.__next}return n},{editor:C})}function Jn(e){M(e)||e[Kn]===void 0&&(e[Kn]=D(e)?e.__text.length:e.getTextContentSize())}var Yn=4,Xn,C,Zn,w=``,Qn=null,$n=null,er=null;function tr(){return{firstTextKey:er,format:Qn,style:$n}}function nr(e){e.firstTextKey!==null&&(Qn=e.format,$n=e.style,er=e.firstTextKey)}function rr(e){if(er!==null)return;let t=e.__lexicalFirstTextKey;if(t===void 0&&S(348),t===null)return;let n=lr.get(t);D(n)&&(Qn=n.getFormat(),$n=n.getStyle(),er=t)}var ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr=!1,hr=!1;function gr(e,t){let n=sr.get(e),r=lr.has(e);if(t!==null){let n=Vr(e);n.parentNode===t&&t.removeChild(n)}if(!r){if(C._keyToDOMMap.delete(e),M(n)){let e=Nd(n,sr);_r(e,0,e.length-1,null)}if(n!==void 0){for(let e of Er(n).values()){let t=Or(e);gr(e,null),t!==null&&t.remove()}Jl(fr,Zn,ir,n,`destroyed`)}}}function _r(e,t,n,r){for(let i=t;i<=n;++i){let t=e[i];t!==void 0&&gr(t,r)}}function vr(e,t){e.setProperty(`text-align`,t)}var yr=`40px`;function br(e,t){let n=Xn.theme.indent;if(typeof n==`string`){let r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}e.style.setProperty(`padding-inline-start`,t===0?``:`calc(${t} * var(--lexical-indent-base-value, ${yr}))`),Kl(e,`class`),Kl(e,`style`)}function xr(e,t){let n=e.style;t===0?vr(n,``):t===1?vr(n,`left`):t===2?vr(n,`center`):t===3?vr(n,`right`):t===4?vr(n,`justify`):t===5?vr(n,`start`):t===6&&vr(n,`end`),Kl(e,`style`)}function Sr(e,t){let n=function(e){let t=e.__dir;if(t!==null)return t;if(P(e))return null;let n=e.getParent();return n===null||B(n)&&n.__dir===null?`auto`:null}(t);n===null?e.removeAttribute(`dir`):e.dir=n}function Cr(e){let t=V().createElement(`div`);return t.setAttribute(`data-lexical-slot`,e),t.style.display=`none`,t}function wr(e,t,n){t||e.contentEditable===`false`?rd(n,C):n.removeAttribute(`contenteditable`)}function Tr(e,t,n){let r=w,i=tr();w=``;let a=``,o=N(e);for(let[r,i]of n){let n=Cr(r);wr(t,o,n),t.appendChild(n),w=``;let s=tr();Ar(i,Wu(e,n,C)),nr(s),Dr(e,r,t,n),a+=w}return nr(i),w=r,a}function Er(e){return Id(e)&&e.__slots!==null?e.__slots:Fd}function Dr(e,t,n,r){let i=pr.$getSlotTargetElement(e,t,n,C);i!==null&&(r.parentElement!==i&&i.appendChild(r),r.style.display=``)}function Or(e){let t=ur.get(e);return t===void 0?null:t.parentElement}function kr(e,t,n){let r=Er(e),i=Er(t);for(let[e,t]of r)if(!i.has(e)){let e=Or(t);gr(t,null),e!==null&&e.remove()}let a=w,o=tr(),s=``,c=null,l=N(t);for(let[e,a]of i){let i=r.get(e),o=i===void 0?null:Or(i);w=``;let u=tr();if(o===null){o=Cr(e);let r=null;for(let e of n.children)if(!e.hasAttribute(`data-lexical-slot`)){r=e;break}n.insertBefore(o,r),Ar(a,Wu(t,o,C))}else i===a?Ir(a,o):(i!==void 0&&gr(i,o),Ar(a,Wu(t,o,C)));if(nr(u),wr(n,l,o),Dr(t,e,n,o),s+=w,o.parentElement===n){let e=c===null?n.firstChild:c.nextSibling;e!==o&&n.insertBefore(o,e),c=o}}return nr(o),w=a,s}function Ar(e,t){let n=lr.get(e);if(n===void 0&&S(60),t!==null){let r=sr.get(e);if(r!==void 0){let i=ur.get(e);if(i!==void 0){let a=Ld(r)?r.__slotHost:null,o=Ld(n)?n.__slotHost:null,s=r.__parent!==n.__parent||a!==o,c=o!==null&&i.parentElement!==t.element;if(s||c)return t.insertChild(i),Ir(e,t.element)}}}let r=pr.$createDOM(n,C);if(function(e,t,n){let r=n._keyToDOMMap;Tl(t,n,e),r.set(e,t)}(e,r,C),D(n)?r.setAttribute(`data-lexical-text`,`true`):N(n)&&(r.setAttribute(`data-lexical-decorator`,`true`),td(r,{captureSelection:!0})),M(n)){let e=n.__indent,t=n.__size;Sr(r,n),e!==0&&br(r,e);let i=Er(n),a=i.size>0?Tr(n,r,i):``;if(t===0)r.__lexicalTextContent=a,r.__lexicalFirstTextKey=null,w+=a,i.size>0&&(r.__lexicalSlotTextLength=a.length);else{let e=w,o=t-1;if(jr(Nd(n,lr),n,0,o,Wu(n,r,C)),a!==``){let t=r.__lexicalTextContent||``;r.__lexicalTextContent=a+t,w=e+a+t}i.size>0&&(r.__lexicalSlotTextLength=a.length)}let o=n.__format;o!==0&&xr(r,o),n.isInline()||(Pr(0,n,r),Nr(n,r))}else{let t=n.getTextContent();if(N(n)){let t=n.decorate(C,Xn);t!==null&&Lr(e,t),r.contentEditable=`false`;let i=Er(n);i.size>0&&Tr(n,r,i)}w+=t}return t!==null&&t.insertChild(r),pr.$decorateDOM(n,null,r,C),Jn(n),Jl(fr,Zn,ir,n,`created`),r}function jr(e,t,n,r,i){let a=w,o=tr();w=``,Qn=null,$n=null,er=null;let s=n;for(;s<=r;++s){let t=tr();Ar(e[s],i);let n=lr.get(e[s]);n!==null&&D(n)?Qn===null&&(Qn=n.getFormat(),$n=n.getStyle(),er=n.__key):M(n)&&s<r&&!n.isInline()&&(w+=st),nr(t)}let c=C._keyToDOMMap.get(t.__key);c===void 0&&S(349,t.__key),c.__lexicalTextContent=w,c.__lexicalFirstTextKey=er,w=a+w,nr(o)}function Mr(e,t){if(!e)return!1;let n=t.get(e);return N(n)&&!n.isInline()}function Nr(e,t){let n=Wu(e,t,C);n.setDecoratorBoundaryAnchor(`leading`,Mr(e.__first,lr)),n.setDecoratorBoundaryAnchor(`trailing`,Mr(e.__last,lr))}function Pr(e,t,n){let r=Wu(t,n,C),i=function(e,t){if(e){let n=e.__last;if(n){let e=t.get(n);if(e)return bc(e)?`line-break`:N(e)&&e.isInline()?`decorator`:null}return`empty`}return null}(t,lr);r.setManagedLineBreak(i)}function Fr(e,t,n){let r=t.__lexicalFirstTextKey;if(r!=null){let t=e.__key,i=r;for(;i!==null;){let e=lr.get(i);if(e===void 0){i=null;break}if(e.__parent===t)break;i=e.__parent}if(i!==null&&!n.has(i)){let e=lr.get(r);if(D(e))return Qn=e.getFormat(),void($n=e.getStyle())}}t.__lexicalFirstTextKey=er}function Ir(e,t){let n=sr.get(e),r=lr.get(e);n!==void 0&&r!==void 0||S(61);let i=mr||or.has(e)||ar.has(e),a=Ql(C,e);if(n===r&&!i){let e;if(M(n)){let t=a.__lexicalTextContent;typeof t!=`string`&&S(355,n.getType()),e=t,rr(a)}else e=n.getTextContent();return w+=e,a}if(n!==r&&i&&Jl(fr,Zn,ir,r,`updated`),pr.$updateDOM(r,n,a,C)){let n=Ar(e,null);return t===null&&S(62),t.replaceChild(n,a),gr(e,null),n}if(M(n)){M(r)||S(334,e);let t=r.__indent;(mr||t!==n.__indent)&&br(a,t);let o=r.__format;(mr||o!==n.__format)&&xr(a,o);let s=i&&(Er(r).size>0||Er(n).size>0)?kr(n,r,a):``;if(i){let e=w;if(function(e,t,n){var r;Qn=null,$n=null,er=null,function(e,t,n){let r=w,i=e.__size,a=t.__size;w=``;let o=n.element,s=C._keyToDOMMap.get(t.__key);s===void 0&&S(351,t.__key);let c=a-i;if(!mr&&Math.abs(c)<=1&&i>=Yn&&e.__first===t.__first&&(c!==0||!C._cloneNotNeeded.has(e.__key))){let i=s.__lexicalTextContent,l=dr.get(e.__key);if(!mr&&typeof i==`string`&&l!==void 0){let a=function(e,t){let n=t.size;if(n===0||n>=e.__size)return null;let r=e.__last,i=null,a=0;for(;r!==null&&a<n;){if(!t.has(r))return null;i=r;let e=lr.get(r);if(e===void 0)return null;r=e.__prev,a++}return a!==n||r!==null&&t.has(r)?null:i}(t,l);if(a!==null){let u=l.size;if(c===0){let e=qn(a,u),n=a,c=0;for(;n!==null&&c<u;){let e=lr.get(n);if(e===void 0)break;let t=tr();Ir(n,o),D(e)&&Qn===null&&(Qn=e.getFormat(),$n=e.getStyle(),er=e.__key),nr(t),n=e.__next,c++}let d=``;for(n=a,c=0;n!==null&&c<u;){let e=lr.get(n);if(e===void 0)break;let t;if(M(e)){let r=C._keyToDOMMap.get(n),i=r&&r.__lexicalTextContent;typeof i!=`string`&&S(352,e.getType()),t=i}else t=e.getTextContent();d+=t,c<u-1&&M(e)&&!e.isInline()&&(d+=st),n=e.__next,c++}let f=s.__lexicalSlotTextLength||0,p=f>0?i.slice(f):i,m=p.slice(0,p.length-e)+d;s.__lexicalTextContent=m,w=r+m,Fr(t,s,l);return}if(function(e,t,n,r,i,a,o,s){if(s!==1&&s!==-1||o!==(s===1?2:1))return!1;let c=o-s,l=e.__last;for(let e=0;e<c-1;e++){if(l===null)return!1;let e=sr.get(l);if(e===void 0)return!1;l=e.__prev}if(l===null)return!1;let u=lr.get(a),d=sr.get(l);if(u===void 0||d===void 0||u.__prev!==d.__prev)return!1;let f=[],p=a;for(let e=0;e<o;e++){if(p===null)return!1;f.push(p);let e=lr.get(p);p=e?e.__next:null}let m=[];p=l;for(let e=0;e<c;e++){if(p===null)return!1;m.push(p);let e=sr.get(p);p=e?e.__next:null}let h=new Set(m),g=new Set(f),_=[],v=0,y=0;for(;v<c&&y<o;)if(f[y]===m[v])_.push({key:f[y],kind:`reconcile`}),v++,y++;else if(g.has(m[v])){if(h.has(f[y]))return!1;_.push({key:f[y],kind:`create`,nextIndex:y}),y++}else _.push({key:m[v],kind:`destroy`}),v++;for(;v<c;)_.push({key:m[v++],kind:`destroy`});for(;y<o;)_.push({key:f[y],kind:`create`,nextIndex:y}),y++;let b=qn(l,c);for(let e of _){let t=tr();if(e.kind===`reconcile`)Ir(e.key,n.element);else if(e.kind===`destroy`)gr(e.key,n.element);else{let t=null;for(let n=e.nextIndex+1;n<o;n++){let e=C._keyToDOMMap.get(f[n]);if(e!==void 0){t=e;break}}Ar(e.key,n.withBefore(t??n.before))}if(e.kind!==`destroy`){let t=lr.get(e.key);t&&D(t)&&Qn===null&&(Qn=t.getFormat(),$n=t.getStyle(),er=t.__key)}nr(t)}let ee=``;for(let e=0;e<o;e++){let t=lr.get(f[e]);if(t===void 0)return!1;let n;if(M(t)){let r=C._keyToDOMMap.get(f[e]),i=r&&r.__lexicalTextContent;typeof i!=`string`&&S(350,t.getType()),n=i}else n=t.getTextContent();ee+=n,e<o-1&&M(t)&&!t.isInline()&&(ee+=st)}let te=r.__lexicalSlotTextLength||0,ne=te>0?i.slice(te):i;return r.__lexicalTextContent=ne.slice(0,ne.length-b)+ee,!0}(e,0,n,s,i,a,u,c)){let e=s.__lexicalTextContent;typeof e!=`string`&&S(353),w=r+e,Fr(t,s,l);return}}}if(c===0){let t=e.__first,n=0;for(;t!==null;){let e=lr.get(t);if(e===void 0)break;let r=mr||or.has(t)||ar.has(t),i=tr();if(r)Ir(t,o);else{let n,r;if(M(e)){r=ur.get(t);let i=r&&r.__lexicalTextContent;typeof i!=`string`&&S(354,e.getType()),n=i}else n=e.getTextContent();w+=n,r!==void 0&&rr(r)}D(e)?Qn===null&&(Qn=e.getFormat(),$n=e.getStyle(),er=e.__key):M(e)&&n<a-1&&!e.isInline()&&(w+=st),nr(i),t=e.__next,n++}s.__lexicalTextContent=w,s.__lexicalFirstTextKey=er,w=r+w;return}}if(i===1&&a===1){let r=e.__first,i=t.__first;if(r===i)Ir(r,o);else{let e=Vr(r),t=Ar(i,null);try{e.parentNode===o?o.replaceChild(t,e):n.insertChild(t)}catch(n){if(typeof n==`object`&&n){let a=`${n.toString()} Parent: ${o.tagName}, new child: {tag: ${t.tagName} key: ${i}}, old child: {tag: ${e.tagName}, key: ${r}}.`;throw Error(a)}throw n}gr(r,null)}let a=lr.get(i);D(a)&&Qn===null&&(Qn=a.getFormat(),$n=a.getStyle(),er=a.__key)}else{let r=Nd(e,sr),s=Nd(t,lr);if(r.length!==i&&S(227),s.length!==a&&S(228),i===0)a!==0&&jr(s,t,0,a-1,n);else if(a===0){if(i!==0){let e=n.after==null&&n.before==null&&Er(t).size===0&&n.element.__lexicalLineBreak==null;_r(r,0,i-1,e?null:o),e&&(o.textContent=``)}}else(function(e,t,n,r,i,a){let o=r-1,s=i-1,c,l,u=a.getFirstChild(),d=0,f=0;for(;d<=o&&f<=s;){let e=t[d],r=n[f],i=tr();if(e===r)u=Rr(Ir(r,a.element)),d++,f++;else{if(l===void 0&&(l=zr(n,f)),c===void 0)c=zr(t,d);else if(!c.has(e)){d++,nr(i);continue}if(!l.has(e)){u=Rr(Vr(e)),gr(e,a.element),d++,c.delete(e),nr(i);continue}if(c.has(r)){let e=Ql(C,r);e!==u&&a.withBefore(u??a.before).insertChild(e),u=Rr(Ir(r,a.element)),d++,f++}else Ar(r,a.withBefore(u??a.before)),f++}let o=lr.get(r);o!==null&&D(o)?Qn===null&&(Qn=o.getFormat(),$n=o.getStyle(),er=o.__key):M(o)&&f<=s&&!o.isInline()&&(w+=st),nr(i)}let p=d>o,m=f>s;if(p&&!m){let t=n[s+1],r=t===void 0?null:C.getElementByKey(t);jr(n,e,f,s,a.withBefore(r??a.before))}else m&&!p&&_r(t,d,o,a.element)})(t,r,s,i,a,n)}s.__lexicalTextContent=w,s.__lexicalFirstTextKey=er,w=r+w}(e,t,Wu(t,n,C)),B(t)||(r=t,Qn==null||Qn===r.__textFormat||hr||r.setTextFormat(Qn),function(e){$n==null||$n===e.__textStyle||hr||e.setTextStyle($n)}(t))}(n,r,a),r.isInline()||(P(r)||Pr(0,r,a),Nr(r,a)),s!==``){let t=a.__lexicalTextContent||``;a.__lexicalTextContent=s+t,w=e+s+t,a.__lexicalSlotTextLength=s.length}else(Er(r).size>0||Er(n).size>0)&&(a.__lexicalSlotTextLength=0)}else{let e=a.__lexicalTextContent;typeof e!=`string`&&S(356,n.getType()),w+=e,rr(a)}if((mr||r.__dir!==n.__dir||r.__parent!==n.__parent)&&(Sr(a,r),P(r)&&!mr))for(let e of r.getChildren())M(e)&&Sr(Ql(C,e.getKey()),e)}else{let t=r.getTextContent();if(N(r)){let t=r.decorate(C,Xn);t!==null&&Lr(e,t),i&&(Er(r).size>0||Er(n).size>0)&&kr(n,r,a)}w+=t}if(!hr&&P(r)){let e=r.getLatest();if(e.__cachedText!==w){let t=e.getWritable();t.__cachedText=w,r=t}}return pr.$decorateDOM(r,n,a,C),Jn(r),a}function Lr(e,t){let n=C._pendingDecorators,r=C._decorators;if(n===null){if(r[e]===t)return;n=Ol(C)}n[e]=t}function Rr(e){let t=e.nextSibling;return t!==null&&t===C._blockCursorElement&&(t=t.nextSibling),t}function zr(e,t){let n=new Set;for(let r=t;r<e.length;r++)n.add(e[r]);return n}function Br(e,t,n,r,i,a){w=``,Qn=null,$n=null,er=null,mr=r===2,C=n,Xn=n._config,pr=n._config.dom||Yc,Zn=n._nodes,ir=C._listeners.mutation,ar=i,or=a,sr=e._nodeMap,cr=e,lr=t._nodeMap,hr=t._readOnly,ur=jt(n._keyToDOMMap),dr=function(){let e=new Map,t=t=>{for(let n of t){let t=lr.get(n);if(t===void 0)continue;let r=t.__parent;if(r===null)continue;let i=e.get(r);i===void 0&&(i=new Set,e.set(r,i)),i.add(n)}};return t(ar.keys()),t(or),e}();let o=new Map;return fr=o,Ir(`root`,null),C=void 0,Zn=void 0,ar=void 0,or=void 0,sr=void 0,cr=void 0,lr=void 0,Xn=void 0,ur=void 0,dr=void 0,fr=void 0,pr=Yc,o}function Vr(e){let t=ur.get(e);return t===void 0&&S(75,e),t}function Hr(e){return()=>{}}function T(e){return{type:e}}var Ur=T(`SELECTION_CHANGE_COMMAND`),Wr=T(`SELECTION_INSERT_CLIPBOARD_NODES_COMMAND`),Gr=T(`CLICK_COMMAND`),Kr=T(`BEFORE_INPUT_COMMAND`),qr=T(`INPUT_COMMAND`),Jr=T(`COMPOSITION_START_COMMAND`),Yr=T(`COMPOSITION_END_COMMAND`),Xr=T(`DELETE_CHARACTER_COMMAND`),Zr=T(`INSERT_LINE_BREAK_COMMAND`),Qr=T(`INSERT_PARAGRAPH_COMMAND`),$r=T(`CONTROLLED_TEXT_INSERTION_COMMAND`),ei=T(`PASTE_COMMAND`),ti=T(`REMOVE_TEXT_COMMAND`),ni=T(`DELETE_WORD_COMMAND`),ri=T(`DELETE_LINE_COMMAND`),ii=T(`FORMAT_TEXT_COMMAND`),ai=T(`SET_TEXT_FORMAT_COMMAND`),oi=T(`UNDO_COMMAND`),si=T(`REDO_COMMAND`),ci=T(`KEYDOWN_COMMAND`),li=T(`KEY_ARROW_RIGHT_COMMAND`),ui=T(`MOVE_TO_END`),di=T(`KEY_ARROW_LEFT_COMMAND`),fi=T(`MOVE_TO_START`),pi=T(`KEY_ARROW_UP_COMMAND`),mi=T(`KEY_ARROW_DOWN_COMMAND`),hi=T(`KEY_ENTER_COMMAND`),gi=T(`KEY_SPACE_COMMAND`),_i=T(`KEY_BACKSPACE_COMMAND`),vi=T(`KEY_ESCAPE_COMMAND`),yi=T(`KEY_DELETE_COMMAND`),bi=T(`KEY_TAB_COMMAND`),xi=T(`INSERT_TAB_COMMAND`),Si=T(`INDENT_CONTENT_COMMAND`),Ci=T(`OUTDENT_CONTENT_COMMAND`),wi=T(`DROP_COMMAND`),Ti=T(`FORMAT_ELEMENT_COMMAND`),Ei=T(`DRAGSTART_COMMAND`),Di=T(`DRAGOVER_COMMAND`),Oi=T(`DRAGEND_COMMAND`),ki=T(`COPY_COMMAND`),Ai=T(`CUT_COMMAND`),ji=T(`SELECT_ALL_COMMAND`),Mi=T(`CLEAR_EDITOR_COMMAND`),Ni=T(`CLEAR_HISTORY_COMMAND`),Pi=T(`CAN_REDO_COMMAND`),Fi=T(`CAN_UNDO_COMMAND`),Ii=T(`FOCUS_COMMAND`),Li=T(`BLUR_COMMAND`),Ri=T(`KEY_MODIFIER_COMMAND`);function zi(e,t){return{...t,[gt]:e}}var Bi=zi(`metaKey`,{ctrlKey:!qe,metaKey:qe}),Vi=zi(`altKey`,{altKey:qe,ctrlKey:!qe}),Hi=[[`altKey`,1],[`ctrlKey`,2],[`metaKey`,4],[`shiftKey`,8]];function Ui(e,t,n){let r=e.get(t);r?r.push(n):e.set(t,[n])}var Wi=class{byKey=new Map;byCode=new Map;add(e){let{key:t,modifiers:n={}}=e;t.length>0||S(399);let r=t.toLowerCase();for(let i of function(e){let t=[0];for(let[n,r]of Hi){let i=e[n]||!1;i===`any`?t=t.concat(t.map(e=>e|r)):i&&(t=t.map(e=>e|r))}return t}(n))Ui(this.byKey,`${i}:${r}`,e),t.length===1&&(/[0-9]/.test(t)?Ui(this.byCode,`${i}:Digit${t}`,e):/[a-z]/.test(r)&&Ui(this.byCode,`${i}:Key${r.toUpperCase()}`,e));return this}matches(e){let t=e.key;if(!t)return[];let n=function(e){let t=0;for(let[n,r]of Hi)e[n]&&(t|=r);return t}(e),r=this.byKey.get(`${n}:${t.toLowerCase()}`),i=r?r.slice():[];if(this.byCode.size>0&&!(t.length===1&&t.charCodeAt(0)<=127)){let t=this.byCode.get(`${n}:${e.code}`);t&&i.push(...t)}return i}match(e){return this.matches(e)[0]}};function Gi(e){let t=new Wi;for(let n of e)t.add(n);return t}function Ki(e){let t=new Map;return{dispose(){for(let e of t.values())e.dispose();t.clear()},register(n,r){let i=t.get(n);i===void 0&&(i={dispose:e(n,r),holders:new Set},t.set(n,i));let a=()=>{let e=t.get(n);e&&e.holders.delete(a)&&e.holders.size===0&&(t.delete(n),e.dispose())};return i.holders.add(a),a}}}function qi(e,t,n,r){return e.addEventListener(t,n,r),e.removeEventListener.bind(e,t,n,r)}var Ji=Object.freeze({}),Yi,Xi=new WeakMap,Zi=new WeakMap,Qi=Ki(e=>(e.addEventListener(`selectionchange`,ka),()=>e.removeEventListener(`selectionchange`,ka)));function $i(e,t,n,r,i,a){let o=e.anchor,s=e.focus,c=o.getNode(),l=j(),u;if(a!==void 0)u=a;else{let e=_u(su(l));u=e===null?null:Eu(e,l._rootElement)}let d=u===null?null:u.anchorNode,f=o.key,p=l.getElementByKey(f),m=n.length;return f!==s.key||!D(c)||(!i&&(!Xe||l._inputState.lastBeforeInputInsertTextTimeStamp<r+50)||c.isDirty()&&m<2||Nl(n))&&o.offset!==s.offset&&!c.isComposing()||pl(c)||c.isDirty()&&m>1||(i||!Xe)&&p!==null&&!c.isComposing()&&d!==Ku(c,p,l)||u!==null&&t!==null&&(!t.collapsed||t.startContainer!==u.anchorNode||t.startOffset!==u.anchorOffset)||!c.isComposing()&&(c.getFormat()!==e.format||c.getStyle()!==e.style)||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;let n=e.anchor.offset,r=t.getParentOrThrow(),i=fl(t);return n===0?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){let t=e.getPreviousSibling();return(D(t)||M(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,c)}function ea(e,t){return ml(e)&&e.nodeValue!==null&&t!==0&&t!==e.nodeValue.length}function ta(e,t,n){let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=Eu(e,t._rootElement),s=t._inputState;if(s.isSelectionChangeFromDOMUpdate){s.isSelectionChangeFromDOMUpdate=!1;let e=s.selectionChangeFromDOMUpdatePoints;if(s.selectionChangeFromDOMUpdatePoints=null,ea(r,i)&&ea(a,o)&&!s.postDeleteSelectionToRestore&&(e===null||e.anchorNode===r&&e.anchorOffset===i&&e.focusNode===a&&e.focusOffset===o))return}ec(t,()=>{if(!n)return void R(null);if(!cl(t,r,a))return;let c=A();if(s.postDeleteSelectionToRestore&&O(c)&&c.isCollapsed()){let e=c.anchor,t=s.postDeleteSelectionToRestore.anchor;(e.key===t.key&&e.offset===t.offset+1||e.offset===1&&t.getNode().is(e.getNode().getPreviousSibling()))&&(c=s.postDeleteSelectionToRestore.clone(),R(c))}if(s.postDeleteSelectionToRestore=null,O(c)){let n=c.anchor,l=n.getNode();if(c.isCollapsed()){e.type===`Range`&&r===a&&(c.dirty=!0);let i=su(t).event,o=i?i.timeStamp:performance.now(),{format:u,style:d,offset:f,key:p,timeStamp:m}=s.collapsedSelectionFormat,h=L(),g=!1===t.isComposing()&&h.getTextContent()===``;if(o<m+200&&n.offset===f&&n.key===p)na(c,u,d);else if(n.type===`text`)D(l)||S(141),ra(c,l);else if(n.type===`element`&&!g){M(l)||S(259);let e=n.getNode();e.isEmpty()?function(e,t){na(e,t.getTextFormat(),t.getTextStyle())}(c,e):na(c,c.format,``)}}else{let e=n.key,t=c.focus.key,r=c.getNodes(),a=r.length,s=c.isBackward(),l=s?o:i,u=s?i:o,d=s?t:e,f=s?e:t,p=at,m=!1;for(let e=0;e<a;e++){let t=r[e],n=t.getTextContentSize();if(D(t)&&n!==0&&!(e===0&&t.__key===d&&l===n||e===a-1&&t.__key===f&&u===0)&&(m=!0,p&=t.getFormat(),p===0))break}c.format=m?p:0}}(function(e,t,n=!1){(n||Js(e,t))&&e.dispatchCommand(Ur)})(t,c,c!==null&&(c.dirty||!O(c)))})}function na(e,t,n){e.format===t&&e.style===n||(e.format=t,e.style=n,e.dirty=!0)}function ra(e,t){na(e,t.getFormat(),t.getStyle())}function ia(e,t){ec(t,()=>{let n=A(),r=_u(su(t)),i=as();if(r){if(O(n)){let e=n.anchor,t=e.getNode();e.type===`element`&&e.offset===0&&n.isCollapsed()&&!P(t)&&L().getChildrenSize()===1&&t.getTopLevelElementOrThrow().isEmpty()&&i!==null&&n.is(i)&&(r.removeAllRanges(),n.dirty=!0)}else if(e.pointerType===`touch`||e.pointerType===`pen`){let n=Eu(r,t._rootElement).anchorNode;(H(n)||ml(n))&&R(is(i,r,t,e))}}if(Je&&r!==null&&r.rangeCount===0){let n=t._rootElement;if(n!==null&&e.target===n){let a=e.clientY,o=n.childNodes.length;for(let e=0;e<n.childNodes.length;e++){let t=n.childNodes[e];if(H(t)){let n=t.getBoundingClientRect();if(a<=(n.top+n.bottom)/2){o=e;break}}}r.setBaseAndExtent(n,o,n,o);let s=is(i,r,t,e);s===null?r.removeAllRanges():R(s)}}z(t,Gr,e)})}function aa(e,t){let n=Mu(e),r=e.pointerType;Fu(n)&&r!==`touch`&&r!==`pen`&&e.button===0&&ec(t,()=>{id(n,t)||(t._inputState.isSelectionChangeFromMouseDown=!0)})}function oa(e){if(!e.getTargetRanges)return null;let t=e.getTargetRanges();return t.length===0?null:t[0]}function sa(e){let{lastKeyCode:t}=j()._inputState;if(e==null||e.length<=1||t==null)return;let n=t.length===1?t:t===`Enter`?`
|
|
4
4
|
`:t===`Tab`?` `:null;if(!n)return;let r=A();if(!O(r)||!r.isCollapsed())return;let i=r.anchor.getNode();if(!D(i))return;let{offset:a}=r.anchor;if(i.getTextContentSize()===a){let e=i.getNextSibling();if(n===`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./preload-helper-DpV6A1kQ.js";import{C as t,D as n,E as r,O as i,S as a,T as o,b as s,c,d as l,g as u,h as d,l as f,m as p,p as m,u as h,v as g,x as _}from"./schemas-D7cgkv3L.js";import{$n as v,Cn as y,Dn as b,En as x,Jn as S,On as C,Qn as w,Sn as T,Tn as E,U as D,Un as O,Wn as k,X as A,cr as ee,en as te,lr as ne,pn as re,qt as ie,s as ae,sr as oe,tn as se,tr as ce}from"./tool-schema-Sm_QLU6x.js";import{c as j}from"./host-patterns-F-KZIzkF.js";import{$ as le,At as ue,Br as de,Bt as fe,Er as pe,Et as me,F as he,Ft as ge,G as _e,Gt as ve,Ht as ye,I as be,Ir as xe,It as Se,Jt as Ce,Kt as we,L as Te,Lr as Ee,Lt as De,Mr as Oe,N as ke,Or as Ae,Ot as je,P as Me,R as Ne,Rr as Pe,Sr as Fe,Ur as M,Ut as Ie,V as Le,Vr as Re,Vt as ze,Wn as Be,Wt as Ve,Xn as He,Yt as Ue,Z as We,_n as Ge,an as Ke,at as qe,bn as Je,cr as Ye,dn as Xe,dt as Ze,fn as Qe,hr as $e,in as et,it as tt,j as nt,jr as rt,kn as it,lr as at,mr as ot,nt as st,pt as ct,qt as lt,rn as ut,rt as dt,tn as ft,tt as pt,un as mt,vt as N,wn as ht,wt as gt,xn as _t,yn as vt,zn as yt,zt as bt}from"./shaped-data-CK3-VEaY.js";import{S as xt,_ as St,b as Ct,x as wt}from"./browser-connection-DgdBd76s.js";import{C as Tt,D as Et,F as Dt,I as Ot,M as kt,O as At,P as jt,T as Mt,b as Nt,v as Pt,y as Ft}from"./schema-C46sNlNM.js";import{a as It}from"./live-ingress-OuSlQ6q7.js";import{n as Lt,t as Rt}from"./trace-schema--4IGmLeE.js";import{n as zt}from"./stub-BMOs6lLs.js";function Bt(e){return{type:`guardrail`,guardrail:e}}function Vt(e,t,n,r=`redact`,i){if(n.length!==0)return Bt({stage:e,trust:t,action:r,hits:n,...i?{provenance:i}:{}})}function Ht(e,t){return e.type===`guardrail`?{...e,guardrail:at(e.guardrail,t)}:e}var P=65536;function F(e){let t=e.classStarts.length,n=new Uint16Array(P);for(let r=0;r<t;r++)n.fill(r,e.classStarts[r],e.classStarts[r+1]??P);let r=e.charsets.map(e=>{let n=new Uint8Array(t);for(let t of e)n[t]=1;return n}),i=e.nodes.length,a=new Int32Array(i),o=new Uint8Array(i),s=[];return e.nodes.forEach((e,t)=>{a[t]=e[0],o[t]=e[1],s.push(Int32Array.from(e.slice(2)))}),{classOf:n,has:r,pattern:a,final:o,edges:s,initials:e.initials,leads:e.leads,size:i}}var Ut,I,Wt;async function Gt(){if(Ut)return;let{FORWARD_AUTOMATON:t,REVERSED_AUTOMATON:n}=await e(async()=>{let{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}=await import(`./egress-automata-CpTxDNty.js`);return{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}},[]);Ut={forward:t,reversed:n}}function Kt(){if(!Ut)throw Error(`A stream was opened before loadEgressAutomata() finished.`);return Ut}var L;function qt(e){let t=String.fromCharCode(e).toUpperCase();if(t.length!==1)return e;let n=t.charCodeAt(0);return e>=128&&n<128?e:n}function Jt(e){if(!L){L=new Map;for(let e=0;e<P;e++){let t=qt(e),n=L.get(t);n?n.push(e):L.set(t,[e])}}return L.get(qt(e))??[e]}function Yt(e){let t=[0];for(let n of e)t.at(-1)!==n&&t.push(n),n+1<P&&t.push(n+1);return t}var Xt=new Map;function Zt(e){let t=Xt.get(e);if(t)return t;let n=Array.from({length:e.length},(t,n)=>Jt(e.charCodeAt(n))),r=Yt([...new Set(n.flat())].sort((e,t)=>e-t)),i=e=>r.indexOf(e),a=F({classStarts:r,charsets:n.map(e=>e.map(i)),initials:[0],leads:[-1],nodes:[...n.map((e,t)=>[0,0,t+1,t]),[0,1]]});return Xt.set(e,a),a}function Qt(e){let t=JSON.stringify(e),n=Xt.get(t);if(n)return n;let r=[...new Set(e.flatMap(e=>Array.from(e,e=>e.charCodeAt(0))))];r.sort((e,t)=>e-t);let i=Yt(r),a=r.map(e=>[i.indexOf(e)]),o=[],s=F({classStarts:i,charsets:a,initials:e.map((e,t)=>{let n=o.length;for(let n=0;n<e.length;n++)o.push([t,0,o.length+1,r.indexOf(e.charCodeAt(n))]);return o.push([t,1]),n}),leads:e.map(()=>-1),nodes:o});return Xt.set(t,s),s}function $t(e,t){let n=e.has[0]?.length??0,r=Array.from({length:n},()=>[]);for(let i of t){let t=e.edges[e.initials[i]];for(let i=0;i<t.length;i+=2){let a=e.has[t[i+1]];for(let e=0;e<n;e++)a[e]&&r[e]?.push(t[i])}}return r.map(e=>Int32Array.from(e))}function en(e,t){e.text+=t,e.fresh+=t}function tn(e){return e.text.length-e.fresh.length}function R(e,t){let n=tn(e);return t>=n?e.fresh.charCodeAt(t-n):e.text.charCodeAt(t)}function nn(e,t,n=e.text.length){let r=tn(e);return t>=r?e.fresh.slice(t-r,n-r):e.text.slice(t,n)}function rn(e){let t={text:``,fresh:``,rawAt:e=>e,update(){t.text=e.text,t.fresh=e.fresh}};return t}function an(e,t){let n={text:``,fresh:``,rawAt:e.rawAt,update(){n.fresh=``,en(n,t(nn(e,n.text.length)))}};return n}var on=/\w/,sn=Math.max(...ze.map(e=>e.length));function cn(e){return e.length<=sn+1&&/^[A-Za-z]*$/.test(e)}function ln(e){let t=0,n,r=!1,i=[],a=(e,t,n)=>{en(o,e);for(let r=0;r<e.length;r++)i.push(t+Math.min(r,n-1))},o={text:``,fresh:``,rawAt:r=>e.rawAt(r<i.length?i[r]:t-(n?.length??0)),update(){o.fresh=``;for(let i=e.text.length;t<i;t++){let i=String.fromCharCode(R(e,t)),o=on.test(i);o&&!r&&(n=``),r=o,o?n===void 0?a(i,t,1):n+=i:(n!==void 0&&a(ve(n),t-n.length,n.length),n=void 0,a(i,t,1))}n!==void 0&&!cn(n)&&(a(n,t-n.length,n.length),n=void 0)}};return o}function un(e){let t={text:``,fresh:``,from:[],rawAt:n=>n<t.from.length?t.from[n]:e(),update(){}};return t}function z(e,t,n){en(e,t);for(let r=0;r<t.length;r++)e.from.push(n)}var dn=55296,fn=56319,pn=/[A-Za-z]/,mn=56320,hn=57343;function gn(e){let t=0,n=``,r=[],i=``,a=[],o=!1,s=-1,c=un(()=>Math.min(t,r[0]??t,a[0]??t,s<0?t:s));function l(e,t){s>=0&&(pn.test(e)||z(c,`\\`,s),s=-1),e===`\\`?s=t:z(c,e,t)}function u(e,t){if(we(e)&&(o||i)){i+=e;for(let n=0;n<e.length;n++)a.push(t)}else{if(i){if(!pn.test(e))for(let e=0;e<i.length;e++)l(i[e],a[e]);i=``,a=[]}for(let n=0;n<e.length;n++)l(e[n],t);o=pn.test(e)&&e.length===1}}function d(){let e=0;for(;e<n.length;){let t=n.charCodeAt(e),i=t>=dn&&t<=fn;if(i&&e+1>=n.length)break;let a=n.charCodeAt(e+1),o=i&&a>=mn&&a<=hn?2:1;u(n.slice(e,e+o),r[e]),e+=o}n=n.slice(e),r=r.slice(e)}return c.update=()=>{c.fresh=``;let i=e.text.length;for(;t<i;){let a=R(e,t),o=a>=dn&&a<=fn;if(o&&t+1>=i)break;let s=R(e,t+1),c=o&&s>=mn&&s<=hn?2:1,l=lt(nn(e,t,t+c));n+=l;for(let e=0;e<l.length;e++)r.push(t);t+=c}d()},c}var _n=/[0-9A-Fa-f]/;function vn(e){let t=0,n=-1,r=un(()=>n<0?t:n);r.update=()=>{r.fresh=``;let a=e.text.length;for(;t<a;){let a=String.fromCharCode(R(e,t));if(n<0){a===`%`?n=t:(z(r,a,t),t++);continue}let o=(t-n)%3;if(o===0?a===`%`:_n.test(a))t++;else{i(t-o);for(let n=t-o;n<t;n++)z(r,String.fromCharCode(R(e,n)),n)}}};function i(t){t>n&&z(r,ye(nn(e,n,t)),n),n=-1}return r}var yn=new Set([`injection`,`base64`,`hex`,`spaced`,`pipe`]),bn=new Map(fe.map(({pattern:e,hit:t})=>[e,t])),xn=new Map(st.flatMap(({pattern:e,hit:t})=>t?[[e,t]]:[]));function B(e){return{rule:ot(e),severity:`high`,detector:e}}var Sn=B(`injection`),Cn=B(`marker_leak`),wn=B(`tool_leak`);function Tn({kind:e,group:t}){if(yn.has(e))return Sn;switch(e){case`sensitive`:case`card`:return t===void 0?void 0:B(t);case`boundary`:return Cn;case`image`:return B(`ungiven_images`);default:return B(`ungiven_links`)}}function En(e,t,n){if(e===`card`)return{hit:dt};if(e===`image`||e===`link`){let r=(e===`image`?tt:qe).indexOf(t),i=n[e][r];return`find`in i?{find:i.find}:{hit:i.test}}let r=bn.get(t)??xn.get(t);return r?{hit:r}:{}}function Dn(e,{given:t,allow:n,skipImages:r}){let i=e=>({...e,...t?{given:t}:{}}),a={image:Ze(i(n?.ungiven_images)),link:ct(i(n?.ungiven_links),r??e.includes(`ungiven_images`))},o=[];return le.forEach((t,n)=>{let r=Tn(t);r?.detector&&e.includes(r.detector)&&o.push({...r,id:n,regex:Ue(t.pattern),...En(t.kind,t.pattern,a)})}),o}function On(){let e=[];return le.forEach(({kind:t,pattern:n},r)=>{if(t!==`injection`)return;let i=bn.get(n);e.push({...Sn,id:r,regex:Ue(n),...i?{hit:i}:{}})}),e}function kn(){return Ce.map((e,t)=>({...Sn,id:t,regex:new RegExp(e.source,e.flags)}))}function An(e,t,n){let r=$t(t,n.map(e=>e.id)),i=new Int32Array(t.initials.length).fill(-1);n.forEach((e,t)=>{i[e.id]=t});let a=new Int32Array(t.size),o=new Int32Array(t.size),s=new Int32Array(t.size),c=new Int32Array(t.size),l=0,u=new Int32Array(t.size),d=new Int32Array(t.size),f=0,p=0,m=new Uint8Array(n.length),h=new Uint8Array(n.length),g=new Int32Array(n.length),_=new Int32Array(n.length),v=new Uint8Array(n.length),y=Uint8Array.from(n,e=>+!!e.find),b=new Int32Array(n.length).fill(-1),x=new Int32Array(n.length).fill(-1),S=Int32Array.from(n,e=>t.leads[e.id]??-1),C=[...new Set(S)].filter(e=>e>=0),w=n.flatMap((e,t)=>S[t]<0?[]:[t]),T=new Int32Array(t.has.length).fill(-1);function E(){let{text:n,fresh:h}=e,g=tn(e),{classOf:_,has:v,edges:w,final:E,pattern:D}=t;for(;p<n.length;p++){let e=_[p>=g?h.charCodeAt(p-g):n.charCodeAt(p)];f++;let t=0,O=(e,n)=>{if(d[e]===f){let t=u[e];n<c[t]&&(c[t]=n)}else d[e]=f,u[e]=t,s[t]=e,c[t]=n,t++,E[e]&&(m[i[D[e]]]=1)};for(let t=0;t<l;t++){let n=w[a[t]],r=o[t];for(let t=0;t<n.length;t+=2)v[n[t+1]][e]&&O(n[t],r)}let k=r[e];for(let e=0;e<k.length;e++){let t=k[e],n=i[D[t]],r=S[n],a=r<0?-1:T[r],o=a<0?p:a;O(t,o),y[n]&&(x[n]=p,b[n]<0&&(b[n]=o))}for(let t of C)v[t][e]?T[t]<0&&(T[t]=p):T[t]=-1;[a,s]=[s,a],[o,c]=[c,o],l=t}}function D(){let n=e.text.length;_.fill(n),v.fill(0);let r=n;for(let e=0;e<l;e++){let n=a[e],s=i[t.pattern[n]],c=o[e];c<_[s]&&(_[s]=c),t.final[n]&&(v[s]=1),c<r&&(r=c)}for(let e of w){let t=T[S[e]];t<0||(t<_[e]&&(_[e]=t),t<r&&(r=t))}return r}function O(t,r){let i=b[t],a=g[t];if(i<0||i>=r){g[t]=r;return}let{find:o,rule:s,severity:c,detector:l}=n[t],u=o?.(e.text,a,r);if(u===void 0)g[t]=r,b[t]=x[t]>=r?r:-1;else return g[t]=Math.max(a,u)+1,{rule:s,severity:c,start:e.rawAt(u),detector:l}}let k={text:``,lower:``},A=()=>(k.text!==e.text&&(k={text:e.text,lower:e.text.toLowerCase()}),k.lower);function ee(t,r){if(!m[t]&&!h[t]){g[t]=r;return}m[t]=0;let i=e.text,{regex:a,hit:o,rule:s,severity:c,detector:l}=n[t];for(a.lastIndex=g[t];;){let n=a.exec(i);if(!n||n.index>=r){g[t]=r,h[t]=n||v[t]?1:0;return}let[u]=n;if(u&&(!o||o(u,i,n.index,A)))return g[t]=a.lastIndex,h[t]=1,{rule:s,severity:c,start:e.rawAt(n.index),detector:l};u||a.lastIndex++,g[t]=a.lastIndex}}function te(){for(let e=0;e<n.length;e++){let t=_[e];if(t<=g[e])continue;let r=n[e].find?O(e,t):ee(e,t);if(r)return r}}return{run(t){E();let n=D();for(let e=te();e;e=te())t.push(e);return e.rawAt(n)}}}var jn=new WeakMap;function Mn(e){let t=jn.get(e);return t||(t=F(e),jn.set(e,t)),t}function Nn(e={}){let t={text:``,fresh:``},n=rn(t),r=[n],i=(e,t,n)=>(r.includes(e)||r.push(e),An(e,t,n)),a=[],o=e.detect??[],s=Dn(o,e);if(s.length>0&&(I??=F(Kt().forward),a.push(i(n,I,s))),o.includes(`injection`)){I??=F(Kt().forward),Wt??=F(Kt().reversed);let e=gn(t),r=On();a.push(i(n,Wt,kn()),i(ln(n),I,r),i(e,I,r),i(ln(e),I,r),i(an(n,Ve),I,r),i(an(n,e=>Ie(e)??e),I,r),i(vn(t),I,r))}if(o.includes(`marker_leak`)&&e.note){let t=pt(e.note);a.push(i(n,Zt(e.note),[{...Cn,id:0,regex:t}]))}if(o.includes(`tool_leak`)&&e.tools){let t=_e(e.tools),r=t.map(({regex:e},t)=>({...wn,id:t,regex:e}));t.length>0&&a.push(i(n,Qt(t.map(({literal:e})=>e)),r))}for(let{detector:t,compiled:r,matchers:o}of e.own??[]){let e=o.map(({regex:e},n)=>({...B(t),id:n,regex:new RegExp(e.source,e.flags)}));a.push(i(n,Mn(r.automaton),e))}let c=0;return{push(e){t.text+=e,t.fresh=e;for(let e of r)e.update();let n=[],i=t.text.length;for(let e of a)i=Math.min(i,e.run(n));return c=i,n},holdFrom:()=>c}}function Pn(e,t,n={},r=[]){let i=be(e,t).filter(e=>!(Ne(e)||r.includes(e))),a=Te(e,t);if(i.length===0&&a.length===0)return;let o=[...i,...a.map(({id:e})=>e)],s=t.sources??{},c=[...i.map(e=>({detector:e,...s[e]})),...a.map(({id:e,matchers:t,compiled:n})=>({detector:e,matchers:t,compiled:n}))],l=c.some(({matchers:e,compiled:t})=>e?.length&&!t),u=Nn({detect:i.filter(e=>s[e]?.theorem!==!1),own:c.flatMap(({detector:e,compiled:t,matchers:n=[]})=>t?[{detector:e,compiled:t,matchers:n}]:[]),skipImages:t.ungiven_images[e]!==`ignore`,...n.allow?{allow:n.allow}:{},...n.givenUrls?{given:n.givenUrls}:{},...n.note?{note:n.note}:{},...n.ownTools?{tools:n.ownTools}:{}}),d=a.some(({find:e})=>e),f=e===`live_reply`?96:256,p=``,m=[];return{push(e){p+=e;for(let{start:t,detector:n}of u.push(e))n&&m.push({start:t,detector:n})},holdFrom(){if(l)return 0;let e=u.holdFrom();return d?Math.min(e,Math.max(0,p.length-f)):e},take(r,i,a=!1){let s=m.filter(({start:e})=>e<i);if(s.length===0&&!a&&!d)return{action:`allow`,text:p.slice(r,i),hits:[],taken:i-r};let c={from:r,to:i,settled:s.map(({detector:e})=>e)},l=he(p,c,e,t,{detectors:o,scope:n});return m=m.filter(({start:e})=>e>=r+l.taken),l}}}function Fn(e){let{context:t}=e,n=e.detect,r=n?Pn(n.boundary,n.matrix,n.scope):void 0,i=e=>n?n.matrix[e][n.boundary]:`block`,a=i(`canary_leak`),o=i(`prompt_leak`),s=t.canaryGiven||a===`ignore`?void 0:t.canary,c=o===`ignore`?void 0:t.privateSystem,l=s!==void 0||c!==void 0,u=l?e.carry??``:``,d=[],f=new Set,p=``,m=0,h=``,g=u.slice(-N),_=u,v=0,y=u,b=0,x=0,S=s?me(s):void 0;S?.push(u);function C(e){let n=[];if(S?.push(e)&&n.push([a,Ye]),c){let r=_.length;_+=e;let i=bt(_,r);_=_.slice(i),v+=i;let[a]=We(_,c,t.canary);a&&n.push([o,a])}for(let[e,t]of n)e!==`flag`||f.has(t.rule)||(f.add(t.rule),d.push(t));return n.filter(([e])=>e!==`flag`).map(([,e])=>e)}function w(e){let t=l?C(e??``):[];return e&&r?.push(e),t.length===0?null:{hits:t,...n?{boundary:n.boundary}:{}}}function T(){let e=s&&a!==`flag`?D(s):h.length,n=c&&o!==`flag`?O(c,t.canary):h.length;return m+Math.min(e,n)}function E(e){if(d.length===0)return e;let t=[...d,...e.found?.hits??[]];return d=[],{...e,found:{action:e.found?.action??`flag`,hits:t}}}function D(e){let t=u.length+m,n=Math.max(t,x),r=Math.max(b,n-N),i=r+gt(y.slice(r-b),e);i<n&&n>t&&(y=g+h,b=t-g.length,i=b+gt(y,e)),x=Math.min(i,u.length+p.length-N);let a=Math.max(b,Math.max(t,x)-N);return y=y.slice(a-b),b=a,Math.max(0,i-t)}function O(e,t){let n=m===0?u:``,r=u.length+m-n.length,[i,a]=v>=r?[_,v]:[n+h,r];return Math.max(0,a+De(i,e,t)-u.length-m)}function k(e){let t=w(e);if(t)return{blocked:!0,...t};let i=e===void 0,a=i?p.length:Math.min(T(),r?.holdFrom()??p.length),o=Math.max(0,a-m);if(!(n&&r))return E({blocked:!1,emit:A(o)});let s=r.take(m,m+o,i);return s.action===`block`||s.action===`redact`&&!n.rewrite?{blocked:!0,hits:s.hits,boundary:n.boundary}:(A(s.taken),E({blocked:!1,emit:s.text??``,...s.action===`allow`?{}:{found:{action:s.action,hits:s.hits}}}))}function A(e){let t=h.slice(0,e);return h=h.slice(e),m+=t.length,l&&(g=(g+t).slice(-N)),t}return{process(e){return e?(p+=e,h+=e,l&&(y+=e),k(e)):{blocked:!1,emit:``}},flush:()=>k(),accumulated:()=>p,unreleased:()=>h,drainUnreleased:()=>A(h.length),carryOut:()=>l?ue(u+p,s,c):``}}function V(e,t,n){return Me(t,e.detect,n)}async function In(e,t,n,r){return V(e,[n],t)?(await Gt(),Ln(e,t,n,r)):null}function Ln(e,t,n,r){return V(e,[n],t)?Fn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:n===`reply`,scope:Le(e,t)},...r?{carry:r}:{}}):null}async function Rn(e,t,n,r){return V(e,[n],r??t)?(await Gt(),Fn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:!1,scope:r??Le(e,t)}})):null}var zn=class{open;gate;constructor(e){this.open=e}async read(e){if(this.gate===void 0&&(this.gate=await this.open()),this.gate===`stopped`)return``;if(!this.gate)return e;let t=this.gate.process(e);return t.blocked?(this.gate=`stopped`,``):t.emit}end(){if(!this.gate||this.gate===`stopped`)return``;let e=this.gate.flush();return e.blocked?``:e.emit}},Bn=[`user`,`options`,`repair`,`attachment`,`voice`,`history`,`system`];function Vn(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t.read(n)]))}var Hn={client:`untrusted`,server:`assembled`};function Un(e){return typeof e==`string`?e:JSON.stringify(e)}function Wn(e,t){let n=[],r=!1;if(!e)return{context:e,events:n,blocked:r};let i={};for(let a of et){let o=e[a];if(o===void 0)continue;let s=t();i[a]=s.read(Un(o));let c=s.found(),l=ke(`context`,c);l&&n.push({...l,trust:Hn[a]}),r||=c.action===`block`}return{context:i,events:n,blocked:r}}var Gn=/^[A-Za-z0-9._-]+$/;function Kn(e){let t=e?.trim();return t&&Gn.test(t)?t:void 0}function qn(e,t){if(!e)return e;let n=e.guidance?t.read(e.guidance):void 0;return{previousOutput:t.read(e.previousOutput),rejection:t.read(e.rejection),...n?{guidance:n}:{}}}function Jn(e,t){return e.map(e=>{let n=e.content===void 0?void 0:t.read(e.content),r=e.parts?.map(e=>e.type===`text`?{...e,text:t.read(e.text)}:e);return{role:e.role,...n===void 0?{}:{content:n},...r?{parts:r}:{},...e.tool_calls?{tool_calls:e.tool_calls}:{},...e.tool_call_id?{tool_call_id:e.tool_call_id}:{},...e.name?{name:e.name}:{},...e.metadata?{metadata:e.metadata}:{},...e.reasoning?{reasoning:e.reasoning}:{}}})}function Yn(e,t){let n=t?`: ${t}`:``;return new j(`input`,`guardrails.detect blocked the request at ${e}${n}`,{copy:{key:`detect.blocked`}})}function Xn(e,t){let{detect:n}=C(t.guardrails),r=pe(Bn,e=>nt(e,n)),i=e.input??{},a=i.text===void 0?void 0:r.user.read(i.text),o=e.system===void 0?void 0:Dt(e.system,`TurnRequest.system`,e=>r.system.read(e)),s=Vn(i.options,r.options),c=Wn(i.context,()=>nt(`context`,n)),l=qn(i.repair,r.repair),u=i.history?Jn(i.history,r.history):void 0,{attachments:d,voice:f}=i.attachments?.length||i.voice?.length?xt(t,i.attachments,i.voice,r):i,p=[],m;for(let e of Bn){let t=r[e].found(),n=ke(e,t);n&&p.push(Bt(n)),t.action===`block`&&(m??=Yn(e,t.errorInternal))}return p.push(...c.events.map(Bt)),c.blocked&&(m??=Yn(`context`)),{request:{...e,system:o,projectId:Kn(e.projectId),input:{...i,text:a,options:s,...c.context?{context:c.context}:{},repair:l,history:u,attachments:d,voice:f}},events:p,...m?{refusal:m}:{}}}function Zn(e,t){let{request:n,refusal:r}=Xn(e,t);if(r)throw r;return n}function Qn(e,t){return[...new Set([...t.filter(t=>y(e,t)),...e.filter(e=>y(t,e))])]}function $n(e,t){let n=e.attachments?t?Qn(e.attachments.accept,t.media.flatMap(e=>e.accept)):[...e.attachments.accept]:[],r=(t?.media??[]).flatMap(e=>e.maxPerInput===void 0?[]:[{accept:[...e.accept],max:e.maxPerInput}]);return{text:e.text!==!1,...n.length>0?{attachments:{accept:n}}:{},...e.maxFiles===void 0?{}:{maxFiles:e.maxFiles},...e.maxBytes===void 0?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===void 0?{}:{maxTurnBytes:e.maxTurnBytes},...e.limitsByMime===void 0?{}:{limitsByMime:{...e.limitsByMime}},...t?.maxInputs===void 0?{}:{maxInputs:t.maxInputs},...r.length>0?{perInput:r}:{}}}function er(e){let t=b(e[0]??``);return t===`application/pdf`?`PDF`:t.split(`/`)[0]??t}function tr(e,t){let n=wt(e),r=St({attachments:e.attachments?.accept,...n?{limits:{...n,maxFiles:2**53-1}}:{}},t.flat(),[]);if(n)for(let i of t){i.length>n.maxFiles&&r.push({code:`too_many_files`,params:{maxFiles:n.maxFiles}});for(let t of e.perInput??[])i.filter(e=>y(t.accept,e.mimeType)).length>t.max&&r.push({code:`too_many_of_kind`,params:{maxFiles:t.max,kind:er(t.accept)}})}let i=new Set;return r.filter(e=>{let t=JSON.stringify(e);return!i.has(t)&&(i.add(t),!0)})}var nr=`final_answer`;function rr(e){return e.structured!==null&&e.tools.wire.length>0}function ir(e,t,n){let{structured:r}=t;if(!r||!rr(t))return e;let i={type:`function`,name:nr,description:M(`structured.answer_tool`,{},n),parameters:r.jsonSchema};return{...e,structured:null,wireTools:[...e.wireTools??[],i]}}function ar(e,t){return e.get(t)||{name:t,missing:!0}}function or(e){let t=new Set;if(e.type===`host`||e.type===`decision`||e.type===`embedding`)return[];for(let n of Object.values(e.models))for(let e of n.builtInTools??[])t.add(e);return[...t]}function sr(e,t){return[...Pt(t),...or(t)].map(t=>ar(e,t))}function cr(e,t){if(Array.isArray(e)){for(let n of e)cr(n,t);return}if(typeof e!=`object`||!e)return;let{properties:n,...r}=e;if(typeof n==`object`&&n)for(let[e,r]of Object.entries(n))t.add(e),cr(r,t);for(let e of Object.values(r))cr(e,t)}function lr(e,t){let n=sr(e,t);if(n.length===0)return;let r=new Set;for(let e of n)`inputSchema`in e&&cr(e.inputSchema,r);return{names:n.map(({name:e})=>e),params:[...r]}}function ur(e){return!e||e.length===0?[]:e.slice(-4)}function dr(e,t){if(e.length===0)return``;let n=e.map(e=>`${e.role===`user`?`User`:`Assistant`}: ${e.content}`);return`${M(`repair.history_heading`,{count:e.length},t)}\n${n.join(`
|
|
1
|
+
import{t as e}from"./preload-helper-DpV6A1kQ.js";import{C as t,D as n,E as r,O as i,S as a,T as o,b as s,c,d as l,g as u,h as d,l as f,m as p,p as m,u as h,v as g,x as _}from"./schemas-D7cgkv3L.js";import{$n as v,Cn as y,Dn as b,En as x,Jn as S,On as C,Qn as w,Sn as T,Tn as E,U as D,Un as O,Wn as k,X as A,cr as ee,en as te,lr as ne,pn as re,qt as ie,s as ae,sr as oe,tn as se,tr as ce}from"./tool-schema-BMdqCPG0.js";import{c as j}from"./host-patterns-F-KZIzkF.js";import{$ as le,At as ue,Br as de,Bt as fe,Er as pe,Et as me,F as he,Ft as ge,G as _e,Gt as ve,Ht as ye,I as be,Ir as xe,It as Se,Jt as Ce,Kt as we,L as Te,Lr as Ee,Lt as De,Mr as Oe,N as ke,Or as Ae,Ot as je,P as Me,R as Ne,Rr as Pe,Sr as Fe,Ur as M,Ut as Ie,V as Le,Vr as Re,Vt as ze,Wn as Be,Wt as Ve,Xn as He,Yt as Ue,Z as We,_n as Ge,an as Ke,at as qe,bn as Je,cr as Ye,dn as Xe,dt as Ze,fn as Qe,hr as $e,in as et,it as tt,j as nt,jr as rt,kn as it,lr as at,mr as ot,nt as st,pt as ct,qt as lt,rn as ut,rt as dt,tn as ft,tt as pt,un as mt,vt as N,wn as ht,wt as gt,xn as _t,yn as vt,zn as yt,zt as bt}from"./shaped-data-QPeAmaJ4.js";import{S as xt,_ as St,b as Ct,x as wt}from"./browser-connection-qRFid-Dw.js";import{C as Tt,D as Et,F as Dt,I as Ot,M as kt,O as At,P as jt,T as Mt,b as Nt,v as Pt,y as Ft}from"./schema-BgiRaskO.js";import{a as It}from"./live-ingress-OuSlQ6q7.js";import{n as Lt,t as Rt}from"./trace-schema--4IGmLeE.js";import{n as zt}from"./stub-xIKEDapD.js";function Bt(e){return{type:`guardrail`,guardrail:e}}function Vt(e,t,n,r=`redact`,i){if(n.length!==0)return Bt({stage:e,trust:t,action:r,hits:n,...i?{provenance:i}:{}})}function Ht(e,t){return e.type===`guardrail`?{...e,guardrail:at(e.guardrail,t)}:e}var P=65536;function F(e){let t=e.classStarts.length,n=new Uint16Array(P);for(let r=0;r<t;r++)n.fill(r,e.classStarts[r],e.classStarts[r+1]??P);let r=e.charsets.map(e=>{let n=new Uint8Array(t);for(let t of e)n[t]=1;return n}),i=e.nodes.length,a=new Int32Array(i),o=new Uint8Array(i),s=[];return e.nodes.forEach((e,t)=>{a[t]=e[0],o[t]=e[1],s.push(Int32Array.from(e.slice(2)))}),{classOf:n,has:r,pattern:a,final:o,edges:s,initials:e.initials,leads:e.leads,size:i}}var Ut,I,Wt;async function Gt(){if(Ut)return;let{FORWARD_AUTOMATON:t,REVERSED_AUTOMATON:n}=await e(async()=>{let{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}=await import(`./egress-automata-CiZ3Vt9G.js`);return{FORWARD_AUTOMATON:e,REVERSED_AUTOMATON:t}},[]);Ut={forward:t,reversed:n}}function Kt(){if(!Ut)throw Error(`A stream was opened before loadEgressAutomata() finished.`);return Ut}var L;function qt(e){let t=String.fromCharCode(e).toUpperCase();if(t.length!==1)return e;let n=t.charCodeAt(0);return e>=128&&n<128?e:n}function Jt(e){if(!L){L=new Map;for(let e=0;e<P;e++){let t=qt(e),n=L.get(t);n?n.push(e):L.set(t,[e])}}return L.get(qt(e))??[e]}function Yt(e){let t=[0];for(let n of e)t.at(-1)!==n&&t.push(n),n+1<P&&t.push(n+1);return t}var Xt=new Map;function Zt(e){let t=Xt.get(e);if(t)return t;let n=Array.from({length:e.length},(t,n)=>Jt(e.charCodeAt(n))),r=Yt([...new Set(n.flat())].sort((e,t)=>e-t)),i=e=>r.indexOf(e),a=F({classStarts:r,charsets:n.map(e=>e.map(i)),initials:[0],leads:[-1],nodes:[...n.map((e,t)=>[0,0,t+1,t]),[0,1]]});return Xt.set(e,a),a}function Qt(e){let t=JSON.stringify(e),n=Xt.get(t);if(n)return n;let r=[...new Set(e.flatMap(e=>Array.from(e,e=>e.charCodeAt(0))))];r.sort((e,t)=>e-t);let i=Yt(r),a=r.map(e=>[i.indexOf(e)]),o=[],s=F({classStarts:i,charsets:a,initials:e.map((e,t)=>{let n=o.length;for(let n=0;n<e.length;n++)o.push([t,0,o.length+1,r.indexOf(e.charCodeAt(n))]);return o.push([t,1]),n}),leads:e.map(()=>-1),nodes:o});return Xt.set(t,s),s}function $t(e,t){let n=e.has[0]?.length??0,r=Array.from({length:n},()=>[]);for(let i of t){let t=e.edges[e.initials[i]];for(let i=0;i<t.length;i+=2){let a=e.has[t[i+1]];for(let e=0;e<n;e++)a[e]&&r[e]?.push(t[i])}}return r.map(e=>Int32Array.from(e))}function en(e,t){e.text+=t,e.fresh+=t}function tn(e){return e.text.length-e.fresh.length}function R(e,t){let n=tn(e);return t>=n?e.fresh.charCodeAt(t-n):e.text.charCodeAt(t)}function nn(e,t,n=e.text.length){let r=tn(e);return t>=r?e.fresh.slice(t-r,n-r):e.text.slice(t,n)}function rn(e){let t={text:``,fresh:``,rawAt:e=>e,update(){t.text=e.text,t.fresh=e.fresh}};return t}function an(e,t){let n={text:``,fresh:``,rawAt:e.rawAt,update(){n.fresh=``,en(n,t(nn(e,n.text.length)))}};return n}var on=/\w/,sn=Math.max(...ze.map(e=>e.length));function cn(e){return e.length<=sn+1&&/^[A-Za-z]*$/.test(e)}function ln(e){let t=0,n,r=!1,i=[],a=(e,t,n)=>{en(o,e);for(let r=0;r<e.length;r++)i.push(t+Math.min(r,n-1))},o={text:``,fresh:``,rawAt:r=>e.rawAt(r<i.length?i[r]:t-(n?.length??0)),update(){o.fresh=``;for(let i=e.text.length;t<i;t++){let i=String.fromCharCode(R(e,t)),o=on.test(i);o&&!r&&(n=``),r=o,o?n===void 0?a(i,t,1):n+=i:(n!==void 0&&a(ve(n),t-n.length,n.length),n=void 0,a(i,t,1))}n!==void 0&&!cn(n)&&(a(n,t-n.length,n.length),n=void 0)}};return o}function un(e){let t={text:``,fresh:``,from:[],rawAt:n=>n<t.from.length?t.from[n]:e(),update(){}};return t}function z(e,t,n){en(e,t);for(let r=0;r<t.length;r++)e.from.push(n)}var dn=55296,fn=56319,pn=/[A-Za-z]/,mn=56320,hn=57343;function gn(e){let t=0,n=``,r=[],i=``,a=[],o=!1,s=-1,c=un(()=>Math.min(t,r[0]??t,a[0]??t,s<0?t:s));function l(e,t){s>=0&&(pn.test(e)||z(c,`\\`,s),s=-1),e===`\\`?s=t:z(c,e,t)}function u(e,t){if(we(e)&&(o||i)){i+=e;for(let n=0;n<e.length;n++)a.push(t)}else{if(i){if(!pn.test(e))for(let e=0;e<i.length;e++)l(i[e],a[e]);i=``,a=[]}for(let n=0;n<e.length;n++)l(e[n],t);o=pn.test(e)&&e.length===1}}function d(){let e=0;for(;e<n.length;){let t=n.charCodeAt(e),i=t>=dn&&t<=fn;if(i&&e+1>=n.length)break;let a=n.charCodeAt(e+1),o=i&&a>=mn&&a<=hn?2:1;u(n.slice(e,e+o),r[e]),e+=o}n=n.slice(e),r=r.slice(e)}return c.update=()=>{c.fresh=``;let i=e.text.length;for(;t<i;){let a=R(e,t),o=a>=dn&&a<=fn;if(o&&t+1>=i)break;let s=R(e,t+1),c=o&&s>=mn&&s<=hn?2:1,l=lt(nn(e,t,t+c));n+=l;for(let e=0;e<l.length;e++)r.push(t);t+=c}d()},c}var _n=/[0-9A-Fa-f]/;function vn(e){let t=0,n=-1,r=un(()=>n<0?t:n);r.update=()=>{r.fresh=``;let a=e.text.length;for(;t<a;){let a=String.fromCharCode(R(e,t));if(n<0){a===`%`?n=t:(z(r,a,t),t++);continue}let o=(t-n)%3;if(o===0?a===`%`:_n.test(a))t++;else{i(t-o);for(let n=t-o;n<t;n++)z(r,String.fromCharCode(R(e,n)),n)}}};function i(t){t>n&&z(r,ye(nn(e,n,t)),n),n=-1}return r}var yn=new Set([`injection`,`base64`,`hex`,`spaced`,`pipe`]),bn=new Map(fe.map(({pattern:e,hit:t})=>[e,t])),xn=new Map(st.flatMap(({pattern:e,hit:t})=>t?[[e,t]]:[]));function B(e){return{rule:ot(e),severity:`high`,detector:e}}var Sn=B(`injection`),Cn=B(`marker_leak`),wn=B(`tool_leak`);function Tn({kind:e,group:t}){if(yn.has(e))return Sn;switch(e){case`sensitive`:case`card`:return t===void 0?void 0:B(t);case`boundary`:return Cn;case`image`:return B(`ungiven_images`);default:return B(`ungiven_links`)}}function En(e,t,n){if(e===`card`)return{hit:dt};if(e===`image`||e===`link`){let r=(e===`image`?tt:qe).indexOf(t),i=n[e][r];return`find`in i?{find:i.find}:{hit:i.test}}let r=bn.get(t)??xn.get(t);return r?{hit:r}:{}}function Dn(e,{given:t,allow:n,skipImages:r}){let i=e=>({...e,...t?{given:t}:{}}),a={image:Ze(i(n?.ungiven_images)),link:ct(i(n?.ungiven_links),r??e.includes(`ungiven_images`))},o=[];return le.forEach((t,n)=>{let r=Tn(t);r?.detector&&e.includes(r.detector)&&o.push({...r,id:n,regex:Ue(t.pattern),...En(t.kind,t.pattern,a)})}),o}function On(){let e=[];return le.forEach(({kind:t,pattern:n},r)=>{if(t!==`injection`)return;let i=bn.get(n);e.push({...Sn,id:r,regex:Ue(n),...i?{hit:i}:{}})}),e}function kn(){return Ce.map((e,t)=>({...Sn,id:t,regex:new RegExp(e.source,e.flags)}))}function An(e,t,n){let r=$t(t,n.map(e=>e.id)),i=new Int32Array(t.initials.length).fill(-1);n.forEach((e,t)=>{i[e.id]=t});let a=new Int32Array(t.size),o=new Int32Array(t.size),s=new Int32Array(t.size),c=new Int32Array(t.size),l=0,u=new Int32Array(t.size),d=new Int32Array(t.size),f=0,p=0,m=new Uint8Array(n.length),h=new Uint8Array(n.length),g=new Int32Array(n.length),_=new Int32Array(n.length),v=new Uint8Array(n.length),y=Uint8Array.from(n,e=>+!!e.find),b=new Int32Array(n.length).fill(-1),x=new Int32Array(n.length).fill(-1),S=Int32Array.from(n,e=>t.leads[e.id]??-1),C=[...new Set(S)].filter(e=>e>=0),w=n.flatMap((e,t)=>S[t]<0?[]:[t]),T=new Int32Array(t.has.length).fill(-1);function E(){let{text:n,fresh:h}=e,g=tn(e),{classOf:_,has:v,edges:w,final:E,pattern:D}=t;for(;p<n.length;p++){let e=_[p>=g?h.charCodeAt(p-g):n.charCodeAt(p)];f++;let t=0,O=(e,n)=>{if(d[e]===f){let t=u[e];n<c[t]&&(c[t]=n)}else d[e]=f,u[e]=t,s[t]=e,c[t]=n,t++,E[e]&&(m[i[D[e]]]=1)};for(let t=0;t<l;t++){let n=w[a[t]],r=o[t];for(let t=0;t<n.length;t+=2)v[n[t+1]][e]&&O(n[t],r)}let k=r[e];for(let e=0;e<k.length;e++){let t=k[e],n=i[D[t]],r=S[n],a=r<0?-1:T[r],o=a<0?p:a;O(t,o),y[n]&&(x[n]=p,b[n]<0&&(b[n]=o))}for(let t of C)v[t][e]?T[t]<0&&(T[t]=p):T[t]=-1;[a,s]=[s,a],[o,c]=[c,o],l=t}}function D(){let n=e.text.length;_.fill(n),v.fill(0);let r=n;for(let e=0;e<l;e++){let n=a[e],s=i[t.pattern[n]],c=o[e];c<_[s]&&(_[s]=c),t.final[n]&&(v[s]=1),c<r&&(r=c)}for(let e of w){let t=T[S[e]];t<0||(t<_[e]&&(_[e]=t),t<r&&(r=t))}return r}function O(t,r){let i=b[t],a=g[t];if(i<0||i>=r){g[t]=r;return}let{find:o,rule:s,severity:c,detector:l}=n[t],u=o?.(e.text,a,r);if(u===void 0)g[t]=r,b[t]=x[t]>=r?r:-1;else return g[t]=Math.max(a,u)+1,{rule:s,severity:c,start:e.rawAt(u),detector:l}}let k={text:``,lower:``},A=()=>(k.text!==e.text&&(k={text:e.text,lower:e.text.toLowerCase()}),k.lower);function ee(t,r){if(!m[t]&&!h[t]){g[t]=r;return}m[t]=0;let i=e.text,{regex:a,hit:o,rule:s,severity:c,detector:l}=n[t];for(a.lastIndex=g[t];;){let n=a.exec(i);if(!n||n.index>=r){g[t]=r,h[t]=n||v[t]?1:0;return}let[u]=n;if(u&&(!o||o(u,i,n.index,A)))return g[t]=a.lastIndex,h[t]=1,{rule:s,severity:c,start:e.rawAt(n.index),detector:l};u||a.lastIndex++,g[t]=a.lastIndex}}function te(){for(let e=0;e<n.length;e++){let t=_[e];if(t<=g[e])continue;let r=n[e].find?O(e,t):ee(e,t);if(r)return r}}return{run(t){E();let n=D();for(let e=te();e;e=te())t.push(e);return e.rawAt(n)}}}var jn=new WeakMap;function Mn(e){let t=jn.get(e);return t||(t=F(e),jn.set(e,t)),t}function Nn(e={}){let t={text:``,fresh:``},n=rn(t),r=[n],i=(e,t,n)=>(r.includes(e)||r.push(e),An(e,t,n)),a=[],o=e.detect??[],s=Dn(o,e);if(s.length>0&&(I??=F(Kt().forward),a.push(i(n,I,s))),o.includes(`injection`)){I??=F(Kt().forward),Wt??=F(Kt().reversed);let e=gn(t),r=On();a.push(i(n,Wt,kn()),i(ln(n),I,r),i(e,I,r),i(ln(e),I,r),i(an(n,Ve),I,r),i(an(n,e=>Ie(e)??e),I,r),i(vn(t),I,r))}if(o.includes(`marker_leak`)&&e.note){let t=pt(e.note);a.push(i(n,Zt(e.note),[{...Cn,id:0,regex:t}]))}if(o.includes(`tool_leak`)&&e.tools){let t=_e(e.tools),r=t.map(({regex:e},t)=>({...wn,id:t,regex:e}));t.length>0&&a.push(i(n,Qt(t.map(({literal:e})=>e)),r))}for(let{detector:t,compiled:r,matchers:o}of e.own??[]){let e=o.map(({regex:e},n)=>({...B(t),id:n,regex:new RegExp(e.source,e.flags)}));a.push(i(n,Mn(r.automaton),e))}let c=0;return{push(e){t.text+=e,t.fresh=e;for(let e of r)e.update();let n=[],i=t.text.length;for(let e of a)i=Math.min(i,e.run(n));return c=i,n},holdFrom:()=>c}}function Pn(e,t,n={},r=[]){let i=be(e,t).filter(e=>!(Ne(e)||r.includes(e))),a=Te(e,t);if(i.length===0&&a.length===0)return;let o=[...i,...a.map(({id:e})=>e)],s=t.sources??{},c=[...i.map(e=>({detector:e,...s[e]})),...a.map(({id:e,matchers:t,compiled:n})=>({detector:e,matchers:t,compiled:n}))],l=c.some(({matchers:e,compiled:t})=>e?.length&&!t),u=Nn({detect:i.filter(e=>s[e]?.theorem!==!1),own:c.flatMap(({detector:e,compiled:t,matchers:n=[]})=>t?[{detector:e,compiled:t,matchers:n}]:[]),skipImages:t.ungiven_images[e]!==`ignore`,...n.allow?{allow:n.allow}:{},...n.givenUrls?{given:n.givenUrls}:{},...n.note?{note:n.note}:{},...n.ownTools?{tools:n.ownTools}:{}}),d=a.some(({find:e})=>e),f=e===`live_reply`?96:256,p=``,m=[];return{push(e){p+=e;for(let{start:t,detector:n}of u.push(e))n&&m.push({start:t,detector:n})},holdFrom(){if(l)return 0;let e=u.holdFrom();return d?Math.min(e,Math.max(0,p.length-f)):e},take(r,i,a=!1){let s=m.filter(({start:e})=>e<i);if(s.length===0&&!a&&!d)return{action:`allow`,text:p.slice(r,i),hits:[],taken:i-r};let c={from:r,to:i,settled:s.map(({detector:e})=>e)},l=he(p,c,e,t,{detectors:o,scope:n});return m=m.filter(({start:e})=>e>=r+l.taken),l}}}function Fn(e){let{context:t}=e,n=e.detect,r=n?Pn(n.boundary,n.matrix,n.scope):void 0,i=e=>n?n.matrix[e][n.boundary]:`block`,a=i(`canary_leak`),o=i(`prompt_leak`),s=t.canaryGiven||a===`ignore`?void 0:t.canary,c=o===`ignore`?void 0:t.privateSystem,l=s!==void 0||c!==void 0,u=l?e.carry??``:``,d=[],f=new Set,p=``,m=0,h=``,g=u.slice(-N),_=u,v=0,y=u,b=0,x=0,S=s?me(s):void 0;S?.push(u);function C(e){let n=[];if(S?.push(e)&&n.push([a,Ye]),c){let r=_.length;_+=e;let i=bt(_,r);_=_.slice(i),v+=i;let[a]=We(_,c,t.canary);a&&n.push([o,a])}for(let[e,t]of n)e!==`flag`||f.has(t.rule)||(f.add(t.rule),d.push(t));return n.filter(([e])=>e!==`flag`).map(([,e])=>e)}function w(e){let t=l?C(e??``):[];return e&&r?.push(e),t.length===0?null:{hits:t,...n?{boundary:n.boundary}:{}}}function T(){let e=s&&a!==`flag`?D(s):h.length,n=c&&o!==`flag`?O(c,t.canary):h.length;return m+Math.min(e,n)}function E(e){if(d.length===0)return e;let t=[...d,...e.found?.hits??[]];return d=[],{...e,found:{action:e.found?.action??`flag`,hits:t}}}function D(e){let t=u.length+m,n=Math.max(t,x),r=Math.max(b,n-N),i=r+gt(y.slice(r-b),e);i<n&&n>t&&(y=g+h,b=t-g.length,i=b+gt(y,e)),x=Math.min(i,u.length+p.length-N);let a=Math.max(b,Math.max(t,x)-N);return y=y.slice(a-b),b=a,Math.max(0,i-t)}function O(e,t){let n=m===0?u:``,r=u.length+m-n.length,[i,a]=v>=r?[_,v]:[n+h,r];return Math.max(0,a+De(i,e,t)-u.length-m)}function k(e){let t=w(e);if(t)return{blocked:!0,...t};let i=e===void 0,a=i?p.length:Math.min(T(),r?.holdFrom()??p.length),o=Math.max(0,a-m);if(!(n&&r))return E({blocked:!1,emit:A(o)});let s=r.take(m,m+o,i);return s.action===`block`||s.action===`redact`&&!n.rewrite?{blocked:!0,hits:s.hits,boundary:n.boundary}:(A(s.taken),E({blocked:!1,emit:s.text??``,...s.action===`allow`?{}:{found:{action:s.action,hits:s.hits}}}))}function A(e){let t=h.slice(0,e);return h=h.slice(e),m+=t.length,l&&(g=(g+t).slice(-N)),t}return{process(e){return e?(p+=e,h+=e,l&&(y+=e),k(e)):{blocked:!1,emit:``}},flush:()=>k(),accumulated:()=>p,unreleased:()=>h,drainUnreleased:()=>A(h.length),carryOut:()=>l?ue(u+p,s,c):``}}function V(e,t,n){return Me(t,e.detect,n)}async function In(e,t,n,r){return V(e,[n],t)?(await Gt(),Ln(e,t,n,r)):null}function Ln(e,t,n,r){return V(e,[n],t)?Fn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:n===`reply`,scope:Le(e,t)},...r?{carry:r}:{}}):null}async function Rn(e,t,n,r){return V(e,[n],r??t)?(await Gt(),Fn({context:t,detect:{matrix:e.detect,boundary:n,rewrite:!1,scope:r??Le(e,t)}})):null}var zn=class{open;gate;constructor(e){this.open=e}async read(e){if(this.gate===void 0&&(this.gate=await this.open()),this.gate===`stopped`)return``;if(!this.gate)return e;let t=this.gate.process(e);return t.blocked?(this.gate=`stopped`,``):t.emit}end(){if(!this.gate||this.gate===`stopped`)return``;let e=this.gate.flush();return e.blocked?``:e.emit}},Bn=[`user`,`options`,`repair`,`attachment`,`voice`,`history`,`system`];function Vn(e,t){return e&&Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t.read(n)]))}var Hn={client:`untrusted`,server:`assembled`};function Un(e){return typeof e==`string`?e:JSON.stringify(e)}function Wn(e,t){let n=[],r=!1;if(!e)return{context:e,events:n,blocked:r};let i={};for(let a of et){let o=e[a];if(o===void 0)continue;let s=t();i[a]=s.read(Un(o));let c=s.found(),l=ke(`context`,c);l&&n.push({...l,trust:Hn[a]}),r||=c.action===`block`}return{context:i,events:n,blocked:r}}var Gn=/^[A-Za-z0-9._-]+$/;function Kn(e){let t=e?.trim();return t&&Gn.test(t)?t:void 0}function qn(e,t){if(!e)return e;let n=e.guidance?t.read(e.guidance):void 0;return{previousOutput:t.read(e.previousOutput),rejection:t.read(e.rejection),...n?{guidance:n}:{}}}function Jn(e,t){return e.map(e=>{let n=e.content===void 0?void 0:t.read(e.content),r=e.parts?.map(e=>e.type===`text`?{...e,text:t.read(e.text)}:e);return{role:e.role,...n===void 0?{}:{content:n},...r?{parts:r}:{},...e.tool_calls?{tool_calls:e.tool_calls}:{},...e.tool_call_id?{tool_call_id:e.tool_call_id}:{},...e.name?{name:e.name}:{},...e.metadata?{metadata:e.metadata}:{},...e.reasoning?{reasoning:e.reasoning}:{}}})}function Yn(e,t){let n=t?`: ${t}`:``;return new j(`input`,`guardrails.detect blocked the request at ${e}${n}`,{copy:{key:`detect.blocked`}})}function Xn(e,t){let{detect:n}=C(t.guardrails),r=pe(Bn,e=>nt(e,n)),i=e.input??{},a=i.text===void 0?void 0:r.user.read(i.text),o=e.system===void 0?void 0:Dt(e.system,`TurnRequest.system`,e=>r.system.read(e)),s=Vn(i.options,r.options),c=Wn(i.context,()=>nt(`context`,n)),l=qn(i.repair,r.repair),u=i.history?Jn(i.history,r.history):void 0,{attachments:d,voice:f}=i.attachments?.length||i.voice?.length?xt(t,i.attachments,i.voice,r):i,p=[],m;for(let e of Bn){let t=r[e].found(),n=ke(e,t);n&&p.push(Bt(n)),t.action===`block`&&(m??=Yn(e,t.errorInternal))}return p.push(...c.events.map(Bt)),c.blocked&&(m??=Yn(`context`)),{request:{...e,system:o,projectId:Kn(e.projectId),input:{...i,text:a,options:s,...c.context?{context:c.context}:{},repair:l,history:u,attachments:d,voice:f}},events:p,...m?{refusal:m}:{}}}function Zn(e,t){let{request:n,refusal:r}=Xn(e,t);if(r)throw r;return n}function Qn(e,t){return[...new Set([...t.filter(t=>y(e,t)),...e.filter(e=>y(t,e))])]}function $n(e,t){let n=e.attachments?t?Qn(e.attachments.accept,t.media.flatMap(e=>e.accept)):[...e.attachments.accept]:[],r=(t?.media??[]).flatMap(e=>e.maxPerInput===void 0?[]:[{accept:[...e.accept],max:e.maxPerInput}]);return{text:e.text!==!1,...n.length>0?{attachments:{accept:n}}:{},...e.maxFiles===void 0?{}:{maxFiles:e.maxFiles},...e.maxBytes===void 0?{}:{maxBytes:e.maxBytes},...e.maxTurnBytes===void 0?{}:{maxTurnBytes:e.maxTurnBytes},...e.limitsByMime===void 0?{}:{limitsByMime:{...e.limitsByMime}},...t?.maxInputs===void 0?{}:{maxInputs:t.maxInputs},...r.length>0?{perInput:r}:{}}}function er(e){let t=b(e[0]??``);return t===`application/pdf`?`PDF`:t.split(`/`)[0]??t}function tr(e,t){let n=wt(e),r=St({attachments:e.attachments?.accept,...n?{limits:{...n,maxFiles:2**53-1}}:{}},t.flat(),[]);if(n)for(let i of t){i.length>n.maxFiles&&r.push({code:`too_many_files`,params:{maxFiles:n.maxFiles}});for(let t of e.perInput??[])i.filter(e=>y(t.accept,e.mimeType)).length>t.max&&r.push({code:`too_many_of_kind`,params:{maxFiles:t.max,kind:er(t.accept)}})}let i=new Set;return r.filter(e=>{let t=JSON.stringify(e);return!i.has(t)&&(i.add(t),!0)})}var nr=`final_answer`;function rr(e){return e.structured!==null&&e.tools.wire.length>0}function ir(e,t,n){let{structured:r}=t;if(!r||!rr(t))return e;let i={type:`function`,name:nr,description:M(`structured.answer_tool`,{},n),parameters:r.jsonSchema};return{...e,structured:null,wireTools:[...e.wireTools??[],i]}}function ar(e,t){return e.get(t)||{name:t,missing:!0}}function or(e){let t=new Set;if(e.type===`host`||e.type===`decision`||e.type===`embedding`)return[];for(let n of Object.values(e.models))for(let e of n.builtInTools??[])t.add(e);return[...t]}function sr(e,t){return[...Pt(t),...or(t)].map(t=>ar(e,t))}function cr(e,t){if(Array.isArray(e)){for(let n of e)cr(n,t);return}if(typeof e!=`object`||!e)return;let{properties:n,...r}=e;if(typeof n==`object`&&n)for(let[e,r]of Object.entries(n))t.add(e),cr(r,t);for(let e of Object.values(r))cr(e,t)}function lr(e,t){let n=sr(e,t);if(n.length===0)return;let r=new Set;for(let e of n)`inputSchema`in e&&cr(e.inputSchema,r);return{names:n.map(({name:e})=>e),params:[...r]}}function ur(e){return!e||e.length===0?[]:e.slice(-4)}function dr(e,t){if(e.length===0)return``;let n=e.map(e=>`${e.role===`user`?`User`:`Assistant`}: ${e.content}`);return`${M(`repair.history_heading`,{count:e.length},t)}\n${n.join(`
|
|
2
2
|
`)}\n\n`}function fr(e){let{profile:t,repair:n,history:r}=e,i=n.guidance||M(`repair.default_guidance`,{},t.labels),a=dr(ur(r),t.labels),o=`${M(`repair.prompt_header`,{},t.labels)}\n\n`;return o+=`${M(`repair.prompt_intro`,{},t.labels)}\n\n`,o+=`${M(`repair.section_previous_output`,{},t.labels)}\n\`\`\`\n${n.previousOutput.trim()}\n\`\`\`\n\n`,o+=`${M(`repair.section_validator_rejection`,{},t.labels)}\n${n.rejection.trim()}\n\n`,i.trim()&&(o+=`${M(`repair.section_repair_guidance`,{},t.labels)}\n${i.trim()}\n\n`),a&&(o+=a),o+=`${M(`repair.section_instructions`,{},t.labels)}\n`,o+=M(`repair.prompt_instructions`,{},t.labels),o}function pr(e,t){let n=[];return t&&n.push(`structured`),e.type===`image`&&n.push(`image`),e.type===`speech`&&n.push(`speech`),n}function mr(e,t){let n=pr(e,t);if(!(n.length<=1))throw new j(`config`,`Profile ${e.id} declares multiple output wire formats (${n.join(`, `)}). Only one of a structured JSON schema (outputs.structured), image, or speech may be active.`)}function hr(e,t){if(e.type!==`speech`){if(t.speech)throw new j(`request`,`Profile ${e.id} (${e.type}) takes no speech settings — only a speech profile speaks`)}else if(t.system)throw new j(`config`,`Profile ${e.id} (speech) takes no system prompt — the input text is the transcript`)}function gr(e,t){if(e.type===`transcription`){if(t.system)throw new j(`config`,`Profile ${e.id} (transcription) takes no system prompt — the input is the clip`);if(!t.input?.voice?.length)throw new j(`request`,`Profile ${e.id} (transcription) requires a voice clip`)}}function _r(e,t){return e.type===`speech`?{...e.speech,...vr(t.speech)}:void 0}function vr(e){return Object.fromEntries(Object.entries(e??{}).filter(([,e])=>e!==void 0))}function yr(e){if(e.type!==`image`)return null;let t=e.image;return{type:`image`,mimeType:t.mimeType,aspectRatio:t.aspectRatio,resolution:t.resolution,quality:t.quality,background:t.background,n:t.n,seed:t.seed,outputCompression:t.outputCompression,includeText:t.includeText===!0}}function br(e){let t=T(e);if(!t)throw new j(`input`,`MIME '${e}' is not a supported media input type`);return t}function xr(e){return e.map(e=>{let t=br(e.mimeType),n=b(e.mimeType),r=n===`image/jpg`?`image/jpeg`:n;return Ct(e)?{type:t,mimeType:r,uri:e.uri}:{type:t,mimeType:r,data:e.data}})}function Sr(e,t){let{text:n,repair:r,history:i}=t.input??{};if(e.type===`speech`&&!n?.trim())throw new j(`request`,`Profile ${e.id} (speech) requires text input`);if(E(e)?.text===!1&&n)throw new j(`request`,`Profile ${e.id} does not accept text input`);let a=r?fr({profile:e,repair:r,history:i}):wr(e,t)??n;if(e.type===`speech`)return a?{type:`text`,text:a}:null;let o=[...Cr(t),...a?[Se(a)]:[]];return o.length>0?{type:`text`,text:o.join(`
|
|
3
3
|
|
|
4
4
|
`)}:null}function Cr(e){let t=e.input?.context??{};return[...et].reverse().filter(e=>t[e]!==void 0).map(e=>ge(e,Un(t[e])))}function wr(e,t){if(t.continueFrom&&ie.includes(e.type)){if(t.input?.text)throw new j(`request`,`Profile ${e.id}: a continueFrom turn takes no input.text — its user message is the continue instruction`);return M(`continue.instruction`,{},e.labels)}}function Tr(e){return e.type===`image`&&e.image.references?xr(e.image.references):[]}function Er(e,t){let n=t.input?.attachments??[],r=t.input?.voice??[];return[...Tr(e),...xr(n),...xr(r)]}function Dr(e,t){let n=[],r=Sr(e,t);return r&&n.push(r),n.push(...Er(e,t)),n}function Or(e,t){let n=t.input?.context;if(!n)return;let r=E(e)?.context;for(let[t,i]of Object.entries(n))if(i!==void 0){if(!et.includes(t)||!r?.from.some(e=>e===t))throw new j(`request`,`Profile ${e.id} takes no context from '${t}'`);if(Un(i).length>r.maxChars)throw new j(`request`,`Profile ${e.id}: context from '${t}' is over inputs.context.maxChars (${String(r.maxChars)})`)}}function kr(e,t){if(e.type===`speech`||e.type===`transcription`)return[];let n=e.identity.system;if(!n)return[];let r=kt(e,t);return Mt(n,r,t=>At(e,t,r))}function Ar(e,t){let n=kr(e,t);return{pieces:jt([...n.map(({pieces:e})=>e),t.system===void 0?[]:Ot(t.system)]),lines:n.map(({line:e})=>e)}}function jr(e){return e.type!==`host`&&e.type!==`decision`&&e.type!==`embedding`}function Mr(e,t){if(jr(e))return e;throw e.type===`host`?new j(`request`,`Profile ${e.id}: type 'host' never runs a model — ${t} is not supported; execute tools with invokeTool`):e.type===`embedding`?new j(`request`,`Profile ${e.id}: type 'embedding' runs through runEmbedding — ${t} is not supported`):new j(`request`,`Profile ${e.id}: type 'decision' runs through runDecision — ${t} is not supported`)}function Nr(e,t){if(t){if(!e.allowModelSelect)throw new j(`request`,`Profile ${e.id} does not allow model selection`);if(!e.models[t])throw new j(`request`,`Unknown model '${t}' for ${e.id}`);return t}return e.defaultModel}function Pr(e,t,n,r){let i=t.efforts;if(!i||Object.keys(i).length===0){if(r)throw new j(`request`,`Profile ${e.id} model '${n}' has no selectable efforts`);return}let a=Object.keys(i);if(r){if(!t.allowEffortSelect)throw new j(`request`,`Profile ${e.id} model '${n}' does not allow effort selection`);let a=i[r];if(!a)throw new j(`request`,`Unknown effort '${r}' for ${e.id} model '${n}'`);return a}return i[t.defaultEffort??a[0]]}function Fr(e){if(e.summaries===!0)return`auto`;if(e.summaries===!1)return`none`}function Ir(e,t){if(e.type===`live`)return null;let n=e.outputs?.structured;if(!n)return null;if(typeof n==`string`)return n;let r=t[n.by];if(r){let e=n.map[r];if(e)return e}return n.fallback}function Lr(e){return e.type===`live`||e.outputs?.streaming?.mode!==`buffered`}function Rr(e,t){return e.type===`live`?`live`:`turn`}function zr(e,t){if(!t.continueFrom)return;if(e.type===`live`)throw new j(`request`,`Profile ${e.id}: type 'live' uses live.sessionResumption, not turnBehaviour.resumption/continueFrom`);let n=se(e)?.maxContinues;if(n===void 0)return;let r=t.continuation;if(r===void 0)throw new j(`request`,`Profile ${e.id}: continueFrom requires TurnRequest.continuation when turnBehaviour.resumption.maxContinues is set`);if(r<1)throw new j(`request`,`Profile ${e.id}: continuation must be >= 1`);if(r>n)throw new j(`request`,`Profile ${e.id}: continuation ${r} exceeds turnBehaviour.resumption.maxContinues (${n})`)}function Br(e,t){return V(C(t),[`live_reply`])?{...e,transcription:{...e?.transcription,output:!0}}:e}function Vr(e){let{detect:t}=C(e.guardrails);return e.type!==`speech`&&e.type!==`transcription`&&He(t,`canary_leak`)?je():``}function Hr(e,t,n,r){if(!r)return;let i={};for(let[a,o]of Object.entries(r)){if(!n.builtInTools?.includes(a))throw new j(`request`,`Profile ${e.id}: builtInArgs names '${a}', which model '${t}' does not list in builtInTools`);i[a]=o}return i}function Ur(e,t,n){let r=Mr(e.profiles.get(t.profile),`resolveTurn`);Et(r,t),Or(r,t);let i=Zn(t,r),a=i.input??{};zr(r,i);let o=n??Nr(r,i.model),s=x(r,o),c=Tt(e.tools,r,i,o),l=c.builtins,u=Ir(r,kt(r,i));if(mr(r,u),u&&c.wire.some(e=>e.name===`final_answer`))throw new j(`config`,`Profile ${r.id}: a structured turn answers through '${nr}', so no tool of its own may take that name`);hr(r,i),gr(r,i);let d=Hr(r,o,s,i.builtInArgs),f=Rr(r,s),p=e.providers.get(s.provider),m=p&&re(p,s,r.type),h=Ar(r,i);return{profile:r,generation:{model:o,apiId:s.apiId,transport:f,...m?{operationName:m}:{},stream:Lr(r),thinking:Pr(r,s,o,i.effort),summaries:Fr(s),maxOutputTokens:s.maxOutputTokens,temperature:s.temperature,builtins:l,builtInArgs:d,sessionId:i.sessionId,tools:c,sessionPermissions:i.sessionPermissions,execution:i.execution,pageExecution:i.pageExecution,history:a.history,maxSteps:r.maxSteps??20,structured:u?{id:u,jsonSchema:e.schemas.get(u).jsonSchema}:null,image:yr(r),speech:_r(r,i),live:r.type===`live`?Br(r.live,r.guardrails):void 0,input:Dr(r,i),canary:Vr(r),resolvedSystem:h.pieces,systemLines:h.lines,host:i.host}}}function Wr(e){return e.type===`image`?e.image:null}function Gr(e,t){let n=Mr(t,`projectProfile`),{identity:r}=n,i=E(n)??null,a=n.type===`live`?null:n.outputs??null;return{id:n.id,type:n.type,handle:r.handle,models:n.models,defaultModel:n.defaultModel,allowModelSelect:n.allowModelSelect,maxSteps:n.maxSteps,tools:sr(e,n),inputs:i,outputs:a,image:Wr(n),speech:n.type===`speech`?n.speech:null,live:n.type===`live`?n.live:null}}function Kr(e,t){return Gr(e.tools,e.profiles.get(t))}var qr=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/wav`,`audio/mpeg`];function Jr(e){return e.join(`,`)}function Yr(e){let t=e?.attachments?.accept,n=e?.voice?.accept;return{text:e?.text!==!1,attachments:t?.length?{accept:t,acceptAttr:Jr(t)}:null,voice:n?.length?{accept:n}:null,maxFiles:e?.maxFiles,maxBytes:e?.maxBytes,maxTurnBytes:e?.maxTurnBytes,limitsByMime:e?.limitsByMime,options:e?.options,context:e?.context}}function Xr(e){return{text:e.text,attachments:e.attachments?{accept:e.attachments.accept}:void 0,voice:e.voice?{accept:e.voice.accept}:void 0,maxFiles:e.maxFiles,maxBytes:e.maxBytes,maxTurnBytes:e.maxTurnBytes,limitsByMime:e.limitsByMime,options:e.options,context:e.context}}function Zr(e,t){let n=e=>(e??[]).map(({name:e,mimeType:t,sizeBytes:n})=>({name:e,mimeType:t,sizeBytes:n})),r=St({attachments:e.attachments?.accept,voice:e.voice?.accept,limits:wt(Xr(e))},n(t.attachments),n(t.voice));return{ok:r.length===0,issues:r}}function Qr(e){let t=globalThis.MediaRecorder;if(t===void 0)return;let n=e=>t.isTypeSupported(e),r=e=>e.find(n);return e?.length?r(qr.filter(t=>y(e,t)))??e.find(n):r(qr)}var $r=_({protocol:r(),provider:r(),apiId:r(),options:t(r(),u()).optional(),keySlot:r().optional(),fallbackKeySlot:r().optional(),efforts:t(r(),c(_t)).optional(),defaultEffort:r().optional(),allowEffortSelect:m().optional(),summaries:m().optional(),maxOutputTokens:s().optional(),temperature:s().optional(),builtInTools:l(r()).optional(),compaction:_({maxTokens:s(),compactAt:s(),previousExchanges:s(),profile:r().optional(),timing:c(ut),meter:c(ft).optional()}).optional(),limits:_({operationTimeoutMs:s().optional(),connectTimeoutMs:s().optional(),liveStepTimeoutMs:s().optional(),maxWireRecordBytes:s().optional(),maxWireResponseBytes:s().optional(),maxEventBytes:s().optional(),maxStepBytes:s().optional(),maxStepEvents:s().optional(),maxPendingToolCalls:s().optional()}).optional()}),ei=_({structured:n([r(),_({by:r(),map:t(r(),r()),fallback:r()}),f()]).optional(),streaming:_({mode:c(Je).optional(),streamThoughts:m().optional()}).optional()}),ti=_(pe(Fe,()=>c(Be))),ni=_(pe(yt,()=>ti)),ri=_({id:r(),label:r(),actions:ti,names:l(r()),find:m()}),ii=_({hosts:l(r()),fromTools:m()}),ai=_({quota:_({perDay:s()}).optional(),detect:ni,patterns:a(c(yt),_({theorem:m(),names:l(r())})).optional(),host:l(ri).optional(),allow:_({ungiven_images:ii,ungiven_links:ii}),blockedReply:_({onBlock:c($e),maxRetries:s()})}),oi=n([m(),_({theorem:m(),host:m()})]),si=_({record:m(),writeTo:n([g(!1),r()]).optional(),sampleRate:s(),include:_({upstreamLog:m(),outboundWire:m(),evidenceRaw:m(),usage:m(),guardrailDecisions:m(),guardrailMatchPreview:m()}),scrub:_({sensitive:oi,injection:oi,canary:oi}),resource:Rt,retainForDays:s(),rotateAfterMiB:s(),hasOnWriteError:m()}),ci=t(r(),_({label:r().optional(),choices:l(_({value:r(),description:r().optional()}))})),H=_({text:m(),attachments:_({accept:l(r()),acceptAttr:r()}).nullable(),voice:_({accept:l(r())}).nullable(),maxFiles:s().optional(),maxBytes:s().optional(),maxTurnBytes:s().optional(),limitsByMime:t(r(),s()).optional(),options:ci.optional(),context:_({from:l(c(et)),maxChars:s()}).optional()}),li=_({allowContinue:l(c(Ke)).optional(),autoContinue:l(c(Ke)).optional(),maxContinues:s().optional()}),ui=_({resumption:li.optional()}),di=_({allow:l(r()),page:l(r()),t2Loader:r().optional(),parallel:m().optional()}),U={providerContinuation:_({history:c([`host`,`stateless`,`provider`]).optional()}).optional(),id:r(),models:t(r(),$r),defaultModel:r(),allowModelSelect:m().optional(),maxSteps:s().optional(),labels:a(c(de),r()),guardrails:ai.optional(),observability:si.optional()},fi=n([r(),o({private:r().min(1)})]),pi=n([r(),l(n([r(),l(fi).readonly()])).min(1).readonly()]),mi=_({handle:r(),options:ci.optional(),system:pi.optional()}),W=d(`type`,[_({...U,type:g(`text`),identity:mi,outputs:ei.optional(),inputs:H,tools:di,turnBehaviour:_({resumption:li.optional(),allowSteering:m().optional(),atStepLimit:c(vt).optional()}).optional(),canStop:g(!0),allowSteering:m()}),_({...U,type:g(`image`),identity:mi,outputs:ei.optional(),image:_({aspectRatio:r().optional(),resolution:r().optional(),mimeType:r().optional(),quality:r().optional(),background:r().optional(),n:s().int().min(1).optional(),seed:s().int().optional(),outputCompression:s().int().min(0).max(100).optional(),references:l(n([_({mimeType:r(),data:r(),name:r().optional()}),_({mimeType:r(),uri:r(),name:r().optional()})])).optional(),includeText:m().optional()}),inputs:H,tools:di,turnBehaviour:ui.optional(),canStop:g(!0)}),_({...U,type:g(`transcription`),identity:_({handle:r()}),maxSteps:h().optional(),outputs:ei.optional(),inputs:H,canStop:g(!0)}),_({...U,type:g(`speech`),identity:_({handle:r()}),outputs:ei.optional(),speech:_({voice:r().optional(),style:r().optional(),speed:s().optional(),format:c(Ge).optional()}),inputs:H,turnBehaviour:ui.optional(),canStop:g(!0)}),_({...U,type:g(`live`),identity:mi,inputs:H.pick({options:!0,context:!0}).optional(),live:_({ingress:_({audio:m().optional(),video:m().optional(),text:m().optional()}).optional(),voice:r().optional(),vad:_({activityHandling:c(mt).optional(),startSensitivity:c(Qe).optional(),endSensitivity:c(Xe).optional(),prefixPaddingMs:s().optional(),silenceDurationMs:s().optional()}).optional(),sessionResumption:m().optional(),contextCompression:_({triggerTokens:s().optional(),slidingWindow:_({targetTokens:s().optional()})}).optional(),transcription:_({input:m().optional(),output:m().optional()}).optional()}),tools:di.pick({allow:!0,page:!0}),turnBehaviour:_({allowSteering:m().optional()}).optional()})]);function hi(e){let t=C(e),{sources:n,host:r,...i}=t.detect;return{quota:t.quota,detect:i,...n?{patterns:Object.fromEntries(Object.entries(n).map(([e,{theorem:t,matchers:n}])=>[e,{theorem:t,names:n.map(({name:e})=>e)}]))}:{},...r?{host:r.map(({id:e,label:t,actions:n,matchers:r,find:i})=>({id:e,label:t,actions:n,names:r.map(({name:e})=>e),find:!!i}))}:{},allow:{ungiven_images:gi(t.allow.ungiven_images),ungiven_links:gi(t.allow.ungiven_links)},blockedReply:t.blockedReply}}function gi(e){return{hosts:[...e.hosts??[]],fromTools:e.fromTools??!0}}function _i(e){return e===void 0||e===!1||typeof e==`string`?e:`custom`}function vi(e){if(!e)return;let t=It(e);return{record:t.record,writeTo:_i(t.writeTo),sampleRate:t.sampleRate,include:t.include,scrub:t.scrub,resource:t.resource,retainForDays:t.retainForDays,rotateAfterMiB:t.rotateAfterMiB,hasOnWriteError:!!t.onWriteError}}function yi(e){let{greeting:t,resumed:n,...r}=e??{};return r}function bi(e,t){let n=e.tools.filter(e=>`type`in e&&e.type===`function`&&e.answeredBy===`page`).map(e=>e.name);if(t){let e=Nt(t),r=Ft(t);return{allow:[...Pt(t)],page:n,...e?.t2Loader?{t2Loader:e.t2Loader}:{},...r===void 0?{}:{parallel:r}}}return{allow:e.tools.filter(e=>!(`type`in e&&e.type===`builtin`)).map(e=>e.name),page:n}}function xi({allow:e,page:t}){return{allow:e,page:t}}function Si(e,t){let n=Yr(e.inputs),r=t?.identity??{handle:e.handle},i=t?hi(t.guardrails):void 0,a=t?vi(t.observability):void 0,o=e.outputs??void 0,s={id:e.id,identity:r,models:e.models,defaultModel:e.defaultModel,allowModelSelect:e.allowModelSelect,maxSteps:e.maxSteps,providerContinuation:e.providerContinuation,outputs:o,guardrails:i,observability:a,labels:Re(t?.labels)};switch(e.type){case`text`:return W.parse({...s,type:`text`,inputs:n,tools:bi(e,t),turnBehaviour:t?.type===`text`?t.turnBehaviour:void 0,canStop:!0,allowSteering:!t||te(t)});case`image`:return W.parse({...s,type:`image`,image:e.image??{},inputs:n,tools:bi(e,t),turnBehaviour:t?.type===`image`?t.turnBehaviour:void 0,canStop:!0});case`speech`:return W.parse({...s,type:`speech`,speech:e.speech??{},inputs:n,turnBehaviour:t?.type===`speech`?t.turnBehaviour:void 0,canStop:!0});case`transcription`:return W.parse({...s,type:`transcription`,inputs:n,canStop:!0});case`live`:return W.parse({...s,type:`live`,live:yi(e.live),...e.inputs?{inputs:{options:n.options,context:n.context}}:{},tools:xi(bi(e,t))});default:return e.type}}function Ci(e,t){let n=Mr(e,`interfaceFromProfile`);return Si(Gr(t,n),n)}function wi(e){return p(t=>w.safeParse(e(t)).success)}var Ti=[`running`,`gate`,`background`,`complete`,`error`,`cancel`],Ei=p(e=>{let t=w.safeParse({type:`tool`,tool:e});if(!t.success||t.data.type!==`tool`||!(`phase`in t.data.tool))return!1;let{phase:n}=t.data.tool;return Ti.some(e=>e===n)}),Di=t(r(),i()),Oi=_({operationId:r().optional(),name:r(),callId:r(),arguments:Di,draft:r().optional(),reasoning:l(S).optional(),stepId:r().optional(),edited:_({from:Di,to:Di}).optional(),activity:r().optional(),activityPast:r().optional(),outputDraft:r().optional(),state:Ei.optional(),startedAt:s().optional(),endedAt:s().optional(),artifacts:l(i()),get steps(){return l(Oi).optional()}}),ki=_({kind:c(it),native:r().optional()}),G={id:r()},K=d(`kind`,[_({...G,kind:g(`user-text`),text:r()}),_({...G,kind:c([`user-attachment`,`user-voice`]),name:r(),mimeType:r(),sizeBytes:s(),data:r().optional()}),_({...G,kind:g(`thought`),text:r()}),_({...G,kind:g(`text`),text:r()}),_({...G,kind:g(`tool`),tool:Oi}),_({...G,kind:g(`structured`),value:i(),draft:r().optional()}),_({...G,kind:g(`media`),mimeType:r(),data:r().optional(),url:r().optional(),previewUrl:r().optional()}),_({...G,kind:g(`grounding`),grounding:wi(e=>({type:`grounding`,grounding:e}))}),_({...G,kind:g(`citation`),sources:wi(e=>({type:`citation`,sources:e})),callId:r().optional()}),_({...G,kind:g(`evidence`),evidence:wi(e=>({type:`evidence`,evidence:e}))}),_({...G,kind:g(`guardrail`),guardrail:ne}),_({...G,kind:g(`late-results`),text:r()}),_({...G,kind:g(`error`),message:r()}),_({...G,kind:g(`turn-done`),stop:ki.optional(),tokens:wi(e=>({type:`tokens`,tokens:e})).optional(),interactionId:r().optional(),compaction:m().optional(),workedMs:s().optional(),endedAt:s().optional()})]),Ai=_({type:r()});function ji(e,t){return Object.hasOwn(e,t)}function Mi(e,t){return e.map(e=>{let n=[...t,...e.path],r=`${n.map(String).join(`.`)||`(root)`} ${e.code}`;return e.code!==`invalid_union`||e.errors.length===0?r:`${r} [${e.errors.map(e=>Mi(e,n)).join(` | `)}]`}).join(`; `)}function Ni(e){return Mi(e.issues,[])}function Pi(e,t){return new j(`bad_response`,`${e} failed its wire check: ${Ni(t)}`)}function q(e,t,n){let r=e.safeParse(t);if(!r.success)throw Pi(n,r.error);return r.data}function Fi(e){return{type:`malformed`,error:new j(`bad_response`,e,{copy:{key:`session.part_skipped`}})}}function Ii(e,t){let n=Ai.safeParse(t);if(!n.success)return Fi(`a line without a kind failed its wire check: ${Ni(n.error)}`);let{type:r}=n.data;if(!ji(e,r))return{type:`unsupported`,received:r,raw:t};let i=e[r].safeParse(t);return i.success?i.data:Fi(`a '${r}' line failed its wire check: ${Ni(i.error)}`)}function Li(e){try{return{value:JSON.parse(e)}}catch(e){if(e instanceof SyntaxError)return;throw e}}function Ri(e,t){let n=Li(t);return n?Ii(e,n.value):Fi(`a line is not JSON`)}function zi(e){let t=Li(e);if(!t)throw new j(`bad_response`,`a line is not JSON`);return t.value}var Bi=_({name:r(),mimeType:r(),data:r()}),Vi=_({options:t(r(),r()).optional(),context:i().optional(),text:r().optional(),attachments:l(Bi).optional(),voice:l(Bi).optional()}),Hi=_({gateKind:c(ht).optional(),sessionPermissions:l(r()).optional(),name:r().optional(),input:i().optional(),snapshot:ce.optional(),promoted:l(r()).optional(),model:r().optional(),effort:r().optional()}),J=r().trim().min(1),Ui=_({path:r().optional(),options:t(r(),r()).optional()}),Wi=Ui;_({input:Vi,conversation:r().min(1).optional(),model:r().optional(),effort:r().optional(),stated:Ui.optional(),turnId:J.optional(),abandon:l(k).min(1).optional(),replay:Hi.pick({sessionPermissions:!0}).optional(),transcript:l(K).optional()});var Gi=[`approve`,`deny`],Ki=n([o({unanswered:g(!0)}),o({output:i()}).refine(e=>`output`in e).transform(e=>({output:e.output}))]);_({gateId:r().min(1),operationId:r().min(1).max(256),decision:c(Gi),input:i().optional(),secret:r().optional(),page:Ki.optional(),conversation:r().min(1).optional(),turnId:J.optional(),replay:Hi.optional()}),_({turnId:J,id:J,inject:l(v).min(1)}),_({turnId:J});var qi=_({type:g(`conversation`),ref:r().min(1),posted:g(!0).optional()}),Ji={...O,conversation:qi},Yi=_({transcript:l(K),paused:_({events:l(w),blocks:l(K)}).optional(),notify:_({retryMs:s().optional()}).optional()});_({conversation:r().min(1)}),o({});var Xi={changed:_({type:g(`changed`)})};_({conversation:r().min(1),at:s().int().min(-1)}),_({blocks:l(K)});var Zi=_({conversation:r().min(1),view:Yi}),Qi=class extends Error{kind;publicMessage;internalMessage;copy;constructor(e,t,n,r){super(n??t??e),this.name=`TheoremStreamError`,this.kind=e,t&&(this.publicMessage=t),n&&(this.internalMessage=n),r&&(this.copy=r)}};function $i(e){return e instanceof Qi}function ea(e){return e?.trim()||void 0}var ta=_({error:r().optional(),errorKind:ee.optional(),errorCopy:oe.optional(),errorInternal:r().optional()}),na=ta;function ra(e,t){let n=ea(e.error),r=ea(e.errorInternal);return new Qi(e.errorKind??t,n,r&&r!==n?r:void 0,e.errorCopy)}function ia(e){return!$i(e)||e.copy===void 0?!1:(Array.isArray(e.copy)?e.copy:[e.copy]).some(e=>e.key===`session.conversation_unknown`)}function aa(e,t){let n=Ri(e,t);if(n.type===`error`)throw ra(ta.parse(n),`internal`);return n}function oa(e,t,n){let r=e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,E as t,T as n,b as r,c as i,d as a,h as o,o as s,p as c,pt as l,s as ee,t as te,v as ne}from"./schemas-D7cgkv3L.js";import{$n as re,Ct as ie,Gn as ae,Tn as oe,Un as u,_t as d,ar as f,cr as p,dr as m,mt as h,or as g,ur as se}from"./tool-schema-Sm_QLU6x.js";import{c as _}from"./host-patterns-F-KZIzkF.js";import{Pn as ce,Ur as v}from"./shaped-data-CK3-VEaY.js";import{d as le,f as ue,i as y,l as de,n as b,s as fe,t as x}from"./schema-C46sNlNM.js";var pe=n({accepted:f,preparedInput:g});function S(e){return new _(`internal`,e)}function C(e,t,n){return new _(e,t,{copy:{key:`tool.execution_uncertain`},cause:n})}function w(e){return C(`conflict`,`The tool operation is ${e}, so it does not run again until the host settles it`)}async function T(e){let t=e=>Array.isArray(e)?e.map(t):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,n])=>[e,t(n)])):e,n=g.parse(t(j(e))),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,`0`)).join(``)}var E=u.tool.transform((e,t)=>e.tool.phase===`complete`||e.tool.phase===`error`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),D=n({finding:t(),data:g.optional(),parts:a(ae).optional(),modelText:t().optional(),provenance:m.optional(),suspicious:a(se).optional()}),O=u.tool.transform((e,t)=>e.tool.phase===`background`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),k=n({event:O,replay:n({modelResult:D})}),A=n({event:E,effects:i([`not_started`,`completed`,`unknown`]),replay:n({modelResult:D.optional(),outputRaw:g.optional(),failure:n({code:t(),kind:p,message:t(),error:t().optional(),details:g.optional()}).optional(),awaiting:c().optional(),denied:ne(!0).optional(),callNotStarted:c().optional(),aborted:e([c(),n({reason:t().optional()})]).optional(),pendingInject:a(n({id:t().optional(),messages:a(re),released:r().int().nonnegative().optional()})).optional()})});function j(e){let t=new Set,n=e=>{if(!e||typeof e!=`object`)return e;if(t.has(e))throw S(`Tool operation value has a cycle`);let r=Object.getPrototypeOf(e);if(!Array.isArray(e)&&r!==Object.prototype&&r!==null)throw S(`Tool operation value holds an object that is not plain data`);if(Object.hasOwn(e,`__proto__`))throw S(`Tool operation value has an own __proto__ key`);t.add(e);try{if(Array.isArray(e))return e.map(n);let t=Object.entries(Object.getOwnPropertyDescriptors(e)),r=t.find(([,e])=>e.get||e.set);if(r)throw S(`Tool operation value has a getter or setter at '${r[0]}'`);return Object.fromEntries(t.filter(([,e])=>e.enumerable&&e.value!==void 0).map(([e,t])=>[e,n(t.value)]))}finally{t.delete(e)}};return g.parse(n(e))}var M=e([i([`always`,`ask`,`never`]),n({afterMs:r().finite().nonnegative()})]),N=`background`;function P(){return c().optional().describe(v(`tool.background_field`))}function F(e,t){if(e?.background!==`ask`||typeof t!=`object`||!t)return{input:t,asked:!1};let{[N]:n,...r}=t;return{input:r,asked:n===!0}}function I(e,t){let{background:n}=e;if(n!==void 0&&n!==`never`)return n===`always`?`claim`:n===`ask`?F(e,t).asked?`claim`:void 0:n}function L(e){let{tool:t,support:n,base:r,labels:i}=e;if(!t||!n)return;let a=I(t,e.input);if(a!==void 0)return{at:a,support:n,trace:n.openTrace(r.callId),reply:()=>{let e={finding:v(`tool.background_started`,{tool:t.name},i)},n=d(e),a=h(r,{phase:`background`,readBack:n});return k.parse(j({event:a,replay:{modelResult:e}}))}}}function R(e,t){if(e&&!t?.detach)throw new _(`config`,`A request with a background service needs a coordinator with detach`)}function z(e){let{name:t,background:n}=e;if(n!==void 0&&n!==`never`){if(e.answeredBy===`page`)throw new _(`config`,`Tool '${t}' sets background, which a tool answered by the page cannot`);if(!M.safeParse(n).success)throw new _(`config`,typeof n==`object`?`Tool '${t}' sets background.afterMs, which must be a time in milliseconds`:`Tool '${t}' sets background to ${JSON.stringify(n)}; it takes 'always', 'ask', 'never' or { afterMs }`)}}var B=/^[\x21-\x7E]{1,256}$/;function V(e=Date.now){let t=new Map,n=new Map,r=({tool:e,max:n})=>{if(n===void 0)return;let r=[...t.values()].filter(t=>t.tool===e).length;for(let[i,a]of t){if(r<=n)break;a.tool===e&&(t.delete(i),r--)}};return{get(n,i){let a=t.get(n);if(a&&(t.delete(n),!(i.idleMs!==void 0&&e()-a.usedAt>i.idleMs)))return t.set(n,{...a,usedAt:e(),tool:i.tool}),r(i),{id:a.id,protocolVersion:a.protocolVersion}},open(i,a,o){let s=n.get(i);if(s)return s;let c=o().then(n=>(t.delete(i),t.set(i,{...n,usedAt:e(),tool:a.tool}),r(a),n)).finally(()=>n.delete(i));return n.set(i,c),c},drop(e,n){t.get(e)?.id===n&&t.delete(e)},clear(){t.clear(),n.clear()}}}function me(e){return e!==null&&B.test(e)}async function he(e,t){let n=JSON.stringify([e,Object.entries(t).map(([e,t])=>[e.toLowerCase(),t]).sort(([e],[t])=>e<t?-1:+(e>t))]),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(n));return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var H=`after`;function ge(){return a(t()).optional().describe(v(`tool.after_field`))}function U(t,n,r,i){let a=n=>{if(n instanceof s){if(r in n.shape)throw new _(`config`,`Tool '${t}' sets ${r}, and its input already has a field of that name`);return n.safeExtend({[r]:i()})}if(n instanceof te){let e=n.options.map(a);return o(n.def.discriminator,e)}if(n instanceof ee)return e(n.options.map(a));throw new _(`config`,`Tool '${t}' sets ${r}, which needs an object input or a union of objects`)};return a(n)}function W(e,t){return U(e,t,H,ge)}function _e(e,t){if(!e.after||typeof t!=`object`||!t)return{input:t,names:[]};let{[H]:n,...r}=t;return{input:r,names:n??[]}}function ve(e,t,n){return n?e.flatMap(e=>{let r=n.filter(n=>n.tool===e&&n.callId!==t).map(e=>e.callId);return r.length>0?r:[e]}):[]}var G=class{value;constructor(e){this.value=e}};function ye(e){return new G(e)}function be(e){return(t,n)=>{let{page:r}=n;if(r&&`output`in r)return ye(r.output);let{labels:i}=n.profile;throw r?.timedOut?Error(v(`tool.page_timed_out`,{},i)):Error(v(`tool.page_no_answer`,{tool:e},i))}}var K=new WeakMap;function q(e,t){let n=K.get(e);n||(n=new WeakMap,K.set(e,n));let r=n.get(t);if(!r){let i=b(e,`input`);y(i,`input`);let a=b(t,`output`);y(a,`output`),r={inputSchema:i,outputSchema:a},n.set(t,r)}return r}function J(e){let{inputSchema:t,outputSchema:n}=q(e.input,e.output),r={activity:{input:t},activityPast:{input:t,output:n},activityFailed:{input:t},request:{input:t}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let n=e.labels?.[t],i=n?ie(n,r[t]):void 0;if(i)throw new _(`config`,`Tool "${e.name}" ${t} label: ${i}`)}return{inputSchema:structuredClone(t),outputSchema:structuredClone(n)}}function xe(e,t){if(t&&(typeof t.service!=`string`||!t.service.trim()))throw new _(`config`,`Tool "${e}" signs in with slot "${t.slot}" but names no service`)}function Y(e,t,n=[]){if(t?.queryParam===void 0)return;let r=t.queryParam.trim()?t.type===`api_key`?t.headerName!==void 0||t.headerPrefix!==void 0?`is set with headerName or headerPrefix; the key goes in one place`:n.includes(t.queryParam)?`"${t.queryParam}" is also one of mapping.queryParams`:void 0:`is set on a '${t.type}' sign-in; only an API key goes in the URL`:`is blank`;if(r)throw new _(`config`,`Tool "${e}" auth.queryParam ${r}`)}function Se(e,t){if(t!==void 0&&!(Number.isInteger(t.requests)&&t.requests>0&&Number.isFinite(t.windowMs)&&t.windowMs>0))throw new _(`config`,`Tool "${e}" limit needs a whole number of requests above 0 and a window above 0 ms`)}function X(e,t){if(!(t===void 0||Number.isFinite(t)&&t>0))throw new _(`config`,`Tool "${e}" timeoutMs needs a finite number of ms above 0`)}function Z(e,t,n){if(!(n===void 0||Number.isInteger(n)&&n>0))throw new _(`config`,`Tool "${e}" ${t} needs a whole number above 0`)}function Ce(e){Z(e.name,`maxResponseBytes`,e.maxResponseBytes);let t=e.imageLimits;t&&(Z(e.name,`imageLimits.count`,t.count),Z(e.name,`imageLimits.bytes`,t.bytes),Z(e.name,`imageLimits.totalBytes`,t.totalBytes),X(e.name,t.timeoutMs))}function Q(e){if(e.type!==`builtin`&&z({name:e.name,...e.background===void 0?{}:{background:e.background},...e.answeredBy?{answeredBy:e.answeredBy}:{}}),e.type===`builtin`||e.type===`agent`)return;xe(e.name,e.auth),e.type===`http`?(e.endpoint?.trim()&&x(e.endpoint),Y(e.name,e.auth,e.mapping?.queryParams),Se(e.name,e.limit),X(e.name,e.timeoutMs)):Y(e.name,e.auth),(e.type===`http`||e.type===`mcp`)&&Ce(e),e.type===`mcp`&&(Z(e.name,`session.idleMs`,e.session?.idleMs),Z(e.name,`session.max`,e.session?.max));let[t]=ce(e);if(t)throw new _(`config`,`Tool "${e.name}" ${t.path} ${t.message}`)}function $(e){return x(e.endpoint),{...e,type:`http`,...J(e)}}function we(e){return{...e,type:`mcp`,...J(e)}}function Te(e){let t=e.answeredBy===`page`?be(e.name):e.handler;if(typeof t!=`function`)throw new _(`config`,`Tool '${e.name}' needs a handler, or answeredBy: 'page'`);return{...e,handler:t,type:`function`,...J(e)}}function Ee(e){if(e.type===`builtin`||e.background!==`ask`)return e;let t=e.input,n=U(e.name,t,`background`,P);return{...e,askInputSchema:q(n,e.output).inputSchema}}function De(e,t,n){return Q(e),Ee(Oe(e,t,n))}function Oe(e,t,n){if(e.type===`builtin`)return e;if(e.type===`agent`){let r=le(e,t,n),i=oe(r),a=fe({type:r.type,...i?{inputs:i}:{}},e),o=e.after?W(e.name,a):a,s=J({...e,input:o,output:de});return ue(e,o,s)}let r=e.after?{...e,input:W(e.name,e.input)}:e;return r.type===`http`?$(r):r.type===`mcp`?we(r):Te(r)}function ke(e=()=>void 0){let t=new Map,n=V(),r=e=>t.get(e),i=n=>{let i=De(n,e,r);return t.set(i.name,i),i};return{register:i,registerMany:e=>e.map(e=>i(e)),get:r,require(e){let t=r(e);if(!t)throw new _(`config`,`Tool '${e}' is not registered`);return t},has:e=>t.has(e),list:()=>[...t.values()],findProfile:e,reset:()=>{t.clear(),n.clear()},mcpSessions:n}}export{A as _,ve as a,he as c,F as d,w as f,T as g,pe as h,_e as i,R as l,j as m,ke as n,V as o,S as p,G as r,me as s,Q as t,L as u,k as v,C as y};
|
|
1
|
+
import{D as e,E as t,T as n,b as r,c as i,d as a,h as o,o as s,p as c,pt as l,s as ee,t as te,v as ne}from"./schemas-D7cgkv3L.js";import{$n as re,Ct as ie,Gn as ae,Tn as oe,Un as u,_t as d,ar as f,cr as p,dr as m,mt as h,or as g,ur as se}from"./tool-schema-BMdqCPG0.js";import{c as _}from"./host-patterns-F-KZIzkF.js";import{Pn as ce,Ur as v}from"./shaped-data-QPeAmaJ4.js";import{d as le,f as ue,i as y,l as de,n as b,s as fe,t as x}from"./schema-BgiRaskO.js";var pe=n({accepted:f,preparedInput:g});function S(e){return new _(`internal`,e)}function C(e,t,n){return new _(e,t,{copy:{key:`tool.execution_uncertain`},cause:n})}function w(e){return C(`conflict`,`The tool operation is ${e}, so it does not run again until the host settles it`)}async function T(e){let t=e=>Array.isArray(e)?e.map(t):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,n])=>[e,t(n)])):e,n=g.parse(t(j(e))),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(JSON.stringify(n)));return Array.from(new Uint8Array(r),e=>e.toString(16).padStart(2,`0`)).join(``)}var E=u.tool.transform((e,t)=>e.tool.phase===`complete`||e.tool.phase===`error`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),D=n({finding:t(),data:g.optional(),parts:a(ae).optional(),modelText:t().optional(),provenance:m.optional(),suspicious:a(se).optional()}),O=u.tool.transform((e,t)=>e.tool.phase===`background`?{...e,tool:e.tool}:(t.addIssue({code:`custom`}),l)),k=n({event:O,replay:n({modelResult:D})}),A=n({event:E,effects:i([`not_started`,`completed`,`unknown`]),replay:n({modelResult:D.optional(),outputRaw:g.optional(),failure:n({code:t(),kind:p,message:t(),error:t().optional(),details:g.optional()}).optional(),awaiting:c().optional(),denied:ne(!0).optional(),callNotStarted:c().optional(),aborted:e([c(),n({reason:t().optional()})]).optional(),pendingInject:a(n({id:t().optional(),messages:a(re),released:r().int().nonnegative().optional()})).optional()})});function j(e){let t=new Set,n=e=>{if(!e||typeof e!=`object`)return e;if(t.has(e))throw S(`Tool operation value has a cycle`);let r=Object.getPrototypeOf(e);if(!Array.isArray(e)&&r!==Object.prototype&&r!==null)throw S(`Tool operation value holds an object that is not plain data`);if(Object.hasOwn(e,`__proto__`))throw S(`Tool operation value has an own __proto__ key`);t.add(e);try{if(Array.isArray(e))return e.map(n);let t=Object.entries(Object.getOwnPropertyDescriptors(e)),r=t.find(([,e])=>e.get||e.set);if(r)throw S(`Tool operation value has a getter or setter at '${r[0]}'`);return Object.fromEntries(t.filter(([,e])=>e.enumerable&&e.value!==void 0).map(([e,t])=>[e,n(t.value)]))}finally{t.delete(e)}};return g.parse(n(e))}var M=e([i([`always`,`ask`,`never`]),n({afterMs:r().finite().nonnegative()})]),N=`background`;function P(){return c().optional().describe(v(`tool.background_field`))}function F(e,t){if(e?.background!==`ask`||typeof t!=`object`||!t)return{input:t,asked:!1};let{[N]:n,...r}=t;return{input:r,asked:n===!0}}function I(e,t){let{background:n}=e;if(n!==void 0&&n!==`never`)return n===`always`?`claim`:n===`ask`?F(e,t).asked?`claim`:void 0:n}function L(e){let{tool:t,support:n,base:r,labels:i}=e;if(!t||!n)return;let a=I(t,e.input);if(a!==void 0)return{at:a,support:n,trace:n.openTrace(r.callId),reply:()=>{let e={finding:v(`tool.background_started`,{tool:t.name},i)},n=d(e),a=h(r,{phase:`background`,readBack:n});return k.parse(j({event:a,replay:{modelResult:e}}))}}}function R(e,t){if(e&&!t?.detach)throw new _(`config`,`A request with a background service needs a coordinator with detach`)}function z(e){let{name:t,background:n}=e;if(n!==void 0&&n!==`never`){if(e.answeredBy===`page`)throw new _(`config`,`Tool '${t}' sets background, which a tool answered by the page cannot`);if(!M.safeParse(n).success)throw new _(`config`,typeof n==`object`?`Tool '${t}' sets background.afterMs, which must be a time in milliseconds`:`Tool '${t}' sets background to ${JSON.stringify(n)}; it takes 'always', 'ask', 'never' or { afterMs }`)}}var B=/^[\x21-\x7E]{1,256}$/;function V(e=Date.now){let t=new Map,n=new Map,r=({tool:e,max:n})=>{if(n===void 0)return;let r=[...t.values()].filter(t=>t.tool===e).length;for(let[i,a]of t){if(r<=n)break;a.tool===e&&(t.delete(i),r--)}};return{get(n,i){let a=t.get(n);if(a&&(t.delete(n),!(i.idleMs!==void 0&&e()-a.usedAt>i.idleMs)))return t.set(n,{...a,usedAt:e(),tool:i.tool}),r(i),{id:a.id,protocolVersion:a.protocolVersion}},open(i,a,o){let s=n.get(i);if(s)return s;let c=o().then(n=>(t.delete(i),t.set(i,{...n,usedAt:e(),tool:a.tool}),r(a),n)).finally(()=>n.delete(i));return n.set(i,c),c},drop(e,n){t.get(e)?.id===n&&t.delete(e)},clear(){t.clear(),n.clear()}}}function me(e){return e!==null&&B.test(e)}async function he(e,t){let n=JSON.stringify([e,Object.entries(t).map(([e,t])=>[e.toLowerCase(),t]).sort(([e],[t])=>e<t?-1:+(e>t))]),r=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(n));return[...new Uint8Array(r)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var H=`after`;function ge(){return a(t()).optional().describe(v(`tool.after_field`))}function U(t,n,r,i){let a=n=>{if(n instanceof s){if(r in n.shape)throw new _(`config`,`Tool '${t}' sets ${r}, and its input already has a field of that name`);return n.safeExtend({[r]:i()})}if(n instanceof te){let e=n.options.map(a);return o(n.def.discriminator,e)}if(n instanceof ee)return e(n.options.map(a));throw new _(`config`,`Tool '${t}' sets ${r}, which needs an object input or a union of objects`)};return a(n)}function W(e,t){return U(e,t,H,ge)}function _e(e,t){if(!e.after||typeof t!=`object`||!t)return{input:t,names:[]};let{[H]:n,...r}=t;return{input:r,names:n??[]}}function ve(e,t,n){return n?e.flatMap(e=>{let r=n.filter(n=>n.tool===e&&n.callId!==t).map(e=>e.callId);return r.length>0?r:[e]}):[]}var G=class{value;constructor(e){this.value=e}};function ye(e){return new G(e)}function be(e){return(t,n)=>{let{page:r}=n;if(r&&`output`in r)return ye(r.output);let{labels:i}=n.profile;throw r?.timedOut?Error(v(`tool.page_timed_out`,{},i)):Error(v(`tool.page_no_answer`,{tool:e},i))}}var K=new WeakMap;function q(e,t){let n=K.get(e);n||(n=new WeakMap,K.set(e,n));let r=n.get(t);if(!r){let i=b(e,`input`);y(i,`input`);let a=b(t,`output`);y(a,`output`),r={inputSchema:i,outputSchema:a},n.set(t,r)}return r}function J(e){let{inputSchema:t,outputSchema:n}=q(e.input,e.output),r={activity:{input:t},activityPast:{input:t,output:n},activityFailed:{input:t},request:{input:t}};for(let t of[`activity`,`activityPast`,`activityFailed`,`request`]){let n=e.labels?.[t],i=n?ie(n,r[t]):void 0;if(i)throw new _(`config`,`Tool "${e.name}" ${t} label: ${i}`)}return{inputSchema:structuredClone(t),outputSchema:structuredClone(n)}}function xe(e,t){if(t&&(typeof t.service!=`string`||!t.service.trim()))throw new _(`config`,`Tool "${e}" signs in with slot "${t.slot}" but names no service`)}function Y(e,t,n=[]){if(t?.queryParam===void 0)return;let r=t.queryParam.trim()?t.type===`api_key`?t.headerName!==void 0||t.headerPrefix!==void 0?`is set with headerName or headerPrefix; the key goes in one place`:n.includes(t.queryParam)?`"${t.queryParam}" is also one of mapping.queryParams`:void 0:`is set on a '${t.type}' sign-in; only an API key goes in the URL`:`is blank`;if(r)throw new _(`config`,`Tool "${e}" auth.queryParam ${r}`)}function Se(e,t){if(t!==void 0&&!(Number.isInteger(t.requests)&&t.requests>0&&Number.isFinite(t.windowMs)&&t.windowMs>0))throw new _(`config`,`Tool "${e}" limit needs a whole number of requests above 0 and a window above 0 ms`)}function X(e,t){if(!(t===void 0||Number.isFinite(t)&&t>0))throw new _(`config`,`Tool "${e}" timeoutMs needs a finite number of ms above 0`)}function Z(e,t,n){if(!(n===void 0||Number.isInteger(n)&&n>0))throw new _(`config`,`Tool "${e}" ${t} needs a whole number above 0`)}function Ce(e){Z(e.name,`maxResponseBytes`,e.maxResponseBytes);let t=e.imageLimits;t&&(Z(e.name,`imageLimits.count`,t.count),Z(e.name,`imageLimits.bytes`,t.bytes),Z(e.name,`imageLimits.totalBytes`,t.totalBytes),X(e.name,t.timeoutMs))}function Q(e){if(e.type!==`builtin`&&z({name:e.name,...e.background===void 0?{}:{background:e.background},...e.answeredBy?{answeredBy:e.answeredBy}:{}}),e.type===`builtin`||e.type===`agent`)return;xe(e.name,e.auth),e.type===`http`?(e.endpoint?.trim()&&x(e.endpoint),Y(e.name,e.auth,e.mapping?.queryParams),Se(e.name,e.limit),X(e.name,e.timeoutMs)):Y(e.name,e.auth),(e.type===`http`||e.type===`mcp`)&&Ce(e),e.type===`mcp`&&(Z(e.name,`session.idleMs`,e.session?.idleMs),Z(e.name,`session.max`,e.session?.max));let[t]=ce(e);if(t)throw new _(`config`,`Tool "${e.name}" ${t.path} ${t.message}`)}function $(e){return x(e.endpoint),{...e,type:`http`,...J(e)}}function we(e){return{...e,type:`mcp`,...J(e)}}function Te(e){let t=e.answeredBy===`page`?be(e.name):e.handler;if(typeof t!=`function`)throw new _(`config`,`Tool '${e.name}' needs a handler, or answeredBy: 'page'`);return{...e,handler:t,type:`function`,...J(e)}}function Ee(e){if(e.type===`builtin`||e.background!==`ask`)return e;let t=e.input,n=U(e.name,t,`background`,P);return{...e,askInputSchema:q(n,e.output).inputSchema}}function De(e,t,n){return Q(e),Ee(Oe(e,t,n))}function Oe(e,t,n){if(e.type===`builtin`)return e;if(e.type===`agent`){let r=le(e,t,n),i=oe(r),a=fe({type:r.type,...i?{inputs:i}:{}},e),o=e.after?W(e.name,a):a,s=J({...e,input:o,output:de});return ue(e,o,s)}let r=e.after?{...e,input:W(e.name,e.input)}:e;return r.type===`http`?$(r):r.type===`mcp`?we(r):Te(r)}function ke(e=()=>void 0){let t=new Map,n=V(),r=e=>t.get(e),i=n=>{let i=De(n,e,r);return t.set(i.name,i),i};return{register:i,registerMany:e=>e.map(e=>i(e)),get:r,require(e){let t=r(e);if(!t)throw new _(`config`,`Tool '${e}' is not registered`);return t},has:e=>t.has(e),list:()=>[...t.values()],findProfile:e,reset:()=>{t.clear(),n.clear()},mcpSessions:n}}export{A as _,ve as a,he as c,F as d,w as f,T as g,pe as h,_e as i,R as l,j as m,ke as n,V as o,S as p,G as r,me as s,Q as t,L as u,k as v,C as y};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{A as e,D as t,E as n,O as r,T as i,b as a,c as o,d as s,f as c,x as l}from"./schemas-D7cgkv3L.js";import{Dt as u,Gn as ee,Gt as d,Tn as te,Tt as ne,Yn as re,qn as ie,wt as ae}from"./tool-schema-
|
|
1
|
+
import{A as e,D as t,E as n,O as r,T as i,b as a,c as o,d as s,f as c,x as l}from"./schemas-D7cgkv3L.js";import{Dt as u,Gn as ee,Gt as d,Tn as te,Tt as ne,Yn as re,qn as ie,wt as ae}from"./tool-schema-BMdqCPG0.js";import{c as f}from"./host-patterns-F-KZIzkF.js";import{A as oe}from"./shaped-data-QPeAmaJ4.js";var se=`
|
|
2
2
|
|
|
3
3
|
`;function p(e){if(typeof e==`string`)return;if(typeof e!=`object`||!e||Array.isArray(e))return`must be a string or { private: string }`;let t=Object.keys(e);if(t.length!==1||t[0]!==`private`)return`must have exactly one key, private`;let n=e.private;if(typeof n!=`string`)return`must be a string`;if(n===``)return`must not be empty`}function m(e,t){if(typeof e!=`string`){if(!Array.isArray(e))return`${t} must be a string or an array of parts`;if(e.length===0)return`${t} must not be an empty array`;for(let[n,r]of e.entries()){let e=p(r);if(e)return`${t}[${n}]${typeof r==`object`&&r&&`private`in r?`.private`:``} ${e}`}}}function h(e,t){let n=m(e,t);if(n)throw new f(`config`,n)}function g(e,t,n){return h(e,t),typeof e==`string`?n(e):e.map(e=>typeof e==`string`?n(e):{private:n(e.private)})}function ce(e){if(typeof e==`string`)return[{text:e,private:!0}];let t=e.some(e=>typeof e!=`string`);return e.map(e=>typeof e==`string`?{text:e,private:!t}:{text:e.private,private:!0})}function _(e){let t=[];for(let n of e)n.some(e=>e.text)&&(t.length>0&&t.push({text:se,private:!0}),t.push(...n));return t}function le(e){return e.map(e=>e.text).join(``)}function ue(e){let t=[],n=``;for(let r of e)r.private?n+=r.text:(n.trim()&&t.push(n),n=``);return n.trim()&&t.push(n),{text:le(e),private:t}}function de(e,t){return ue(_([e,...t.map(e=>e?[{text:e,private:!0}]:[])]))}var fe=/^[A-Za-z_][\w-]*$/,pe=/\{([A-Za-z_][\w-]*)\}/g,me=[`input`,`output`];function v(e){return e.choices.map(e=>e.value)}function y(e){return(e.type===`text`||e.type===`image`||e.type===`live`?e.identity.options:void 0)??{}}function b(e){return te(e)?.options??{}}function x(e,t){let n={...y(e),...b(e)};return Object.hasOwn(n,t)?n[t]:void 0}function he(e,t){if(!fe.test(e))return`Option "${e}" needs a plain name.`;if(me.includes(e))return`Option "${e}" is a reserved name.`;let n=Array.isArray(t.choices)?v(t):[];if(n.length===0)return`Option "${e}" lists no values.`;let r=n.find(e=>!e.trim()||e===`null`);return r===void 0?void 0:`Option "${e}" can't take the value "${r}".`}function S(e,t){for(let[n,r]of Object.entries({...e,...t})){if(e&&t&&Object.hasOwn(e,n)&&Object.hasOwn(t,n))return`"${n}" is on both identity.options and inputs.options.`;let i=he(n,r);if(i)return i}}function C(e,t,n,r){for(let[i,a]of Object.entries(r??{})){let r=Object.hasOwn(t,i)?t[i]:void 0;if(!r)throw new f(`request`,`Profile ${e} has no option '${i}' on ${n}`);let o=v(r);if(!o.includes(a))throw new f(`request`,`Profile ${e}: option '${i}' takes ${o.join(`, `)}, not '${a}'`)}}function w(e,t){return Object.hasOwn(e,`path`)&&t.path!==void 0?{path:t.path}:{}}function T(e,t){let n=y(e);if(t.options&&Object.hasOwn(t.options,`path`))throw new f(`request`,`Profile ${e.id}: the turn's own path states path`);C(e.id,n,`identity.options`,{...t.options,...w(n,t)}),C(e.id,b(e),`inputs.options`,t.input?.options)}function E(e,t){return{...t.options,...w(y(e),t),...t.input?.options}}function D(e,t,n){let r=!0,i=t.replace(pe,(t,i)=>{if(!x(e,i))return t;let a=Object.hasOwn(n,i)?n[i]:void 0;return a===void 0&&(r=!1),a??t});return r?i:void 0}function O(e){return typeof e==`string`?[[e]]:e.map(e=>typeof e==`string`?[e]:e)}function k(e){return typeof e==`string`?e:e.private}function A(e){return u(e[0]===void 0?``:k(e[0]))}function j(e){let t={};for(let[n,r]of Object.entries(e))t[n]={type:`string`,enum:v(r)};return{type:`object`,properties:t}}function M(e,t){if(e.length===0)return`It has no wording to send.`;let n=A(e);if(n.joined)return`A prompt line can't start with "+"; every line that fits is sent.`;if(n.when===`unreadable`)return`A line that opens with "when" needs an option and a colon, like "when path is web: …".`;for(let e of n.when){if(e.path.includes(`.`))return`"${e.path}" isn't one option.`;if(e.expected===null)return`An option has no null value, so "is null" never fits.`;let n=ne(e,t,`this profile’s options`);if(n)return n}if(n.when.length>0&&!n.text&&e.length===1)return`It has no wording to send.`}function N(e,t,n){let r=S(t,n);if(r)return r;let i=j({...t,...n});for(let[t,n]of O(e).entries()){let e=M(n,i);if(e)return`Line ${t+1}: ${e}`}}function P(e,t){return e.when!==`unreadable`&&e.when.every(e=>ae(e,t))}function F(e,t,n){let r=O(e),i=r.flat().some(e=>typeof e!=`string`),a=[];for(let[e,o]of r.entries()){let r=A(o);if(!P(r,t))continue;let s=o.map((e,t)=>n(t===0?r.text:k(e)));if(s.includes(void 0))continue;let c=o.flatMap((e,t)=>{let n=s[t];return n?[{text:n,private:typeof e!=`string`||!i}]:[]});a.push({line:e+1,pieces:c})}return a}function I(e,t){if(typeof e!=`string`){if(!Array.isArray(e))throw new f(`config`,`${t} must be a string or an array of lines`);if(e.length===0)throw new f(`config`,`${t} must not be an empty array`);for(let[n,r]of e.entries())if(typeof r!=`string`){if(!Array.isArray(r))throw new f(`config`,`${t}[${n}] must be a string or a list of parts; put { private } inside the list`);h(r,`${t}[${n}]`)}}}function L(e,t){let n=e?.path;if(!n)return;let r=v(n);for(let e of t){let t=e.paths?.find(e=>e!==`*`&&!r.includes(e));if(t!==void 0)return`Tool ${e.name} lists path "${t}", which is not one of ${r.join(`, `)}.`}}function R(e,t){let n=e.get(t);return n!==void 0&&n.type!==`builtin`}function z(e,t){return!e||e.includes(`*`)?!0:t?e.includes(t):!1}function ge(e,t){return t.filter(n=>{let r=e.get(n);return r?.type!==`builtin`||!(r.conflictsWith??[]).some(e=>t.includes(e))})}function B(e){return`tools`in e?e.tools.allow:[]}function V(e){return e.type===`text`||e.type===`image`?e.tools:void 0}function _e(e){return`tools`in e?e.tools.parallel:void 0}function ve(e,t,n){return B(t).filter(r=>{let i=e.get(r);return!i||i.type===`builtin`?!1:t.type===`host`||z(i.paths,n.path)})}function ye(e,t,n,r){let i=t.models[r];return i?(i.builtInTools??[]).filter(t=>{let r=e.get(t);return r?.type===`builtin`&&z(r.paths,n.path)}):[]}function H(e,t,n){let r=e.get(t);if(r&&r.type!==`builtin`)return{type:`function`,name:r.name,description:r.description,parameters:n&&r.askInputSchema||r.inputSchema}}function be(e,t,n){let r=[];for(let i of t){let t=H(e,i,n);t&&r.push(t)}return r}function U(e,t,n){if(t.visible.includes(n))return;t.visible.push(n);let r=H(e,n,t.modelBackground);r&&!t.wire.some(e=>e.name===n)&&t.wire.push(r)}function xe(e,t,n){if(t.builtins.includes(n))return;let r=e.get(n);if(r?.type!==`builtin`)return;let i=r.conflictsWith??[];t.builtins=t.builtins.filter(t=>{if(i.includes(t))return!1;let r=e.get(t);return!(r?.type===`builtin`&&r.conflictsWith?.includes(n))}),t.builtins.push(n)}function Se(e,t,n){return t.type===`live`||t.type===`host`?[...n]:n.filter(t=>e.get(t)?.loadTier===`T0`)}function Ce(e,t,n){return ge(e,n.filter(n=>{let r=e.get(n);return r?.type===`builtin`&&(t.type===`live`||r.loadTier===`T0`)}))}function we(e,t){if(t.type!==`text`&&t.type!==`image`&&t.type!==`live`)return;let n=B(t).flatMap(t=>e.get(t)??[]),r=L(t.identity.options,n);if(r)throw new f(`config`,`Profile ${t.id}: ${r}`)}function Te(e,t){let n=V(t)?.t2Loader,r=n===void 0?void 0:e.get(n);if(r&&r.type!==`builtin`&&(r.background??`never`)!==`never`)throw new f(`config`,`Profile ${t.id}: tools.t2Loader '${r.name}' sets background, and a loader cannot detach`)}function W(e,t,n,r){we(e,t),Te(e,t);let i=ve(e,t,n),a=t.type===`host`||t.type===`decision`||t.type===`embedding`||r===void 0?[]:ye(e,t,n,r),o=[...i,...a],s=Ce(e,t,o),c=Se(e,t,o),l=c.filter(t=>R(e,t)),u=n.background!==void 0;return{builtins:s,gated:o,visible:c,executable:l,path:n.path,sessionPermissions:n.sessionPermissions,wire:be(e,c,u),...u?{modelBackground:u}:{}}}async function Ee(e,t,n,r){let i=W(e,t,n,r);return await G(e,i,t,n),i}function De(e){return{builtins:[...e.builtins],gated:[...e.gated],visible:[...e.visible],executable:[...e.executable],path:e.path,sessionPermissions:e.sessionPermissions?[...e.sessionPermissions]:void 0,wire:e.wire.map(e=>({...e,parameters:structuredClone(e.parameters)})),...e.modelBackground?{modelBackground:e.modelBackground}:{}}}async function G(e,t,n,r){let i=V(n)?.t1Policy;if(!i)return;let a;try{a=await i({profile:n,input:r.input,path:r.path,sessionPermissions:r.sessionPermissions,gated:t.gated,host:r.host})}catch(e){let t=e instanceof Error?e.message:String(e);throw new f(`config`,`Profile '${n.id}' tools.t1Policy rejected: ${t}`,{cause:e})}if(!Array.isArray(a))throw new f(`config`,`Profile '${n.id}' tools.t1Policy must return ToolId[]`);K(e,t,a)}function K(e,t,n=[]){for(let r of n){if(!t.gated.includes(r))continue;let n=e.get(r);n?.loadTier===`T2`&&(n.type===`builtin`?xe(e,t,r):U(e,t,r))}t.executable=t.visible.filter(t=>R(e,t))}var Oe=new Set([`__proto__`,`constructor`,`prototype`]);function ke(e){if(!oe(e))return;let{loaded:t}=e;if(Array.isArray(t)&&t.every(e=>typeof e==`string`))return t}function Ae(e,t,n,r){if(r.type===`live`||r.type===`host`)return{promoted:[]};let i=[];for(let a of n){if(typeof a!=`string`||Oe.has(a))return{promoted:[],failure:{code:`invalid_output`,kind:`bad_response`,message:`tools.t2Loader loaded ids must be plain strings`}};let n=je(e,a,r);if(`failure`in n)return{promoted:[],failure:n.failure};let{tool:o}=n;z(o.paths,t.path)&&t.gated.includes(a)&&i.push(a)}let a=[];for(let n of i)U(e,t,n),a.push(n);return t.executable=t.visible.filter(t=>R(e,t)),{promoted:a}}function q(e){return{failure:{code:`invalid_output`,kind:`bad_response`,message:e}}}function je(e,t,n){if(!B(n).includes(t))return q(`tools.t2Loader attempted to promote tool '${t}' outside profile allow`);let r=e.get(t);return r?r.type===`builtin`?q(`tools.t2Loader attempted to promote builtin '${t}' — only custom tools may be promoted`):r.loadTier===`T2`?{tool:r}:q(`tools.t2Loader attempted to promote tool '${t}' with loadTier '${r.loadTier}' — only T2 tools may be promoted`):q(`tools.t2Loader attempted to promote unknown tool '${t}'`)}var Me=class extends Error{failure;constructor(e){super(e.message),this.failure=e}},Ne=new Set([`text`,`image`,`speech`]),Pe=n().regex(/\S/),J=i({mimeType:n(),data:c(),name:n().optional()}),Fe=i({mimeType:n(),uri:n(),name:n().optional()}),Ie=i({voice:n().optional(),style:n().optional(),speed:a().positive().optional()});function Le(e){return i(Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=v(t);return[e,o(n).optional()]})))}var Re=new Set([`text`,`attachments`,`voice`,`options`,`speech`]);function ze(e,t){if(!e.hostFields)return{sent:t};let n={...t},r={};for(let t of Object.keys(e.hostFields))n[t]!==void 0&&(r[t]=n[t]);let{text:i,attachments:a,voice:o,options:s,speech:c}=t;return{sent:{text:i,...a?{attachments:a}:{},...o?{voice:o}:{},...s?{options:s}:{},...c?{speech:c}:{}},hostInput:r}}function Be(e,n){let{inputs:r}=e,a={text:Pe};r?.attachments&&(a.attachments=s(t([J,Fe])).optional()),r?.voice&&(a.voice=s(J).optional()),r?.options&&(a.options=Le(r.options).optional()),e.type===`speech`&&(a.speech=Ie.optional());for(let e of n?.hostOnly??[]){if(!a[e])throw new f(`config`,`Tool '${n?.name}' keeps '${e}' for the host, which its profile does not take`);delete a[e]}for(let[e,t]of Object.entries(n?.fieldText??{})){let r=a[e];if(!r)throw new f(`config`,`Tool '${n?.name}' describes '${e}', which its profile does not take`);a[e]=r.describe(t)}for(let[e,t]of Object.entries(n?.hostFields??{})){if(Re.has(e))throw new f(`config`,`Tool '${n?.name}' declares the host field '${e}', which is a field of every agent tool`);a[e]=t}return i(a)}var Y=l({text:n().optional(),structured:r().optional(),removed:s(l({path:n(),reason:n(),item:r()})).optional(),parts:s(ee).optional(),sources:s(re).optional()});function Ve(e){return e.type===`speech`||(e.type===`text`||e.type===`image`)&&e.inputs.text!==!1}function He(e){return e.type===`builtin`?!1:e.permission!==`auto`||`auth`in e&&e.auth!==void 0&&(e.auth.onUnauthenticated??`gate`)===`gate`}function X(e,t){if(!Ne.has(e.type))return`it is a ${e.type} profile; an agent tool runs a text, image, or speech profile`;if(!Ve(e))return`it does not take text`;for(let n of B(e)){let e=t(n);if(!e)return`its tool '${n}' is not registered; register it first`;if(He(e))return`its tool '${n}' can stop on a gate; give it permission 'auto' and no sign-in`}}function Ue(e,t,n){let r=`Agent tool "${e.name}"`,i=e.maxCallsPerTurn;if(i!==void 0&&!(Number.isInteger(i)&&i>0))throw new f(`config`,`${r}: maxCallsPerTurn must be a whole number above 0`);let a=t(e.profile);if(!a)throw new f(`config`,`${r}: profile '${e.profile}' must be registered before the tool`);let o=X(a,n);if(o)throw new f(`config`,`${r} can't run '${e.profile}': ${o}`);return a}function Z(e){if(!e)return`delegated`;let t=`models`in e&&Object.values(e.models).some(e=>(e.builtInTools?.length??0)>0);return B(e).length===0&&!t?`local`:`delegated`}function We(e){let t=ie(e),n=t.flatMap(e=>e.type===`text`?[e.text]:[]).join(``),r=d(t,e=>e.type===`structured`),i=r?.structured,a=t.flatMap(e=>e.type===`media`?[{type:e.media.mimeType.startsWith(`audio/`)?`audio`:`image`,mimeType:e.media.mimeType,data:e.media.data}]:[]),o=t.flatMap(e=>e.type===`citation`?e.sources:[]);return{...i===void 0?{text:n}:{structured:i},...r?.removed?.length?{removed:r.removed}:{},...a.length>0?{parts:a}:{},...o.length>0?{sources:o}:{}}}function Ge(e,t,n){return{...e,type:`agent`,input:t,output:Y,sources:e=>e.sources??[],...n}}function Ke(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return n.push(`${t}: schema must be an object`),!1;let r=typeof e.type==`string`||Array.isArray(e.type),i=e.anyOf!==void 0||e.oneOf!==void 0;if(!r&&!i){if(t!==`$`)return!0;n.push(`${t}: missing type or combinator`)}return e.type===`array`&&e.items===void 0&&n.push(`${t}: array schema must define items`),!0}function qe(e,t,n,r){let i=Array.isArray(t)?t:[];for(let t of i)typeof t==`string`&&!Object.hasOwn(e,t)&&r.push(`${n}: required key '${t}' missing from properties`);for(let[t,i]of Object.entries(e))i&&typeof i==`object`&&Q(i,`${n}.properties.${t}`,r)}function Q(e,t,n){if(!Ke(e,t,n))return;let r=e.properties;r&&typeof r==`object`&&!Array.isArray(r)&&qe(r,e.required,t,n),e.items&&typeof e.items==`object`&&!Array.isArray(e.items)&&Q(e.items,`${t}.items`,n);for(let r of[`anyOf`,`oneOf`]){let i=e[r];Array.isArray(i)&&i.forEach((e,i)=>{e&&typeof e==`object`&&Q(e,`${t}.${r}[${i}]`,n)})}}function Je(e,t){let n=[];if(Q(e,`$`,n),n.length>0)throw new f(`config`,`Invalid tool ${t} schema: ${n.join(`; `)}`)}function Ye(t,n=`output`){let r=e(t,{target:`draft-7`,io:n});return delete r.$schema,r.type||=`object`,r}function $(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map($);let t={};for(let n of Object.keys(e))n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&(t[n]=$(e[n]));return t}function Xe(e){let t=/^[a-z][a-z0-9+.-]*:\/\/[^/?#]*/i.exec(e)?.[0];if(!t||/[{}]/.test(t))throw new f(`config`,`Endpoint "${e}" must start with a fixed scheme and host; placeholders belong in the path or query`)}export{S as A,W as C,T as D,N as E,g as F,ce as I,E as M,de as N,D as O,_ as P,K as S,F as T,Ee as _,Me as a,V as b,Z as c,Ue as d,Ge as f,ke as g,G as h,Je as i,x as j,v as k,Y as l,De as m,Ye as n,X as o,ze as p,$ as r,Be as s,Xe as t,We as u,B as v,I as w,Ae as x,_e as y};
|
|
@@ -14,7 +14,7 @@ import{c as e,n as t,o as n}from"./host-patterns-F-KZIzkF.js";var r=`provider.de
|
|
|
14
14
|
`,t.start-1)+1,a=n.text.indexOf(`
|
|
15
15
|
`,t.end),o=a<0?n.text.length:a,s=n.lines.get(e);s||(s=new Map,n.lines.set(e,s));let c=`${i}:${o}`,l=s.get(c);return l===void 0&&(l=nu(e,n.text.slice(i,o)),s.set(c,l)),l}function iu(){return{goto:new Map,next:new Map,fail:void 0,ends:[]}}var au=new WeakMap;function ou(e){let t=iu();for(let n of e){let e=t;for(let t=0;t<n.length;t+=1){let r=n.charCodeAt(t),i=e.goto.get(r)??iu();e.goto.set(r,i),e=i}e.ends.push(n)}return t}function su(e){let t=[e];for(let n=0;n<t.length;n+=1){let r=t[n]??e,i=r.fail;if(i){r.ends.push(...i.ends);for(let[e,t]of i.next)r.next.set(e,t)}for(let[n,a]of r.goto)r.next.set(n,a),a.fail=i?.next.get(n)??e,t.push(a)}}function cu(e){let t=au.get(e);if(t)return t;let n=[...new Set(e.flatMap(e=>e.keywords))],r=ou(n);su(r);let i={words:n.length,root:r};return au.set(e,i),i}function lu(e,t){let{words:n,root:r}=cu(t),i=new Map,a=r;for(let t=0;t<e.length&&i.size<n;t+=1){a=a.next.get(e.charCodeAt(t))??r;for(let e of a.ends)i.has(e)||i.set(e,t+1-e.length)}return i}function uu(e,t,n){return e.keywords.length===0||e.keywords.some(e=>{let r=t.get(e);return r!==void 0&&r+e.length<=n})}function du(e,t,n=t.length){return e.keywords.length===0||e.keywords.some(e=>{let r=t.indexOf(e);return r>=0&&r+e.length<=n})}var fu=new WeakMap,pu=new WeakMap;function mu(e){let t=pu.get(e);return t||(t=new RegExp(e.source,`${e.flags.replace(`g`,``)}g`),pu.set(e,t)),t}function hu(e){let t=fu.get(e);return t||(t=new RegExp(e.source,`${e.flags.replace(`g`,``)}d`),fu.set(e,t)),t}function gu(e,t,n,r,i,a=tu(n)){let o=0;for(;r[o]===`
|
|
16
16
|
`;)o++;let s=r.length;for(;s>o&&r[s-1]===`
|
|
17
|
-
`;)s--;let c=r.slice(o,s),l=i+o,u={start:l,end:l+c.length},d=hu(e.pattern).exec(c),f=d?.indices;if(d&&f&&d.length>=2){let t=f[e.secretGroup??d.findIndex((e,t)=>t>0&&e!==void 0&&e!==``)];t?u={start:l+t[0],end:l+t[1]}:e.secretGroup&&(u={start:l,end:l})}let p={secret:n.slice(u.start,u.end),match:c,start:l,end:l+c.length};if(!(e.entropy!==void 0&&Ql(p.secret)<=e.entropy)&&!(ru(t,p,a)||e.allowlists.some(e=>ru(e,p,a))))return u.end>u.start?u:{start:l,end:l+c.length}}function _u(e,t,n){let r=e.toLowerCase(),i=lu(r,t),a=tu(e),o=[];for(let s of t)if(uu(s,i,r.length))for(let t of e.matchAll(mu(s.pattern))){if(t[0]===``||!uu(s,i,t.index+t[0].length))continue;let r=gu(s,n,e,t[0],t.index,a);r&&o.push({...r,kind:`sensitive`})}return o}function vu(e,t,n,r,i,a){let o=i+n.length;return(a?.length===r.length?du(e,a,o):du(e,r.slice(0,o).toLowerCase()))&&gu(e,t,r,n,i)!==void 0}var yu=/\b\d{3}-\d{2}-\d{4}\b/g,bu=/(?:SSN|social\s*security(?:\s*number)?)[:\s]+\d(?:[-\s]*\d){8}/gi,xu=/\b9\d{2}-\d{2}-\d{4}\b/g,Su=/\b\d{2}-\d{7}\b/g,Cu=/(?<!\p{L})(?:ssn|social[\s_-]*security(?:[\s_-]*number)?|tax[\s_-]*(?:payer[\s_-]*)?id(?:entification)?(?:[\s_-]*(?:number|no))?|taxpayer[\s_-]*id(?:entification)?(?:[\s_-]*number)?|itin|tin|ein|employer[\s_-]*identification[\s_-]*number)[\s"'\x60*:=>#\\]{0,10}(?:\d{3}[- ]?\d{2}[- ]?\d{4}|\d{2}-?\d{7})(?!\d)/giu,wu=/\b[A-Z]{2}\d{2}(?:[A-Z0-9]{11,30}|(?: [A-Z0-9]{4}){2,7}(?: [A-Z0-9]{1,4})?)\b/g,Tu=/\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g,J=`[0-9a-f]{1,4}`,Eu=`(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)`,Du=RegExp(`(?<![\\w:.])(?:${[`(?:${J}:){6}${Eu}`,`(?:${J}:){1,5}:${Eu}`,`::(?:${J}:){0,5}${Eu}`,`(?:${J}:){7}${J}`,`(?:${J}:){1,6}(?::${J}){1,6}`,`(?:${J}:){1,7}:`,`:(?::${J}){1,7}`].join(`|`)})(?![\\w:])`,`gi`),Ou=/(?<![\w.+-])[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g,ku=/\.[A-Za-z][\w-]*$/,Y=`[ .\\-]`,Au=`(?:\\s?(?:x|ext\\.?)\\s?\\d{1,5})?`,ju=[RegExp(`(?<![\\w+])\\+\\s?[1-9]\\d{0,2}(?:\\s?\\(0\\))?(?:${Y}?\\(?\\d{1,4}\\)?){2,5}${Au}(?!\\w)`,`g`),RegExp(`(?<![\\w.\\-+])(?:(?:00)?1${Y})?(?:\\(\\d{3}\\)\\s?|\\d{3}${Y})\\d{3}${Y}\\d{4}${Au}(?![\\w\\-]|\\.\\d)`,`g`),RegExp(`(?<![\\w.\\-+]|\\d[ .\\-])0\\d{1,4}(?:${Y}\\d{2,4}){2,5}(?![\\w\\-]|\\.\\d)`,`g`),RegExp(`(?<![\\w)]|\\d[ .\\-])\\(0\\d{1,3}\\)${Y}?\\d{3,4}${Y}?\\d{4}(?![\\w\\-]|\\.\\d)`,`g`)],Mu=/(?<!\p{L})(?:phone|tel(?:ephone|efone|efono|éfono)?|téléphone|mobile|cell(?:ular)?|portable|handy|celular|whatsapp|fax)(?:[\s_]*(?:number|no\.?|nr\.?|#|numéro|número|numero|nummer))?[\s"'`*:=>]*(\+?\(?\d[\d ().-]{5,20}\d)/giu,Nu=/^(?:\d{3}[- ]\d{2}[- ]\d{4}|\d{3} \d{3} \d{3}|\d{1,2}[.\-/ ]\d{1,2}[.\-/ ]\d{4}|\d{4}[.\-/ ]\d{1,2}[.\-/ ]\d{1,2})$/,Pu=7,Fu=15;function Iu(e){if(Nu.test(e.trim()))return!1;let t=e.replace(/(?:x|ext\.?)\s?\d+$/i,``).replace(/\D/g,``).length;return t>=Pu&&t<=Fu}var Lu=[`bank[\\s_\\-]{0,3}account(?:[\\s_]{0,3}(?:number|no\\.?|#|nr\\.?))?`,`account[\\s_]{0,3}(?:number|no\\.?|#|nr\\.?)`,`acct\\.?(?:[\\s_]{0,3}(?:number|no\\.?|#))?`,`a\\/c(?:[\\s_]{0,3}no\\.?)?(?!\\p{L})`,`bban`,`routing[\\s_]{0,3}(?:number|no\\.?|#)?`,`aba(?:[\\s_]{0,3}(?:number|routing))?`,`sort[\\s_]{0,3}code`,`kontonummer`,`bankverbindung(?:snummer)?`,`konto`,`numero[\\s_]{0,3}di[\\s_]{0,3}conto(?:[\\s_]{0,3}corrente)?`,`conto[\\s_]{0,3}corrente`,`n[úu]mero[\\s_]{0,3}da[\\s_]{0,3}conta(?:[\\s_]{0,3}corrente)?`,`conta[\\s_]{0,3}corrente`,`num[ée]ro[\\s_]{0,3}de[\\s_]{0,3}compte(?:[\\s_]{0,3}bancaire)?`,`compte[\\s_]{0,3}bancaire`,`n[úu]mero[\\s_]{0,3}de[\\s_]{0,3}cuenta`,`cuenta[\\s_]{0,3}bancaria`,`rekeningnummer`].join(`|`),Ru=RegExp(`(?<![\\p{L}\\p{N}])(?:${Lu})(?:\\s{1,4}type="\\w+")?(?:\\s{0,4}\\([^)\\n]{1,24}\\))?[\\s"'\x60:=>*#]{0,8}(?:[a-z\\s]{0,12}[:\\s])?\\s{0,4}([A-Z0-9](?:[A-Z0-9\\-]|(?<=\\d) (?=\\d)){3,32}[A-Z0-9])`,`giu`),zu=/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/;function Bu(e){let t=e.replaceAll(` `,``),n=0;for(let e of t.slice(4)+t.slice(0,4)){let t=Number.parseInt(e,36);n=(n*(t>9?100:10)+t)%97}return n===1}var Vu=5;function Hu(e,t){return new RegExp(e.source,e.flags.replace(`g`,``)).exec(t)?.[1]}function Uu(e){let t=Hu(Ru,e);return t!==void 0&&!zu.test(t.replaceAll(` `,``))&&(t.match(/\d/g)??[]).length>=Vu}var Wu=[{id:`openai-api-key-any`,pattern:/\bsk-\s*[A-Za-z0-9]{20,}\b/,keywords:[`sk-`],allowlists:[]},{id:`anthropic-api-key-any`,pattern:/\bsk-ant-[A-Za-z0-9_-]{20,}\b/,keywords:[`sk-ant-`],allowlists:[]},{id:`openrouter-api-key`,pattern:/\bsk-or-[A-Za-z0-9_-]{20,}\b/,keywords:[`sk-or-`],allowlists:[]},{id:`github-fine-grained-pat-any`,pattern:/\bgithub_pat_[A-Za-z0-9_]{20,}\b/,keywords:[`github_pat_`],allowlists:[]},{id:`slack-token-any`,pattern:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/,keywords:[`xox`],allowlists:[]},{id:`private-key-any`,pattern:/-----BEGIN (?:(?:RSA|DSA|EC|OPENSSH|ENCRYPTED|PGP) )?PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,16384}?-----END (?:(?:RSA|DSA|EC|OPENSSH|ENCRYPTED|PGP) )?PRIVATE KEY(?: BLOCK)?-----/,keywords:[`-----begin`],allowlists:[]},{id:`bearer-token`,pattern:/\bBearer[ \t]+([A-Za-z0-9._~+/-]{16,}=*)/i,entropy:3,keywords:[`bearer`],allowlists:[]},{id:`apify-api-token`,pattern:/\bapify_api_[A-Za-z0-9]{36}\b/,keywords:[`apify_api_`],allowlists:[]},{id:`fleetbase-api-key`,pattern:/\bflb_live_[A-Za-z0-9]{20}\b/,keywords:[`flb_live_`],allowlists:[]},{id:`nightfall-api-key`,pattern:/\bNF-[A-Za-z0-9]{32}\b/,keywords:[`nf-`],allowlists:[]},{id:`teamwork-api-token`,pattern:/\btkn\.v1_[A-Za-z0-9]{71}=/,keywords:[`tkn.v1_`],allowlists:[]},{id:`ubidots-api-token`,pattern:/\bBBFF-[A-Za-z0-9]{30}\b/,keywords:[`bbff-`],allowlists:[]},{id:`zapier-webhook-url`,pattern:/https:\/\/hooks\.zapier\.com\/hooks\/catch\/\d+\/[A-Za-z0-9]+\/?/,keywords:[`hooks.zapier.com`],allowlists:[]}],Gu=[...Zl,...Wu],Ku=/\b(?:\d[\s.-]*?){13,19}\b/g,qu=T.filter(e=>e!==`credentials`),Ju={ids:[yu,bu,xu,Su,Cu].map(e=>({pattern:e})),financial:[{pattern:wu,hit:Bu}],network:[{pattern:Tu},{pattern:Du}],email:[{pattern:Ou,hit:e=>ku.test(e)}],phone:[...ju.map(e=>({pattern:e,hit:Iu})),{pattern:Mu,hit:e=>Iu(Hu(Mu,e)??``)}],bank_account:[{pattern:Ru,hit:Uu}]},Yu=[...qu.flatMap(e=>Ju[e].map(t=>({group:e,...t}))),...Gu.map(e=>({group:`credentials`,pattern:new RegExp(e.pattern.source,`${e.pattern.flags}g`),hit:(t,n,r,i)=>vu(e,Xl,t,n,r,i?.())}))],Xu=y(T,()=>!0);function Zu(e,t=Xu){return e===void 0?t:typeof e==`boolean`?y(T,()=>e):{...t,...e}}var Qu=2,$u=9,ed=10;function td(e){let t=0,n=!1;for(let r=e.length-1;r>=0;--r){let i=e[r];if(i===void 0)return!1;let a=Number(i);n&&(a*=Qu,a>$u&&(a-=$u)),t+=a,n=!n}return t%ed===0}var X=[16,17,18,19],nd=[{leading:[[`4`,`4`]],lengths:[13,16,19]},{leading:[[`51`,`55`],[`2221`,`2720`]],lengths:[16]},{leading:[[`34`,`34`],[`37`,`37`]],lengths:[15]},{leading:[[`300`,`305`],[`3095`,`3095`],[`36`,`36`],[`38`,`39`]],lengths:[14,15,...X]},{leading:[[`6011`,`6011`],[`644`,`649`],[`65`,`65`]],lengths:X},{leading:[[`3528`,`3589`]],lengths:X},{leading:[[`62`,`62`]],lengths:X},{leading:[[`5018`,`5018`],[`5020`,`5020`],[`5038`,`5038`],[`5893`,`5893`],[`6304`,`6304`],[`6759`,`6759`],[`6761`,`6763`]],lengths:[13,14,15,...X]},{leading:[[`2200`,`2204`]],lengths:X},{leading:[[`60`,`60`],[`81`,`82`],[`508`,`508`],[`353`,`353`],[`356`,`356`]],lengths:[16]}];function rd(e){return nd.some(t=>t.lengths.includes(e.length)&&t.leading.some(([t,n])=>{let r=e.slice(0,t.length);return r>=t&&r<=n}))}var id=/https?:\/\//i,ad=2048;function od(e,t){let n=Math.max(0,t-ad),r=t;for(;r>n&&!/\s/.test(e[r-1]??` `);)--r;return id.test(e.slice(r,t))}function sd(e,t,n){let r=e.replaceAll(/[^\d]/g,``);return rd(r)&&td(r)&&!od(t,n)}function cd(e){let t=[];for(let n of e.matchAll(Ku)){let r=ur(n);r&&sd(r.blob,e,r.index)&&t.push({start:r.index,end:r.index+r.blob.length,kind:`sensitive`})}return t}function ld(e,t=!0){let n=Zu(t),r=[];for(let{group:t,pattern:i,hit:a}of Yu)if(t!==`credentials`&&n[t])for(let t of e.matchAll(i)){let n=ur(t);n&&(!a||a(n.blob,e,n.index))&&r.push({start:n.index,end:n.index+n.blob.length,kind:`sensitive`})}return[...r,...n.financial?cd(e):[],...n.credentials?_u(e,Gu,Xl):[]]}var ud=/This turn\x27s canary is|Your canary token is|<\s*(?:\/\s*)?user_data(?:\s*(?:\/\s*)?>)?/i,dd=[...oi.map(e=>({kind:`injection`,pattern:e})),...Yu.map(({group:e,pattern:t})=>({kind:`sensitive`,pattern:t,group:e})),{kind:`card`,pattern:Ku,group:`financial`},{kind:`boundary`,pattern:new RegExp(ud.source,`gi`)},{kind:`base64`,pattern:mi},{kind:`hex`,pattern:hi},{kind:`spaced`,pattern:gi},{kind:`pipe`,pattern:_i},...Gl.map(e=>({kind:`image`,pattern:e})),...Kl.map(e=>({kind:`link`,pattern:e}))];function fd(e){return new RegExp(e.replace(/[\\^$.*+?()[\]{}|/-]/g,`\\$&`),`gi`)}var pd={canary:`canary leaked`,promptEcho:`system prompt echoed`,providerToolLeak:`a provider-side tool already sent the canary or system prompt`,egress:`Turn withheld: egress disclosure violation`};function md(e,t){return t&&Hs(e,t)?[He]:[]}function hd(e,t,n){return t?wo(e,t,n).map(([t,n])=>Ue(e,t,n)):[]}function gd(e,t){let{canary:n,canaryGiven:r,privateSystem:i}=t;return[...md(e,r?void 0:n),...hd(e,i,n)]}var _d={rule:ze.providerToolLeak,severity:`high`},vd=new Set([`code_execution_call`,`code_execution_result`,`url_context`,`provider_step`]);function yd(e){return e.type===`grounding`||e.type===`evidence`&&vd.has(e.evidence.kind)}function bd(e,t){let n=cc(e).flatMap(e=>gd(e,t));return n.length>0&&yd(e)?[_d]:[...new Map(n.map(e=>[e.rule,e])).values()]}function xd(e,t,n,r){if(yd(e)){let n=bd(e,t);return n.length>0?{stop:!0,hits:n}:void 0}let i=cc(e),a=[],o=t.canaryGiven?void 0:t.canary,s=n.canary_leak[r];s!==`ignore`&&i.some(e=>md(e,o).length>0)&&a.push([s,He]);let c=n.prompt_leak[r];if(c!==`ignore`)for(let e of i)for(let n of hd(e,t.privateSystem,t.canary))a.push([c,n]);if(a.length!==0)return{stop:a.some(([e])=>e!==`flag`),hits:a.map(([,e])=>e)}}var Sd=new Set([C.canary_leak,C.prompt_leak,ze.providerToolLeak]);function Cd(e){return Sd.has(e.rule)}function wd(e){return e.some(e=>e.rule===ze.providerToolLeak)?pd.providerToolLeak:e.some(e=>e.rule===C.canary_leak)?pd.canary:pd.promptEcho}function Td({canary:e,labels:t}){if(!e)return;let n=Ho(t);return n&&!ud.test(n)?n:void 0}var Ed=[/\b(?:next|final|remaining)\s+steps?\s*[:—-]/gi,/\byou\s+(?:must|should|need\s+to|are\s+required\s+to)\s+(?:now\s+)?\w{2,20}/gi,/\bto\s+(?:complete|finish|fulfil|fulfill)\s+(?:this|the)\s+\w{2,20}/gi,/\b(?:call|invoke|run|execute)\s+(?:the\s+)?[\w.-]{2,40}\s+(?:tool|function)\b/gi,/\b(?:send|forward|email|transfer|upload|post)\s+(?:the\s+|all\s+|your\s+)?[\w\s]{2,40}\s+to\s+\S{3,80}/gi,/\b(?:delete|remove|drop|purge)\s+(?:the\s+|all\s+)?[\w\s]{2,40}\b/gi],Dd=/\b[\w.+-]{1,64}@[\w-]{1,63}(?:\.[\w-]{1,63}){1,4}\b|\bhttps?:\/\/\S{4,120}/i,Od=new RegExp(Dd.source,`gi`),kd=240;function Ad(e,t){let n=e[t];return n===`
|
|
17
|
+
`;)s--;let c=r.slice(o,s),l=i+o,u={start:l,end:l+c.length},d=hu(e.pattern).exec(c),f=d?.indices;if(d&&f&&d.length>=2){let t=f[e.secretGroup??d.findIndex((e,t)=>t>0&&e!==void 0&&e!==``)];t?u={start:l+t[0],end:l+t[1]}:e.secretGroup&&(u={start:l,end:l})}let p={secret:n.slice(u.start,u.end),match:c,start:l,end:l+c.length};if(!(e.entropy!==void 0&&Ql(p.secret)<=e.entropy)&&!(ru(t,p,a)||e.allowlists.some(e=>ru(e,p,a))))return u.end>u.start?u:{start:l,end:l+c.length}}function _u(e,t,n){let r=e.toLowerCase(),i=lu(r,t),a=tu(e),o=[];for(let s of t)if(uu(s,i,r.length))for(let t of e.matchAll(mu(s.pattern))){if(t[0]===``||!uu(s,i,t.index+t[0].length))continue;let r=gu(s,n,e,t[0],t.index,a);r&&o.push({...r,kind:`sensitive`})}return o}function vu(e,t,n,r,i,a){let o=i+n.length;return(a?.length===r.length?du(e,a,o):du(e,r.slice(0,o).toLowerCase()))&&gu(e,t,r,n,i)!==void 0}var yu=/\b\d{3}-\d{2}-\d{4}\b/g,bu=/(?:SSN|social\s*security(?:\s*number)?)[:\s]+\d(?:[-\s]*\d){8}/gi,xu=/\b9\d{2}-\d{2}-\d{4}\b/g,Su=/\b\d{2}-\d{7}\b/g,Cu=/(?<!\p{L})(?:ssn|social[\s_-]*security(?:[\s_-]*number)?|tax[\s_-]*(?:payer[\s_-]*)?id(?:entification)?(?:[\s_-]*(?:number|no))?|taxpayer[\s_-]*id(?:entification)?(?:[\s_-]*number)?|itin|tin|ein|employer[\s_-]*identification[\s_-]*number)[\s"'\x60*:=>#\\.]{0,10}(?:[a-z]{1,12}[\s"'\x60*:=>#\\.]{1,4}){0,3}(?:\d{3}[- ]?\d{2}[- ]?\d{4}|\d{2}-?\d{7})(?!\d)/giu,wu=/\b[A-Z]{2}\d{2}(?:[A-Z0-9]{11,30}|(?: [A-Z0-9]{4}){2,7}(?: [A-Z0-9]{1,4})?)\b/g,Tu=/\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b/g,J=`[0-9a-f]{1,4}`,Eu=`(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)`,Du=RegExp(`(?<![\\w:.])(?:${[`(?:${J}:){6}${Eu}`,`(?:${J}:){1,5}:${Eu}`,`::(?:${J}:){0,5}${Eu}`,`(?:${J}:){7}${J}`,`(?:${J}:){1,6}(?::${J}){1,6}`,`(?:${J}:){1,7}:`,`:(?::${J}){1,7}`].join(`|`)})(?![\\w:])`,`gi`),Ou=/(?<![\w.+-])[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g,ku=/\.[A-Za-z][\w-]*$/,Y=`[ .\\-]`,Au=`(?:\\s?(?:x|ext\\.?)\\s?\\d{1,5})?`,ju=[RegExp(`(?<![\\w+])\\+\\s?[1-9]\\d{0,2}(?:\\s?\\(0\\))?(?:${Y}?\\(?\\d{1,4}\\)?){2,5}${Au}(?!\\w)`,`g`),RegExp(`(?<![\\w.\\-+])(?:(?:00)?1${Y})?(?:\\(\\d{3}\\)\\s?|\\d{3}${Y})\\d{3}${Y}\\d{4}${Au}(?![\\w\\-]|\\.\\d)`,`g`),RegExp(`(?<![\\w.\\-+]|\\d[ .\\-])0\\d{1,4}(?:${Y}\\d{2,4}){2,5}(?![\\w\\-]|\\.\\d)`,`g`),RegExp(`(?<![\\w)]|\\d[ .\\-])\\(0\\d{1,3}\\)${Y}?\\d{3,4}${Y}?\\d{4}(?![\\w\\-]|\\.\\d)`,`g`)],Mu=/(?<!\p{L})(?:phone|tel(?:ephone|efone|efono|éfono)?|téléphone|mobile|cell(?:ular)?|portable|handy|celular|whatsapp|fax)(?:[\s_]*(?:number|no\.?|nr\.?|#|numéro|número|numero|nummer))?[\s"'`*:=>]*(\+?\(?\d[\d ().-]{5,20}\d)/giu,Nu=/^(?:\d{3}[- ]\d{2}[- ]\d{4}|\d{3} \d{3} \d{3}|\d{1,2}[.\-/ ]\d{1,2}[.\-/ ]\d{4}|\d{4}[.\-/ ]\d{1,2}[.\-/ ]\d{1,2})$/,Pu=7,Fu=15;function Iu(e){if(Nu.test(e.trim()))return!1;let t=e.replace(/(?:x|ext\.?)\s?\d+$/i,``).replace(/\D/g,``).length;return t>=Pu&&t<=Fu}var Lu=[`bank[\\s_\\-]{0,3}account(?:[\\s_]{0,3}(?:number|no\\.?|#|nr\\.?))?`,`account[\\s_]{0,3}(?:number|no\\.?|#|nr\\.?)`,`acct\\.?(?:[\\s_]{0,3}(?:number|no\\.?|#))?`,`a\\/c(?:[\\s_]{0,3}no\\.?)?(?!\\p{L})`,`bban`,`routing[\\s_]{0,3}(?:number|no\\.?|#)?`,`aba(?:[\\s_]{0,3}(?:number|routing))?`,`sort[\\s_]{0,3}code`,`kontonummer`,`bankverbindung(?:snummer)?`,`konto`,`numero[\\s_]{0,3}di[\\s_]{0,3}conto(?:[\\s_]{0,3}corrente)?`,`conto[\\s_]{0,3}corrente`,`n[úu]mero[\\s_]{0,3}da[\\s_]{0,3}conta(?:[\\s_]{0,3}corrente)?`,`conta[\\s_]{0,3}corrente`,`num[ée]ro[\\s_]{0,3}de[\\s_]{0,3}compte(?:[\\s_]{0,3}bancaire)?`,`compte[\\s_]{0,3}bancaire`,`n[úu]mero[\\s_]{0,3}de[\\s_]{0,3}cuenta`,`cuenta[\\s_]{0,3}bancaria`,`rekeningnummer`].join(`|`),Ru=RegExp(`(?<![\\p{L}\\p{N}])(?:${Lu})(?:\\s{1,4}type="\\w+")?(?:\\s{0,4}\\([^)\\n]{1,24}\\))?[\\s"'\x60:=>*#]{0,8}(?:[a-z\\s]{0,12}[:\\s])?\\s{0,4}([A-Z0-9](?:[A-Z0-9\\-]|(?<=\\d) (?=\\d)){3,32}[A-Z0-9])`,`giu`),zu=/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/;function Bu(e){let t=e.replaceAll(` `,``),n=0;for(let e of t.slice(4)+t.slice(0,4)){let t=Number.parseInt(e,36);n=(n*(t>9?100:10)+t)%97}return n===1}var Vu=5;function Hu(e,t){return new RegExp(e.source,e.flags.replace(`g`,``)).exec(t)?.[1]}function Uu(e){let t=Hu(Ru,e);return t!==void 0&&!zu.test(t.replaceAll(` `,``))&&(t.match(/\d/g)??[]).length>=Vu}var Wu=[{id:`openai-api-key-any`,pattern:/\bsk-\s*[A-Za-z0-9]{20,}\b/,keywords:[`sk-`],allowlists:[]},{id:`anthropic-api-key-any`,pattern:/\bsk-ant-[A-Za-z0-9_-]{20,}\b/,keywords:[`sk-ant-`],allowlists:[]},{id:`openrouter-api-key`,pattern:/\bsk-or-[A-Za-z0-9_-]{20,}\b/,keywords:[`sk-or-`],allowlists:[]},{id:`github-fine-grained-pat-any`,pattern:/\bgithub_pat_[A-Za-z0-9_]{20,}\b/,keywords:[`github_pat_`],allowlists:[]},{id:`slack-token-any`,pattern:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/,keywords:[`xox`],allowlists:[]},{id:`private-key-any`,pattern:/-----BEGIN (?:(?:RSA|DSA|EC|OPENSSH|ENCRYPTED|PGP) )?PRIVATE KEY(?: BLOCK)?-----[\s\S]{0,16384}?-----END (?:(?:RSA|DSA|EC|OPENSSH|ENCRYPTED|PGP) )?PRIVATE KEY(?: BLOCK)?-----/,keywords:[`-----begin`],allowlists:[]},{id:`bearer-token`,pattern:/\bBearer[ \t]+([A-Za-z0-9._~+/-]{16,}=*)/i,entropy:3,keywords:[`bearer`],allowlists:[]},{id:`apify-api-token`,pattern:/\bapify_api_[A-Za-z0-9]{36}\b/,keywords:[`apify_api_`],allowlists:[]},{id:`fleetbase-api-key`,pattern:/\bflb_live_[A-Za-z0-9]{20}\b/,keywords:[`flb_live_`],allowlists:[]},{id:`nightfall-api-key`,pattern:/\bNF-[A-Za-z0-9]{32}\b/,keywords:[`nf-`],allowlists:[]},{id:`teamwork-api-token`,pattern:/\btkn\.v1_[A-Za-z0-9]{71}=/,keywords:[`tkn.v1_`],allowlists:[]},{id:`ubidots-api-token`,pattern:/\bBBFF-[A-Za-z0-9]{30}\b/,keywords:[`bbff-`],allowlists:[]},{id:`zapier-webhook-url`,pattern:/https:\/\/hooks\.zapier\.com\/hooks\/catch\/\d+\/[A-Za-z0-9]+\/?/,keywords:[`hooks.zapier.com`],allowlists:[]}],Gu=[...Zl,...Wu],Ku=/\b(?:\d[\s.-]*?){13,19}\b/g,qu=T.filter(e=>e!==`credentials`),Ju={ids:[yu,bu,xu,Su,Cu].map(e=>({pattern:e})),financial:[{pattern:wu,hit:Bu}],network:[{pattern:Tu},{pattern:Du}],email:[{pattern:Ou,hit:e=>ku.test(e)}],phone:[...ju.map(e=>({pattern:e,hit:Iu})),{pattern:Mu,hit:e=>Iu(Hu(Mu,e)??``)}],bank_account:[{pattern:Ru,hit:Uu}]},Yu=[...qu.flatMap(e=>Ju[e].map(t=>({group:e,...t}))),...Gu.map(e=>({group:`credentials`,pattern:new RegExp(e.pattern.source,`${e.pattern.flags}g`),hit:(t,n,r,i)=>vu(e,Xl,t,n,r,i?.())}))],Xu=y(T,()=>!0);function Zu(e,t=Xu){return e===void 0?t:typeof e==`boolean`?y(T,()=>e):{...t,...e}}var Qu=2,$u=9,ed=10;function td(e){let t=0,n=!1;for(let r=e.length-1;r>=0;--r){let i=e[r];if(i===void 0)return!1;let a=Number(i);n&&(a*=Qu,a>$u&&(a-=$u)),t+=a,n=!n}return t%ed===0}var X=[16,17,18,19],nd=[{leading:[[`4`,`4`]],lengths:[13,16,19]},{leading:[[`51`,`55`],[`2221`,`2720`]],lengths:[16]},{leading:[[`34`,`34`],[`37`,`37`]],lengths:[15]},{leading:[[`300`,`305`],[`3095`,`3095`],[`36`,`36`],[`38`,`39`]],lengths:[14,15,...X]},{leading:[[`6011`,`6011`],[`644`,`649`],[`65`,`65`]],lengths:X},{leading:[[`3528`,`3589`]],lengths:X},{leading:[[`62`,`62`]],lengths:X},{leading:[[`5018`,`5018`],[`5020`,`5020`],[`5038`,`5038`],[`5893`,`5893`],[`6304`,`6304`],[`6759`,`6759`],[`6761`,`6763`]],lengths:[13,14,15,...X]},{leading:[[`2200`,`2204`]],lengths:X},{leading:[[`60`,`60`],[`81`,`82`],[`508`,`508`],[`353`,`353`],[`356`,`356`]],lengths:[16]}];function rd(e){return nd.some(t=>t.lengths.includes(e.length)&&t.leading.some(([t,n])=>{let r=e.slice(0,t.length);return r>=t&&r<=n}))}var id=/https?:\/\//i,ad=2048;function od(e,t){let n=Math.max(0,t-ad),r=t;for(;r>n&&!/\s/.test(e[r-1]??` `);)--r;return id.test(e.slice(r,t))}function sd(e,t,n){let r=e.replaceAll(/[^\d]/g,``);return rd(r)&&td(r)&&!od(t,n)}function cd(e){let t=[];for(let n of e.matchAll(Ku)){let r=ur(n);r&&sd(r.blob,e,r.index)&&t.push({start:r.index,end:r.index+r.blob.length,kind:`sensitive`})}return t}function ld(e,t=!0){let n=Zu(t),r=[];for(let{group:t,pattern:i,hit:a}of Yu)if(t!==`credentials`&&n[t])for(let t of e.matchAll(i)){let n=ur(t);n&&(!a||a(n.blob,e,n.index))&&r.push({start:n.index,end:n.index+n.blob.length,kind:`sensitive`})}return[...r,...n.financial?cd(e):[],...n.credentials?_u(e,Gu,Xl):[]]}var ud=/This turn\x27s canary is|Your canary token is|<\s*(?:\/\s*)?user_data(?:\s*(?:\/\s*)?>)?/i,dd=[...oi.map(e=>({kind:`injection`,pattern:e})),...Yu.map(({group:e,pattern:t})=>({kind:`sensitive`,pattern:t,group:e})),{kind:`card`,pattern:Ku,group:`financial`},{kind:`boundary`,pattern:new RegExp(ud.source,`gi`)},{kind:`base64`,pattern:mi},{kind:`hex`,pattern:hi},{kind:`spaced`,pattern:gi},{kind:`pipe`,pattern:_i},...Gl.map(e=>({kind:`image`,pattern:e})),...Kl.map(e=>({kind:`link`,pattern:e}))];function fd(e){return new RegExp(e.replace(/[\\^$.*+?()[\]{}|/-]/g,`\\$&`),`gi`)}var pd={canary:`canary leaked`,promptEcho:`system prompt echoed`,providerToolLeak:`a provider-side tool already sent the canary or system prompt`,egress:`Turn withheld: egress disclosure violation`};function md(e,t){return t&&Hs(e,t)?[He]:[]}function hd(e,t,n){return t?wo(e,t,n).map(([t,n])=>Ue(e,t,n)):[]}function gd(e,t){let{canary:n,canaryGiven:r,privateSystem:i}=t;return[...md(e,r?void 0:n),...hd(e,i,n)]}var _d={rule:ze.providerToolLeak,severity:`high`},vd=new Set([`code_execution_call`,`code_execution_result`,`url_context`,`provider_step`]);function yd(e){return e.type===`grounding`||e.type===`evidence`&&vd.has(e.evidence.kind)}function bd(e,t){let n=cc(e).flatMap(e=>gd(e,t));return n.length>0&&yd(e)?[_d]:[...new Map(n.map(e=>[e.rule,e])).values()]}function xd(e,t,n,r){if(yd(e)){let n=bd(e,t);return n.length>0?{stop:!0,hits:n}:void 0}let i=cc(e),a=[],o=t.canaryGiven?void 0:t.canary,s=n.canary_leak[r];s!==`ignore`&&i.some(e=>md(e,o).length>0)&&a.push([s,He]);let c=n.prompt_leak[r];if(c!==`ignore`)for(let e of i)for(let n of hd(e,t.privateSystem,t.canary))a.push([c,n]);if(a.length!==0)return{stop:a.some(([e])=>e!==`flag`),hits:a.map(([,e])=>e)}}var Sd=new Set([C.canary_leak,C.prompt_leak,ze.providerToolLeak]);function Cd(e){return Sd.has(e.rule)}function wd(e){return e.some(e=>e.rule===ze.providerToolLeak)?pd.providerToolLeak:e.some(e=>e.rule===C.canary_leak)?pd.canary:pd.promptEcho}function Td({canary:e,labels:t}){if(!e)return;let n=Ho(t);return n&&!ud.test(n)?n:void 0}var Ed=[/\b(?:next|final|remaining)\s+steps?\s*[:—-]/gi,/\byou\s+(?:must|should|need\s+to|are\s+required\s+to)\s+(?:now\s+)?\w{2,20}/gi,/\bto\s+(?:complete|finish|fulfil|fulfill)\s+(?:this|the)\s+\w{2,20}/gi,/\b(?:call|invoke|run|execute)\s+(?:the\s+)?[\w.-]{2,40}\s+(?:tool|function)\b/gi,/\b(?:send|forward|email|transfer|upload|post)\s+(?:the\s+|all\s+|your\s+)?[\w\s]{2,40}\s+to\s+\S{3,80}/gi,/\b(?:delete|remove|drop|purge)\s+(?:the\s+|all\s+)?[\w\s]{2,40}\b/gi],Dd=/\b[\w.+-]{1,64}@[\w-]{1,63}(?:\.[\w-]{1,63}){1,4}\b|\bhttps?:\/\/\S{4,120}/i,Od=new RegExp(Dd.source,`gi`),kd=240;function Ad(e,t){let n=e[t];return n===`
|
|
18
18
|
`||(n===`.`||n===`!`||n===`?`)&&/\s/.test(e[t+1]??` `)}function jd(e,t){let n=e[t];return Ad(e,t)||(n===`,`||n===`;`)&&/\s/.test(e[t+1]??` `)}function Md(e,t,n){let r=t,i=Math.min(e.length,t+kd);for(;r<i&&!n(e,r);)r+=1;return r}function Nd(e,t){let n=t,r=Math.max(0,t-kd);for(;n>r&&!Ad(e,n-1);)--n;return n}var Pd=[/\b(?:the\s+)?user\s+has\s+(?:already\s+)?(?:approved|authorised|authorized|confirmed|requested)\b/gi,/\b(?:system|admin|operator)\s+(?:note|notice|message|override|instruction)s?\s*[:—-]/gi,/\bon\s+behalf\s+of\s+the\s+(?:user|operator|admin)\b/gi,/\bthis\s+(?:is|was)\s+(?:pre-?)?(?:approved|authorised|authorized)\b/gi],Fd=[new RegExp(ti(5),`gi`)];function Id(e,t,n){return[...e.slice(t,n).matchAll(Od)].map(e=>[t+e.index,t+e.index+e[0].length])}function Ld(e,t){return e.flatMap(e=>[...t.matchAll(e)].flatMap(e=>{let n=e.index+e[0].length,r=Id(t,e.index,Md(t,n,jd));return r.length>0?[[e.index,n],...r]:[]}))}function Rd(e){let t=xa(e);return Fd.flatMap(e=>[...t.text.matchAll(e)].map(e=>[t.at(e.index),t.at(e.index+e[0].length-1)+1]))}function zd(e){return e===void 0||!/[a-z0-9_-]/i.test(e)}function Bd(e,t){if(t.length<3)return[];let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=n.indexOf(r);for(;a>=0;){let t=a+r.length;if(zd(n[a-1])&&zd(n[t])){let n=Id(e,Nd(e,a),Md(e,t,Ad)),r=n.some(([e,n])=>e<=a&&t<=n);n.length>0&&!r&&i.push([a,t],...n)}a=n.indexOf(r,t)}return i}function Vd(e){let t=[];for(let[n,r]of[...e].sort((e,t)=>e[0]-t[0])){let e=t.at(-1);e&&n<=e[1]?e[1]=Math.max(e[1],r):t.push([n,r])}return t}function Hd(e,t){return Vd(t).map(([t,n])=>({signal:e,start:t,end:n}))}function Ud(e,t=[]){if(!e)return[];let n=Wi(e),r=Hd(`override`,Rd(n));if(Dd.test(n)&&r.push(...Hd(`tool_name`,t.flatMap(e=>Bd(n,e))),...Hd(`order`,Ld(Ed,n)),...Hd(`authority`,Ld(Pd,n))),n===e||r.length===0)return r;let i=Ki(e);return r.map(({signal:t,start:n,end:r})=>({signal:t,start:i.start[n]??e.length,end:i.end[r-1]??e.length}))}function Wd(e){if(e.length===0)return`none`;let t=new Set(e);return t.has(`tool_name`)||t.has(`override`)||t.size>1?`high`:`elevated`}var Gd=`[A-Za-z0-9_]`;function Kd(e){return e.replace(/[\\^$.*+?()[\]{}|/-]/g,`\\$&`)}function qd(e){let t=`(?!${Gd})`,n=[...new Set(e.names)].filter(Boolean).map(e=>({literal:e,regex:RegExp(`(?<!${Gd})${Kd(e)}${t}`,`g`)})),r=[...new Set(e.params)].filter(Boolean).flatMap(e=>[`"${e}"`,`\\"${e}\\"`]).map(e=>({literal:e,regex:new RegExp(Kd(e),`g`)}));return[...n,...r]}function Jd(e,t){return t?qd(t).flatMap(({literal:t,regex:n})=>e.includes(t)?[...e.matchAll(n)].map(({index:e,0:t})=>({start:e,end:e+t.length,kind:`tool`})):[]):[]}function Yd(e,t=[]){if(!e)return;let n=e.names.filter(e=>!t.includes(e)),r=e.params.filter(e=>!t.includes(e));return n.length+r.length>0?{names:n,params:r}:void 0}function Xd(e){return e.length===0?{}:{errorInternal:e.map(({errorInternal:e})=>e).join(`
|
|
19
19
|
`),errorSummary:e.map(({errorSummary:e})=>e).join(`
|
|
20
20
|
`)}}var Zd=[`allow`,`flag`,`redact`,`block`];function Qd(e,t){return t===`ignore`?e:Zd.indexOf(t)>Zd.indexOf(e)?t:e}var $d=y(T,e=>y(T,t=>t===e)),ef={};function tf(e,t){let n=j(e,`canary_leak`)?t.canary:void 0,r=j(e,`prompt_leak`)&&t.privateSystem?.length;return{...n?{canary:n}:{},...n&&t.canaryGiven?{canaryGiven:!0}:{},...r?{privateSystem:t.privateSystem}:{}}}function nf(e,t){let{detect:n}=e,r=tf(n,t),i=j(n,`ungiven_images`)||j(n,`ungiven_links`),a=j(n,`marker_leak`)?Td({canary:r.canary,labels:t.labels}):void 0,o=j(n,`tool_leak`)?Yd(t.ownTools,n.innocent):void 0;return{...r,...i&&t.givenUrls?{givenUrls:t.givenUrls}:{},...i?{allow:e.allow}:{},...a?{note:a}:{},...o?{ownTools:o}:{}}}var rf=[`canary_leak`,`prompt_leak`];function af(e){return rf.includes(e)}function of(e,t){return Vd(e).map(([e,n])=>({start:e,end:n,kind:t}))}function sf(e,t){return{...t.allow?.[e],...t.givenUrls?{given:t.givenUrls}:{}}}var cf=new RegExp(ud.source,`gi`);function lf(e,t,n){return t.flatMap(({name:t,regex:r})=>pr(e,[r],n).map(e=>({...e,name:t})))}var uf={injection:`injection`,tool_instructions:`directive`,tool_leak:`tool`};function df(e,t,n,r,i=!1){if(!r)return ff(e,t,n,i);let a=lf(t,r.matchers,uf[e]??`sensitive`);return r.theorem?[...ff(e,t,n,i),...a]:a}function ff(e,t,n,r=!1){if(e===`injection`)return Ja(t);if(e===`marker_leak`)return pr(t,[cf,...n.note?[fd(n.note)]:[]],`prompt`);if(e===`ungiven_images`)return Hl(t,sf(e,n)).map(e=>({...e,kind:`image`}));if(e===`ungiven_links`)return Ul(t,sf(e,n),r).map(e=>({...e,kind:`link`}));if(e===`canary_leak`){let{canary:e,canaryGiven:r}=n;return e&&!r?of(Vs(t,e),`canary`):[]}if(e===`prompt_leak`){let{privateSystem:e,canary:r}=n;return e?of(wo(t,e,r),`prompt`):[]}return e===`tool_leak`?Jd(t,n.ownTools):e===`tool_instructions`?Ud(t,n.callable).map(e=>({...e,kind:`directive`})):ld(t,$d[e])}function pf(e,t,n){let{start:r,end:i}=n;if(e===`canary_leak`)return{...He,span:{start:r,end:i}};if(e===`prompt_leak`)return Ue(t,r,i);if(e===`tool_instructions`&&n.signal){let r=n.signal===`order`||n.signal===`authority`?`medium`:`high`;return{...w(t,n,C[e],r),signal:n.signal}}return w(t,n,C[e],`high`)}function mf(e,t,n){return e===`ungiven_links`&&n.ungiven_images[t]!==`ignore`}function hf(e){let t=e instanceof Error?e.name:typeof e;return/^[A-Za-z]{1,64}$/.test(t)?t:`Error`}function gf(e,t,n){try{let r=e(t,n?{boundary:n}:{}),i=`find returned no list of stretches inside the text`,a={signal:`find_result`,reason:i,summary:i};return Array.isArray(r)&&r.every(({start:e,end:n})=>Number.isInteger(e)&&Number.isInteger(n)&&e>=0&&e<n&&n<=t.length)?r.map(({start:e,end:t})=>({start:e,end:t,kind:`host`})):a}catch(e){let t=crypto.randomUUID().slice(0,8);return{signal:`find_threw`,reason:`find threw: ${he(e)} (error ${t})`,summary:`find threw ${hf(e)} (error ${t})`}}}function _f(e,t,n){let r=Re(e.id);return{key:e.id,rule:r,label:e.label,chosen:n,spans(n){let r=lf(n,e.matchers,`host`);if(!e.find)return r;let i=gf(e.find,n,t);if(!Array.isArray(i)){let t=`Host detector '${e.id}'`;return{...i,reason:`${t} ${i.reason}`,summary:`${t} ${i.summary}`}}return[...r,...i]},hit:(t,n)=>({...w(t,n,r,`high`),label:e.label})}}function vf(e,t){return(t.host??[]).filter(({actions:t})=>t[e]!==`ignore`)}function yf(e,t,n,r){let i=[];for(let r of E){let a=t[r][e];if(a===`ignore`)continue;let o=mf(r,e,t);i.push({key:r,rule:C[r],chosen:a,spans:e=>df(r,e,n,t.sources?.[r],o),hit:(e,t)=>pf(r,e,t)})}for(let n of vf(e,t))i.push(_f(n,e,n.actions[e]));return r?i.filter(({key:e})=>r.includes(e)):i}function bf({rule:e,label:t},n){return{rule:e,severity:`high`,...t===void 0?{}:{label:t},...n===void 0?{}:{signal:n}}}function xf(e,t,n,r=ef){let i=[],a=[],o=[],s=`allow`;for(let c of yf(t,n,r)){let t=c.spans(e);if(!Array.isArray(t))i.push(bf(c,t.signal)),o.push({errorInternal:t.reason,errorSummary:t.summary}),s=`block`;else if(t.length!==0){for(let n of t)i.push(c.hit(e,n));if(c.chosen===`redact`)for(let e of t)a.push(e);s=Qd(s,c.chosen)}}if(s===`block`)return{action:s,hits:i,...Xd(o)};if(a.length===0)return{action:s,text:e,hits:i};let c=fr(e,a);return Sf(c,t,n,r)?{action:`block`,hits:i}:{action:s,text:c,hits:i}}function Sf(e,t,n,r,i){return yf(t,n,r,i).some(({chosen:t,spans:n})=>{if(t===`flag`)return!1;let r=n(e);return!Array.isArray(r)||r.length>0})}function Cf(e,t){return E.filter(n=>t[n][e]!==`ignore`)}function wf(e,t){return e===`canary_leak`?!!t.canary:e===`prompt_leak`?!!t.privateSystem?.length:e!==`tool_leak`||!!t.ownTools?.names.length}function Tf(e,t,n){return e.some(e=>vf(e,t).length>0||Cf(e,t).some(e=>!n||wf(e,n)))}function Ef(e,{from:t,to:n,settled:r},i,a,{detectors:o,scope:s}){let c=[],l=[],u=yf(i,a,s,o).flatMap(r=>{let i=r.spans(e);return Array.isArray(i)?i.filter(e=>e.end>t&&e.start<n).map(e=>({span:e,rule:r.rule,label:r.label,chosen:r.chosen})):(c.push(bf(r,i.signal)),l.push({errorInternal:i.reason,errorSummary:i.summary}),[])});if(c.length>0)return{action:`block`,hits:c,taken:0,...Xd(l)};let d=({span:t,rule:n,label:r})=>({...w(e,t,n,`high`),...r===void 0?{}:{label:r}}),f=u.filter(({chosen:e})=>e===`block`);if(f.length>0)return{action:`block`,hits:f.map(d),taken:0};let p=r.filter(e=>xt(a,e,i)===`block`);if(p.length>0)return{action:`block`,hits:p.map(e=>bf({rule:Re(e),label:a.host?.find(({id:t})=>t===e)?.label})),taken:0};let m=u.filter(({chosen:e})=>e===`redact`),h=n;for(;;){let e=m.find(({span:e})=>e.start<h&&e.end>h);if(!e)break;h=Math.max(t,e.span.start)}let g=u.filter(({span:e,chosen:n})=>n===`redact`?e.end<=h:e.start>=t&&e.start<h),ee=g.filter(({chosen:e})=>e===`redact`).map(({span:e})=>({...e,start:Math.max(0,e.start-t),end:e.end-t})),te=fr(e.slice(t,h),ee);return ee.length>0&&Sf(te,i,a,s,o)?{action:`block`,hits:g.map(d),taken:0}:{action:g.reduce((e,{chosen:t})=>Qd(e,t),`allow`),text:te,hits:g.map(d),taken:h-t}}function Df(e,t){return fr(e,t.flatMap(t=>df(t,e,ef)))}function Of(e,t,n,r){return t.flatMap(t=>{let i=r?.sources?.[t];return df(t,e,ef,n===!0?i:{theorem:n.theorem,matchers:n.host?i?.matchers??[]:[]})})}function kf(e,t){return(t?.host??[]).flatMap(t=>{let n=lf(e,t.matchers,`host`);if(!t.find||!e)return n;let r=gf(t.find,e);return Array.isArray(r)?[...n,...r]:[{start:0,end:e.length,kind:`host`}]})}function Af(e,t){let n=[],r=[],i=`allow`;return{read(a){let o=xf(a,e,t);for(let e of o.hits)n.push(e);return o.errorInternal&&o.errorSummary&&r.push({errorInternal:o.errorInternal,errorSummary:o.errorSummary}),i=Qd(i,o.action),o.text??``},found:()=>({action:i,hits:n,...Xd(r)})}}var jf={user:`input`,options:`input`,context:`input`,repair:`input`,attachment:`attachment`,voice:`attachment`,history:`history`,injected:`history`,system:`system`,live_user:`live_inbound`,...Object.fromEntries(Se.map(e=>[e,e.startsWith(`tool_arguments`)?`tool_call`:`tool_result`])),reply:`output_final`,reply_structured:`output_final`,live_reply:`live_outbound`,thought:`thought`};function Mf(e){return e===`system`?`assembled`:`untrusted`}function Nf(e,t,n,r=jf[e]){if(t.action!==`allow`)return{stage:r,boundary:e,trust:Mf(e),action:t.action,hits:t.hits,...n?{provenance:n}:{},...t.action===`block`&&t.errorInternal?{errorInternal:t.errorInternal}:{},...t.action===`block`&&t.errorSummary?{errorSummary:t.errorSummary}:{}}}function Pf(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ff=16,If=8,Lf=1e6,Rf=2,zf=16,Bf=/^00-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}$/,Vf=/^0+$/,Hf=`01`,Uf=`unclosed`;function Wf(e){for(;;){let t=[...crypto.getRandomValues(new Uint8Array(e))].map(e=>e.toString(zf).padStart(Rf,`0`)).join(``);if(!Vf.test(t))return t}}function Gf(){let e=Date.now(),t=performance.now();return{nowUnixNano:()=>BigInt(e)*BigInt(Lf)+BigInt(Math.round((performance.now()-t)*Lf))}}function Kf(){return globalThis.navigator?.userAgent===`Cloudflare-Workers`}function qf(e){let t=Bf.exec(e.trim()),n=t?.[1],r=t?.[2];if(n&&r&&!Vf.test(n)&&!Vf.test(r))return{traceId:n,spanId:r}}function Jf(t){let n=qf(t);if(!n)throw new e(`request`,`traceparent is not a valid W3C trace context: '${t}'`);return n}function Yf(e,t){return`00-${e}-${t}-${Hf}`}function Xf(e){return{$content:e}}function Zf(e){return{$bytes:e}}function Qf(e){return{$json:$f(e)??null}}function $f(e){if(typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`)return Number.isFinite(e)?e:null;if(e===null)return null;if(Array.isArray(e))return e.map(e=>$f(e)??null);if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e)){let e=$f(r);e!==void 0&&(t[n]=e)}return t}}function ep(e,t){return Pf(e)&&t in e}function tp(e){return ep(e,`$content`)&&typeof e.$content==`string`}function np(e){return ep(e,`$bytes`)&&typeof e.$bytes==`string`}function rp(e){return ep(e,`$json`)}function ip(e){let{traceId:t,spanId:n}=Jf(e.traceparent);return{traceId:t,spanId:n,attributes:{...e.attributes??{}}}}function ap(e,t){return Number(t.nowUnixNano()-BigInt(e))/Lf}function op(e,t,n,r,i){let a={span:{traceId:t,spanId:Wf(If),...n?{parentSpanId:n}:{},name:r,kind:i?.kind??`INTERNAL`,startTimeUnixNano:i?.startTimeUnixNano??String(e.clock.nowUnixNano()),endTimeUnixNano:``,attributes:{...i?.attributes??{}},events:[],links:(i?.links??[]).map(ip),status:{code:`UNSET`}},ended:!1,order:e.open.length};e.open.push(a);let{span:o}=a;return{traceId:t,spanId:o.spanId,get ended(){return a.ended},traceparent:()=>Yf(t,o.spanId),child:(n,r)=>op(e,t,o.spanId,n,r),set:e=>{a.ended||Object.assign(o.attributes,e)},event:(t,n,r)=>{a.ended||o.events.push({name:t,timeUnixNano:r??String(e.clock.nowUnixNano()),attributes:{...n??{}}})},end:t=>{a.ended||(a.ended=!0,o.endTimeUnixNano=String(e.clock.nowUnixNano()),o.status=t??{code:`OK`})},msSinceStart:()=>ap(o.startTimeUnixNano,e.clock),msSinceEnd:()=>a.ended?ap(o.endTimeUnixNano,e.clock):void 0,nowUnixNano:()=>String(e.clock.nowUnixNano())}}function sp(e,t={}){let n=t.traceparent?Jf(t.traceparent):void 0,r={clock:t.clock??Gf(),open:[]};return{root:op(r,n?.traceId??Wf(Ff),n?.spanId,e,{...t,attributes:{...Kf()?{"theorem.clock":`io`}:{},...t.attributes??{}}}),clock:r.clock,collect:()=>{let e=String(r.clock.nowUnixNano());for(let t of r.open)t.ended||(t.ended=!0,t.span.endTimeUnixNano=e,t.span.status={code:`ERROR`,message:Uf});return[...r.open].sort((e,t)=>e.order-t.order).map(e=>e.span)}}}function cp(e){let t=new Set(e.spans.map(e=>e.spanId));return e.spans.find(e=>e.parentSpanId===void 0||!t.has(e.parentSpanId))}var lp=[`name`,`title`,`label`,`headline`,`subject`,`id`],up=[`country`,`region`,`state`,`admin1`,`city`,`category`,`type`,`kind`,`status`],dp=2,fp=24,pp=[`description`,`summary`,`snippet`,`extract`,`subtitle`,`address`,`display_name`,`text`],mp=[`url`,`link`,`href`],hp=2,gp=6,_p=8,vp=8,yp=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){return typeof e!=`object`||!e}var bp=`[Unreadable]`,xp=Symbol(`no toJSON`);function Sp(e){try{return e()}catch{return bp}}function Cp(e,t){let n=e.toJSON;return typeof n==`function`?wp(n.call(e),t):xp}function wp(e,t=[]){if(typeof e==`bigint`)return String(e);if(typeof e!=`object`||!e)return e;if(t.includes(e))return`[Circular]`;let n=[...t,e],r=Sp(()=>Cp(e,n));return r===xp?Array.isArray(e)?e.map(e=>wp(e,n)):Object.fromEntries(Object.keys(e).map(t=>[t,Sp(()=>wp(e[t],n))])):r}function Tp(e){try{return JSON.stringify(e,null,2)??String(e)}catch{return JSON.stringify(wp(e),null,2)??String(e)}}var Ep=new Set(tn);function Dp(e){return!Z(e)||typeof e.type!=`string`?!1:e.type===`text`?typeof e.text==`string`:Ep.has(e.type)&&typeof e.mimeType==`string`&&(typeof e.data==`string`||typeof e.uri==`string`)}function Op(e){try{return JSON.stringify(e,(e,t)=>Dp(t)&&`data`in t?{...t,data:``}:t,2)?.length??0}catch{return Tp(e).length}}function kp(e){if(typeof e!=`string`)return e;let t=e.trim();if(!/^[[{]/.test(t))return e;try{return JSON.parse(t)}catch{return e}}function $(e){let t=e.replace(/([a-z\d])([A-Z])/g,`$1 $2`).replace(/([a-zA-Z])(\d)/g,`$1 $2`).replace(/[_-]+/g,` `).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function Ap(e){if(!(typeof e!=`string`||e===``||/\s/.test(e)||e===`iso8601`))return e}var jp={m:`m`,km:`km`,mi:`mi`,ms:`ms`,s:`s`,sec:`s`,min:`min`,h:`h`,kg:`kg`,g:`g`,pct:`%`,percent:`%`,c:`°C`,f:`°F`,usd:`USD`,eur:`EUR`,gbp:`GBP`,jpy:`JPY`};function Mp(e){let t=/^(.+?)[_-]([a-z]+)$/i.exec(e),n=t?jp[(t[2]??``).toLowerCase()]:void 0;return t?.[1]&&n?{label:$(t[1]),unit:n}:void 0}function Np(e,t){let n=Ap(t?.[e]);return n?{label:$(e),unit:n}:Mp(e)??{label:$(e)}}function Pp(e,t,n){return typeof t==`number`?Np(e,n):{label:$(e)}}function Fp(e,t){let n=e[`${t}_units`];return Z(n)?n:void 0}function Ip(e){return Object.entries(e).filter(([t,n])=>!(t.endsWith(`_units`)&&Z(n)&&t.slice(0,-6)in e))}function Lp(e){if(!yp.test(e))return;let t=new Date(e);if(!Number.isNaN(t.getTime()))return e.includes(`T`)?{kind:`date-time`,date:t}:{kind:`date`,date:t}}function Rp(e,t){if(e==null)return{kind:`none`};if(typeof e==`boolean`)return{kind:`boolean`,value:e};if(typeof e==`number`)return t?{kind:`number`,value:e,unit:t}:{kind:`number`,value:e};let n=String(e);return/^https?:\/\/\S+$/.test(n)?{kind:`link`,href:n}:Lp(n)??{kind:`text`,text:n}}function zp(e,t){return t?/^[°%]/.test(t)?`${e}${t}`:`${e} ${t}`:e}function Bp(e){return lp.find(t=>typeof e[t]==`string`||typeof e[t]==`number`)}function Vp(e,t){return up.filter(n=>{let r=e[n];return n!==t&&typeof r==`string`&&r.length>0&&r.length<=fp}).slice(0,dp).map(t=>e[t])}function Hp(e){if(!Z(e)||!Object.values(e).every(Q))return;let t=Bp(e),n=pp.find(t=>typeof e[t]==`string`&&e[t]!==``);if(!t||!n)return;let r=mp.find(t=>typeof e[t]==`string`&&/^https?:\/\//.test(e[t])),i=Vp(e,t),a=new Set([t,n,r]),o=Object.entries(e).filter(([e,t])=>!a.has(e)&&!(up.includes(e)&&i.includes(t)));if(!(o.length>hp))return{title:String(e[t]),description:e[n],href:r?e[r]:void 0,tags:i,extras:o}}function Up(e){if(!Z(e))return{tags:[],rest:e};let t=Bp(e);return t?{title:String(e[t]),tags:Vp(e,t),rest:Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}:{tags:Vp(e,void 0),rest:e}}function Wp(e){if(e.length<2||!e.every(e=>Z(e)&&Object.values(e).every(Q)))return;let t=[...new Set(e.flatMap(e=>Object.keys(e)))];return t.length<=gp?t:void 0}function Gp(e){let t=Ip(e);if(t.length<2)return;let n=new Set(t.map(([,e])=>Array.isArray(e)&&e.every(Q)?e.length:-1)),[r]=n;return n.size===1&&r!==void 0&&r>=2?t.map(([e])=>e):void 0}function Kp(e,t){let n=t.map(t=>e[t]);return(n[0]??[]).map((e,r)=>Object.fromEntries(t.map((e,t)=>[e,n[t]?.[r]])))}function qp(e){if(e.length===0)return{kind:`none`};if(e.every(Q))return{kind:`tokens`,items:e};if(e.every(Dp))return{kind:`parts`,parts:e};let t=e.map(Hp);if(t.every(e=>e!==void 0))return{kind:`list`,rows:t};let n=Wp(e);return n?{kind:`table`,columns:n,rows:e}:{kind:`rows`,items:e}}function Jp(e){if(Object.keys(e).length===0)return{kind:`none`};let t=Gp(e);return t?{kind:`table`,columns:t,rows:Kp(e,t)}:{kind:`fields`,row:e}}function Yp(e,t){return t>vp?{kind:`json`}:Array.isArray(e)?qp(e):Z(e)?Jp(e):{kind:`plain`}}var Xp=160;function Zp(e){return typeof e==`string`&&(e.length>Xp||e.includes(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t}from"./tool-schema-
|
|
1
|
+
import{i as e,o as t}from"./tool-schema-BMdqCPG0.js";import{An as n,Zt as r}from"./shaped-data-QPeAmaJ4.js";var i=r.filter(e=>e===`image/*`||e===`application/pdf`||e.startsWith(`text/`)),a=n.filter(e=>e===`audio/*`),o=`{
|
|
2
2
|
"User-Agent": "TheoremStudio/1.0 (travel demo; +https://github.com/masudl-hub/theoremai)"
|
|
3
3
|
}`,s=`{
|
|
4
4
|
"Accept": "application/vnd.github.raw",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/studio-monaco-C20o5PnA.js","assets/preload-helper-DpV6A1kQ.js","assets/editor.api-BldS301e.js","assets/editor-DjpsE8to.css","assets/studio-monaco-BkNqudm7.css","assets/register-BLInT6S0.js","assets/studio-type-checker-f2wzNB9Y.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{t as r}from"./preload-helper-DpV6A1kQ.js";import{D as i,Jt as a,T as o,Yt as s,k as c}from"./tool-schema-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{t as r}from"./preload-helper-DpV6A1kQ.js";import{D as i,Jt as a,T as o,Yt as s,k as c}from"./tool-schema-BMdqCPG0.js";import{c as l}from"./host-patterns-F-KZIzkF.js";import{Er as u,Nn as d,Sr as f,er as p,in as m,zn as h}from"./shaped-data-QPeAmaJ4.js";import{X as g,b as _,g as v,h as y,m as ee,w as b,x,y as S}from"./tree-BRzl4J61.js";import{r as C}from"./live-ingress-OuSlQ6q7.js";import{t as te}from"./registry-CWNE3rO6.js";import{i as ne,n as re,r as ie,t as ae}from"./types-5TSKtfT6.js";import{n as oe}from"./stub-xIKEDapD.js";import{I as w,M as se,k as ce,r as le}from"./workspace-B0zHlpWt.js";import{O as ue,wt as de}from"./index-BA2jTPWc.js";var T=class extends Error{line;column;constructor(e,t,n){super(e),this.line=t,this.column=n}},fe=class{text;of;i=0;line=1;column=1;constructor(e,t=`profile`){this.text=e,this.of=t}get done(){return this.i>=this.text.length}pos(){return{line:this.line,column:this.column}}fail(e){throw new T(e,this.line,this.column)}peek(e=0){return this.text[this.i+e]??``}bump(){let e=this.text[this.i]??``;return this.i+=1,e===`
|
|
3
3
|
`?(this.line+=1,this.column=1):this.column+=1,e}skip(){for(;;){let e=this.peek();if(e===` `||e===` `||e===`
|
|
4
4
|
`||e===`\r`||e===``)this.bump();else if(e===`/`&&this.peek(1)===`/`)for(;!this.done&&this.peek()!==`
|
|
5
5
|
`;)this.bump();else if(e===`/`&&this.peek(1)===`*`){for(this.bump(),this.bump();!this.done&&(this.peek()!==`*`||this.peek(1)!==`/`);)this.bump();this.done&&this.fail(`This comment never closes.`),this.bump(),this.bump()}else return}}starts(e){return this.skip(),this.text.startsWith(e,this.i)}eat(e){if(!this.starts(e))return!1;for(let t=0;t<e.length;t+=1)this.bump();return!0}expect(e){this.eat(e)||this.fail(`Expected '${e}'.`)}ident(){this.skip();let e=this.peek();if(!/^[A-Za-z_$]/.test(e))return;let t=``;for(;/^[A-Za-z0-9_$]/.test(this.peek());)t+=this.bump();return t}expectIdent(){let e=this.ident();return e===void 0&&this.fail(`Expected a name.`),e}peekIdent(){return this.skip(),/^[A-Za-z_$][A-Za-z0-9_$]*/.exec(this.text.slice(this.i))?.[0]}rest(){return this.skip(),this.text.slice(this.i)}};function E(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function D(e){e.skip();let t=e.peek();t!==`'`&&t!==`"`&&e.fail(`Expected a string.`),e.bump();let n=``;for(;!e.done&&e.peek()!==t;){let t=e.bump();if(t!==`\\`){n+=t;continue}let r=e.bump(),i={n:`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{p as r}from"./useTooltip-ClCeZiOV.js";import{t as i}from"./VStack-CCYGIv4A.js";import{s as a}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,l as n}from"./themeProps-Bo2jNkIC.js";import{p as r}from"./useTooltip-ClCeZiOV.js";import{t as i}from"./VStack-CCYGIv4A.js";import{s as a}from"./index-BA2jTPWc.js";var o=e(t(),1),s=r();function c(e,t,n){return Math.max(1,Math.floor((e+n)/(t+n)))}function l(e,t,n){let r=Array.from({length:t},()=>0);return{places:e.map(e=>{let t=r.indexOf(Math.min(...r)),i=r[t]??0;return e!==0&&(r[t]=i+(e??0)+n),{column:t,top:i}}),height:Math.max(0,Math.max(...r)-n)}}var u=n();function d(e,t){return e.width===t.width&&e.gap===t.gap&&e.heights.length===t.heights.length&&e.heights.every((e,n)=>e===t.heights[n])}function f({minWidth:e,children:t}){let n=o.Children.toArray(t),r=(e,t)=>(0,o.isValidElement)(e)&&e.key!==null?e.key:String(t),a=(0,o.useRef)(null),f=(0,o.useRef)([]),p=(0,o.useRef)(null),m=(0,o.useRef)([]),h=e=>(m.current[e]??=t=>(f.current[e]=t,t&&p.current?.observe(t),()=>{t&&p.current?.unobserve(t)}),m.current[e]),[g,_]=(0,o.useState)({width:0,gap:0,heights:[]}),v=c(g.width,e,g.gap),y=(g.width-g.gap*(v-1))/v,{places:b,height:x}=l(n.map((e,t)=>g.heights[t]),v,g.gap),S=g.width>0;return f.current.length=n.length,(0,o.useLayoutEffect)(()=>{let e=a.current;if(!e)return;let t=new WeakMap,n=0,r=new ResizeObserver(r=>{for(let i of r){let r=i.borderBoxSize[0];i.target===e?n=i.contentBoxSize[0]?.inlineSize??n:r&&t.set(i.target,r.blockSize)}let i={width:n,gap:Number.parseFloat(getComputedStyle(e).rowGap)||0,heights:f.current.map(e=>e?t.get(e):void 0)};(0,s.flushSync)(()=>_(e=>d(e,i)?e:i))});r.observe(e);for(let e of f.current)e&&r.observe(e);return p.current=r,()=>{r.disconnect(),p.current=null}},[]),(0,u.jsx)(i,{ref:a,gap:3,style:S?{position:`relative`,height:x}:void 0,children:n.map((e,t)=>{let n=b[t];return(0,u.jsx)(`div`,{ref:h(t),style:S&&n?{position:`absolute`,top:n.top,left:n.column*(y+g.gap),width:y}:void 0,children:e},r(e,t))})})}function p({payload:e,runtime:t=null,traces:n,onActivity:r},i,s){return(0,o.useMemo)(()=>{let o=t?s(e,t,{traces:n}):i(e,{traces:n});return r?a(o,r):o},[e,t,n,r,i,s])}export{f as n,p as t};
|