@agent-deck/backend 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/agent-run/adapter.d.ts +134 -0
- package/dist/agent-run/adapter.d.ts.map +1 -0
- package/dist/agent-run/adapter.js +70 -0
- package/dist/agent-run/adapter.js.map +1 -0
- package/dist/agent-run/claude-probe.d.ts +30 -0
- package/dist/agent-run/claude-probe.d.ts.map +1 -0
- package/dist/agent-run/claude-probe.js +85 -0
- package/dist/agent-run/claude-probe.js.map +1 -0
- package/dist/agent-run/claude.d.ts +49 -0
- package/dist/agent-run/claude.d.ts.map +1 -0
- package/dist/agent-run/claude.js +104 -0
- package/dist/agent-run/claude.js.map +1 -0
- package/dist/agent-run/codex.d.ts +86 -0
- package/dist/agent-run/codex.d.ts.map +1 -0
- package/dist/agent-run/codex.js +377 -0
- package/dist/agent-run/codex.js.map +1 -0
- package/dist/agent-run/cursor.d.ts +80 -0
- package/dist/agent-run/cursor.d.ts.map +1 -0
- package/dist/agent-run/cursor.js +462 -0
- package/dist/agent-run/cursor.js.map +1 -0
- package/dist/agent-run/index.d.ts +15 -0
- package/dist/agent-run/index.d.ts.map +1 -0
- package/dist/agent-run/index.js +31 -0
- package/dist/agent-run/index.js.map +1 -0
- package/dist/agent-run/muse.d.ts +134 -0
- package/dist/agent-run/muse.d.ts.map +1 -0
- package/dist/agent-run/muse.js +512 -0
- package/dist/agent-run/muse.js.map +1 -0
- package/dist/agent-run/provenance.d.ts +28 -0
- package/dist/agent-run/provenance.d.ts.map +1 -0
- package/dist/agent-run/provenance.js +118 -0
- package/dist/agent-run/provenance.js.map +1 -0
- package/dist/agent-run/records.d.ts +182 -0
- package/dist/agent-run/records.d.ts.map +1 -0
- package/dist/agent-run/records.js +359 -0
- package/dist/agent-run/records.js.map +1 -0
- package/dist/agent-run/service.d.ts +206 -0
- package/dist/agent-run/service.d.ts.map +1 -0
- package/dist/agent-run/service.js +503 -0
- package/dist/agent-run/service.js.map +1 -0
- package/dist/agent-run-api/auth.d.ts +22 -0
- package/dist/agent-run-api/auth.d.ts.map +1 -0
- package/dist/agent-run-api/auth.js +54 -0
- package/dist/agent-run-api/auth.js.map +1 -0
- package/dist/agent-run-api/finalization-store.d.ts +62 -0
- package/dist/agent-run-api/finalization-store.d.ts.map +1 -0
- package/dist/agent-run-api/finalization-store.js +126 -0
- package/dist/agent-run-api/finalization-store.js.map +1 -0
- package/dist/agent-run-api/git-finalize.d.ts +98 -0
- package/dist/agent-run-api/git-finalize.d.ts.map +1 -0
- package/dist/agent-run-api/git-finalize.js +639 -0
- package/dist/agent-run-api/git-finalize.js.map +1 -0
- package/dist/agent-run-api/host.d.ts +10 -0
- package/dist/agent-run-api/host.d.ts.map +1 -0
- package/dist/agent-run-api/host.js +27 -0
- package/dist/agent-run-api/host.js.map +1 -0
- package/dist/agent-run-api/run-index.d.ts +40 -0
- package/dist/agent-run-api/run-index.d.ts.map +1 -0
- package/dist/agent-run-api/run-index.js +69 -0
- package/dist/agent-run-api/run-index.js.map +1 -0
- package/dist/audit/store.d.ts +22 -3
- package/dist/audit/store.d.ts.map +1 -1
- package/dist/audit/store.js +67 -6
- package/dist/audit/store.js.map +1 -1
- package/dist/auth/client-grants.d.ts +28 -3
- package/dist/auth/client-grants.d.ts.map +1 -1
- package/dist/auth/client-grants.js +40 -10
- package/dist/auth/client-grants.js.map +1 -1
- package/dist/auth/hosted-mode.d.ts +2 -0
- package/dist/auth/hosted-mode.d.ts.map +1 -1
- package/dist/auth/hosted-mode.js +27 -1
- package/dist/auth/hosted-mode.js.map +1 -1
- package/dist/routes/agent-grants.d.ts.map +1 -1
- package/dist/routes/agent-grants.js +63 -1
- package/dist/routes/agent-grants.js.map +1 -1
- package/dist/routes/agent-runs.d.ts +40 -0
- package/dist/routes/agent-runs.d.ts.map +1 -0
- package/dist/routes/agent-runs.js +755 -0
- package/dist/routes/agent-runs.js.map +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +6 -0
- package/dist/server/index.js.map +1 -1
- package/dist/trusted-session/auth.d.ts +12 -1
- package/dist/trusted-session/auth.d.ts.map +1 -1
- package/dist/trusted-session/auth.js +1 -0
- package/dist/trusted-session/auth.js.map +1 -1
- package/dist/trusted-session/policy-hook.d.ts.map +1 -1
- package/dist/trusted-session/policy-hook.js +25 -9
- package/dist/trusted-session/policy-hook.js.map +1 -1
- package/dist/trusted-session/route-policy-registry.d.ts.map +1 -1
- package/dist/trusted-session/route-policy-registry.js +11 -0
- package/dist/trusted-session/route-policy-registry.js.map +1 -1
- package/package.json +13 -2
- package/static-ui/assets/{index-ynIby2JK.js → index-eHjUHhT-.js} +58 -58
- package/static-ui/index.html +1 -1
|
@@ -29,8 +29,8 @@ Error generating stack: `+e.message+`
|
|
|
29
29
|
${r?`hover:scale-110 hover:rotate-0`:`hover:scale-105`}
|
|
30
30
|
`,style:{borderColor:p,boxShadow:`0 0 20px ${p}20`},children:[(0,H.jsx)(Xl,{warnings:l}),t&&(0,H.jsx)(ru,{}),(0,H.jsx)(`div`,{className:`absolute top-1 left-1 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:p},children:`PB`})}),(0,H.jsx)(`div`,{className:`absolute bottom-1 right-1 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:p},children:`PB`})}),(0,H.jsx)(tu,{usage:u,createdAt:e.createdAt,color:p,onDelete:t=>{t.stopPropagation(),window.confirm(`Delete playbook "${e.title}"?`)&&g.mutate()},deleteTitle:`Delete ${e.title}`}),(0,H.jsxs)(`div`,{className:`absolute inset-x-2 top-6 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`mb-2`,style:{color:p},children:(0,H.jsx)(di,{className:`h-7 w-7`,strokeWidth:2.25})}),(0,H.jsx)(`h3`,{className:`font-bold text-xs mb-1 line-clamp-2`,style:{color:p},children:e.title}),(0,H.jsxs)(`div`,{className:`text-[8px] px-1 py-0.5 rounded border opacity-70`,style:{color:p,borderColor:p},children:[`Playbook`,m>0?` · ${m} deps`:``]})]}),(0,H.jsx)(`div`,{className:`absolute bottom-6 inset-x-1`,children:(0,H.jsx)(K,{size:`sm`,className:`w-full text-[8px] px-1 py-1 h-5 bg-black/20 hover:bg-black/40 border`,style:{color:p,borderColor:p},onClick:e=>{e.stopPropagation(),h.mutate()},disabled:t||h.isPending||!n,children:t?`IN DECK`:`ADD`})}),(0,H.jsx)(`div`,{className:`absolute inset-0 rounded-lg bg-gradient-to-br from-transparent via-white/5 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-500 pointer-events-none`})]})})}var du=(0,b.memo)(uu),fu=64,pu=4,mu=12,hu=1.08;function gu(e=mu,t=hu){let n=e*Math.PI/180,r=128*Math.sin(n)+192*Math.cos(n);return Math.ceil(r*t)+8}var _u=gu();function vu(e,t=48){return e===0?0:128+Math.max(0,e-1)*(128-t)}function yu(e=10,t=48,n=12){return vu(e,t)+2*n}function bu(e,t=48){return vu(e,t)+24}var xu=yu();function Su(e,t,n,r=mu){let i=t+n/2,a=n/2;if(a<=0)return 0;let o=(e-i)/a;return Math.max(-r,Math.min(r,o*r))}function Cu(e){return{flexShrink:0,marginLeft:e===0?0:`-48px`}}function wu(e,t,n){return n===e?999999:t-e}function Tu({cardCount:e,children:t}){let n=(0,b.useRef)(null),r=(0,b.useRef)([]),i=(0,b.useRef)(0),a=(0,b.useRef)(void 0),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(!1),g=(0,b.useRef)(!1),_=(0,b.useRef)(!1),[v,y]=(0,b.useState)(null),x=(0,b.useRef)(null);x.current=v;let S=(0,b.useCallback)(()=>{let t=n.current;if(!t)return;let i=t.getBoundingClientRect(),a=x.current;r.current.forEach((t,n)=>{if(!t)return;let r=t.getBoundingClientRect(),o=r.left+r.width/2,s=a===n?0:Su(o,i.left,i.width),c=a===n?hu:1;t.style.transform=`rotate(${s}deg) scale(${c})`,t.style.transformOrigin=`center center`,t.style.zIndex=String(wu(n,e,a))})},[e]),C=(0,b.useCallback)(e=>{let t=n.current;t&&t.scrollBy({left:e===`left`?-80:80,behavior:`smooth`})},[]),w=(0,b.useCallback)(()=>{let t=n.current;if(!t)return;let r=bu(e,48)>t.clientWidth+2;s(r),l(r&&t.scrollLeft>4),d(r&&t.scrollLeft+t.clientWidth<t.scrollWidth-4),S()},[e,S]);(0,b.useLayoutEffect)(()=>{let e=n.current;if(!e)return;w();let t=new ResizeObserver(w);return t.observe(e),e.addEventListener(`scroll`,w,{passive:!0}),()=>{t.disconnect(),e.removeEventListener(`scroll`,w)}},[e,w]),(0,b.useEffect)(()=>{let e=()=>{let t=n.current,r=i.current;if(t&&r!==0){t.scrollLeft+=r,S();let e=t.scrollLeft>4,n=t.scrollLeft+t.clientWidth<t.scrollWidth-4;l(e),d(n)}let o=r<0,s=r>0;o!==g.current&&(g.current=o,p(o)),s!==_.current&&(_.current=s,h(s)),a.current=requestAnimationFrame(e)};return a.current=requestAnimationFrame(e),()=>{a.current!==void 0&&cancelAnimationFrame(a.current)}},[S]);let T=e=>{let t=n.current;if(!t||!o){i.current=0;return}let r=t.getBoundingClientRect(),a=e.clientX-r.left;if(a<fu&&c){let e=1-a/fu;i.current=-(pu+e*10)}else if(a>r.width-fu&&u){let e=1-(r.width-a)/fu;i.current=pu+e*10}else i.current=0;S()},E=()=>{i.current=0,g.current=!1,_.current=!1,p(!1),h(!1)};if((0,b.useLayoutEffect)(()=>{r.current.length=e,S()},[e,v,S]),e===0)return(0,H.jsx)(H.Fragment,{children:t});let D=(e,t)=>`absolute ${e===`left`?`left-2`:`right-2`} top-1/2 z-30 -translate-y-1/2 rounded-full bg-gray-950/90 p-1.5 text-yellow-300 shadow-lg ring-1 ring-black/50 transition-all duration-150 hover:bg-gray-950 hover:ring-yellow-300/40 ${t?`scale-110`:`scale-100`}`;return(0,H.jsxs)(`div`,{className:`relative flex h-full w-full min-w-0 max-w-full items-center justify-center overflow-hidden`,"data-testid":`deck-fan`,onMouseMove:T,onMouseLeave:E,children:[o&&c&&(0,H.jsx)(`button`,{type:`button`,className:D(`left`,f),"aria-label":`Scroll deck left`,"data-testid":`deck-scroll-left`,onClick:()=>C(`left`),children:(0,H.jsx)(gi,{className:`h-6 w-6`,strokeWidth:2.5})}),o&&u&&(0,H.jsx)(`button`,{type:`button`,className:D(`right`,m),"aria-label":`Scroll deck right`,"data-testid":`deck-scroll-right`,onClick:()=>C(`right`),children:(0,H.jsx)(_i,{className:`h-6 w-6`,strokeWidth:2.5})}),(0,H.jsx)(`div`,{ref:n,className:`max-w-full overflow-x-auto overflow-y-visible [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,style:{width:xu,maxWidth:`100%`},children:(0,H.jsx)(`div`,{className:`flex items-center justify-start isolate group/fan`,style:{minHeight:_u,paddingLeft:12,paddingRight:12},children:b.Children.map(t,(e,t)=>(0,H.jsx)(`div`,{ref:e=>{r.current[t]=e},className:`relative flex items-center justify-center transition-[transform,box-shadow] duration-500 will-change-transform`,style:{...Cu(t),minHeight:_u},onMouseEnter:()=>y(t),onMouseLeave:()=>y(null),children:e},e&&typeof e==`object`&&`key`in e?e.key:t))})})]})}var Eu=b.forwardRef(({className:e,type:t,...n},r)=>(0,H.jsx)(`input`,{type:t,className:Ja(`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,e),ref:r,...n}));Eu.displayName=`Input`;var Du=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getParsedType=e.ZodParsedType=e.objectUtil=e.util=void 0;var t;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(t||(e.util=t={}));var n;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(n||(e.objectUtil=n={})),e.ZodParsedType=t.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),e.getParsedType=t=>{switch(typeof t){case`undefined`:return e.ZodParsedType.undefined;case`string`:return e.ZodParsedType.string;case`number`:return Number.isNaN(t)?e.ZodParsedType.nan:e.ZodParsedType.number;case`boolean`:return e.ZodParsedType.boolean;case`function`:return e.ZodParsedType.function;case`bigint`:return e.ZodParsedType.bigint;case`symbol`:return e.ZodParsedType.symbol;case`object`:return Array.isArray(t)?e.ZodParsedType.array:t===null?e.ZodParsedType.null:t.then&&typeof t.then==`function`&&t.catch&&typeof t.catch==`function`?e.ZodParsedType.promise:typeof Map<`u`&&t instanceof Map?e.ZodParsedType.map:typeof Set<`u`&&t instanceof Set?e.ZodParsedType.set:typeof Date<`u`&&t instanceof Date?e.ZodParsedType.date:e.ZodParsedType.object;default:return e.ZodParsedType.unknown}}})),Ou=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ZodError=e.quotelessJson=e.ZodIssueCode=void 0;var t=Du();e.ZodIssueCode=t.util.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),e.quotelessJson=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`);var n=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,t.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};e.ZodError=n,n.create=e=>new n(e)})),ku=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Ou(),n=Du();e.default=(e,r)=>{let i;switch(e.code){case t.ZodIssueCode.invalid_type:i=e.received===n.ZodParsedType.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case t.ZodIssueCode.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(e.expected,n.util.jsonStringifyReplacer)}`;break;case t.ZodIssueCode.unrecognized_keys:i=`Unrecognized key(s) in object: ${n.util.joinValues(e.keys,`, `)}`;break;case t.ZodIssueCode.invalid_union:i=`Invalid input`;break;case t.ZodIssueCode.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${n.util.joinValues(e.options)}`;break;case t.ZodIssueCode.invalid_enum_value:i=`Invalid enum value. Expected ${n.util.joinValues(e.options)}, received '${e.received}'`;break;case t.ZodIssueCode.invalid_arguments:i=`Invalid function arguments`;break;case t.ZodIssueCode.invalid_return_type:i=`Invalid function return type`;break;case t.ZodIssueCode.invalid_date:i=`Invalid date`;break;case t.ZodIssueCode.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(i=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(i=`${i} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?i=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?i=`Invalid input: must end with "${e.validation.endsWith}"`:n.util.assertNever(e.validation):i=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case t.ZodIssueCode.too_small:i=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case t.ZodIssueCode.too_big:i=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case t.ZodIssueCode.custom:i=`Invalid input`;break;case t.ZodIssueCode.invalid_intersection_types:i=`Intersection results could not be merged`;break;case t.ZodIssueCode.not_multiple_of:i=`Number must be a multiple of ${e.multipleOf}`;break;case t.ZodIssueCode.not_finite:i=`Number must be finite`;break;default:i=r.defaultError,n.util.assertNever(e)}return{message:i}}})),Au=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.defaultErrorMap=void 0,e.setErrorMap=i,e.getErrorMap=a;var n=t(ku());e.defaultErrorMap=n.default;var r=n.default;function i(e){r=e}function a(){return r}})),ju=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.isAsync=e.isValid=e.isDirty=e.isAborted=e.OK=e.DIRTY=e.INVALID=e.ParseStatus=e.EMPTY_PATH=e.makeIssue=void 0,e.addIssueToContext=i;var n=Au(),r=t(ku());e.makeIssue=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},e.EMPTY_PATH=[];function i(t,i){let a=(0,n.getErrorMap)(),o=(0,e.makeIssue)({issueData:i,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,a,a===r.default?void 0:r.default].filter(e=>!!e)});t.common.issues.push(o)}e.ParseStatus=class t{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(t,n){let r=[];for(let i of n){if(i.status===`aborted`)return e.INVALID;i.status===`dirty`&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return t.mergeObjectSync(e,r)}static mergeObjectSync(t,n){let r={};for(let i of n){let{key:n,value:a}=i;if(n.status===`aborted`||a.status===`aborted`)return e.INVALID;n.status===`dirty`&&t.dirty(),a.status===`dirty`&&t.dirty(),n.value!==`__proto__`&&(a.value!==void 0||i.alwaysSet)&&(r[n.value]=a.value)}return{status:t.value,value:r}}},e.INVALID=Object.freeze({status:`aborted`}),e.DIRTY=e=>({status:`dirty`,value:e}),e.OK=e=>({status:`valid`,value:e}),e.isAborted=e=>e.status===`aborted`,e.isDirty=e=>e.status===`dirty`,e.isValid=e=>e.status===`valid`,e.isAsync=e=>typeof Promise<`u`&&e instanceof Promise})),Mu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),Nu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.errorUtil=void 0;var t;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(t||(e.errorUtil=t={}))})),Pu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.discriminatedUnion=e.date=e.boolean=e.bigint=e.array=e.any=e.coerce=e.ZodFirstPartyTypeKind=e.late=e.ZodSchema=e.Schema=e.ZodReadonly=e.ZodPipeline=e.ZodBranded=e.BRAND=e.ZodNaN=e.ZodCatch=e.ZodDefault=e.ZodNullable=e.ZodOptional=e.ZodTransformer=e.ZodEffects=e.ZodPromise=e.ZodNativeEnum=e.ZodEnum=e.ZodLiteral=e.ZodLazy=e.ZodFunction=e.ZodSet=e.ZodMap=e.ZodRecord=e.ZodTuple=e.ZodIntersection=e.ZodDiscriminatedUnion=e.ZodUnion=e.ZodObject=e.ZodArray=e.ZodVoid=e.ZodNever=e.ZodUnknown=e.ZodAny=e.ZodNull=e.ZodUndefined=e.ZodSymbol=e.ZodDate=e.ZodBoolean=e.ZodBigInt=e.ZodNumber=e.ZodString=e.ZodType=void 0,e.NEVER=e.void=e.unknown=e.union=e.undefined=e.tuple=e.transformer=e.symbol=e.string=e.strictObject=e.set=e.record=e.promise=e.preprocess=e.pipeline=e.ostring=e.optional=e.onumber=e.oboolean=e.object=e.number=e.nullable=e.null=e.never=e.nativeEnum=e.nan=e.map=e.literal=e.lazy=e.intersection=e.instanceof=e.function=e.enum=e.effect=void 0,e.datetimeRegex=A,e.custom=Fe;var t=Ou(),n=Au(),r=Nu(),i=ju(),a=Du(),o=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},s=(e,n)=>{if((0,i.isValid)(n))return{success:!0,data:n.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let n=new t.ZodError(e.common.issues);return this._error=n,this._error}}};function c(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var l=class{get description(){return this._def.description}_getType(e){return(0,a.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0,a.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new i.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,a.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if((0,i.isAsync)(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,a.getParsedType)(e)};return s(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,a.getParsedType)(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return(0,i.isValid)(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>(0,i.isValid)(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,a.getParsedType)(e)},r=this._parse({data:e,path:n.path,parent:n});return s(n,await((0,i.isAsync)(r)?r:Promise.resolve(r)))}refine(e,n){let r=e=>typeof n==`string`||n===void 0?{message:n}:typeof n==`function`?n(e):n;return this._refinement((n,i)=>{let a=e(n),o=()=>i.addIssue({code:t.ZodIssueCode.custom,...r(n)});return typeof Promise<`u`&&a instanceof Promise?a.then(e=>e?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Te({schema:this,typeName:V.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Ee.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return oe.create(this)}promise(){return we.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return pe.create(this,e,this._def)}transform(e){return new Te({...c(this._def),schema:this,typeName:V.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Oe({...c(this._def),innerType:this,defaultValue:t,typeName:V.ZodDefault})}brand(){return new je({typeName:V.ZodBranded,type:this,...c(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ke({...c(this._def),innerType:this,catchValue:t,typeName:V.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return Ne.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};e.ZodType=l,e.Schema=l,e.ZodSchema=l;var u=/^c[^\s-]{8,}$/i,d=/^[0-9a-z]+$/,f=/^[0-9A-HJKMNP-TV-Z]{26}$/i,p=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,m=/^[a-z0-9_-]{21}$/i,h=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,g=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,v=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,y,b=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,x=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,S=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,C=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,w=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,T=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,E=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,D=RegExp(`^${E}$`);function O(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function k(e){return RegExp(`^${O(e)}$`)}function A(e){let t=`${E}T${O(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function j(e,t){return!((t!==`v4`&&t||!b.test(e))&&(t!==`v6`&&t||!S.test(e)))}function M(e,t){if(!h.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function N(e,t){return!((t!==`v4`&&t||!x.test(e))&&(t!==`v6`&&t||!C.test(e)))}var P=class e extends l{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==a.ZodParsedType.string){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.string,received:n.parsedType}),i.INVALID}let n=new i.ParseStatus,r;for(let o of this._def.checks)if(o.kind===`min`)e.data.length<o.value&&(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_small,minimum:o.value,type:`string`,inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind===`max`)e.data.length>o.value&&(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_big,maximum:o.value,type:`string`,inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind===`length`){let a=e.data.length>o.value,s=e.data.length<o.value;(a||s)&&(r=this._getOrReturnCtx(e,r),a?(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_big,maximum:o.value,type:`string`,inclusive:!0,exact:!0,message:o.message}):s&&(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_small,minimum:o.value,type:`string`,inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind===`email`)_.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`email`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind===`emoji`)y||=new RegExp(v,`u`),y.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`emoji`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind===`uuid`)p.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`uuid`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind===`nanoid`)m.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`nanoid`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind===`cuid`)u.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`cuid`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind===`cuid2`)d.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`cuid2`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind===`ulid`)f.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`ulid`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty());else if(o.kind===`url`)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`url`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty()}else o.kind===`regex`?(o.regex.lastIndex=0,o.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`regex`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty())):o.kind===`trim`?e.data=e.data.trim():o.kind===`includes`?e.data.includes(o.value,o.position)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind===`toLowerCase`?e.data=e.data.toLowerCase():o.kind===`toUpperCase`?e.data=e.data.toUpperCase():o.kind===`startsWith`?e.data.startsWith(o.value)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind===`endsWith`?e.data.endsWith(o.value)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind===`datetime`?A(o).test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_string,validation:`datetime`,message:o.message}),n.dirty()):o.kind===`date`?D.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_string,validation:`date`,message:o.message}),n.dirty()):o.kind===`time`?k(o).test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_string,validation:`time`,message:o.message}),n.dirty()):o.kind===`duration`?g.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`duration`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty()):o.kind===`ip`?j(e.data,o.version)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`ip`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty()):o.kind===`jwt`?M(e.data,o.alg)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`jwt`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty()):o.kind===`cidr`?N(e.data,o.version)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`cidr`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty()):o.kind===`base64`?w.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`base64`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty()):o.kind===`base64url`?T.test(e.data)||(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{validation:`base64url`,code:t.ZodIssueCode.invalid_string,message:o.message}),n.dirty()):a.util.assertNever(o);return{status:n.value,value:e.data}}_regex(e,n,i){return this.refinement(t=>e.test(t),{validation:n,code:t.ZodIssueCode.invalid_string,...r.errorUtil.errToObj(i)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...r.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...r.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...r.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...r.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...r.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...r.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...r.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...r.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...r.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...r.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...r.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...r.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...r.errorUtil.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...r.errorUtil.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...r.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...r.errorUtil.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...r.errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...r.errorUtil.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...r.errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...r.errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...r.errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...r.errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...r.errorUtil.errToObj(t)})}nonempty(e){return this.min(1,r.errorUtil.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};e.ZodString=P,P.create=e=>new P({checks:[],typeName:V.ZodString,coerce:e?.coerce??!1,...c(e)});function F(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var I=class e extends l{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==a.ZodParsedType.number){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.number,received:n.parsedType}),i.INVALID}let n,r=new i.ParseStatus;for(let o of this._def.checks)o.kind===`int`?a.util.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:`integer`,received:`float`,message:o.message}),r.dirty()):o.kind===`min`?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.too_small,minimum:o.value,type:`number`,inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind===`max`?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.too_big,maximum:o.value,type:`number`,inclusive:o.inclusive,exact:!1,message:o.message}),r.dirty()):o.kind===`multipleOf`?F(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):o.kind===`finite`?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.not_finite,message:o.message}),r.dirty()):a.util.assertNever(o);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,r.errorUtil.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,r.errorUtil.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,r.errorUtil.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,r.errorUtil.toString(t))}setLimit(t,n,i,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:i,message:r.errorUtil.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:r.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:r.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:r.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:r.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:r.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:r.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:r.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:r.errorUtil.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:r.errorUtil.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&a.util.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};e.ZodNumber=I,I.create=e=>new I({checks:[],typeName:V.ZodNumber,coerce:e?.coerce||!1,...c(e)});var L=class e extends l{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==a.ZodParsedType.bigint)return this._getInvalidInput(e);let n,r=new i.ParseStatus;for(let o of this._def.checks)o.kind===`min`?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.too_small,type:`bigint`,minimum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind===`max`?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.too_big,type:`bigint`,maximum:o.value,inclusive:o.inclusive,message:o.message}),r.dirty()):o.kind===`multipleOf`?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.not_multiple_of,multipleOf:o.value,message:o.message}),r.dirty()):a.util.assertNever(o);return{status:r.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.bigint,received:n.parsedType}),i.INVALID}gte(e,t){return this.setLimit(`min`,e,!0,r.errorUtil.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,r.errorUtil.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,r.errorUtil.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,r.errorUtil.toString(t))}setLimit(t,n,i,a){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:i,message:r.errorUtil.toString(a)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:r.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:r.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:r.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:r.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:r.errorUtil.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};e.ZodBigInt=L,L.create=e=>new L({checks:[],typeName:V.ZodBigInt,coerce:e?.coerce??!1,...c(e)});var ee=class extends l{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==a.ZodParsedType.boolean){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.boolean,received:n.parsedType}),i.INVALID}return(0,i.OK)(e.data)}};e.ZodBoolean=ee,ee.create=e=>new ee({typeName:V.ZodBoolean,coerce:e?.coerce||!1,...c(e)});var te=class e extends l{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==a.ZodParsedType.date){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.date,received:n.parsedType}),i.INVALID}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_date}),i.INVALID}let n=new i.ParseStatus,r;for(let o of this._def.checks)o.kind===`min`?e.data.getTime()<o.value&&(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:`date`}),n.dirty()):o.kind===`max`?e.data.getTime()>o.value&&(r=this._getOrReturnCtx(e,r),(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:`date`}),n.dirty()):a.util.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:r.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:r.errorUtil.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};e.ZodDate=te,te.create=e=>new te({checks:[],coerce:e?.coerce||!1,typeName:V.ZodDate,...c(e)});var ne=class extends l{_parse(e){if(this._getType(e)!==a.ZodParsedType.symbol){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.symbol,received:n.parsedType}),i.INVALID}return(0,i.OK)(e.data)}};e.ZodSymbol=ne,ne.create=e=>new ne({typeName:V.ZodSymbol,...c(e)});var R=class extends l{_parse(e){if(this._getType(e)!==a.ZodParsedType.undefined){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.undefined,received:n.parsedType}),i.INVALID}return(0,i.OK)(e.data)}};e.ZodUndefined=R,R.create=e=>new R({typeName:V.ZodUndefined,...c(e)});var z=class extends l{_parse(e){if(this._getType(e)!==a.ZodParsedType.null){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.null,received:n.parsedType}),i.INVALID}return(0,i.OK)(e.data)}};e.ZodNull=z,z.create=e=>new z({typeName:V.ZodNull,...c(e)});var B=class extends l{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,i.OK)(e.data)}};e.ZodAny=B,B.create=e=>new B({typeName:V.ZodAny,...c(e)});var re=class extends l{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,i.OK)(e.data)}};e.ZodUnknown=re,re.create=e=>new re({typeName:V.ZodUnknown,...c(e)});var ie=class extends l{_parse(e){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.never,received:n.parsedType}),i.INVALID}};e.ZodNever=ie,ie.create=e=>new ie({typeName:V.ZodNever,...c(e)});var ae=class extends l{_parse(e){if(this._getType(e)!==a.ZodParsedType.undefined){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.void,received:n.parsedType}),i.INVALID}return(0,i.OK)(e.data)}};e.ZodVoid=ae,ae.create=e=>new ae({typeName:V.ZodVoid,...c(e)});var oe=class e extends l{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==a.ZodParsedType.array)return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.array,received:n.parsedType}),i.INVALID;if(s.exactLength!==null){let e=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(e||a)&&((0,i.addIssueToContext)(n,{code:e?t.ZodIssueCode.too_big:t.ZodIssueCode.too_small,minimum:a?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&((0,i.addIssueToContext)(n,{code:t.ZodIssueCode.too_small,minimum:s.minLength.value,type:`array`,inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&((0,i.addIssueToContext)(n,{code:t.ZodIssueCode.too_big,maximum:s.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((e,t)=>s.type._parseAsync(new o(n,e,n.path,t)))).then(e=>i.ParseStatus.mergeArray(r,e));let c=[...n.data].map((e,t)=>s.type._parseSync(new o(n,e,n.path,t)));return i.ParseStatus.mergeArray(r,c)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:r.errorUtil.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:r.errorUtil.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:r.errorUtil.toString(n)}})}nonempty(e){return this.min(1,e)}};e.ZodArray=oe,oe.create=(e,t)=>new oe({type:e,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...c(t)});function se(e){if(e instanceof ce){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ee.create(se(r))}return new ce({...e._def,shape:()=>t})}return e instanceof oe?new oe({...e._def,type:se(e.element)}):e instanceof Ee?Ee.create(se(e.unwrap())):e instanceof De?De.create(se(e.unwrap())):e instanceof me?me.create(e.items.map(e=>se(e))):e}var ce=class e extends l{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=a.util.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==a.ZodParsedType.object){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.object,received:n.parsedType}),i.INVALID}let{status:n,ctx:r}=this._processInputParams(e),{shape:s,keys:c}=this._getCached(),l=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys===`strip`))for(let e in r.data)c.includes(e)||l.push(e);let u=[];for(let e of c){let t=s[e],n=r.data[e];u.push({key:{status:`valid`,value:e},value:t._parse(new o(r,n,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof ie){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of l)u.push({key:{status:`valid`,value:e},value:{status:`valid`,value:r.data[e]}});else if(e===`strict`)l.length>0&&((0,i.addIssueToContext)(r,{code:t.ZodIssueCode.unrecognized_keys,keys:l}),n.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of l){let n=r.data[t];u.push({key:{status:`valid`,value:t},value:e._parse(new o(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of u){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>i.ParseStatus.mergeObjectSync(n,e)):i.ParseStatus.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(t){return r.errorUtil.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let i=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:r.errorUtil.errToObj(t).message??i}:{message:i}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:V.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of a.util.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of a.util.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return se(this)}partial(t){let n={};for(let e of a.util.objectKeys(this.shape)){let r=this.shape[e];n[e]=t&&!t[e]?r:r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of a.util.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ee;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return xe(a.util.objectKeys(this.shape))}};e.ZodObject=ce,ce.create=(e,t)=>new ce({shape:()=>e,unknownKeys:`strip`,catchall:ie.create(),typeName:V.ZodObject,...c(t)}),ce.strictCreate=(e,t)=>new ce({shape:()=>e,unknownKeys:`strict`,catchall:ie.create(),typeName:V.ZodObject,...c(t)}),ce.lazycreate=(e,t)=>new ce({shape:e,unknownKeys:`strip`,catchall:ie.create(),typeName:V.ZodObject,...c(t)});var le=class extends l{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function a(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let t of e)if(t.result.status===`dirty`)return n.common.issues.push(...t.ctx.common.issues),t.result;let r=e.map(e=>new t.ZodError(e.ctx.common.issues));return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_union,unionErrors:r}),i.INVALID}if(n.common.async)return Promise.all(r.map(async e=>{let t={...n,common:{...n.common,issues:[]},parent:null};return{result:await e._parseAsync({data:n.data,path:n.path,parent:t}),ctx:t}})).then(a);{let e,a=[];for(let t of r){let r={...n,common:{...n.common,issues:[]},parent:null},i=t._parseSync({data:n.data,path:n.path,parent:r});if(i.status===`valid`)return i;i.status===`dirty`&&!e&&(e={result:i,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return n.common.issues.push(...e.ctx.common.issues),e.result;let o=a.map(e=>new t.ZodError(e));return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_union,unionErrors:o}),i.INVALID}}get options(){return this._def.options}};e.ZodUnion=le,le.create=(e,t)=>new le({options:e,typeName:V.ZodUnion,...c(t)});var ue=e=>e instanceof ye?ue(e.schema):e instanceof Te?ue(e.innerType()):e instanceof be?[e.value]:e instanceof Se?e.options:e instanceof Ce?a.util.objectValues(e.enum):e instanceof Oe?ue(e._def.innerType):e instanceof R?[void 0]:e instanceof z?[null]:e instanceof Ee?[void 0,...ue(e.unwrap())]:e instanceof De?[null,...ue(e.unwrap())]:e instanceof je||e instanceof Ne?ue(e.unwrap()):e instanceof ke?ue(e._def.innerType):[],de=class e extends l{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==a.ZodParsedType.object)return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.object,received:n.parsedType}),i.INVALID;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):((0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),i.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=ue(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:V.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...c(r)})}};e.ZodDiscriminatedUnion=de;function fe(e,t){let n=(0,a.getParsedType)(e),r=(0,a.getParsedType)(t);if(e===t)return{valid:!0,data:e};if(n===a.ZodParsedType.object&&r===a.ZodParsedType.object){let n=a.util.objectKeys(t),r=a.util.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=fe(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===a.ZodParsedType.array&&r===a.ZodParsedType.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=fe(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}return n===a.ZodParsedType.date&&r===a.ZodParsedType.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var pe=class extends l{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=(e,a)=>{if((0,i.isAborted)(e)||(0,i.isAborted)(a))return i.INVALID;let o=fe(e.value,a.value);return o.valid?(((0,i.isDirty)(e)||(0,i.isDirty)(a))&&n.dirty(),{status:n.value,value:o.data}):((0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_intersection_types}),i.INVALID)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>a(e,t)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};e.ZodIntersection=pe,pe.create=(e,t,n)=>new pe({left:e,right:t,typeName:V.ZodIntersection,...c(n)});var me=class e extends l{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.ZodParsedType.array)return(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.array,received:r.parsedType}),i.INVALID;if(r.data.length<this._def.items.length)return(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),i.INVALID;!this._def.rest&&r.data.length>this._def.items.length&&((0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),n.dirty());let s=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new o(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(s).then(e=>i.ParseStatus.mergeArray(n,e)):i.ParseStatus.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};e.ZodTuple=me,me.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new me({items:e,typeName:V.ZodTuple,rest:null,...c(t)})};var he=class e extends l{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.ZodParsedType.object)return(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.object,received:r.parsedType}),i.INVALID;let s=[],c=this._def.keyType,l=this._def.valueType;for(let e in r.data)s.push({key:c._parse(new o(r,e,r.path,e)),value:l._parse(new o(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?i.ParseStatus.mergeObjectAsync(n,s):i.ParseStatus.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof l?new e({keyType:t,valueType:n,typeName:V.ZodRecord,...c(r)}):new e({keyType:P.create(),valueType:t,typeName:V.ZodRecord,...c(n)})}};e.ZodRecord=he;var ge=class extends l{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.ZodParsedType.map)return(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.map,received:r.parsedType}),i.INVALID;let s=this._def.keyType,c=this._def.valueType,l=[...r.data.entries()].map(([e,t],n)=>({key:s._parse(new o(r,e,r.path,[n,`key`])),value:c._parse(new o(r,t,r.path,[n,`value`]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let t of l){let r=await t.key,a=await t.value;if(r.status===`aborted`||a.status===`aborted`)return i.INVALID;(r.status===`dirty`||a.status===`dirty`)&&n.dirty(),e.set(r.value,a.value)}return{status:n.value,value:e}})}{let e=new Map;for(let t of l){let r=t.key,a=t.value;if(r.status===`aborted`||a.status===`aborted`)return i.INVALID;(r.status===`dirty`||a.status===`dirty`)&&n.dirty(),e.set(r.value,a.value)}return{status:n.value,value:e}}}};e.ZodMap=ge,ge.create=(e,t,n)=>new ge({valueType:t,keyType:e,typeName:V.ZodMap,...c(n)});var _e=class e extends l{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.ZodParsedType.set)return(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.set,received:r.parsedType}),i.INVALID;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&((0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_small,minimum:s.minSize.value,type:`set`,inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&((0,i.addIssueToContext)(r,{code:t.ZodIssueCode.too_big,maximum:s.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let c=this._def.valueType;function l(e){let t=new Set;for(let r of e){if(r.status===`aborted`)return i.INVALID;r.status===`dirty`&&n.dirty(),t.add(r.value)}return{status:n.value,value:t}}let u=[...r.data.values()].map((e,t)=>c._parse(new o(r,e,r.path,t)));return r.common.async?Promise.all(u).then(e=>l(e)):l(u)}min(t,n){return new e({...this._def,minSize:{value:t,message:r.errorUtil.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:r.errorUtil.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};e.ZodSet=_e,_e.create=(e,t)=>new _e({valueType:e,minSize:null,maxSize:null,typeName:V.ZodSet,...c(t)});var ve=class e extends l{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==a.ZodParsedType.function)return(0,i.addIssueToContext)(r,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.function,received:r.parsedType}),i.INVALID;function o(e,a){return(0,i.makeIssue)({data:e,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,n.getErrorMap)(),n.defaultErrorMap].filter(e=>!!e),issueData:{code:t.ZodIssueCode.invalid_arguments,argumentsError:a}})}function s(e,a){return(0,i.makeIssue)({data:e,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,n.getErrorMap)(),n.defaultErrorMap].filter(e=>!!e),issueData:{code:t.ZodIssueCode.invalid_return_type,returnTypeError:a}})}let c={errorMap:r.common.contextualErrorMap},l=r.data;if(this._def.returns instanceof we){let e=this;return(0,i.OK)(async function(...n){let r=new t.ZodError([]),i=await e._def.args.parseAsync(n,c).catch(e=>{throw r.addIssue(o(n,e)),r}),a=await Reflect.apply(l,this,i);return await e._def.returns._def.type.parseAsync(a,c).catch(e=>{throw r.addIssue(s(a,e)),r})})}{let e=this;return(0,i.OK)(function(...n){let r=e._def.args.safeParse(n,c);if(!r.success)throw new t.ZodError([o(n,r.error)]);let i=Reflect.apply(l,this,r.data),a=e._def.returns.safeParse(i,c);if(!a.success)throw new t.ZodError([s(i,a.error)]);return a.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:me.create(t).rest(re.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||me.create([]).rest(re.create()),returns:n||re.create(),typeName:V.ZodFunction,...c(r)})}};e.ZodFunction=ve;var ye=class extends l{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};e.ZodLazy=ye,ye.create=(e,t)=>new ye({getter:e,typeName:V.ZodLazy,...c(t)});var be=class extends l{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{received:n.data,code:t.ZodIssueCode.invalid_literal,expected:this._def.value}),i.INVALID}return{status:`valid`,value:e.data}}get value(){return this._def.value}};e.ZodLiteral=be,be.create=(e,t)=>new be({value:e,typeName:V.ZodLiteral,...c(t)});function xe(e,t){return new Se({values:e,typeName:V.ZodEnum,...c(t)})}var Se=class e extends l{_parse(e){if(typeof e.data!=`string`){let n=this._getOrReturnCtx(e),r=this._def.values;return(0,i.addIssueToContext)(n,{expected:a.util.joinValues(r),received:n.parsedType,code:t.ZodIssueCode.invalid_type}),i.INVALID}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return(0,i.addIssueToContext)(n,{received:n.data,code:t.ZodIssueCode.invalid_enum_value,options:r}),i.INVALID}return(0,i.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};e.ZodEnum=Se,Se.create=xe;var Ce=class extends l{_parse(e){let n=a.util.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==a.ZodParsedType.string&&r.parsedType!==a.ZodParsedType.number){let e=a.util.objectValues(n);return(0,i.addIssueToContext)(r,{expected:a.util.joinValues(e),received:r.parsedType,code:t.ZodIssueCode.invalid_type}),i.INVALID}if(this._cache||=new Set(a.util.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=a.util.objectValues(n);return(0,i.addIssueToContext)(r,{received:r.data,code:t.ZodIssueCode.invalid_enum_value,options:e}),i.INVALID}return(0,i.OK)(e.data)}get enum(){return this._def.values}};e.ZodNativeEnum=Ce,Ce.create=(e,t)=>new Ce({values:e,typeName:V.ZodNativeEnum,...c(t)});var we=class extends l{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==a.ZodParsedType.promise&&n.common.async===!1)return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.promise,received:n.parsedType}),i.INVALID;let r=n.parsedType===a.ZodParsedType.promise?n.data:Promise.resolve(n.data);return(0,i.OK)(r.then(e=>this._def.type.parseAsync(e,{path:n.path,errorMap:n.common.contextualErrorMap})))}};e.ZodPromise=we,we.create=(e,t)=>new we({type:e,typeName:V.ZodPromise,...c(t)});var Te=class extends l{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,o={addIssue:e=>{(0,i.addIssueToContext)(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),r.type===`preprocess`){let e=r.transform(n.data,o);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return i.INVALID;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?i.INVALID:r.status===`dirty`||t.value===`dirty`?(0,i.DIRTY)(r.value):r});{if(t.value===`aborted`)return i.INVALID;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?i.INVALID:r.status===`dirty`||t.value===`dirty`?(0,i.DIRTY)(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,o);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?i.INVALID:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?i.INVALID:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!(0,i.isValid)(e))return i.INVALID;let a=r.transform(e.value,o);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>(0,i.isValid)(e)?Promise.resolve(r.transform(e.value,o)).then(e=>({status:t.value,value:e})):i.INVALID)}a.util.assertNever(r)}};e.ZodEffects=Te,e.ZodTransformer=Te,Te.create=(e,t,n)=>new Te({schema:e,typeName:V.ZodEffects,effect:t,...c(n)}),Te.createWithPreprocess=(e,t,n)=>new Te({schema:t,effect:{type:`preprocess`,transform:e},typeName:V.ZodEffects,...c(n)});var Ee=class extends l{_parse(e){return this._getType(e)===a.ZodParsedType.undefined?(0,i.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};e.ZodOptional=Ee,Ee.create=(e,t)=>new Ee({innerType:e,typeName:V.ZodOptional,...c(t)});var De=class extends l{_parse(e){return this._getType(e)===a.ZodParsedType.null?(0,i.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};e.ZodNullable=De,De.create=(e,t)=>new De({innerType:e,typeName:V.ZodNullable,...c(t)});var Oe=class extends l{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===a.ZodParsedType.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};e.ZodDefault=Oe,Oe.create=(e,t)=>new Oe({innerType:e,typeName:V.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...c(t)});var ke=class extends l{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return(0,i.isAsync)(a)?a.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new t.ZodError(r.common.issues)},input:r.data})})):{status:`valid`,value:a.status===`valid`?a.value:this._def.catchValue({get error(){return new t.ZodError(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};e.ZodCatch=ke,ke.create=(e,t)=>new ke({innerType:e,typeName:V.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...c(t)});var Ae=class extends l{_parse(e){if(this._getType(e)!==a.ZodParsedType.nan){let n=this._getOrReturnCtx(e);return(0,i.addIssueToContext)(n,{code:t.ZodIssueCode.invalid_type,expected:a.ZodParsedType.nan,received:n.parsedType}),i.INVALID}return{status:`valid`,value:e.data}}};e.ZodNaN=Ae,Ae.create=e=>new Ae({typeName:V.ZodNaN,...c(e)}),e.BRAND=Symbol(`zod_brand`);var je=class extends l{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};e.ZodBranded=je;var Me=class e extends l{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?i.INVALID:e.status===`dirty`?(t.dirty(),(0,i.DIRTY)(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?i.INVALID:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:V.ZodPipeline})}};e.ZodPipeline=Me;var Ne=class extends l{_parse(e){let t=this._def.innerType._parse(e),n=e=>((0,i.isValid)(e)&&(e.value=Object.freeze(e.value)),e);return(0,i.isAsync)(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};e.ZodReadonly=Ne,Ne.create=(e,t)=>new Ne({innerType:e,typeName:V.ZodReadonly,...c(t)});function Pe(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function Fe(e,t={},n){return e?B.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=Pe(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=Pe(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):B.create()}e.late={object:ce.lazycreate};var V;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(V||(e.ZodFirstPartyTypeKind=V={})),e.instanceof=(e,t={message:`Input not instance of ${e.name}`})=>Fe(t=>t instanceof e,t);var Ie=P.create;e.string=Ie;var Le=I.create;e.number=Le,e.nan=Ae.create,e.bigint=L.create;var Re=ee.create;e.boolean=Re,e.date=te.create,e.symbol=ne.create,e.undefined=R.create,e.null=z.create,e.any=B.create,e.unknown=re.create,e.never=ie.create,e.void=ae.create,e.array=oe.create,e.object=ce.create,e.strictObject=ce.strictCreate,e.union=le.create,e.discriminatedUnion=de.create,e.intersection=pe.create,e.tuple=me.create,e.record=he.create,e.map=ge.create,e.set=_e.create,e.function=ve.create,e.lazy=ye.create,e.literal=be.create,e.enum=Se.create,e.nativeEnum=Ce.create,e.promise=we.create;var ze=Te.create;e.effect=ze,e.transformer=ze,e.optional=Ee.create,e.nullable=De.create,e.preprocess=Te.createWithPreprocess,e.pipeline=Me.create,e.ostring=()=>Ie().optional(),e.onumber=()=>Le().optional(),e.oboolean=()=>Re().optional(),e.coerce={string:(e=>P.create({...e,coerce:!0})),number:(e=>I.create({...e,coerce:!0})),boolean:(e=>ee.create({...e,coerce:!0})),bigint:(e=>L.create({...e,coerce:!0})),date:(e=>te.create({...e,coerce:!0}))},e.NEVER=i.INVALID})),Fu=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(Au(),e),n(ju(),e),n(Mu(),e),n(Du(),e),n(Pu(),e),n(Ou(),e)})),Iu=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.z=void 0;var a=r(Fu());e.z=a,i(Fu(),e),e.default=a})),Lu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.LocalMCPServerProcessSchema=e.MCPServersManifestSchema=e.LocalMCPServerConfigSchema=e.ServiceCallResultSchema=e.ServiceToolErrorDetailsSchema=e.UpdateServiceToolSettingsSchema=e.ServiceToolSchema=e.ServiceCallSchema=e.UpdateServiceSchema=e.CreateServiceSchema=e.ServiceSchema=void 0;var t=Iu();e.ServiceSchema=t.z.object({id:t.z.string().uuid(),name:t.z.string().min(1,`Name is required`),type:t.z.enum([`mcp`,`a2a`,`local-mcp`]),url:t.z.string().url(`Valid URL is required`),health:t.z.enum([`unknown`,`healthy`,`unhealthy`]).default(`unknown`),description:t.z.string().optional(),cardColor:t.z.string().regex(/^#[0-9A-F]{6}$/i,`Valid hex color required`).default(`#92E4DD`),iconUrl:t.z.string().optional(),disabledToolNames:t.z.array(t.z.string()).default([]),isConnected:t.z.boolean().default(!1),lastPing:t.z.string().datetime().optional(),registeredAt:t.z.string().datetime(),updatedAt:t.z.string().datetime(),headers:t.z.record(t.z.string()).optional(),credentialId:t.z.string().optional(),oauthClientId:t.z.string().optional(),oauthClientSecret:t.z.string().optional(),oauthAuthorizationUrl:t.z.string().url().optional(),oauthTokenUrl:t.z.string().url().optional(),oauthRedirectUri:t.z.string().url().optional(),oauthScope:t.z.string().optional(),oauthAccessToken:t.z.string().optional(),oauthRefreshToken:t.z.string().optional(),oauthTokenExpiresAt:t.z.string().datetime().optional(),oauthHasToken:t.z.boolean().optional(),oauthState:t.z.string().optional(),localCommand:t.z.string().optional(),localArgs:t.z.array(t.z.string()).optional(),localWorkingDir:t.z.string().optional(),localEnv:t.z.record(t.z.string()).optional()}),e.CreateServiceSchema=e.ServiceSchema.omit({id:!0,health:!0,isConnected:!0,lastPing:!0,registeredAt:!0,updatedAt:!0,oauthAccessToken:!0,oauthRefreshToken:!0,oauthTokenExpiresAt:!0,oauthState:!0,disabledToolNames:!0}),e.UpdateServiceSchema=e.CreateServiceSchema.partial(),e.ServiceCallSchema=t.z.object({serviceId:t.z.string().uuid(`Valid service ID required`),toolName:t.z.string().min(1,`Tool name is required`),arguments:t.z.record(t.z.any()).optional()}),e.ServiceToolSchema=t.z.object({name:t.z.string().min(1,`Tool name is required`),title:t.z.string().optional(),description:t.z.string().min(1,`Tool description is required`),inputSchema:t.z.record(t.z.any()),enabled:t.z.boolean().optional()}),e.UpdateServiceToolSettingsSchema=t.z.object({disabledTools:t.z.array(t.z.string())}),e.ServiceToolErrorDetailsSchema=t.z.object({service_id:t.z.string(),service_name:t.z.string(),remote_url:t.z.string(),tool_name:t.z.string().optional(),cause:t.z.string(),phase:t.z.enum([`connect`,`discoverTools`,`callTool`]),hint:t.z.string().optional()}),e.ServiceCallResultSchema=t.z.object({success:t.z.boolean(),result:t.z.any().optional(),error:t.z.string().optional(),error_code:t.z.enum([`MCP_TRANSPORT_ERROR`,`MCP_AUTH_ERROR`,`MCP_TOOL_ERROR`,`MCP_CONNECTION_ERROR`]).optional(),details:e.ServiceToolErrorDetailsSchema.optional(),serviceName:t.z.string().optional(),toolName:t.z.string().optional()}),e.LocalMCPServerConfigSchema=t.z.object({command:t.z.string().min(1,`Command is required`),args:t.z.array(t.z.string()).optional().default([]),workingDir:t.z.string().optional(),env:t.z.record(t.z.string()).optional()}),e.MCPServersManifestSchema=t.z.object({mcpServers:t.z.record(t.z.string(),e.LocalMCPServerConfigSchema)}),e.LocalMCPServerProcessSchema=t.z.object({id:t.z.string(),serviceId:t.z.string(),process:t.z.any(),isRunning:t.z.boolean(),startTime:t.z.date(),lastActivity:t.z.date(),capabilities:t.z.object({tools:t.z.array(e.ServiceToolSchema),resources:t.z.array(t.z.any()),prompts:t.z.array(t.z.string())}).optional()})})),Ru=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExecRunSchema=e.RemoveCredentialFromDeckSchema=e.AddCredentialToDeckSchema=e.DeckCredentialSchema=e.RotateCredentialSchema=e.UpdateCredentialSchema=e.CreateCredentialSimpleSchema=e.CreateCredentialSchema=e.CredentialSchema=e.CredentialSchemeSchema=e.CredentialIdSchema=void 0;var t=Iu();e.CredentialIdSchema=t.z.string().regex(/^cred_[a-z0-9_]+$/,`Credential id must match cred_<slug> (lowercase letters, numbers, underscores)`),e.CredentialSchemeSchema=t.z.enum([`bearer`,`header`,`http_basic_user`]),e.CredentialSchema=t.z.object({id:e.CredentialIdSchema,label:t.z.string().min(1,`Label is required`),scheme:e.CredentialSchemeSchema,headerName:t.z.string().optional(),envName:t.z.string().regex(/^[A-Z_][A-Z0-9_]*$/,`env_name must be a valid environment variable name`),keychainAccount:t.z.string().min(1),tags:t.z.array(t.z.string()).default([]),docsUrl:t.z.string().url().optional(),iconUrl:t.z.string().optional(),hasSecret:t.z.boolean().default(!1),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}),e.CreateCredentialSchema=t.z.object({id:e.CredentialIdSchema,label:t.z.string().min(1,`Label is required`),scheme:e.CredentialSchemeSchema.default(`bearer`),headerName:t.z.string().optional(),envName:t.z.string().regex(/^[A-Z_][A-Z0-9_]*$/,`env_name must be a valid environment variable name`),keychainAccount:t.z.string().min(1).optional(),tags:t.z.array(t.z.string()).default([]),docsUrl:t.z.string().url().optional(),value:t.z.string().min(1,`Secret value is required`)}).superRefine((e,n)=>{e.scheme===`header`&&!e.headerName&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`headerName is required when scheme is header`,path:[`headerName`]})}),e.CreateCredentialSimpleSchema=t.z.object({label:t.z.string().min(1,`Name is required`),value:t.z.string().min(1,`API key is required`),docsUrl:t.z.string().url().optional()}),e.UpdateCredentialSchema=t.z.object({label:t.z.string().min(1).optional(),scheme:e.CredentialSchemeSchema.optional(),headerName:t.z.string().optional(),envName:t.z.string().regex(/^[A-Z_][A-Z0-9_]*$/).optional(),tags:t.z.array(t.z.string()).optional(),docsUrl:t.z.union([t.z.string().url(),t.z.literal(``)]).optional()}),e.RotateCredentialSchema=t.z.object({value:t.z.string().min(1,`Secret value is required`)}),e.DeckCredentialSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),credentialId:e.CredentialIdSchema,position:t.z.number().int().min(0,`Position must be non-negative`)}),e.AddCredentialToDeckSchema=e.DeckCredentialSchema.omit({position:!0}).extend({position:t.z.number().int().min(0).optional()}),e.RemoveCredentialFromDeckSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),credentialId:e.CredentialIdSchema}),e.ExecRunSchema=t.z.object({id:t.z.string().uuid(),deckId:t.z.string().uuid().optional(),manifestPath:t.z.string().optional(),command:t.z.string(),credentialIds:t.z.array(e.CredentialIdSchema),exitCode:t.z.number().int().optional(),startedAt:t.z.string().datetime(),finishedAt:t.z.string().datetime().optional()})})),zu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TriggerValidationError=e.TRIGGER_OVERLAP_JACCARD_THRESHOLD=e.MAX_TRIGGER_LENGTH=e.MAX_TRIGGERS_PER_PLAYBOOK=void 0,e.normalizeTrigger=t,e.triggerErrorMessage=i,e.assertTriggerCountPolicy=a,e.normalizeTriggers=o,e.detectTriggerConflicts=f,e.MAX_TRIGGERS_PER_PLAYBOOK=16,e.MAX_TRIGGER_LENGTH=80,e.TRIGGER_OVERLAP_JACCARD_THRESHOLD=.6;function t(e){return e.trim().replace(/\s+/g,` `)}var n=class extends Error{details;constructor(e,t){super(e),this.name=`TriggerValidationError`,this.details=t}};e.TriggerValidationError=n;var r=` Fix the trigger list and retry — do not ask the user to resolve this.`;function i(e,t){return!t&&e.details?.userMessage?e.details.userMessage:t&&e.details?.code===`TRIGGER_COUNT`?e.message.includes(`do not ask the user`)?e.message:`${e.message}${r}`:e.message}function a(t,i){if(i.mode===`create`){if(t<=e.MAX_TRIGGERS_PER_PLAYBOOK)return;throw new n(`At most ${e.MAX_TRIGGERS_PER_PLAYBOOK} triggers per playbook (got ${t}).`,{code:`TRIGGER_COUNT`,currentCount:t,maxCount:e.MAX_TRIGGERS_PER_PLAYBOOK,userMessage:`At most ${e.MAX_TRIGGERS_PER_PLAYBOOK} triggers per playbook. Remove extras before saving.`})}let{previousCount:a}=i;if(!(t<=e.MAX_TRIGGERS_PER_PLAYBOOK)&&!(t<=a)){if(a<=e.MAX_TRIGGERS_PER_PLAYBOOK){let i=`At most ${e.MAX_TRIGGERS_PER_PLAYBOOK} triggers per playbook. Remove extras before saving.`;throw new n(`${i}${r}`,{code:`TRIGGER_COUNT`,currentCount:t,maxCount:e.MAX_TRIGGERS_PER_PLAYBOOK,previousCount:a,userMessage:i})}throw new n(`Cannot grow triggers while over the ${e.MAX_TRIGGERS_PER_PLAYBOOK}-trigger guide (had ${a}, got ${t}). Keep count ≤ ${a}, or trim to ≤ ${e.MAX_TRIGGERS_PER_PLAYBOOK}.${r}`,{code:`TRIGGER_COUNT`,currentCount:t,maxCount:e.MAX_TRIGGERS_PER_PLAYBOOK,previousCount:a,userMessage:`Cannot add more triggers while this playbook already has ${a} (over the ${e.MAX_TRIGGERS_PER_PLAYBOOK} guide). Remove some first.`})}}function o(r,i={}){let a=new Set,o=[],s=i.maxCount===void 0?e.MAX_TRIGGERS_PER_PLAYBOOK:i.maxCount;for(let i of r){let r=t(i);if(!r)continue;if(r.length>e.MAX_TRIGGER_LENGTH)throw new n(`Trigger exceeds ${e.MAX_TRIGGER_LENGTH} characters: ${r.slice(0,24)}…`,{code:`TRIGGER_LENGTH`});let s=r.toLowerCase();a.has(s)||(a.add(s),o.push(r))}if(s!=null&&o.length>s){let e=`At most ${s} triggers per playbook. Remove extras before saving.`;throw new n(e,{code:`TRIGGER_COUNT`,currentCount:o.length,maxCount:s,userMessage:e})}return o}function s(e){return t(e).toLowerCase().split(/\s+/).filter(Boolean)}function c(e,t){let n=new Set(e),r=new Set(t),i=[...n].filter(e=>r.has(e)).length,a=new Set([...n,...r]).size;return a===0?0:i/a}function l(e,t){if(e.length===0||e.length>=t.length)return!1;let n=0;for(let r of t)if(r===e[n]&&(n+=1,n===e.length))return!0;return!1}function u(n,r){let i=t(n),a=t(r);if(!i||!a)return null;if(i.toLowerCase()===a.toLowerCase())return`exact`;let o=s(n),u=s(r);return l(o,u)||l(u,o)?`subsumes`:o.length>=2&&u.length>=2&&c(o,u)>=e.TRIGGER_OVERLAP_JACCARD_THRESHOLD?`overlap`:null}function d(e){return`${e.trigger}\0${e.otherPlaybookId}\0${e.level}`}function f(e,n){let r=[],i=new Set;for(let a of n)if(a.id!==e.id)for(let n of e.triggers)for(let e of a.triggers){let o=u(n,e);if(!o)continue;let s={trigger:t(n),otherPlaybookId:a.id,otherPlaybookTitle:a.title,otherTrigger:t(e),level:o},c=d(s);i.has(c)||(i.add(c),r.push(s))}return r}})),Bu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RemovePlaybookFromDeckSchema=e.AddPlaybookToDeckSchema=e.DeckPlaybookSchema=e.AgentUpdatePlaybookSchema=e.AgentRegisterPlaybookSchema=e.DashboardUpdatePlaybookSchema=e.DashboardRegisterPlaybookSchema=e.UpdatePlaybookSchema=e.CreatePlaybookSchema=e.PlaybookSchema=e.PlaybookIdSchema=e.PlaybookTriggersUpdateSchema=e.PlaybookTriggersSchema=void 0;var t=Iu(),n=zu();function r(e){return t.z.array(t.z.string()).transform((r,i)=>{try{return e===void 0?(0,n.normalizeTriggers)(r):(0,n.normalizeTriggers)(r,{maxCount:e})}catch(e){return i.addIssue({code:t.z.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid triggers`}),t.z.NEVER}}).default([])}e.PlaybookTriggersSchema=r(void 0),e.PlaybookTriggersUpdateSchema=r(null),e.PlaybookIdSchema=t.z.string().regex(/^pb_[a-z0-9_]+$/,`Playbook id must match pb_<slug>`),e.PlaybookSchema=t.z.object({id:e.PlaybookIdSchema,title:t.z.string().min(1,`Title is required`),body:t.z.string().default(``),triggers:e.PlaybookTriggersUpdateSchema,dependsOnCredentialIds:t.z.array(t.z.string()).default([]),dependsOnServiceIds:t.z.array(t.z.string()).default([]),exec:t.z.string().optional(),skill:t.z.string().optional(),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}),e.CreatePlaybookSchema=t.z.object({id:e.PlaybookIdSchema.optional(),title:t.z.string().min(1,`Title is required`),body:t.z.string().default(``),triggers:e.PlaybookTriggersSchema,dependsOnCredentialIds:t.z.array(t.z.string()).default([]),dependsOnServiceIds:t.z.array(t.z.string()).default([]),exec:t.z.string().optional(),skill:t.z.string().optional()}),e.UpdatePlaybookSchema=t.z.object({title:t.z.string().min(1,`Title is required`).optional(),body:t.z.string().optional(),triggers:e.PlaybookTriggersUpdateSchema.optional(),dependsOnCredentialIds:t.z.array(t.z.string()).optional(),dependsOnServiceIds:t.z.array(t.z.string()).optional(),exec:t.z.string().optional(),skill:t.z.string().optional()}),e.DashboardRegisterPlaybookSchema=e.CreatePlaybookSchema.extend({autoDetectDependencies:t.z.boolean().default(!0)}),e.DashboardUpdatePlaybookSchema=e.UpdatePlaybookSchema.extend({autoDetectDependencies:t.z.boolean().default(!0)}),e.AgentRegisterPlaybookSchema=e.CreatePlaybookSchema.extend({addToBoundDeck:t.z.boolean().default(!0),autoDetectDependencies:t.z.boolean().default(!0)}),e.AgentUpdatePlaybookSchema=e.UpdatePlaybookSchema.extend({autoDetectDependencies:t.z.boolean().default(!0)}),e.DeckPlaybookSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),playbookId:e.PlaybookIdSchema,position:t.z.number().int().min(0,`Position must be non-negative`)}),e.AddPlaybookToDeckSchema=e.DeckPlaybookSchema.omit({position:!0}).extend({position:t.z.number().int().min(0).optional()}),e.RemovePlaybookFromDeckSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),playbookId:e.PlaybookIdSchema})})),Vu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ReorderDeckServicesSchema=e.RemoveServiceFromDeckSchema=e.AddServiceToDeckSchema=e.DeckServiceSchema=e.UpdateDeckSchema=e.CreateDeckSchema=e.DeckSchema=e.OperatingInstructionsSchema=e.OPERATING_INSTRUCTIONS_MAX_LENGTH=void 0,e.normalizeOperatingInstructions=i;var t=Iu(),n=Ru(),r=Bu();e.OPERATING_INSTRUCTIONS_MAX_LENGTH=16e3;function i(e){return e===``||e===`
|
|
31
31
|
`?``:e.endsWith(`
|
|
32
|
-
`)?e:`${e}\n`}e.OperatingInstructionsSchema=t.z.string().transform(e=>i(e)).pipe(t.z.string().max(e.OPERATING_INSTRUCTIONS_MAX_LENGTH,`Deck operating instructions must be at most ${e.OPERATING_INSTRUCTIONS_MAX_LENGTH.toLocaleString(`en-US`)} characters`)),e.DeckSchema=t.z.object({id:t.z.string().uuid(),name:t.z.string().min(1,`Deck name is required`),isActive:t.z.boolean().default(!1),operatingInstructions:e.OperatingInstructionsSchema.default(``),services:t.z.array(t.z.any()).default([]),credentials:t.z.array(n.CredentialSchema).default([]),playbooks:t.z.array(r.PlaybookSchema).default([]),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}),e.CreateDeckSchema=e.DeckSchema.omit({id:!0,services:!0,createdAt:!0,updatedAt:!0}),e.UpdateDeckSchema=e.CreateDeckSchema.partial(),e.DeckServiceSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),serviceId:t.z.string().uuid(`Valid service ID required`),position:t.z.number().int().min(0,`Position must be non-negative`)}),e.AddServiceToDeckSchema=e.DeckServiceSchema.omit({position:!0}).extend({position:t.z.number().int().min(0).optional()}),e.RemoveServiceFromDeckSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),serviceId:t.z.string().uuid(`Valid service ID required`)}),e.ReorderDeckServicesSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),serviceIds:t.z.array(t.z.string().uuid(`Valid service ID required`)).min(1,`At least one service ID required`)})})),Hu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OAuthRefreshInputSchema=e.OAuthCallbackInputSchema=e.OAuthFlowInputSchema=e.OAuthTokenSchema=e.OAuthConfigSchema=void 0;var t=Iu();e.OAuthConfigSchema=t.z.object({clientId:t.z.string().min(1,`Client ID is required`),clientSecret:t.z.string().min(1,`Client secret is required`),authorizationUrl:t.z.string().url(`Valid authorization URL required`),tokenUrl:t.z.string().url(`Valid token URL required`),redirectUri:t.z.string().url(`Valid redirect URI required`),scope:t.z.string().min(1,`Scope is required`)}),e.OAuthTokenSchema=t.z.object({accessToken:t.z.string().min(1,`Access token is required`),refreshToken:t.z.string().optional(),expiresAt:t.z.string().datetime().optional(),tokenType:t.z.string().default(`Bearer`),scope:t.z.string().optional()}),e.OAuthFlowInputSchema=t.z.object({serviceId:t.z.string().uuid(`Valid service ID required`),redirectUri:t.z.string().url(`Valid redirect URI required`)}),e.OAuthCallbackInputSchema=t.z.object({serviceId:t.z.string().uuid(`Valid service ID required`),code:t.z.string().min(1,`Authorization code is required`),state:t.z.string().min(1,`State parameter is required`)}),e.OAuthRefreshInputSchema=t.z.object({serviceId:t.z.string().uuid(`Valid service ID required`),refreshToken:t.z.string().min(1,`Refresh token is required`)})})),Uu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RejectPlaybookPatchSchema=e.ProposePlaybookPatchSchema=e.CreatePlaybookPatchFieldsSchema=e.PatchOpSchema=e.BodyPatchOpSchema=e.RewriteBodyOpSchema=e.SetTriggersOpSchema=e.RemoveItemOpSchema=e.AmendItemOpSchema=e.AddItemOpSchema=e.PatchEvidenceSchema=e.PlaybookPatchSourceSchema=e.PlaybookPatchStatusSchema=e.ProposePlaybookPatchKindSchema=e.PlaybookPatchKindSchema=e.PlaybookPatchIdSchema=void 0;var t=Iu(),n=Bu();e.PlaybookPatchIdSchema=t.z.string().regex(/^pp_[a-z0-9_]+$/,`Patch id must match pp_<slug>`),e.PlaybookPatchKindSchema=t.z.enum([`create`,`update`,`merge`,`retire`]),e.ProposePlaybookPatchKindSchema=t.z.enum([`create`,`update`,`merge`,`retire`,`signal_only`]),e.PlaybookPatchStatusSchema=t.z.enum([`proposed`,`accepted`,`rejected`,`stale`,`superseded`]),e.PlaybookPatchSourceSchema=t.z.enum([`ide`,`dealer`,`hook`,`harvester`]),e.PatchEvidenceSchema=t.z.object({failure_summary:t.z.string().min(1),user_feedback_excerpt:t.z.string().min(1),corrected_output_hint:t.z.string().optional()}),e.AddItemOpSchema=t.z.object({op:t.z.literal(`add_item`).describe(`Append a bullet to a ## section (creates the section if missing)`),section:t.z.string().min(1).describe(`## heading name, e.g. Gotchas or Checklist`),text:t.z.string().min(1).describe(`Bullet text; a leading "- " is added when omitted`)}),e.AmendItemOpSchema=t.z.object({op:t.z.literal(`amend_item`).describe(`Replace one existing list item line (not prose paragraphs)`),section:t.z.string().min(1).describe(`## heading that contains the anchor line`),anchor:t.z.string().min(1).describe(`Exact list line to replace, including "- " prefix`),text:t.z.string().min(1).describe(`Replacement bullet text; leading "- " optional`)}),e.RemoveItemOpSchema=t.z.object({op:t.z.literal(`remove_item`).describe(`Delete one existing list item line (not prose paragraphs)`),section:t.z.string().min(1).describe(`## heading that contains the anchor line`),anchor:t.z.string().min(1).describe(`Exact list line to delete, including "- " prefix`)}),e.SetTriggersOpSchema=t.z.object({op:t.z.literal(`set_triggers`).describe(`Replace the playbook trigger phrases`),triggers:n.PlaybookTriggersUpdateSchema.describe(`New trigger list (count policy enforced against the current playbook)`)}),e.RewriteBodyOpSchema=t.z.object({op:t.z.literal(`rewrite_body`).describe(`Replace the entire playbook body — use only when item ops cannot reach the edit`),text:t.z.string().describe(`Full new markdown body`)}),e.BodyPatchOpSchema=t.z.discriminatedUnion(`op`,[e.AddItemOpSchema,e.AmendItemOpSchema,e.RemoveItemOpSchema,e.RewriteBodyOpSchema]),e.PatchOpSchema=t.z.discriminatedUnion(`op`,[e.AddItemOpSchema,e.AmendItemOpSchema,e.RemoveItemOpSchema,e.SetTriggersOpSchema,e.RewriteBodyOpSchema]),e.CreatePlaybookPatchFieldsSchema=t.z.object({title:t.z.string().min(1),body:t.z.string().default(``),triggers:n.PlaybookTriggersSchema.refine(e=>e.length>0,{message:`Genesis playbooks need at least one trigger`}),deck_id:t.z.string().uuid(),exec:t.z.string().optional(),skill:t.z.string().optional()}),e.ProposePlaybookPatchSchema=t.z.object({kind:e.ProposePlaybookPatchKindSchema,playbook_id:n.PlaybookIdSchema.optional(),ops:t.z.array(e.PatchOpSchema).optional(),new_playbook:e.CreatePlaybookPatchFieldsSchema.optional(),rationale:t.z.string().min(1),evidence:e.PatchEvidenceSchema.optional(),signal_ids:t.z.array(t.z.string().regex(/^fs_[a-z0-9_]+$/)).optional(),supersedes:t.z.array(e.PlaybookPatchIdSchema).optional()}).superRefine((e,n)=>{e.kind===`signal_only`&&(e.evidence||n.addIssue({code:t.z.ZodIssueCode.custom,message:`evidence is required for signal_only`,path:[`evidence`]}),e.ops!==void 0&&e.ops.length>0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`ops must not be set for signal_only`,path:[`ops`]}),e.new_playbook!==void 0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`new_playbook must not be set for signal_only`,path:[`new_playbook`]}),e.signal_ids!==void 0&&e.signal_ids.length>0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`signal_ids must not be set for signal_only`,path:[`signal_ids`]}),e.supersedes!==void 0&&e.supersedes.length>0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`supersedes must not be set for signal_only`,path:[`supersedes`]}))}),e.RejectPlaybookPatchSchema=t.z.object({reason:t.z.string().optional()})})),Wu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignalEvidenceSchema=e.ImportFeedbackSignalsResultSchema=e.ImportFeedbackSignalsSchema=e.ImportFeedbackSignalItemSchema=e.DiscardFeedbackSignalsResultSchema=e.DiscardFeedbackSignalsSchema=e.ListFeedbackSignalsQuerySchema=e.FeedbackSignalCountSchema=e.FeedbackSignalSchema=e.FeedbackSignalStatusSchema=e.FeedbackSignalSourceSchema=e.FeedbackSignalIdSchema=void 0;var t=Iu(),n=Uu();e.FeedbackSignalIdSchema=t.z.string().regex(/^fs_[a-z0-9_]+$/,`Signal id must match fs_<slug>`),e.FeedbackSignalSourceSchema=t.z.enum([`ide`,`dealer`,`backfill`]),e.FeedbackSignalStatusSchema=t.z.enum([`open`,`actioned`,`discarded`]),e.FeedbackSignalSchema=t.z.object({id:e.FeedbackSignalIdSchema,source:e.FeedbackSignalSourceSchema,sourceRef:t.z.string().nullable(),failureSummary:t.z.string().min(1),userFeedbackExcerpt:t.z.string().min(1),correctedOutputHint:t.z.string().nullable(),candidatePlaybookId:t.z.string().nullable(),candidateDeckId:t.z.string().uuid().nullable(),linkedPatchId:t.z.string().nullable(),status:e.FeedbackSignalStatusSchema,createdAt:t.z.string()}),e.FeedbackSignalCountSchema=t.z.object({open:t.z.number().int().nonnegative()}),e.ListFeedbackSignalsQuerySchema=t.z.object({status:e.FeedbackSignalStatusSchema.optional(),playbookId:t.z.string().optional(),deckId:t.z.string().uuid().optional(),excludeInProposal:t.z.union([t.z.boolean(),t.z.enum([`true`,`false`,`1`,`0`])]).optional().transform(e=>e===!0||e===`true`||e===`1`)}),e.DiscardFeedbackSignalsSchema=t.z.object({signalIds:t.z.array(e.FeedbackSignalIdSchema).min(1)}),e.DiscardFeedbackSignalsResultSchema=t.z.object({discarded:t.z.number().int().nonnegative(),ids:t.z.array(e.FeedbackSignalIdSchema)}),e.ImportFeedbackSignalItemSchema=t.z.object({source:t.z.literal(`backfill`).default(`backfill`),sourceRef:t.z.string().nullable().optional(),failureSummary:t.z.string().min(1),userFeedbackExcerpt:t.z.string().min(1),correctedOutputHint:t.z.string().nullable().optional(),candidatePlaybookId:t.z.string().nullable().optional(),candidateDeckId:t.z.string().uuid().nullable().optional()}),e.ImportFeedbackSignalsSchema=t.z.object({signals:t.z.array(e.ImportFeedbackSignalItemSchema).min(1)}),e.ImportFeedbackSignalsResultSchema=t.z.object({inserted:t.z.number().int().nonnegative(),errors:t.z.array(t.z.object({index:t.z.number().int().nonnegative(),error:t.z.string()})),ids:t.z.array(e.FeedbackSignalIdSchema)}),e.SignalEvidenceSchema=n.PatchEvidenceSchema})),Gu=s(((e,t)=>{t.exports={}})),Ku=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.MULTIPLE_SESSION_DECKS_LINE=e.SESSION_OVERRIDE_MARKER_SUFFIX=e.SESSION_OVERRIDE_MARKER_PREFIX=e.DISPLAY_LINE_MAX_LENGTH=e.PendingDeckSwitchRequestSchema=e.PendingAdminChallengeSchema=e.DeckListEntrySchema=e.BindingActiveSourceSchema=e.StatusLinePayloadSchema=e.DeckDisplaySchema=e.LiveBindingSchema=e.DeckCardCountsSchema=e.DeckDisplaySourceSchema=void 0,e.countDeckCards=i,e.formatDisplayUpdatedSuffix=a,e.formatDisplayLine=c,e.formatAmbiguousSessionDisplayLine=l,e.appendSessionOverrideSuffix=u,e.normalizeWorkspaceRoot=d,e.resolveStatusLineSessionId=f,e.resolveStatusLineWorkspace=p;var n=Iu(),r=t(Gu());e.DeckDisplaySourceSchema=n.z.enum([`launch`,`session_override`,`env`,`unbound`]),e.DeckCardCountsSchema=n.z.object({mcp:n.z.number().int().min(0),credentials:n.z.number().int().min(0),playbooks:n.z.number().int().min(0)}),e.LiveBindingSchema=n.z.object({badge:n.z.string().min(1),deckId:n.z.string().uuid(),deckName:n.z.string().min(1),source:e.DeckDisplaySourceSchema.exclude([`unbound`]),workspaceRoot:n.z.string().min(1).optional(),clientName:n.z.string().min(1).optional(),mode:n.z.enum([`normal`,`agent-admin`]).optional(),cardCounts:e.DeckCardCountsSchema,updatedAt:n.z.string().datetime(),lastActivityAt:n.z.string().datetime()}),e.DeckDisplaySchema=n.z.object({workspaceRoot:n.z.string(),deckId:n.z.string().uuid().nullable(),deckName:n.z.string().nullable(),source:e.DeckDisplaySourceSchema,cardCounts:e.DeckCardCountsSchema,oauthWarningCount:n.z.number().int().min(0).optional(),agentDeckOnline:n.z.boolean(),mcpOnline:n.z.boolean().optional(),updatedAt:n.z.string().datetime().optional(),displayLine:n.z.string()}),e.StatusLinePayloadSchema=n.z.object({session_id:n.z.string().optional(),cwd:n.z.string().optional(),workspace:n.z.object({current_dir:n.z.string().optional(),project_dir:n.z.string().optional()}).optional()}),e.BindingActiveSourceSchema=n.z.enum([`session`,`workspace`,`launch`]),e.DeckListEntrySchema=n.z.object({id:n.z.string().uuid(),name:n.z.string().min(1),isActive:n.z.boolean(),cardCounts:e.DeckCardCountsSchema,workspaceCount:n.z.number().int().nonnegative().optional()}),e.PendingAdminChallengeSchema=n.z.object({challengeId:n.z.string().min(1),runtimeSessionId:n.z.string().min(1),deckId:n.z.string().uuid(),deckName:n.z.string().min(1).optional(),expiresAt:n.z.string().datetime(),approvalPath:n.z.string().min(1)}),e.PendingDeckSwitchRequestSchema=n.z.object({requestId:n.z.string().min(1),runtimeSessionId:n.z.string().min(1),status:n.z.literal(`pending`),currentDeckName:n.z.string().min(1).optional(),requestedDeckName:n.z.string().min(1).optional(),expiresAt:n.z.string().datetime(),approvalPath:n.z.string().min(1)}),e.DISPLAY_LINE_MAX_LENGTH=120;function i(e){return{mcp:(e.services??[]).filter(e=>e.type===`mcp`).length,credentials:e.credentials?.length??0,playbooks:e.playbooks?.length??0}}function a(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return` (updated ${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())})`}e.SESSION_OVERRIDE_MARKER_PREFIX=` · session (default `,e.SESSION_OVERRIDE_MARKER_SUFFIX=`)`;function o(e,t,n){let r=e?.trim(),i=t?.trim();return!r||!i?null:n===void 0?r===i?null:i:n?i:null}function s(t){return t.length>e.DISPLAY_LINE_MAX_LENGTH?t.slice(0,e.DISPLAY_LINE_MAX_LENGTH):t}function c(t,n,r){let i=`◆ `,c=r?.updatedAt?a(r.updatedAt):``;if(r?.offline){let t=`${i}Agent Deck offline${c}`;return t.length>e.DISPLAY_LINE_MAX_LENGTH?t.slice(0,e.DISPLAY_LINE_MAX_LENGTH):t}if(!t){let t=`${i}Unbound — bind a deck to use Agent Deck`,n=r?.mcpOffline?`${t} · MCP offline`:t;return n.length>e.DISPLAY_LINE_MAX_LENGTH?n.slice(0,e.DISPLAY_LINE_MAX_LENGTH):n}let l=`${n.mcp} MCP · ${n.credentials} keys · ${n.playbooks} playbooks`,u=r?.badge?` · ⌘${r.badge}`:``,d=r?.mcpOffline?` · MCP offline`:``,f=r?.sessionCount??0,p=f>=2?` · ${f} sessions`:``,m=r?.workspaceDefault?` · workspace default`:``,h=o(t,r?.workspaceDefaultName,r?.sessionOverride),g=``;if(h!==null){let t=`${e.SESSION_OVERRIDE_MARKER_PREFIX}${h}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`,n=5+l.length+c.length+d.length+u.length+p.length+m.length,r=e.DISPLAY_LINE_MAX_LENGTH-n-1;if(t.length<=r)g=t;else{let t=r-e.SESSION_OVERRIDE_MARKER_PREFIX.length-e.SESSION_OVERRIDE_MARKER_SUFFIX.length;t>=2&&(g=`${e.SESSION_OVERRIDE_MARKER_PREFIX}${h.slice(0,t-1)}…${e.SESSION_OVERRIDE_MARKER_SUFFIX}`)}}let _=c.length+d.length+u.length+p.length+m.length+g.length,v=5+l.length+_,y=e.DISPLAY_LINE_MAX_LENGTH-v,b=t;if(y<1){let t=`${i}${l}${u}${d}${p}${m}${c}`;if(!g)return s(t);let n=e.DISPLAY_LINE_MAX_LENGTH-(t.length+e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length);if(n<2)return s(t);let r=h.length>n?`${h.slice(0,n-1)}…`:h;return`${t}${e.SESSION_OVERRIDE_MARKER_PREFIX}${r}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`}return b.length>y&&(b=y>=2?`${b.slice(0,y-1)}…`:b.slice(0,Math.max(0,y))),`${i}${b} · ${l}${u}${d}${p}${m}${c}${g}`}e.MULTIPLE_SESSION_DECKS_LINE=`◆ Agent Deck · multiple session decks · see chat receipt`;function l(){return e.MULTIPLE_SESSION_DECKS_LINE}function u(t,n,r,i){let a=o(n,r,i);if(a===null)return t;let s=`${t}${e.SESSION_OVERRIDE_MARKER_PREFIX}${a}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`;if(s.length<=e.DISPLAY_LINE_MAX_LENGTH)return s;let c=e.DISPLAY_LINE_MAX_LENGTH-(t.length+e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length);if(c>=2)return`${t}${e.SESSION_OVERRIDE_MARKER_PREFIX}${a.slice(0,c-1)}…${e.SESSION_OVERRIDE_MARKER_SUFFIX}`;let l=e.DISPLAY_LINE_MAX_LENGTH-(e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length+2);if(l<1)return s.slice(0,e.DISPLAY_LINE_MAX_LENGTH);let u=t.length>l?`${t.slice(0,Math.max(0,l-1))}…`:t,d=e.DISPLAY_LINE_MAX_LENGTH-(u.length+e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length),f=a.length>d?`${a.slice(0,Math.max(0,d-1))}…`:a;return`${u}${e.SESSION_OVERRIDE_MARKER_PREFIX}${f}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`}function d(e){return r.default.resolve(e.trim())}function f(e){return e.session_id?.trim()||void 0}function p(e,t){let n=e.workspace?.project_dir?.trim();if(n)return d(n);let r=e.cwd?.trim()||e.workspace?.current_dir?.trim()||t?.trim();return r?d(r):void 0}})),qu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExportRequestSchema=e.ImportReportSchema=e.ImportReportCountsSchema=e.ImportEntityCountsSchema=e.BundleAnySchema=e.BundleV2Schema=e.BundleDeckV2Schema=e.BundleV1Schema=e.BundleDeckSchema=e.BundlePlaybookSchema=e.BundleServiceSchema=e.BundleScopeSchema=e.BundleV2VersionSchema=e.BundleVersionSchema=e.BundleFormatSchema=void 0;var t=Iu(),n=Vu(),r=Bu();e.BundleFormatSchema=t.z.literal(`agent-deck-bundle`),e.BundleVersionSchema=t.z.literal(1),e.BundleV2VersionSchema=t.z.literal(2),e.BundleScopeSchema=t.z.enum([`collection`,`deck`]),e.BundleServiceSchema=t.z.object({id:t.z.string().min(1),name:t.z.string().min(1),type:t.z.enum([`mcp`,`a2a`,`local-mcp`]),url:t.z.string().min(1),description:t.z.string().optional(),cardColor:t.z.string().optional(),iconUrl:t.z.string().optional(),disabledToolNames:t.z.array(t.z.string()).default([]),headers:t.z.record(t.z.string()).optional(),oauthClientId:t.z.string().optional(),oauthAuthorizationUrl:t.z.string().optional(),oauthTokenUrl:t.z.string().optional(),oauthRedirectUri:t.z.string().optional(),oauthScope:t.z.string().optional(),localCommand:t.z.string().optional(),localArgs:t.z.array(t.z.string()).optional(),localWorkingDir:t.z.string().optional()}).strict(),e.BundlePlaybookSchema=t.z.object({id:r.PlaybookIdSchema,title:t.z.string().min(1),body:t.z.string().default(``),triggers:t.z.array(t.z.string()).default([]),dependsOnServiceIds:t.z.array(t.z.string()).default([]),exec:t.z.string().optional(),skill:t.z.string().optional()}).strict(),e.BundleDeckSchema=t.z.object({id:t.z.string().min(1),name:t.z.string().min(1),serviceIds:t.z.array(t.z.string()).default([]),playbookIds:t.z.array(t.z.string()).default([])}).strip(),e.BundleV1Schema=t.z.object({format:e.BundleFormatSchema,version:e.BundleVersionSchema,exportedAt:t.z.string().datetime(),exportedFrom:t.z.object({agentDeckVersion:t.z.string().min(1)}),scope:e.BundleScopeSchema,services:t.z.array(e.BundleServiceSchema).default([]),playbooks:t.z.array(e.BundlePlaybookSchema).default([]),decks:t.z.array(e.BundleDeckSchema).default([])}).strict(),e.BundleDeckV2Schema=t.z.object({id:t.z.string().min(1),name:t.z.string().min(1),operatingInstructions:n.OperatingInstructionsSchema.default(``),serviceIds:t.z.array(t.z.string()).default([]),playbookIds:t.z.array(t.z.string()).default([])}).strip(),e.BundleV2Schema=t.z.object({format:e.BundleFormatSchema,version:e.BundleV2VersionSchema,exportedAt:t.z.string().datetime(),exportedFrom:t.z.object({agentDeckVersion:t.z.string().min(1)}),scope:e.BundleScopeSchema,services:t.z.array(e.BundleServiceSchema).default([]),playbooks:t.z.array(e.BundlePlaybookSchema).default([]),decks:t.z.array(e.BundleDeckV2Schema).default([])}).strict(),e.BundleAnySchema=t.z.discriminatedUnion(`version`,[e.BundleV1Schema,e.BundleV2Schema]),e.ImportEntityCountsSchema=t.z.object({created:t.z.number().int().min(0),reused:t.z.number().int().min(0)}),e.ImportReportCountsSchema=t.z.object({services:e.ImportEntityCountsSchema,playbooks:e.ImportEntityCountsSchema,decks:e.ImportEntityCountsSchema}),e.ImportReportSchema=t.z.object({status:t.z.enum([`completed`,`failed`,`partial`]),counts:e.ImportReportCountsSchema,servicesNeedingOauth:t.z.array(t.z.string()),warnings:t.z.array(t.z.string()),idMap:t.z.record(t.z.string())}),e.ExportRequestSchema=t.z.object({scope:e.BundleScopeSchema.default(`collection`),deckId:t.z.string().uuid().optional()}).superRefine((e,n)=>{e.scope===`deck`&&!e.deckId&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`deckId is required when scope is deck`,path:[`deckId`]})})})),Ju=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StoreCredentialMetaSchema=e.StoreDeckSchema=e.StoreServiceSchema=e.StorePlaybookFileSchema=e.StorePlaybookTriggersSchema=e.StoreManifestSchema=void 0;var t=Iu(),n=Bu(),r=qu(),i=Vu(),a=zu();e.StoreManifestSchema=t.z.object({format:t.z.literal(`agent-deck-store`),version:t.z.union([t.z.literal(1),t.z.literal(2)]),migratedFrom:t.z.literal(`sqlite`).optional()}).strict(),e.StorePlaybookTriggersSchema=t.z.array(t.z.string()).transform((e,n)=>{try{return(0,a.normalizeTriggers)(e,{maxCount:null})}catch(e){return n.addIssue({code:t.z.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid triggers`}),t.z.NEVER}}).default([]),e.StorePlaybookFileSchema=t.z.object({id:n.PlaybookIdSchema,title:t.z.string().min(1),body:t.z.string().default(``),triggers:e.StorePlaybookTriggersSchema,dependsOnCredentialIds:t.z.array(t.z.string()).default([]),dependsOnServiceIds:t.z.array(t.z.string()).default([]),exec:t.z.string().optional(),skill:t.z.string().optional(),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}).strict(),e.StoreServiceSchema=r.BundleServiceSchema.extend({credentialId:t.z.string().min(1).optional()}),e.StoreDeckSchema=t.z.object({id:t.z.string().uuid(),name:t.z.string().min(1),serviceIds:t.z.array(t.z.string()).default([]),credentialIds:t.z.array(t.z.string()).default([]),playbookIds:t.z.array(t.z.string()).default([]),operatingInstructions:i.OperatingInstructionsSchema.default(``),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}).strict(),e.StoreCredentialMetaSchema=t.z.object({id:t.z.string().min(1),label:t.z.string().min(1),scheme:t.z.enum([`bearer`,`header`,`http_basic_user`]),headerName:t.z.string().nullable().optional(),envName:t.z.string().min(1),tags:t.z.array(t.z.string()).default([]),docsUrl:t.z.string().nullable().optional()}).strict()})),Yu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BootstrapManifestSchema=e.BootstrapHostCountsSchema=e.BootstrapWorkspaceSchema=e.SessionDigestSchema=e.OutcomeSchema=e.TopFileItemSchema=e.SkillItemSchema=e.ToolItemSchema=e.CommandItemSchema=e.IntentItemSchema=e.FeedbackMomentSchema=e.BootstrapHostSchema=e.OutcomeSignalSchema=e.PolarityHintSchema=void 0;var t=Iu();e.PolarityHintSchema=t.z.enum([`negative`,`positive`,`mixed`,`unknown`]),e.OutcomeSignalSchema=t.z.enum([`pr_opened`,`committed`,`unknown`]),e.BootstrapHostSchema=t.z.enum([`claude`,`cursor`]),e.FeedbackMomentSchema=t.z.object({agentAction:t.z.string().max(400),userReaction:t.z.string().max(600),polarityHint:e.PolarityHintSchema,markers:t.z.array(t.z.string()),followupChange:t.z.string().max(400).nullable().optional(),at:t.z.string().datetime().optional()}).strict(),e.IntentItemSchema=t.z.object({text:t.z.string().max(280),at:t.z.string().datetime().optional()}).strict(),e.CommandItemSchema=t.z.object({command:t.z.string().max(160),count:t.z.number().int().min(1)}).strict(),e.ToolItemSchema=t.z.object({name:t.z.string(),count:t.z.number().int().min(1)}).strict(),e.SkillItemSchema=t.z.object({name:t.z.string(),count:t.z.number().int().min(1)}).strict(),e.TopFileItemSchema=t.z.object({path:t.z.string(),edits:t.z.number().int().min(1)}).strict(),e.OutcomeSchema=t.z.object({signal:e.OutcomeSignalSchema,evidence:t.z.string().optional()}).strict(),e.SessionDigestSchema=t.z.object({schemaVersion:t.z.literal(1),host:e.BootstrapHostSchema.default(`claude`),sessionId:t.z.string(),workspaceRoot:t.z.string(),workspaceLabel:t.z.string().optional(),workspaceSlug:t.z.string().optional(),gitBranch:t.z.string().nullable().optional(),startedAt:t.z.string().datetime(),endedAt:t.z.string().datetime().optional(),durationMinutes:t.z.number().min(0).optional(),turnCount:t.z.number().int().min(0),skippedLineCount:t.z.number().int().min(0).optional(),intents:t.z.array(e.IntentItemSchema).max(40),commands:t.z.array(e.CommandItemSchema).max(40).default([]),tools:t.z.array(e.ToolItemSchema).max(40).default([]),skills:t.z.array(e.SkillItemSchema).max(40).default([]),topFiles:t.z.array(e.TopFileItemSchema).max(20).default([]),feedbackMoments:t.z.array(e.FeedbackMomentSchema).max(30),outcome:e.OutcomeSchema}).strict(),e.BootstrapWorkspaceSchema=t.z.object({workspaceRoot:t.z.string(),label:t.z.string(),workspaceSlug:t.z.string().optional(),sessionCount:t.z.number().int().min(0),digestPaths:t.z.array(t.z.string())}).strict(),e.BootstrapHostCountsSchema=t.z.object({claude:t.z.number().int().min(0),cursor:t.z.number().int().min(0)}).strict(),e.BootstrapManifestSchema=t.z.object({schemaVersion:t.z.literal(1),generatedAt:t.z.string().datetime(),digestDir:t.z.string(),guideRef:t.z.string(),totalSessions:t.z.number().int().min(0),hosts:e.BootstrapHostCountsSchema.default({claude:0,cursor:0}),workspaces:t.z.array(e.BootstrapWorkspaceSchema)}).strict()})),Xu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DeckSwitchResolutionSchema=e.DeckSwitchResolveBodySchema=e.DeckSwitchDecisionSchema=e.RedactedSessionBindingSchema=e.WorkspaceAssignmentSchema=e.WorkspaceV2ManifestSchema=e.WorkspaceGrantManifestSchema=e.RuntimeSessionSchema=e.WorkspaceGrantStatusSchema=e.TrustedSessionErrorCodeSchema=e.AgentSessionModeSchema=void 0,e.trustedSessionError=n,e.httpStatusForTrustedError=r;var t=Iu();e.AgentSessionModeSchema=t.z.enum([`normal`,`agent-admin`]),e.TrustedSessionErrorCodeSchema=t.z.enum([`GRANT_REQUIRED`,`SESSION_INVALID`,`SESSION_REVOKED`,`RESOURCE_OUT_OF_SCOPE`,`ADMIN_REQUIRED`,`DASHBOARD_REQUIRED`,`ADMIN_CHALLENGE_EXPIRED`,`DECK_FIXED`,`SWITCH_APPROVAL_REQUIRED`,`DECK_SWITCH_EXPIRED`,`DECK_SWITCH_CONSUMED`]),e.WorkspaceGrantStatusSchema=t.z.enum([`pending`,`active`,`revoked`]),e.RuntimeSessionSchema=t.z.object({sessionId:t.z.string(),mcpSessionId:t.z.string().optional(),deckId:t.z.string(),mode:e.AgentSessionModeSchema,lastSeenAt:t.z.string().datetime(),expiresAt:t.z.string().datetime(),adminExpiresAt:t.z.string().datetime().nullable()}).strict(),e.WorkspaceGrantManifestSchema=t.z.object({version:t.z.literal(2),workspaceKey:t.z.string(),grantId:t.z.string(),secret:t.z.string().min(32),deckId:t.z.string(),deckName:t.z.string().optional(),mcpUrl:t.z.string().url().optional(),store:t.z.enum([`file`,`keychain`]).optional(),updatedAt:t.z.string().datetime()}).strict(),e.WorkspaceV2ManifestSchema=e.WorkspaceGrantManifestSchema,e.WorkspaceAssignmentSchema=t.z.object({version:t.z.literal(3),deckId:t.z.string().min(1),deckName:t.z.string().min(1),mcpUrl:t.z.string().url().optional()}).strict(),e.RedactedSessionBindingSchema=t.z.object({sessionId:t.z.string(),deckId:t.z.string(),deckName:t.z.string().optional(),mode:e.AgentSessionModeSchema,expiresAt:t.z.string().datetime(),adminExpiresAt:t.z.string().datetime().nullable().optional(),display_summary:t.z.string().optional()}).strict();function n(e,t){return{success:!1,error:t,error_code:e}}function r(e){switch(e){case`GRANT_REQUIRED`:case`SESSION_INVALID`:case`SESSION_REVOKED`:return 401;case`RESOURCE_OUT_OF_SCOPE`:case`ADMIN_REQUIRED`:case`DASHBOARD_REQUIRED`:case`DECK_FIXED`:case`SWITCH_APPROVAL_REQUIRED`:return 403;case`DECK_SWITCH_CONSUMED`:return 409;case`ADMIN_CHALLENGE_EXPIRED`:case`DECK_SWITCH_EXPIRED`:return 410;default:return 500}}e.DeckSwitchDecisionSchema=t.z.enum([`session`,`workspace-default`,`decline`]),e.DeckSwitchResolveBodySchema=t.z.object({runtimeSessionId:t.z.string().min(1),decision:e.DeckSwitchDecisionSchema}).strict(),e.DeckSwitchResolutionSchema=t.z.object({requestId:t.z.string(),decision:e.DeckSwitchDecisionSchema,status:t.z.enum([`consumed`,`declined`]),deckId:t.z.string().optional(),deckName:t.z.string().optional(),workspaceRoot:t.z.string().optional()}).strict()})),Zu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CARD_USAGE_CATEGORIES=e.CARD_USAGE_CARD_TYPES=void 0,e.isValidCorrelationId=r,e.normalizeCorrelationId=i,e.CARD_USAGE_CARD_TYPES=[`service`,`credential`,`playbook`];var t=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,n=/^[A-Za-z0-9_-]{8,128}$/;function r(e){return t.test(e)||n.test(e)}function i(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||!r(t)?null:t}e.CARD_USAGE_CATEGORIES=[`popular`,`used`,`unused`,`new`]})),Qu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),$u=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateId=n,e.generateShortId=r,e.isValidUUID=i;var t=Gu();function n(){return(0,t.randomUUID)()}function r(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}function i(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}})),ed=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatZodError=t,e.isValidUrl=n,e.isValidHexColor=r,e.sanitizeHeaders=i;function t(e){return e.errors.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `)}function n(e){try{return new URL(e),!0}catch{return!1}}function r(e){return/^#[0-9A-F]{6}$/i.test(e)}function i(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&r.trim()&&(t[n.trim()]=r.trim());return t}})),td=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.toSnakeCase=t,e.toCamelCase=n,e.convertToSnakeCase=r,e.convertToCamelCase=i,e.serializeForDatabase=a,e.deserializeFromDatabase=o;function t(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function n(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}function r(e){let n={};for(let[r,i]of Object.entries(e)){let e=t(r);n[e]=i}return n}function i(e){let t={};for(let[r,i]of Object.entries(e)){let e=n(r);t[e]=i}return t}function a(e){let n={};for(let[r,i]of Object.entries(e))i!=null&&(typeof i==`object`&&!Array.isArray(i)?n[t(r)]=JSON.stringify(i):n[t(r)]=i);return n}function o(e){let t={};for(let[r,i]of Object.entries(e)){let e=n(r);if(typeof i==`string`&&(i.startsWith(`{`)||i.startsWith(`[`)))try{t[e]=JSON.parse(i)}catch{t[e]=i}else t[e]=i}return t}})),nd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.slugifyCredentialLabel=t,e.deriveEnvNameFromLabel=n,e.deriveCredentialIdFromLabel=r,e.deriveCredentialDefaults=i;function t(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`connection`}function n(e){let n=t(e).toUpperCase();return n.endsWith(`_API_KEY`)?n:(n.endsWith(`_API`)&&(n=n.slice(0,-4)),`${n}_API_KEY`)}function r(e){return`cred_${t(e)}`}function i(e,t){let i=e.trim();return{id:t?.id??r(i),label:i,scheme:t?.scheme??`bearer`,envName:t?.envName??n(i),tags:t?.tags??[]}}})),rd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.slugifyPlaybookTitle=t,e.derivePlaybookIdFromTitle=n,e.derivePlaybookDefaults=r;function t(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/_+/g,`_`).slice(0,48)}function n(e){return`pb_${t(e)||`playbook`}`}function r(e,t){let r=e.trim();return{title:r,id:t?.id??n(r)}}})),id=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.buildPlaybookSearchText=o,e.detectPlaybookDependencies=s;var t=/\bcred_[a-z0-9_]+\b/g,n=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,r=/--connections(?:=|\s+)([^\s]+)/g;function i(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function a(e,t){let n=t.trim();return n?RegExp(`\\b${i(n)}\\b`,`i`).test(e):!1}function o(e){return[e.title??``,e.body??``,e.exec??``,e.skill??``,...e.triggers??[]].join(`
|
|
33
|
-
`)}function s(e,i,o={}){let s=new Set(o.credentialIds??[]),c=new Set(o.serviceIds??[]),l=new Set(i.credentials.map(e=>e.id)),u=new Map(i.services.map(e=>[e.id.toLowerCase(),e.id]));for(let n of e.matchAll(t)){let e=n[0];l.has(e)&&s.add(e)}for(let t of e.matchAll(r))for(let e of t[1].split(`,`)){let t=e.trim();l.has(t)&&s.add(t)}for(let t of i.credentials)t.envName&&e.includes(t.envName)&&s.add(t.id),a(e,t.label)&&s.add(t.id);for(let t of e.matchAll(n)){let e=u.get(t[0].toLowerCase());e&&c.add(e)}for(let t of i.services)a(e,t.name)&&c.add(t.id);return{dependsOnCredentialIds:[...s].sort(),dependsOnServiceIds:[...c].sort()}}})),
|
|
32
|
+
`)?e:`${e}\n`}e.OperatingInstructionsSchema=t.z.string().transform(e=>i(e)).pipe(t.z.string().max(e.OPERATING_INSTRUCTIONS_MAX_LENGTH,`Deck operating instructions must be at most ${e.OPERATING_INSTRUCTIONS_MAX_LENGTH.toLocaleString(`en-US`)} characters`)),e.DeckSchema=t.z.object({id:t.z.string().uuid(),name:t.z.string().min(1,`Deck name is required`),isActive:t.z.boolean().default(!1),operatingInstructions:e.OperatingInstructionsSchema.default(``),services:t.z.array(t.z.any()).default([]),credentials:t.z.array(n.CredentialSchema).default([]),playbooks:t.z.array(r.PlaybookSchema).default([]),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}),e.CreateDeckSchema=e.DeckSchema.omit({id:!0,services:!0,createdAt:!0,updatedAt:!0}),e.UpdateDeckSchema=e.CreateDeckSchema.partial(),e.DeckServiceSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),serviceId:t.z.string().uuid(`Valid service ID required`),position:t.z.number().int().min(0,`Position must be non-negative`)}),e.AddServiceToDeckSchema=e.DeckServiceSchema.omit({position:!0}).extend({position:t.z.number().int().min(0).optional()}),e.RemoveServiceFromDeckSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),serviceId:t.z.string().uuid(`Valid service ID required`)}),e.ReorderDeckServicesSchema=t.z.object({deckId:t.z.string().uuid(`Valid deck ID required`),serviceIds:t.z.array(t.z.string().uuid(`Valid service ID required`)).min(1,`At least one service ID required`)})})),Hu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OAuthRefreshInputSchema=e.OAuthCallbackInputSchema=e.OAuthFlowInputSchema=e.OAuthTokenSchema=e.OAuthConfigSchema=void 0;var t=Iu();e.OAuthConfigSchema=t.z.object({clientId:t.z.string().min(1,`Client ID is required`),clientSecret:t.z.string().min(1,`Client secret is required`),authorizationUrl:t.z.string().url(`Valid authorization URL required`),tokenUrl:t.z.string().url(`Valid token URL required`),redirectUri:t.z.string().url(`Valid redirect URI required`),scope:t.z.string().min(1,`Scope is required`)}),e.OAuthTokenSchema=t.z.object({accessToken:t.z.string().min(1,`Access token is required`),refreshToken:t.z.string().optional(),expiresAt:t.z.string().datetime().optional(),tokenType:t.z.string().default(`Bearer`),scope:t.z.string().optional()}),e.OAuthFlowInputSchema=t.z.object({serviceId:t.z.string().uuid(`Valid service ID required`),redirectUri:t.z.string().url(`Valid redirect URI required`)}),e.OAuthCallbackInputSchema=t.z.object({serviceId:t.z.string().uuid(`Valid service ID required`),code:t.z.string().min(1,`Authorization code is required`),state:t.z.string().min(1,`State parameter is required`)}),e.OAuthRefreshInputSchema=t.z.object({serviceId:t.z.string().uuid(`Valid service ID required`),refreshToken:t.z.string().min(1,`Refresh token is required`)})})),Uu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RejectPlaybookPatchSchema=e.ProposePlaybookPatchSchema=e.CreatePlaybookPatchFieldsSchema=e.PatchOpSchema=e.BodyPatchOpSchema=e.RewriteBodyOpSchema=e.SetTriggersOpSchema=e.RemoveItemOpSchema=e.AmendItemOpSchema=e.AddItemOpSchema=e.PatchEvidenceSchema=e.PlaybookPatchSourceSchema=e.PlaybookPatchStatusSchema=e.ProposePlaybookPatchKindSchema=e.PlaybookPatchKindSchema=e.PlaybookPatchIdSchema=void 0;var t=Iu(),n=Bu();e.PlaybookPatchIdSchema=t.z.string().regex(/^pp_[a-z0-9_]+$/,`Patch id must match pp_<slug>`),e.PlaybookPatchKindSchema=t.z.enum([`create`,`update`,`merge`,`retire`]),e.ProposePlaybookPatchKindSchema=t.z.enum([`create`,`update`,`merge`,`retire`,`signal_only`]),e.PlaybookPatchStatusSchema=t.z.enum([`proposed`,`accepted`,`rejected`,`stale`,`superseded`]),e.PlaybookPatchSourceSchema=t.z.enum([`ide`,`dealer`,`hook`,`harvester`]),e.PatchEvidenceSchema=t.z.object({failure_summary:t.z.string().min(1),user_feedback_excerpt:t.z.string().min(1),corrected_output_hint:t.z.string().optional()}),e.AddItemOpSchema=t.z.object({op:t.z.literal(`add_item`).describe(`Append a bullet to a ## section (creates the section if missing)`),section:t.z.string().min(1).describe(`## heading name, e.g. Gotchas or Checklist`),text:t.z.string().min(1).describe(`Bullet text; a leading "- " is added when omitted`)}),e.AmendItemOpSchema=t.z.object({op:t.z.literal(`amend_item`).describe(`Replace one existing list item line (not prose paragraphs)`),section:t.z.string().min(1).describe(`## heading that contains the anchor line`),anchor:t.z.string().min(1).describe(`Exact list line to replace, including "- " prefix`),text:t.z.string().min(1).describe(`Replacement bullet text; leading "- " optional`)}),e.RemoveItemOpSchema=t.z.object({op:t.z.literal(`remove_item`).describe(`Delete one existing list item line (not prose paragraphs)`),section:t.z.string().min(1).describe(`## heading that contains the anchor line`),anchor:t.z.string().min(1).describe(`Exact list line to delete, including "- " prefix`)}),e.SetTriggersOpSchema=t.z.object({op:t.z.literal(`set_triggers`).describe(`Replace the playbook trigger phrases`),triggers:n.PlaybookTriggersUpdateSchema.describe(`New trigger list (count policy enforced against the current playbook)`)}),e.RewriteBodyOpSchema=t.z.object({op:t.z.literal(`rewrite_body`).describe(`Replace the entire playbook body — use only when item ops cannot reach the edit`),text:t.z.string().describe(`Full new markdown body`)}),e.BodyPatchOpSchema=t.z.discriminatedUnion(`op`,[e.AddItemOpSchema,e.AmendItemOpSchema,e.RemoveItemOpSchema,e.RewriteBodyOpSchema]),e.PatchOpSchema=t.z.discriminatedUnion(`op`,[e.AddItemOpSchema,e.AmendItemOpSchema,e.RemoveItemOpSchema,e.SetTriggersOpSchema,e.RewriteBodyOpSchema]),e.CreatePlaybookPatchFieldsSchema=t.z.object({title:t.z.string().min(1),body:t.z.string().default(``),triggers:n.PlaybookTriggersSchema.refine(e=>e.length>0,{message:`Genesis playbooks need at least one trigger`}),deck_id:t.z.string().uuid(),exec:t.z.string().optional(),skill:t.z.string().optional()}),e.ProposePlaybookPatchSchema=t.z.object({kind:e.ProposePlaybookPatchKindSchema,playbook_id:n.PlaybookIdSchema.optional(),ops:t.z.array(e.PatchOpSchema).optional(),new_playbook:e.CreatePlaybookPatchFieldsSchema.optional(),rationale:t.z.string().min(1),evidence:e.PatchEvidenceSchema.optional(),signal_ids:t.z.array(t.z.string().regex(/^fs_[a-z0-9_]+$/)).optional(),supersedes:t.z.array(e.PlaybookPatchIdSchema).optional()}).superRefine((e,n)=>{e.kind===`signal_only`&&(e.evidence||n.addIssue({code:t.z.ZodIssueCode.custom,message:`evidence is required for signal_only`,path:[`evidence`]}),e.ops!==void 0&&e.ops.length>0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`ops must not be set for signal_only`,path:[`ops`]}),e.new_playbook!==void 0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`new_playbook must not be set for signal_only`,path:[`new_playbook`]}),e.signal_ids!==void 0&&e.signal_ids.length>0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`signal_ids must not be set for signal_only`,path:[`signal_ids`]}),e.supersedes!==void 0&&e.supersedes.length>0&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`supersedes must not be set for signal_only`,path:[`supersedes`]}))}),e.RejectPlaybookPatchSchema=t.z.object({reason:t.z.string().optional()})})),Wu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignalEvidenceSchema=e.ImportFeedbackSignalsResultSchema=e.ImportFeedbackSignalsSchema=e.ImportFeedbackSignalItemSchema=e.DiscardFeedbackSignalsResultSchema=e.DiscardFeedbackSignalsSchema=e.ListFeedbackSignalsQuerySchema=e.FeedbackSignalCountSchema=e.FeedbackSignalSchema=e.FeedbackSignalStatusSchema=e.FeedbackSignalSourceSchema=e.FeedbackSignalIdSchema=void 0;var t=Iu(),n=Uu();e.FeedbackSignalIdSchema=t.z.string().regex(/^fs_[a-z0-9_]+$/,`Signal id must match fs_<slug>`),e.FeedbackSignalSourceSchema=t.z.enum([`ide`,`dealer`,`backfill`]),e.FeedbackSignalStatusSchema=t.z.enum([`open`,`actioned`,`discarded`]),e.FeedbackSignalSchema=t.z.object({id:e.FeedbackSignalIdSchema,source:e.FeedbackSignalSourceSchema,sourceRef:t.z.string().nullable(),failureSummary:t.z.string().min(1),userFeedbackExcerpt:t.z.string().min(1),correctedOutputHint:t.z.string().nullable(),candidatePlaybookId:t.z.string().nullable(),candidateDeckId:t.z.string().uuid().nullable(),linkedPatchId:t.z.string().nullable(),status:e.FeedbackSignalStatusSchema,createdAt:t.z.string()}),e.FeedbackSignalCountSchema=t.z.object({open:t.z.number().int().nonnegative()}),e.ListFeedbackSignalsQuerySchema=t.z.object({status:e.FeedbackSignalStatusSchema.optional(),playbookId:t.z.string().optional(),deckId:t.z.string().uuid().optional(),excludeInProposal:t.z.union([t.z.boolean(),t.z.enum([`true`,`false`,`1`,`0`])]).optional().transform(e=>e===!0||e===`true`||e===`1`)}),e.DiscardFeedbackSignalsSchema=t.z.object({signalIds:t.z.array(e.FeedbackSignalIdSchema).min(1)}),e.DiscardFeedbackSignalsResultSchema=t.z.object({discarded:t.z.number().int().nonnegative(),ids:t.z.array(e.FeedbackSignalIdSchema)}),e.ImportFeedbackSignalItemSchema=t.z.object({source:t.z.literal(`backfill`).default(`backfill`),sourceRef:t.z.string().nullable().optional(),failureSummary:t.z.string().min(1),userFeedbackExcerpt:t.z.string().min(1),correctedOutputHint:t.z.string().nullable().optional(),candidatePlaybookId:t.z.string().nullable().optional(),candidateDeckId:t.z.string().uuid().nullable().optional()}),e.ImportFeedbackSignalsSchema=t.z.object({signals:t.z.array(e.ImportFeedbackSignalItemSchema).min(1)}),e.ImportFeedbackSignalsResultSchema=t.z.object({inserted:t.z.number().int().nonnegative(),errors:t.z.array(t.z.object({index:t.z.number().int().nonnegative(),error:t.z.string()})),ids:t.z.array(e.FeedbackSignalIdSchema)}),e.SignalEvidenceSchema=n.PatchEvidenceSchema})),Gu=s(((e,t)=>{t.exports={}})),Ku=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.MULTIPLE_SESSION_DECKS_LINE=e.SESSION_OVERRIDE_MARKER_SUFFIX=e.SESSION_OVERRIDE_MARKER_PREFIX=e.DISPLAY_LINE_MAX_LENGTH=e.PendingDeckSwitchRequestSchema=e.PendingAdminChallengeSchema=e.DeckListEntrySchema=e.BindingActiveSourceSchema=e.StatusLinePayloadSchema=e.DeckDisplaySchema=e.LiveBindingSchema=e.DeckCardCountsSchema=e.DeckDisplaySourceSchema=void 0,e.countDeckCards=i,e.formatDisplayUpdatedSuffix=a,e.formatDisplayLine=c,e.formatAmbiguousSessionDisplayLine=l,e.appendSessionOverrideSuffix=u,e.normalizeWorkspaceRoot=d,e.resolveStatusLineSessionId=f,e.resolveStatusLineWorkspace=p;var n=Iu(),r=t(Gu());e.DeckDisplaySourceSchema=n.z.enum([`launch`,`session_override`,`env`,`unbound`]),e.DeckCardCountsSchema=n.z.object({mcp:n.z.number().int().min(0),credentials:n.z.number().int().min(0),playbooks:n.z.number().int().min(0)}),e.LiveBindingSchema=n.z.object({badge:n.z.string().min(1),deckId:n.z.string().uuid(),deckName:n.z.string().min(1),source:e.DeckDisplaySourceSchema.exclude([`unbound`]),workspaceRoot:n.z.string().min(1).optional(),clientName:n.z.string().min(1).optional(),mode:n.z.enum([`normal`,`agent-admin`]).optional(),cardCounts:e.DeckCardCountsSchema,updatedAt:n.z.string().datetime(),lastActivityAt:n.z.string().datetime()}),e.DeckDisplaySchema=n.z.object({workspaceRoot:n.z.string(),deckId:n.z.string().uuid().nullable(),deckName:n.z.string().nullable(),source:e.DeckDisplaySourceSchema,cardCounts:e.DeckCardCountsSchema,oauthWarningCount:n.z.number().int().min(0).optional(),agentDeckOnline:n.z.boolean(),mcpOnline:n.z.boolean().optional(),updatedAt:n.z.string().datetime().optional(),displayLine:n.z.string()}),e.StatusLinePayloadSchema=n.z.object({session_id:n.z.string().optional(),cwd:n.z.string().optional(),workspace:n.z.object({current_dir:n.z.string().optional(),project_dir:n.z.string().optional()}).optional()}),e.BindingActiveSourceSchema=n.z.enum([`session`,`workspace`,`launch`]),e.DeckListEntrySchema=n.z.object({id:n.z.string().uuid(),name:n.z.string().min(1),isActive:n.z.boolean(),cardCounts:e.DeckCardCountsSchema,workspaceCount:n.z.number().int().nonnegative().optional()}),e.PendingAdminChallengeSchema=n.z.object({challengeId:n.z.string().min(1),runtimeSessionId:n.z.string().min(1),deckId:n.z.string().uuid(),deckName:n.z.string().min(1).optional(),expiresAt:n.z.string().datetime(),approvalPath:n.z.string().min(1)}),e.PendingDeckSwitchRequestSchema=n.z.object({requestId:n.z.string().min(1),runtimeSessionId:n.z.string().min(1),status:n.z.literal(`pending`),currentDeckName:n.z.string().min(1).optional(),requestedDeckName:n.z.string().min(1).optional(),expiresAt:n.z.string().datetime(),approvalPath:n.z.string().min(1)}),e.DISPLAY_LINE_MAX_LENGTH=120;function i(e){return{mcp:(e.services??[]).filter(e=>e.type===`mcp`).length,credentials:e.credentials?.length??0,playbooks:e.playbooks?.length??0}}function a(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return` (updated ${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())})`}e.SESSION_OVERRIDE_MARKER_PREFIX=` · session (default `,e.SESSION_OVERRIDE_MARKER_SUFFIX=`)`;function o(e,t,n){let r=e?.trim(),i=t?.trim();return!r||!i?null:n===void 0?r===i?null:i:n?i:null}function s(t){return t.length>e.DISPLAY_LINE_MAX_LENGTH?t.slice(0,e.DISPLAY_LINE_MAX_LENGTH):t}function c(t,n,r){let i=`◆ `,c=r?.updatedAt?a(r.updatedAt):``;if(r?.offline){let t=`${i}Agent Deck offline${c}`;return t.length>e.DISPLAY_LINE_MAX_LENGTH?t.slice(0,e.DISPLAY_LINE_MAX_LENGTH):t}if(!t){let t=`${i}Unbound — bind a deck to use Agent Deck`,n=r?.mcpOffline?`${t} · MCP offline`:t;return n.length>e.DISPLAY_LINE_MAX_LENGTH?n.slice(0,e.DISPLAY_LINE_MAX_LENGTH):n}let l=`${n.mcp} MCP · ${n.credentials} keys · ${n.playbooks} playbooks`,u=r?.badge?` · ⌘${r.badge}`:``,d=r?.mcpOffline?` · MCP offline`:``,f=r?.sessionCount??0,p=f>=2?` · ${f} sessions`:``,m=r?.workspaceDefault?` · workspace default`:``,h=o(t,r?.workspaceDefaultName,r?.sessionOverride),g=``;if(h!==null){let t=`${e.SESSION_OVERRIDE_MARKER_PREFIX}${h}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`,n=5+l.length+c.length+d.length+u.length+p.length+m.length,r=e.DISPLAY_LINE_MAX_LENGTH-n-1;if(t.length<=r)g=t;else{let t=r-e.SESSION_OVERRIDE_MARKER_PREFIX.length-e.SESSION_OVERRIDE_MARKER_SUFFIX.length;t>=2&&(g=`${e.SESSION_OVERRIDE_MARKER_PREFIX}${h.slice(0,t-1)}…${e.SESSION_OVERRIDE_MARKER_SUFFIX}`)}}let _=c.length+d.length+u.length+p.length+m.length+g.length,v=5+l.length+_,y=e.DISPLAY_LINE_MAX_LENGTH-v,b=t;if(y<1){let t=`${i}${l}${u}${d}${p}${m}${c}`;if(!g)return s(t);let n=e.DISPLAY_LINE_MAX_LENGTH-(t.length+e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length);if(n<2)return s(t);let r=h.length>n?`${h.slice(0,n-1)}…`:h;return`${t}${e.SESSION_OVERRIDE_MARKER_PREFIX}${r}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`}return b.length>y&&(b=y>=2?`${b.slice(0,y-1)}…`:b.slice(0,Math.max(0,y))),`${i}${b} · ${l}${u}${d}${p}${m}${c}${g}`}e.MULTIPLE_SESSION_DECKS_LINE=`◆ Agent Deck · multiple session decks · see chat receipt`;function l(){return e.MULTIPLE_SESSION_DECKS_LINE}function u(t,n,r,i){let a=o(n,r,i);if(a===null)return t;let s=`${t}${e.SESSION_OVERRIDE_MARKER_PREFIX}${a}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`;if(s.length<=e.DISPLAY_LINE_MAX_LENGTH)return s;let c=e.DISPLAY_LINE_MAX_LENGTH-(t.length+e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length);if(c>=2)return`${t}${e.SESSION_OVERRIDE_MARKER_PREFIX}${a.slice(0,c-1)}…${e.SESSION_OVERRIDE_MARKER_SUFFIX}`;let l=e.DISPLAY_LINE_MAX_LENGTH-(e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length+2);if(l<1)return s.slice(0,e.DISPLAY_LINE_MAX_LENGTH);let u=t.length>l?`${t.slice(0,Math.max(0,l-1))}…`:t,d=e.DISPLAY_LINE_MAX_LENGTH-(u.length+e.SESSION_OVERRIDE_MARKER_PREFIX.length+e.SESSION_OVERRIDE_MARKER_SUFFIX.length),f=a.length>d?`${a.slice(0,Math.max(0,d-1))}…`:a;return`${u}${e.SESSION_OVERRIDE_MARKER_PREFIX}${f}${e.SESSION_OVERRIDE_MARKER_SUFFIX}`}function d(e){return r.default.resolve(e.trim())}function f(e){return e.session_id?.trim()||void 0}function p(e,t){let n=e.workspace?.project_dir?.trim();if(n)return d(n);let r=e.cwd?.trim()||e.workspace?.current_dir?.trim()||t?.trim();return r?d(r):void 0}})),qu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExportRequestSchema=e.ImportReportSchema=e.ImportReportCountsSchema=e.ImportEntityCountsSchema=e.BundleAnySchema=e.BundleV2Schema=e.BundleDeckV2Schema=e.BundleV1Schema=e.BundleDeckSchema=e.BundlePlaybookSchema=e.BundleServiceSchema=e.BundleScopeSchema=e.BundleV2VersionSchema=e.BundleVersionSchema=e.BundleFormatSchema=void 0;var t=Iu(),n=Vu(),r=Bu();e.BundleFormatSchema=t.z.literal(`agent-deck-bundle`),e.BundleVersionSchema=t.z.literal(1),e.BundleV2VersionSchema=t.z.literal(2),e.BundleScopeSchema=t.z.enum([`collection`,`deck`]),e.BundleServiceSchema=t.z.object({id:t.z.string().min(1),name:t.z.string().min(1),type:t.z.enum([`mcp`,`a2a`,`local-mcp`]),url:t.z.string().min(1),description:t.z.string().optional(),cardColor:t.z.string().optional(),iconUrl:t.z.string().optional(),disabledToolNames:t.z.array(t.z.string()).default([]),headers:t.z.record(t.z.string()).optional(),oauthClientId:t.z.string().optional(),oauthAuthorizationUrl:t.z.string().optional(),oauthTokenUrl:t.z.string().optional(),oauthRedirectUri:t.z.string().optional(),oauthScope:t.z.string().optional(),localCommand:t.z.string().optional(),localArgs:t.z.array(t.z.string()).optional(),localWorkingDir:t.z.string().optional()}).strict(),e.BundlePlaybookSchema=t.z.object({id:r.PlaybookIdSchema,title:t.z.string().min(1),body:t.z.string().default(``),triggers:t.z.array(t.z.string()).default([]),dependsOnServiceIds:t.z.array(t.z.string()).default([]),exec:t.z.string().optional(),skill:t.z.string().optional()}).strict(),e.BundleDeckSchema=t.z.object({id:t.z.string().min(1),name:t.z.string().min(1),serviceIds:t.z.array(t.z.string()).default([]),playbookIds:t.z.array(t.z.string()).default([])}).strip(),e.BundleV1Schema=t.z.object({format:e.BundleFormatSchema,version:e.BundleVersionSchema,exportedAt:t.z.string().datetime(),exportedFrom:t.z.object({agentDeckVersion:t.z.string().min(1)}),scope:e.BundleScopeSchema,services:t.z.array(e.BundleServiceSchema).default([]),playbooks:t.z.array(e.BundlePlaybookSchema).default([]),decks:t.z.array(e.BundleDeckSchema).default([])}).strict(),e.BundleDeckV2Schema=t.z.object({id:t.z.string().min(1),name:t.z.string().min(1),operatingInstructions:n.OperatingInstructionsSchema.default(``),serviceIds:t.z.array(t.z.string()).default([]),playbookIds:t.z.array(t.z.string()).default([])}).strip(),e.BundleV2Schema=t.z.object({format:e.BundleFormatSchema,version:e.BundleV2VersionSchema,exportedAt:t.z.string().datetime(),exportedFrom:t.z.object({agentDeckVersion:t.z.string().min(1)}),scope:e.BundleScopeSchema,services:t.z.array(e.BundleServiceSchema).default([]),playbooks:t.z.array(e.BundlePlaybookSchema).default([]),decks:t.z.array(e.BundleDeckV2Schema).default([])}).strict(),e.BundleAnySchema=t.z.discriminatedUnion(`version`,[e.BundleV1Schema,e.BundleV2Schema]),e.ImportEntityCountsSchema=t.z.object({created:t.z.number().int().min(0),reused:t.z.number().int().min(0)}),e.ImportReportCountsSchema=t.z.object({services:e.ImportEntityCountsSchema,playbooks:e.ImportEntityCountsSchema,decks:e.ImportEntityCountsSchema}),e.ImportReportSchema=t.z.object({status:t.z.enum([`completed`,`failed`,`partial`]),counts:e.ImportReportCountsSchema,servicesNeedingOauth:t.z.array(t.z.string()),warnings:t.z.array(t.z.string()),idMap:t.z.record(t.z.string())}),e.ExportRequestSchema=t.z.object({scope:e.BundleScopeSchema.default(`collection`),deckId:t.z.string().uuid().optional()}).superRefine((e,n)=>{e.scope===`deck`&&!e.deckId&&n.addIssue({code:t.z.ZodIssueCode.custom,message:`deckId is required when scope is deck`,path:[`deckId`]})})})),Ju=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.StoreCredentialMetaSchema=e.StoreDeckSchema=e.StoreServiceSchema=e.StorePlaybookFileSchema=e.StorePlaybookTriggersSchema=e.StoreManifestSchema=void 0;var t=Iu(),n=Bu(),r=qu(),i=Vu(),a=zu();e.StoreManifestSchema=t.z.object({format:t.z.literal(`agent-deck-store`),version:t.z.union([t.z.literal(1),t.z.literal(2)]),migratedFrom:t.z.literal(`sqlite`).optional()}).strict(),e.StorePlaybookTriggersSchema=t.z.array(t.z.string()).transform((e,n)=>{try{return(0,a.normalizeTriggers)(e,{maxCount:null})}catch(e){return n.addIssue({code:t.z.ZodIssueCode.custom,message:e instanceof Error?e.message:`Invalid triggers`}),t.z.NEVER}}).default([]),e.StorePlaybookFileSchema=t.z.object({id:n.PlaybookIdSchema,title:t.z.string().min(1),body:t.z.string().default(``),triggers:e.StorePlaybookTriggersSchema,dependsOnCredentialIds:t.z.array(t.z.string()).default([]),dependsOnServiceIds:t.z.array(t.z.string()).default([]),exec:t.z.string().optional(),skill:t.z.string().optional(),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}).strict(),e.StoreServiceSchema=r.BundleServiceSchema.extend({credentialId:t.z.string().min(1).optional()}),e.StoreDeckSchema=t.z.object({id:t.z.string().uuid(),name:t.z.string().min(1),serviceIds:t.z.array(t.z.string()).default([]),credentialIds:t.z.array(t.z.string()).default([]),playbookIds:t.z.array(t.z.string()).default([]),operatingInstructions:i.OperatingInstructionsSchema.default(``),createdAt:t.z.string().datetime(),updatedAt:t.z.string().datetime()}).strict(),e.StoreCredentialMetaSchema=t.z.object({id:t.z.string().min(1),label:t.z.string().min(1),scheme:t.z.enum([`bearer`,`header`,`http_basic_user`]),headerName:t.z.string().nullable().optional(),envName:t.z.string().min(1),tags:t.z.array(t.z.string()).default([]),docsUrl:t.z.string().nullable().optional()}).strict()})),Yu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BootstrapManifestSchema=e.BootstrapHostCountsSchema=e.BootstrapWorkspaceSchema=e.SessionDigestSchema=e.OutcomeSchema=e.TopFileItemSchema=e.SkillItemSchema=e.ToolItemSchema=e.CommandItemSchema=e.IntentItemSchema=e.FeedbackMomentSchema=e.BootstrapHostSchema=e.OutcomeSignalSchema=e.PolarityHintSchema=void 0;var t=Iu();e.PolarityHintSchema=t.z.enum([`negative`,`positive`,`mixed`,`unknown`]),e.OutcomeSignalSchema=t.z.enum([`pr_opened`,`committed`,`unknown`]),e.BootstrapHostSchema=t.z.enum([`claude`,`cursor`]),e.FeedbackMomentSchema=t.z.object({agentAction:t.z.string().max(400),userReaction:t.z.string().max(600),polarityHint:e.PolarityHintSchema,markers:t.z.array(t.z.string()),followupChange:t.z.string().max(400).nullable().optional(),at:t.z.string().datetime().optional()}).strict(),e.IntentItemSchema=t.z.object({text:t.z.string().max(280),at:t.z.string().datetime().optional()}).strict(),e.CommandItemSchema=t.z.object({command:t.z.string().max(160),count:t.z.number().int().min(1)}).strict(),e.ToolItemSchema=t.z.object({name:t.z.string(),count:t.z.number().int().min(1)}).strict(),e.SkillItemSchema=t.z.object({name:t.z.string(),count:t.z.number().int().min(1)}).strict(),e.TopFileItemSchema=t.z.object({path:t.z.string(),edits:t.z.number().int().min(1)}).strict(),e.OutcomeSchema=t.z.object({signal:e.OutcomeSignalSchema,evidence:t.z.string().optional()}).strict(),e.SessionDigestSchema=t.z.object({schemaVersion:t.z.literal(1),host:e.BootstrapHostSchema.default(`claude`),sessionId:t.z.string(),workspaceRoot:t.z.string(),workspaceLabel:t.z.string().optional(),workspaceSlug:t.z.string().optional(),gitBranch:t.z.string().nullable().optional(),startedAt:t.z.string().datetime(),endedAt:t.z.string().datetime().optional(),durationMinutes:t.z.number().min(0).optional(),turnCount:t.z.number().int().min(0),skippedLineCount:t.z.number().int().min(0).optional(),intents:t.z.array(e.IntentItemSchema).max(40),commands:t.z.array(e.CommandItemSchema).max(40).default([]),tools:t.z.array(e.ToolItemSchema).max(40).default([]),skills:t.z.array(e.SkillItemSchema).max(40).default([]),topFiles:t.z.array(e.TopFileItemSchema).max(20).default([]),feedbackMoments:t.z.array(e.FeedbackMomentSchema).max(30),outcome:e.OutcomeSchema}).strict(),e.BootstrapWorkspaceSchema=t.z.object({workspaceRoot:t.z.string(),label:t.z.string(),workspaceSlug:t.z.string().optional(),sessionCount:t.z.number().int().min(0),digestPaths:t.z.array(t.z.string())}).strict(),e.BootstrapHostCountsSchema=t.z.object({claude:t.z.number().int().min(0),cursor:t.z.number().int().min(0)}).strict(),e.BootstrapManifestSchema=t.z.object({schemaVersion:t.z.literal(1),generatedAt:t.z.string().datetime(),digestDir:t.z.string(),guideRef:t.z.string(),totalSessions:t.z.number().int().min(0),hosts:e.BootstrapHostCountsSchema.default({claude:0,cursor:0}),workspaces:t.z.array(e.BootstrapWorkspaceSchema)}).strict()})),Xu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DeckSwitchResolutionSchema=e.DeckSwitchResolveBodySchema=e.DeckSwitchDecisionSchema=e.RedactedSessionBindingSchema=e.WorkspaceAssignmentSchema=e.WorkspaceV2ManifestSchema=e.WorkspaceGrantManifestSchema=e.RuntimeSessionSchema=e.WorkspaceGrantStatusSchema=e.TrustedSessionErrorCodeSchema=e.AgentSessionModeSchema=void 0,e.trustedSessionError=n,e.httpStatusForTrustedError=r;var t=Iu();e.AgentSessionModeSchema=t.z.enum([`normal`,`agent-admin`]),e.TrustedSessionErrorCodeSchema=t.z.enum([`GRANT_REQUIRED`,`SESSION_INVALID`,`SESSION_REVOKED`,`RESOURCE_OUT_OF_SCOPE`,`ADMIN_REQUIRED`,`DASHBOARD_REQUIRED`,`ADMIN_CHALLENGE_EXPIRED`,`DECK_FIXED`,`SWITCH_APPROVAL_REQUIRED`,`DECK_SWITCH_EXPIRED`,`DECK_SWITCH_CONSUMED`,`RUN_CAPABILITY_REQUIRED`,`FINALIZATION_CAPABILITY_REQUIRED`]),e.WorkspaceGrantStatusSchema=t.z.enum([`pending`,`active`,`revoked`]),e.RuntimeSessionSchema=t.z.object({sessionId:t.z.string(),mcpSessionId:t.z.string().optional(),deckId:t.z.string(),mode:e.AgentSessionModeSchema,lastSeenAt:t.z.string().datetime(),expiresAt:t.z.string().datetime(),adminExpiresAt:t.z.string().datetime().nullable()}).strict(),e.WorkspaceGrantManifestSchema=t.z.object({version:t.z.literal(2),workspaceKey:t.z.string(),grantId:t.z.string(),secret:t.z.string().min(32),deckId:t.z.string(),deckName:t.z.string().optional(),mcpUrl:t.z.string().url().optional(),store:t.z.enum([`file`,`keychain`]).optional(),updatedAt:t.z.string().datetime()}).strict(),e.WorkspaceV2ManifestSchema=e.WorkspaceGrantManifestSchema,e.WorkspaceAssignmentSchema=t.z.object({version:t.z.literal(3),deckId:t.z.string().min(1),deckName:t.z.string().min(1),mcpUrl:t.z.string().url().optional()}).strict(),e.RedactedSessionBindingSchema=t.z.object({sessionId:t.z.string(),deckId:t.z.string(),deckName:t.z.string().optional(),mode:e.AgentSessionModeSchema,expiresAt:t.z.string().datetime(),adminExpiresAt:t.z.string().datetime().nullable().optional(),display_summary:t.z.string().optional()}).strict();function n(e,t){return{success:!1,error:t,error_code:e}}function r(e){switch(e){case`GRANT_REQUIRED`:case`SESSION_INVALID`:case`SESSION_REVOKED`:return 401;case`RESOURCE_OUT_OF_SCOPE`:case`ADMIN_REQUIRED`:case`DASHBOARD_REQUIRED`:case`DECK_FIXED`:case`SWITCH_APPROVAL_REQUIRED`:case`RUN_CAPABILITY_REQUIRED`:case`FINALIZATION_CAPABILITY_REQUIRED`:return 403;case`DECK_SWITCH_CONSUMED`:return 409;case`ADMIN_CHALLENGE_EXPIRED`:case`DECK_SWITCH_EXPIRED`:return 410;default:return 500}}e.DeckSwitchDecisionSchema=t.z.enum([`session`,`workspace-default`,`decline`]),e.DeckSwitchResolveBodySchema=t.z.object({runtimeSessionId:t.z.string().min(1),decision:e.DeckSwitchDecisionSchema}).strict(),e.DeckSwitchResolutionSchema=t.z.object({requestId:t.z.string(),decision:e.DeckSwitchDecisionSchema,status:t.z.enum([`consumed`,`declined`]),deckId:t.z.string().optional(),deckName:t.z.string().optional(),workspaceRoot:t.z.string().optional()}).strict()})),Zu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CARD_USAGE_CATEGORIES=e.CARD_USAGE_CARD_TYPES=void 0,e.isValidCorrelationId=r,e.normalizeCorrelationId=i,e.CARD_USAGE_CARD_TYPES=[`service`,`credential`,`playbook`];var t=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,n=/^[A-Za-z0-9_-]{8,128}$/;function r(e){return t.test(e)||n.test(e)}function i(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||!r(t)?null:t}e.CARD_USAGE_CATEGORIES=[`popular`,`used`,`unused`,`new`]})),Qu=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AgentRunErrorCodeSchema=e.FinalizeAgentRunResponseSchema=e.FinalizeAgentRunRequestSchema=e.AgentRunChangesResponseSchema=e.FinalizationManifestEntrySchema=e.FinalizationFileModeSchema=e.FINALIZATION_REVIEW_ID_MAX_CHARS=e.FINALIZATION_COMMIT_MESSAGE_MAX_CHARS=e.FINALIZATION_PATH_MAX_CHARS=e.FINALIZATION_MANIFEST_MAX_FILES=e.AgentRunCapabilitiesResponseSchema=e.AgentRunClientCapabilitySchema=e.AgentRunEventsResponseSchema=e.AgentRunEventsQuerySchema=e.AgentRunEventSchema=e.AgentRunStatusSchema=e.AgentRunFinalizationStatusSchema=e.FinalizationStateSchema=e.FinalizationBaselineRefSchema=e.Sha256HexSchema=e.GitObjectIdSchema=e.CreateAgentRunResponseSchema=e.AGENT_RUN_TERMINAL_STATES=e.AgentRunStateSchema=e.CreateAgentRunRequestSchema=e.AgentRunIdempotencyKeySchema=e.AgentRunIdSchema=e.AgentRunToolsSchema=e.AgentRunClientSchema=e.AGENT_RUN_EVENTS_MAX_LIMIT=e.AGENT_RUN_EVENTS_DEFAULT_LIMIT=e.AGENT_RUN_IDEMPOTENCY_HEADER=e.AGENT_RUN_REQUEST_BODY_LIMIT_BYTES=e.AGENT_RUN_PROMPT_MAX_CHARS=void 0,e.agentRunError=i;var t=Iu();e.AGENT_RUN_PROMPT_MAX_CHARS=65536,e.AGENT_RUN_REQUEST_BODY_LIMIT_BYTES=262144,e.AGENT_RUN_IDEMPOTENCY_HEADER=`idempotency-key`,e.AGENT_RUN_EVENTS_DEFAULT_LIMIT=200,e.AGENT_RUN_EVENTS_MAX_LIMIT=1e3,e.AgentRunClientSchema=t.z.enum([`claude`,`codex`,`cursor`,`muse`]),e.AgentRunToolsSchema=t.z.enum([`readonly`,`edit`]),e.AgentRunIdSchema=t.z.string().regex(/^run-\d{8}T\d{6}-[0-9a-f]{6}$/),e.AgentRunIdempotencyKeySchema=t.z.string().min(1).max(200).regex(/^[\x21-\x7e]+$/,`Idempotency-Key must be printable ASCII without spaces`);function n(e){return e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)}e.CreateAgentRunRequestSchema=t.z.object({deckId:t.z.string().min(1).max(200),client:e.AgentRunClientSchema,cwd:t.z.string().min(1).max(4096).refine(n,`cwd must be an absolute path on the Agent Deck host`),prompt:t.z.string().max(e.AGENT_RUN_PROMPT_MAX_CHARS).refine(e=>e.trim().length>0,`prompt must not be empty`),tools:e.AgentRunToolsSchema.default(`readonly`),resumeSessionId:t.z.string().min(1).max(512).optional(),prepareFinalization:t.z.boolean().default(!1)}).strict(),e.AgentRunStateSchema=t.z.enum([`starting`,`running`,`ended`,`error`,`died`,`canceled`]),e.AGENT_RUN_TERMINAL_STATES=[`ended`,`error`,`died`,`canceled`],e.CreateAgentRunResponseSchema=t.z.object({runId:e.AgentRunIdSchema,state:e.AgentRunStateSchema}).strict(),e.GitObjectIdSchema=t.z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),e.Sha256HexSchema=t.z.string().regex(/^[0-9a-f]{64}$/),e.FinalizationBaselineRefSchema=t.z.string().regex(/^bl_[0-9a-f]{24}$/),e.FinalizationStateSchema=t.z.enum([`prepared`,`finalizing`,`finalized`]),e.AgentRunFinalizationStatusSchema=t.z.object({baselineRef:e.FinalizationBaselineRefSchema,baselineDigest:e.Sha256HexSchema,state:e.FinalizationStateSchema,commit:e.GitObjectIdSchema.nullable()}).strict(),e.AgentRunStatusSchema=t.z.object({runId:e.AgentRunIdSchema,deckId:t.z.string(),client:e.AgentRunClientSchema,tools:e.AgentRunToolsSchema,state:e.AgentRunStateSchema,sessionId:t.z.string().nullable(),startedAt:t.z.string(),lastEventAt:t.z.string().nullable(),finalization:e.AgentRunFinalizationStatusSchema.nullable()}).strict();var r={seq:t.z.number().int().positive(),ts:t.z.string()};e.AgentRunEventSchema=t.z.discriminatedUnion(`type`,[t.z.object({...r,type:t.z.literal(`text`),text:t.z.string()}).strict(),t.z.object({...r,type:t.z.literal(`tool`),name:t.z.string()}).strict(),t.z.object({...r,type:t.z.literal(`notice`),message:t.z.string(),sessionId:t.z.string().nullable()}).strict(),t.z.object({...r,type:t.z.literal(`result`),subtype:t.z.string(),result:t.z.unknown(),sessionId:t.z.string().nullable()}).strict(),t.z.object({...r,type:t.z.literal(`end`),sessionId:t.z.string().nullable()}).strict(),t.z.object({...r,type:t.z.literal(`error`),message:t.z.string(),sessionId:t.z.string().nullable()}).strict(),t.z.object({...r,type:t.z.literal(`canceled`),sessionId:t.z.string().nullable()}).strict()]),e.AgentRunEventsQuerySchema=t.z.object({after:t.z.string().regex(/^\d+$/).optional(),limit:t.z.coerce.number().int().min(1).max(e.AGENT_RUN_EVENTS_MAX_LIMIT).optional()}).strict(),e.AgentRunEventsResponseSchema=t.z.object({runId:e.AgentRunIdSchema,state:e.AgentRunStateSchema,events:t.z.array(e.AgentRunEventSchema),nextCursor:t.z.string()}).strict(),e.AgentRunClientCapabilitySchema=t.z.object({client:e.AgentRunClientSchema,start:t.z.array(e.AgentRunToolsSchema),resume:t.z.array(e.AgentRunToolsSchema),resumeRequires:t.z.enum([`none`,`same_profile_provenance`])}).strict(),e.AgentRunCapabilitiesResponseSchema=t.z.object({host:t.z.literal(`same-host`),clients:t.z.array(e.AgentRunClientCapabilitySchema)}).strict(),e.FINALIZATION_MANIFEST_MAX_FILES=1e3,e.FINALIZATION_PATH_MAX_CHARS=1024,e.FINALIZATION_COMMIT_MESSAGE_MAX_CHARS=8192,e.FINALIZATION_REVIEW_ID_MAX_CHARS=200,e.FinalizationFileModeSchema=t.z.enum([`100644`,`100755`]),e.FinalizationManifestEntrySchema=t.z.object({path:t.z.string().min(1).max(e.FINALIZATION_PATH_MAX_CHARS),sha256:e.Sha256HexSchema.nullable(),mode:e.FinalizationFileModeSchema.nullable()}).strict().refine(e=>e.sha256===null==(e.mode===null),{message:`sha256 and mode are both null (deleted) or both set`}),e.AgentRunChangesResponseSchema=t.z.object({runId:e.AgentRunIdSchema,baselineRef:e.FinalizationBaselineRefSchema,baselineDigest:e.Sha256HexSchema,baseCommit:e.GitObjectIdSchema,files:t.z.array(e.FinalizationManifestEntrySchema),manifestDigest:e.Sha256HexSchema}).strict(),e.FinalizeAgentRunRequestSchema=t.z.object({baselineDigest:e.Sha256HexSchema,expectedBaseCommit:e.GitObjectIdSchema,reviewId:t.z.string().min(1).max(e.FINALIZATION_REVIEW_ID_MAX_CHARS).regex(/^[\x21-\x7e]+$/,`reviewId must be printable ASCII without spaces`),commitMessage:t.z.string().max(e.FINALIZATION_COMMIT_MESSAGE_MAX_CHARS).refine(e=>e.trim().length>0,`commitMessage must not be empty`).refine(e=>!e.includes(`\0`),`commitMessage must not contain NUL`),files:t.z.array(e.FinalizationManifestEntrySchema).min(1).max(e.FINALIZATION_MANIFEST_MAX_FILES)}).strict(),e.FinalizeAgentRunResponseSchema=t.z.object({runId:e.AgentRunIdSchema,finalizationState:t.z.literal(`finalized`),commit:e.GitObjectIdSchema,tree:e.GitObjectIdSchema,parent:e.GitObjectIdSchema,manifestDigest:e.Sha256HexSchema,fileCount:t.z.number().int().positive(),reviewId:t.z.string()}).strict(),e.AgentRunErrorCodeSchema=t.z.enum([`INVALID_REQUEST`,`REQUEST_TOO_LARGE`,`IDEMPOTENCY_KEY_REQUIRED`,`IDEMPOTENCY_CONFLICT`,`DECK_NOT_FOUND`,`WORKSPACE_INVALID`,`WORKSPACE_MISMATCH`,`CLIENT_UNAVAILABLE`,`PROFILE_UNSUPPORTED`,`RESUME_UNVERIFIED`,`RUN_NOT_FOUND`,`RUN_NOT_CANCELABLE`,`FINALIZATION_INVALID`,`FINALIZATION_NOT_PREPARED`,`RUN_NOT_TERMINAL`,`BASE_MISMATCH`,`INDEX_DIRTY`,`BASELINE_MISMATCH`,`PATH_INVALID`,`PATH_UNEXPECTED`,`DIGEST_MISMATCH`,`GIT_LOCK_CONFLICT`,`REF_RACE`,`FINALIZATION_CANCELED`,`FINALIZATION_FAILED`]);function i(e,t){return{success:!1,error:t,error_code:e}}})),$u=s((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),ed=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateId=n,e.generateShortId=r,e.isValidUUID=i;var t=Gu();function n(){return(0,t.randomUUID)()}function r(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}function i(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}})),td=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatZodError=t,e.isValidUrl=n,e.isValidHexColor=r,e.sanitizeHeaders=i;function t(e){return e.errors.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`, `)}function n(e){try{return new URL(e),!0}catch{return!1}}function r(e){return/^#[0-9A-F]{6}$/i.test(e)}function i(e){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&r.trim()&&(t[n.trim()]=r.trim());return t}})),nd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.toSnakeCase=t,e.toCamelCase=n,e.convertToSnakeCase=r,e.convertToCamelCase=i,e.serializeForDatabase=a,e.deserializeFromDatabase=o;function t(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function n(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}function r(e){let n={};for(let[r,i]of Object.entries(e)){let e=t(r);n[e]=i}return n}function i(e){let t={};for(let[r,i]of Object.entries(e)){let e=n(r);t[e]=i}return t}function a(e){let n={};for(let[r,i]of Object.entries(e))i!=null&&(typeof i==`object`&&!Array.isArray(i)?n[t(r)]=JSON.stringify(i):n[t(r)]=i);return n}function o(e){let t={};for(let[r,i]of Object.entries(e)){let e=n(r);if(typeof i==`string`&&(i.startsWith(`{`)||i.startsWith(`[`)))try{t[e]=JSON.parse(i)}catch{t[e]=i}else t[e]=i}return t}})),rd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.slugifyCredentialLabel=t,e.deriveEnvNameFromLabel=n,e.deriveCredentialIdFromLabel=r,e.deriveCredentialDefaults=i;function t(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`connection`}function n(e){let n=t(e).toUpperCase();return n.endsWith(`_API_KEY`)?n:(n.endsWith(`_API`)&&(n=n.slice(0,-4)),`${n}_API_KEY`)}function r(e){return`cred_${t(e)}`}function i(e,t){let i=e.trim();return{id:t?.id??r(i),label:i,scheme:t?.scheme??`bearer`,envName:t?.envName??n(i),tags:t?.tags??[]}}})),id=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.slugifyPlaybookTitle=t,e.derivePlaybookIdFromTitle=n,e.derivePlaybookDefaults=r;function t(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).replace(/_+/g,`_`).slice(0,48)}function n(e){return`pb_${t(e)||`playbook`}`}function r(e,t){let r=e.trim();return{title:r,id:t?.id??n(r)}}})),ad=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.buildPlaybookSearchText=o,e.detectPlaybookDependencies=s;var t=/\bcred_[a-z0-9_]+\b/g,n=/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi,r=/--connections(?:=|\s+)([^\s]+)/g;function i(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function a(e,t){let n=t.trim();return n?RegExp(`\\b${i(n)}\\b`,`i`).test(e):!1}function o(e){return[e.title??``,e.body??``,e.exec??``,e.skill??``,...e.triggers??[]].join(`
|
|
33
|
+
`)}function s(e,i,o={}){let s=new Set(o.credentialIds??[]),c=new Set(o.serviceIds??[]),l=new Set(i.credentials.map(e=>e.id)),u=new Map(i.services.map(e=>[e.id.toLowerCase(),e.id]));for(let n of e.matchAll(t)){let e=n[0];l.has(e)&&s.add(e)}for(let t of e.matchAll(r))for(let e of t[1].split(`,`)){let t=e.trim();l.has(t)&&s.add(t)}for(let t of i.credentials)t.envName&&e.includes(t.envName)&&s.add(t.id),a(e,t.label)&&s.add(t.id);for(let t of e.matchAll(n)){let e=u.get(t[0].toLowerCase());e&&c.add(e)}for(let t of i.services)a(e,t.name)&&c.add(t.id);return{dependsOnCredentialIds:[...s].sort(),dependsOnServiceIds:[...c].sort()}}})),od=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.serviceHasOAuthToken=n,e.isOAuthSessionValid=r,e.isOAuthAccessTokenExpired=i;var t=sd();function n(e){return!!(e.oauthHasToken||e.oauthAccessToken)}function r(e){return n(e)?!(0,t.isOAuthTokenExpiringSoon)(e.oauthTokenExpiresAt):!1}function i(e,t=3e5){return n(e)?e.oauthTokenExpiresAt?new Date(e.oauthTokenExpiresAt).getTime()<=Date.now()+t:!1:!0}})),sd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isOAuthTokenExpiringSoon=r,e.getServiceWarnings=o,e.getCredentialWarnings=s,e.getPlaybookWarnings=c,e.buildCollectionCatalog=l,e.summarizeCollectionWarnings=u,e.primaryCollectionWarning=d;var t=od(),n=3e5;function r(e){return e?new Date(e).getTime()<=Date.now()+n:!1}function i(e){return!!(e.oauthClientId||e.oauthAuthorizationUrl||e.oauthTokenUrl)}function a(e){return(0,t.isOAuthSessionValid)(e)}function o(e,n={}){let r=[];if(e.health===`unhealthy`){let t=e.type===`mcp`&&a(e);r.push({kind:`service_unhealthy`,message:t?`OAuth OK but MCP unreachable — for Slack, enable MCP under Agents & AI Apps in your app settings`:`Service reported unhealthy`,severity:`warning`})}if(e.type!==`mcp`||a(e)||!(n.oauthRequired===!0||i(e)))return r;if(!(e.oauthHasToken||e.oauthAccessToken))return r.push({kind:`oauth_required`,message:`OAuth authentication required`,severity:`error`}),r;if(!(0,t.isOAuthSessionValid)(e)){if(n.hasRefreshToken)return r;r.push({kind:`oauth_expired`,message:`OAuth token expired — re-authenticate`,severity:`error`})}return r}function s(e){return e.hasSecret?[]:[{kind:`credential_missing_secret`,message:`Key missing from vault — open to add or rotate`,severity:`error`}]}function c(e,t){let n=e.dependsOnCredentialIds.filter(e=>!t.credentialIds.has(e)),r=e.dependsOnServiceIds.filter(e=>!t.serviceIds.has(e)),i=n.length+r.length;return i===0?[]:[{kind:`playbook_missing_deps`,message:`${i} missing dependency reference${i===1?``:`s`}`,severity:`warning`}]}function l(e,t){return{credentialIds:new Set(e.map(e=>e.id)),serviceIds:new Set(t.map(e=>e.id))}}function u(e,t,n,r={}){let i=l(t,e),a=new Map,u=new Map,d=new Map,f={oauth_required:0,oauth_expired:0,service_unhealthy:0,credential_missing_secret:0,playbook_missing_deps:0};for(let t of e){let e=o(t,r[t.id]);if(e.length>0){a.set(t.id,e);for(let t of e)f[t.kind]+=1}}for(let e of t){let t=s(e);if(t.length>0){u.set(e.id,t);for(let e of t)f[e.kind]+=1}}for(let e of n){let t=c(e,i);if(t.length>0){d.set(e.id,t);for(let e of t)f[e.kind]+=1}}return{total:a.size+u.size+d.size,byKind:f,serviceWarnings:a,credentialWarnings:u,playbookWarnings:d}}function d(e){if(e?.length)return e.find(e=>e.severity===`error`)??e[0]}})),cd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.stripJsonMarkdownFences=i,e.normalizeLocalMcpManifestInput=a,e.parseLocalMcpManifestJson=o;function t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function n(e){return t(e)&&typeof e.command==`string`}function r(e){return!t(e)||Object.keys(e).length===0?!1:Object.values(e).every(n)}function i(e){let t=e.trim();return t.startsWith("```")?t.replace(/^```(?:json)?\s*\n?/i,``).replace(/\n?```\s*$/,``).trim():t}function a(e){if(!t(e))throw Error(`Configuration must be a JSON object`);if(t(e.config)&&r(e.config.mcpServers))return{mcpServers:e.config.mcpServers};if(r(e.mcpServers))return{mcpServers:e.mcpServers};if(t(e)&&typeof e.command==`string`){let t=typeof e.name==`string`&&e.name.trim()?e.name.trim():`local-server`,{name:r,...i}=e;if(!n(i))throw Error(`Missing or invalid command`);return{mcpServers:{[t]:i}}}if(r(e))return{mcpServers:e};throw Error(`Invalid configuration: expected a top-level "mcpServers" object. Example:
|
|
34
34
|
{
|
|
35
35
|
"mcpServers": {
|
|
36
36
|
"google-drive": {
|
|
@@ -38,15 +38,15 @@ Error generating stack: `+e.message+`
|
|
|
38
38
|
"args": ["-y", "@piotr-agier/google-drive-mcp"]
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
}`)}function o(e){let t;try{t=JSON.parse(i(e))}catch(e){throw Error(`Failed to parse JSON: ${e instanceof Error?e.message:`Unknown error`}`)}return a(t)}})),
|
|
41
|
+
}`)}function o(e){let t;try{t=JSON.parse(i(e))}catch(e){throw Error(`Failed to parse JSON: ${e instanceof Error?e.message:`Unknown error`}`)}return a(t)}})),ld=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.isAgentDeckDevMode=o,e.realAgentDeckHome=s,e.isUnderStoreRoot=d,e.resolveAgentDeckHome=m;var n=t(Gu()),r=t(Gu()),i=t(Gu()),a=`AGENT_DECK_ALLOW_REAL_HOME_IN_TESTS`;function o(){let e={}.AGENT_DECK_DEV?.trim().toLowerCase();return e===`1`||e===`true`||e===`yes`}function s(){return i.default.join(r.default.homedir(),`.agent-deck`)}function c(){let e={}.VITEST?.trim().toLowerCase();return e===`1`||e===`true`||!1}function l(e,t){return t===e||t.startsWith(`${e}${i.default.sep}`)}function u(e){try{return n.default.realpathSync(e)}catch{return e}}function d(e,t){return l(t,e)?!0:l(u(t),u(e))}function f(e){return d(e,s())}function p(){if({}.AGENT_DECK_HOME?.trim())return i.default.resolve({}.AGENT_DECK_HOME.trim());let e=s();return o()?i.default.join(e,`dev`):e}function m(){let e=p();if(c()&&{}[a]?.trim()!==`1`&&f(e))throw Error(`Refusing to use the real Agent Deck store (${e}) from a test process. Set AGENT_DECK_HOME to a temp dir for this test — each package vitest config already points the whole run at one. If the test only asserts default path resolution and writes nothing, set ${a}=1.`);return e}})),ud=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.canonicalizeWorkspacePath=a,e.digestCanonicalWorkspacePath=o,e.prefixTrustedId=s;var n=Gu(),r=t(Gu()),i=t(Gu());function a(e){let t=i.default.resolve(e),n=t;try{n=r.default.realpathSync.native(t)}catch{n=i.default.normalize(t)}return process.platform===`win32`?(n=n.replace(/^([A-Za-z]):/,(e,t)=>`${t.toLowerCase()}:`),n=n.replace(/\//g,`\\`)):n=n.replace(/\\/g,`/`),n=i.default.normalize(n),!(n===`/`||process.platform===`win32`&&/^[a-z]:\\?$/i.test(n))&&(n.endsWith(`/`)||n.endsWith(`\\`))&&(n=n.replace(/[\\/]+$/,``)),n.normalize(`NFC`)}function o(e){return(0,n.createHash)(`sha256`).update(e,`utf8`).digest(`hex`)}function s(e,t){return`${e}_${t.replace(/-/g,``)}`}})),dd=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.AGENT_DECK_GIT_EXCLUDE_PATTERNS=void 0,e.ensureGitExcluded=a;var n=Gu(),r=t(Gu()),i=t(Gu());e.AGENT_DECK_GIT_EXCLUDE_PATTERNS=[`/.agent-deck/`,`/.cursor/rules/agent-deck-stubs/`,`/.claude/skills/agent-deck-*/`];function a(t,a=e.AGENT_DECK_GIT_EXCLUDE_PATTERNS){if(a.length===0)return;let o;try{o=(0,n.execFileSync)(`git`,[`-C`,t,`rev-parse`,`--git-path`,`info/exclude`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{return}if(!o)return;let s=i.default.isAbsolute(o)?o:i.default.resolve(t,o);r.default.mkdirSync(i.default.dirname(s),{recursive:!0});let c=``;try{c=r.default.readFileSync(s,`utf8`)}catch(e){if(e.code!==`ENOENT`)throw e}let l=new Set(c.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`))),u=a.filter(e=>!l.has(e));if(u.length===0)return;let d=c.length===0||c.endsWith(`
|
|
42
42
|
`)?``:`
|
|
43
43
|
`;r.default.writeFileSync(s,`${d}${u.join(`
|
|
44
|
-
`)}\n`,`utf8`)}})),dd=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n($u(),e),n(ed(),e),n(td(),e),n(nd(),e),n(rd(),e),n(id(),e),n(od(),e),n(ad(),e),n(sd(),e),n(cd(),e),n(zu(),e),n(ld(),e),n(ud(),e)})),fd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AGENT_DECK_BRIDGE_LIVENESS_V1=e.AGENT_DECK_BRIDGE_LIVENESS_HEADER=e.AGENT_DECK_RECOVERED_SESSION_HEADER=e.AGENT_DECK_CORRELATION_HEADER=e.AGENT_DECK_DECK_ID_HEADER=e.AGENT_DECK_WORKSPACE_HEADER=e.AGENT_DECK_AGENT_CLIENT=e.AGENT_DECK_DASHBOARD_CLIENT=e.AGENT_DECK_CLIENT_HEADER=void 0,e.AGENT_DECK_CLIENT_HEADER=`x-agent-deck-client`,e.AGENT_DECK_DASHBOARD_CLIENT=`dashboard`,e.AGENT_DECK_AGENT_CLIENT=`agent`,e.AGENT_DECK_WORKSPACE_HEADER=`x-agent-deck-workspace`,e.AGENT_DECK_DECK_ID_HEADER=`x-agent-deck-deck-id`,e.AGENT_DECK_CORRELATION_HEADER=`x-agent-deck-correlation-id`,e.AGENT_DECK_RECOVERED_SESSION_HEADER=`x-agent-deck-recovered-session`,e.AGENT_DECK_BRIDGE_LIVENESS_HEADER=`x-agent-deck-bridge-liveness`,e.AGENT_DECK_BRIDGE_LIVENESS_V1=`1`})),pd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DASHBOARD_COOKIE_MAX_AGE_MS=e.DASHBOARD_SESSION_LEASE_MS=e.DASHBOARD_NONCE_TTL_MS=e.ADMIN_CHALLENGE_TTL_MS=e.ADMIN_MODE_LEASE_MS=e.RUNTIME_SESSION_LEASE_MS=e.AGENT_DECK_DASHBOARD_COOKIE=e.AGENT_DECK_SESSION_HEADER=void 0,e.AGENT_DECK_SESSION_HEADER=`x-agent-deck-session-id`,e.AGENT_DECK_DASHBOARD_COOKIE=`agent_deck_dashboard`,e.RUNTIME_SESSION_LEASE_MS=864e5,e.ADMIN_MODE_LEASE_MS=18e5,e.ADMIN_CHALLENGE_TTL_MS=3e5,e.DASHBOARD_NONCE_TTL_MS=12e4,e.DASHBOARD_SESSION_LEASE_MS=864e5,e.DASHBOARD_COOKIE_MAX_AGE_MS=2592e6})),md=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PLAYBOOK_CARD_COLOR=e.API_KEY_CARD_COLOR=e.MCP_CARD_COLOR=void 0,e.getServiceCardColor=t,e.MCP_CARD_COLOR=`#92E4DD`,e.API_KEY_CARD_COLOR=`#F9386D`,e.PLAYBOOK_CARD_COLOR=`#FFFFFF`;function t(t){return t.cardColor,e.MCP_CARD_COLOR}})),hd=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.getServiceCardColor=e.PLAYBOOK_CARD_COLOR=e.API_KEY_CARD_COLOR=e.MCP_CARD_COLOR=e.DASHBOARD_COOKIE_MAX_AGE_MS=e.DASHBOARD_SESSION_LEASE_MS=e.DASHBOARD_NONCE_TTL_MS=e.ADMIN_CHALLENGE_TTL_MS=e.ADMIN_MODE_LEASE_MS=e.RUNTIME_SESSION_LEASE_MS=e.AGENT_DECK_DASHBOARD_COOKIE=e.AGENT_DECK_SESSION_HEADER=e.AGENT_DECK_BRIDGE_LIVENESS_V1=e.AGENT_DECK_BRIDGE_LIVENESS_HEADER=e.AGENT_DECK_RECOVERED_SESSION_HEADER=e.AGENT_DECK_CORRELATION_HEADER=e.AGENT_DECK_DECK_ID_HEADER=e.AGENT_DECK_WORKSPACE_HEADER=e.AGENT_DECK_AGENT_CLIENT=e.AGENT_DECK_DASHBOARD_CLIENT=e.AGENT_DECK_CLIENT_HEADER=e.stripJsonMarkdownFences=e.parseLocalMcpManifestJson=e.normalizeLocalMcpManifestInput=e.primaryCollectionWarning=e.getPlaybookWarnings=e.getCredentialWarnings=e.getServiceWarnings=e.summarizeCollectionWarnings=void 0,n(Lu(),e),n(Vu(),e),n(Ru(),e),n(Hu(),e),n(Bu(),e),n(Uu(),e),n(Wu(),e),n(Ku(),e),n(qu(),e),n(Ju(),e),n(Yu(),e),n(Xu(),e),n(Zu(),e),n(Qu(),e),n(dd(),e);var r=od();Object.defineProperty(e,"summarizeCollectionWarnings",{enumerable:!0,get:function(){return r.summarizeCollectionWarnings}}),Object.defineProperty(e,"getServiceWarnings",{enumerable:!0,get:function(){return r.getServiceWarnings}}),Object.defineProperty(e,"getCredentialWarnings",{enumerable:!0,get:function(){return r.getCredentialWarnings}}),Object.defineProperty(e,"getPlaybookWarnings",{enumerable:!0,get:function(){return r.getPlaybookWarnings}}),Object.defineProperty(e,"primaryCollectionWarning",{enumerable:!0,get:function(){return r.primaryCollectionWarning}});var i=sd();Object.defineProperty(e,"normalizeLocalMcpManifestInput",{enumerable:!0,get:function(){return i.normalizeLocalMcpManifestInput}}),Object.defineProperty(e,"parseLocalMcpManifestJson",{enumerable:!0,get:function(){return i.parseLocalMcpManifestJson}}),Object.defineProperty(e,"stripJsonMarkdownFences",{enumerable:!0,get:function(){return i.stripJsonMarkdownFences}});var a=fd();Object.defineProperty(e,"AGENT_DECK_CLIENT_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_CLIENT_HEADER}}),Object.defineProperty(e,"AGENT_DECK_DASHBOARD_CLIENT",{enumerable:!0,get:function(){return a.AGENT_DECK_DASHBOARD_CLIENT}}),Object.defineProperty(e,"AGENT_DECK_AGENT_CLIENT",{enumerable:!0,get:function(){return a.AGENT_DECK_AGENT_CLIENT}}),Object.defineProperty(e,"AGENT_DECK_WORKSPACE_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_WORKSPACE_HEADER}}),Object.defineProperty(e,"AGENT_DECK_DECK_ID_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_DECK_ID_HEADER}}),Object.defineProperty(e,"AGENT_DECK_CORRELATION_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_CORRELATION_HEADER}}),Object.defineProperty(e,"AGENT_DECK_RECOVERED_SESSION_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_RECOVERED_SESSION_HEADER}}),Object.defineProperty(e,"AGENT_DECK_BRIDGE_LIVENESS_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_BRIDGE_LIVENESS_HEADER}}),Object.defineProperty(e,"AGENT_DECK_BRIDGE_LIVENESS_V1",{enumerable:!0,get:function(){return a.AGENT_DECK_BRIDGE_LIVENESS_V1}});var o=pd();Object.defineProperty(e,"AGENT_DECK_SESSION_HEADER",{enumerable:!0,get:function(){return o.AGENT_DECK_SESSION_HEADER}}),Object.defineProperty(e,"AGENT_DECK_DASHBOARD_COOKIE",{enumerable:!0,get:function(){return o.AGENT_DECK_DASHBOARD_COOKIE}}),Object.defineProperty(e,"RUNTIME_SESSION_LEASE_MS",{enumerable:!0,get:function(){return o.RUNTIME_SESSION_LEASE_MS}}),Object.defineProperty(e,"ADMIN_MODE_LEASE_MS",{enumerable:!0,get:function(){return o.ADMIN_MODE_LEASE_MS}}),Object.defineProperty(e,"ADMIN_CHALLENGE_TTL_MS",{enumerable:!0,get:function(){return o.ADMIN_CHALLENGE_TTL_MS}}),Object.defineProperty(e,"DASHBOARD_NONCE_TTL_MS",{enumerable:!0,get:function(){return o.DASHBOARD_NONCE_TTL_MS}}),Object.defineProperty(e,"DASHBOARD_SESSION_LEASE_MS",{enumerable:!0,get:function(){return o.DASHBOARD_SESSION_LEASE_MS}}),Object.defineProperty(e,"DASHBOARD_COOKIE_MAX_AGE_MS",{enumerable:!0,get:function(){return o.DASHBOARD_COOKIE_MAX_AGE_MS}});var s=md();Object.defineProperty(e,"MCP_CARD_COLOR",{enumerable:!0,get:function(){return s.MCP_CARD_COLOR}}),Object.defineProperty(e,"API_KEY_CARD_COLOR",{enumerable:!0,get:function(){return s.API_KEY_CARD_COLOR}}),Object.defineProperty(e,"PLAYBOOK_CARD_COLOR",{enumerable:!0,get:function(){return s.PLAYBOOK_CARD_COLOR}}),Object.defineProperty(e,"getServiceCardColor",{enumerable:!0,get:function(){return s.getServiceCardColor}})}))(),gd=`focusScope.autoFocusOnMount`,_d=`focusScope.autoFocusOnUnmount`,vd={bubbles:!1,cancelable:!0},yd=`FocusScope`,bd=b.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=b.useState(null),l=wn(i),u=wn(a),d=b.useRef(null),f=ln(t,e=>c(e)),p=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Dd(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Dd(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Dd(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),b.useEffect(()=>{if(s){Od.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(gd,vd);s.addEventListener(gd,l),s.dispatchEvent(t),t.defaultPrevented||(xd(jd(Cd(s)),{select:!0}),document.activeElement===e&&Dd(s))}return()=>{s.removeEventListener(gd,l),setTimeout(()=>{let t=new CustomEvent(_d,vd);s.addEventListener(_d,u),s.dispatchEvent(t),t.defaultPrevented||Dd(e??document.body,{select:!0}),s.removeEventListener(_d,u),Od.remove(p)},0)}}},[s,l,u,p]);let m=b.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Sd(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Dd(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Dd(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,H.jsx)(Sn.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});bd.displayName=yd;function xd(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Dd(r,{select:t}),document.activeElement!==n)return}function Sd(e){let t=Cd(e);return[wd(t,e),wd(t.reverse(),e)]}function Cd(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function wd(e,t){for(let n of e)if(!Td(n,{upTo:t}))return n}function Td(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Ed(e){return e instanceof HTMLInputElement&&`select`in e}function Dd(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ed(e)&&t&&e.select()}}var Od=kd();function kd(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Ad(e,t),e.unshift(t)},remove(t){e=Ad(e,t),e[0]?.resume()}}}function Ad(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function jd(e){return e.filter(e=>e.tagName!==`A`)}var Md=0;function Nd(){b.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Pd()),document.body.insertAdjacentElement(`beforeend`,e[1]??Pd()),Md++,()=>{Md===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Md--}},[])}function Pd(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Fd=function(){return Fd=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Fd.apply(this,arguments)};function Id(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Ld(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Rd=`right-scroll-bar-position`,zd=`width-before-scroll-bar`,Bd=`with-scroll-bars-hidden`,Vd=`--removed-body-scroll-bar-size`;function Hd(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ud(e,t){var n=(0,b.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Wd=typeof window<`u`?b.useLayoutEffect:b.useEffect,Gd=new WeakMap;function Kd(e,t){var n=Ud(t||null,function(t){return e.forEach(function(e){return Hd(e,t)})});return Wd(function(){var t=Gd.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Hd(e,null)}),i.forEach(function(e){r.has(e)||Hd(e,a)})}Gd.set(n,e)},[e]),n}function qd(e){return e}function Jd(e,t){t===void 0&&(t=qd);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Yd(e){e===void 0&&(e={});var t=Jd(null);return t.options=Fd({async:!0,ssr:!1},e),t}var Xd=function(e){var t=e.sideCar,n=Id(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return b.createElement(r,Fd({},n))};Xd.isSideCarExport=!0;function Zd(e,t){return e.useMedium(t),Xd}var Qd=Yd(),$d=function(){},ef=b.forwardRef(function(e,t){var n=b.useRef(null),r=b.useState({onScrollCapture:$d,onWheelCapture:$d,onTouchMoveCapture:$d}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,x=Id(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=Kd([n,t]),w=Fd(Fd({},x),i);return b.createElement(b.Fragment,null,u&&b.createElement(S,{sideCar:Qd,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?b.cloneElement(b.Children.only(s),Fd(Fd({},w),{ref:C})):b.createElement(v,Fd({},w,{className:c,ref:C}),s))});ef.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ef.classNames={fullWidth:zd,zeroRight:Rd};var tf=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function nf(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=tf();return t&&e.setAttribute(`nonce`,t),e}function rf(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function af(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var of=function(){var e=0,t=null;return{add:function(n){e==0&&(t=nf())&&(rf(t,n),af(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},sf=function(){var e=of();return function(t,n){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},cf=function(){var e=sf();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},lf={left:0,top:0,right:0,gap:0},uf=function(e){return parseInt(e||``,10)||0},df=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[uf(n),uf(r),uf(i)]},ff=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return lf;var t=df(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},pf=cf(),mf=`data-scroll-locked`,hf=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
45
|
-
.${
|
|
44
|
+
`)}\n`,`utf8`)}})),fd=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),n(ed(),e),n(td(),e),n(nd(),e),n(rd(),e),n(id(),e),n(ad(),e),n(sd(),e),n(od(),e),n(cd(),e),n(ld(),e),n(zu(),e),n(ud(),e),n(dd(),e)})),pd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AGENT_DECK_BRIDGE_LIVENESS_V1=e.AGENT_DECK_BRIDGE_LIVENESS_HEADER=e.AGENT_DECK_RECOVERED_SESSION_HEADER=e.AGENT_DECK_CORRELATION_HEADER=e.AGENT_DECK_DECK_ID_HEADER=e.AGENT_DECK_WORKSPACE_HEADER=e.AGENT_DECK_AGENT_CLIENT=e.AGENT_DECK_DASHBOARD_CLIENT=e.AGENT_DECK_CLIENT_HEADER=void 0,e.AGENT_DECK_CLIENT_HEADER=`x-agent-deck-client`,e.AGENT_DECK_DASHBOARD_CLIENT=`dashboard`,e.AGENT_DECK_AGENT_CLIENT=`agent`,e.AGENT_DECK_WORKSPACE_HEADER=`x-agent-deck-workspace`,e.AGENT_DECK_DECK_ID_HEADER=`x-agent-deck-deck-id`,e.AGENT_DECK_CORRELATION_HEADER=`x-agent-deck-correlation-id`,e.AGENT_DECK_RECOVERED_SESSION_HEADER=`x-agent-deck-recovered-session`,e.AGENT_DECK_BRIDGE_LIVENESS_HEADER=`x-agent-deck-bridge-liveness`,e.AGENT_DECK_BRIDGE_LIVENESS_V1=`1`})),md=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DASHBOARD_COOKIE_MAX_AGE_MS=e.DASHBOARD_SESSION_LEASE_MS=e.DASHBOARD_NONCE_TTL_MS=e.ADMIN_CHALLENGE_TTL_MS=e.ADMIN_MODE_LEASE_MS=e.RUNTIME_SESSION_LEASE_MS=e.AGENT_DECK_DASHBOARD_COOKIE=e.AGENT_DECK_SESSION_HEADER=void 0,e.AGENT_DECK_SESSION_HEADER=`x-agent-deck-session-id`,e.AGENT_DECK_DASHBOARD_COOKIE=`agent_deck_dashboard`,e.RUNTIME_SESSION_LEASE_MS=864e5,e.ADMIN_MODE_LEASE_MS=18e5,e.ADMIN_CHALLENGE_TTL_MS=3e5,e.DASHBOARD_NONCE_TTL_MS=12e4,e.DASHBOARD_SESSION_LEASE_MS=864e5,e.DASHBOARD_COOKIE_MAX_AGE_MS=2592e6})),hd=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PLAYBOOK_CARD_COLOR=e.API_KEY_CARD_COLOR=e.MCP_CARD_COLOR=void 0,e.getServiceCardColor=t,e.MCP_CARD_COLOR=`#92E4DD`,e.API_KEY_CARD_COLOR=`#F9386D`,e.PLAYBOOK_CARD_COLOR=`#FFFFFF`;function t(t){return t.cardColor,e.MCP_CARD_COLOR}})),gd=s((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.getServiceCardColor=e.PLAYBOOK_CARD_COLOR=e.API_KEY_CARD_COLOR=e.MCP_CARD_COLOR=e.DASHBOARD_COOKIE_MAX_AGE_MS=e.DASHBOARD_SESSION_LEASE_MS=e.DASHBOARD_NONCE_TTL_MS=e.ADMIN_CHALLENGE_TTL_MS=e.ADMIN_MODE_LEASE_MS=e.RUNTIME_SESSION_LEASE_MS=e.AGENT_DECK_DASHBOARD_COOKIE=e.AGENT_DECK_SESSION_HEADER=e.AGENT_DECK_BRIDGE_LIVENESS_V1=e.AGENT_DECK_BRIDGE_LIVENESS_HEADER=e.AGENT_DECK_RECOVERED_SESSION_HEADER=e.AGENT_DECK_CORRELATION_HEADER=e.AGENT_DECK_DECK_ID_HEADER=e.AGENT_DECK_WORKSPACE_HEADER=e.AGENT_DECK_AGENT_CLIENT=e.AGENT_DECK_DASHBOARD_CLIENT=e.AGENT_DECK_CLIENT_HEADER=e.stripJsonMarkdownFences=e.parseLocalMcpManifestJson=e.normalizeLocalMcpManifestInput=e.primaryCollectionWarning=e.getPlaybookWarnings=e.getCredentialWarnings=e.getServiceWarnings=e.summarizeCollectionWarnings=void 0,n(Lu(),e),n(Vu(),e),n(Ru(),e),n(Hu(),e),n(Bu(),e),n(Uu(),e),n(Wu(),e),n(Ku(),e),n(qu(),e),n(Ju(),e),n(Yu(),e),n(Xu(),e),n(Zu(),e),n(Qu(),e),n($u(),e),n(fd(),e);var r=sd();Object.defineProperty(e,"summarizeCollectionWarnings",{enumerable:!0,get:function(){return r.summarizeCollectionWarnings}}),Object.defineProperty(e,"getServiceWarnings",{enumerable:!0,get:function(){return r.getServiceWarnings}}),Object.defineProperty(e,"getCredentialWarnings",{enumerable:!0,get:function(){return r.getCredentialWarnings}}),Object.defineProperty(e,"getPlaybookWarnings",{enumerable:!0,get:function(){return r.getPlaybookWarnings}}),Object.defineProperty(e,"primaryCollectionWarning",{enumerable:!0,get:function(){return r.primaryCollectionWarning}});var i=cd();Object.defineProperty(e,"normalizeLocalMcpManifestInput",{enumerable:!0,get:function(){return i.normalizeLocalMcpManifestInput}}),Object.defineProperty(e,"parseLocalMcpManifestJson",{enumerable:!0,get:function(){return i.parseLocalMcpManifestJson}}),Object.defineProperty(e,"stripJsonMarkdownFences",{enumerable:!0,get:function(){return i.stripJsonMarkdownFences}});var a=pd();Object.defineProperty(e,"AGENT_DECK_CLIENT_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_CLIENT_HEADER}}),Object.defineProperty(e,"AGENT_DECK_DASHBOARD_CLIENT",{enumerable:!0,get:function(){return a.AGENT_DECK_DASHBOARD_CLIENT}}),Object.defineProperty(e,"AGENT_DECK_AGENT_CLIENT",{enumerable:!0,get:function(){return a.AGENT_DECK_AGENT_CLIENT}}),Object.defineProperty(e,"AGENT_DECK_WORKSPACE_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_WORKSPACE_HEADER}}),Object.defineProperty(e,"AGENT_DECK_DECK_ID_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_DECK_ID_HEADER}}),Object.defineProperty(e,"AGENT_DECK_CORRELATION_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_CORRELATION_HEADER}}),Object.defineProperty(e,"AGENT_DECK_RECOVERED_SESSION_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_RECOVERED_SESSION_HEADER}}),Object.defineProperty(e,"AGENT_DECK_BRIDGE_LIVENESS_HEADER",{enumerable:!0,get:function(){return a.AGENT_DECK_BRIDGE_LIVENESS_HEADER}}),Object.defineProperty(e,"AGENT_DECK_BRIDGE_LIVENESS_V1",{enumerable:!0,get:function(){return a.AGENT_DECK_BRIDGE_LIVENESS_V1}});var o=md();Object.defineProperty(e,"AGENT_DECK_SESSION_HEADER",{enumerable:!0,get:function(){return o.AGENT_DECK_SESSION_HEADER}}),Object.defineProperty(e,"AGENT_DECK_DASHBOARD_COOKIE",{enumerable:!0,get:function(){return o.AGENT_DECK_DASHBOARD_COOKIE}}),Object.defineProperty(e,"RUNTIME_SESSION_LEASE_MS",{enumerable:!0,get:function(){return o.RUNTIME_SESSION_LEASE_MS}}),Object.defineProperty(e,"ADMIN_MODE_LEASE_MS",{enumerable:!0,get:function(){return o.ADMIN_MODE_LEASE_MS}}),Object.defineProperty(e,"ADMIN_CHALLENGE_TTL_MS",{enumerable:!0,get:function(){return o.ADMIN_CHALLENGE_TTL_MS}}),Object.defineProperty(e,"DASHBOARD_NONCE_TTL_MS",{enumerable:!0,get:function(){return o.DASHBOARD_NONCE_TTL_MS}}),Object.defineProperty(e,"DASHBOARD_SESSION_LEASE_MS",{enumerable:!0,get:function(){return o.DASHBOARD_SESSION_LEASE_MS}}),Object.defineProperty(e,"DASHBOARD_COOKIE_MAX_AGE_MS",{enumerable:!0,get:function(){return o.DASHBOARD_COOKIE_MAX_AGE_MS}});var s=hd();Object.defineProperty(e,"MCP_CARD_COLOR",{enumerable:!0,get:function(){return s.MCP_CARD_COLOR}}),Object.defineProperty(e,"API_KEY_CARD_COLOR",{enumerable:!0,get:function(){return s.API_KEY_CARD_COLOR}}),Object.defineProperty(e,"PLAYBOOK_CARD_COLOR",{enumerable:!0,get:function(){return s.PLAYBOOK_CARD_COLOR}}),Object.defineProperty(e,"getServiceCardColor",{enumerable:!0,get:function(){return s.getServiceCardColor}})}))(),_d=`focusScope.autoFocusOnMount`,vd=`focusScope.autoFocusOnUnmount`,yd={bubbles:!1,cancelable:!0},bd=`FocusScope`,xd=b.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=b.useState(null),l=wn(i),u=wn(a),d=b.useRef(null),f=ln(t,e=>c(e)),p=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Od(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Od(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Od(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),b.useEffect(()=>{if(s){kd.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(_d,yd);s.addEventListener(_d,l),s.dispatchEvent(t),t.defaultPrevented||(Sd(Md(wd(s)),{select:!0}),document.activeElement===e&&Od(s))}return()=>{s.removeEventListener(_d,l),setTimeout(()=>{let t=new CustomEvent(vd,yd);s.addEventListener(vd,u),s.dispatchEvent(t),t.defaultPrevented||Od(e??document.body,{select:!0}),s.removeEventListener(vd,u),kd.remove(p)},0)}}},[s,l,u,p]);let m=b.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Cd(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Od(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Od(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,H.jsx)(Sn.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});xd.displayName=bd;function Sd(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Od(r,{select:t}),document.activeElement!==n)return}function Cd(e){let t=wd(e);return[Td(t,e),Td(t.reverse(),e)]}function wd(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Td(e,t){for(let n of e)if(!Ed(n,{upTo:t}))return n}function Ed(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Dd(e){return e instanceof HTMLInputElement&&`select`in e}function Od(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Dd(e)&&t&&e.select()}}var kd=Ad();function Ad(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=jd(e,t),e.unshift(t)},remove(t){e=jd(e,t),e[0]?.resume()}}}function jd(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Md(e){return e.filter(e=>e.tagName!==`A`)}var Nd=0;function Pd(){b.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Fd()),document.body.insertAdjacentElement(`beforeend`,e[1]??Fd()),Nd++,()=>{Nd===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Nd--}},[])}function Fd(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Id=function(){return Id=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Id.apply(this,arguments)};function Ld(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Rd(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var zd=`right-scroll-bar-position`,Bd=`width-before-scroll-bar`,Vd=`with-scroll-bars-hidden`,Hd=`--removed-body-scroll-bar-size`;function Ud(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Wd(e,t){var n=(0,b.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Gd=typeof window<`u`?b.useLayoutEffect:b.useEffect,Kd=new WeakMap;function qd(e,t){var n=Wd(t||null,function(t){return e.forEach(function(e){return Ud(e,t)})});return Gd(function(){var t=Kd.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Ud(e,null)}),i.forEach(function(e){r.has(e)||Ud(e,a)})}Kd.set(n,e)},[e]),n}function Jd(e){return e}function Yd(e,t){t===void 0&&(t=Jd);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Xd(e){e===void 0&&(e={});var t=Yd(null);return t.options=Id({async:!0,ssr:!1},e),t}var Zd=function(e){var t=e.sideCar,n=Ld(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return b.createElement(r,Id({},n))};Zd.isSideCarExport=!0;function Qd(e,t){return e.useMedium(t),Zd}var $d=Xd(),ef=function(){},tf=b.forwardRef(function(e,t){var n=b.useRef(null),r=b.useState({onScrollCapture:ef,onWheelCapture:ef,onTouchMoveCapture:ef}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,x=Ld(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),S=f,C=qd([n,t]),w=Id(Id({},x),i);return b.createElement(b.Fragment,null,u&&b.createElement(S,{sideCar:$d,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?b.cloneElement(b.Children.only(s),Id(Id({},w),{ref:C})):b.createElement(v,Id({},w,{className:c,ref:C}),s))});tf.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},tf.classNames={fullWidth:Bd,zeroRight:zd};var nf=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function rf(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=nf();return t&&e.setAttribute(`nonce`,t),e}function af(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function of(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var sf=function(){var e=0,t=null;return{add:function(n){e==0&&(t=rf())&&(af(t,n),of(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cf=function(){var e=sf();return function(t,n){b.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},lf=function(){var e=cf();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},uf={left:0,top:0,right:0,gap:0},df=function(e){return parseInt(e||``,10)||0},ff=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[df(n),df(r),df(i)]},pf=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return uf;var t=ff(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},mf=lf(),hf=`data-scroll-locked`,gf=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
45
|
+
.${Vd} {
|
|
46
46
|
overflow: hidden ${r};
|
|
47
47
|
padding-right: ${s}px ${r};
|
|
48
48
|
}
|
|
49
|
-
body[${
|
|
49
|
+
body[${hf}] {
|
|
50
50
|
overflow: hidden ${r};
|
|
51
51
|
overscroll-behavior: contain;
|
|
52
52
|
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
@@ -59,35 +59,35 @@ Error generating stack: `+e.message+`
|
|
|
59
59
|
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
.${
|
|
62
|
+
.${zd} {
|
|
63
63
|
right: ${s}px ${r};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
.${
|
|
66
|
+
.${Bd} {
|
|
67
67
|
margin-right: ${s}px ${r};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
.${
|
|
70
|
+
.${zd} .${zd} {
|
|
71
71
|
right: 0 ${r};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
.${
|
|
74
|
+
.${Bd} .${Bd} {
|
|
75
75
|
margin-right: 0 ${r};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
body[${
|
|
79
|
-
${
|
|
78
|
+
body[${hf}] {
|
|
79
|
+
${Hd}: ${s}px;
|
|
80
80
|
}
|
|
81
|
-
`},
|
|
81
|
+
`},_f=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},vf=function(){b.useEffect(function(){return document.body.setAttribute(hf,(_f()+1).toString()),function(){var e=_f()-1;e<=0?document.body.removeAttribute(hf):document.body.setAttribute(hf,e.toString())}},[])},yf=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;vf();var a=b.useMemo(function(){return pf(i)},[i]);return b.createElement(mf,{styles:gf(a,!t,i,n?``:`!important`)})},bf=!1;if(typeof window<`u`)try{var xf=Object.defineProperty({},"passive",{get:function(){return bf=!0,!0}});window.addEventListener(`test`,xf,xf),window.removeEventListener(`test`,xf,xf)}catch{bf=!1}var Sf=bf?{passive:!1}:!1,Cf=function(e){return e.tagName===`TEXTAREA`},wf=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Cf(e)&&n[t]===`visible`)},Tf=function(e){return wf(e,`overflowY`)},Ef=function(e){return wf(e,`overflowX`)},Df=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Af(e,r)){var i=jf(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Of=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},kf=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Af=function(e,t){return e===`v`?Tf(t):Ef(t)},jf=function(e,t){return e===`v`?Of(t):kf(t)},Mf=function(e,t){return e===`h`&&t===`rtl`?-1:1},Nf=function(e,t,n,r,i){var a=Mf(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=jf(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Af(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Pf=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Ff=function(e){return[e.deltaX,e.deltaY]},If=function(e){return e&&`current`in e?e.current:e},Lf=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Rf=function(e){return`
|
|
82
82
|
.block-interactivity-${e} {pointer-events: none;}
|
|
83
83
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
84
|
-
`},
|
|
84
|
+
`},zf=0,Bf=[];function Vf(e){var t=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(zf++)[0],a=b.useState(lf)[0],o=b.useRef(e);b.useEffect(function(){o.current=e},[e]),b.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Rd([e.lockRef.current],(e.shards||[]).map(If),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=b.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Pf(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=Df(d,u);if(!f)return!0;if(f?l=d:(l=d===`v`?`h`:`v`,f=Df(d,u)),!f)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var p=r.current||l;return Nf(p,t,e,p===`h`?s:c,!0)},[]),c=b.useCallback(function(e){var n=e;if(Bf.length&&Bf[Bf.length-1]===a){var r=`deltaY`in n?Ff(n):Pf(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Lf(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(If).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=b.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Hf(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=b.useCallback(function(e){n.current=Pf(e),r.current=void 0},[]),d=b.useCallback(function(t){l(t.type,Ff(t),t.target,s(t,e.lockRef.current))},[]),f=b.useCallback(function(t){l(t.type,Pf(t),t.target,s(t,e.lockRef.current))},[]);b.useEffect(function(){return Bf.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Sf),document.addEventListener(`touchmove`,c,Sf),document.addEventListener(`touchstart`,u,Sf),function(){Bf=Bf.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Sf),document.removeEventListener(`touchmove`,c,Sf),document.removeEventListener(`touchstart`,u,Sf)}},[]);var p=e.removeScrollBar,m=e.inert;return b.createElement(b.Fragment,null,m?b.createElement(a,{styles:Rf(i)}):null,p?b.createElement(yf,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Hf(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Uf=Qd($d,Vf),Wf=b.forwardRef(function(e,t){return b.createElement(tf,Id({},e,{ref:t,sideCar:Uf}))});Wf.classNames=tf.classNames;var Gf=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Kf=new WeakMap,qf=new WeakMap,Jf={},Yf=0,Xf=function(e){return e&&(e.host||Xf(e.parentNode))},Zf=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Xf(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Qf=function(e,t,n,r){var i=Zf(t,Array.isArray(e)?e:[e]);Jf[n]||(Jf[n]=new WeakMap);var a=Jf[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(Kf.get(e)||0)+1,l=(a.get(e)||0)+1;Kf.set(e,c),a.set(e,l),o.push(e),c===1&&i&&qf.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Yf++,function(){o.forEach(function(e){var t=Kf.get(e)-1,i=a.get(e)-1;Kf.set(e,t),a.set(e,i),t||(qf.has(e)||e.removeAttribute(r),qf.delete(e)),i||e.removeAttribute(n)}),Yf--,Yf||(Kf=new WeakMap,Kf=new WeakMap,qf=new WeakMap,Jf={})}},$f=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Gf(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Qf(r,i,n,`aria-hidden`)):function(){return null}},ep=`Dialog`,[tp,np]=dn(ep),[rp,ip]=tp(ep),ap=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=b.useRef(null),c=b.useRef(null),[l,u]=Xn({prop:r,defaultProp:i??!1,onChange:a,caller:ep});return(0,H.jsx)(rp,{scope:t,triggerRef:s,contentRef:c,contentId:oo(),titleId:oo(),descriptionId:oo(),open:l,onOpenChange:u,onOpenToggle:b.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};ap.displayName=ep;var op=`DialogTrigger`,sp=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ip(op,n),a=ln(t,i.triggerRef);return(0,H.jsx)(Sn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Dp(i.open),...r,ref:a,onClick:W(e.onClick,i.onOpenToggle)})});sp.displayName=op;var cp=`DialogPortal`,[lp,up]=tp(cp,{forceMount:void 0}),dp=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ip(cp,t);return(0,H.jsx)(lp,{scope:t,forceMount:n,children:b.Children.map(r,e=>(0,H.jsx)(Gn,{present:n||a.open,children:(0,H.jsx)(Un,{asChild:!0,container:i,children:e})}))})};dp.displayName=cp;var fp=`DialogOverlay`,pp=b.forwardRef((e,t)=>{let n=up(fp,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ip(fp,e.__scopeDialog);return a.modal?(0,H.jsx)(Gn,{present:r||a.open,children:(0,H.jsx)(hp,{...i,ref:t})}):null});pp.displayName=fp;var mp=pn(`DialogOverlay.RemoveScroll`),hp=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ip(fp,n);return(0,H.jsx)(Wf,{as:mp,allowPinchZoom:!0,shards:[i.contentRef],children:(0,H.jsx)(Sn.div,{"data-state":Dp(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),gp=`DialogContent`,_p=b.forwardRef((e,t)=>{let n=up(gp,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ip(gp,e.__scopeDialog);return(0,H.jsx)(Gn,{present:r||a.open,children:a.modal?(0,H.jsx)(vp,{...i,ref:t}):(0,H.jsx)(yp,{...i,ref:t})})});_p.displayName=gp;var vp=b.forwardRef((e,t)=>{let n=ip(gp,e.__scopeDialog),r=b.useRef(null),i=ln(t,n.contentRef,r);return b.useEffect(()=>{let e=r.current;if(e)return $f(e)},[]),(0,H.jsx)(bp,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:W(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault())})}),yp=b.forwardRef((e,t)=>{let n=ip(gp,e.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return(0,H.jsx)(bp,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),bp=b.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ip(gp,n),c=b.useRef(null),l=ln(t,c);return Pd(),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(xd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,H.jsx)(Mn,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Dp(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(jp,{titleId:s.titleId}),(0,H.jsx)(Np,{contentRef:c,descriptionId:s.descriptionId})]})]})}),xp=`DialogTitle`,Sp=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ip(xp,n);return(0,H.jsx)(Sn.h2,{id:i.titleId,...r,ref:t})});Sp.displayName=xp;var Cp=`DialogDescription`,wp=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ip(Cp,n);return(0,H.jsx)(Sn.p,{id:i.descriptionId,...r,ref:t})});wp.displayName=Cp;var Tp=`DialogClose`,Ep=b.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ip(Tp,n);return(0,H.jsx)(Sn.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,()=>i.onOpenChange(!1))})});Ep.displayName=Tp;function Dp(e){return e?`open`:`closed`}var Op=`DialogTitleWarning`,[kp,Ap]=un(Op,{contentName:gp,titleName:xp,docsSlug:`dialog`}),jp=({titleId:e})=>{let t=Ap(Op),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
85
85
|
|
|
86
86
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
87
87
|
|
|
88
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},
|
|
88
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Mp=`DialogDescriptionWarning`,Np=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ap(Mp).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Pp=ap,Fp=dp,Ip=pp,Lp=_p,Rp=Sp,zp=wp,Bp=Ep,Vp=Pp,Hp=Fp,Up=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Ip,{ref:n,className:Ja(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Up.displayName=Ip.displayName;var Wp=b.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(Hp,{children:[(0,H.jsx)(Up,{}),(0,H.jsxs)(Lp,{ref:r,className:Ja(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...n,children:[t,(0,H.jsxs)(Bp,{className:`absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground`,children:[(0,H.jsx)(Zi,{className:`h-4 w-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]}));Wp.displayName=Lp.displayName;var Gp=({className:e,...t})=>(0,H.jsx)(`div`,{className:Ja(`flex flex-col space-y-1.5 text-center sm:text-left`,e),...t});Gp.displayName=`DialogHeader`;var Kp=({className:e,...t})=>(0,H.jsx)(`div`,{className:Ja(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Kp.displayName=`DialogFooter`;var qp=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Rp,{ref:n,className:Ja(`text-lg font-semibold leading-none tracking-tight`,e),...t}));qp.displayName=Rp.displayName;var Jp=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(zp,{ref:n,className:Ja(`text-sm text-muted-foreground`,e),...t}));Jp.displayName=zp.displayName;var Yp=`Label`,Xp=b.forwardRef((e,t)=>(0,H.jsx)(Sn.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));Xp.displayName=Yp;var Zp=Xp,Qp=ni(`text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70`),$p=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Zp,{ref:n,className:Ja(Qp(),e),...t}));$p.displayName=Zp.displayName;var em=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`textarea`,{className:Ja(`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,e),ref:n,...t}));em.displayName=`Textarea`;function tm({deck:e,open:t,onOpenChange:n,onDirtyChange:r}){let i=e.operatingInstructions??``,[a,o]=(0,b.useState)(i),s=Tt(),{toast:c}=an();(0,b.useEffect)(()=>{t&&o(e.operatingInstructions??``)},[t,e.id]);let l=t&&a!==i,u=(0,gd.normalizeOperatingInstructions)(a).length,d=u>gd.OPERATING_INSTRUCTIONS_MAX_LENGTH;(0,b.useEffect)(()=>(r?.(l),()=>{r?.(!1)}),[l,r]);let f=Vt({mutationFn:async t=>(await U(`PUT`,`/api/decks/${e.id}`,{operatingInstructions:t})).json(),onSuccess:async(t,r)=>{if(!t.success){c({title:`Could not save deck instructions`,description:t.error||`Save failed`,variant:`destructive`});return}o(t.data?.operatingInstructions??r),await s.invalidateQueries({queryKey:[`/api/decks`]}).catch(()=>{}),c({title:`Deck instructions saved`,description:`New sessions using ${e.name} will receive the updated instructions.`}),n(!1)},onError:e=>{c({title:`Could not save deck instructions`,description:e.message,variant:`destructive`})}}),p=()=>{(a===i||window.confirm(`You have unsaved deck instructions. Discard them?`))&&(o(i),n(!1))},m=gd.OPERATING_INSTRUCTIONS_MAX_LENGTH.toLocaleString(`en-US`);return(0,H.jsx)(Vp,{open:t,onOpenChange:e=>{e||p()},children:(0,H.jsxs)(Wp,{className:`max-h-[90vh] overflow-y-auto border-white/10 bg-[#161612] text-[#E8F6F4] sm:max-w-2xl`,"data-testid":`deck-instructions-modal`,children:[(0,H.jsxs)(Gp,{children:[(0,H.jsx)(qp,{children:`Deck instructions`}),(0,H.jsxs)(Jp,{className:`text-[#A8C4C0]`,children:[`Markdown instructions for agent sessions using `,e.name,`. They are stored in this deck's Git-synced deck file and cannot override host safety or authorization policy.`]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,H.jsx)($p,{htmlFor:`deck-instructions`,children:`Instructions (Markdown)`}),(0,H.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums ${d?`font-semibold text-red-400`:`text-gray-400`}`,"data-testid":`deck-instructions-count`,children:[u.toLocaleString(`en-US`),` / `,m]})]}),(0,H.jsx)(em,{id:`deck-instructions`,value:a,onChange:e=>o(e.target.value),placeholder:`e.g. Prefer pnpm. Never push without asking.
|
|
89
89
|
|
|
90
|
-
Leave empty for no deck instructions.`,rows:12,"aria-label":`Deck instructions (Markdown)`,"data-testid":`input-deck-instructions`,className:`min-h-48 border-white/15 bg-[#0F0F0C] font-mono text-sm text-[#E8F6F4] placeholder:text-[#A8C4C0]/60`}),d&&(0,H.jsxs)(`p`,{className:`text-sm text-red-400`,"data-testid":`deck-instructions-over-limit`,children:[`Instructions exceed the `,m,`-character limit and cannot be saved. Non-empty instructions are stored with a trailing newline, which counts toward the limit.`]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-400`,children:`Saving does not rewrite active host system prompts. New sessions — and existing sessions on their next supported session-context refresh — receive the saved value.`})]}),(0,H.jsxs)(Gp,{className:`gap-2`,children:[(0,H.jsx)(K,{type:`button`,variant:`outline`,onClick:p,"data-testid":`button-cancel-deck-instructions`,className:`rounded-full border-white/20 text-[#E8F6F4] hover:bg-white/10`,children:`Cancel`}),(0,H.jsx)(K,{type:`button`,onClick:()=>f.mutate(a),disabled:a===i||d||f.isPending,"data-testid":`button-save-deck-instructions`,className:`rounded-full border border-[#C4B643] bg-[#C4B643] px-6 text-sm font-semibold text-black hover:opacity-90 disabled:border-white/15 disabled:bg-white/10 disabled:text-white/40 disabled:opacity-100`,children:f.isPending?`Saving…`:`Save instructions`})]})]})})}function tm({deck:e,services:t,credentials:n=[],playbooks:r=[],collectionWarnings:i,onDrop:a,onDragStart:o,onCredentialDragStart:s,onPlaybookDragStart:c,onDragEnd:l,onCardClick:u,onPlaybookClick:d,onCredentialClick:f,onInstructionsDirtyChange:p}){let[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(e.name),[v,y]=(0,b.useState)(!1),x=(0,b.useRef)(null),S=Tt(),{toast:C}=an();(0,b.useEffect)(()=>{_(e.name),h(!1)},[e.id,e.name]),(0,b.useEffect)(()=>{m&&(x.current?.focus(),x.current?.select())},[m]);let w=Vt({mutationFn:async t=>(await U(`PUT`,`/api/decks/${e.id}`,{name:t})).json(),onSuccess:e=>{if(!e.success)throw Error(e.error||`Rename failed`);S.invalidateQueries({queryKey:[`/api/decks`]}),h(!1)},onError:t=>{_(e.name),h(!1),C({title:`Could not rename deck`,description:t.message,variant:`destructive`})}}),T=()=>{let t=g.trim();if(!t||t===e.name){_(e.name),h(!1);return}w.mutate(t)},E=e=>{e.preventDefault(),a(e)},D=e=>{e.preventDefault()},O=t.length+n.length+r.length;return(0,H.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,H.jsxs)(`h3`,{className:`mb-4 flex min-w-0 shrink-0 items-center text-lg font-bold`,children:[(0,H.jsx)(`i`,{className:`fas fa-layer-group mr-2 text-blue-400`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Deck`}),m?(0,H.jsx)(Eu,{ref:x,value:g,disabled:w.isPending,onChange:e=>_(e.target.value),onBlur:T,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),T()):t.key===`Escape`&&(t.preventDefault(),_(e.name),h(!1))},className:`ml-2 h-7 max-w-[12rem] border-white/20 bg-white/10 px-2 text-sm font-normal text-white sm:max-w-[16rem]`,"data-testid":`input-deck-name`,"aria-label":`Deck name`}):(0,H.jsx)(`button`,{type:`button`,className:`ml-2 min-w-0 truncate text-left text-sm font-normal text-gray-400 hover:text-white hover:underline`,title:`Click to rename`,onClick:()=>h(!0),"data-testid":`button-rename-deck`,children:e.name}),(0,H.jsxs)(`span`,{className:`ml-2 shrink-0 text-sm font-normal text-gray-400`,children:[`(`,O,` cards)`]}),(0,H.jsxs)(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>y(!0),"data-testid":`button-deck-instructions`,title:`Edit deck instructions`,className:`ml-2 h-7 shrink-0 px-2 text-xs font-normal text-gray-400 hover:text-white`,children:[(0,H.jsx)(Di,{}),`Instructions`]})]}),(0,H.jsx)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden rounded-xl border-2 border-dashed px-4 py-2 min-w-0`,onDrop:E,onDragOver:D,style:{background:`linear-gradient(135deg, rgba(196, 182, 67, 0.1), rgba(212, 199, 96, 0.1))`,borderColor:`rgba(196, 182, 67, 0.3)`},"data-testid":`deck-drop-zone`,children:(0,H.jsx)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden min-w-0`,children:O===0?(0,H.jsx)(`div`,{className:`flex items-center justify-center`,style:{minHeight:_u},children:(0,H.jsx)(`div`,{className:`flex items-center justify-center rounded-lg border-2 border-dashed border-gray-500 opacity-50 transition-opacity hover:opacity-75`,style:{width:128,height:192},"data-testid":`deck-empty-placeholder`,children:(0,H.jsx)(Ii,{className:`h-8 w-8 text-gray-500`})})}):(0,H.jsxs)(Tu,{cardCount:O,children:[n.map((e,t)=>(0,H.jsxs)(`div`,{className:`w-32 h-48 aspect-[2/3] rounded-lg border-2 p-3 transition-shadow duration-500 shadow-lg hover:shadow-2xl bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900 relative overflow-hidden cursor-pointer`,style:{borderColor:Wl,boxShadow:`0 0 20px ${Wl}20`},draggable:!0,onDragStart:t=>s(t,e,!0),onDragEnd:l,onClick:()=>f?.(e),"data-testid":`deck-card-${e.id}`,children:[(0,H.jsx)(Xl,{warnings:i?.credentialWarnings.get(e.id)}),(0,H.jsx)(`div`,{className:`absolute top-1 left-1 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Wl},children:`AK`})}),(0,H.jsx)(`div`,{className:`absolute bottom-1 right-1 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Wl},children:`AK`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-2 top-6 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`mb-2`,style:{color:Wl},children:(0,H.jsx)(su,{credential:e,color:Wl})}),(0,H.jsx)(`h3`,{className:`font-bold text-xs mb-1 line-clamp-2`,style:{color:Wl},children:e.label}),(0,H.jsx)(`div`,{className:`text-[8px] px-1 py-0.5 rounded border opacity-70`,style:{color:Wl,borderColor:Wl},children:e.hasSecret?`API Key`:`Missing key`})]})]},e.id)),r.map((e,t)=>(0,H.jsxs)(`div`,{className:`w-32 h-48 aspect-[2/3] rounded-lg border-2 p-3 transition-shadow duration-500 shadow-lg hover:shadow-2xl bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900 relative overflow-hidden cursor-pointer`,style:{borderColor:Gl,boxShadow:`0 0 20px ${Gl}20`},draggable:!0,onDragStart:t=>c(t,e,!0),onDragEnd:l,onClick:()=>d?.(e),"data-testid":`deck-card-${e.id}`,children:[(0,H.jsx)(Xl,{warnings:i?.playbookWarnings.get(e.id)}),(0,H.jsx)(`div`,{className:`absolute top-1 left-1 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Gl},children:`PB`})}),(0,H.jsx)(`div`,{className:`absolute bottom-1 right-1 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Gl},children:`PB`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-2 top-6 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`mb-2`,style:{color:Gl},children:(0,H.jsx)(di,{className:`h-7 w-7`,strokeWidth:2.25})}),(0,H.jsx)(`h3`,{className:`font-bold text-xs mb-1 line-clamp-2`,style:{color:Gl},children:e.title}),(0,H.jsx)(`div`,{className:`text-[8px] px-1 py-0.5 rounded border opacity-70`,style:{color:Gl,borderColor:Gl},children:`Playbook`})]})]},e.id)),t.map(e=>(0,H.jsxs)(`div`,{className:`w-32 h-48 aspect-[2/3] rounded-lg border-2 p-3 transition-shadow duration-500 shadow-lg hover:shadow-2xl bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900 relative overflow-hidden cursor-pointer`,style:{borderColor:ql(e),boxShadow:`0 0 20px ${ql(e)}20`},draggable:!0,onDragStart:t=>o(t,e,!0),onDragEnd:l,onClick:()=>u?.(e),"data-testid":`deck-card-${e.id}`,children:[(0,H.jsx)(Xl,{warnings:i?.serviceWarnings.get(e.id)}),(0,H.jsx)(`div`,{className:`absolute top-1 left-1 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:ql(e)},children:e.type===`mcp`?`RM`:e.type===`local-mcp`?`LM`:`A`})}),(0,H.jsx)(`div`,{className:`absolute bottom-1 right-1 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:ql(e)},children:e.type===`mcp`?`RM`:e.type===`local-mcp`?`LM`:`A`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-2 top-6 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`mb-2`,style:{color:ql(e)},children:(0,H.jsx)($l,{service:e})}),(0,H.jsx)(`h3`,{className:`font-bold text-xs mb-1 line-clamp-2`,style:{color:ql(e)},children:e.name}),(0,H.jsx)(`div`,{className:`text-[8px] px-1 py-0.5 rounded border opacity-70`,style:{color:ql(e),borderColor:ql(e)},children:e.type===`mcp`?`Remote MCP`:e.type===`local-mcp`?`Local MCP`:`A2A`})]})]},e.id))]})})}),(0,H.jsx)(em,{deck:e,open:v,onOpenChange:y,onDirtyChange:p})]})}var nm=`Popover`,[rm,im]=dn(nm,[jc]),am=jc(),[om,sm]=rm(nm),cm=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=am(t),c=b.useRef(null),[l,u]=b.useState(!1),[d,f]=Xn({prop:r,defaultProp:i??!1,onChange:a,caller:nm});return(0,H.jsx)(qc,{...s,children:(0,H.jsx)(om,{scope:t,contentId:oo(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:b.useCallback(()=>u(!0),[]),onCustomAnchorRemove:b.useCallback(()=>u(!1),[]),modal:o,children:n})})};cm.displayName=nm;var lm=`PopoverAnchor`,um=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=sm(lm,n),a=am(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return b.useEffect(()=>(o(),()=>s()),[o,s]),(0,H.jsx)(Jc,{...a,...r,ref:t})});um.displayName=lm;var dm=`PopoverTrigger`,fm=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=sm(dm,n),a=am(n),o=ln(t,i.triggerRef),s=(0,H.jsx)(Sn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Dm(i.open),...r,ref:o,onClick:W(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,H.jsx)(Jc,{asChild:!0,...a,children:s})});fm.displayName=dm;var pm=`PopoverPortal`,[mm,hm]=rm(pm,{forceMount:void 0}),gm=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=sm(pm,t);return(0,H.jsx)(mm,{scope:t,forceMount:n,children:(0,H.jsx)(Gn,{present:n||a.open,children:(0,H.jsx)(Un,{asChild:!0,container:i,children:r})})})};gm.displayName=pm;var _m=`PopoverContent`,vm=b.forwardRef((e,t)=>{let n=hm(_m,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=sm(_m,e.__scopePopover);return(0,H.jsx)(Gn,{present:r||a.open,children:a.modal?(0,H.jsx)(bm,{...i,ref:t}):(0,H.jsx)(xm,{...i,ref:t})})});vm.displayName=_m;var ym=pn(`PopoverContent.RemoveScroll`),bm=b.forwardRef((e,t)=>{let n=sm(_m,e.__scopePopover),r=b.useRef(null),i=ln(t,r),a=b.useRef(!1);return b.useEffect(()=>{let e=r.current;if(e)return Qf(e)},[]),(0,H.jsx)(Uf,{as:ym,allowPinchZoom:!0,children:(0,H.jsx)(Sm,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:W(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),xm=b.forwardRef((e,t)=>{let n=sm(_m,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return(0,H.jsx)(Sm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Sm=b.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=sm(_m,n),p=am(n);return Nd(),(0,H.jsx)(bd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,H.jsx)(Mn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,H.jsx)(Yc,{"data-state":Dm(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),Cm=`PopoverClose`,wm=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=sm(Cm,n);return(0,H.jsx)(Sn.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,()=>i.onOpenChange(!1))})});wm.displayName=Cm;var Tm=`PopoverArrow`,Em=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=am(n);return(0,H.jsx)(Xc,{...i,...r,ref:t})});Em.displayName=Tm;function Dm(e){return e?`open`:`closed`}var Om=cm,km=fm,Am=gm,jm=vm,Mm=Om,Nm=km,Pm=b.forwardRef(({className:e,align:t=`center`,sideOffset:n=4,...r},i)=>(0,H.jsx)(Am,{children:(0,H.jsx)(jm,{ref:i,align:t,sideOffset:n,className:Ja(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]`,e),...r})}));Pm.displayName=jm.displayName;function Fm(e,t){let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=Math.max(0,Math.floor((t.getTime()-n)/1e3));if(r<60)return`${r}s`;let i=Math.floor(r/60);if(i<60)return`${i}m`;let a=Math.floor(i/60);return a<24?`${a}h`:`${Math.floor(a/24)}d`}function Im(e,t=24){return e.length>t?`${e.slice(0,t-1)}…`:e}function Lm(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function Rm(e){let t=new Map;for(let n of e)t.set(n.deckId,(t.get(n.deckId)??0)+1);return t}function zm(e,t){let n=e>0?`${e} cards`:`Empty`;return t<=0?n:`${n}, ${t===1?`1 session`:`${t} sessions`}`}function Bm(e){return e===`agent-admin`?`admin`:e===`normal`?`normal`:`unknown`}function Vm(e){return e===`agent-admin`?`bg-amber-500/20 text-amber-200 ring-1 ring-amber-400/40`:e===`normal`?`bg-white/10 text-gray-300 ring-1 ring-white/10`:`bg-white/10 text-gray-300`}function Hm(e){let t=new Map,n=[],r=new Map;for(let r of e){if(r.workspaceRoot){let e=r.workspaceRoot,n=`${Lm(r.workspaceRoot)}/`,i=t.get(e)??{label:n,rows:[],deckIds:new Set};i.rows.push(r),i.deckIds.add(r.deckId),t.set(e,i);continue}n.push(r)}for(let e of n){let n=!1;for(let r of t.values())if(r.deckIds.has(e.deckId)){r.rows.push(e),n=!0;break}if(n)continue;let i=`deck:${e.deckId}`,a=`◆ ${Im(e.deckName)}`,o=r.get(i)??{label:a,rows:[]};o.rows.push(e),r.set(i,o)}return[...[...t.entries()].map(([e,{label:t,rows:n}])=>({key:e,label:t,isWorkspaceGroup:!0,rows:[...n].sort((e,t)=>e.lastActivityAt<t.lastActivityAt?1:-1)})),...[...r.entries()].map(([e,{label:t,rows:n}])=>({key:e,label:t,isWorkspaceGroup:!1,rows:[...n].sort((e,t)=>e.lastActivityAt<t.lastActivityAt?1:-1)}))].sort((e,t)=>e.label.localeCompare(t.label))}function Um(e,t){let{isWorkspaceGroup:n,highlighted:r,clientMeta:i}=t;return!e.workspaceRoot&&n?`no folder · ${i}`:n&&r?i:n?`${Im(e.deckName)} · ${i}`:i}var Wm=`w-[min(22rem,calc(100vw-2rem))]`;function Gm({bindings:e,now:t=new Date,highlightDeckId:n,showContainmentNote:r=!1,scrollClassName:i=`max-h-64 overflow-y-auto`}){let a=n?e.filter(e=>e.deckId===n).length:0,o=(0,b.useMemo)(()=>Hm(e),[e]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`border-b border-white/10 px-3 py-2.5`,children:(0,H.jsxs)(`p`,{className:`text-sm font-semibold leading-snug`,style:{color:Ul},children:[`Live sessions`,(0,H.jsx)(`span`,{className:`ml-1 font-normal text-gray-400`,children:`· match ⌘badge to chat opener`})]})}),r?(0,H.jsx)(`div`,{className:`border-b border-white/10 px-3 py-2 text-xs text-gray-400`,children:(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(Ui,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-gray-400`,"aria-hidden":!0}),(0,H.jsxs)(`p`,{children:[`Agents are bound to one deck per workspace. Cross-deck service calls return`,` `,(0,H.jsx)(`span`,{className:`font-mono text-gray-300`,children:`RESOURCE_OUT_OF_SCOPE`}),`.`]})]})}):null,n&&a>1?(0,H.jsxs)(`div`,{className:`border-b border-[#92E4DD]/20 bg-[#92E4DD]/5 px-3 py-1.5 text-xs text-gray-300`,children:[a,` sessions on this deck`]}):null,(0,H.jsx)(`div`,{className:Ja(i,`p-2`),children:o.map(({key:e,label:r,isWorkspaceGroup:i,rows:a})=>(0,H.jsxs)(`div`,{className:`mb-2 last:mb-0`,children:[(0,H.jsx)(`p`,{className:`px-1 pb-1 text-[10px] uppercase tracking-wide text-gray-500`,children:r}),(0,H.jsx)(`ul`,{className:`space-y-1`,children:a.map(e=>{let r=e.clientName??`agent`,a=Fm(e.lastActivityAt,t),o=a?`${r} · ${a}`:r,s=n===e.deckId,c=Um(e,{isWorkspaceGroup:i,highlighted:s,clientMeta:o});return(0,H.jsxs)(`li`,{className:Ja(`rounded-md border-l-2 py-1.5 pl-2 pr-2 font-mono text-xs`,s?`border-[#92E4DD] bg-[#92E4DD]/5`:`border-transparent bg-white/5`),"data-testid":`live-session-row-${e.badge}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`span`,{style:{color:Ul},children:[`⌘`,e.badge]}),(0,H.jsx)(`span`,{className:Ja(`rounded px-1.5 py-0.5 font-sans text-[10px] uppercase tracking-wide`,Vm(e.mode)),children:Bm(e.mode)})]}),(0,H.jsx)(`span`,{className:`mt-0.5 block font-sans text-[10px] text-gray-400`,children:c})]},e.badge)})})]},e))})]})}function Km({highlightDeckId:e}){let{data:t}=Bt({queryKey:[`/api/scope/bindings`],refetchInterval:3e3}),n=t?.data??[];if(n.length===0)return null;let r=e?n.filter(t=>t.deckId===e).length:0;return(0,H.jsxs)(Mm,{children:[(0,H.jsx)(Nm,{asChild:!0,children:(0,H.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`h-9 shrink-0 whitespace-nowrap border-white/20 bg-black/30 px-2 text-xs text-gray-200 hover:bg-white/10 hover:text-white`,"data-testid":`live-session-badges-trigger`,title:`Live MCP session binds — click for badges`,children:[(0,H.jsx)(Li,{className:`mr-1 h-3 w-3`,style:{color:Ul},"aria-hidden":!0}),(0,H.jsxs)(`span`,{className:`font-mono`,children:[`⌘`,n.length]}),r>0&&r<n.length?(0,H.jsxs)(`span`,{className:`ml-1 text-gray-400`,children:[`(`,r,` here)`]}):null]})}),(0,H.jsx)(Pm,{align:`end`,className:Ja(Wm,`border-white/10 bg-gray-950/95 p-0 text-gray-100`),"data-testid":`live-session-badges-panel`,children:(0,H.jsx)(Gm,{bindings:n,highlightDeckId:e})})]})}var qm=b.createContext(void 0);function Jm(e){let t=b.useContext(qm);return e||t||`ltr`}var Ym=`rovingFocusGroup.onEntryFocus`,Xm={bubbles:!1,cancelable:!0},Zm=`RovingFocusGroup`,[Qm,$m,eh]=xn(Zm),[th,nh]=dn(Zm,[eh]),[rh,ih]=th(Zm),ah=b.forwardRef((e,t)=>(0,H.jsx)(Qm.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(Qm.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(oh,{...e,ref:t})})}));ah.displayName=Zm;var oh=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=b.useRef(null),p=ln(t,f),m=Jm(a),[h,g]=Xn({prop:o,defaultProp:s??null,onChange:c,caller:Zm}),[_,v]=b.useState(!1),y=wn(l),x=$m(n),S=b.useRef(!1),[C,w]=b.useState(0);return b.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Ym,y),()=>e.removeEventListener(Ym,y)},[y]),(0,H.jsx)(rh,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>w(e=>e-1),[]),children:(0,H.jsx)(Sn.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:W(e.onMouseDown,()=>{S.current=!0}),onFocus:W(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Ym,Xm);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);fh([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:W(e.onBlur,()=>v(!1))})})}),sh=`RovingFocusGroupItem`,ch=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=oo(),l=a||c,u=ih(sh,n),d=u.currentTabStopId===l,f=$m(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return b.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,H.jsx)(Qm.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,H.jsx)(Sn.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:W(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:W(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:W(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=dh(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?ph(n,r+1):n.slice(r+1)}setTimeout(()=>fh(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});ch.displayName=sh;var lh={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function uh(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function dh(e,t,n){let r=uh(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return lh[r]}function fh(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ph(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var mh=ah,hh=ch,gh=`Tabs`,[_h,vh]=dn(gh,[nh]),yh=nh(),[bh,xh]=_h(gh),Sh=b.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Jm(s),[d,f]=Xn({prop:r,onChange:i,defaultProp:a??``,caller:gh});return(0,H.jsx)(bh,{scope:n,baseId:oo(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,H.jsx)(Sn.div,{dir:u,"data-orientation":o,...l,ref:t})})});Sh.displayName=gh;var Ch=`TabsList`,wh=b.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=xh(Ch,n),o=yh(n);return(0,H.jsx)(mh,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,H.jsx)(Sn.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});wh.displayName=Ch;var Th=`TabsTrigger`,Eh=b.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=xh(Th,n),s=yh(n),c=kh(o.baseId,r),l=Ah(o.baseId,r),u=r===o.value;return(0,H.jsx)(hh,{asChild:!0,...s,focusable:!i,active:u,children:(0,H.jsx)(Sn.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:W(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:W(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:W(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Eh.displayName=Th;var Dh=`TabsContent`,Oh=b.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=xh(Dh,n),c=kh(s.baseId,r),l=Ah(s.baseId,r),u=r===s.value,d=b.useRef(u);return b.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,H.jsx)(Gn,{present:i||u,children:({present:n})=>(0,H.jsx)(Sn.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Oh.displayName=Dh;function kh(e,t){return`${e}-trigger-${t}`}function Ah(e,t){return`${e}-content-${t}`}var jh=Sh,Mh=wh,Nh=Eh,Ph=Oh,Fh=jh,Ih=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Mh,{ref:n,className:Ja(`inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground`,e),...t}));Ih.displayName=Mh.displayName;var Lh=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Nh,{ref:n,className:Ja(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm`,e),...t}));Lh.displayName=Nh.displayName;var Rh=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Ph,{ref:n,className:Ja(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));Rh.displayName=Ph.displayName;function zh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Bh(e){return zh(e)&&typeof e.command==`string`}function Vh(e){return!zh(e)||Object.keys(e).length===0?!1:Object.values(e).every(Bh)}function Hh(e){let t=e.trim();return t.startsWith("```")?t.replace(/^```(?:json)?\s*\n?/i,``).replace(/\n?```\s*$/,``).trim():t}function Uh(e){if(!zh(e))throw Error(`Configuration must be a JSON object`);if(zh(e.config)&&Vh(e.config.mcpServers))return{mcpServers:e.config.mcpServers};if(Vh(e.mcpServers))return{mcpServers:e.mcpServers};if(zh(e)&&typeof e.command==`string`){let t=typeof e.name==`string`&&e.name.trim()?e.name.trim():`local-server`,{name:n,...r}=e;if(!Bh(r))throw Error(`Missing or invalid command`);return{mcpServers:{[t]:r}}}if(Vh(e))return{mcpServers:e};throw Error(`Invalid configuration: expected a top-level "mcpServers" object. Example:
|
|
90
|
+
Leave empty for no deck instructions.`,rows:12,"aria-label":`Deck instructions (Markdown)`,"data-testid":`input-deck-instructions`,className:`min-h-48 border-white/15 bg-[#0F0F0C] font-mono text-sm text-[#E8F6F4] placeholder:text-[#A8C4C0]/60`}),d&&(0,H.jsxs)(`p`,{className:`text-sm text-red-400`,"data-testid":`deck-instructions-over-limit`,children:[`Instructions exceed the `,m,`-character limit and cannot be saved. Non-empty instructions are stored with a trailing newline, which counts toward the limit.`]}),(0,H.jsx)(`p`,{className:`text-xs text-gray-400`,children:`Saving does not rewrite active host system prompts. New sessions — and existing sessions on their next supported session-context refresh — receive the saved value.`})]}),(0,H.jsxs)(Kp,{className:`gap-2`,children:[(0,H.jsx)(K,{type:`button`,variant:`outline`,onClick:p,"data-testid":`button-cancel-deck-instructions`,className:`rounded-full border-white/20 text-[#E8F6F4] hover:bg-white/10`,children:`Cancel`}),(0,H.jsx)(K,{type:`button`,onClick:()=>f.mutate(a),disabled:a===i||d||f.isPending,"data-testid":`button-save-deck-instructions`,className:`rounded-full border border-[#C4B643] bg-[#C4B643] px-6 text-sm font-semibold text-black hover:opacity-90 disabled:border-white/15 disabled:bg-white/10 disabled:text-white/40 disabled:opacity-100`,children:f.isPending?`Saving…`:`Save instructions`})]})]})})}function nm({deck:e,services:t,credentials:n=[],playbooks:r=[],collectionWarnings:i,onDrop:a,onDragStart:o,onCredentialDragStart:s,onPlaybookDragStart:c,onDragEnd:l,onCardClick:u,onPlaybookClick:d,onCredentialClick:f,onInstructionsDirtyChange:p}){let[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(e.name),[v,y]=(0,b.useState)(!1),x=(0,b.useRef)(null),S=Tt(),{toast:C}=an();(0,b.useEffect)(()=>{_(e.name),h(!1)},[e.id,e.name]),(0,b.useEffect)(()=>{m&&(x.current?.focus(),x.current?.select())},[m]);let w=Vt({mutationFn:async t=>(await U(`PUT`,`/api/decks/${e.id}`,{name:t})).json(),onSuccess:e=>{if(!e.success)throw Error(e.error||`Rename failed`);S.invalidateQueries({queryKey:[`/api/decks`]}),h(!1)},onError:t=>{_(e.name),h(!1),C({title:`Could not rename deck`,description:t.message,variant:`destructive`})}}),T=()=>{let t=g.trim();if(!t||t===e.name){_(e.name),h(!1);return}w.mutate(t)},E=e=>{e.preventDefault(),a(e)},D=e=>{e.preventDefault()},O=t.length+n.length+r.length;return(0,H.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,H.jsxs)(`h3`,{className:`mb-4 flex min-w-0 shrink-0 items-center text-lg font-bold`,children:[(0,H.jsx)(`i`,{className:`fas fa-layer-group mr-2 text-blue-400`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Deck`}),m?(0,H.jsx)(Eu,{ref:x,value:g,disabled:w.isPending,onChange:e=>_(e.target.value),onBlur:T,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),T()):t.key===`Escape`&&(t.preventDefault(),_(e.name),h(!1))},className:`ml-2 h-7 max-w-[12rem] border-white/20 bg-white/10 px-2 text-sm font-normal text-white sm:max-w-[16rem]`,"data-testid":`input-deck-name`,"aria-label":`Deck name`}):(0,H.jsx)(`button`,{type:`button`,className:`ml-2 min-w-0 truncate text-left text-sm font-normal text-gray-400 hover:text-white hover:underline`,title:`Click to rename`,onClick:()=>h(!0),"data-testid":`button-rename-deck`,children:e.name}),(0,H.jsxs)(`span`,{className:`ml-2 shrink-0 text-sm font-normal text-gray-400`,children:[`(`,O,` cards)`]}),(0,H.jsxs)(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>y(!0),"data-testid":`button-deck-instructions`,title:`Edit deck instructions`,className:`ml-2 h-7 shrink-0 px-2 text-xs font-normal text-gray-400 hover:text-white`,children:[(0,H.jsx)(Di,{}),`Instructions`]})]}),(0,H.jsx)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden rounded-xl border-2 border-dashed px-4 py-2 min-w-0`,onDrop:E,onDragOver:D,style:{background:`linear-gradient(135deg, rgba(196, 182, 67, 0.1), rgba(212, 199, 96, 0.1))`,borderColor:`rgba(196, 182, 67, 0.3)`},"data-testid":`deck-drop-zone`,children:(0,H.jsx)(`div`,{className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden min-w-0`,children:O===0?(0,H.jsx)(`div`,{className:`flex items-center justify-center`,style:{minHeight:_u},children:(0,H.jsx)(`div`,{className:`flex items-center justify-center rounded-lg border-2 border-dashed border-gray-500 opacity-50 transition-opacity hover:opacity-75`,style:{width:128,height:192},"data-testid":`deck-empty-placeholder`,children:(0,H.jsx)(Ii,{className:`h-8 w-8 text-gray-500`})})}):(0,H.jsxs)(Tu,{cardCount:O,children:[n.map((e,t)=>(0,H.jsxs)(`div`,{className:`w-32 h-48 aspect-[2/3] rounded-lg border-2 p-3 transition-shadow duration-500 shadow-lg hover:shadow-2xl bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900 relative overflow-hidden cursor-pointer`,style:{borderColor:Wl,boxShadow:`0 0 20px ${Wl}20`},draggable:!0,onDragStart:t=>s(t,e,!0),onDragEnd:l,onClick:()=>f?.(e),"data-testid":`deck-card-${e.id}`,children:[(0,H.jsx)(Xl,{warnings:i?.credentialWarnings.get(e.id)}),(0,H.jsx)(`div`,{className:`absolute top-1 left-1 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Wl},children:`AK`})}),(0,H.jsx)(`div`,{className:`absolute bottom-1 right-1 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Wl},children:`AK`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-2 top-6 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`mb-2`,style:{color:Wl},children:(0,H.jsx)(su,{credential:e,color:Wl})}),(0,H.jsx)(`h3`,{className:`font-bold text-xs mb-1 line-clamp-2`,style:{color:Wl},children:e.label}),(0,H.jsx)(`div`,{className:`text-[8px] px-1 py-0.5 rounded border opacity-70`,style:{color:Wl,borderColor:Wl},children:e.hasSecret?`API Key`:`Missing key`})]})]},e.id)),r.map((e,t)=>(0,H.jsxs)(`div`,{className:`w-32 h-48 aspect-[2/3] rounded-lg border-2 p-3 transition-shadow duration-500 shadow-lg hover:shadow-2xl bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900 relative overflow-hidden cursor-pointer`,style:{borderColor:Gl,boxShadow:`0 0 20px ${Gl}20`},draggable:!0,onDragStart:t=>c(t,e,!0),onDragEnd:l,onClick:()=>d?.(e),"data-testid":`deck-card-${e.id}`,children:[(0,H.jsx)(Xl,{warnings:i?.playbookWarnings.get(e.id)}),(0,H.jsx)(`div`,{className:`absolute top-1 left-1 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Gl},children:`PB`})}),(0,H.jsx)(`div`,{className:`absolute bottom-1 right-1 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:Gl},children:`PB`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-2 top-6 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`mb-2`,style:{color:Gl},children:(0,H.jsx)(di,{className:`h-7 w-7`,strokeWidth:2.25})}),(0,H.jsx)(`h3`,{className:`font-bold text-xs mb-1 line-clamp-2`,style:{color:Gl},children:e.title}),(0,H.jsx)(`div`,{className:`text-[8px] px-1 py-0.5 rounded border opacity-70`,style:{color:Gl,borderColor:Gl},children:`Playbook`})]})]},e.id)),t.map(e=>(0,H.jsxs)(`div`,{className:`w-32 h-48 aspect-[2/3] rounded-lg border-2 p-3 transition-shadow duration-500 shadow-lg hover:shadow-2xl bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900 relative overflow-hidden cursor-pointer`,style:{borderColor:ql(e),boxShadow:`0 0 20px ${ql(e)}20`},draggable:!0,onDragStart:t=>o(t,e,!0),onDragEnd:l,onClick:()=>u?.(e),"data-testid":`deck-card-${e.id}`,children:[(0,H.jsx)(Xl,{warnings:i?.serviceWarnings.get(e.id)}),(0,H.jsx)(`div`,{className:`absolute top-1 left-1 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:ql(e)},children:e.type===`mcp`?`RM`:e.type===`local-mcp`?`LM`:`A`})}),(0,H.jsx)(`div`,{className:`absolute bottom-1 right-1 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`leading-none`,style:{color:ql(e)},children:e.type===`mcp`?`RM`:e.type===`local-mcp`?`LM`:`A`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-2 top-6 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`mb-2`,style:{color:ql(e)},children:(0,H.jsx)($l,{service:e})}),(0,H.jsx)(`h3`,{className:`font-bold text-xs mb-1 line-clamp-2`,style:{color:ql(e)},children:e.name}),(0,H.jsx)(`div`,{className:`text-[8px] px-1 py-0.5 rounded border opacity-70`,style:{color:ql(e),borderColor:ql(e)},children:e.type===`mcp`?`Remote MCP`:e.type===`local-mcp`?`Local MCP`:`A2A`})]})]},e.id))]})})}),(0,H.jsx)(tm,{deck:e,open:v,onOpenChange:y,onDirtyChange:p})]})}var rm=`Popover`,[im,am]=dn(rm,[jc]),om=jc(),[sm,cm]=im(rm),lm=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=om(t),c=b.useRef(null),[l,u]=b.useState(!1),[d,f]=Xn({prop:r,defaultProp:i??!1,onChange:a,caller:rm});return(0,H.jsx)(qc,{...s,children:(0,H.jsx)(sm,{scope:t,contentId:oo(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:b.useCallback(()=>u(!0),[]),onCustomAnchorRemove:b.useCallback(()=>u(!1),[]),modal:o,children:n})})};lm.displayName=rm;var um=`PopoverAnchor`,dm=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=cm(um,n),a=om(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return b.useEffect(()=>(o(),()=>s()),[o,s]),(0,H.jsx)(Jc,{...a,...r,ref:t})});dm.displayName=um;var fm=`PopoverTrigger`,pm=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=cm(fm,n),a=om(n),o=ln(t,i.triggerRef),s=(0,H.jsx)(Sn.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Om(i.open),...r,ref:o,onClick:W(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,H.jsx)(Jc,{asChild:!0,...a,children:s})});pm.displayName=fm;var mm=`PopoverPortal`,[hm,gm]=im(mm,{forceMount:void 0}),_m=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=cm(mm,t);return(0,H.jsx)(hm,{scope:t,forceMount:n,children:(0,H.jsx)(Gn,{present:n||a.open,children:(0,H.jsx)(Un,{asChild:!0,container:i,children:r})})})};_m.displayName=mm;var vm=`PopoverContent`,ym=b.forwardRef((e,t)=>{let n=gm(vm,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=cm(vm,e.__scopePopover);return(0,H.jsx)(Gn,{present:r||a.open,children:a.modal?(0,H.jsx)(xm,{...i,ref:t}):(0,H.jsx)(Sm,{...i,ref:t})})});ym.displayName=vm;var bm=pn(`PopoverContent.RemoveScroll`),xm=b.forwardRef((e,t)=>{let n=cm(vm,e.__scopePopover),r=b.useRef(null),i=ln(t,r),a=b.useRef(!1);return b.useEffect(()=>{let e=r.current;if(e)return $f(e)},[]),(0,H.jsx)(Wf,{as:bm,allowPinchZoom:!0,children:(0,H.jsx)(Cm,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:W(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:W(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:W(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Sm=b.forwardRef((e,t)=>{let n=cm(vm,e.__scopePopover),r=b.useRef(!1),i=b.useRef(!1);return(0,H.jsx)(Cm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Cm=b.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=cm(vm,n),p=om(n);return Pd(),(0,H.jsx)(xd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,H.jsx)(Mn,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,H.jsx)(Yc,{"data-state":Om(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),wm=`PopoverClose`,Tm=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=cm(wm,n);return(0,H.jsx)(Sn.button,{type:`button`,...r,ref:t,onClick:W(e.onClick,()=>i.onOpenChange(!1))})});Tm.displayName=wm;var Em=`PopoverArrow`,Dm=b.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=om(n);return(0,H.jsx)(Xc,{...i,...r,ref:t})});Dm.displayName=Em;function Om(e){return e?`open`:`closed`}var km=lm,Am=pm,jm=_m,Mm=ym,Nm=km,Pm=Am,Fm=b.forwardRef(({className:e,align:t=`center`,sideOffset:n=4,...r},i)=>(0,H.jsx)(jm,{children:(0,H.jsx)(Mm,{ref:i,align:t,sideOffset:n,className:Ja(`z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]`,e),...r})}));Fm.displayName=Mm.displayName;function Im(e,t){let n=new Date(e).getTime();if(Number.isNaN(n))return``;let r=Math.max(0,Math.floor((t.getTime()-n)/1e3));if(r<60)return`${r}s`;let i=Math.floor(r/60);if(i<60)return`${i}m`;let a=Math.floor(i/60);return a<24?`${a}h`:`${Math.floor(a/24)}d`}function Lm(e,t=24){return e.length>t?`${e.slice(0,t-1)}…`:e}function Rm(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function zm(e){let t=new Map;for(let n of e)t.set(n.deckId,(t.get(n.deckId)??0)+1);return t}function Bm(e,t){let n=e>0?`${e} cards`:`Empty`;return t<=0?n:`${n}, ${t===1?`1 session`:`${t} sessions`}`}function Vm(e){return e===`agent-admin`?`admin`:e===`normal`?`normal`:`unknown`}function Hm(e){return e===`agent-admin`?`bg-amber-500/20 text-amber-200 ring-1 ring-amber-400/40`:e===`normal`?`bg-white/10 text-gray-300 ring-1 ring-white/10`:`bg-white/10 text-gray-300`}function Um(e){let t=new Map,n=[],r=new Map;for(let r of e){if(r.workspaceRoot){let e=r.workspaceRoot,n=`${Rm(r.workspaceRoot)}/`,i=t.get(e)??{label:n,rows:[],deckIds:new Set};i.rows.push(r),i.deckIds.add(r.deckId),t.set(e,i);continue}n.push(r)}for(let e of n){let n=!1;for(let r of t.values())if(r.deckIds.has(e.deckId)){r.rows.push(e),n=!0;break}if(n)continue;let i=`deck:${e.deckId}`,a=`◆ ${Lm(e.deckName)}`,o=r.get(i)??{label:a,rows:[]};o.rows.push(e),r.set(i,o)}return[...[...t.entries()].map(([e,{label:t,rows:n}])=>({key:e,label:t,isWorkspaceGroup:!0,rows:[...n].sort((e,t)=>e.lastActivityAt<t.lastActivityAt?1:-1)})),...[...r.entries()].map(([e,{label:t,rows:n}])=>({key:e,label:t,isWorkspaceGroup:!1,rows:[...n].sort((e,t)=>e.lastActivityAt<t.lastActivityAt?1:-1)}))].sort((e,t)=>e.label.localeCompare(t.label))}function Wm(e,t){let{isWorkspaceGroup:n,highlighted:r,clientMeta:i}=t;return!e.workspaceRoot&&n?`no folder · ${i}`:n&&r?i:n?`${Lm(e.deckName)} · ${i}`:i}var Gm=`w-[min(22rem,calc(100vw-2rem))]`;function Km({bindings:e,now:t=new Date,highlightDeckId:n,showContainmentNote:r=!1,scrollClassName:i=`max-h-64 overflow-y-auto`}){let a=n?e.filter(e=>e.deckId===n).length:0,o=(0,b.useMemo)(()=>Um(e),[e]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`border-b border-white/10 px-3 py-2.5`,children:(0,H.jsxs)(`p`,{className:`text-sm font-semibold leading-snug`,style:{color:Ul},children:[`Live sessions`,(0,H.jsx)(`span`,{className:`ml-1 font-normal text-gray-400`,children:`· match ⌘badge to chat opener`})]})}),r?(0,H.jsx)(`div`,{className:`border-b border-white/10 px-3 py-2 text-xs text-gray-400`,children:(0,H.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(Ui,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-gray-400`,"aria-hidden":!0}),(0,H.jsxs)(`p`,{children:[`Agents are bound to one deck per workspace. Cross-deck service calls return`,` `,(0,H.jsx)(`span`,{className:`font-mono text-gray-300`,children:`RESOURCE_OUT_OF_SCOPE`}),`.`]})]})}):null,n&&a>1?(0,H.jsxs)(`div`,{className:`border-b border-[#92E4DD]/20 bg-[#92E4DD]/5 px-3 py-1.5 text-xs text-gray-300`,children:[a,` sessions on this deck`]}):null,(0,H.jsx)(`div`,{className:Ja(i,`p-2`),children:o.map(({key:e,label:r,isWorkspaceGroup:i,rows:a})=>(0,H.jsxs)(`div`,{className:`mb-2 last:mb-0`,children:[(0,H.jsx)(`p`,{className:`px-1 pb-1 text-[10px] uppercase tracking-wide text-gray-500`,children:r}),(0,H.jsx)(`ul`,{className:`space-y-1`,children:a.map(e=>{let r=e.clientName??`agent`,a=Im(e.lastActivityAt,t),o=a?`${r} · ${a}`:r,s=n===e.deckId,c=Wm(e,{isWorkspaceGroup:i,highlighted:s,clientMeta:o});return(0,H.jsxs)(`li`,{className:Ja(`rounded-md border-l-2 py-1.5 pl-2 pr-2 font-mono text-xs`,s?`border-[#92E4DD] bg-[#92E4DD]/5`:`border-transparent bg-white/5`),"data-testid":`live-session-row-${e.badge}`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`span`,{style:{color:Ul},children:[`⌘`,e.badge]}),(0,H.jsx)(`span`,{className:Ja(`rounded px-1.5 py-0.5 font-sans text-[10px] uppercase tracking-wide`,Hm(e.mode)),children:Vm(e.mode)})]}),(0,H.jsx)(`span`,{className:`mt-0.5 block font-sans text-[10px] text-gray-400`,children:c})]},e.badge)})})]},e))})]})}function qm({highlightDeckId:e}){let{data:t}=Bt({queryKey:[`/api/scope/bindings`],refetchInterval:3e3}),n=t?.data??[];if(n.length===0)return null;let r=e?n.filter(t=>t.deckId===e).length:0;return(0,H.jsxs)(Nm,{children:[(0,H.jsx)(Pm,{asChild:!0,children:(0,H.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`h-9 shrink-0 whitespace-nowrap border-white/20 bg-black/30 px-2 text-xs text-gray-200 hover:bg-white/10 hover:text-white`,"data-testid":`live-session-badges-trigger`,title:`Live MCP session binds — click for badges`,children:[(0,H.jsx)(Li,{className:`mr-1 h-3 w-3`,style:{color:Ul},"aria-hidden":!0}),(0,H.jsxs)(`span`,{className:`font-mono`,children:[`⌘`,n.length]}),r>0&&r<n.length?(0,H.jsxs)(`span`,{className:`ml-1 text-gray-400`,children:[`(`,r,` here)`]}):null]})}),(0,H.jsx)(Fm,{align:`end`,className:Ja(Gm,`border-white/10 bg-gray-950/95 p-0 text-gray-100`),"data-testid":`live-session-badges-panel`,children:(0,H.jsx)(Km,{bindings:n,highlightDeckId:e})})]})}var Jm=b.createContext(void 0);function Ym(e){let t=b.useContext(Jm);return e||t||`ltr`}var Xm=`rovingFocusGroup.onEntryFocus`,Zm={bubbles:!1,cancelable:!0},Qm=`RovingFocusGroup`,[$m,eh,th]=xn(Qm),[nh,rh]=dn(Qm,[th]),[ih,ah]=nh(Qm),oh=b.forwardRef((e,t)=>(0,H.jsx)($m.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)($m.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,H.jsx)(sh,{...e,ref:t})})}));oh.displayName=Qm;var sh=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=b.useRef(null),p=ln(t,f),m=Ym(a),[h,g]=Xn({prop:o,defaultProp:s??null,onChange:c,caller:Qm}),[_,v]=b.useState(!1),y=wn(l),x=eh(n),S=b.useRef(!1),[C,w]=b.useState(0);return b.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Xm,y),()=>e.removeEventListener(Xm,y)},[y]),(0,H.jsx)(ih,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>w(e=>e-1),[]),children:(0,H.jsx)(Sn.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:W(e.onMouseDown,()=>{S.current=!0}),onFocus:W(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Xm,Zm);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);ph([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:W(e.onBlur,()=>v(!1))})})}),ch=`RovingFocusGroupItem`,lh=b.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=oo(),l=a||c,u=ah(ch,n),d=u.currentTabStopId===l,f=eh(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return b.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,H.jsx)($m.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,H.jsx)(Sn.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:W(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:W(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:W(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=fh(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?mh(n,r+1):n.slice(r+1)}setTimeout(()=>ph(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});lh.displayName=ch;var uh={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function dh(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function fh(e,t,n){let r=dh(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return uh[r]}function ph(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function mh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var hh=oh,gh=lh,_h=`Tabs`,[vh,yh]=dn(_h,[rh]),bh=rh(),[xh,Sh]=vh(_h),Ch=b.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=Ym(s),[d,f]=Xn({prop:r,onChange:i,defaultProp:a??``,caller:_h});return(0,H.jsx)(xh,{scope:n,baseId:oo(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,H.jsx)(Sn.div,{dir:u,"data-orientation":o,...l,ref:t})})});Ch.displayName=_h;var wh=`TabsList`,Th=b.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=Sh(wh,n),o=bh(n);return(0,H.jsx)(hh,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,H.jsx)(Sn.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Th.displayName=wh;var Eh=`TabsTrigger`,Dh=b.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=Sh(Eh,n),s=bh(n),c=Ah(o.baseId,r),l=jh(o.baseId,r),u=r===o.value;return(0,H.jsx)(gh,{asChild:!0,...s,focusable:!i,active:u,children:(0,H.jsx)(Sn.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:W(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:W(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:W(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Dh.displayName=Eh;var Oh=`TabsContent`,kh=b.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=Sh(Oh,n),c=Ah(s.baseId,r),l=jh(s.baseId,r),u=r===s.value,d=b.useRef(u);return b.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,H.jsx)(Gn,{present:i||u,children:({present:n})=>(0,H.jsx)(Sn.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});kh.displayName=Oh;function Ah(e,t){return`${e}-trigger-${t}`}function jh(e,t){return`${e}-content-${t}`}var Mh=Ch,Nh=Th,Ph=Dh,Fh=kh,Ih=Mh,Lh=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Nh,{ref:n,className:Ja(`inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground`,e),...t}));Lh.displayName=Nh.displayName;var Rh=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Ph,{ref:n,className:Ja(`inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm`,e),...t}));Rh.displayName=Ph.displayName;var zh=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Fh,{ref:n,className:Ja(`mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,e),...t}));zh.displayName=Fh.displayName;function Bh(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Vh(e){return Bh(e)&&typeof e.command==`string`}function Hh(e){return!Bh(e)||Object.keys(e).length===0?!1:Object.values(e).every(Vh)}function Uh(e){let t=e.trim();return t.startsWith("```")?t.replace(/^```(?:json)?\s*\n?/i,``).replace(/\n?```\s*$/,``).trim():t}function Wh(e){if(!Bh(e))throw Error(`Configuration must be a JSON object`);if(Bh(e.config)&&Hh(e.config.mcpServers))return{mcpServers:e.config.mcpServers};if(Hh(e.mcpServers))return{mcpServers:e.mcpServers};if(Bh(e)&&typeof e.command==`string`){let t=typeof e.name==`string`&&e.name.trim()?e.name.trim():`local-server`,{name:n,...r}=e;if(!Vh(r))throw Error(`Missing or invalid command`);return{mcpServers:{[t]:r}}}if(Hh(e))return{mcpServers:e};throw Error(`Invalid configuration: expected a top-level "mcpServers" object. Example:
|
|
91
91
|
{
|
|
92
92
|
"mcpServers": {
|
|
93
93
|
"google-drive": {
|
|
@@ -95,7 +95,7 @@ Leave empty for no deck instructions.`,rows:12,"aria-label":`Deck instructions (
|
|
|
95
95
|
"args": ["-y", "@piotr-agier/google-drive-mcp"]
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
}`)}function
|
|
98
|
+
}`)}function Gh(e){let t;try{t=JSON.parse(Uh(e))}catch(e){throw Error(`Failed to parse JSON: ${e instanceof Error?e.message:`Unknown error`}`)}return Wh(t)}function Kh({type:e,open:t,onOpenChange:n}){let[r,i]=(0,b.useState)(`remote`),[a,o]=(0,b.useState)(`json`),[s,c]=(0,b.useState)(`{
|
|
99
99
|
"mcpServers": {
|
|
100
100
|
"memory": {
|
|
101
101
|
"command": "npx",
|
|
@@ -107,7 +107,7 @@ Leave empty for no deck instructions.`,rows:12,"aria-label":`Deck instructions (
|
|
|
107
107
|
}
|
|
108
108
|
}`),[l,u]=(0,b.useState)(null),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)({name:``,type:`mcp`,url:`http://localhost:8000/mcp`,description:``,headers_enabled:!1,headers:{},cardColor:Ul}),[_,v]=(0,b.useState)(`{
|
|
109
109
|
|
|
110
|
-
}`),[y,x]=(0,b.useState)(null),[S,C]=(0,b.useState)({name:``,type:`local-mcp`,command:``,args:[``],env:{},description:``,cardColor:Ul}),[w,T]=(0,b.useState)({name:``,type:`a2a`,manifest_url:`http://localhost:8001/.well-known/a2a/manifest.json`,description:``,cardColor:Ul}),E=Tt(),{toast:D}=an(),O=()=>{try{f(null);let e=
|
|
110
|
+
}`),[y,x]=(0,b.useState)(null),[S,C]=(0,b.useState)({name:``,type:`local-mcp`,command:``,args:[``],env:{},description:``,cardColor:Ul}),[w,T]=(0,b.useState)({name:``,type:`a2a`,manifest_url:`http://localhost:8001/.well-known/a2a/manifest.json`,description:``,cardColor:Ul}),E=Tt(),{toast:D}=an(),O=()=>{try{f(null);let e=Gh(s),t=Object.entries(e.mcpServers);if(t.length===0)throw Error(`No MCP servers found in configuration`);if(t.length>1)throw Error(`Multiple servers not supported. Please configure one server at a time.`);let[n,r]=t[0],{command:i,args:a,env:c,description:l}=r;if(!i||typeof i!=`string`)throw Error(`Missing or invalid command`);if(!a||!Array.isArray(a))throw Error(`Missing or invalid args array`);let d={name:n,command:i,args:a.map(String),env:c&&typeof c==`object`?c:void 0,description:l&&typeof l==`string`?l:void 0};u(d),o(`review`),C({name:d.name,type:`local-mcp`,command:d.command,args:d.args,env:d.env||{},description:d.description||``,cardColor:Ul}),k(n)}catch(e){f(e instanceof Error?e.message:`Failed to parse JSON`),u(null)}},k=async e=>{try{((await U(`GET`,`/api/services`)).data||[]).find(t=>t.name===e)?m(e):m(null)}catch(e){console.error(`Failed to check name conflict:`,e)}},A=async e=>{await k(e)},j=Vt({mutationFn:async t=>{if(e===`mcp`&&r===`local`){let e={mcpServers:{[t.name]:{command:t.command,args:t.args.filter(e=>e.trim()!==``),...Object.keys(t.env).length>0&&{env:t.env}}}};return console.log(`Importing local MCP server:`,e),U(`POST`,`/api/local-mcp/import`,{config:JSON.stringify(e)})}{let n={name:t.name,type:e,url:e===`mcp`?t.url:t.manifest_url,description:t.description,cardColor:t.cardColor,...t.headers_enabled&&{headers:t.headers}};return console.log(`Sending service data:`,n),U(`POST`,`/api/services`,n)}},onSuccess:()=>{E.invalidateQueries({queryKey:[`/api/services`]}),E.invalidateQueries({queryKey:[`/api/collection/warnings`]}),D({title:`Service registered successfully!`,description:`${(e===`mcp`?r===`remote`?h:S:w).name} has been added to your collection.`}),N()},onError:e=>{console.error(`Registration failed:`,e),console.error(`Error details:`,{message:e?.message,name:e?.name,stack:e?.stack,toString:e?.toString(),constructor:e?.constructor?.name}),D({title:`Registration failed`,description:e?.message||`Failed to register service. Please try again.`,variant:`destructive`})}}),M=async()=>{if(e===`mcp`&&r===`local`){if(a===`json`)O();else if(a===`review`){if(await A(S.name),p){D({title:`Name Conflict`,description:`A service with the name "${S.name}" already exists. Please choose a different name.`,variant:`destructive`});return}j.mutate(S)}}else{let t=e===`mcp`?r===`remote`?h:S:w;if(await A(t.name),p){D({title:`Name Conflict`,description:`A service with the name "${t.name}" already exists. Please choose a different name.`,variant:`destructive`});return}if(e===`mcp`&&r===`remote`&&h.headers_enabled){let e=I();if(e===null)return;j.mutate({...h,headers:e});return}j.mutate(t)}},N=()=>{o(`json`),c(`{
|
|
111
111
|
"mcpServers": {
|
|
112
112
|
"memory": {
|
|
113
113
|
"command": "npx",
|
|
@@ -123,7 +123,7 @@ Leave empty for no deck instructions.`,rows:12,"aria-label":`Deck instructions (
|
|
|
123
123
|
|
|
124
124
|
}`&&v(`{
|
|
125
125
|
"Authorization": "Bearer "
|
|
126
|
-
}`),e||x(null)},I=()=>{let e=_.trim();if(!e||e===`{}`)return{};try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return x(`Headers must be a JSON object (e.g. {"Authorization": "Bearer token"})`),null;for(let[e,n]of Object.entries(t))if(typeof n!=`string`)return x(`Header "${e}" must be a string value`),null;return x(null),t}catch{return x(`Invalid JSON — fix syntax before registering`),null}},L=(e,t)=>{C(n=>({...n,[e]:t}))},ee=(e,t)=>{T(n=>({...n,[e]:t}))},te=()=>{if(e===`mcp`&&r===`local`){if(a===`json`)return`Parse Configuration`;if(a===`review`)return p?`Register Anyway`:`Register Service`}return`Register Service`},ne=()=>{if(e===`mcp`&&r===`local`){if(a===`json`)return!s.trim();if(a===`review`)return!S.name.trim()||!S.command.trim()}else{let t=e===`mcp`?r===`remote`?h:S:w;return!t.name.trim()||e===`mcp`&&r===`remote`&&!t.url?.trim()||e===`a2a`&&!t.manifest_url?.trim()}return!1};return(0,H.jsx)(
|
|
126
|
+
}`),e||x(null)},I=()=>{let e=_.trim();if(!e||e===`{}`)return{};try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))return x(`Headers must be a JSON object (e.g. {"Authorization": "Bearer token"})`),null;for(let[e,n]of Object.entries(t))if(typeof n!=`string`)return x(`Header "${e}" must be a string value`),null;return x(null),t}catch{return x(`Invalid JSON — fix syntax before registering`),null}},L=(e,t)=>{C(n=>({...n,[e]:t}))},ee=(e,t)=>{T(n=>({...n,[e]:t}))},te=()=>{if(e===`mcp`&&r===`local`){if(a===`json`)return`Parse Configuration`;if(a===`review`)return p?`Register Anyway`:`Register Service`}return`Register Service`},ne=()=>{if(e===`mcp`&&r===`local`){if(a===`json`)return!s.trim();if(a===`review`)return!S.name.trim()||!S.command.trim()}else{let t=e===`mcp`?r===`remote`?h:S:w;return!t.name.trim()||e===`mcp`&&r===`remote`&&!t.url?.trim()||e===`a2a`&&!t.manifest_url?.trim()}return!1};return(0,H.jsx)(Vp,{open:t,onOpenChange:n,children:(0,H.jsxs)(Wp,{className:`sm:max-w-2xl max-h-[90vh] overflow-y-auto bg-black/40 backdrop-blur-md border border-white/10 text-white shadow-2xl`,children:[(0,H.jsxs)(Gp,{children:[(0,H.jsxs)(qp,{className:`text-2xl font-bold flex items-center`,style:{background:`linear-gradient(to right, #C4B643, #D4C760)`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`},children:[e===`mcp`?(0,H.jsx)(Bi,{className:`w-6 h-6 mr-3`,style:{color:`#92E4DD`}}):(0,H.jsx)(fi,{className:`w-6 h-6 mr-3`,style:{color:`#92E4DD`}}),`Register `,e===`mcp`?`MCP Server`:`A2A Agent`]}),(0,H.jsx)(Jp,{className:`mt-2`,style:{color:`#92E4DD`,opacity:.8},children:e===`mcp`?`Add a new Model Context Protocol (MCP) server to your service deck. Configure the server URL and provide details for registration.`:`Register a new A2A agent with your service deck. Provide the agent manifest and configuration details.`})]}),e===`mcp`?(0,H.jsxs)(Ih,{value:r,onValueChange:e=>i(e),className:`w-full`,children:[(0,H.jsxs)(Lh,{className:`grid w-full grid-cols-2 bg-white/10 border border-white/20`,children:[(0,H.jsxs)(Rh,{value:`remote`,className:`data-[state=active]:bg-white/20 data-[state=active]:text-white text-gray-400`,children:[(0,H.jsx)(Bi,{className:`w-4 h-4 mr-2`}),`Remote MCP`]}),(0,H.jsxs)(Rh,{value:`local`,className:`data-[state=active]:bg-white/20 data-[state=active]:text-white text-gray-400`,children:[(0,H.jsx)(Gi,{className:`w-4 h-4 mr-2`}),`Local MCP`]})]}),(0,H.jsxs)(zh,{value:`remote`,className:`space-y-4 mt-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`name`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Server Name`}),(0,H.jsx)(Eu,{id:`name`,placeholder:`e.g., Database Tools`,value:h.name,onChange:e=>{P(`name`,e.target.value),e.target.value.trim()?A(e.target.value):m(null)},className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,required:!0,"data-testid":`input-service-name`}),p&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-red-400 text-sm`,children:[(0,H.jsx)(qi,{className:`w-4 h-4`}),(0,H.jsx)(`span`,{children:`A service with this name already exists`})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`url`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`MCP URL`}),(0,H.jsx)(Eu,{id:`url`,type:`url`,placeholder:`http://localhost:8080/mcp or https://mcp.notion.com/mcp`,value:h.url,onChange:e=>P(`url`,e.target.value),className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,required:!0,"data-testid":`input-mcp-url`}),(0,H.jsxs)(`div`,{className:`mt-1 text-xs text-gray-400`,children:[(0,H.jsx)(`p`,{children:`Supported formats:`}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,H.jsxs)(`li`,{children:[`HTTP MCP: `,(0,H.jsx)(`code`,{children:`http://localhost:8080/mcp`})]}),(0,H.jsxs)(`li`,{children:[`SSE MCP: `,(0,H.jsx)(`code`,{children:`https://be.omnimcp.ai/api/v1/mcp/.../sse`})]}),(0,H.jsxs)(`li`,{children:[`Notion MCP: `,(0,H.jsx)(`code`,{children:`https://mcp.notion.com/mcp`})]})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`description`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Description`}),(0,H.jsx)(em,{id:`description`,placeholder:`Brief description of capabilities...`,value:h.description,onChange:e=>P(`description`,e.target.value),rows:3,className:`bg-white/10 border-white/20 text-white placeholder-gray-400 resize-none`,"data-testid":`textarea-description`})]})]}),(0,H.jsxs)(zh,{value:`local`,className:`space-y-4 mt-4`,children:[a===`json`&&(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`local-json`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Local MCP Configuration (JSON)`}),(0,H.jsx)(em,{id:`local-json`,placeholder:`{
|
|
127
127
|
"mcpServers": {
|
|
128
128
|
"memory": {
|
|
129
129
|
"command": "npx",
|
|
@@ -140,12 +140,12 @@ Leave empty for no deck instructions.`,rows:12,"aria-label":`Deck instructions (
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
}`})]})]}),(0,H.jsxs)(K,{type:`button`,className:`flex-1 border`,style:{background:`linear-gradient(135deg, #C4B643, #D4C760)`,borderColor:`#C4B643`,color:`#0A0A07`},onClick:O,disabled:!s.trim()||s.trim().length<10,"data-testid":`button-parse-json`,children:[(0,H.jsx)(bi,{className:`w-4 h-4 mr-2`,style:{color:`#0A0A07`}}),`Parse Configuration`]})]}),a===`review`&&(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(
|
|
143
|
+
}`})]})]}),(0,H.jsxs)(K,{type:`button`,className:`flex-1 border`,style:{background:`linear-gradient(135deg, #C4B643, #D4C760)`,borderColor:`#C4B643`,color:`#0A0A07`},onClick:O,disabled:!s.trim()||s.trim().length<10,"data-testid":`button-parse-json`,children:[(0,H.jsx)(bi,{className:`w-4 h-4 mr-2`,style:{color:`#0A0A07`}}),`Parse Configuration`]})]}),a===`review`&&(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`local-name`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Server Name`}),(0,H.jsx)(Eu,{id:`local-name`,placeholder:`e.g., Memory Server`,value:S.name,onChange:e=>{L(`name`,e.target.value),e.target.value.trim()?A(e.target.value):m(null)},className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,required:!0,"data-testid":`input-local-service-name`}),p&&(0,H.jsxs)(`div`,{className:`mt-2 text-xs text-red-400 flex items-center`,children:[(0,H.jsx)(qi,{className:`w-4 h-4 mr-1`}),`A service with the name "`,p,`" already exists.`]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`command`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Command`}),(0,H.jsx)(Eu,{id:`command`,placeholder:`e.g., npx, python, node`,value:S.command,onChange:e=>L(`command`,e.target.value),className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,required:!0,"data-testid":`input-command`}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-gray-400`,children:`The command to execute (e.g., npx, python, node)`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Arguments`}),S.args.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex gap-2 mb-2`,children:[(0,H.jsx)(Eu,{placeholder:`Argument ${t+1}`,value:e,onChange:e=>{let n=[...S.args];n[t]=e.target.value,L(`args`,n)},className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,"data-testid":`input-arg-${t}`}),t===S.args.length-1&&(0,H.jsx)(K,{type:`button`,size:`sm`,onClick:()=>L(`args`,[...S.args,``]),className:`bg-white/20 hover:bg-white/30 text-white`,children:(0,H.jsx)(Ii,{className:`w-4 h-4`})}),S.args.length>1&&(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`destructive`,onClick:()=>{let e=S.args.filter((e,n)=>n!==t);L(`args`,e)},className:`bg-red-500/80 hover:bg-red-500 text-white`,children:(0,H.jsx)(Zi,{className:`w-4 h-4`})})]},t)),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-gray-400`,children:`Command arguments (e.g., -y, @modelcontextprotocol/server-memory)`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Environment Variables`}),Object.entries(S.env).length===0?(0,H.jsx)(`div`,{className:`text-gray-400 text-sm italic`,children:`No environment variables configured`}):(0,H.jsx)(`div`,{className:`space-y-2`,children:Object.entries(S.env).map(([e,t],n)=>(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(Eu,{placeholder:`Variable name`,value:e,onChange:n=>{let r={...S.env};delete r[e],r[n.target.value]=t,L(`env`,r)},className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,"data-testid":`input-env-key-${n}`}),(0,H.jsx)(Eu,{placeholder:`Value`,value:t,onChange:t=>{let n={...S.env};n[e]=t.target.value,L(`env`,n)},className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,"data-testid":`input-env-value-${n}`}),(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`destructive`,onClick:()=>{let t={...S.env};delete t[e],L(`env`,t)},className:`bg-red-500/80 hover:bg-red-500 text-white`,children:(0,H.jsx)(Zi,{className:`w-4 h-4`})})]},n))}),(0,H.jsxs)(K,{type:`button`,size:`sm`,onClick:()=>{let e={...S.env};e[``]=``,L(`env`,e)},className:`mt-2 bg-white/20 hover:bg-white/30 text-white`,children:[(0,H.jsx)(Ii,{className:`w-4 h-4 mr-2`}),`Add Environment Variable`]}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-gray-400`,children:`Environment variables for the MCP server process`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`local-description`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Description`}),(0,H.jsx)(em,{id:`local-description`,placeholder:`Brief description of capabilities...`,value:S.description,onChange:e=>L(`description`,e.target.value),rows:3,className:`bg-white/10 border-white/20 text-white placeholder-gray-400 resize-none`,"data-testid":`textarea-local-description`})]}),(0,H.jsxs)(`div`,{className:`flex gap-3`,children:[(0,H.jsx)(K,{type:`button`,variant:`outline`,className:`flex-1 border-white/20 text-white hover:bg-white/10`,onClick:()=>o(`json`),"data-testid":`button-back-to-json`,children:`← Back to JSON`}),(0,H.jsxs)(K,{type:`button`,variant:`ghost`,className:`flex-1 border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Jl(`#92E4DD`),onClick:M,disabled:ne(),"data-testid":`button-register`,children:[(0,H.jsx)(Ii,{className:`w-4 h-4 mr-2`}),j.isPending?`Registering...`:te()]})]})]}),a===`complete`&&(0,H.jsxs)(`div`,{className:`text-center py-8`,children:[(0,H.jsx)(bi,{className:`w-16 h-16 text-green-500 mx-auto mb-4`}),(0,H.jsx)(`h3`,{className:`text-xl font-bold mb-2`,style:{color:`#92E4DD`},children:`Local MCP Registered!`}),(0,H.jsx)(`p`,{className:`text-gray-400 mb-4`,children:`Your local MCP server has been successfully registered.`}),(0,H.jsx)(K,{type:`button`,className:`flex-1 border`,style:{background:`linear-gradient(135deg, #C4B643, #D4C760)`,borderColor:`#C4B643`,color:`#0A0A07`},onClick:N,"data-testid":`button-close`,children:`Close`})]})]})]}):(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`name`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Agent Name`}),(0,H.jsx)(Eu,{id:`name`,placeholder:`e.g., Code Assistant`,value:w.name,onChange:e=>{ee(`name`,e.target.value),e.target.value.trim()?A(e.target.value):m(null)},className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,required:!0,"data-testid":`input-service-name`}),p&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-red-400 text-sm`,children:[(0,H.jsx)(qi,{className:`w-4 h-4`}),(0,H.jsx)(`span`,{children:`A service with this name already exists`})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`manifest_url`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Manifest URL`}),(0,H.jsx)(Eu,{id:`manifest_url`,type:`url`,placeholder:`http://localhost:8001/.well-known/a2a/manifest.json`,value:w.manifest_url,onChange:e=>ee(`manifest_url`,e.target.value),className:`bg-white/10 border-white/20 text-white placeholder-gray-400`,required:!0,"data-testid":`input-manifest-url`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`description`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`Description`}),(0,H.jsx)(em,{id:`description`,placeholder:`Brief description of capabilities...`,value:w.description,onChange:e=>ee(`description`,e.target.value),rows:3,className:`bg-white/10 border-white/20 text-white placeholder-gray-400 resize-none`,"data-testid":`textarea-description`})]})]}),e===`mcp`&&r===`remote`&&(0,H.jsxs)(`div`,{className:`space-y-4 border border-white/10 rounded-lg p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,id:`headers_enabled`,checked:h.headers_enabled,onChange:e=>F(e.target.checked),className:`rounded border-white/20 bg-white/10`}),(0,H.jsx)($p,{htmlFor:`headers_enabled`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`🔐 Authentication Required`})]}),(0,H.jsx)(`div`,{className:`text-xs text-gray-400`,children:(0,H.jsx)(`p`,{children:`Enable this if your MCP server requires authentication (API keys, tokens, etc.).`})}),h.headers_enabled&&(0,H.jsxs)(`div`,{className:`space-y-3 pl-6`,children:[(0,H.jsxs)(`div`,{className:`text-xs text-gray-400 mb-2`,children:[(0,H.jsx)(`p`,{children:`Configure HTTP headers for authentication. Common examples:`}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 mt-1 space-y-1`,children:[(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:`Authorization: Bearer YOUR_TOKEN`}),` - For API tokens`]}),(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:`X-API-Key: YOUR_API_KEY`}),` - For API keys`]}),(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:`X-Custom-Header: value`}),` - For custom headers`]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)($p,{htmlFor:`headers`,className:`text-sm font-semibold`,style:{color:`#92E4DD`},children:`HTTP Headers (JSON)`}),(0,H.jsx)(em,{id:`headers`,placeholder:`{
|
|
144
144
|
"Authorization": "Bearer YOUR_TOKEN_HERE",
|
|
145
145
|
"X-API-Key": "YOUR_API_KEY_HERE"
|
|
146
|
-
}`,value:_,onChange:e=>{v(e.target.value),y&&x(null)},onBlur:()=>{_.trim()&&I()},rows:6,className:`bg-white/10 border-white/20 text-white placeholder-gray-400 resize-none font-mono text-xs`,"data-testid":`textarea-headers`}),y&&(0,H.jsxs)(`p`,{className:`text-red-400 text-xs mt-1 flex items-center gap-1`,children:[(0,H.jsx)(qi,{className:`w-3 h-3 shrink-0`}),y]}),(0,H.jsx)(`div`,{className:`text-xs text-gray-400 mt-1`,children:(0,H.jsx)(`p`,{children:`Enter headers as JSON. Keys are header names, values are header values.`})})]})]})]}),d&&(0,H.jsxs)(`div`,{className:`text-red-400 text-sm mt-2`,children:[(0,H.jsx)(qi,{className:`w-4 h-4 mr-1`}),d]}),p&&(0,H.jsxs)(`div`,{className:`text-red-400 text-sm mt-2`,children:[(0,H.jsx)(qi,{className:`w-4 h-4 mr-1`}),`A service with the name "`,p,`" already exists. You can register it anyway, but it might overwrite the existing one.`]}),(0,H.jsxs)(`div`,{className:`flex space-x-3 pt-4`,children:[(0,H.jsx)(K,{type:`button`,variant:`secondary`,className:`flex-1 border text-white`,style:{background:`#ad095e`,borderColor:`#ad095e`},onClick:N,"data-testid":`button-cancel`,children:`Cancel`}),(e!==`mcp`||r!==`local`)&&(0,H.jsxs)(K,{type:`button`,variant:`ghost`,className:`flex-1 border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Jl(`#92E4DD`),disabled:j.isPending||ne(),"data-testid":`button-register`,onClick:M,children:[(0,H.jsx)(Ii,{className:`w-4 h-4 mr-2`}),j.isPending?`Registering...`:`Register Service`]})]})]})})}function Kh(e){let t=e.message||`Unknown error`;if(/already exists/i.test(t))return{title:`Deck name already exists`,description:`Choose a different name — a deck with that name already exists.`};if(e instanceof Ht){if(e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`)return{title:`Dashboard session required`,description:`Your dashboard session is missing or expired. Run agent-deck open and try again.`};if(e.errorCode===`ADMIN_REQUIRED`)return{title:`Admin elevation required`,description:`Deck-admin elevation is required for this agent session.`}}return/file store/i.test(t)?{title:`Could not save deck`,description:t}:{title:`Failed to create deck`,description:t}}async function qh(e){return(await(await U(`POST`,`/api/export`,{scope:e.scope??`collection`,...e.deckId?{deckId:e.deckId}:{}})).json()).data}async function Jh(e){return(await(await U(`POST`,`/api/import`,e)).json()).data}function Yh(e,t){let n=new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}function Xh(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)||`deck`}function Zh(e){let{services:t,playbooks:n,decks:r}=e.counts;return`Decks +${r.created} / skipped ${r.reused}. Services +${t.created} / skipped ${t.reused}. Playbooks +${n.created} / skipped ${n.reused}.`}function Qh({decks:e,editingDeckId:t,onSelectDeck:n,isLoading:r}){let[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(``),c=Tt(),{toast:l}=an(),{data:u}=Bt({queryKey:[`/api/scope/bindings`],refetchInterval:3e3}),d=(0,b.useMemo)(()=>Rm(u?.data??[]),[u]),f=Vt({mutationFn:async e=>U(`POST`,`/api/decks`,{name:e,isActive:!1}),onSuccess:async(e,t)=>{let r=await e.json();await c.invalidateQueries({queryKey:[`/api/decks`]}),r.data?.id&&n(r.data.id),l({title:`Deck created`,description:`${t} has been created successfully.`}),a(!1),s(``)},onError:e=>{let{title:t,description:n}=Kh(e);l({title:t,description:n,variant:`destructive`})}}),p=Vt({mutationFn:async e=>{let t=await qh({scope:`deck`,deckId:e.id});return Yh(t,`${Xh(e.name)}.agent-deck.json`),t},onSuccess:(e,t)=>{l({title:`Deck exported`,description:`${t.name}: ${e.services.length} services, ${e.playbooks.length} playbooks`})},onError:e=>{l({title:`Export failed`,description:e.message,variant:`destructive`})}}),m=(e,t)=>{e.stopPropagation(),p.mutate(t)},h=Vt({mutationFn:async e=>U(`DELETE`,`/api/decks/${e}`,{}),onSuccess:()=>{c.invalidateQueries({queryKey:[`/api/decks`]}),l({title:`Deck deleted`,description:`Your deck has been deleted successfully.`})},onError:e=>{e.message.includes(`Cannot delete the last deck`)?l({title:`Cannot delete deck`,description:`You cannot delete the last deck. Please create another deck first.`,variant:`destructive`}):l({title:`Failed to delete deck`,description:e.message,variant:`destructive`})}}),g=async(e,t)=>{e.stopPropagation();try{await navigator.clipboard.writeText(t.id),l({title:`Copied deck id`,description:`Use with bind_workspace({ workspaceRoot, deckId }) in your agent.`})}catch(e){l({title:`Failed to copy deck id`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}},_=(e,t)=>{e.stopPropagation(),window.confirm(`Are you sure you want to delete this deck? This action cannot be undone.`)&&h.mutate(t)},v=e=>{e.preventDefault();let t=o.trim();t&&f.mutate(t)},y=e=>(e.services?.length??0)+(e.credentials?.length??0)+(e.playbooks?.length??0);return r?(0,H.jsx)(`div`,{className:`bg-black/40 backdrop-blur-md rounded-2xl border border-white/10 p-6 shadow-2xl`,children:(0,H.jsxs)(`div`,{className:`animate-pulse space-y-4`,children:[(0,H.jsx)(`div`,{className:`h-6 bg-white/10 rounded`}),(0,H.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,H.jsx)(`div`,{className:`h-16 bg-white/5 rounded-lg`},t))})]})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`deck-management-panel`,children:[(0,H.jsxs)(`h2`,{className:`text-lg font-bold mb-3 flex items-center`,children:[(0,H.jsx)(Mi,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,H.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`My Decks`})]}),(0,H.jsx)(`div`,{className:`mb-3`,children:(0,H.jsxs)(K,{onClick:()=>a(!0),className:`w-full border text-sm py-2`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},"data-testid":`create-deck-button`,children:[(0,H.jsx)(Ii,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Add Deck`})]})}),(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{let r=e.id===t,i=zm(y(e),d.get(e.id)??0);return(0,H.jsxs)(`div`,{className:`p-2 rounded-lg border cursor-pointer transition-all relative group ${r?`bg-gradient-to-r from-yellow-500/20 to-yellow-600/20 border-2 border-yellow-500/40 hover:border-yellow-400/60`:`bg-white/5 border border-white/10 hover:border-white/20`}`,onClick:()=>n(e.id),"data-testid":`deck-item-${e.id}`,children:[(0,H.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200`,children:[(0,H.jsx)(K,{size:`sm`,variant:`secondary`,className:`h-5 w-5 p-0`,onClick:t=>m(t,e),title:`Export this deck`,"data-testid":`export-deck-${e.id}`,children:(0,H.jsx)(Ti,{className:`w-2 h-2`})}),(0,H.jsx)(K,{size:`sm`,variant:`secondary`,className:`h-5 w-5 p-0`,onClick:t=>g(t,e),title:`Copy deck id for bind_workspace`,children:(0,H.jsx)(Ci,{className:`w-2 h-2`})}),(0,H.jsx)(K,{size:`sm`,variant:`destructive`,className:`h-5 w-5 p-0 bg-red-500/80 hover:bg-red-500 border-red-400`,onClick:t=>_(t,e.id),title:`Delete deck`,children:(0,H.jsx)(Ki,{className:`w-2 h-2`})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-semibold text-sm pr-16 ${r?`text-yellow-300`:`text-white`}`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-gray-400 select-none pointer-events-none`,children:i})]})]},e.id)})})})]}),(0,H.jsx)(Bp,{open:i,onOpenChange:a,children:(0,H.jsxs)(Up,{className:`sm:max-w-md border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsx)(Wp,{children:(0,H.jsxs)(Kp,{className:`flex items-center text-xl font-bold`,children:[(0,H.jsx)(Mi,{className:`mr-2 h-5 w-5`,style:{color:`#92E4DD`}}),`Create New Deck`]})}),(0,H.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,"data-testid":`form-create-deck`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`deckName`,children:`Deck Name`}),(0,H.jsx)(Eu,{id:`deckName`,placeholder:`e.g., Hiring stack`,value:o,onChange:e=>s(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#A8C4C0]/60`,required:!0,"data-testid":`input-deck-name`})]}),(0,H.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,H.jsx)(K,{type:`button`,variant:`outline`,className:`flex-1 rounded-full border-white/20 text-[#E8F6F4] hover:bg-white/10`,onClick:()=>a(!1),"data-testid":`button-cancel-create`,children:`Cancel`}),(0,H.jsx)(K,{type:`submit`,className:`flex-1 rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},disabled:f.isPending,"data-testid":`button-submit-create`,children:f.isPending?`Creating…`:`Create Deck`})]})]})]})})]})}function $h({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),o=Tt(),{toast:s}=an(),c=Vt({mutationFn:async()=>U(`POST`,`/api/credentials`,{label:n.trim(),value:i}),onSuccess:()=>{o.invalidateQueries({queryKey:[`/api/credentials/vault`]}),o.invalidateQueries({queryKey:[`/api/decks`]}),s({title:`API key saved`,description:`${n.trim()} is stored securely. Your agent can use it from the active deck.`}),t(!1),r(``),a(``)},onError:e=>{s({title:`Could not save API key`,description:e.message,variant:`destructive`})}}),l=n.trim().length>0&&i.trim().length>0;return(0,H.jsx)(Bp,{open:e,onOpenChange:t,children:(0,H.jsxs)(Up,{className:`sm:max-w-md border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Wp,{children:[(0,H.jsx)(Kp,{className:`text-[#E8F6F4]`,children:`Register API key`}),(0,H.jsx)(qp,{className:`text-[#A8C4C0]`,children:`Name the service and paste the key. Agent Deck handles the rest — stored in your vault, never shown again.`})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`credential-name`,className:`text-[#CFEAE6]`,children:`Service name`}),(0,H.jsx)(Eu,{id:`credential-name`,placeholder:`OpenAI, Linear, Slack…`,value:n,onChange:e=>r(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`credential-value`,className:`text-[#CFEAE6]`,children:`API key`}),(0,H.jsx)(Eu,{id:`credential-value`,type:`password`,placeholder:`Paste key from the service dashboard`,value:i,onChange:e=>a(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsx)(K,{variant:`ghost`,className:`w-full border-2 hover:opacity-90 ${Kl}`,style:Jl(Wl),onClick:()=>c.mutate(),disabled:!l||c.isPending,children:`Save to vault`})]})]})})}function eg({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(``),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)([]),[m,h]=(0,b.useState)([]),g=Tt(),{toast:_}=an(),{data:v}=Bt({queryKey:[`/api/credentials/vault`],enabled:e}),{data:y}=Bt({queryKey:[`/api/services`],enabled:e}),x=v?.data??[],S=y?.data??[],C=Vt({mutationFn:async()=>U(`POST`,`/api/playbooks`,{title:n.trim(),body:i,triggers:o.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOnCredentialIds:f,dependsOnServiceIds:m,exec:c.trim()||void 0,skill:u.trim()||void 0,autoDetectDependencies:!0}),onSuccess:()=>{g.invalidateQueries({queryKey:[`/api/playbooks/vault`]}),_({title:`Playbook saved`,description:`${n.trim()} is in your collection.`}),t(!1),r(``),a(``),s(``),l(``),d(``),p([]),h([])},onError:e=>{_({title:`Could not save playbook`,description:e.message,variant:`destructive`})}}),w=(e,t,n)=>{n(e.includes(t)?e.filter(e=>e!==t):[...e,t])},T=n.trim().length>0&&i.trim().length>0;return(0,H.jsx)(Bp,{open:e,onOpenChange:t,children:(0,H.jsxs)(Up,{className:`sm:max-w-2xl max-h-[90vh] overflow-y-auto border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Wp,{children:[(0,H.jsx)(Kp,{children:`Register Playbook`}),(0,H.jsxs)(qp,{className:`text-[#A8C4C0]`,children:[`Prefer`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`register_playbook`}),` /`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`update_playbook`}),` from your AI agent. This form also auto-detects API key and MCP dependencies from the content on save.`]})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`playbook-title`,children:`Title`}),(0,H.jsx)(Eu,{id:`playbook-title`,placeholder:`Hiring inbox, Ashby API guide…`,value:n,onChange:e=>r(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`playbook-triggers`,children:`Triggers (comma-separated, max 16)`}),(0,H.jsx)(Eu,{id:`playbook-triggers`,placeholder:`check inbox, review applicants`,value:o,onChange:e=>s(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`playbook-body`,children:`Instructions (markdown)`}),(0,H.jsx)($p,{id:`playbook-body`,rows:8,placeholder:`# Steps
|
|
146
|
+
}`,value:_,onChange:e=>{v(e.target.value),y&&x(null)},onBlur:()=>{_.trim()&&I()},rows:6,className:`bg-white/10 border-white/20 text-white placeholder-gray-400 resize-none font-mono text-xs`,"data-testid":`textarea-headers`}),y&&(0,H.jsxs)(`p`,{className:`text-red-400 text-xs mt-1 flex items-center gap-1`,children:[(0,H.jsx)(qi,{className:`w-3 h-3 shrink-0`}),y]}),(0,H.jsx)(`div`,{className:`text-xs text-gray-400 mt-1`,children:(0,H.jsx)(`p`,{children:`Enter headers as JSON. Keys are header names, values are header values.`})})]})]})]}),d&&(0,H.jsxs)(`div`,{className:`text-red-400 text-sm mt-2`,children:[(0,H.jsx)(qi,{className:`w-4 h-4 mr-1`}),d]}),p&&(0,H.jsxs)(`div`,{className:`text-red-400 text-sm mt-2`,children:[(0,H.jsx)(qi,{className:`w-4 h-4 mr-1`}),`A service with the name "`,p,`" already exists. You can register it anyway, but it might overwrite the existing one.`]}),(0,H.jsxs)(`div`,{className:`flex space-x-3 pt-4`,children:[(0,H.jsx)(K,{type:`button`,variant:`secondary`,className:`flex-1 border text-white`,style:{background:`#ad095e`,borderColor:`#ad095e`},onClick:N,"data-testid":`button-cancel`,children:`Cancel`}),(e!==`mcp`||r!==`local`)&&(0,H.jsxs)(K,{type:`button`,variant:`ghost`,className:`flex-1 border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Jl(`#92E4DD`),disabled:j.isPending||ne(),"data-testid":`button-register`,onClick:M,children:[(0,H.jsx)(Ii,{className:`w-4 h-4 mr-2`}),j.isPending?`Registering...`:`Register Service`]})]})]})})}function qh(e){let t=e.message||`Unknown error`;if(/already exists/i.test(t))return{title:`Deck name already exists`,description:`Choose a different name — a deck with that name already exists.`};if(e instanceof Ht){if(e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`)return{title:`Dashboard session required`,description:`Your dashboard session is missing or expired. Run agent-deck open and try again.`};if(e.errorCode===`ADMIN_REQUIRED`)return{title:`Admin elevation required`,description:`Deck-admin elevation is required for this agent session.`}}return/file store/i.test(t)?{title:`Could not save deck`,description:t}:{title:`Failed to create deck`,description:t}}async function Jh(e){return(await(await U(`POST`,`/api/export`,{scope:e.scope??`collection`,...e.deckId?{deckId:e.deckId}:{}})).json()).data}async function Yh(e){return(await(await U(`POST`,`/api/import`,e)).json()).data}function Xh(e,t){let n=new Blob([`${JSON.stringify(e,null,2)}\n`],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}function Zh(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)||`deck`}function Qh(e){let{services:t,playbooks:n,decks:r}=e.counts;return`Decks +${r.created} / skipped ${r.reused}. Services +${t.created} / skipped ${t.reused}. Playbooks +${n.created} / skipped ${n.reused}.`}function $h({decks:e,editingDeckId:t,onSelectDeck:n,isLoading:r}){let[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(``),c=Tt(),{toast:l}=an(),{data:u}=Bt({queryKey:[`/api/scope/bindings`],refetchInterval:3e3}),d=(0,b.useMemo)(()=>zm(u?.data??[]),[u]),f=Vt({mutationFn:async e=>U(`POST`,`/api/decks`,{name:e,isActive:!1}),onSuccess:async(e,t)=>{let r=await e.json();await c.invalidateQueries({queryKey:[`/api/decks`]}),r.data?.id&&n(r.data.id),l({title:`Deck created`,description:`${t} has been created successfully.`}),a(!1),s(``)},onError:e=>{let{title:t,description:n}=qh(e);l({title:t,description:n,variant:`destructive`})}}),p=Vt({mutationFn:async e=>{let t=await Jh({scope:`deck`,deckId:e.id});return Xh(t,`${Zh(e.name)}.agent-deck.json`),t},onSuccess:(e,t)=>{l({title:`Deck exported`,description:`${t.name}: ${e.services.length} services, ${e.playbooks.length} playbooks`})},onError:e=>{l({title:`Export failed`,description:e.message,variant:`destructive`})}}),m=(e,t)=>{e.stopPropagation(),p.mutate(t)},h=Vt({mutationFn:async e=>U(`DELETE`,`/api/decks/${e}`,{}),onSuccess:()=>{c.invalidateQueries({queryKey:[`/api/decks`]}),l({title:`Deck deleted`,description:`Your deck has been deleted successfully.`})},onError:e=>{e.message.includes(`Cannot delete the last deck`)?l({title:`Cannot delete deck`,description:`You cannot delete the last deck. Please create another deck first.`,variant:`destructive`}):l({title:`Failed to delete deck`,description:e.message,variant:`destructive`})}}),g=async(e,t)=>{e.stopPropagation();try{await navigator.clipboard.writeText(t.id),l({title:`Copied deck id`,description:`Use with bind_workspace({ workspaceRoot, deckId }) in your agent.`})}catch(e){l({title:`Failed to copy deck id`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}},_=(e,t)=>{e.stopPropagation(),window.confirm(`Are you sure you want to delete this deck? This action cannot be undone.`)&&h.mutate(t)},v=e=>{e.preventDefault();let t=o.trim();t&&f.mutate(t)},y=e=>(e.services?.length??0)+(e.credentials?.length??0)+(e.playbooks?.length??0);return r?(0,H.jsx)(`div`,{className:`bg-black/40 backdrop-blur-md rounded-2xl border border-white/10 p-6 shadow-2xl`,children:(0,H.jsxs)(`div`,{className:`animate-pulse space-y-4`,children:[(0,H.jsx)(`div`,{className:`h-6 bg-white/10 rounded`}),(0,H.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,H.jsx)(`div`,{className:`h-16 bg-white/5 rounded-lg`},t))})]})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`deck-management-panel`,children:[(0,H.jsxs)(`h2`,{className:`text-lg font-bold mb-3 flex items-center`,children:[(0,H.jsx)(Mi,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,H.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`My Decks`})]}),(0,H.jsx)(`div`,{className:`mb-3`,children:(0,H.jsxs)(K,{onClick:()=>a(!0),className:`w-full border text-sm py-2`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},"data-testid":`create-deck-button`,children:[(0,H.jsx)(Ii,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Add Deck`})]})}),(0,H.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,H.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>{let r=e.id===t,i=Bm(y(e),d.get(e.id)??0);return(0,H.jsxs)(`div`,{className:`p-2 rounded-lg border cursor-pointer transition-all relative group ${r?`bg-gradient-to-r from-yellow-500/20 to-yellow-600/20 border-2 border-yellow-500/40 hover:border-yellow-400/60`:`bg-white/5 border border-white/10 hover:border-white/20`}`,onClick:()=>n(e.id),"data-testid":`deck-item-${e.id}`,children:[(0,H.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200`,children:[(0,H.jsx)(K,{size:`sm`,variant:`secondary`,className:`h-5 w-5 p-0`,onClick:t=>m(t,e),title:`Export this deck`,"data-testid":`export-deck-${e.id}`,children:(0,H.jsx)(Ti,{className:`w-2 h-2`})}),(0,H.jsx)(K,{size:`sm`,variant:`secondary`,className:`h-5 w-5 p-0`,onClick:t=>g(t,e),title:`Copy deck id for bind_workspace`,children:(0,H.jsx)(Ci,{className:`w-2 h-2`})}),(0,H.jsx)(K,{size:`sm`,variant:`destructive`,className:`h-5 w-5 p-0 bg-red-500/80 hover:bg-red-500 border-red-400`,onClick:t=>_(t,e.id),title:`Delete deck`,children:(0,H.jsx)(Ki,{className:`w-2 h-2`})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`font-semibold text-sm pr-16 ${r?`text-yellow-300`:`text-white`}`,children:e.name}),(0,H.jsx)(`p`,{className:`text-xs text-gray-400 select-none pointer-events-none`,children:i})]})]},e.id)})})})]}),(0,H.jsx)(Vp,{open:i,onOpenChange:a,children:(0,H.jsxs)(Wp,{className:`sm:max-w-md border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsx)(Gp,{children:(0,H.jsxs)(qp,{className:`flex items-center text-xl font-bold`,children:[(0,H.jsx)(Mi,{className:`mr-2 h-5 w-5`,style:{color:`#92E4DD`}}),`Create New Deck`]})}),(0,H.jsxs)(`form`,{onSubmit:v,className:`space-y-4`,"data-testid":`form-create-deck`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`deckName`,children:`Deck Name`}),(0,H.jsx)(Eu,{id:`deckName`,placeholder:`e.g., Hiring stack`,value:o,onChange:e=>s(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#A8C4C0]/60`,required:!0,"data-testid":`input-deck-name`})]}),(0,H.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,H.jsx)(K,{type:`button`,variant:`outline`,className:`flex-1 rounded-full border-white/20 text-[#E8F6F4] hover:bg-white/10`,onClick:()=>a(!1),"data-testid":`button-cancel-create`,children:`Cancel`}),(0,H.jsx)(K,{type:`submit`,className:`flex-1 rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},disabled:f.isPending,"data-testid":`button-submit-create`,children:f.isPending?`Creating…`:`Create Deck`})]})]})]})})]})}function eg({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),o=Tt(),{toast:s}=an(),c=Vt({mutationFn:async()=>U(`POST`,`/api/credentials`,{label:n.trim(),value:i}),onSuccess:()=>{o.invalidateQueries({queryKey:[`/api/credentials/vault`]}),o.invalidateQueries({queryKey:[`/api/decks`]}),s({title:`API key saved`,description:`${n.trim()} is stored securely. Your agent can use it from the active deck.`}),t(!1),r(``),a(``)},onError:e=>{s({title:`Could not save API key`,description:e.message,variant:`destructive`})}}),l=n.trim().length>0&&i.trim().length>0;return(0,H.jsx)(Vp,{open:e,onOpenChange:t,children:(0,H.jsxs)(Wp,{className:`sm:max-w-md border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Gp,{children:[(0,H.jsx)(qp,{className:`text-[#E8F6F4]`,children:`Register API key`}),(0,H.jsx)(Jp,{className:`text-[#A8C4C0]`,children:`Name the service and paste the key. Agent Deck handles the rest — stored in your vault, never shown again.`})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`credential-name`,className:`text-[#CFEAE6]`,children:`Service name`}),(0,H.jsx)(Eu,{id:`credential-name`,placeholder:`OpenAI, Linear, Slack…`,value:n,onChange:e=>r(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`credential-value`,className:`text-[#CFEAE6]`,children:`API key`}),(0,H.jsx)(Eu,{id:`credential-value`,type:`password`,placeholder:`Paste key from the service dashboard`,value:i,onChange:e=>a(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsx)(K,{variant:`ghost`,className:`w-full border-2 hover:opacity-90 ${Kl}`,style:Jl(Wl),onClick:()=>c.mutate(),disabled:!l||c.isPending,children:`Save to vault`})]})]})})}function tg({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(``),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)([]),[m,h]=(0,b.useState)([]),g=Tt(),{toast:_}=an(),{data:v}=Bt({queryKey:[`/api/credentials/vault`],enabled:e}),{data:y}=Bt({queryKey:[`/api/services`],enabled:e}),x=v?.data??[],S=y?.data??[],C=Vt({mutationFn:async()=>U(`POST`,`/api/playbooks`,{title:n.trim(),body:i,triggers:o.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOnCredentialIds:f,dependsOnServiceIds:m,exec:c.trim()||void 0,skill:u.trim()||void 0,autoDetectDependencies:!0}),onSuccess:()=>{g.invalidateQueries({queryKey:[`/api/playbooks/vault`]}),_({title:`Playbook saved`,description:`${n.trim()} is in your collection.`}),t(!1),r(``),a(``),s(``),l(``),d(``),p([]),h([])},onError:e=>{_({title:`Could not save playbook`,description:e.message,variant:`destructive`})}}),w=(e,t,n)=>{n(e.includes(t)?e.filter(e=>e!==t):[...e,t])},T=n.trim().length>0&&i.trim().length>0;return(0,H.jsx)(Vp,{open:e,onOpenChange:t,children:(0,H.jsxs)(Wp,{className:`sm:max-w-2xl max-h-[90vh] overflow-y-auto border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Gp,{children:[(0,H.jsx)(qp,{children:`Register Playbook`}),(0,H.jsxs)(Jp,{className:`text-[#A8C4C0]`,children:[`Prefer`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`register_playbook`}),` /`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`update_playbook`}),` from your AI agent. This form also auto-detects API key and MCP dependencies from the content on save.`]})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`playbook-title`,children:`Title`}),(0,H.jsx)(Eu,{id:`playbook-title`,placeholder:`Hiring inbox, Ashby API guide…`,value:n,onChange:e=>r(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`playbook-triggers`,children:`Triggers (comma-separated, max 16)`}),(0,H.jsx)(Eu,{id:`playbook-triggers`,placeholder:`check inbox, review applicants`,value:o,onChange:e=>s(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`playbook-body`,children:`Instructions (markdown)`}),(0,H.jsx)(em,{id:`playbook-body`,rows:8,placeholder:`# Steps
|
|
147
147
|
1. …
|
|
148
|
-
2. …`,value:i,onChange:e=>a(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] font-mono text-sm`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(
|
|
148
|
+
2. …`,value:i,onChange:e=>a(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] font-mono text-sm`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{children:`Extra API key deps (optional)`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:`Merged with auto-detected refs from content.`}),(0,H.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded border border-white/10 p-2 space-y-1`,children:x.length===0?(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:`No API keys registered yet.`}):x.map(e=>(0,H.jsxs)(`label`,{className:`flex items-center gap-2 text-xs cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:f.includes(e.id),onChange:()=>w(f,e.id,p)}),e.label]},e.id))})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{children:`Extra MCP deps (optional)`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:`Merged with auto-detected refs from content.`}),(0,H.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded border border-white/10 p-2 space-y-1`,children:S.length===0?(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:`No MCP services registered yet.`}):S.map(e=>(0,H.jsxs)(`label`,{className:`flex items-center gap-2 text-xs cursor-pointer`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:m.includes(e.id),onChange:()=>w(m,e.id,h)}),e.name]},e.id))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`playbook-exec`,children:`Suggested exec (optional)`}),(0,H.jsx)(Eu,{id:`playbook-exec`,placeholder:`agent-deck exec --connections … -- uv run …`,value:c,onChange:e=>l(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] font-mono text-xs`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`playbook-skill`,children:`Skill path hint (optional)`}),(0,H.jsx)(Eu,{id:`playbook-skill`,placeholder:`.cursor/skills/…/SKILL.md`,value:u,onChange:e=>d(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] font-mono text-xs`})]}),(0,H.jsx)(K,{variant:`ghost`,className:`w-full border-2 hover:opacity-90 ${Kl}`,style:Jl(Gl),onClick:()=>C.mutate(),disabled:!T||C.isPending,children:`Save to collection`})]})]})})}async function ng(e){let t=await e.json();if(!t.success)throw Error(t.error??`Request failed`);return t.data}function rg(e){return e.length===0?null:e.length<=3?e.join(`, `):`${e.slice(0,3).join(`, `)} and ${e.length-3} more`}async function ig(e){return ng(await U(`GET`,`/api/playbook-patches${e?`?status=${encodeURIComponent(e)}`:``}`))}async function ag(e){return ng(await U(`GET`,`/api/playbook-patches/${e}/preview`))}async function og(e){return ng(await U(`POST`,`/api/playbook-patches/${e}/accept`))}async function sg(e,t){let n=t?.trim();return ng(await U(`POST`,`/api/playbook-patches/${e}/reject`,n?{reason:n}:{}))}async function cg(e){return ng(await U(`GET`,`/api/playbooks/${e}/events/count`))}async function lg(e){let t=await e.json();if(!t.success)throw Error(t.error??`Request failed`);return t.data}async function ug(e){let t=new URLSearchParams({available:`1`});return e&&t.set(`playbookId`,e),(await lg(await U(`GET`,`/api/feedback-signals/count?${t.toString()}`))).open}async function dg(e){let t=new URLSearchParams;return e?.status&&t.set(`status`,e.status),e?.playbookId&&t.set(`playbookId`,e.playbookId),e?.deckId&&t.set(`deckId`,e.deckId),e?.excludeInProposal!==void 0&&t.set(`excludeInProposal`,e.excludeInProposal?`true`:`false`),lg(await U(`GET`,`/api/feedback-signals${t.toString()?`?${t.toString()}`:``}`))}async function fg(e){return lg(await U(`POST`,`/api/feedback-signals/discard`,{signalIds:e}))}function pg(e){return!!e.linkedPatchId&&e.status===`open`}function mg(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`)}"`}function hg(e){return e==null||e===``?`null`:mg(e)}function gg(e){return`Propose playbook updates from these Agent Deck feedback signals (copied from the Feedback table).
|
|
149
149
|
|
|
150
150
|
For each coherent pattern:
|
|
151
151
|
1. Call \`propose_playbook_patch\` with consolidated item ops (prefer \`add_item\`) — or kind \`create\` when there is no playbook.
|
|
@@ -155,44 +155,44 @@ For each coherent pattern:
|
|
|
155
155
|
Signals (\`id\` required for tracking):
|
|
156
156
|
|
|
157
157
|
\`\`\`yaml
|
|
158
|
-
${e.map(e=>{let t=[`- id: ${e.id}`,` playbook: ${
|
|
158
|
+
${e.map(e=>{let t=[`- id: ${e.id}`,` playbook: ${hg(e.candidatePlaybookId)}`,` feedback: ${mg(e.userFeedbackExcerpt)}`,` failure: ${mg(e.failureSummary)}`];return e.correctedOutputHint&&t.push(` hint: ${mg(e.correctedOutputHint)}`),e.candidateDeckId&&t.push(` deck: ${e.candidateDeckId}`),t.join(`
|
|
159
159
|
`)}).join(`
|
|
160
160
|
`)}
|
|
161
|
-
\`\`\``}function gg({playbookId:e,open:t,onOpenChange:n}){let{data:r,isLoading:i}=Bt({queryKey:e?[`/api/playbooks/${e}`]:[`playbook-detail-disabled`],enabled:t&&!!e}),{data:a}=Bt({queryKey:[`/api/playbooks/${e}/events/count`],queryFn:()=>sg(e),enabled:t&&!!e}),{data:o}=Bt({queryKey:[`/api/feedback-signals/count`,`available`,e],queryFn:()=>lg(e),enabled:t&&!!e}),s=r?.data,c=(s?.dependencies.missingCredentialIds.length??0)+(s?.dependencies.missingServiceIds.length??0);return(0,H.jsx)(Bp,{open:t,onOpenChange:n,children:(0,H.jsxs)(Up,{className:`sm:max-w-6xl max-h-[90vh] overflow-y-auto border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Wp,{children:[(0,H.jsx)(Kp,{children:s?.title??`Playbook`}),(0,H.jsx)(qp,{className:`text-[#A8C4C0]`,children:s?.id??e})]}),i||!s?(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading…`}):(0,H.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,H.jsxs)(`p`,{className:`rounded-md border border-white/10 bg-white/5 px-3 py-2 text-[#A8C4C0]`,children:[`Agent corrections file as`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`propose_playbook_patch`}),` proposals — review in the queue. Direct`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`update_playbook`}),` is for explicit edits only.`]}),typeof a==`number`&&(0,H.jsxs)(`p`,{className:`text-xs text-gray-500`,children:[`Fetched `,a,` time`,a===1?``:`s`,` (undertriggering signal)`,typeof o==`number`&&o>0?` · ${o} open feedback signal${o===1?``:`s`}`:null]}),typeof a!=`number`&&typeof o==`number`&&o>0&&(0,H.jsxs)(`p`,{className:`text-xs text-gray-500`,children:[o,` open feedback signal`,o===1?``:`s`]}),s.triggers.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Triggers`}),(0,H.jsx)(`p`,{className:`text-gray-300`,children:s.triggers.join(`, `)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Dependencies`}),s.dependencies.credentials.length===0&&s.dependencies.services.length===0&&c===0?(0,H.jsx)(`p`,{className:`text-gray-400`,children:`None declared.`}):(0,H.jsxs)(`ul`,{className:`space-y-1 text-gray-300`,children:[s.dependencies.credentials.map(e=>(0,H.jsxs)(`li`,{children:[`API key: `,e.label]},e.id)),s.dependencies.services.map(e=>(0,H.jsxs)(`li`,{children:[`MCP: `,e.label]},e.id)),s.dependencies.missingCredentialIds.map(e=>(0,H.jsxs)(`li`,{className:`text-amber-300 flex items-center gap-1`,children:[(0,H.jsx)(qi,{className:`w-3 h-3`}),` Missing API key: `,e]},e)),s.dependencies.missingServiceIds.map(e=>(0,H.jsxs)(`li`,{className:`text-amber-300 flex items-center gap-1`,children:[(0,H.jsx)(qi,{className:`w-3 h-3`}),` Missing MCP: `,e]},e))]})]}),s.exec&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Suggested exec`}),(0,H.jsx)(`pre`,{className:`rounded bg-black/40 p-2 text-xs overflow-x-auto`,children:s.exec})]}),s.skill&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Skill hint`}),(0,H.jsx)(`p`,{className:`font-mono text-xs text-gray-300`,children:s.skill})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Instructions`}),(0,H.jsx)(`div`,{className:`rounded bg-black/30 p-3 whitespace-pre-wrap text-gray-200`,children:s.body})]})]})]})})}function _g({credentialId:e,open:t,onOpenChange:n}){let r=Tt(),{toast:i}=an(),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(``),[l,u]=(0,b.useState)(``),{data:d,isLoading:f}=Bt({queryKey:e?[`/api/credentials/${e}`]:[`credential-detail-disabled`],enabled:t&&!!e}),p=d?.data;(0,b.useEffect)(()=>{p&&(o(p.label),c(p.docsUrl??``),u(``))},[p?.id,p?.label,p?.docsUrl]);let m=Vt({mutationFn:async()=>{if(!e)throw Error(`No credential selected`);let t=a.trim();if(!t)throw Error(`Name is required`);let n=s.trim();if(n)try{new URL(n)}catch{throw Error(`Documentation link must be a valid URL`)}await U(`PUT`,`/api/credentials/${e}`,{label:t,docsUrl:n}),l.trim()&&await U(`POST`,`/api/credentials/${e}/rotate`,{value:l.trim()})},onSuccess:()=>{r.invalidateQueries({queryKey:[`/api/credentials/vault`]}),e&&r.invalidateQueries({queryKey:[`/api/credentials/${e}`]}),r.invalidateQueries({queryKey:[`/api/collection/warnings`]}),r.invalidateQueries({queryKey:[`/api/decks`]}),i({title:l.trim()?`API key updated`:`API key saved`,description:l.trim()?`Name, docs link, and key value were updated.`:`Name and docs link were updated.`}),u(``),n(!1)},onError:e=>{i({title:`Could not save API key`,description:e.message,variant:`destructive`})}}),h=a.trim().length>0&&(a.trim()!==p?.label||s.trim()!==(p?.docsUrl??``)||l.trim().length>0);return(0,H.jsx)(Bp,{open:t,onOpenChange:n,children:(0,H.jsxs)(Up,{className:`sm:max-w-md border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Wp,{children:[(0,H.jsx)(Kp,{className:`text-[#E8F6F4]`,children:p?.label??`API key`}),(0,H.jsx)(qp,{className:`font-mono text-xs text-[#A8C4C0]`,children:p?.id??e})]}),f||!p?(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading…`}):(0,H.jsxs)(`div`,{className:`space-y-4`,children:[!p.hasSecret&&(0,H.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-200`,children:[(0,H.jsx)(qi,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,H.jsx)(`p`,{children:`No key is stored in your vault for this credential. Paste a key below to save it — the value is never shown after saving.`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`credential-detail-name`,className:`text-[#CFEAE6]`,children:`Name`}),(0,H.jsx)(Eu,{id:`credential-detail-name`,value:a,onChange:e=>o(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`credential-detail-key`,className:`text-[#CFEAE6]`,children:p.hasSecret?`Rotate API key`:`API key`}),(0,H.jsx)(Eu,{id:`credential-detail-key`,type:`password`,placeholder:p.hasSecret?`Leave blank to keep current key`:`Paste key from the service dashboard`,value:l,onChange:e=>u(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`}),p.hasSecret&&(0,H.jsx)(`p`,{className:`text-xs text-[#6B8581]`,children:`Stored securely in Keychain. Enter a new value only when rotating.`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`credential-detail-docs`,className:`text-[#CFEAE6]`,children:`Documentation link`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(Eu,{id:`credential-detail-docs`,type:`url`,placeholder:`https://…`,value:s,onChange:e=>c(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`}),s.trim()&&(0,H.jsx)(K,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0 border-white/15 bg-[#0F0F0C] text-[#A8C4C0] hover:bg-white/5`,onClick:()=>window.open(s.trim(),`_blank`,`noopener,noreferrer`),title:`Open documentation`,children:(0,H.jsx)(Ei,{className:`h-4 w-4`})})]})]}),(0,H.jsx)(K,{variant:`ghost`,className:`w-full border-2 hover:opacity-90 ${Kl}`,style:Jl(Wl),onClick:()=>m.mutate(),disabled:!h||m.isPending,children:m.isPending?`Saving…`:`Save changes`})]})]})})}var vg=ni(`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground hover:bg-primary/80`,secondary:`border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80`,destructive:`border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function yg({className:e,variant:t,...n}){return(0,H.jsx)(`div`,{className:Ja(vg({variant:t}),e),...n})}function bg(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function xg(...e){return t=>{let n=!1,r=e.map(e=>{let r=bg(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():bg(e[t],null)}}}}function Sg(...e){return b.useCallback(xg(...e),e)}function Cg(e,t=[]){let n=[];function r(t,r){let i=b.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=b.useMemo(()=>o,Object.values(o));return(0,H.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=b.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>b.createContext(e));return function(n){let r=n?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,wg(i,...t)]}function wg(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function Tg(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}var Eg=globalThis?.document?b.useLayoutEffect:()=>{},Dg=b.useInsertionEffect||Eg;function Og({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=kg({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=b.useRef(e!==void 0);b.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,b.useCallback(t=>{if(s){let n=Ag(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function kg({defaultProp:e,onChange:t}){let[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return Dg(()=>{a.current=t},[t]),b.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Ag(e){return typeof e==`function`}function jg(e){let t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function Mg(e){let[t,n]=b.useState(void 0);return Eg(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}function Ng(e,t){return b.useReducer((e,n)=>t[e][n]??e,e)}var Pg=e=>{let{present:t,children:n}=e,r=Fg(t),i=typeof n==`function`?n({present:r.isPresent}):b.Children.only(n),a=Lg(r.ref,zg(i));return typeof n==`function`||r.isPresent?b.cloneElement(i,{ref:a}):null};Pg.displayName=`Presence`;function Fg(e){let[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef(`none`),o=b.useRef(void 0),[s,c]=Ng(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return b.useEffect(()=>{s===`mounted`?(a.current=o.current??Rg(r.current),o.current=void 0):a.current=`none`},[s]),Eg(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Rg(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Eg(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Rg(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=Rg(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:b.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Rg(t)}else r.current=null;n(e)},[])}}function Ig(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Lg(...e){let t=b.useRef(e);return t.current=e,b.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Ig(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Ig(n[e],null)}}},[])}function Rg(e){return e?.animationName||`none`}function zg(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Bg(e){let t=b.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];qg(r)&&typeof Zg==`function`&&(r=Zg(r._payload)),b.Children.forEach(r,e=>{if(Gg(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;qg(n)&&typeof Zg==`function`&&(n=Zg(n._payload)),a=Hg(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=b.cloneElement(a,void 0,s):!o&&b.Children.count(r)===1&&b.isValidElement(r)&&(a=r);let c=a?Wg(a):void 0,l=Sg(n,c);if(!a){if(r||r===0)throw Error(o?Xg(e):Yg(e));return r}let u=Ug(i,a.props??{});return a.type!==b.Fragment&&(u.ref=n?l:c),b.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var Vg=Symbol.for(`radix.slottable`),Hg=(e,t)=>{if(`child`in e.props){let t=e.props.child;return b.isValidElement(t)?b.cloneElement(t,void 0,e.props.children(t.props.children)):null}return b.isValidElement(t)?t:null};function Ug(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Wg(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Gg(e){return b.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Vg}var Kg=Symbol.for(`react.lazy`);function qg(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Kg&&`_payload`in e&&Jg(e._payload)}function Jg(e){return typeof e==`object`&&!!e&&`then`in e}var Yg=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Xg=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Zg=b.use,Qg=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Bg(`Primitive.${t}`),r=b.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,H.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),$g=`Checkbox`,[e_,t_]=Cg($g),[n_,r_]=e_($g);function i_(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Og({prop:n,defaultProp:i??!1,onChange:c,caller:$g}),[m,h]=b.useState(null),[g,_]=b.useState(null),v=b.useRef(!1),y=!m||!!o||!!m.closest(`form`),x={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,required:l,defaultChecked:!p_(i)&&i,isFormControl:y,bubbleInput:g,setBubbleInput:_};return(0,H.jsx)(n_,{scope:t,...x,children:f_(d)?d(x):r})}var a_=`CheckboxTrigger`,o_=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=r_(a_,e),h=Sg(i,u),g=b.useRef(c);return b.useEffect(()=>{let e=a?.form;if(e){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,H.jsx)(Qg.button,{type:`button`,role:`checkbox`,"aria-checked":p_(c)?`mixed`:c,"aria-required":l,"data-state":m_(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:h,onKeyDown:Tg(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Tg(n,e=>{d(e=>p_(e)?!0:!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});o_.displayName=a_;var s_=b.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,H.jsx)(i_,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(o_,{...d,ref:t,__scopeCheckbox:n}),e&&(0,H.jsx)(d_,{__scopeCheckbox:n})]})})});s_.displayName=$g;var c_=`CheckboxIndicator`,l_=b.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=r_(c_,n);return(0,H.jsx)(Pg,{present:r||p_(a.checked)||a.checked===!0,children:(0,H.jsx)(Qg.span,{"data-state":m_(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});l_.displayName=c_;var u_=`CheckboxBubbleInput`,d_=b.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:c,name:l,value:u,form:d,bubbleInput:f,setBubbleInput:p}=r_(u_,e),m=Sg(n,p),h=jg(a),g=Mg(r);b.useEffect(()=>{let e=f;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(h!==a&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=p_(a),n.call(e,!p_(a)&&a),e.dispatchEvent(t)}},[f,h,a,i]);let _=b.useRef(!p_(a)&&a);return(0,H.jsx)(Qg.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??_.current,required:s,disabled:c,name:l,value:u,form:d,...t,tabIndex:-1,ref:m,style:{...t.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});d_.displayName=u_;function f_(e){return typeof e==`function`}function p_(e){return e===`indeterminate`}function m_(e){return p_(e)?`indeterminate`:e?`checked`:`unchecked`}var h_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(s_,{ref:n,className:Ja(`peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground`,e),...t,children:(0,H.jsx)(l_,{className:Ja(`flex items-center justify-center text-current`),children:(0,H.jsx)(mi,{className:`h-4 w-4`})})}));h_.displayName=s_.displayName;var g_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{className:`relative w-full overflow-auto`,children:(0,H.jsx)(`table`,{ref:n,className:Ja(`w-full caption-bottom text-sm`,e),...t})}));g_.displayName=`Table`;var __=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`thead`,{ref:n,className:Ja(`[&_tr]:border-b`,e),...t}));__.displayName=`TableHeader`;var v_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`tbody`,{ref:n,className:Ja(`[&_tr:last-child]:border-0`,e),...t}));v_.displayName=`TableBody`;var y_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`tfoot`,{ref:n,className:Ja(`border-t bg-muted/50 font-medium [&>tr]:last:border-b-0`,e),...t}));y_.displayName=`TableFooter`;var b_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`tr`,{ref:n,className:Ja(`border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted`,e),...t}));b_.displayName=`TableRow`;var x_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`th`,{ref:n,className:Ja(`h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0`,e),...t}));x_.displayName=`TableHead`;var S_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`td`,{ref:n,className:Ja(`p-4 align-middle [&:has([role=checkbox])]:pr-0`,e),...t}));S_.displayName=`TableCell`;var C_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`caption`,{ref:n,className:Ja(`mt-4 text-sm text-muted-foreground`,e),...t}));C_.displayName=`TableCaption`;function w_(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var T_=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,E_=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,D_={};function O_(e,t){return((t||D_).jsx?E_:T_).test(e)}var k_=/[ \t\n\f\r]/g;function A_(e){return typeof e==`object`?e.type===`text`&&j_(e.value):j_(e)}function j_(e){return e.replace(k_,``)===``}var M_=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};M_.prototype.normal={},M_.prototype.property={},M_.prototype.space=void 0;function N_(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new M_(n,r,t)}function P_(e){return e.toLowerCase()}var F_=class{constructor(e,t){this.attribute=t,this.property=e}};F_.prototype.attribute=``,F_.prototype.booleanish=!1,F_.prototype.boolean=!1,F_.prototype.commaOrSpaceSeparated=!1,F_.prototype.commaSeparated=!1,F_.prototype.defined=!1,F_.prototype.mustUseProperty=!1,F_.prototype.number=!1,F_.prototype.overloadedBoolean=!1,F_.prototype.property=``,F_.prototype.spaceSeparated=!1,F_.prototype.space=void 0;var I_=c({boolean:()=>R_,booleanish:()=>z_,commaOrSpaceSeparated:()=>U_,commaSeparated:()=>H_,number:()=>q,overloadedBoolean:()=>B_,spaceSeparated:()=>V_}),L_=0,R_=W_(),z_=W_(),B_=W_(),q=W_(),V_=W_(),H_=W_(),U_=W_();function W_(){return 2**++L_}var G_=Object.keys(I_),K_=class extends F_{constructor(e,t,n,r){let i=-1;if(super(e,t),q_(this,`space`,r),typeof n==`number`)for(;++i<G_.length;){let e=G_[i];q_(this,G_[i],(n&I_[e])===I_[e])}}};K_.prototype.defined=!0;function q_(e,t,n){n&&(e[t]=n)}function J_(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new K_(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[P_(r)]=r,n[P_(a.attribute)]=r}return new M_(t,n,e.space)}var Y_=J_({properties:{ariaActiveDescendant:null,ariaAtomic:z_,ariaAutoComplete:null,ariaBusy:z_,ariaChecked:z_,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:V_,ariaCurrent:null,ariaDescribedBy:V_,ariaDetails:null,ariaDisabled:z_,ariaDropEffect:V_,ariaErrorMessage:null,ariaExpanded:z_,ariaFlowTo:V_,ariaGrabbed:z_,ariaHasPopup:null,ariaHidden:z_,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:V_,ariaLevel:q,ariaLive:null,ariaModal:z_,ariaMultiLine:z_,ariaMultiSelectable:z_,ariaOrientation:null,ariaOwns:V_,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:z_,ariaReadOnly:z_,ariaRelevant:null,ariaRequired:z_,ariaRoleDescription:V_,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:z_,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function X_(e,t){return t in e?e[t]:t}function Z_(e,t){return X_(e,t.toLowerCase())}var Q_=J_({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:H_,acceptCharset:V_,accessKey:V_,action:null,allow:null,allowFullScreen:R_,allowPaymentRequest:R_,allowUserMedia:R_,alpha:R_,alt:null,as:null,async:R_,autoCapitalize:null,autoComplete:V_,autoFocus:R_,autoPlay:R_,blocking:V_,capture:null,charSet:null,checked:R_,cite:null,className:V_,closedBy:null,colorSpace:null,cols:q,colSpan:q,command:null,commandFor:null,content:null,contentEditable:z_,controls:R_,controlsList:V_,coords:q|H_,crossOrigin:null,data:null,dateTime:null,decoding:null,default:R_,defer:R_,dir:null,dirName:null,disabled:R_,download:B_,draggable:z_,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:R_,formTarget:null,headers:V_,height:q,hidden:B_,high:q,href:null,hrefLang:null,htmlFor:V_,httpEquiv:V_,id:null,imageSizes:null,imageSrcSet:null,inert:R_,inputMode:null,integrity:null,is:null,isMap:R_,itemId:null,itemProp:V_,itemRef:V_,itemScope:R_,itemType:V_,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:R_,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:R_,muted:R_,name:null,nonce:null,noModule:R_,noValidate:R_,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:R_,optimum:q,pattern:null,ping:V_,placeholder:null,playsInline:R_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:R_,referrerPolicy:null,rel:V_,required:R_,reversed:R_,rows:q,rowSpan:q,sandbox:V_,scope:null,scoped:R_,seamless:R_,selected:R_,shadowRootClonable:R_,shadowRootCustomElementRegistry:R_,shadowRootDelegatesFocus:R_,shadowRootMode:null,shadowRootSerializable:R_,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:z_,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:R_,useMap:null,value:z_,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:V_,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:R_,declare:R_,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:R_,noHref:R_,noShade:R_,noWrap:R_,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:z_,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:R_,disablePictureInPicture:R_,disableRemotePlayback:R_,exportParts:H_,part:V_,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:Z_}),$_=J_({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:U_,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:V_,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:R_,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:H_,g2:H_,glyphName:H_,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:U_,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:V_,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:U_,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:U_,rev:U_,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:U_,requiredFeatures:U_,requiredFonts:U_,requiredFormats:U_,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:U_,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:U_,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:U_,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:X_}),ev=J_({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),tv=J_({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Z_}),nv=J_({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),rv={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},iv=/[A-Z]/g,av=/-[a-z]/g,ov=/^data[-\w.:]+$/i;function sv(e,t){let n=P_(t),r=t,i=F_;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&ov.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(av,lv);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!av.test(e)){let n=e.replace(iv,cv);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=K_}return new i(r,t)}function cv(e){return`-`+e.toLowerCase()}function lv(e){return e.charAt(1).toUpperCase()}var uv=N_([Y_,Q_,ev,tv,nv],`html`),dv=N_([Y_,$_,ev,tv,nv],`svg`);function fv(e){return e.join(` `).trim()}var pv=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
162
|
-
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),mv=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(pv());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),hv=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),gv=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(mv()),r=hv();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),_v=yv(`end`),vv=yv(`start`);function yv(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function bv(e){let t=vv(e),n=_v(e);if(t&&n)return{start:t,end:n}}function xv(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Cv(e.position):`start`in e||`end`in e?Cv(e):`line`in e||`column`in e?Sv(e):``}function Sv(e){return wv(e&&e.line)+`:`+wv(e&&e.column)}function Cv(e){return Sv(e&&e.start)+`-`+Sv(e&&e.end)}function wv(e){return e&&typeof e==`number`?e:1}var Tv=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=xv(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Tv.prototype.file=``,Tv.prototype.name=``,Tv.prototype.reason=``,Tv.prototype.message=``,Tv.prototype.stack=``,Tv.prototype.column=void 0,Tv.prototype.line=void 0,Tv.prototype.ancestors=void 0,Tv.prototype.cause=void 0,Tv.prototype.fatal=void 0,Tv.prototype.place=void 0,Tv.prototype.ruleId=void 0,Tv.prototype.source=void 0;var Ev=u(gv(),1),Dv={}.hasOwnProperty,Ov=new Map,kv=/[A-Z]/g,Av=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),jv=new Set([`td`,`th`]),Mv=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Nv(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Wv(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Uv(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?dv:uv,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Pv(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Pv(e,t,n){if(t.type===`element`)return Fv(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Iv(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Rv(e,t,n);if(t.type===`mdxjsEsm`)return Lv(e,t);if(t.type===`root`)return zv(e,t,n);if(t.type===`text`)return Bv(e,t)}function Fv(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=dv,e.schema=i),e.ancestors.push(t);let a=Xv(e,t.tagName,!1),o=Gv(e,t),s=qv(e,t);return Av.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!A_(e)})),Vv(e,o,a,t),Hv(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Iv(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Zv(e,t.position)}function Lv(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Zv(e,t.position)}function Rv(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=dv,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Xv(e,t.name,!0),o=Kv(e,t),s=qv(e,t);return Vv(e,o,a,t),Hv(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function zv(e,t,n){let r={};return Hv(r,qv(e,t)),e.create(t,e.Fragment,r,n)}function Bv(e,t){return t.value}function Vv(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Hv(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Uv(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Wv(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=vv(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Gv(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Dv.call(t.properties,i)){let a=Jv(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&jv.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Kv(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Zv(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Zv(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function qv(e,t){let n=[],r=-1,i=e.passKeys?new Map:Ov;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Pv(e,a,o);s!==void 0&&n.push(s)}return n}function Jv(e,t,n){let r=sv(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?w_(n):fv(n)),r.property===`style`){let t=typeof n==`object`?n:Yv(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Qv(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?rv[r.property]||r.property:r.attribute,n]}}function Yv(e,t){try{return(0,Ev.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Tv("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Mv+`#cannot-parse-style-attribute`,r}}function Xv(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=O_(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=O_(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Dv.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Zv(e)}function Zv(e,t){let n=new Tv("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Mv+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function Qv(e){let t={},n;for(n in e)Dv.call(e,n)&&(t[$v(n)]=e[n]);return t}function $v(e){let t=e.replace(kv,ey);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function ey(e){return`-`+e.toLowerCase()}var ty={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},ny={};function ry(e,t){let n=t||ny;return iy(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function iy(e,t,n){if(oy(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return ay(e.children,t,n)}return Array.isArray(e)?ay(e,t,n):``}function ay(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=iy(e[i],t,n);return r.join(``)}function oy(e){return!!(e&&typeof e==`object`)}var sy=document.createElement(`i`);function cy(e){let t=`&`+e+`;`;sy.innerHTML=t;let n=sy.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function ly(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function uy(e,t){return e.length>0?(ly(e,e.length,0,t),e):t}var dy={}.hasOwnProperty;function fy(e){let t={},n=-1;for(;++n<e.length;)py(t,e[n]);return t}function py(e,t){let n;for(n in t){let r=(dy.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){dy.call(r,a)||(r[a]=[]);let e=i[a];my(r[a],Array.isArray(e)?e:e?[e]:[])}}}function my(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);ly(e,0,0,r)}function hy(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function gy(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var _y=ky(/[A-Za-z]/),vy=ky(/[\dA-Za-z]/),yy=ky(/[#-'*+\--9=?A-Z^-~]/);function by(e){return e!==null&&(e<32||e===127)}var xy=ky(/\d/),Sy=ky(/[\dA-Fa-f]/),Cy=ky(/[!-/:-@[-`{-~]/);function wy(e){return e!==null&&e<-2}function Ty(e){return e!==null&&(e<0||e===32)}function Ey(e){return e===-2||e===-1||e===32}var Dy=ky(/\p{P}|\p{S}/u),Oy=ky(/\s/);function ky(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function Ay(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&vy(e.charCodeAt(n+1))&&vy(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function jy(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Ey(r)?(e.enter(n),s(r)):t(r)}function s(r){return Ey(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var My={tokenize:Ny};function Ny(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),jy(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return wy(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Py={tokenize:Iy},Fy={tokenize:Ly};function Iy(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return ly(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Fy,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Fy,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return wy(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;ly(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ly(e,t,n){return jy(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function Ry(e){if(e===null||Ty(e)||Oy(e))return 1;if(Dy(e))return 2}function zy(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var By={name:`attention`,resolveAll:Vy,tokenize:Hy};function Vy(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Uy(d,-c),Uy(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=uy(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=uy(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=uy(l,zy(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=uy(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=uy(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,ly(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Hy(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ry(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=Ry(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Uy(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Wy={name:`autolink`,tokenize:Gy};function Gy(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return _y(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||vy(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||vy(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||by(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):yy(t)?(e.consume(t),l):n(t)}function u(e){return vy(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||vy(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Ky={partial:!0,tokenize:qy};function qy(e,t,n){return r;function r(t){return Ey(t)?jy(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||wy(e)?t(e):n(e)}}var Jy={continuation:{tokenize:Xy},exit:Zy,name:`blockQuote`,tokenize:Yy};function Yy(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Ey(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Xy(e,t,n){let r=this;return i;function i(t){return Ey(t)?jy(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Jy,t,n)(r)}}function Zy(e){e.exit(`blockQuote`)}var Qy={name:`characterEscape`,tokenize:$y};function $y(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Cy(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var eb={name:`characterReference`,tokenize:tb};function tb(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=vy,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Sy,u):(e.enter(`characterReferenceValue`),a=7,o=xy,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===vy&&!cy(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var nb={partial:!0,tokenize:ab},rb={concrete:!0,name:`codeFenced`,tokenize:ib};function ib(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Ey(t)?jy(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||wy(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(nb,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||wy(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Ey(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),jy(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||wy(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||wy(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Ey(t)?jy(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||wy(t)?e.check(nb,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||wy(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Ey(t)?jy(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Ey(t)?jy(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||wy(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function ab(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var ob={name:`codeIndented`,tokenize:cb},sb={partial:!0,tokenize:lb};function cb(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),jy(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):wy(t)?e.attempt(sb,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||wy(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function lb(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):wy(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):jy(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):wy(e)?i(e):n(e)}}var ub={name:`codeText`,previous:fb,resolve:db,tokenize:pb};function db(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function fb(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function pb(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):wy(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||wy(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var mb=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&hb(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),hb(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),hb(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);hb(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);hb(this.left,t.reverse())}}}};function hb(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function gb(e){let t={},n=-1,r,i,a,o,s,c,l,u=new mb(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,_b(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return ly(e,0,1/0,u.slice(0)),!l}function _b(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var vb={resolve:bb,tokenize:xb},yb={partial:!0,tokenize:Sb};function bb(e){return gb(e),e}function xb(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):wy(t)?e.check(yb,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Sb(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),jy(e,a,`linePrefix`)}function a(i){if(i===null||wy(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function Cb(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||by(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||wy(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Ty(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||by(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function wb(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):wy(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||wy(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Ey(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Tb(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):wy(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),jy(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||wy(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Eb(e,t){let n;return r;function r(i){return wy(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Ey(i)?jy(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Db={name:`definition`,tokenize:kb},Ob={partial:!0,tokenize:Ab};function kb(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return wb.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=gy(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Ty(t)?Eb(e,l)(t):l(t)}function l(t){return Cb(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Ob,d,d)(t)}function d(t){return Ey(t)?jy(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||wy(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Ab(e,t,n){return r;function r(t){return Ty(t)?Eb(e,i)(t):n(t)}function i(t){return Tb(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Ey(t)?jy(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||wy(e)?t(e):n(e)}}var jb={name:`hardBreakEscape`,tokenize:Mb};function Mb(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return wy(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Nb={name:`headingAtx`,resolve:Pb,tokenize:Fb};function Pb(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},ly(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Fb(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Ty(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||wy(n)?(e.exit(`atxHeading`),t(n)):Ey(n)?jy(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Ty(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Ib=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Lb=[`pre`,`script`,`style`,`textarea`],Rb={concrete:!0,name:`htmlFlow`,resolveTo:Vb,tokenize:Hb},zb={partial:!0,tokenize:Wb},Bb={partial:!0,tokenize:Ub};function Vb(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Hb(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):_y(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):_y(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return _y(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Ty(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Lb.includes(l)?(i=1,r.interrupt?t(s):O(s)):Ib.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||vy(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Ey(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||_y(t)?(e.consume(t),b):Ey(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||vy(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Ey(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Ey(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||wy(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Ty(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Ey(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||wy(t)?O(t):Ey(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):wy(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(zb,ee,k)(t)):t===null||wy(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Bb,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||wy(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Lb.includes(n)?(e.consume(t),L):O(t)}return _y(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||wy(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function Ub(e,t,n){let r=this;return i;function i(t){return wy(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Wb(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Ky,t,n)}}var Gb={name:`htmlText`,tokenize:Kb};function Kb(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):_y(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):_y(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):wy(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):wy(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):wy(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):wy(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return _y(t)?(e.consume(t),S):n(t)}function S(t){return t===45||vy(t)?(e.consume(t),S):C(t)}function C(t){return wy(t)?(o=C,N(t)):Ey(t)?(e.consume(t),C):M(t)}function w(t){return t===45||vy(t)?(e.consume(t),w):t===47||t===62||Ty(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||_y(t)?(e.consume(t),E):wy(t)?(o=T,N(t)):Ey(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||vy(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):wy(t)?(o=D,N(t)):Ey(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):wy(t)?(o=O,N(t)):Ey(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):wy(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Ty(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||Ty(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return Ey(t)?jy(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var qb={name:`labelEnd`,resolveAll:Zb,resolveTo:Qb,tokenize:$b},Jb={tokenize:ex},Yb={tokenize:tx},Xb={tokenize:nx};function Zb(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&ly(e,0,e.length,n),e}function Qb(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=uy(s,e.slice(a+1,a+r+3)),s=uy(s,[[`enter`,u,t]]),s=uy(s,zy(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=uy(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=uy(s,e.slice(o+1)),s=uy(s,[[`exit`,c,t]]),ly(e,a,e.length,s),e}function $b(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(gy(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Jb,u,o?u:d)(t):t===91?e.attempt(Yb,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Xb,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function ex(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Ty(t)?Eb(e,a)(t):a(t)}function a(t){return t===41?u(t):Cb(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Ty(t)?Eb(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Tb(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Ty(t)?Eb(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function tx(e,t,n){let r=this;return i;function i(t){return wb.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(gy(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function nx(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var rx={name:`labelStartImage`,resolveAll:qb.resolveAll,tokenize:ix};function ix(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ax={name:`labelStartLink`,resolveAll:qb.resolveAll,tokenize:ox};function ox(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var sx={name:`lineEnding`,tokenize:cx};function cx(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),jy(e,t,`linePrefix`)}}var lx={name:`thematicBreak`,tokenize:ux};function ux(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||wy(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Ey(t)?jy(e,s,`whitespace`)(t):s(t))}}var dx={continuation:{tokenize:hx},exit:_x,name:`list`,tokenize:mx},fx={partial:!0,tokenize:vx},px={partial:!0,tokenize:gx};function mx(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:xy(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(lx,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return xy(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Ky,r.interrupt?n:u,e.attempt(fx,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Ey(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function hx(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Ky,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,jy(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Ey(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(px,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,jy(e,e.attempt(dx,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function gx(e,t,n){let r=this;return jy(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function _x(e){e.exit(this.containerState.type)}function vx(e,t,n){let r=this;return jy(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Ey(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var yx={name:`setextUnderline`,resolveTo:bx,tokenize:xx};function bx(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function xx(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Ey(t)?jy(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||wy(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Sx={tokenize:Cx};function Cx(e){let t=this,n=e.attempt(Ky,r,e.attempt(this.parser.constructs.flowInitial,i,jy(e,e.attempt(this.parser.constructs.flow,i,e.attempt(vb,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var wx={resolveAll:Ox()},Tx=Dx(`string`),Ex=Dx(`text`);function Dx(e){return{resolveAll:Ox(e===`text`?kx:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Ox(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function kx(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Ax=c({attentionMarkers:()=>Rx,contentInitial:()=>Mx,disable:()=>zx,document:()=>jx,flow:()=>Px,flowInitial:()=>Nx,insideSpan:()=>Lx,string:()=>Fx,text:()=>Ix}),jx={42:dx,43:dx,45:dx,48:dx,49:dx,50:dx,51:dx,52:dx,53:dx,54:dx,55:dx,56:dx,57:dx,62:Jy},Mx={91:Db},Nx={[-2]:ob,[-1]:ob,32:ob},Px={35:Nb,42:lx,45:[yx,lx],60:Rb,61:yx,95:lx,96:rb,126:rb},Fx={38:eb,92:Qy},Ix={[-5]:sx,[-4]:sx,[-3]:sx,33:rx,38:eb,42:By,60:[Wy,Gb],91:ax,92:[jb,Qy],93:qb,95:By,96:ub},Lx={null:[By,wx]},Rx={null:[42,95]},zx={null:[]};function Bx(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=uy(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=zy(a,l.events,l),l.events):[]}function f(e,t){return Hx(p(e),t)}function p(e){return Vx(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){wy(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&ly(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Vx(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Hx(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
161
|
+
\`\`\``}function _g({playbookId:e,open:t,onOpenChange:n}){let{data:r,isLoading:i}=Bt({queryKey:e?[`/api/playbooks/${e}`]:[`playbook-detail-disabled`],enabled:t&&!!e}),{data:a}=Bt({queryKey:[`/api/playbooks/${e}/events/count`],queryFn:()=>cg(e),enabled:t&&!!e}),{data:o}=Bt({queryKey:[`/api/feedback-signals/count`,`available`,e],queryFn:()=>ug(e),enabled:t&&!!e}),s=r?.data,c=(s?.dependencies.missingCredentialIds.length??0)+(s?.dependencies.missingServiceIds.length??0);return(0,H.jsx)(Vp,{open:t,onOpenChange:n,children:(0,H.jsxs)(Wp,{className:`sm:max-w-6xl max-h-[90vh] overflow-y-auto border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Gp,{children:[(0,H.jsx)(qp,{children:s?.title??`Playbook`}),(0,H.jsx)(Jp,{className:`text-[#A8C4C0]`,children:s?.id??e})]}),i||!s?(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading…`}):(0,H.jsxs)(`div`,{className:`space-y-4 text-sm`,children:[(0,H.jsxs)(`p`,{className:`rounded-md border border-white/10 bg-white/5 px-3 py-2 text-[#A8C4C0]`,children:[`Agent corrections file as`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`propose_playbook_patch`}),` proposals — review in the queue. Direct`,` `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:`update_playbook`}),` is for explicit edits only.`]}),typeof a==`number`&&(0,H.jsxs)(`p`,{className:`text-xs text-gray-500`,children:[`Fetched `,a,` time`,a===1?``:`s`,` (undertriggering signal)`,typeof o==`number`&&o>0?` · ${o} open feedback signal${o===1?``:`s`}`:null]}),typeof a!=`number`&&typeof o==`number`&&o>0&&(0,H.jsxs)(`p`,{className:`text-xs text-gray-500`,children:[o,` open feedback signal`,o===1?``:`s`]}),s.triggers.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Triggers`}),(0,H.jsx)(`p`,{className:`text-gray-300`,children:s.triggers.join(`, `)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Dependencies`}),s.dependencies.credentials.length===0&&s.dependencies.services.length===0&&c===0?(0,H.jsx)(`p`,{className:`text-gray-400`,children:`None declared.`}):(0,H.jsxs)(`ul`,{className:`space-y-1 text-gray-300`,children:[s.dependencies.credentials.map(e=>(0,H.jsxs)(`li`,{children:[`API key: `,e.label]},e.id)),s.dependencies.services.map(e=>(0,H.jsxs)(`li`,{children:[`MCP: `,e.label]},e.id)),s.dependencies.missingCredentialIds.map(e=>(0,H.jsxs)(`li`,{className:`text-amber-300 flex items-center gap-1`,children:[(0,H.jsx)(qi,{className:`w-3 h-3`}),` Missing API key: `,e]},e)),s.dependencies.missingServiceIds.map(e=>(0,H.jsxs)(`li`,{className:`text-amber-300 flex items-center gap-1`,children:[(0,H.jsx)(qi,{className:`w-3 h-3`}),` Missing MCP: `,e]},e))]})]}),s.exec&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Suggested exec`}),(0,H.jsx)(`pre`,{className:`rounded bg-black/40 p-2 text-xs overflow-x-auto`,children:s.exec})]}),s.skill&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Skill hint`}),(0,H.jsx)(`p`,{className:`font-mono text-xs text-gray-300`,children:s.skill})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h4`,{className:`font-semibold text-amber-200 mb-1`,children:`Instructions`}),(0,H.jsx)(`div`,{className:`rounded bg-black/30 p-3 whitespace-pre-wrap text-gray-200`,children:s.body})]})]})]})})}function vg({credentialId:e,open:t,onOpenChange:n}){let r=Tt(),{toast:i}=an(),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(``),[l,u]=(0,b.useState)(``),{data:d,isLoading:f}=Bt({queryKey:e?[`/api/credentials/${e}`]:[`credential-detail-disabled`],enabled:t&&!!e}),p=d?.data;(0,b.useEffect)(()=>{p&&(o(p.label),c(p.docsUrl??``),u(``))},[p?.id,p?.label,p?.docsUrl]);let m=Vt({mutationFn:async()=>{if(!e)throw Error(`No credential selected`);let t=a.trim();if(!t)throw Error(`Name is required`);let n=s.trim();if(n)try{new URL(n)}catch{throw Error(`Documentation link must be a valid URL`)}await U(`PUT`,`/api/credentials/${e}`,{label:t,docsUrl:n}),l.trim()&&await U(`POST`,`/api/credentials/${e}/rotate`,{value:l.trim()})},onSuccess:()=>{r.invalidateQueries({queryKey:[`/api/credentials/vault`]}),e&&r.invalidateQueries({queryKey:[`/api/credentials/${e}`]}),r.invalidateQueries({queryKey:[`/api/collection/warnings`]}),r.invalidateQueries({queryKey:[`/api/decks`]}),i({title:l.trim()?`API key updated`:`API key saved`,description:l.trim()?`Name, docs link, and key value were updated.`:`Name and docs link were updated.`}),u(``),n(!1)},onError:e=>{i({title:`Could not save API key`,description:e.message,variant:`destructive`})}}),h=a.trim().length>0&&(a.trim()!==p?.label||s.trim()!==(p?.docsUrl??``)||l.trim().length>0);return(0,H.jsx)(Vp,{open:t,onOpenChange:n,children:(0,H.jsxs)(Wp,{className:`sm:max-w-md border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Gp,{children:[(0,H.jsx)(qp,{className:`text-[#E8F6F4]`,children:p?.label??`API key`}),(0,H.jsx)(Jp,{className:`font-mono text-xs text-[#A8C4C0]`,children:p?.id??e})]}),f||!p?(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading…`}):(0,H.jsxs)(`div`,{className:`space-y-4`,children:[!p.hasSecret&&(0,H.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-200`,children:[(0,H.jsx)(qi,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,H.jsx)(`p`,{children:`No key is stored in your vault for this credential. Paste a key below to save it — the value is never shown after saving.`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`credential-detail-name`,className:`text-[#CFEAE6]`,children:`Name`}),(0,H.jsx)(Eu,{id:`credential-detail-name`,value:a,onChange:e=>o(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`credential-detail-key`,className:`text-[#CFEAE6]`,children:p.hasSecret?`Rotate API key`:`API key`}),(0,H.jsx)(Eu,{id:`credential-detail-key`,type:`password`,placeholder:p.hasSecret?`Leave blank to keep current key`:`Paste key from the service dashboard`,value:l,onChange:e=>u(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`}),p.hasSecret&&(0,H.jsx)(`p`,{className:`text-xs text-[#6B8581]`,children:`Stored securely in Keychain. Enter a new value only when rotating.`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`credential-detail-docs`,className:`text-[#CFEAE6]`,children:`Documentation link`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(Eu,{id:`credential-detail-docs`,type:`url`,placeholder:`https://…`,value:s,onChange:e=>c(e.target.value),className:`border-white/15 bg-[#0F0F0C] text-[#E8F6F4] placeholder:text-[#6B8581]`}),s.trim()&&(0,H.jsx)(K,{type:`button`,variant:`outline`,size:`icon`,className:`shrink-0 border-white/15 bg-[#0F0F0C] text-[#A8C4C0] hover:bg-white/5`,onClick:()=>window.open(s.trim(),`_blank`,`noopener,noreferrer`),title:`Open documentation`,children:(0,H.jsx)(Ei,{className:`h-4 w-4`})})]})]}),(0,H.jsx)(K,{variant:`ghost`,className:`w-full border-2 hover:opacity-90 ${Kl}`,style:Jl(Wl),onClick:()=>m.mutate(),disabled:!h||m.isPending,children:m.isPending?`Saving…`:`Save changes`})]})]})})}var yg=ni(`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground hover:bg-primary/80`,secondary:`border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80`,destructive:`border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function bg({className:e,variant:t,...n}){return(0,H.jsx)(`div`,{className:Ja(yg({variant:t}),e),...n})}function xg(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Sg(...e){return t=>{let n=!1,r=e.map(e=>{let r=xg(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():xg(e[t],null)}}}}function Cg(...e){return b.useCallback(Sg(...e),e)}function wg(e,t=[]){let n=[];function r(t,r){let i=b.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=b.useMemo(()=>o,Object.values(o));return(0,H.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=b.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>b.createContext(e));return function(n){let r=n?.[e]||t;return b.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Tg(i,...t)]}function Tg(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return b.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function Eg(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}var Dg=globalThis?.document?b.useLayoutEffect:()=>{},Og=b.useInsertionEffect||Dg;function kg({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Ag({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=b.useRef(e!==void 0);b.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,b.useCallback(t=>{if(s){let n=jg(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Ag({defaultProp:e,onChange:t}){let[n,r]=b.useState(e),i=b.useRef(n),a=b.useRef(t);return Og(()=>{a.current=t},[t]),b.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function jg(e){return typeof e==`function`}function Mg(e){let t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function Ng(e){let[t,n]=b.useState(void 0);return Dg(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}function Pg(e,t){return b.useReducer((e,n)=>t[e][n]??e,e)}var Fg=e=>{let{present:t,children:n}=e,r=Ig(t),i=typeof n==`function`?n({present:r.isPresent}):b.Children.only(n),a=Rg(r.ref,Bg(i));return typeof n==`function`||r.isPresent?b.cloneElement(i,{ref:a}):null};Fg.displayName=`Presence`;function Ig(e){let[t,n]=b.useState(),r=b.useRef(null),i=b.useRef(e),a=b.useRef(`none`),o=b.useRef(void 0),[s,c]=Pg(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return b.useEffect(()=>{s===`mounted`?(a.current=o.current??zg(r.current),o.current=void 0):a.current=`none`},[s]),Dg(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=zg(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),Dg(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=zg(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=zg(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:b.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=zg(t)}else r.current=null;n(e)},[])}}function Lg(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Rg(...e){let t=b.useRef(e);return t.current=e,b.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Lg(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Lg(n[e],null)}}},[])}function zg(e){return e?.animationName||`none`}function Bg(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Vg(e){let t=b.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];Jg(r)&&typeof Qg==`function`&&(r=Qg(r._payload)),b.Children.forEach(r,e=>{if(Kg(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;Jg(n)&&typeof Qg==`function`&&(n=Qg(n._payload)),a=Ug(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=b.cloneElement(a,void 0,s):!o&&b.Children.count(r)===1&&b.isValidElement(r)&&(a=r);let c=a?Gg(a):void 0,l=Cg(n,c);if(!a){if(r||r===0)throw Error(o?Zg(e):Xg(e));return r}let u=Wg(i,a.props??{});return a.type!==b.Fragment&&(u.ref=n?l:c),b.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var Hg=Symbol.for(`radix.slottable`),Ug=(e,t)=>{if(`child`in e.props){let t=e.props.child;return b.isValidElement(t)?b.cloneElement(t,void 0,e.props.children(t.props.children)):null}return b.isValidElement(t)?t:null};function Wg(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Gg(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Kg(e){return b.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Hg}var qg=Symbol.for(`react.lazy`);function Jg(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===qg&&`_payload`in e&&Yg(e._payload)}function Yg(e){return typeof e==`object`&&!!e&&`then`in e}var Xg=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Zg=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Qg=b.use,$g=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Vg(`Primitive.${t}`),r=b.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,H.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),e_=`Checkbox`,[t_,n_]=wg(e_),[r_,i_]=t_(e_);function a_(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=kg({prop:n,defaultProp:i??!1,onChange:c,caller:e_}),[m,h]=b.useState(null),[g,_]=b.useState(null),v=b.useRef(!1),y=!m||!!o||!!m.closest(`form`),x={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,required:l,defaultChecked:!m_(i)&&i,isFormControl:y,bubbleInput:g,setBubbleInput:_};return(0,H.jsx)(r_,{scope:t,...x,children:p_(d)?d(x):r})}var o_=`CheckboxTrigger`,s_=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=i_(o_,e),h=Cg(i,u),g=b.useRef(c);return b.useEffect(()=>{let e=a?.form;if(e){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,H.jsx)($g.button,{type:`button`,role:`checkbox`,"aria-checked":m_(c)?`mixed`:c,"aria-required":l,"data-state":h_(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:h,onKeyDown:Eg(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:Eg(n,e=>{d(e=>m_(e)?!0:!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});s_.displayName=o_;var c_=b.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,H.jsx)(a_,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(s_,{...d,ref:t,__scopeCheckbox:n}),e&&(0,H.jsx)(f_,{__scopeCheckbox:n})]})})});c_.displayName=e_;var l_=`CheckboxIndicator`,u_=b.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,a=i_(l_,n);return(0,H.jsx)(Fg,{present:r||m_(a.checked)||a.checked===!0,children:(0,H.jsx)($g.span,{"data-state":h_(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})});u_.displayName=l_;var d_=`CheckboxBubbleInput`,f_=b.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:c,name:l,value:u,form:d,bubbleInput:f,setBubbleInput:p}=i_(d_,e),m=Cg(n,p),h=Mg(a),g=Ng(r);b.useEffect(()=>{let e=f;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(h!==a&&n){let t=new Event(`click`,{bubbles:r});e.indeterminate=m_(a),n.call(e,!m_(a)&&a),e.dispatchEvent(t)}},[f,h,a,i]);let _=b.useRef(!m_(a)&&a);return(0,H.jsx)($g.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??_.current,required:s,disabled:c,name:l,value:u,form:d,...t,tabIndex:-1,ref:m,style:{...t.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});f_.displayName=d_;function p_(e){return typeof e==`function`}function m_(e){return e===`indeterminate`}function h_(e){return m_(e)?`indeterminate`:e?`checked`:`unchecked`}var g_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(c_,{ref:n,className:Ja(`peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground`,e),...t,children:(0,H.jsx)(u_,{className:Ja(`flex items-center justify-center text-current`),children:(0,H.jsx)(mi,{className:`h-4 w-4`})})}));g_.displayName=c_.displayName;var __=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{className:`relative w-full overflow-auto`,children:(0,H.jsx)(`table`,{ref:n,className:Ja(`w-full caption-bottom text-sm`,e),...t})}));__.displayName=`Table`;var v_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`thead`,{ref:n,className:Ja(`[&_tr]:border-b`,e),...t}));v_.displayName=`TableHeader`;var y_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`tbody`,{ref:n,className:Ja(`[&_tr:last-child]:border-0`,e),...t}));y_.displayName=`TableBody`;var b_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`tfoot`,{ref:n,className:Ja(`border-t bg-muted/50 font-medium [&>tr]:last:border-b-0`,e),...t}));b_.displayName=`TableFooter`;var x_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`tr`,{ref:n,className:Ja(`border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted`,e),...t}));x_.displayName=`TableRow`;var S_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`th`,{ref:n,className:Ja(`h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0`,e),...t}));S_.displayName=`TableHead`;var C_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`td`,{ref:n,className:Ja(`p-4 align-middle [&:has([role=checkbox])]:pr-0`,e),...t}));C_.displayName=`TableCell`;var w_=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`caption`,{ref:n,className:Ja(`mt-4 text-sm text-muted-foreground`,e),...t}));w_.displayName=`TableCaption`;function T_(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var E_=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,D_=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,O_={};function k_(e,t){return((t||O_).jsx?D_:E_).test(e)}var A_=/[ \t\n\f\r]/g;function j_(e){return typeof e==`object`?e.type===`text`&&M_(e.value):M_(e)}function M_(e){return e.replace(A_,``)===``}var N_=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};N_.prototype.normal={},N_.prototype.property={},N_.prototype.space=void 0;function P_(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new N_(n,r,t)}function F_(e){return e.toLowerCase()}var I_=class{constructor(e,t){this.attribute=t,this.property=e}};I_.prototype.attribute=``,I_.prototype.booleanish=!1,I_.prototype.boolean=!1,I_.prototype.commaOrSpaceSeparated=!1,I_.prototype.commaSeparated=!1,I_.prototype.defined=!1,I_.prototype.mustUseProperty=!1,I_.prototype.number=!1,I_.prototype.overloadedBoolean=!1,I_.prototype.property=``,I_.prototype.spaceSeparated=!1,I_.prototype.space=void 0;var L_=c({boolean:()=>z_,booleanish:()=>B_,commaOrSpaceSeparated:()=>W_,commaSeparated:()=>U_,number:()=>q,overloadedBoolean:()=>V_,spaceSeparated:()=>H_}),R_=0,z_=G_(),B_=G_(),V_=G_(),q=G_(),H_=G_(),U_=G_(),W_=G_();function G_(){return 2**++R_}var K_=Object.keys(L_),q_=class extends I_{constructor(e,t,n,r){let i=-1;if(super(e,t),J_(this,`space`,r),typeof n==`number`)for(;++i<K_.length;){let e=K_[i];J_(this,K_[i],(n&L_[e])===L_[e])}}};q_.prototype.defined=!0;function J_(e,t,n){n&&(e[t]=n)}function Y_(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new q_(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[F_(r)]=r,n[F_(a.attribute)]=r}return new N_(t,n,e.space)}var X_=Y_({properties:{ariaActiveDescendant:null,ariaAtomic:B_,ariaAutoComplete:null,ariaBusy:B_,ariaChecked:B_,ariaColCount:q,ariaColIndex:q,ariaColSpan:q,ariaControls:H_,ariaCurrent:null,ariaDescribedBy:H_,ariaDetails:null,ariaDisabled:B_,ariaDropEffect:H_,ariaErrorMessage:null,ariaExpanded:B_,ariaFlowTo:H_,ariaGrabbed:B_,ariaHasPopup:null,ariaHidden:B_,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:H_,ariaLevel:q,ariaLive:null,ariaModal:B_,ariaMultiLine:B_,ariaMultiSelectable:B_,ariaOrientation:null,ariaOwns:H_,ariaPlaceholder:null,ariaPosInSet:q,ariaPressed:B_,ariaReadOnly:B_,ariaRelevant:null,ariaRequired:B_,ariaRoleDescription:H_,ariaRowCount:q,ariaRowIndex:q,ariaRowSpan:q,ariaSelected:B_,ariaSetSize:q,ariaSort:null,ariaValueMax:q,ariaValueMin:q,ariaValueNow:q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Z_(e,t){return t in e?e[t]:t}function Q_(e,t){return Z_(e,t.toLowerCase())}var $_=Y_({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:U_,acceptCharset:H_,accessKey:H_,action:null,allow:null,allowFullScreen:z_,allowPaymentRequest:z_,allowUserMedia:z_,alpha:z_,alt:null,as:null,async:z_,autoCapitalize:null,autoComplete:H_,autoFocus:z_,autoPlay:z_,blocking:H_,capture:null,charSet:null,checked:z_,cite:null,className:H_,closedBy:null,colorSpace:null,cols:q,colSpan:q,command:null,commandFor:null,content:null,contentEditable:B_,controls:z_,controlsList:H_,coords:q|U_,crossOrigin:null,data:null,dateTime:null,decoding:null,default:z_,defer:z_,dir:null,dirName:null,disabled:z_,download:V_,draggable:B_,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:z_,formTarget:null,headers:H_,height:q,hidden:V_,high:q,href:null,hrefLang:null,htmlFor:H_,httpEquiv:H_,id:null,imageSizes:null,imageSrcSet:null,inert:z_,inputMode:null,integrity:null,is:null,isMap:z_,itemId:null,itemProp:H_,itemRef:H_,itemScope:z_,itemType:H_,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:z_,low:q,manifest:null,max:null,maxLength:q,media:null,method:null,min:null,minLength:q,multiple:z_,muted:z_,name:null,nonce:null,noModule:z_,noValidate:z_,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:z_,optimum:q,pattern:null,ping:H_,placeholder:null,playsInline:z_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:z_,referrerPolicy:null,rel:H_,required:z_,reversed:z_,rows:q,rowSpan:q,sandbox:H_,scope:null,scoped:z_,seamless:z_,selected:z_,shadowRootClonable:z_,shadowRootCustomElementRegistry:z_,shadowRootDelegatesFocus:z_,shadowRootMode:null,shadowRootSerializable:z_,shape:null,size:q,sizes:null,slot:null,span:q,spellCheck:B_,src:null,srcDoc:null,srcLang:null,srcSet:null,start:q,step:null,style:null,tabIndex:q,target:null,title:null,translate:null,type:null,typeMustMatch:z_,useMap:null,value:B_,width:q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:H_,axis:null,background:null,bgColor:null,border:q,borderColor:null,bottomMargin:q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:z_,declare:z_,event:null,face:null,frame:null,frameBorder:null,hSpace:q,leftMargin:q,link:null,longDesc:null,lowSrc:null,marginHeight:q,marginWidth:q,noResize:z_,noHref:z_,noShade:z_,noWrap:z_,object:null,profile:null,prompt:null,rev:null,rightMargin:q,rules:null,scheme:null,scrolling:B_,standby:null,summary:null,text:null,topMargin:q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:z_,disablePictureInPicture:z_,disableRemotePlayback:z_,exportParts:U_,part:H_,prefix:null,property:null,results:q,security:null,unselectable:null},space:`html`,transform:Q_}),ev=Y_({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:W_,accentHeight:q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:q,amplitude:q,arabicForm:null,ascent:q,attributeName:null,attributeType:null,azimuth:q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:q,by:null,calcMode:null,capHeight:q,className:H_,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:q,diffuseConstant:q,direction:null,display:null,dur:null,divisor:q,dominantBaseline:null,download:z_,dx:null,dy:null,edgeMode:null,editable:null,elevation:q,enableBackground:null,end:null,event:null,exponent:q,externalResourcesRequired:null,fill:null,fillOpacity:q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:U_,g2:U_,glyphName:U_,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:q,horizOriginX:q,horizOriginY:q,id:null,ideographic:q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:q,k:q,k1:q,k2:q,k3:q,k4:q,kernelMatrix:W_,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:q,overlineThickness:q,paintOrder:null,panose1:null,path:null,pathLength:q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:H_,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:q,pointsAtY:q,pointsAtZ:q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:W_,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:W_,rev:W_,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:W_,requiredFeatures:W_,requiredFonts:W_,requiredFormats:W_,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:q,specularExponent:q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:q,strikethroughThickness:q,string:null,stroke:null,strokeDashArray:W_,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:q,strokeOpacity:q,strokeWidth:null,style:null,surfaceScale:q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:W_,tabIndex:q,tableValues:null,target:null,targetX:q,targetY:q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:W_,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:q,underlineThickness:q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:q,values:null,vAlphabetic:q,vMathematical:q,vectorEffect:null,vHanging:q,vIdeographic:q,version:null,vertAdvY:q,vertOriginX:q,vertOriginY:q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Z_}),tv=Y_({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),nv=Y_({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Q_}),rv=Y_({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),iv={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},av=/[A-Z]/g,ov=/-[a-z]/g,sv=/^data[-\w.:]+$/i;function cv(e,t){let n=F_(t),r=t,i=I_;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&sv.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(ov,uv);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!ov.test(e)){let n=e.replace(av,lv);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=q_}return new i(r,t)}function lv(e){return`-`+e.toLowerCase()}function uv(e){return e.charAt(1).toUpperCase()}var dv=P_([X_,$_,tv,nv,rv],`html`),fv=P_([X_,ev,tv,nv,rv],`svg`);function pv(e){return e.join(` `).trim()}var mv=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
162
|
+
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),hv=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(mv());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),gv=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),_v=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(hv()),r=gv();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),vv=bv(`end`),yv=bv(`start`);function bv(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function xv(e){let t=yv(e),n=vv(e);if(t&&n)return{start:t,end:n}}function Sv(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?wv(e.position):`start`in e||`end`in e?wv(e):`line`in e||`column`in e?Cv(e):``}function Cv(e){return Tv(e&&e.line)+`:`+Tv(e&&e.column)}function wv(e){return Cv(e&&e.start)+`-`+Cv(e&&e.end)}function Tv(e){return e&&typeof e==`number`?e:1}var Ev=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Sv(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};Ev.prototype.file=``,Ev.prototype.name=``,Ev.prototype.reason=``,Ev.prototype.message=``,Ev.prototype.stack=``,Ev.prototype.column=void 0,Ev.prototype.line=void 0,Ev.prototype.ancestors=void 0,Ev.prototype.cause=void 0,Ev.prototype.fatal=void 0,Ev.prototype.place=void 0,Ev.prototype.ruleId=void 0,Ev.prototype.source=void 0;var Dv=u(_v(),1),Ov={}.hasOwnProperty,kv=new Map,Av=/[A-Z]/g,jv=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Mv=new Set([`td`,`th`]),Nv=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function Pv(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Gv(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Wv(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?fv:dv,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Fv(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Fv(e,t,n){if(t.type===`element`)return Iv(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Lv(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return zv(e,t,n);if(t.type===`mdxjsEsm`)return Rv(e,t);if(t.type===`root`)return Bv(e,t,n);if(t.type===`text`)return Vv(e,t)}function Iv(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=fv,e.schema=i),e.ancestors.push(t);let a=Zv(e,t.tagName,!1),o=Kv(e,t),s=Jv(e,t);return jv.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!j_(e)})),Hv(e,o,a,t),Uv(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Lv(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Qv(e,t.position)}function Rv(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Qv(e,t.position)}function zv(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=fv,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Zv(e,t.name,!0),o=qv(e,t),s=Jv(e,t);return Hv(e,o,a,t),Uv(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Bv(e,t,n){let r={};return Uv(r,Jv(e,t)),e.create(t,e.Fragment,r,n)}function Vv(e,t){return t.value}function Hv(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Uv(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Wv(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Gv(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=yv(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Kv(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Ov.call(t.properties,i)){let a=Yv(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Mv.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function qv(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Qv(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Qv(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function Jv(e,t){let n=[],r=-1,i=e.passKeys?new Map:kv;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=Fv(e,a,o);s!==void 0&&n.push(s)}return n}function Yv(e,t,n){let r=cv(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?T_(n):pv(n)),r.property===`style`){let t=typeof n==`object`?n:Xv(e,String(n));return e.stylePropertyNameCase===`css`&&(t=$v(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?iv[r.property]||r.property:r.attribute,n]}}function Xv(e,t){try{return(0,Dv.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new Ev("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=Nv+`#cannot-parse-style-attribute`,r}}function Zv(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=k_(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=k_(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Ov.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Qv(e)}function Qv(e,t){let n=new Ev("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=Nv+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function $v(e){let t={},n;for(n in e)Ov.call(e,n)&&(t[ey(n)]=e[n]);return t}function ey(e){let t=e.replace(Av,ty);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function ty(e){return`-`+e.toLowerCase()}var ny={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},ry={};function iy(e,t){let n=t||ry;return ay(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function ay(e,t,n){if(sy(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return oy(e.children,t,n)}return Array.isArray(e)?oy(e,t,n):``}function oy(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=ay(e[i],t,n);return r.join(``)}function sy(e){return!!(e&&typeof e==`object`)}var cy=document.createElement(`i`);function ly(e){let t=`&`+e+`;`;cy.innerHTML=t;let n=cy.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function uy(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function dy(e,t){return e.length>0?(uy(e,e.length,0,t),e):t}var fy={}.hasOwnProperty;function py(e){let t={},n=-1;for(;++n<e.length;)my(t,e[n]);return t}function my(e,t){let n;for(n in t){let r=(fy.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){fy.call(r,a)||(r[a]=[]);let e=i[a];hy(r[a],Array.isArray(e)?e:e?[e]:[])}}}function hy(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);uy(e,0,0,r)}function gy(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function _y(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var vy=Ay(/[A-Za-z]/),yy=Ay(/[\dA-Za-z]/),by=Ay(/[#-'*+\--9=?A-Z^-~]/);function xy(e){return e!==null&&(e<32||e===127)}var Sy=Ay(/\d/),Cy=Ay(/[\dA-Fa-f]/),wy=Ay(/[!-/:-@[-`{-~]/);function Ty(e){return e!==null&&e<-2}function Ey(e){return e!==null&&(e<0||e===32)}function Dy(e){return e===-2||e===-1||e===32}var Oy=Ay(/\p{P}|\p{S}/u),ky=Ay(/\s/);function Ay(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function jy(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&yy(e.charCodeAt(n+1))&&yy(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function My(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Dy(r)?(e.enter(n),s(r)):t(r)}function s(r){return Dy(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Ny={tokenize:Py};function Py(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),My(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return Ty(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Fy={tokenize:Ly},Iy={tokenize:Ry};function Ly(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return uy(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Iy,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Iy,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return Ty(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;uy(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Ry(e,t,n){return My(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function zy(e){if(e===null||Ey(e)||ky(e))return 1;if(Oy(e))return 2}function By(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var Vy={name:`attention`,resolveAll:Hy,tokenize:Uy};function Hy(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Wy(d,-c),Wy(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=dy(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=dy(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=dy(l,By(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=dy(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=dy(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,uy(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function Uy(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=zy(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=zy(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function Wy(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var Gy={name:`autolink`,tokenize:Ky};function Ky(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return vy(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||yy(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||yy(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||xy(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):by(t)?(e.consume(t),l):n(t)}function u(e){return yy(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||yy(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var qy={partial:!0,tokenize:Jy};function Jy(e,t,n){return r;function r(t){return Dy(t)?My(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||Ty(e)?t(e):n(e)}}var Yy={continuation:{tokenize:Zy},exit:Qy,name:`blockQuote`,tokenize:Xy};function Xy(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Dy(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Zy(e,t,n){let r=this;return i;function i(t){return Dy(t)?My(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Yy,t,n)(r)}}function Qy(e){e.exit(`blockQuote`)}var $y={name:`characterEscape`,tokenize:eb};function eb(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return wy(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var tb={name:`characterReference`,tokenize:nb};function nb(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=yy,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Cy,u):(e.enter(`characterReferenceValue`),a=7,o=Sy,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===yy&&!ly(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var rb={partial:!0,tokenize:ob},ib={concrete:!0,name:`codeFenced`,tokenize:ab};function ab(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Dy(t)?My(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||Ty(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(rb,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||Ty(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Dy(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),My(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||Ty(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||Ty(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Dy(t)?My(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||Ty(t)?e.check(rb,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||Ty(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Dy(t)?My(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Dy(t)?My(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||Ty(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function ob(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var sb={name:`codeIndented`,tokenize:lb},cb={partial:!0,tokenize:ub};function lb(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),My(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):Ty(t)?e.attempt(cb,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||Ty(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function ub(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):Ty(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):My(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):Ty(e)?i(e):n(e)}}var db={name:`codeText`,previous:pb,resolve:fb,tokenize:mb};function fb(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function pb(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function mb(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):Ty(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||Ty(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var hb=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&gb(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),gb(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),gb(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);gb(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);gb(this.left,t.reverse())}}}};function gb(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function _b(e){let t={},n=-1,r,i,a,o,s,c,l,u=new hb(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,vb(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return uy(e,0,1/0,u.slice(0)),!l}function vb(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var yb={resolve:xb,tokenize:Sb},bb={partial:!0,tokenize:Cb};function xb(e){return _b(e),e}function Sb(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):Ty(t)?e.check(bb,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Cb(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),My(e,a,`linePrefix`)}function a(i){if(i===null||Ty(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function wb(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||xy(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||Ty(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||Ey(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||xy(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Tb(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):Ty(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||Ty(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Dy(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Eb(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):Ty(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),My(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||Ty(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Db(e,t){let n;return r;function r(i){return Ty(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Dy(i)?My(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Ob={name:`definition`,tokenize:Ab},kb={partial:!0,tokenize:jb};function Ab(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Tb.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=_y(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return Ey(t)?Db(e,l)(t):l(t)}function l(t){return wb(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(kb,d,d)(t)}function d(t){return Dy(t)?My(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||Ty(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function jb(e,t,n){return r;function r(t){return Ey(t)?Db(e,i)(t):n(t)}function i(t){return Eb(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Dy(t)?My(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||Ty(e)?t(e):n(e)}}var Mb={name:`hardBreakEscape`,tokenize:Nb};function Nb(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return Ty(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Pb={name:`headingAtx`,resolve:Fb,tokenize:Ib};function Fb(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},uy(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Ib(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||Ey(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||Ty(n)?(e.exit(`atxHeading`),t(n)):Dy(n)?My(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||Ey(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Lb=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Rb=[`pre`,`script`,`style`,`textarea`],zb={concrete:!0,name:`htmlFlow`,resolveTo:Hb,tokenize:Ub},Bb={partial:!0,tokenize:Gb},Vb={partial:!0,tokenize:Wb};function Hb(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Ub(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):vy(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):vy(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return vy(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||Ey(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&Rb.includes(l)?(i=1,r.interrupt?t(s):O(s)):Lb.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||yy(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Dy(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||vy(t)?(e.consume(t),b):Dy(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||yy(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Dy(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Dy(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||Ty(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||Ey(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Dy(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||Ty(t)?O(t):Dy(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):Ty(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Bb,ee,k)(t)):t===null||Ty(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Vb,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||Ty(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return Rb.includes(n)?(e.consume(t),L):O(t)}return vy(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||Ty(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function Wb(e,t,n){let r=this;return i;function i(t){return Ty(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Gb(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(qy,t,n)}}var Kb={name:`htmlText`,tokenize:qb};function qb(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):vy(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):vy(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):Ty(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):Ty(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):Ty(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):Ty(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return vy(t)?(e.consume(t),S):n(t)}function S(t){return t===45||yy(t)?(e.consume(t),S):C(t)}function C(t){return Ty(t)?(o=C,N(t)):Dy(t)?(e.consume(t),C):M(t)}function w(t){return t===45||yy(t)?(e.consume(t),w):t===47||t===62||Ey(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||vy(t)?(e.consume(t),E):Ty(t)?(o=T,N(t)):Dy(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||yy(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):Ty(t)?(o=D,N(t)):Dy(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):Ty(t)?(o=O,N(t)):Dy(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):Ty(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||Ey(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||Ey(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return Dy(t)?My(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var Jb={name:`labelEnd`,resolveAll:Qb,resolveTo:$b,tokenize:ex},Yb={tokenize:tx},Xb={tokenize:nx},Zb={tokenize:rx};function Qb(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&uy(e,0,e.length,n),e}function $b(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=dy(s,e.slice(a+1,a+r+3)),s=dy(s,[[`enter`,u,t]]),s=dy(s,By(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=dy(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=dy(s,e.slice(o+1)),s=dy(s,[[`exit`,c,t]]),uy(e,a,e.length,s),e}function ex(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(_y(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Yb,u,o?u:d)(t):t===91?e.attempt(Xb,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Zb,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function tx(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return Ey(t)?Db(e,a)(t):a(t)}function a(t){return t===41?u(t):wb(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return Ey(t)?Db(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Eb(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return Ey(t)?Db(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function nx(e,t,n){let r=this;return i;function i(t){return Tb.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(_y(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function rx(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var ix={name:`labelStartImage`,resolveAll:Jb.resolveAll,tokenize:ax};function ax(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var ox={name:`labelStartLink`,resolveAll:Jb.resolveAll,tokenize:sx};function sx(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var cx={name:`lineEnding`,tokenize:lx};function lx(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),My(e,t,`linePrefix`)}}var ux={name:`thematicBreak`,tokenize:dx};function dx(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||Ty(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Dy(t)?My(e,s,`whitespace`)(t):s(t))}}var fx={continuation:{tokenize:gx},exit:vx,name:`list`,tokenize:hx},px={partial:!0,tokenize:yx},mx={partial:!0,tokenize:_x};function hx(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Sy(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(ux,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Sy(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(qy,r.interrupt?n:u,e.attempt(px,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Dy(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function gx(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(qy,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,My(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Dy(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(mx,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,My(e,e.attempt(fx,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function _x(e,t,n){let r=this;return My(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function vx(e){e.exit(this.containerState.type)}function yx(e,t,n){let r=this;return My(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Dy(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var bx={name:`setextUnderline`,resolveTo:xx,tokenize:Sx};function xx(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Sx(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Dy(t)?My(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||Ty(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Cx={tokenize:wx};function wx(e){let t=this,n=e.attempt(qy,r,e.attempt(this.parser.constructs.flowInitial,i,My(e,e.attempt(this.parser.constructs.flow,i,e.attempt(yb,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Tx={resolveAll:kx()},Ex=Ox(`string`),Dx=Ox(`text`);function Ox(e){return{resolveAll:kx(e===`text`?Ax:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function kx(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Ax(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var jx=c({attentionMarkers:()=>zx,contentInitial:()=>Nx,disable:()=>Bx,document:()=>Mx,flow:()=>Fx,flowInitial:()=>Px,insideSpan:()=>Rx,string:()=>Ix,text:()=>Lx}),Mx={42:fx,43:fx,45:fx,48:fx,49:fx,50:fx,51:fx,52:fx,53:fx,54:fx,55:fx,56:fx,57:fx,62:Yy},Nx={91:Ob},Px={[-2]:sb,[-1]:sb,32:sb},Fx={35:Pb,42:ux,45:[bx,ux],60:zb,61:bx,95:ux,96:ib,126:ib},Ix={38:tb,92:$y},Lx={[-5]:cx,[-4]:cx,[-3]:cx,33:ix,38:tb,42:Vy,60:[Gy,Kb],91:ox,92:[Mb,$y],93:Jb,95:Vy,96:db},Rx={null:[Vy,Tx]},zx={null:[42,95]},Bx={null:[]};function Vx(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=dy(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=By(a,l.events,l),l.events):[]}function f(e,t){return Ux(p(e),t)}function p(e){return Hx(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){Ty(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&uy(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Hx(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Ux(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
163
163
|
`;break;case-3:o=`\r
|
|
164
|
-
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Ux(e){let t={constructs:fy([Ax,...(e||{}).extensions||[]]),content:n(My),defined:[],document:n(Py),flow:n(Sx),lazy:{},string:n(Tx),text:n(Ex)};return t;function n(e){return n;function n(n){return Bx(t,e,n)}}}function Wx(e){for(;!gb(e););return e}var Gx=/[\0\t\n\r]/g;function Kx(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Gx.lastIndex=u,c=Gx.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var qx=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Jx(e){return e.replace(qx,Yx)}function Yx(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return hy(n.slice(t?2:1),t?16:10)}return cy(n)||e}var Xx={}.hasOwnProperty;function Zx(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Qx(n)(Wx(Ux(n).document().write(Kx()(e,t,!0))))}function Qx(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(me),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ue),blockQuote:a(ae),characterEscape:T,characterReference:T,codeFenced:a(oe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(oe,o),codeText:a(se,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ce),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(le),hardBreakEscape:a(de),hardBreakTrailing:a(de),htmlFlow:a(fe,o),htmlFlowData:T,htmlText:a(fe,o),htmlTextData:T,image:a(pe),label:o,link:a(me),listItem:a(ge),listItemValue:f,listOrdered:a(he,d),listUnordered:a(he),paragraph:a(_e),reference:te,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ue),strong:a(ve),thematicBreak:a(be)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ie,autolinkProtocol:re,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:R,characterReferenceMarkerNumeric:R,characterReferenceValue:z,characterReference:B,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};eS(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Xx.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||nS).call(a,void 0,e[0])}for(r.position={start:$x(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:$x(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:$x(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||nS).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+xv({start:e.start,end:e.end})+`): it’s not open`);n.position.end=$x(e.end)}function u(){return ry(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=gy(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ye(),n.position={start:$x(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=$x(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=$x(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Jx(t),n.identifier=gy(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function te(){this.data.referenceType=`collapsed`}function ne(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=gy(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function R(e){this.data.characterReferenceType=e.type}function z(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=hy(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=cy(t);let i=this.stack[this.stack.length-1];i.value+=r}function B(e){let t=this.stack.pop();t.position.end=$x(e.end)}function re(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ie(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ae(){return{type:`blockquote`,children:[]}}function oe(){return{type:`code`,lang:null,meta:null,value:``}}function se(){return{type:`inlineCode`,value:``}}function ce(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function le(){return{type:`emphasis`,children:[]}}function ue(){return{type:`heading`,depth:0,children:[]}}function de(){return{type:`break`}}function fe(){return{type:`html`,value:``}}function pe(){return{type:`image`,title:null,url:``,alt:null}}function me(){return{type:`link`,title:null,url:``,children:[]}}function he(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ge(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function _e(){return{type:`paragraph`,children:[]}}function ve(){return{type:`strong`,children:[]}}function ye(){return{type:`text`,value:``}}function be(){return{type:`thematicBreak`}}}function $x(e){return{line:e.line,column:e.column,offset:e.offset}}function eS(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?eS(e,r):tS(e,r)}}function tS(e,t){let n;for(n in t)if(Xx.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function nS(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+xv({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+xv({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+xv({start:t.start,end:t.end})+`) is still open`)}function rS(e){let t=this;t.parser=n;function n(n){return Zx(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function iS(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function aS(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
165
|
-
`}]}function
|
|
166
|
-
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function
|
|
164
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Wx(e){let t={constructs:py([jx,...(e||{}).extensions||[]]),content:n(Ny),defined:[],document:n(Fy),flow:n(Cx),lazy:{},string:n(Ex),text:n(Dx)};return t;function n(e){return n;function n(n){return Vx(t,e,n)}}}function Gx(e){for(;!_b(e););return e}var Kx=/[\0\t\n\r]/g;function qx(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Kx.lastIndex=u,c=Kx.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Jx=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Yx(e){return e.replace(Jx,Xx)}function Xx(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return gy(n.slice(t?2:1),t?16:10)}return ly(n)||e}var Zx={}.hasOwnProperty;function Qx(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),$x(n)(Gx(Wx(n).document().write(qx()(e,t,!0))))}function $x(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(me),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ue),blockQuote:a(ae),characterEscape:T,characterReference:T,codeFenced:a(oe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(oe,o),codeText:a(se,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ce),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(le),hardBreakEscape:a(de),hardBreakTrailing:a(de),htmlFlow:a(fe,o),htmlFlowData:T,htmlText:a(fe,o),htmlTextData:T,image:a(pe),label:o,link:a(me),listItem:a(ge),listItemValue:f,listOrdered:a(he,d),listUnordered:a(he),paragraph:a(_e),reference:te,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ue),strong:a(ve),thematicBreak:a(be)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:ie,autolinkProtocol:re,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:R,characterReferenceMarkerNumeric:R,characterReferenceValue:z,characterReference:B,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};tS(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Zx.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||rS).call(a,void 0,e[0])}for(r.position={start:eS(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:eS(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:eS(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||rS).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Sv({start:e.start,end:e.end})+`): it’s not open`);n.position.end=eS(e.end)}function u(){return iy(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=_y(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ye(),n.position={start:eS(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=eS(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=eS(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Yx(t),n.identifier=_y(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function te(){this.data.referenceType=`collapsed`}function ne(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=_y(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function R(e){this.data.characterReferenceType=e.type}function z(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=gy(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=ly(t);let i=this.stack[this.stack.length-1];i.value+=r}function B(e){let t=this.stack.pop();t.position.end=eS(e.end)}function re(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function ie(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ae(){return{type:`blockquote`,children:[]}}function oe(){return{type:`code`,lang:null,meta:null,value:``}}function se(){return{type:`inlineCode`,value:``}}function ce(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function le(){return{type:`emphasis`,children:[]}}function ue(){return{type:`heading`,depth:0,children:[]}}function de(){return{type:`break`}}function fe(){return{type:`html`,value:``}}function pe(){return{type:`image`,title:null,url:``,alt:null}}function me(){return{type:`link`,title:null,url:``,children:[]}}function he(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ge(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function _e(){return{type:`paragraph`,children:[]}}function ve(){return{type:`strong`,children:[]}}function ye(){return{type:`text`,value:``}}function be(){return{type:`thematicBreak`}}}function eS(e){return{line:e.line,column:e.column,offset:e.offset}}function tS(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?tS(e,r):nS(e,r)}}function nS(e,t){let n;for(n in t)if(Zx.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function rS(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Sv({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Sv({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Sv({start:t.start,end:t.end})+`) is still open`)}function iS(e){let t=this;t.parser=n;function n(n){return Qx(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function aS(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function oS(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
165
|
+
`}]}function sS(e,t){let n=t.value?t.value+`
|
|
166
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function cS(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lS(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function uS(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=jy(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function dS(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function fS(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function pS(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function mS(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return pS(e,t);let i={src:jy(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function hS(e,t){let n={src:jy(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function gS(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function _S(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return pS(e,t);let i={href:jy(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function vS(e,t){let n={href:jy(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function yS(e,t,n){let r=e.all(t),i=n?bS(n):xS(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
167
167
|
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
168
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function
|
|
168
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function bS(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=xS(n[r])}return t}function xS(e){return e.spread??e.children.length>1}function SS(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function CS(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function wS(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function TS(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ES(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=yv(t.children[1]),o=vv(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function DS(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function OS(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var kS=9,AS=32;function jS(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(MS(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(MS(t.slice(i),i>0,!1)),a.join(``)}function MS(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===kS||t===AS;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===kS||t===AS;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function NS(e,t){let n={type:`text`,value:jS(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function PS(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var FS={blockquote:aS,break:oS,code:sS,delete:cS,emphasis:lS,footnoteReference:uS,heading:dS,html:fS,imageReference:mS,image:hS,inlineCode:gS,linkReference:_S,link:vS,listItem:yS,list:SS,paragraph:CS,root:wS,strong:TS,table:ES,tableCell:OS,tableRow:DS,text:NS,thematicBreak:PS,toml:IS,yaml:IS,definition:IS,footnoteDefinition:IS};function IS(){}var LS=typeof self==`object`?self:globalThis,RS=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new LS[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new LS[a](o),i)};return r},zS=e=>RS(new Map,e)(0),BS=``,{toString:VS}={},{keys:HS}=Object,US=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=VS.call(e).slice(8,-1);switch(n){case`Array`:return[1,BS];case`Object`:return[2,BS];case`Date`:return[3,BS];case`RegExp`:return[4,BS];case`Map`:return[5,BS];case`Set`:return[6,BS];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},WS=([e,t])=>e===0&&(t===`function`||t===`symbol`),GS=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=US(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of HS(r))(e||!WS(US(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(WS(US(n))||WS(US(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!WS(US(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},KS=(e,{json:t,lossy:n}={})=>{let r=[];return GS(!(t||n),!!t,new Map,r)(e),r},qS=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?zS(KS(e,t)):structuredClone(e):(e,t)=>zS(KS(e,t));function JS(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function YS(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function XS(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||JS,r=e.options.footnoteBackLabel||YS,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=jy(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...qS(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
169
169
|
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
170
|
-
`}]}}var
|
|
170
|
+
`}]}}var ZS=(function(e){if(e==null)return nC;if(typeof e==`function`)return tC(e);if(typeof e==`object`)return Array.isArray(e)?QS(e):$S(e);if(typeof e==`string`)return eC(e);throw Error(`Expected function, string, or object as test`)});function QS(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ZS(e[n]);return tC(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function $S(e){let t=e;return tC(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function eC(e){return tC(t);function t(t){return t&&t.type===e}}function tC(e){return t;function t(t,n,r){return!!(rC(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function nC(){return!0}function rC(e){return typeof e==`object`&&!!e&&`type`in e}function iC(e){return e}var aC=[];function oC(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=ZS(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+iC(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=aC,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=sC(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function sC(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?aC:[e]}function cC(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),oC(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var lC={}.hasOwnProperty,uC={};function dC(e,t){let n=t||uC,r=new Map,i=new Map,a={all:s,applyData:pC,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...FS,...n.handlers},one:o,options:n,patch:fC,wrap:hC};return cC(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(lC.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=qS(n);return r.children=a.all(e),r}return qS(e)}return(a.options.unknownHandler||mC)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=gC(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=gC(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function fC(e,t){e.position&&(t.position=xv(e))}function pC(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,qS(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function mC(e,t){let n=t.data||{},r=`value`in t&&!(lC.call(n,`hProperties`)||lC.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function hC(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
171
171
|
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
172
172
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
173
|
-
`}),n}function
|
|
174
|
-
`},i)),a}function _C(e,t){return e&&`run`in e?async function(n,r){let i=gC(n,{file:r,...t});await e.run(i,r)}:function(n,r){return gC(n,{file:r,...e||t})}}function vC(e){if(e)throw e}var yC=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function bC(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function xC(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?SC(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function SC(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var CC={basename:wC,dirname:TC,extname:EC,join:DC,sep:`/`};function wC(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);AC(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function TC(e){if(AC(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function EC(e){AC(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function DC(...e){let t=-1,n;for(;++t<e.length;)AC(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:OC(n)}function OC(e){AC(e);let t=e.codePointAt(0)===47,n=kC(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function kC(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function AC(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var jC={cwd:MC};function MC(){return`/`}function NC(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function PC(e){if(typeof e==`string`)e=new URL(e);else if(!NC(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return FC(e)}function FC(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var IC=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],LC=class{constructor(e){let t;t=e?NC(e)?{path:e}:typeof e==`string`||VC(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:jC.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<IC.length;){let e=IC[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)IC.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?CC.basename(this.path):void 0}set basename(e){zC(e,`basename`),RC(e,`basename`),this.path=CC.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?CC.dirname(this.path):void 0}set dirname(e){BC(this.basename,`dirname`),this.path=CC.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?CC.extname(this.path):void 0}set extname(e){if(RC(e,`extname`),BC(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=CC.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){NC(e)&&(e=PC(e)),zC(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?CC.basename(this.path,this.extname):void 0}set stem(e){zC(e,`stem`),RC(e,`stem`),this.path=CC.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Tv(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function RC(e,t){if(e&&e.includes(CC.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+CC.sep+"`")}function zC(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function BC(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function VC(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var HC=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),UC=u(yC(),1),WC={}.hasOwnProperty,GC=new class e extends HC{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=xC()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,UC.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(JC(`data`,this.frozen),this.namespace[e]=t,this):WC.call(this.namespace,e)&&this.namespace[e]||void 0:e?(JC(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=ZC(e),n=this.parser||this.Parser;return KC(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),KC(`process`,this.parser||this.Parser),qC(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=ZC(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);$C(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),KC(`processSync`,this.parser||this.Parser),qC(`processSync`,this.compiler||this.Compiler),this.process(e,r),XC(`processSync`,`process`,t),n;function r(e,r){t=!0,vC(e),n=r}}run(e,t,n){YC(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=ZC(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),XC(`runSync`,`run`,n),r;function i(e,t){vC(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=ZC(t),r=this.compiler||this.Compiler;return qC(`stringify`,r),YC(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(JC(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,UC.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];bC(o)&&bC(r)&&(r=(0,UC.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function KC(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function qC(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function JC(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function YC(e){if(!bC(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function XC(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function ZC(e){return QC(e)?e:new LC(e)}function QC(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function $C(e){return typeof e==`string`||ew(e)}function ew(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var tw=[],nw={allowDangerousHtml:!0},rw=/^(https?|ircs?|mailto|xmpp)$/i,iw=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function aw(e){let t=ow(e),n=sw(e);return cw(t.runSync(t.parse(n),n),e)}function ow(e){let t=e.rehypePlugins||tw,n=e.remarkPlugins||tw,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...nw}:nw;return GC().use(rS).use(n).use(_C,r).use(t)}function sw(e){let t=e.children||``,n=new LC;return typeof t==`string`?n.value=t:``+t,n}function cw(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||lw;for(let e of iw)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return sC(e,l),Nv(e,{Fragment:H.Fragment,components:i,ignoreInvalidStyle:!0,jsx:H.jsx,jsxs:H.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in ty)if(Object.hasOwn(ty,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=ty[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function lw(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||rw.test(e.slice(0,t))?e:``}function uw(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function dw(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function fw(e,t,n){let r=XS((n||{}).ignore||[]),i=pw(t),a=-1;for(;++a<i.length;)aC(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function pw(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([mw(e[0]),hw(e[1])])}return t}function mw(e){return typeof e==`string`?new RegExp(dw(e),`g`):e}function hw(e){return typeof e==`function`?e:function(){return e}}var gw=`phrasing`,_w=[`autolink`,`link`,`image`,`label`];function vw(){return{transforms:[Ew],enter:{literalAutolink:bw,literalAutolinkEmail:xw,literalAutolinkHttp:xw,literalAutolinkWww:xw},exit:{literalAutolink:Tw,literalAutolinkEmail:ww,literalAutolinkHttp:Sw,literalAutolinkWww:Cw}}}function yw(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:gw,notInConstruct:_w},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:gw,notInConstruct:_w},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:gw,notInConstruct:_w}]}}function bw(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function xw(e){this.config.enter.autolinkProtocol.call(this,e)}function Sw(e){this.config.exit.autolinkProtocol.call(this,e)}function Cw(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function ww(e){this.config.exit.autolinkEmail.call(this,e)}function Tw(e){this.exit(e)}function Ew(e){fw(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Dw],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Ow]],{ignore:[`link`,`linkReference`]})}function Dw(e,t,n,r,i){let a=``;if(!jw(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!kw(n)))return!1;let o=Aw(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Ow(e,t,n,r){return!jw(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function kw(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Aw(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=uw(e,`(`),a=uw(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function jw(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Oy(n)||Dy(n))&&(!t||n!==47)}Vw.peek=Bw;function Mw(){this.buffer()}function Nw(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Pw(){this.buffer()}function Fw(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Iw(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=gy(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Lw(e){this.exit(e)}function Rw(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=gy(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zw(e){this.exit(e)}function Bw(){return`[`}function Vw(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Hw(){return{enter:{gfmFootnoteCallString:Mw,gfmFootnoteCall:Nw,gfmFootnoteDefinitionLabelString:Pw,gfmFootnoteDefinition:Fw},exit:{gfmFootnoteCallString:Iw,gfmFootnoteCall:Lw,gfmFootnoteDefinitionLabelString:Rw,gfmFootnoteDefinition:zw}}}function Uw(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Vw},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
175
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Gw
|
|
176
|
-
`)}function
|
|
177
|
-
`&&
|
|
178
|
-
`}function
|
|
173
|
+
`}),n}function gC(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function _C(e,t){let n=dC(e,t),r=n.one(e,void 0),i=XS(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
174
|
+
`},i)),a}function vC(e,t){return e&&`run`in e?async function(n,r){let i=_C(n,{file:r,...t});await e.run(i,r)}:function(n,r){return _C(n,{file:r,...e||t})}}function yC(e){if(e)throw e}var bC=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function xC(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function SC(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?CC(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function CC(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var wC={basename:TC,dirname:EC,extname:DC,join:OC,sep:`/`};function TC(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);jC(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function EC(e){if(jC(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function DC(e){jC(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function OC(...e){let t=-1,n;for(;++t<e.length;)jC(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:kC(n)}function kC(e){jC(e);let t=e.codePointAt(0)===47,n=AC(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function AC(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function jC(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var MC={cwd:NC};function NC(){return`/`}function PC(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function FC(e){if(typeof e==`string`)e=new URL(e);else if(!PC(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return IC(e)}function IC(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var LC=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],RC=class{constructor(e){let t;t=e?PC(e)?{path:e}:typeof e==`string`||HC(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:MC.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<LC.length;){let e=LC[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)LC.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?wC.basename(this.path):void 0}set basename(e){BC(e,`basename`),zC(e,`basename`),this.path=wC.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?wC.dirname(this.path):void 0}set dirname(e){VC(this.basename,`dirname`),this.path=wC.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?wC.extname(this.path):void 0}set extname(e){if(zC(e,`extname`),VC(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=wC.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){PC(e)&&(e=FC(e)),BC(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?wC.basename(this.path,this.extname):void 0}set stem(e){BC(e,`stem`),zC(e,`stem`),this.path=wC.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new Ev(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function zC(e,t){if(e&&e.includes(wC.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+wC.sep+"`")}function BC(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function VC(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function HC(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var UC=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),WC=u(bC(),1),GC={}.hasOwnProperty,KC=new class e extends UC{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=SC()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,WC.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(YC(`data`,this.frozen),this.namespace[e]=t,this):GC.call(this.namespace,e)&&this.namespace[e]||void 0:e?(YC(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=QC(e),n=this.parser||this.Parser;return qC(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),qC(`process`,this.parser||this.Parser),JC(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=QC(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);ew(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),qC(`processSync`,this.parser||this.Parser),JC(`processSync`,this.compiler||this.Compiler),this.process(e,r),ZC(`processSync`,`process`,t),n;function r(e,r){t=!0,yC(e),n=r}}run(e,t,n){XC(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=QC(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),ZC(`runSync`,`run`,n),r;function i(e,t){yC(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=QC(t),r=this.compiler||this.Compiler;return JC(`stringify`,r),XC(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(YC(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,WC.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];xC(o)&&xC(r)&&(r=(0,WC.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function qC(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function JC(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function YC(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function XC(e){if(!xC(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function ZC(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function QC(e){return $C(e)?e:new RC(e)}function $C(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function ew(e){return typeof e==`string`||tw(e)}function tw(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var nw=[],rw={allowDangerousHtml:!0},iw=/^(https?|ircs?|mailto|xmpp)$/i,aw=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function ow(e){let t=sw(e),n=cw(e);return lw(t.runSync(t.parse(n),n),e)}function sw(e){let t=e.rehypePlugins||nw,n=e.remarkPlugins||nw,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...rw}:rw;return KC().use(iS).use(n).use(vC,r).use(t)}function cw(e){let t=e.children||``,n=new RC;return typeof t==`string`?n.value=t:``+t,n}function lw(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||uw;for(let e of aw)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return cC(e,l),Pv(e,{Fragment:H.Fragment,components:i,ignoreInvalidStyle:!0,jsx:H.jsx,jsxs:H.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in ny)if(Object.hasOwn(ny,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=ny[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function uw(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||iw.test(e.slice(0,t))?e:``}function dw(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function fw(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function pw(e,t,n){let r=ZS((n||{}).ignore||[]),i=mw(t),a=-1;for(;++a<i.length;)oC(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function mw(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([hw(e[0]),gw(e[1])])}return t}function hw(e){return typeof e==`string`?new RegExp(fw(e),`g`):e}function gw(e){return typeof e==`function`?e:function(){return e}}var _w=`phrasing`,vw=[`autolink`,`link`,`image`,`label`];function yw(){return{transforms:[Dw],enter:{literalAutolink:xw,literalAutolinkEmail:Sw,literalAutolinkHttp:Sw,literalAutolinkWww:Sw},exit:{literalAutolink:Ew,literalAutolinkEmail:Tw,literalAutolinkHttp:Cw,literalAutolinkWww:ww}}}function bw(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:_w,notInConstruct:vw},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:_w,notInConstruct:vw},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:_w,notInConstruct:vw}]}}function xw(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Sw(e){this.config.enter.autolinkProtocol.call(this,e)}function Cw(e){this.config.exit.autolinkProtocol.call(this,e)}function ww(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Tw(e){this.config.exit.autolinkEmail.call(this,e)}function Ew(e){this.exit(e)}function Dw(e){pw(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Ow],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,kw]],{ignore:[`link`,`linkReference`]})}function Ow(e,t,n,r,i){let a=``;if(!Mw(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Aw(n)))return!1;let o=jw(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function kw(e,t,n,r){return!Mw(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Aw(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function jw(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=dw(e,`(`),a=dw(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Mw(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||ky(n)||Oy(n))&&(!t||n!==47)}Hw.peek=Vw;function Nw(){this.buffer()}function Pw(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Fw(){this.buffer()}function Iw(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Lw(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=_y(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Rw(e){this.exit(e)}function zw(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=_y(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Bw(e){this.exit(e)}function Vw(){return`[`}function Hw(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Uw(){return{enter:{gfmFootnoteCallString:Nw,gfmFootnoteCall:Pw,gfmFootnoteDefinitionLabelString:Fw,gfmFootnoteDefinition:Iw},exit:{gfmFootnoteCallString:Lw,gfmFootnoteCall:Rw,gfmFootnoteDefinitionLabelString:zw,gfmFootnoteDefinition:Bw}}}function Ww(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Hw},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
175
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Kw:Gw))),s(),o}}function Gw(e,t,n){return t===0?e:Kw(e,t,n)}function Kw(e,t,n){return(n?``:` `)+e}var qw=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Qw.peek=$w;function Jw(){return{canContainEols:[`delete`],enter:{strikethrough:Xw},exit:{strikethrough:Zw}}}function Yw(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:qw}],handlers:{delete:Qw}}}function Xw(e){this.enter({type:`delete`,children:[]},e)}function Zw(e){this.exit(e)}function Qw(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function $w(){return`~`}function eT(e){return e.length}function tT(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||eT,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=nT(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=rT(r[d]);else{let e=rT(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
176
|
+
`)}function nT(e){return e==null?``:String(e)}function rT(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function iT(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),aT);return i(),o}function aT(e,t,n){return`>`+(n?``:` `)+e}function oT(e,t){return sT(e,t.inConstruct,!0)&&!sT(e,t.notInConstruct,!1)}function sT(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function cT(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
177
|
+
`&&oT(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
178
|
+
`}function lT(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function uT(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function dT(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function fT(e,t,n,r){let i=dT(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(uT(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,pT);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(lT(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
179
179
|
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
180
180
|
`),a&&(u+=s.move(a+`
|
|
181
|
-
`)),u+=s.move(c),l(),u}function
|
|
182
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function
|
|
181
|
+
`)),u+=s.move(c),l(),u}function pT(e,t,n){return(n?``:` `)+e}function mT(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function hT(e,t,n,r){let i=mT(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
182
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function gT(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function _T(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function vT(e,t,n){let r=zy(e),i=zy(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}yT.peek=bT;function yT(e,t,n,r){let i=gT(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=vT(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=_T(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=vT(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+_T(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function bT(e,t,n){return n.options.emphasis||`*`}function xT(e,t){let n=!1;return cC(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&iy(e)&&(t.options.setext||n))}function ST(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(xT(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
183
183
|
`,after:`
|
|
184
184
|
`});return r(),t(),o+`
|
|
185
185
|
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
186
186
|
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
187
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=
|
|
187
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=_T(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}CT.peek=wT;function CT(e){return e.value||``}function wT(){return`<`}TT.peek=ET;function TT(e,t,n,r){let i=mT(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function ET(){return`!`}DT.peek=OT;function DT(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function OT(){return`!`}kT.peek=AT;function kT(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function AT(){return"`"}function jT(e,t){let n=iy(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}MT.peek=NT;function MT(e,t,n,r){let i=mT(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(jT(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function NT(e,t,n){return jT(e,n)?`<`:`[`}PT.peek=FT;function PT(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function FT(){return`[`}function IT(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function LT(e){let t=IT(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function RT(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function zT(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function BT(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?RT(n):IT(n),s=e.ordered?o===`.`?`)`:`.`:LT(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),zT(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function VT(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function HT(e,t,n,r){let i=VT(n),a=n.bulletCurrent||IT(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function UT(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var WT=ZS([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function GT(e,t,n,r){return(e.children.some(function(e){return WT(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function KT(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}qT.peek=JT;function qT(e,t,n,r){let i=KT(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=vT(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=_T(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=vT(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+_T(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function JT(e,t,n){return n.options.strong||`*`}function YT(e,t,n,r){return n.safe(e.value,r)}function XT(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function ZT(e,t,n){let r=(zT(n)+(n.options.ruleSpaces?` `:``)).repeat(XT(n));return n.options.ruleSpaces?r.slice(0,-1):r}var QT={blockquote:iT,break:cT,code:fT,definition:hT,emphasis:yT,hardBreak:cT,heading:ST,html:CT,image:TT,imageReference:DT,inlineCode:kT,link:MT,linkReference:PT,list:BT,listItem:HT,paragraph:UT,root:GT,strong:qT,text:YT,thematicBreak:ZT};function $T(){return{enter:{table:eE,tableData:iE,tableHeader:iE,tableRow:nE},exit:{codeText:aE,table:tE,tableData:rE,tableHeader:rE,tableRow:rE}}}function eE(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function tE(e){this.exit(e),this.data.inTable=void 0}function nE(e){this.enter({type:`tableRow`,children:[]},e)}function rE(e){this.exit(e)}function iE(e){this.enter({type:`tableCell`,children:[]},e)}function aE(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,oE));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function oE(e,t){return t===`|`?t:e}function sE(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
188
188
|
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
189
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return eT(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=ZT.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function sE(){return{exit:{taskListCheckValueChecked:lE,taskListCheckValueUnchecked:lE,paragraph:uE}}}function cE(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:dE}}}function lE(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function uE(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function dE(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=ZT.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function fE(){return[vw(),Hw(),qw(),QT(),sE()]}function pE(e){return{extensions:[yw(),Uw(e),Jw(),oE(e),cE()]}}var mE={tokenize:OE,partial:!0},hE={tokenize:kE,partial:!0},gE={tokenize:AE,partial:!0},_E={tokenize:jE,partial:!0},vE={tokenize:ME,partial:!0},yE={name:`wwwAutolink`,tokenize:EE,previous:NE},bE={name:`protocolAutolink`,tokenize:DE,previous:PE},xE={name:`emailAutolink`,tokenize:TE,previous:FE},SE={};function CE(){return{text:SE}}for(var wE=48;wE<123;)SE[wE]=xE,wE++,wE===58?wE=65:wE===91&&(wE=97);SE[43]=xE,SE[45]=xE,SE[46]=xE,SE[95]=xE,SE[72]=[xE,bE],SE[104]=[xE,bE],SE[87]=[xE,yE],SE[119]=[xE,yE];function TE(e,t,n){let r=this,i,a;return o;function o(t){return!IE(t)||!FE.call(r,r.previous)||LE(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return IE(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(vE,u,l)(t):t===45||t===95||vy(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&_y(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function EE(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!NE.call(r,r.previous)||LE(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(mE,e.attempt(hE,e.attempt(gE,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function DE(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&PE.call(r,r.previous)&&!LE(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(_y(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||by(t)||Ty(t)||Oy(t)||Dy(t)?n(t):e.attempt(hE,e.attempt(gE,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function OE(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function kE(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(_E,c,s)(t):t===null||Ty(t)||Oy(t)||t!==45&&Dy(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function AE(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(_E,t,a)(o):o===null||Ty(o)||Oy(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function jE(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Ty(o)||Oy(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Ty(e)||Oy(e)?t(e):r(e)}function a(e){return _y(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):_y(t)?(e.consume(t),o):n(t)}}function ME(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return vy(e)?n(e):t(e)}}function NE(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ty(e)}function PE(e){return!_y(e)}function FE(e){return!(e===47||IE(e))}function IE(e){return e===43||e===45||e===46||e===95||vy(e)}function LE(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var RE={tokenize:KE,partial:!0};function zE(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:UE,continuation:{tokenize:WE},exit:GE}},text:{91:{name:`gfmFootnoteCall`,tokenize:HE},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:BE,resolveTo:VE}}}}function BE(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=gy(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function VE(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function HE(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Ty(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(gy(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Ty(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function UE(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Ty(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=gy(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Ty(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),jy(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function WE(e,t,n){return e.check(Ky,t,e.attempt(RE,t,n))}function GE(e){e.exit(`gfmFootnoteDefinition`)}function KE(e,t,n){let r=this;return jy(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function qE(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&ly(o,o.length,0,zy(s,e.slice(r+1,n),t)),ly(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),ly(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=Ry(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=Ry(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var JE=class{constructor(){this.map=[]}add(e,t,n){YE(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function YE(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function XE(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function ZE(){return{flow:{null:{name:`table`,tokenize:QE,resolveAll:$E}}}}function QE(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):wy(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Ey(t)?jy(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Ty(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Ey(t)?jy(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Ey(t)?jy(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||wy(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Ey(t)?jy(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||wy(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||wy(n)?(e.exit(`tableRow`),t(n)):Ey(n)?jy(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Ty(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function $E(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new JE;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(tD(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=eD(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=eD(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=eD(f,t,o,i,n,d)):(o[0]=o[1],d=eD(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&tD(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=XE(t.events,n))}return e}function eD(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},nD(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=nD(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=nD(t.events,n[2]),a=nD(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},nD(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function tD(e,t,n,r,i){let a=[],o=nD(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function nD(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var rD={name:`tasklistCheck`,tokenize:aD};function iD(){return{text:{91:rD}}}function aD(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Ty(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return wy(r)?t(r):Ey(r)?e.check({tokenize:oD},t,n)(r):n(r)}}function oD(e,t,n){return jy(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function sD(e){return fy([CE(),zE(),qE(e),ZE(),iD()])}var cD={};function lD(e){let t=this,n=e||cD,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(sD(n)),a.push(fE()),o.push(pE(n))}var uD=180;function dD(e){return e.replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/^#+\s+/gm,``).replace(/\s+/g,` `).trim()}function fD(e,t){if(t?.trim())return t.trim();let n=dD(e.split(/\n\n+/)[0]?.replace(/\n/g,` `)??e);return n.length<=uD?n:`${n.slice(0,179).trimEnd()}…`}function pD(e,t){return t?.trim()&&e.length>uD?!0:e.length>uD||/\n/.test(e)}function mD({description:e,title:t,expanded:n,onToggle:r}){let i=fD(e,t),a=pD(e,t);return e?a?(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`line-clamp-3 text-sm leading-relaxed`,children:i}),(0,H.jsxs)(`button`,{type:`button`,onClick:r,className:`inline-flex items-center gap-1 text-xs text-[#92E4DD] hover:text-white`,children:[(0,H.jsx)(hi,{className:`h-3.5 w-3.5 transition-transform ${n?`rotate-180`:``}`}),n?`Hide full description`:`Show full description`]})]}):(0,H.jsx)(`span`,{children:i}):(0,H.jsx)(`span`,{className:`text-gray-500`,children:`—`})}function hD({description:e}){return(0,H.jsx)(`div`,{className:`max-h-64 overflow-auto rounded border border-white/10 bg-[#0F0F0C] p-3`,children:(0,H.jsx)(`div`,{className:`prose prose-sm prose-invert max-w-none prose-headings:text-gray-100 prose-p:text-gray-300 prose-li:text-gray-300 prose-strong:text-gray-100 prose-code:text-[#92E4DD] prose-code:before:content-none prose-code:after:content-none`,children:(0,H.jsx)(aw,{remarkPlugins:[lD],children:e})})})}function gD(){let[e,t]=(0,b.useState)(null);return{expandedDescription:e,toggleDescription:e=>{t(t=>t===e?null:e)}}}function _D(e){return new Set(e.filter(e=>e.enabled===!1).map(e=>e.name))}function vD({serviceId:e,tools:t,isLoading:n}){let[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(null),{expandedDescription:s,toggleDescription:c}=gD(),[l,u]=(0,b.useState)(()=>_D(t)),d=Tt(),{toast:f}=an(),p=(0,b.useMemo)(()=>t.map(e=>`${e.name}:${e.enabled===!1?`0`:`1`}`).sort().join(`\0`),[t]);(0,b.useEffect)(()=>{u(_D(t))},[e,p]);let m=Vt({mutationFn:async t=>{await U(`PUT`,`/api/services/${e}/tool-settings`,{disabledTools:t})},onSuccess:()=>{d.invalidateQueries({queryKey:[`/api/services`,e,`tools`]}),d.invalidateQueries({queryKey:[`/api/services`]})},onError:e=>{f({title:`Could not save tool settings`,description:e.message,variant:`destructive`}),u(_D(t))}}),h=e=>{u(e),m.mutate([...e])},g=(e,t)=>{let n=new Set(l);t?n.delete(e):n.add(e),h(n)},_=e=>{if(e){h(new Set);return}h(new Set(t.map(e=>e.name)))},v=(0,b.useMemo)(()=>{let e=r.trim().toLowerCase();return e?t.filter(t=>t.name.toLowerCase().includes(e)||(t.title?.toLowerCase().includes(e)??!1)||t.description.toLowerCase().includes(e)):t},[t,r]),y=t.length-l.size;return n?(0,H.jsx)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading tools…`})}):t.length===0?null:(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center`,children:[(0,H.jsx)(Xi,{className:`w-5 h-5 mr-2`}),`Tools`,(0,H.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-gray-400`,children:[y,` of `,t.length,` enabled`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-8 text-xs text-[#A8C4C0] hover:text-white hover:bg-white/10`,onClick:()=>_(!0),disabled:l.size===0||m.isPending,children:`Enable all`}),(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-8 text-xs text-[#A8C4C0] hover:text-white hover:bg-white/10`,onClick:()=>_(!1),disabled:y===0||m.isPending,children:`Disable all`})]})]}),(0,H.jsx)(`p`,{className:`mb-3 text-xs text-[#A8C4C0]`,children:`Choose which tools your agent can use from this MCP. Disabled tools are hidden from the agent but stay registered on the server.`}),(0,H.jsxs)(`div`,{className:`relative mb-3`,children:[(0,H.jsx)(zi,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500`}),(0,H.jsx)(Eu,{value:r,onChange:e=>i(e.target.value),placeholder:`Search tools…`,className:`border-white/15 bg-[#0F0F0C] pl-9 text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsx)(`div`,{className:`rounded-md border border-white/10 overflow-hidden`,children:(0,H.jsxs)(g_,{children:[(0,H.jsx)(__,{children:(0,H.jsxs)(b_,{className:`border-white/10 hover:bg-transparent`,children:[(0,H.jsx)(x_,{className:`w-[72px] text-center text-[#A8C4C0]`,children:`Enabled`}),(0,H.jsx)(x_,{className:`w-[220px] text-[#A8C4C0]`,children:`Tool`}),(0,H.jsx)(x_,{className:`text-[#A8C4C0]`,children:`Description`})]})}),(0,H.jsx)(v_,{children:v.length===0?(0,H.jsx)(b_,{className:`border-white/10 hover:bg-transparent`,children:(0,H.jsx)(S_,{colSpan:3,className:`py-8 text-center text-sm text-gray-400`,children:`No tools match your search.`})}):v.map(e=>{let t=!l.has(e.name),n=a===e.name,r=s===e.name,i=e.inputSchema&&Object.keys(e.inputSchema).length>0;return(0,H.jsxs)(b.Fragment,{children:[(0,H.jsxs)(b_,{className:`border-white/10 ${t?`hover:bg-white/5`:`opacity-60 hover:bg-white/5`}`,children:[(0,H.jsx)(S_,{className:`text-center`,children:(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(h_,{checked:t,onCheckedChange:t=>g(e.name,t===!0),disabled:m.isPending,"aria-label":`${t?`Disable`:`Enable`} ${e.name}`,className:`h-[18px] w-[18px] border-white/40 bg-[#0F0F0C] data-[state=checked]:border-[#92E4DD] data-[state=checked]:bg-[#92E4DD] data-[state=checked]:text-[#0F0F0C]`})})}),(0,H.jsx)(S_,{children:i?(0,H.jsxs)(`button`,{type:`button`,onClick:()=>o(n?null:e.name),className:`flex w-full items-center gap-1 text-left font-mono text-sm text-[#92E4DD] hover:text-white`,children:[(0,H.jsx)(hi,{className:`h-4 w-4 shrink-0 transition-transform ${n?`rotate-180`:``}`}),e.name]}):(0,H.jsx)(`span`,{className:`font-mono text-sm text-[#92E4DD]`,children:e.name})}),(0,H.jsx)(S_,{className:`max-w-0 text-sm text-gray-300`,children:(0,H.jsx)(mD,{description:e.description,title:e.title,expanded:r,onToggle:()=>c(e.name)})})]}),r&&(0,H.jsx)(b_,{className:`border-white/10 bg-black/30 hover:bg-black/30`,children:(0,H.jsx)(S_,{colSpan:3,className:`py-3`,children:(0,H.jsx)(hD,{description:e.description})})}),i&&n&&(0,H.jsx)(b_,{className:`border-white/10 bg-black/30 hover:bg-black/30`,children:(0,H.jsx)(S_,{colSpan:3,className:`py-3`,children:(0,H.jsx)(`pre`,{className:`max-h-48 overflow-auto rounded border border-white/10 bg-[#0F0F0C] p-3 text-xs text-gray-300`,children:JSON.stringify(e.inputSchema,null,2)})})})]},e.name)})})]})})]})}function yD({items:e,className:t}){return e.length===0?null:(0,H.jsx)(`ol`,{className:`list-decimal list-inside space-y-1 text-xs ${t??``}`,children:e.map((e,t)=>(0,H.jsx)(`li`,{children:e},`${t}-${e.slice(0,24)}`))})}function bD({serviceId:e,onConnected:t}){let{toast:n}=an(),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),{data:p,isLoading:m}=Bt({queryKey:[`/api/oauth`,e,`setup`],queryFn:async()=>{let t=await U(`GET`,`/api/oauth/${e}/setup`),n=await t.json();if(!t.ok||!n.success)throw Error(n.error||`Failed to load OAuth setup`);return n.data},enabled:!!e}),h=p?.guide,g=!!p?.hasSavedCredentials,_=()=>{if(!l||h?.setupMode!==`manual`)return;let e={};return r.trim()&&(e.clientId=r.trim()),a.trim()&&(e.clientSecret=a.trim()),e},v=async(e,t)=>{try{await navigator.clipboard.writeText(t),n({title:`Copied`,description:`${e} copied to clipboard.`})}catch{n({title:`Copy failed`,description:`Select and copy manually.`,variant:`destructive`})}};(0,b.useEffect)(()=>{h?.setupMode===`manual`?u(!0):u(!1),f(!g)},[h?.setupMode,g]),(0,b.useEffect)(()=>{p?.savedOAuthClientId&&!r&&i(p.savedOAuthClientId)},[p?.savedOAuthClientId,r]);let y=async r=>{c(!0);try{let i=await U(`POST`,`/api/oauth/${e}/connect`,r??{}),a=await i.json();if(!i.ok||!a.success){(a.data?.needsCredentials||a.data?.setupMode===`manual`)&&u(!0),n({title:`OAuth setup`,description:a.error||`Could not start OAuth flow.`,variant:`destructive`});return}a.data?.authorizationUrl&&(window.open(a.data.authorizationUrl,`_blank`),n({title:`Continue in browser`,description:`Complete sign-in in the new tab, then return here.`}),t?.())}catch(e){n({title:`OAuth setup failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{c(!1)}};if(m)return(0,H.jsx)(`p`,{className:`text-sm text-orange-200`,children:`Loading setup guide…`});if(!h)return null;if(h.setupMode===`unavailable`)return(0,H.jsxs)(`div`,{className:`space-y-3 text-sm text-orange-100`,children:[(0,H.jsx)(`p`,{children:h.unavailableReason}),h.docsUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.docsUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Provider docs`]})]});let x=h.setupMode===`dynamic`||h.setupMode===`managed`||h.setupMode===`manual`;return(0,H.jsxs)(`div`,{className:`space-y-4 text-sm text-orange-100`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-medium text-orange-200`,children:h.title}),h.summary&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-orange-100/90`,children:h.summary}),x&&(0,H.jsxs)(`p`,{className:`mt-2 text-xs text-orange-100/80`,children:[`Redirect URI:`,` `,(0,H.jsx)(`code`,{className:`text-orange-50`,children:h.redirectUri})]}),h.easierAlternative&&(0,H.jsx)(`p`,{className:`mt-2 text-xs text-orange-100/70 border-l-2 border-orange-500/30 pl-2`,children:h.easierAlternative})]}),g&&h.setupMode===`manual`&&(0,H.jsxs)(`div`,{className:`rounded-lg border border-green-500/30 bg-green-500/10 p-3 text-xs text-green-100`,children:[(0,H.jsx)(`p`,{className:`font-medium text-green-200`,children:`OAuth credentials saved`}),(0,H.jsx)(`p`,{className:`mt-1 text-green-100/90`,children:`Client ID is prefilled and your secret is remembered. Click Reconnect — no need to paste the secret again unless Slack rejects the flow.`})]}),h.prerequisites&&h.prerequisites.length>0&&!g&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-orange-200 mb-1`,children:`Before you start`}),(0,H.jsx)(`ul`,{className:`list-disc list-inside space-y-1 text-xs text-orange-100/90`,children:h.prerequisites.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),(h.manifestJson||h.createAppUrl||x)&&(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[h.manifestJson&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>void v(`App manifest`,h.manifestJson),children:[(0,H.jsx)(Si,{className:`w-4 h-4 mr-1`}),`Copy manifest`]}),x&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>void v(`Redirect URI`,h.redirectUri),children:[(0,H.jsx)(Ci,{className:`w-4 h-4 mr-1`}),`Copy redirect URI`]}),h.createAppUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.createAppUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),h.createAppLabel??`Open app creator`]})]}),h.steps.length>0&&(0,H.jsx)(`div`,{children:g&&h.setupMode===`manual`?(0,H.jsxs)(`details`,{className:`rounded-lg border border-orange-500/20 bg-orange-500/5 p-3`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-orange-200`,children:`First-time Slack app setup`}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(yD,{items:h.steps})})]}):(0,H.jsxs)(H.Fragment,{children:[h.setupMode===`informational`?(0,H.jsx)(`p`,{className:`text-xs font-medium text-orange-200 mb-1`,children:`What to do`}):null,(0,H.jsx)(yD,{items:h.steps})]})}),h.tokenAlternative&&(0,H.jsxs)(`p`,{className:`text-xs text-orange-100/80 border-l-2 border-orange-500/30 pl-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-orange-200`,children:`Alternative: `}),h.tokenAlternative]}),l&&h.setupMode===`manual`&&(0,H.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-orange-500/20 bg-orange-500/5 p-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(Qp,{htmlFor:`oauth-client-id-${e}`,className:`text-orange-200`,children:`Client ID`}),(0,H.jsx)(Eu,{id:`oauth-client-id-${e}`,value:r,onChange:e=>i(e.target.value),placeholder:`OAuth Client ID`,className:`bg-black/20 border-orange-500/30`})]}),d?(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(Qp,{htmlFor:`oauth-client-secret-${e}`,className:`text-orange-200`,children:`Client Secret`}),(0,H.jsx)(Eu,{id:`oauth-client-secret-${e}`,type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:`OAuth Client Secret`,className:`bg-black/20 border-orange-500/30`})]}):(0,H.jsx)(`p`,{className:`text-xs text-orange-200/80`,children:`Client secret is saved locally for this service.`}),g&&(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>f(e=>!e),children:d?`Hide client secret field`:`Update client secret`}),p?.hasStoredClientSecret&&d&&(0,H.jsx)(`p`,{className:`text-xs text-orange-200/80`,children:`Leave blank to keep the saved secret. Enter a new value only if Slack rejected the last connect attempt.`})]}),h.afterConnect&&h.afterConnect.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-orange-200 mb-1`,children:`After connect`}),(0,H.jsx)(yD,{items:h.afterConnect,className:`text-orange-100/80`})]}),x&&(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(K,{size:`sm`,className:`bg-orange-600 hover:bg-orange-700`,disabled:s||l&&h.setupMode===`manual`&&!g&&(!r.trim()||!a.trim()),onClick:()=>y(_()),children:s?`Connecting…`:g&&h.setupMode===`manual`?`Reconnect`:h.setupMode===`dynamic`||h.setupMode===`managed`?`Connect`:`Connect with credentials`}),h.docsUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.docsUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Docs`]})]}),h.setupMode===`informational`&&h.docsUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.docsUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Docs`]})]})}function xD(e,t){e.invalidateQueries({queryKey:[`/api/services`]}),e.invalidateQueries({queryKey:[`/api/collection/warnings`]}),t&&(e.invalidateQueries({queryKey:[`/api/services`,t]}),e.invalidateQueries({queryKey:[`/api/services`,t,`tools`]}))}var SD=`agent-deck:oauth-complete`;function CD(e){return typeof e==`object`&&!!e&&e.type===`agent-deck:oauth-complete`}function wD(e){return!!(e&&typeof e==`object`&&Object.keys(e).length>0)}function TD(e){return wD(e)?JSON.stringify(e,null,2):`{
|
|
189
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return tT(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=QT.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function cE(){return{exit:{taskListCheckValueChecked:uE,taskListCheckValueUnchecked:uE,paragraph:dE}}}function lE(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:fE}}}function uE(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function dE(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function fE(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=QT.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function pE(){return[yw(),Uw(),Jw(),$T(),cE()]}function mE(e){return{extensions:[bw(),Ww(e),Yw(),sE(e),lE()]}}var hE={tokenize:kE,partial:!0},gE={tokenize:AE,partial:!0},_E={tokenize:jE,partial:!0},vE={tokenize:ME,partial:!0},yE={tokenize:NE,partial:!0},bE={name:`wwwAutolink`,tokenize:DE,previous:PE},xE={name:`protocolAutolink`,tokenize:OE,previous:FE},SE={name:`emailAutolink`,tokenize:EE,previous:IE},CE={};function wE(){return{text:CE}}for(var TE=48;TE<123;)CE[TE]=SE,TE++,TE===58?TE=65:TE===91&&(TE=97);CE[43]=SE,CE[45]=SE,CE[46]=SE,CE[95]=SE,CE[72]=[SE,xE],CE[104]=[SE,xE],CE[87]=[SE,bE],CE[119]=[SE,bE];function EE(e,t,n){let r=this,i,a;return o;function o(t){return!LE(t)||!IE.call(r,r.previous)||RE(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return LE(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(yE,u,l)(t):t===45||t===95||yy(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&vy(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function DE(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!PE.call(r,r.previous)||RE(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(hE,e.attempt(gE,e.attempt(_E,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function OE(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&FE.call(r,r.previous)&&!RE(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(vy(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||xy(t)||Ey(t)||ky(t)||Oy(t)?n(t):e.attempt(gE,e.attempt(_E,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function kE(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function AE(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(vE,c,s)(t):t===null||Ey(t)||ky(t)||t!==45&&Oy(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function jE(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(vE,t,a)(o):o===null||Ey(o)||ky(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function ME(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Ey(o)||ky(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Ey(e)||ky(e)?t(e):r(e)}function a(e){return vy(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):vy(t)?(e.consume(t),o):n(t)}}function NE(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return yy(e)?n(e):t(e)}}function PE(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ey(e)}function FE(e){return!vy(e)}function IE(e){return!(e===47||LE(e))}function LE(e){return e===43||e===45||e===46||e===95||yy(e)}function RE(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var zE={tokenize:qE,partial:!0};function BE(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:WE,continuation:{tokenize:GE},exit:KE}},text:{91:{name:`gfmFootnoteCall`,tokenize:UE},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:VE,resolveTo:HE}}}}function VE(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=_y(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function HE(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function UE(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Ey(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(_y(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Ey(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function WE(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Ey(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=_y(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Ey(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),My(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function GE(e,t,n){return e.check(qy,t,e.attempt(zE,t,n))}function KE(e){e.exit(`gfmFootnoteDefinition`)}function qE(e,t,n){let r=this;return My(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function JE(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&uy(o,o.length,0,By(s,e.slice(r+1,n),t)),uy(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),uy(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=zy(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=zy(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var YE=class{constructor(){this.map=[]}add(e,t,n){XE(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function XE(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function ZE(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function QE(){return{flow:{null:{name:`table`,tokenize:$E,resolveAll:eD}}}}function $E(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Ty(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Dy(t)?My(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Ey(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Dy(t)?My(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Dy(t)?My(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Ty(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Dy(t)?My(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Ty(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||Ty(n)?(e.exit(`tableRow`),t(n)):Dy(n)?My(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||Ey(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function eD(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new YE;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(nD(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=tD(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=tD(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=tD(f,t,o,i,n,d)):(o[0]=o[1],d=tD(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&nD(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=ZE(t.events,n))}return e}function tD(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},rD(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=rD(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=rD(t.events,n[2]),a=rD(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},rD(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function nD(e,t,n,r,i){let a=[],o=rD(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function rD(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var iD={name:`tasklistCheck`,tokenize:oD};function aD(){return{text:{91:iD}}}function oD(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Ey(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Ty(r)?t(r):Dy(r)?e.check({tokenize:sD},t,n)(r):n(r)}}function sD(e,t,n){return My(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function cD(e){return py([wE(),BE(),JE(e),QE(),aD()])}var lD={};function uD(e){let t=this,n=e||lD,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(cD(n)),a.push(pE()),o.push(mE(n))}var dD=180;function fD(e){return e.replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/^#+\s+/gm,``).replace(/\s+/g,` `).trim()}function pD(e,t){if(t?.trim())return t.trim();let n=fD(e.split(/\n\n+/)[0]?.replace(/\n/g,` `)??e);return n.length<=dD?n:`${n.slice(0,179).trimEnd()}…`}function mD(e,t){return t?.trim()&&e.length>dD?!0:e.length>dD||/\n/.test(e)}function hD({description:e,title:t,expanded:n,onToggle:r}){let i=pD(e,t),a=mD(e,t);return e?a?(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`line-clamp-3 text-sm leading-relaxed`,children:i}),(0,H.jsxs)(`button`,{type:`button`,onClick:r,className:`inline-flex items-center gap-1 text-xs text-[#92E4DD] hover:text-white`,children:[(0,H.jsx)(hi,{className:`h-3.5 w-3.5 transition-transform ${n?`rotate-180`:``}`}),n?`Hide full description`:`Show full description`]})]}):(0,H.jsx)(`span`,{children:i}):(0,H.jsx)(`span`,{className:`text-gray-500`,children:`—`})}function gD({description:e}){return(0,H.jsx)(`div`,{className:`max-h-64 overflow-auto rounded border border-white/10 bg-[#0F0F0C] p-3`,children:(0,H.jsx)(`div`,{className:`prose prose-sm prose-invert max-w-none prose-headings:text-gray-100 prose-p:text-gray-300 prose-li:text-gray-300 prose-strong:text-gray-100 prose-code:text-[#92E4DD] prose-code:before:content-none prose-code:after:content-none`,children:(0,H.jsx)(ow,{remarkPlugins:[uD],children:e})})})}function _D(){let[e,t]=(0,b.useState)(null);return{expandedDescription:e,toggleDescription:e=>{t(t=>t===e?null:e)}}}function vD(e){return new Set(e.filter(e=>e.enabled===!1).map(e=>e.name))}function yD({serviceId:e,tools:t,isLoading:n}){let[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(null),{expandedDescription:s,toggleDescription:c}=_D(),[l,u]=(0,b.useState)(()=>vD(t)),d=Tt(),{toast:f}=an(),p=(0,b.useMemo)(()=>t.map(e=>`${e.name}:${e.enabled===!1?`0`:`1`}`).sort().join(`\0`),[t]);(0,b.useEffect)(()=>{u(vD(t))},[e,p]);let m=Vt({mutationFn:async t=>{await U(`PUT`,`/api/services/${e}/tool-settings`,{disabledTools:t})},onSuccess:()=>{d.invalidateQueries({queryKey:[`/api/services`,e,`tools`]}),d.invalidateQueries({queryKey:[`/api/services`]})},onError:e=>{f({title:`Could not save tool settings`,description:e.message,variant:`destructive`}),u(vD(t))}}),h=e=>{u(e),m.mutate([...e])},g=(e,t)=>{let n=new Set(l);t?n.delete(e):n.add(e),h(n)},_=e=>{if(e){h(new Set);return}h(new Set(t.map(e=>e.name)))},v=(0,b.useMemo)(()=>{let e=r.trim().toLowerCase();return e?t.filter(t=>t.name.toLowerCase().includes(e)||(t.title?.toLowerCase().includes(e)??!1)||t.description.toLowerCase().includes(e)):t},[t,r]),y=t.length-l.size;return n?(0,H.jsx)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading tools…`})}):t.length===0?null:(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center`,children:[(0,H.jsx)(Xi,{className:`w-5 h-5 mr-2`}),`Tools`,(0,H.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-gray-400`,children:[y,` of `,t.length,` enabled`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-8 text-xs text-[#A8C4C0] hover:text-white hover:bg-white/10`,onClick:()=>_(!0),disabled:l.size===0||m.isPending,children:`Enable all`}),(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,className:`h-8 text-xs text-[#A8C4C0] hover:text-white hover:bg-white/10`,onClick:()=>_(!1),disabled:y===0||m.isPending,children:`Disable all`})]})]}),(0,H.jsx)(`p`,{className:`mb-3 text-xs text-[#A8C4C0]`,children:`Choose which tools your agent can use from this MCP. Disabled tools are hidden from the agent but stay registered on the server.`}),(0,H.jsxs)(`div`,{className:`relative mb-3`,children:[(0,H.jsx)(zi,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500`}),(0,H.jsx)(Eu,{value:r,onChange:e=>i(e.target.value),placeholder:`Search tools…`,className:`border-white/15 bg-[#0F0F0C] pl-9 text-[#E8F6F4] placeholder:text-[#6B8581]`})]}),(0,H.jsx)(`div`,{className:`rounded-md border border-white/10 overflow-hidden`,children:(0,H.jsxs)(__,{children:[(0,H.jsx)(v_,{children:(0,H.jsxs)(x_,{className:`border-white/10 hover:bg-transparent`,children:[(0,H.jsx)(S_,{className:`w-[72px] text-center text-[#A8C4C0]`,children:`Enabled`}),(0,H.jsx)(S_,{className:`w-[220px] text-[#A8C4C0]`,children:`Tool`}),(0,H.jsx)(S_,{className:`text-[#A8C4C0]`,children:`Description`})]})}),(0,H.jsx)(y_,{children:v.length===0?(0,H.jsx)(x_,{className:`border-white/10 hover:bg-transparent`,children:(0,H.jsx)(C_,{colSpan:3,className:`py-8 text-center text-sm text-gray-400`,children:`No tools match your search.`})}):v.map(e=>{let t=!l.has(e.name),n=a===e.name,r=s===e.name,i=e.inputSchema&&Object.keys(e.inputSchema).length>0;return(0,H.jsxs)(b.Fragment,{children:[(0,H.jsxs)(x_,{className:`border-white/10 ${t?`hover:bg-white/5`:`opacity-60 hover:bg-white/5`}`,children:[(0,H.jsx)(C_,{className:`text-center`,children:(0,H.jsx)(`div`,{className:`flex justify-center`,children:(0,H.jsx)(g_,{checked:t,onCheckedChange:t=>g(e.name,t===!0),disabled:m.isPending,"aria-label":`${t?`Disable`:`Enable`} ${e.name}`,className:`h-[18px] w-[18px] border-white/40 bg-[#0F0F0C] data-[state=checked]:border-[#92E4DD] data-[state=checked]:bg-[#92E4DD] data-[state=checked]:text-[#0F0F0C]`})})}),(0,H.jsx)(C_,{children:i?(0,H.jsxs)(`button`,{type:`button`,onClick:()=>o(n?null:e.name),className:`flex w-full items-center gap-1 text-left font-mono text-sm text-[#92E4DD] hover:text-white`,children:[(0,H.jsx)(hi,{className:`h-4 w-4 shrink-0 transition-transform ${n?`rotate-180`:``}`}),e.name]}):(0,H.jsx)(`span`,{className:`font-mono text-sm text-[#92E4DD]`,children:e.name})}),(0,H.jsx)(C_,{className:`max-w-0 text-sm text-gray-300`,children:(0,H.jsx)(hD,{description:e.description,title:e.title,expanded:r,onToggle:()=>c(e.name)})})]}),r&&(0,H.jsx)(x_,{className:`border-white/10 bg-black/30 hover:bg-black/30`,children:(0,H.jsx)(C_,{colSpan:3,className:`py-3`,children:(0,H.jsx)(gD,{description:e.description})})}),i&&n&&(0,H.jsx)(x_,{className:`border-white/10 bg-black/30 hover:bg-black/30`,children:(0,H.jsx)(C_,{colSpan:3,className:`py-3`,children:(0,H.jsx)(`pre`,{className:`max-h-48 overflow-auto rounded border border-white/10 bg-[#0F0F0C] p-3 text-xs text-gray-300`,children:JSON.stringify(e.inputSchema,null,2)})})})]},e.name)})})]})})]})}function bD({items:e,className:t}){return e.length===0?null:(0,H.jsx)(`ol`,{className:`list-decimal list-inside space-y-1 text-xs ${t??``}`,children:e.map((e,t)=>(0,H.jsx)(`li`,{children:e},`${t}-${e.slice(0,24)}`))})}function xD({serviceId:e,onConnected:t}){let{toast:n}=an(),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),{data:p,isLoading:m}=Bt({queryKey:[`/api/oauth`,e,`setup`],queryFn:async()=>{let t=await U(`GET`,`/api/oauth/${e}/setup`),n=await t.json();if(!t.ok||!n.success)throw Error(n.error||`Failed to load OAuth setup`);return n.data},enabled:!!e}),h=p?.guide,g=!!p?.hasSavedCredentials,_=()=>{if(!l||h?.setupMode!==`manual`)return;let e={};return r.trim()&&(e.clientId=r.trim()),a.trim()&&(e.clientSecret=a.trim()),e},v=async(e,t)=>{try{await navigator.clipboard.writeText(t),n({title:`Copied`,description:`${e} copied to clipboard.`})}catch{n({title:`Copy failed`,description:`Select and copy manually.`,variant:`destructive`})}};(0,b.useEffect)(()=>{h?.setupMode===`manual`?u(!0):u(!1),f(!g)},[h?.setupMode,g]),(0,b.useEffect)(()=>{p?.savedOAuthClientId&&!r&&i(p.savedOAuthClientId)},[p?.savedOAuthClientId,r]);let y=async r=>{c(!0);try{let i=await U(`POST`,`/api/oauth/${e}/connect`,r??{}),a=await i.json();if(!i.ok||!a.success){(a.data?.needsCredentials||a.data?.setupMode===`manual`)&&u(!0),n({title:`OAuth setup`,description:a.error||`Could not start OAuth flow.`,variant:`destructive`});return}a.data?.authorizationUrl&&(window.open(a.data.authorizationUrl,`_blank`),n({title:`Continue in browser`,description:`Complete sign-in in the new tab, then return here.`}),t?.())}catch(e){n({title:`OAuth setup failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{c(!1)}};if(m)return(0,H.jsx)(`p`,{className:`text-sm text-orange-200`,children:`Loading setup guide…`});if(!h)return null;if(h.setupMode===`unavailable`)return(0,H.jsxs)(`div`,{className:`space-y-3 text-sm text-orange-100`,children:[(0,H.jsx)(`p`,{children:h.unavailableReason}),h.docsUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.docsUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Provider docs`]})]});let x=h.setupMode===`dynamic`||h.setupMode===`managed`||h.setupMode===`manual`;return(0,H.jsxs)(`div`,{className:`space-y-4 text-sm text-orange-100`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-medium text-orange-200`,children:h.title}),h.summary&&(0,H.jsx)(`p`,{className:`mt-1 text-xs text-orange-100/90`,children:h.summary}),x&&(0,H.jsxs)(`p`,{className:`mt-2 text-xs text-orange-100/80`,children:[`Redirect URI:`,` `,(0,H.jsx)(`code`,{className:`text-orange-50`,children:h.redirectUri})]}),h.easierAlternative&&(0,H.jsx)(`p`,{className:`mt-2 text-xs text-orange-100/70 border-l-2 border-orange-500/30 pl-2`,children:h.easierAlternative})]}),g&&h.setupMode===`manual`&&(0,H.jsxs)(`div`,{className:`rounded-lg border border-green-500/30 bg-green-500/10 p-3 text-xs text-green-100`,children:[(0,H.jsx)(`p`,{className:`font-medium text-green-200`,children:`OAuth credentials saved`}),(0,H.jsx)(`p`,{className:`mt-1 text-green-100/90`,children:`Client ID is prefilled and your secret is remembered. Click Reconnect — no need to paste the secret again unless Slack rejects the flow.`})]}),h.prerequisites&&h.prerequisites.length>0&&!g&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-orange-200 mb-1`,children:`Before you start`}),(0,H.jsx)(`ul`,{className:`list-disc list-inside space-y-1 text-xs text-orange-100/90`,children:h.prerequisites.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),(h.manifestJson||h.createAppUrl||x)&&(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[h.manifestJson&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>void v(`App manifest`,h.manifestJson),children:[(0,H.jsx)(Si,{className:`w-4 h-4 mr-1`}),`Copy manifest`]}),x&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>void v(`Redirect URI`,h.redirectUri),children:[(0,H.jsx)(Ci,{className:`w-4 h-4 mr-1`}),`Copy redirect URI`]}),h.createAppUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.createAppUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),h.createAppLabel??`Open app creator`]})]}),h.steps.length>0&&(0,H.jsx)(`div`,{children:g&&h.setupMode===`manual`?(0,H.jsxs)(`details`,{className:`rounded-lg border border-orange-500/20 bg-orange-500/5 p-3`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-orange-200`,children:`First-time Slack app setup`}),(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsx)(bD,{items:h.steps})})]}):(0,H.jsxs)(H.Fragment,{children:[h.setupMode===`informational`?(0,H.jsx)(`p`,{className:`text-xs font-medium text-orange-200 mb-1`,children:`What to do`}):null,(0,H.jsx)(bD,{items:h.steps})]})}),h.tokenAlternative&&(0,H.jsxs)(`p`,{className:`text-xs text-orange-100/80 border-l-2 border-orange-500/30 pl-2`,children:[(0,H.jsx)(`span`,{className:`font-medium text-orange-200`,children:`Alternative: `}),h.tokenAlternative]}),l&&h.setupMode===`manual`&&(0,H.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-orange-500/20 bg-orange-500/5 p-3`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)($p,{htmlFor:`oauth-client-id-${e}`,className:`text-orange-200`,children:`Client ID`}),(0,H.jsx)(Eu,{id:`oauth-client-id-${e}`,value:r,onChange:e=>i(e.target.value),placeholder:`OAuth Client ID`,className:`bg-black/20 border-orange-500/30`})]}),d?(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)($p,{htmlFor:`oauth-client-secret-${e}`,className:`text-orange-200`,children:`Client Secret`}),(0,H.jsx)(Eu,{id:`oauth-client-secret-${e}`,type:`password`,value:a,onChange:e=>o(e.target.value),placeholder:`OAuth Client Secret`,className:`bg-black/20 border-orange-500/30`})]}):(0,H.jsx)(`p`,{className:`text-xs text-orange-200/80`,children:`Client secret is saved locally for this service.`}),g&&(0,H.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>f(e=>!e),children:d?`Hide client secret field`:`Update client secret`}),p?.hasStoredClientSecret&&d&&(0,H.jsx)(`p`,{className:`text-xs text-orange-200/80`,children:`Leave blank to keep the saved secret. Enter a new value only if Slack rejected the last connect attempt.`})]}),h.afterConnect&&h.afterConnect.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-xs font-medium text-orange-200 mb-1`,children:`After connect`}),(0,H.jsx)(bD,{items:h.afterConnect,className:`text-orange-100/80`})]}),x&&(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(K,{size:`sm`,className:`bg-orange-600 hover:bg-orange-700`,disabled:s||l&&h.setupMode===`manual`&&!g&&(!r.trim()||!a.trim()),onClick:()=>y(_()),children:s?`Connecting…`:g&&h.setupMode===`manual`?`Reconnect`:h.setupMode===`dynamic`||h.setupMode===`managed`?`Connect`:`Connect with credentials`}),h.docsUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.docsUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Docs`]})]}),h.setupMode===`informational`&&h.docsUrl&&(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-200`,onClick:()=>window.open(h.docsUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Docs`]})]})}function SD(e,t){e.invalidateQueries({queryKey:[`/api/services`]}),e.invalidateQueries({queryKey:[`/api/collection/warnings`]}),t&&(e.invalidateQueries({queryKey:[`/api/services`,t]}),e.invalidateQueries({queryKey:[`/api/services`,t,`tools`]}))}var CD=`agent-deck:oauth-complete`;function wD(e){return typeof e==`object`&&!!e&&e.type===`agent-deck:oauth-complete`}function TD(e){return!!(e&&typeof e==`object`&&Object.keys(e).length>0)}function ED(e){return TD(e)?JSON.stringify(e,null,2):`{
|
|
190
190
|
|
|
191
|
-
}`}function
|
|
191
|
+
}`}function DD(e){let t=e.trim();if(!t||t===`{}`)return{ok:!0,headers:{}};try{let e=JSON.parse(t);if(typeof e!=`object`||!e||Array.isArray(e))return{ok:!1,error:`Headers must be a JSON object (e.g. {"Authorization": "Bearer token"})`};for(let[t,n]of Object.entries(e))if(typeof n!=`string`)return{ok:!1,error:`Header "${t}" must be a string value`};return{ok:!0,headers:e}}catch{return{ok:!1,error:`Invalid JSON — fix syntax before saving`}}}function OD(e){return/^bearer\s+/i.test(e)?`Bearer ••••`:e.length>0?`••••`:``}function kD(e){return TD(e)?Object.entries(e).map(([e,t])=>({name:e,masked:OD(t)})):[]}function AD(e){return e===`not_required`||e===`authenticated`||e===`authenticated_refreshable`}function jD(e){if(!e)return`unknown`;let t=new Date(e).getTime()-Date.now();if(t<=0)return`soon`;let n=Math.round(t/6e4);if(n<60)return`in ${n} minute${n===1?``:`s`}`;let r=Math.round(n/60);if(r<48)return`in ${r} hour${r===1?``:`s`}`;let i=Math.round(r/24);return`in ${i} day${i===1?``:`s`}`}function MD(e){if(!e||e.type!==`local-mcp`)return!1;let t=[e.localCommand,...e.localArgs??[],e.url,e.name].filter(Boolean).join(` `).toLowerCase();return t.includes(`google-drive`)||t.includes(`google_drive`)}function ND({service:e,isOpen:t,onClose:n}){let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(``),[d,f]=(0,b.useState)(``),[p,m]=(0,b.useState)(!1),[h,g]=(0,b.useState)(!1),[_,v]=(0,b.useState)(!1),[y,x]=(0,b.useState)(`{
|
|
192
192
|
|
|
193
|
-
}`),[S,C]=(0,b.useState)(null),[w,T]=(0,b.useState)(!1),[E,D]=(0,b.useState)(null),O=(0,b.useRef)(null),k=Tt(),{toast:A}=an(),j=e&&E?.id===e.id?E:e,M=j,N=M?.headers&&typeof M.headers==`object`?M.headers:null,P=!!(M&&M.id&&M.url),{data:F,isLoading:I,error:L,refetch:ee}=Bt({queryKey:[`/api/mcp/discover`,M?.url],queryFn:async()=>{if(!M||M.type!==`mcp`)return null;console.log(`🔍 Attempting MCP discovery for: ${M.url}`);try{let e=await(await U(`POST`,`/api/mcp/discover`,{url:M.url})).json();return console.log(`✅ MCP discovery successful for ${M.url}:`,e),e}catch(e){throw console.log(`❌ MCP discovery failed for ${M.url}:`,e),e}},enabled:P&&M.type===`mcp`&&t,staleTime:0,gcTime:12e4}),te=F?.data?.oauth?.required===!0,{data:ne,refetch:R}=Bt({queryKey:[`/api/oauth`,M?.id,`status`],queryFn:async()=>{let e=await U(`GET`,`/api/oauth/${M.id}/status`),t=await e.json();if(!e.ok||!t.success)throw Error(t.error||`Failed to load OAuth status`);return t.data},enabled:P&&M.type===`mcp`&&t&&te,refetchInterval:e=>{let t=e.state.data;return t?.authenticated||t?.refreshFailed?!1:2e3}}),z=te?ne?.refreshFailed?{status:`refresh_failed`,message:`OAuth renewal failed — please re-authenticate`}:ne?.authenticated?ne.hasRefreshToken&&ne.expiresAt?{status:`authenticated_refreshable`,message:`Access expires ${AD(ne.expiresAt)} · renews automatically`}:{status:`authenticated`,message:null}:ne?.hasToken&&ne?.isExpired?{status:`expired`,message:`OAuth Token Expired - Please re-authenticate`}:{status:`required`,message:`OAuth 2.0 Authentication Required`}:{status:`not_required`,message:null};console.log(`MCP Discovery Query Debug:`,{apiService:M?.id,apiServiceType:M?.type,apiServiceUrl:M?.url,isOpen:t,hasValidService:P,enabled:P&&M.type===`mcp`&&t,mcpDiscoveryLoading:I,mcpDiscoveryData:F?JSON.stringify(F,null,2):null,mcpDiscoveryDataKeys:F?Object.keys(F):null,oauthRequired:F?.data?.oauth?.required,oauthData:F?.data?.oauth?JSON.stringify(F.data.oauth,null,2):null,toolsQueryEnabled:P&&M.type===`mcp`&&t&&!F?.data?.oauth?.required});let{data:B,isLoading:re,error:ie,refetch:ae}=Bt({queryKey:[`/api/services`,M?.id,`tools`],queryFn:async()=>{if(!M||M.type!==`mcp`&&M.type!==`local-mcp`)return{data:[]};console.log(`🔍 Attempting to discover tools for MCP service: ${M.id} at ${M.url}`);try{let e=await(await U(`GET`,`/api/services/${M.id}/tools`)).json();return console.log(`✅ MCP tools discovery successful for ${M.id}:`,e),e}catch(e){throw console.log(`❌ MCP tools discovery failed for ${M.id}:`,e),e}},enabled:P&&(M.type===`mcp`||M.type===`local-mcp`)&&t&&(M.type===`local-mcp`||kD(z.status)),staleTime:0,gcTime:12e4});(0,b.useEffect)(()=>{if(!t||!M?.id||M.type!==`mcp`&&M.type!==`local-mcp`||!(M.type===`local-mcp`||kD(z.status)||z.status===`not_required`)||re||ie)return;let e=!1;return(async()=>{try{let t=await(await U(`GET`,`/api/services/${M.id}`)).json();!e&&t?.success&&t.data&&D(t.data),k.invalidateQueries({queryKey:[`/api/services`]})}catch{}})(),()=>{e=!0}},[t,M?.id,M?.type,re,ie,z.status,k]),(0,b.useEffect)(()=>{if(!t||!M?.id||M.type!==`a2a`)return;let e=!1;return(async()=>{try{await U(`GET`,`/api/services/${M.id}/health`);let t=await(await U(`GET`,`/api/services/${M.id}`)).json();!e&&t?.success&&t.data&&D(t.data),k.invalidateQueries({queryKey:[`/api/services`]})}catch{}})(),()=>{e=!0}},[t,M?.id,M?.type,k]),console.log(`MCP Tools Query Debug:`,{hasValidService:P,apiServiceType:M?.type,isOpen:t,oauthRequired:F?.data?.oauth?.required,oauthStatus:z.status,toolsQueryEnabled:P&&(M.type===`mcp`||M.type===`local-mcp`)&&t&&(M.type===`local-mcp`||kD(z.status)),mcpToolsLoading:re});let{data:oe,isLoading:se,error:ce}=Bt({queryKey:[`/api/proxy/a2a`,M?.id,`manifest`],queryFn:async()=>{if(!M||M.type!==`a2a`)return null;let e=await(await U(`GET`,`/api/proxy/a2a/${M.id}/manifest`)).text();return JSON.parse(e)},enabled:P&&M.type===`a2a`&&t,staleTime:0,gcTime:12e4}),le=B?.data||[],ue=oe,de=re||se;console.log(`ServiceDetailsModal Debug:`,{service:e?.id,serviceType:e?.type,isOpen:t,mcpDiscoveryLoading:I,mcpDiscoveryData:F,mcpDiscoveryError:L?String(L):null,mcpToolsLoading:re,a2aManifestLoading:se,mcpToolsError:ie?String(ie):null,a2aManifestError:ce?String(ce):null,mcpToolsCount:le.length,mcpToolsData:B,hasA2aManifest:!!ue,isLoading:de,oauthRequired:F?.data?.oauth?.required,oauthStatus:z.status,oauthMessage:z.message,oauthAuthenticated:ne?.authenticated,expiresAt:ne?.expiresAt}),(0,b.useEffect)(()=>{if(!t){D(null),v(!1),C(null),pe.current=!1,fe.current=!1;return}e&&(D(e),u(e.name||``),f(e.description||``),v(!1),C(null))},[e,t]);let fe=(0,b.useRef)(!1),pe=(0,b.useRef)(!1);(0,b.useEffect)(()=>{if(!t||!M?.id){fe.current=!1;return}if(!ne?.authenticated){fe.current=!1;return}fe.current||(fe.current=!0,pe.current=!0,(async()=>{A({title:`OAuth completed`,description:`Authentication successful! Refreshing service status...`}),xD(k,M.id),k.invalidateQueries({queryKey:[`/api/mcp/discover`,M.url]});try{let e=await U(`GET`,`/api/services/${M.id}`);if(e.ok){let t=await e.json();D(t.data??t)}}catch{}await ee(),k.invalidateQueries({queryKey:[`/api/services`,M.id,`tools`]}),await ae(),pe.current=!1})())},[ne?.authenticated,t,M?.id]);let me=()=>e?.type===`mcp`?(0,H.jsx)(wi,{className:`w-6 h-6`}):(0,H.jsx)(pi,{className:`w-6 h-6`}),he=()=>e?.type===`mcp`?`text-blue-400`:`text-purple-400`,ge=()=>e?.type===`mcp`?`bg-blue-500/20`:`bg-purple-500/20`,_e=e=>new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});(0,b.useEffect)(()=>{a&&(O.current?.focus(),O.current?.select())},[a]);let ve=async()=>{let e=j?.name||``,t=l.trim();if(!j||!t||t===e){u(e),o(!1);return}m(!0);try{await U(`PUT`,`/api/services/${j.id}`,{name:t}),D({...j,name:t}),k.invalidateQueries({queryKey:[`/api/services`]}),k.invalidateQueries({queryKey:[`/api/collection/warnings`]}),k.invalidateQueries({queryKey:[`/api/decks`]}),o(!1)}catch(t){u(e),o(!1),A({title:`Could not rename service`,description:t instanceof Error?t.message:`Failed to update name`,variant:`destructive`})}finally{m(!1)}};return(0,H.jsx)(Bp,{open:t,onOpenChange:t=>{t||(pe.current&&=(xD(k,M?.id??e?.id),!1),fe.current=!1,n())},children:(0,H.jsxs)(Up,{className:`sm:max-w-6xl bg-gradient-to-br from-cosmic-900 to-cosmic-800 border border-white/20 text-white max-h-[90vh] overflow-y-auto`,children:[(0,H.jsx)(Wp,{children:(0,H.jsxs)(Kp,{className:`text-2xl font-bold flex items-center`,children:[me(),(0,H.jsx)(`div`,{className:`ml-3 flex min-w-0 items-center`,children:a?(0,H.jsx)(`input`,{ref:O,type:`text`,value:l,disabled:p,onChange:e=>u(e.target.value),onBlur:()=>{ve()},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ve()):e.key===`Escape`&&(e.preventDefault(),u(j?.name||``),o(!1))},className:`max-w-[16rem] rounded border border-white/20 bg-white/10 px-2 py-1 text-2xl font-bold text-white focus:border-white/40 focus:outline-none sm:max-w-[20rem]`,"aria-label":`Service name`,"data-testid":`input-service-name`}):(0,H.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left hover:underline`,title:`Click to rename`,onClick:()=>{u(j?.name||``),o(!0)},"data-testid":`button-rename-service`,children:j?.name})}),(0,H.jsx)(yg,{className:`ml-3 ${ge()} ${he()}`,children:e?.type?.toUpperCase()})]})}),e&&(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsx)(`div`,{className:`mb-3`,children:(0,H.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center`,children:[(0,H.jsx)(si,{className:`w-5 h-5 mr-2`}),`Service Overview`]})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm`,children:`Description`}),!s&&(0,H.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>c(!0),className:`h-6 w-6 p-0 opacity-0 hover:opacity-100 transition-opacity`,title:`Edit description`,children:(0,H.jsx)(Xi,{className:`w-3 h-3`})})]}),s?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),className:`w-full bg-black/30 border border-white/20 rounded px-2 py-1 text-white focus:outline-none focus:border-white/40 resize-none`,rows:3,placeholder:`Enter description...`,autoFocus:!0}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(K,{size:`sm`,onClick:async()=>{if(e){g(!0);try{if((await U(`PUT`,`/api/services/${e.id}`,{description:d.trim()})).ok){if(E){let e={...E,description:d.trim()};D(e)}k.invalidateQueries({queryKey:[`/api/services`]}),k.invalidateQueries({queryKey:[`/api/collection/warnings`]}),k.invalidateQueries({queryKey:[`/api/decks`]}),k.invalidateQueries({queryKey:[`/api/decks`]}),A({title:`Description updated`,description:`Service description has been updated successfully.`}),c(!1)}else throw Error(`Failed to update description`)}catch{A({title:`Update failed`,description:`Failed to update service description. Please try again.`,variant:`destructive`})}finally{g(!1)}}},disabled:h,className:`h-6 px-2 text-xs`,children:h?`Saving...`:`Save`}),(0,H.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),f(j?.description||``)},className:`h-6 px-2 text-xs`,children:`Cancel`})]})]}):(0,H.jsx)(`p`,{className:`text-white cursor-pointer hover:bg-white/10 px-2 py-1 rounded transition-colors`,onClick:()=>c(!0),title:`Click to edit description`,children:j?.description||`No description`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Endpoint`}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,H.jsx)(yg,{variant:`outline`,className:`border-blue-500/30 text-blue-300`,children:M.type.toUpperCase()}),wD(N)&&(0,H.jsx)(yg,{variant:`outline`,className:`border-green-500/30 text-green-300`,children:`Custom Headers`})]}),(0,H.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>window.open(M.url,`_blank`),className:`p-1 h-auto`,children:(0,H.jsx)(Ei,{className:`w-4 h-4`})})]}),(0,H.jsx)(`div`,{className:`text-xs text-gray-400 break-all bg-black/20 p-2 rounded border border-white/10`,children:M.url||`No URL available`}),M.type===`mcp`?(0,H.jsxs)(`div`,{className:`text-xs text-gray-400 bg-black/20 p-2 rounded border border-white/10`,"data-testid":`custom-headers-section`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,H.jsx)(`p`,{className:`font-semibold text-gray-300`,children:`Custom Headers`}),!_&&(0,H.jsx)(K,{size:`sm`,variant:`ghost`,className:`h-6 px-2 text-xs text-teal-300 hover:text-teal-200`,onClick:()=>{x(TD(N)),C(null),v(!0)},"data-testid":`button-edit-headers`,children:`Edit`})]}),_?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{value:y,onChange:e=>{x(e.target.value),S&&C(null)},rows:6,className:`bg-white/10 border-white/20 text-white placeholder-gray-400 resize-none font-mono text-xs`,"data-testid":`textarea-edit-headers`,disabled:w}),S&&(0,H.jsxs)(`p`,{className:`text-red-400 text-xs flex items-center gap-1`,"data-testid":`headers-json-error`,children:[(0,H.jsx)(qi,{className:`w-3 h-3 shrink-0`}),S]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(K,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>{v(!1),C(null),x(TD(N))},disabled:w,"data-testid":`button-cancel-headers`,children:`Cancel`}),(0,H.jsx)(K,{size:`sm`,className:`h-7 px-3 text-xs bg-teal-600 hover:bg-teal-500`,onClick:async()=>{if(!j)return;let e=ED(y);if(!e.ok){C(e.error);return}T(!0);try{if(!(await U(`PUT`,`/api/services/${j.id}`,{headers:e.headers})).ok)throw Error(`Failed to update headers`);let t=Object.keys(e.headers).length>0?e.headers:void 0;D({...j,headers:t}),v(!1),C(null),xD(k,j.id),k.invalidateQueries({queryKey:[`/api/decks`]}),A({title:`Headers updated`,description:`Custom headers saved. Reconnecting with the new values.`})}catch(e){A({title:`Update failed`,description:e instanceof Error?e.message:`Failed to update headers. Please try again.`,variant:`destructive`})}finally{T(!1)}},disabled:w,"data-testid":`button-save-headers`,children:w?`Saving…`:`Save`})]})]}):wD(N)?(0,H.jsx)(`ul`,{className:`space-y-1 font-mono`,"data-testid":`headers-masked-list`,children:OD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`text-gray-300`,children:e}),(0,H.jsx)(`span`,{className:`text-gray-500`,children:`: `}),(0,H.jsx)(`span`,{children:t})]},e))}):(0,H.jsx)(`p`,{className:`text-gray-500`,"data-testid":`headers-empty-state`,children:`No custom headers. Add Bearer or API key headers to authenticate.`})]}):wD(N)&&(0,H.jsxs)(`div`,{className:`text-xs text-gray-400 bg-black/20 p-2 rounded border border-white/10`,children:[(0,H.jsx)(`p`,{className:`font-semibold mb-1`,children:`Custom Headers:`}),(0,H.jsx)(`ul`,{className:`space-y-1 font-mono`,children:OD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`text-gray-300`,children:e}),(0,H.jsx)(`span`,{className:`text-gray-500`,children:`: `}),(0,H.jsx)(`span`,{children:t})]},e))})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Health Status`}),(0,H.jsx)(yg,{className:M.health===`healthy`?`bg-green-500/20 text-green-300`:M.health===`unhealthy`?`bg-red-500/20 text-red-300`:`bg-amber-500/20 text-amber-200`,children:M.health===`healthy`?`Healthy`:M.health===`unhealthy`?`Unreachable`:z.status===`required`||z.status===`expired`||z.status===`refresh_failed`?`Auth required`:`Unknown`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Registered`}),(0,H.jsx)(`p`,{className:`text-white text-sm`,children:_e(M.registeredAt)})]})]})]}),de&&(0,H.jsxs)(`div`,{className:`text-center py-8`,children:[(0,H.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-white mx-auto mb-4`}),(0,H.jsx)(`p`,{className:`text-gray-400`,children:`Fetching service details...`})]}),r&&(0,H.jsx)(`div`,{className:`bg-red-500/20 border border-red-500/30 rounded-lg p-4`,children:(0,H.jsx)(`p`,{className:`text-red-300`,children:r})}),(e.type===`mcp`||e.type===`local-mcp`)&&(0,H.jsxs)(H.Fragment,{children:[e.type===`local-mcp`&&(0,H.jsxs)(`div`,{className:`bg-cyan-500/15 border border-cyan-500/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-cyan-200 font-semibold mb-2`,children:`Local MCP — auth happens outside Agent Deck`}),(0,H.jsx)(`div`,{className:`text-cyan-100/90 text-sm space-y-2`,children:jD(M)?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{children:[`This card runs `,(0,H.jsx)(`code`,{className:`text-xs`,children:`@piotr-agier/google-drive-mcp`}),` on your machine. Agent Deck does `,(0,H.jsx)(`strong`,{children:`not`}),` handle Google OAuth for it. If Google shows "app not verified", that is `,(0,H.jsx)(`strong`,{children:`your Google Cloud project`}),`, not Agent Deck.`]}),(0,H.jsxs)(`ol`,{className:`list-decimal list-inside space-y-1 ml-1`,children:[(0,H.jsxs)(`li`,{children:[`Create a GCP OAuth client type `,(0,H.jsx)(`strong`,{children:`Desktop app`}),` (not Web).`]}),(0,H.jsxs)(`li`,{children:[`Add yourself as a `,(0,H.jsx)(`strong`,{children:`Test user`}),` on the consent screen.`]}),(0,H.jsxs)(`li`,{children:[`Run in terminal first:`,` `,(0,H.jsx)(`code`,{className:`text-xs block mt-1 bg-black/30 p-2 rounded whitespace-pre-wrap`,children:`export GOOGLE_DRIVE_OAUTH_CREDENTIALS="/path/to/gcp-oauth.keys.json"
|
|
193
|
+
}`),[S,C]=(0,b.useState)(null),[w,T]=(0,b.useState)(!1),[E,D]=(0,b.useState)(null),O=(0,b.useRef)(null),k=Tt(),{toast:A}=an(),j=e&&E?.id===e.id?E:e,M=j,N=M?.headers&&typeof M.headers==`object`?M.headers:null,P=!!(M&&M.id&&M.url),{data:F,isLoading:I,error:L,refetch:ee}=Bt({queryKey:[`/api/mcp/discover`,M?.url],queryFn:async()=>{if(!M||M.type!==`mcp`)return null;console.log(`🔍 Attempting MCP discovery for: ${M.url}`);try{let e=await(await U(`POST`,`/api/mcp/discover`,{url:M.url})).json();return console.log(`✅ MCP discovery successful for ${M.url}:`,e),e}catch(e){throw console.log(`❌ MCP discovery failed for ${M.url}:`,e),e}},enabled:P&&M.type===`mcp`&&t,staleTime:0,gcTime:12e4}),te=F?.data?.oauth?.required===!0,{data:ne,refetch:R}=Bt({queryKey:[`/api/oauth`,M?.id,`status`],queryFn:async()=>{let e=await U(`GET`,`/api/oauth/${M.id}/status`),t=await e.json();if(!e.ok||!t.success)throw Error(t.error||`Failed to load OAuth status`);return t.data},enabled:P&&M.type===`mcp`&&t&&te,refetchInterval:e=>{let t=e.state.data;return t?.authenticated||t?.refreshFailed?!1:2e3}}),z=te?ne?.refreshFailed?{status:`refresh_failed`,message:`OAuth renewal failed — please re-authenticate`}:ne?.authenticated?ne.hasRefreshToken&&ne.expiresAt?{status:`authenticated_refreshable`,message:`Access expires ${jD(ne.expiresAt)} · renews automatically`}:{status:`authenticated`,message:null}:ne?.hasToken&&ne?.isExpired?{status:`expired`,message:`OAuth Token Expired - Please re-authenticate`}:{status:`required`,message:`OAuth 2.0 Authentication Required`}:{status:`not_required`,message:null};console.log(`MCP Discovery Query Debug:`,{apiService:M?.id,apiServiceType:M?.type,apiServiceUrl:M?.url,isOpen:t,hasValidService:P,enabled:P&&M.type===`mcp`&&t,mcpDiscoveryLoading:I,mcpDiscoveryData:F?JSON.stringify(F,null,2):null,mcpDiscoveryDataKeys:F?Object.keys(F):null,oauthRequired:F?.data?.oauth?.required,oauthData:F?.data?.oauth?JSON.stringify(F.data.oauth,null,2):null,toolsQueryEnabled:P&&M.type===`mcp`&&t&&!F?.data?.oauth?.required});let{data:B,isLoading:re,error:ie,refetch:ae}=Bt({queryKey:[`/api/services`,M?.id,`tools`],queryFn:async()=>{if(!M||M.type!==`mcp`&&M.type!==`local-mcp`)return{data:[]};console.log(`🔍 Attempting to discover tools for MCP service: ${M.id} at ${M.url}`);try{let e=await(await U(`GET`,`/api/services/${M.id}/tools`)).json();return console.log(`✅ MCP tools discovery successful for ${M.id}:`,e),e}catch(e){throw console.log(`❌ MCP tools discovery failed for ${M.id}:`,e),e}},enabled:P&&(M.type===`mcp`||M.type===`local-mcp`)&&t&&(M.type===`local-mcp`||AD(z.status)),staleTime:0,gcTime:12e4});(0,b.useEffect)(()=>{if(!t||!M?.id||M.type!==`mcp`&&M.type!==`local-mcp`||!(M.type===`local-mcp`||AD(z.status)||z.status===`not_required`)||re||ie)return;let e=!1;return(async()=>{try{let t=await(await U(`GET`,`/api/services/${M.id}`)).json();!e&&t?.success&&t.data&&D(t.data),k.invalidateQueries({queryKey:[`/api/services`]})}catch{}})(),()=>{e=!0}},[t,M?.id,M?.type,re,ie,z.status,k]),(0,b.useEffect)(()=>{if(!t||!M?.id||M.type!==`a2a`)return;let e=!1;return(async()=>{try{await U(`GET`,`/api/services/${M.id}/health`);let t=await(await U(`GET`,`/api/services/${M.id}`)).json();!e&&t?.success&&t.data&&D(t.data),k.invalidateQueries({queryKey:[`/api/services`]})}catch{}})(),()=>{e=!0}},[t,M?.id,M?.type,k]),console.log(`MCP Tools Query Debug:`,{hasValidService:P,apiServiceType:M?.type,isOpen:t,oauthRequired:F?.data?.oauth?.required,oauthStatus:z.status,toolsQueryEnabled:P&&(M.type===`mcp`||M.type===`local-mcp`)&&t&&(M.type===`local-mcp`||AD(z.status)),mcpToolsLoading:re});let{data:oe,isLoading:se,error:ce}=Bt({queryKey:[`/api/proxy/a2a`,M?.id,`manifest`],queryFn:async()=>{if(!M||M.type!==`a2a`)return null;let e=await(await U(`GET`,`/api/proxy/a2a/${M.id}/manifest`)).text();return JSON.parse(e)},enabled:P&&M.type===`a2a`&&t,staleTime:0,gcTime:12e4}),le=B?.data||[],ue=oe,de=re||se;console.log(`ServiceDetailsModal Debug:`,{service:e?.id,serviceType:e?.type,isOpen:t,mcpDiscoveryLoading:I,mcpDiscoveryData:F,mcpDiscoveryError:L?String(L):null,mcpToolsLoading:re,a2aManifestLoading:se,mcpToolsError:ie?String(ie):null,a2aManifestError:ce?String(ce):null,mcpToolsCount:le.length,mcpToolsData:B,hasA2aManifest:!!ue,isLoading:de,oauthRequired:F?.data?.oauth?.required,oauthStatus:z.status,oauthMessage:z.message,oauthAuthenticated:ne?.authenticated,expiresAt:ne?.expiresAt}),(0,b.useEffect)(()=>{if(!t){D(null),v(!1),C(null),pe.current=!1,fe.current=!1;return}e&&(D(e),u(e.name||``),f(e.description||``),v(!1),C(null))},[e,t]);let fe=(0,b.useRef)(!1),pe=(0,b.useRef)(!1);(0,b.useEffect)(()=>{if(!t||!M?.id){fe.current=!1;return}if(!ne?.authenticated){fe.current=!1;return}fe.current||(fe.current=!0,pe.current=!0,(async()=>{A({title:`OAuth completed`,description:`Authentication successful! Refreshing service status...`}),SD(k,M.id),k.invalidateQueries({queryKey:[`/api/mcp/discover`,M.url]});try{let e=await U(`GET`,`/api/services/${M.id}`);if(e.ok){let t=await e.json();D(t.data??t)}}catch{}await ee(),k.invalidateQueries({queryKey:[`/api/services`,M.id,`tools`]}),await ae(),pe.current=!1})())},[ne?.authenticated,t,M?.id]);let me=()=>e?.type===`mcp`?(0,H.jsx)(wi,{className:`w-6 h-6`}):(0,H.jsx)(pi,{className:`w-6 h-6`}),he=()=>e?.type===`mcp`?`text-blue-400`:`text-purple-400`,ge=()=>e?.type===`mcp`?`bg-blue-500/20`:`bg-purple-500/20`,_e=e=>new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});(0,b.useEffect)(()=>{a&&(O.current?.focus(),O.current?.select())},[a]);let ve=async()=>{let e=j?.name||``,t=l.trim();if(!j||!t||t===e){u(e),o(!1);return}m(!0);try{await U(`PUT`,`/api/services/${j.id}`,{name:t}),D({...j,name:t}),k.invalidateQueries({queryKey:[`/api/services`]}),k.invalidateQueries({queryKey:[`/api/collection/warnings`]}),k.invalidateQueries({queryKey:[`/api/decks`]}),o(!1)}catch(t){u(e),o(!1),A({title:`Could not rename service`,description:t instanceof Error?t.message:`Failed to update name`,variant:`destructive`})}finally{m(!1)}};return(0,H.jsx)(Vp,{open:t,onOpenChange:t=>{t||(pe.current&&=(SD(k,M?.id??e?.id),!1),fe.current=!1,n())},children:(0,H.jsxs)(Wp,{className:`sm:max-w-6xl bg-gradient-to-br from-cosmic-900 to-cosmic-800 border border-white/20 text-white max-h-[90vh] overflow-y-auto`,children:[(0,H.jsx)(Gp,{children:(0,H.jsxs)(qp,{className:`text-2xl font-bold flex items-center`,children:[me(),(0,H.jsx)(`div`,{className:`ml-3 flex min-w-0 items-center`,children:a?(0,H.jsx)(`input`,{ref:O,type:`text`,value:l,disabled:p,onChange:e=>u(e.target.value),onBlur:()=>{ve()},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ve()):e.key===`Escape`&&(e.preventDefault(),u(j?.name||``),o(!1))},className:`max-w-[16rem] rounded border border-white/20 bg-white/10 px-2 py-1 text-2xl font-bold text-white focus:border-white/40 focus:outline-none sm:max-w-[20rem]`,"aria-label":`Service name`,"data-testid":`input-service-name`}):(0,H.jsx)(`button`,{type:`button`,className:`min-w-0 truncate text-left hover:underline`,title:`Click to rename`,onClick:()=>{u(j?.name||``),o(!0)},"data-testid":`button-rename-service`,children:j?.name})}),(0,H.jsx)(bg,{className:`ml-3 ${ge()} ${he()}`,children:e?.type?.toUpperCase()})]})}),e&&(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsx)(`div`,{className:`mb-3`,children:(0,H.jsxs)(`h3`,{className:`text-lg font-semibold flex items-center`,children:[(0,H.jsx)(si,{className:`w-5 h-5 mr-2`}),`Service Overview`]})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm`,children:`Description`}),!s&&(0,H.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>c(!0),className:`h-6 w-6 p-0 opacity-0 hover:opacity-100 transition-opacity`,title:`Edit description`,children:(0,H.jsx)(Xi,{className:`w-3 h-3`})})]}),s?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),className:`w-full bg-black/30 border border-white/20 rounded px-2 py-1 text-white focus:outline-none focus:border-white/40 resize-none`,rows:3,placeholder:`Enter description...`,autoFocus:!0}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(K,{size:`sm`,onClick:async()=>{if(e){g(!0);try{if((await U(`PUT`,`/api/services/${e.id}`,{description:d.trim()})).ok){if(E){let e={...E,description:d.trim()};D(e)}k.invalidateQueries({queryKey:[`/api/services`]}),k.invalidateQueries({queryKey:[`/api/collection/warnings`]}),k.invalidateQueries({queryKey:[`/api/decks`]}),k.invalidateQueries({queryKey:[`/api/decks`]}),A({title:`Description updated`,description:`Service description has been updated successfully.`}),c(!1)}else throw Error(`Failed to update description`)}catch{A({title:`Update failed`,description:`Failed to update service description. Please try again.`,variant:`destructive`})}finally{g(!1)}}},disabled:h,className:`h-6 px-2 text-xs`,children:h?`Saving...`:`Save`}),(0,H.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>{c(!1),f(j?.description||``)},className:`h-6 px-2 text-xs`,children:`Cancel`})]})]}):(0,H.jsx)(`p`,{className:`text-white cursor-pointer hover:bg-white/10 px-2 py-1 rounded transition-colors`,onClick:()=>c(!0),title:`Click to edit description`,children:j?.description||`No description`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Endpoint`}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,H.jsx)(bg,{variant:`outline`,className:`border-blue-500/30 text-blue-300`,children:M.type.toUpperCase()}),TD(N)&&(0,H.jsx)(bg,{variant:`outline`,className:`border-green-500/30 text-green-300`,children:`Custom Headers`})]}),(0,H.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>window.open(M.url,`_blank`),className:`p-1 h-auto`,children:(0,H.jsx)(Ei,{className:`w-4 h-4`})})]}),(0,H.jsx)(`div`,{className:`text-xs text-gray-400 break-all bg-black/20 p-2 rounded border border-white/10`,children:M.url||`No URL available`}),M.type===`mcp`?(0,H.jsxs)(`div`,{className:`text-xs text-gray-400 bg-black/20 p-2 rounded border border-white/10`,"data-testid":`custom-headers-section`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,H.jsx)(`p`,{className:`font-semibold text-gray-300`,children:`Custom Headers`}),!_&&(0,H.jsx)(K,{size:`sm`,variant:`ghost`,className:`h-6 px-2 text-xs text-teal-300 hover:text-teal-200`,onClick:()=>{x(ED(N)),C(null),v(!0)},"data-testid":`button-edit-headers`,children:`Edit`})]}),_?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(em,{value:y,onChange:e=>{x(e.target.value),S&&C(null)},rows:6,className:`bg-white/10 border-white/20 text-white placeholder-gray-400 resize-none font-mono text-xs`,"data-testid":`textarea-edit-headers`,disabled:w}),S&&(0,H.jsxs)(`p`,{className:`text-red-400 text-xs flex items-center gap-1`,"data-testid":`headers-json-error`,children:[(0,H.jsx)(qi,{className:`w-3 h-3 shrink-0`}),S]}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(K,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:()=>{v(!1),C(null),x(ED(N))},disabled:w,"data-testid":`button-cancel-headers`,children:`Cancel`}),(0,H.jsx)(K,{size:`sm`,className:`h-7 px-3 text-xs bg-teal-600 hover:bg-teal-500`,onClick:async()=>{if(!j)return;let e=DD(y);if(!e.ok){C(e.error);return}T(!0);try{if(!(await U(`PUT`,`/api/services/${j.id}`,{headers:e.headers})).ok)throw Error(`Failed to update headers`);let t=Object.keys(e.headers).length>0?e.headers:void 0;D({...j,headers:t}),v(!1),C(null),SD(k,j.id),k.invalidateQueries({queryKey:[`/api/decks`]}),A({title:`Headers updated`,description:`Custom headers saved. Reconnecting with the new values.`})}catch(e){A({title:`Update failed`,description:e instanceof Error?e.message:`Failed to update headers. Please try again.`,variant:`destructive`})}finally{T(!1)}},disabled:w,"data-testid":`button-save-headers`,children:w?`Saving…`:`Save`})]})]}):TD(N)?(0,H.jsx)(`ul`,{className:`space-y-1 font-mono`,"data-testid":`headers-masked-list`,children:kD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`text-gray-300`,children:e}),(0,H.jsx)(`span`,{className:`text-gray-500`,children:`: `}),(0,H.jsx)(`span`,{children:t})]},e))}):(0,H.jsx)(`p`,{className:`text-gray-500`,"data-testid":`headers-empty-state`,children:`No custom headers. Add Bearer or API key headers to authenticate.`})]}):TD(N)&&(0,H.jsxs)(`div`,{className:`text-xs text-gray-400 bg-black/20 p-2 rounded border border-white/10`,children:[(0,H.jsx)(`p`,{className:`font-semibold mb-1`,children:`Custom Headers:`}),(0,H.jsx)(`ul`,{className:`space-y-1 font-mono`,children:kD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`span`,{className:`text-gray-300`,children:e}),(0,H.jsx)(`span`,{className:`text-gray-500`,children:`: `}),(0,H.jsx)(`span`,{children:t})]},e))})]})]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Health Status`}),(0,H.jsx)(bg,{className:M.health===`healthy`?`bg-green-500/20 text-green-300`:M.health===`unhealthy`?`bg-red-500/20 text-red-300`:`bg-amber-500/20 text-amber-200`,children:M.health===`healthy`?`Healthy`:M.health===`unhealthy`?`Unreachable`:z.status===`required`||z.status===`expired`||z.status===`refresh_failed`?`Auth required`:`Unknown`})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Registered`}),(0,H.jsx)(`p`,{className:`text-white text-sm`,children:_e(M.registeredAt)})]})]})]}),de&&(0,H.jsxs)(`div`,{className:`text-center py-8`,children:[(0,H.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-white mx-auto mb-4`}),(0,H.jsx)(`p`,{className:`text-gray-400`,children:`Fetching service details...`})]}),r&&(0,H.jsx)(`div`,{className:`bg-red-500/20 border border-red-500/30 rounded-lg p-4`,children:(0,H.jsx)(`p`,{className:`text-red-300`,children:r})}),(e.type===`mcp`||e.type===`local-mcp`)&&(0,H.jsxs)(H.Fragment,{children:[e.type===`local-mcp`&&(0,H.jsxs)(`div`,{className:`bg-cyan-500/15 border border-cyan-500/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-cyan-200 font-semibold mb-2`,children:`Local MCP — auth happens outside Agent Deck`}),(0,H.jsx)(`div`,{className:`text-cyan-100/90 text-sm space-y-2`,children:MD(M)?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`p`,{children:[`This card runs `,(0,H.jsx)(`code`,{className:`text-xs`,children:`@piotr-agier/google-drive-mcp`}),` on your machine. Agent Deck does `,(0,H.jsx)(`strong`,{children:`not`}),` handle Google OAuth for it. If Google shows "app not verified", that is `,(0,H.jsx)(`strong`,{children:`your Google Cloud project`}),`, not Agent Deck.`]}),(0,H.jsxs)(`ol`,{className:`list-decimal list-inside space-y-1 ml-1`,children:[(0,H.jsxs)(`li`,{children:[`Create a GCP OAuth client type `,(0,H.jsx)(`strong`,{children:`Desktop app`}),` (not Web).`]}),(0,H.jsxs)(`li`,{children:[`Add yourself as a `,(0,H.jsx)(`strong`,{children:`Test user`}),` on the consent screen.`]}),(0,H.jsxs)(`li`,{children:[`Run in terminal first:`,` `,(0,H.jsx)(`code`,{className:`text-xs block mt-1 bg-black/30 p-2 rounded whitespace-pre-wrap`,children:`export GOOGLE_DRIVE_OAUTH_CREDENTIALS="/path/to/gcp-oauth.keys.json"
|
|
194
194
|
export GOOGLE_DRIVE_MCP_AUTH_PORT=3100
|
|
195
|
-
npx @piotr-agier/google-drive-mcp auth`})]}),(0,H.jsxs)(`li`,{children:[`Set `,(0,H.jsx)(`code`,{className:`text-xs`,children:`GOOGLE_DRIVE_MCP_TOKEN_PATH`}),` in the card env to the same token file (`,(0,H.jsx)(`code`,{className:`text-xs`,children:`~/.config/google-drive-mcp/tokens.json`}),`).`]})]}),(0,H.jsxs)(`p`,{className:`text-xs text-cyan-200/80`,children:[`Full steps: `,(0,H.jsx)(`code`,{className:`text-xs`,children:`docs/GOOGLE_DRIVE_WORKAROUND.md`}),` in the repo.`]})]}):(0,H.jsx)(`p`,{children:`Local servers manage their own credentials (API keys, OAuth, etc.) in the spawned process. Complete any login in the terminal or config for that package before expecting tools here.`})})]}),(0,H.jsx)(vD,{serviceId:M.id,tools:le,isLoading:re})]}),e.type===`a2a`&&ue&&(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-4 flex items-center`,children:[(0,H.jsx)(Yi,{className:`w-5 h-5 mr-2`}),`Agent Overview`]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Agent Name`}),(0,H.jsx)(`p`,{className:`text-white font-semibold`,children:ue.name})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Version`}),(0,H.jsx)(`p`,{className:`text-white`,children:ue.version})]}),(0,H.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Description`}),(0,H.jsx)(`p`,{className:`text-white`,children:ue.description})]}),ue.provider&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Provider`}),(0,H.jsx)(`p`,{className:`text-white`,children:ue.provider.organization})]}),ue.documentationUrl&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Documentation`}),(0,H.jsxs)(K,{size:`sm`,variant:`ghost`,onClick:()=>window.open(ue.documentationUrl,`_blank`),className:`p-1 h-auto text-purple-300`,children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`View Docs`]})]})]})]}),ue.capabilities&&(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-4 flex items-center`,children:[(0,H.jsx)(ui,{className:`w-5 h-5 mr-2`}),`Capabilities`]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[ue.capabilities.streaming&&(0,H.jsx)(yg,{className:`bg-green-500/20 text-green-300`,children:`Streaming`}),ue.capabilities.pushNotifications&&(0,H.jsx)(yg,{className:`bg-blue-500/20 text-blue-300`,children:`Push Notifications`}),ue.capabilities.stateTransitionHistory&&(0,H.jsx)(yg,{className:`bg-purple-500/20 text-purple-300`,children:`State History`})]})]}),ue.skills&&ue.skills.length>0&&(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-4 flex items-center`,children:[(0,H.jsx)(pi,{className:`w-5 h-5 mr-2`}),`Skills (`,ue.skills.length,`)`]}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4`,children:ue.skills.map((e,t)=>(0,H.jsxs)(`div`,{className:`relative group cursor-pointer transform hover:scale-105 transition-all duration-300`,style:{aspectRatio:`2/3`,background:`linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(196, 181, 253, 0.1))`,border:`2px solid rgba(147, 51, 234, 0.3)`,borderRadius:`12px`,boxShadow:`0 4px 20px rgba(147, 51, 234, 0.2)`,minWidth:`120px`,maxWidth:`160px`},children:[(0,H.jsx)(`div`,{className:`absolute top-2 left-2 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`text-purple-300 leading-none`,children:`S`})}),(0,H.jsx)(`div`,{className:`absolute bottom-2 right-2 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`text-purple-300 leading-none`,children:`S`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-3 top-8 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`text-purple-300 mb-2`,children:(0,H.jsx)(pi,{className:`w-6 h-6`})}),(0,H.jsx)(`h4`,{className:`font-bold text-sm mb-2 line-clamp-2 text-white`,children:e.name}),(0,H.jsx)(`p`,{className:`text-gray-300 text-xs line-clamp-4 mb-2`,children:e.description}),e.tags&&e.tags.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1 justify-center`,children:e.tags.slice(0,2).map((e,t)=>(0,H.jsx)(`span`,{className:`text-purple-300 text-xs bg-purple-500/20 px-1 py-0.5 rounded`,children:e},t))})]}),(0,H.jsx)(`div`,{className:`absolute inset-0 rounded-lg bg-gradient-to-br from-transparent via-purple-500/5 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-500 pointer-events-none`})]},t))})]}),(ue.defaultInputModes||ue.defaultOutputModes)&&(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-3 flex items-center`,children:[(0,H.jsx)(wi,{className:`w-5 h-5 mr-2`}),`Data Modes`]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[ue.defaultInputModes&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-2`,children:`Input Modes`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ue.defaultInputModes.map((e,t)=>(0,H.jsx)(yg,{className:`bg-blue-500/20 text-blue-300 text-xs`,children:e},t))})]}),ue.defaultOutputModes&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-2`,children:`Output Modes`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ue.defaultOutputModes.map((e,t)=>(0,H.jsx)(yg,{className:`bg-green-500/20 text-green-300 text-xs`,children:e},t))})]})]})]})]}),e?.type===`mcp`&&z.status===`not_required`&&M?.id&&(0,H.jsxs)(`div`,{className:`bg-blue-500/20 border border-blue-500/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-blue-300 font-semibold mb-2`,children:`How to connect`}),(0,H.jsx)(bD,{serviceId:M.id})]}),e?.type===`mcp`&&z.status===`authenticated_refreshable`&&(0,H.jsxs)(`div`,{className:`bg-green-500/15 border border-green-500/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-green-300 font-semibold mb-2`,children:`✓ OAuth connected`}),(0,H.jsx)(`p`,{className:`text-green-100 text-sm`,children:z.message})]}),e?.type===`mcp`&&!kD(z.status)&&z.status!==`not_required`&&(0,H.jsxs)(`div`,{className:`${z.status===`expired`||z.status===`refresh_failed`?`bg-red-500/20 border-red-500/30`:`bg-orange-500/20 border-orange-500/30`} rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`${z.status===`expired`||z.status===`refresh_failed`?`text-red-300`:`text-orange-300`} font-semibold mb-2`,children:z.status===`expired`||z.status===`refresh_failed`?`⏰ Token Expired`:`🔐 Authentication Required`}),(0,H.jsxs)(`div`,{className:`${z.status===`expired`||z.status===`refresh_failed`?`text-red-200`:`text-orange-200`} text-sm space-y-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:z.message})}),(0,H.jsx)(`p`,{children:z.status===`expired`||z.status===`refresh_failed`?`Your OAuth token has expired or could not be renewed. Please re-authenticate to continue using this service.`:`This MCP server requires OAuth authentication to access its tools. Please authenticate to continue.`}),M?.id&&(0,H.jsx)(bD,{serviceId:M.id,onConnected:()=>void R()}),F?.data?.oauth?.resourceName&&(0,H.jsx)(`div`,{className:`mt-3 p-2 bg-orange-500/10 rounded border border-orange-500/20 text-xs text-orange-100`,children:(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Resource:`}),` `,F.data.oauth.resourceName]})})]})]}),e?.type===`mcp`&&(0,H.jsxs)(`div`,{className:`bg-gray-800/50 border border-gray-600/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-gray-300 font-semibold mb-2`,children:`Connection Logs`}),(0,H.jsxs)(`div`,{className:`text-gray-200 text-sm space-y-2`,children:[(0,H.jsxs)(`div`,{className:`bg-black/30 p-2 rounded text-xs`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`🔍 Attempting to discover tools for MCP service:`})}),(0,H.jsxs)(`p`,{children:[`Service ID: `,e?.id]}),(0,H.jsxs)(`p`,{children:[`Service URL: `,M?.url]}),(0,H.jsxs)(`p`,{children:[`Status: `,re?`🔄 Loading...`:ie?`❌ Failed`:`✅ Complete`]})]}),re&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 p-2 rounded text-xs`,children:[(0,H.jsxs)(`p`,{children:[`🔄 Making HTTP request to: `,(0,H.jsxs)(`code`,{children:[`GET /api/services/`,e?.id,`/tools`]})]}),(0,H.jsxs)(`p`,{children:[`Target MCP server: `,(0,H.jsx)(`code`,{children:M?.url})]})]}),ie&&(0,H.jsxs)(`div`,{className:`bg-red-500/20 p-2 rounded text-xs`,children:[(0,H.jsx)(`p`,{children:`❌ Request failed:`}),(0,H.jsx)(`pre`,{className:`whitespace-pre-wrap overflow-x-auto`,children:ie instanceof Error?ie.message:String(ie)}),(0,H.jsxs)(`div`,{className:`mt-2 p-2 bg-black/30 rounded`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`🔍 What we tried:`})}),(0,H.jsxs)(`p`,{children:[`• Service ID: `,e?.id]}),(0,H.jsxs)(`p`,{children:[`• Target URL: `,M?.url]}),(0,H.jsxs)(`p`,{children:[`• Request: GET /api/services/`,e?.id,`/tools`]}),wD(N)&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`📋 Headers sent:`})}),(0,H.jsx)(`ul`,{className:`text-xs font-mono`,children:OD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[e,`: `,t]},e))})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`💡 What this means:`})}),(0,H.jsxs)(`p`,{children:[`• The MCP server at `,M?.url,` returned an error`]}),(0,H.jsx)(`p`,{children:`• This could be due to authentication issues, server being down, or invalid configuration`}),(0,H.jsx)(`p`,{children:`• Check the error message above for specific details from the MCP server`})]})]})]}),!re&&!ie&&le.length>0&&(0,H.jsx)(`div`,{className:`bg-green-500/20 p-2 rounded text-xs`,children:(0,H.jsxs)(`p`,{children:[`✅ Successfully discovered `,le.length,` tools from MCP server`]})}),!re&&!ie&&le.length===0&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 p-2 rounded text-xs`,children:[(0,H.jsx)(`p`,{children:`⚠️ Connected to MCP server but no tools were found`}),(0,H.jsx)(`p`,{children:`This could mean the server has no tools or requires specific authentication`})]})]})]}),ie&&(e.type===`mcp`||e.type===`local-mcp`)&&(0,H.jsxs)(`div`,{className:`bg-red-500/20 border border-red-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-red-300 font-semibold mb-2`,children:`MCP Tool Discovery Failed`}),(0,H.jsxs)(`div`,{className:`text-red-200 text-sm space-y-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`Raw Error:`})}),(0,H.jsx)(`pre`,{className:`bg-black/30 p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap`,children:ie instanceof Error?ie.message:String(ie)}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service URL:`}),` `,M?.url]}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service ID:`}),` `,M?.id]}),wD(N)&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`Custom Headers:`})}),(0,H.jsx)(`ul`,{className:`bg-black/30 p-2 rounded text-xs font-mono`,children:OD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[e,`: `,t]},e))})]})]})]}),ce&&e.type===`a2a`&&(0,H.jsxs)(`div`,{className:`bg-red-500/20 border border-red-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-red-300 font-semibold mb-2`,children:`A2A Manifest Discovery Failed`}),(0,H.jsxs)(`div`,{className:`text-red-200 text-sm space-y-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`Raw Error:`})}),(0,H.jsx)(`pre`,{className:`bg-black/30 p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap`,children:ce instanceof Error?ce.message:String(ce)}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service URL:`}),` `,M?.url]}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service ID:`}),` `,M?.id]})]})]}),!de&&!ie&&!ce&&(e.type===`mcp`||e.type===`local-mcp`)&&le.length===0&&(e.type===`local-mcp`||!F?.data?.oauth?.required)&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 border border-yellow-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-yellow-300 font-semibold mb-2`,children:`No Tools Available`}),(0,H.jsxs)(`p`,{className:`text-yellow-200 text-sm`,children:[`Successfully connected to MCP server at `,M?.url,`, but no tools were discovered.`]}),(0,H.jsxs)(`div`,{className:`text-yellow-200 text-xs mt-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`This could mean:`})}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,H.jsx)(`li`,{children:`The MCP server has no tools registered`}),(0,H.jsx)(`li`,{children:`Tools require specific authentication`}),(0,H.jsx)(`li`,{children:`Tools are only available after certain operations`})]})]})]}),(e.type===`mcp`||e.type===`local-mcp`)&&(0,H.jsxs)(`div`,{className:`bg-blue-500/20 border border-blue-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-blue-300 font-semibold mb-2`,children:`🔍 MCP Server Analysis`}),(0,H.jsxs)(`div`,{className:`text-blue-200 text-sm space-y-2`,children:[(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Server URL:`}),` `,M?.url]}),I&&(0,H.jsx)(`div`,{className:`mt-3 p-3 bg-black/30 rounded`,children:(0,H.jsx)(`p`,{children:`🔍 Analyzing MCP server configuration...`})}),F&&(0,H.jsxs)(`div`,{className:`mt-3 p-3 bg-black/30 rounded`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`🔍 What we discovered:`})}),F.error&&F.analysis&&(0,H.jsxs)(`div`,{className:`text-yellow-200`,children:[F.analysis.auth_type===`oauth2`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`OAuth 2.0 Authentication Required`})]}),(0,H.jsx)(`p`,{children:`• This MCP server requires OAuth 2.0 Bearer token authentication`}),(0,H.jsx)(`p`,{children:`• You'll need to provide OAuth credentials (client ID, client secret, authorization URL, token URL)`}),(0,H.jsx)(`p`,{children:`• Check the service provider's documentation for OAuth setup instructions`})]}),F.analysis.protocol===`sse`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`SSE Protocol Required`})]}),(0,H.jsx)(`p`,{children:`• This MCP server uses Server-Sent Events (SSE) protocol`}),(0,H.jsx)(`p`,{children:`• We'll need to connect using event streaming instead of HTTP`})]}),F.analysis.issue===`not_found`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`Server Not Found`})]}),(0,H.jsx)(`p`,{children:`• The MCP server URL might be incorrect`}),(0,H.jsx)(`p`,{children:`• Check if the server is running and the URL is correct`})]}),F.analysis.issue===`server_error`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`Server Error`})]}),(0,H.jsx)(`p`,{children:`• The MCP server is experiencing internal errors`}),(0,H.jsx)(`p`,{children:`• Try again later or contact the service provider`})]}),F.analysis.message&&(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`Analysis:`}),` `,F.analysis.message]})]}),F?.data?.oauth?.required&&(0,H.jsxs)(`div`,{className:`text-yellow-200`,children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`OAuth 2.0 Authentication Required`})]}),F.data.oauth.authorizationUrl&&(0,H.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,H.jsx)(K,{size:`sm`,variant:`default`,className:`h-7`,onClick:async()=>{if(M?.id)try{A({title:`Setting up OAuth...`,description:`Automatically registering OAuth application and starting authorization flow...`});let e=await U(`POST`,`/api/oauth/${M.id}/auto-setup`,{});if(!e.ok){let t=await e.json();t.data?.registrationUrl?(window.open(t.data.registrationUrl,`_blank`),A({title:`OAuth Registration Required`,description:`${t.error} I've opened the registration page for you. Please create an OAuth app and then come back to add your credentials.`,duration:15e3})):A({title:`OAuth Setup Failed`,description:t.error||`Failed to setup OAuth automatically. Please configure manually.`,variant:`destructive`});return}let t=await e.json();t.success&&t.data?.authorizationUrl?(window.open(t.data.authorizationUrl,`_blank`),A({title:`OAuth Setup Successful`,description:`OAuth application registered automatically! Please complete the authorization in the new window.`,duration:1e4}),R()):A({title:`OAuth Setup Failed`,description:`Failed to get authorization URL. Please try again.`,variant:`destructive`})}catch(e){A({title:`OAuth Setup Failed`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}},children:`🔧 Auto-Setup OAuth`}),(0,H.jsxs)(K,{size:`sm`,variant:`ghost`,className:`p-1 h-auto text-blue-300`,onClick:()=>window.open(F.data.oauth.authorizationUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Open Raw Authorization URL`]})]}),!F.data.oauth.authorizationUrl&&F.data.oauth.protectedResourceConfigUrl&&(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsxs)(K,{size:`sm`,variant:`ghost`,className:`p-1 h-auto text-blue-300`,onClick:()=>window.open(F.data.oauth.protectedResourceConfigUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`View OAuth Configuration`]})}),F.data.oauth.authorizationServerMetadataUrl&&(0,H.jsxs)(`div`,{className:`mt-2 text-xs text-gray-300`,children:[(0,H.jsx)(`span`,{className:`mr-1`,children:`Auth Server Metadata:`}),(0,H.jsx)(`button`,{className:`underline text-blue-300`,onClick:()=>window.open(F.data.oauth.authorizationServerMetadataUrl,`_blank`),children:F.data.oauth.authorizationServerMetadataUrl})]})]}),F?.success&&!F?.data?.oauth?.required&&(0,H.jsxs)(`div`,{className:`text-green-200`,children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`✅ Server Analysis Complete`})]}),(0,H.jsx)(`p`,{children:`• MCP server is accessible and responding`}),(0,H.jsx)(`p`,{children:`• No authentication issues detected`}),(0,H.jsx)(`p`,{children:`• Protocol compatibility confirmed`})]}),F?.data?.oauth?.required&&(0,H.jsxs)(`div`,{className:`text-orange-200`,children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`🔐 OAuth 2.0 Authentication Required`})]}),(0,H.jsx)(`p`,{children:`• This MCP server requires OAuth authentication`}),F.data.oauth.resourceName&&(0,H.jsxs)(`p`,{children:[`• Service: `,F.data.oauth.resourceName]}),F.data.oauth.authorizationUrl&&(0,H.jsxs)(`p`,{children:[`• Authorization URL: `,F.data.oauth.authorizationUrl]}),F.data.oauth.tokenUrl&&(0,H.jsxs)(`p`,{children:[`• Token URL: `,F.data.oauth.tokenUrl]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(K,{size:`sm`,variant:`default`,className:`bg-orange-600 hover:bg-orange-700`,onClick:async()=>{if(M?.id)try{A({title:`Setting up OAuth...`,description:`Automatically registering OAuth application and starting authorization flow...`});let e=await U(`POST`,`/api/oauth/${M.id}/auto-setup`,{});if(!e.ok){let t=await e.json();t.data?.registrationUrl?(window.open(t.data.registrationUrl,`_blank`),A({title:`OAuth Registration Required`,description:`${t.error} I've opened the registration page for you. Please create an OAuth app and then come back to add your credentials.`,duration:15e3})):A({title:`OAuth Setup Failed`,description:t.error||`Failed to setup OAuth automatically. Please configure manually.`,variant:`destructive`});return}let t=await e.json();t.success&&t.data?.authorizationUrl?(window.open(t.data.authorizationUrl,`_blank`),A({title:`OAuth Setup Successful`,description:`OAuth application registered automatically! Please complete the authorization in the new window.`,duration:1e4}),R()):A({title:`OAuth Setup Failed`,description:`Failed to get authorization URL. Please try again.`,variant:`destructive`})}catch(e){A({title:`OAuth Setup Failed`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}},children:`🔧 Auto-Setup OAuth`}),(0,H.jsx)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-300 hover:bg-orange-500/10`,onClick:()=>{let e=`OAuth Setup Instructions:
|
|
195
|
+
npx @piotr-agier/google-drive-mcp auth`})]}),(0,H.jsxs)(`li`,{children:[`Set `,(0,H.jsx)(`code`,{className:`text-xs`,children:`GOOGLE_DRIVE_MCP_TOKEN_PATH`}),` in the card env to the same token file (`,(0,H.jsx)(`code`,{className:`text-xs`,children:`~/.config/google-drive-mcp/tokens.json`}),`).`]})]}),(0,H.jsxs)(`p`,{className:`text-xs text-cyan-200/80`,children:[`Full steps: `,(0,H.jsx)(`code`,{className:`text-xs`,children:`docs/GOOGLE_DRIVE_WORKAROUND.md`}),` in the repo.`]})]}):(0,H.jsx)(`p`,{children:`Local servers manage their own credentials (API keys, OAuth, etc.) in the spawned process. Complete any login in the terminal or config for that package before expecting tools here.`})})]}),(0,H.jsx)(yD,{serviceId:M.id,tools:le,isLoading:re})]}),e.type===`a2a`&&ue&&(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-4 flex items-center`,children:[(0,H.jsx)(Yi,{className:`w-5 h-5 mr-2`}),`Agent Overview`]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Agent Name`}),(0,H.jsx)(`p`,{className:`text-white font-semibold`,children:ue.name})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Version`}),(0,H.jsx)(`p`,{className:`text-white`,children:ue.version})]}),(0,H.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Description`}),(0,H.jsx)(`p`,{className:`text-white`,children:ue.description})]}),ue.provider&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Provider`}),(0,H.jsx)(`p`,{className:`text-white`,children:ue.provider.organization})]}),ue.documentationUrl&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`Documentation`}),(0,H.jsxs)(K,{size:`sm`,variant:`ghost`,onClick:()=>window.open(ue.documentationUrl,`_blank`),className:`p-1 h-auto text-purple-300`,children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`View Docs`]})]})]})]}),ue.capabilities&&(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-4 flex items-center`,children:[(0,H.jsx)(ui,{className:`w-5 h-5 mr-2`}),`Capabilities`]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[ue.capabilities.streaming&&(0,H.jsx)(bg,{className:`bg-green-500/20 text-green-300`,children:`Streaming`}),ue.capabilities.pushNotifications&&(0,H.jsx)(bg,{className:`bg-blue-500/20 text-blue-300`,children:`Push Notifications`}),ue.capabilities.stateTransitionHistory&&(0,H.jsx)(bg,{className:`bg-purple-500/20 text-purple-300`,children:`State History`})]})]}),ue.skills&&ue.skills.length>0&&(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-4 flex items-center`,children:[(0,H.jsx)(pi,{className:`w-5 h-5 mr-2`}),`Skills (`,ue.skills.length,`)`]}),(0,H.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-4`,children:ue.skills.map((e,t)=>(0,H.jsxs)(`div`,{className:`relative group cursor-pointer transform hover:scale-105 transition-all duration-300`,style:{aspectRatio:`2/3`,background:`linear-gradient(135deg, rgba(147, 51, 234, 0.1), rgba(196, 181, 253, 0.1))`,border:`2px solid rgba(147, 51, 234, 0.3)`,borderRadius:`12px`,boxShadow:`0 4px 20px rgba(147, 51, 234, 0.2)`,minWidth:`120px`,maxWidth:`160px`},children:[(0,H.jsx)(`div`,{className:`absolute top-2 left-2 text-xs font-bold`,children:(0,H.jsx)(`div`,{className:`text-purple-300 leading-none`,children:`S`})}),(0,H.jsx)(`div`,{className:`absolute bottom-2 right-2 text-xs font-bold rotate-180`,children:(0,H.jsx)(`div`,{className:`text-purple-300 leading-none`,children:`S`})}),(0,H.jsxs)(`div`,{className:`absolute inset-x-3 top-8 bottom-8 flex flex-col items-center justify-center text-center`,children:[(0,H.jsx)(`div`,{className:`text-purple-300 mb-2`,children:(0,H.jsx)(pi,{className:`w-6 h-6`})}),(0,H.jsx)(`h4`,{className:`font-bold text-sm mb-2 line-clamp-2 text-white`,children:e.name}),(0,H.jsx)(`p`,{className:`text-gray-300 text-xs line-clamp-4 mb-2`,children:e.description}),e.tags&&e.tags.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1 justify-center`,children:e.tags.slice(0,2).map((e,t)=>(0,H.jsx)(`span`,{className:`text-purple-300 text-xs bg-purple-500/20 px-1 py-0.5 rounded`,children:e},t))})]}),(0,H.jsx)(`div`,{className:`absolute inset-0 rounded-lg bg-gradient-to-br from-transparent via-purple-500/5 to-transparent opacity-0 group-hover:opacity-100 transition-all duration-500 pointer-events-none`})]},t))})]}),(ue.defaultInputModes||ue.defaultOutputModes)&&(0,H.jsxs)(`div`,{className:`bg-black/20 rounded-lg p-4 border border-white/10`,children:[(0,H.jsxs)(`h3`,{className:`text-lg font-semibold mb-3 flex items-center`,children:[(0,H.jsx)(wi,{className:`w-5 h-5 mr-2`}),`Data Modes`]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[ue.defaultInputModes&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-2`,children:`Input Modes`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ue.defaultInputModes.map((e,t)=>(0,H.jsx)(bg,{className:`bg-blue-500/20 text-blue-300 text-xs`,children:e},t))})]}),ue.defaultOutputModes&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-2`,children:`Output Modes`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ue.defaultOutputModes.map((e,t)=>(0,H.jsx)(bg,{className:`bg-green-500/20 text-green-300 text-xs`,children:e},t))})]})]})]})]}),e?.type===`mcp`&&z.status===`not_required`&&M?.id&&(0,H.jsxs)(`div`,{className:`bg-blue-500/20 border border-blue-500/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-blue-300 font-semibold mb-2`,children:`How to connect`}),(0,H.jsx)(xD,{serviceId:M.id})]}),e?.type===`mcp`&&z.status===`authenticated_refreshable`&&(0,H.jsxs)(`div`,{className:`bg-green-500/15 border border-green-500/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-green-300 font-semibold mb-2`,children:`✓ OAuth connected`}),(0,H.jsx)(`p`,{className:`text-green-100 text-sm`,children:z.message})]}),e?.type===`mcp`&&!AD(z.status)&&z.status!==`not_required`&&(0,H.jsxs)(`div`,{className:`${z.status===`expired`||z.status===`refresh_failed`?`bg-red-500/20 border-red-500/30`:`bg-orange-500/20 border-orange-500/30`} rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`${z.status===`expired`||z.status===`refresh_failed`?`text-red-300`:`text-orange-300`} font-semibold mb-2`,children:z.status===`expired`||z.status===`refresh_failed`?`⏰ Token Expired`:`🔐 Authentication Required`}),(0,H.jsxs)(`div`,{className:`${z.status===`expired`||z.status===`refresh_failed`?`text-red-200`:`text-orange-200`} text-sm space-y-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:z.message})}),(0,H.jsx)(`p`,{children:z.status===`expired`||z.status===`refresh_failed`?`Your OAuth token has expired or could not be renewed. Please re-authenticate to continue using this service.`:`This MCP server requires OAuth authentication to access its tools. Please authenticate to continue.`}),M?.id&&(0,H.jsx)(xD,{serviceId:M.id,onConnected:()=>void R()}),F?.data?.oauth?.resourceName&&(0,H.jsx)(`div`,{className:`mt-3 p-2 bg-orange-500/10 rounded border border-orange-500/20 text-xs text-orange-100`,children:(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Resource:`}),` `,F.data.oauth.resourceName]})})]})]}),e?.type===`mcp`&&(0,H.jsxs)(`div`,{className:`bg-gray-800/50 border border-gray-600/30 rounded-lg p-4 mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-gray-300 font-semibold mb-2`,children:`Connection Logs`}),(0,H.jsxs)(`div`,{className:`text-gray-200 text-sm space-y-2`,children:[(0,H.jsxs)(`div`,{className:`bg-black/30 p-2 rounded text-xs`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`🔍 Attempting to discover tools for MCP service:`})}),(0,H.jsxs)(`p`,{children:[`Service ID: `,e?.id]}),(0,H.jsxs)(`p`,{children:[`Service URL: `,M?.url]}),(0,H.jsxs)(`p`,{children:[`Status: `,re?`🔄 Loading...`:ie?`❌ Failed`:`✅ Complete`]})]}),re&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 p-2 rounded text-xs`,children:[(0,H.jsxs)(`p`,{children:[`🔄 Making HTTP request to: `,(0,H.jsxs)(`code`,{children:[`GET /api/services/`,e?.id,`/tools`]})]}),(0,H.jsxs)(`p`,{children:[`Target MCP server: `,(0,H.jsx)(`code`,{children:M?.url})]})]}),ie&&(0,H.jsxs)(`div`,{className:`bg-red-500/20 p-2 rounded text-xs`,children:[(0,H.jsx)(`p`,{children:`❌ Request failed:`}),(0,H.jsx)(`pre`,{className:`whitespace-pre-wrap overflow-x-auto`,children:ie instanceof Error?ie.message:String(ie)}),(0,H.jsxs)(`div`,{className:`mt-2 p-2 bg-black/30 rounded`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`🔍 What we tried:`})}),(0,H.jsxs)(`p`,{children:[`• Service ID: `,e?.id]}),(0,H.jsxs)(`p`,{children:[`• Target URL: `,M?.url]}),(0,H.jsxs)(`p`,{children:[`• Request: GET /api/services/`,e?.id,`/tools`]}),TD(N)&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`📋 Headers sent:`})}),(0,H.jsx)(`ul`,{className:`text-xs font-mono`,children:kD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[e,`: `,t]},e))})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`💡 What this means:`})}),(0,H.jsxs)(`p`,{children:[`• The MCP server at `,M?.url,` returned an error`]}),(0,H.jsx)(`p`,{children:`• This could be due to authentication issues, server being down, or invalid configuration`}),(0,H.jsx)(`p`,{children:`• Check the error message above for specific details from the MCP server`})]})]})]}),!re&&!ie&&le.length>0&&(0,H.jsx)(`div`,{className:`bg-green-500/20 p-2 rounded text-xs`,children:(0,H.jsxs)(`p`,{children:[`✅ Successfully discovered `,le.length,` tools from MCP server`]})}),!re&&!ie&&le.length===0&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 p-2 rounded text-xs`,children:[(0,H.jsx)(`p`,{children:`⚠️ Connected to MCP server but no tools were found`}),(0,H.jsx)(`p`,{children:`This could mean the server has no tools or requires specific authentication`})]})]})]}),ie&&(e.type===`mcp`||e.type===`local-mcp`)&&(0,H.jsxs)(`div`,{className:`bg-red-500/20 border border-red-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-red-300 font-semibold mb-2`,children:`MCP Tool Discovery Failed`}),(0,H.jsxs)(`div`,{className:`text-red-200 text-sm space-y-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`Raw Error:`})}),(0,H.jsx)(`pre`,{className:`bg-black/30 p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap`,children:ie instanceof Error?ie.message:String(ie)}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service URL:`}),` `,M?.url]}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service ID:`}),` `,M?.id]}),TD(N)&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`Custom Headers:`})}),(0,H.jsx)(`ul`,{className:`bg-black/30 p-2 rounded text-xs font-mono`,children:kD(N).map(({name:e,masked:t})=>(0,H.jsxs)(`li`,{children:[e,`: `,t]},e))})]})]})]}),ce&&e.type===`a2a`&&(0,H.jsxs)(`div`,{className:`bg-red-500/20 border border-red-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-red-300 font-semibold mb-2`,children:`A2A Manifest Discovery Failed`}),(0,H.jsxs)(`div`,{className:`text-red-200 text-sm space-y-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`Raw Error:`})}),(0,H.jsx)(`pre`,{className:`bg-black/30 p-2 rounded text-xs overflow-x-auto whitespace-pre-wrap`,children:ce instanceof Error?ce.message:String(ce)}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service URL:`}),` `,M?.url]}),(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Service ID:`}),` `,M?.id]})]})]}),!de&&!ie&&!ce&&(e.type===`mcp`||e.type===`local-mcp`)&&le.length===0&&(e.type===`local-mcp`||!F?.data?.oauth?.required)&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 border border-yellow-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-yellow-300 font-semibold mb-2`,children:`No Tools Available`}),(0,H.jsxs)(`p`,{className:`text-yellow-200 text-sm`,children:[`Successfully connected to MCP server at `,M?.url,`, but no tools were discovered.`]}),(0,H.jsxs)(`div`,{className:`text-yellow-200 text-xs mt-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`This could mean:`})}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,H.jsx)(`li`,{children:`The MCP server has no tools registered`}),(0,H.jsx)(`li`,{children:`Tools require specific authentication`}),(0,H.jsx)(`li`,{children:`Tools are only available after certain operations`})]})]})]}),(e.type===`mcp`||e.type===`local-mcp`)&&(0,H.jsxs)(`div`,{className:`bg-blue-500/20 border border-blue-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-blue-300 font-semibold mb-2`,children:`🔍 MCP Server Analysis`}),(0,H.jsxs)(`div`,{className:`text-blue-200 text-sm space-y-2`,children:[(0,H.jsxs)(`p`,{children:[(0,H.jsx)(`strong`,{children:`Server URL:`}),` `,M?.url]}),I&&(0,H.jsx)(`div`,{className:`mt-3 p-3 bg-black/30 rounded`,children:(0,H.jsx)(`p`,{children:`🔍 Analyzing MCP server configuration...`})}),F&&(0,H.jsxs)(`div`,{className:`mt-3 p-3 bg-black/30 rounded`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`🔍 What we discovered:`})}),F.error&&F.analysis&&(0,H.jsxs)(`div`,{className:`text-yellow-200`,children:[F.analysis.auth_type===`oauth2`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`OAuth 2.0 Authentication Required`})]}),(0,H.jsx)(`p`,{children:`• This MCP server requires OAuth 2.0 Bearer token authentication`}),(0,H.jsx)(`p`,{children:`• You'll need to provide OAuth credentials (client ID, client secret, authorization URL, token URL)`}),(0,H.jsx)(`p`,{children:`• Check the service provider's documentation for OAuth setup instructions`})]}),F.analysis.protocol===`sse`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`SSE Protocol Required`})]}),(0,H.jsx)(`p`,{children:`• This MCP server uses Server-Sent Events (SSE) protocol`}),(0,H.jsx)(`p`,{children:`• We'll need to connect using event streaming instead of HTTP`})]}),F.analysis.issue===`not_found`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`Server Not Found`})]}),(0,H.jsx)(`p`,{children:`• The MCP server URL might be incorrect`}),(0,H.jsx)(`p`,{children:`• Check if the server is running and the URL is correct`})]}),F.analysis.issue===`server_error`&&(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`Server Error`})]}),(0,H.jsx)(`p`,{children:`• The MCP server is experiencing internal errors`}),(0,H.jsx)(`p`,{children:`• Try again later or contact the service provider`})]}),F.analysis.message&&(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`Analysis:`}),` `,F.analysis.message]})]}),F?.data?.oauth?.required&&(0,H.jsxs)(`div`,{className:`text-yellow-200`,children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`OAuth 2.0 Authentication Required`})]}),F.data.oauth.authorizationUrl&&(0,H.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,H.jsx)(K,{size:`sm`,variant:`default`,className:`h-7`,onClick:async()=>{if(M?.id)try{A({title:`Setting up OAuth...`,description:`Automatically registering OAuth application and starting authorization flow...`});let e=await U(`POST`,`/api/oauth/${M.id}/auto-setup`,{});if(!e.ok){let t=await e.json();t.data?.registrationUrl?(window.open(t.data.registrationUrl,`_blank`),A({title:`OAuth Registration Required`,description:`${t.error} I've opened the registration page for you. Please create an OAuth app and then come back to add your credentials.`,duration:15e3})):A({title:`OAuth Setup Failed`,description:t.error||`Failed to setup OAuth automatically. Please configure manually.`,variant:`destructive`});return}let t=await e.json();t.success&&t.data?.authorizationUrl?(window.open(t.data.authorizationUrl,`_blank`),A({title:`OAuth Setup Successful`,description:`OAuth application registered automatically! Please complete the authorization in the new window.`,duration:1e4}),R()):A({title:`OAuth Setup Failed`,description:`Failed to get authorization URL. Please try again.`,variant:`destructive`})}catch(e){A({title:`OAuth Setup Failed`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}},children:`🔧 Auto-Setup OAuth`}),(0,H.jsxs)(K,{size:`sm`,variant:`ghost`,className:`p-1 h-auto text-blue-300`,onClick:()=>window.open(F.data.oauth.authorizationUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`Open Raw Authorization URL`]})]}),!F.data.oauth.authorizationUrl&&F.data.oauth.protectedResourceConfigUrl&&(0,H.jsx)(`div`,{className:`mt-2`,children:(0,H.jsxs)(K,{size:`sm`,variant:`ghost`,className:`p-1 h-auto text-blue-300`,onClick:()=>window.open(F.data.oauth.protectedResourceConfigUrl,`_blank`),children:[(0,H.jsx)(Ei,{className:`w-4 h-4 mr-1`}),`View OAuth Configuration`]})}),F.data.oauth.authorizationServerMetadataUrl&&(0,H.jsxs)(`div`,{className:`mt-2 text-xs text-gray-300`,children:[(0,H.jsx)(`span`,{className:`mr-1`,children:`Auth Server Metadata:`}),(0,H.jsx)(`button`,{className:`underline text-blue-300`,onClick:()=>window.open(F.data.oauth.authorizationServerMetadataUrl,`_blank`),children:F.data.oauth.authorizationServerMetadataUrl})]})]}),F?.success&&!F?.data?.oauth?.required&&(0,H.jsxs)(`div`,{className:`text-green-200`,children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`✅ Server Analysis Complete`})]}),(0,H.jsx)(`p`,{children:`• MCP server is accessible and responding`}),(0,H.jsx)(`p`,{children:`• No authentication issues detected`}),(0,H.jsx)(`p`,{children:`• Protocol compatibility confirmed`})]}),F?.data?.oauth?.required&&(0,H.jsxs)(`div`,{className:`text-orange-200`,children:[(0,H.jsxs)(`p`,{children:[`• `,(0,H.jsx)(`strong`,{children:`🔐 OAuth 2.0 Authentication Required`})]}),(0,H.jsx)(`p`,{children:`• This MCP server requires OAuth authentication`}),F.data.oauth.resourceName&&(0,H.jsxs)(`p`,{children:[`• Service: `,F.data.oauth.resourceName]}),F.data.oauth.authorizationUrl&&(0,H.jsxs)(`p`,{children:[`• Authorization URL: `,F.data.oauth.authorizationUrl]}),F.data.oauth.tokenUrl&&(0,H.jsxs)(`p`,{children:[`• Token URL: `,F.data.oauth.tokenUrl]}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,H.jsx)(K,{size:`sm`,variant:`default`,className:`bg-orange-600 hover:bg-orange-700`,onClick:async()=>{if(M?.id)try{A({title:`Setting up OAuth...`,description:`Automatically registering OAuth application and starting authorization flow...`});let e=await U(`POST`,`/api/oauth/${M.id}/auto-setup`,{});if(!e.ok){let t=await e.json();t.data?.registrationUrl?(window.open(t.data.registrationUrl,`_blank`),A({title:`OAuth Registration Required`,description:`${t.error} I've opened the registration page for you. Please create an OAuth app and then come back to add your credentials.`,duration:15e3})):A({title:`OAuth Setup Failed`,description:t.error||`Failed to setup OAuth automatically. Please configure manually.`,variant:`destructive`});return}let t=await e.json();t.success&&t.data?.authorizationUrl?(window.open(t.data.authorizationUrl,`_blank`),A({title:`OAuth Setup Successful`,description:`OAuth application registered automatically! Please complete the authorization in the new window.`,duration:1e4}),R()):A({title:`OAuth Setup Failed`,description:`Failed to get authorization URL. Please try again.`,variant:`destructive`})}catch(e){A({title:`OAuth Setup Failed`,description:e instanceof Error?e.message:`Unknown error occurred`,variant:`destructive`})}},children:`🔧 Auto-Setup OAuth`}),(0,H.jsx)(K,{size:`sm`,variant:`outline`,className:`border-orange-500/30 text-orange-300 hover:bg-orange-500/10`,onClick:()=>{let e=`OAuth Setup Instructions:
|
|
196
196
|
|
|
197
197
|
1. Go to the service provider's OAuth/Developer settings
|
|
198
198
|
2. Create a new OAuth application
|
|
@@ -202,9 +202,9 @@ npx @piotr-agier/google-drive-mcp auth`})]}),(0,H.jsxs)(`li`,{children:[`Set `,(
|
|
|
202
202
|
|
|
203
203
|
${F.data.oauth.authorizationUrl?`Authorization URL: ${F.data.oauth.authorizationUrl}`:``}
|
|
204
204
|
${F.data.oauth.tokenUrl?`Token URL: ${F.data.oauth.tokenUrl}`:``}
|
|
205
|
-
${F.data.oauth.issuer?`Issuer: ${F.data.oauth.issuer}`:``}`;A({title:`OAuth Setup Instructions`,description:e,duration:1e4})},children:`📋 Setup Instructions`})]})]}),(0,H.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`💡 Next Steps:`})}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,H.jsx)(`li`,{children:`For OAuth servers: Provide OAuth credentials in service settings`}),(0,H.jsx)(`li`,{children:`For SSE servers: We'll automatically use the correct protocol`}),(0,H.jsx)(`li`,{children:`For connection issues: Verify the server URL and status`})]})]})]}),L&&(0,H.jsxs)(`div`,{className:`mt-3 p-3 bg-red-500/20 rounded`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`❌ Discovery Failed`})}),(0,H.jsx)(`p`,{children:`Could not analyze MCP server configuration`}),(0,H.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:L instanceof Error?L.message:String(L)})]})]})]}),!de&&!ie&&!ce&&e.type===`a2a`&&!ue&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 border border-yellow-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-yellow-300 font-semibold mb-2`,children:`Agent Details Not Available`}),(0,H.jsxs)(`p`,{className:`text-yellow-200 text-sm`,children:[`Successfully connected to A2A agent at `,M?.url,`, but no manifest was found.`]}),(0,H.jsxs)(`div`,{className:`text-yellow-200 text-xs mt-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`This could mean:`})}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,H.jsx)(`li`,{children:`The agent doesn't provide a manifest`}),(0,H.jsx)(`li`,{children:`Manifest endpoint is not implemented`}),(0,H.jsx)(`li`,{children:`Agent requires specific authentication`})]})]})]})]})]})})}function ND({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),u=Tt(),{toast:d}=an(),f=()=>{r(null),a(null),s(null),l(!1)},p=Vt({mutationFn:async()=>{if(!n)throw Error(`Choose a bundle file first`);let e=await n.text(),t;try{t=JSON.parse(e)}catch{throw Error(`File is not valid JSON`)}return Jh(t)},onSuccess:e=>{s(e),u.invalidateQueries({queryKey:[`/api/decks`]}),u.invalidateQueries({queryKey:[`/api/services`]}),u.invalidateQueries({queryKey:[`/api/playbooks`]}),u.invalidateQueries({queryKey:[`/api/playbooks/collection`]}),u.invalidateQueries({queryKey:[`/api/credentials/collection`]}),u.invalidateQueries({queryKey:[`/api/collection/warnings`]}),d({title:`Import complete`,description:Zh(e)})},onError:e=>{d({title:`Import failed`,description:e.message,variant:`destructive`})}}),m=async e=>{if(r(e),s(null),!e){a(null);return}try{let t=await e.text(),n=JSON.parse(t);a(`${n.services?.length??0} services · ${n.playbooks?.length??0} playbooks · ${n.decks?.length??0} decks`)}catch{a(`Invalid JSON`)}};return(0,H.jsx)(Bp,{open:e,onOpenChange:e=>{e||f(),t(e)},children:(0,H.jsxs)(Up,{className:`sm:max-w-lg border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Wp,{children:[(0,H.jsx)(Kp,{children:`Import bundle`}),(0,H.jsx)(qp,{asChild:!0,children:(0,H.jsxs)(`div`,{className:`space-y-2 text-left text-sm text-[#A8C4C0]`,children:[(0,H.jsx)(`p`,{children:`Adds MCP, playbooks, and decks from a JSON file.`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-medium text-amber-200/90`,children:`Notes`}),(0,H.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,H.jsx)(`li`,{children:`Same name as an existing card or deck is skipped (linked only).`}),(0,H.jsx)(`li`,{children:`No credentials or secrets — re-enter keys and reconnect OAuth.`})]})]})]})})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`bundle-file`,children:`Bundle file`}),(0,H.jsx)(Eu,{id:`bundle-file`,type:`file`,accept:`.json,.agent-deck.json,application/json`,className:`cursor-pointer bg-white/5 border-white/20`,onChange:e=>m(e.target.files?.[0]??null),"data-testid":`input-import-bundle`}),i&&(0,H.jsx)(`p`,{className:`text-xs text-[#A8C4C0]`,"data-testid":`import-preview`,children:i})]}),!o&&(0,H.jsx)(K,{onClick:()=>p.mutate(),disabled:!n||p.isPending||i===`Invalid JSON`,className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},"data-testid":`button-import-apply`,children:p.isPending?`Importing…`:`Import`}),o&&(0,H.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-white/10 bg-white/5 p-3 text-sm`,"data-testid":`import-report`,children:[(0,H.jsx)(`p`,{className:`font-medium`,children:Zh(o)}),o.servicesNeedingOauth.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-amber-200`,children:`Needs OAuth reconnect:`}),(0,H.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.servicesNeedingOauth.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),o.warnings.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-amber-200`,children:`Warnings:`}),(0,H.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.warnings.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),(0,H.jsx)(K,{variant:`outline`,size:`sm`,className:`rounded-full border border-white/20 text-white hover:bg-white/10`,onClick:()=>l(e=>!e),children:c?`Hide id map`:`Show id map`}),c&&(0,H.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded bg-black/40 p-2 text-xs`,children:JSON.stringify(o.idMap,null,2)}),(0,H.jsx)(K,{className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},onClick:()=>{f(),t(!1)},children:`Done`})]})]})]})})}function PD(){let[e,t]=(0,b.useState)(`connecting`),[n,r]=(0,b.useState)(null),i=(0,b.useRef)(null),a=(0,b.useRef)(null),o=Tt();return(0,b.useEffect)(()=>{let e=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/ws/events`,n=()=>{try{let s=new WebSocket(e);i.current=s,s.onopen=()=>{console.log(`WebSocket connected`),t(`connected`)},s.onmessage=e=>{try{let n=JSON.parse(e.data);r(n),n.type===`deck_update`?(console.log(`Received deck update:`,n),o.invalidateQueries({queryKey:[`/api/decks`]})):n.type===`service_update`?(console.log(`Received service update:`,n),xD(o,typeof n.data?.serviceId==`string`?n.data.serviceId:void 0)):n.type===`connection_status`&&t(n.status===`connected`?`connected`:`disconnected`)}catch(e){console.error(`Failed to parse WebSocket message:`,e)}},s.onclose=()=>{console.log(`WebSocket disconnected`),t(`disconnected`),a.current=setTimeout(()=>{console.log(`Attempting to reconnect WebSocket...`),t(`connecting`),n()},3e3)},s.onerror=e=>{console.error(`WebSocket error:`,e),t(`disconnected`)}}catch(e){console.error(`Failed to connect WebSocket:`,e),t(`disconnected`)}};n();let s=e=>{e.origin===window.location.origin&&CD(e.data)&&xD(o,e.data.serviceId)};return window.addEventListener(`message`,s),()=>{window.removeEventListener(`message`,s),a.current&&clearTimeout(a.current),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.close()}},[o]),{connectionStatus:e,lastMessage:n}}async function FD(e,t){return(await(await U(`GET`,`/api/playbooks/dependents/check?${e===`credential`?`credentialId=${encodeURIComponent(t)}`:`serviceId=${encodeURIComponent(t)}`}`)).json()).data??[]}function ID(e){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),l=Tt(),{toast:u}=an(),d=()=>{if(!e)throw Error(`Select a deck to edit first`);return e},f=Vt({mutationFn:async e=>{let t=d(),n=(await(await U(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t);if(!n)throw Error(`Selected deck not found`);if(n.services?.some(t=>t.id===e))throw Error(`Service is already in the deck`);let r=n.services?.length??0;return U(`POST`,`/api/decks/${t}/services`,{serviceId:e,position:r})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service added to deck`,description:`${t?.name||`Service`} has been added to the deck.`})},onError:e=>{u({title:`Failed to add service`,description:e.message,variant:`destructive`})}}),p=Vt({mutationFn:async e=>{let t=d();if(((await(await U(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.credentials?.some(t=>t.id===e))throw Error(`API key is already in the deck`);return U(`POST`,`/api/decks/${t}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key added to deck`,description:`${r?.label||`API key`} is scoped to this deck.`})},onError:e=>{u({title:`Failed to add API key`,description:e.message,variant:`destructive`})}}),m=Vt({mutationFn:async e=>{let t=d();if(((await(await U(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.playbooks?.some(t=>t.id===e))throw Error(`Playbook is already in the deck`);return U(`POST`,`/api/decks/${t}/playbooks`,{playbookId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook added to deck`,description:`${a?.title||`Playbook`} is on this deck.`})},onError:e=>{u({title:`Failed to add playbook`,description:e.message,variant:`destructive`})}}),h=Vt({mutationFn:async e=>{let t=await FD(`service`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this MCP (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return U(`DELETE`,`/api/decks/${d()}/services`,{serviceId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service removed from deck`,description:`${t?.name||`Service`} has been removed from the deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove service`,description:e.message,variant:`destructive`})}}),g=Vt({mutationFn:async e=>{let t=await FD(`credential`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this API key (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return U(`DELETE`,`/api/decks/${d()}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key removed from deck`,description:`${r?.label||`API key`} is no longer on this deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove API key`,description:e.message,variant:`destructive`})}}),_=Vt({mutationFn:async e=>U(`DELETE`,`/api/decks/${d()}/playbooks`,{playbookId:e}),onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook removed from deck`,description:`${a?.title||`Playbook`} is no longer on this deck.`})},onError:e=>{u({title:`Failed to remove playbook`,description:e.message,variant:`destructive`})}}),v=(e,t)=>{e.currentTarget instanceof HTMLElement&&(e.currentTarget.style.opacity=t)},y=(e,t)=>{e.dataTransfer.setData(`text/plain`,t.id),e.dataTransfer.setData(`application/json`,JSON.stringify(t)),e.dataTransfer.effectAllowed=t.fromDeck?`move`:`copy`},x=(e,t,r=!1)=>{n(t),i(null),o(null),c(r),y(e,{kind:`service`,id:t.id,fromDeck:r}),v(e,`0.5`)},S=(e,t,r=!1)=>{i(t),n(null),o(null),c(r),y(e,{kind:`credential`,id:t.id,fromDeck:r}),v(e,`0.5`)},C=(e,t,r=!1)=>{o(t),n(null),i(null),c(r),y(e,{kind:`playbook`,id:t.id,fromDeck:r}),v(e,`0.5`)},w=e=>{n(null),i(null),o(null),v(e,`1`)},T=e=>{if(e.kind===`service`){e.fromDeck?h.mutate(e.id):f.mutate(e.id);return}if(e.kind===`credential`){e.fromDeck?g.mutate(e.id):p.mutate(e.id);return}e.fromDeck?_.mutate(e.id):m.mutate(e.id)};return{draggedService:t,draggedCredential:r,draggedPlaybook:a,isDraggingFromDeck:s,handleDragStart:x,handleCredentialDragStart:S,handlePlaybookDragStart:C,handleDragEnd:w,handleDrop:e=>{e.preventDefault();let r=e.dataTransfer.getData(`application/json`);if(r){try{T(JSON.parse(r))}catch{let n=e.dataTransfer.getData(`text/plain`);n&&t&&f.mutate(n)}n(null),i(null),o(null),c(!1)}},handleGlobalDrop:e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/json`);if(t){try{let e=JSON.parse(t);e.fromDeck&&T(e)}catch{}n(null),i(null),o(null),c(!1)}},isDropping:f.isPending||p.isPending||m.isPending||h.isPending||g.isPending||_.isPending}}var LD=`agent-deck-editing-deck-id`;function RD(e){let[t,n]=(0,b.useState)(()=>typeof window>`u`?null:localStorage.getItem(LD));return(0,b.useEffect)(()=>{if(e.length!==0&&!(t&&e.some(e=>e.id===t))){let t=e[0].id;n(t),localStorage.setItem(LD,t)}},[e,t]),{editingDeck:e.find(e=>e.id===t)??null,editingDeckId:t,setEditingDeckId:e=>{n(e),localStorage.setItem(LD,e)}}}function zD(e,[t,n]){return Math.min(n,Math.max(t,e))}function BD(e){let t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var VD=[` `,`Enter`,`ArrowUp`,`ArrowDown`],HD=[` `,`Enter`],UD=`Select`,[WD,GD,KD]=xn(UD),[qD,JD]=dn(UD,[KD,jc]),YD=jc(),[XD,ZD]=qD(UD),[QD,$D]=qD(UD),eO=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=YD(t),[g,_]=b.useState(null),[v,y]=b.useState(null),[x,S]=b.useState(!1),C=Jm(l),[w,T]=Xn({prop:r,defaultProp:i??!1,onChange:a,caller:UD}),[E,D]=Xn({prop:o,defaultProp:s,onChange:c,caller:UD}),O=b.useRef(null),k=!g||m||!!g.closest(`form`),[A,j]=b.useState(new Set),M=Array.from(A).map(e=>e.props.value).join(`;`);return(0,H.jsx)(qc,{...h,children:(0,H.jsxs)(XD,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:oo(),value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,children:[(0,H.jsx)(WD.Provider,{scope:t,children:(0,H.jsx)(QD,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(e=>{j(t=>new Set(t).add(e))},[]),onNativeOptionRemove:b.useCallback(e=>{j(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),k?(0,H.jsxs)(YO,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:E,onChange:e=>D(e.target.value),disabled:f,form:m,children:[E===void 0?(0,H.jsx)(`option`,{value:``}):null,Array.from(A)]},M):null]})})};eO.displayName=UD;var tO=`SelectTrigger`,nO=b.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=YD(n),o=ZD(tO,n),s=o.disabled||r,c=ln(t,o.onTriggerChange),l=GD(n),u=b.useRef(`touch`),[d,f,p]=ZO(e=>{let t=l().filter(e=>!e.disabled),n=QO(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,H.jsx)(Jc,{asChild:!0,...a,children:(0,H.jsx)(Sn.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":XO(o.value)?``:void 0,...i,ref:c,onClick:W(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:W(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:W(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&VD.includes(e.key)&&(m(),e.preventDefault())})})})});nO.displayName=tO;var rO=`SelectValue`,iO=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=ZD(rO,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=ln(t,c.onValueNodeChange);return Vn(()=>{l(u)},[l,u]),(0,H.jsx)(Sn.span,{...s,ref:d,style:{pointerEvents:`none`},children:XO(c.value)?(0,H.jsx)(H.Fragment,{children:o}):a})});iO.displayName=rO;var aO=`SelectIcon`,oO=b.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,H.jsx)(Sn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});oO.displayName=aO;var sO=`SelectPortal`,cO=e=>(0,H.jsx)(Un,{asChild:!0,...e});cO.displayName=sO;var lO=`SelectContent`,uO=b.forwardRef((e,t)=>{let n=ZD(lO,e.__scopeSelect),[r,i]=b.useState();if(Vn(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?on.createPortal((0,H.jsx)(fO,{scope:e.__scopeSelect,children:(0,H.jsx)(WD.Slot,{scope:e.__scopeSelect,children:(0,H.jsx)(`div`,{children:e.children})})}),t):null}return(0,H.jsx)(gO,{...e,ref:t})});uO.displayName=lO;var dO=10,[fO,pO]=qD(lO),mO=`SelectContentImpl`,hO=pn(`SelectContent.RemoveScroll`),gO=b.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=ZD(lO,n),[y,x]=b.useState(null),[S,C]=b.useState(null),w=ln(t,e=>x(e)),[T,E]=b.useState(null),[D,O]=b.useState(null),k=GD(n),[A,j]=b.useState(!1),M=b.useRef(!1);b.useEffect(()=>{if(y)return Qf(y)},[y]),Nd();let N=b.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),P=b.useCallback(()=>N([T,y]),[N,T,y]);b.useEffect(()=>{A&&P()},[A,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=v;b.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null};return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,I]),b.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,ee]=ZO(e=>{let t=k().filter(e=>!e.disabled),n=QO(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),te=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&(E(e),r&&(M.current=!0))},[v.value]),ne=b.useCallback(()=>y?.focus(),[y]),R=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&O(e)},[v.value]),z=r===`popper`?bO:vO,B=z===bO?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,H.jsx)(fO,{scope:n,content:y,viewport:S,onViewportChange:C,itemRefCallback:te,selectedItem:T,onItemLeave:ne,itemTextRefCallback:R,focusSelectedItem:P,selectedItemText:D,position:r,isPositioned:A,searchRef:L,children:(0,H.jsx)(Uf,{as:hO,allowPinchZoom:!0,children:(0,H.jsx)(bd,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:W(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,H.jsx)(Mn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,H.jsx)(z,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>j(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:W(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})});gO.displayName=mO;var _O=`SelectItemAlignedPosition`,vO=b.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=ZD(lO,n),o=pO(lO,n),[s,c]=b.useState(null),[l,u]=b.useState(null),d=ln(t,e=>u(e)),f=GD(n),p=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=b.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-dO,d=zD(a,[dO,Math.max(dO,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-dO,d=zD(a,[dO,Math.max(dO,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-dO*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-dO,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${dO}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);Vn(()=>y(),[y]);let[x,S]=b.useState();Vn(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);let C=b.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,H.jsx)(xO,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:(0,H.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,H.jsx)(Sn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});vO.displayName=_O;var yO=`SelectPopperPosition`,bO=b.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=dO,...a}=e,o=YD(n);return(0,H.jsx)(Yc,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});bO.displayName=yO;var[xO,SO]=qD(lO,{}),CO=`SelectViewport`,wO=b.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=pO(CO,n),o=SO(CO,n),s=ln(t,a.onViewportChange),c=b.useRef(0);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,H.jsx)(WD.Slot,{scope:n,children:(0,H.jsx)(Sn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:W(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-dO*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});wO.displayName=CO;var TO=`SelectGroup`,[EO,DO]=qD(TO),OO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=oo();return(0,H.jsx)(EO,{scope:n,id:i,children:(0,H.jsx)(Sn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});OO.displayName=TO;var kO=`SelectLabel`,AO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=DO(kO,n);return(0,H.jsx)(Sn.div,{id:i.id,...r,ref:t})});AO.displayName=kO;var jO=`SelectItem`,[MO,NO]=qD(jO),PO=b.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=ZD(jO,n),c=pO(jO,n),l=s.value===r,[u,d]=b.useState(a??``),[f,p]=b.useState(!1),m=ln(t,e=>c.itemRefCallback?.(e,r,i)),h=oo(),g=b.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,H.jsx)(MO,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:b.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,H.jsx)(WD.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,H.jsx)(Sn.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:W(o.onFocus,()=>p(!0)),onBlur:W(o.onBlur,()=>p(!1)),onClick:W(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:W(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:W(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:W(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:W(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:W(o.onKeyDown,e=>{(c.searchRef?.current===``||e.key!==` `)&&(HD.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});PO.displayName=jO;var FO=`SelectItemText`,IO=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=ZD(FO,n),s=pO(FO,n),c=NO(FO,n),l=$D(FO,n),[u,d]=b.useState(null),f=ln(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=b.useMemo(()=>(0,H.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return Vn(()=>(h(m),()=>g(m)),[h,g,m]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Sn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?on.createPortal(a.children,o.valueNode):null]})});IO.displayName=FO;var LO=`SelectItemIndicator`,RO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return NO(LO,n).isSelected?(0,H.jsx)(Sn.span,{"aria-hidden":!0,...r,ref:t}):null});RO.displayName=LO;var zO=`SelectScrollUpButton`,BO=b.forwardRef((e,t)=>{let n=pO(zO,e.__scopeSelect),r=SO(zO,e.__scopeSelect),[i,a]=b.useState(!1),o=ln(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)(UO,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});BO.displayName=zO;var VO=`SelectScrollDownButton`,HO=b.forwardRef((e,t)=>{let n=pO(VO,e.__scopeSelect),r=SO(VO,e.__scopeSelect),[i,a]=b.useState(!1),o=ln(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)(UO,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});HO.displayName=VO;var UO=b.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=pO(`SelectScrollButton`,n),o=b.useRef(null),s=GD(n),c=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),Vn(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,H.jsx)(Sn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:W(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:W(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:W(i.onPointerLeave,()=>{c()})})}),WO=`SelectSeparator`,GO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,H.jsx)(Sn.div,{"aria-hidden":!0,...r,ref:t})});GO.displayName=WO;var KO=`SelectArrow`,qO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=YD(n),a=ZD(KO,n),o=pO(KO,n);return a.open&&o.position===`popper`?(0,H.jsx)(Xc,{...i,...r,ref:t}):null});qO.displayName=KO;var JO=`SelectBubbleInput`,YO=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=b.useRef(null),a=ln(r,i),o=BD(t);return b.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,H.jsx)(Sn.select,{...n,style:{...$n,...n.style},ref:a,defaultValue:t})});YO.displayName=JO;function XO(e){return e===``||e===void 0}function ZO(e){let t=wn(e),n=b.useRef(``),r=b.useRef(0),i=b.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=b.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function QO(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=$O(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function $O(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ek=eO,tk=nO,nk=iO,rk=oO,ik=cO,ak=uO,ok=wO,sk=AO,ck=PO,lk=IO,uk=RO,dk=BO,fk=HO,pk=GO,mk=ek,hk=nk,gk=b.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(tk,{ref:r,className:Ja(`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,H.jsx)(rk,{asChild:!0,children:(0,H.jsx)(hi,{className:`h-4 w-4 opacity-50`})})]}));gk.displayName=tk.displayName;var _k=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(dk,{ref:n,className:Ja(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(vi,{className:`h-4 w-4`})}));_k.displayName=dk.displayName;var vk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(fk,{ref:n,className:Ja(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(hi,{className:`h-4 w-4`})}));vk.displayName=fk.displayName;var yk=b.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,H.jsx)(ik,{children:(0,H.jsxs)(ak,{ref:i,className:Ja(`relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,H.jsx)(_k,{}),(0,H.jsx)(ok,{className:Ja(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,H.jsx)(vk,{})]})}));yk.displayName=ak.displayName;var bk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(sk,{ref:n,className:Ja(`py-1.5 pl-8 pr-2 text-sm font-semibold`,e),...t}));bk.displayName=sk.displayName;var xk=b.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(ck,{ref:r,className:Ja(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(uk,{children:(0,H.jsx)(mi,{className:`h-4 w-4`})})}),(0,H.jsx)(lk,{children:t})]}));xk.displayName=ck.displayName;var Sk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(pk,{ref:n,className:Ja(`-mx-1 my-1 h-px bg-muted`,e),...t}));Sk.displayName=pk.displayName;var Ck=`/api/mcp/endpoint`;async function wk(){let e=await fetch(Ck,{credentials:`include`});if(!e.ok)throw Error(`MCP endpoint request failed: ${e.status}`);let t=(await e.json())?.data?.url;if(typeof t!=`string`||t.length===0)throw Error(`MCP endpoint response did not include a URL`);return t}async function Tk(e){try{let t=await wk();await navigator.clipboard.writeText(t),e({title:`MCP URL copied!`,description:t})}catch(t){e({title:`Failed to copy MCP URL`,description:t instanceof Error?t.message:`Unknown error`,variant:`destructive`})}}var Ek=`/assets/AgentDeckLogo3-X5qCXS2A.png`,Dk=`agent-deck open`,Ok=`agent-deck://open`;function kk(e=document){let t=e.createElement(`iframe`);t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`tabindex`,`-1`),t.style.display=`none`,t.src=Ok,e.body.appendChild(t),window.setTimeout(()=>{t.remove()},5e3)}async function Ak(e=e=>navigator.clipboard.writeText(e)){try{return await e(Dk),!0}catch{return!1}}var jk=`Agent Deck carries the method; Agent Dealer runs the issue queue.`;function Mk(){let[e,t]=(0,b.useState)(!1),{toast:n}=an();return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,H.jsxs)(`div`,{className:`text-center max-w-lg px-4`,"data-testid":`dashboard-recovery`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-bold text-gray-100 mb-4`,children:`Open your dashboard securely`}),(0,H.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`This page is Agent Deck running on your own machine — nothing is broken.`}),(0,H.jsx)(`p`,{className:`text-gray-400 text-sm mb-6`,children:`Your browser just doesn't have a launch pass yet. Agent Deck opens the dashboard with a fresh pass each time, so typing this address alone can never sign anyone in — this page can't grant access by itself.`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{kk(),t(!0)},"data-testid":`button-open-dashboard`,className:`px-5 py-2.5 bg-blue-600 text-white rounded hover:bg-blue-700 font-medium`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(Ei,{className:`w-4 h-4`}),`Open dashboard`]})}),e&&(0,H.jsxs)(`div`,{className:`mt-6 rounded-lg border border-white/10 bg-black/30 p-4`,"data-testid":`dashboard-recovery-manual`,children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`If nothing opened, run this in your terminal:`}),(0,H.jsx)(`code`,{className:`mb-3 block rounded bg-black/40 px-3 py-2 text-gray-100 select-all`,children:`agent-deck open`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{Ak().then(e=>{n(e?{title:`Command copied`,description:`Run it in your terminal.`}:{title:`Copy failed`,description:`Type this in your terminal: ${Dk}`})})},"data-testid":`button-copy-open-command`,className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 text-sm`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(Ci,{className:`w-4 h-4`}),`Copy command`]})}),(0,H.jsxs)(`p`,{className:`text-gray-500 text-xs mt-3`,children:[`Then come back here and reload — or pick `,(0,H.jsx)(`strong`,{children:`Open dashboard`}),` from the Agent Deck menubar, which runs the same command.`]})]})]})})}var Nk=[],Pk=[],Fk=[];function Ik(){let[e,t]=(0,b.useState)(``),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(`default`),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(null),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(null),{toast:N}=an(),{connectionStatus:P}=PD(),{data:F=[]}=Bt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>rg(`proposed`)}),{data:I=0}=Bt({queryKey:[`/api/feedback-signals/count`,`available`],queryFn:()=>lg()}),{data:L}=Bt({queryKey:[`/api/dashboard-auth/context`]}),ee=async()=>{A(!0);try{let e=await qh({scope:`collection`});Yh(e,`backup.agent-deck.json`),N({title:`Exported collection`,description:`${e.services.length} services, ${e.playbooks.length} playbooks, ${e.decks.length} decks`})}catch(e){N({title:`Export failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{A(!1)}},{data:te,isLoading:ne,error:R}=Bt({queryKey:[`/api/decks`]}),z=te?.data||[],{editingDeck:B,editingDeckId:re,setEditingDeckId:ie}=RD(z),[ae,oe]=(0,b.useState)(!1),se=e=>{(e===re||!ae||window.confirm(`You have unsaved deck instructions. Discard them?`))&&ie(e)},{handleDragStart:ce,handleCredentialDragStart:le,handlePlaybookDragStart:ue,handleDragEnd:de,handleDrop:fe,handleGlobalDrop:pe,isDraggingFromDeck:me}=ID(re),{data:he,isLoading:ge,error:_e}=Bt({queryKey:[`/api/services`]}),{data:ve,isLoading:be}=Bt({queryKey:[`/api/credentials/vault`]}),{data:xe,isLoading:Se}=Bt({queryKey:[`/api/playbooks/vault`]}),{data:Ce}=Bt({queryKey:[`/api/collection/warnings`],staleTime:6e4}),{data:we}=Il(),Te=(0,b.useMemo)(()=>Rl(we?.data?.cards),[we?.data?.cards]),Ee=he?.data??Nk,De=ve?.data??Pk,Oe=xe?.data??Fk,ke=(0,b.useMemo)(()=>Nl(Ce?.data),[Ce?.data]),Ae=Array.isArray(we?.data?.cards),je=(0,b.useMemo)(()=>new Map(Ee.map(e=>[e.id,e])),[Ee]),Me=(0,b.useMemo)(()=>new Map(De.map(e=>[e.id,e])),[De]),Ne=(0,b.useMemo)(()=>new Map(Oe.map(e=>[e.id,e])),[Oe]),Pe=(0,b.useMemo)(()=>Hl({services:Ee,credentials:De,playbooks:Oe},{searchQuery:e,typeFilter:n,warningsOnly:i,warnings:ke,getUsageCount:(e,t)=>Te.get(Ll(e,t))?.usageCount}).map(e=>e.kind===`playbook`?{...e,playbook:Ne.get(e.id)}:e.kind===`credential`?{...e,credential:Me.get(e.id)}:{...e,service:je.get(e.id)}),[Ee,De,Oe,e,n,i,ke,Te,je,Me,Ne]),Fe=Pe.length,V=(0,b.useMemo)(()=>Vl(Pe,o,Ae),[Pe,o,Ae]);_e&&console.error(`Services error:`,_e),R&&console.error(`Decks error:`,R);let Ie=()=>{t(``),r(``),a(!1)},Le=!!(e||n||i),Re=new Set((B?.credentials??[]).map(e=>e.id)),ze=new Set((B?.playbooks??[]).map(e=>e.id)),Be=B?.services||[],Ve=B?.playbooks||[],He=e=>{d(e),p(!0)},Ue=e=>{w(e.id),E(!0)},We=e=>{_(e.id),y(!0)},Ge=e=>{M(e)};if(_e||R){if(Ut(R)||Ut(_e))return(0,H.jsx)(Mk,{});let e=(R instanceof Error?R.message:null)??(_e instanceof Error?_e.message:null)??`There was an error loading the application data.`;return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,H.jsxs)(`div`,{className:`text-center max-w-lg px-4`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-bold text-red-400 mb-4`,children:`Error Loading Data`}),(0,H.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`There was an error loading the application data.`}),(0,H.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:e}),(0,H.jsxs)(`p`,{className:`text-gray-500 text-xs mb-6`,children:[`Is the API running? Try `,(0,H.jsx)(`code`,{className:`text-gray-300`,children:`agent-deck stop && agent-deck start`})]}),(0,H.jsx)(`button`,{onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700`,children:`Reload Page`})]})})}return ge||ne||be||Se?(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,H.jsxs)(`div`,{className:`text-center`,children:[(0,H.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-yellow-400 mx-auto mb-4`}),(0,H.jsx)(`p`,{className:`text-gray-300`,children:`Loading AgentDeck...`})]})}):(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col overflow-x-hidden`,onDrop:pe,onDragOver:e=>e.preventDefault(),style:{position:`relative`,...me&&{background:`linear-gradient(to bottom right, #1a1a2e, #16213e, #0f3460)`}},children:[(0,H.jsx)(`header`,{className:`relative z-20 shrink-0 bg-black/30 backdrop-blur-md border-b border-white/10`,"data-testid":`top-bar`,children:(0,H.jsx)(`div`,{className:`container mx-auto px-4 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`img`,{src:Ek,alt:`Agent Deck Logo`,className:`h-9 w-9 shrink-0 object-contain`}),(0,H.jsx)(`h1`,{className:`whitespace-nowrap text-xl font-bold bg-gradient-to-r from-yellow-400 to-yellow-600 bg-clip-text text-transparent`,style:{background:`linear-gradient(to right, #C4B643, #D4C760)`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`},children:`AgentDeck`}),(0,H.jsx)(`p`,{className:`sr-only`,children:`Build tool deck for your agent`})]}),(0,H.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 overflow-x-auto -my-1 py-1 sm:gap-3`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-2 whitespace-nowrap rounded-full border px-3 text-sm ${P===`connected`?`bg-emerald-500/20 border-emerald-500/30`:`bg-red-500/20 border-red-500/30`}`,"data-testid":`button-copy-mcp-url`,onClick:()=>{Tk(N)},title:`Click to copy MCP URL`,children:[(0,H.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full animate-pulse ${P===`connected`?`bg-emerald-400`:`bg-red-400`}`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`font-ui-display hover:underline ${P===`connected`?`text-emerald-300`:`text-red-300`}`,children:`Get MCP URL`})]}),(0,H.jsx)(Km,{highlightDeckId:re??void 0}),L?.data.hosted&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ye,{href:`/grants`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(Vi,{className:`mr-2 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Grants`})]})}),(0,H.jsx)(ye,{href:`/audit`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(Ri,{className:`mr-2 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Audit`})]})})]}),(0,H.jsx)(ye,{href:`/feedback-signals`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Feedback`}),I>0&&(0,H.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Open feedback available for curation`,children:I})]})}),(0,H.jsx)(ye,{href:`/playbook-patches`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(ki,{className:`mr-2 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Review`}),F.length>0&&(0,H.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Proposed playbook patches`,children:F.length})]})})]})]})})}),me&&(0,H.jsx)(`div`,{className:`fixed inset-0 pointer-events-none z-50 flex items-center justify-center`,children:(0,H.jsxs)(`div`,{className:`bg-red-500/20 border-2 border-dashed border-red-500/50 rounded-lg p-8 text-center`,children:[(0,H.jsx)(`div`,{className:`text-red-400 text-lg font-bold mb-2`,children:`Drop to Remove`}),(0,H.jsx)(`div`,{className:`text-red-300 text-sm`,children:`Release to remove card from deck`})]})}),(0,H.jsx)(`main`,{className:`container mx-auto flex min-h-0 flex-1 flex-col px-4 py-4 sm:py-6`,children:(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 sm:gap-6 xl:min-h-0 xl:flex-1 xl:grid-cols-4 xl:overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 space-y-4 sm:space-y-6 xl:col-span-1 xl:min-h-0 xl:overflow-y-auto`,children:[(0,H.jsx)(`div`,{className:`panel-surface h-64 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:(0,H.jsx)(Qh,{decks:z,editingDeckId:re,onSelectDeck:se,isLoading:ne})}),(0,H.jsxs)(`div`,{className:`panel-surface p-4`,children:[(0,H.jsxs)(`h2`,{className:`text-lg font-bold mb-3 flex items-center`,children:[(0,H.jsx)(ui,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,H.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`Add Cards`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(K,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Kl}`,style:Jl(Ul),onClick:()=>l(!0),"data-testid":`button-register-mcp`,children:[(0,H.jsx)(Bi,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,H.jsxs)(K,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Kl}`,style:Jl(Wl),onClick:()=>h(!0),"data-testid":`button-register-api-key`,children:[(0,H.jsx)(Ai,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]}),(0,H.jsxs)(K,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Kl}`,style:Jl(Gl),onClick:()=>S(!0),"data-testid":`button-register-playbook`,children:[(0,H.jsx)(di,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register Playbook`})]})]})]})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 sm:gap-6 xl:col-span-3 xl:h-full xl:min-h-0`,children:[(0,H.jsx)(`div`,{className:`panel-surface h-64 shrink-0 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:B?(0,H.jsx)(`div`,{className:`h-full`,children:(0,H.jsx)(tm,{deck:B,services:Be,credentials:B.credentials??[],playbooks:Ve,allServices:Ee,collectionWarnings:ke,onDrop:fe,onDragStart:ce,onCredentialDragStart:le,onPlaybookDragStart:ue,onDragEnd:de,onCardClick:He,onPlaybookClick:Ue,onCredentialClick:We,onInstructionsDirtyChange:oe})}):(0,H.jsxs)(`div`,{className:`text-center h-full flex flex-col justify-center`,children:[(0,H.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-yellow-500/20 border border-yellow-500/30 flex items-center justify-center mx-auto mb-3`,children:(0,H.jsx)(Mi,{className:`w-6 h-6 text-yellow-400`})}),(0,H.jsx)(`h3`,{className:`text-lg font-bold mb-2`,style:{color:`#92E4DD`},children:`No deck selected`}),(0,H.jsx)(`p`,{className:`text-gray-300 mb-4 text-sm`,children:`Create a deck or select one from the sidebar to edit its cards.`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(K,{onClick:()=>{let e=document.querySelector(`[data-testid="create-deck-button"]`);e&&e.click()},className:`border text-sm py-2`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},children:[(0,H.jsx)(Ii,{className:`w-4 h-4 mr-2`}),`Create New Deck`]}),(0,H.jsxs)(K,{variant:`outline`,className:`border-white/20 text-white hover:bg-white/10 text-sm py-2`,onClick:()=>{let e=document.querySelector(`[data-testid="deck-management-panel"]`);e&&e.scrollIntoView({behavior:`smooth`})},children:[(0,H.jsx)(Mi,{className:`w-4 h-4 mr-2`}),`Manage Decks`]})]})]})}),(0,H.jsxs)(`div`,{className:`panel-surface flex min-h-[20rem] flex-col overflow-hidden p-4 min-w-0 sm:min-h-[24rem] xl:min-h-0 xl:flex-1`,"data-testid":`collection-panel`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,H.jsxs)(`h2`,{className:`text-lg font-bold flex items-center`,children:[(0,H.jsx)(Ni,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,H.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`My Collection`}),(0,H.jsxs)(`span`,{className:`ml-3 text-sm font-normal text-gray-400`,children:[`(`,Fe,` cards)`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:ee,disabled:k,title:`Export all MCP, playbooks, and decks`,"data-testid":`button-export-all`,children:[(0,H.jsx)(Ti,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:k?`Exporting…`:`Export all`})]}),(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:()=>O(!0),title:`Import a bundle file`,"data-testid":`button-import-bundle`,children:[(0,H.jsx)(Ji,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Import`})]}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(zi,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4`}),(0,H.jsx)(Eu,{placeholder:`Search...`,value:e,onChange:e=>t(e.target.value),className:`h-8 w-36 pl-8 text-sm bg-white/10 border-white/20 text-white placeholder-gray-400 sm:w-48`,"data-testid":`input-search`})]}),(0,H.jsxs)(mk,{value:n||`all`,onValueChange:e=>r(e===`all`?``:e),children:[(0,H.jsxs)(gk,{className:`w-[7.5rem] h-8 bg-white/10 border-white/20 text-white text-xs shrink-0`,"data-testid":`select-type`,children:[(0,H.jsx)(Oi,{className:`w-3 h-3 mr-1 shrink-0`}),(0,H.jsx)(hk,{placeholder:`Type`})]}),(0,H.jsxs)(yk,{children:[(0,H.jsx)(xk,{value:`all`,children:`All`}),(0,H.jsx)(xk,{value:`mcp`,children:`MCP`}),(0,H.jsx)(xk,{value:`local-mcp`,children:`Local MCP`}),(0,H.jsx)(xk,{value:`api-key`,children:`API Key`}),(0,H.jsx)(xk,{value:`playbook`,children:`Playbook`})]})]}),(0,H.jsxs)(mk,{value:Ae?o:`default`,onValueChange:e=>s(e),disabled:!Ae,children:[(0,H.jsxs)(gk,{className:`w-[7.5rem] h-8 bg-white/10 border-white/20 text-white text-xs shrink-0`,"data-testid":`select-sort`,title:Ae?`Sort collection by 30-day use`:`Usage data unavailable — showing Default order`,"aria-label":`Sort collection`,children:[(0,H.jsx)(li,{className:`w-3 h-3 mr-1 shrink-0`}),(0,H.jsx)(hk,{placeholder:`Sort`})]}),(0,H.jsxs)(yk,{children:[(0,H.jsx)(xk,{value:`default`,children:`Default`}),(0,H.jsx)(xk,{value:`most-used`,children:`Most used`}),(0,H.jsx)(xk,{value:`least-used`,children:`Least used`})]})]}),(e||n||i)&&(0,H.jsx)(K,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:Ie,title:`Clear all filters`,children:`Clear`})]})]}),ke.total>0&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`mb-3 w-full shrink-0 rounded-lg border px-3 py-2 text-left text-sm transition-colors ${i?`border-amber-300/60 bg-amber-500/15 text-amber-100`:`border-amber-400/30 bg-amber-500/10 text-amber-100 hover:bg-amber-500/15`}`,"data-testid":`button-collection-warnings`,children:(0,H.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(qi,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-300`}),(0,H.jsx)(`span`,{children:i?(0,H.jsxs)(H.Fragment,{children:[`Showing `,(0,H.jsx)(`strong`,{children:Fe}),` card`,Fe===1?``:`s`,` needing attention.`,(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:` Click to show all cards.`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`strong`,{children:ke.total}),` card`,ke.total===1?``:`s`,` need attention`,ke.byKind.oauth_expired+ke.byKind.oauth_required>0&&(0,H.jsxs)(H.Fragment,{children:[` `,`(`,ke.byKind.oauth_expired+ke.byKind.oauth_required,` `,`OAuth)`]}),`. `,(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:`Click to filter.`})]})})]})}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-1 py-2`,children:ge||be||Se?(0,H.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,children:Array.from({length:10}).map((e,t)=>(0,H.jsx)(`div`,{className:`animate-pulse`,children:(0,H.jsx)(`div`,{className:`bg-white/10 rounded-lg w-32 h-48 aspect-[2/3]`})},t))}):Fe===0?(0,H.jsxs)(`div`,{className:`text-center py-12`,children:[(0,H.jsx)(`div`,{className:`text-gray-400 mb-4`,children:(0,H.jsx)(`i`,{className:`fas fa-layer-group text-4xl`})}),(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-300 mb-2`,children:`No cards yet`}),(0,H.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:Le?i?`No cards with warnings match your current filters`:`Try adjusting your search or filters`:`Register an MCP server, API key, or playbook to get started`}),!Le&&(0,H.jsxs)(`div`,{className:`flex gap-3 justify-center`,children:[(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Jl(`#92E4DD`),onClick:()=>l(!0),"data-testid":`button-register-mcp-empty`,children:[(0,H.jsx)(Bi,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Jl(`#F9386D`),onClick:()=>h(!0),"data-testid":`button-register-api-key-empty`,children:[(0,H.jsx)(Ai,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]})]})]}):(0,H.jsx)(`div`,{className:`relative isolate grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,style:{isolation:`isolate`},"data-testid":`collection-card-grid`,children:V.map((e,t)=>{let{playbook:n,credential:r,service:i}=e;return(0,H.jsxs)(`div`,{className:`relative group`,style:{zIndex:j===e.id?999999:Fe-t},children:[e.kind===`playbook`&&n?(0,H.jsx)(du,{playbook:n,isInActiveDeck:ze.has(n.id),activeDeck:B??void 0,isInCollection:!0,onDragStart:ue,onDragEnd:de,onCardClick:Ue,onMouseEnter:()=>Ge(n.id),onMouseLeave:()=>Ge(null),warnings:ke.playbookWarnings.get(n.id),usage:Te.get(Ll(`playbook`,n.id))}):null,e.kind===`credential`&&r?(0,H.jsx)(lu,{credential:r,isInActiveDeck:Re.has(r.id),activeDeck:B??void 0,isInCollection:!0,onDragStart:le,onDragEnd:de,onMouseEnter:()=>Ge(r.id),onMouseLeave:()=>Ge(null),onCardClick:We,warnings:ke.credentialWarnings.get(r.id),usage:Te.get(Ll(`credential`,r.id))}):null,e.kind===`service`&&i?(0,H.jsx)(au,{service:i,onDragStart:ce,onDragEnd:de,isInActiveDeck:B?.services?.some(e=>e.id===i.id)||!1,onCardClick:He,isInCollection:!0,onMouseEnter:()=>Ge(i.id),onMouseLeave:()=>Ge(null),activeDeck:B??void 0,warnings:ke.serviceWarnings.get(i.id),usage:Te.get(Ll(`service`,i.id))}):null]},`${e.kind}:${e.id}`)})})})]})]})]})}),(0,H.jsx)(`footer`,{className:`shrink-0 border-t border-white/5 py-2 text-center text-xs text-gray-500`,"data-testid":`deck-dealer-note`,children:jk}),(0,H.jsxs)(`div`,{className:`fixed inset-0 pointer-events-none z-0 overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`absolute top-20 left-20`,children:(0,H.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-cyan-500/10 blur-3xl animate-orb-drift-1`})}),(0,H.jsx)(`div`,{className:`absolute bottom-20 right-20`,children:(0,H.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-pink-500/10 blur-3xl animate-orb-drift-2`})}),(0,H.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2`,children:(0,H.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-purple-500/5 blur-3xl animate-orb-drift-3`})})]}),(0,H.jsx)(Gh,{type:`mcp`,open:c,onOpenChange:l}),(0,H.jsx)(MD,{service:u,isOpen:f,onClose:()=>p(!1)}),(0,H.jsx)($h,{open:m,onOpenChange:h}),(0,H.jsx)(_g,{credentialId:g,open:v,onOpenChange:y}),(0,H.jsx)(eg,{open:x,onOpenChange:S}),(0,H.jsx)(gg,{playbookId:C,open:T,onOpenChange:E}),(0,H.jsx)(ND,{open:D,onOpenChange:O})]})}var Lk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));Lk.displayName=`Card`;var Rk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`flex flex-col space-y-1.5 p-6`,e),...t}));Rk.displayName=`CardHeader`;var zk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));zk.displayName=`CardTitle`;var Bk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`text-sm text-muted-foreground`,e),...t}));Bk.displayName=`CardDescription`;var Vk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`p-6 pt-0`,e),...t}));Vk.displayName=`CardContent`;var Hk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`flex items-center p-6 pt-0`,e),...t}));Hk.displayName=`CardFooter`;function Uk(){return(0,H.jsx)(`div`,{className:`min-h-screen w-full flex items-center justify-center bg-gray-50`,children:(0,H.jsx)(Lk,{className:`w-full max-w-md mx-4`,children:(0,H.jsxs)(Vk,{className:`pt-6`,children:[(0,H.jsxs)(`div`,{className:`flex mb-4 gap-2`,children:[(0,H.jsx)(yi,{className:`h-8 w-8 text-red-500`}),(0,H.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`404 Page Not Found`})]}),(0,H.jsx)(`p`,{className:`mt-4 text-sm text-gray-600`,children:`Did you forget to add the page to the router?`})]})})})}function Wk(){let[e]=pe(),[t,n]=(0,b.useState)(`loading`),[r,i]=(0,b.useState)(`Authenticating...`);return(0,b.useEffect)(()=>{(async()=>{try{let e=new URL(window.location.href),t=e.searchParams.get(`success`),r=e.searchParams.get(`error`),a=e.searchParams.get(`serviceId`);t===`true`?(n(`success`),i(`Authentication successful! This window will close automatically.`),window.opener&&!window.opener.closed&&window.opener.postMessage({type:SD,serviceId:a??void 0},window.location.origin),setTimeout(()=>{window.close()},2e3)):t===`false`?(n(`error`),i(`OAuth Error: ${r||`Authentication failed`}`)):(n(`error`),i(`Invalid OAuth callback - please try again`))}catch(e){n(`error`),i(e instanceof Error?e.message:`Authentication failed`)}})()},[e]),(0,H.jsx)(`div`,{className:`flex items-center justify-center min-h-screen bg-background`,children:(0,H.jsxs)(`div`,{className:`text-center space-y-4`,children:[t===`loading`&&(0,H.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),t===`success`&&(0,H.jsx)(`div`,{className:`text-green-500 text-4xl`,children:`✓`}),t===`error`&&(0,H.jsx)(`div`,{className:`text-red-500 text-4xl`,children:`✗`}),(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:r}),t===`error`&&(0,H.jsx)(`button`,{onClick:()=>window.close(),className:`px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90`,children:`Close Window`})]})})}function Gk(e){let t=()=>{throw Error(`Invalid url to pass to open(): ${e}`)},n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(Kk).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}function Kk([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}var qk=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`MCP Browser Client`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.callbackUrl=Gk(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.onPopupWindow=t.onPopupWindow}get redirectUrl(){return Gk(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`))}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e)}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=crypto.randomUUID(),n=`${this.storageKeyPrefix}:state_${t}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+6e5,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl}};localStorage.setItem(n,JSON.stringify(r)),e.searchParams.set(`state`,t);let i=Gk(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),i),i}async redirectToAuthorization(e){if(this.preventAutoAuth)return;let t=await this.prepareAuthorizationUrl(e),n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?Gk(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}},Jk=Object.freeze({status:`aborted`});function J(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Yk=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Xk={};function Zk(e){return e&&Object.assign(Xk,e),Xk}function Qk(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function $k(e,t){return typeof t==`bigint`?t.toString():t}function eA(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function tA(e){return e==null}function nA(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function rA(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function iA(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function aA(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function oA(e){return JSON.stringify(e)}var sA=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function cA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var lA=eA(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function uA(e){if(cA(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return cA(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}var dA=new Set([`string`,`number`,`symbol`]);function fA(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function pA(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function mA(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var hA={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function gA(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return pA(e,{...e._zod.def,shape:n,checks:[]})}function _A(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return pA(e,{...e._zod.def,shape:n,checks:[]})}function vA(e,t){if(!uA(t))throw Error(`Invalid input to extend: expected a plain object`);return pA(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return aA(this,`shape`,n),n},checks:[]})}function yA(e,t){return pA(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return aA(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function bA(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return pA(t,{...t._zod.def,shape:i,checks:[]})}function xA(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return pA(t,{...t._zod.def,shape:i,checks:[]})}function SA(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function CA(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function wA(e){return typeof e==`string`?e:e?.message}function TA(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=wA(e.inst?._zod.def?.error?.(e))??wA(t?.error?.(e))??wA(n.customError?.(e))??wA(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function EA(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function DA(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var OA=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,$k,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},kA=J(`$ZodError`,OA),AA=J(`$ZodError`,OA,{Parent:Error});function jA(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function MA(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var NA=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Yk;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>TA(e,a,Zk())));throw sA(t,i?.callee),t}return o.value},PA=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>TA(e,a,Zk())));throw sA(t,i?.callee),t}return o.value},FA=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Yk;return a.issues.length?{success:!1,error:new(e??kA)(a.issues.map(e=>TA(e,i,Zk())))}:{success:!0,data:a.value}},IA=FA(AA),LA=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>TA(e,i,Zk())))}:{success:!0,data:a.value}},RA=LA(AA),zA=/^[cC][^\s-]{8,}$/,BA=/^[0-9a-z]+$/,VA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,HA=/^[0-9a-vA-V]{20}$/,UA=/^[A-Za-z0-9]{27}$/,WA=/^[a-zA-Z0-9_-]{21}$/,GA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,KA=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,qA=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,JA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,YA=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function XA(){return new RegExp(YA,`u`)}var ZA=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,QA=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,$A=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ej=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tj=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,nj=/^[A-Za-z0-9_-]*$/,rj=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,ij=/^\+(?:[0-9]){6,14}[0-9]$/,aj=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,oj=RegExp(`^${aj}$`);function sj(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function cj(e){return RegExp(`^${sj(e)}$`)}function lj(e){let t=sj({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${aj}T(?:${r})$`)}var uj=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},dj=/^\d+$/,fj=/^-?\d+(?:\.\d+)?/i,pj=/true|false/i,mj=/null/i,hj=/^[^A-Z]*$/,gj=/^[^a-z]*$/,_j=J(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),vj={number:`number`,bigint:`bigint`,object:`date`},yj=J(`$ZodCheckLessThan`,(e,t)=>{_j.init(e,t);let n=vj[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bj=J(`$ZodCheckGreaterThan`,(e,t)=>{_j.init(e,t);let n=vj[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xj=J(`$ZodCheckMultipleOf`,(e,t)=>{_j.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):rA(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Sj=J(`$ZodCheckNumberFormat`,(e,t)=>{_j.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=hA[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=dj)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Cj=J(`$ZodCheckMaxLength`,(e,t)=>{var n;_j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!tA(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=EA(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wj=J(`$ZodCheckMinLength`,(e,t)=>{var n;_j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!tA(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=EA(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Tj=J(`$ZodCheckLengthEquals`,(e,t)=>{var n;_j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!tA(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=EA(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ej=J(`$ZodCheckStringFormat`,(e,t)=>{var n,r;_j.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Dj=J(`$ZodCheckRegex`,(e,t)=>{Ej.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Oj=J(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=hj,Ej.init(e,t)}),kj=J(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=gj,Ej.init(e,t)}),Aj=J(`$ZodCheckIncludes`,(e,t)=>{_j.init(e,t);let n=fA(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),jj=J(`$ZodCheckStartsWith`,(e,t)=>{_j.init(e,t);let n=RegExp(`^${fA(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Mj=J(`$ZodCheckEndsWith`,(e,t)=>{_j.init(e,t);let n=RegExp(`.*${fA(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Nj=J(`$ZodCheckOverwrite`,(e,t)=>{_j.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Pj=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
205
|
+
${F.data.oauth.issuer?`Issuer: ${F.data.oauth.issuer}`:``}`;A({title:`OAuth Setup Instructions`,description:e,duration:1e4})},children:`📋 Setup Instructions`})]})]}),(0,H.jsxs)(`div`,{className:`mt-2 text-xs`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`💡 Next Steps:`})}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,H.jsx)(`li`,{children:`For OAuth servers: Provide OAuth credentials in service settings`}),(0,H.jsx)(`li`,{children:`For SSE servers: We'll automatically use the correct protocol`}),(0,H.jsx)(`li`,{children:`For connection issues: Verify the server URL and status`})]})]})]}),L&&(0,H.jsxs)(`div`,{className:`mt-3 p-3 bg-red-500/20 rounded`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`❌ Discovery Failed`})}),(0,H.jsx)(`p`,{children:`Could not analyze MCP server configuration`}),(0,H.jsx)(`pre`,{className:`text-xs overflow-x-auto`,children:L instanceof Error?L.message:String(L)})]})]})]}),!de&&!ie&&!ce&&e.type===`a2a`&&!ue&&(0,H.jsxs)(`div`,{className:`bg-yellow-500/20 border border-yellow-500/30 rounded-lg p-4`,children:[(0,H.jsx)(`h3`,{className:`text-yellow-300 font-semibold mb-2`,children:`Agent Details Not Available`}),(0,H.jsxs)(`p`,{className:`text-yellow-200 text-sm`,children:[`Successfully connected to A2A agent at `,M?.url,`, but no manifest was found.`]}),(0,H.jsxs)(`div`,{className:`text-yellow-200 text-xs mt-2`,children:[(0,H.jsx)(`p`,{children:(0,H.jsx)(`strong`,{children:`This could mean:`})}),(0,H.jsxs)(`ul`,{className:`list-disc list-inside ml-2 space-y-1`,children:[(0,H.jsx)(`li`,{children:`The agent doesn't provide a manifest`}),(0,H.jsx)(`li`,{children:`Manifest endpoint is not implemented`}),(0,H.jsx)(`li`,{children:`Agent requires specific authentication`})]})]})]})]})]})})}function PD({open:e,onOpenChange:t}){let[n,r]=(0,b.useState)(null),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(!1),u=Tt(),{toast:d}=an(),f=()=>{r(null),a(null),s(null),l(!1)},p=Vt({mutationFn:async()=>{if(!n)throw Error(`Choose a bundle file first`);let e=await n.text(),t;try{t=JSON.parse(e)}catch{throw Error(`File is not valid JSON`)}return Yh(t)},onSuccess:e=>{s(e),u.invalidateQueries({queryKey:[`/api/decks`]}),u.invalidateQueries({queryKey:[`/api/services`]}),u.invalidateQueries({queryKey:[`/api/playbooks`]}),u.invalidateQueries({queryKey:[`/api/playbooks/collection`]}),u.invalidateQueries({queryKey:[`/api/credentials/collection`]}),u.invalidateQueries({queryKey:[`/api/collection/warnings`]}),d({title:`Import complete`,description:Qh(e)})},onError:e=>{d({title:`Import failed`,description:e.message,variant:`destructive`})}}),m=async e=>{if(r(e),s(null),!e){a(null);return}try{let t=await e.text(),n=JSON.parse(t);a(`${n.services?.length??0} services · ${n.playbooks?.length??0} playbooks · ${n.decks?.length??0} decks`)}catch{a(`Invalid JSON`)}};return(0,H.jsx)(Vp,{open:e,onOpenChange:e=>{e||f(),t(e)},children:(0,H.jsxs)(Wp,{className:`sm:max-w-lg border-border bg-[#161612] text-[#E8F6F4]`,children:[(0,H.jsxs)(Gp,{children:[(0,H.jsx)(qp,{children:`Import bundle`}),(0,H.jsx)(Jp,{asChild:!0,children:(0,H.jsxs)(`div`,{className:`space-y-2 text-left text-sm text-[#A8C4C0]`,children:[(0,H.jsx)(`p`,{children:`Adds MCP, playbooks, and decks from a JSON file.`}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`font-medium text-amber-200/90`,children:`Notes`}),(0,H.jsxs)(`ul`,{className:`mt-1 list-disc space-y-0.5 pl-4`,children:[(0,H.jsx)(`li`,{children:`Same name as an existing card or deck is skipped (linked only).`}),(0,H.jsx)(`li`,{children:`No credentials or secrets — re-enter keys and reconnect OAuth.`})]})]})]})})]}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`bundle-file`,children:`Bundle file`}),(0,H.jsx)(Eu,{id:`bundle-file`,type:`file`,accept:`.json,.agent-deck.json,application/json`,className:`cursor-pointer bg-white/5 border-white/20`,onChange:e=>m(e.target.files?.[0]??null),"data-testid":`input-import-bundle`}),i&&(0,H.jsx)(`p`,{className:`text-xs text-[#A8C4C0]`,"data-testid":`import-preview`,children:i})]}),!o&&(0,H.jsx)(K,{onClick:()=>p.mutate(),disabled:!n||p.isPending||i===`Invalid JSON`,className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},"data-testid":`button-import-apply`,children:p.isPending?`Importing…`:`Import`}),o&&(0,H.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-white/10 bg-white/5 p-3 text-sm`,"data-testid":`import-report`,children:[(0,H.jsx)(`p`,{className:`font-medium`,children:Qh(o)}),o.servicesNeedingOauth.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-amber-200`,children:`Needs OAuth reconnect:`}),(0,H.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.servicesNeedingOauth.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),o.warnings.length>0&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`p`,{className:`text-amber-200`,children:`Warnings:`}),(0,H.jsx)(`ul`,{className:`list-disc pl-5 text-[#A8C4C0]`,children:o.warnings.map(e=>(0,H.jsx)(`li`,{children:e},e))})]}),(0,H.jsx)(K,{variant:`outline`,size:`sm`,className:`rounded-full border border-white/20 text-white hover:bg-white/10`,onClick:()=>l(e=>!e),children:c?`Hide id map`:`Show id map`}),c&&(0,H.jsx)(`pre`,{className:`max-h-40 overflow-auto rounded bg-black/40 p-2 text-xs`,children:JSON.stringify(o.idMap,null,2)}),(0,H.jsx)(K,{className:`rounded-full border px-6 text-sm font-semibold hover:opacity-90`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},onClick:()=>{f(),t(!1)},children:`Done`})]})]})]})})}function FD(){let[e,t]=(0,b.useState)(`connecting`),[n,r]=(0,b.useState)(null),i=(0,b.useRef)(null),a=(0,b.useRef)(null),o=Tt();return(0,b.useEffect)(()=>{let e=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/api/ws/events`,n=()=>{try{let s=new WebSocket(e);i.current=s,s.onopen=()=>{console.log(`WebSocket connected`),t(`connected`)},s.onmessage=e=>{try{let n=JSON.parse(e.data);r(n),n.type===`deck_update`?(console.log(`Received deck update:`,n),o.invalidateQueries({queryKey:[`/api/decks`]})):n.type===`service_update`?(console.log(`Received service update:`,n),SD(o,typeof n.data?.serviceId==`string`?n.data.serviceId:void 0)):n.type===`connection_status`&&t(n.status===`connected`?`connected`:`disconnected`)}catch(e){console.error(`Failed to parse WebSocket message:`,e)}},s.onclose=()=>{console.log(`WebSocket disconnected`),t(`disconnected`),a.current=setTimeout(()=>{console.log(`Attempting to reconnect WebSocket...`),t(`connecting`),n()},3e3)},s.onerror=e=>{console.error(`WebSocket error:`,e),t(`disconnected`)}}catch(e){console.error(`Failed to connect WebSocket:`,e),t(`disconnected`)}};n();let s=e=>{e.origin===window.location.origin&&wD(e.data)&&SD(o,e.data.serviceId)};return window.addEventListener(`message`,s),()=>{window.removeEventListener(`message`,s),a.current&&clearTimeout(a.current),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.close()}},[o]),{connectionStatus:e,lastMessage:n}}async function ID(e,t){return(await(await U(`GET`,`/api/playbooks/dependents/check?${e===`credential`?`credentialId=${encodeURIComponent(t)}`:`serviceId=${encodeURIComponent(t)}`}`)).json()).data??[]}function LD(e){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),l=Tt(),{toast:u}=an(),d=()=>{if(!e)throw Error(`Select a deck to edit first`);return e},f=Vt({mutationFn:async e=>{let t=d(),n=(await(await U(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t);if(!n)throw Error(`Selected deck not found`);if(n.services?.some(t=>t.id===e))throw Error(`Service is already in the deck`);let r=n.services?.length??0;return U(`POST`,`/api/decks/${t}/services`,{serviceId:e,position:r})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service added to deck`,description:`${t?.name||`Service`} has been added to the deck.`})},onError:e=>{u({title:`Failed to add service`,description:e.message,variant:`destructive`})}}),p=Vt({mutationFn:async e=>{let t=d();if(((await(await U(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.credentials?.some(t=>t.id===e))throw Error(`API key is already in the deck`);return U(`POST`,`/api/decks/${t}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key added to deck`,description:`${r?.label||`API key`} is scoped to this deck.`})},onError:e=>{u({title:`Failed to add API key`,description:e.message,variant:`destructive`})}}),m=Vt({mutationFn:async e=>{let t=d();if(((await(await U(`GET`,`/api/decks`)).json()).data?.find(e=>e.id===t))?.playbooks?.some(t=>t.id===e))throw Error(`Playbook is already in the deck`);return U(`POST`,`/api/decks/${t}/playbooks`,{playbookId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook added to deck`,description:`${a?.title||`Playbook`} is on this deck.`})},onError:e=>{u({title:`Failed to add playbook`,description:e.message,variant:`destructive`})}}),h=Vt({mutationFn:async e=>{let t=await ID(`service`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this MCP (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return U(`DELETE`,`/api/decks/${d()}/services`,{serviceId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Service removed from deck`,description:`${t?.name||`Service`} has been removed from the deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove service`,description:e.message,variant:`destructive`})}}),g=Vt({mutationFn:async e=>{let t=await ID(`credential`,e);if(t.length>0){let e=t.map(e=>e.title).join(`, `);if(!window.confirm(`Warning: ${t.length} playbook(s) depend on this API key (${e}). Remove from deck anyway?`))throw Error(`Cancelled`)}return U(`DELETE`,`/api/decks/${d()}/credentials`,{credentialId:e})},onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`API key removed from deck`,description:`${r?.label||`API key`} is no longer on this deck.`})},onError:e=>{e.message!==`Cancelled`&&u({title:`Failed to remove API key`,description:e.message,variant:`destructive`})}}),_=Vt({mutationFn:async e=>U(`DELETE`,`/api/decks/${d()}/playbooks`,{playbookId:e}),onSuccess:()=>{l.invalidateQueries({queryKey:[`/api/decks`]}),u({title:`Playbook removed from deck`,description:`${a?.title||`Playbook`} is no longer on this deck.`})},onError:e=>{u({title:`Failed to remove playbook`,description:e.message,variant:`destructive`})}}),v=(e,t)=>{e.currentTarget instanceof HTMLElement&&(e.currentTarget.style.opacity=t)},y=(e,t)=>{e.dataTransfer.setData(`text/plain`,t.id),e.dataTransfer.setData(`application/json`,JSON.stringify(t)),e.dataTransfer.effectAllowed=t.fromDeck?`move`:`copy`},x=(e,t,r=!1)=>{n(t),i(null),o(null),c(r),y(e,{kind:`service`,id:t.id,fromDeck:r}),v(e,`0.5`)},S=(e,t,r=!1)=>{i(t),n(null),o(null),c(r),y(e,{kind:`credential`,id:t.id,fromDeck:r}),v(e,`0.5`)},C=(e,t,r=!1)=>{o(t),n(null),i(null),c(r),y(e,{kind:`playbook`,id:t.id,fromDeck:r}),v(e,`0.5`)},w=e=>{n(null),i(null),o(null),v(e,`1`)},T=e=>{if(e.kind===`service`){e.fromDeck?h.mutate(e.id):f.mutate(e.id);return}if(e.kind===`credential`){e.fromDeck?g.mutate(e.id):p.mutate(e.id);return}e.fromDeck?_.mutate(e.id):m.mutate(e.id)};return{draggedService:t,draggedCredential:r,draggedPlaybook:a,isDraggingFromDeck:s,handleDragStart:x,handleCredentialDragStart:S,handlePlaybookDragStart:C,handleDragEnd:w,handleDrop:e=>{e.preventDefault();let r=e.dataTransfer.getData(`application/json`);if(r){try{T(JSON.parse(r))}catch{let n=e.dataTransfer.getData(`text/plain`);n&&t&&f.mutate(n)}n(null),i(null),o(null),c(!1)}},handleGlobalDrop:e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/json`);if(t){try{let e=JSON.parse(t);e.fromDeck&&T(e)}catch{}n(null),i(null),o(null),c(!1)}},isDropping:f.isPending||p.isPending||m.isPending||h.isPending||g.isPending||_.isPending}}var RD=`agent-deck-editing-deck-id`;function zD(e){let[t,n]=(0,b.useState)(()=>typeof window>`u`?null:localStorage.getItem(RD));return(0,b.useEffect)(()=>{if(e.length!==0&&!(t&&e.some(e=>e.id===t))){let t=e[0].id;n(t),localStorage.setItem(RD,t)}},[e,t]),{editingDeck:e.find(e=>e.id===t)??null,editingDeckId:t,setEditingDeckId:e=>{n(e),localStorage.setItem(RD,e)}}}function BD(e,[t,n]){return Math.min(n,Math.max(t,e))}function VD(e){let t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var HD=[` `,`Enter`,`ArrowUp`,`ArrowDown`],UD=[` `,`Enter`],WD=`Select`,[GD,KD,qD]=xn(WD),[JD,YD]=dn(WD,[qD,jc]),XD=jc(),[ZD,QD]=JD(WD),[$D,eO]=JD(WD),tO=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=XD(t),[g,_]=b.useState(null),[v,y]=b.useState(null),[x,S]=b.useState(!1),C=Ym(l),[w,T]=Xn({prop:r,defaultProp:i??!1,onChange:a,caller:WD}),[E,D]=Xn({prop:o,defaultProp:s,onChange:c,caller:WD}),O=b.useRef(null),k=!g||m||!!g.closest(`form`),[A,j]=b.useState(new Set),M=Array.from(A).map(e=>e.props.value).join(`;`);return(0,H.jsx)(qc,{...h,children:(0,H.jsxs)(ZD,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:oo(),value:E,onValueChange:D,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:O,disabled:f,children:[(0,H.jsx)(GD.Provider,{scope:t,children:(0,H.jsx)($D,{scope:e.__scopeSelect,onNativeOptionAdd:b.useCallback(e=>{j(t=>new Set(t).add(e))},[]),onNativeOptionRemove:b.useCallback(e=>{j(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),k?(0,H.jsxs)(XO,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:E,onChange:e=>D(e.target.value),disabled:f,form:m,children:[E===void 0?(0,H.jsx)(`option`,{value:``}):null,Array.from(A)]},M):null]})})};tO.displayName=WD;var nO=`SelectTrigger`,rO=b.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=XD(n),o=QD(nO,n),s=o.disabled||r,c=ln(t,o.onTriggerChange),l=KD(n),u=b.useRef(`touch`),[d,f,p]=QO(e=>{let t=l().filter(e=>!e.disabled),n=$O(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,H.jsx)(Jc,{asChild:!0,...a,children:(0,H.jsx)(Sn.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":ZO(o.value)?``:void 0,...i,ref:c,onClick:W(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:W(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:W(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&HD.includes(e.key)&&(m(),e.preventDefault())})})})});rO.displayName=nO;var iO=`SelectValue`,aO=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=QD(iO,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=ln(t,c.onValueNodeChange);return Vn(()=>{l(u)},[l,u]),(0,H.jsx)(Sn.span,{...s,ref:d,style:{pointerEvents:`none`},children:ZO(c.value)?(0,H.jsx)(H.Fragment,{children:o}):a})});aO.displayName=iO;var oO=`SelectIcon`,sO=b.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,H.jsx)(Sn.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});sO.displayName=oO;var cO=`SelectPortal`,lO=e=>(0,H.jsx)(Un,{asChild:!0,...e});lO.displayName=cO;var uO=`SelectContent`,dO=b.forwardRef((e,t)=>{let n=QD(uO,e.__scopeSelect),[r,i]=b.useState();if(Vn(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?on.createPortal((0,H.jsx)(pO,{scope:e.__scopeSelect,children:(0,H.jsx)(GD.Slot,{scope:e.__scopeSelect,children:(0,H.jsx)(`div`,{children:e.children})})}),t):null}return(0,H.jsx)(_O,{...e,ref:t})});dO.displayName=uO;var fO=10,[pO,mO]=JD(uO),hO=`SelectContentImpl`,gO=pn(`SelectContent.RemoveScroll`),_O=b.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=QD(uO,n),[y,x]=b.useState(null),[S,C]=b.useState(null),w=ln(t,e=>x(e)),[T,E]=b.useState(null),[D,O]=b.useState(null),k=KD(n),[A,j]=b.useState(!1),M=b.useRef(!1);b.useEffect(()=>{if(y)return $f(y)},[y]),Pd();let N=b.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&S&&(S.scrollTop=0),n===r&&S&&(S.scrollTop=S.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,S]),P=b.useCallback(()=>N([T,y]),[N,T,y]);b.useEffect(()=>{A&&P()},[A,P]);let{onOpenChange:F,triggerPointerDownPosRef:I}=v;b.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(I.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(I.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||F(!1),document.removeEventListener(`pointermove`,t),I.current=null};return I.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,F,I]),b.useEffect(()=>{let e=()=>F(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[F]);let[L,ee]=QO(e=>{let t=k().filter(e=>!e.disabled),n=$O(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),te=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&(E(e),r&&(M.current=!0))},[v.value]),ne=b.useCallback(()=>y?.focus(),[y]),R=b.useCallback((e,t,n)=>{let r=!M.current&&!n;(v.value!==void 0&&v.value===t||r)&&O(e)},[v.value]),z=r===`popper`?xO:yO,B=z===xO?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,H.jsx)(pO,{scope:n,content:y,viewport:S,onViewportChange:C,itemRefCallback:te,selectedItem:T,onItemLeave:ne,itemTextRefCallback:R,focusSelectedItem:P,selectedItemText:D,position:r,isPositioned:A,searchRef:L,children:(0,H.jsx)(Wf,{as:gO,allowPinchZoom:!0,children:(0,H.jsx)(xd,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:W(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,H.jsx)(Mn,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,H.jsx)(z,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...B,onPlaced:()=>j(!0),ref:w,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:W(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ee(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>N(t)),e.preventDefault()}})})})})})})});_O.displayName=hO;var vO=`SelectItemAlignedPosition`,yO=b.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=QD(uO,n),o=mO(uO,n),[s,c]=b.useState(null),[l,u]=b.useState(null),d=ln(t,e=>u(e)),f=KD(n),p=b.useRef(!1),m=b.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=b.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-fO,d=BD(a,[fO,Math.max(fO,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-fO,d=BD(a,[fO,Math.max(fO,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-fO*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-fO,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${fO}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);Vn(()=>y(),[y]);let[x,S]=b.useState();Vn(()=>{l&&S(window.getComputedStyle(l).zIndex)},[l]);let C=b.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,H.jsx)(SO,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:(0,H.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:x},children:(0,H.jsx)(Sn.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});yO.displayName=vO;var bO=`SelectPopperPosition`,xO=b.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=fO,...a}=e,o=XD(n);return(0,H.jsx)(Yc,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});xO.displayName=bO;var[SO,CO]=JD(uO,{}),wO=`SelectViewport`,TO=b.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=mO(wO,n),o=CO(wO,n),s=ln(t,a.onViewportChange),c=b.useRef(0);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,H.jsx)(GD.Slot,{scope:n,children:(0,H.jsx)(Sn.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:W(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-fO*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});TO.displayName=wO;var EO=`SelectGroup`,[DO,OO]=JD(EO),kO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=oo();return(0,H.jsx)(DO,{scope:n,id:i,children:(0,H.jsx)(Sn.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});kO.displayName=EO;var AO=`SelectLabel`,jO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=OO(AO,n);return(0,H.jsx)(Sn.div,{id:i.id,...r,ref:t})});jO.displayName=AO;var MO=`SelectItem`,[NO,PO]=JD(MO),FO=b.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=QD(MO,n),c=mO(MO,n),l=s.value===r,[u,d]=b.useState(a??``),[f,p]=b.useState(!1),m=ln(t,e=>c.itemRefCallback?.(e,r,i)),h=oo(),g=b.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,H.jsx)(NO,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:b.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,H.jsx)(GD.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,H.jsx)(Sn.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:W(o.onFocus,()=>p(!0)),onBlur:W(o.onBlur,()=>p(!1)),onClick:W(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:W(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:W(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:W(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:W(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:W(o.onKeyDown,e=>{(c.searchRef?.current===``||e.key!==` `)&&(UD.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});FO.displayName=MO;var IO=`SelectItemText`,LO=b.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=QD(IO,n),s=mO(IO,n),c=PO(IO,n),l=eO(IO,n),[u,d]=b.useState(null),f=ln(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=b.useMemo(()=>(0,H.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return Vn(()=>(h(m),()=>g(m)),[h,g,m]),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Sn.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?on.createPortal(a.children,o.valueNode):null]})});LO.displayName=IO;var RO=`SelectItemIndicator`,zO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return PO(RO,n).isSelected?(0,H.jsx)(Sn.span,{"aria-hidden":!0,...r,ref:t}):null});zO.displayName=RO;var BO=`SelectScrollUpButton`,VO=b.forwardRef((e,t)=>{let n=mO(BO,e.__scopeSelect),r=CO(BO,e.__scopeSelect),[i,a]=b.useState(!1),o=ln(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)(WO,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});VO.displayName=BO;var HO=`SelectScrollDownButton`,UO=b.forwardRef((e,t)=>{let n=mO(HO,e.__scopeSelect),r=CO(HO,e.__scopeSelect),[i,a]=b.useState(!1),o=ln(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,H.jsx)(WO,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});UO.displayName=HO;var WO=b.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=mO(`SelectScrollButton`,n),o=b.useRef(null),s=KD(n),c=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>c(),[c]),Vn(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,H.jsx)(Sn.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:W(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:W(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:W(i.onPointerLeave,()=>{c()})})}),GO=`SelectSeparator`,KO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,H.jsx)(Sn.div,{"aria-hidden":!0,...r,ref:t})});KO.displayName=GO;var qO=`SelectArrow`,JO=b.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=XD(n),a=QD(qO,n),o=mO(qO,n);return a.open&&o.position===`popper`?(0,H.jsx)(Xc,{...i,...r,ref:t}):null});JO.displayName=qO;var YO=`SelectBubbleInput`,XO=b.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=b.useRef(null),a=ln(r,i),o=VD(t);return b.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,H.jsx)(Sn.select,{...n,style:{...$n,...n.style},ref:a,defaultValue:t})});XO.displayName=YO;function ZO(e){return e===``||e===void 0}function QO(e){let t=wn(e),n=b.useRef(``),r=b.useRef(0),i=b.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=b.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function $O(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ek(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function ek(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var tk=tO,nk=rO,rk=aO,ik=sO,ak=lO,ok=dO,sk=TO,ck=jO,lk=FO,uk=LO,dk=zO,fk=VO,pk=UO,mk=KO,hk=tk,gk=rk,_k=b.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(nk,{ref:r,className:Ja(`flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,H.jsx)(ik,{asChild:!0,children:(0,H.jsx)(hi,{className:`h-4 w-4 opacity-50`})})]}));_k.displayName=nk.displayName;var vk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(fk,{ref:n,className:Ja(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(vi,{className:`h-4 w-4`})}));vk.displayName=fk.displayName;var yk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(pk,{ref:n,className:Ja(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,H.jsx)(hi,{className:`h-4 w-4`})}));yk.displayName=pk.displayName;var bk=b.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,H.jsx)(ak,{children:(0,H.jsxs)(ok,{ref:i,className:Ja(`relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,H.jsx)(vk,{}),(0,H.jsx)(sk,{className:Ja(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t}),(0,H.jsx)(yk,{})]})}));bk.displayName=ok.displayName;var xk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(ck,{ref:n,className:Ja(`py-1.5 pl-8 pr-2 text-sm font-semibold`,e),...t}));xk.displayName=ck.displayName;var Sk=b.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(lk,{ref:r,className:Ja(`relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(dk,{children:(0,H.jsx)(mi,{className:`h-4 w-4`})})}),(0,H.jsx)(uk,{children:t})]}));Sk.displayName=lk.displayName;var Ck=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(mk,{ref:n,className:Ja(`-mx-1 my-1 h-px bg-muted`,e),...t}));Ck.displayName=mk.displayName;var wk=`/api/mcp/endpoint`;async function Tk(){let e=await fetch(wk,{credentials:`include`});if(!e.ok)throw Error(`MCP endpoint request failed: ${e.status}`);let t=(await e.json())?.data?.url;if(typeof t!=`string`||t.length===0)throw Error(`MCP endpoint response did not include a URL`);return t}async function Ek(e){try{let t=await Tk();await navigator.clipboard.writeText(t),e({title:`MCP URL copied!`,description:t})}catch(t){e({title:`Failed to copy MCP URL`,description:t instanceof Error?t.message:`Unknown error`,variant:`destructive`})}}var Dk=`/assets/AgentDeckLogo3-X5qCXS2A.png`,Ok=`agent-deck open`,kk=`agent-deck://open`;function Ak(e=document){let t=e.createElement(`iframe`);t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`tabindex`,`-1`),t.style.display=`none`,t.src=kk,e.body.appendChild(t),window.setTimeout(()=>{t.remove()},5e3)}async function jk(e=e=>navigator.clipboard.writeText(e)){try{return await e(Ok),!0}catch{return!1}}var Mk=`Agent Deck carries the method; Agent Dealer runs the issue queue.`;function Nk(){let[e,t]=(0,b.useState)(!1),{toast:n}=an();return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,H.jsxs)(`div`,{className:`text-center max-w-lg px-4`,"data-testid":`dashboard-recovery`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-bold text-gray-100 mb-4`,children:`Open your dashboard securely`}),(0,H.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`This page is Agent Deck running on your own machine — nothing is broken.`}),(0,H.jsx)(`p`,{className:`text-gray-400 text-sm mb-6`,children:`Your browser just doesn't have a launch pass yet. Agent Deck opens the dashboard with a fresh pass each time, so typing this address alone can never sign anyone in — this page can't grant access by itself.`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{Ak(),t(!0)},"data-testid":`button-open-dashboard`,className:`px-5 py-2.5 bg-blue-600 text-white rounded hover:bg-blue-700 font-medium`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(Ei,{className:`w-4 h-4`}),`Open dashboard`]})}),e&&(0,H.jsxs)(`div`,{className:`mt-6 rounded-lg border border-white/10 bg-black/30 p-4`,"data-testid":`dashboard-recovery-manual`,children:[(0,H.jsx)(`p`,{className:`text-gray-300 text-sm mb-1`,children:`If nothing opened, run this in your terminal:`}),(0,H.jsx)(`code`,{className:`mb-3 block rounded bg-black/40 px-3 py-2 text-gray-100 select-all`,children:`agent-deck open`}),(0,H.jsx)(`button`,{type:`button`,onClick:()=>{jk().then(e=>{n(e?{title:`Command copied`,description:`Run it in your terminal.`}:{title:`Copy failed`,description:`Type this in your terminal: ${Ok}`})})},"data-testid":`button-copy-open-command`,className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 text-sm`,children:(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(Ci,{className:`w-4 h-4`}),`Copy command`]})}),(0,H.jsxs)(`p`,{className:`text-gray-500 text-xs mt-3`,children:[`Then come back here and reload — or pick `,(0,H.jsx)(`strong`,{children:`Open dashboard`}),` from the Agent Deck menubar, which runs the same command.`]})]})]})})}var Pk=[],Fk=[],Ik=[];function Lk(){let[e,t]=(0,b.useState)(``),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(`default`),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(null),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(null),{toast:N}=an(),{connectionStatus:P}=FD(),{data:F=[]}=Bt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>ig(`proposed`)}),{data:I=0}=Bt({queryKey:[`/api/feedback-signals/count`,`available`],queryFn:()=>ug()}),{data:L}=Bt({queryKey:[`/api/dashboard-auth/context`]}),ee=async()=>{A(!0);try{let e=await Jh({scope:`collection`});Xh(e,`backup.agent-deck.json`),N({title:`Exported collection`,description:`${e.services.length} services, ${e.playbooks.length} playbooks, ${e.decks.length} decks`})}catch(e){N({title:`Export failed`,description:e instanceof Error?e.message:`Unknown error`,variant:`destructive`})}finally{A(!1)}},{data:te,isLoading:ne,error:R}=Bt({queryKey:[`/api/decks`]}),z=te?.data||[],{editingDeck:B,editingDeckId:re,setEditingDeckId:ie}=zD(z),[ae,oe]=(0,b.useState)(!1),se=e=>{(e===re||!ae||window.confirm(`You have unsaved deck instructions. Discard them?`))&&ie(e)},{handleDragStart:ce,handleCredentialDragStart:le,handlePlaybookDragStart:ue,handleDragEnd:de,handleDrop:fe,handleGlobalDrop:pe,isDraggingFromDeck:me}=LD(re),{data:he,isLoading:ge,error:_e}=Bt({queryKey:[`/api/services`]}),{data:ve,isLoading:be}=Bt({queryKey:[`/api/credentials/vault`]}),{data:xe,isLoading:Se}=Bt({queryKey:[`/api/playbooks/vault`]}),{data:Ce}=Bt({queryKey:[`/api/collection/warnings`],staleTime:6e4}),{data:we}=Il(),Te=(0,b.useMemo)(()=>Rl(we?.data?.cards),[we?.data?.cards]),Ee=he?.data??Pk,De=ve?.data??Fk,Oe=xe?.data??Ik,ke=(0,b.useMemo)(()=>Nl(Ce?.data),[Ce?.data]),Ae=Array.isArray(we?.data?.cards),je=(0,b.useMemo)(()=>new Map(Ee.map(e=>[e.id,e])),[Ee]),Me=(0,b.useMemo)(()=>new Map(De.map(e=>[e.id,e])),[De]),Ne=(0,b.useMemo)(()=>new Map(Oe.map(e=>[e.id,e])),[Oe]),Pe=(0,b.useMemo)(()=>Hl({services:Ee,credentials:De,playbooks:Oe},{searchQuery:e,typeFilter:n,warningsOnly:i,warnings:ke,getUsageCount:(e,t)=>Te.get(Ll(e,t))?.usageCount}).map(e=>e.kind===`playbook`?{...e,playbook:Ne.get(e.id)}:e.kind===`credential`?{...e,credential:Me.get(e.id)}:{...e,service:je.get(e.id)}),[Ee,De,Oe,e,n,i,ke,Te,je,Me,Ne]),Fe=Pe.length,V=(0,b.useMemo)(()=>Vl(Pe,o,Ae),[Pe,o,Ae]);_e&&console.error(`Services error:`,_e),R&&console.error(`Decks error:`,R);let Ie=()=>{t(``),r(``),a(!1)},Le=!!(e||n||i),Re=new Set((B?.credentials??[]).map(e=>e.id)),ze=new Set((B?.playbooks??[]).map(e=>e.id)),Be=B?.services||[],Ve=B?.playbooks||[],He=e=>{d(e),p(!0)},Ue=e=>{w(e.id),E(!0)},We=e=>{_(e.id),y(!0)},Ge=e=>{M(e)};if(_e||R){if(Ut(R)||Ut(_e))return(0,H.jsx)(Nk,{});let e=(R instanceof Error?R.message:null)??(_e instanceof Error?_e.message:null)??`There was an error loading the application data.`;return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,H.jsxs)(`div`,{className:`text-center max-w-lg px-4`,children:[(0,H.jsx)(`h2`,{className:`text-2xl font-bold text-red-400 mb-4`,children:`Error Loading Data`}),(0,H.jsx)(`p`,{className:`text-gray-300 mb-2`,children:`There was an error loading the application data.`}),(0,H.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:e}),(0,H.jsxs)(`p`,{className:`text-gray-500 text-xs mb-6`,children:[`Is the API running? Try `,(0,H.jsx)(`code`,{className:`text-gray-300`,children:`agent-deck stop && agent-deck start`})]}),(0,H.jsx)(`button`,{onClick:()=>window.location.reload(),className:`px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700`,children:`Reload Page`})]})})}return ge||ne||be||Se?(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-900`,children:(0,H.jsxs)(`div`,{className:`text-center`,children:[(0,H.jsx)(`div`,{className:`animate-spin rounded-full h-12 w-12 border-b-2 border-yellow-400 mx-auto mb-4`}),(0,H.jsx)(`p`,{className:`text-gray-300`,children:`Loading AgentDeck...`})]})}):(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col overflow-x-hidden`,onDrop:pe,onDragOver:e=>e.preventDefault(),style:{position:`relative`,...me&&{background:`linear-gradient(to bottom right, #1a1a2e, #16213e, #0f3460)`}},children:[(0,H.jsx)(`header`,{className:`relative z-20 shrink-0 bg-black/30 backdrop-blur-md border-b border-white/10`,"data-testid":`top-bar`,children:(0,H.jsx)(`div`,{className:`container mx-auto px-4 py-2`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`img`,{src:Dk,alt:`Agent Deck Logo`,className:`h-9 w-9 shrink-0 object-contain`}),(0,H.jsx)(`h1`,{className:`whitespace-nowrap text-xl font-bold bg-gradient-to-r from-yellow-400 to-yellow-600 bg-clip-text text-transparent`,style:{background:`linear-gradient(to right, #C4B643, #D4C760)`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`},children:`AgentDeck`}),(0,H.jsx)(`p`,{className:`sr-only`,children:`Build tool deck for your agent`})]}),(0,H.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-2 overflow-x-auto -my-1 py-1 sm:gap-3`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`flex h-9 shrink-0 items-center gap-2 whitespace-nowrap rounded-full border px-3 text-sm ${P===`connected`?`bg-emerald-500/20 border-emerald-500/30`:`bg-red-500/20 border-red-500/30`}`,"data-testid":`button-copy-mcp-url`,onClick:()=>{Ek(N)},title:`Click to copy MCP URL`,children:[(0,H.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full animate-pulse ${P===`connected`?`bg-emerald-400`:`bg-red-400`}`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`font-ui-display hover:underline ${P===`connected`?`text-emerald-300`:`text-red-300`}`,children:`Get MCP URL`})]}),(0,H.jsx)(qm,{highlightDeckId:re??void 0}),L?.data.hosted&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ye,{href:`/grants`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(Vi,{className:`mr-2 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Grants`})]})}),(0,H.jsx)(ye,{href:`/audit`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(Ri,{className:`mr-2 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Audit`})]})})]}),(0,H.jsx)(ye,{href:`/feedback-signals`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Feedback`}),I>0&&(0,H.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Open feedback available for curation`,children:I})]})}),(0,H.jsx)(ye,{href:`/playbook-patches`,children:(0,H.jsxs)(K,{variant:`outline`,size:`sm`,className:`relative shrink-0 border-white/20 bg-white/5 text-[#E8F6F4]`,children:[(0,H.jsx)(ki,{className:`mr-2 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Review`}),F.length>0&&(0,H.jsx)(`span`,{className:`ml-2 rounded-full px-2 py-0.5 text-xs font-semibold`,style:{background:`#C4B643`,color:`#0A0A07`},title:`Proposed playbook patches`,children:F.length})]})})]})]})})}),me&&(0,H.jsx)(`div`,{className:`fixed inset-0 pointer-events-none z-50 flex items-center justify-center`,children:(0,H.jsxs)(`div`,{className:`bg-red-500/20 border-2 border-dashed border-red-500/50 rounded-lg p-8 text-center`,children:[(0,H.jsx)(`div`,{className:`text-red-400 text-lg font-bold mb-2`,children:`Drop to Remove`}),(0,H.jsx)(`div`,{className:`text-red-300 text-sm`,children:`Release to remove card from deck`})]})}),(0,H.jsx)(`main`,{className:`container mx-auto flex min-h-0 flex-1 flex-col px-4 py-4 sm:py-6`,children:(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 sm:gap-6 xl:min-h-0 xl:flex-1 xl:grid-cols-4 xl:overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 space-y-4 sm:space-y-6 xl:col-span-1 xl:min-h-0 xl:overflow-y-auto`,children:[(0,H.jsx)(`div`,{className:`panel-surface h-64 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:(0,H.jsx)($h,{decks:z,editingDeckId:re,onSelectDeck:se,isLoading:ne})}),(0,H.jsxs)(`div`,{className:`panel-surface p-4`,children:[(0,H.jsxs)(`h2`,{className:`text-lg font-bold mb-3 flex items-center`,children:[(0,H.jsx)(ui,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,H.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`Add Cards`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(K,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Kl}`,style:Jl(Ul),onClick:()=>l(!0),"data-testid":`button-register-mcp`,children:[(0,H.jsx)(Bi,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,H.jsxs)(K,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Kl}`,style:Jl(Wl),onClick:()=>h(!0),"data-testid":`button-register-api-key`,children:[(0,H.jsx)(Ai,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]}),(0,H.jsxs)(K,{variant:`ghost`,className:`w-full border-2 text-sm py-2 hover:opacity-90 ${Kl}`,style:Jl(Gl),onClick:()=>S(!0),"data-testid":`button-register-playbook`,children:[(0,H.jsx)(di,{className:`w-3 h-3 mr-2`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register Playbook`})]})]})]})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4 sm:gap-6 xl:col-span-3 xl:h-full xl:min-h-0`,children:[(0,H.jsx)(`div`,{className:`panel-surface h-64 shrink-0 overflow-hidden p-4 min-w-0 sm:h-72 xl:h-80`,children:B?(0,H.jsx)(`div`,{className:`h-full`,children:(0,H.jsx)(nm,{deck:B,services:Be,credentials:B.credentials??[],playbooks:Ve,allServices:Ee,collectionWarnings:ke,onDrop:fe,onDragStart:ce,onCredentialDragStart:le,onPlaybookDragStart:ue,onDragEnd:de,onCardClick:He,onPlaybookClick:Ue,onCredentialClick:We,onInstructionsDirtyChange:oe})}):(0,H.jsxs)(`div`,{className:`text-center h-full flex flex-col justify-center`,children:[(0,H.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-yellow-500/20 border border-yellow-500/30 flex items-center justify-center mx-auto mb-3`,children:(0,H.jsx)(Mi,{className:`w-6 h-6 text-yellow-400`})}),(0,H.jsx)(`h3`,{className:`text-lg font-bold mb-2`,style:{color:`#92E4DD`},children:`No deck selected`}),(0,H.jsx)(`p`,{className:`text-gray-300 mb-4 text-sm`,children:`Create a deck or select one from the sidebar to edit its cards.`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(K,{onClick:()=>{let e=document.querySelector(`[data-testid="create-deck-button"]`);e&&e.click()},className:`border text-sm py-2`,style:{background:`#C4B643`,borderColor:`#C4B643`,color:`black`},children:[(0,H.jsx)(Ii,{className:`w-4 h-4 mr-2`}),`Create New Deck`]}),(0,H.jsxs)(K,{variant:`outline`,className:`border-white/20 text-white hover:bg-white/10 text-sm py-2`,onClick:()=>{let e=document.querySelector(`[data-testid="deck-management-panel"]`);e&&e.scrollIntoView({behavior:`smooth`})},children:[(0,H.jsx)(Mi,{className:`w-4 h-4 mr-2`}),`Manage Decks`]})]})]})}),(0,H.jsxs)(`div`,{className:`panel-surface flex min-h-[20rem] flex-col overflow-hidden p-4 min-w-0 sm:min-h-[24rem] xl:min-h-0 xl:flex-1`,"data-testid":`collection-panel`,children:[(0,H.jsxs)(`div`,{className:`mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2`,children:[(0,H.jsxs)(`h2`,{className:`text-lg font-bold flex items-center`,children:[(0,H.jsx)(Ni,{className:`w-4 h-4 mr-2`,style:{color:`#92E4DD`}}),(0,H.jsx)(`span`,{className:`font-ui-display`,style:{color:`#92E4DD`},children:`My Collection`}),(0,H.jsxs)(`span`,{className:`ml-3 text-sm font-normal text-gray-400`,children:[`(`,Fe,` cards)`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:ee,disabled:k,title:`Export all MCP, playbooks, and decks`,"data-testid":`button-export-all`,children:[(0,H.jsx)(Ti,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:k?`Exporting…`:`Export all`})]}),(0,H.jsxs)(K,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:()=>O(!0),title:`Import a bundle file`,"data-testid":`button-import-bundle`,children:[(0,H.jsx)(Ji,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Import`})]}),(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(zi,{className:`absolute left-2 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4`}),(0,H.jsx)(Eu,{placeholder:`Search...`,value:e,onChange:e=>t(e.target.value),className:`h-8 w-36 pl-8 text-sm bg-white/10 border-white/20 text-white placeholder-gray-400 sm:w-48`,"data-testid":`input-search`})]}),(0,H.jsxs)(hk,{value:n||`all`,onValueChange:e=>r(e===`all`?``:e),children:[(0,H.jsxs)(_k,{className:`w-[7.5rem] h-8 bg-white/10 border-white/20 text-white text-xs shrink-0`,"data-testid":`select-type`,children:[(0,H.jsx)(Oi,{className:`w-3 h-3 mr-1 shrink-0`}),(0,H.jsx)(gk,{placeholder:`Type`})]}),(0,H.jsxs)(bk,{children:[(0,H.jsx)(Sk,{value:`all`,children:`All`}),(0,H.jsx)(Sk,{value:`mcp`,children:`MCP`}),(0,H.jsx)(Sk,{value:`local-mcp`,children:`Local MCP`}),(0,H.jsx)(Sk,{value:`api-key`,children:`API Key`}),(0,H.jsx)(Sk,{value:`playbook`,children:`Playbook`})]})]}),(0,H.jsxs)(hk,{value:Ae?o:`default`,onValueChange:e=>s(e),disabled:!Ae,children:[(0,H.jsxs)(_k,{className:`w-[7.5rem] h-8 bg-white/10 border-white/20 text-white text-xs shrink-0`,"data-testid":`select-sort`,title:Ae?`Sort collection by 30-day use`:`Usage data unavailable — showing Default order`,"aria-label":`Sort collection`,children:[(0,H.jsx)(li,{className:`w-3 h-3 mr-1 shrink-0`}),(0,H.jsx)(gk,{placeholder:`Sort`})]}),(0,H.jsxs)(bk,{children:[(0,H.jsx)(Sk,{value:`default`,children:`Default`}),(0,H.jsx)(Sk,{value:`most-used`,children:`Most used`}),(0,H.jsx)(Sk,{value:`least-used`,children:`Least used`})]})]}),(e||n||i)&&(0,H.jsx)(K,{size:`sm`,variant:`outline`,className:`h-8 px-2 text-xs border-white/20 text-white hover:bg-white/10`,onClick:Ie,title:`Clear all filters`,children:`Clear`})]})]}),ke.total>0&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`mb-3 w-full shrink-0 rounded-lg border px-3 py-2 text-left text-sm transition-colors ${i?`border-amber-300/60 bg-amber-500/15 text-amber-100`:`border-amber-400/30 bg-amber-500/10 text-amber-100 hover:bg-amber-500/15`}`,"data-testid":`button-collection-warnings`,children:(0,H.jsxs)(`span`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(qi,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-300`}),(0,H.jsx)(`span`,{children:i?(0,H.jsxs)(H.Fragment,{children:[`Showing `,(0,H.jsx)(`strong`,{children:Fe}),` card`,Fe===1?``:`s`,` needing attention.`,(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:` Click to show all cards.`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`strong`,{children:ke.total}),` card`,ke.total===1?``:`s`,` need attention`,ke.byKind.oauth_expired+ke.byKind.oauth_required>0&&(0,H.jsxs)(H.Fragment,{children:[` `,`(`,ke.byKind.oauth_expired+ke.byKind.oauth_required,` `,`OAuth)`]}),`. `,(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:`Click to filter.`})]})})]})}),(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-1 py-2`,children:ge||be||Se?(0,H.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,children:Array.from({length:10}).map((e,t)=>(0,H.jsx)(`div`,{className:`animate-pulse`,children:(0,H.jsx)(`div`,{className:`bg-white/10 rounded-lg w-32 h-48 aspect-[2/3]`})},t))}):Fe===0?(0,H.jsxs)(`div`,{className:`text-center py-12`,children:[(0,H.jsx)(`div`,{className:`text-gray-400 mb-4`,children:(0,H.jsx)(`i`,{className:`fas fa-layer-group text-4xl`})}),(0,H.jsx)(`h3`,{className:`text-lg font-semibold text-gray-300 mb-2`,children:`No cards yet`}),(0,H.jsx)(`p`,{className:`text-gray-400 text-sm mb-4`,children:Le?i?`No cards with warnings match your current filters`:`Try adjusting your search or filters`:`Register an MCP server, API key, or playbook to get started`}),!Le&&(0,H.jsxs)(`div`,{className:`flex gap-3 justify-center`,children:[(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Jl(`#92E4DD`),onClick:()=>l(!0),"data-testid":`button-register-mcp-empty`,children:[(0,H.jsx)(Bi,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register MCP`})]}),(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`border-2 hover:opacity-90 bg-gradient-to-b from-gray-900 via-gray-800 to-gray-900`,style:Jl(`#F9386D`),onClick:()=>h(!0),"data-testid":`button-register-api-key-empty`,children:[(0,H.jsx)(Ai,{className:`w-3 h-3 mr-1`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Register API key`})]})]})]}):(0,H.jsx)(`div`,{className:`relative isolate grid grid-cols-[repeat(auto-fill,5rem)] gap-y-2 pr-12`,style:{isolation:`isolate`},"data-testid":`collection-card-grid`,children:V.map((e,t)=>{let{playbook:n,credential:r,service:i}=e;return(0,H.jsxs)(`div`,{className:`relative group`,style:{zIndex:j===e.id?999999:Fe-t},children:[e.kind===`playbook`&&n?(0,H.jsx)(du,{playbook:n,isInActiveDeck:ze.has(n.id),activeDeck:B??void 0,isInCollection:!0,onDragStart:ue,onDragEnd:de,onCardClick:Ue,onMouseEnter:()=>Ge(n.id),onMouseLeave:()=>Ge(null),warnings:ke.playbookWarnings.get(n.id),usage:Te.get(Ll(`playbook`,n.id))}):null,e.kind===`credential`&&r?(0,H.jsx)(lu,{credential:r,isInActiveDeck:Re.has(r.id),activeDeck:B??void 0,isInCollection:!0,onDragStart:le,onDragEnd:de,onMouseEnter:()=>Ge(r.id),onMouseLeave:()=>Ge(null),onCardClick:We,warnings:ke.credentialWarnings.get(r.id),usage:Te.get(Ll(`credential`,r.id))}):null,e.kind===`service`&&i?(0,H.jsx)(au,{service:i,onDragStart:ce,onDragEnd:de,isInActiveDeck:B?.services?.some(e=>e.id===i.id)||!1,onCardClick:He,isInCollection:!0,onMouseEnter:()=>Ge(i.id),onMouseLeave:()=>Ge(null),activeDeck:B??void 0,warnings:ke.serviceWarnings.get(i.id),usage:Te.get(Ll(`service`,i.id))}):null]},`${e.kind}:${e.id}`)})})})]})]})]})}),(0,H.jsx)(`footer`,{className:`shrink-0 border-t border-white/5 py-2 text-center text-xs text-gray-500`,"data-testid":`deck-dealer-note`,children:Mk}),(0,H.jsxs)(`div`,{className:`fixed inset-0 pointer-events-none z-0 overflow-hidden`,children:[(0,H.jsx)(`div`,{className:`absolute top-20 left-20`,children:(0,H.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-cyan-500/10 blur-3xl animate-orb-drift-1`})}),(0,H.jsx)(`div`,{className:`absolute bottom-20 right-20`,children:(0,H.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-pink-500/10 blur-3xl animate-orb-drift-2`})}),(0,H.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2`,children:(0,H.jsx)(`div`,{className:`h-96 w-96 rounded-full bg-purple-500/5 blur-3xl animate-orb-drift-3`})})]}),(0,H.jsx)(Kh,{type:`mcp`,open:c,onOpenChange:l}),(0,H.jsx)(ND,{service:u,isOpen:f,onClose:()=>p(!1)}),(0,H.jsx)(eg,{open:m,onOpenChange:h}),(0,H.jsx)(vg,{credentialId:g,open:v,onOpenChange:y}),(0,H.jsx)(tg,{open:x,onOpenChange:S}),(0,H.jsx)(_g,{playbookId:C,open:T,onOpenChange:E}),(0,H.jsx)(PD,{open:D,onOpenChange:O})]})}var Rk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));Rk.displayName=`Card`;var zk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`flex flex-col space-y-1.5 p-6`,e),...t}));zk.displayName=`CardHeader`;var Bk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`text-2xl font-semibold leading-none tracking-tight`,e),...t}));Bk.displayName=`CardTitle`;var Vk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`text-sm text-muted-foreground`,e),...t}));Vk.displayName=`CardDescription`;var Hk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`p-6 pt-0`,e),...t}));Hk.displayName=`CardContent`;var Uk=b.forwardRef(({className:e,...t},n)=>(0,H.jsx)(`div`,{ref:n,className:Ja(`flex items-center p-6 pt-0`,e),...t}));Uk.displayName=`CardFooter`;function Wk(){return(0,H.jsx)(`div`,{className:`min-h-screen w-full flex items-center justify-center bg-gray-50`,children:(0,H.jsx)(Rk,{className:`w-full max-w-md mx-4`,children:(0,H.jsxs)(Hk,{className:`pt-6`,children:[(0,H.jsxs)(`div`,{className:`flex mb-4 gap-2`,children:[(0,H.jsx)(yi,{className:`h-8 w-8 text-red-500`}),(0,H.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900`,children:`404 Page Not Found`})]}),(0,H.jsx)(`p`,{className:`mt-4 text-sm text-gray-600`,children:`Did you forget to add the page to the router?`})]})})})}function Gk(){let[e]=pe(),[t,n]=(0,b.useState)(`loading`),[r,i]=(0,b.useState)(`Authenticating...`);return(0,b.useEffect)(()=>{(async()=>{try{let e=new URL(window.location.href),t=e.searchParams.get(`success`),r=e.searchParams.get(`error`),a=e.searchParams.get(`serviceId`);t===`true`?(n(`success`),i(`Authentication successful! This window will close automatically.`),window.opener&&!window.opener.closed&&window.opener.postMessage({type:CD,serviceId:a??void 0},window.location.origin),setTimeout(()=>{window.close()},2e3)):t===`false`?(n(`error`),i(`OAuth Error: ${r||`Authentication failed`}`)):(n(`error`),i(`Invalid OAuth callback - please try again`))}catch(e){n(`error`),i(e instanceof Error?e.message:`Authentication failed`)}})()},[e]),(0,H.jsx)(`div`,{className:`flex items-center justify-center min-h-screen bg-background`,children:(0,H.jsxs)(`div`,{className:`text-center space-y-4`,children:[t===`loading`&&(0,H.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto`}),t===`success`&&(0,H.jsx)(`div`,{className:`text-green-500 text-4xl`,children:`✓`}),t===`error`&&(0,H.jsx)(`div`,{className:`text-red-500 text-4xl`,children:`✗`}),(0,H.jsx)(`h1`,{className:`text-xl font-semibold`,children:r}),t===`error`&&(0,H.jsx)(`button`,{onClick:()=>window.close(),className:`px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90`,children:`Close Window`})]})})}function Kk(e){let t=()=>{throw Error(`Invalid url to pass to open(): ${e}`)},n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(qk).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}function qk([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}var Jk=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;callbackUrl;preventAutoAuth;onPopupWindow;constructor(e,t={}){this.serverUrl=e,this.storageKeyPrefix=t.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=this.hashString(e),this.clientName=t.clientName||`MCP Browser Client`,this.clientUri=t.clientUri||(typeof window<`u`?window.location.origin:``),this.callbackUrl=Kk(t.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.preventAutoAuth=t.preventAutoAuth,this.onPopupWindow=t.onPopupWindow}get redirectUrl(){return Kk(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri}}async clientInformation(){let e=this.getKey(`client_info`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,t),localStorage.removeItem(e);return}}async saveClientInformation(e){let t=this.getKey(`client_info`);localStorage.setItem(t,JSON.stringify(e))}async tokens(){let e=this.getKey(`tokens`),t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,t),localStorage.removeItem(e);return}}async saveTokens(e){let t=this.getKey(`tokens`);localStorage.setItem(t,JSON.stringify(e)),localStorage.removeItem(this.getKey(`code_verifier`)),localStorage.removeItem(this.getKey(`last_auth_url`))}async saveCodeVerifier(e){let t=this.getKey(`code_verifier`);localStorage.setItem(t,e)}async codeVerifier(){let e=this.getKey(`code_verifier`),t=localStorage.getItem(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async prepareAuthorizationUrl(e){let t=crypto.randomUUID(),n=`${this.storageKeyPrefix}:state_${t}`,r={serverUrlHash:this.serverUrlHash,expiry:Date.now()+6e5,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl}};localStorage.setItem(n,JSON.stringify(r)),e.searchParams.set(`state`,t);let i=Kk(e.toString());return localStorage.setItem(this.getKey(`last_auth_url`),i),i}async redirectToAuthorization(e){if(this.preventAutoAuth)return;let t=await this.prepareAuthorizationUrl(e),n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?Kk(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}},Yk=Object.freeze({status:`aborted`});function J(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Xk=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Zk={};function Qk(e){return e&&Object.assign(Zk,e),Zk}function $k(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function eA(e,t){return typeof t==`bigint`?t.toString():t}function tA(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nA(e){return e==null}function rA(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function iA(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function aA(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function oA(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function sA(e){return JSON.stringify(e)}var cA=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function lA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var uA=tA(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function dA(e){if(lA(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return lA(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}var fA=new Set([`string`,`number`,`symbol`]);function pA(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function mA(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function hA(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var gA={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function _A(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return mA(e,{...e._zod.def,shape:n,checks:[]})}function vA(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return mA(e,{...e._zod.def,shape:n,checks:[]})}function yA(e,t){if(!dA(t))throw Error(`Invalid input to extend: expected a plain object`);return mA(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return oA(this,`shape`,n),n},checks:[]})}function bA(e,t){return mA(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return oA(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function xA(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return mA(t,{...t._zod.def,shape:i,checks:[]})}function SA(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return mA(t,{...t._zod.def,shape:i,checks:[]})}function CA(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function wA(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function TA(e){return typeof e==`string`?e:e?.message}function EA(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=TA(e.inst?._zod.def?.error?.(e))??TA(t?.error?.(e))??TA(n.customError?.(e))??TA(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function DA(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function OA(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var kA=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,eA,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},AA=J(`$ZodError`,kA),jA=J(`$ZodError`,kA,{Parent:Error});function MA(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function NA(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var PA=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Xk;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>EA(e,a,Qk())));throw cA(t,i?.callee),t}return o.value},FA=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>EA(e,a,Qk())));throw cA(t,i?.callee),t}return o.value},IA=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Xk;return a.issues.length?{success:!1,error:new(e??AA)(a.issues.map(e=>EA(e,i,Qk())))}:{success:!0,data:a.value}},LA=IA(jA),RA=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>EA(e,i,Qk())))}:{success:!0,data:a.value}},zA=RA(jA),BA=/^[cC][^\s-]{8,}$/,VA=/^[0-9a-z]+$/,HA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,UA=/^[0-9a-vA-V]{20}$/,WA=/^[A-Za-z0-9]{27}$/,GA=/^[a-zA-Z0-9_-]{21}$/,KA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qA=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,JA=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,YA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,XA=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function ZA(){return new RegExp(XA,`u`)}var QA=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$A=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,ej=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,tj=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nj=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rj=/^[A-Za-z0-9_-]*$/,ij=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,aj=/^\+(?:[0-9]){6,14}[0-9]$/,oj=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,sj=RegExp(`^${oj}$`);function cj(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function lj(e){return RegExp(`^${cj(e)}$`)}function uj(e){let t=cj({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${oj}T(?:${r})$`)}var dj=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},fj=/^\d+$/,pj=/^-?\d+(?:\.\d+)?/i,mj=/true|false/i,hj=/null/i,gj=/^[^A-Z]*$/,_j=/^[^a-z]*$/,vj=J(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),yj={number:`number`,bigint:`bigint`,object:`date`},bj=J(`$ZodCheckLessThan`,(e,t)=>{vj.init(e,t);let n=yj[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xj=J(`$ZodCheckGreaterThan`,(e,t)=>{vj.init(e,t);let n=yj[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sj=J(`$ZodCheckMultipleOf`,(e,t)=>{vj.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):iA(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Cj=J(`$ZodCheckNumberFormat`,(e,t)=>{vj.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=gA[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=fj)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),wj=J(`$ZodCheckMaxLength`,(e,t)=>{var n;vj.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nA(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=DA(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Tj=J(`$ZodCheckMinLength`,(e,t)=>{var n;vj.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nA(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=DA(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ej=J(`$ZodCheckLengthEquals`,(e,t)=>{var n;vj.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nA(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=DA(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Dj=J(`$ZodCheckStringFormat`,(e,t)=>{var n,r;vj.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Oj=J(`$ZodCheckRegex`,(e,t)=>{Dj.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),kj=J(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=gj,Dj.init(e,t)}),Aj=J(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=_j,Dj.init(e,t)}),jj=J(`$ZodCheckIncludes`,(e,t)=>{vj.init(e,t);let n=pA(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Mj=J(`$ZodCheckStartsWith`,(e,t)=>{vj.init(e,t);let n=RegExp(`^${pA(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Nj=J(`$ZodCheckEndsWith`,(e,t)=>{vj.init(e,t);let n=RegExp(`.*${pA(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Pj=J(`$ZodCheckOverwrite`,(e,t)=>{vj.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Fj=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
206
206
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
207
|
-
`))}},
|
|
207
|
+
`))}},Ij={major:4,minor:0,patch:0},Lj=J(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ij;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=CA(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Xk;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=CA(e,t))});else{if(e.issues.length===t)continue;r||=CA(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new Xk;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=LA(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return zA(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Rj=J(`$ZodString`,(e,t)=>{Lj.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??dj(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),zj=J(`$ZodStringFormat`,(e,t)=>{Dj.init(e,t),Rj.init(e,t)}),Bj=J(`$ZodGUID`,(e,t)=>{t.pattern??=qA,zj.init(e,t)}),Vj=J(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=JA(e)}else t.pattern??=JA();zj.init(e,t)}),Hj=J(`$ZodEmail`,(e,t)=>{t.pattern??=YA,zj.init(e,t)}),Uj=J(`$ZodURL`,(e,t)=>{zj.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:ij.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=!r.endsWith(`/`)&&a.endsWith(`/`)?a.slice(0,-1):a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Wj=J(`$ZodEmoji`,(e,t)=>{t.pattern??=ZA(),zj.init(e,t)}),Gj=J(`$ZodNanoID`,(e,t)=>{t.pattern??=GA,zj.init(e,t)}),Kj=J(`$ZodCUID`,(e,t)=>{t.pattern??=BA,zj.init(e,t)}),qj=J(`$ZodCUID2`,(e,t)=>{t.pattern??=VA,zj.init(e,t)}),Jj=J(`$ZodULID`,(e,t)=>{t.pattern??=HA,zj.init(e,t)}),Yj=J(`$ZodXID`,(e,t)=>{t.pattern??=UA,zj.init(e,t)}),Xj=J(`$ZodKSUID`,(e,t)=>{t.pattern??=WA,zj.init(e,t)}),Zj=J(`$ZodISODateTime`,(e,t)=>{t.pattern??=uj(t),zj.init(e,t)}),Qj=J(`$ZodISODate`,(e,t)=>{t.pattern??=sj,zj.init(e,t)}),$j=J(`$ZodISOTime`,(e,t)=>{t.pattern??=lj(t),zj.init(e,t)}),eM=J(`$ZodISODuration`,(e,t)=>{t.pattern??=KA,zj.init(e,t)}),tM=J(`$ZodIPv4`,(e,t)=>{t.pattern??=QA,zj.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),nM=J(`$ZodIPv6`,(e,t)=>{t.pattern??=$A,zj.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),rM=J(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ej,zj.init(e,t)}),iM=J(`$ZodCIDRv6`,(e,t)=>{t.pattern??=tj,zj.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function aM(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var oM=J(`$ZodBase64`,(e,t)=>{t.pattern??=nj,zj.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{aM(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function sM(e){if(!rj.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return aM(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var cM=J(`$ZodBase64URL`,(e,t)=>{t.pattern??=rj,zj.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{sM(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),lM=J(`$ZodE164`,(e,t)=>{t.pattern??=aj,zj.init(e,t)});function uM(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var dM=J(`$ZodJWT`,(e,t)=>{zj.init(e,t),e._zod.check=n=>{uM(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),fM=J(`$ZodNumber`,(e,t)=>{Lj.init(e,t),e._zod.pattern=e._zod.bag.pattern??pj,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),pM=J(`$ZodNumber`,(e,t)=>{Cj.init(e,t),fM.init(e,t)}),mM=J(`$ZodBoolean`,(e,t)=>{Lj.init(e,t),e._zod.pattern=mj,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),hM=J(`$ZodNull`,(e,t)=>{Lj.init(e,t),e._zod.pattern=hj,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),gM=J(`$ZodAny`,(e,t)=>{Lj.init(e,t),e._zod.parse=e=>e}),_M=J(`$ZodUnknown`,(e,t)=>{Lj.init(e,t),e._zod.parse=e=>e}),vM=J(`$ZodNever`,(e,t)=>{Lj.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function yM(e,t,n){e.issues.length&&t.issues.push(...wA(n,e.issues)),t.value[n]=e.value}var bM=J(`$ZodArray`,(e,t)=>{Lj.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>yM(t,n,e))):yM(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function xM(e,t,n){e.issues.length&&t.issues.push(...wA(n,e.issues)),t.value[n]=e.value}function SM(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...wA(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}var CM=J(`$ZodObject`,(e,t)=>{Lj.init(e,t);let n=tA(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof Lj))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=hA(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});aA(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new Fj([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=sA(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=sA(e);t.write(`
|
|
208
208
|
if (${n}.issues.length) {
|
|
209
209
|
if (input[${r}] === undefined) {
|
|
210
210
|
if (${r} in input) {
|
|
@@ -226,26 +226,26 @@ ${F.data.oauth.issuer?`Issuer: ${F.data.oauth.issuer}`:``}`;A({title:`OAuth Setu
|
|
|
226
226
|
`)}else{let n=a[e];t.write(`const ${n} = ${i(e)};`),t.write(`
|
|
227
227
|
if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
228
228
|
...iss,
|
|
229
|
-
path: iss.path ? [${
|
|
230
|
-
})));`),t.write(`newResult[${oA(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=cA,o=!Xk.jitless,s=o&&lA.value,c=t.catchall,l;e._zod.parse=(u,d)=>{l??=n.value;let f=u.value;if(!a(f))return u.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),u;let p=[];if(o&&s&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),u=i(u,d);else{u.value={};let e=l.shape;for(let t of l.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?xM(e,u,t,f):bM(e,u,t))):i?xM(r,u,t,f):bM(r,u,t)}}if(!c)return p.length?Promise.all(p).then(()=>u):u;let m=[],h=l.keySet,g=c._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>bM(t,u,e))):bM(t,u,e)}return m.length&&u.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>u):u}});function CM(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>TA(e,r,Zk())))}),t}var wM=J(`$ZodUnion`,(e,t)=>{Ij.init(e,t),iA(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),iA(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),iA(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),iA(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>nA(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>CM(t,n,e,r)):CM(a,n,e,r)}}),TM=J(`$ZodDiscriminatedUnion`,(e,t)=>{wM.init(e,t);let n=e._zod.parse;iA(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=eA(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!cA(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),EM=J(`$ZodIntersection`,(e,t)=>{Ij.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>OM(e,t,n)):OM(e,i,a)}});function DM(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(uA(e)&&uA(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=DM(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=DM(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function OM(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),SA(e))return e;let r=DM(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var kM=J(`$ZodRecord`,(e,t)=>{Ij.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!uA(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...CA(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...CA(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>TA(e,r,Zk())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...CA(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...CA(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),AM=J(`$ZodEnum`,(e,t)=>{Ij.init(e,t);let n=Qk(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>dA.has(typeof e)).map(e=>typeof e==`string`?fA(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),jM=J(`$ZodLiteral`,(e,t)=>{Ij.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?fA(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),MM=J(`$ZodTransform`,(e,t)=>{Ij.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new Yk;return e.value=r,e}}),NM=J(`$ZodOptional`,(e,t)=>{Ij.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,iA(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),iA(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${nA(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),PM=J(`$ZodNullable`,(e,t)=>{Ij.init(e,t),iA(e._zod,`optin`,()=>t.innerType._zod.optin),iA(e._zod,`optout`,()=>t.innerType._zod.optout),iA(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${nA(e.source)}|null)$`):void 0}),iA(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),FM=J(`$ZodDefault`,(e,t)=>{Ij.init(e,t),e._zod.optin=`optional`,iA(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>IM(e,t)):IM(r,t)}});function IM(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var LM=J(`$ZodPrefault`,(e,t)=>{Ij.init(e,t),e._zod.optin=`optional`,iA(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),RM=J(`$ZodNonOptional`,(e,t)=>{Ij.init(e,t),iA(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>zM(t,e)):zM(i,e)}});function zM(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var BM=J(`$ZodCatch`,(e,t)=>{Ij.init(e,t),e._zod.optin=`optional`,iA(e._zod,`optout`,()=>t.innerType._zod.optout),iA(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>TA(e,n,Zk()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>TA(e,n,Zk()))},input:e.value}),e.issues=[]),e)}}),VM=J(`$ZodPipe`,(e,t)=>{Ij.init(e,t),iA(e._zod,`values`,()=>t.in._zod.values),iA(e._zod,`optin`,()=>t.in._zod.optin),iA(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>HM(e,t,n)):HM(r,t,n)}});function HM(e,t,n){return SA(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}var UM=J(`$ZodReadonly`,(e,t)=>{Ij.init(e,t),iA(e._zod,`propValues`,()=>t.innerType._zod.propValues),iA(e._zod,`values`,()=>t.innerType._zod.values),iA(e._zod,`optin`,()=>t.innerType._zod.optin),iA(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(WM):WM(r)}});function WM(e){return e.value=Object.freeze(e.value),e}var GM=J(`$ZodCustom`,(e,t)=>{_j.init(e,t),Ij.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>KM(t,n,r,e));KM(i,n,r,e)}});function KM(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(DA(e))}}var qM=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function JM(){return new qM}var YM=JM();function XM(e,t){return new e({type:`string`,...Y(t)})}function ZM(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function QM(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function $M(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function eN(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function tN(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function nN(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function rN(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function iN(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function aN(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function oN(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function sN(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function cN(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function lN(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function uN(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function dN(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function fN(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function pN(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function mN(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function hN(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function gN(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function _N(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function vN(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function yN(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function bN(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function xN(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function SN(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function CN(e,t){return new e({type:`number`,checks:[],...Y(t)})}function wN(e,t){return new e({type:`number`,coerce:!0,checks:[],...Y(t)})}function TN(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function EN(e,t){return new e({type:`boolean`,...Y(t)})}function DN(e,t){return new e({type:`null`,...Y(t)})}function ON(e){return new e({type:`any`})}function kN(e){return new e({type:`unknown`})}function AN(e,t){return new e({type:`never`,...Y(t)})}function jN(e,t){return new yj({check:`less_than`,...Y(t),value:e,inclusive:!1})}function MN(e,t){return new yj({check:`less_than`,...Y(t),value:e,inclusive:!0})}function NN(e,t){return new bj({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function PN(e,t){return new bj({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function FN(e,t){return new xj({check:`multiple_of`,...Y(t),value:e})}function IN(e,t){return new Cj({check:`max_length`,...Y(t),maximum:e})}function LN(e,t){return new wj({check:`min_length`,...Y(t),minimum:e})}function RN(e,t){return new Tj({check:`length_equals`,...Y(t),length:e})}function zN(e,t){return new Dj({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function BN(e){return new Oj({check:`string_format`,format:`lowercase`,...Y(e)})}function VN(e){return new kj({check:`string_format`,format:`uppercase`,...Y(e)})}function HN(e,t){return new Aj({check:`string_format`,format:`includes`,...Y(t),includes:e})}function UN(e,t){return new jj({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function WN(e,t){return new Mj({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function GN(e){return new Nj({check:`overwrite`,tx:e})}function KN(e){return GN(t=>t.normalize(e))}function qN(){return GN(e=>e.trim())}function JN(){return GN(e=>e.toLowerCase())}function YN(){return GN(e=>e.toUpperCase())}function XN(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function ZN(e,t,n){let r=Y(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function QN(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}var $N=J(`ZodISODateTime`,(e,t)=>{Xj.init(e,t),gP.init(e,t)});function eP(e){return yN($N,e)}var tP=J(`ZodISODate`,(e,t)=>{Zj.init(e,t),gP.init(e,t)});function nP(e){return bN(tP,e)}var rP=J(`ZodISOTime`,(e,t)=>{Qj.init(e,t),gP.init(e,t)});function iP(e){return xN(rP,e)}var aP=J(`ZodISODuration`,(e,t)=>{$j.init(e,t),gP.init(e,t)});function oP(e){return SN(aP,e)}var sP=(e,t)=>{kA.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>MA(e,t)},flatten:{value:t=>jA(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};J(`ZodError`,sP);var cP=J(`ZodError`,sP,{Parent:Error}),lP=NA(cP),uP=PA(cP),dP=FA(cP),fP=LA(cP),pP=J(`ZodType`,(e,t)=>(Ij.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>pA(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>lP(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>dP(e,t,n),e.parseAsync=async(t,n)=>uP(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>fP(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(MF(t,n)),e.superRefine=t=>e.check(NF(t)),e.overwrite=t=>e.check(GN(t)),e.optional=()=>mF(e),e.nullable=()=>gF(e),e.nullish=()=>mF(gF(e)),e.nonoptional=t=>SF(e,t),e.array=()=>Z(e),e.or=t=>tF([e,t]),e.and=t=>aF(e,t),e.transform=t=>EF(e,fF(t)),e.default=t=>vF(e,t),e.prefault=t=>bF(e,t),e.catch=t=>wF(e,t),e.pipe=t=>EF(e,t),e.readonly=()=>OF(e),e.describe=t=>{let n=e.clone();return YM.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return YM.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return YM.get(e);let n=e.clone();return YM.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),mP=J(`_ZodString`,(e,t)=>{Lj.init(e,t),pP.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(zN(...t)),e.includes=(...t)=>e.check(HN(...t)),e.startsWith=(...t)=>e.check(UN(...t)),e.endsWith=(...t)=>e.check(WN(...t)),e.min=(...t)=>e.check(LN(...t)),e.max=(...t)=>e.check(IN(...t)),e.length=(...t)=>e.check(RN(...t)),e.nonempty=(...t)=>e.check(LN(1,...t)),e.lowercase=t=>e.check(BN(t)),e.uppercase=t=>e.check(VN(t)),e.trim=()=>e.check(qN()),e.normalize=(...t)=>e.check(KN(...t)),e.toLowerCase=()=>e.check(JN()),e.toUpperCase=()=>e.check(YN())}),hP=J(`ZodString`,(e,t)=>{Lj.init(e,t),mP.init(e,t),e.email=t=>e.check(ZM(_P,t)),e.url=t=>e.check(rN(bP,t)),e.jwt=t=>e.check(vN(IP,t)),e.emoji=t=>e.check(iN(SP,t)),e.guid=t=>e.check(QM(vP,t)),e.uuid=t=>e.check($M(yP,t)),e.uuidv4=t=>e.check(eN(yP,t)),e.uuidv6=t=>e.check(tN(yP,t)),e.uuidv7=t=>e.check(nN(yP,t)),e.nanoid=t=>e.check(aN(CP,t)),e.guid=t=>e.check(QM(vP,t)),e.cuid=t=>e.check(oN(wP,t)),e.cuid2=t=>e.check(sN(TP,t)),e.ulid=t=>e.check(cN(EP,t)),e.base64=t=>e.check(hN(NP,t)),e.base64url=t=>e.check(gN(PP,t)),e.xid=t=>e.check(lN(DP,t)),e.ksuid=t=>e.check(uN(OP,t)),e.ipv4=t=>e.check(dN(kP,t)),e.ipv6=t=>e.check(fN(AP,t)),e.cidrv4=t=>e.check(pN(jP,t)),e.cidrv6=t=>e.check(mN(MP,t)),e.e164=t=>e.check(_N(FP,t)),e.datetime=t=>e.check(eP(t)),e.date=t=>e.check(nP(t)),e.time=t=>e.check(iP(t)),e.duration=t=>e.check(oP(t))});function X(e){return XM(hP,e)}var gP=J(`ZodStringFormat`,(e,t)=>{Rj.init(e,t),mP.init(e,t)}),_P=J(`ZodEmail`,(e,t)=>{Vj.init(e,t),gP.init(e,t)}),vP=J(`ZodGUID`,(e,t)=>{zj.init(e,t),gP.init(e,t)}),yP=J(`ZodUUID`,(e,t)=>{Bj.init(e,t),gP.init(e,t)}),bP=J(`ZodURL`,(e,t)=>{Hj.init(e,t),gP.init(e,t)});function xP(e){return rN(bP,e)}var SP=J(`ZodEmoji`,(e,t)=>{Uj.init(e,t),gP.init(e,t)}),CP=J(`ZodNanoID`,(e,t)=>{Wj.init(e,t),gP.init(e,t)}),wP=J(`ZodCUID`,(e,t)=>{Gj.init(e,t),gP.init(e,t)}),TP=J(`ZodCUID2`,(e,t)=>{Kj.init(e,t),gP.init(e,t)}),EP=J(`ZodULID`,(e,t)=>{qj.init(e,t),gP.init(e,t)}),DP=J(`ZodXID`,(e,t)=>{Jj.init(e,t),gP.init(e,t)}),OP=J(`ZodKSUID`,(e,t)=>{Yj.init(e,t),gP.init(e,t)}),kP=J(`ZodIPv4`,(e,t)=>{eM.init(e,t),gP.init(e,t)}),AP=J(`ZodIPv6`,(e,t)=>{tM.init(e,t),gP.init(e,t)}),jP=J(`ZodCIDRv4`,(e,t)=>{nM.init(e,t),gP.init(e,t)}),MP=J(`ZodCIDRv6`,(e,t)=>{rM.init(e,t),gP.init(e,t)}),NP=J(`ZodBase64`,(e,t)=>{aM.init(e,t),gP.init(e,t)}),PP=J(`ZodBase64URL`,(e,t)=>{sM.init(e,t),gP.init(e,t)}),FP=J(`ZodE164`,(e,t)=>{cM.init(e,t),gP.init(e,t)}),IP=J(`ZodJWT`,(e,t)=>{uM.init(e,t),gP.init(e,t)}),LP=J(`ZodNumber`,(e,t)=>{dM.init(e,t),pP.init(e,t),e.gt=(t,n)=>e.check(NN(t,n)),e.gte=(t,n)=>e.check(PN(t,n)),e.min=(t,n)=>e.check(PN(t,n)),e.lt=(t,n)=>e.check(jN(t,n)),e.lte=(t,n)=>e.check(MN(t,n)),e.max=(t,n)=>e.check(MN(t,n)),e.int=t=>e.check(BP(t)),e.safe=t=>e.check(BP(t)),e.positive=t=>e.check(NN(0,t)),e.nonnegative=t=>e.check(PN(0,t)),e.negative=t=>e.check(jN(0,t)),e.nonpositive=t=>e.check(MN(0,t)),e.multipleOf=(t,n)=>e.check(FN(t,n)),e.step=(t,n)=>e.check(FN(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function RP(e){return CN(LP,e)}var zP=J(`ZodNumberFormat`,(e,t)=>{fM.init(e,t),LP.init(e,t)});function BP(e){return TN(zP,e)}var VP=J(`ZodBoolean`,(e,t)=>{pM.init(e,t),pP.init(e,t)});function HP(e){return EN(VP,e)}var UP=J(`ZodNull`,(e,t)=>{mM.init(e,t),pP.init(e,t)});function WP(e){return DN(UP,e)}var GP=J(`ZodAny`,(e,t)=>{hM.init(e,t),pP.init(e,t)});function KP(){return ON(GP)}var qP=J(`ZodUnknown`,(e,t)=>{gM.init(e,t),pP.init(e,t)});function JP(){return kN(qP)}var YP=J(`ZodNever`,(e,t)=>{_M.init(e,t),pP.init(e,t)});function XP(e){return AN(YP,e)}var ZP=J(`ZodArray`,(e,t)=>{yM.init(e,t),pP.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(LN(t,n)),e.nonempty=t=>e.check(LN(1,t)),e.max=(t,n)=>e.check(IN(t,n)),e.length=(t,n)=>e.check(RN(t,n)),e.unwrap=()=>e.element});function Z(e,t){return XN(ZP,e,t)}var QP=J(`ZodObject`,(e,t)=>{SM.init(e,t),pP.init(e,t),iA(e,`shape`,()=>t.shape),e.keyof=()=>lF(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:JP()}),e.loose=()=>e.clone({...e._zod.def,catchall:JP()}),e.strict=()=>e.clone({...e._zod.def,catchall:XP()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>vA(e,t),e.merge=t=>yA(e,t),e.pick=t=>gA(e,t),e.omit=t=>_A(e,t),e.partial=(...t)=>bA(pF,e,t[0]),e.required=(...t)=>xA(xF,e,t[0])});function Q(e,t){return new QP({type:`object`,get shape(){return aA(this,`shape`,{...e}),this.shape},...Y(t)})}function $P(e,t){return new QP({type:`object`,get shape(){return aA(this,`shape`,{...e}),this.shape},catchall:JP(),...Y(t)})}var eF=J(`ZodUnion`,(e,t)=>{wM.init(e,t),pP.init(e,t),e.options=t.options});function tF(e,t){return new eF({type:`union`,options:e,...Y(t)})}var nF=J(`ZodDiscriminatedUnion`,(e,t)=>{eF.init(e,t),TM.init(e,t)});function rF(e,t,n){return new nF({type:`union`,options:t,discriminator:e,...Y(n)})}var iF=J(`ZodIntersection`,(e,t)=>{EM.init(e,t),pP.init(e,t)});function aF(e,t){return new iF({type:`intersection`,left:e,right:t})}var oF=J(`ZodRecord`,(e,t)=>{kM.init(e,t),pP.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function sF(e,t,n){return new oF({type:`record`,keyType:e,valueType:t,...Y(n)})}var cF=J(`ZodEnum`,(e,t)=>{AM.init(e,t),pP.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new cF({...t,checks:[],...Y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new cF({...t,checks:[],...Y(r),entries:i})}});function lF(e,t){return new cF({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var uF=J(`ZodLiteral`,(e,t)=>{jM.init(e,t),pP.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new uF({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var dF=J(`ZodTransform`,(e,t)=>{MM.init(e,t),pP.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(DA(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(DA(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function fF(e){return new dF({type:`transform`,transform:e})}var pF=J(`ZodOptional`,(e,t)=>{NM.init(e,t),pP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function mF(e){return new pF({type:`optional`,innerType:e})}var hF=J(`ZodNullable`,(e,t)=>{PM.init(e,t),pP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function gF(e){return new hF({type:`nullable`,innerType:e})}var _F=J(`ZodDefault`,(e,t)=>{FM.init(e,t),pP.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vF(e,t){return new _F({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var yF=J(`ZodPrefault`,(e,t)=>{LM.init(e,t),pP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function bF(e,t){return new yF({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var xF=J(`ZodNonOptional`,(e,t)=>{RM.init(e,t),pP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function SF(e,t){return new xF({type:`nonoptional`,innerType:e,...Y(t)})}var CF=J(`ZodCatch`,(e,t)=>{BM.init(e,t),pP.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wF(e,t){return new CF({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var TF=J(`ZodPipe`,(e,t)=>{VM.init(e,t),pP.init(e,t),e.in=t.in,e.out=t.out});function EF(e,t){return new TF({type:`pipe`,in:e,out:t})}var DF=J(`ZodReadonly`,(e,t)=>{UM.init(e,t),pP.init(e,t)});function OF(e){return new DF({type:`readonly`,innerType:e})}var kF=J(`ZodCustom`,(e,t)=>{GM.init(e,t),pP.init(e,t)});function AF(e){let t=new _j({check:`custom`});return t._zod.check=e,t}function jF(e,t){return ZN(kF,e??(()=>!0),t)}function MF(e,t={}){return QN(kF,e,t)}function NF(e){let t=AF(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(DA(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(DA(r))}},e(n.value,n)));return t}function PF(e,t){return EF(fF(e),t)}var FF={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};function IF(e){return wN(LP,e)}var LF=`2025-11-25`,RF=[LF,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],zF=`io.modelcontextprotocol/related-task`,BF=jF(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),VF=tF([X(),RP().int()]),HF=X();$P({ttl:RP().optional(),pollInterval:RP().optional()});var UF=Q({ttl:RP().optional()}),WF=Q({taskId:X()}),GF=$P({progressToken:VF.optional(),[zF]:WF.optional()}),KF=Q({_meta:GF.optional()}),qF=KF.extend({task:UF.optional()}),JF=e=>qF.safeParse(e).success,YF=Q({method:X(),params:KF.loose().optional()}),XF=Q({_meta:GF.optional()}),ZF=Q({method:X(),params:XF.loose().optional()}),QF=$P({_meta:GF.optional()}),$F=tF([X(),RP().int()]),eI=Q({jsonrpc:$(`2.0`),id:$F,...YF.shape}).strict(),tI=e=>eI.safeParse(e).success,nI=Q({jsonrpc:$(`2.0`),...ZF.shape}).strict(),rI=e=>nI.safeParse(e).success,iI=Q({jsonrpc:$(`2.0`),id:$F,result:QF}).strict(),aI=e=>iI.safeParse(e).success,oI;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(oI||={});var sI=Q({jsonrpc:$(`2.0`),id:$F.optional(),error:Q({code:RP().int(),message:X(),data:JP().optional()})}).strict(),cI=e=>sI.safeParse(e).success,lI=tF([eI,nI,iI,sI]);tF([iI,sI]);var uI=QF.strict(),dI=XF.extend({requestId:$F.optional(),reason:X().optional()}),fI=ZF.extend({method:$(`notifications/cancelled`),params:dI}),pI=Q({icons:Z(Q({src:X(),mimeType:X().optional(),sizes:Z(X()).optional(),theme:lF([`light`,`dark`]).optional()})).optional()}),mI=Q({name:X(),title:X().optional()}),hI=mI.extend({...mI.shape,...pI.shape,version:X(),websiteUrl:X().optional(),description:X().optional()}),gI=PF(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,aF(Q({form:aF(Q({applyDefaults:HP().optional()}),sF(X(),JP())).optional(),url:BF.optional()}),sF(X(),JP()).optional())),_I=$P({list:BF.optional(),cancel:BF.optional(),requests:$P({sampling:$P({createMessage:BF.optional()}).optional(),elicitation:$P({create:BF.optional()}).optional()}).optional()}),vI=$P({list:BF.optional(),cancel:BF.optional(),requests:$P({tools:$P({call:BF.optional()}).optional()}).optional()}),yI=Q({experimental:sF(X(),BF).optional(),sampling:Q({context:BF.optional(),tools:BF.optional()}).optional(),elicitation:gI.optional(),roots:Q({listChanged:HP().optional()}).optional(),tasks:_I.optional(),extensions:sF(X(),BF).optional()}),bI=KF.extend({protocolVersion:X(),capabilities:yI,clientInfo:hI}),xI=YF.extend({method:$(`initialize`),params:bI}),SI=Q({experimental:sF(X(),BF).optional(),logging:BF.optional(),completions:BF.optional(),prompts:Q({listChanged:HP().optional()}).optional(),resources:Q({subscribe:HP().optional(),listChanged:HP().optional()}).optional(),tools:Q({listChanged:HP().optional()}).optional(),tasks:vI.optional(),extensions:sF(X(),BF).optional()}),CI=QF.extend({protocolVersion:X(),capabilities:SI,serverInfo:hI,instructions:X().optional()}),wI=ZF.extend({method:$(`notifications/initialized`),params:XF.optional()}),TI=e=>wI.safeParse(e).success,EI=YF.extend({method:$(`ping`),params:KF.optional()}),DI=Q({progress:RP(),total:mF(RP()),message:mF(X())}),OI=Q({...XF.shape,...DI.shape,progressToken:VF}),kI=ZF.extend({method:$(`notifications/progress`),params:OI}),AI=KF.extend({cursor:HF.optional()}),jI=YF.extend({params:AI.optional()}),MI=QF.extend({nextCursor:HF.optional()}),NI=lF([`working`,`input_required`,`completed`,`failed`,`cancelled`]),PI=Q({taskId:X(),status:NI,ttl:tF([RP(),WP()]),createdAt:X(),lastUpdatedAt:X(),pollInterval:mF(RP()),statusMessage:mF(X())}),FI=QF.extend({task:PI}),II=XF.merge(PI),LI=ZF.extend({method:$(`notifications/tasks/status`),params:II}),RI=YF.extend({method:$(`tasks/get`),params:KF.extend({taskId:X()})}),zI=QF.merge(PI),BI=YF.extend({method:$(`tasks/result`),params:KF.extend({taskId:X()})});QF.loose();var VI=jI.extend({method:$(`tasks/list`)}),HI=MI.extend({tasks:Z(PI)}),UI=YF.extend({method:$(`tasks/cancel`),params:KF.extend({taskId:X()})}),WI=QF.merge(PI),GI=Q({uri:X(),mimeType:mF(X()),_meta:sF(X(),JP()).optional()}),KI=GI.extend({text:X()}),qI=X().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),JI=GI.extend({blob:qI}),YI=lF([`user`,`assistant`]),XI=Q({audience:Z(YI).optional(),priority:RP().min(0).max(1).optional(),lastModified:eP({offset:!0}).optional()}),ZI=Q({...mI.shape,...pI.shape,uri:X(),description:mF(X()),mimeType:mF(X()),size:mF(RP()),annotations:XI.optional(),_meta:mF($P({}))}),QI=Q({...mI.shape,...pI.shape,uriTemplate:X(),description:mF(X()),mimeType:mF(X()),annotations:XI.optional(),_meta:mF($P({}))}),$I=jI.extend({method:$(`resources/list`)}),eL=MI.extend({resources:Z(ZI)}),tL=jI.extend({method:$(`resources/templates/list`)}),nL=MI.extend({resourceTemplates:Z(QI)}),rL=KF.extend({uri:X()}),iL=rL,aL=YF.extend({method:$(`resources/read`),params:iL}),oL=QF.extend({contents:Z(tF([KI,JI]))}),sL=ZF.extend({method:$(`notifications/resources/list_changed`),params:XF.optional()}),cL=rL,lL=YF.extend({method:$(`resources/subscribe`),params:cL}),uL=rL,dL=YF.extend({method:$(`resources/unsubscribe`),params:uL}),fL=XF.extend({uri:X()}),pL=ZF.extend({method:$(`notifications/resources/updated`),params:fL}),mL=Q({name:X(),description:mF(X()),required:mF(HP())}),hL=Q({...mI.shape,...pI.shape,description:mF(X()),arguments:mF(Z(mL)),_meta:mF($P({}))}),gL=jI.extend({method:$(`prompts/list`)}),_L=MI.extend({prompts:Z(hL)}),vL=KF.extend({name:X(),arguments:sF(X(),X()).optional()}),yL=YF.extend({method:$(`prompts/get`),params:vL}),bL=Q({type:$(`text`),text:X(),annotations:XI.optional(),_meta:sF(X(),JP()).optional()}),xL=Q({type:$(`image`),data:qI,mimeType:X(),annotations:XI.optional(),_meta:sF(X(),JP()).optional()}),SL=Q({type:$(`audio`),data:qI,mimeType:X(),annotations:XI.optional(),_meta:sF(X(),JP()).optional()}),CL=Q({type:$(`tool_use`),name:X(),id:X(),input:sF(X(),JP()),_meta:sF(X(),JP()).optional()}),wL=Q({type:$(`resource`),resource:tF([KI,JI]),annotations:XI.optional(),_meta:sF(X(),JP()).optional()}),TL=tF([bL,xL,SL,ZI.extend({type:$(`resource_link`)}),wL]),EL=Q({role:YI,content:TL}),DL=QF.extend({description:X().optional(),messages:Z(EL)}),OL=ZF.extend({method:$(`notifications/prompts/list_changed`),params:XF.optional()}),kL=Q({title:X().optional(),readOnlyHint:HP().optional(),destructiveHint:HP().optional(),idempotentHint:HP().optional(),openWorldHint:HP().optional()}),AL=Q({taskSupport:lF([`required`,`optional`,`forbidden`]).optional()}),jL=Q({...mI.shape,...pI.shape,description:X().optional(),inputSchema:Q({type:$(`object`),properties:sF(X(),BF).optional(),required:Z(X()).optional()}).catchall(JP()),outputSchema:Q({type:$(`object`),properties:sF(X(),BF).optional(),required:Z(X()).optional()}).catchall(JP()).optional(),annotations:kL.optional(),execution:AL.optional(),_meta:sF(X(),JP()).optional()}),ML=jI.extend({method:$(`tools/list`)}),NL=MI.extend({tools:Z(jL)}),PL=QF.extend({content:Z(TL).default([]),structuredContent:sF(X(),JP()).optional(),isError:HP().optional()});PL.or(QF.extend({toolResult:JP()}));var FL=qF.extend({name:X(),arguments:sF(X(),JP()).optional()}),IL=YF.extend({method:$(`tools/call`),params:FL}),LL=ZF.extend({method:$(`notifications/tools/list_changed`),params:XF.optional()}),RL=Q({autoRefresh:HP().default(!0),debounceMs:RP().int().nonnegative().default(300)}),zL=lF([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),BL=KF.extend({level:zL}),VL=YF.extend({method:$(`logging/setLevel`),params:BL}),HL=XF.extend({level:zL,logger:X().optional(),data:JP()}),UL=ZF.extend({method:$(`notifications/message`),params:HL}),WL=Q({hints:Z(Q({name:X().optional()})).optional(),costPriority:RP().min(0).max(1).optional(),speedPriority:RP().min(0).max(1).optional(),intelligencePriority:RP().min(0).max(1).optional()}),GL=Q({mode:lF([`auto`,`required`,`none`]).optional()}),KL=Q({type:$(`tool_result`),toolUseId:X().describe(`The unique identifier for the corresponding tool call.`),content:Z(TL).default([]),structuredContent:Q({}).loose().optional(),isError:HP().optional(),_meta:sF(X(),JP()).optional()}),qL=rF(`type`,[bL,xL,SL]),JL=rF(`type`,[bL,xL,SL,CL,KL]),YL=Q({role:YI,content:tF([JL,Z(JL)]),_meta:sF(X(),JP()).optional()}),XL=qF.extend({messages:Z(YL),modelPreferences:WL.optional(),systemPrompt:X().optional(),includeContext:lF([`none`,`thisServer`,`allServers`]).optional(),temperature:RP().optional(),maxTokens:RP().int(),stopSequences:Z(X()).optional(),metadata:BF.optional(),tools:Z(jL).optional(),toolChoice:GL.optional()}),ZL=YF.extend({method:$(`sampling/createMessage`),params:XL}),QL=QF.extend({model:X(),stopReason:mF(lF([`endTurn`,`stopSequence`,`maxTokens`]).or(X())),role:YI,content:qL}),$L=QF.extend({model:X(),stopReason:mF(lF([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(X())),role:YI,content:tF([JL,Z(JL)])}),eR=Q({type:$(`boolean`),title:X().optional(),description:X().optional(),default:HP().optional()}),tR=Q({type:$(`string`),title:X().optional(),description:X().optional(),minLength:RP().optional(),maxLength:RP().optional(),format:lF([`email`,`uri`,`date`,`date-time`]).optional(),default:X().optional()}),nR=Q({type:lF([`number`,`integer`]),title:X().optional(),description:X().optional(),minimum:RP().optional(),maximum:RP().optional(),default:RP().optional()}),rR=Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),default:X().optional()}),iR=Q({type:$(`string`),title:X().optional(),description:X().optional(),oneOf:Z(Q({const:X(),title:X()})),default:X().optional()}),aR=tF([tF([Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),enumNames:Z(X()).optional(),default:X().optional()}),tF([rR,iR]),tF([Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:RP().optional(),maxItems:RP().optional(),items:Q({type:$(`string`),enum:Z(X())}),default:Z(X()).optional()}),Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:RP().optional(),maxItems:RP().optional(),items:Q({anyOf:Z(Q({const:X(),title:X()}))}),default:Z(X()).optional()})])]),eR,tR,nR]),oR=tF([qF.extend({mode:$(`form`).optional(),message:X(),requestedSchema:Q({type:$(`object`),properties:sF(X(),aR),required:Z(X()).optional()})}),qF.extend({mode:$(`url`),message:X(),elicitationId:X(),url:X().url()})]),sR=YF.extend({method:$(`elicitation/create`),params:oR}),cR=XF.extend({elicitationId:X()}),lR=ZF.extend({method:$(`notifications/elicitation/complete`),params:cR}),uR=QF.extend({action:lF([`accept`,`decline`,`cancel`]),content:PF(e=>e===null?void 0:e,sF(X(),tF([X(),RP(),HP(),Z(X())])).optional())}),dR=Q({type:$(`ref/resource`),uri:X()}),fR=Q({type:$(`ref/prompt`),name:X()}),pR=KF.extend({ref:tF([fR,dR]),argument:Q({name:X(),value:X()}),context:Q({arguments:sF(X(),X()).optional()}).optional()}),mR=YF.extend({method:$(`completion/complete`),params:pR}),hR=QF.extend({completion:$P({values:Z(X()).max(100),total:mF(RP().int()),hasMore:mF(HP())})}),gR=Q({uri:X().startsWith(`file://`),name:X().optional(),_meta:sF(X(),JP()).optional()}),_R=YF.extend({method:$(`roots/list`),params:KF.optional()}),vR=QF.extend({roots:Z(gR)}),yR=ZF.extend({method:$(`notifications/roots/list_changed`),params:XF.optional()});tF([EI,xI,mR,VL,yL,gL,$I,tL,aL,lL,dL,IL,ML,RI,BI,VI,UI]),tF([fI,kI,wI,yR,LI]),tF([uI,QL,$L,uR,vR,zI,HI,FI]),tF([EI,ZL,sR,_R,RI,BI,VI,UI]),tF([fI,kI,UL,pL,sL,LL,OL,LI,lR]),tF([uI,CI,hR,DL,_L,eL,nL,oL,PL,NL,zI,HI,FI]);var bR=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===oI.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new xR(e.elicitations,n)}return new e(t,n,r)}},xR=class extends bR{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(oI.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},SR=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function CR(e){}function wR(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=CR,onError:n=CR,onRetry:r=CR,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=TR(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
231
|
-
`;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new
|
|
232
|
-
`)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function
|
|
229
|
+
path: iss.path ? [${sA(e)}, ...iss.path] : [${sA(e)}]
|
|
230
|
+
})));`),t.write(`newResult[${sA(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=lA,o=!Zk.jitless,s=o&&uA.value,c=t.catchall,l;e._zod.parse=(u,d)=>{l??=n.value;let f=u.value;if(!a(f))return u.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),u;let p=[];if(o&&s&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),u=i(u,d);else{u.value={};let e=l.shape;for(let t of l.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?SM(e,u,t,f):xM(e,u,t))):i?SM(r,u,t,f):xM(r,u,t)}}if(!c)return p.length?Promise.all(p).then(()=>u):u;let m=[],h=l.keySet,g=c._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>xM(t,u,e))):xM(t,u,e)}return m.length&&u.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>u):u}});function wM(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>EA(e,r,Qk())))}),t}var TM=J(`$ZodUnion`,(e,t)=>{Lj.init(e,t),aA(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),aA(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),aA(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),aA(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>rA(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>wM(t,n,e,r)):wM(a,n,e,r)}}),EM=J(`$ZodDiscriminatedUnion`,(e,t)=>{TM.init(e,t);let n=e._zod.parse;aA(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=tA(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!lA(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),DM=J(`$ZodIntersection`,(e,t)=>{Lj.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>kM(e,t,n)):kM(e,i,a)}});function OM(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(dA(e)&&dA(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=OM(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=OM(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function kM(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),CA(e))return e;let r=OM(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var AM=J(`$ZodRecord`,(e,t)=>{Lj.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!dA(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...wA(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...wA(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>EA(e,r,Qk())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...wA(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...wA(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),jM=J(`$ZodEnum`,(e,t)=>{Lj.init(e,t);let n=$k(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>fA.has(typeof e)).map(e=>typeof e==`string`?pA(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),MM=J(`$ZodLiteral`,(e,t)=>{Lj.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?pA(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),NM=J(`$ZodTransform`,(e,t)=>{Lj.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new Xk;return e.value=r,e}}),PM=J(`$ZodOptional`,(e,t)=>{Lj.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,aA(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),aA(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${rA(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),FM=J(`$ZodNullable`,(e,t)=>{Lj.init(e,t),aA(e._zod,`optin`,()=>t.innerType._zod.optin),aA(e._zod,`optout`,()=>t.innerType._zod.optout),aA(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${rA(e.source)}|null)$`):void 0}),aA(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),IM=J(`$ZodDefault`,(e,t)=>{Lj.init(e,t),e._zod.optin=`optional`,aA(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>LM(e,t)):LM(r,t)}});function LM(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var RM=J(`$ZodPrefault`,(e,t)=>{Lj.init(e,t),e._zod.optin=`optional`,aA(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),zM=J(`$ZodNonOptional`,(e,t)=>{Lj.init(e,t),aA(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>BM(t,e)):BM(i,e)}});function BM(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var VM=J(`$ZodCatch`,(e,t)=>{Lj.init(e,t),e._zod.optin=`optional`,aA(e._zod,`optout`,()=>t.innerType._zod.optout),aA(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>EA(e,n,Qk()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>EA(e,n,Qk()))},input:e.value}),e.issues=[]),e)}}),HM=J(`$ZodPipe`,(e,t)=>{Lj.init(e,t),aA(e._zod,`values`,()=>t.in._zod.values),aA(e._zod,`optin`,()=>t.in._zod.optin),aA(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>UM(e,t,n)):UM(r,t,n)}});function UM(e,t,n){return CA(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}var WM=J(`$ZodReadonly`,(e,t)=>{Lj.init(e,t),aA(e._zod,`propValues`,()=>t.innerType._zod.propValues),aA(e._zod,`values`,()=>t.innerType._zod.values),aA(e._zod,`optin`,()=>t.innerType._zod.optin),aA(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(GM):GM(r)}});function GM(e){return e.value=Object.freeze(e.value),e}var KM=J(`$ZodCustom`,(e,t)=>{vj.init(e,t),Lj.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>qM(t,n,r,e));qM(i,n,r,e)}});function qM(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(OA(e))}}var JM=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function YM(){return new JM}var XM=YM();function ZM(e,t){return new e({type:`string`,...Y(t)})}function QM(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function $M(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function eN(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function tN(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function nN(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function rN(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function iN(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function aN(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function oN(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function sN(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function cN(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function lN(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function uN(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function dN(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function fN(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function pN(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function mN(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function hN(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function gN(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function _N(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function vN(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function yN(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function bN(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function xN(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function SN(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function CN(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function wN(e,t){return new e({type:`number`,checks:[],...Y(t)})}function TN(e,t){return new e({type:`number`,coerce:!0,checks:[],...Y(t)})}function EN(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function DN(e,t){return new e({type:`boolean`,...Y(t)})}function ON(e,t){return new e({type:`null`,...Y(t)})}function kN(e){return new e({type:`any`})}function AN(e){return new e({type:`unknown`})}function jN(e,t){return new e({type:`never`,...Y(t)})}function MN(e,t){return new bj({check:`less_than`,...Y(t),value:e,inclusive:!1})}function NN(e,t){return new bj({check:`less_than`,...Y(t),value:e,inclusive:!0})}function PN(e,t){return new xj({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function FN(e,t){return new xj({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function IN(e,t){return new Sj({check:`multiple_of`,...Y(t),value:e})}function LN(e,t){return new wj({check:`max_length`,...Y(t),maximum:e})}function RN(e,t){return new Tj({check:`min_length`,...Y(t),minimum:e})}function zN(e,t){return new Ej({check:`length_equals`,...Y(t),length:e})}function BN(e,t){return new Oj({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function VN(e){return new kj({check:`string_format`,format:`lowercase`,...Y(e)})}function HN(e){return new Aj({check:`string_format`,format:`uppercase`,...Y(e)})}function UN(e,t){return new jj({check:`string_format`,format:`includes`,...Y(t),includes:e})}function WN(e,t){return new Mj({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function GN(e,t){return new Nj({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function KN(e){return new Pj({check:`overwrite`,tx:e})}function qN(e){return KN(t=>t.normalize(e))}function JN(){return KN(e=>e.trim())}function YN(){return KN(e=>e.toLowerCase())}function XN(){return KN(e=>e.toUpperCase())}function ZN(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function QN(e,t,n){let r=Y(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function $N(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}var eP=J(`ZodISODateTime`,(e,t)=>{Zj.init(e,t),_P.init(e,t)});function tP(e){return bN(eP,e)}var nP=J(`ZodISODate`,(e,t)=>{Qj.init(e,t),_P.init(e,t)});function rP(e){return xN(nP,e)}var iP=J(`ZodISOTime`,(e,t)=>{$j.init(e,t),_P.init(e,t)});function aP(e){return SN(iP,e)}var oP=J(`ZodISODuration`,(e,t)=>{eM.init(e,t),_P.init(e,t)});function sP(e){return CN(oP,e)}var cP=(e,t)=>{AA.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>NA(e,t)},flatten:{value:t=>MA(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};J(`ZodError`,cP);var lP=J(`ZodError`,cP,{Parent:Error}),uP=PA(lP),dP=FA(lP),fP=IA(lP),pP=RA(lP),mP=J(`ZodType`,(e,t)=>(Lj.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>mA(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>uP(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>fP(e,t,n),e.parseAsync=async(t,n)=>dP(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>pP(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(NF(t,n)),e.superRefine=t=>e.check(PF(t)),e.overwrite=t=>e.check(KN(t)),e.optional=()=>hF(e),e.nullable=()=>_F(e),e.nullish=()=>hF(_F(e)),e.nonoptional=t=>CF(e,t),e.array=()=>Z(e),e.or=t=>nF([e,t]),e.and=t=>oF(e,t),e.transform=t=>DF(e,pF(t)),e.default=t=>yF(e,t),e.prefault=t=>xF(e,t),e.catch=t=>TF(e,t),e.pipe=t=>DF(e,t),e.readonly=()=>kF(e),e.describe=t=>{let n=e.clone();return XM.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return XM.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return XM.get(e);let n=e.clone();return XM.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),hP=J(`_ZodString`,(e,t)=>{Rj.init(e,t),mP.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(BN(...t)),e.includes=(...t)=>e.check(UN(...t)),e.startsWith=(...t)=>e.check(WN(...t)),e.endsWith=(...t)=>e.check(GN(...t)),e.min=(...t)=>e.check(RN(...t)),e.max=(...t)=>e.check(LN(...t)),e.length=(...t)=>e.check(zN(...t)),e.nonempty=(...t)=>e.check(RN(1,...t)),e.lowercase=t=>e.check(VN(t)),e.uppercase=t=>e.check(HN(t)),e.trim=()=>e.check(JN()),e.normalize=(...t)=>e.check(qN(...t)),e.toLowerCase=()=>e.check(YN()),e.toUpperCase=()=>e.check(XN())}),gP=J(`ZodString`,(e,t)=>{Rj.init(e,t),hP.init(e,t),e.email=t=>e.check(QM(vP,t)),e.url=t=>e.check(iN(xP,t)),e.jwt=t=>e.check(yN(LP,t)),e.emoji=t=>e.check(aN(CP,t)),e.guid=t=>e.check($M(yP,t)),e.uuid=t=>e.check(eN(bP,t)),e.uuidv4=t=>e.check(tN(bP,t)),e.uuidv6=t=>e.check(nN(bP,t)),e.uuidv7=t=>e.check(rN(bP,t)),e.nanoid=t=>e.check(oN(wP,t)),e.guid=t=>e.check($M(yP,t)),e.cuid=t=>e.check(sN(TP,t)),e.cuid2=t=>e.check(cN(EP,t)),e.ulid=t=>e.check(lN(DP,t)),e.base64=t=>e.check(gN(PP,t)),e.base64url=t=>e.check(_N(FP,t)),e.xid=t=>e.check(uN(OP,t)),e.ksuid=t=>e.check(dN(kP,t)),e.ipv4=t=>e.check(fN(AP,t)),e.ipv6=t=>e.check(pN(jP,t)),e.cidrv4=t=>e.check(mN(MP,t)),e.cidrv6=t=>e.check(hN(NP,t)),e.e164=t=>e.check(vN(IP,t)),e.datetime=t=>e.check(tP(t)),e.date=t=>e.check(rP(t)),e.time=t=>e.check(aP(t)),e.duration=t=>e.check(sP(t))});function X(e){return ZM(gP,e)}var _P=J(`ZodStringFormat`,(e,t)=>{zj.init(e,t),hP.init(e,t)}),vP=J(`ZodEmail`,(e,t)=>{Hj.init(e,t),_P.init(e,t)}),yP=J(`ZodGUID`,(e,t)=>{Bj.init(e,t),_P.init(e,t)}),bP=J(`ZodUUID`,(e,t)=>{Vj.init(e,t),_P.init(e,t)}),xP=J(`ZodURL`,(e,t)=>{Uj.init(e,t),_P.init(e,t)});function SP(e){return iN(xP,e)}var CP=J(`ZodEmoji`,(e,t)=>{Wj.init(e,t),_P.init(e,t)}),wP=J(`ZodNanoID`,(e,t)=>{Gj.init(e,t),_P.init(e,t)}),TP=J(`ZodCUID`,(e,t)=>{Kj.init(e,t),_P.init(e,t)}),EP=J(`ZodCUID2`,(e,t)=>{qj.init(e,t),_P.init(e,t)}),DP=J(`ZodULID`,(e,t)=>{Jj.init(e,t),_P.init(e,t)}),OP=J(`ZodXID`,(e,t)=>{Yj.init(e,t),_P.init(e,t)}),kP=J(`ZodKSUID`,(e,t)=>{Xj.init(e,t),_P.init(e,t)}),AP=J(`ZodIPv4`,(e,t)=>{tM.init(e,t),_P.init(e,t)}),jP=J(`ZodIPv6`,(e,t)=>{nM.init(e,t),_P.init(e,t)}),MP=J(`ZodCIDRv4`,(e,t)=>{rM.init(e,t),_P.init(e,t)}),NP=J(`ZodCIDRv6`,(e,t)=>{iM.init(e,t),_P.init(e,t)}),PP=J(`ZodBase64`,(e,t)=>{oM.init(e,t),_P.init(e,t)}),FP=J(`ZodBase64URL`,(e,t)=>{cM.init(e,t),_P.init(e,t)}),IP=J(`ZodE164`,(e,t)=>{lM.init(e,t),_P.init(e,t)}),LP=J(`ZodJWT`,(e,t)=>{dM.init(e,t),_P.init(e,t)}),RP=J(`ZodNumber`,(e,t)=>{fM.init(e,t),mP.init(e,t),e.gt=(t,n)=>e.check(PN(t,n)),e.gte=(t,n)=>e.check(FN(t,n)),e.min=(t,n)=>e.check(FN(t,n)),e.lt=(t,n)=>e.check(MN(t,n)),e.lte=(t,n)=>e.check(NN(t,n)),e.max=(t,n)=>e.check(NN(t,n)),e.int=t=>e.check(VP(t)),e.safe=t=>e.check(VP(t)),e.positive=t=>e.check(PN(0,t)),e.nonnegative=t=>e.check(FN(0,t)),e.negative=t=>e.check(MN(0,t)),e.nonpositive=t=>e.check(NN(0,t)),e.multipleOf=(t,n)=>e.check(IN(t,n)),e.step=(t,n)=>e.check(IN(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function zP(e){return wN(RP,e)}var BP=J(`ZodNumberFormat`,(e,t)=>{pM.init(e,t),RP.init(e,t)});function VP(e){return EN(BP,e)}var HP=J(`ZodBoolean`,(e,t)=>{mM.init(e,t),mP.init(e,t)});function UP(e){return DN(HP,e)}var WP=J(`ZodNull`,(e,t)=>{hM.init(e,t),mP.init(e,t)});function GP(e){return ON(WP,e)}var KP=J(`ZodAny`,(e,t)=>{gM.init(e,t),mP.init(e,t)});function qP(){return kN(KP)}var JP=J(`ZodUnknown`,(e,t)=>{_M.init(e,t),mP.init(e,t)});function YP(){return AN(JP)}var XP=J(`ZodNever`,(e,t)=>{vM.init(e,t),mP.init(e,t)});function ZP(e){return jN(XP,e)}var QP=J(`ZodArray`,(e,t)=>{bM.init(e,t),mP.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(RN(t,n)),e.nonempty=t=>e.check(RN(1,t)),e.max=(t,n)=>e.check(LN(t,n)),e.length=(t,n)=>e.check(zN(t,n)),e.unwrap=()=>e.element});function Z(e,t){return ZN(QP,e,t)}var $P=J(`ZodObject`,(e,t)=>{CM.init(e,t),mP.init(e,t),aA(e,`shape`,()=>t.shape),e.keyof=()=>uF(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:YP()}),e.loose=()=>e.clone({...e._zod.def,catchall:YP()}),e.strict=()=>e.clone({...e._zod.def,catchall:ZP()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>yA(e,t),e.merge=t=>bA(e,t),e.pick=t=>_A(e,t),e.omit=t=>vA(e,t),e.partial=(...t)=>xA(mF,e,t[0]),e.required=(...t)=>SA(SF,e,t[0])});function Q(e,t){return new $P({type:`object`,get shape(){return oA(this,`shape`,{...e}),this.shape},...Y(t)})}function eF(e,t){return new $P({type:`object`,get shape(){return oA(this,`shape`,{...e}),this.shape},catchall:YP(),...Y(t)})}var tF=J(`ZodUnion`,(e,t)=>{TM.init(e,t),mP.init(e,t),e.options=t.options});function nF(e,t){return new tF({type:`union`,options:e,...Y(t)})}var rF=J(`ZodDiscriminatedUnion`,(e,t)=>{tF.init(e,t),EM.init(e,t)});function iF(e,t,n){return new rF({type:`union`,options:t,discriminator:e,...Y(n)})}var aF=J(`ZodIntersection`,(e,t)=>{DM.init(e,t),mP.init(e,t)});function oF(e,t){return new aF({type:`intersection`,left:e,right:t})}var sF=J(`ZodRecord`,(e,t)=>{AM.init(e,t),mP.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function cF(e,t,n){return new sF({type:`record`,keyType:e,valueType:t,...Y(n)})}var lF=J(`ZodEnum`,(e,t)=>{jM.init(e,t),mP.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new lF({...t,checks:[],...Y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new lF({...t,checks:[],...Y(r),entries:i})}});function uF(e,t){return new lF({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var dF=J(`ZodLiteral`,(e,t)=>{MM.init(e,t),mP.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new dF({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var fF=J(`ZodTransform`,(e,t)=>{NM.init(e,t),mP.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(OA(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(OA(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function pF(e){return new fF({type:`transform`,transform:e})}var mF=J(`ZodOptional`,(e,t)=>{PM.init(e,t),mP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function hF(e){return new mF({type:`optional`,innerType:e})}var gF=J(`ZodNullable`,(e,t)=>{FM.init(e,t),mP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _F(e){return new gF({type:`nullable`,innerType:e})}var vF=J(`ZodDefault`,(e,t)=>{IM.init(e,t),mP.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function yF(e,t){return new vF({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var bF=J(`ZodPrefault`,(e,t)=>{RM.init(e,t),mP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function xF(e,t){return new bF({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var SF=J(`ZodNonOptional`,(e,t)=>{zM.init(e,t),mP.init(e,t),e.unwrap=()=>e._zod.def.innerType});function CF(e,t){return new SF({type:`nonoptional`,innerType:e,...Y(t)})}var wF=J(`ZodCatch`,(e,t)=>{VM.init(e,t),mP.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function TF(e,t){return new wF({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var EF=J(`ZodPipe`,(e,t)=>{HM.init(e,t),mP.init(e,t),e.in=t.in,e.out=t.out});function DF(e,t){return new EF({type:`pipe`,in:e,out:t})}var OF=J(`ZodReadonly`,(e,t)=>{WM.init(e,t),mP.init(e,t)});function kF(e){return new OF({type:`readonly`,innerType:e})}var AF=J(`ZodCustom`,(e,t)=>{KM.init(e,t),mP.init(e,t)});function jF(e){let t=new vj({check:`custom`});return t._zod.check=e,t}function MF(e,t){return QN(AF,e??(()=>!0),t)}function NF(e,t={}){return $N(AF,e,t)}function PF(e){let t=jF(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(OA(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(OA(r))}},e(n.value,n)));return t}function FF(e,t){return DF(pF(e),t)}var IF={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};function LF(e){return TN(RP,e)}var RF=`2025-11-25`,zF=[RF,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],BF=`io.modelcontextprotocol/related-task`,VF=MF(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),HF=nF([X(),zP().int()]),UF=X();eF({ttl:zP().optional(),pollInterval:zP().optional()});var WF=Q({ttl:zP().optional()}),GF=Q({taskId:X()}),KF=eF({progressToken:HF.optional(),[BF]:GF.optional()}),qF=Q({_meta:KF.optional()}),JF=qF.extend({task:WF.optional()}),YF=e=>JF.safeParse(e).success,XF=Q({method:X(),params:qF.loose().optional()}),ZF=Q({_meta:KF.optional()}),QF=Q({method:X(),params:ZF.loose().optional()}),$F=eF({_meta:KF.optional()}),eI=nF([X(),zP().int()]),tI=Q({jsonrpc:$(`2.0`),id:eI,...XF.shape}).strict(),nI=e=>tI.safeParse(e).success,rI=Q({jsonrpc:$(`2.0`),...QF.shape}).strict(),iI=e=>rI.safeParse(e).success,aI=Q({jsonrpc:$(`2.0`),id:eI,result:$F}).strict(),oI=e=>aI.safeParse(e).success,sI;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(sI||={});var cI=Q({jsonrpc:$(`2.0`),id:eI.optional(),error:Q({code:zP().int(),message:X(),data:YP().optional()})}).strict(),lI=e=>cI.safeParse(e).success,uI=nF([tI,rI,aI,cI]);nF([aI,cI]);var dI=$F.strict(),fI=ZF.extend({requestId:eI.optional(),reason:X().optional()}),pI=QF.extend({method:$(`notifications/cancelled`),params:fI}),mI=Q({icons:Z(Q({src:X(),mimeType:X().optional(),sizes:Z(X()).optional(),theme:uF([`light`,`dark`]).optional()})).optional()}),hI=Q({name:X(),title:X().optional()}),gI=hI.extend({...hI.shape,...mI.shape,version:X(),websiteUrl:X().optional(),description:X().optional()}),_I=FF(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,oF(Q({form:oF(Q({applyDefaults:UP().optional()}),cF(X(),YP())).optional(),url:VF.optional()}),cF(X(),YP()).optional())),vI=eF({list:VF.optional(),cancel:VF.optional(),requests:eF({sampling:eF({createMessage:VF.optional()}).optional(),elicitation:eF({create:VF.optional()}).optional()}).optional()}),yI=eF({list:VF.optional(),cancel:VF.optional(),requests:eF({tools:eF({call:VF.optional()}).optional()}).optional()}),bI=Q({experimental:cF(X(),VF).optional(),sampling:Q({context:VF.optional(),tools:VF.optional()}).optional(),elicitation:_I.optional(),roots:Q({listChanged:UP().optional()}).optional(),tasks:vI.optional(),extensions:cF(X(),VF).optional()}),xI=qF.extend({protocolVersion:X(),capabilities:bI,clientInfo:gI}),SI=XF.extend({method:$(`initialize`),params:xI}),CI=Q({experimental:cF(X(),VF).optional(),logging:VF.optional(),completions:VF.optional(),prompts:Q({listChanged:UP().optional()}).optional(),resources:Q({subscribe:UP().optional(),listChanged:UP().optional()}).optional(),tools:Q({listChanged:UP().optional()}).optional(),tasks:yI.optional(),extensions:cF(X(),VF).optional()}),wI=$F.extend({protocolVersion:X(),capabilities:CI,serverInfo:gI,instructions:X().optional()}),TI=QF.extend({method:$(`notifications/initialized`),params:ZF.optional()}),EI=e=>TI.safeParse(e).success,DI=XF.extend({method:$(`ping`),params:qF.optional()}),OI=Q({progress:zP(),total:hF(zP()),message:hF(X())}),kI=Q({...ZF.shape,...OI.shape,progressToken:HF}),AI=QF.extend({method:$(`notifications/progress`),params:kI}),jI=qF.extend({cursor:UF.optional()}),MI=XF.extend({params:jI.optional()}),NI=$F.extend({nextCursor:UF.optional()}),PI=uF([`working`,`input_required`,`completed`,`failed`,`cancelled`]),FI=Q({taskId:X(),status:PI,ttl:nF([zP(),GP()]),createdAt:X(),lastUpdatedAt:X(),pollInterval:hF(zP()),statusMessage:hF(X())}),II=$F.extend({task:FI}),LI=ZF.merge(FI),RI=QF.extend({method:$(`notifications/tasks/status`),params:LI}),zI=XF.extend({method:$(`tasks/get`),params:qF.extend({taskId:X()})}),BI=$F.merge(FI),VI=XF.extend({method:$(`tasks/result`),params:qF.extend({taskId:X()})});$F.loose();var HI=MI.extend({method:$(`tasks/list`)}),UI=NI.extend({tasks:Z(FI)}),WI=XF.extend({method:$(`tasks/cancel`),params:qF.extend({taskId:X()})}),GI=$F.merge(FI),KI=Q({uri:X(),mimeType:hF(X()),_meta:cF(X(),YP()).optional()}),qI=KI.extend({text:X()}),JI=X().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),YI=KI.extend({blob:JI}),XI=uF([`user`,`assistant`]),ZI=Q({audience:Z(XI).optional(),priority:zP().min(0).max(1).optional(),lastModified:tP({offset:!0}).optional()}),QI=Q({...hI.shape,...mI.shape,uri:X(),description:hF(X()),mimeType:hF(X()),size:hF(zP()),annotations:ZI.optional(),_meta:hF(eF({}))}),$I=Q({...hI.shape,...mI.shape,uriTemplate:X(),description:hF(X()),mimeType:hF(X()),annotations:ZI.optional(),_meta:hF(eF({}))}),eL=MI.extend({method:$(`resources/list`)}),tL=NI.extend({resources:Z(QI)}),nL=MI.extend({method:$(`resources/templates/list`)}),rL=NI.extend({resourceTemplates:Z($I)}),iL=qF.extend({uri:X()}),aL=iL,oL=XF.extend({method:$(`resources/read`),params:aL}),sL=$F.extend({contents:Z(nF([qI,YI]))}),cL=QF.extend({method:$(`notifications/resources/list_changed`),params:ZF.optional()}),lL=iL,uL=XF.extend({method:$(`resources/subscribe`),params:lL}),dL=iL,fL=XF.extend({method:$(`resources/unsubscribe`),params:dL}),pL=ZF.extend({uri:X()}),mL=QF.extend({method:$(`notifications/resources/updated`),params:pL}),hL=Q({name:X(),description:hF(X()),required:hF(UP())}),gL=Q({...hI.shape,...mI.shape,description:hF(X()),arguments:hF(Z(hL)),_meta:hF(eF({}))}),_L=MI.extend({method:$(`prompts/list`)}),vL=NI.extend({prompts:Z(gL)}),yL=qF.extend({name:X(),arguments:cF(X(),X()).optional()}),bL=XF.extend({method:$(`prompts/get`),params:yL}),xL=Q({type:$(`text`),text:X(),annotations:ZI.optional(),_meta:cF(X(),YP()).optional()}),SL=Q({type:$(`image`),data:JI,mimeType:X(),annotations:ZI.optional(),_meta:cF(X(),YP()).optional()}),CL=Q({type:$(`audio`),data:JI,mimeType:X(),annotations:ZI.optional(),_meta:cF(X(),YP()).optional()}),wL=Q({type:$(`tool_use`),name:X(),id:X(),input:cF(X(),YP()),_meta:cF(X(),YP()).optional()}),TL=Q({type:$(`resource`),resource:nF([qI,YI]),annotations:ZI.optional(),_meta:cF(X(),YP()).optional()}),EL=nF([xL,SL,CL,QI.extend({type:$(`resource_link`)}),TL]),DL=Q({role:XI,content:EL}),OL=$F.extend({description:X().optional(),messages:Z(DL)}),kL=QF.extend({method:$(`notifications/prompts/list_changed`),params:ZF.optional()}),AL=Q({title:X().optional(),readOnlyHint:UP().optional(),destructiveHint:UP().optional(),idempotentHint:UP().optional(),openWorldHint:UP().optional()}),jL=Q({taskSupport:uF([`required`,`optional`,`forbidden`]).optional()}),ML=Q({...hI.shape,...mI.shape,description:X().optional(),inputSchema:Q({type:$(`object`),properties:cF(X(),VF).optional(),required:Z(X()).optional()}).catchall(YP()),outputSchema:Q({type:$(`object`),properties:cF(X(),VF).optional(),required:Z(X()).optional()}).catchall(YP()).optional(),annotations:AL.optional(),execution:jL.optional(),_meta:cF(X(),YP()).optional()}),NL=MI.extend({method:$(`tools/list`)}),PL=NI.extend({tools:Z(ML)}),FL=$F.extend({content:Z(EL).default([]),structuredContent:cF(X(),YP()).optional(),isError:UP().optional()});FL.or($F.extend({toolResult:YP()}));var IL=JF.extend({name:X(),arguments:cF(X(),YP()).optional()}),LL=XF.extend({method:$(`tools/call`),params:IL}),RL=QF.extend({method:$(`notifications/tools/list_changed`),params:ZF.optional()}),zL=Q({autoRefresh:UP().default(!0),debounceMs:zP().int().nonnegative().default(300)}),BL=uF([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),VL=qF.extend({level:BL}),HL=XF.extend({method:$(`logging/setLevel`),params:VL}),UL=ZF.extend({level:BL,logger:X().optional(),data:YP()}),WL=QF.extend({method:$(`notifications/message`),params:UL}),GL=Q({hints:Z(Q({name:X().optional()})).optional(),costPriority:zP().min(0).max(1).optional(),speedPriority:zP().min(0).max(1).optional(),intelligencePriority:zP().min(0).max(1).optional()}),KL=Q({mode:uF([`auto`,`required`,`none`]).optional()}),qL=Q({type:$(`tool_result`),toolUseId:X().describe(`The unique identifier for the corresponding tool call.`),content:Z(EL).default([]),structuredContent:Q({}).loose().optional(),isError:UP().optional(),_meta:cF(X(),YP()).optional()}),JL=iF(`type`,[xL,SL,CL]),YL=iF(`type`,[xL,SL,CL,wL,qL]),XL=Q({role:XI,content:nF([YL,Z(YL)]),_meta:cF(X(),YP()).optional()}),ZL=JF.extend({messages:Z(XL),modelPreferences:GL.optional(),systemPrompt:X().optional(),includeContext:uF([`none`,`thisServer`,`allServers`]).optional(),temperature:zP().optional(),maxTokens:zP().int(),stopSequences:Z(X()).optional(),metadata:VF.optional(),tools:Z(ML).optional(),toolChoice:KL.optional()}),QL=XF.extend({method:$(`sampling/createMessage`),params:ZL}),$L=$F.extend({model:X(),stopReason:hF(uF([`endTurn`,`stopSequence`,`maxTokens`]).or(X())),role:XI,content:JL}),eR=$F.extend({model:X(),stopReason:hF(uF([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(X())),role:XI,content:nF([YL,Z(YL)])}),tR=Q({type:$(`boolean`),title:X().optional(),description:X().optional(),default:UP().optional()}),nR=Q({type:$(`string`),title:X().optional(),description:X().optional(),minLength:zP().optional(),maxLength:zP().optional(),format:uF([`email`,`uri`,`date`,`date-time`]).optional(),default:X().optional()}),rR=Q({type:uF([`number`,`integer`]),title:X().optional(),description:X().optional(),minimum:zP().optional(),maximum:zP().optional(),default:zP().optional()}),iR=Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),default:X().optional()}),aR=Q({type:$(`string`),title:X().optional(),description:X().optional(),oneOf:Z(Q({const:X(),title:X()})),default:X().optional()}),oR=nF([nF([Q({type:$(`string`),title:X().optional(),description:X().optional(),enum:Z(X()),enumNames:Z(X()).optional(),default:X().optional()}),nF([iR,aR]),nF([Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:zP().optional(),maxItems:zP().optional(),items:Q({type:$(`string`),enum:Z(X())}),default:Z(X()).optional()}),Q({type:$(`array`),title:X().optional(),description:X().optional(),minItems:zP().optional(),maxItems:zP().optional(),items:Q({anyOf:Z(Q({const:X(),title:X()}))}),default:Z(X()).optional()})])]),tR,nR,rR]),sR=nF([JF.extend({mode:$(`form`).optional(),message:X(),requestedSchema:Q({type:$(`object`),properties:cF(X(),oR),required:Z(X()).optional()})}),JF.extend({mode:$(`url`),message:X(),elicitationId:X(),url:X().url()})]),cR=XF.extend({method:$(`elicitation/create`),params:sR}),lR=ZF.extend({elicitationId:X()}),uR=QF.extend({method:$(`notifications/elicitation/complete`),params:lR}),dR=$F.extend({action:uF([`accept`,`decline`,`cancel`]),content:FF(e=>e===null?void 0:e,cF(X(),nF([X(),zP(),UP(),Z(X())])).optional())}),fR=Q({type:$(`ref/resource`),uri:X()}),pR=Q({type:$(`ref/prompt`),name:X()}),mR=qF.extend({ref:nF([pR,fR]),argument:Q({name:X(),value:X()}),context:Q({arguments:cF(X(),X()).optional()}).optional()}),hR=XF.extend({method:$(`completion/complete`),params:mR}),gR=$F.extend({completion:eF({values:Z(X()).max(100),total:hF(zP().int()),hasMore:hF(UP())})}),_R=Q({uri:X().startsWith(`file://`),name:X().optional(),_meta:cF(X(),YP()).optional()}),vR=XF.extend({method:$(`roots/list`),params:qF.optional()}),yR=$F.extend({roots:Z(_R)}),bR=QF.extend({method:$(`notifications/roots/list_changed`),params:ZF.optional()});nF([DI,SI,hR,HL,bL,_L,eL,nL,oL,uL,fL,LL,NL,zI,VI,HI,WI]),nF([pI,AI,TI,bR,RI]),nF([dI,$L,eR,dR,yR,BI,UI,II]),nF([DI,QL,cR,vR,zI,VI,HI,WI]),nF([pI,AI,WL,mL,cL,RL,kL,RI,uR]),nF([dI,wI,gR,OL,vL,tL,rL,sL,FL,PL,BI,UI,II]);var xR=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===sI.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new SR(e.elicitations,n)}return new e(t,n,r)}},SR=class extends xR{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(sI.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},CR=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function wR(e){}function TR(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=wR,onError:n=wR,onRetry:r=wR,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=ER(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1;f(n,e.slice(t+r),e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
231
|
+
`;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new CR(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new CR(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
|
|
232
|
+
`)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function ER(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
|
|
233
233
|
`,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
|
|
234
|
-
`&&r++}}return[t,n]}var ER=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(kR(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(kR(this),t)}};function DR(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function OR(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(OR).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${OR(e.cause)}`:e.message:`${e}`}function kR(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var AR=e=>{throw TypeError(e)},jR=(e,t,n)=>t.has(e)||AR(`Cannot `+n),MR=(e,t,n)=>(jR(e,t,`read from private field`),n?n.call(e):t.get(e)),NR=(e,t,n)=>t.has(e)?AR(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),PR=(e,t,n,r)=>(jR(e,t,`write to private field`),t.set(e,n),n),FR=(e,t,n)=>(jR(e,t,`access private method`),n),IR,LR,RR,zR,BR,VR,HR,UR,WR,GR,KR,qR,JR,YR,XR,ZR,QR,$R,ez,tz,nz,rz,iz,az=class extends EventTarget{constructor(e,t){super(),NR(this,YR),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,NR(this,IR),NR(this,LR),NR(this,RR),NR(this,zR),NR(this,BR),NR(this,VR),NR(this,HR),NR(this,UR,null),NR(this,WR),NR(this,GR),NR(this,KR,null),NR(this,qR,null),NR(this,JR,null),NR(this,ZR,async e=>{var t;MR(this,GR).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){FR(this,YR,nz).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?PR(this,RR,new URL(e.url)):PR(this,RR,void 0),i!==200){FR(this,YR,nz).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){FR(this,YR,nz).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(MR(this,IR)===this.CLOSED)return;PR(this,IR,this.OPEN);let o=new Event(`open`);if((t=MR(this,JR))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){FR(this,YR,nz).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&MR(this,GR).feed(s.decode(t,{stream:!e})),e&&(l=!1,MR(this,GR).reset(),FR(this,YR,rz).call(this))}while(l)}),NR(this,QR,e=>{PR(this,WR,void 0),e.name!==`AbortError`&&e.type!==`aborted`&&FR(this,YR,rz).call(this,OR(e))}),NR(this,ez,e=>{typeof e.id==`string`&&PR(this,UR,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:MR(this,RR)?MR(this,RR).origin:MR(this,LR).origin,lastEventId:e.id||``});MR(this,qR)&&(!e.event||e.event===`message`)&&MR(this,qR).call(this,t),this.dispatchEvent(t)}),NR(this,tz,e=>{PR(this,VR,e)}),NR(this,iz,()=>{PR(this,HR,void 0),MR(this,IR)===this.CONNECTING&&FR(this,YR,XR).call(this)});try{if(e instanceof URL)PR(this,LR,e);else if(typeof e==`string`)PR(this,LR,new URL(e,oz()));else throw Error(`Invalid URL`)}catch{throw DR(`An invalid or illegal string was specified`)}PR(this,GR,wR({onEvent:MR(this,ez),onRetry:MR(this,tz)})),PR(this,IR,this.CONNECTING),PR(this,VR,3e3),PR(this,BR,t?.fetch??globalThis.fetch),PR(this,zR,t?.withCredentials??!1),FR(this,YR,XR).call(this)}get readyState(){return MR(this,IR)}get url(){return MR(this,LR).href}get withCredentials(){return MR(this,zR)}get onerror(){return MR(this,KR)}set onerror(e){PR(this,KR,e)}get onmessage(){return MR(this,qR)}set onmessage(e){PR(this,qR,e)}get onopen(){return MR(this,JR)}set onopen(e){PR(this,JR,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){MR(this,HR)&&clearTimeout(MR(this,HR)),MR(this,IR)!==this.CLOSED&&(MR(this,WR)&&MR(this,WR).abort(),PR(this,IR,this.CLOSED),PR(this,WR,void 0))}};IR=new WeakMap,LR=new WeakMap,RR=new WeakMap,zR=new WeakMap,BR=new WeakMap,VR=new WeakMap,HR=new WeakMap,UR=new WeakMap,WR=new WeakMap,GR=new WeakMap,KR=new WeakMap,qR=new WeakMap,JR=new WeakMap,YR=new WeakSet,XR=function(){PR(this,IR,this.CONNECTING),PR(this,WR,new AbortController),MR(this,BR)(MR(this,LR),FR(this,YR,$R).call(this)).then(MR(this,ZR)).catch(MR(this,QR))},ZR=new WeakMap,QR=new WeakMap,$R=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...MR(this,UR)?{"Last-Event-ID":MR(this,UR)}:void 0},cache:`no-store`,signal:MR(this,WR)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},ez=new WeakMap,tz=new WeakMap,nz=function(e,t){var n;MR(this,IR)!==this.CLOSED&&PR(this,IR,this.CLOSED);let r=new ER(`error`,{code:t,message:e});(n=MR(this,KR))==null||n.call(this,r),this.dispatchEvent(r)},rz=function(e,t){var n;if(MR(this,IR)===this.CLOSED)return;PR(this,IR,this.CONNECTING);let r=new ER(`error`,{code:t,message:e});(n=MR(this,KR))==null||n.call(this,r),this.dispatchEvent(r),PR(this,HR,setTimeout(MR(this,iz),MR(this,VR)))},iz=new WeakMap,az.CONNECTING=0,az.OPEN=1,az.CLOSED=2;function oz(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}function sz(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function cz(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...sz(t.headers),...sz(r.headers)}:t.headers}):e}var lz=globalThis.crypto;async function uz(e){return(await lz).getRandomValues(new Uint8Array(e))}async function dz(e){let t=``,n=await uz(e);for(let r=0;r<e;r++){let e=n[r]%66;t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e]}return t}async function fz(e){return await dz(e)}async function pz(e){let t=await(await lz).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function mz(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await fz(e);return{code_verifier:t,code_challenge:await pz(t)}}var hz=xP().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:FF.custom,message:`URL must be parseable`,fatal:!0}),Jk}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),gz=$P({resource:X().url(),authorization_servers:Z(hz).optional(),jwks_uri:X().url().optional(),scopes_supported:Z(X()).optional(),bearer_methods_supported:Z(X()).optional(),resource_signing_alg_values_supported:Z(X()).optional(),resource_name:X().optional(),resource_documentation:X().optional(),resource_policy_uri:X().url().optional(),resource_tos_uri:X().url().optional(),tls_client_certificate_bound_access_tokens:HP().optional(),authorization_details_types_supported:Z(X()).optional(),dpop_signing_alg_values_supported:Z(X()).optional(),dpop_bound_access_tokens_required:HP().optional()}),_z=$P({issuer:X(),authorization_endpoint:hz,token_endpoint:hz,registration_endpoint:hz.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),service_documentation:hz.optional(),revocation_endpoint:hz.optional(),revocation_endpoint_auth_methods_supported:Z(X()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),introspection_endpoint:X().optional(),introspection_endpoint_auth_methods_supported:Z(X()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),code_challenge_methods_supported:Z(X()).optional(),client_id_metadata_document_supported:HP().optional()}),vz=Q({...$P({issuer:X(),authorization_endpoint:hz,token_endpoint:hz,userinfo_endpoint:hz.optional(),jwks_uri:hz,registration_endpoint:hz.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),acr_values_supported:Z(X()).optional(),subject_types_supported:Z(X()),id_token_signing_alg_values_supported:Z(X()),id_token_encryption_alg_values_supported:Z(X()).optional(),id_token_encryption_enc_values_supported:Z(X()).optional(),userinfo_signing_alg_values_supported:Z(X()).optional(),userinfo_encryption_alg_values_supported:Z(X()).optional(),userinfo_encryption_enc_values_supported:Z(X()).optional(),request_object_signing_alg_values_supported:Z(X()).optional(),request_object_encryption_alg_values_supported:Z(X()).optional(),request_object_encryption_enc_values_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),display_values_supported:Z(X()).optional(),claim_types_supported:Z(X()).optional(),claims_supported:Z(X()).optional(),service_documentation:X().optional(),claims_locales_supported:Z(X()).optional(),ui_locales_supported:Z(X()).optional(),claims_parameter_supported:HP().optional(),request_parameter_supported:HP().optional(),request_uri_parameter_supported:HP().optional(),require_request_uri_registration:HP().optional(),op_policy_uri:hz.optional(),op_tos_uri:hz.optional(),client_id_metadata_document_supported:HP().optional()}).shape,..._z.pick({code_challenge_methods_supported:!0}).shape}),yz=Q({access_token:X(),id_token:X().optional(),token_type:X(),expires_in:IF().optional(),scope:X().optional(),refresh_token:X().optional()}).strip(),bz=Q({error:X(),error_description:X().optional(),error_uri:X().optional()}),xz=hz.optional().or($(``).transform(()=>void 0)),Sz=Q({redirect_uris:Z(hz),token_endpoint_auth_method:X().optional(),grant_types:Z(X()).optional(),response_types:Z(X()).optional(),client_name:X().optional(),client_uri:hz.optional(),logo_uri:xz,scope:X().optional(),contacts:Z(X()).optional(),tos_uri:xz,policy_uri:X().optional(),jwks_uri:hz.optional(),jwks:KP().optional(),software_id:X().optional(),software_version:X().optional(),software_statement:X().optional()}).strip(),Cz=Q({client_id:X(),client_secret:X().optional(),client_id_issued_at:RP().optional(),client_secret_expires_at:RP().optional()}).strip(),wz=Sz.merge(Cz);Q({error:X(),error_description:X().optional()}).strip(),Q({token:X(),token_type_hint:X().optional()}).strip();function Tz(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function Ez({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var Dz=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Oz=class extends Dz{};Oz.errorCode=`invalid_request`;var kz=class extends Dz{};kz.errorCode=`invalid_client`;var Az=class extends Dz{};Az.errorCode=`invalid_grant`;var jz=class extends Dz{};jz.errorCode=`unauthorized_client`;var Mz=class extends Dz{};Mz.errorCode=`unsupported_grant_type`;var Nz=class extends Dz{};Nz.errorCode=`invalid_scope`;var Pz=class extends Dz{};Pz.errorCode=`access_denied`;var Fz=class extends Dz{};Fz.errorCode=`server_error`;var Iz=class extends Dz{};Iz.errorCode=`temporarily_unavailable`;var Lz=class extends Dz{};Lz.errorCode=`unsupported_response_type`;var Rz=class extends Dz{};Rz.errorCode=`unsupported_token_type`;var zz=class extends Dz{};zz.errorCode=`invalid_token`;var Bz=class extends Dz{};Bz.errorCode=`method_not_allowed`;var Vz=class extends Dz{};Vz.errorCode=`too_many_requests`;var Hz=class extends Dz{};Hz.errorCode=`invalid_client_metadata`;var Uz=class extends Dz{};Uz.errorCode=`insufficient_scope`;var Wz=class extends Dz{};Wz.errorCode=`invalid_target`;var Gz={[Oz.errorCode]:Oz,[kz.errorCode]:kz,[Az.errorCode]:Az,[jz.errorCode]:jz,[Mz.errorCode]:Mz,[Nz.errorCode]:Nz,[Pz.errorCode]:Pz,[Fz.errorCode]:Fz,[Iz.errorCode]:Iz,[Lz.errorCode]:Lz,[Rz.errorCode]:Rz,[zz.errorCode]:zz,[Bz.errorCode]:Bz,[Vz.errorCode]:Vz,[Hz.errorCode]:Hz,[Uz.errorCode]:Uz,[Wz.errorCode]:Wz},Kz=class extends Error{constructor(e){super(e??`Unauthorized`)}};function qz(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}var Jz=`code`,Yz=`S256`;function Xz(e,t){let n=e.client_secret!==void 0;return`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&qz(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?n?`client_secret_basic`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function Zz(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:Qz(i,a,n);return;case`client_secret_post`:$z(i,a,r);return;case`none`:eB(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function Qz(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function $z(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function eB(e,t){t.set(`client_id`,e)}async function tB(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=bz.parse(JSON.parse(n));return new(Gz[e]||Fz)(t||``,r)}catch(e){return new Fz(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function nB(e,t){try{return await rB(e,t)}catch(n){if(n instanceof kz||n instanceof jz)return await e.invalidateCredentials?.(`all`),await rB(e,t);if(n instanceof Az)return await e.invalidateCredentials?.(`tokens`),await rB(e,t);throw n}}async function rB(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await hB(c,{fetchFn:a}),!s)try{s=await cB(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await gB(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await aB(t,e,s),f=r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,p=await Promise.resolve(e.clientInformation());if(!p){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!iB(r))throw new Hz(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)p={client_id:r},await e.saveClientInformation?.(p);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await SB(c,{metadata:l,clientMetadata:e.clientMetadata,scope:f,fetchFn:a});await e.saveClientInformation(t),p=t}}let m=!e.redirectUrl;if(n!==void 0||m){let t=await xB(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let h=await e.tokens();if(h?.refresh_token)try{let t=await bB(c,{metadata:l,clientInformation:p,refreshToken:h.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof Dz)||e instanceof Fz))throw e}let g=e.state?await e.state():void 0,{authorizationUrl:_,codeVerifier:v}=await _B(c,{metadata:l,clientInformation:p,state:g,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier(v),await e.redirectToAuthorization(_),`REDIRECT`}function iB(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function aB(e,t,n){let r=Tz(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!Ez({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function oB(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=sB(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=sB(e,`scope`)||void 0,s=sB(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function sB(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function cB(e,t,n=fetch){let r=await pB(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return gz.parse(await r.json())}async function lB(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?lB(e,void 0,n):void 0;throw r}}function uB(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function dB(e,t,n=fetch){return await lB(e,{"MCP-Protocol-Version":t},n)}function fB(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function pB(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=uB(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await dB(o,a,n);return!r?.metadataUrl&&fB(s,i.pathname)&&(s=await dB(new URL(`/.well-known/${t}`,i),a,n)),s}function mB(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function hB(e,{fetchFn:t=fetch,protocolVersion:n=LF}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=mB(e);for(let{url:e,type:n}of i){let i=await lB(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?_z.parse(await i.json()):vz.parse(await i.json())}}}async function gB(e,t){let n,r;try{n=await cB(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await hB(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function _B(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Jz))throw Error(`Incompatible auth server: does not support response type ${Jz}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(Yz))throw Error(`Incompatible auth server: does not support code challenge method ${Yz}`)}else s=new URL(`/authorize`,e);let c=await mz(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,Jz),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,Yz),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function vB(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function yB(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&Zz(Xz(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await tB(l);return yz.parse(await l.json())}async function bB(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await yB(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function xB(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=vB(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return yB(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function SB(e,{metadata:t,clientMetadata:n,scope:r,fetchFn:i}){let a;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);a=new URL(t.registration_endpoint)}else a=new URL(`/register`,e);let o=await(i??fetch)(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,...r===void 0?{}:{scope:r}})});if(!o.ok)throw await tB(o);return wz.parse(await o.json())}var CB=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},wB=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=cz(t?.fetch,t?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new Kz(`No auth provider`);let e;try{e=await nB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new Kz;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=sz(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((t,n)=>{this._eventSource=new az(this._url.href,{...this._eventSourceInit,fetch:async(t,n)=>{let r=await this._commonHeaders();r.set(`Accept`,`text/event-stream`);let i=await e(t,{...n,headers:r});if(i.status===401&&i.headers.has(`www-authenticate`)){let{resourceMetadataUrl:e,scope:t}=oB(i);this._resourceMetadataUrl=e,this._scope=t}return i}}),this._abortController=new AbortController,this._eventSource.onerror=e=>{if(e.code===401&&this._authProvider){this._authThenStart().then(t,n);return}let r=new CB(e.code,e.message,e);n(r),this.onerror?.(r)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,e=>{let r=e;try{if(this._endpoint=new URL(r.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){n(e),this.onerror?.(e),this.close();return}t()}),this._eventSource.onmessage=e=>{let t=e,n;try{n=lI.parse(JSON.parse(t.data))}catch(e){this.onerror?.(e);return}this.onmessage?.(n)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Kz(`No auth provider`);if(await nB(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new Kz(`Failed to authorize`)}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._endpoint,n);if(!r.ok){let t=await r.text().catch(()=>null);if(r.status===401&&this._authProvider){let{resourceMetadataUrl:t,scope:n}=oB(r);if(this._resourceMetadataUrl=t,this._scope=n,await nB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new Kz;return this.send(e)}throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${t}`)}await r.body?.cancel()}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}},TB=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=wR({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}},EB={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},DB=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},OB=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=cz(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??EB}async _authThenStart(){if(!this._authProvider)throw new Kz(`No auth provider`);let e;try{e=await nB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new Kz;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=sz(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new DB(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new TB({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=lI.parse(JSON.parse(e.data));aI(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Kz(`No auth provider`);if(await nB(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new Kz(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:tI(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new DB(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=oB(o);if(this._resourceMetadataUrl=t,this._scope=n,await nB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new Kz;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=oB(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new DB(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await nB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new Kz;return this.send(e)}}throw new DB(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),TI(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c){if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>lI.parse(e)):[lI.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new DB(-1,`Unexpected content type: ${l}`)}else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new DB(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};function kB(e){return!!e._zod}function AB(e,t){return kB(e)?IA(e,t):e.safeParse(t)}function jB(e){if(!e)return;let t;if(t=kB(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function MB(e){if(kB(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function NB(e){return e===`completed`||e===`failed`||e===`cancelled`}function PB(e){let t=jB(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=MB(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function FB(e,t){let n=AB(e,t);if(!n.success)throw n.error;return n.data}var IB=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(fI,e=>{this._oncancel(e)}),this.setNotificationHandler(kI,e=>{this._onprogress(e)}),this.setRequestHandler(EI,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(RI,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new bR(oI.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(BI,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new bR(e.error.code,e.error.message,e.error.data))}}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new bR(oI.InvalidParams,`Task not found: ${r}`);if(!NB(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(NB(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[zF]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(VI,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new bR(oI.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(UI,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new bR(oI.InvalidParams,`Task not found: ${e.params.taskId}`);if(NB(n.status))throw new bR(oI.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new bR(oI.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof bR?e:new bR(oI.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),bR.fromError(oI.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),aI(e)||cI(e)?this._onresponse(e):tI(e)?this._onrequest(e,t):rI(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=bR.fromError(oI.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[zF]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:oI.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=JF(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new bR(oI.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:oI.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),aI(e)?n(e):n(new bR(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(aI(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),aI(e)?r(e):r(bR.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof bR?e:new bR(oI.InternalError,String(e))}}return}let i;try{let r=await this.request(e,FI,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new bR(oI.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},NB(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new bR(oI.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new bR(oI.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof bR?e:new bR(oI.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[zF]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof bR?e:new bR(oI.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=AB(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(bR.fromError(oI.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},zI,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},HI,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},WI,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[zF]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[zF]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[zF]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=PB(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=FB(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=PB(e);this._notificationHandlers.set(n,n=>{let r=FB(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&tI(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new bR(oI.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new bR(oI.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new bR(oI.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new bR(oI.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=LI.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),NB(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new bR(oI.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(NB(a.status))throw new bR(oI.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=LI.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),NB(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function LB(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function RB(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=LB(a)&&LB(i)?{...a,...i}:i}return n}var zB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),BB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=zB(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),VB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=zB(),n=BB(),r=zB();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=BB();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(t!==!1&&this.nodes.length)return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
235
|
-
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-->0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),HB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=VB(),n=zB();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),UB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),WB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=VB(),n=HB(),r=UB();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),GB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=WB(),n=VB(),r=UB(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),KB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),qB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),JB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=KB(),n=qB(),r=WB(),i=VB(),a=HB(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
234
|
+
`&&r++}}return[t,n]}var DR=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(AR(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(AR(this),t)}};function OR(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function kR(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(kR).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${kR(e.cause)}`:e.message:`${e}`}function AR(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var jR=e=>{throw TypeError(e)},MR=(e,t,n)=>t.has(e)||jR(`Cannot `+n),NR=(e,t,n)=>(MR(e,t,`read from private field`),n?n.call(e):t.get(e)),PR=(e,t,n)=>t.has(e)?jR(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),FR=(e,t,n,r)=>(MR(e,t,`write to private field`),t.set(e,n),n),IR=(e,t,n)=>(MR(e,t,`access private method`),n),LR,RR,zR,BR,VR,HR,UR,WR,GR,KR,qR,JR,YR,XR,ZR,QR,$R,ez,tz,nz,rz,iz,az,oz=class extends EventTarget{constructor(e,t){super(),PR(this,XR),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,PR(this,LR),PR(this,RR),PR(this,zR),PR(this,BR),PR(this,VR),PR(this,HR),PR(this,UR),PR(this,WR,null),PR(this,GR),PR(this,KR),PR(this,qR,null),PR(this,JR,null),PR(this,YR,null),PR(this,QR,async e=>{var t;NR(this,KR).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){IR(this,XR,rz).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?FR(this,zR,new URL(e.url)):FR(this,zR,void 0),i!==200){IR(this,XR,rz).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){IR(this,XR,rz).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(NR(this,LR)===this.CLOSED)return;FR(this,LR,this.OPEN);let o=new Event(`open`);if((t=NR(this,YR))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){IR(this,XR,rz).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&NR(this,KR).feed(s.decode(t,{stream:!e})),e&&(l=!1,NR(this,KR).reset(),IR(this,XR,iz).call(this))}while(l)}),PR(this,$R,e=>{FR(this,GR,void 0),e.name!==`AbortError`&&e.type!==`aborted`&&IR(this,XR,iz).call(this,kR(e))}),PR(this,tz,e=>{typeof e.id==`string`&&FR(this,WR,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:NR(this,zR)?NR(this,zR).origin:NR(this,RR).origin,lastEventId:e.id||``});NR(this,JR)&&(!e.event||e.event===`message`)&&NR(this,JR).call(this,t),this.dispatchEvent(t)}),PR(this,nz,e=>{FR(this,HR,e)}),PR(this,az,()=>{FR(this,UR,void 0),NR(this,LR)===this.CONNECTING&&IR(this,XR,ZR).call(this)});try{if(e instanceof URL)FR(this,RR,e);else if(typeof e==`string`)FR(this,RR,new URL(e,sz()));else throw Error(`Invalid URL`)}catch{throw OR(`An invalid or illegal string was specified`)}FR(this,KR,TR({onEvent:NR(this,tz),onRetry:NR(this,nz)})),FR(this,LR,this.CONNECTING),FR(this,HR,3e3),FR(this,VR,t?.fetch??globalThis.fetch),FR(this,BR,t?.withCredentials??!1),IR(this,XR,ZR).call(this)}get readyState(){return NR(this,LR)}get url(){return NR(this,RR).href}get withCredentials(){return NR(this,BR)}get onerror(){return NR(this,qR)}set onerror(e){FR(this,qR,e)}get onmessage(){return NR(this,JR)}set onmessage(e){FR(this,JR,e)}get onopen(){return NR(this,YR)}set onopen(e){FR(this,YR,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){NR(this,UR)&&clearTimeout(NR(this,UR)),NR(this,LR)!==this.CLOSED&&(NR(this,GR)&&NR(this,GR).abort(),FR(this,LR,this.CLOSED),FR(this,GR,void 0))}};LR=new WeakMap,RR=new WeakMap,zR=new WeakMap,BR=new WeakMap,VR=new WeakMap,HR=new WeakMap,UR=new WeakMap,WR=new WeakMap,GR=new WeakMap,KR=new WeakMap,qR=new WeakMap,JR=new WeakMap,YR=new WeakMap,XR=new WeakSet,ZR=function(){FR(this,LR,this.CONNECTING),FR(this,GR,new AbortController),NR(this,VR)(NR(this,RR),IR(this,XR,ez).call(this)).then(NR(this,QR)).catch(NR(this,$R))},QR=new WeakMap,$R=new WeakMap,ez=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...NR(this,WR)?{"Last-Event-ID":NR(this,WR)}:void 0},cache:`no-store`,signal:NR(this,GR)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},tz=new WeakMap,nz=new WeakMap,rz=function(e,t){var n;NR(this,LR)!==this.CLOSED&&FR(this,LR,this.CLOSED);let r=new DR(`error`,{code:t,message:e});(n=NR(this,qR))==null||n.call(this,r),this.dispatchEvent(r)},iz=function(e,t){var n;if(NR(this,LR)===this.CLOSED)return;FR(this,LR,this.CONNECTING);let r=new DR(`error`,{code:t,message:e});(n=NR(this,qR))==null||n.call(this,r),this.dispatchEvent(r),FR(this,UR,setTimeout(NR(this,az),NR(this,HR)))},az=new WeakMap,oz.CONNECTING=0,oz.OPEN=1,oz.CLOSED=2;function sz(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}function cz(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function lz(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...cz(t.headers),...cz(r.headers)}:t.headers}):e}var uz=globalThis.crypto;async function dz(e){return(await uz).getRandomValues(new Uint8Array(e))}async function fz(e){let t=``,n=await dz(e);for(let r=0;r<e;r++){let e=n[r]%66;t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e]}return t}async function pz(e){return await fz(e)}async function mz(e){let t=await(await uz).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function hz(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await pz(e);return{code_verifier:t,code_challenge:await mz(t)}}var gz=SP().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:IF.custom,message:`URL must be parseable`,fatal:!0}),Yk}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),_z=eF({resource:X().url(),authorization_servers:Z(gz).optional(),jwks_uri:X().url().optional(),scopes_supported:Z(X()).optional(),bearer_methods_supported:Z(X()).optional(),resource_signing_alg_values_supported:Z(X()).optional(),resource_name:X().optional(),resource_documentation:X().optional(),resource_policy_uri:X().url().optional(),resource_tos_uri:X().url().optional(),tls_client_certificate_bound_access_tokens:UP().optional(),authorization_details_types_supported:Z(X()).optional(),dpop_signing_alg_values_supported:Z(X()).optional(),dpop_bound_access_tokens_required:UP().optional()}),vz=eF({issuer:X(),authorization_endpoint:gz,token_endpoint:gz,registration_endpoint:gz.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),service_documentation:gz.optional(),revocation_endpoint:gz.optional(),revocation_endpoint_auth_methods_supported:Z(X()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),introspection_endpoint:X().optional(),introspection_endpoint_auth_methods_supported:Z(X()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),code_challenge_methods_supported:Z(X()).optional(),client_id_metadata_document_supported:UP().optional()}),yz=Q({...eF({issuer:X(),authorization_endpoint:gz,token_endpoint:gz,userinfo_endpoint:gz.optional(),jwks_uri:gz,registration_endpoint:gz.optional(),scopes_supported:Z(X()).optional(),response_types_supported:Z(X()),response_modes_supported:Z(X()).optional(),grant_types_supported:Z(X()).optional(),acr_values_supported:Z(X()).optional(),subject_types_supported:Z(X()),id_token_signing_alg_values_supported:Z(X()),id_token_encryption_alg_values_supported:Z(X()).optional(),id_token_encryption_enc_values_supported:Z(X()).optional(),userinfo_signing_alg_values_supported:Z(X()).optional(),userinfo_encryption_alg_values_supported:Z(X()).optional(),userinfo_encryption_enc_values_supported:Z(X()).optional(),request_object_signing_alg_values_supported:Z(X()).optional(),request_object_encryption_alg_values_supported:Z(X()).optional(),request_object_encryption_enc_values_supported:Z(X()).optional(),token_endpoint_auth_methods_supported:Z(X()).optional(),token_endpoint_auth_signing_alg_values_supported:Z(X()).optional(),display_values_supported:Z(X()).optional(),claim_types_supported:Z(X()).optional(),claims_supported:Z(X()).optional(),service_documentation:X().optional(),claims_locales_supported:Z(X()).optional(),ui_locales_supported:Z(X()).optional(),claims_parameter_supported:UP().optional(),request_parameter_supported:UP().optional(),request_uri_parameter_supported:UP().optional(),require_request_uri_registration:UP().optional(),op_policy_uri:gz.optional(),op_tos_uri:gz.optional(),client_id_metadata_document_supported:UP().optional()}).shape,...vz.pick({code_challenge_methods_supported:!0}).shape}),bz=Q({access_token:X(),id_token:X().optional(),token_type:X(),expires_in:LF().optional(),scope:X().optional(),refresh_token:X().optional()}).strip(),xz=Q({error:X(),error_description:X().optional(),error_uri:X().optional()}),Sz=gz.optional().or($(``).transform(()=>void 0)),Cz=Q({redirect_uris:Z(gz),token_endpoint_auth_method:X().optional(),grant_types:Z(X()).optional(),response_types:Z(X()).optional(),client_name:X().optional(),client_uri:gz.optional(),logo_uri:Sz,scope:X().optional(),contacts:Z(X()).optional(),tos_uri:Sz,policy_uri:X().optional(),jwks_uri:gz.optional(),jwks:qP().optional(),software_id:X().optional(),software_version:X().optional(),software_statement:X().optional()}).strip(),wz=Q({client_id:X(),client_secret:X().optional(),client_id_issued_at:zP().optional(),client_secret_expires_at:zP().optional()}).strip(),Tz=Cz.merge(wz);Q({error:X(),error_description:X().optional()}).strip(),Q({token:X(),token_type_hint:X().optional()}).strip();function Ez(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function Dz({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var Oz=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},kz=class extends Oz{};kz.errorCode=`invalid_request`;var Az=class extends Oz{};Az.errorCode=`invalid_client`;var jz=class extends Oz{};jz.errorCode=`invalid_grant`;var Mz=class extends Oz{};Mz.errorCode=`unauthorized_client`;var Nz=class extends Oz{};Nz.errorCode=`unsupported_grant_type`;var Pz=class extends Oz{};Pz.errorCode=`invalid_scope`;var Fz=class extends Oz{};Fz.errorCode=`access_denied`;var Iz=class extends Oz{};Iz.errorCode=`server_error`;var Lz=class extends Oz{};Lz.errorCode=`temporarily_unavailable`;var Rz=class extends Oz{};Rz.errorCode=`unsupported_response_type`;var zz=class extends Oz{};zz.errorCode=`unsupported_token_type`;var Bz=class extends Oz{};Bz.errorCode=`invalid_token`;var Vz=class extends Oz{};Vz.errorCode=`method_not_allowed`;var Hz=class extends Oz{};Hz.errorCode=`too_many_requests`;var Uz=class extends Oz{};Uz.errorCode=`invalid_client_metadata`;var Wz=class extends Oz{};Wz.errorCode=`insufficient_scope`;var Gz=class extends Oz{};Gz.errorCode=`invalid_target`;var Kz={[kz.errorCode]:kz,[Az.errorCode]:Az,[jz.errorCode]:jz,[Mz.errorCode]:Mz,[Nz.errorCode]:Nz,[Pz.errorCode]:Pz,[Fz.errorCode]:Fz,[Iz.errorCode]:Iz,[Lz.errorCode]:Lz,[Rz.errorCode]:Rz,[zz.errorCode]:zz,[Bz.errorCode]:Bz,[Vz.errorCode]:Vz,[Hz.errorCode]:Hz,[Uz.errorCode]:Uz,[Wz.errorCode]:Wz,[Gz.errorCode]:Gz},qz=class extends Error{constructor(e){super(e??`Unauthorized`)}};function Jz(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}var Yz=`code`,Xz=`S256`;function Zz(e,t){let n=e.client_secret!==void 0;return`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&Jz(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?n?`client_secret_basic`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function Qz(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:$z(i,a,n);return;case`client_secret_post`:eB(i,a,r);return;case`none`:tB(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function $z(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function eB(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function tB(e,t){t.set(`client_id`,e)}async function nB(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=xz.parse(JSON.parse(n));return new(Kz[e]||Iz)(t||``,r)}catch(e){return new Iz(`${t?`HTTP ${t}: `:``}Invalid OAuth error response: ${e}. Raw body: ${n}`)}}async function rB(e,t){try{return await iB(e,t)}catch(n){if(n instanceof Az||n instanceof Mz)return await e.invalidateCredentials?.(`all`),await iB(e,t);if(n instanceof jz)return await e.invalidateCredentials?.(`tokens`),await iB(e,t);throw n}}async function iB(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await gB(c,{fetchFn:a}),!s)try{s=await lB(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await _B(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=await oB(t,e,s),f=r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,p=await Promise.resolve(e.clientInformation());if(!p){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!aB(r))throw new Uz(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)p={client_id:r},await e.saveClientInformation?.(p);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);let t=await CB(c,{metadata:l,clientMetadata:e.clientMetadata,scope:f,fetchFn:a});await e.saveClientInformation(t),p=t}}let m=!e.redirectUrl;if(n!==void 0||m){let t=await SB(e,c,{metadata:l,resource:d,authorizationCode:n,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}let h=await e.tokens();if(h?.refresh_token)try{let t=await xB(c,{metadata:l,clientInformation:p,refreshToken:h.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens(t),`AUTHORIZED`}catch(e){if(!(!(e instanceof Oz)||e instanceof Iz))throw e}let g=e.state?await e.state():void 0,{authorizationUrl:_,codeVerifier:v}=await vB(c,{metadata:l,clientInformation:p,state:g,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier(v),await e.redirectToAuthorization(_),`REDIRECT`}function aB(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function oB(e,t,n){let r=Ez(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!Dz({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function sB(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=cB(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=cB(e,`scope`)||void 0,s=cB(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function cB(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function lB(e,t,n=fetch){let r=await mB(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return _z.parse(await r.json())}async function uB(e,t,n=fetch){try{return await n(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?uB(e,void 0,n):void 0;throw r}}function dB(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function fB(e,t,n=fetch){return await uB(e,{"MCP-Protocol-Version":t},n)}function pB(e,t){return!e||e.status>=400&&e.status<500&&t!==`/`}async function mB(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=dB(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await fB(o,a,n);return!r?.metadataUrl&&pB(s,i.pathname)&&(s=await fB(new URL(`/.well-known/${t}`,i),a,n)),s}function hB(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function gB(e,{fetchFn:t=fetch,protocolVersion:n=RF}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=hB(e);for(let{url:e,type:n}of i){let i=await uB(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status>=400&&i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?vz.parse(await i.json()):yz.parse(await i.json())}}}async function _B(e,t){let n,r;try{n=await lB(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await gB(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}async function vB(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Yz))throw Error(`Incompatible auth server: does not support response type ${Yz}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(Xz))throw Error(`Incompatible auth server: does not support code challenge method ${Xz}`)}else s=new URL(`/authorize`,e);let c=await hz(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,Yz),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,Xz),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,o.href),{authorizationUrl:s,codeVerifier:l}}function yB(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function bB(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,a.href),i?await i(c,n,s,t):r&&Qz(Zz(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await nB(l);return bz.parse(await l.json())}async function xB(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await bB(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function SB(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=e.clientMetadata.scope,s;if(e.prepareTokenRequest&&(s=await e.prepareTokenRequest(o)),!s){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);s=yB(i,await e.codeVerifier(),e.redirectUrl)}let c=await e.clientInformation();return bB(t,{metadata:n,tokenRequestParams:s,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function CB(e,{metadata:t,clientMetadata:n,scope:r,fetchFn:i}){let a;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);a=new URL(t.registration_endpoint)}else a=new URL(`/register`,e);let o=await(i??fetch)(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,...r===void 0?{}:{scope:r}})});if(!o.ok)throw await nB(o);return Tz.parse(await o.json())}var wB=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},TB=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=lz(t?.fetch,t?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new qz(`No auth provider`);let e;try{e=await rB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new qz;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=cz(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((t,n)=>{this._eventSource=new oz(this._url.href,{...this._eventSourceInit,fetch:async(t,n)=>{let r=await this._commonHeaders();r.set(`Accept`,`text/event-stream`);let i=await e(t,{...n,headers:r});if(i.status===401&&i.headers.has(`www-authenticate`)){let{resourceMetadataUrl:e,scope:t}=sB(i);this._resourceMetadataUrl=e,this._scope=t}return i}}),this._abortController=new AbortController,this._eventSource.onerror=e=>{if(e.code===401&&this._authProvider){this._authThenStart().then(t,n);return}let r=new wB(e.code,e.message,e);n(r),this.onerror?.(r)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,e=>{let r=e;try{if(this._endpoint=new URL(r.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){n(e),this.onerror?.(e),this.close();return}t()}),this._eventSource.onmessage=e=>{let t=e,n;try{n=uI.parse(JSON.parse(t.data))}catch(e){this.onerror?.(e);return}this.onmessage?.(n)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new qz(`No auth provider`);if(await rB(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new qz(`Failed to authorize`)}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._endpoint,n);if(!r.ok){let t=await r.text().catch(()=>null);if(r.status===401&&this._authProvider){let{resourceMetadataUrl:t,scope:n}=sB(r);if(this._resourceMetadataUrl=t,this._scope=n,await rB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new qz;return this.send(e)}throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${t}`)}await r.body?.cancel()}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}},EB=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=TR({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}},DB={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},OB=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},kB=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=lz(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??DB}async _authThenStart(){if(!this._authProvider)throw new qz(`No auth provider`);let e;try{e=await rB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new qz;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=cz(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=await(this._fetch??fetch)(this._url,{method:`GET`,headers:n,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new OB(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new EB({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=uI.parse(JSON.parse(e.data));oI(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new qz(`No auth provider`);if(await rB(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new qz(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:nI(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new OB(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=sB(o);if(this._resourceMetadataUrl=t,this._scope=n,await rB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new qz;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=sB(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new OB(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await rB(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new qz;return this.send(e)}}throw new OB(o.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),EI(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`);if(c){if(l?.includes(`text/event-stream`))this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(l?.includes(`application/json`)){let e=await o.json(),t=Array.isArray(e)?e.map(e=>uI.parse(e)):[uI.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new OB(-1,`Unexpected content type: ${l}`)}else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new OB(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};function AB(e){return!!e._zod}function jB(e,t){return AB(e)?LA(e,t):e.safeParse(t)}function MB(e){if(!e)return;let t;if(t=AB(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function NB(e){if(AB(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function PB(e){return e===`completed`||e===`failed`||e===`cancelled`}function FB(e){let t=MB(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=NB(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function IB(e,t){let n=jB(e,t);if(!n.success)throw n.error;return n.data}var LB=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(pI,e=>{this._oncancel(e)}),this.setNotificationHandler(AI,e=>{this._onprogress(e)}),this.setRequestHandler(DI,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(zI,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new xR(sI.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(VI,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new xR(e.error.code,e.error.message,e.error.data))}}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new xR(sI.InvalidParams,`Task not found: ${r}`);if(!PB(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(PB(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[BF]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(HI,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new xR(sI.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(WI,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new xR(sI.InvalidParams,`Task not found: ${e.params.taskId}`);if(PB(n.status))throw new xR(sI.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new xR(sI.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof xR?e:new xR(sI.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),xR.fromError(sI.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),oI(e)||lI(e)?this._onresponse(e):nI(e)?this._onrequest(e,t):iI(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=xR.fromError(sI.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[BF]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:sI.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=YF(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new xR(sI.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:sI.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),oI(e)?n(e):n(new xR(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(oI(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),oI(e)?r(e):r(xR.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof xR?e:new xR(sI.InternalError,String(e))}}return}let i;try{let r=await this.request(e,II,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new xR(sI.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},PB(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new xR(sI.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new xR(sI.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof xR?e:new xR(sI.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[BF]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof xR?e:new xR(sI.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=jB(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(xR.fromError(sI.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},BI,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},UI,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},GI,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[BF]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[BF]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[BF]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=FB(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=IB(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=FB(e);this._notificationHandlers.set(n,n=>{let r=IB(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&nI(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new xR(sI.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new xR(sI.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new xR(sI.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new xR(sI.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=RI.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),PB(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new xR(sI.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(PB(a.status))throw new xR(sI.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=RI.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),PB(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function RB(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zB(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=RB(a)&&RB(i)?{...a,...i}:i}return n}var BB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;var a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),VB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;var t=BB(),n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;var o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),HB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;var t=BB(),n=VB(),r=BB();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=VB();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=k(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=k(this.rhs,e,n),this}get names(){return O(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=k(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(A(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>D(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(j(t),n instanceof e?[n]:n.nodes);if(t!==!1&&this.nodes.length)return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=k(this.condition,e,t),this}get names(){let e=super.names;return O(e,this.condition),this.else&&D(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=k(this.iteration,e,t),this}get names(){return D(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return O(O(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=k(this.iterable,e,t),this}get names(){return D(super.names,this.iterable.names)}},S=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};S.kind=`func`;var C=class extends p{render(e){return`return `+super.render(e)}};C.kind=`return`;var w=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&D(e,this.catch.names),this.finally&&D(e,this.finally.names),e}},T=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};T.kind=`catch`;var E=class extends m{render(e){return`finally`+super.render(e)}};E.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
|
|
235
|
+
`:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new C;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(C)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new w;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new T(e),t(e)}return n&&(this._currNode=r.finally=new E,this.code(n)),this._endBlockNode(T,E)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new S(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(S)}optimize(e=1){for(;e-->0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function D(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function O(e,n){return n instanceof t._CodeOrName?D(e,n.names):e}function k(e,n,r){if(e instanceof t.Name)return i(e);if(!a(e))return e;return new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[]));function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function A(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function j(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${L(e)}`}e.not=j;var M=I(e.operators.AND);function N(...e){return e.reduce(M)}e.and=N;var P=I(e.operators.OR);function F(...e){return e.reduce(P)}e.or=F;function I(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${L(n)} ${e} ${L(r)}`}function L(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),UB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;var t=HB(),n=BB();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;var _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),WB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),GB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;var t=HB(),n=UB(),r=WB();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}var u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),KB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;var t=GB(),n=HB(),r=WB(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),qB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;var t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),JB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),YB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;var t=qB(),n=JB(),r=GB(),i=HB(),a=UB(),o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;var u=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
|
|
236
236
|
|| (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
|
|
237
237
|
|| (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
|
|
238
|
-
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;var g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),YB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;var t=VB(),n=HB();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),XB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;var t=VB(),n=HB(),r=UB(),i=HB();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;var h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),ZB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=VB(),n=UB(),r=XB(),i=WB();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),QB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=VB(),n=HB();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),$B=s(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),eV=s(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else(p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),tV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=HB(),n=$B(),r=eV(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;var o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;var d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;var m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),nV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=GB(),n=JB(),r=qB(),i=JB(),a=YB(),o=ZB(),s=QB(),c=VB(),l=UB(),u=tV(),d=HB(),f=WB();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return N(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);N(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function j(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&M(e),t.return((0,c._)`${l.default.errors} === 0`))}function M({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function N(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>re(e,`$ref`,h.all.$ref.definition));return}p.jtd||F(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),P(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):P(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function P(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&re(e,n.keyword,n.definition,t.type)})}function F(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(I(e,t),e.opts.allowUnionTypes||L(e,t),ee(e,e.dataTypes))}function I(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ne(e.dataTypes,t)||z(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),R(e,t)}}function L(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&z(e,`use allowUnionTypes to allow union type keyword`)}function ee(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>te(t,e))&&z(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function te(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ne(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function R(e,t){let n=[];for(let r of e.dataTypes)ne(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function z(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var B=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,oe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=B;function re(e,t,n,r){let i=new B(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}var ie=/^\/(?:[^~]|~0|~1)*$/,ae=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function oe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!ie.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ae.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=oe})),rV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),iV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=tV();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),aV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=VB(),n=rV(),r=UB(),i=tV(),a=HB(),o=nV(),s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;var h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),oV=c({$id:()=>sV,additionalProperties:()=>!1,default:()=>fV,description:()=>cV,properties:()=>dV,required:()=>uV,type:()=>lV}),sV,cV,lV,uV,dV,fV,pV=o((()=>{sV=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,cV=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,lV=`object`,uV=[`$data`],dV={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},fV={$id:sV,description:cV,type:lV,required:uV,properties:dV,additionalProperties:!1}})),mV=s(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^\d*$/u),a=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),s=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),l=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),u=Array(256);{let e=`0123456789ABCDEF`;for(let t=0;t<256;t++)u[t]=`%`+e[t>>4]+e[t&15]}function d(e){return e<2048?u[192|e>>6]+u[128|e&63]:e<65536?u[224|e>>12]+u[128|e>>6&63]+u[128|e&63]:u[240|e>>18]+u[128|e>>12&63]+u[128|e>>6&63]+u[128|e&63]}function f(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var p=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),m=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),h=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),g=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function _(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!h(e[t])){if(e[t]===`%`&&t+2<e.length&&a(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function v(e){let t=-1,n=0,r=-1,i=0;for(let a=0;a<e.length;a++)e[a]===`0`?(r===-1&&(r=a),i++,i>n&&(n=i,t=r)):(r=-1,i=0);if(n<2)return e.join(`:`);let a=e.slice(0,t).join(`:`),o=e.slice(t+n).join(`:`);return a+`::`+o}function y(e){let t=e.indexOf(`::`);if(t!==-1&&e.indexOf(`::`,t+1)!==-1)return;let n=t===-1?e.split(`:`):e.slice(0,t).split(`:`),i=t===-1?[]:e.slice(t+2).split(`:`);t!==-1&&(n.length===1&&n[0]===``&&(n.length=0),i.length===1&&i[0]===``&&(i.length=0));let a=n.concat(i),o=0;for(let e=0;e<a.length;e++){let n=a[e];if(n===``)return;if(n.indexOf(`.`)!==-1){if(e!==a.length-1||t!==-1&&i.length===0||!r(n))return;o+=2;continue}if(!p(n))return;a[e]=parseInt(n,16).toString(16),o++}if(t===-1)return o===8?v(a):void 0;if(o>=8)return;let s=a.slice(0,n.length);for(let e=o;e<8;e++)s.push(`0`);for(let e=n.length;e<a.length;e++)s.push(a[e]);return v(s)}function b(e){let t=e[0]===`[`&&e[e.length-1]===`]`;if((e[0]===`[`||e[e.length-1]===`]`)&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&m(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(x(n,`:`)<2)return{host:e,isIPV6:!1,error:t};let r=``,i=n.indexOf(`%`);if(i!==-1){let t=n.slice(i,i+3).toLowerCase()===`%25`?3:1;if(r=n.slice(i+t),!_(r))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,i)}let a=y(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(r?`%`+r:``),escapedHost:a+(r?`%25`+r:``),isIPV6:!0}}function x(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function S(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}n.push(t);break}if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}var C={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},w=/[@/?#:]/g,T=/[@/?#]/g;function E(e,t){let n=t?T:w;return n.lastIndex=0,e.replace(n,e=>C[e])}function D(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let i=e.slice(r+1,r+3);if(a(i)){let e=i.toUpperCase(),a=String.fromCharCode(parseInt(e,16));t&&o(a)?n+=a:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function O(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(s(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function k(e,t=!1){let n=``,r=t&&e[0]!==`/`;for(let t=0;t<e.length;t++){let i=e[t];if(i===`%`&&t+2<e.length){let r=e.slice(t+1,t+3);if(a(r)){n+=`%`+r.toUpperCase(),t+=2;continue}}if(i===`/`&&(r=!1),s(i)&&(i!==`:`||!r))n+=i;else{let r=e.charCodeAt(t);if(r<128)n+=u[r];else if(r<55296||r>57343)n+=d(r);else if(r<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=d(65536+(r-55296<<10)+(i-56320)),t++):n+=d(65533)}else n+=d(65533)}}return n}function A(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`%`&&r+2<e.length){let t=e.slice(r+1,r+3);if(a(t)){n+=`%`+t.toUpperCase(),r+=2;continue}}if(t(i))n+=i;else{let t=e.charCodeAt(r);if(t<128)n+=u[t];else if(t<55296||t>57343)n+=d(t);else if(t<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(n+=d(65536+(t-55296<<10)+(i-56320)),r++):n+=d(65533)}else n+=d(65533)}}return n}function j(e){return A(e,l)}function M(e){return A(e,c)}function N(e){return A(e,c)}function P(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function F(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(c(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function I(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function L(e){let t=[];if(e.userinfo!==void 0&&(t.push(j(e.userinfo)),t.push(`@`)),e.host!==void 0){let n=e.host;if(!r(n)){let e=b(n);e.isIPV6!==!0&&e.isIPVFuture!==!0&&(n=D(n,!0),e=b(n)),n=e.isIPV6===!0||e.isIPVFuture===!0?`[${e.escapedHost}]`:E(n,!1)}t.push(n)}if(typeof e.port==`number`||typeof e.port==`string`){let n=String(e.port);if(!i(n))throw TypeError(`URI port is malformed.`);t.push(`:`),t.push(n)}return t.length?t.join(``):void 0}t.exports={nonSimpleDomain:g,recomposeAuthority:L,reescapeHostDelimiters:E,normalizePercentEncoding:D,normalizePathEncoding:O,serializePathEncoding:k,normalizeQueryFragmentEncoding:F,encodeUserinfo:j,encodeQuery:M,encodeFragment:N,escapePreservingEscapes:I,removeDotSegments:S,isIPv4:r,isUUID:n,normalizeIPv6:b,stringArrayToHexStripped:f}})),hV=s(((e,t)=>{var{isUUID:n}=mV(),r=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf(`?`),n=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=n&&n!==`/`?n:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n&&n[0]===e.path){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),gV=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,serializePathEncoding:s,normalizeQueryFragmentEncoding:c,encodeQuery:l,encodeFragment:u,reescapeHostDelimiters:d,isIPv4:f,nonSimpleDomain:p}=mV(),{SCHEMES:m,getSchemeHandler:h}=hV(),g=/^[A-Za-z][A-Za-z0-9+.-]*$/u,_=`URI scheme is malformed.`;function v(e){let t=unescape(String(e));if(!g.test(t))throw TypeError(_);return t}function y(e,t){return typeof e==`string`?e=P(e,t):typeof e==`object`&&(e=N(C(e,t),t)),e}function b(e,t,r){let i=r?Object.assign({scheme:`null`},r):{scheme:`null`},{parsed:a,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:c,malformedHost:l,malformedScheme:u}=M(e,i),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:g,malformedHost:_,malformedScheme:v}=M(t,i);if(o||p||s||m||c||g||l||_||u||v)throw Error(a.error||d.error||`URI is malformed.`);let y=x(a,d,i,!0),b=h(r&&r.scheme||y.scheme),S=y.host,w=S!==void 0&&S!==``&&(f(S)||n(S).isIPV6);j(y,r||{},b,w);let T=S&&S.indexOf(`%`)!==-1&&!/\P{ASCII}/u.test(S);if(y.error&&!T)throw Error(y.error);return i.skipEscape=!0,C(y,i)}function x(e,t,n,i){let a={};return i||(e=N(C(e,n),n),t=N(C(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):(a.path=(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?`/`+t.path:e.path?e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,a.query=t.query===void 0?e.query:t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function S(e,t,n){let r=I(e,n),i=I(t,n);return r!==void 0&&i!==void 0&&r===i}function C(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[];n.scheme&&=v(n.scheme);let d=h(o.scheme||n.scheme);d&&d.serialize&&d.serialize(n,o);let f=n.userinfo!==void 0||n.host!==void 0||n.port!==void 0,p=!o.skipEscape&&n.scheme===void 0&&!f;n.path!==void 0&&(n.path=o.skipEscape?a(n.path):s(n.path,p)),o.reference!==`suffix`&&n.scheme&&(n.scheme=v(n.scheme),c.push(n.scheme,`:`));let m=i(n);if(m!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(m),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!d||!d.absolutePath)&&(e=r(e)),p&&(e=s(e,!0)),m===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,l(n.query)),n.fragment!==void 0&&c.push(`#`,u(n.fragment)),c.join(``)}var w=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,T=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,E=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function D(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function O(e){if(e===void 0)return!1;let t=e.indexOf(`%`);for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf(`%`,t+3)}return!1}function k(e){return e[0]===`[`&&e[e.length-1]===`]`}function A(e){let t=e[4];return O(e[3])||t!==void 0&&!k(t)&&O(t)||O(e[6])||O(e[7])||O(e[8])}function j(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&!k(e.host)&&(t.domainHost||n&&n.domainHost)&&r===!1&&p(e.host))try{e.host=new URL(`http://`+e.host).hostname}catch(t){return e.error=e.error||`Host's domain name can not be converted to ASCII: `+t,!0}return!1}function M(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},s=!1,l=!1,u=!1,p=!1,v=!1,y=!1,b=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let x=e.match(T);x!==null&&x[1].indexOf(`\\`)!==-1&&(i.error=`URI authority must not contain a literal backslash.`,s=!0);let S=e.match(E);if(S!==null){let e=S[1],t=e.replace(/[\t\n\r]/g,``);t.length>=2&&(t.slice(0,2)===`//`?e.length!==t.length&&(i.error=i.error||`URI authority introducer must not contain whitespace.`,s=!0):(i.error=i.error||`URI authority must not contain a literal backslash.`,s=!0))}let C=e.match(w);if(C){if(i.scheme=C[1],i.userinfo=C[3],i.host=C[4],i.port=parseInt(C[5],10),i.path=C[6]||``,i.query=C[7],i.fragment=C[8],i.scheme!==void 0){let e=unescape(i.scheme);g.test(e)?i.scheme=e.toLowerCase():(i.error=i.error||_,y=!0)}l=A(C),l&&(i.error=i.error||`URI contains malformed percent-encoding.`),isNaN(i.port)&&(i.port=C[5]);let t=D(i,C);if(t!==void 0&&(i.error=i.error||t,s=!0),i.host){if(f(i.host)===!1){let e=k(i.host),t=i.host.indexOf(`[`)!==-1||i.host.indexOf(`]`)!==-1,r=n(i.host);b=r.isIPV6||r.isIPVFuture===!0,v=t&&(!e||r.error===!0),i.host=b?r.host:r.host.toLowerCase(),v&&(i.error=i.error||`URI host is malformed.`,s=!0)}else b=!0}i.reference=i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?`same-document`:i.scheme===void 0?`relative`:i.fragment===void 0?`absolute`:`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let x=h(r.scheme||i.scheme);if(v||(p=j(i,r,x,b)),e.indexOf(`%`)!==-1&&i.host!==void 0&&!v){let e=b?i.host:a(i.host,!0);b||(e=a(e.toLowerCase())),i.host=d(e,b)}(!x||x&&!x.skipNormalize)&&(i.path&&=o(i.path),i.query&&=c(i.query),i.fragment&&=c(i.fragment)),x&&x.parse&&(x.parse(i,r),x===m.urn&&i.nid===void 0&&(u=!0))}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:s,malformedPercentEncoding:l,malformedSchemeSpecific:u,malformedHost:p,malformedScheme:y}}function N(e,t){return M(e,t).parsed}function P(e,t){return F(e,t).normalized}function F(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}=M(e,t);return{normalized:r||i||a||o||s?e:C(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}}function I(e,t){if(typeof e!=`string`&&typeof e!=`object`)return;let n;try{n=typeof e==`string`?e:C(e,t)}catch{return}let{normalized:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:c}=F(n,t);return i||a||o||s||c?void 0:r}var L={SCHEMES:m,normalize:y,resolve:b,resolveComponent:x,equal:S,serialize:C,parse:N};t.exports=L,t.exports.default=L,t.exports.fastUri=L})),_V=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=gV();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),vV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=nV();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=VB();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});var r=rV(),i=iV(),a=KB(),o=aV(),s=VB(),c=tV(),l=JB(),u=HB(),f=(pV(),d(oV).default),p=_V(),m=(e,t)=>new RegExp(e,t);m.code=`new RegExp`;var h=[`removeAdditional`,`useDefaults`,`coerceTypes`],g=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),_={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},v={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`},y=200;function b(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??m,a=e.uriResolver??p.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??y,loopEnum:e.loopEnum??y,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var x=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...b(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,_,e,`NOT SUPPORTED`),S.call(this,v,e,`DEPRECATED`,`warn`),this._metaOpts=D.call(this),e.formats&&T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),w.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f;n===`id`&&(r={...f},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=C.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=C.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(j.call(this,n,t),!t)return(0,u.eachItem)(n,e=>M.call(this,e)),this;P.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>M.call(this,e,r):e=>r.type.forEach(t=>M.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=I(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=r.default,x.MissingRefError=i.default,e.default=x;function S(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function C(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function w(){let e=this.opts.schemas;if(e){if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}}function T(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function D(){let e={...this.opts};for(let t of h)delete e[t];return e}var O={log(){},warn(){},error(){}};function k(e){if(e===!1)return O;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}var A=/^[a-z_$][a-z0-9_$:-]*$/i;function j(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!A.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function M(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function N(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function P(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=I(t)),e.validateSchema=this.compile(t,!0))}var F={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function I(e){return{anyOf:[e,F]}}})),yV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),bV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;var t=iV(),n=XB(),r=VB(),i=UB(),a=aV(),o=HB(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0){if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}}if(l.items!==!0){if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}}e.callRef=l,e.default=s})),xV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=yV(),n=bV();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),SV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),CV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),wV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),TV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB(),r=wV();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),EV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=XB(),n=HB(),r=VB();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),DV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),OV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=XB(),n=VB(),r=HB();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),kV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),AV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=$B();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),jV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=JB(),n=VB(),r=HB(),i=AV();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),MV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB(),r=AV();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),NV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB(),r=AV();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),PV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=SV(),n=CV(),r=TV(),i=EV(),a=DV(),o=OV(),s=kV(),c=jV(),l=MV(),u=NV();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),FV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;var t=VB(),n=HB(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),IV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;var t=VB(),n=HB(),r=XB(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),LV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=IV();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),RV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB(),r=XB(),i=FV();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),zV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),BV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=VB(),n=HB(),r=XB();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
238
|
+
|| ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;var g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),XB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;var t=HB(),n=UB();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),ZB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;var t=HB(),n=UB(),r=WB(),i=UB();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;var h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),QB=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;var t=HB(),n=WB(),r=ZB(),i=GB();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),$B=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;var t=HB(),n=UB();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),eV=s(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),tV=s(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else(p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),nV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;var t=UB(),n=eV(),r=tV(),i=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;var o=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;var d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;var m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),rV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;var t=KB(),n=YB(),r=JB(),i=YB(),a=XB(),o=QB(),s=$B(),c=HB(),l=WB(),u=nV(),d=UB(),f=GB();function p(e){if(S(e)&&(w(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&A(e),D(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),T(e),j(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(S(e)&&(w(e),x(e))){C(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function S(e){return typeof e.schema!=`boolean`}function C(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&A(e),O(e),k(e);let a=r.const(`_errs`,l.default.errors);T(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function w(e){(0,d.checkUnknownRules)(e),E(e)}function T(e,t){if(e.opts.jtd)return N(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);N(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function E(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function D(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function O(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function k(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function A({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function j(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&M(e),t.return((0,c._)`${l.default.errors} === 0`))}function M({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function N(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>re(e,`$ref`,h.all.$ref.definition));return}p.jtd||F(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),P(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):P(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function P(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&re(e,n.keyword,n.definition,t.type)})}function F(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(I(e,t),e.opts.allowUnionTypes||L(e,t),ee(e,e.dataTypes))}function I(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ne(e.dataTypes,t)||z(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),R(e,t)}}function L(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&z(e,`use allowUnionTypes to allow union type keyword`)}function ee(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>te(t,e))&&z(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function te(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ne(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function R(e,t){let n=[];for(let r of e.dataTypes)ne(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function z(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var B=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,oe(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=B;function re(e,t,n,r){let i=new B(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}var ie=/^\/(?:[^~]|~0|~1)*$/,ae=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function oe(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!ie.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=ae.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=oe})),iV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),aV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=nV();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),oV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;var t=HB(),n=iV(),r=WB(),i=nV(),a=UB(),o=rV(),s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;var h=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),sV=c({$id:()=>cV,additionalProperties:()=>!1,default:()=>pV,description:()=>lV,properties:()=>fV,required:()=>dV,type:()=>uV}),cV,lV,uV,dV,fV,pV,mV=o((()=>{cV=`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,lV=`Meta-schema for $data reference (JSON AnySchema extension proposal)`,uV=`object`,dV=[`$data`],fV={$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},pV={$id:cV,description:lV,type:uV,required:dV,properties:fV,additionalProperties:!1}})),hV=s(((e,t)=>{var n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^\d*$/u),a=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),s=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),c=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),l=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),u=Array(256);{let e=`0123456789ABCDEF`;for(let t=0;t<256;t++)u[t]=`%`+e[t>>4]+e[t&15]}function d(e){return e<2048?u[192|e>>6]+u[128|e&63]:e<65536?u[224|e>>12]+u[128|e>>6&63]+u[128|e&63]:u[240|e>>18]+u[128|e>>12&63]+u[128|e>>6&63]+u[128|e&63]}function f(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}var p=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),m=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),h=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),g=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function _(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!h(e[t])){if(e[t]===`%`&&t+2<e.length&&a(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function v(e){let t=-1,n=0,r=-1,i=0;for(let a=0;a<e.length;a++)e[a]===`0`?(r===-1&&(r=a),i++,i>n&&(n=i,t=r)):(r=-1,i=0);if(n<2)return e.join(`:`);let a=e.slice(0,t).join(`:`),o=e.slice(t+n).join(`:`);return a+`::`+o}function y(e){let t=e.indexOf(`::`);if(t!==-1&&e.indexOf(`::`,t+1)!==-1)return;let n=t===-1?e.split(`:`):e.slice(0,t).split(`:`),i=t===-1?[]:e.slice(t+2).split(`:`);t!==-1&&(n.length===1&&n[0]===``&&(n.length=0),i.length===1&&i[0]===``&&(i.length=0));let a=n.concat(i),o=0;for(let e=0;e<a.length;e++){let n=a[e];if(n===``)return;if(n.indexOf(`.`)!==-1){if(e!==a.length-1||t!==-1&&i.length===0||!r(n))return;o+=2;continue}if(!p(n))return;a[e]=parseInt(n,16).toString(16),o++}if(t===-1)return o===8?v(a):void 0;if(o>=8)return;let s=a.slice(0,n.length);for(let e=o;e<8;e++)s.push(`0`);for(let e=n.length;e<a.length;e++)s.push(a[e]);return v(s)}function b(e){let t=e[0]===`[`&&e[e.length-1]===`]`;if((e[0]===`[`||e[e.length-1]===`]`)&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&m(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(x(n,`:`)<2)return{host:e,isIPV6:!1,error:t};let r=``,i=n.indexOf(`%`);if(i!==-1){let t=n.slice(i,i+3).toLowerCase()===`%25`?3:1;if(r=n.slice(i+t),!_(r))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,i)}let a=y(n);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(r?`%`+r:``),escapedHost:a+(r?`%25`+r:``),isIPV6:!0}}function x(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function S(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}n.push(t);break}if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}var C={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},w=/[@/?#:]/g,T=/[@/?#]/g;function E(e,t){let n=t?T:w;return n.lastIndex=0,e.replace(n,e=>C[e])}function D(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let i=e.slice(r+1,r+3);if(a(i)){let e=i.toUpperCase(),a=String.fromCharCode(parseInt(e,16));t&&o(a)?n+=a:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function O(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(s(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function k(e,t=!1){let n=``,r=t&&e[0]!==`/`;for(let t=0;t<e.length;t++){let i=e[t];if(i===`%`&&t+2<e.length){let r=e.slice(t+1,t+3);if(a(r)){n+=`%`+r.toUpperCase(),t+=2;continue}}if(i===`/`&&(r=!1),s(i)&&(i!==`:`||!r))n+=i;else{let r=e.charCodeAt(t);if(r<128)n+=u[r];else if(r<55296||r>57343)n+=d(r);else if(r<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);i>=56320&&i<=57343?(n+=d(65536+(r-55296<<10)+(i-56320)),t++):n+=d(65533)}else n+=d(65533)}}return n}function A(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`%`&&r+2<e.length){let t=e.slice(r+1,r+3);if(a(t)){n+=`%`+t.toUpperCase(),r+=2;continue}}if(t(i))n+=i;else{let t=e.charCodeAt(r);if(t<128)n+=u[t];else if(t<55296||t>57343)n+=d(t);else if(t<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(n+=d(65536+(t-55296<<10)+(i-56320)),r++):n+=d(65533)}else n+=d(65533)}}return n}function j(e){return A(e,l)}function M(e){return A(e,c)}function N(e){return A(e,c)}function P(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function F(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));o(i)?t+=i:t+=`%`+e,n+=2;continue}}if(c(r))t+=r;else{let i=e.charCodeAt(n);if(i<128)t+=P(i)?r:u[i];else if(i<55296||i>57343)t+=d(i);else if(i<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=d(65536+(i-55296<<10)+(r-56320)),n++):t+=d(65533)}else t+=d(65533)}}return t}function I(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(a(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function L(e){let t=[];if(e.userinfo!==void 0&&(t.push(j(e.userinfo)),t.push(`@`)),e.host!==void 0){let n=e.host;if(!r(n)){let e=b(n);e.isIPV6!==!0&&e.isIPVFuture!==!0&&(n=D(n,!0),e=b(n)),n=e.isIPV6===!0||e.isIPVFuture===!0?`[${e.escapedHost}]`:E(n,!1)}t.push(n)}if(typeof e.port==`number`||typeof e.port==`string`){let n=String(e.port);if(!i(n))throw TypeError(`URI port is malformed.`);t.push(`:`),t.push(n)}return t.length?t.join(``):void 0}t.exports={nonSimpleDomain:g,recomposeAuthority:L,reescapeHostDelimiters:E,normalizePercentEncoding:D,normalizePathEncoding:O,serializePathEncoding:k,normalizeQueryFragmentEncoding:F,encodeUserinfo:j,encodeQuery:M,encodeFragment:N,escapePreservingEscapes:I,removeDotSegments:S,isIPv4:r,isUUID:n,normalizeIPv6:b,stringArrayToHexStripped:f}})),gV=s(((e,t)=>{var{isUUID:n}=hV(),r=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf(`?`),n=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=n&&n!==`/`?n:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n&&n[0]===e.path){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}var h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),_V=s(((e,t)=>{var{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,serializePathEncoding:s,normalizeQueryFragmentEncoding:c,encodeQuery:l,encodeFragment:u,reescapeHostDelimiters:d,isIPv4:f,nonSimpleDomain:p}=hV(),{SCHEMES:m,getSchemeHandler:h}=gV(),g=/^[A-Za-z][A-Za-z0-9+.-]*$/u,_=`URI scheme is malformed.`;function v(e){let t=unescape(String(e));if(!g.test(t))throw TypeError(_);return t}function y(e,t){return typeof e==`string`?e=P(e,t):typeof e==`object`&&(e=N(C(e,t),t)),e}function b(e,t,r){let i=r?Object.assign({scheme:`null`},r):{scheme:`null`},{parsed:a,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:c,malformedHost:l,malformedScheme:u}=M(e,i),{parsed:d,malformedAuthorityOrPort:p,malformedPercentEncoding:m,malformedSchemeSpecific:g,malformedHost:_,malformedScheme:v}=M(t,i);if(o||p||s||m||c||g||l||_||u||v)throw Error(a.error||d.error||`URI is malformed.`);let y=x(a,d,i,!0),b=h(r&&r.scheme||y.scheme),S=y.host,w=S!==void 0&&S!==``&&(f(S)||n(S).isIPV6);j(y,r||{},b,w);let T=S&&S.indexOf(`%`)!==-1&&!/\P{ASCII}/u.test(S);if(y.error&&!T)throw Error(y.error);return i.skipEscape=!0,C(y,i)}function x(e,t,n,i){let a={};return i||(e=N(C(e,n),n),t=N(C(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):(a.path=(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?`/`+t.path:e.path?e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,a.query=t.query===void 0?e.query:t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function S(e,t,n){let r=I(e,n),i=I(t,n);return r!==void 0&&i!==void 0&&r===i}function C(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[];n.scheme&&=v(n.scheme);let d=h(o.scheme||n.scheme);d&&d.serialize&&d.serialize(n,o);let f=n.userinfo!==void 0||n.host!==void 0||n.port!==void 0,p=!o.skipEscape&&n.scheme===void 0&&!f;n.path!==void 0&&(n.path=o.skipEscape?a(n.path):s(n.path,p)),o.reference!==`suffix`&&n.scheme&&(n.scheme=v(n.scheme),c.push(n.scheme,`:`));let m=i(n);if(m!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(m),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!d||!d.absolutePath)&&(e=r(e)),p&&(e=s(e,!0)),m===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,l(n.query)),n.fragment!==void 0&&c.push(`#`,u(n.fragment)),c.join(``)}var w=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,T=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,E=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function D(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function O(e){if(e===void 0)return!1;let t=e.indexOf(`%`);for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf(`%`,t+3)}return!1}function k(e){return e[0]===`[`&&e[e.length-1]===`]`}function A(e){let t=e[4];return O(e[3])||t!==void 0&&!k(t)&&O(t)||O(e[6])||O(e[7])||O(e[8])}function j(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&!k(e.host)&&(t.domainHost||n&&n.domainHost)&&r===!1&&p(e.host))try{e.host=new URL(`http://`+e.host).hostname}catch(t){return e.error=e.error||`Host's domain name can not be converted to ASCII: `+t,!0}return!1}function M(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},s=!1,l=!1,u=!1,p=!1,v=!1,y=!1,b=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let x=e.match(T);x!==null&&x[1].indexOf(`\\`)!==-1&&(i.error=`URI authority must not contain a literal backslash.`,s=!0);let S=e.match(E);if(S!==null){let e=S[1],t=e.replace(/[\t\n\r]/g,``);t.length>=2&&(t.slice(0,2)===`//`?e.length!==t.length&&(i.error=i.error||`URI authority introducer must not contain whitespace.`,s=!0):(i.error=i.error||`URI authority must not contain a literal backslash.`,s=!0))}let C=e.match(w);if(C){if(i.scheme=C[1],i.userinfo=C[3],i.host=C[4],i.port=parseInt(C[5],10),i.path=C[6]||``,i.query=C[7],i.fragment=C[8],i.scheme!==void 0){let e=unescape(i.scheme);g.test(e)?i.scheme=e.toLowerCase():(i.error=i.error||_,y=!0)}l=A(C),l&&(i.error=i.error||`URI contains malformed percent-encoding.`),isNaN(i.port)&&(i.port=C[5]);let t=D(i,C);if(t!==void 0&&(i.error=i.error||t,s=!0),i.host){if(f(i.host)===!1){let e=k(i.host),t=i.host.indexOf(`[`)!==-1||i.host.indexOf(`]`)!==-1,r=n(i.host);b=r.isIPV6||r.isIPVFuture===!0,v=t&&(!e||r.error===!0),i.host=b?r.host:r.host.toLowerCase(),v&&(i.error=i.error||`URI host is malformed.`,s=!0)}else b=!0}i.reference=i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?`same-document`:i.scheme===void 0?`relative`:i.fragment===void 0?`absolute`:`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let x=h(r.scheme||i.scheme);if(v||(p=j(i,r,x,b)),e.indexOf(`%`)!==-1&&i.host!==void 0&&!v){let e=b?i.host:a(i.host,!0);b||(e=a(e.toLowerCase())),i.host=d(e,b)}(!x||x&&!x.skipNormalize)&&(i.path&&=o(i.path),i.query&&=c(i.query),i.fragment&&=c(i.fragment)),x&&x.parse&&(x.parse(i,r),x===m.urn&&i.nid===void 0&&(u=!0))}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:s,malformedPercentEncoding:l,malformedSchemeSpecific:u,malformedHost:p,malformedScheme:y}}function N(e,t){return M(e,t).parsed}function P(e,t){return F(e,t).normalized}function F(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}=M(e,t);return{normalized:r||i||a||o||s?e:C(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:o,malformedScheme:s}}function I(e,t){if(typeof e!=`string`&&typeof e!=`object`)return;let n;try{n=typeof e==`string`?e:C(e,t)}catch{return}let{normalized:r,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:c}=F(n,t);return i||a||o||s||c?void 0:r}var L={SCHEMES:m,normalize:y,resolve:b,resolveComponent:x,equal:S,serialize:C,parse:N};t.exports=L,t.exports.default=L,t.exports.fastUri=L})),vV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=_V();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),yV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=rV();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=HB();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});var r=iV(),i=aV(),a=qB(),o=oV(),s=HB(),c=nV(),l=YB(),u=UB(),f=(mV(),d(sV).default),p=vV(),m=(e,t)=>new RegExp(e,t);m.code=`new RegExp`;var h=[`removeAdditional`,`useDefaults`,`coerceTypes`],g=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),_={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},v={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`},y=200;function b(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??m,a=e.uriResolver??p.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??y,loopEnum:e.loopEnum??y,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var x=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...b(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:g,es5:t,lines:n}),this.logger=k(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),S.call(this,_,e,`NOT SUPPORTED`),S.call(this,v,e,`DEPRECATED`,`warn`),this._metaOpts=D.call(this),e.formats&&T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),w.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f;n===`id`&&(r={...f},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=C.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=C.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(j.call(this,n,t),!t)return(0,u.eachItem)(n,e=>M.call(this,e)),this;P.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>M.call(this,e,r):e=>r.type.forEach(t=>M.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=I(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};x.ValidationError=r.default,x.MissingRefError=i.default,e.default=x;function S(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function C(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function w(){let e=this.opts.schemas;if(e){if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}}function T(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function D(){let e={...this.opts};for(let t of h)delete e[t];return e}var O={log(){},warn(){},error(){}};function k(e){if(e===!1)return O;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}var A=/^[a-z_$][a-z0-9_$:-]*$/i;function j(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!A.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function M(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?N.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function N(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function P(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=I(t)),e.validateSchema=this.compile(t,!0))}var F={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function I(e){return{anyOf:[e,F]}}})),bV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),xV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;var t=aV(),n=ZB(),r=HB(),i=WB(),a=oV(),o=UB(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);if(h instanceof a.SchemaEnv)return _(h);return v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0){if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}}if(l.items!==!0){if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}}e.callRef=l,e.default=s})),SV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=bV(),n=xV();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),CV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),wV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),TV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),EV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB(),r=TV();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),DV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ZB(),n=UB(),r=HB();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),OV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),kV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ZB(),n=HB(),r=UB();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),AV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),jV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=eV();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),MV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=YB(),n=HB(),r=UB(),i=jV();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),NV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB(),r=jV();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),PV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB(),r=jV();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),FV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=CV(),n=wV(),r=EV(),i=DV(),a=OV(),o=kV(),s=AV(),c=MV(),l=NV(),u=PV();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),IV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;var t=HB(),n=UB(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),LV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;var t=HB(),n=UB(),r=ZB(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),RV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=LV();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),zV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB(),r=ZB(),i=IV();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),BV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),VV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;var t=HB(),n=UB(),r=ZB();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
|
|
239
239
|
missingProperty: ${i},
|
|
240
240
|
depsCount: ${n},
|
|
241
|
-
deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),VV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),HV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=XB(),n=VB(),r=UB(),i=HB();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),UV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=nV(),n=XB(),r=HB(),i=HV();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),WV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=XB(),n=VB(),r=HB(),i=HB();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),GV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),KV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:XB().validateUnion,error:{message:`must match a schema in anyOf`}}})),qV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),JV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),YV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=HB(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),XV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),ZV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=FV(),n=LV(),r=IV(),i=RV(),a=zV(),o=BV(),s=VV(),c=HV(),l=UV(),u=WV(),d=GV(),f=KV(),p=qV(),m=JV(),h=YV(),g=XV();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),QV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),$V=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[QV().default]})),eH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),tH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=xV(),n=PV(),r=ZV(),i=$V(),a=eH();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),nH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),rH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=VB(),n=nH(),r=aV(),i=iV(),a=HB();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),iH=c({$id:()=>oH,$schema:()=>aH,default:()=>dH,definitions:()=>cH,properties:()=>uH,title:()=>sH,type:()=>lH}),aH,oH,sH,cH,lH,uH,dH,fH=o((()=>{aH=`http://json-schema.org/draft-07/schema#`,oH=`http://json-schema.org/draft-07/schema#`,sH=`Core schema meta-schema`,cH={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},lH=[`object`,`boolean`],uH={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},dH={$schema:aH,$id:oH,title:sH,definitions:cH,type:lH,properties:uH,default:!0}})),pH=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var n=vV(),r=tH(),i=rH(),a=(fH(),d(iH).default),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`,c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=nV();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=VB();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var f=rV();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=iV();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),mH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:E,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:w},double:{type:`number`,validate:w},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}var d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}var h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}var v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}var b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function w(){return!0}var T=/[^\\]\\Z/;function E(e){if(T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),hH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=pH(),n=VB(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),gH=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=mH(),r=hH(),i=VB(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),_H=u(pH(),1),vH=u(gH(),1);function yH(){let e=new _H.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,vH.default)(e),e}var bH=class{constructor(e){this._ajv=e??yH()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},xH=class{constructor(e){this._client=e}async*callToolStream(e,t=PL,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new bR(oI.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new bR(oI.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof bR){yield{type:`error`,error:e};return}yield{type:`error`,error:new bR(oI.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function SH(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);if(t===`tools/call`&&!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`)}function CH(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`)}}function wH(e,t){if(e&&typeof t==`object`&&t){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&wH(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&wH(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&wH(n,t)}}function TH(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var EH=class extends IB{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new bH,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,LL,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,OL,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,sL,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new xH(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=RB(this._capabilities,e)}setRequestHandler(e,t){let n=jB(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(kB(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=AB(sR,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new bR(oI.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=TH(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new bR(oI.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new bR(oI.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=AB(FI,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new bR(oI.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=AB(uR,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new bR(oI.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{wH(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=AB(ZL,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new bR(oI.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=AB(FI,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new bR(oI.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=AB(i.tools||i.toolChoice?$L:QL,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new bR(oI.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:LF,capabilities:this._capabilities,clientInfo:this._clientInfo}},CI,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!RF.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if(e===`notifications/roots/list_changed`&&!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){SH(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&CH(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},uI,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},hR,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},uI,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},DL,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},_L,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},eL,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},nL,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},oL,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},uI,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},uI,t)}async callTool(e,t=PL,n){if(this.isToolTaskRequired(e.name))throw new bR(oI.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new bR(oI.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new bR(oI.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof bR?e:new bR(oI.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},NL,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=RL.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{let e=await r();s(null,e)}catch(e){let t=e instanceof Error?e:Error(String(e));s(t,null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}};function DH(e,t){if(!e)throw Error(t)}var OH=3e3,kH=5e3,AH=3e5;function jH(e){let{url:t,clientName:n,clientUri:r,callbackUrl:i=typeof window<`u`?Gk(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:a=`mcp:auth`,clientConfig:o={},customHeaders:s={},debug:c=!1,autoRetry:l=!1,autoReconnect:u=OH,transportType:d=`auto`,preventAutoAuth:f=!1,onPopupWindow:p}=e,[m,h]=(0,b.useState)(`discovering`),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)([]),[x,S]=(0,b.useState)([]),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(void 0),[D,O]=(0,b.useState)([]),[k,A]=(0,b.useState)(void 0),j=(0,b.useRef)(null),M=(0,b.useRef)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(!1),F=(0,b.useRef)(!0),I=(0,b.useRef)(0),L=(0,b.useRef)(null),ee=(0,b.useRef)(m),te=(0,b.useRef)(u),ne=(0,b.useRef)(null);(0,b.useEffect)(()=>{ee.current=m,te.current=u},[m,u]);let R=(0,b.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t;console[e](`[useMcp] ${r}`),F.current&&O(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[]),z=(0,b.useCallback)(async(e=!1)=>{e||R(`info`,`Disconnecting...`),P.current=!1,L.current&&clearTimeout(L.current),L.current=null;let t=M.current;if(j.current=null,M.current=null,F.current&&!e&&(h(`discovering`),_([]),y([]),S([]),w([]),E(void 0),A(void 0)),t)try{await t.close(),e||R(`debug`,`Transport closed`)}catch(t){e||R(`warn`,`Error closing transport:`,t)}},[R]),B=(0,b.useCallback)((e,t)=>{if(R(`error`,e,t??``),F.current){h(`failed`),E(e);let t=N.current?.getLastAttemptedAuthUrl();t&&(A(t),R(`info`,`Manual authentication URL may be available.`,t))}P.current=!1},[R]),re=(0,b.useCallback)(async()=>{if(P.current){R(`debug`,`Connection attempt already in progress.`);return}if(!F.current){R(`debug`,`Connect called after unmount, aborting.`);return}P.current=!0,I.current+=1,E(void 0),A(void 0),ne.current=null,h(`discovering`),R(`info`,`Connecting attempt #${I.current} to ${t}...`),N.current||(N.current=new qk(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized in connect.`)),j.current||(j.current=new EH({name:o.name||`use-mcp-react-client`,version:o.version||`0.1.0`},{capabilities:{}}),R(`debug`,`MCP Client initialized in connect.`));let e=async e=>{R(`info`,`Attempting connection with ${e.toUpperCase()} transport...`),ee.current!==`authenticating`&&h(`connecting`);let n;try{DH(N.current,`Auth Provider must be initialized`),DH(j.current,`Client must be initialized`),M.current&&=(await M.current.close().catch(e=>R(`warn`,`Error closing previous transport: ${e.message}`)),null);let r={authProvider:N.current,requestInit:{headers:{Accept:`application/json, text/event-stream`,...s}}},i=Gk(t),a=new URL(i);R(`debug`,`Creating ${e.toUpperCase()} transport for URL: ${a.toString()}`),R(`debug`,`Transport options:`,{authProvider:!!N.current,headers:s,url:a.toString()}),e===`http`?(R(`debug`,`Creating StreamableHTTPClientTransport...`),n=new OB(a,r),R(`debug`,`StreamableHTTPClientTransport created successfully`)):(R(`debug`,`Creating SSEClientTransport...`),n=new wB(a,r),R(`debug`,`SSEClientTransport created successfully`)),M.current=n,R(`debug`,`${e.toUpperCase()} transport created and assigned to ref.`)}catch(t){return B(`Failed to create ${e.toUpperCase()} transport: ${t instanceof Error?t.message:String(t)}`,t instanceof Error?t:void 0),`failed`}n.onmessage=e=>{R(`debug`,`[Transport] Received: ${JSON.stringify(e)}`),j.current?.handleMessage?.(e)},n.onerror=t=>{R(`warn`,`Transport error event (${e.toUpperCase()}):`,t),R(`debug`,`Error details:`,{message:t.message,stack:t.stack,name:t.name,cause:t.cause}),B(`Transport error (${e.toUpperCase()}): ${t.message}`,t)},n.onclose=()=>{if(!F.current||P.current)return;R(`info`,`Transport connection closed (${ne.current||`unknown`} type).`);let e=ee.current,t=te.current;if(e===`ready`&&t){let e=typeof t==`number`?t:OH;R(`info`,`Attempting to reconnect in ${e}ms...`),h(`connecting`),setTimeout(()=>{F.current&&re()},e)}else e!==`failed`&&e!==`authenticating`&&B(`Connection closed unexpectedly.`)};try{R(`info`,`Connecting client via ${e.toUpperCase()}...`),R(`debug`,`About to call client.connect() with transport instance`),R(`debug`,`Transport instance type: ${n.constructor.name}`),await j.current.connect(n),R(`info`,`Client connected via ${e.toUpperCase()}. Loading tools, resources, and prompts...`),ne.current=e,h(`loading`);let t=await j.current.request({method:`tools/list`},NL),r={resources:[],resourceTemplates:[]};try{r=await j.current.request({method:`resources/list`},eL)}catch(e){R(`debug`,`Server does not support resources/list method`,e)}let i={prompts:[]};try{i=await j.current.request({method:`prompts/list`},_L)}catch(e){R(`debug`,`Server does not support prompts/list method`,e)}if(F.current){_(t.tools),y(r.resources),S(Array.isArray(r.resourceTemplates)?r.resourceTemplates:[]),w(i.prompts);let e=[`Loaded ${t.tools.length} tools`];return(r.resources.length>0||r.resourceTemplates&&r.resourceTemplates.length>0)&&(e.push(`${r.resources.length} resources`),Array.isArray(r.resourceTemplates)&&r.resourceTemplates.length>0&&e.push(`${r.resourceTemplates.length} resource templates`)),i.prompts.length>0&&e.push(`${i.prompts.length} prompts`),R(`info`,e.join(`, `)+`.`),h(`ready`),I.current=0,`success`}return`failed`}catch(n){R(`debug`,`Client connect error via ${e.toUpperCase()}:`,n),R(`debug`,`Connect error details:`,{message:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:`N/A`,name:n instanceof Error?n.name:`Unknown`,cause:n instanceof Error?n.cause:void 0});let r=n instanceof Error?n:Error(String(n)),i=r.message,a=i.includes(`404`)||i.includes(`Not Found`),o=i.includes(`405`)||i.includes(`Method Not Allowed`),s=i===`Failed to fetch`||i===`NetworkError when attempting to fetch resource.`||i===`Load failed`;if(e===`http`&&(a||o||s))return R(`warn`,`HTTP transport failed (${s?`CORS`:a?`404`:`405`}).`),`fallback`;if(r instanceof Kz||i.includes(`Unauthorized`)||i.includes(`401`)){R(`info`,`Authentication required.`),DH(N.current,`Auth Provider not available for auth flow`);let e=await N.current.tokens();if(f&&!e)return R(`info`,`Authentication required but auto-auth prevented. User action needed.`),h(`pending_auth`),`auth_redirect`;ee.current!==`authenticating`&&ee.current!==`pending_auth`&&(h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},AH));try{let e=await nB(N.current,{serverUrl:t});if(!F.current)return`failed`;if(e===`AUTHORIZED`)return R(`info`,`Authentication successful via existing token or refresh. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re(),`failed`;if(e===`REDIRECT`)return R(`info`,`Redirecting for authentication. Waiting for callback...`),`auth_redirect`}catch(e){return F.current?(L.current&&clearTimeout(L.current),B(`Failed to initiate authentication: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0),`failed`):`failed`}}return B(`Failed to connect via ${e.toUpperCase()}: ${i}`,r),`failed`}},c=`failed`;if(console.log({transportType:d}),d===`sse`)R(`debug`,`Using SSE-only transport mode`),c=await e(`sse`);else if(d===`http`)R(`debug`,`Using HTTP-only transport mode`),c=await e(`http`);else{R(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);if(t===`fallback`&&F.current&&ee.current!==`authenticating`){R(`info`,`HTTP failed, attempting SSE fallback...`);let t=await e(`sse`);c=t,t===`failed`&&F.current}else c=t}(c===`success`||c===`failed`)&&(P.current=!1),R(`debug`,`Connection sequence finished with status: ${c}`)},[R,B,z,nB,t,a,n,r,i,o.name,o.version]),ie=(0,b.useCallback)(async(e,n)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot call tool "${e}".`);R(`info`,`Calling tool: ${e}`,n);try{let t=await j.current.request({method:`tools/call`,params:{name:e,arguments:n}},PL);return R(`info`,`Tool "${e}" call successful:`,t),t}catch(n){R(`error`,`Error calling tool "${e}": ${n instanceof Error?n.message:String(n)}`,n);let r=n instanceof Error?n:Error(String(n));if(r instanceof Kz||r.message.includes(`Unauthorized`)||r.message.includes(`401`)){R(`warn`,`Tool call unauthorized, attempting re-authentication...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},AH);try{DH(N.current,`Auth Provider not available for tool re-auth`);let e=await nB(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Re-authentication successful. Retrying tool call is recommended, or reconnecting.`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for re-authentication for tool call.`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Re-authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}if(ee.current!==`authenticating`)throw n;return}},[m,t,R,B,re]),ae=(0,b.useCallback)(()=>{ee.current===`failed`?(R(`info`,`Retry requested...`),re()):R(`warn`,`Retry called but state is not 'failed' (state: ${ee.current}). Ignoring.`)},[R,re]),oe=(0,b.useCallback)(async()=>{R(`info`,`Manual authentication requested...`);let e=ee.current;if(e===`failed`)R(`info`,`Attempting to reconnect and authenticate via retry...`),ae();else if(e===`pending_auth`){R(`info`,`Proceeding with authentication from pending state...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},AH);try{DH(N.current,`Auth Provider not available for manual auth`);let e=await nB(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Manual authentication successful. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for manual authentication. Waiting for callback...`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}else if(e===`authenticating`){R(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=N.current?.getLastAttemptedAuthUrl();e&&!k&&(A(e),R(`info`,`Manual authentication URL retrieved:`,e))}else R(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[R,ae,k,t,B,re]),se=(0,b.useCallback)(()=>{if(N.current){let e=N.current.clearStorage();R(`info`,`Cleared ${e} item(s) from localStorage for ${t}.`),A(void 0),z()}else R(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,R,z]),ce=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list resources.`);R(`info`,`Listing resources...`);try{let e=await j.current.request({method:`resources/list`},eL);F.current&&(y(e.resources),S(Array.isArray(e.resourceTemplates)?e.resourceTemplates:[]),R(`info`,`Listed ${e.resources.length} resources, ${Array.isArray(e.resourceTemplates)?e.resourceTemplates.length:0} resource templates.`))}catch(e){throw R(`error`,`Error listing resources: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),le=(0,b.useCallback)(async e=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot read resource "${e}".`);R(`info`,`Reading resource: ${e}`);try{let t=await j.current.request({method:`resources/read`,params:{uri:e}},oL);return R(`info`,`Resource "${e}" read successfully`),t}catch(t){throw R(`error`,`Error reading resource "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]),ue=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list prompts.`);R(`info`,`Listing prompts...`);try{let e=await j.current.request({method:`prompts/list`},_L);F.current&&(w(e.prompts),R(`info`,`Listed ${e.prompts.length} prompts.`))}catch(e){throw R(`error`,`Error listing prompts: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),de=(0,b.useCallback)(async(e,t)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot get prompt "${e}".`);R(`info`,`Getting prompt: ${e}`,t);try{let n=await j.current.request({method:`prompts/get`,params:{name:e,arguments:t}},DL);return R(`info`,`Prompt "${e}" retrieved successfully`),n}catch(t){throw R(`error`,`Error getting prompt "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]);return(0,b.useEffect)(()=>{let e=e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(R(`info`,`Received auth callback message.`,e.data),L.current&&clearTimeout(L.current),e.data.success?(R(`info`,`Authentication successful via popup. Reconnecting client...`),P.current=!1,re()):B(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))};return window.addEventListener(`message`,e),R(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),R(`debug`,`Auth callback message listener removed.`),L.current&&clearTimeout(L.current)}},[R,B,re]),(0,b.useEffect)(()=>(F.current=!0,R(`debug`,`useMcp mounted, initiating connection.`),I.current=0,(!N.current||N.current.serverUrl!==t)&&(N.current=new qk(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized/updated on mount/option change.`)),re(),()=>{F.current=!1,R(`debug`,`useMcp unmounting, disconnecting.`),z(!0)}),[t,a,i,n,r,o.name,o.version,re,z]),(0,b.useEffect)(()=>{let e=null;if(m===`failed`&&l&&I.current>0){let t=typeof l==`number`?l:kH;R(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{F.current&&ee.current===`failed`&&ae()},t)}return()=>{e&&clearTimeout(e)}},[m,l,ae,R]),{state:m,tools:g,resources:v,resourceTemplates:x,prompts:C,error:T,log:D,authUrl:k,callTool:ie,listResources:ce,readResource:le,listPrompts:ue,getPrompt:de,retry:ae,disconnect:z,authenticate:oe,clearStorage:se}}function MH({service:e,autoConnect:t=!1,onConnected:n,onError:r}){let{toast:i}=an(),{state:a,tools:o,resources:s,prompts:c,error:l,authUrl:u,callTool:d,readResource:f,listResources:p,getPrompt:m,listPrompts:h,retry:g,disconnect:_,authenticate:v,clearStorage:y}=jH({url:e.url,clientName:`AgentDeck`,clientUri:window.location.origin,callbackUrl:`${window.location.origin}/oauth/callback`,storageKeyPrefix:`mcp:auth:${e.id}`,debug:!0,autoRetry:3,autoReconnect:5e3,transportType:`auto`,preventAutoAuth:!t}),x=a===`ready`,S=a===`connecting`||a===`loading`,C=a===`authenticating`||a===`pending_auth`,w=a===`failed`;return b.useEffect(()=>{x&&n&&(n(),i({title:`Connected to MCP service`,description:`Successfully connected to ${e.name}`}))},[x,n,e.name,i]),b.useEffect(()=>{w&&l&&r&&(r(l),i({title:`MCP connection failed`,description:l,variant:`destructive`}))},[w,l,r,i]),{isConnected:x,isConnecting:S,isAuthenticating:C,hasError:w,error:l,tools:o,resources:s,prompts:c,connect:()=>{g()},disconnect:_,retry:g,authenticate:v,callTool:async(e,t)=>{try{return await d(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Tool call failed`,description:t,variant:`destructive`}),e}},readResource:async e=>{try{return await f(e)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource read failed`,description:t,variant:`destructive`}),e}},listResources:async()=>{try{await p()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource listing failed`,description:t,variant:`destructive`}),e}},getPrompt:async(e,t)=>{try{return await m(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt retrieval failed`,description:t,variant:`destructive`}),e}},listPrompts:async()=>{try{await h()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt listing failed`,description:t,variant:`destructive`}),e}},authUrl:u,clearStorage:y}}function NH(){let[e,t]=(0,b.useState)(`https://api.githubcopilot.com/mcp`),[n,r]=(0,b.useState)(`get_me`),[i,a]=(0,b.useState)(`{}`),[o,s]=(0,b.useState)(``),{isConnected:c,isConnecting:l,isAuthenticating:u,hasError:d,error:f,tools:p,resources:m,prompts:h,connect:g,disconnect:_,retry:v,authenticate:y,callTool:x,authUrl:S,clearStorage:C}=MH({service:{id:`test-mcp-service`,name:`Test MCP Service`,type:`mcp`,url:e,health:`unknown`,description:`Test service for use-mcp integration`,cardColor:`#7ed4da`,isConnected:!1,lastPing:void 0,registeredAt:new Date().toISOString(),updatedAt:new Date().toISOString()},autoConnect:!1,onConnected:()=>{console.log(`Connected to test MCP service`)},onError:e=>{console.error(`Test MCP service error:`,e)}}),w=l?{status:`connecting`,icon:Pi,color:`text-yellow-500`}:u?{status:`authenticating`,icon:ji,color:`text-blue-500`}:c?{status:`connected`,icon:bi,color:`text-green-500`}:d?{status:`error`,icon:xi,color:`text-red-500`}:{status:`disconnected`,icon:xi,color:`text-gray-500`};return(0,H.jsxs)(`div`,{className:`container mx-auto p-6 space-y-6`,children:[(0,H.jsxs)(`div`,{className:`text-center`,children:[(0,H.jsx)(`h1`,{className:`text-3xl font-bold mb-2`,children:`use-mcp Integration Test`}),(0,H.jsx)(`p`,{className:`text-muted-foreground`,children:`Testing the new use-mcp library integration with OAuth support`})]}),(0,H.jsxs)(Lk,{children:[(0,H.jsxs)(Rk,{children:[(0,H.jsxs)(zk,{className:`flex items-center gap-2`,children:[(0,H.jsx)(w.icon,{className:`w-5 h-5 ${w.color}`}),`Connection Status: `,w.status]}),(0,H.jsx)(Bk,{children:`Current connection state and available actions`})]}),(0,H.jsxs)(Vk,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(Qp,{children:`Service URL`}),(0,H.jsx)(Eu,{value:e,onChange:e=>t(e.target.value),placeholder:`Enter MCP service URL`})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[!c&&!l&&(0,H.jsx)(K,{onClick:g,children:`Connect`}),c&&(0,H.jsx)(K,{onClick:_,variant:`outline`,children:`Disconnect`}),d&&(0,H.jsxs)(K,{onClick:v,variant:`outline`,children:[(0,H.jsx)(Pi,{className:`w-4 h-4 mr-1`}),`Retry`]}),S&&!c&&(0,H.jsxs)(K,{onClick:y,variant:`outline`,children:[(0,H.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Authenticate`]})]})]}),f&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-md`,children:[(0,H.jsx)(yi,{className:`w-4 h-4 text-destructive`}),(0,H.jsx)(`span`,{className:`text-sm text-destructive`,children:f})]})]})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,H.jsxs)(Lk,{children:[(0,H.jsx)(Rk,{children:(0,H.jsxs)(zk,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Xi,{className:`w-4 h-4`}),`Tools (`,p.length,`)`]})}),(0,H.jsx)(Vk,{children:p.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`No tools available`:`Connect to see tools`}):(0,H.jsxs)(`div`,{className:`space-y-2`,children:[p.slice(0,5).map((e,t)=>(0,H.jsx)(`div`,{className:`text-sm`,children:(0,H.jsx)(yg,{variant:`outline`,className:`text-xs`,children:e.name})},t)),p.length>5&&(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`+`,p.length-5,` more tools`]})]})})]}),(0,H.jsxs)(Lk,{children:[(0,H.jsx)(Rk,{children:(0,H.jsxs)(zk,{children:[`Resources (`,m.length,`)`]})}),(0,H.jsx)(Vk,{children:(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${m.length} resources available`:`Connect to see resources`})})]}),(0,H.jsxs)(Lk,{children:[(0,H.jsx)(Rk,{children:(0,H.jsxs)(zk,{children:[`Prompts (`,h.length,`)`]})}),(0,H.jsx)(Vk,{children:(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${h.length} prompts available`:`Connect to see prompts`})})]})]}),c&&(0,H.jsxs)(Lk,{children:[(0,H.jsxs)(Rk,{children:[(0,H.jsx)(zk,{children:`Test Tool Call`}),(0,H.jsx)(Bk,{children:`Test calling a tool on the connected MCP service`})]}),(0,H.jsxs)(Vk,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`toolName`,children:`Tool Name`}),(0,H.jsx)(Eu,{id:`toolName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g., get_me`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{htmlFor:`toolArgs`,children:`Arguments (JSON)`}),(0,H.jsx)(Eu,{id:`toolArgs`,value:i,onChange:e=>a(e.target.value),placeholder:`{"key": "value"}`})]})]}),(0,H.jsxs)(K,{onClick:async()=>{try{let e={};i.trim()&&(e=JSON.parse(i));let t=await x(n,e);s(JSON.stringify(t,null,2))}catch(e){s(`Error: ${e instanceof Error?e.message:`Unknown error`}`)}},disabled:!c,children:[(0,H.jsx)(Fi,{className:`w-4 h-4 mr-1`}),`Call Tool`]}),o&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(Qp,{children:`Result`}),(0,H.jsx)($p,{value:o,readOnly:!0,rows:10,className:`font-mono text-sm`})]})]})]}),S&&(0,H.jsxs)(Lk,{children:[(0,H.jsxs)(Rk,{children:[(0,H.jsxs)(zk,{className:`flex items-center gap-2`,children:[(0,H.jsx)(ji,{className:`w-4 h-4`}),`OAuth Authentication`]}),(0,H.jsx)(Bk,{children:`This service requires OAuth authentication`})]}),(0,H.jsxs)(Vk,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`p-3 bg-blue-50 border border-blue-200 rounded-md`,children:(0,H.jsx)(`p`,{className:`text-sm text-blue-800`,children:`This MCP service requires OAuth authentication. Click the "Authenticate" button above to start the OAuth flow.`})}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(K,{onClick:y,variant:`outline`,children:[(0,H.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Start OAuth Flow`]}),(0,H.jsx)(K,{onClick:C,variant:`outline`,children:`Clear OAuth Data`})]})]})]})]})}function PH(e){return e.before.title!==e.after.title||e.before.body!==e.after.body||e.before.triggers.join(`
|
|
241
|
+
deps: ${r}}`};var i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),HV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),UV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ZB(),n=HB(),r=WB(),i=UB();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),WV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=rV(),n=ZB(),r=UB(),i=UV();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),GV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=ZB(),n=HB(),r=UB(),i=UB();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),KV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=UB();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),qV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:ZB().validateUnion,error:{message:`must match a schema in anyOf`}}})),JV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),YV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=UB();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),XV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=UB(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),ZV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=UB();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),QV=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=IV(),n=RV(),r=LV(),i=zV(),a=BV(),o=VV(),s=HV(),c=UV(),l=WV(),u=GV(),d=KV(),f=qV(),p=JV(),m=YV(),h=XV(),g=ZV();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),$V=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),eH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[$V().default]})),tH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),nH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=SV(),n=FV(),r=QV(),i=eH(),a=tH();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),rH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),iH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=HB(),n=rH(),r=oV(),i=aV(),a=UB();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),aH=c({$id:()=>sH,$schema:()=>oH,default:()=>fH,definitions:()=>lH,properties:()=>dH,title:()=>cH,type:()=>uH}),oH,sH,cH,lH,uH,dH,fH,pH=o((()=>{oH=`http://json-schema.org/draft-07/schema#`,sH=`http://json-schema.org/draft-07/schema#`,cH=`Core schema meta-schema`,lH={schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},uH=[`object`,`boolean`],dH={$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},fH={$schema:oH,$id:sH,title:cH,definitions:lH,type:uH,properties:dH,default:!0}})),mH=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;var n=yV(),r=nH(),i=iH(),a=(pH(),d(aH).default),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`,c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=rV();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=HB();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var f=iV();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var p=aV();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return p.default}})})),hH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:E,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:y,int32:{type:`number`,validate:S},int64:{type:`number`,validate:C},float:{type:`number`,validate:w},double:{type:`number`,validate:w},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,m),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}var r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}var s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=new Date(`2020-01-01T`+e).valueOf(),r=new Date(`2020-01-01T`+t).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}var d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}var h=/\/|:/,g=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function _(e){return h.test(e)&&g.test(e)}var v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}var b=-(2**31),x=2**31-1;function S(e){return Number.isInteger(e)&&e<=x&&e>=b}function C(e){return Number.isInteger(e)}function w(){return!0}var T=/[^\\]\\Z/;function E(e){if(T.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),gH=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;var t=mH(),n=HB(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),_H=s(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=hH(),r=gH(),i=HB(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),vH=u(mH(),1),yH=u(_H(),1);function bH(){let e=new vH.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,yH.default)(e),e}var xH=class{constructor(e){this._ajv=e??bH()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},SH=class{constructor(e){this._client=e}async*callToolStream(e,t=FL,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new xR(sI.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new xR(sI.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof xR){yield{type:`error`,error:e};return}yield{type:`error`,error:new xR(sI.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function CH(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);if(t===`tools/call`&&!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`)}function wH(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`)}}function TH(e,t){if(e&&typeof t==`object`&&t){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&TH(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&TH(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&TH(n,t)}}function EH(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var DH=class extends LB{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new xH,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,RL,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,kL,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,cL,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new SH(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=zB(this._capabilities,e)}setRequestHandler(e,t){let n=MB(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(AB(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=jB(cR,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new xR(sI.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=EH(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new xR(sI.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new xR(sI.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=jB(II,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new xR(sI.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=jB(dR,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new xR(sI.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{TH(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=jB(QL,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new xR(sI.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=jB(II,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new xR(sI.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=jB(i.tools||i.toolChoice?eR:$L,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new xR(sI.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:RF,capabilities:this._capabilities,clientInfo:this._clientInfo}},wI,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!zF.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if(e===`notifications/roots/list_changed`&&!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){CH(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&wH(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},dI,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},gR,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},dI,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},OL,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},vL,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},tL,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},rL,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},sL,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},dI,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},dI,t)}async callTool(e,t=FL,n){if(this.isToolTaskRequired(e.name))throw new xR(sI.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new xR(sI.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new xR(sI.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof xR?e:new xR(sI.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},PL,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=zL.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{let e=await r();s(null,e)}catch(e){let t=e instanceof Error?e:Error(String(e));s(t,null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}};function OH(e,t){if(!e)throw Error(t)}var kH=3e3,AH=5e3,jH=3e5;function MH(e){let{url:t,clientName:n,clientUri:r,callbackUrl:i=typeof window<`u`?Kk(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:a=`mcp:auth`,clientConfig:o={},customHeaders:s={},debug:c=!1,autoRetry:l=!1,autoReconnect:u=kH,transportType:d=`auto`,preventAutoAuth:f=!1,onPopupWindow:p}=e,[m,h]=(0,b.useState)(`discovering`),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)([]),[x,S]=(0,b.useState)([]),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(void 0),[D,O]=(0,b.useState)([]),[k,A]=(0,b.useState)(void 0),j=(0,b.useRef)(null),M=(0,b.useRef)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(!1),F=(0,b.useRef)(!0),I=(0,b.useRef)(0),L=(0,b.useRef)(null),ee=(0,b.useRef)(m),te=(0,b.useRef)(u),ne=(0,b.useRef)(null);(0,b.useEffect)(()=>{ee.current=m,te.current=u},[m,u]);let R=(0,b.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t;console[e](`[useMcp] ${r}`),F.current&&O(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[]),z=(0,b.useCallback)(async(e=!1)=>{e||R(`info`,`Disconnecting...`),P.current=!1,L.current&&clearTimeout(L.current),L.current=null;let t=M.current;if(j.current=null,M.current=null,F.current&&!e&&(h(`discovering`),_([]),y([]),S([]),w([]),E(void 0),A(void 0)),t)try{await t.close(),e||R(`debug`,`Transport closed`)}catch(t){e||R(`warn`,`Error closing transport:`,t)}},[R]),B=(0,b.useCallback)((e,t)=>{if(R(`error`,e,t??``),F.current){h(`failed`),E(e);let t=N.current?.getLastAttemptedAuthUrl();t&&(A(t),R(`info`,`Manual authentication URL may be available.`,t))}P.current=!1},[R]),re=(0,b.useCallback)(async()=>{if(P.current){R(`debug`,`Connection attempt already in progress.`);return}if(!F.current){R(`debug`,`Connect called after unmount, aborting.`);return}P.current=!0,I.current+=1,E(void 0),A(void 0),ne.current=null,h(`discovering`),R(`info`,`Connecting attempt #${I.current} to ${t}...`),N.current||(N.current=new Jk(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized in connect.`)),j.current||(j.current=new DH({name:o.name||`use-mcp-react-client`,version:o.version||`0.1.0`},{capabilities:{}}),R(`debug`,`MCP Client initialized in connect.`));let e=async e=>{R(`info`,`Attempting connection with ${e.toUpperCase()} transport...`),ee.current!==`authenticating`&&h(`connecting`);let n;try{OH(N.current,`Auth Provider must be initialized`),OH(j.current,`Client must be initialized`),M.current&&=(await M.current.close().catch(e=>R(`warn`,`Error closing previous transport: ${e.message}`)),null);let r={authProvider:N.current,requestInit:{headers:{Accept:`application/json, text/event-stream`,...s}}},i=Kk(t),a=new URL(i);R(`debug`,`Creating ${e.toUpperCase()} transport for URL: ${a.toString()}`),R(`debug`,`Transport options:`,{authProvider:!!N.current,headers:s,url:a.toString()}),e===`http`?(R(`debug`,`Creating StreamableHTTPClientTransport...`),n=new kB(a,r),R(`debug`,`StreamableHTTPClientTransport created successfully`)):(R(`debug`,`Creating SSEClientTransport...`),n=new TB(a,r),R(`debug`,`SSEClientTransport created successfully`)),M.current=n,R(`debug`,`${e.toUpperCase()} transport created and assigned to ref.`)}catch(t){return B(`Failed to create ${e.toUpperCase()} transport: ${t instanceof Error?t.message:String(t)}`,t instanceof Error?t:void 0),`failed`}n.onmessage=e=>{R(`debug`,`[Transport] Received: ${JSON.stringify(e)}`),j.current?.handleMessage?.(e)},n.onerror=t=>{R(`warn`,`Transport error event (${e.toUpperCase()}):`,t),R(`debug`,`Error details:`,{message:t.message,stack:t.stack,name:t.name,cause:t.cause}),B(`Transport error (${e.toUpperCase()}): ${t.message}`,t)},n.onclose=()=>{if(!F.current||P.current)return;R(`info`,`Transport connection closed (${ne.current||`unknown`} type).`);let e=ee.current,t=te.current;if(e===`ready`&&t){let e=typeof t==`number`?t:kH;R(`info`,`Attempting to reconnect in ${e}ms...`),h(`connecting`),setTimeout(()=>{F.current&&re()},e)}else e!==`failed`&&e!==`authenticating`&&B(`Connection closed unexpectedly.`)};try{R(`info`,`Connecting client via ${e.toUpperCase()}...`),R(`debug`,`About to call client.connect() with transport instance`),R(`debug`,`Transport instance type: ${n.constructor.name}`),await j.current.connect(n),R(`info`,`Client connected via ${e.toUpperCase()}. Loading tools, resources, and prompts...`),ne.current=e,h(`loading`);let t=await j.current.request({method:`tools/list`},PL),r={resources:[],resourceTemplates:[]};try{r=await j.current.request({method:`resources/list`},tL)}catch(e){R(`debug`,`Server does not support resources/list method`,e)}let i={prompts:[]};try{i=await j.current.request({method:`prompts/list`},vL)}catch(e){R(`debug`,`Server does not support prompts/list method`,e)}if(F.current){_(t.tools),y(r.resources),S(Array.isArray(r.resourceTemplates)?r.resourceTemplates:[]),w(i.prompts);let e=[`Loaded ${t.tools.length} tools`];return(r.resources.length>0||r.resourceTemplates&&r.resourceTemplates.length>0)&&(e.push(`${r.resources.length} resources`),Array.isArray(r.resourceTemplates)&&r.resourceTemplates.length>0&&e.push(`${r.resourceTemplates.length} resource templates`)),i.prompts.length>0&&e.push(`${i.prompts.length} prompts`),R(`info`,e.join(`, `)+`.`),h(`ready`),I.current=0,`success`}return`failed`}catch(n){R(`debug`,`Client connect error via ${e.toUpperCase()}:`,n),R(`debug`,`Connect error details:`,{message:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:`N/A`,name:n instanceof Error?n.name:`Unknown`,cause:n instanceof Error?n.cause:void 0});let r=n instanceof Error?n:Error(String(n)),i=r.message,a=i.includes(`404`)||i.includes(`Not Found`),o=i.includes(`405`)||i.includes(`Method Not Allowed`),s=i===`Failed to fetch`||i===`NetworkError when attempting to fetch resource.`||i===`Load failed`;if(e===`http`&&(a||o||s))return R(`warn`,`HTTP transport failed (${s?`CORS`:a?`404`:`405`}).`),`fallback`;if(r instanceof qz||i.includes(`Unauthorized`)||i.includes(`401`)){R(`info`,`Authentication required.`),OH(N.current,`Auth Provider not available for auth flow`);let e=await N.current.tokens();if(f&&!e)return R(`info`,`Authentication required but auto-auth prevented. User action needed.`),h(`pending_auth`),`auth_redirect`;ee.current!==`authenticating`&&ee.current!==`pending_auth`&&(h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},jH));try{let e=await rB(N.current,{serverUrl:t});if(!F.current)return`failed`;if(e===`AUTHORIZED`)return R(`info`,`Authentication successful via existing token or refresh. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re(),`failed`;if(e===`REDIRECT`)return R(`info`,`Redirecting for authentication. Waiting for callback...`),`auth_redirect`}catch(e){return F.current?(L.current&&clearTimeout(L.current),B(`Failed to initiate authentication: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0),`failed`):`failed`}}return B(`Failed to connect via ${e.toUpperCase()}: ${i}`,r),`failed`}},c=`failed`;if(console.log({transportType:d}),d===`sse`)R(`debug`,`Using SSE-only transport mode`),c=await e(`sse`);else if(d===`http`)R(`debug`,`Using HTTP-only transport mode`),c=await e(`http`);else{R(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);if(t===`fallback`&&F.current&&ee.current!==`authenticating`){R(`info`,`HTTP failed, attempting SSE fallback...`);let t=await e(`sse`);c=t,t===`failed`&&F.current}else c=t}(c===`success`||c===`failed`)&&(P.current=!1),R(`debug`,`Connection sequence finished with status: ${c}`)},[R,B,z,rB,t,a,n,r,i,o.name,o.version]),ie=(0,b.useCallback)(async(e,n)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot call tool "${e}".`);R(`info`,`Calling tool: ${e}`,n);try{let t=await j.current.request({method:`tools/call`,params:{name:e,arguments:n}},FL);return R(`info`,`Tool "${e}" call successful:`,t),t}catch(n){R(`error`,`Error calling tool "${e}": ${n instanceof Error?n.message:String(n)}`,n);let r=n instanceof Error?n:Error(String(n));if(r instanceof qz||r.message.includes(`Unauthorized`)||r.message.includes(`401`)){R(`warn`,`Tool call unauthorized, attempting re-authentication...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},jH);try{OH(N.current,`Auth Provider not available for tool re-auth`);let e=await rB(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Re-authentication successful. Retrying tool call is recommended, or reconnecting.`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for re-authentication for tool call.`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Re-authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}if(ee.current!==`authenticating`)throw n;return}},[m,t,R,B,re]),ae=(0,b.useCallback)(()=>{ee.current===`failed`?(R(`info`,`Retry requested...`),re()):R(`warn`,`Retry called but state is not 'failed' (state: ${ee.current}). Ignoring.`)},[R,re]),oe=(0,b.useCallback)(async()=>{R(`info`,`Manual authentication requested...`);let e=ee.current;if(e===`failed`)R(`info`,`Attempting to reconnect and authenticate via retry...`),ae();else if(e===`pending_auth`){R(`info`,`Proceeding with authentication from pending state...`),h(`authenticating`),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{},jH);try{OH(N.current,`Auth Provider not available for manual auth`);let e=await rB(N.current,{serverUrl:t});if(!F.current)return;e===`AUTHORIZED`?(R(`info`,`Manual authentication successful. Re-attempting connection...`),L.current&&clearTimeout(L.current),P.current=!1,re()):e===`REDIRECT`&&R(`info`,`Redirecting for manual authentication. Waiting for callback...`)}catch(e){if(!F.current)return;L.current&&clearTimeout(L.current),B(`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:void 0)}}else if(e===`authenticating`){R(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=N.current?.getLastAttemptedAuthUrl();e&&!k&&(A(e),R(`info`,`Manual authentication URL retrieved:`,e))}else R(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[R,ae,k,t,B,re]),se=(0,b.useCallback)(()=>{if(N.current){let e=N.current.clearStorage();R(`info`,`Cleared ${e} item(s) from localStorage for ${t}.`),A(void 0),z()}else R(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,R,z]),ce=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list resources.`);R(`info`,`Listing resources...`);try{let e=await j.current.request({method:`resources/list`},tL);F.current&&(y(e.resources),S(Array.isArray(e.resourceTemplates)?e.resourceTemplates:[]),R(`info`,`Listed ${e.resources.length} resources, ${Array.isArray(e.resourceTemplates)?e.resourceTemplates.length:0} resource templates.`))}catch(e){throw R(`error`,`Error listing resources: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),le=(0,b.useCallback)(async e=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot read resource "${e}".`);R(`info`,`Reading resource: ${e}`);try{let t=await j.current.request({method:`resources/read`,params:{uri:e}},sL);return R(`info`,`Resource "${e}" read successfully`),t}catch(t){throw R(`error`,`Error reading resource "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]),ue=(0,b.useCallback)(async()=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot list prompts.`);R(`info`,`Listing prompts...`);try{let e=await j.current.request({method:`prompts/list`},vL);F.current&&(w(e.prompts),R(`info`,`Listed ${e.prompts.length} prompts.`))}catch(e){throw R(`error`,`Error listing prompts: ${e instanceof Error?e.message:String(e)}`,e),e}},[m,R]),de=(0,b.useCallback)(async(e,t)=>{if(ee.current!==`ready`||!j.current)throw Error(`MCP client is not ready (current state: ${m}). Cannot get prompt "${e}".`);R(`info`,`Getting prompt: ${e}`,t);try{let n=await j.current.request({method:`prompts/get`,params:{name:e,arguments:t}},OL);return R(`info`,`Prompt "${e}" retrieved successfully`),n}catch(t){throw R(`error`,`Error getting prompt "${e}": ${t instanceof Error?t.message:String(t)}`,t),t}},[m,R]);return(0,b.useEffect)(()=>{let e=e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(R(`info`,`Received auth callback message.`,e.data),L.current&&clearTimeout(L.current),e.data.success?(R(`info`,`Authentication successful via popup. Reconnecting client...`),P.current=!1,re()):B(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))};return window.addEventListener(`message`,e),R(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),R(`debug`,`Auth callback message listener removed.`),L.current&&clearTimeout(L.current)}},[R,B,re]),(0,b.useEffect)(()=>(F.current=!0,R(`debug`,`useMcp mounted, initiating connection.`),I.current=0,(!N.current||N.current.serverUrl!==t)&&(N.current=new Jk(t,{storageKeyPrefix:a,clientName:n,clientUri:r,callbackUrl:i,preventAutoAuth:f,onPopupWindow:p}),R(`debug`,`BrowserOAuthClientProvider initialized/updated on mount/option change.`)),re(),()=>{F.current=!1,R(`debug`,`useMcp unmounting, disconnecting.`),z(!0)}),[t,a,i,n,r,o.name,o.version,re,z]),(0,b.useEffect)(()=>{let e=null;if(m===`failed`&&l&&I.current>0){let t=typeof l==`number`?l:AH;R(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{F.current&&ee.current===`failed`&&ae()},t)}return()=>{e&&clearTimeout(e)}},[m,l,ae,R]),{state:m,tools:g,resources:v,resourceTemplates:x,prompts:C,error:T,log:D,authUrl:k,callTool:ie,listResources:ce,readResource:le,listPrompts:ue,getPrompt:de,retry:ae,disconnect:z,authenticate:oe,clearStorage:se}}function NH({service:e,autoConnect:t=!1,onConnected:n,onError:r}){let{toast:i}=an(),{state:a,tools:o,resources:s,prompts:c,error:l,authUrl:u,callTool:d,readResource:f,listResources:p,getPrompt:m,listPrompts:h,retry:g,disconnect:_,authenticate:v,clearStorage:y}=MH({url:e.url,clientName:`AgentDeck`,clientUri:window.location.origin,callbackUrl:`${window.location.origin}/oauth/callback`,storageKeyPrefix:`mcp:auth:${e.id}`,debug:!0,autoRetry:3,autoReconnect:5e3,transportType:`auto`,preventAutoAuth:!t}),x=a===`ready`,S=a===`connecting`||a===`loading`,C=a===`authenticating`||a===`pending_auth`,w=a===`failed`;return b.useEffect(()=>{x&&n&&(n(),i({title:`Connected to MCP service`,description:`Successfully connected to ${e.name}`}))},[x,n,e.name,i]),b.useEffect(()=>{w&&l&&r&&(r(l),i({title:`MCP connection failed`,description:l,variant:`destructive`}))},[w,l,r,i]),{isConnected:x,isConnecting:S,isAuthenticating:C,hasError:w,error:l,tools:o,resources:s,prompts:c,connect:()=>{g()},disconnect:_,retry:g,authenticate:v,callTool:async(e,t)=>{try{return await d(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Tool call failed`,description:t,variant:`destructive`}),e}},readResource:async e=>{try{return await f(e)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource read failed`,description:t,variant:`destructive`}),e}},listResources:async()=>{try{await p()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Resource listing failed`,description:t,variant:`destructive`}),e}},getPrompt:async(e,t)=>{try{return await m(e,t)}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt retrieval failed`,description:t,variant:`destructive`}),e}},listPrompts:async()=>{try{await h()}catch(e){let t=e instanceof Error?e.message:`Unknown error`;throw i({title:`Prompt listing failed`,description:t,variant:`destructive`}),e}},authUrl:u,clearStorage:y}}function PH(){let[e,t]=(0,b.useState)(`https://api.githubcopilot.com/mcp`),[n,r]=(0,b.useState)(`get_me`),[i,a]=(0,b.useState)(`{}`),[o,s]=(0,b.useState)(``),{isConnected:c,isConnecting:l,isAuthenticating:u,hasError:d,error:f,tools:p,resources:m,prompts:h,connect:g,disconnect:_,retry:v,authenticate:y,callTool:x,authUrl:S,clearStorage:C}=NH({service:{id:`test-mcp-service`,name:`Test MCP Service`,type:`mcp`,url:e,health:`unknown`,description:`Test service for use-mcp integration`,cardColor:`#7ed4da`,isConnected:!1,lastPing:void 0,registeredAt:new Date().toISOString(),updatedAt:new Date().toISOString()},autoConnect:!1,onConnected:()=>{console.log(`Connected to test MCP service`)},onError:e=>{console.error(`Test MCP service error:`,e)}}),w=l?{status:`connecting`,icon:Pi,color:`text-yellow-500`}:u?{status:`authenticating`,icon:ji,color:`text-blue-500`}:c?{status:`connected`,icon:bi,color:`text-green-500`}:d?{status:`error`,icon:xi,color:`text-red-500`}:{status:`disconnected`,icon:xi,color:`text-gray-500`};return(0,H.jsxs)(`div`,{className:`container mx-auto p-6 space-y-6`,children:[(0,H.jsxs)(`div`,{className:`text-center`,children:[(0,H.jsx)(`h1`,{className:`text-3xl font-bold mb-2`,children:`use-mcp Integration Test`}),(0,H.jsx)(`p`,{className:`text-muted-foreground`,children:`Testing the new use-mcp library integration with OAuth support`})]}),(0,H.jsxs)(Rk,{children:[(0,H.jsxs)(zk,{children:[(0,H.jsxs)(Bk,{className:`flex items-center gap-2`,children:[(0,H.jsx)(w.icon,{className:`w-5 h-5 ${w.color}`}),`Connection Status: `,w.status]}),(0,H.jsx)(Vk,{children:`Current connection state and available actions`})]}),(0,H.jsxs)(Hk,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)($p,{children:`Service URL`}),(0,H.jsx)(Eu,{value:e,onChange:e=>t(e.target.value),placeholder:`Enter MCP service URL`})]}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[!c&&!l&&(0,H.jsx)(K,{onClick:g,children:`Connect`}),c&&(0,H.jsx)(K,{onClick:_,variant:`outline`,children:`Disconnect`}),d&&(0,H.jsxs)(K,{onClick:v,variant:`outline`,children:[(0,H.jsx)(Pi,{className:`w-4 h-4 mr-1`}),`Retry`]}),S&&!c&&(0,H.jsxs)(K,{onClick:y,variant:`outline`,children:[(0,H.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Authenticate`]})]})]}),f&&(0,H.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-md`,children:[(0,H.jsx)(yi,{className:`w-4 h-4 text-destructive`}),(0,H.jsx)(`span`,{className:`text-sm text-destructive`,children:f})]})]})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,H.jsxs)(Rk,{children:[(0,H.jsx)(zk,{children:(0,H.jsxs)(Bk,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Xi,{className:`w-4 h-4`}),`Tools (`,p.length,`)`]})}),(0,H.jsx)(Hk,{children:p.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`No tools available`:`Connect to see tools`}):(0,H.jsxs)(`div`,{className:`space-y-2`,children:[p.slice(0,5).map((e,t)=>(0,H.jsx)(`div`,{className:`text-sm`,children:(0,H.jsx)(bg,{variant:`outline`,className:`text-xs`,children:e.name})},t)),p.length>5&&(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`+`,p.length-5,` more tools`]})]})})]}),(0,H.jsxs)(Rk,{children:[(0,H.jsx)(zk,{children:(0,H.jsxs)(Bk,{children:[`Resources (`,m.length,`)`]})}),(0,H.jsx)(Hk,{children:(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${m.length} resources available`:`Connect to see resources`})})]}),(0,H.jsxs)(Rk,{children:[(0,H.jsx)(zk,{children:(0,H.jsxs)(Bk,{children:[`Prompts (`,h.length,`)`]})}),(0,H.jsx)(Hk,{children:(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c?`${h.length} prompts available`:`Connect to see prompts`})})]})]}),c&&(0,H.jsxs)(Rk,{children:[(0,H.jsxs)(zk,{children:[(0,H.jsx)(Bk,{children:`Test Tool Call`}),(0,H.jsx)(Vk,{children:`Test calling a tool on the connected MCP service`})]}),(0,H.jsxs)(Hk,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`toolName`,children:`Tool Name`}),(0,H.jsx)(Eu,{id:`toolName`,value:n,onChange:e=>r(e.target.value),placeholder:`e.g., get_me`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{htmlFor:`toolArgs`,children:`Arguments (JSON)`}),(0,H.jsx)(Eu,{id:`toolArgs`,value:i,onChange:e=>a(e.target.value),placeholder:`{"key": "value"}`})]})]}),(0,H.jsxs)(K,{onClick:async()=>{try{let e={};i.trim()&&(e=JSON.parse(i));let t=await x(n,e);s(JSON.stringify(t,null,2))}catch(e){s(`Error: ${e instanceof Error?e.message:`Unknown error`}`)}},disabled:!c,children:[(0,H.jsx)(Fi,{className:`w-4 h-4 mr-1`}),`Call Tool`]}),o&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)($p,{children:`Result`}),(0,H.jsx)(em,{value:o,readOnly:!0,rows:10,className:`font-mono text-sm`})]})]})]}),S&&(0,H.jsxs)(Rk,{children:[(0,H.jsxs)(zk,{children:[(0,H.jsxs)(Bk,{className:`flex items-center gap-2`,children:[(0,H.jsx)(ji,{className:`w-4 h-4`}),`OAuth Authentication`]}),(0,H.jsx)(Vk,{children:`This service requires OAuth authentication`})]}),(0,H.jsxs)(Hk,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`p-3 bg-blue-50 border border-blue-200 rounded-md`,children:(0,H.jsx)(`p`,{className:`text-sm text-blue-800`,children:`This MCP service requires OAuth authentication. Click the "Authenticate" button above to start the OAuth flow.`})}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsxs)(K,{onClick:y,variant:`outline`,children:[(0,H.jsx)(ji,{className:`w-4 h-4 mr-1`}),`Start OAuth Flow`]}),(0,H.jsx)(K,{onClick:C,variant:`outline`,children:`Clear OAuth Data`})]})]})]})]})}function FH(e){return e.before.title!==e.after.title||e.before.body!==e.after.body||e.before.triggers.join(`
|
|
242
242
|
`)!==e.after.triggers.join(`
|
|
243
|
-
`)}var
|
|
243
|
+
`)}var IH=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}};new class extends IH{};function LH(e,t){let n=0;for(;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function RH(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function zH(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function BH(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function VH(e,t){return zH(e,t,``)}function HH(e,t){return BH(e,t,``)}function UH(e,t){return t.slice(0,WH(e,t))}function WH(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function GH(e,t){let n=[];for(let r of Array.from(t.segment(e))){let e=r.segment;n.length&&/\s/.test(n[n.length-1])&&/\s/.test(e)?n[n.length-1]+=e:n.push(e)}return n}function KH(e,t){if(t)return JH(e,t)[1];let n;for(n=e.length-1;n>=0&&e[n].match(/\s/);n--);return e.substring(n+1)}function qH(e,t){if(t)return JH(e,t)[0];let n=e.match(/^\s*/);return n?n[0]:``}function JH(e,t){if(!t)return[qH(e),KH(e)];if(t.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);let n=GH(e,t),r=n[0],i=n[n.length-1];return[/\s/.test(r)?r:``,/\s/.test(i)?i:``]}var YH=`a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,XH=RegExp(`[${YH}]+|\\s+|[^${YH}]`,`ug`);new class extends IH{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=GH(e,r)}else n=e.match(XH)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&ZH(n,i,r,e,t.intlSegmenter),n=e,r=null,i=null)}),(r||i)&&ZH(n,i,r,null,t.intlSegmenter),e}};function ZH(e,t,n,r,i){if(t&&n){let[a,o]=JH(t.value,i),[s,c]=JH(n.value,i);if(e){let r=LH(a,s);e.value=BH(e.value,s,r),t.value=VH(t.value,r),n.value=VH(n.value,r)}if(r){let e=RH(o,c);r.value=zH(r.value,c,e),t.value=HH(t.value,e),n.value=HH(n.value,e)}}else if(n){if(e){let e=qH(n.value,i);n.value=n.value.substring(e.length)}if(r){let e=qH(r.value,i);r.value=r.value.substring(e.length)}}else if(e&&r){let n=qH(r.value,i),[a,o]=JH(t.value,i),s=LH(n,a);t.value=VH(t.value,s);let c=RH(VH(n,s),o);t.value=HH(t.value,c),r.value=zH(r.value,n,c),e.value=BH(e.value,n,n.slice(0,n.length-c.length))}else if(r){let e=qH(r.value,i),n=UH(KH(t.value,i),e);t.value=HH(t.value,n)}else if(e){let n=UH(KH(e.value,i),qH(t.value,i));t.value=VH(t.value,n)}}new class extends IH{tokenize(e){let t=RegExp(`(\\r?\\n)|[${YH}]+|[^\\S\\n\\r]+|[^${YH}]`,`ug`);return e.match(t)||[]}};var QH=new class extends IH{constructor(){super(...arguments),this.tokenize=eU}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
244
244
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
245
245
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
246
246
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
247
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function
|
|
248
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
249
|
-
`)}function
|
|
247
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};function $H(e,t,n){return QH.diff(e,t,n)}function eU(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
248
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function tU(e){return e==`.`||e==`!`||e==`?`}new class extends IH{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(tU(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends IH{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends IH{constructor(){super(...arguments),this.tokenize=eU}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(nU(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function nU(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=nU(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=nU(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends IH{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};var rU=3,iU=10;function aU(e){return e===``?[]:e.replace(/\n$/,``).split(`
|
|
249
|
+
`)}function oU(e,t){let n=$H(e,t),r=[],i=1,a=1;for(let e of n){let t=aU(e.value);if(!e.added&&!e.removed&&t.length>=iU){let e=t.slice(0,rU),n=t.slice(-3),o=t.length-6;for(let t of e)r.push({kind:`unchanged`,text:t,oldLine:i++,newLine:a++});o>0&&(r.push({kind:`ellipsis`,text:`${o} unchanged lines`}),i+=o,a+=o);for(let e of n)r.push({kind:`unchanged`,text:e,oldLine:i++,newLine:a++});continue}for(let n of t)e.added?r.push({kind:`added`,text:n,newLine:a++}):e.removed?r.push({kind:`removed`,text:n,oldLine:i++}):r.push({kind:`unchanged`,text:n,oldLine:i++,newLine:a++})}return r}function sU(e){return e.some(e=>e.kind===`added`||e.kind===`removed`)}var cU=`max-w-full overflow-x-auto rounded-md border border-gray-800 bg-gray-950 font-mono text-xs leading-5`;function lU(e){switch(e){case`added`:return`bg-emerald-950/70 text-emerald-100`;case`removed`:return`bg-rose-950/70 text-rose-100`;case`ellipsis`:return`bg-gray-900 text-gray-500 italic`;default:return`bg-gray-950 text-gray-300`}}function uU(e){switch(e){case`added`:return`+`;case`removed`:return`-`;case`ellipsis`:return`…`;default:return` `}}function dU({rows:e,emptyLabel:t}){return e.length===0?(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:t}):(0,H.jsx)(`div`,{className:cU,children:e.map((e,t)=>(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] gap-0 ${lU(e.kind)}`,children:[(0,H.jsx)(`span`,{className:`select-none border-r border-gray-800/80 px-2 py-0.5 text-right text-gray-600`,children:e.oldLine??``}),(0,H.jsx)(`span`,{className:`select-none border-r border-gray-800/80 px-2 py-0.5 text-right text-gray-600`,children:e.newLine??``}),(0,H.jsxs)(`div`,{className:`flex min-w-0 gap-2 px-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`w-3 shrink-0 select-none text-gray-500`,children:uU(e.kind)}),(0,H.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words`,children:e.text||` `})]})]},`${e.kind}-${t}-${e.oldLine??``}-${e.newLine??``}`))})}function fU({before:e,after:t}){let n=e.filter(e=>!t.includes(e)),r=t.filter(t=>!e.includes(t));return n.length===0&&r.length===0?null:(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Triggers`}),(0,H.jsxs)(`div`,{className:`${cU} p-0`,children:[n.map(e=>(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,H.jsx)(`span`,{children:e})]})]},`removed-${e}`)),r.map(e=>(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,H.jsx)(`span`,{children:e})]})]},`added-${e}`))]})]})}function pU({preview:e}){let t=FH(e),n=oU(e.before.body,e.after.body),r=e.before.body.trim()!==e.after.body.trim()&&e.after.body.length>0&&!e.after.body.includes(e.before.body.slice(0,40))&&sU(n),i=e.before.title!==e.after.title,a=e.before.triggers.join(`
|
|
250
250
|
`)!==e.after.triggers.join(`
|
|
251
|
-
`);return(0,H.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[!t&&(0,H.jsxs)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:[`No change detected — ops did not alter the playbook body or triggers. Reject this proposal and re-propose with a matching list anchor or `,(0,H.jsx)(`code`,{children:`rewrite_body`}),`.`]}),r&&(0,H.jsx)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:`Full-body rewrite proposed — review carefully.`}),i&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Title`}),(0,H.jsxs)(`div`,{className:`${sU} p-0`,children:[e.before.title&&(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,H.jsx)(`span`,{children:e.before.title})]})]}),e.after.title&&(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,H.jsx)(`span`,{children:e.after.title})]})]})]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Body`}),(0,H.jsx)(uU,{rows:n,emptyLabel:`No body changes.`})]}),a&&(0,H.jsx)(dU,{before:e.before.triggers,after:e.after.triggers})]})}function pU(e){if(!e)return[];try{return JSON.parse(e)}catch{return[]}}function mU({conflicts:e,title:t=`Trigger overlap warnings`}){return e.length===0?null:(0,H.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-4 text-sm text-amber-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-amber-200/90`,children:t}),(0,H.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`These triggers overlap with other playbooks on the deck. Accept is still allowed — disambiguate triggers or propose a merge if the wrong playbook keeps firing.`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>(0,H.jsxs)(`li`,{className:`rounded border border-amber-500/20 bg-gray-950/60 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(yg,{variant:`outline`,className:`border-amber-400/40 text-amber-100`,children:e.level}),(0,H.jsx)(`span`,{className:`font-medium text-amber-50`,children:e.otherPlaybookTitle}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-amber-200/70`,children:e.otherPlaybookId})]}),(0,H.jsxs)(`p`,{className:`mt-2 text-amber-100/90`,children:[(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:`Candidate:`}),` `,e.trigger]}),(0,H.jsxs)(`p`,{className:`text-amber-100/80`,children:[(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:`Other:`}),` `,e.otherTrigger]})]},`${e.trigger}-${e.otherPlaybookId}-${e.level}`))})]})}var hU=8,gU=[{value:`proposed`,label:`Waiting`},{value:`accepted`,label:`Accepted`},{value:`rejected`,label:`Rejected`},{value:`superseded`,label:`Superseded`},{value:`stale`,label:`Stale`},{value:`all`,label:`All`}];function _U(e){if(!e.evidenceJson)return null;try{return JSON.parse(e.evidenceJson)}catch{return null}}function vU(e){switch(e){case`proposed`:return`border-blue-500/40 text-blue-200`;case`accepted`:return`border-emerald-500/40 text-emerald-200`;case`rejected`:return`border-rose-500/40 text-rose-200`;case`superseded`:return`border-violet-500/40 text-violet-200`;case`stale`:return`border-amber-500/40 text-amber-200`}}function yU(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(`proposed`),[i,a]=(0,b.useState)(0),{toast:o}=an(),s=Tt();function c(e){t(e)}function l(e){r(e),a(0),t(null)}let{data:u=[]}=Bt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>rg(`proposed`)}),d=n===`all`?void 0:n,{data:f=[],isLoading:p}=Bt({queryKey:[`/api/playbook-patches`,n],queryFn:()=>rg(d)}),m=Math.max(1,Math.ceil(f.length/hU)),h=Math.min(i,m-1),g=(0,b.useMemo)(()=>{let e=h*hU;return f.slice(e,e+hU)},[f,h]);(0,b.useEffect)(()=>{i!==h&&a(h)},[i,h]);let{data:_,isLoading:v,isError:y,error:x}=Bt({queryKey:[`/api/playbook-patches`,e,`preview`],queryFn:()=>ig(e),enabled:!!e}),S=_?PH(_):!1,C=f.find(t=>t.id===e)??null,w=C?.status===`proposed`,T=Vt({mutationFn:e=>ag(e),onSuccess:()=>{o({title:`Patch accepted`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/playbooks`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Accept failed`,description:e.message,variant:`destructive`})}}),E=Vt({mutationFn:e=>og(e),onSuccess:()=>{o({title:`Patch rejected`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Reject failed`,description:e.message,variant:`destructive`})}}),D=n===`proposed`?`No proposals waiting for review.`:n===`all`?`No playbook patches yet.`:`No ${n} patches.`;return(0,H.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Deck`})]})}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Playbook review queue`}),(0,H.jsxs)(yg,{variant:`secondary`,children:[u.length,` waiting`]}),(0,H.jsx)(ye,{href:`/feedback-signals`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Feedback data →`})]})}),(0,H.jsxs)(`main`,{className:`mx-auto grid w-full max-w-7xl min-h-0 flex-1 gap-6 overflow-hidden px-4 py-6 sm:px-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)] lg:items-stretch`,children:[(0,H.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Proposals`}),(0,H.jsx)(`div`,{className:`mb-3 flex shrink-0 flex-wrap gap-1`,children:gU.map(({value:e,label:t})=>{let r=n===e;return(0,H.jsx)(K,{size:`sm`,variant:r?`gold`:`outline`,className:r?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":r,onClick:()=>l(e),children:t},e)})}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!p&&f.length===0&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:D}),(0,H.jsx)(`ul`,{className:`space-y-2`,children:g.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:`w-full rounded-lg border p-3 text-left transition ${e===t.id?`border-blue-500 bg-gray-900`:`border-gray-800 bg-gray-900/50 hover:border-gray-700`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block font-medium leading-snug`,children:t.kind===`create`?`New: ${t.displayTitle}`:t.displayTitle}),t.playbookId&&t.kind!==`create`&&(0,H.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-gray-600`,children:t.playbookId}),ng(t.deckNames)&&(0,H.jsxs)(`span`,{className:`mt-1 block text-xs text-gray-500`,children:[`Decks: `,ng(t.deckNames)]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,H.jsx)(yg,{variant:`outline`,className:`shrink-0`,children:t.kind}),n!==`proposed`&&(0,H.jsx)(yg,{variant:`outline`,className:`shrink-0 ${vU(t.status)}`,children:t.status})]})]}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-gray-400`,children:t.rationale}),(0,H.jsxs)(`p`,{className:`mt-1 text-xs text-gray-600`,children:[t.source,` · `,new Date(t.createdAt).toLocaleString()]})]})},t.id))})]}),f.length>hU&&(0,H.jsxs)(`div`,{className:`mt-3 flex shrink-0 items-center justify-between gap-2 border-t border-gray-800 pt-3`,children:[(0,H.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h<=0,onClick:()=>a(e=>Math.max(0,e-1)),children:[(0,H.jsx)(gi,{className:`mr-1 h-4 w-4`}),`Newer`]}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[h+1,` / `,m,(0,H.jsxs)(`span`,{className:`ml-1 text-gray-600`,children:[`(`,f.length,`)`]})]}),(0,H.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h>=m-1,onClick:()=>a(e=>Math.min(m-1,e+1)),children:[`Older`,(0,H.jsx)(_i,{className:`ml-1 h-4 w-4`})]})]})]}),(0,H.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Detail`}),!C&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Select a proposal to preview the diff.`}),C&&(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-gray-800 bg-gray-900/50`,children:[(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-5`,children:(0,H.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(yg,{variant:`outline`,className:vU(C.status),children:C.status}),C.resolvedAt&&(0,H.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Resolved `,new Date(C.resolvedAt).toLocaleString()]})]}),(0,H.jsx)(`p`,{className:`text-sm leading-relaxed text-gray-300`,children:C.rationale}),C.status===`rejected`&&C.rejectionReason&&(0,H.jsxs)(`div`,{className:`rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-rose-300/80`,children:`Rejection reason`}),(0,H.jsx)(`p`,{className:`mt-1`,children:C.rejectionReason})]}),C.status===`superseded`&&C.supersededBy&&(0,H.jsxs)(`div`,{className:`rounded-md border border-violet-500/40 bg-violet-500/10 p-3 text-sm text-violet-100`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-violet-300/80`,children:`Superseded by`}),(0,H.jsx)(`button`,{type:`button`,className:`mt-1 font-mono text-sm underline-offset-2 hover:underline`,onClick:()=>{let e=C.supersededBy;r(`all`),a(0),c(e)},children:C.supersededBy})]}),(()=>{let e=_U(C);return e?(0,H.jsxs)(`div`,{className:`rounded-md border border-gray-700 bg-gray-950 p-4 text-sm`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500`,children:`Your correction`}),(0,H.jsxs)(`p`,{className:`mt-2 italic text-gray-200`,children:[`“`,e.user_feedback_excerpt,`”`]}),e.failure_summary&&(0,H.jsx)(`p`,{className:`mt-2 text-gray-400`,children:e.failure_summary})]}):null})(),(()=>{let e=pU(C.conflictsJson),t=_?.trigger_conflicts??[],n=t.length>0?t:e;return(0,H.jsx)(mU,{conflicts:n})})(),v&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading preview…`}),y&&(0,H.jsxs)(`div`,{className:`rounded-md border border-rose-500/50 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[`Preview failed —`,` `,x?.message??`could not apply ops to the current playbook.`,w?` Reject and re-propose with exact list anchors or rewrite_body.`:` Historical preview may be incomplete if the playbook changed.`]}),_&&(0,H.jsx)(fU,{preview:_}),C.status===`stale`&&(0,H.jsx)(`p`,{className:`text-sm text-amber-400`,children:`Stale — playbook changed since proposal. Re-propose from a fresh session.`})]})}),w?(0,H.jsxs)(`div`,{className:`relative z-10 shrink-0 space-y-3 border-t border-gray-800 bg-gray-950 p-4 shadow-[0_-16px_32px_rgba(0,0,0,0.55)] sm:p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-gray-400`,children:`Your decision`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(K,{variant:`gold`,onClick:()=>T.mutate(C.id),disabled:T.isPending||y||!S,children:`Accept`}),(0,H.jsx)(K,{variant:`destructive`,onClick:()=>E.mutate(C.id),disabled:E.isPending,children:`Reject`})]})]}):(0,H.jsxs)(`div`,{className:`shrink-0 border-t border-gray-800 bg-gray-950 px-4 py-3 text-sm text-gray-500 sm:px-5`,children:[`Read-only — already `,C.status,`. Switch to Waiting to review open proposals.`]})]})]})]})]})}var bU=`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07] data-[state=indeterminate]:bg-[#C4B643] data-[state=indeterminate]:text-[#0A0A07]`;function xU(){let{toast:e}=an(),t=Tt(),[n,r]=(0,b.useState)(`open`),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(new Set),{data:u}=Bt({queryKey:[`/api/playbooks/vault`]}),d=u?.data??[],f=(0,b.useMemo)(()=>{let e=new Map;for(let t of d)e.set(t.id,t.title);return e},[d]),p={status:n===`all`?void 0:n,playbookId:i||void 0,excludeInProposal:n===`open`?!o:void 0},{data:m=[],isLoading:h}=Bt({queryKey:[`/api/feedback-signals`,p],queryFn:()=>ug(p)}),g=Vt({mutationFn:e=>dg(e),onSuccess:n=>{e({title:`Discarded ${n.discarded} signal(s)`}),l(new Set),t.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:t=>{e({title:`Discard failed`,description:t.message,variant:`destructive`})}}),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async()=>{let t=c.size>0?m.filter(e=>c.has(e.id)):m;if(t.length!==0){if(t.some(e=>!e.id)){e({title:`Copy blocked`,description:`Every signal must include an id for tracking.`,variant:`destructive`});return}try{await navigator.clipboard.writeText(hg(t)),e({title:`Copied curation prompt`,description:`${t.length} signal id(s) included — paste into your IDE agent.`})}catch(t){e({title:`Copy failed`,description:t instanceof Error?t.message:`Clipboard unavailable`,variant:`destructive`})}}},y=[...c].filter(e=>m.find(t=>t.id===e)?.status===`open`),x=m.length>0&&m.every(e=>c.has(e.id)),S=m.some(e=>c.has(e.id));return(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),`Home`]})}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Feedback`}),(0,H.jsx)(yg,{variant:`outline`,children:m.length}),(0,H.jsx)(ye,{href:`/playbook-patches`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Playbook proposals →`})]})}),(0,H.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-4 px-4 py-6 sm:px-6`,children:[(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Durable correction data for playbook enhancement. Filter by playbook, copy rows (with ids) for an IDE agent to propose, then accept the proposal to mark feedback solved.`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-gray-500`,children:[(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Playbook`}),(0,H.jsxs)(`select`,{className:`mt-1 block min-w-[12rem] rounded border border-gray-700 bg-gray-950 px-2 py-1.5 text-sm text-gray-100`,value:i,onChange:e=>{a(e.target.value),l(new Set)},children:[(0,H.jsx)(`option`,{value:``,children:`All`}),d.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[[`open`,`Open`],[`actioned`,`Actioned`],[`discarded`,`Discarded`],[`all`,`All`]].map(([e,t])=>{let i=n===e;return(0,H.jsx)(K,{size:`sm`,variant:i?`gold`:`outline`,className:i?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":i,onClick:()=>{r(e),l(new Set)},children:t},e)})}),n===`open`&&(0,H.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-gray-400`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Include already in an open proposal`]}),(0,H.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[(0,H.jsxs)(K,{size:`sm`,variant:`outline`,disabled:m.length===0,onClick:()=>void v(),children:[(0,H.jsx)(Ci,{className:`mr-1 h-3.5 w-3.5`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Copy for agent`}),c.size>0?` (${c.size})`:``]}),(0,H.jsxs)(K,{size:`sm`,variant:`destructive`,disabled:y.length===0||g.isPending,onClick:()=>g.mutate(y),children:[(0,H.jsx)(Ki,{className:`mr-1 h-3.5 w-3.5`}),`Discard selected`]})]})]}),h&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!h&&m.length===0&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`No signals match these filters.`}),!h&&m.length>0&&(0,H.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-gray-800`,children:(0,H.jsxs)(`table`,{className:`w-full min-w-[48rem] text-left text-sm`,children:[(0,H.jsx)(`thead`,{className:`border-b border-gray-800 bg-gray-900/80 text-xs uppercase text-gray-500`,children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{className:`w-10 px-3 py-2`,children:(0,H.jsx)(h_,{checked:x?!0:S?`indeterminate`:!1,onCheckedChange:()=>{if(x){l(new Set);return}l(new Set(m.map(e=>e.id)))},"aria-label":`Select all visible signals`,disabled:m.length===0,className:bU})}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Excerpt`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Failure`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Playbook`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Source`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`When`})]})}),(0,H.jsx)(`tbody`,{children:m.map(e=>{let t=fg(e);return(0,H.jsxs)(`tr`,{className:`border-b border-gray-800/80 align-top`,children:[(0,H.jsx)(`td`,{className:`px-3 py-2`,children:(0,H.jsx)(h_,{checked:c.has(e.id),onCheckedChange:()=>_(e.id),"aria-label":`Select ${e.id}`,className:bU})}),(0,H.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`font-mono text-[11px] text-gray-600`,children:e.id}),(0,H.jsxs)(`p`,{className:`text-gray-200`,children:[`“`,e.userFeedbackExcerpt,`”`]}),t&&(0,H.jsx)(yg,{variant:`outline`,className:`mt-1 text-[10px]`,children:`In proposal`})]}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-gray-400`,children:e.failureSummary}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-gray-300`,children:e.candidatePlaybookId?f.get(e.candidatePlaybookId)??e.candidatePlaybookId:`—`}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-gray-500`,children:e.source}),(0,H.jsx)(`td`,{className:`px-3 py-2 whitespace-nowrap text-gray-500`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]})})]})]})}function SU(e){return e instanceof Ht?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`ADMIN_CHALLENGE_EXPIRED`?{message:`This approval request expired or was already used. Ask the agent to request admin elevation again.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request admin elevation again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function CU(){let e=new URLSearchParams(window.location.search),t=e.get(`challenge`)??``,n=e.get(`session`)??``,[r,i]=(0,b.useState)(`idle`),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!0);(0,b.useEffect)(()=>{(!t||!n)&&(i(`error`),c(!1),o(`This link is incomplete. Ask the agent to request admin elevation again.`))},[t,n]);async function l(){if(t&&n){i(`approving`);try{await U(`POST`,`/api/trusted-session/admin/approve`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation approved for this MCP session. Return to the agent.`)}catch(e){let t=SU(e);i(`error`),c(t.retryable),o(t.message)}}}async function u(){if(t&&n){i(`denying`);try{await U(`POST`,`/api/trusted-session/admin/deny`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation denied. The MCP session remains in normal mode.`)}catch(e){let t=SU(e);i(`error`),c(t.retryable),o(t.message)}}}return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,H.jsxs)(Lk,{className:`w-full max-w-md`,children:[(0,H.jsxs)(Rk,{children:[(0,H.jsx)(zk,{children:`Approve agent-admin elevation`}),(0,H.jsx)(Bk,{children:`Grants ephemeral deck-admin mode to one MCP session (30-minute lease). This does not change the folder's deck assignment.`})]}),(0,H.jsxs)(Vk,{className:`space-y-4`,children:[t&&n?(0,H.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:n})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Challenge `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:t})]})]}):null,r===`success`?(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:a}):r===`error`?(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,r!==`success`&&t&&n&&(r!==`error`||s)?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,H.jsx)(K,{variant:`outline`,onClick:()=>void u(),disabled:r===`approving`||r===`denying`,className:`w-full`,children:r===`denying`?`Denying…`:`Deny`}),(0,H.jsx)(K,{onClick:()=>void l(),disabled:r===`approving`||r===`denying`,className:`w-full`,children:r===`approving`?`Approving…`:`Approve elevation`})]}):null]})]})})}function wU(e){return e instanceof Ht?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`DECK_SWITCH_EXPIRED`||e.status===410?{message:`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`,retryable:!1}:e.errorCode===`DECK_SWITCH_CONSUMED`||e.status===409?{message:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`,retryable:!1}:e.errorCode===`RESOURCE_OUT_OF_SCOPE`?{message:`This approval link does not match the requesting session. Only the matching session's request can be approved here — ask the agent for a fresh link if needed.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request the deck switch again.`,retryable:!1}:e.status===404?{message:`This deck-switch request was not found. It may have been cleaned up. Ask the agent to request the switch again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function TU(){let e=new URLSearchParams(window.location.search);return{requestId:(e.get(`request`)??e.get(`requestId`)??``).trim(),runtimeSessionId:(e.get(`session`)??e.get(`runtimeSessionId`)??``).trim()}}function EU(e){return e===`expired`?`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`:e===`declined`?`This deck-switch request was already declined. Nothing was changed.`:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`}function DU(e){let t=e.deckName?` “${e.deckName}”`:``,n=!!e.workspaceRoot?.trim();return e.decision===`session`?n?`Approved for this session only. This session now uses${t}. The workspace default was not changed.`:`Approved for this session only. This session now uses${t}. The agent's configured default was not changed.`:e.decision===`workspace-default`?`Approved. Future sessions${e.workspaceRoot?` in ${e.workspaceRoot}`:``} will use${t} as the new default. This session was switched too.`:n?`Declined. Nothing was changed — the session and workspace default are untouched.`:`Declined. Nothing was changed — the session and the agent's configured default are untouched.`}function OU(){let[{requestId:e,runtimeSessionId:t}]=(0,b.useState)(TU),[n,r]=(0,b.useState)(`loading`),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!0),[u,d]=(0,b.useState)(null),f=(0,b.useRef)(!1),p=(0,b.useCallback)(async()=>{if(!e){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}r(`loading`),s(``);try{let t=(await(await U(`GET`,`/api/trusted-session/deck-switch/${e}`)).json()).data;if(!t||t.requestId!==e)throw Error(`Approval lookup returned an unexpected response`);a(t),t.status===`pending`?r(`pending`):(r(`error`),l(!1),s(EU(t.status)))}catch(e){let t=wU(e);r(`error`),l(t.retryable),s(t.message)}},[e]);(0,b.useEffect)(()=>{p()},[p]);async function m(n){if(f.current)return;let a=t||i?.runtimeSessionId||``;if(!e||!a){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}f.current=!0,d(n),r(`submitting`);try{let t=await(await U(`POST`,`/api/trusted-session/deck-switch/${e}/resolve`,{runtimeSessionId:a,decision:n})).json(),o={decision:n,deckName:t.data?.deckName??i?.requestedDeckName,workspaceRoot:t.data?.workspaceRoot??i?.workspaceRoot};s(DU(o)),r(`success`)}catch(e){let t=wU(e);l(t.retryable),s(t.message),t.retryable&&i?r(`pending`):r(`error`)}finally{f.current=!1,d(null)}}function h(){s(``),i&&c?r(`pending`):p()}let g=n===`loading`||n===`submitting`,_=i?.currentDeckName??i?.currentDeckId,v=i?.requestedDeckName??i?.requestedDeckId,y=t||i?.runtimeSessionId,x=!!i?.workspaceRoot?.trim();return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,H.jsxs)(Lk,{className:`w-full max-w-md`,children:[(0,H.jsxs)(Rk,{children:[(0,H.jsx)(zk,{children:`Approve deck switch`}),(0,H.jsx)(Bk,{children:x?`Choose whether the requested deck applies to this session only or becomes the workspace default. Declining leaves everything unchanged.`:`Choose whether the requested deck applies to this session only, or decline. This session has no writable workspace default.`})]}),(0,H.jsxs)(Vk,{className:`space-y-4`,children:[i&&(_||v)?(0,H.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[_?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Current deck `}),(0,H.jsx)(`dd`,{className:`inline`,children:_})]}):null,v?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Requested deck `}),(0,H.jsx)(`dd`,{className:`inline`,children:v})]}):null,i.workspaceRoot?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Workspace `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:i.workspaceRoot})]}):null,y?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:y})]}):null]}):e?(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Request `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:e})]}):null,n===`loading`?(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading the deck-switch request…`}):null,n===`success`?(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:o}):null,(n===`error`||n===`pending`)&&o?(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o}):null,(n===`pending`||n===`submitting`)&&i?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(K,{onClick:()=>void m(`session`),disabled:g,className:`w-full`,children:u===`session`?`Approving…`:`This session only`}),x?(0,H.jsx)(K,{onClick:()=>void m(`workspace-default`),disabled:g,variant:`secondary`,className:`w-full`,children:u===`workspace-default`?`Approving…`:`This workspace by default`}):null,(0,H.jsx)(K,{onClick:()=>void m(`decline`),disabled:g,variant:`outline`,className:`w-full`,children:u===`decline`?`Declining…`:`Decline`})]}):null,n===`error`?c?(0,H.jsx)(K,{onClick:h,variant:`outline`,className:`w-full`,children:`Try again`}):(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No further action is possible on this link. You can close this tab.`}):null,n===`success`?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You can close this tab and return to the agent.`}):null]})]})})}async function kU(e){return(await(await U(`POST`,`/api/agent-grants`,e)).json()).data}async function AU(e){await U(`POST`,`/api/agent-grants/${encodeURIComponent(e)}/revoke`)}var jU=[];function MU(e){if(!e)return`Never`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function NU(e){return e.revokedAt?`revoked`:e.expiresAt&&Date.parse(e.expiresAt)<=Date.now()?`expired`:`active`}function PU(e,t){if(e===`none`)return;if(e===`custom`)return new Date(t).toISOString();let n=e===`30`?30:90;return new Date(Date.now()+n*24*60*60*1e3).toISOString()}function FU(){let e=Tt(),{toast:t}=an(),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(new Set),[c,l]=(0,b.useState)(`none`),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)(null),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(null),[v,y]=(0,b.useState)(null),x=(0,b.useRef)(!1),{data:S,isLoading:C,error:w}=Bt({queryKey:[`/api/dashboard-auth/context`]}),T=S?.data.hosted===!0,{data:E}=Bt({queryKey:[`/api/decks`],enabled:T}),D=E?.data??[],{data:O,isLoading:k,error:A}=Bt({queryKey:[`/api/agent-grants`],enabled:T}),j=O?.data??jU;(0,b.useEffect)(()=>{x.current||D.length===0||(x.current=!0,a(D[0].id),s(new Set(D.map(e=>e.id))))},[D]);let M=(0,b.useMemo)(()=>new Map(D.map(e=>[e.id,e.name])),[D]),N=Vt({mutationFn:AU,onSuccess:(n,r)=>{let i=new Date().toISOString();e.setQueryData([`/api/agent-grants`],e=>e&&{...e,data:e.data.map(e=>e.id===r?{...e,revokedAt:i}:e)}),y(null),e.invalidateQueries({queryKey:[`/api/agent-grants`]}),t({title:`Grant revoked`,description:`The bearer stops working immediately.`})},onError:e=>{t({title:`Revoke failed`,description:e.message,variant:`destructive`})}}),P=(e,t)=>{s(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},F=e=>{a(e),s(t=>new Set(t).add(e))};return C?(0,H.jsx)(RU,{message:`Loading grant settings…`}):w?(0,H.jsx)(RU,{message:`Owner sign-in is required to manage grants.`,isError:!0}):T?(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),`Deck`]})}),(0,H.jsx)(Ai,{className:`h-5 w-5 text-[#C4B643]`,"aria-hidden":!0}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Remote agent grants`}),(0,H.jsx)(yg,{variant:`outline`,className:`border-gray-700 text-gray-300`,children:j.length})]})}),(0,H.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-5 px-4 py-6 sm:px-6`,children:[(0,H.jsx)(`p`,{className:`max-w-3xl text-sm leading-6 text-gray-400`,children:`Issue a separate bearer for each remote agent. Deck access is fixed at creation; revoke and reissue when it needs to change.`}),f&&(0,H.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-amber-400/50 bg-amber-400/10 p-4`,"aria-label":`New bearer secret`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`font-ui-display font-semibold text-amber-200`,children:[`Copy the bearer for `,f.label]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm font-semibold text-amber-100`,children:`This secret will not be shown again.`})]}),(0,H.jsxs)(K,{type:`button`,variant:`ghost`,size:`sm`,className:`text-amber-100 hover:bg-amber-300/10 hover:text-amber-50`,onClick:()=>p(null),children:[(0,H.jsx)(mi,{className:`h-4 w-4`}),`Done — hide secret`]})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex min-w-0 flex-col gap-2 sm:flex-row`,children:[(0,H.jsx)(Eu,{readOnly:!0,"aria-label":`Bearer secret`,value:f.token,className:`min-w-0 flex-1 border-amber-300/30 bg-black/40 font-mono text-xs text-amber-50`}),(0,H.jsxs)(K,{type:`button`,variant:`gold`,className:`w-full sm:w-auto`,onClick:async()=>{try{await navigator.clipboard.writeText(f.token),t({title:`Bearer copied`})}catch{t({title:`Copy failed`,variant:`destructive`})}},children:[(0,H.jsx)(Ci,{className:`h-4 w-4`}),`Copy bearer`]})]})]}),(0,H.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)]`,children:[(0,H.jsxs)(`section`,{className:`h-fit min-w-0 rounded-xl border border-gray-800 bg-gray-900/50 p-4 sm:p-5`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display text-base font-semibold`,children:`Create grant`}),(0,H.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:async t=>{if(t.preventDefault(),_(null),!i){_(`Choose a default deck.`);return}if(c===`custom`&&!u){_(`Choose a custom expiry date.`);return}h(!0);try{let t=await kU({label:n.trim(),defaultDeck:i,allowedDecks:[...o],expiresAt:PU(c,u)});p({label:t.grant.label,token:t.token}),e.setQueryData([`/api/agent-grants`],e=>({success:!0,data:e?[...e.data.filter(e=>e.id!==t.grant.id),t.grant]:[t.grant]})),r(``)}catch(e){_(e instanceof Error?e.message:`Grant creation failed`)}finally{h(!1)}},children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Qp,{htmlFor:`grant-label`,children:`Agent label`}),(0,H.jsx)(Eu,{id:`grant-label`,required:!0,value:n,onChange:e=>r(e.target.value),placeholder:`Research agent`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Qp,{htmlFor:`default-deck`,children:`Default deck`}),(0,H.jsx)(`select`,{id:`default-deck`,required:!0,value:i,onChange:e=>F(e.target.value),className:`h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:D.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,H.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,H.jsx)(`legend`,{className:`text-sm font-medium`,children:`Allowed decks`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:`All decks are selected by default.`}),(0,H.jsx)(`div`,{className:`max-h-48 space-y-2 overflow-y-auto rounded-md border border-gray-800 p-3`,children:D.map(e=>{let t=e.id===i;return(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(h_,{id:`allowed-${e.id}`,checked:o.has(e.id),disabled:t,onCheckedChange:t=>P(e.id,t===!0),className:`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07]`}),(0,H.jsxs)(Qp,{htmlFor:`allowed-${e.id}`,className:`min-w-0 break-words font-normal`,children:[e.name,t?` (default)`:``]})]},e.id)})})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Qp,{htmlFor:`grant-expiry`,children:`Expiry`}),(0,H.jsxs)(`select`,{id:`grant-expiry`,value:c,onChange:e=>l(e.target.value),className:`h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:[(0,H.jsx)(`option`,{value:`none`,children:`None`}),(0,H.jsx)(`option`,{value:`30`,children:`30 days`}),(0,H.jsx)(`option`,{value:`90`,children:`90 days`}),(0,H.jsx)(`option`,{value:`custom`,children:`Custom`})]})]}),c===`custom`&&(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(Qp,{htmlFor:`custom-expiry`,children:`Expires at`}),(0,H.jsx)(Eu,{id:`custom-expiry`,type:`datetime-local`,required:!0,value:u,onChange:e=>d(e.target.value)})]}),g&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-rose-300`,children:g}),(0,H.jsx)(K,{type:`submit`,variant:`gold`,className:`w-full`,disabled:m||D.length===0,children:m?`Creating…`:`Create grant`})]})]}),(0,H.jsxs)(`section`,{className:`min-w-0 space-y-3`,"aria-label":`Existing grants`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display text-base font-semibold`,children:`Existing grants`}),k&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading grants…`}),A&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-rose-300`,children:`Could not load grants.`}),!k&&!A&&j.length===0&&(0,H.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-800 p-8 text-center text-sm text-gray-500`,children:`No remote agent grants yet.`}),j.map(e=>{let t=NU(e),n=t!==`revoked`,r=v===e.id;return(0,H.jsxs)(`article`,{className:`min-w-0 rounded-xl border border-gray-800 bg-gray-900/50 p-4 sm:p-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`break-words font-semibold text-gray-100`,children:e.label}),(0,H.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-gray-600`,children:e.id})]}),(0,H.jsx)(IU,{status:t})]}),(0,H.jsxs)(`dl`,{className:`mt-4 grid min-w-0 gap-x-5 gap-y-3 text-sm sm:grid-cols-2 xl:grid-cols-3`,children:[(0,H.jsx)(LU,{label:`Default deck`,value:M.get(e.defaultDeck)??e.defaultDeck}),(0,H.jsx)(LU,{label:`Allowed decks`,value:e.allowedDecks.map(e=>M.get(e)??e).join(`, `)||`None`}),(0,H.jsx)(LU,{label:`Created`,value:MU(e.createdAt)}),(0,H.jsx)(LU,{label:`Expires`,value:MU(e.expiresAt)}),(0,H.jsx)(LU,{label:`Last used`,value:e.lastUsedAt?MU(e.lastUsedAt):`Never`})]}),n&&(0,H.jsx)(`div`,{className:`mt-4 border-t border-gray-800 pt-4`,children:r?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,role:`group`,"aria-label":`Confirm revoke ${e.label}`,children:[(0,H.jsxs)(`p`,{className:`text-sm text-rose-200`,children:[`Revoke `,e.label,` now? This is immediate.`]}),(0,H.jsxs)(`div`,{className:`flex w-full gap-2 sm:w-auto`,children:[(0,H.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,className:`flex-1 sm:flex-none`,onClick:()=>y(null),children:`Cancel`}),(0,H.jsx)(K,{type:`button`,variant:`destructive`,size:`sm`,className:`flex-1 sm:flex-none`,disabled:N.isPending,onClick:()=>N.mutate(e.id),children:`Confirm revoke`})]})]}):(0,H.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`border-rose-900 text-rose-200 hover:bg-rose-950`,onClick:()=>y(e.id),children:[(0,H.jsx)(Hi,{className:`h-4 w-4`}),`Revoke`]})})]},e.id)})]})]})]})]}):(0,H.jsx)(RU,{message:`Remote agent grants are available in hosted mode only.`})}function IU({status:e}){return(0,H.jsx)(yg,{variant:`outline`,className:e===`active`?`border-emerald-500/40 text-emerald-200`:e===`expired`?`border-amber-500/40 text-amber-200`:`border-rose-500/40 text-rose-200`,children:e})}function LU({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`font-ui-display text-xs text-gray-500`,children:e}),(0,H.jsx)(`dd`,{className:`mt-1 break-words text-gray-300`,children:t})]})}function RU({message:e,isError:t=!1}){return(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,children:[(0,H.jsx)(ci,{className:`h-4 w-4`}),`Deck`]})}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Remote agent grants`})]})}),(0,H.jsx)(`main`,{className:`mx-auto w-full max-w-7xl px-4 py-8 sm:px-6`,children:(0,H.jsx)(`p`,{role:t?`alert`:`status`,className:t?`text-rose-300`:`text-gray-400`,children:e})})]})}async function zU(e){let t=new URLSearchParams({limit:`50`});return e&&t.set(`before`,e),(await U(`GET`,`/api/audit?${t.toString()}`)).json()}function BU(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}).format(t)}function VU({entry:e}){return(0,H.jsx)(yg,{variant:`outline`,className:e.outcome===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-300`:`border-rose-500/40 bg-rose-500/10 text-rose-300`,children:e.outcome})}function HU({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`font-ui-display text-xs uppercase tracking-wide text-gray-500`,children:e}),(0,H.jsx)(`dd`,{className:`mt-1 break-all text-sm text-gray-200`,children:t})]})}function UU(){let[e,t]=(0,b.useState)([void 0]),n=e.at(-1),{data:r,isLoading:i,error:a}=Bt({queryKey:[`/api/dashboard-auth/context`]}),o=r?.data.hosted===!0,{data:s,isLoading:c,error:l}=Bt({queryKey:[`audit`,n??`newest`],queryFn:()=>zU(n),enabled:o});return i?(0,H.jsx)(WU,{message:`Loading audit history…`}):a?(0,H.jsx)(WU,{message:`Owner sign-in is required to view audit history.`,isError:!0}):o?(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),`Deck`]})}),(0,H.jsx)(Ri,{className:`h-5 w-5 text-[#C4B643]`,"aria-hidden":!0}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Audit history`})]})}),(0,H.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-5 px-4 py-6 sm:px-6`,children:[(0,H.jsx)(`p`,{className:`max-w-3xl text-sm leading-6 text-gray-400`,children:`Security-relevant grant, sign-in, deck-selection and elevation activity from the last 90 days.`}),c?(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading events…`}):null,l?(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-rose-300`,children:`Audit history could not be loaded.`}):null,s?.data.length===0?(0,H.jsx)(`div`,{className:`rounded-xl border border-gray-800 bg-gray-900/70 p-8 text-center text-sm text-gray-400`,children:`No audit events on this page.`}):null,s?.data.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`hidden overflow-hidden rounded-xl border border-gray-800 bg-gray-900/70 md:block`,children:(0,H.jsxs)(g_,{children:[(0,H.jsx)(__,{children:(0,H.jsxs)(b_,{className:`border-gray-800 hover:bg-transparent`,children:[(0,H.jsx)(x_,{children:`Time`}),(0,H.jsx)(x_,{children:`Event`}),(0,H.jsx)(x_,{children:`Actor`}),(0,H.jsx)(x_,{children:`Target`}),(0,H.jsx)(x_,{children:`Outcome`}),(0,H.jsx)(x_,{children:`Reason`})]})}),(0,H.jsx)(v_,{children:s.data.map(e=>(0,H.jsxs)(b_,{className:`border-gray-800 hover:bg-white/[0.03]`,children:[(0,H.jsx)(S_,{className:`whitespace-nowrap text-xs text-gray-400`,children:BU(e.timestamp)}),(0,H.jsx)(S_,{className:`font-medium text-[#E8F6F4]`,children:e.event}),(0,H.jsx)(S_,{className:`max-w-48 break-all font-mono text-xs`,children:e.actor}),(0,H.jsx)(S_,{className:`max-w-56 break-all font-mono text-xs`,children:e.targetId}),(0,H.jsx)(S_,{children:(0,H.jsx)(VU,{entry:e})}),(0,H.jsx)(S_,{className:`text-xs text-gray-400`,children:e.reasonCode??`—`})]},e.id))})]})}),(0,H.jsx)(`ol`,{className:`space-y-3 md:hidden`,"aria-label":`Audit events`,children:s.data.map(e=>(0,H.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-gray-800 bg-gray-900/70 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`min-w-0 break-words font-medium text-[#E8F6F4]`,children:e.event}),(0,H.jsx)(VU,{entry:e})]}),(0,H.jsxs)(`dl`,{className:`mt-4 grid min-w-0 grid-cols-1 gap-3`,children:[(0,H.jsx)(HU,{label:`Time`,children:BU(e.timestamp)}),(0,H.jsx)(HU,{label:`Actor`,children:e.actor}),(0,H.jsx)(HU,{label:`Target`,children:e.targetId}),(0,H.jsx)(HU,{label:`Reason`,children:e.reasonCode??`—`})]})]},e.id))})]}):null,s?(0,H.jsxs)(`nav`,{className:`flex items-center justify-between gap-3`,"aria-label":`Audit pagination`,children:[(0,H.jsx)(K,{variant:`outline`,disabled:e.length===1,onClick:()=>t(e=>e.slice(0,-1)),children:`Newer`}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Page `,e.length]}),(0,H.jsx)(K,{variant:`outline`,disabled:!s.paging.nextBefore,onClick:()=>s.paging.nextBefore&&t(e=>[...e,s.paging.nextBefore]),children:`Older`})]}):null]})]}):(0,H.jsx)(WU,{message:`Audit history is available in hosted mode only.`})}function WU({message:e,isError:t=!1}){return(0,H.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center bg-gray-950 px-4 text-center`,children:(0,H.jsx)(`p`,{className:t?`text-rose-300`:`text-gray-300`,children:e})})}function GU(){return(0,H.jsxs)(xe,{children:[(0,H.jsx)(ve,{path:`/`,component:Ik}),(0,H.jsx)(ve,{path:`/oauth/callback`,component:Wk}),(0,H.jsx)(ve,{path:`/playbook-patches`,component:yU}),(0,H.jsx)(ve,{path:`/feedback-signals`,component:xU}),(0,H.jsx)(ve,{path:`/grants`,component:FU}),(0,H.jsx)(ve,{path:`/audit`,component:UU}),(0,H.jsx)(ve,{path:`/admin/approve`,component:CU}),(0,H.jsx)(ve,{path:`/deck-switch/approve`,component:OU}),(0,H.jsx)(ve,{path:`/mcp-test`,component:NH}),(0,H.jsx)(ve,{component:Uk})]})}function KU(){let[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=!1;return Kt().finally(()=>{e||t(!0)}),()=>{e=!0}},[]),e?(0,H.jsx)(Et,{client:Gt,children:(0,H.jsxs)(Al,{children:[(0,H.jsx)(ro,{}),(0,H.jsx)(GU,{})]})}):(0,H.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[#0B1220] text-sm text-gray-300`,children:`Loading AgentDeck...`})}(0,x.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(b.StrictMode,{children:(0,H.jsx)(KU,{})}));
|
|
251
|
+
`);return(0,H.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[!t&&(0,H.jsxs)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:[`No change detected — ops did not alter the playbook body or triggers. Reject this proposal and re-propose with a matching list anchor or `,(0,H.jsx)(`code`,{children:`rewrite_body`}),`.`]}),r&&(0,H.jsx)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:`Full-body rewrite proposed — review carefully.`}),i&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Title`}),(0,H.jsxs)(`div`,{className:`${cU} p-0`,children:[e.before.title&&(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,H.jsx)(`span`,{children:e.before.title})]})]}),e.after.title&&(0,H.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,H.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,H.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,H.jsx)(`span`,{children:e.after.title})]})]})]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Body`}),(0,H.jsx)(dU,{rows:n,emptyLabel:`No body changes.`})]}),a&&(0,H.jsx)(fU,{before:e.before.triggers,after:e.after.triggers})]})}function mU(e){if(!e)return[];try{return JSON.parse(e)}catch{return[]}}function hU({conflicts:e,title:t=`Trigger overlap warnings`}){return e.length===0?null:(0,H.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-4 text-sm text-amber-50`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-amber-200/90`,children:t}),(0,H.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`These triggers overlap with other playbooks on the deck. Accept is still allowed — disambiguate triggers or propose a merge if the wrong playbook keeps firing.`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>(0,H.jsxs)(`li`,{className:`rounded border border-amber-500/20 bg-gray-950/60 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(bg,{variant:`outline`,className:`border-amber-400/40 text-amber-100`,children:e.level}),(0,H.jsx)(`span`,{className:`font-medium text-amber-50`,children:e.otherPlaybookTitle}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-amber-200/70`,children:e.otherPlaybookId})]}),(0,H.jsxs)(`p`,{className:`mt-2 text-amber-100/90`,children:[(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:`Candidate:`}),` `,e.trigger]}),(0,H.jsxs)(`p`,{className:`text-amber-100/80`,children:[(0,H.jsx)(`span`,{className:`text-amber-200/80`,children:`Other:`}),` `,e.otherTrigger]})]},`${e.trigger}-${e.otherPlaybookId}-${e.level}`))})]})}var gU=8,_U=[{value:`proposed`,label:`Waiting`},{value:`accepted`,label:`Accepted`},{value:`rejected`,label:`Rejected`},{value:`superseded`,label:`Superseded`},{value:`stale`,label:`Stale`},{value:`all`,label:`All`}];function vU(e){if(!e.evidenceJson)return null;try{return JSON.parse(e.evidenceJson)}catch{return null}}function yU(e){switch(e){case`proposed`:return`border-blue-500/40 text-blue-200`;case`accepted`:return`border-emerald-500/40 text-emerald-200`;case`rejected`:return`border-rose-500/40 text-rose-200`;case`superseded`:return`border-violet-500/40 text-violet-200`;case`stale`:return`border-amber-500/40 text-amber-200`}}function bU(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(`proposed`),[i,a]=(0,b.useState)(0),{toast:o}=an(),s=Tt();function c(e){t(e)}function l(e){r(e),a(0),t(null)}let{data:u=[]}=Bt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>ig(`proposed`)}),d=n===`all`?void 0:n,{data:f=[],isLoading:p}=Bt({queryKey:[`/api/playbook-patches`,n],queryFn:()=>ig(d)}),m=Math.max(1,Math.ceil(f.length/gU)),h=Math.min(i,m-1),g=(0,b.useMemo)(()=>{let e=h*gU;return f.slice(e,e+gU)},[f,h]);(0,b.useEffect)(()=>{i!==h&&a(h)},[i,h]);let{data:_,isLoading:v,isError:y,error:x}=Bt({queryKey:[`/api/playbook-patches`,e,`preview`],queryFn:()=>ag(e),enabled:!!e}),S=_?FH(_):!1,C=f.find(t=>t.id===e)??null,w=C?.status===`proposed`,T=Vt({mutationFn:e=>og(e),onSuccess:()=>{o({title:`Patch accepted`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/playbooks`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Accept failed`,description:e.message,variant:`destructive`})}}),E=Vt({mutationFn:e=>sg(e),onSuccess:()=>{o({title:`Patch rejected`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Reject failed`,description:e.message,variant:`destructive`})}}),D=n===`proposed`?`No proposals waiting for review.`:n===`all`?`No playbook patches yet.`:`No ${n} patches.`;return(0,H.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Deck`})]})}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Playbook review queue`}),(0,H.jsxs)(bg,{variant:`secondary`,children:[u.length,` waiting`]}),(0,H.jsx)(ye,{href:`/feedback-signals`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Feedback data →`})]})}),(0,H.jsxs)(`main`,{className:`mx-auto grid w-full max-w-7xl min-h-0 flex-1 gap-6 overflow-hidden px-4 py-6 sm:px-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)] lg:items-stretch`,children:[(0,H.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Proposals`}),(0,H.jsx)(`div`,{className:`mb-3 flex shrink-0 flex-wrap gap-1`,children:_U.map(({value:e,label:t})=>{let r=n===e;return(0,H.jsx)(K,{size:`sm`,variant:r?`gold`:`outline`,className:r?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":r,onClick:()=>l(e),children:t},e)})}),(0,H.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!p&&f.length===0&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:D}),(0,H.jsx)(`ul`,{className:`space-y-2`,children:g.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:`w-full rounded-lg border p-3 text-left transition ${e===t.id?`border-blue-500 bg-gray-900`:`border-gray-800 bg-gray-900/50 hover:border-gray-700`}`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`span`,{className:`block font-medium leading-snug`,children:t.kind===`create`?`New: ${t.displayTitle}`:t.displayTitle}),t.playbookId&&t.kind!==`create`&&(0,H.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-gray-600`,children:t.playbookId}),rg(t.deckNames)&&(0,H.jsxs)(`span`,{className:`mt-1 block text-xs text-gray-500`,children:[`Decks: `,rg(t.deckNames)]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,H.jsx)(bg,{variant:`outline`,className:`shrink-0`,children:t.kind}),n!==`proposed`&&(0,H.jsx)(bg,{variant:`outline`,className:`shrink-0 ${yU(t.status)}`,children:t.status})]})]}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-gray-400`,children:t.rationale}),(0,H.jsxs)(`p`,{className:`mt-1 text-xs text-gray-600`,children:[t.source,` · `,new Date(t.createdAt).toLocaleString()]})]})},t.id))})]}),f.length>gU&&(0,H.jsxs)(`div`,{className:`mt-3 flex shrink-0 items-center justify-between gap-2 border-t border-gray-800 pt-3`,children:[(0,H.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h<=0,onClick:()=>a(e=>Math.max(0,e-1)),children:[(0,H.jsx)(gi,{className:`mr-1 h-4 w-4`}),`Newer`]}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[h+1,` / `,m,(0,H.jsxs)(`span`,{className:`ml-1 text-gray-600`,children:[`(`,f.length,`)`]})]}),(0,H.jsxs)(K,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h>=m-1,onClick:()=>a(e=>Math.min(m-1,e+1)),children:[`Older`,(0,H.jsx)(_i,{className:`ml-1 h-4 w-4`})]})]})]}),(0,H.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Detail`}),!C&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Select a proposal to preview the diff.`}),C&&(0,H.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-gray-800 bg-gray-900/50`,children:[(0,H.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-5`,children:(0,H.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(bg,{variant:`outline`,className:yU(C.status),children:C.status}),C.resolvedAt&&(0,H.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Resolved `,new Date(C.resolvedAt).toLocaleString()]})]}),(0,H.jsx)(`p`,{className:`text-sm leading-relaxed text-gray-300`,children:C.rationale}),C.status===`rejected`&&C.rejectionReason&&(0,H.jsxs)(`div`,{className:`rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-rose-300/80`,children:`Rejection reason`}),(0,H.jsx)(`p`,{className:`mt-1`,children:C.rejectionReason})]}),C.status===`superseded`&&C.supersededBy&&(0,H.jsxs)(`div`,{className:`rounded-md border border-violet-500/40 bg-violet-500/10 p-3 text-sm text-violet-100`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-violet-300/80`,children:`Superseded by`}),(0,H.jsx)(`button`,{type:`button`,className:`mt-1 font-mono text-sm underline-offset-2 hover:underline`,onClick:()=>{let e=C.supersededBy;r(`all`),a(0),c(e)},children:C.supersededBy})]}),(()=>{let e=vU(C);return e?(0,H.jsxs)(`div`,{className:`rounded-md border border-gray-700 bg-gray-950 p-4 text-sm`,children:[(0,H.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500`,children:`Your correction`}),(0,H.jsxs)(`p`,{className:`mt-2 italic text-gray-200`,children:[`“`,e.user_feedback_excerpt,`”`]}),e.failure_summary&&(0,H.jsx)(`p`,{className:`mt-2 text-gray-400`,children:e.failure_summary})]}):null})(),(()=>{let e=mU(C.conflictsJson),t=_?.trigger_conflicts??[],n=t.length>0?t:e;return(0,H.jsx)(hU,{conflicts:n})})(),v&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading preview…`}),y&&(0,H.jsxs)(`div`,{className:`rounded-md border border-rose-500/50 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[`Preview failed —`,` `,x?.message??`could not apply ops to the current playbook.`,w?` Reject and re-propose with exact list anchors or rewrite_body.`:` Historical preview may be incomplete if the playbook changed.`]}),_&&(0,H.jsx)(pU,{preview:_}),C.status===`stale`&&(0,H.jsx)(`p`,{className:`text-sm text-amber-400`,children:`Stale — playbook changed since proposal. Re-propose from a fresh session.`})]})}),w?(0,H.jsxs)(`div`,{className:`relative z-10 shrink-0 space-y-3 border-t border-gray-800 bg-gray-950 p-4 shadow-[0_-16px_32px_rgba(0,0,0,0.55)] sm:p-5`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-gray-400`,children:`Your decision`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,H.jsx)(K,{variant:`gold`,onClick:()=>T.mutate(C.id),disabled:T.isPending||y||!S,children:`Accept`}),(0,H.jsx)(K,{variant:`destructive`,onClick:()=>E.mutate(C.id),disabled:E.isPending,children:`Reject`})]})]}):(0,H.jsxs)(`div`,{className:`shrink-0 border-t border-gray-800 bg-gray-950 px-4 py-3 text-sm text-gray-500 sm:px-5`,children:[`Read-only — already `,C.status,`. Switch to Waiting to review open proposals.`]})]})]})]})]})}var xU=`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07] data-[state=indeterminate]:bg-[#C4B643] data-[state=indeterminate]:text-[#0A0A07]`;function SU(){let{toast:e}=an(),t=Tt(),[n,r]=(0,b.useState)(`open`),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(new Set),{data:u}=Bt({queryKey:[`/api/playbooks/vault`]}),d=u?.data??[],f=(0,b.useMemo)(()=>{let e=new Map;for(let t of d)e.set(t.id,t.title);return e},[d]),p={status:n===`all`?void 0:n,playbookId:i||void 0,excludeInProposal:n===`open`?!o:void 0},{data:m=[],isLoading:h}=Bt({queryKey:[`/api/feedback-signals`,p],queryFn:()=>dg(p)}),g=Vt({mutationFn:e=>fg(e),onSuccess:n=>{e({title:`Discarded ${n.discarded} signal(s)`}),l(new Set),t.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:t=>{e({title:`Discard failed`,description:t.message,variant:`destructive`})}}),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async()=>{let t=c.size>0?m.filter(e=>c.has(e.id)):m;if(t.length!==0){if(t.some(e=>!e.id)){e({title:`Copy blocked`,description:`Every signal must include an id for tracking.`,variant:`destructive`});return}try{await navigator.clipboard.writeText(gg(t)),e({title:`Copied curation prompt`,description:`${t.length} signal id(s) included — paste into your IDE agent.`})}catch(t){e({title:`Copy failed`,description:t instanceof Error?t.message:`Clipboard unavailable`,variant:`destructive`})}}},y=[...c].filter(e=>m.find(t=>t.id===e)?.status===`open`),x=m.length>0&&m.every(e=>c.has(e.id)),S=m.some(e=>c.has(e.id));return(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),`Home`]})}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Feedback`}),(0,H.jsx)(bg,{variant:`outline`,children:m.length}),(0,H.jsx)(ye,{href:`/playbook-patches`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Playbook proposals →`})]})}),(0,H.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-4 px-4 py-6 sm:px-6`,children:[(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Durable correction data for playbook enhancement. Filter by playbook, copy rows (with ids) for an IDE agent to propose, then accept the proposal to mark feedback solved.`}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-3`,children:[(0,H.jsxs)(`label`,{className:`text-xs text-gray-500`,children:[(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Playbook`}),(0,H.jsxs)(`select`,{className:`mt-1 block min-w-[12rem] rounded border border-gray-700 bg-gray-950 px-2 py-1.5 text-sm text-gray-100`,value:i,onChange:e=>{a(e.target.value),l(new Set)},children:[(0,H.jsx)(`option`,{value:``,children:`All`}),d.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[[`open`,`Open`],[`actioned`,`Actioned`],[`discarded`,`Discarded`],[`all`,`All`]].map(([e,t])=>{let i=n===e;return(0,H.jsx)(K,{size:`sm`,variant:i?`gold`:`outline`,className:i?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":i,onClick:()=>{r(e),l(new Set)},children:t},e)})}),n===`open`&&(0,H.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-gray-400`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Include already in an open proposal`]}),(0,H.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[(0,H.jsxs)(K,{size:`sm`,variant:`outline`,disabled:m.length===0,onClick:()=>void v(),children:[(0,H.jsx)(Ci,{className:`mr-1 h-3.5 w-3.5`}),(0,H.jsx)(`span`,{className:`font-ui-display`,children:`Copy for agent`}),c.size>0?` (${c.size})`:``]}),(0,H.jsxs)(K,{size:`sm`,variant:`destructive`,disabled:y.length===0||g.isPending,onClick:()=>g.mutate(y),children:[(0,H.jsx)(Ki,{className:`mr-1 h-3.5 w-3.5`}),`Discard selected`]})]})]}),h&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!h&&m.length===0&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`No signals match these filters.`}),!h&&m.length>0&&(0,H.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-gray-800`,children:(0,H.jsxs)(`table`,{className:`w-full min-w-[48rem] text-left text-sm`,children:[(0,H.jsx)(`thead`,{className:`border-b border-gray-800 bg-gray-900/80 text-xs uppercase text-gray-500`,children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(`th`,{className:`w-10 px-3 py-2`,children:(0,H.jsx)(g_,{checked:x?!0:S?`indeterminate`:!1,onCheckedChange:()=>{if(x){l(new Set);return}l(new Set(m.map(e=>e.id)))},"aria-label":`Select all visible signals`,disabled:m.length===0,className:xU})}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Excerpt`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Failure`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Playbook`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`Source`}),(0,H.jsx)(`th`,{className:`px-3 py-2`,children:`When`})]})}),(0,H.jsx)(`tbody`,{children:m.map(e=>{let t=pg(e);return(0,H.jsxs)(`tr`,{className:`border-b border-gray-800/80 align-top`,children:[(0,H.jsx)(`td`,{className:`px-3 py-2`,children:(0,H.jsx)(g_,{checked:c.has(e.id),onCheckedChange:()=>_(e.id),"aria-label":`Select ${e.id}`,className:xU})}),(0,H.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`font-mono text-[11px] text-gray-600`,children:e.id}),(0,H.jsxs)(`p`,{className:`text-gray-200`,children:[`“`,e.userFeedbackExcerpt,`”`]}),t&&(0,H.jsx)(bg,{variant:`outline`,className:`mt-1 text-[10px]`,children:`In proposal`})]}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-gray-400`,children:e.failureSummary}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-gray-300`,children:e.candidatePlaybookId?f.get(e.candidatePlaybookId)??e.candidatePlaybookId:`—`}),(0,H.jsx)(`td`,{className:`px-3 py-2 text-gray-500`,children:e.source}),(0,H.jsx)(`td`,{className:`px-3 py-2 whitespace-nowrap text-gray-500`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]})})]})]})}function CU(e){return e instanceof Ht?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`ADMIN_CHALLENGE_EXPIRED`?{message:`This approval request expired or was already used. Ask the agent to request admin elevation again.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request admin elevation again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function wU(){let e=new URLSearchParams(window.location.search),t=e.get(`challenge`)??``,n=e.get(`session`)??``,[r,i]=(0,b.useState)(`idle`),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(!0);(0,b.useEffect)(()=>{(!t||!n)&&(i(`error`),c(!1),o(`This link is incomplete. Ask the agent to request admin elevation again.`))},[t,n]);async function l(){if(t&&n){i(`approving`);try{await U(`POST`,`/api/trusted-session/admin/approve`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation approved for this MCP session. Return to the agent.`)}catch(e){let t=CU(e);i(`error`),c(t.retryable),o(t.message)}}}async function u(){if(t&&n){i(`denying`);try{await U(`POST`,`/api/trusted-session/admin/deny`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation denied. The MCP session remains in normal mode.`)}catch(e){let t=CU(e);i(`error`),c(t.retryable),o(t.message)}}}return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,H.jsxs)(Rk,{className:`w-full max-w-md`,children:[(0,H.jsxs)(zk,{children:[(0,H.jsx)(Bk,{children:`Approve agent-admin elevation`}),(0,H.jsx)(Vk,{children:`Grants ephemeral deck-admin mode to one MCP session (30-minute lease). This does not change the folder's deck assignment.`})]}),(0,H.jsxs)(Hk,{className:`space-y-4`,children:[t&&n?(0,H.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:n})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Challenge `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:t})]})]}):null,r===`success`?(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:a}):r===`error`?(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,r!==`success`&&t&&n&&(r!==`error`||s)?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,H.jsx)(K,{variant:`outline`,onClick:()=>void u(),disabled:r===`approving`||r===`denying`,className:`w-full`,children:r===`denying`?`Denying…`:`Deny`}),(0,H.jsx)(K,{onClick:()=>void l(),disabled:r===`approving`||r===`denying`,className:`w-full`,children:r===`approving`?`Approving…`:`Approve elevation`})]}):null]})]})})}function TU(e){return e instanceof Ht?e.errorCode===`GRANT_REQUIRED`||e.errorCode===`DASHBOARD_REQUIRED`?{message:`This browser is not signed in to the Agent Deck dashboard. Run agent-deck open, then open this approval link again.`,retryable:!0}:e.errorCode===`DECK_SWITCH_EXPIRED`||e.status===410?{message:`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`,retryable:!1}:e.errorCode===`DECK_SWITCH_CONSUMED`||e.status===409?{message:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`,retryable:!1}:e.errorCode===`RESOURCE_OUT_OF_SCOPE`?{message:`This approval link does not match the requesting session. Only the matching session's request can be approved here — ask the agent for a fresh link if needed.`,retryable:!1}:e.errorCode===`SESSION_INVALID`?{message:`The agent session for this request is gone. Ask the agent to reconnect and request the deck switch again.`,retryable:!1}:e.status===404?{message:`This deck-switch request was not found. It may have been cleaned up. Ask the agent to request the switch again.`,retryable:!1}:{message:e.message||`Approval failed`,retryable:!0}:e instanceof TypeError?{message:`Could not reach Agent Deck. Check that it is running (agent-deck status) and try again.`,retryable:!0}:{message:e instanceof Error&&e.message?e.message:`Approval failed`,retryable:!0}}function EU(){let e=new URLSearchParams(window.location.search);return{requestId:(e.get(`request`)??e.get(`requestId`)??``).trim(),runtimeSessionId:(e.get(`session`)??e.get(`runtimeSessionId`)??``).trim()}}function DU(e){return e===`expired`?`This deck-switch request expired. The session and workspace default were not changed. Ask the agent to request the switch again.`:e===`declined`?`This deck-switch request was already declined. Nothing was changed.`:`This deck-switch request was already resolved. The switch was not applied twice — check the current deck before requesting again.`}function OU(e){let t=e.deckName?` “${e.deckName}”`:``,n=!!e.workspaceRoot?.trim();return e.decision===`session`?n?`Approved for this session only. This session now uses${t}. The workspace default was not changed.`:`Approved for this session only. This session now uses${t}. The agent's configured default was not changed.`:e.decision===`workspace-default`?`Approved. Future sessions${e.workspaceRoot?` in ${e.workspaceRoot}`:``} will use${t} as the new default. This session was switched too.`:n?`Declined. Nothing was changed — the session and workspace default are untouched.`:`Declined. Nothing was changed — the session and the agent's configured default are untouched.`}function kU(){let[{requestId:e,runtimeSessionId:t}]=(0,b.useState)(EU),[n,r]=(0,b.useState)(`loading`),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!0),[u,d]=(0,b.useState)(null),f=(0,b.useRef)(!1),p=(0,b.useCallback)(async()=>{if(!e){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}r(`loading`),s(``);try{let t=(await(await U(`GET`,`/api/trusted-session/deck-switch/${e}`)).json()).data;if(!t||t.requestId!==e)throw Error(`Approval lookup returned an unexpected response`);a(t),t.status===`pending`?r(`pending`):(r(`error`),l(!1),s(DU(t.status)))}catch(e){let t=TU(e);r(`error`),l(t.retryable),s(t.message)}},[e]);(0,b.useEffect)(()=>{p()},[p]);async function m(n){if(f.current)return;let a=t||i?.runtimeSessionId||``;if(!e||!a){r(`error`),l(!1),s(`This link is incomplete. Ask the agent to request the deck switch again.`);return}f.current=!0,d(n),r(`submitting`);try{let t=await(await U(`POST`,`/api/trusted-session/deck-switch/${e}/resolve`,{runtimeSessionId:a,decision:n})).json(),o={decision:n,deckName:t.data?.deckName??i?.requestedDeckName,workspaceRoot:t.data?.workspaceRoot??i?.workspaceRoot};s(OU(o)),r(`success`)}catch(e){let t=TU(e);l(t.retryable),s(t.message),t.retryable&&i?r(`pending`):r(`error`)}finally{f.current=!1,d(null)}}function h(){s(``),i&&c?r(`pending`):p()}let g=n===`loading`||n===`submitting`,_=i?.currentDeckName??i?.currentDeckId,v=i?.requestedDeckName??i?.requestedDeckId,y=t||i?.runtimeSessionId,x=!!i?.workspaceRoot?.trim();return(0,H.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,H.jsxs)(Rk,{className:`w-full max-w-md`,children:[(0,H.jsxs)(zk,{children:[(0,H.jsx)(Bk,{children:`Approve deck switch`}),(0,H.jsx)(Vk,{children:x?`Choose whether the requested deck applies to this session only or becomes the workspace default. Declining leaves everything unchanged.`:`Choose whether the requested deck applies to this session only, or decline. This session has no writable workspace default.`})]}),(0,H.jsxs)(Hk,{className:`space-y-4`,children:[i&&(_||v)?(0,H.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[_?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Current deck `}),(0,H.jsx)(`dd`,{className:`inline`,children:_})]}):null,v?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Requested deck `}),(0,H.jsx)(`dd`,{className:`inline`,children:v})]}):null,i.workspaceRoot?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Workspace `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:i.workspaceRoot})]}):null,y?(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,H.jsx)(`dd`,{className:`inline font-mono text-xs`,children:y})]}):null]}):e?(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Request `,(0,H.jsx)(`span`,{className:`font-mono text-xs`,children:e})]}):null,n===`loading`?(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading the deck-switch request…`}):null,n===`success`?(0,H.jsx)(`p`,{role:`status`,className:`text-sm text-green-700 dark:text-green-400`,children:o}):null,(n===`error`||n===`pending`)&&o?(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o}):null,(n===`pending`||n===`submitting`)&&i?(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(K,{onClick:()=>void m(`session`),disabled:g,className:`w-full`,children:u===`session`?`Approving…`:`This session only`}),x?(0,H.jsx)(K,{onClick:()=>void m(`workspace-default`),disabled:g,variant:`secondary`,className:`w-full`,children:u===`workspace-default`?`Approving…`:`This workspace by default`}):null,(0,H.jsx)(K,{onClick:()=>void m(`decline`),disabled:g,variant:`outline`,className:`w-full`,children:u===`decline`?`Declining…`:`Decline`})]}):null,n===`error`?c?(0,H.jsx)(K,{onClick:h,variant:`outline`,className:`w-full`,children:`Try again`}):(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No further action is possible on this link. You can close this tab.`}):null,n===`success`?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You can close this tab and return to the agent.`}):null]})]})})}async function AU(e){return(await(await U(`POST`,`/api/agent-grants`,e)).json()).data}async function jU(e){await U(`POST`,`/api/agent-grants/${encodeURIComponent(e)}/revoke`)}var MU=[];function NU(e){if(!e)return`Never`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown`:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(t)}function PU(e){return e.revokedAt?`revoked`:e.expiresAt&&Date.parse(e.expiresAt)<=Date.now()?`expired`:`active`}function FU(e,t){if(e===`none`)return;if(e===`custom`)return new Date(t).toISOString();let n=e===`30`?30:90;return new Date(Date.now()+n*24*60*60*1e3).toISOString()}function IU(){let e=Tt(),{toast:t}=an(),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(new Set),[c,l]=(0,b.useState)(`none`),[u,d]=(0,b.useState)(``),[f,p]=(0,b.useState)(null),[m,h]=(0,b.useState)(!1),[g,_]=(0,b.useState)(null),[v,y]=(0,b.useState)(null),x=(0,b.useRef)(!1),{data:S,isLoading:C,error:w}=Bt({queryKey:[`/api/dashboard-auth/context`]}),T=S?.data.hosted===!0,{data:E}=Bt({queryKey:[`/api/decks`],enabled:T}),D=E?.data??[],{data:O,isLoading:k,error:A}=Bt({queryKey:[`/api/agent-grants`],enabled:T}),j=O?.data??MU;(0,b.useEffect)(()=>{x.current||D.length===0||(x.current=!0,a(D[0].id),s(new Set(D.map(e=>e.id))))},[D]);let M=(0,b.useMemo)(()=>new Map(D.map(e=>[e.id,e.name])),[D]),N=Vt({mutationFn:jU,onSuccess:(n,r)=>{let i=new Date().toISOString();e.setQueryData([`/api/agent-grants`],e=>e&&{...e,data:e.data.map(e=>e.id===r?{...e,revokedAt:i}:e)}),y(null),e.invalidateQueries({queryKey:[`/api/agent-grants`]}),t({title:`Grant revoked`,description:`The bearer stops working immediately.`})},onError:e=>{t({title:`Revoke failed`,description:e.message,variant:`destructive`})}}),P=(e,t)=>{s(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},F=e=>{a(e),s(t=>new Set(t).add(e))};return C?(0,H.jsx)(zU,{message:`Loading grant settings…`}):w?(0,H.jsx)(zU,{message:`Owner sign-in is required to manage grants.`,isError:!0}):T?(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),`Deck`]})}),(0,H.jsx)(Ai,{className:`h-5 w-5 text-[#C4B643]`,"aria-hidden":!0}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Remote agent grants`}),(0,H.jsx)(bg,{variant:`outline`,className:`border-gray-700 text-gray-300`,children:j.length})]})}),(0,H.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-5 px-4 py-6 sm:px-6`,children:[(0,H.jsx)(`p`,{className:`max-w-3xl text-sm leading-6 text-gray-400`,children:`Issue a separate bearer for each remote agent. Deck access is fixed at creation; revoke and reissue when it needs to change.`}),f&&(0,H.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-amber-400/50 bg-amber-400/10 p-4`,"aria-label":`New bearer secret`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`font-ui-display font-semibold text-amber-200`,children:[`Copy the bearer for `,f.label]}),(0,H.jsx)(`p`,{className:`mt-1 text-sm font-semibold text-amber-100`,children:`This secret will not be shown again.`})]}),(0,H.jsxs)(K,{type:`button`,variant:`ghost`,size:`sm`,className:`text-amber-100 hover:bg-amber-300/10 hover:text-amber-50`,onClick:()=>p(null),children:[(0,H.jsx)(mi,{className:`h-4 w-4`}),`Done — hide secret`]})]}),(0,H.jsxs)(`div`,{className:`mt-3 flex min-w-0 flex-col gap-2 sm:flex-row`,children:[(0,H.jsx)(Eu,{readOnly:!0,"aria-label":`Bearer secret`,value:f.token,className:`min-w-0 flex-1 border-amber-300/30 bg-black/40 font-mono text-xs text-amber-50`}),(0,H.jsxs)(K,{type:`button`,variant:`gold`,className:`w-full sm:w-auto`,onClick:async()=>{try{await navigator.clipboard.writeText(f.token),t({title:`Bearer copied`})}catch{t({title:`Copy failed`,variant:`destructive`})}},children:[(0,H.jsx)(Ci,{className:`h-4 w-4`}),`Copy bearer`]})]})]}),(0,H.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)]`,children:[(0,H.jsxs)(`section`,{className:`h-fit min-w-0 rounded-xl border border-gray-800 bg-gray-900/50 p-4 sm:p-5`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display text-base font-semibold`,children:`Create grant`}),(0,H.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:async t=>{if(t.preventDefault(),_(null),!i){_(`Choose a default deck.`);return}if(c===`custom`&&!u){_(`Choose a custom expiry date.`);return}h(!0);try{let t=await AU({label:n.trim(),defaultDeck:i,allowedDecks:[...o],expiresAt:FU(c,u)});p({label:t.grant.label,token:t.token}),e.setQueryData([`/api/agent-grants`],e=>({success:!0,data:e?[...e.data.filter(e=>e.id!==t.grant.id),t.grant]:[t.grant]})),r(``)}catch(e){_(e instanceof Error?e.message:`Grant creation failed`)}finally{h(!1)}},children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)($p,{htmlFor:`grant-label`,children:`Agent label`}),(0,H.jsx)(Eu,{id:`grant-label`,required:!0,value:n,onChange:e=>r(e.target.value),placeholder:`Research agent`})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)($p,{htmlFor:`default-deck`,children:`Default deck`}),(0,H.jsx)(`select`,{id:`default-deck`,required:!0,value:i,onChange:e=>F(e.target.value),className:`h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:D.map(e=>(0,H.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,H.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,H.jsx)(`legend`,{className:`text-sm font-medium`,children:`Allowed decks`}),(0,H.jsx)(`p`,{className:`text-xs text-gray-500`,children:`All decks are selected by default.`}),(0,H.jsx)(`div`,{className:`max-h-48 space-y-2 overflow-y-auto rounded-md border border-gray-800 p-3`,children:D.map(e=>{let t=e.id===i;return(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(g_,{id:`allowed-${e.id}`,checked:o.has(e.id),disabled:t,onCheckedChange:t=>P(e.id,t===!0),className:`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07]`}),(0,H.jsxs)($p,{htmlFor:`allowed-${e.id}`,className:`min-w-0 break-words font-normal`,children:[e.name,t?` (default)`:``]})]},e.id)})})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)($p,{htmlFor:`grant-expiry`,children:`Expiry`}),(0,H.jsxs)(`select`,{id:`grant-expiry`,value:c,onChange:e=>l(e.target.value),className:`h-10 w-full rounded-md border border-input bg-background px-3 text-sm`,children:[(0,H.jsx)(`option`,{value:`none`,children:`None`}),(0,H.jsx)(`option`,{value:`30`,children:`30 days`}),(0,H.jsx)(`option`,{value:`90`,children:`90 days`}),(0,H.jsx)(`option`,{value:`custom`,children:`Custom`})]})]}),c===`custom`&&(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)($p,{htmlFor:`custom-expiry`,children:`Expires at`}),(0,H.jsx)(Eu,{id:`custom-expiry`,type:`datetime-local`,required:!0,value:u,onChange:e=>d(e.target.value)})]}),g&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-rose-300`,children:g}),(0,H.jsx)(K,{type:`submit`,variant:`gold`,className:`w-full`,disabled:m||D.length===0,children:m?`Creating…`:`Create grant`})]})]}),(0,H.jsxs)(`section`,{className:`min-w-0 space-y-3`,"aria-label":`Existing grants`,children:[(0,H.jsx)(`h2`,{className:`font-ui-display text-base font-semibold`,children:`Existing grants`}),k&&(0,H.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading grants…`}),A&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-rose-300`,children:`Could not load grants.`}),!k&&!A&&j.length===0&&(0,H.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-800 p-8 text-center text-sm text-gray-500`,children:`No remote agent grants yet.`}),j.map(e=>{let t=PU(e),n=t!==`revoked`,r=v===e.id;return(0,H.jsxs)(`article`,{className:`min-w-0 rounded-xl border border-gray-800 bg-gray-900/50 p-4 sm:p-5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`break-words font-semibold text-gray-100`,children:e.label}),(0,H.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-gray-600`,children:e.id})]}),(0,H.jsx)(LU,{status:t})]}),(0,H.jsxs)(`dl`,{className:`mt-4 grid min-w-0 gap-x-5 gap-y-3 text-sm sm:grid-cols-2 xl:grid-cols-3`,children:[(0,H.jsx)(RU,{label:`Default deck`,value:M.get(e.defaultDeck)??e.defaultDeck}),(0,H.jsx)(RU,{label:`Allowed decks`,value:e.allowedDecks.map(e=>M.get(e)??e).join(`, `)||`None`}),(0,H.jsx)(RU,{label:`Created`,value:NU(e.createdAt)}),(0,H.jsx)(RU,{label:`Expires`,value:NU(e.expiresAt)}),(0,H.jsx)(RU,{label:`Last used`,value:e.lastUsedAt?NU(e.lastUsedAt):`Never`})]}),n&&(0,H.jsx)(`div`,{className:`mt-4 border-t border-gray-800 pt-4`,children:r?(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,role:`group`,"aria-label":`Confirm revoke ${e.label}`,children:[(0,H.jsxs)(`p`,{className:`text-sm text-rose-200`,children:[`Revoke `,e.label,` now? This is immediate.`]}),(0,H.jsxs)(`div`,{className:`flex w-full gap-2 sm:w-auto`,children:[(0,H.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,className:`flex-1 sm:flex-none`,onClick:()=>y(null),children:`Cancel`}),(0,H.jsx)(K,{type:`button`,variant:`destructive`,size:`sm`,className:`flex-1 sm:flex-none`,disabled:N.isPending,onClick:()=>N.mutate(e.id),children:`Confirm revoke`})]})]}):(0,H.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`border-rose-900 text-rose-200 hover:bg-rose-950`,onClick:()=>y(e.id),children:[(0,H.jsx)(Hi,{className:`h-4 w-4`}),`Revoke`]})})]},e.id)})]})]})]})]}):(0,H.jsx)(zU,{message:`Remote agent grants are available in hosted mode only.`})}function LU({status:e}){return(0,H.jsx)(bg,{variant:`outline`,className:e===`active`?`border-emerald-500/40 text-emerald-200`:e===`expired`?`border-amber-500/40 text-amber-200`:`border-rose-500/40 text-rose-200`,children:e})}function RU({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`font-ui-display text-xs text-gray-500`,children:e}),(0,H.jsx)(`dd`,{className:`mt-1 break-words text-gray-300`,children:t})]})}function zU({message:e,isError:t=!1}){return(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,children:[(0,H.jsx)(ci,{className:`h-4 w-4`}),`Deck`]})}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Remote agent grants`})]})}),(0,H.jsx)(`main`,{className:`mx-auto w-full max-w-7xl px-4 py-8 sm:px-6`,children:(0,H.jsx)(`p`,{role:t?`alert`:`status`,className:t?`text-rose-300`:`text-gray-400`,children:e})})]})}async function BU(e){let t=new URLSearchParams({limit:`50`});return e&&t.set(`before`,e),(await U(`GET`,`/api/audit?${t.toString()}`)).json()}function VU(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}).format(t)}function HU({entry:e}){return(0,H.jsx)(bg,{variant:`outline`,className:e.outcome===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-300`:`border-rose-500/40 bg-rose-500/10 text-rose-300`,children:e.outcome})}function UU({label:e,children:t}){return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`font-ui-display text-xs uppercase tracking-wide text-gray-500`,children:e}),(0,H.jsx)(`dd`,{className:`mt-1 break-all text-sm text-gray-200`,children:t})]})}function WU(){let[e,t]=(0,b.useState)([void 0]),n=e.at(-1),{data:r,isLoading:i,error:a}=Bt({queryKey:[`/api/dashboard-auth/context`]}),o=r?.data.hosted===!0,{data:s,isLoading:c,error:l}=Bt({queryKey:[`audit`,n??`newest`],queryFn:()=>BU(n),enabled:o});return i?(0,H.jsx)(GU,{message:`Loading audit history…`}):a?(0,H.jsx)(GU,{message:`Owner sign-in is required to view audit history.`,isError:!0}):o?(0,H.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,H.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,H.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center gap-3`,children:[(0,H.jsx)(ye,{href:`/`,children:(0,H.jsxs)(K,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,H.jsx)(ci,{className:`mr-1 h-4 w-4`}),`Deck`]})}),(0,H.jsx)(Ri,{className:`h-5 w-5 text-[#C4B643]`,"aria-hidden":!0}),(0,H.jsx)(`h1`,{className:`font-ui-display text-lg font-semibold`,children:`Audit history`})]})}),(0,H.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-5 px-4 py-6 sm:px-6`,children:[(0,H.jsx)(`p`,{className:`max-w-3xl text-sm leading-6 text-gray-400`,children:`Security-relevant grant, sign-in, deck-selection and elevation activity from the last 90 days.`}),c?(0,H.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Loading events…`}):null,l?(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-rose-300`,children:`Audit history could not be loaded.`}):null,s?.data.length===0?(0,H.jsx)(`div`,{className:`rounded-xl border border-gray-800 bg-gray-900/70 p-8 text-center text-sm text-gray-400`,children:`No audit events on this page.`}):null,s?.data.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`hidden overflow-hidden rounded-xl border border-gray-800 bg-gray-900/70 md:block`,children:(0,H.jsxs)(__,{children:[(0,H.jsx)(v_,{children:(0,H.jsxs)(x_,{className:`border-gray-800 hover:bg-transparent`,children:[(0,H.jsx)(S_,{children:`Time`}),(0,H.jsx)(S_,{children:`Event`}),(0,H.jsx)(S_,{children:`Actor`}),(0,H.jsx)(S_,{children:`Target`}),(0,H.jsx)(S_,{children:`Outcome`}),(0,H.jsx)(S_,{children:`Reason`})]})}),(0,H.jsx)(y_,{children:s.data.map(e=>(0,H.jsxs)(x_,{className:`border-gray-800 hover:bg-white/[0.03]`,children:[(0,H.jsx)(C_,{className:`whitespace-nowrap text-xs text-gray-400`,children:VU(e.timestamp)}),(0,H.jsx)(C_,{className:`font-medium text-[#E8F6F4]`,children:e.event}),(0,H.jsx)(C_,{className:`max-w-48 break-all font-mono text-xs`,children:e.actor}),(0,H.jsx)(C_,{className:`max-w-56 break-all font-mono text-xs`,children:e.targetId}),(0,H.jsx)(C_,{children:(0,H.jsx)(HU,{entry:e})}),(0,H.jsx)(C_,{className:`text-xs text-gray-400`,children:e.reasonCode??`—`})]},e.id))})]})}),(0,H.jsx)(`ol`,{className:`space-y-3 md:hidden`,"aria-label":`Audit events`,children:s.data.map(e=>(0,H.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-gray-800 bg-gray-900/70 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`min-w-0 break-words font-medium text-[#E8F6F4]`,children:e.event}),(0,H.jsx)(HU,{entry:e})]}),(0,H.jsxs)(`dl`,{className:`mt-4 grid min-w-0 grid-cols-1 gap-3`,children:[(0,H.jsx)(UU,{label:`Time`,children:VU(e.timestamp)}),(0,H.jsx)(UU,{label:`Actor`,children:e.actor}),(0,H.jsx)(UU,{label:`Target`,children:e.targetId}),(0,H.jsx)(UU,{label:`Reason`,children:e.reasonCode??`—`})]})]},e.id))})]}):null,s?(0,H.jsxs)(`nav`,{className:`flex items-center justify-between gap-3`,"aria-label":`Audit pagination`,children:[(0,H.jsx)(K,{variant:`outline`,disabled:e.length===1,onClick:()=>t(e=>e.slice(0,-1)),children:`Newer`}),(0,H.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Page `,e.length]}),(0,H.jsx)(K,{variant:`outline`,disabled:!s.paging.nextBefore,onClick:()=>s.paging.nextBefore&&t(e=>[...e,s.paging.nextBefore]),children:`Older`})]}):null]})]}):(0,H.jsx)(GU,{message:`Audit history is available in hosted mode only.`})}function GU({message:e,isError:t=!1}){return(0,H.jsx)(`div`,{className:`flex min-h-dvh items-center justify-center bg-gray-950 px-4 text-center`,children:(0,H.jsx)(`p`,{className:t?`text-rose-300`:`text-gray-300`,children:e})})}function KU(){return(0,H.jsxs)(xe,{children:[(0,H.jsx)(ve,{path:`/`,component:Lk}),(0,H.jsx)(ve,{path:`/oauth/callback`,component:Gk}),(0,H.jsx)(ve,{path:`/playbook-patches`,component:bU}),(0,H.jsx)(ve,{path:`/feedback-signals`,component:SU}),(0,H.jsx)(ve,{path:`/grants`,component:IU}),(0,H.jsx)(ve,{path:`/audit`,component:WU}),(0,H.jsx)(ve,{path:`/admin/approve`,component:wU}),(0,H.jsx)(ve,{path:`/deck-switch/approve`,component:kU}),(0,H.jsx)(ve,{path:`/mcp-test`,component:PH}),(0,H.jsx)(ve,{component:Wk})]})}function qU(){let[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=!1;return Kt().finally(()=>{e||t(!0)}),()=>{e=!0}},[]),e?(0,H.jsx)(Et,{client:Gt,children:(0,H.jsxs)(Al,{children:[(0,H.jsx)(ro,{}),(0,H.jsx)(KU,{})]})}):(0,H.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[#0B1220] text-sm text-gray-300`,children:`Loading AgentDeck...`})}(0,x.createRoot)(document.getElementById(`root`)).render((0,H.jsx)(b.StrictMode,{children:(0,H.jsx)(qU,{})}));
|